diff --git a/main.js b/main.js index 7c5be4e..1c8abeb 100644 --- a/main.js +++ b/main.js @@ -1,40 +1,40 @@ -"use strict";var Hp=Object.defineProperty;var k2=Object.getOwnPropertyDescriptor;var W2=Object.getOwnPropertyNames;var H2=Object.prototype.hasOwnProperty;var A=(n,e)=>()=>(n&&(e=n(n=0)),e);var De=(n,e)=>{for(var t in e)Hp(n,t,{get:e[t],enumerable:!0})},z2=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of W2(e))!H2.call(n,r)&&r!==t&&Hp(n,r,{get:()=>e[r],enumerable:!(i=k2(e,r))||i.enumerable});return n};var X2=n=>z2(Hp({},"__esModule",{value:!0}),n);function Zo(n,e,t){return`${n}::${e}::${t}`}function Y2(n,e){return!!(n.cacheVersion===2&&n.converterId&&n.converterCacheKey&&n.sourcePath&&n.sourceExt&&n.targetExt==="glb"&&n.outputPath&&n.outputExt==="glb"&&Number.isFinite(n.createdAt)&&e-n.createdAt<=2592e6)}function uR(n,e=Date.now()){let t=new Map;for(let i of n){if(!Y2(i,e))continue;let r=Zo(i.sourcePath,i.sourceExt,i.targetExt),s=t.get(r);(!s||i.createdAt>s.createdAt)&&t.set(r,i)}return[...t.values()].sort((i,r)=>r.createdAt-i.createdAt).slice(0,200)}function K2(n,e){return!!n&&!!e&&n.cacheVersion===e.cacheVersion&&n.converterId===e.converterId&&n.converterCacheKey===e.converterCacheKey&&n.sourcePath===e.sourcePath&&n.sourceExt===e.sourceExt&&n.targetExt===e.targetExt&&n.outputPath===e.outputPath&&n.outputExt===e.outputExt&&n.createdAt===e.createdAt&&n.warnings.join(` +"use strict";var Yp=Object.defineProperty;var aV=Object.getOwnPropertyDescriptor;var oV=Object.getOwnPropertyNames;var lV=Object.prototype.hasOwnProperty;var A=(n,e)=>()=>(n&&(e=n(n=0)),e);var De=(n,e)=>{for(var t in e)Yp(n,t,{get:e[t],enumerable:!0})},cV=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of oV(e))!lV.call(n,r)&&r!==t&&Yp(n,r,{get:()=>e[r],enumerable:!(i=aV(e,r))||i.enumerable});return n};var fV=n=>cV(Yp({},"__esModule",{value:!0}),n);function qo(n,e,t){return`${n}::${e}::${t}`}function dV(n,e){return!!(n.cacheVersion===2&&n.converterId&&n.converterCacheKey&&n.sourcePath&&n.sourceExt&&n.targetExt==="glb"&&n.outputPath&&n.outputExt==="glb"&&Number.isFinite(n.createdAt)&&e-n.createdAt<=2592e6)}function TR(n,e=Date.now()){let t=new Map;for(let i of n){if(!dV(i,e))continue;let r=qo(i.sourcePath,i.sourceExt,i.targetExt),s=t.get(r);(!s||i.createdAt>s.createdAt)&&t.set(r,i)}return[...t.values()].sort((i,r)=>r.createdAt-i.createdAt).slice(0,200)}function hV(n,e){return!!n&&!!e&&n.cacheVersion===e.cacheVersion&&n.converterId===e.converterId&&n.converterCacheKey===e.converterCacheKey&&n.sourcePath===e.sourcePath&&n.sourceExt===e.sourceExt&&n.targetExt===e.targetExt&&n.outputPath===e.outputPath&&n.outputExt===e.outputExt&&n.createdAt===e.createdAt&&n.warnings.join(` `)===e.warnings.join(` -`)}function mR(n=[],e){function t(){return uR([...s.values()])}function i(l){s.clear();for(let c of l)s.set(Zo(c.sourcePath,c.sourceExt,c.targetExt),c)}let r=uR(n),s=new Map(r.map(l=>[Zo(l.sourcePath,l.sourceExt,l.targetExt),l]));function a(){let l=t();i(l),e==null||e(l)}return(n.length!==r.length||r.some((l,c)=>!K2(l,n[c])))&&(e==null||e(r)),{get(l,c,f){return s.get(Zo(l,c,f))},set(l){s.set(Zo(l.sourcePath,l.sourceExt,l.targetExt),l),a()},delete(l,c,f){let d=s.delete(Zo(l,c,f));return d&&a(),d},clear(){s.size!==0&&(s.clear(),a())},entries(){return t()}}}var zp=A(()=>{"use strict"});function xn(n){return n.trim().toLowerCase().replace(/^\./,"")}function Xp(n){return j2.get(xn(n))}function es(n){let e=Xp(n);return!!(e!=null&&e.enabled)}function to(){return pR.filter(n=>n.enabled).map(n=>n.ext)}var pR,j2,ts=A(()=>{"use strict";pR=[{ext:"glb",family:"mesh",strategy:"direct",directLoader:"babylon",enabled:!0},{ext:"gltf",family:"mesh",strategy:"direct",directLoader:"babylon",enabled:!0},{ext:"stl",family:"mesh",strategy:"direct",directLoader:"custom-stl",enabled:!0},{ext:"obj",family:"mesh",strategy:"direct",directLoader:"babylon",converterId:"obj2gltf",outputFormat:"glb",enabled:!0},{ext:"ply",family:"mesh",strategy:"direct",directLoader:"custom-ply",enabled:!0},{ext:"fbx",family:"mesh",strategy:"convert",converterId:"fbx2gltf",outputFormat:"glb",enabled:!0},{ext:"step",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"stp",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"iges",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"igs",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"brep",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"sldprt",family:"cad",strategy:"convert",converterId:"sldprt",outputFormat:"glb",enabled:!0},{ext:"3mf",family:"mesh",strategy:"convert",converterId:"assimp",outputFormat:"glb",enabled:!0},{ext:"dae",family:"mesh",strategy:"convert",converterId:"assimp",outputFormat:"glb",enabled:!0}],j2=new Map(pR.map(n=>[n.ext,n]))});function ER(n,e=12){let t=new Set,i=[];for(let r of n){let s=r.trim().toLowerCase();if(s&&!t.has(s)&&(t.add(s),i.push(s),i.length>=e))break}return i}var vR=A(()=>{"use strict"});var q2,Yp,Kp,Y,ct=A(()=>{q2=typeof WeakRef!="undefined",Yp=class{constructor(e,t=!1,i,r){this.initialize(e,t,i,r)}initialize(e,t=!1,i,r){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this}},Kp=class{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}},Y=class n{static FromPromise(e,t){let i=new n;return e.then(r=>{i.notifyObservers(r)}).catch(r=>{if(t)t.notifyObservers(r);else throw r}),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 Yp(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,r=null,s=!1){if(!e)return null;let a=new Kp(e,t,r);a.unregisterOnNextCall=s,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(a,this._lastNotifiedValue);let o=q2?new WeakRef(this):{deref:()=>this};return a._remove=(l=!1)=>{let c=o.deref();c&&(l?c.remove(a):c._remove(a))},a}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._remove(e)},0))}_remove(e,t=!0){if(!e)return!1;let 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,r,s){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;let a=this._eventState;a.mask=t,a.target=i,a.currentTarget=r,a.skipNextObservers=!1,a.lastReturnValue=e,a.userInfo=s;for(let o of this._observers)if(!o._willBeUnregistered&&(o.mask&t&&(o.unregisterOnNextCall&&this._deferUnregister(o),o.scope?a.lastReturnValue=o.callback.apply(o.scope,[e,a]):a.lastReturnValue=o.callback(e,a)),a.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;let r=this._eventState;r.mask=i,r.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,r)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){let 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(){let e=new n;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(let t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}});var bd,TR=A(()=>{bd=class{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,r=1,s=2,a=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=r,this.samplingMode=s,this._comparisonFunction=a,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 SR,bt,_r=A(()=>{ct();TR();(function(n){n[n.Unknown=0]="Unknown",n[n.Url=1]="Url",n[n.Temp=2]="Temp",n[n.Raw=3]="Raw",n[n.Dynamic=4]="Dynamic",n[n.RenderTarget=5]="RenderTarget",n[n.MultiRenderTarget=6]="MultiRenderTarget",n[n.Cube=7]="Cube",n[n.CubeRaw=8]="CubeRaw",n[n.CubePrefiltered=9]="CubePrefiltered",n[n.Raw3D=10]="Raw3D",n[n.Raw2DArray=11]="Raw2DArray",n[n.DepthStencil=12]="DepthStencil",n[n.CubeRawRGBD=13]="CubeRawRGBD",n[n.Depth=14]="Depth"})(SR||(SR={}));bt=class n extends bd{get useMipMaps(){return this._useMipMaps===null?this.generateMipMaps:this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,i=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this._useMipMaps=null,this.mipLevelCount=1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new Y,this.onErrorObservable=new Y,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=n._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){let r=this.onRebuildCallback(this),s=a=>{a._swapAndDie(this,!1),this.isReady=r.isReady};r.isAsync?r.proxy.then(s):s(r.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,r=>{r._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:if(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,this.mipLevelCount),e._swapAndDie(this,!1),this._bufferViewArray)for(let r=0;r{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,r=>{r&&r._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension),e._sphericalPolynomial=this._sphericalPolynomial;return;case 12:case 14:break}}_swapAndDie(e,t=!0){var s;(s=this._hardwareTexture)==null||s.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);let i=this._engine.getLoadedTexturesCache(),r=i.indexOf(this);r!==-1&&i.splice(r,1),r=i.indexOf(e),r===-1&&i.push(e)}dispose(){this._references--,this._references===0&&(this.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}};bt._Counter=0});var ue,At=A(()=>{ct();ue=class{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}};ue.Instances=[];ue.OnEnginesDisposedObservable=new Y;ue._LastCreatedScene=null;ue.UseFallbackTexture=!0;ue.FallbackTexture=""});var W,ze=A(()=>{W=class n{static _CheckLimit(e,t){let i=n._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},n._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var s;let i=n._LogLimitOutputs[e];if(!i||!n.MessageLimitReached)return;let r=this._Levels[t];i.current===i.limit&&n[r.name](n.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,(s=r.name)!=null?s:""))}static _AddLogEntry(e){n._LogCache=e+n._LogCache,n.OnNewCacheEntry&&n.OnNewCacheEntry(e)}static _FormatMessage(e){let t=r=>r<10?"0"+r:""+r,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){let r=Array.isArray(t)?t[0]:t;if(i!==void 0&&!n._CheckLimit(r,i))return;let s=n._FormatMessage(r),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+s,...o);let l=`
${s}

`;n._AddLogEntry(l),n._GenerateLimitMessage(r,e)}static get LogCache(){return n._LogCache}static ClearLogCache(){n._LogCache="",n._LogLimitOutputs={},n.errorsCount=0}static set LogLevels(e){n.Log=n._LogDisabled,n.Warn=n._LogDisabled,n.Error=n._LogDisabled;let t=[n.MessageLogLevel,n.WarningLogLevel,n.ErrorLogLevel];for(let i of t)if((e&i)===i){let r=this._Levels[i];n[r.name]=n._LogEnabled.bind(n,i)}}};W.NoneLogLevel=0;W.MessageLogLevel=1;W.WarningLogLevel=2;W.ErrorLogLevel=4;W.AllLogLevel=7;W.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";W._LogCache="";W._LogLimitOutputs={};W._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];W.errorsCount=0;W.Log=W._LogEnabled.bind(W,W.MessageLogLevel);W.Warn=W._LogEnabled.bind(W,W.WarningLogLevel);W.Error=W._LogEnabled.bind(W,W.ErrorLogLevel)});var E,N=A(()=>{E=class n{static GetShadersRepository(e=0){return e===0?n.ShadersRepository:n.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?n.ShadersStore:n.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?n.IncludesShadersStore:n.IncludesShadersStoreWGSL}};E.ShadersRepository="src/Shaders/";E.ShadersStore={};E.IncludesShadersStore={};E.ShadersRepositoryWGSL="src/ShadersWGSL/";E.ShadersStoreWGSL={};E.IncludesShadersStoreWGSL={}});function Bt(){return typeof window!="undefined"}function is(){return typeof navigator!="undefined"}function sa(){return typeof document!="undefined"}function Md(n){let e="",t=n.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}var yr=A(()=>{});var yd,AR=A(()=>{yd=class{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,r,s,a,o,l){let c=this.engine;if(c.supportsUniformBuffers)for(let h in t)e.bindUniformBlock(h,t[h]);this.engine.getUniforms(this,i).forEach((h,u)=>{r[i[u]]=h}),this._uniforms=r;let d;for(d=0;d{a[h]=u});for(let h of c.getAttributes(this,o))l.push(h)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){let i=this._valueCache[e],r=t.updateFlag;return i!==void 0&&i===r?!1:(this._valueCache[e]=r,!0)}_cacheFloat2(e,t,i){let r=this._valueCache[e];if(!r||r.length!==2)return r=[t,i],this._valueCache[e]=r,!0;let s=!1;return r[0]!==t&&(r[0]=t,s=!0),r[1]!==i&&(r[1]=i,s=!0),s}_cacheFloat3(e,t,i,r){let s=this._valueCache[e];if(!s||s.length!==3)return s=[t,i,r],this._valueCache[e]=s,!0;let a=!1;return s[0]!==t&&(s[0]=t,a=!0),s[1]!==i&&(s[1]=i,a=!0),s[2]!==r&&(s[2]=r,a=!0),a}_cacheFloat4(e,t,i,r,s){let a=this._valueCache[e];if(!a||a.length!==4)return a=[t,i,r,s],this._valueCache[e]=a,!0;let o=!1;return a[0]!==t&&(a[0]=t,o=!0),a[1]!==i&&(a[1]=i,o=!0),a[2]!==r&&(a[2]=r,o=!0),a[3]!==s&&(a[3]=s,o=!0),o}setInt(e,t){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setInt3(this._uniforms[e],t,i,r)||(this._valueCache[e]=null))}setInt4(e,t,i,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setInt4(this._uniforms[e],t,i,r,s)||(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){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setUInt3(this._uniforms[e],t,i,r)||(this._valueCache[e]=null))}setUInt4(e,t,i,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setUInt4(this._uniforms[e],t,i,r,s)||(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){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setFloat3(this._uniforms[e],t,i,r)||(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,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setFloat4(this._uniforms[e],t,i,r,s)||(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}}});function Ie(n,e=!1){if(!(e&&RR[n]))return RR[n]=!0,`${n} needs to be imported before as it contains a side-effect required by your code.`}var RR,gi=A(()=>{RR={}});function Dd(n,e,t=""){return t+(e?e+` -`:"")+n}function Ld(n,e,t,i,r,s,a){let o=a||qo.loadFile;if(o)return o(n,e,t,i,r,s);throw Ie("FileTools")}function Pd(n,e,t,i){if(n){e?n.IS_NDC_HALF_ZRANGE="":delete n.IS_NDC_HALF_ZRANGE,t?n.USE_REVERSE_DEPTHBUFFER="":delete n.USE_REVERSE_DEPTHBUFFER,i?n.USE_EXACT_SRGB_CONVERSIONS="":delete n.USE_EXACT_SRGB_CONVERSIONS;return}else{let r="";return e&&(r+="#define IS_NDC_HALF_ZRANGE"),t&&(r&&(r+=` +`)}function SR(n=[],e){function t(){return TR([...s.values()])}function i(l){s.clear();for(let c of l)s.set(qo(c.sourcePath,c.sourceExt,c.targetExt),c)}let r=TR(n),s=new Map(r.map(l=>[qo(l.sourcePath,l.sourceExt,l.targetExt),l]));function a(){let l=t();i(l),e==null||e(l)}return(n.length!==r.length||r.some((l,c)=>!hV(l,n[c])))&&(e==null||e(r)),{get(l,c,f){return s.get(qo(l,c,f))},set(l){s.set(qo(l.sourcePath,l.sourceExt,l.targetExt),l),a()},delete(l,c,f){let d=s.delete(qo(l,c,f));return d&&a(),d},clear(){s.size!==0&&(s.clear(),a())},entries(){return t()}}}var Kp=A(()=>{"use strict"});function xn(n){return n.trim().toLowerCase().replace(/^\./,"")}function jp(n){return uV.get(xn(n))}function ts(n){let e=jp(n);return!!(e!=null&&e.enabled)}function to(){return AR.filter(n=>n.enabled).map(n=>n.ext)}var AR,uV,is=A(()=>{"use strict";AR=[{ext:"glb",family:"mesh",strategy:"direct",directLoader:"babylon",enabled:!0},{ext:"gltf",family:"mesh",strategy:"direct",directLoader:"babylon",enabled:!0},{ext:"stl",family:"mesh",strategy:"direct",directLoader:"custom-stl",enabled:!0},{ext:"obj",family:"mesh",strategy:"direct",directLoader:"babylon",converterId:"obj2gltf",outputFormat:"glb",enabled:!0},{ext:"ply",family:"mesh",strategy:"direct",directLoader:"custom-ply",enabled:!0},{ext:"fbx",family:"mesh",strategy:"convert",converterId:"fbx2gltf",outputFormat:"glb",enabled:!0},{ext:"step",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"stp",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"iges",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"igs",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"brep",family:"cad",strategy:"convert",converterId:"freecad",outputFormat:"glb",enabled:!0},{ext:"sldprt",family:"cad",strategy:"convert",converterId:"sldprt",outputFormat:"glb",enabled:!0},{ext:"3mf",family:"mesh",strategy:"convert",converterId:"assimp",outputFormat:"glb",enabled:!0},{ext:"dae",family:"mesh",strategy:"convert",converterId:"assimp",outputFormat:"glb",enabled:!0}],uV=new Map(AR.map(n=>[n.ext,n]))});function xR(n,e=12){let t=new Set,i=[];for(let r of n){let s=r.trim().toLowerCase();if(s&&!t.has(s)&&(t.add(s),i.push(s),i.length>=e))break}return i}var CR=A(()=>{"use strict"});var pV,Zp,qp,Y,ft=A(()=>{pV=typeof WeakRef!="undefined",Zp=class{constructor(e,t=!1,i,r){this.initialize(e,t,i,r)}initialize(e,t=!1,i,r){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this}},qp=class{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}},Y=class n{static FromPromise(e,t){let i=new n;return e.then(r=>{i.notifyObservers(r)}).catch(r=>{if(t)t.notifyObservers(r);else throw r}),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 Zp(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,r=null,s=!1){if(!e)return null;let a=new qp(e,t,r);a.unregisterOnNextCall=s,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(a,this._lastNotifiedValue);let o=pV?new WeakRef(this):{deref:()=>this};return a._remove=(l=!1)=>{let c=o.deref();c&&(l?c.remove(a):c._remove(a))},a}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._remove(e)},0))}_remove(e,t=!0){if(!e)return!1;let 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,r,s){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;let a=this._eventState;a.mask=t,a.target=i,a.currentTarget=r,a.skipNextObservers=!1,a.lastReturnValue=e,a.userInfo=s;for(let o of this._observers)if(!o._willBeUnregistered&&(o.mask&t&&(o.unregisterOnNextCall&&this._deferUnregister(o),o.scope?a.lastReturnValue=o.callback.apply(o.scope,[e,a]):a.lastReturnValue=o.callback(e,a)),a.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;let r=this._eventState;r.mask=i,r.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,r)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){let 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(){let e=new n;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(let t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}});var Md,bR=A(()=>{Md=class{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,r=1,s=2,a=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=r,this.samplingMode=s,this._comparisonFunction=a,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 MR,bt,vr=A(()=>{ft();bR();(function(n){n[n.Unknown=0]="Unknown",n[n.Url=1]="Url",n[n.Temp=2]="Temp",n[n.Raw=3]="Raw",n[n.Dynamic=4]="Dynamic",n[n.RenderTarget=5]="RenderTarget",n[n.MultiRenderTarget=6]="MultiRenderTarget",n[n.Cube=7]="Cube",n[n.CubeRaw=8]="CubeRaw",n[n.CubePrefiltered=9]="CubePrefiltered",n[n.Raw3D=10]="Raw3D",n[n.Raw2DArray=11]="Raw2DArray",n[n.DepthStencil=12]="DepthStencil",n[n.CubeRawRGBD=13]="CubeRawRGBD",n[n.Depth=14]="Depth"})(MR||(MR={}));bt=class n extends Md{get useMipMaps(){return this._useMipMaps===null?this.generateMipMaps:this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,i=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this._useMipMaps=null,this.mipLevelCount=1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new Y,this.onErrorObservable=new Y,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=n._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){let r=this.onRebuildCallback(this),s=a=>{a._swapAndDie(this,!1),this.isReady=r.isReady};r.isAsync?r.proxy.then(s):s(r.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,r=>{r._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:if(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,this.mipLevelCount),e._swapAndDie(this,!1),this._bufferViewArray)for(let r=0;r{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,r=>{r&&r._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension),e._sphericalPolynomial=this._sphericalPolynomial;return;case 12:case 14:break}}_swapAndDie(e,t=!0){var s;(s=this._hardwareTexture)==null||s.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);let i=this._engine.getLoadedTexturesCache(),r=i.indexOf(this);r!==-1&&i.splice(r,1),r=i.indexOf(e),r===-1&&i.push(e)}dispose(){this._references--,this._references===0&&(this.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}};bt._Counter=0});var ue,At=A(()=>{ft();ue=class{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}};ue.Instances=[];ue.OnEnginesDisposedObservable=new Y;ue._LastCreatedScene=null;ue.UseFallbackTexture=!0;ue.FallbackTexture=""});var W,ze=A(()=>{W=class n{static _CheckLimit(e,t){let i=n._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},n._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var s;let i=n._LogLimitOutputs[e];if(!i||!n.MessageLimitReached)return;let r=this._Levels[t];i.current===i.limit&&n[r.name](n.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,(s=r.name)!=null?s:""))}static _AddLogEntry(e){n._LogCache=e+n._LogCache,n.OnNewCacheEntry&&n.OnNewCacheEntry(e)}static _FormatMessage(e){let t=r=>r<10?"0"+r:""+r,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){let r=Array.isArray(t)?t[0]:t;if(i!==void 0&&!n._CheckLimit(r,i))return;let s=n._FormatMessage(r),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+s,...o);let l=`
${s}

`;n._AddLogEntry(l),n._GenerateLimitMessage(r,e)}static get LogCache(){return n._LogCache}static ClearLogCache(){n._LogCache="",n._LogLimitOutputs={},n.errorsCount=0}static set LogLevels(e){n.Log=n._LogDisabled,n.Warn=n._LogDisabled,n.Error=n._LogDisabled;let t=[n.MessageLogLevel,n.WarningLogLevel,n.ErrorLogLevel];for(let i of t)if((e&i)===i){let r=this._Levels[i];n[r.name]=n._LogEnabled.bind(n,i)}}};W.NoneLogLevel=0;W.MessageLogLevel=1;W.WarningLogLevel=2;W.ErrorLogLevel=4;W.AllLogLevel=7;W.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";W._LogCache="";W._LogLimitOutputs={};W._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];W.errorsCount=0;W.Log=W._LogEnabled.bind(W,W.MessageLogLevel);W.Warn=W._LogEnabled.bind(W,W.WarningLogLevel);W.Error=W._LogEnabled.bind(W,W.ErrorLogLevel)});var E,N=A(()=>{E=class n{static GetShadersRepository(e=0){return e===0?n.ShadersRepository:n.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?n.ShadersStore:n.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?n.IncludesShadersStore:n.IncludesShadersStoreWGSL}};E.ShadersRepository="src/Shaders/";E.ShadersStore={};E.IncludesShadersStore={};E.ShadersRepositoryWGSL="src/ShadersWGSL/";E.ShadersStoreWGSL={};E.IncludesShadersStoreWGSL={}});function Bt(){return typeof window!="undefined"}function rs(){return typeof navigator!="undefined"}function sa(){return typeof document!="undefined"}function yd(n){let e="",t=n.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}var Lr=A(()=>{});var Dd,yR=A(()=>{Dd=class{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,r,s,a,o,l){let c=this.engine;if(c.supportsUniformBuffers)for(let h in t)e.bindUniformBlock(h,t[h]);this.engine.getUniforms(this,i).forEach((h,u)=>{r[i[u]]=h}),this._uniforms=r;let d;for(d=0;d{a[h]=u});for(let h of c.getAttributes(this,o))l.push(h)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){let i=this._valueCache[e],r=t.updateFlag;return i!==void 0&&i===r?!1:(this._valueCache[e]=r,!0)}_cacheFloat2(e,t,i){let r=this._valueCache[e];if(!r||r.length!==2)return r=[t,i],this._valueCache[e]=r,!0;let s=!1;return r[0]!==t&&(r[0]=t,s=!0),r[1]!==i&&(r[1]=i,s=!0),s}_cacheFloat3(e,t,i,r){let s=this._valueCache[e];if(!s||s.length!==3)return s=[t,i,r],this._valueCache[e]=s,!0;let a=!1;return s[0]!==t&&(s[0]=t,a=!0),s[1]!==i&&(s[1]=i,a=!0),s[2]!==r&&(s[2]=r,a=!0),a}_cacheFloat4(e,t,i,r,s){let a=this._valueCache[e];if(!a||a.length!==4)return a=[t,i,r,s],this._valueCache[e]=a,!0;let o=!1;return a[0]!==t&&(a[0]=t,o=!0),a[1]!==i&&(a[1]=i,o=!0),a[2]!==r&&(a[2]=r,o=!0),a[3]!==s&&(a[3]=s,o=!0),o}setInt(e,t){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setInt3(this._uniforms[e],t,i,r)||(this._valueCache[e]=null))}setInt4(e,t,i,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setInt4(this._uniforms[e],t,i,r,s)||(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){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setUInt3(this._uniforms[e],t,i,r)||(this._valueCache[e]=null))}setUInt4(e,t,i,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setUInt4(this._uniforms[e],t,i,r,s)||(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){let 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,r){this._cacheFloat3(e,t,i,r)&&(this.engine.setFloat3(this._uniforms[e],t,i,r)||(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,r,s){this._cacheFloat4(e,t,i,r,s)&&(this.engine.setFloat4(this._uniforms[e],t,i,r,s)||(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}}});function Ie(n,e=!1){if(!(e&&DR[n]))return DR[n]=!0,`${n} needs to be imported before as it contains a side-effect required by your code.`}var DR,Ei=A(()=>{DR={}});function Ld(n,e,t=""){return t+(e?e+` +`:"")+n}function Pd(n,e,t,i,r,s,a){let o=a||Qo.loadFile;if(o)return o(n,e,t,i,r,s);throw Ie("FileTools")}function Od(n,e,t,i){if(n){e?n.IS_NDC_HALF_ZRANGE="":delete n.IS_NDC_HALF_ZRANGE,t?n.USE_REVERSE_DEPTHBUFFER="":delete n.USE_REVERSE_DEPTHBUFFER,i?n.USE_EXACT_SRGB_CONVERSIONS="":delete n.USE_EXACT_SRGB_CONVERSIONS;return}else{let r="";return e&&(r+="#define IS_NDC_HALF_ZRANGE"),t&&(r&&(r+=` `),r+="#define USE_REVERSE_DEPTHBUFFER"),i&&(r&&(r+=` -`),r+="#define USE_EXACT_SRGB_CONVERSIONS"),r}}function IR(n,e,t=!1,i){switch(n){case 3:{let s=new Int8Array(e);return i&&s.set(new Int8Array(i)),s}case 0:{let s=new Uint8Array(e);return i&&s.set(new Uint8Array(i)),s}case 4:{let s=typeof e!="number"?new Int16Array(e):new Int16Array(t?e/2:e);return i&&s.set(new Int16Array(i)),s}case 5:case 8:case 9:case 10:case 2:{let s=typeof e!="number"?new Uint16Array(e):new Uint16Array(t?e/2:e);return i&&s.set(new Uint16Array(i)),s}case 6:{let s=typeof e!="number"?new Int32Array(e):new Int32Array(t?e/4:e);return i&&s.set(new Int32Array(i)),s}case 7:case 11:case 12:case 13:case 14:case 15:{let s=typeof e!="number"?new Uint32Array(e):new Uint32Array(t?e/4:e);return i&&s.set(new Uint32Array(i)),s}case 1:{let s=typeof e!="number"?new Float32Array(e):new Float32Array(t?e/4:e);return i&&s.set(new Float32Array(i)),s}}let r=new Uint8Array(e);return i&&r.set(new Uint8Array(i)),r}var qo,aa=A(()=>{gi();yr();qo={}});function xi(n){let e=jp.get(n);if(!e){if(!n)return Q2;e={_webGLVersion:n.TEXTURE_BINDING_3D?2:1,_context:n,parallelShaderCompile:n.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},jp.set(n,e)}return e}function Od(n){jp.delete(n)}function qp(n,e,t,i,r,s){var c;let a=xi(i);s||(s=(c=a._createShaderProgramInjection)!=null?c:Nd);let o=Zp(e,"vertex",i,a._contextWasLost),l=Zp(t,"fragment",i,a._contextWasLost);return s(n,o,l,i,r,a.validateShaderPrograms)}function Qp(n,e,t,i,r,s=null,a){var d;let o=xi(r);a||(a=(d=o._createShaderProgramInjection)!=null?d:Nd);let l=o._webGLVersion>1?`#version 300 es +`),r+="#define USE_EXACT_SRGB_CONVERSIONS"),r}}function LR(n,e,t=!1,i){switch(n){case 3:{let s=new Int8Array(e);return i&&s.set(new Int8Array(i)),s}case 0:{let s=new Uint8Array(e);return i&&s.set(new Uint8Array(i)),s}case 4:{let s=typeof e!="number"?new Int16Array(e):new Int16Array(t?e/2:e);return i&&s.set(new Int16Array(i)),s}case 5:case 8:case 9:case 10:case 2:{let s=typeof e!="number"?new Uint16Array(e):new Uint16Array(t?e/2:e);return i&&s.set(new Uint16Array(i)),s}case 6:{let s=typeof e!="number"?new Int32Array(e):new Int32Array(t?e/4:e);return i&&s.set(new Int32Array(i)),s}case 7:case 11:case 12:case 13:case 14:case 15:{let s=typeof e!="number"?new Uint32Array(e):new Uint32Array(t?e/4:e);return i&&s.set(new Uint32Array(i)),s}case 1:{let s=typeof e!="number"?new Float32Array(e):new Float32Array(t?e/4:e);return i&&s.set(new Float32Array(i)),s}}let r=new Uint8Array(e);return i&&r.set(new Uint8Array(i)),r}var Qo,aa=A(()=>{Ei();Lr();Qo={}});function Ci(n){let e=Qp.get(n);if(!e){if(!n)return _V;e={_webGLVersion:n.TEXTURE_BINDING_3D?2:1,_context:n,parallelShaderCompile:n.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},Qp.set(n,e)}return e}function Nd(n){Qp.delete(n)}function $p(n,e,t,i,r,s){var c;let a=Ci(i);s||(s=(c=a._createShaderProgramInjection)!=null?c:Fd);let o=Jp(e,"vertex",i,a._contextWasLost),l=Jp(t,"fragment",i,a._contextWasLost);return s(n,o,l,i,r,a.validateShaderPrograms)}function e_(n,e,t,i,r,s=null,a){var d;let o=Ci(r);a||(a=(d=o._createShaderProgramInjection)!=null?d:Fd);let l=o._webGLVersion>1?`#version 300 es #define WEBGL2 -`:"",c=xR(e,"vertex",i,l,r,o._contextWasLost),f=xR(t,"fragment",i,l,r,o._contextWasLost);return a(n,c,f,r,s,o.validateShaderPrograms)}function CR(n,e){let t=new yd,i=xi(n);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function Nd(n,e,t,i,r=null,s){let a=i.createProgram();if(n.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,e),i.attachShader(a,t),i.linkProgram(a),n.context=i,n.vertexShader=e,n.fragmentShader=t,n.isParallelCompiled||Fd(n,i,s),a}function bR(n,e,t){let i=n;if(i._isDisposed)return!1;let r=xi(e);return r&&r.parallelShaderCompile&&r.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,r.parallelShaderCompile.COMPLETION_STATUS_KHR)?(Fd(i,e,t),!0):!1}function Fd(n,e,t){let i=n.context,r=n.vertexShader,s=n.fragmentShader,a=n.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!e.getShaderParameter(r,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(r);if(c)throw n.vertexCompilationError=c,new Error("VERTEX SHADER "+c)}if(!e.getShaderParameter(s,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(s);if(c)throw n.fragmentCompilationError=c,new Error("FRAGMENT SHADER "+c)}let l=i.getProgramInfoLog(a);if(l)throw n.programLinkError=l,new Error(l)}if(t&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){let c=i.getProgramInfoLog(a);if(c)throw n.programValidationError=c,new Error(c)}i.deleteShader(r),i.deleteShader(s),n.vertexShader=void 0,n.fragmentShader=void 0,n.onCompiled&&(n.onCompiled(),n.onCompiled=void 0)}function MR(n,e,t,i,r,s,a,o,l,c="",f,d,h){var p,_;let u=xi(n.context);d||(d=(p=u.createRawShaderProgramInjection)!=null?p:qp),h||(h=(_=u.createShaderProgramInjection)!=null?_:Qp);let m=n;i?m.program=d(m,e,t,m.context,l):m.program=h(m,e,t,o,m.context,l),m.program.__SPECTOR_rebuildProgram=a,f()}function xR(n,e,t,i,r,s){return Zp(Dd(n,t,i),e,r,s)}function Zp(n,e,t,i){let r=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!r){let s=t.NO_ERROR,a;for(;(a=t.getError())!==t.NO_ERROR;)s=a;throw new Error(`Something went wrong while creating a gl ${e} shader object. gl error=${s}, gl isContextLost=${t.isContextLost()}, _contextWasLost=${i}`)}return t.shaderSource(r,n),t.compileShader(r),r}function yR(n,e){e.useProgram(n)}function DR(n,e){let t=n;if(!t.isParallelCompiled){e(n);return}let i=t.onCompiled;t.onCompiled=()=>{i==null||i(),e(n)}}var jp,Q2,Jp=A(()=>{AR();aa();jp=new WeakMap,Q2={_webGLVersion:2,cachedPipelines:{}}});var J2,$2,Cn,wd=A(()=>{J2="attribute",$2="varying",Cn=class{constructor(){this.children=[]}isValid(e){return!0}process(e,t,i){var s,a,o,l,c,f,d;let r="";if(this.line){let h=this.line,u=t.processor;if(u){u.lineProcessor&&(h=u.lineProcessor(h,t.isFragment,t.processingContext));let m=(a=(s=t.processor)==null?void 0:s.attributeKeywordName)!=null?a:J2,p=t.isFragment&&((o=t.processor)!=null&&o.varyingFragmentKeywordName)?(l=t.processor)==null?void 0:l.varyingFragmentKeywordName:!t.isFragment&&((c=t.processor)!=null&&c.varyingVertexKeywordName)?(f=t.processor)==null?void 0:f.varyingVertexKeywordName:$2;!t.isFragment&&u.attributeProcessor&&this.line.startsWith(m)?h=u.attributeProcessor(this.line,e,t.processingContext):u.varyingProcessor&&((d=u.varyingCheck)!=null&&d.call(u,this.line,t.isFragment)||!u.varyingCheck&&this.line.startsWith(p))?h=u.varyingProcessor(this.line,t.isFragment,e,t.processingContext):u.uniformProcessor&&u.uniformRegexp&&u.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(h=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&u.uniformBufferRegexp&&u.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(h=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):u.textureProcessor&&u.textureRegexp&&u.textureRegexp.test(this.line)?h=u.textureProcessor(this.line,t.isFragment,e,t.processingContext):(u.uniformProcessor||u.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?u.uniformProcessor&&(h=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&(h=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,u.endOfUniformBufferProcessor&&(h=u.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}r+=h+` -`}for(let h of this.children)r+=h.process(e,t,i);return this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true",i[this.additionalDefineKey]=e[this.additionalDefineKey]),r}}});var Bd,LR=A(()=>{Bd=class{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex1&&this._lines.push(i);else{let s=t.split(";");for(let a=0;a{wd();Qo=class extends Cn{process(e,t,i){for(let r=0;r{wd();Ud=class extends Cn{isValid(e){return this.testExpression.isTrue(e)}}});var Si,Jo=A(()=>{Si=class n{isTrue(e){return!0}static postfixToInfix(e){let t=[];for(let i of e)if(n._OperatorPriority[i]===void 0)t.push(i);else{let r=t[t.length-1],s=t[t.length-2];t.length-=2,t.push(`(${s}${i}${r})`)}return t[t.length-1]}static infixToPostfix(e){let t=n._InfixToPostfixCache.get(e);if(t)return t.accessTime=Date.now(),t.result;if(!e.includes("&&")&&!e.includes("||")&&!e.includes(")")&&!e.includes("("))return[e];let i=[],r=-1,s=()=>{f=f.trim(),f!==""&&(i.push(f),f="")},a=d=>{rn._Stack[r],l=()=>r===-1?"!!INVALID EXPRESSION!!":n._Stack[r--],c=0,f="";for(;c1){for(s();r!==-1&&n._OperatorPriority[o()]>=n._OperatorPriority[h];)i.push(l());a(h),c++}else f+=d;c++}for(s();r!==-1;)o()==="("?l():i.push(l());return n._InfixToPostfixCache.size>=n.InfixToPostfixCacheLimitSize&&n.ClearCache(),n._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){let e=Array.from(n._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t{Jo();ro=class extends Si{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}}});var Vd,FR=A(()=>{Jo();Vd=class extends Si{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}});var Gd,wR=A(()=>{Jo();Gd=class extends Si{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}});var kd,BR=A(()=>{Jo();kd=class extends Si{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}toString(){return`${this.define} ${this.operand} ${this.testValue}`}isTrue(e){let t=!1,i=parseInt(e[this.define]!=null?e[this.define]:this.define),r=parseInt(e[this.testValue]!=null?e[this.testValue]:this.testValue);if(isNaN(i)||isNaN(r))return!1;switch(this.operand){case">":t=i>r;break;case"<":t=i=":t=i>=r;break;case"==":t=i===r;break;case"!=":t=i!==r;break}return t}}});function GR(n){n.processor&&n.processor.initializeShaders&&n.processor.initializeShaders(n.processingContext)}function r_(n,e,t,i){var r;(r=e.processor)!=null&&r.preProcessShaderCode&&(n=e.processor.preProcessShaderCode(n,e.isFragment)),Gc(n,e,s=>{e.processCodeAfterIncludes&&(s=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",s,e.defines));let a=lV(s,e,i);t(a,s)})}function kR(n,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:n,fragmentCode:e}:t.processor.finalizeShaders(n,e,t.processingContext)}function nV(n,e){var i;if((i=e.processor)!=null&&i.noPrecision)return n;let t=e.shouldUseHighPrecisionShader;return n.indexOf("precision highp float")===-1?t?n=`precision highp float; +`:"",c=PR(e,"vertex",i,l,r,o._contextWasLost),f=PR(t,"fragment",i,l,r,o._contextWasLost);return a(n,c,f,r,s,o.validateShaderPrograms)}function OR(n,e){let t=new Dd,i=Ci(n);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function Fd(n,e,t,i,r=null,s){let a=i.createProgram();if(n.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,e),i.attachShader(a,t),i.linkProgram(a),n.context=i,n.vertexShader=e,n.fragmentShader=t,n.isParallelCompiled||wd(n,i,s),a}function NR(n,e,t){let i=n;if(i._isDisposed)return!1;let r=Ci(e);return r&&r.parallelShaderCompile&&r.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,r.parallelShaderCompile.COMPLETION_STATUS_KHR)?(wd(i,e,t),!0):!1}function wd(n,e,t){let i=n.context,r=n.vertexShader,s=n.fragmentShader,a=n.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!e.getShaderParameter(r,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(r);if(c)throw n.vertexCompilationError=c,new Error("VERTEX SHADER "+c)}if(!e.getShaderParameter(s,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(s);if(c)throw n.fragmentCompilationError=c,new Error("FRAGMENT SHADER "+c)}let l=i.getProgramInfoLog(a);if(l)throw n.programLinkError=l,new Error(l)}if(t&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){let c=i.getProgramInfoLog(a);if(c)throw n.programValidationError=c,new Error(c)}i.deleteShader(r),i.deleteShader(s),n.vertexShader=void 0,n.fragmentShader=void 0,n.onCompiled&&(n.onCompiled(),n.onCompiled=void 0)}function FR(n,e,t,i,r,s,a,o,l,c="",f,d,h){var p,_;let u=Ci(n.context);d||(d=(p=u.createRawShaderProgramInjection)!=null?p:$p),h||(h=(_=u.createShaderProgramInjection)!=null?_:e_);let m=n;i?m.program=d(m,e,t,m.context,l):m.program=h(m,e,t,o,m.context,l),m.program.__SPECTOR_rebuildProgram=a,f()}function PR(n,e,t,i,r,s){return Jp(Ld(n,t,i),e,r,s)}function Jp(n,e,t,i){let r=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!r){let s=t.NO_ERROR,a;for(;(a=t.getError())!==t.NO_ERROR;)s=a;throw new Error(`Something went wrong while creating a gl ${e} shader object. gl error=${s}, gl isContextLost=${t.isContextLost()}, _contextWasLost=${i}`)}return t.shaderSource(r,n),t.compileShader(r),r}function wR(n,e){e.useProgram(n)}function BR(n,e){let t=n;if(!t.isParallelCompiled){e(n);return}let i=t.onCompiled;t.onCompiled=()=>{i==null||i(),e(n)}}var Qp,_V,t_=A(()=>{yR();aa();Qp=new WeakMap,_V={_webGLVersion:2,cachedPipelines:{}}});var gV,EV,Cn,Bd=A(()=>{gV="attribute",EV="varying",Cn=class{constructor(){this.children=[]}isValid(e){return!0}process(e,t,i){var s,a,o,l,c,f,d;let r="";if(this.line){let h=this.line,u=t.processor;if(u){u.lineProcessor&&(h=u.lineProcessor(h,t.isFragment,t.processingContext));let m=(a=(s=t.processor)==null?void 0:s.attributeKeywordName)!=null?a:gV,p=t.isFragment&&((o=t.processor)!=null&&o.varyingFragmentKeywordName)?(l=t.processor)==null?void 0:l.varyingFragmentKeywordName:!t.isFragment&&((c=t.processor)!=null&&c.varyingVertexKeywordName)?(f=t.processor)==null?void 0:f.varyingVertexKeywordName:EV;!t.isFragment&&u.attributeProcessor&&this.line.startsWith(m)?h=u.attributeProcessor(this.line,e,t.processingContext):u.varyingProcessor&&((d=u.varyingCheck)!=null&&d.call(u,this.line,t.isFragment)||!u.varyingCheck&&this.line.startsWith(p))?h=u.varyingProcessor(this.line,t.isFragment,e,t.processingContext):u.uniformProcessor&&u.uniformRegexp&&u.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(h=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&u.uniformBufferRegexp&&u.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(h=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):u.textureProcessor&&u.textureRegexp&&u.textureRegexp.test(this.line)?h=u.textureProcessor(this.line,t.isFragment,e,t.processingContext):(u.uniformProcessor||u.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?u.uniformProcessor&&(h=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&(h=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,u.endOfUniformBufferProcessor&&(h=u.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}r+=h+` +`}for(let h of this.children)r+=h.process(e,t,i);return this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true",i[this.additionalDefineKey]=e[this.additionalDefineKey]),r}}});var Ud,UR=A(()=>{Ud=class{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex1&&this._lines.push(i);else{let s=t.split(";");for(let a=0;a{Bd();Jo=class extends Cn{process(e,t,i){for(let r=0;r{Bd();Vd=class extends Cn{isValid(e){return this.testExpression.isTrue(e)}}});var Ai,$o=A(()=>{Ai=class n{isTrue(e){return!0}static postfixToInfix(e){let t=[];for(let i of e)if(n._OperatorPriority[i]===void 0)t.push(i);else{let r=t[t.length-1],s=t[t.length-2];t.length-=2,t.push(`(${s}${i}${r})`)}return t[t.length-1]}static infixToPostfix(e){let t=n._InfixToPostfixCache.get(e);if(t)return t.accessTime=Date.now(),t.result;if(!e.includes("&&")&&!e.includes("||")&&!e.includes(")")&&!e.includes("("))return[e];let i=[],r=-1,s=()=>{f=f.trim(),f!==""&&(i.push(f),f="")},a=d=>{rn._Stack[r],l=()=>r===-1?"!!INVALID EXPRESSION!!":n._Stack[r--],c=0,f="";for(;c1){for(s();r!==-1&&n._OperatorPriority[o()]>=n._OperatorPriority[h];)i.push(l());a(h),c++}else f+=d;c++}for(s();r!==-1;)o()==="("?l():i.push(l());return n._InfixToPostfixCache.size>=n.InfixToPostfixCacheLimitSize&&n.ClearCache(),n._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){let e=Array.from(n._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t{$o();ro=class extends Ai{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}}});var Gd,WR=A(()=>{$o();Gd=class extends Ai{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}});var kd,HR=A(()=>{$o();kd=class extends Ai{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}});var Wd,zR=A(()=>{$o();Wd=class extends Ai{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}toString(){return`${this.define} ${this.operand} ${this.testValue}`}isTrue(e){let t=!1,i=parseInt(e[this.define]!=null?e[this.define]:this.define),r=parseInt(e[this.testValue]!=null?e[this.testValue]:this.testValue);if(isNaN(i)||isNaN(r))return!1;switch(this.operand){case">":t=i>r;break;case"<":t=i=":t=i>=r;break;case"==":t=i===r;break;case"!=":t=i!==r;break}return t}}});function KR(n){n.processor&&n.processor.initializeShaders&&n.processor.initializeShaders(n.processingContext)}function a_(n,e,t,i){var r;(r=e.processor)!=null&&r.preProcessShaderCode&&(n=e.processor.preProcessShaderCode(n,e.isFragment)),Gc(n,e,s=>{e.processCodeAfterIncludes&&(s=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",s,e.defines));let a=bV(s,e,i);t(a,s)})}function jR(n,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:n,fragmentCode:e}:t.processor.finalizeShaders(n,e,t.processingContext)}function RV(n,e){var i;if((i=e.processor)!=null&&i.noPrecision)return n;let t=e.shouldUseHighPrecisionShader;return n.indexOf("precision highp float")===-1?t?n=`precision highp float; `+n:n=`precision mediump float; -`+n:t||(n=n.replace("precision highp float","precision mediump float")),n}function e_(n){let t=/defined\((.+)\)/.exec(n);if(t&&t.length)return new ro(t[1].trim(),n[0]==="!");let i=["==","!=",">=","<=","<",">"],r="",s=0;for(r of i)if(s=n.indexOf(r),s>-1)break;if(s===-1)return new ro(n);let a=n.substring(0,s).trim(),o=n.substring(s+r.length).trim();return new kd(a,r,o)}function sV(n){n=n.replace(eV,"defined[$1]");let e=Si.infixToPostfix(n),t=[];for(let r of e)if(r!=="||"&&r!=="&&")t.push(r);else if(t.length>=2){let s=t[t.length-1],a=t[t.length-2];t.length-=2;let o=r=="&&"?new Gd:new Vd;typeof s=="string"&&(s=s.replace($p,"defined($1)")),typeof a=="string"&&(a=a.replace($p,"defined($1)")),o.leftOperand=typeof a=="string"?e_(a):a,o.rightOperand=typeof s=="string"?e_(s):s,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace($p,"defined($1)")),typeof i=="string"?e_(i):i}function Hd(n,e){let t=new Ud,i=n.substring(0,e),r=n.substring(e);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i==="#ifdef"?t.testExpression=new ro(r):i==="#ifndef"?t.testExpression=new ro(r,!0):t.testExpression=sV(r),t}function t_(n,e,t,i){let r;for(;i_(n,t,i);){r=n.currentLine;let s=r.substring(0,5).toLowerCase();if(s==="#else"){let a=new Cn;e.children.push(a),i_(n,a,i);return}else if(s==="#elif"){let a=Hd(r,5);e.children.push(a),t=a}}}function i_(n,e,t){for(;n.canRead;){n.lineIndex++;let i=n.currentLine;if(i.indexOf("#")>=0){let s=rV.exec(i);if(s&&s.length){switch(s[0]){case"#ifdef":{let o=new Qo;e.children.push(o);let l=Hd(i,6);o.children.push(l),t_(n,o,l,t);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{let o=new Qo;e.children.push(o);let l=Hd(i,7);o.children.push(l),t_(n,o,l,t);break}case"#if":{let o=new Qo,l=Hd(i,3);e.children.push(o),o.children.push(l),t_(n,o,l,t);break}}continue}}let r=new Cn;if(r.line=i,e.children.push(r),i[0]==="#"&&i[1]==="d"){let s=i.replace(";","").split(" ");r.additionalDefineKey=s[1],s.length===3&&(r.additionalDefineValue=s[2])}}return!1}function aV(n,e,t,i){let r=new Cn,s=new Bd;return s.lineIndex=-1,s.lines=n.split(` -`),i_(s,r,i),r.process(e,t,i)}function oV(n,e){var r;let t=n.defines,i={};for(let s of t){let o=s.replace("#define","").replace(";","").trim().split(" ");i[o[0]]=o.length>1?o[1]:""}return((r=n.processor)==null?void 0:r.shaderLanguage)===0&&(i.GL_ES="true"),i.__VERSION__=n.version,i[n.platformName]="true",Pd(i,e==null?void 0:e.isNDCHalfZRange,e==null?void 0:e.useReverseDepthBuffer,e==null?void 0:e.useExactSrgbConversions),i}function lV(n,e,t){let i=nV(n,e);if(!e.processor||e.processor.shaderLanguage===0&&i.indexOf("#version 3")!==-1&&(i=i.replace("#version 300 es",""),!e.processor.parseGLES3))return i;let r=e.defines,s=oV(e,t);e.processor.preProcessor&&(i=e.processor.preProcessor(i,r,s,e.isFragment,e.processingContext));let a={};return i=aV(i,s,e,a),e.processor.postProcessor&&(i=e.processor.postProcessor(i,r,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{},s,a)),t!=null&&t._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Gc(n,e,t){Wd.length=0;let i;for(;(i=tV.exec(n))!==null;)Wd.push(i);let r=[n],s=!1;for(let o of Wd){let l=o[1];if(l.indexOf("__decl__")!==-1&&(l=l.replace(iV,""),e.supportsUniformBuffers&&(l=l.replace("Vertex","Ubo").replace("Fragment","Ubo")),l=l+"Declaration"),e.includesShadersStore[l]){let c=e.includesShadersStore[l];if(o[2]){let d=o[3].split(",");for(let h=0;hT+"{X}")),c+=p.replace(VR,_.toString())+` -`}else e.supportsUniformBuffers||(c=c.replace(UR,(h,u)=>u+"{X}")),c=c.replace(VR,d)}let f=[];for(let d of r){let h=d.split(o[0]);for(let u=0;u=0||c.indexOf("#include <")>=0}else{let c=e.shadersRepository+"ShadersInclude/"+l+".fx";n_.loadFile(c,f=>{e.includesShadersStore[l]=f,Gc(r.join(""),e,t)});return}}Wd.length=0;let a=r.join("");s?Gc(a.toString(),e,t):t(a)}var eV,$p,tV,iV,UR,VR,Wd,rV,n_,zd=A(()=>{wd();LR();PR();OR();NR();FR();wR();Jo();BR();gi();aa();eV=/defined\s*?\((.+?)\)/g,$p=/defined\s*?\[(.+?)\]/g,tV=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,iV=/__decl__/,UR=/light\{X\}.(\w*)/g,VR=/\{X\}/g,Wd=[],rV=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;n_={loadFile:(n,e,t,i,r,s)=>{throw Ie("FileTools")}}});function HR(n,e){return xi(e).cachedPipelines[n]}function Xd(n){let e=n._name,t=n.context;if(e&&t){let i=xi(t),r=i.cachedPipelines[e];r==null||r.dispose(),delete i.cachedPipelines[e]}}function zR(n,e,t,i,r,s,a){let o,l,c=Bt()?s==null?void 0:s.getHostDocument():null;typeof e=="string"?o=e:typeof e.vertexSource=="string"?o="source:"+e.vertexSource:typeof e.vertexElement=="string"?o=(c==null?void 0:c.getElementById(e.vertexElement))||e.vertexElement:o=e.vertex||e,typeof e=="string"?l=e:typeof e.fragmentSource=="string"?l="source:"+e.fragmentSource:typeof e.fragmentElement=="string"?l=(c==null?void 0:c.getElementById(e.fragmentElement))||e.fragmentElement:l=e.fragment||e;let f=[void 0,void 0],d=()=>{if(f[0]&&f[1]){let[h,u]=f;GR(n),r_(h,n,(m,p)=>{a&&(a._vertexSourceCodeBeforeMigration=p),t&&(m=t("vertex",m)),n.isFragment=!0,r_(u,n,(_,g)=>{a&&(a._fragmentSourceCodeBeforeMigration=g),t&&(_=t("fragment",_));let T=kR(m,_,n);n=null;let b=cV(T.vertexCode,T.fragmentCode,e,r);i==null||i(b.vertexSourceCode,b.fragmentSourceCode)},s)},s)}};WR(o,"Vertex","",h=>{a&&(a._rawVertexSourceCode=h),f[0]=h,d()},r),WR(l,"Fragment","Pixel",h=>{a&&(a._rawFragmentSourceCode=h),f[1]=h,d()},r)}function WR(n,e,t,i,r,s){if(typeof HTMLElement!="undefined"&&n instanceof HTMLElement){let l=Md(n);i(l);return}if(n.substring(0,7)==="source:"){i(n.substring(7));return}if(n.substring(0,7)==="base64:"){let l=window.atob(n.substring(7));i(l);return}let a=E.GetShadersStore(r);if(a[n+e+"Shader"]){i(a[n+e+"Shader"]);return}if(t&&a[n+t+"Shader"]){i(a[n+t+"Shader"]);return}let o;if(n[0]==="."||n[0]==="/"||n.indexOf("http")>-1?o=n:o=E.GetShadersRepository(r)+n,s=s||Ld,!s)throw new Error("loadFileInjection is not defined");s(o+"."+e.toLowerCase()+".fx",i)}function cV(n,e,t,i){if(t){let r=t.vertexElement||t.vertex||t.spectorName||t,s=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+r+` +`+n:t||(n=n.replace("precision highp float","precision mediump float")),n}function r_(n){let t=/defined\((.+)\)/.exec(n);if(t&&t.length)return new ro(t[1].trim(),n[0]==="!");let i=["==","!=",">=","<=","<",">"],r="",s=0;for(r of i)if(s=n.indexOf(r),s>-1)break;if(s===-1)return new ro(n);let a=n.substring(0,s).trim(),o=n.substring(s+r.length).trim();return new Wd(a,r,o)}function IV(n){n=n.replace(vV,"defined[$1]");let e=Ai.infixToPostfix(n),t=[];for(let r of e)if(r!=="||"&&r!=="&&")t.push(r);else if(t.length>=2){let s=t[t.length-1],a=t[t.length-2];t.length-=2;let o=r=="&&"?new kd:new Gd;typeof s=="string"&&(s=s.replace(i_,"defined($1)")),typeof a=="string"&&(a=a.replace(i_,"defined($1)")),o.leftOperand=typeof a=="string"?r_(a):a,o.rightOperand=typeof s=="string"?r_(s):s,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(i_,"defined($1)")),typeof i=="string"?r_(i):i}function zd(n,e){let t=new Vd,i=n.substring(0,e),r=n.substring(e);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i==="#ifdef"?t.testExpression=new ro(r):i==="#ifndef"?t.testExpression=new ro(r,!0):t.testExpression=IV(r),t}function n_(n,e,t,i){let r;for(;s_(n,t,i);){r=n.currentLine;let s=r.substring(0,5).toLowerCase();if(s==="#else"){let a=new Cn;e.children.push(a),s_(n,a,i);return}else if(s==="#elif"){let a=zd(r,5);e.children.push(a),t=a}}}function s_(n,e,t){for(;n.canRead;){n.lineIndex++;let i=n.currentLine;if(i.indexOf("#")>=0){let s=AV.exec(i);if(s&&s.length){switch(s[0]){case"#ifdef":{let o=new Jo;e.children.push(o);let l=zd(i,6);o.children.push(l),n_(n,o,l,t);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{let o=new Jo;e.children.push(o);let l=zd(i,7);o.children.push(l),n_(n,o,l,t);break}case"#if":{let o=new Jo,l=zd(i,3);e.children.push(o),o.children.push(l),n_(n,o,l,t);break}}continue}}let r=new Cn;if(r.line=i,e.children.push(r),i[0]==="#"&&i[1]==="d"){let s=i.replace(";","").split(" ");r.additionalDefineKey=s[1],s.length===3&&(r.additionalDefineValue=s[2])}}return!1}function xV(n,e,t,i){let r=new Cn,s=new Ud;return s.lineIndex=-1,s.lines=n.split(` +`),s_(s,r,i),r.process(e,t,i)}function CV(n,e){var r;let t=n.defines,i={};for(let s of t){let o=s.replace("#define","").replace(";","").trim().split(" ");i[o[0]]=o.length>1?o[1]:""}return((r=n.processor)==null?void 0:r.shaderLanguage)===0&&(i.GL_ES="true"),i.__VERSION__=n.version,i[n.platformName]="true",Od(i,e==null?void 0:e.isNDCHalfZRange,e==null?void 0:e.useReverseDepthBuffer,e==null?void 0:e.useExactSrgbConversions),i}function bV(n,e,t){let i=RV(n,e);if(!e.processor||e.processor.shaderLanguage===0&&i.indexOf("#version 3")!==-1&&(i=i.replace("#version 300 es",""),!e.processor.parseGLES3))return i;let r=e.defines,s=CV(e,t);e.processor.preProcessor&&(i=e.processor.preProcessor(i,r,s,e.isFragment,e.processingContext));let a={};return i=xV(i,s,e,a),e.processor.postProcessor&&(i=e.processor.postProcessor(i,r,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{},s,a)),t!=null&&t._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Gc(n,e,t){Hd.length=0;let i;for(;(i=TV.exec(n))!==null;)Hd.push(i);let r=[n],s=!1;for(let o of Hd){let l=o[1];if(l.indexOf("__decl__")!==-1&&(l=l.replace(SV,""),e.supportsUniformBuffers&&(l=l.replace("Vertex","Ubo").replace("Fragment","Ubo")),l=l+"Declaration"),e.includesShadersStore[l]){let c=e.includesShadersStore[l];if(o[2]){let d=o[3].split(",");for(let h=0;hT+"{X}")),c+=p.replace(YR,_.toString())+` +`}else e.supportsUniformBuffers||(c=c.replace(XR,(h,u)=>u+"{X}")),c=c.replace(YR,d)}let f=[];for(let d of r){let h=d.split(o[0]);for(let u=0;u=0||c.indexOf("#include <")>=0}else{let c=e.shadersRepository+"ShadersInclude/"+l+".fx";o_.loadFile(c,f=>{e.includesShadersStore[l]=f,Gc(r.join(""),e,t)});return}}Hd.length=0;let a=r.join("");s?Gc(a.toString(),e,t):t(a)}var vV,i_,TV,SV,XR,YR,Hd,AV,o_,Xd=A(()=>{Bd();UR();VR();GR();kR();WR();HR();$o();zR();Ei();aa();vV=/defined\s*?\((.+?)\)/g,i_=/defined\s*?\[(.+?)\]/g,TV=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,SV=/__decl__/,XR=/light\{X\}.(\w*)/g,YR=/\{X\}/g,Hd=[],AV=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;o_={loadFile:(n,e,t,i,r,s)=>{throw Ie("FileTools")}}});function qR(n,e){return Ci(e).cachedPipelines[n]}function Yd(n){let e=n._name,t=n.context;if(e&&t){let i=Ci(t),r=i.cachedPipelines[e];r==null||r.dispose(),delete i.cachedPipelines[e]}}function QR(n,e,t,i,r,s,a){let o,l,c=Bt()?s==null?void 0:s.getHostDocument():null;typeof e=="string"?o=e:typeof e.vertexSource=="string"?o="source:"+e.vertexSource:typeof e.vertexElement=="string"?o=(c==null?void 0:c.getElementById(e.vertexElement))||e.vertexElement:o=e.vertex||e,typeof e=="string"?l=e:typeof e.fragmentSource=="string"?l="source:"+e.fragmentSource:typeof e.fragmentElement=="string"?l=(c==null?void 0:c.getElementById(e.fragmentElement))||e.fragmentElement:l=e.fragment||e;let f=[void 0,void 0],d=()=>{if(f[0]&&f[1]){let[h,u]=f;KR(n),a_(h,n,(m,p)=>{a&&(a._vertexSourceCodeBeforeMigration=p),t&&(m=t("vertex",m)),n.isFragment=!0,a_(u,n,(_,g)=>{a&&(a._fragmentSourceCodeBeforeMigration=g),t&&(_=t("fragment",_));let T=jR(m,_,n);n=null;let b=MV(T.vertexCode,T.fragmentCode,e,r);i==null||i(b.vertexSourceCode,b.fragmentSourceCode)},s)},s)}};ZR(o,"Vertex","",h=>{a&&(a._rawVertexSourceCode=h),f[0]=h,d()},r),ZR(l,"Fragment","Pixel",h=>{a&&(a._rawFragmentSourceCode=h),f[1]=h,d()},r)}function ZR(n,e,t,i,r,s){if(typeof HTMLElement!="undefined"&&n instanceof HTMLElement){let l=yd(n);i(l);return}if(n.substring(0,7)==="source:"){i(n.substring(7));return}if(n.substring(0,7)==="base64:"){let l=window.atob(n.substring(7));i(l);return}let a=E.GetShadersStore(r);if(a[n+e+"Shader"]){i(a[n+e+"Shader"]);return}if(t&&a[n+t+"Shader"]){i(a[n+t+"Shader"]);return}let o;if(n[0]==="."||n[0]==="/"||n.indexOf("http")>-1?o=n:o=E.GetShadersRepository(r)+n,s=s||Pd,!s)throw new Error("loadFileInjection is not defined");s(o+"."+e.toLowerCase()+".fx",i)}function MV(n,e,t,i){if(t){let r=t.vertexElement||t.vertex||t.spectorName||t,s=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+r+` `+n,fragmentSourceCode:(i===1?"//":"")+"#define SHADER_NAME fragment:"+s+` -`+e}}else return{vertexSourceCode:n,fragmentSourceCode:e}}var XR,s_=A(()=>{yr();Jp();N();ze();zd();aa();XR=(n,e,t,i)=>{try{let r=n.context?xi(n.context):null;r&&(r.disableParallelShaderCompile=n.disableParallelCompilation);let s=n.existingPipelineContext||e(n.shaderProcessingContext);return s._name=n.name,n.name&&r&&(r.cachedPipelines[n.name]=s),t(s,n.vertex,n.fragment,!!n.createAsRaw,"","",n.rebuildRebind,n.defines,n.transformFeedbackVaryings,"",()=>{i(s,()=>{var a;(a=n.onRenderingStateCompiled)==null||a.call(n,s)})}),s}catch(r){throw W.Error("Error compiling effect"),r}}});function YR(n,e,t){try{if(n())return e(),!0}catch(i){return t==null||t(i),!0}return!1}var Yd,en,bn,Mn=A(()=>{Yd=[],en=class{static SetImmediate(e){Yd.length===0&&setTimeout(()=>{let t=Yd;Yd=[];for(let i of t)i()},1),Yd.push(e)}};bn=(n,e,t,i=16,r=3e4,s=!0,a)=>{if(s&&YR(n,e,t))return null;let o=!1,l=null,c=()=>{if(!o&&!YR(n,e,t)){if(r-=i,r<0){t==null||t(new Error("Operation timed out after maximum retries. "+(a||"")),!0);return}l=setTimeout(c,i)}};return l=setTimeout(c,i),()=>{o=!0,l!==null&&clearTimeout(l)}}});var Nt,no=A(()=>{ct();ze();N();s_();Mn();Nt=class n{static get ShadersRepository(){return E.ShadersRepository}static set ShadersRepository(e){E.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new Y),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,r=null,s,a=null,o=null,l=null,c=null,f,d="",h=0,u){var _,g,T,b;this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new Y,this.onErrorObservable=new Y,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._disableParallelShaderCompilation=!1,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this._onReleaseEffectsObserver=null,this.name=e,this._key=d;let m=this._key.replace(/\r/g,"").replace(/\n/g,"|"),p;if(t.attributes){let R=t;if(this._engine=i,this._attributesNames=R.attributes,this._uniformsNames=R.uniformsNames.concat(R.samplers),this._samplerList=R.samplers.slice(),this.defines=R.defines,this.onError=R.onError,this.onCompiled=R.onCompiled,this._fallbacks=R.fallbacks,this._indexParameters=R.indexParameters,this._transformFeedbackVaryings=R.transformFeedbackVaryings||null,this._multiTarget=!!R.multiTarget,this._shaderLanguage=(_=R.shaderLanguage)!=null?_:0,this._disableParallelShaderCompilation=!!R.disableParallelShaderCompilation,R.uniformBuffersNames){this._uniformBuffersNamesList=R.uniformBuffersNames.slice();for(let S=0;S{this._onReleaseEffectsObserver=null,!this.isDisposed&&this.dispose(!0)})}async _processShaderCodeAsync(e=null,t=!1,i=null,r){r&&await r(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);let s={defines:this.defines.split(` -`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e!=null?e:this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:E.GetShadersRepository(this._shaderLanguage),includesShadersStore:E.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};zR(s,this.name,this._processFinalCode,(a,o)=>{this._vertexSourceCode=a,this._fragmentSourceCode=o,this._prepareEffect(t)},this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch(e){return!1}}_isReadyInternal(){return this._engine.isDisposed||this._isReady?!0:this._pipelineContext?this._pipelineContext.isReady:!1}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}async whenCompiledAsync(){return await new Promise(e=>{this.executeWhenCompiled(e)})}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&this._checkIsReady(null)}_checkIsReady(e){bn(()=>this._isReadyInternal()||this._isDisposed,()=>{},t=>{this._processCompilationErrors(t,e)},16,12e4,!0,` - Effect: ${typeof this.name=="string"?this.name:this.key}`)}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(` -`),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,r){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(s,a)=>{r&&r(a)},this.onCompiled=()=>{var a,o;let s=this.getEngine().scenes;if(s)for(let l=0;lthis._rebuildProgram(l,c,f,d),defines:r,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:i,disableParallelCompilation:this._disableParallelShaderCompilation,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:l=>{t&&!e&&this._engine._deletePipelineContext(t),l&&this._onRenderingStateCompiled(l)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContextAsync.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(i){this._processCompilationErrors(i,t)}}_getShaderCodeAndErrorLine(e,t,i){let r=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,s=null;if(t&&e){let a=t.match(r);if(a&&a.length===2){let o=parseInt(a[1]),l=e.split(` +`+e}}else return{vertexSourceCode:n,fragmentSourceCode:e}}var JR,l_=A(()=>{Lr();t_();N();ze();Xd();aa();JR=(n,e,t,i)=>{try{let r=n.context?Ci(n.context):null;r&&(r.disableParallelShaderCompile=n.disableParallelCompilation);let s=n.existingPipelineContext||e(n.shaderProcessingContext);return s._name=n.name,n.name&&r&&(r.cachedPipelines[n.name]=s),t(s,n.vertex,n.fragment,!!n.createAsRaw,"","",n.rebuildRebind,n.defines,n.transformFeedbackVaryings,"",()=>{i(s,()=>{var a;(a=n.onRenderingStateCompiled)==null||a.call(n,s)})}),s}catch(r){throw W.Error("Error compiling effect"),r}}});function $R(n,e,t){try{if(n())return e(),!0}catch(i){return t==null||t(i),!0}return!1}var Kd,rn,bn,Mn=A(()=>{Kd=[],rn=class{static SetImmediate(e){Kd.length===0&&setTimeout(()=>{let t=Kd;Kd=[];for(let i of t)i()},1),Kd.push(e)}};bn=(n,e,t,i=16,r=3e4,s=!0,a)=>{if(s&&$R(n,e,t))return null;let o=!1,l=null,c=()=>{if(!o&&!$R(n,e,t)){if(r-=i,r<0){t==null||t(new Error("Operation timed out after maximum retries. "+(a||"")),!0);return}l=setTimeout(c,i)}};return l=setTimeout(c,i),()=>{o=!0,l!==null&&clearTimeout(l)}}});var Nt,no=A(()=>{ft();ze();N();l_();Mn();Nt=class n{static get ShadersRepository(){return E.ShadersRepository}static set ShadersRepository(e){E.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new Y),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,r=null,s,a=null,o=null,l=null,c=null,f,d="",h=0,u){var _,g,T,b;this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new Y,this.onErrorObservable=new Y,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._disableParallelShaderCompilation=!1,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this._onReleaseEffectsObserver=null,this.name=e,this._key=d;let m=this._key.replace(/\r/g,"").replace(/\n/g,"|"),p;if(t.attributes){let R=t;if(this._engine=i,this._attributesNames=R.attributes,this._uniformsNames=R.uniformsNames.concat(R.samplers),this._samplerList=R.samplers.slice(),this.defines=R.defines,this.onError=R.onError,this.onCompiled=R.onCompiled,this._fallbacks=R.fallbacks,this._indexParameters=R.indexParameters,this._transformFeedbackVaryings=R.transformFeedbackVaryings||null,this._multiTarget=!!R.multiTarget,this._shaderLanguage=(_=R.shaderLanguage)!=null?_:0,this._disableParallelShaderCompilation=!!R.disableParallelShaderCompilation,R.uniformBuffersNames){this._uniformBuffersNamesList=R.uniformBuffersNames.slice();for(let S=0;S{this._onReleaseEffectsObserver=null,!this.isDisposed&&this.dispose(!0)})}async _processShaderCodeAsync(e=null,t=!1,i=null,r){r&&await r(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);let s={defines:this.defines.split(` +`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e!=null?e:this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:E.GetShadersRepository(this._shaderLanguage),includesShadersStore:E.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};QR(s,this.name,this._processFinalCode,(a,o)=>{this._vertexSourceCode=a,this._fragmentSourceCode=o,this._prepareEffect(t)},this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch(e){return!1}}_isReadyInternal(){return this._engine.isDisposed||this._isReady?!0:this._pipelineContext?this._pipelineContext.isReady:!1}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}async whenCompiledAsync(){return await new Promise(e=>{this.executeWhenCompiled(e)})}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&this._checkIsReady(null)}_checkIsReady(e){bn(()=>this._isReadyInternal()||this._isDisposed,()=>{},t=>{this._processCompilationErrors(t,e)},16,12e4,!0,` - Effect: ${typeof this.name=="string"?this.name:this.key}`)}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(` +`),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,r){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(s,a)=>{r&&r(a)},this.onCompiled=()=>{var a,o;let s=this.getEngine().scenes;if(s)for(let l=0;lthis._rebuildProgram(l,c,f,d),defines:r,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:i,disableParallelCompilation:this._disableParallelShaderCompilation,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:l=>{t&&!e&&this._engine._deletePipelineContext(t),l&&this._onRenderingStateCompiled(l)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContextAsync.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(i){this._processCompilationErrors(i,t)}}_getShaderCodeAndErrorLine(e,t,i){let r=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,s=null;if(t&&e){let a=t.match(r);if(a&&a.length===2){let o=parseInt(a[1]),l=e.split(` `,-1);l.length>=o&&(s=`Offending line [${o}] in ${i?"fragment":"vertex"} code: ${l[o-1]}`)}}return[e,s]}_processCompilationErrors(e,t=null){var a,o,l;this._compilationError=e.message;let i=this._attributesNames,r=this._fallbacks;if(W.Error("Unable to compile effect:"),W.Error(`Uniforms: ${this._uniformsNames.join(" ")}`),W.Error(`Attributes: ${i.join(" ")}`),W.Error(`Defines: -`+this.defines),n.LogShaderCodeOnCompilationError){let c=null,f=null,d;(a=this._pipelineContext)!=null&&a._getVertexShaderCode()&&([d,c]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),d&&(W.Error("Vertex code:"),W.Error(d))),(o=this._pipelineContext)!=null&&o._getFragmentShaderCode()&&([d,f]=this._getShaderCodeAndErrorLine((l=this._pipelineContext)==null?void 0:l._getFragmentShaderCode(),this._compilationError,!0),d&&(W.Error("Fragment code:"),W.Error(d))),c&&W.Error(c),f&&W.Error(f)}W.Error("Error: "+this._compilationError);let s=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this._engine.onEffectErrorObservable.notifyObservers({effect:this,errors:this._compilationError})};t&&(this._pipelineContext=t,this._isReady=!0,s()),r?(this._pipelineContext=null,r.hasMoreFallbacks?(this._allFallbacksProcessed=!1,W.Error("Trying next fallback."),this.defines=r.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,s(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||s())}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){let i=e+"Ex";if(this._samplerList.indexOf(i+"0")===-1){let r=this._samplerList.indexOf(e);for(let a=1;a0||this._isDisposed||(this._onReleaseEffectsObserver&&(this._engine.onReleaseEffectsObservable.remove(this._onReleaseEffectsObserver),this._onReleaseEffectsObserver=null),this._pipelineContext&&Xd(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,r=0){t&&(E.GetShadersStore(r)[`${e}PixelShader`]=t),i&&(E.GetShadersStore(r)[`${e}VertexShader`]=i)}static ResetCache(){n._BaseCache={}}};Nt.LogShaderCodeOnCompilationError=!0;Nt.PersistentMode=!1;Nt.AutomaticallyClearCodeCache=!1;Nt._UniqueIdSeed=0;Nt._BaseCache={};Nt.ShadersStore=E.ShadersStore;Nt.IncludesShadersStore=E.IncludesShadersStore});var ki,a_=A(()=>{ki=class n{static SetMatrixPrecision(e){if(n.MatrixTrackPrecisionChange=!1,e&&!n.MatrixUse64Bits&&n.MatrixTrackedMatrices)for(let t=0;t{yr();kt=class{static get Now(){return Bt()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}});var Kd,KR=A(()=>{Kd=class{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))}}});var jd,jR=A(()=>{jd=class{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get backFunc(){return this._func}set backFunc(e){this._backFunc!==e&&(this._backFunc=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail!==e&&(this._backOpStencilFail=e,this._isStencilOpDirty=!0)}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail!==e&&(this._backOpDepthFail=e,this._isStencilOpDirty=!0)}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass!==e&&(this._backOpStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){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;let 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.backFunc=t?this.stencilMaterial.backFunc:this.stencilGlobal.backFunc,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.backOpStencilFail=t?this.stencilMaterial.backOpStencilFail:this.stencilGlobal.backOpStencilFail,this.backOpDepthFail=t?this.stencilMaterial.backOpDepthFail:this.stencilGlobal.backOpDepthFail,this.backOpStencilDepthPass=t?this.stencilMaterial.backOpStencilDepthPass:this.stencilGlobal.backOpStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFuncSeparate(e.FRONT,this.func,this.funcRef,this.funcMask),e.stencilFuncSeparate(e.BACK,this.backFunc,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOpSeparate(e.FRONT,this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),e.stencilOpSeparate(e.BACK,this.backOpStencilFail,this.backOpDepthFail,this.backOpStencilDepthPass),this._isStencilOpDirty=!1))}}});var so,ZR=A(()=>{so=class n{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=n.ALWAYS,this.opStencilFail=n.KEEP,this.opDepthFail=n.KEEP,this.opStencilDepthPass=n.REPLACE,this.backFunc=n.ALWAYS,this.backOpStencilFail=n.KEEP,this.backOpDepthFail=n.KEEP,this.backOpStencilDepthPass=n.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilBackFunc(){return this.backFunc}set stencilBackFunc(e){this.backFunc=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilBackOpStencilFail(){return this.backOpStencilFail}set stencilBackOpStencilFail(e){this.backOpStencilFail=e}get stencilBackOpDepthFail(){return this.backOpDepthFail}set stencilBackOpDepthFail(e){this.backOpDepthFail=e}get stencilBackOpStencilDepthPass(){return this.backOpStencilDepthPass}set stencilBackOpStencilDepthPass(e){this.backOpStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}};so.ALWAYS=519;so.KEEP=7680;so.REPLACE=7681});var $o,o_=A(()=>{$o=class{constructor(e){this._supportBlendParametersPerTarget=e,this._blendFunctionParameters=new Array(32),this._blendEquationParameters=new Array(16),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=Array(8).fill(!1),this._numTargetEnabled=0,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._numTargetEnabled>0}set alphaBlend(e){this.setAlphaBlend(e)}setAlphaBlend(e,t=0){this._alphaBlend[t]!==e&&(e?this._numTargetEnabled++:this._numTargetEnabled--,this._alphaBlend[t]=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,i,r,s=0){let a=s*4;this._blendFunctionParameters[a+0]===e&&this._blendFunctionParameters[a+1]===t&&this._blendFunctionParameters[a+2]===i&&this._blendFunctionParameters[a+3]===r||(this._blendFunctionParameters[a+0]=e,this._blendFunctionParameters[a+1]=t,this._blendFunctionParameters[a+2]=i,this._blendFunctionParameters[a+3]=r,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t,i=0){let r=i*2;this._blendEquationParameters[r+0]===e&&this._blendEquationParameters[r+1]===t||(this._blendEquationParameters[r+0]=e,this._blendEquationParameters[r+1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend.fill(!1),this._numTargetEnabled=0,this._blendFunctionParameters.fill(null),this._blendEquationParameters.fill(null),this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e,t=1){if(!this.isDirty)return;if(this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1),t===1||!this._supportBlendParametersPerTarget){this._isAlphaBlendDirty&&(this._alphaBlend[0]?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1);return}let i=e;if(this._isAlphaBlendDirty){for(let r=0;r{ct();no();At();ze();a_();rs();KR();jR();ZR();o_();gi();_r();yr();aa();fe=class n{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}_resetAlphaMode(){this._alphaMode.fill(-1),this._alphaEquation.fill(-1)}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,e?this._depthCullingState.depthFunc=518:this._depthCullingState.depthFunc=515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}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+=` +`+this.defines),n.LogShaderCodeOnCompilationError){let c=null,f=null,d;(a=this._pipelineContext)!=null&&a._getVertexShaderCode()&&([d,c]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),d&&(W.Error("Vertex code:"),W.Error(d))),(o=this._pipelineContext)!=null&&o._getFragmentShaderCode()&&([d,f]=this._getShaderCodeAndErrorLine((l=this._pipelineContext)==null?void 0:l._getFragmentShaderCode(),this._compilationError,!0),d&&(W.Error("Fragment code:"),W.Error(d))),c&&W.Error(c),f&&W.Error(f)}W.Error("Error: "+this._compilationError);let s=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this._engine.onEffectErrorObservable.notifyObservers({effect:this,errors:this._compilationError})};t&&(this._pipelineContext=t,this._isReady=!0,s()),r?(this._pipelineContext=null,r.hasMoreFallbacks?(this._allFallbacksProcessed=!1,W.Error("Trying next fallback."),this.defines=r.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,s(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||s())}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){let i=e+"Ex";if(this._samplerList.indexOf(i+"0")===-1){let r=this._samplerList.indexOf(e);for(let a=1;a0||this._isDisposed||(this._onReleaseEffectsObserver&&(this._engine.onReleaseEffectsObservable.remove(this._onReleaseEffectsObserver),this._onReleaseEffectsObserver=null),this._pipelineContext&&Yd(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,r=0){t&&(E.GetShadersStore(r)[`${e}PixelShader`]=t),i&&(E.GetShadersStore(r)[`${e}VertexShader`]=i)}static ResetCache(){n._BaseCache={}}};Nt.LogShaderCodeOnCompilationError=!0;Nt.PersistentMode=!1;Nt.AutomaticallyClearCodeCache=!1;Nt._UniqueIdSeed=0;Nt._BaseCache={};Nt.ShadersStore=E.ShadersStore;Nt.IncludesShadersStore=E.IncludesShadersStore});var Wi,c_=A(()=>{Wi=class n{static SetMatrixPrecision(e){if(n.MatrixTrackPrecisionChange=!1,e&&!n.MatrixUse64Bits&&n.MatrixTrackedMatrices)for(let t=0;t{Lr();kt=class{static get Now(){return Bt()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}});var jd,eI=A(()=>{jd=class{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))}}});var Zd,tI=A(()=>{Zd=class{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get backFunc(){return this._func}set backFunc(e){this._backFunc!==e&&(this._backFunc=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail!==e&&(this._backOpStencilFail=e,this._isStencilOpDirty=!0)}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail!==e&&(this._backOpDepthFail=e,this._isStencilOpDirty=!0)}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass!==e&&(this._backOpStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){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;let 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.backFunc=t?this.stencilMaterial.backFunc:this.stencilGlobal.backFunc,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.backOpStencilFail=t?this.stencilMaterial.backOpStencilFail:this.stencilGlobal.backOpStencilFail,this.backOpDepthFail=t?this.stencilMaterial.backOpDepthFail:this.stencilGlobal.backOpDepthFail,this.backOpStencilDepthPass=t?this.stencilMaterial.backOpStencilDepthPass:this.stencilGlobal.backOpStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFuncSeparate(e.FRONT,this.func,this.funcRef,this.funcMask),e.stencilFuncSeparate(e.BACK,this.backFunc,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOpSeparate(e.FRONT,this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),e.stencilOpSeparate(e.BACK,this.backOpStencilFail,this.backOpDepthFail,this.backOpStencilDepthPass),this._isStencilOpDirty=!1))}}});var so,iI=A(()=>{so=class n{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=n.ALWAYS,this.opStencilFail=n.KEEP,this.opDepthFail=n.KEEP,this.opStencilDepthPass=n.REPLACE,this.backFunc=n.ALWAYS,this.backOpStencilFail=n.KEEP,this.backOpDepthFail=n.KEEP,this.backOpStencilDepthPass=n.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilBackFunc(){return this.backFunc}set stencilBackFunc(e){this.backFunc=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilBackOpStencilFail(){return this.backOpStencilFail}set stencilBackOpStencilFail(e){this.backOpStencilFail=e}get stencilBackOpDepthFail(){return this.backOpDepthFail}set stencilBackOpDepthFail(e){this.backOpDepthFail=e}get stencilBackOpStencilDepthPass(){return this.backOpStencilDepthPass}set stencilBackOpStencilDepthPass(e){this.backOpStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}};so.ALWAYS=519;so.KEEP=7680;so.REPLACE=7681});var el,f_=A(()=>{el=class{constructor(e){this._supportBlendParametersPerTarget=e,this._blendFunctionParameters=new Array(32),this._blendEquationParameters=new Array(16),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=Array(8).fill(!1),this._numTargetEnabled=0,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._numTargetEnabled>0}set alphaBlend(e){this.setAlphaBlend(e)}setAlphaBlend(e,t=0){this._alphaBlend[t]!==e&&(e?this._numTargetEnabled++:this._numTargetEnabled--,this._alphaBlend[t]=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,i,r,s=0){let a=s*4;this._blendFunctionParameters[a+0]===e&&this._blendFunctionParameters[a+1]===t&&this._blendFunctionParameters[a+2]===i&&this._blendFunctionParameters[a+3]===r||(this._blendFunctionParameters[a+0]=e,this._blendFunctionParameters[a+1]=t,this._blendFunctionParameters[a+2]=i,this._blendFunctionParameters[a+3]=r,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t,i=0){let r=i*2;this._blendEquationParameters[r+0]===e&&this._blendEquationParameters[r+1]===t||(this._blendEquationParameters[r+0]=e,this._blendEquationParameters[r+1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend.fill(!1),this._numTargetEnabled=0,this._blendFunctionParameters.fill(null),this._blendEquationParameters.fill(null),this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e,t=1){if(!this.isDirty)return;if(this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1),t===1||!this._supportBlendParametersPerTarget){this._isAlphaBlendDirty&&(this._alphaBlend[0]?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1);return}let i=e;if(this._isAlphaBlendDirty){for(let r=0;r{ft();no();At();ze();c_();ns();eI();tI();iI();f_();Ei();vr();Lr();aa();fe=class n{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}_resetAlphaMode(){this._alphaMode.fill(-1),this._alphaEquation.fill(-1)}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,e?this._depthCullingState.depthFunc=518:this._depthCullingState.depthFunc=515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}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+=` `),t+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(t&&(t+=` -`),t+="#define USE_EXACT_SRGB_CONVERSIONS"),t}}_rebuildInternalTextures(){let e=this._internalTexturesCache.slice();for(let t of e)t._rebuild()}_rebuildRenderTargetWrappers(){let e=this._renderTargetWrapperCache.slice();for(let t of e)t._rebuild()}_rebuildEffects(){for(let e in this._compiledEffects){let t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}Nt.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(){W.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout(()=>{this._clearEmptyResources();let t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,r=this._depthCullingState.depthMask,s=this._stencilState.stencilTest;e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=r,this._stencilState.stencilTest=s,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){let 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}let t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),this._activeRenderLoops.length==0&&this._cancelFrame())}_cancelFrame(){if(this._frameHandler!==0){let e=this._frameHandler;if(this._frameHandler=0,Bt()){let{cancelAnimationFrame:t}=this.getHostWindow()||window;if(typeof t=="function")return t(e)}else if(typeof cancelAnimationFrame=="function")return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}get maxFPS(){return this._maxFPS}set maxFPS(e){if(this._maxFPS=e,e!==void 0){if(e<=0){this._minFrameTime=Number.MAX_VALUE;return}this._minFrameTime=1e3/e}}_isOverFrameTime(e){if(!e||this._maxFPS===void 0)return!1;let t=e-this._lastFrameTime;return this._lastFrameTime=e,this._renderAccumulator+=t,this._renderAccumulatorthis._minFrameTime&&(this._renderAccumulator=this._minFrameTime),!1)}_processFrame(e){if(this._frameHandler=0,!this._contextWasLost&&!this._isOverFrameTime(e)){let t=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(t=!1),t&&(this.beginFrame(),!this.skipFrameRender&&!this._renderViews()&&this._renderFrame(),this.endFrame())}}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e-1?e.substring(I).toLowerCase():"");x.indexOf("?")>-1&&(x=x.split("?")[0]);let L=n.GetCompatibleTextureLoader(x,m);r&&r.addPendingData(R),R.url=e,R.generateMipMaps=!t,R.samplingMode=s,R.invertY=i,R._useSRGBBuffer=this._getUseSRGBBuffer(!!_,t),this._doNotHandleContextLost||(R._buffer=f);let y=null;a&&!d&&(y=R.onLoadedObservable.add(a)),d||this._internalTexturesCache.push(R);let B=(w,H)=>{r&&r.removePendingData(R),e===S?(y&&R.onLoadedObservable.remove(y),ue.UseFallbackTexture&&e!==ue.FallbackTexture&&this._createTextureBase(ue.FallbackTexture,t,R.invertY,r,s,null,o,l,c,f,R),w=(w||"Unknown error")+(ue.UseFallbackTexture?" - Fallback texture was used":""),R.onErrorObservable.notifyObservers({message:w,exception:H}),o&&o(w,H)):(W.Warn(`Failed to load ${e}, falling back to ${S}`),this._createTextureBase(S,t,R.invertY,r,s,a,o,l,c,f,R,h,u,m,p,_))};if(L){let w=async H=>{(await L).loadData(H,R,(V,X,j,Q,$,q)=>{q?B("TextureLoader failed to load data"):l(R,x,r,{width:V,height:X},R.invertY,!j,Q,()=>($(),!1),s)},p)};if(!f)this._loadFile(e,async H=>{try{await w(new Uint8Array(H))}catch(O){B("Failed to parse texture data",O)}},void 0,r?r.offlineProvider:void 0,!0,(H,O)=>{B("Unable to load "+(H&&H.responseURL,O))});else{let H=async O=>{try{await w(O)}catch(V){B("Failed to parse texture data",V)}};f instanceof ArrayBuffer?H(new Uint8Array(f)):ArrayBuffer.isView(f)?H(f):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null)}}else{let w=H=>{T&&!this._doNotHandleContextLost&&(R._buffer=H),l(R,x,r,H,R.invertY,t,!1,c,s)};!g||b?f&&(typeof f.decoding=="string"||f.close)?w(f):n._FileToolsLoadImage(e||"",w,B,r?r.offlineProvider:null,m,R.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof f=="string"||f instanceof ArrayBuffer||ArrayBuffer.isView(f)||f instanceof Blob?n._FileToolsLoadImage(f,w,B,r?r.offlineProvider:null,m,R.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):f&&w(f)}return R}_rebuildBuffers(){for(let e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!!(this._caps.highPrecisionShaderSupported&&this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:sa()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(let 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@9.6.0"}static get Version(){return"9.6.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 a,o,l,c,f,d,h,u,m,p;this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new Kd,this._stencilStateComposer=new jd,this._stencilState=new so,this._alphaState=new $o(!1),this._alphaMode=Array(8).fill(-1),this._alphaEquation=Array(8).fill(-1),this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this._enableGPUDebugMarkers=!1,this.onCanvasBlurObservable=new Y,this.onCanvasFocusObservable=new Y,this.onNewSceneAddedObservable=new Y,this.onResizeObservable=new Y,this.onCanvasPointerOutObservable=new Y,this.onEffectErrorObservable=new Y,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 Y,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=_=>this._renderLoop(_),this._lastFrameTime=0,this._renderAccumulator=0,this.skipFrameRender=!1,this.onBeforeShaderCompilationObservable=new Y,this.onAfterShaderCompilationObservable=new Y,this.onBeginFrameObservable=new Y,this.onEndFrameObservable=new Y,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new Y,this.onContextRestoredObservable=new Y,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 Y,this.onReleaseEffectsObservable=new Y,ue.Instances.push(this),this.startTime=kt.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,ki.SetMatrixPrecision(!!t.useLargeWorldRendering||!!t.useHighPrecisionMatrix),is()&&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=(a=t.deterministicLockstep)!=null?a:!1,t.lockstepMaxSteps=(o=t.lockstepMaxSteps)!=null?o:4,t.timeStep=(l=t.timeStep)!=null?l:1/60,t.stencil=(c=t.stencil)!=null?c:!0,this._audioContext=(d=(f=t.audioEngineOptions)==null?void 0:f.audioContext)!=null?d:null,this._audioDestination=(u=(h=t.audioEngineOptions)==null?void 0:h.audioDestination)!=null?u:null,this.premultipliedAlpha=(m=t.premultipliedAlpha)!=null?m:!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=(p=t.useExactSrgbConversions)!=null?p:!1;let r=Bt()&&window.devicePixelRatio||1,s=t.limitDeviceRatio||r;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(s,r):1,this._lastDevicePixelRatio=r,this._creationOptions=t}resize(e=!1){var r,s;let t,i;if(this.adaptToDeviceRatio){let a=Bt()&&window.devicePixelRatio||1,o=this._lastDevicePixelRatio/a;this._lastDevicePixelRatio=a,this._hardwareScalingLevel*=o}if(Bt()&&sa())if(this._renderingCanvas){let a=(s=(r=this._renderingCanvas).getBoundingClientRect)==null?void 0:s.call(r);t=this._renderingCanvas.clientWidth||(a==null?void 0:a.width)||this._renderingCanvas.width*this._hardwareScalingLevel||100,i=this._renderingCanvas.clientHeight||(a==null?void 0:a.height)||this._renderingCanvas.height*this._hardwareScalingLevel||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)}setSize(e,t,i=!1){if(!this._renderingCanvas||(e=e|0,t=t|0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t))return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let r=0;r{let e=navigator.userAgent;this.hostInformation.isMobile=e.indexOf("Mobile")!==-1||e.indexOf("Mac")!==-1&&sa()&&"ontouchend"in document},this._checkForMobile(),Bt()&&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=="undefined")return new OffscreenCanvas(e,t);let i=document.createElement("canvas");return i.width=e,i.height=t,i}createCanvas(e,t){return n._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,r,s,a,o){throw Ie("FileTools")}_loadFile(e,t,i,r,s,a){let o=Ld(e,t,i,r,s,a);return this._activeRequests.push(o),o.onCompleteObservable.add(()=>{let l=this._activeRequests.indexOf(o);l!==-1&&this._activeRequests.splice(l,1)}),o}static _FileToolsLoadFile(e,t,i,r,s,a){if(qo.loadFile)return qo.loadFile(e,t,i,r,s,a);throw Ie("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),Nt.ResetCache();for(let 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(),this.onEffectErrorObservable.clear(),Bt()&&window.removeEventListener("resize",this._checkForMobile);let e=ue.Instances.indexOf(this);e>=0&&ue.Instances.splice(e,1),ue.Instances.length||(ue.OnEnginesDisposedObservable.notifyObservers(this),ue.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw Ie("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i{});var qd,QR=A(()=>{qd=class{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,r,s){if(s.drawBuffersExtensionDisabled){let a=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(a,"")}return e}}});var fV,Qd,JR=A(()=>{fV=/(flat\s)?\s*varying\s*.*/,Qd=class{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return fV.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,i){let r=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1,s=/#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(s,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){let a=e.search(/layout *\(location *= *0\) *out/g)!==-1,o=t.indexOf("#define DUAL_SOURCE_BLENDING")!==-1,l=o?`layout(location = 0, index = 0) out vec4 glFragColor; +`),t+="#define USE_EXACT_SRGB_CONVERSIONS"),t}}_rebuildInternalTextures(){let e=this._internalTexturesCache.slice();for(let t of e)t._rebuild()}_rebuildRenderTargetWrappers(){let e=this._renderTargetWrapperCache.slice();for(let t of e)t._rebuild()}_rebuildEffects(){for(let e in this._compiledEffects){let t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}Nt.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(){W.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout(()=>{this._clearEmptyResources();let t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,r=this._depthCullingState.depthMask,s=this._stencilState.stencilTest;e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=r,this._stencilState.stencilTest=s,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){let 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}let t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),this._activeRenderLoops.length==0&&this._cancelFrame())}_cancelFrame(){if(this._frameHandler!==0){let e=this._frameHandler;if(this._frameHandler=0,Bt()){let{cancelAnimationFrame:t}=this.getHostWindow()||window;if(typeof t=="function")return t(e)}else if(typeof cancelAnimationFrame=="function")return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}get maxFPS(){return this._maxFPS}set maxFPS(e){if(this._maxFPS=e,e!==void 0){if(e<=0){this._minFrameTime=Number.MAX_VALUE;return}this._minFrameTime=1e3/e}}_isOverFrameTime(e){if(!e||this._maxFPS===void 0)return!1;let t=e-this._lastFrameTime;return this._lastFrameTime=e,this._renderAccumulator+=t,this._renderAccumulatorthis._minFrameTime&&(this._renderAccumulator=this._minFrameTime),!1)}_processFrame(e){if(this._frameHandler=0,!this._contextWasLost&&!this._isOverFrameTime(e)){let t=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(t=!1),t&&(this.beginFrame(),!this.skipFrameRender&&!this._renderViews()&&this._renderFrame(),this.endFrame())}}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e-1?e.substring(I).toLowerCase():"");x.indexOf("?")>-1&&(x=x.split("?")[0]);let L=n.GetCompatibleTextureLoader(x,m);r&&r.addPendingData(R),R.url=e,R.generateMipMaps=!t,R.samplingMode=s,R.invertY=i,R._useSRGBBuffer=this._getUseSRGBBuffer(!!_,t),this._doNotHandleContextLost||(R._buffer=f);let y=null;a&&!d&&(y=R.onLoadedObservable.add(a)),d||this._internalTexturesCache.push(R);let B=(w,H)=>{r&&r.removePendingData(R),e===S?(y&&R.onLoadedObservable.remove(y),ue.UseFallbackTexture&&e!==ue.FallbackTexture&&this._createTextureBase(ue.FallbackTexture,t,R.invertY,r,s,null,o,l,c,f,R),w=(w||"Unknown error")+(ue.UseFallbackTexture?" - Fallback texture was used":""),R.onErrorObservable.notifyObservers({message:w,exception:H}),o&&o(w,H)):(W.Warn(`Failed to load ${e}, falling back to ${S}`),this._createTextureBase(S,t,R.invertY,r,s,a,o,l,c,f,R,h,u,m,p,_))};if(L){let w=async H=>{(await L).loadData(H,R,(k,X,j,Q,$,q)=>{q?B("TextureLoader failed to load data"):l(R,x,r,{width:k,height:X},R.invertY,!j,Q,()=>($(),!1),s)},p)};if(!f)this._loadFile(e,async H=>{try{await w(new Uint8Array(H))}catch(O){B("Failed to parse texture data",O)}},void 0,r?r.offlineProvider:void 0,!0,(H,O)=>{B("Unable to load "+(H&&H.responseURL,O))});else{let H=async O=>{try{await w(O)}catch(k){B("Failed to parse texture data",k)}};f instanceof ArrayBuffer?H(new Uint8Array(f)):ArrayBuffer.isView(f)?H(f):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null)}}else{let w=H=>{T&&!this._doNotHandleContextLost&&(R._buffer=H),l(R,x,r,H,R.invertY,t,!1,c,s)};!g||b?f&&(typeof f.decoding=="string"||f.close)?w(f):n._FileToolsLoadImage(e||"",w,B,r?r.offlineProvider:null,m,R.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof f=="string"||f instanceof ArrayBuffer||ArrayBuffer.isView(f)||f instanceof Blob?n._FileToolsLoadImage(f,w,B,r?r.offlineProvider:null,m,R.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):f&&w(f)}return R}_rebuildBuffers(){for(let e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!!(this._caps.highPrecisionShaderSupported&&this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:sa()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(let 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@9.6.0"}static get Version(){return"9.6.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 a,o,l,c,f,d,h,u,m,p;this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new jd,this._stencilStateComposer=new Zd,this._stencilState=new so,this._alphaState=new el(!1),this._alphaMode=Array(8).fill(-1),this._alphaEquation=Array(8).fill(-1),this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this._enableGPUDebugMarkers=!1,this.onCanvasBlurObservable=new Y,this.onCanvasFocusObservable=new Y,this.onNewSceneAddedObservable=new Y,this.onResizeObservable=new Y,this.onCanvasPointerOutObservable=new Y,this.onEffectErrorObservable=new Y,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 Y,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=_=>this._renderLoop(_),this._lastFrameTime=0,this._renderAccumulator=0,this.skipFrameRender=!1,this.onBeforeShaderCompilationObservable=new Y,this.onAfterShaderCompilationObservable=new Y,this.onBeginFrameObservable=new Y,this.onEndFrameObservable=new Y,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new Y,this.onContextRestoredObservable=new Y,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 Y,this.onReleaseEffectsObservable=new Y,ue.Instances.push(this),this.startTime=kt.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,Wi.SetMatrixPrecision(!!t.useLargeWorldRendering||!!t.useHighPrecisionMatrix),rs()&&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=(a=t.deterministicLockstep)!=null?a:!1,t.lockstepMaxSteps=(o=t.lockstepMaxSteps)!=null?o:4,t.timeStep=(l=t.timeStep)!=null?l:1/60,t.stencil=(c=t.stencil)!=null?c:!0,this._audioContext=(d=(f=t.audioEngineOptions)==null?void 0:f.audioContext)!=null?d:null,this._audioDestination=(u=(h=t.audioEngineOptions)==null?void 0:h.audioDestination)!=null?u:null,this.premultipliedAlpha=(m=t.premultipliedAlpha)!=null?m:!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=(p=t.useExactSrgbConversions)!=null?p:!1;let r=Bt()&&window.devicePixelRatio||1,s=t.limitDeviceRatio||r;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(s,r):1,this._lastDevicePixelRatio=r,this._creationOptions=t}resize(e=!1){var r,s;let t,i;if(this.adaptToDeviceRatio){let a=Bt()&&window.devicePixelRatio||1,o=this._lastDevicePixelRatio/a;this._lastDevicePixelRatio=a,this._hardwareScalingLevel*=o}if(Bt()&&sa())if(this._renderingCanvas){let a=(s=(r=this._renderingCanvas).getBoundingClientRect)==null?void 0:s.call(r);t=this._renderingCanvas.clientWidth||(a==null?void 0:a.width)||this._renderingCanvas.width*this._hardwareScalingLevel||100,i=this._renderingCanvas.clientHeight||(a==null?void 0:a.height)||this._renderingCanvas.height*this._hardwareScalingLevel||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)}setSize(e,t,i=!1){if(!this._renderingCanvas||(e=e|0,t=t|0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t))return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let r=0;r{let e=navigator.userAgent;this.hostInformation.isMobile=e.indexOf("Mobile")!==-1||e.indexOf("Mac")!==-1&&sa()&&"ontouchend"in document},this._checkForMobile(),Bt()&&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=="undefined")return new OffscreenCanvas(e,t);let i=document.createElement("canvas");return i.width=e,i.height=t,i}createCanvas(e,t){return n._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,r,s,a,o){throw Ie("FileTools")}_loadFile(e,t,i,r,s,a){let o=Pd(e,t,i,r,s,a);return this._activeRequests.push(o),o.onCompleteObservable.add(()=>{let l=this._activeRequests.indexOf(o);l!==-1&&this._activeRequests.splice(l,1)}),o}static _FileToolsLoadFile(e,t,i,r,s,a){if(Qo.loadFile)return Qo.loadFile(e,t,i,r,s,a);throw Ie("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),Nt.ResetCache();for(let 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(),this.onEffectErrorObservable.clear(),Bt()&&window.removeEventListener("resize",this._checkForMobile);let e=ue.Instances.indexOf(this);e>=0&&ue.Instances.splice(e,1),ue.Instances.length||(ue.OnEnginesDisposedObservable.notifyObservers(this),ue.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw Ie("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i{});var Qd,nI=A(()=>{Qd=class{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,r,s){if(s.drawBuffersExtensionDisabled){let a=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(a,"")}return e}}});var yV,Jd,sI=A(()=>{yV=/(flat\s)?\s*varying\s*.*/,Jd=class{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return yV.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,i){let r=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1,s=/#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(s,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){let a=e.search(/layout *\(location *= *0\) *out/g)!==-1,o=t.indexOf("#define DUAL_SOURCE_BLENDING")!==-1,l=o?`layout(location = 0, index = 0) out vec4 glFragColor; layout(location = 0, index = 1) out vec4 glFragColor2; `:`layout(location = 0) out vec4 glFragColor; `;o&&(e=`#extension GL_EXT_blend_func_extended : require `+e),e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCubeLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCube\s*\(/g,"texture("),e=e.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),e=e.replace(/gl_FragColor/g,"glFragColor"),e=e.replace(/gl_FragData/g,"glFragData"),e=e.replace(/void\s+?main\s*\(/g,(r||a?"":l)+"void main(")}else if(t.indexOf("#define VERTEXOUTPUT_INVARIANT")>=0&&(e=`invariant gl_Position; `+e),t.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require layout (num_views = 2) in; -`+e;return e}}});var ao,c_=A(()=>{ao=class n{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=n._Counter++}};ao._Counter=0});var yn,Jd=A(()=>{c_();yn=class extends ao{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}});function oo(n){let e=1;do e*=2;while(en-t?t:e}function $R(n){return n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n++,n}function $d(n){return n=n|n>>1,n=n|n>>2,n=n|n>>4,n=n|n>>8,n=n|n>>16,n-(n>>1)}function Qi(n,e,t=2){let i;switch(t){case 1:i=$d(n);break;case 2:i=f_(n);break;case 3:default:i=$R(n);break}return Math.min(i,e)}var Dn=A(()=>{});var el,d_=A(()=>{el=class{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(let 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()}}});function h_(n){return n===13||n===14||n===15||n===16||n===17||n===18||n===19}function ns(n){return n===13||n===17||n===18||n===19}var Wc=A(()=>{});var eI={};De(eI,{ThinEngine:()=>We});var u_,We,Ji=A(()=>{no();Jp();ii();l_();ze();yr();QR();JR();Jd();Dn();d_();_r();aa();s_();Wc();o_();u_=class{},We=class n extends fe{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return Nt.ShadersRepository}static set ShadersRepository(e){Nt.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,r){if(i=i||{},super(t!=null?t:i.antialias,i,r),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 s;if(e.getContext){if(s=e,i.preserveDrawingBuffer===void 0&&(i.preserveDrawingBuffer=!1),i.xrCompatible===void 0&&(i.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();let l=navigator.userAgent;for(let c of n.ExceptionList){let f=c.key,d=c.targets;if(new RegExp(f).test(l)){if(c.capture&&c.captureConstraint){let u=c.capture,m=c.captureConstraint,_=new RegExp(u).exec(l);if(_&&_.length>0&&parseInt(_[_.length-1])>=m)continue}for(let u of d)switch(u){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=()=>{Od(this._gl)}:(this._onContextLost=l=>{l.preventDefault(),this._contextWasLost=!0,Od(this._gl),W.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},s.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),s.addEventListener("webglcontextlost",this._onContextLost,!1),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=s.getContext("webgl2",i)||s.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch(l){}if(!this._gl){if(!s)throw new Error("The provided canvas is null or undefined.");try{this._gl=s.getContext("webgl",i)||s.getContext("experimental-webgl",i)}catch(l){throw new Error("WebGL not supported",{cause:l})}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,s=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";let l=this._gl.getContextAttributes();l&&(i.stencil=l.stencil)}this._sharedInit(s),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 l=0;l1?new Qd:new qd;let a=`Babylon.js v${n.Version}`;W.Log(a+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",a);let o=xi(this._gl);o.validateShaderPrograms=this.validateShaderPrograms,o.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(let e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){var i;this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),shaderFloatPrecision:0,parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||this._gl.getExtension("OES_standard_derivatives")!==null,maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||this._gl.getExtension("OES_element_index_uint")!==null,fragmentDepthSupported:this._webGLVersion>1||this._gl.getExtension("EXT_frag_depth")!==null,highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),blendFloat:this._gl.getExtension("EXT_float_blend")!==null,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:this._webGLVersion!==1,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1,textureNorm16:!!this._gl.getExtension("EXT_texture_norm16"),blendParametersPerTarget:!1,dualSourceBlending:!1,supportReadWriteStorageTextures:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);let e=this._gl.getExtension("WEBGL_debug_renderer_info");e!=null&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),this._gl.HALF_FLOAT_OES!==36193&&(this._gl.HALF_FLOAT_OES=36193),this._gl.RGBA16F!==34842&&(this._gl.RGBA16F=34842),this._gl.RGBA32F!==34836&&(this._gl.RGBA32F=34836),this._gl.DEPTH24_STENCIL8!==35056&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(this._webGLVersion===1&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=((i=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT))!=null?i: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);let t=this._gl.getExtension("OES_draw_buffers_indexed");if(this._caps.blendParametersPerTarget=!!t,this._alphaState=new $o(this._caps.blendParametersPerTarget),t&&(this._gl.blendEquationSeparateIndexed=t.blendEquationSeparateiOES.bind(t),this._gl.blendEquationIndexed=t.blendEquationiOES.bind(t),this._gl.blendFuncSeparateIndexed=t.blendFuncSeparateiOES.bind(t),this._gl.blendFuncIndexed=t.blendFunciOES.bind(t),this._gl.colorMaskIndexed=t.colorMaskiOES.bind(t),this._gl.disableIndexed=t.disableiOES.bind(t),this._gl.enableIndexed=t.enableiOES.bind(t)),this._caps.dualSourceBlending=!!this._gl.getExtension("WEBGL_blend_func_extended"),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_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{let r=this._gl.getExtension("WEBGL_draw_buffers");if(r!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=r.drawBuffersWEBGL.bind(r),this._caps.maxDrawBuffers=this._gl.getParameter(r.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let s=0;s<16;s++)this._gl["COLOR_ATTACHMENT"+s+"_WEBGL"]=r["COLOR_ATTACHMENT"+s+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{let r=this._gl.getExtension("WEBGL_depth_texture");r!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=r.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{let r=this._gl.getExtension("OES_vertex_array_object");r!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{let r=this._gl.getExtension("ANGLE_instanced_arrays");r!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=r.drawArraysInstancedANGLE.bind(r),this._gl.drawElementsInstanced=r.drawElementsInstancedANGLE.bind(r),this._gl.vertexAttribDivisor=r.vertexAttribDivisorANGLE.bind(r)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){let r=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);if(r&&s&&(this._caps.highPrecisionShaderSupported=r.precision!==0&&s.precision!==0,this._caps.shaderFloatPrecision=Math.min(r.precision,s.precision)),!this._shouldUseHighPrecisionShader){let a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.MEDIUM_FLOAT),o=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.MEDIUM_FLOAT);a&&o&&(this._caps.shaderFloatPrecision=Math.min(a.precision,o.precision))}this._caps.shaderFloatPrecision<10&&(this._caps.shaderFloatPrecision=10)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{let r=this._gl.getExtension("EXT_blend_minmax");r!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=r.MAX_EXT,this._gl.MIN=r.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{let r=this._gl.getExtension("EXT_sRGB");r!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:r.SRGB_EXT,SRGB8:r.SRGB_ALPHA_EXT,SRGB8_ALPHA8:r.SRGB_ALPHA_EXT})}if(this._creationOptions){let r=this._creationOptions.forceSRGBBufferSupportState;r!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&r)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let r=0;r=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){let r=e.program,s=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,s,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,r,s,a,o){let l=this._currentBufferPointers[t];if(!l)return;let c=!1;l.active?(l.buffer!==e&&(l.buffer=e,c=!0),l.size!==i&&(l.size=i,c=!0),l.type!==r&&(l.type=r,c=!0),l.normalized!==s&&(l.normalized=s,c=!0),l.stride!==a&&(l.stride=a,c=!0),l.offset!==o&&(l.offset=o,c=!0)):(c=!0,l.active=!0,l.index=t,l.size=i,l.type=r,l.normalized=s,l.stride=a,l.offset=o,l.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),r===this._gl.UNSIGNED_INT||r===this._gl.INT?this._gl.vertexAttribIPointer(t,i,r,a,o):this._gl.vertexAttribPointer(t,i,r,s,a,o))}_bindIndexBufferWithCache(e){e!=null&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,i){let r=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let s=0;s=0){let o=r[s],l=null;if(i&&(l=i[o]),l||(l=e[o]),!l)continue;this._gl.enableVertexAttribArray(a),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[a]=!0);let c=l.getBuffer();c&&(this._vertexAttribPointer(c,a,l.getSize(),l.type,l.normalized,l.byteStride,l.byteOffset),l.getIsInstanced()&&(this._gl.vertexAttribDivisor(a,l.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(c))))}}}recordVertexArrayObject(e,t,i,r){let s=this._gl.createVertexArray();if(!s)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(s),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,r),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),s}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,r,s){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==s){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=s;let a=s.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let o=0;for(let l=0;l=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[l],this._gl.FLOAT,!1,r,o)),o+=i[l]*4}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,i,r){(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i)&&(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i,r)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,i=this._currentInstanceLocations.length;t1||this.isWebGPU)),(o===1&&!this._caps.textureFloatLinearFiltering||o===2&&!this._caps.textureHalfFloatLinearFiltering)&&(l=1),o===1&&!this._caps.textureFloat&&(o=0,W.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));let _=h_(c),g=ns(c),T=this._gl,b=new bt(this,r),R=e.width||e,S=e.height||e,I=e.depth||0,x=e.layers||0,P=this._getSamplingParameters(l,(s||a)&&!_),L=x!==0?T.TEXTURE_2D_ARRAY:I!==0?T.TEXTURE_3D:p?T.TEXTURE_CUBE_MAP:T.TEXTURE_2D,y=_?this._getInternalFormatFromDepthTextureFormat(c,!0,g):this._getRGBABufferInternalSizedFormat(o,c,f),B=_?g?T.DEPTH_STENCIL:T.DEPTH_COMPONENT:this._getInternalFormat(c),w=_?this._getWebGLTextureTypeFromDepthTextureFormat(c):this._getWebGLTextureType(o);if(this._bindTextureDirectly(L,b),x!==0)b.is2DArray=!0,T.texImage3D(L,0,y,R,S,x,0,B,w,null);else if(I!==0)b.is3D=!0,T.texImage3D(L,0,y,R,S,I,0,B,w,null);else if(p){b.isCube=!0;for(let O=0;O<6;O++)T.texImage2D(T.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,y,R,S,0,B,w,null)}else T.texImage2D(L,0,y,R,S,0,B,w,null);if(T.texParameteri(L,T.TEXTURE_MAG_FILTER,P.mag),T.texParameteri(L,T.TEXTURE_MIN_FILTER,P.min),T.texParameteri(L,T.TEXTURE_WRAP_S,T.CLAMP_TO_EDGE),T.texParameteri(L,T.TEXTURE_WRAP_T,T.CLAMP_TO_EDGE),_&&this.webGLVersion>1&&(m===0?(T.texParameteri(L,T.TEXTURE_COMPARE_FUNC,515),T.texParameteri(L,T.TEXTURE_COMPARE_MODE,T.NONE)):(T.texParameteri(L,T.TEXTURE_COMPARE_FUNC,m),T.texParameteri(L,T.TEXTURE_COMPARE_MODE,T.COMPARE_REF_TO_TEXTURE))),(s||a)&&this._gl.generateMipmap(L),this._bindTextureDirectly(L,null),b._useSRGBBuffer=f,b.baseWidth=R,b.baseHeight=S,b.width=R,b.height=S,b.depth=x||I,b.isReady=!0,b.samples=d,b.generateMipMaps=s,b.samplingMode=l,b.type=o,b.format=c,b.label=h,b.comparisonFunction=m,this._internalTexturesCache.push(b),u){let O;if(h_(b.format)?O=this._setupFramebufferDepthAttachments(ns(b.format),b.format!==19,b.width,b.height,d,b.format,!0):O=this._createRenderBuffer(b.width,b.height,d,-1,this._getRGBABufferInternalSizedFormat(b.type,b.format,b._useSRGBBuffer),-1),!O)throw new Error("Unable to create render buffer");b._autoMSAAManagement=!0;let V=b._hardwareTexture;V||(V=b._hardwareTexture=this._createHardwareTexture()),V.addMSAARenderBuffer(O)}return b}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,r,s=3,a=null,o=null,l=null,c=null,f=null,d=null,h,u,m,p){return this._createTextureBase(e,t,i,r,s,a,o,(..._)=>this._prepareWebGLTexture(..._,f),(_,g,T,b,R,S)=>{let I=this._gl,x=T.width===_&&T.height===g;R._creationFlags=m!=null?m:0;let P=this._getTexImageParametersForCreateTexture(R.format,R._useSRGBBuffer);if(x)return I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,T),!1;let L=this._caps.maxTextureSize;if(T.width>L||T.height>L||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=_,this._workingCanvas.height=g,this._workingContext.drawImage(T,0,0,T.width,T.height,0,0,_,g),I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,this._workingCanvas),R.width=_,R.height=g),!1;{let y=new bt(this,2);this._bindTextureDirectly(I.TEXTURE_2D,y,!0),I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,T),this._rescaleTexture(y,R,r,P.format,()=>{this._releaseTexture(y),this._bindTextureDirectly(I.TEXTURE_2D,R,!0),S()})}return!0},l,c,f,d,h,u,p)}_getTexImageParametersForCreateTexture(e,t){let i,r;return this.webGLVersion===1?(i=this._getInternalFormat(e,t),r=i):(i=this._getInternalFormat(e,!1),r=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:r,format:i,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,i,r,s){}_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){let r=this._getTextureTarget(t),s=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(r,this._gl.TEXTURE_MAG_FILTER,s.mag,t),this._setTextureParameterInteger(r,this._gl.TEXTURE_MIN_FILTER,s.min),i&&s.hasMipMaps&&(t.generateMipMaps=!0,this._gl.generateMipmap(r)),this._bindTextureDirectly(r,null),t.samplingMode=e}updateTextureDimensions(e,t,i,r=1){}updateTextureWrappingMode(e,t,i=null,r=null){let s=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&r!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(r),e),e._cachedWrapR=r),this._bindTextureDirectly(s,null)}_uploadCompressedDataToTextureDirectly(e,t,i,r,s,a=0,o=0){let l=this._gl,c=l.TEXTURE_2D;if(e.isCube&&(c=l.TEXTURE_CUBE_MAP_POSITIVE_X+a),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=l.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 37809:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;break;case 37810:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;break;case 37811:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;break;case 37812:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;break;case 37813:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;break;case 37814:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;break;case 37815:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;break;case 37816:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;break;case 37817:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;break;case 37818:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;break;case 37819:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;break;case 37820:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;break;case 37821:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;break;case 33776:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1;break}if(e.generateMipMaps){let f=e._hardwareTexture;f.memoryAllocated||(l.texStorage2D(e.isCube?l.TEXTURE_CUBE_MAP:l.TEXTURE_2D,Math.floor(Math.log2(Math.max(i,r)))+1,t,e.width,e.height),f.memoryAllocated=!0),this._gl.compressedTexSubImage2D(c,o,0,0,i,r,t,s)}else this._gl.compressedTexImage2D(c,o,t,i,r,0,s)}_uploadDataToTextureDirectly(e,t,i=0,r=0,s,a=!1){let o=this._gl,l=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),f=s===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(s,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let d=o.TEXTURE_2D;e.isCube&&(d=o.TEXTURE_CUBE_MAP_POSITIVE_X+i);let h=Math.round(Math.log(e.width)*Math.LOG2E),u=Math.round(Math.log(e.height)*Math.LOG2E),m=a?e.width:Math.pow(2,Math.max(h-r,0)),p=a?e.height:Math.pow(2,Math.max(u-r,0));o.texImage2D(d,r,f,m,p,0,c,l,t)}updateTextureData(e,t,i,r,s,a,o=0,l=0,c=!1){let f=this._gl,d=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let u=f.TEXTURE_2D,m=f.TEXTURE_2D;e.isCube&&(m=f.TEXTURE_CUBE_MAP_POSITIVE_X+o,u=f.TEXTURE_CUBE_MAP),this._bindTextureDirectly(u,e,!0),f.texSubImage2D(m,l,i,r,s,a,h,d,t),c&&this._gl.generateMipmap(m),this._bindTextureDirectly(u,null)}_uploadArrayBufferViewToTexture(e,t,i=0,r=0){let s=this._gl,a=e.isCube?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D;this._bindTextureDirectly(a,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(a,null,!0)}_prepareWebGLTextureContinuation(e,t,i,r,s){let a=this._gl;if(!a)return;let o=this._getSamplingParameters(s,!i);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,o.mag),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,o.min),!i&&!r&&a.generateMipmap(a.TEXTURE_2D),this._bindTextureDirectly(a.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,i,r,s,a,o,l,c,f){let d=this.getCaps().maxTextureSize,h=Math.min(d,this.needPOTTextures?Qi(r.width,d):r.width),u=Math.min(d,this.needPOTTextures?Qi(r.height,d):r.height),m=this._gl;if(m){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(m.TEXTURE_2D,e,!0),this._unpackFlipY(s===void 0?!0:!!s),e.baseWidth=r.width,e.baseHeight=r.height,e.width=h,e.height=u,e.isReady=!0,e.type=e.type!==-1?e.type:0,e.format=e.format!==-1?e.format:f!=null?f:t===".jpg"&&!e._useSRGBBuffer?4:5,!l(h,u,r,t,e,()=>{this._prepareWebGLTextureContinuation(e,i,a,o,c)})&&this._prepareWebGLTextureContinuation(e,i,a,o,c)}}_getInternalFormatFromDepthTextureFormat(e,t,i){let r=this._gl;if(!t)return r.STENCIL_INDEX8;let a=i?r.DEPTH_STENCIL:r.DEPTH_COMPONENT;return this.webGLVersion>1?e===15?a=r.DEPTH_COMPONENT16:e===16?a=r.DEPTH_COMPONENT24:e===17||e===13?a=i?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24:e===14?a=r.DEPTH_COMPONENT32F:e===18&&(a=i?r.DEPTH32F_STENCIL8:r.DEPTH_COMPONENT32F):a=r.DEPTH_COMPONENT16,a}_getWebGLTextureTypeFromDepthTextureFormat(e){let t=this._gl,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,r,s=1,a,o=!1){let l=this._gl;a=a!=null?a:e?13:14;let c=this._getInternalFormatFromDepthTextureFormat(a,t,e);return e&&t?this._createRenderBuffer(i,r,s,l.DEPTH_STENCIL,c,o?-1:l.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,r,s,c,c,o?-1:l.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,r,s,c,c,o?-1:l.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,r,s,a,o=!0){let c=this._gl.createRenderbuffer();return this._updateRenderBuffer(c,e,t,i,r,s,a,o)}_updateRenderBuffer(e,t,i,r,s,a,o,l=!0){let c=this._gl;return c.bindRenderbuffer(c.RENDERBUFFER,e),r>1&&c.renderbufferStorageMultisample?c.renderbufferStorageMultisample(c.RENDERBUFFER,r,a,t,i):c.renderbufferStorage(c.RENDERBUFFER,s,t,i),o!==-1&&c.framebufferRenderbuffer(c.FRAMEBUFFER,o,c.RENDERBUFFER,e),l&&c.bindRenderbuffer(c.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();let 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&&(yR(e,this._gl),this._currentProgram=e)}bindSamplers(e){let t=e.getPipelineContext();this._setProgram(t.program);let i=e.getSamplers();for(let r=0;r-1;if(i&&a&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||r){if(this._activateCurrentTexture(),t&&t.isMultiview)throw W.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,(c=(l=t==null?void 0:t._hardwareTexture)==null?void 0:l.underlyingResource)!=null?c:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(s=!0,this._activateCurrentTexture());return a&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),s}_bindTexture(e,t,i){if(e===void 0)return;t&&(t._associatedChannel=e),this._activeChannel=e;let r=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(r,t)}unbindAllTextures(){for(let e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,i,r){e!==void 0&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))}_bindSamplerUniformToChannel(e,t){let 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,r=!1,s=""){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;let c=t.getInternalTexture();c&&(c._associatedChannel=e),t.update()}else if(t.delayLoadState===4)return t.delayLoad(),!1;let a;r?a=t.depthStencilTexture:t.isReady()?a=t.getInternalTexture():t.isCube?a=this.emptyCubeTexture:t.is3D?a=this.emptyTexture3D:t.is2DArray?a=this.emptyTexture2DArray:a=this.emptyTexture,!i&&a&&(a._associatedChannel=e);let o=!0;this._boundTexturesCache[e]===a&&(i||this._bindSamplerUniformToChannel(a._associatedChannel,e),o=!1),this._activeChannel=e;let l=this._getTextureTarget(a);if(o&&this._bindTextureDirectly(l,a,i),a&&!a.isMultiview){if(a.isCube&&a._cachedCoordinatesMode!==t.coordinatesMode){a._cachedCoordinatesMode=t.coordinatesMode;let c=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=c,t.wrapV=c}a._cachedWrapU!==t.wrapU&&(a._cachedWrapU=t.wrapU,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),a)),a._cachedWrapV!==t.wrapV&&(a._cachedWrapV=t.wrapV,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),a)),a.is3D&&a._cachedWrapR!==t.wrapR&&(a._cachedWrapR=t.wrapR,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),a)),this._setAnisotropicLevel(l,a,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,i,r){if(!(e===void 0||!t)){(!this._textureUnits||this._textureUnits.length!==i.length)&&(this._textureUnits=new Int32Array(i.length));for(let s=0;s=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){this._compiledEffects={},this.onReleaseEffectsObservable.notifyObservers(this)}dispose(){var e;Bt()&&this._renderingCanvas&&(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._onContextRestored&&this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&((e=this._gl.getExtension("WEBGL_lose_context"))==null||e.loseContext()),Od(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){let t=this._gl;for(;t.getError()!==t.NO_ERROR;);let i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),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);let s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);let a=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&a===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);let o=t.RGBA,l=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,o,l,c),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(s),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,r,s=!0,a=!0,o=null){let l=s?4:3,c=s?this._gl.RGBA:this._gl.RGB,f=i*r*l;if(!o)o=new Uint8Array(f);else if(o.length{rs();eh=class{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new m_(e)}sampleFrame(e=kt.Now){if(this._enabled){if(this._lastFrameTimeMs!=null){let 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(){let 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()}},m_=class{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){let 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;let 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){let t=this._samples.length;return(e%t+t)%t}}});var iI=A(()=>{Ji();We.prototype.setAlphaMode=function(n,e=!1,t=0){if(this._alphaMode[t]===n){if(!e){let r=n===0;this.depthCullingState.depthMask!==r&&(this.depthCullingState.depthMask=r)}return}let i=n===0;this._alphaState.setAlphaBlend(!i,t),this._alphaState.setAlphaMode(n,t),e||(this.depthCullingState.depthMask=i),this._alphaMode[t]=n}});function rI(n,e,t,i){let r,s=1;i===1?r=new Float32Array(e*t*4):i===2?(r=new Uint16Array(e*t*4),s=15360):i===7?r=new Uint32Array(e*t*4):r=new Uint8Array(e*t*4);for(let a=0;a{_r();ze();Ji();Dn();We.prototype.updateRawTexture=function(n,e,t,i,r=null,s=0,a=!1){if(!n)return;let o=this._getRGBABufferInternalSizedFormat(s,t,a),l=this._getInternalFormat(t),c=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,n,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(n._bufferView=e,n.format=t,n.type=s,n.invertY=i,n._compression=r),n.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),r&&e?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[r],n.width,n.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,n.width,n.height,0,l,c,e),n.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),n.isReady=!0};We.prototype.createRawTexture=function(n,e,t,i,r,s,a,o=null,l=0,c=0,f=!1){let d=new bt(this,3);d.baseWidth=e,d.baseHeight=t,d.width=e,d.height=t,d.format=i,d.generateMipMaps=r,d.samplingMode=a,d.invertY=s,d._compression=o,d.type=l,d._useSRGBBuffer=this._getUseSRGBBuffer(f,!r),this._doNotHandleContextLost||(d._bufferView=n),this.updateRawTexture(d,n,i,s,o,l,d._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,d,!0);let h=this._getSamplingParameters(a,r);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(d),d};We.prototype.createRawCubeTexture=function(n,e,t,i,r,s,a,o=null){let l=this._gl,c=new bt(this,8);c.isCube=!0,c.format=t,c.type=i,this._doNotHandleContextLost||(c._bufferViewArray=n);let f=this._getWebGLTextureType(i),d=this._getInternalFormat(t);d===l.RGB&&(d=l.RGBA),f===l.FLOAT&&!this._caps.textureFloatLinearFiltering?(r=!1,a=1,W.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):f===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(r=!1,a=1,W.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):f===l.FLOAT&&!this._caps.textureFloatRender?(r=!1,W.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):f===l.HALF_FLOAT&&!this._caps.colorBufferFloat&&(r=!1,W.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));let h=e,u=h;if(c.width=h,c.height=u,c.invertY=s,c._compression=o,!this.needPOTTextures||oo(c.width)&&oo(c.height)||(r=!1),n)this.updateRawCubeTexture(c,n,t,i,s,o);else{let _=this._getRGBABufferInternalSizedFormat(i),g=0;this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c,!0);for(let T=0;T<6;T++)o?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+T,g,this.getCaps().s3tc[o],c.width,c.height,0,void 0):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+T,g,_,c.width,c.height,0,d,f,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c,!0),n&&r&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);let p=this._getSamplingParameters(a,r);return l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,p.mag),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,p.min),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),c.generateMipMaps=r,c.samplingMode=a,c.isReady=!0,c};We.prototype.updateRawCubeTexture=function(n,e,t,i,r,s=null,a=0){n._bufferViewArray=e,n.format=t,n.type=i,n.invertY=r,n._compression=s;let o=this._gl,l=this._getWebGLTextureType(i),c=this._getInternalFormat(t),f=this._getRGBABufferInternalSizedFormat(i),d=!1;c===o.RGB&&(c=o.RGBA,d=!0),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,n,!0),this._unpackFlipY(r===void 0?!0:!!r),n.width%4!==0&&o.pixelStorei(o.UNPACK_ALIGNMENT,1);for(let u=0;u<6;u++){let m=e[u];s?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,this.getCaps().s3tc[s],n.width,n.height,0,m):(d&&(m=rI(m,n.width,n.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,f,n.width,n.height,0,c,l,m))}(!this.needPOTTextures||oo(n.width)&&oo(n.height))&&n.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),n.isReady=!0};We.prototype.createRawCubeTextureFromUrl=function(n,e,t,i,r,s,a,o,l=null,c=null,f=3,d=!1){let h=this._gl,u=this.createRawCubeTexture(null,t,i,r,!s,d,f,null);e==null||e.addPendingData(u),u.url=n,u.isReady=!1,this._internalTexturesCache.push(u);let m=(_,g)=>{e==null||e.removePendingData(u),c&&c(_?_.status+" "+_.statusText:"Failed to parse texture data",g)},p=async _=>{if(!u._hardwareTexture)return;let g=a(_);if(!g)return;let T=g instanceof Promise?await g:g,b=u.width;if(o){let R=this._getWebGLTextureType(r),S=this._getInternalFormat(i),I=this._getRGBABufferInternalSizedFormat(r),x=!1;S===h.RGB&&(S=h.RGBA,x=!0),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,u,!0),this._unpackFlipY(!1);let P=o(T);for(let L=0;L>L;for(let B=0;B<6;B++){let w=P[L][B];x&&(w=rI(w,y,y,r)),h.texImage2D(B,L,I,y,y,0,S,R,w)}}this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(u,T,i,r,d);u.isReady=!0,e==null||e.removePendingData(u),u.onLoadedObservable.notifyObservers(u),u.onLoadedObservable.clear(),l&&l()};return this._loadFile(n,_=>{p(_).catch(g=>{m(void 0,g)})},void 0,e==null?void 0:e.offlineProvider,!0,m),u};We.prototype.createRawTexture2DArray=nI(!1);We.prototype.createRawTexture3D=nI(!0);We.prototype.updateRawTexture2DArray=sI(!1);We.prototype.updateRawTexture3D=sI(!0)});var oI=A(()=>{Ji();aa();We.prototype._readTexturePixelsSync=function(n,e,t,i=-1,r=0,s=null,a=!0,o=!1,l=0,c=0){var h,u,m;let f=this._gl;if(!f)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){let p=f.createFramebuffer();if(!p)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=p}f.bindFramebuffer(f.FRAMEBUFFER,this._dummyFramebuffer),i>-1&&(n.is2DArray||n.is3D)?f.framebufferTextureLayer(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,(h=n._hardwareTexture)==null?void 0:h.underlyingResource,r,i):i>-1?f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+i,(u=n._hardwareTexture)==null?void 0:u.underlyingResource,r):f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,(m=n._hardwareTexture)==null?void 0:m.underlyingResource,r);let d=n.type!==void 0?this._getWebGLTextureType(n.type):f.UNSIGNED_BYTE;if(o)s||(s=IR(n.type,4*e*t));else switch(d){case f.UNSIGNED_BYTE:s||(s=new Uint8Array(4*e*t)),d=f.UNSIGNED_BYTE;break;default:s||(s=new Float32Array(4*e*t)),d=f.FLOAT;break}return a&&this.flushFramebuffer(),f.readPixels(l,c,e,t,f.RGBA,d,s),f.bindFramebuffer(f.FRAMEBUFFER,this._currentFramebuffer),s};We.prototype._readTexturePixels=function(n,e,t,i=-1,r=0,s=null,a=!0,o=!1,l=0,c=0){return Promise.resolve(this._readTexturePixelsSync(n,e,t,i,r,s,a,o,l,c))}});var lI=A(()=>{Ji();We.prototype.updateDynamicIndexBuffer=function(n,e,t=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(n);let i;n.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(n,e,t,i){this.bindArrayBuffer(n),t===void 0&&(t=0);let r=e.byteLength||e.length;i===void 0||i>=r&&t===0?e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e):e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e).subarray(0,i/4)):(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,i):e=new Uint8Array(e,0,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e)),this._resetVertexBufferBinding()}});var cI=A(()=>{Ji();_r();ze();Dn();We.prototype._createDepthStencilCubeTexture=function(n,e){let t=new bt(this,12);if(t.isCube=!0,this.webGLVersion===1)return W.Error("Depth cube texture is not supported by WebGL 1."),t;let i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e},r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,t,!0),this._setupDepthStencilTexture(t,n,i.bilinearFiltering,i.comparisonFunction);for(let s=0;s<6;s++)i.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,r.DEPTH24_STENCIL8,n,n,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,r.DEPTH_COMPONENT24,n,n,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(t),t};We.prototype._setCubeMapTextureParams=function(n,e,t){let 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),n.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&t!==void 0&&t>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,t),n._maxLodLevel=t),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};We.prototype.createCubeTexture=function(n,e,t,i,r=null,s=null,a,o=null,l=!1,c=0,f=0,d=null,h,u=!1,m=null){let p=this._gl;return this.createCubeTextureBase(n,e,t,!!i,r,s,a,o,l,c,f,d,_=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),(_,g)=>{let T=this.needPOTTextures?Qi(g[0].width,this._caps.maxCubemapTextureSize):g[0].width,b=T,R=[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,_,!0),this._unpackFlipY(!1);let S=a?this._getInternalFormat(a,_._useSRGBBuffer):_._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA,I=a?this._getInternalFormat(a):p.RGBA;_._useSRGBBuffer&&this.webGLVersion===1&&(I=S);for(let x=0;x{Wc();th=class{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=ns(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 s,a,o,l;if(!this._textures)return-1;let t=this._textures[e],i=(a=(s=this._layerIndices)==null?void 0:s[e])!=null?a:0,r=(l=(o=this._faceIndices)==null?void 0:o[e])!=null?l:0;return t.isCube?i*6+r:t.is3D?0:i}get samples(){return this._samples}setSamples(e,t=!0,i=!1){if(this.samples===e&&!i)return e;let r=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,r}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&(this.isMulti?this._engine.unBindMultiColorAttachmentFramebuffer(this,!0):this._engine.unBindFramebuffer(this,!0)),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,t,i,r,s){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=i,this._engine=r,this._depthStencilTexture=null,this.label=s}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,r=1,s=14,a){var o;return(o=this._depthStencilTexture)==null||o.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=a,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:r,depthTextureFormat:s,label:a},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,r,s,a,o,l,c;let e=null;if(this._isMulti){let f=this.textures;if(f&&f.length>0){let d=!1,h=f.length,u=-1,m=f[f.length-1]._source;(m===14||m===12)&&(d=!0,u=f[f.length-1].format,h--);let p=[],_=[],g=[],T=[],b=[],R=[],S=[],I={};for(let L=0;L1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e{fI();Wc();ih=class extends th{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;let i=this._engine,r=this._context,s=e._hardwareTexture;if(s&&e._autoMSAAManagement&&this._MSAAFramebuffer){let a=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,ns(e.format)?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,r.RENDERBUFFER,s.getMSAARenderBuffer()),i._bindUnboundFramebuffer(a)}}constructor(e,t,i,r,s){super(e,t,i,r),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=s}_cloneRenderTargetWrapper(){let e;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,r=1,s=14,a){if(this._depthStencilBuffer){let o=this._engine,l=o._currentFramebuffer,c=this._context;o._bindUnboundFramebuffer(this._framebuffer),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.STENCIL_ATTACHMENT,c.RENDERBUFFER,null),o._bindUnboundFramebuffer(l),c.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,t,i,r,s,a)}shareDepth(e){super.shareDepth(e);let t=this._context,i=this._depthStencilBuffer,r=e._MSAAFramebuffer||e._framebuffer,s=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;let a=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;s._bindUnboundFramebuffer(r),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),s._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,r=0){var f,d,h,u;let s=e._hardwareTexture;if(!s)return;let a=this._framebuffer,o=this._engine,l=o._currentFramebuffer;o._bindUnboundFramebuffer(a);let c;if(o.webGLVersion>1){let m=this._context;c=m["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(i=(d=i!=null?i:(f=this.layerIndices)==null?void 0:f[t])!=null?d:0,m.framebufferTextureLayer(m.FRAMEBUFFER,c,s.underlyingResource,r,i)):e.isCube?(i=(u=i!=null?i:(h=this.faceIndices)==null?void 0:h[t])!=null?u:0,m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_CUBE_MAP_POSITIVE_X+i,s.underlyingResource,r)):m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_2D,s.underlyingResource,r)}else{let m=this._context;c=m["COLOR_ATTACHMENT"+t+"_WEBGL"];let p=i!==void 0?m.TEXTURE_CUBE_MAP_POSITIVE_X+i:m.TEXTURE_2D;m.framebufferTexture2D(m.FRAMEBUFFER,c,p,s.underlyingResource,r)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){let m=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),m.framebufferRenderbuffer(m.FRAMEBUFFER,c,m.RENDERBUFFER,s.getMSAARenderBuffer())}o._bindUnboundFramebuffer(l)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){var r,s;if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;let i=(s=(r=this._attachments)==null?void 0:r.length)!=null?s:this.textures.length;for(let a=0;a{ii();fe.prototype.createDepthStencilTexture=function(n,e,t){if(e.isCube){let i=n.width||n;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(n,e,t)}});var hI=A(()=>{_r();ze();Ji();dI();Wc();p_();We.prototype._createHardwareRenderTargetWrapper=function(n,e,t){let i=new ih(n,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};We.prototype.createRenderTargetTexture=function(n,e){var p,_;let t=this._createHardwareRenderTargetWrapper(!1,!1,n),i=!0,r=!1,s=!1,a,o=1,l;e!==void 0&&typeof e=="object"&&(i=(p=e.generateDepthBuffer)!=null?p:!0,r=!!e.generateStencilBuffer,s=!!e.noColorAttachment,a=e.colorAttachment,o=(_=e.samples)!=null?_:1,l=e.label);let c=a||(s?null:this._createInternalTexture(n,e,!0,5)),f=n.width||n,d=n.height||n,h=this._currentFramebuffer,u=this._gl,m=u.createFramebuffer();if(this._bindUnboundFramebuffer(m),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(r,i,f,d),c&&!c.is2DArray&&!c.is3D&&u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,c._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(h),t.label=l!=null?l:"RenderTargetWrapper",t._framebuffer=m,t._generateDepthBuffer=i,t._generateStencilBuffer=r,t.setTextures(c),!a)this.updateRenderTargetTextureSampleCount(t,o);else if(t._samples=a.samples,a.samples>1){let g=a._hardwareTexture.getMSAARenderBuffer(0);t._MSAAFramebuffer=u.createFramebuffer(),this._bindUnboundFramebuffer(t._MSAAFramebuffer),u.framebufferRenderbuffer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.RENDERBUFFER,g),this._bindUnboundFramebuffer(null)}return t};We.prototype._createDepthStencilTexture=function(n,e,t){var u;let i=this._gl,r=n.layers||0,s=n.depth||0,a=i.TEXTURE_2D;r!==0?a=i.TEXTURE_2D_ARRAY:s!==0&&(a=i.TEXTURE_3D);let o=new bt(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return W.Error("Depth texture is not supported by your browser or hardware."),o;let l={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(a,o,!0),this._setupDepthStencilTexture(o,n,l.comparisonFunction===0?!1:l.bilinearFiltering,l.comparisonFunction,l.samples),l.depthTextureFormat!==void 0){if(l.depthTextureFormat!==15&&l.depthTextureFormat!==16&&l.depthTextureFormat!==17&&l.depthTextureFormat!==13&&l.depthTextureFormat!==14&&l.depthTextureFormat!==18)return W.Error(`Depth texture ${l.depthTextureFormat} format is not supported.`),o;o.format=l.depthTextureFormat}else o.format=l.generateStencil?13:16;let c=ns(o.format),f=this._getWebGLTextureTypeFromDepthTextureFormat(o.format),d=c?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,h=this._getInternalFormatFromDepthTextureFormat(o.format,!0,c);return o.is2DArray?i.texImage3D(a,0,h,o.width,o.height,r,0,d,f,null):o.is3D?i.texImage3D(a,0,h,o.width,o.height,s,0,d,f,null):i.texImage2D(a,0,h,o.width,o.height,0,d,f,null),this._bindTextureDirectly(a,null),this._internalTexturesCache.push(o),t._depthStencilBuffer&&(i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),this._bindUnboundFramebuffer((u=t._MSAAFramebuffer)!=null?u:t._framebuffer),t._generateStencilBuffer=c,t._depthStencilTextureWithStencil=c,t._depthStencilBuffer=this._setupFramebufferDepthAttachments(t._generateStencilBuffer,t._generateDepthBuffer,t.width,t.height,t.samples,o.format),this._bindUnboundFramebuffer(null),o};We.prototype.updateRenderTargetTextureSampleCount=function(n,e){var s,a;if(this.webGLVersion<2||!n)return 1;if(n.samples===e)return e;let t=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),n._depthStencilBuffer&&(t.deleteRenderbuffer(n._depthStencilBuffer),n._depthStencilBuffer=null),n._MSAAFramebuffer&&(t.deleteFramebuffer(n._MSAAFramebuffer),n._MSAAFramebuffer=null);let i=(s=n.texture)==null?void 0:s._hardwareTexture;if(i==null||i.releaseMSAARenderBuffers(),n.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){let o=t.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");n._MSAAFramebuffer=o,this._bindUnboundFramebuffer(n._MSAAFramebuffer);let l=this._createRenderBuffer(n.texture.width,n.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(n.texture.type,n.texture.format,n.texture._useSRGBBuffer),t.COLOR_ATTACHMENT0,!1);if(!l)throw new Error("Unable to create multi sampled framebuffer");i==null||i.addMSAARenderBuffer(l)}this._bindUnboundFramebuffer((a=n._MSAAFramebuffer)!=null?a:n._framebuffer),n.texture&&(n.texture.samples=e),n._samples=e;let r=n._depthStencilTexture?n._depthStencilTexture.format:void 0;return n._depthStencilBuffer=this._setupFramebufferDepthAttachments(n._generateStencilBuffer,n._generateDepthBuffer,n.width,n.height,e,r),this._bindUnboundFramebuffer(null),e};We.prototype._setupDepthStencilTexture=function(n,e,t,i,r=1){var h,u;let s=(h=e.width)!=null?h:e,a=(u=e.height)!=null?u:e,o=e.layers||0,l=e.depth||0;n.baseWidth=s,n.baseHeight=a,n.width=s,n.height=a,n.is2DArray=o>0,n.depth=o||l,n.isReady=!0,n.samples=r,n.generateMipMaps=!1,n.samplingMode=t?2:1,n.type=0,n._comparisonFunction=i;let c=this._gl,f=this._getTextureTarget(n),d=this._getSamplingParameters(n.samplingMode,!1);c.texParameteri(f,c.TEXTURE_MAG_FILTER,d.mag),c.texParameteri(f,c.TEXTURE_MIN_FILTER,d.min),c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),this.webGLVersion>1&&(i===0?(c.texParameteri(f,c.TEXTURE_COMPARE_FUNC,515),c.texParameteri(f,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(f,c.TEXTURE_COMPARE_FUNC,i),c.texParameteri(f,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE)))}});var uI=A(()=>{Ji();We.prototype.setDepthStencilTexture=function(n,e,t,i){n!==void 0&&(e&&(this._boundUniforms[n]=e),!t||!t.depthStencilTexture?this._setTexture(n,null,void 0,void 0,i):this._setTexture(n,t,!1,!0,i))}});var mI=A(()=>{_r();ze();Ji();We.prototype.createRenderTargetCubeTexture=function(n,e){let t=this._createHardwareRenderTargetWrapper(!1,!0,n),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);let r=this._gl,s=new bt(this,5);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,s,!0);let a=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,W.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,a.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,a.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(let l=0;l<6;l++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),n,n,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);let o=r.createFramebuffer();return this._bindUnboundFramebuffer(o),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,n,n),i.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),t._framebuffer=o,t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=i.generateStencilBuffer,s.width=n,s.height=n,s.isReady=!0,s.isCube=!0,s.samples=1,s.generateMipMaps=i.generateMipMaps,s.samplingMode=i.samplingMode,s.type=i.type,s.format=i.format,this._internalTexturesCache.push(s),t.setTextures(s),t}});var pI,tl,Wt,Ye,Ci=A(()=>{pI=.45454545454545453,tl=2.2,Wt=(1+Math.sqrt(5))/2,Ye=.001});function Ei(n,e){let t=[];for(let i=0;i{let s=r.previous;if(!s)return;let a=r.next;a?(s.next=a,a.previous=s):(s.next=void 0,n[e]=s),r.next=void 0,r.previous=void 0}}function rh(n,e){let t=hV.map(i=>dV(n,i,e));return()=>{for(let i of t)i==null||i()}}var hV,Ln=A(()=>{hV=["push","splice","pop","shift","unshift"]});function je(n,e){_I[n]=e}function Ai(n){return _I[n]}var _I,Lt=A(()=>{_I={}});function ut(n,e,t=1401298e-51){return Math.abs(n-e)<=t}function Ft(n,e){return n===e?n:Math.random()*(e-n)+n}function tn(n,e,t){return n+(e-n)*t}function gI(n,e,t,i,r){let s=r*r,a=r*s,o=2*a-3*s+1,l=-2*a+3*s,c=a-2*s+r,f=a-s;return n*o+t*l+e*c+i*f}function Ke(n,e=0,t=1){return Math.min(t,Math.max(e,n))}function EI(n){return n-=Math.PI*2*Math.floor((n+Math.PI)/(Math.PI*2)),n}function rn(n){let e=n.toString(16);return n<=15?("0"+e).toUpperCase():e.toUpperCase()}function vI(n){if(Math.log2)return Math.floor(Math.log2(n));if(n<0)return NaN;if(n===0)return-1/0;let e=0;if(n<1){for(;n<1;)e++,n=n*2;e=-e}else if(n>1)for(;n>1;)e++,n=Math.floor(n/2);return e}function nh(n,e){let t=n%e;return t===0?e:nh(e,t)}var bi=A(()=>{});function TI(n){n.updateFlag=il._UpdateFlagSeed++}function __(n,e,t,i=0){let r=n.asArray(),s=e.asArray(),a=r[0],o=r[1],l=r[2],c=r[3],f=r[4],d=r[5],h=r[6],u=r[7],m=r[8],p=r[9],_=r[10],g=r[11],T=r[12],b=r[13],R=r[14],S=r[15],I=s[0],x=s[1],P=s[2],L=s[3],y=s[4],B=s[5],w=s[6],H=s[7],O=s[8],V=s[9],X=s[10],j=s[11],Q=s[12],$=s[13],q=s[14],z=s[15];t[i]=a*I+o*y+l*O+c*Q,t[i+1]=a*x+o*B+l*V+c*$,t[i+2]=a*P+o*w+l*X+c*q,t[i+3]=a*L+o*H+l*j+c*z,t[i+4]=f*I+d*y+h*O+u*Q,t[i+5]=f*x+d*B+h*V+u*$,t[i+6]=f*P+d*w+h*X+u*q,t[i+7]=f*L+d*H+h*j+u*z,t[i+8]=m*I+p*y+_*O+g*Q,t[i+9]=m*x+p*B+_*V+g*$,t[i+10]=m*P+p*w+_*X+g*q,t[i+11]=m*L+p*H+_*j+g*z,t[i+12]=T*I+b*y+R*O+S*Q,t[i+13]=T*x+b*B+R*V+S*$,t[i+14]=T*P+b*w+R*X+S*q,t[i+15]=T*L+b*H+R*j+S*z}function lo(n,e,t,i=0){__(n,e,t.asArray(),i),TI(t)}function SI(n,e,t=0){let i=n.asArray();e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15]}function Hc(n,e){let t=g_(n,e.asArray());return t&&TI(e),t}function g_(n,e){let t=n.asArray(),i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],l=t[5],c=t[6],f=t[7],d=t[8],h=t[9],u=t[10],m=t[11],p=t[12],_=t[13],g=t[14],T=t[15],b=u*T-g*m,R=h*T-_*m,S=h*g-_*u,I=d*T-p*m,x=d*g-u*p,P=d*_-p*h,L=+(l*b-c*R+f*S),y=-(o*b-c*I+f*x),B=+(o*R-l*I+f*P),w=-(o*S-l*x+c*P),H=i*L+r*y+s*B+a*w;if(H===0)return!1;let O=1/H,V=c*T-g*f,X=l*T-_*f,j=l*g-_*c,Q=o*T-p*f,$=o*g-p*c,q=o*_-p*l,z=c*m-u*f,K=l*m-h*f,J=l*u-h*c,te=o*m-d*f,Pe=o*u-d*c,ge=o*h-d*l,me=-(r*b-s*R+a*S),se=+(i*b-s*I+a*x),le=-(i*R-r*I+a*P),xe=+(i*S-r*x+s*P),ce=+(r*V-s*X+a*j),he=-(i*V-s*Q+a*$),ke=+(i*X-r*Q+a*q),$e=-(i*j-r*$+s*q),Fe=-(r*z-s*K+a*J),Xe=+(i*z-s*te+a*Pe),xt=-(i*K-r*te+a*ge),Dt=+(i*J-r*Pe+s*ge);return e[0]=L*O,e[1]=me*O,e[2]=ce*O,e[3]=Fe*O,e[4]=y*O,e[5]=se*O,e[6]=he*O,e[7]=Xe*O,e[8]=B*O,e[9]=le*O,e[10]=ke*O,e[11]=xt*O,e[12]=w*O,e[13]=xe*O,e[14]=$e*O,e[15]=Dt*O,!0}var il,E_=A(()=>{il=class{};il._UpdateFlagSeed=0});var Wi,_e,v,vt,Ae,G,Se,k,co,ve=A(()=>{Ci();Ln();Lt();a_();At();bi();E_();Wi=n=>parseInt(n.toString().replace(/\W/g,"")),_e=class n{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=Wi(this.x),t=Wi(this.y),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 n.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 n(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 n(this.x+e.x,this.y+e.y)}subtract(e){return new n(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 n(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 n(this.x*e,this.y*t)}divide(e){return new n(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 n(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 n(-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 n(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=Ye){return e&&ut(this.x,e.x,t)&&ut(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new n(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 n(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new n)}rotateToRef(e,t){let i=Math.cos(e),r=Math.sin(e);return t.x=i*this.x-r*this.y,t.y=r*this.x+i*this.y,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n;return this.normalizeToRef(e),e}normalizeToRef(e){let t=this.length();return t===0&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new n(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new n(0,0)}static One(){return new n(1,1)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t))}static get ZeroReadOnly(){return n._ZeroReadOnly}static FromArray(e,t=0){return new n(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,r,s){let a=s*s,o=s*a,l=.5*(2*t.x+(-e.x+i.x)*s+(2*e.x-5*t.x+4*i.x-r.x)*a+(-e.x+3*t.x-3*i.x+r.x)*o),c=.5*(2*t.y+(-e.y+i.y)*s+(2*e.y-5*t.y+4*i.y-r.y)*a+(-e.y+3*t.y-3*i.y+r.y)*o);return new n(l,c)}static ClampToRef(e,t,i,r){return r.x=Ke(e.x,t.x,i.x),r.y=Ke(e.y,t.y,i.y),r}static Clamp(e,t,i){let r=Ke(e.x,t.x,i.x),s=Ke(e.y,t.y,i.y);return new n(r,s)}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.x*l+i.x*c+t.x*f+r.x*d,u=e.y*l+i.y*c+t.y*f+r.y*d;return new n(h,u)}static Hermite1stDerivative(e,t,i,r,s){return this.Hermite1stDerivativeToRef(e,t,i,r,s,new n)}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;return a.x=(o-s)*6*e.x+(3*o-4*s+1)*t.x+(-o+s)*6*i.x+(3*o-2*s)*r.x,a.y=(o-s)*6*e.y+(3*o-4*s+1)*t.y+(-o+s)*6*i.y+(3*o-2*s)*r.y,a}static Lerp(e,t,i){return n.LerpToRef(e,t,i,new n)}static LerpToRef(e,t,i,r){return r.x=e.x+(t.x-e.x)*i,r.y=e.y+(t.y-e.y)*i,r}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){let i=e.xt.x?e.x:t.x,r=e.y>t.y?e.y:t.y;return new n(i,r)}static Transform(e,t){return n.TransformToRef(e,t,new n)}static TransformToRef(e,t,i){let r=t.m,s=e.x*r[0]+e.y*r[4]+r[12],a=e.x*r[1]+e.y*r[5]+r[13];return i.x=s,i.y=a,i}static PointInTriangle(e,t,i,r){let s=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),a=s<0?-1:1,o=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*a,l=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*a;return o>0&&l>0&&o+l<2*s*a}static Distance(e,t){return Math.sqrt(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y;return i*i+r*r}static Center(e,t){return n.CenterToRef(e,t,new n)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){let r=n.DistanceSquared(t,i);if(r===0)return n.Distance(e,t);let s=i.subtract(t),a=Math.max(0,Math.min(1,n.Dot(e.subtract(t),s)/r)),o=t.add(s.multiplyByFloats(a,a));return n.Distance(e,o)}};_e._V8PerformanceHack=new _e(.5,.5);_e._ZeroReadOnly=_e.Zero();Object.defineProperties(_e.prototype,{dimension:{value:[2]},rank:{value:1}});v=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=Wi(this._x),t=Wi(this._y),i=Wi(this._z),r=e;return r=r*397^t,r=r*397^i,r}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 n.FromArrayToRef(e,t,this),this}toQuaternion(){return Ae.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 n(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 n(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 n(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._isDirty=!0,r}negate(){return new n(-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 n(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){let t=this.length(),i=Math.acos(this._y/t),r=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;let s=t*Math.sin(i)*Math.cos(r),a=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(r);return e.set(s,a,o),e}applyRotationQuaternionToRef(e,t){let i=this._x,r=this._y,s=this._z,a=e._x,o=e._y,l=e._z,c=e._w,f=2*(o*s-l*r),d=2*(l*i-a*s),h=2*(a*r-o*i);return t._x=i+c*f+o*h-l*d,t._y=r+c*d+l*f-a*h,t._z=s+c*h+a*d-o*f,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new n)}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 n)}projectOnPlaneToRef(e,t,i){let r=e.normal,s=e.d,a=Se.Vector3[0];this.subtractToRef(t,a),a.normalize();let o=n.Dot(a,r);if(Math.abs(o)<1e-10)i.setAll(1/0);else{let l=-(n.Dot(t,r)+s)/o,c=a.scaleInPlace(l);t.addToRef(c,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=Ye){return e&&ut(this._x,e._x,t)&&ut(this._y,e._y,t)&&ut(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 n(this._x*e,this._y*t,this._z*i)}divide(e){return new n(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 ethis._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){let t=Math.abs(this._x),i=Math.abs(this._y);if(!ut(t,i,e))return!0;let r=Math.abs(this._z);return!ut(t,r,e)||!ut(i,r,e)}get isNonUniform(){let e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;let 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 n(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 n(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;let t=Se.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(Se.Matrix[0]),n.TransformCoordinatesToRef(this,Se.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,Se.Vector3[0]),Se.Vector3[0].rotateByQuaternionToRef(e,Se.Vector3[0]),t.addToRef(Se.Vector3[0],i),i}cross(e){return n.CrossToRef(this,e,new n)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let 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 n(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,r){let s=n.Dot(e,i),a=n.Dot(t,i);return(s-r)/(s-a)}static GetAngleBetweenVectors(e,t,i){let r=e.normalizeToRef(Se.Vector3[1]),s=t.normalizeToRef(Se.Vector3[2]),a=n.Dot(r,s);a=Ke(a,-1,1);let o=Math.acos(a),l=Se.Vector3[3];return n.CrossToRef(r,s,l),n.Dot(l,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,t,i){Se.Vector3[0].copyFrom(e);let r=Se.Vector3[0];Se.Vector3[1].copyFrom(t);let s=Se.Vector3[1];Se.Vector3[2].copyFrom(i);let a=Se.Vector3[2],o=Se.Vector3[3],l=Se.Vector3[4];r.normalize(),s.normalize(),a.normalize(),n.CrossToRef(a,r,o),n.CrossToRef(o,a,l);let c=Math.atan2(n.Dot(s,o),n.Dot(s,l));return EI(c)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){let r=k.Vector3[0];return t.subtractToRef(e,r),i._y=Math.atan2(r.x,r.z)||0,i._x=Math.atan2(Math.sqrt(r.x**2+r.z**2),r.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){let i=n.Zero();return n.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,r){i=Ke(i,0,1);let s=Se.Vector3[0],a=Se.Vector3[1];s.copyFrom(e);let o=s.length();s.normalizeFromLength(o),a.copyFrom(t);let l=a.length();a.normalizeFromLength(l);let c=n.Dot(s,a),f,d;if(c<1-Ye){let h=Math.acos(c),u=1/Math.sin(h);f=Math.sin((1-i)*h)*u,d=Math.sin(i*h)*u}else f=1-i,d=i;return s.scaleInPlace(f),a.scaleInPlace(d),r.copyFrom(s).addInPlace(a),r.scaleInPlace(tn(o,l,i)),r}static SmoothToRef(e,t,i,r,s){return n.SlerpToRef(e,t,r===0?1:i/r,s),s}static FromArray(e,t=0){return new n(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return n.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 n.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,r){return r.copyFromFloats(e,t,i),r}static Zero(){return new n(0,0,0)}static One(){return new n(1,1,1)}static Up(){return new n(0,1,0)}static get UpReadOnly(){return n._UpReadOnly}static get DownReadOnly(){return n._DownReadOnly}static get RightReadOnly(){return n._RightReadOnly}static get LeftReadOnly(){return n._LeftReadOnly}static get LeftHandedForwardReadOnly(){return n._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return n._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return n._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return n._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return n._ZeroReadOnly}static get OneReadOnly(){return n._OneReadOnly}static Down(){return new n(0,-1,0)}static Forward(e=!1){return new n(0,0,e?-1:1)}static Backward(e=!1){return new n(0,0,e?1:-1)}static Right(){return new n(1,0,0)}static Left(){return new n(-1,0,0)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t),Ft(e,t))}static TransformCoordinates(e,t){let i=n.Zero();return n.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,s){let a=r.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],l=e*a[1]+t*a[5]+i*a[9]+a[13],c=e*a[2]+t*a[6]+i*a[10]+a[14],f=1/(e*a[3]+t*a[7]+i*a[11]+a[15]);return s._x=o*f,s._y=l*f,s._z=c*f,s._isDirty=!0,s}static TransformNormal(e,t){let i=n.Zero();return n.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,r,s){let a=r.m;return s._x=e*a[0]+t*a[4]+i*a[8],s._y=e*a[1]+t*a[5]+i*a[9],s._z=e*a[2]+t*a[6]+i*a[10],s._isDirty=!0,s}static CatmullRom(e,t,i,r,s){let a=s*s,o=s*a,l=.5*(2*t._x+(-e._x+i._x)*s+(2*e._x-5*t._x+4*i._x-r._x)*a+(-e._x+3*t._x-3*i._x+r._x)*o),c=.5*(2*t._y+(-e._y+i._y)*s+(2*e._y-5*t._y+4*i._y-r._y)*a+(-e._y+3*t._y-3*i._y+r._y)*o),f=.5*(2*t._z+(-e._z+i._z)*s+(2*e._z-5*t._z+4*i._z-r._z)*a+(-e._z+3*t._z-3*i._z+r._z)*o);return new n(l,c,f)}static Clamp(e,t,i){let r=new n;return n.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){let s=e._x;s=s>i._x?i._x:s,s=si._y?i._y:a,a=ai._z?i._z:o,o=o0&&y<0?(w.copyFrom(a),H=t,O=i):y>0&&B<0?(w.copyFrom(l),H=i,O=r):(w.copyFrom(o).scaleInPlace(-1),H=r,O=t);let V=Se.Vector3[9],X=Se.Vector3[4];if(H.subtractToRef(T,I),O.subtractToRef(T,V),n.CrossToRef(I,V,X),!(n.Dot(X,c)<0))return s.copyFrom(T),Math.abs(p*_);let Q=Se.Vector3[5];n.CrossToRef(w,X,Q),Q.normalize();let $=Se.Vector3[9];$.copyFrom(H).subtractInPlace(T);let q=$.length();if(qthis._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,r){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(r,this._w),this}maximizeInPlaceFromFloats(e,t,i,r){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(r,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 n(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 n(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 n)}normalizeToRef(e){let 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 n(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,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}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 n(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 n.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,r,s){return s.x=e,s.y=t,s.z=i,s.w=r,s}static Zero(){return new n(0,0,0,0)}static One(){return new n(1,1,1,1)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.x=Ft(e,t),i.y=Ft(e,t),i.z=Ft(e,t),i.w=Ft(e,t),i}static Clamp(e,t,i){return n.ClampToRef(e,t,i,new n)}static ClampToRef(e,t,i,r){return r.x=Ke(e.x,t.x,i.x),r.y=Ke(e.y,t.y,i.y),r.z=Ke(e.z,t.z,i.z),r.w=Ke(e.w,t.w,i.w),r}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return n._ZeroReadOnly}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){let i=new n;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){let i=new n;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,a=e.w-t.w;return i*i+r*r+s*s+a*a}static Center(e,t){return n.CenterToRef(e,t,new n)}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 n.TransformCoordinatesToRef(e,t,new n)}static TransformCoordinatesToRef(e,t,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,s){let a=r.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],l=e*a[1]+t*a[5]+i*a[9]+a[13],c=e*a[2]+t*a[6]+i*a[10]+a[14],f=e*a[3]+t*a[7]+i*a[11]+a[15];return s.x=o,s.y=l,s.z=c,s.w=f,s}static TransformNormal(e,t){return n.TransformNormalToRef(e,t,new n)}static TransformNormalToRef(e,t,i){let r=t.m,s=e.x*r[0]+e.y*r[4]+e.z*r[8],a=e.x*r[1]+e.y*r[5]+e.z*r[9],o=e.x*r[2]+e.y*r[6]+e.z*r[10];return i.x=s,i.y=a,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,r,s,a){let o=s.m;return a.x=e*o[0]+t*o[4]+i*o[8],a.y=e*o[1]+t*o[5]+i*o[9],a.z=e*o[2]+t*o[6]+i*o[10],a.w=r,a}static FromVector3(e,t=0){return new n(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}};vt._V8PerformanceHack=new vt(.5,.5,.5,.5);vt._ZeroReadOnly=vt.Zero();Object.defineProperties(vt.prototype,{dimension:{value:[4]},rank:{value:1}});Ae=class n{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,r=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=r}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=Wi(this._x),t=Wi(this._y),i=Wi(this._z),r=Wi(this._w),s=e;return s=s*397^t,s=s*397^i,s=s*397^r,s}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 n.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=Ye){return e&&ut(this._x,e._x,t)&&ut(this._y,e._y,t)&&ut(this._z,e._z,t)&&ut(this._w,e._w,t)}isApprox(e,t=Ye){return e&&(ut(this._x,e._x,t)&&ut(this._y,e._y,t)&&ut(this._z,e._z,t)&&ut(this._w,e._w,t)||ut(this._x,-e._x,t)&&ut(this._y,-e._y,t)&&ut(this._z,-e._z,t)&&ut(this._w,-e._w,t))}clone(){return new n(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,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._isDirty=!0,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new n(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,r){return this._x+=e,this._y+=t,this._z+=i,this._w+=r,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,r){return this.subtractFromFloatsToRef(e,t,i,r,new n)}subtractFromFloatsToRef(e,t,i,r,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._w=this._w-r,s._isDirty=!0,s}subtract(e){return new n(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 n(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){let t=new n(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){let i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,r=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,s=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,a=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,r,s,a),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,r){return this._x*=e,this._y*=t,this._z*=i,this._w*=r,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 n)}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,r){return this._x===e&&this._y===t&&this._z===i&&this._w===r}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 n(-this._x,-this._y,-this._z,this._w)}invert(){let e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();let 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(){let e=new n(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){let t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){let e=v.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){let t=this._z,i=this._x,r=this._y,s=this._w,a=r*t-i*s,o=.4999999;if(a<-o)e._y=2*Math.atan2(r,s),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>o)e._y=2*Math.atan2(r,s),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{let l=s*s,c=t*t,f=i*i,d=r*r;e._z=Math.atan2(2*(i*r+t*s),-c-f+d+l),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(t*i+r*s),c-f-d+l),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){let t=this._z,i=this._x,r=this._y,s=this._w,a=Math.sqrt(i*i+r*r),o=Math.sqrt(t*t+s*s),l=2*Math.atan2(a,o),c=2*Math.atan2(t,s),f=2*Math.atan2(r,i),d=(c+f)/2,h=(c-f)/2;return e.set(h,l,d),e}toRotationMatrix(e){return G.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return n.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){let e=v.Zero(),t=this.toAxisAngleToRef(e);return{axis:e,angle:t}}toAxisAngleToRef(e){let t,i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),r=this._w;return i>0?(t=2*Math.atan2(i,r),e.set(this._x/i,this._y/i,this._z/i)):(t=0,e.set(1,0,0)),t}static FromRotationMatrix(e){let t=new n;return n.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){let i=e.m,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],f=i[2],d=i[6],h=i[10],u=r+l+h,m;return u>0?(m=.5/Math.sqrt(u+1),t._w=.25/m,t._x=(d-c)*m,t._y=(a-f)*m,t._z=(o-s)*m,t._isDirty=!0):r>l&&r>h?(m=2*Math.sqrt(1+r-l-h),t._w=(d-c)/m,t._x=.25*m,t._y=(s+o)/m,t._z=(a+f)/m,t._isDirty=!0):l>h?(m=2*Math.sqrt(1+l-r-h),t._w=(a-f)/m,t._x=(s+o)/m,t._y=.25*m,t._z=(c+d)/m,t._isDirty=!0):(m=2*Math.sqrt(1+h-r-l),t._w=(o-s)/m,t._x=(a+f)/m,t._y=(c+d)/m,t._z=.25*m,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){let r=n.Dot(e,t);return 1-r*r<=i}static SmoothToRef(e,t,i,r,s){let a=r===0?1:i/r;return a=Ke(a,0,1),n.SlerpToRef(e,t,a,s),s}static Zero(){return new n(0,0,0,0)}static Inverse(e){return new n(-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 n(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 n.RotationAxisToRef(e,t,new n)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);let r=Math.sin(t/2)/e.length();return i._x=e._x*r,i._y=e._y*r,i._z=e._z*r,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new n(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,r,s){return s.copyFromFloats(e,t,i,r),s}static FromEulerAngles(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerAnglesToRef(e,t,i,r){return n.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerVector(e){let t=new n;return n.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return n.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,r=Ye){let s=v.Dot(e,t)+1;return sMath.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(v.CrossToRef(e,t,k.Vector3[0]),i.set(k.Vector3[0].x,k.Vector3[0].y,k.Vector3[0].z,s)),i.normalize()}static RotationYawPitchRoll(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){let s=i*.5,a=t*.5,o=e*.5,l=Math.sin(s),c=Math.cos(s),f=Math.sin(a),d=Math.cos(a),h=Math.sin(o),u=Math.cos(o);return r._x=u*f*c+h*d*l,r._y=h*d*c-u*f*l,r._z=u*d*l-h*f*c,r._w=u*d*c+h*f*l,r._isDirty=!0,r}static RotationAlphaBetaGamma(e,t,i){let r=new n;return n.RotationAlphaBetaGammaToRef(e,t,i,r),r}static RotationAlphaBetaGammaToRef(e,t,i,r){let s=(i+e)*.5,a=(i-e)*.5,o=t*.5;return r._x=Math.cos(a)*Math.sin(o),r._y=Math.sin(a)*Math.sin(o),r._z=Math.sin(s)*Math.cos(o),r._w=Math.cos(s)*Math.cos(o),r._isDirty=!0,r}static RotationQuaternionFromAxis(e,t,i){let r=new n(0,0,0,0);return n.RotationQuaternionFromAxisToRef(e,t,i,r),r}static RotationQuaternionFromAxisToRef(e,t,i,r){let s=Se.Matrix[0];return e=e.normalizeToRef(Se.Vector3[0]),t=t.normalizeToRef(Se.Vector3[1]),i=i.normalizeToRef(Se.Vector3[2]),G.FromXYZAxesToRef(e,t,i,s),n.FromRotationMatrixToRef(s,r),r}static FromLookDirectionLH(e,t){let i=new n;return n.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){let r=Se.Matrix[0];return G.LookDirectionLHToRef(e,t,r),n.FromRotationMatrixToRef(r,i),i}static FromLookDirectionRH(e,t){let i=new n;return n.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){let r=Se.Matrix[0];return G.LookDirectionRHToRef(e,t,r),n.FromRotationMatrixToRef(r,i)}static Slerp(e,t,i){let r=n.Identity();return n.SlerpToRef(e,t,i,r),r}static SlerpToRef(e,t,i,r){let s,a,o=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,l=!1;if(o<0&&(l=!0,o=-o),o>.999999)a=1-i,s=l?-i:i;else{let c=Math.acos(o),f=1/Math.sin(c);a=Math.sin((1-i)*c)*f,s=l?-Math.sin(i*c)*f:Math.sin(i*c)*f}return r._x=a*e._x+s*t._x,r._y=a*e._y+s*t._y,r._z=a*e._z+s*t._z,r._w=a*e._w+s*t._w,r._isDirty=!0,r}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e._x*l+i._x*c+t._x*f+r._x*d,u=e._y*l+i._y*c+t._y*f+r._y*d,m=e._z*l+i._z*c+t._z*f+r._z*d,p=e._w*l+i._w*c+t._w*f+r._w*d;return new n(h,u,m,p)}static Hermite1stDerivative(e,t,i,r,s){let a=new n;return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;return a._x=(o-s)*6*e._x+(3*o-4*s+1)*t._x+(-o+s)*6*i._x+(3*o-2*s)*r._x,a._y=(o-s)*6*e._y+(3*o-4*s+1)*t._y+(-o+s)*6*i._y+(3*o-2*s)*r._y,a._z=(o-s)*6*e._z+(3*o-4*s+1)*t._z+(-o+s)*6*i._z+(3*o-2*s)*r._z,a._w=(o-s)*6*e._w+(3*o-4*s+1)*t._w+(-o+s)*6*i._w+(3*o-2*s)*r._w,a._isDirty=!0,a}static Normalize(e){let t=n.Zero();return n.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){let r=new n;return n.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){return r.copyFromFloats(Ke(e.x,t.x,i.x),Ke(e.y,t.y,i.y),Ke(e.z,t.z,i.z),Ke(e.w,t.w,i.w))}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t),Ft(e,t),Ft(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(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,a=e.w-t.w;return i*i+r*r+s*s+a*a}static Center(e,t){return n.CenterToRef(e,t,n.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)}};Ae._V8PerformanceHack=new Ae(.5,.5,.5,.5);Object.defineProperties(Ae.prototype,{dimension:{value:[4]},rank:{value:1}});G=class n{static get Use64Bits(){return ki.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=il._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,r=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:r}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,ki.MatrixTrackPrecisionChange&&ki.MatrixTrackedMatrices.push(this),this._m=new ki.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;let 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;let e=this._m,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],d=e[9],h=e[10],u=e[11],m=e[12],p=e[13],_=e[14],g=e[15],T=h*g-_*u,b=d*g-p*u,R=d*_-p*h,S=f*g-m*u,I=f*_-h*m,x=f*p-m*d,P=+(o*T-l*b+c*R),L=-(a*T-l*S+c*I),y=+(a*b-o*S+c*x),B=-(a*R-o*I+l*x);return t*P+i*L+r*y+s*B}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]} +`+e;return e}}});var ao,h_=A(()=>{ao=class n{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=n._Counter++}};ao._Counter=0});var yn,$d=A(()=>{h_();yn=class extends ao{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}});function oo(n){let e=1;do e*=2;while(en-t?t:e}function aI(n){return n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n++,n}function eh(n){return n=n|n>>1,n=n|n>>2,n=n|n>>4,n=n|n>>8,n=n|n>>16,n-(n>>1)}function $i(n,e,t=2){let i;switch(t){case 1:i=eh(n);break;case 2:i=u_(n);break;case 3:default:i=aI(n);break}return Math.min(i,e)}var Dn=A(()=>{});var tl,m_=A(()=>{tl=class{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(let 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()}}});function p_(n){return n===13||n===14||n===15||n===16||n===17||n===18||n===19}function ss(n){return n===13||n===17||n===18||n===19}var Wc=A(()=>{});var oI={};De(oI,{ThinEngine:()=>We});var __,We,er=A(()=>{no();t_();ii();d_();ze();Lr();nI();sI();$d();Dn();m_();vr();aa();l_();Wc();f_();__=class{},We=class n extends fe{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return Nt.ShadersRepository}static set ShadersRepository(e){Nt.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,r){if(i=i||{},super(t!=null?t:i.antialias,i,r),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 s;if(e.getContext){if(s=e,i.preserveDrawingBuffer===void 0&&(i.preserveDrawingBuffer=!1),i.xrCompatible===void 0&&(i.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();let l=navigator.userAgent;for(let c of n.ExceptionList){let f=c.key,d=c.targets;if(new RegExp(f).test(l)){if(c.capture&&c.captureConstraint){let u=c.capture,m=c.captureConstraint,_=new RegExp(u).exec(l);if(_&&_.length>0&&parseInt(_[_.length-1])>=m)continue}for(let u of d)switch(u){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=()=>{Nd(this._gl)}:(this._onContextLost=l=>{l.preventDefault(),this._contextWasLost=!0,Nd(this._gl),W.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},s.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),s.addEventListener("webglcontextlost",this._onContextLost,!1),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=s.getContext("webgl2",i)||s.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch(l){}if(!this._gl){if(!s)throw new Error("The provided canvas is null or undefined.");try{this._gl=s.getContext("webgl",i)||s.getContext("experimental-webgl",i)}catch(l){throw new Error("WebGL not supported",{cause:l})}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,s=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";let l=this._gl.getContextAttributes();l&&(i.stencil=l.stencil)}this._sharedInit(s),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 l=0;l1?new Jd:new Qd;let a=`Babylon.js v${n.Version}`;W.Log(a+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",a);let o=Ci(this._gl);o.validateShaderPrograms=this.validateShaderPrograms,o.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(let e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){var i;this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),shaderFloatPrecision:0,parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||this._gl.getExtension("OES_standard_derivatives")!==null,maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||this._gl.getExtension("OES_element_index_uint")!==null,fragmentDepthSupported:this._webGLVersion>1||this._gl.getExtension("EXT_frag_depth")!==null,highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),blendFloat:this._gl.getExtension("EXT_float_blend")!==null,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:this._webGLVersion!==1,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1,textureNorm16:!!this._gl.getExtension("EXT_texture_norm16"),blendParametersPerTarget:!1,dualSourceBlending:!1,supportReadWriteStorageTextures:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);let e=this._gl.getExtension("WEBGL_debug_renderer_info");e!=null&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),this._gl.HALF_FLOAT_OES!==36193&&(this._gl.HALF_FLOAT_OES=36193),this._gl.RGBA16F!==34842&&(this._gl.RGBA16F=34842),this._gl.RGBA32F!==34836&&(this._gl.RGBA32F=34836),this._gl.DEPTH24_STENCIL8!==35056&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(this._webGLVersion===1&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=((i=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT))!=null?i: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);let t=this._gl.getExtension("OES_draw_buffers_indexed");if(this._caps.blendParametersPerTarget=!!t,this._alphaState=new el(this._caps.blendParametersPerTarget),t&&(this._gl.blendEquationSeparateIndexed=t.blendEquationSeparateiOES.bind(t),this._gl.blendEquationIndexed=t.blendEquationiOES.bind(t),this._gl.blendFuncSeparateIndexed=t.blendFuncSeparateiOES.bind(t),this._gl.blendFuncIndexed=t.blendFunciOES.bind(t),this._gl.colorMaskIndexed=t.colorMaskiOES.bind(t),this._gl.disableIndexed=t.disableiOES.bind(t),this._gl.enableIndexed=t.enableiOES.bind(t)),this._caps.dualSourceBlending=!!this._gl.getExtension("WEBGL_blend_func_extended"),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_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{let r=this._gl.getExtension("WEBGL_draw_buffers");if(r!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=r.drawBuffersWEBGL.bind(r),this._caps.maxDrawBuffers=this._gl.getParameter(r.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let s=0;s<16;s++)this._gl["COLOR_ATTACHMENT"+s+"_WEBGL"]=r["COLOR_ATTACHMENT"+s+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{let r=this._gl.getExtension("WEBGL_depth_texture");r!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=r.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{let r=this._gl.getExtension("OES_vertex_array_object");r!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{let r=this._gl.getExtension("ANGLE_instanced_arrays");r!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=r.drawArraysInstancedANGLE.bind(r),this._gl.drawElementsInstanced=r.drawElementsInstancedANGLE.bind(r),this._gl.vertexAttribDivisor=r.vertexAttribDivisorANGLE.bind(r)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){let r=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);if(r&&s&&(this._caps.highPrecisionShaderSupported=r.precision!==0&&s.precision!==0,this._caps.shaderFloatPrecision=Math.min(r.precision,s.precision)),!this._shouldUseHighPrecisionShader){let a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.MEDIUM_FLOAT),o=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.MEDIUM_FLOAT);a&&o&&(this._caps.shaderFloatPrecision=Math.min(a.precision,o.precision))}this._caps.shaderFloatPrecision<10&&(this._caps.shaderFloatPrecision=10)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{let r=this._gl.getExtension("EXT_blend_minmax");r!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=r.MAX_EXT,this._gl.MIN=r.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{let r=this._gl.getExtension("EXT_sRGB");r!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:r.SRGB_EXT,SRGB8:r.SRGB_ALPHA_EXT,SRGB8_ALPHA8:r.SRGB_ALPHA_EXT})}if(this._creationOptions){let r=this._creationOptions.forceSRGBBufferSupportState;r!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&r)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let r=0;r=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){let r=e.program,s=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,s,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,r,s,a,o){let l=this._currentBufferPointers[t];if(!l)return;let c=!1;l.active?(l.buffer!==e&&(l.buffer=e,c=!0),l.size!==i&&(l.size=i,c=!0),l.type!==r&&(l.type=r,c=!0),l.normalized!==s&&(l.normalized=s,c=!0),l.stride!==a&&(l.stride=a,c=!0),l.offset!==o&&(l.offset=o,c=!0)):(c=!0,l.active=!0,l.index=t,l.size=i,l.type=r,l.normalized=s,l.stride=a,l.offset=o,l.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),r===this._gl.UNSIGNED_INT||r===this._gl.INT?this._gl.vertexAttribIPointer(t,i,r,a,o):this._gl.vertexAttribPointer(t,i,r,s,a,o))}_bindIndexBufferWithCache(e){e!=null&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,i){let r=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let s=0;s=0){let o=r[s],l=null;if(i&&(l=i[o]),l||(l=e[o]),!l)continue;this._gl.enableVertexAttribArray(a),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[a]=!0);let c=l.getBuffer();c&&(this._vertexAttribPointer(c,a,l.getSize(),l.type,l.normalized,l.byteStride,l.byteOffset),l.getIsInstanced()&&(this._gl.vertexAttribDivisor(a,l.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(c))))}}}recordVertexArrayObject(e,t,i,r){let s=this._gl.createVertexArray();if(!s)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(s),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,r),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),s}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,r,s){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==s){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=s;let a=s.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let o=0;for(let l=0;l=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[l],this._gl.FLOAT,!1,r,o)),o+=i[l]*4}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,i,r){(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i)&&(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i,r)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,i=this._currentInstanceLocations.length;t1||this.isWebGPU)),(o===1&&!this._caps.textureFloatLinearFiltering||o===2&&!this._caps.textureHalfFloatLinearFiltering)&&(l=1),o===1&&!this._caps.textureFloat&&(o=0,W.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));let _=p_(c),g=ss(c),T=this._gl,b=new bt(this,r),R=e.width||e,S=e.height||e,I=e.depth||0,x=e.layers||0,P=this._getSamplingParameters(l,(s||a)&&!_),L=x!==0?T.TEXTURE_2D_ARRAY:I!==0?T.TEXTURE_3D:p?T.TEXTURE_CUBE_MAP:T.TEXTURE_2D,y=_?this._getInternalFormatFromDepthTextureFormat(c,!0,g):this._getRGBABufferInternalSizedFormat(o,c,f),B=_?g?T.DEPTH_STENCIL:T.DEPTH_COMPONENT:this._getInternalFormat(c),w=_?this._getWebGLTextureTypeFromDepthTextureFormat(c):this._getWebGLTextureType(o);if(this._bindTextureDirectly(L,b),x!==0)b.is2DArray=!0,T.texImage3D(L,0,y,R,S,x,0,B,w,null);else if(I!==0)b.is3D=!0,T.texImage3D(L,0,y,R,S,I,0,B,w,null);else if(p){b.isCube=!0;for(let O=0;O<6;O++)T.texImage2D(T.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,y,R,S,0,B,w,null)}else T.texImage2D(L,0,y,R,S,0,B,w,null);if(T.texParameteri(L,T.TEXTURE_MAG_FILTER,P.mag),T.texParameteri(L,T.TEXTURE_MIN_FILTER,P.min),T.texParameteri(L,T.TEXTURE_WRAP_S,T.CLAMP_TO_EDGE),T.texParameteri(L,T.TEXTURE_WRAP_T,T.CLAMP_TO_EDGE),_&&this.webGLVersion>1&&(m===0?(T.texParameteri(L,T.TEXTURE_COMPARE_FUNC,515),T.texParameteri(L,T.TEXTURE_COMPARE_MODE,T.NONE)):(T.texParameteri(L,T.TEXTURE_COMPARE_FUNC,m),T.texParameteri(L,T.TEXTURE_COMPARE_MODE,T.COMPARE_REF_TO_TEXTURE))),(s||a)&&this._gl.generateMipmap(L),this._bindTextureDirectly(L,null),b._useSRGBBuffer=f,b.baseWidth=R,b.baseHeight=S,b.width=R,b.height=S,b.depth=x||I,b.isReady=!0,b.samples=d,b.generateMipMaps=s,b.samplingMode=l,b.type=o,b.format=c,b.label=h,b.comparisonFunction=m,this._internalTexturesCache.push(b),u){let O;if(p_(b.format)?O=this._setupFramebufferDepthAttachments(ss(b.format),b.format!==19,b.width,b.height,d,b.format,!0):O=this._createRenderBuffer(b.width,b.height,d,-1,this._getRGBABufferInternalSizedFormat(b.type,b.format,b._useSRGBBuffer),-1),!O)throw new Error("Unable to create render buffer");b._autoMSAAManagement=!0;let k=b._hardwareTexture;k||(k=b._hardwareTexture=this._createHardwareTexture()),k.addMSAARenderBuffer(O)}return b}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,r,s=3,a=null,o=null,l=null,c=null,f=null,d=null,h,u,m,p){return this._createTextureBase(e,t,i,r,s,a,o,(..._)=>this._prepareWebGLTexture(..._,f),(_,g,T,b,R,S)=>{let I=this._gl,x=T.width===_&&T.height===g;R._creationFlags=m!=null?m:0;let P=this._getTexImageParametersForCreateTexture(R.format,R._useSRGBBuffer);if(x)return I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,T),!1;let L=this._caps.maxTextureSize;if(T.width>L||T.height>L||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=_,this._workingCanvas.height=g,this._workingContext.drawImage(T,0,0,T.width,T.height,0,0,_,g),I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,this._workingCanvas),R.width=_,R.height=g),!1;{let y=new bt(this,2);this._bindTextureDirectly(I.TEXTURE_2D,y,!0),I.texImage2D(I.TEXTURE_2D,0,P.internalFormat,P.format,P.type,T),this._rescaleTexture(y,R,r,P.format,()=>{this._releaseTexture(y),this._bindTextureDirectly(I.TEXTURE_2D,R,!0),S()})}return!0},l,c,f,d,h,u,p)}_getTexImageParametersForCreateTexture(e,t){let i,r;return this.webGLVersion===1?(i=this._getInternalFormat(e,t),r=i):(i=this._getInternalFormat(e,!1),r=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:r,format:i,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,i,r,s){}_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){let r=this._getTextureTarget(t),s=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(r,this._gl.TEXTURE_MAG_FILTER,s.mag,t),this._setTextureParameterInteger(r,this._gl.TEXTURE_MIN_FILTER,s.min),i&&s.hasMipMaps&&(t.generateMipMaps=!0,this._gl.generateMipmap(r)),this._bindTextureDirectly(r,null),t.samplingMode=e}updateTextureDimensions(e,t,i,r=1){}updateTextureWrappingMode(e,t,i=null,r=null){let s=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&r!==null&&(this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(r),e),e._cachedWrapR=r),this._bindTextureDirectly(s,null)}_uploadCompressedDataToTextureDirectly(e,t,i,r,s,a=0,o=0){let l=this._gl,c=l.TEXTURE_2D;if(e.isCube&&(c=l.TEXTURE_CUBE_MAP_POSITIVE_X+a),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=l.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 37809:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;break;case 37810:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;break;case 37811:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;break;case 37812:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;break;case 37813:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;break;case 37814:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;break;case 37815:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;break;case 37816:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;break;case 37817:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;break;case 37818:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;break;case 37819:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;break;case 37820:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;break;case 37821:t=l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;break;case 33776:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1;break}if(e.generateMipMaps){let f=e._hardwareTexture;f.memoryAllocated||(l.texStorage2D(e.isCube?l.TEXTURE_CUBE_MAP:l.TEXTURE_2D,Math.floor(Math.log2(Math.max(i,r)))+1,t,e.width,e.height),f.memoryAllocated=!0),this._gl.compressedTexSubImage2D(c,o,0,0,i,r,t,s)}else this._gl.compressedTexImage2D(c,o,t,i,r,0,s)}_uploadDataToTextureDirectly(e,t,i=0,r=0,s,a=!1){let o=this._gl,l=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),f=s===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(s,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let d=o.TEXTURE_2D;e.isCube&&(d=o.TEXTURE_CUBE_MAP_POSITIVE_X+i);let h=Math.round(Math.log(e.width)*Math.LOG2E),u=Math.round(Math.log(e.height)*Math.LOG2E),m=a?e.width:Math.pow(2,Math.max(h-r,0)),p=a?e.height:Math.pow(2,Math.max(u-r,0));o.texImage2D(d,r,f,m,p,0,c,l,t)}updateTextureData(e,t,i,r,s,a,o=0,l=0,c=!1){let f=this._gl,d=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let u=f.TEXTURE_2D,m=f.TEXTURE_2D;e.isCube&&(m=f.TEXTURE_CUBE_MAP_POSITIVE_X+o,u=f.TEXTURE_CUBE_MAP),this._bindTextureDirectly(u,e,!0),f.texSubImage2D(m,l,i,r,s,a,h,d,t),c&&this._gl.generateMipmap(m),this._bindTextureDirectly(u,null)}_uploadArrayBufferViewToTexture(e,t,i=0,r=0){let s=this._gl,a=e.isCube?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D;this._bindTextureDirectly(a,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(a,null,!0)}_prepareWebGLTextureContinuation(e,t,i,r,s){let a=this._gl;if(!a)return;let o=this._getSamplingParameters(s,!i);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,o.mag),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,o.min),!i&&!r&&a.generateMipmap(a.TEXTURE_2D),this._bindTextureDirectly(a.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,i,r,s,a,o,l,c,f){let d=this.getCaps().maxTextureSize,h=Math.min(d,this.needPOTTextures?$i(r.width,d):r.width),u=Math.min(d,this.needPOTTextures?$i(r.height,d):r.height),m=this._gl;if(m){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(m.TEXTURE_2D,e,!0),this._unpackFlipY(s===void 0?!0:!!s),e.baseWidth=r.width,e.baseHeight=r.height,e.width=h,e.height=u,e.isReady=!0,e.type=e.type!==-1?e.type:0,e.format=e.format!==-1?e.format:f!=null?f:t===".jpg"&&!e._useSRGBBuffer?4:5,!l(h,u,r,t,e,()=>{this._prepareWebGLTextureContinuation(e,i,a,o,c)})&&this._prepareWebGLTextureContinuation(e,i,a,o,c)}}_getInternalFormatFromDepthTextureFormat(e,t,i){let r=this._gl;if(!t)return r.STENCIL_INDEX8;let a=i?r.DEPTH_STENCIL:r.DEPTH_COMPONENT;return this.webGLVersion>1?e===15?a=r.DEPTH_COMPONENT16:e===16?a=r.DEPTH_COMPONENT24:e===17||e===13?a=i?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24:e===14?a=r.DEPTH_COMPONENT32F:e===18&&(a=i?r.DEPTH32F_STENCIL8:r.DEPTH_COMPONENT32F):a=r.DEPTH_COMPONENT16,a}_getWebGLTextureTypeFromDepthTextureFormat(e){let t=this._gl,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,r,s=1,a,o=!1){let l=this._gl;a=a!=null?a:e?13:14;let c=this._getInternalFormatFromDepthTextureFormat(a,t,e);return e&&t?this._createRenderBuffer(i,r,s,l.DEPTH_STENCIL,c,o?-1:l.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,r,s,c,c,o?-1:l.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,r,s,c,c,o?-1:l.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,r,s,a,o=!0){let c=this._gl.createRenderbuffer();return this._updateRenderBuffer(c,e,t,i,r,s,a,o)}_updateRenderBuffer(e,t,i,r,s,a,o,l=!0){let c=this._gl;return c.bindRenderbuffer(c.RENDERBUFFER,e),r>1&&c.renderbufferStorageMultisample?c.renderbufferStorageMultisample(c.RENDERBUFFER,r,a,t,i):c.renderbufferStorage(c.RENDERBUFFER,s,t,i),o!==-1&&c.framebufferRenderbuffer(c.FRAMEBUFFER,o,c.RENDERBUFFER,e),l&&c.bindRenderbuffer(c.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();let 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&&(wR(e,this._gl),this._currentProgram=e)}bindSamplers(e){let t=e.getPipelineContext();this._setProgram(t.program);let i=e.getSamplers();for(let r=0;r-1;if(i&&a&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||r){if(this._activateCurrentTexture(),t&&t.isMultiview)throw W.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,(c=(l=t==null?void 0:t._hardwareTexture)==null?void 0:l.underlyingResource)!=null?c:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(s=!0,this._activateCurrentTexture());return a&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),s}_bindTexture(e,t,i){if(e===void 0)return;t&&(t._associatedChannel=e),this._activeChannel=e;let r=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(r,t)}unbindAllTextures(){for(let e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,i,r){e!==void 0&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))}_bindSamplerUniformToChannel(e,t){let 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,r=!1,s=""){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;let c=t.getInternalTexture();c&&(c._associatedChannel=e),t.update()}else if(t.delayLoadState===4)return t.delayLoad(),!1;let a;r?a=t.depthStencilTexture:t.isReady()?a=t.getInternalTexture():t.isCube?a=this.emptyCubeTexture:t.is3D?a=this.emptyTexture3D:t.is2DArray?a=this.emptyTexture2DArray:a=this.emptyTexture,!i&&a&&(a._associatedChannel=e);let o=!0;this._boundTexturesCache[e]===a&&(i||this._bindSamplerUniformToChannel(a._associatedChannel,e),o=!1),this._activeChannel=e;let l=this._getTextureTarget(a);if(o&&this._bindTextureDirectly(l,a,i),a&&!a.isMultiview){if(a.isCube&&a._cachedCoordinatesMode!==t.coordinatesMode){a._cachedCoordinatesMode=t.coordinatesMode;let c=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=c,t.wrapV=c}a._cachedWrapU!==t.wrapU&&(a._cachedWrapU=t.wrapU,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),a)),a._cachedWrapV!==t.wrapV&&(a._cachedWrapV=t.wrapV,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),a)),a.is3D&&a._cachedWrapR!==t.wrapR&&(a._cachedWrapR=t.wrapR,this._setTextureParameterInteger(l,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),a)),this._setAnisotropicLevel(l,a,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,i,r){if(!(e===void 0||!t)){(!this._textureUnits||this._textureUnits.length!==i.length)&&(this._textureUnits=new Int32Array(i.length));for(let s=0;s=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){this._compiledEffects={},this.onReleaseEffectsObservable.notifyObservers(this)}dispose(){var e;Bt()&&this._renderingCanvas&&(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._onContextRestored&&this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&((e=this._gl.getExtension("WEBGL_lose_context"))==null||e.loseContext()),Nd(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){let t=this._gl;for(;t.getError()!==t.NO_ERROR;);let i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),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);let s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);let a=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&a===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);let o=t.RGBA,l=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,o,l,c),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(s),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,r,s=!0,a=!0,o=null){let l=s?4:3,c=s?this._gl.RGBA:this._gl.RGB,f=i*r*l;if(!o)o=new Uint8Array(f);else if(o.length{ns();th=class{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new g_(e)}sampleFrame(e=kt.Now){if(this._enabled){if(this._lastFrameTimeMs!=null){let 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(){let 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()}},g_=class{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){let 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;let 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){let t=this._samples.length;return(e%t+t)%t}}});var cI=A(()=>{er();We.prototype.setAlphaMode=function(n,e=!1,t=0){if(this._alphaMode[t]===n){if(!e){let r=n===0;this.depthCullingState.depthMask!==r&&(this.depthCullingState.depthMask=r)}return}let i=n===0;this._alphaState.setAlphaBlend(!i,t),this._alphaState.setAlphaMode(n,t),e||(this.depthCullingState.depthMask=i),this._alphaMode[t]=n}});function fI(n,e,t,i){let r,s=1;i===1?r=new Float32Array(e*t*4):i===2?(r=new Uint16Array(e*t*4),s=15360):i===7?r=new Uint32Array(e*t*4):r=new Uint8Array(e*t*4);for(let a=0;a{vr();ze();er();Dn();We.prototype.updateRawTexture=function(n,e,t,i,r=null,s=0,a=!1){if(!n)return;let o=this._getRGBABufferInternalSizedFormat(s,t,a),l=this._getInternalFormat(t),c=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,n,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(n._bufferView=e,n.format=t,n.type=s,n.invertY=i,n._compression=r),n.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),r&&e?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[r],n.width,n.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,n.width,n.height,0,l,c,e),n.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),n.isReady=!0};We.prototype.createRawTexture=function(n,e,t,i,r,s,a,o=null,l=0,c=0,f=!1){let d=new bt(this,3);d.baseWidth=e,d.baseHeight=t,d.width=e,d.height=t,d.format=i,d.generateMipMaps=r,d.samplingMode=a,d.invertY=s,d._compression=o,d.type=l,d._useSRGBBuffer=this._getUseSRGBBuffer(f,!r),this._doNotHandleContextLost||(d._bufferView=n),this.updateRawTexture(d,n,i,s,o,l,d._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,d,!0);let h=this._getSamplingParameters(a,r);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(d),d};We.prototype.createRawCubeTexture=function(n,e,t,i,r,s,a,o=null){let l=this._gl,c=new bt(this,8);c.isCube=!0,c.format=t,c.type=i,this._doNotHandleContextLost||(c._bufferViewArray=n);let f=this._getWebGLTextureType(i),d=this._getInternalFormat(t);d===l.RGB&&(d=l.RGBA),f===l.FLOAT&&!this._caps.textureFloatLinearFiltering?(r=!1,a=1,W.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):f===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(r=!1,a=1,W.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):f===l.FLOAT&&!this._caps.textureFloatRender?(r=!1,W.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):f===l.HALF_FLOAT&&!this._caps.colorBufferFloat&&(r=!1,W.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));let h=e,u=h;if(c.width=h,c.height=u,c.invertY=s,c._compression=o,!this.needPOTTextures||oo(c.width)&&oo(c.height)||(r=!1),n)this.updateRawCubeTexture(c,n,t,i,s,o);else{let _=this._getRGBABufferInternalSizedFormat(i),g=0;this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c,!0);for(let T=0;T<6;T++)o?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+T,g,this.getCaps().s3tc[o],c.width,c.height,0,void 0):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+T,g,_,c.width,c.height,0,d,f,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c,!0),n&&r&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);let p=this._getSamplingParameters(a,r);return l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,p.mag),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,p.min),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),c.generateMipMaps=r,c.samplingMode=a,c.isReady=!0,c};We.prototype.updateRawCubeTexture=function(n,e,t,i,r,s=null,a=0){n._bufferViewArray=e,n.format=t,n.type=i,n.invertY=r,n._compression=s;let o=this._gl,l=this._getWebGLTextureType(i),c=this._getInternalFormat(t),f=this._getRGBABufferInternalSizedFormat(i),d=!1;c===o.RGB&&(c=o.RGBA,d=!0),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,n,!0),this._unpackFlipY(r===void 0?!0:!!r),n.width%4!==0&&o.pixelStorei(o.UNPACK_ALIGNMENT,1);for(let u=0;u<6;u++){let m=e[u];s?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,this.getCaps().s3tc[s],n.width,n.height,0,m):(d&&(m=fI(m,n.width,n.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,f,n.width,n.height,0,c,l,m))}(!this.needPOTTextures||oo(n.width)&&oo(n.height))&&n.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),n.isReady=!0};We.prototype.createRawCubeTextureFromUrl=function(n,e,t,i,r,s,a,o,l=null,c=null,f=3,d=!1){let h=this._gl,u=this.createRawCubeTexture(null,t,i,r,!s,d,f,null);e==null||e.addPendingData(u),u.url=n,u.isReady=!1,this._internalTexturesCache.push(u);let m=(_,g)=>{e==null||e.removePendingData(u),c&&c(_?_.status+" "+_.statusText:"Failed to parse texture data",g)},p=async _=>{if(!u._hardwareTexture)return;let g=a(_);if(!g)return;let T=g instanceof Promise?await g:g,b=u.width;if(o){let R=this._getWebGLTextureType(r),S=this._getInternalFormat(i),I=this._getRGBABufferInternalSizedFormat(r),x=!1;S===h.RGB&&(S=h.RGBA,x=!0),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,u,!0),this._unpackFlipY(!1);let P=o(T);for(let L=0;L>L;for(let B=0;B<6;B++){let w=P[L][B];x&&(w=fI(w,y,y,r)),h.texImage2D(B,L,I,y,y,0,S,R,w)}}this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(u,T,i,r,d);u.isReady=!0,e==null||e.removePendingData(u),u.onLoadedObservable.notifyObservers(u),u.onLoadedObservable.clear(),l&&l()};return this._loadFile(n,_=>{p(_).catch(g=>{m(void 0,g)})},void 0,e==null?void 0:e.offlineProvider,!0,m),u};We.prototype.createRawTexture2DArray=dI(!1);We.prototype.createRawTexture3D=dI(!0);We.prototype.updateRawTexture2DArray=hI(!1);We.prototype.updateRawTexture3D=hI(!0)});var mI=A(()=>{er();aa();We.prototype._readTexturePixelsSync=function(n,e,t,i=-1,r=0,s=null,a=!0,o=!1,l=0,c=0){var h,u,m;let f=this._gl;if(!f)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){let p=f.createFramebuffer();if(!p)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=p}f.bindFramebuffer(f.FRAMEBUFFER,this._dummyFramebuffer),i>-1&&(n.is2DArray||n.is3D)?f.framebufferTextureLayer(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,(h=n._hardwareTexture)==null?void 0:h.underlyingResource,r,i):i>-1?f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+i,(u=n._hardwareTexture)==null?void 0:u.underlyingResource,r):f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,(m=n._hardwareTexture)==null?void 0:m.underlyingResource,r);let d=n.type!==void 0?this._getWebGLTextureType(n.type):f.UNSIGNED_BYTE;if(o)s||(s=LR(n.type,4*e*t));else switch(d){case f.UNSIGNED_BYTE:s||(s=new Uint8Array(4*e*t)),d=f.UNSIGNED_BYTE;break;default:s||(s=new Float32Array(4*e*t)),d=f.FLOAT;break}return a&&this.flushFramebuffer(),f.readPixels(l,c,e,t,f.RGBA,d,s),f.bindFramebuffer(f.FRAMEBUFFER,this._currentFramebuffer),s};We.prototype._readTexturePixels=function(n,e,t,i=-1,r=0,s=null,a=!0,o=!1,l=0,c=0){return Promise.resolve(this._readTexturePixelsSync(n,e,t,i,r,s,a,o,l,c))}});var pI=A(()=>{er();We.prototype.updateDynamicIndexBuffer=function(n,e,t=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(n);let i;n.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(n,e,t,i){this.bindArrayBuffer(n),t===void 0&&(t=0);let r=e.byteLength||e.length;i===void 0||i>=r&&t===0?e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e):e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e).subarray(0,i/4)):(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,i):e=new Uint8Array(e,0,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e)),this._resetVertexBufferBinding()}});var _I=A(()=>{er();vr();ze();Dn();We.prototype._createDepthStencilCubeTexture=function(n,e){let t=new bt(this,12);if(t.isCube=!0,this.webGLVersion===1)return W.Error("Depth cube texture is not supported by WebGL 1."),t;let i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e},r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,t,!0),this._setupDepthStencilTexture(t,n,i.bilinearFiltering,i.comparisonFunction);for(let s=0;s<6;s++)i.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,r.DEPTH24_STENCIL8,n,n,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,r.DEPTH_COMPONENT24,n,n,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(t),t};We.prototype._setCubeMapTextureParams=function(n,e,t){let 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),n.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&t!==void 0&&t>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,t),n._maxLodLevel=t),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};We.prototype.createCubeTexture=function(n,e,t,i,r=null,s=null,a,o=null,l=!1,c=0,f=0,d=null,h,u=!1,m=null){let p=this._gl;return this.createCubeTextureBase(n,e,t,!!i,r,s,a,o,l,c,f,d,_=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),(_,g)=>{let T=this.needPOTTextures?$i(g[0].width,this._caps.maxCubemapTextureSize):g[0].width,b=T,R=[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,_,!0),this._unpackFlipY(!1);let S=a?this._getInternalFormat(a,_._useSRGBBuffer):_._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA,I=a?this._getInternalFormat(a):p.RGBA;_._useSRGBBuffer&&this.webGLVersion===1&&(I=S);for(let x=0;x{Wc();ih=class{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=ss(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 s,a,o,l;if(!this._textures)return-1;let t=this._textures[e],i=(a=(s=this._layerIndices)==null?void 0:s[e])!=null?a:0,r=(l=(o=this._faceIndices)==null?void 0:o[e])!=null?l:0;return t.isCube?i*6+r:t.is3D?0:i}get samples(){return this._samples}setSamples(e,t=!0,i=!1){if(this.samples===e&&!i)return e;let r=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,r}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&(this.isMulti?this._engine.unBindMultiColorAttachmentFramebuffer(this,!0):this._engine.unBindFramebuffer(this,!0)),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,t,i,r,s){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=i,this._engine=r,this._depthStencilTexture=null,this.label=s}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,r=1,s=14,a){var o;return(o=this._depthStencilTexture)==null||o.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=a,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:r,depthTextureFormat:s,label:a},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,r,s,a,o,l,c;let e=null;if(this._isMulti){let f=this.textures;if(f&&f.length>0){let d=!1,h=f.length,u=-1,m=f[f.length-1]._source;(m===14||m===12)&&(d=!0,u=f[f.length-1].format,h--);let p=[],_=[],g=[],T=[],b=[],R=[],S=[],I={};for(let L=0;L1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e{gI();Wc();rh=class extends ih{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;let i=this._engine,r=this._context,s=e._hardwareTexture;if(s&&e._autoMSAAManagement&&this._MSAAFramebuffer){let a=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,ss(e.format)?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,r.RENDERBUFFER,s.getMSAARenderBuffer()),i._bindUnboundFramebuffer(a)}}constructor(e,t,i,r,s){super(e,t,i,r),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=s}_cloneRenderTargetWrapper(){let e;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,r=1,s=14,a){if(this._depthStencilBuffer){let o=this._engine,l=o._currentFramebuffer,c=this._context;o._bindUnboundFramebuffer(this._framebuffer),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,null),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.STENCIL_ATTACHMENT,c.RENDERBUFFER,null),o._bindUnboundFramebuffer(l),c.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,t,i,r,s,a)}shareDepth(e){super.shareDepth(e);let t=this._context,i=this._depthStencilBuffer,r=e._MSAAFramebuffer||e._framebuffer,s=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;let a=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;s._bindUnboundFramebuffer(r),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),s._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,r=0){var f,d,h,u;let s=e._hardwareTexture;if(!s)return;let a=this._framebuffer,o=this._engine,l=o._currentFramebuffer;o._bindUnboundFramebuffer(a);let c;if(o.webGLVersion>1){let m=this._context;c=m["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(i=(d=i!=null?i:(f=this.layerIndices)==null?void 0:f[t])!=null?d:0,m.framebufferTextureLayer(m.FRAMEBUFFER,c,s.underlyingResource,r,i)):e.isCube?(i=(u=i!=null?i:(h=this.faceIndices)==null?void 0:h[t])!=null?u:0,m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_CUBE_MAP_POSITIVE_X+i,s.underlyingResource,r)):m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_2D,s.underlyingResource,r)}else{let m=this._context;c=m["COLOR_ATTACHMENT"+t+"_WEBGL"];let p=i!==void 0?m.TEXTURE_CUBE_MAP_POSITIVE_X+i:m.TEXTURE_2D;m.framebufferTexture2D(m.FRAMEBUFFER,c,p,s.underlyingResource,r)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){let m=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),m.framebufferRenderbuffer(m.FRAMEBUFFER,c,m.RENDERBUFFER,s.getMSAARenderBuffer())}o._bindUnboundFramebuffer(l)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){var r,s;if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;let i=(s=(r=this._attachments)==null?void 0:r.length)!=null?s:this.textures.length;for(let a=0;a{ii();fe.prototype.createDepthStencilTexture=function(n,e,t){if(e.isCube){let i=n.width||n;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(n,e,t)}});var vI=A(()=>{vr();ze();er();EI();Wc();E_();We.prototype._createHardwareRenderTargetWrapper=function(n,e,t){let i=new rh(n,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};We.prototype.createRenderTargetTexture=function(n,e){var p,_;let t=this._createHardwareRenderTargetWrapper(!1,!1,n),i=!0,r=!1,s=!1,a,o=1,l;e!==void 0&&typeof e=="object"&&(i=(p=e.generateDepthBuffer)!=null?p:!0,r=!!e.generateStencilBuffer,s=!!e.noColorAttachment,a=e.colorAttachment,o=(_=e.samples)!=null?_:1,l=e.label);let c=a||(s?null:this._createInternalTexture(n,e,!0,5)),f=n.width||n,d=n.height||n,h=this._currentFramebuffer,u=this._gl,m=u.createFramebuffer();if(this._bindUnboundFramebuffer(m),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(r,i,f,d),c&&!c.is2DArray&&!c.is3D&&u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,c._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(h),t.label=l!=null?l:"RenderTargetWrapper",t._framebuffer=m,t._generateDepthBuffer=i,t._generateStencilBuffer=r,t.setTextures(c),!a)this.updateRenderTargetTextureSampleCount(t,o);else if(t._samples=a.samples,a.samples>1){let g=a._hardwareTexture.getMSAARenderBuffer(0);t._MSAAFramebuffer=u.createFramebuffer(),this._bindUnboundFramebuffer(t._MSAAFramebuffer),u.framebufferRenderbuffer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.RENDERBUFFER,g),this._bindUnboundFramebuffer(null)}return t};We.prototype._createDepthStencilTexture=function(n,e,t){var u;let i=this._gl,r=n.layers||0,s=n.depth||0,a=i.TEXTURE_2D;r!==0?a=i.TEXTURE_2D_ARRAY:s!==0&&(a=i.TEXTURE_3D);let o=new bt(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return W.Error("Depth texture is not supported by your browser or hardware."),o;let l={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(a,o,!0),this._setupDepthStencilTexture(o,n,l.comparisonFunction===0?!1:l.bilinearFiltering,l.comparisonFunction,l.samples),l.depthTextureFormat!==void 0){if(l.depthTextureFormat!==15&&l.depthTextureFormat!==16&&l.depthTextureFormat!==17&&l.depthTextureFormat!==13&&l.depthTextureFormat!==14&&l.depthTextureFormat!==18)return W.Error(`Depth texture ${l.depthTextureFormat} format is not supported.`),o;o.format=l.depthTextureFormat}else o.format=l.generateStencil?13:16;let c=ss(o.format),f=this._getWebGLTextureTypeFromDepthTextureFormat(o.format),d=c?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,h=this._getInternalFormatFromDepthTextureFormat(o.format,!0,c);return o.is2DArray?i.texImage3D(a,0,h,o.width,o.height,r,0,d,f,null):o.is3D?i.texImage3D(a,0,h,o.width,o.height,s,0,d,f,null):i.texImage2D(a,0,h,o.width,o.height,0,d,f,null),this._bindTextureDirectly(a,null),this._internalTexturesCache.push(o),t._depthStencilBuffer&&(i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),this._bindUnboundFramebuffer((u=t._MSAAFramebuffer)!=null?u:t._framebuffer),t._generateStencilBuffer=c,t._depthStencilTextureWithStencil=c,t._depthStencilBuffer=this._setupFramebufferDepthAttachments(t._generateStencilBuffer,t._generateDepthBuffer,t.width,t.height,t.samples,o.format),this._bindUnboundFramebuffer(null),o};We.prototype.updateRenderTargetTextureSampleCount=function(n,e){var s,a;if(this.webGLVersion<2||!n)return 1;if(n.samples===e)return e;let t=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),n._depthStencilBuffer&&(t.deleteRenderbuffer(n._depthStencilBuffer),n._depthStencilBuffer=null),n._MSAAFramebuffer&&(t.deleteFramebuffer(n._MSAAFramebuffer),n._MSAAFramebuffer=null);let i=(s=n.texture)==null?void 0:s._hardwareTexture;if(i==null||i.releaseMSAARenderBuffers(),n.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){let o=t.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");n._MSAAFramebuffer=o,this._bindUnboundFramebuffer(n._MSAAFramebuffer);let l=this._createRenderBuffer(n.texture.width,n.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(n.texture.type,n.texture.format,n.texture._useSRGBBuffer),t.COLOR_ATTACHMENT0,!1);if(!l)throw new Error("Unable to create multi sampled framebuffer");i==null||i.addMSAARenderBuffer(l)}this._bindUnboundFramebuffer((a=n._MSAAFramebuffer)!=null?a:n._framebuffer),n.texture&&(n.texture.samples=e),n._samples=e;let r=n._depthStencilTexture?n._depthStencilTexture.format:void 0;return n._depthStencilBuffer=this._setupFramebufferDepthAttachments(n._generateStencilBuffer,n._generateDepthBuffer,n.width,n.height,e,r),this._bindUnboundFramebuffer(null),e};We.prototype._setupDepthStencilTexture=function(n,e,t,i,r=1){var h,u;let s=(h=e.width)!=null?h:e,a=(u=e.height)!=null?u:e,o=e.layers||0,l=e.depth||0;n.baseWidth=s,n.baseHeight=a,n.width=s,n.height=a,n.is2DArray=o>0,n.depth=o||l,n.isReady=!0,n.samples=r,n.generateMipMaps=!1,n.samplingMode=t?2:1,n.type=0,n._comparisonFunction=i;let c=this._gl,f=this._getTextureTarget(n),d=this._getSamplingParameters(n.samplingMode,!1);c.texParameteri(f,c.TEXTURE_MAG_FILTER,d.mag),c.texParameteri(f,c.TEXTURE_MIN_FILTER,d.min),c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),this.webGLVersion>1&&(i===0?(c.texParameteri(f,c.TEXTURE_COMPARE_FUNC,515),c.texParameteri(f,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(f,c.TEXTURE_COMPARE_FUNC,i),c.texParameteri(f,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE)))}});var TI=A(()=>{er();We.prototype.setDepthStencilTexture=function(n,e,t,i){n!==void 0&&(e&&(this._boundUniforms[n]=e),!t||!t.depthStencilTexture?this._setTexture(n,null,void 0,void 0,i):this._setTexture(n,t,!1,!0,i))}});var SI=A(()=>{vr();ze();er();We.prototype.createRenderTargetCubeTexture=function(n,e){let t=this._createHardwareRenderTargetWrapper(!1,!0,n),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);let r=this._gl,s=new bt(this,5);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,s,!0);let a=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,W.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,a.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,a.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(let l=0;l<6;l++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),n,n,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);let o=r.createFramebuffer();return this._bindUnboundFramebuffer(o),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,n,n),i.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),t._framebuffer=o,t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=i.generateStencilBuffer,s.width=n,s.height=n,s.isReady=!0,s.isCube=!0,s.samples=1,s.generateMipMaps=i.generateMipMaps,s.samplingMode=i.samplingMode,s.type=i.type,s.format=i.format,this._internalTexturesCache.push(s),t.setTextures(s),t}});var AI,il,Wt,Ye,bi=A(()=>{AI=.45454545454545453,il=2.2,Wt=(1+Math.sqrt(5))/2,Ye=.001});function vi(n,e){let t=[];for(let i=0;i{let s=r.previous;if(!s)return;let a=r.next;a?(s.next=a,a.previous=s):(s.next=void 0,n[e]=s),r.next=void 0,r.previous=void 0}}function nh(n,e){let t=LV.map(i=>DV(n,i,e));return()=>{for(let i of t)i==null||i()}}var LV,Ln=A(()=>{LV=["push","splice","pop","shift","unshift"]});function je(n,e){RI[n]=e}function Ri(n){return RI[n]}var RI,Lt=A(()=>{RI={}});function mt(n,e,t=1401298e-51){return Math.abs(n-e)<=t}function Ft(n,e){return n===e?n:Math.random()*(e-n)+n}function nn(n,e,t){return n+(e-n)*t}function II(n,e,t,i,r){let s=r*r,a=r*s,o=2*a-3*s+1,l=-2*a+3*s,c=a-2*s+r,f=a-s;return n*o+t*l+e*c+i*f}function Ke(n,e=0,t=1){return Math.min(t,Math.max(e,n))}function xI(n){return n-=Math.PI*2*Math.floor((n+Math.PI)/(Math.PI*2)),n}function sn(n){let e=n.toString(16);return n<=15?("0"+e).toUpperCase():e.toUpperCase()}function CI(n){if(Math.log2)return Math.floor(Math.log2(n));if(n<0)return NaN;if(n===0)return-1/0;let e=0;if(n<1){for(;n<1;)e++,n=n*2;e=-e}else if(n>1)for(;n>1;)e++,n=Math.floor(n/2);return e}function sh(n,e){let t=n%e;return t===0?e:sh(e,t)}var Mi=A(()=>{});function bI(n){n.updateFlag=rl._UpdateFlagSeed++}function v_(n,e,t,i=0){let r=n.asArray(),s=e.asArray(),a=r[0],o=r[1],l=r[2],c=r[3],f=r[4],d=r[5],h=r[6],u=r[7],m=r[8],p=r[9],_=r[10],g=r[11],T=r[12],b=r[13],R=r[14],S=r[15],I=s[0],x=s[1],P=s[2],L=s[3],y=s[4],B=s[5],w=s[6],H=s[7],O=s[8],k=s[9],X=s[10],j=s[11],Q=s[12],$=s[13],q=s[14],z=s[15];t[i]=a*I+o*y+l*O+c*Q,t[i+1]=a*x+o*B+l*k+c*$,t[i+2]=a*P+o*w+l*X+c*q,t[i+3]=a*L+o*H+l*j+c*z,t[i+4]=f*I+d*y+h*O+u*Q,t[i+5]=f*x+d*B+h*k+u*$,t[i+6]=f*P+d*w+h*X+u*q,t[i+7]=f*L+d*H+h*j+u*z,t[i+8]=m*I+p*y+_*O+g*Q,t[i+9]=m*x+p*B+_*k+g*$,t[i+10]=m*P+p*w+_*X+g*q,t[i+11]=m*L+p*H+_*j+g*z,t[i+12]=T*I+b*y+R*O+S*Q,t[i+13]=T*x+b*B+R*k+S*$,t[i+14]=T*P+b*w+R*X+S*q,t[i+15]=T*L+b*H+R*j+S*z}function lo(n,e,t,i=0){v_(n,e,t.asArray(),i),bI(t)}function MI(n,e,t=0){let i=n.asArray();e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15]}function Hc(n,e){let t=T_(n,e.asArray());return t&&bI(e),t}function T_(n,e){let t=n.asArray(),i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],l=t[5],c=t[6],f=t[7],d=t[8],h=t[9],u=t[10],m=t[11],p=t[12],_=t[13],g=t[14],T=t[15],b=u*T-g*m,R=h*T-_*m,S=h*g-_*u,I=d*T-p*m,x=d*g-u*p,P=d*_-p*h,L=+(l*b-c*R+f*S),y=-(o*b-c*I+f*x),B=+(o*R-l*I+f*P),w=-(o*S-l*x+c*P),H=i*L+r*y+s*B+a*w;if(H===0)return!1;let O=1/H,k=c*T-g*f,X=l*T-_*f,j=l*g-_*c,Q=o*T-p*f,$=o*g-p*c,q=o*_-p*l,z=c*m-u*f,K=l*m-h*f,J=l*u-h*c,te=o*m-d*f,Pe=o*u-d*c,ge=o*h-d*l,me=-(r*b-s*R+a*S),se=+(i*b-s*I+a*x),le=-(i*R-r*I+a*P),xe=+(i*S-r*x+s*P),ce=+(r*k-s*X+a*j),he=-(i*k-s*Q+a*$),ke=+(i*X-r*Q+a*q),$e=-(i*j-r*$+s*q),Fe=-(r*z-s*K+a*J),Xe=+(i*z-s*te+a*Pe),xt=-(i*K-r*te+a*ge),Dt=+(i*J-r*Pe+s*ge);return e[0]=L*O,e[1]=me*O,e[2]=ce*O,e[3]=Fe*O,e[4]=y*O,e[5]=se*O,e[6]=he*O,e[7]=Xe*O,e[8]=B*O,e[9]=le*O,e[10]=ke*O,e[11]=xt*O,e[12]=w*O,e[13]=xe*O,e[14]=$e*O,e[15]=Dt*O,!0}var rl,S_=A(()=>{rl=class{};rl._UpdateFlagSeed=0});var Hi,_e,v,vt,Ae,U,Se,G,co,ve=A(()=>{bi();Ln();Lt();c_();At();Mi();S_();Hi=n=>parseInt(n.toString().replace(/\W/g,"")),_e=class n{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=Hi(this.x),t=Hi(this.y),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 n.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 n(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 n(this.x+e.x,this.y+e.y)}subtract(e){return new n(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 n(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 n(this.x*e,this.y*t)}divide(e){return new n(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 n(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 n(-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 n(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=Ye){return e&&mt(this.x,e.x,t)&&mt(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new n(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 n(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new n)}rotateToRef(e,t){let i=Math.cos(e),r=Math.sin(e);return t.x=i*this.x-r*this.y,t.y=r*this.x+i*this.y,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){let e=new n;return this.normalizeToRef(e),e}normalizeToRef(e){let t=this.length();return t===0&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new n(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new n(0,0)}static One(){return new n(1,1)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t))}static get ZeroReadOnly(){return n._ZeroReadOnly}static FromArray(e,t=0){return new n(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,r,s){let a=s*s,o=s*a,l=.5*(2*t.x+(-e.x+i.x)*s+(2*e.x-5*t.x+4*i.x-r.x)*a+(-e.x+3*t.x-3*i.x+r.x)*o),c=.5*(2*t.y+(-e.y+i.y)*s+(2*e.y-5*t.y+4*i.y-r.y)*a+(-e.y+3*t.y-3*i.y+r.y)*o);return new n(l,c)}static ClampToRef(e,t,i,r){return r.x=Ke(e.x,t.x,i.x),r.y=Ke(e.y,t.y,i.y),r}static Clamp(e,t,i){let r=Ke(e.x,t.x,i.x),s=Ke(e.y,t.y,i.y);return new n(r,s)}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.x*l+i.x*c+t.x*f+r.x*d,u=e.y*l+i.y*c+t.y*f+r.y*d;return new n(h,u)}static Hermite1stDerivative(e,t,i,r,s){return this.Hermite1stDerivativeToRef(e,t,i,r,s,new n)}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;return a.x=(o-s)*6*e.x+(3*o-4*s+1)*t.x+(-o+s)*6*i.x+(3*o-2*s)*r.x,a.y=(o-s)*6*e.y+(3*o-4*s+1)*t.y+(-o+s)*6*i.y+(3*o-2*s)*r.y,a}static Lerp(e,t,i){return n.LerpToRef(e,t,i,new n)}static LerpToRef(e,t,i,r){return r.x=e.x+(t.x-e.x)*i,r.y=e.y+(t.y-e.y)*i,r}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){let i=e.xt.x?e.x:t.x,r=e.y>t.y?e.y:t.y;return new n(i,r)}static Transform(e,t){return n.TransformToRef(e,t,new n)}static TransformToRef(e,t,i){let r=t.m,s=e.x*r[0]+e.y*r[4]+r[12],a=e.x*r[1]+e.y*r[5]+r[13];return i.x=s,i.y=a,i}static PointInTriangle(e,t,i,r){let s=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),a=s<0?-1:1,o=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*a,l=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*a;return o>0&&l>0&&o+l<2*s*a}static Distance(e,t){return Math.sqrt(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y;return i*i+r*r}static Center(e,t){return n.CenterToRef(e,t,new n)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){let r=n.DistanceSquared(t,i);if(r===0)return n.Distance(e,t);let s=i.subtract(t),a=Math.max(0,Math.min(1,n.Dot(e.subtract(t),s)/r)),o=t.add(s.multiplyByFloats(a,a));return n.Distance(e,o)}};_e._V8PerformanceHack=new _e(.5,.5);_e._ZeroReadOnly=_e.Zero();Object.defineProperties(_e.prototype,{dimension:{value:[2]},rank:{value:1}});v=class n{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=Hi(this._x),t=Hi(this._y),i=Hi(this._z),r=e;return r=r*397^t,r=r*397^i,r}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 n.FromArrayToRef(e,t,this),this}toQuaternion(){return Ae.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 n(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 n(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 n(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._isDirty=!0,r}negate(){return new n(-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 n(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){let t=this.length(),i=Math.acos(this._y/t),r=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;let s=t*Math.sin(i)*Math.cos(r),a=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(r);return e.set(s,a,o),e}applyRotationQuaternionToRef(e,t){let i=this._x,r=this._y,s=this._z,a=e._x,o=e._y,l=e._z,c=e._w,f=2*(o*s-l*r),d=2*(l*i-a*s),h=2*(a*r-o*i);return t._x=i+c*f+o*h-l*d,t._y=r+c*d+l*f-a*h,t._z=s+c*h+a*d-o*f,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new n)}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 n)}projectOnPlaneToRef(e,t,i){let r=e.normal,s=e.d,a=Se.Vector3[0];this.subtractToRef(t,a),a.normalize();let o=n.Dot(a,r);if(Math.abs(o)<1e-10)i.setAll(1/0);else{let l=-(n.Dot(t,r)+s)/o,c=a.scaleInPlace(l);t.addToRef(c,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=Ye){return e&&mt(this._x,e._x,t)&&mt(this._y,e._y,t)&&mt(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 n(this._x*e,this._y*t,this._z*i)}divide(e){return new n(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 ethis._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){let t=Math.abs(this._x),i=Math.abs(this._y);if(!mt(t,i,e))return!0;let r=Math.abs(this._z);return!mt(t,r,e)||!mt(i,r,e)}get isNonUniform(){let e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;let 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 n(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 n(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;let t=Se.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(Se.Matrix[0]),n.TransformCoordinatesToRef(this,Se.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,Se.Vector3[0]),Se.Vector3[0].rotateByQuaternionToRef(e,Se.Vector3[0]),t.addToRef(Se.Vector3[0],i),i}cross(e){return n.CrossToRef(this,e,new n)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new n)}normalizeToRef(e){let 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 n(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,r){let s=n.Dot(e,i),a=n.Dot(t,i);return(s-r)/(s-a)}static GetAngleBetweenVectors(e,t,i){let r=e.normalizeToRef(Se.Vector3[1]),s=t.normalizeToRef(Se.Vector3[2]),a=n.Dot(r,s);a=Ke(a,-1,1);let o=Math.acos(a),l=Se.Vector3[3];return n.CrossToRef(r,s,l),n.Dot(l,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,t,i){Se.Vector3[0].copyFrom(e);let r=Se.Vector3[0];Se.Vector3[1].copyFrom(t);let s=Se.Vector3[1];Se.Vector3[2].copyFrom(i);let a=Se.Vector3[2],o=Se.Vector3[3],l=Se.Vector3[4];r.normalize(),s.normalize(),a.normalize(),n.CrossToRef(a,r,o),n.CrossToRef(o,a,l);let c=Math.atan2(n.Dot(s,o),n.Dot(s,l));return xI(c)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){let r=G.Vector3[0];return t.subtractToRef(e,r),i._y=Math.atan2(r.x,r.z)||0,i._x=Math.atan2(Math.sqrt(r.x**2+r.z**2),r.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){let i=n.Zero();return n.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,r){i=Ke(i,0,1);let s=Se.Vector3[0],a=Se.Vector3[1];s.copyFrom(e);let o=s.length();s.normalizeFromLength(o),a.copyFrom(t);let l=a.length();a.normalizeFromLength(l);let c=n.Dot(s,a),f,d;if(c<1-Ye){let h=Math.acos(c),u=1/Math.sin(h);f=Math.sin((1-i)*h)*u,d=Math.sin(i*h)*u}else f=1-i,d=i;return s.scaleInPlace(f),a.scaleInPlace(d),r.copyFrom(s).addInPlace(a),r.scaleInPlace(nn(o,l,i)),r}static SmoothToRef(e,t,i,r,s){return n.SlerpToRef(e,t,r===0?1:i/r,s),s}static FromArray(e,t=0){return new n(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return n.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 n.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,r){return r.copyFromFloats(e,t,i),r}static Zero(){return new n(0,0,0)}static One(){return new n(1,1,1)}static Up(){return new n(0,1,0)}static get UpReadOnly(){return n._UpReadOnly}static get DownReadOnly(){return n._DownReadOnly}static get RightReadOnly(){return n._RightReadOnly}static get LeftReadOnly(){return n._LeftReadOnly}static get LeftHandedForwardReadOnly(){return n._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return n._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return n._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return n._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return n._ZeroReadOnly}static get OneReadOnly(){return n._OneReadOnly}static Down(){return new n(0,-1,0)}static Forward(e=!1){return new n(0,0,e?-1:1)}static Backward(e=!1){return new n(0,0,e?1:-1)}static Right(){return new n(1,0,0)}static Left(){return new n(-1,0,0)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t),Ft(e,t))}static TransformCoordinates(e,t){let i=n.Zero();return n.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,s){let a=r.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],l=e*a[1]+t*a[5]+i*a[9]+a[13],c=e*a[2]+t*a[6]+i*a[10]+a[14],f=1/(e*a[3]+t*a[7]+i*a[11]+a[15]);return s._x=o*f,s._y=l*f,s._z=c*f,s._isDirty=!0,s}static TransformNormal(e,t){let i=n.Zero();return n.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,r,s){let a=r.m;return s._x=e*a[0]+t*a[4]+i*a[8],s._y=e*a[1]+t*a[5]+i*a[9],s._z=e*a[2]+t*a[6]+i*a[10],s._isDirty=!0,s}static CatmullRom(e,t,i,r,s){let a=s*s,o=s*a,l=.5*(2*t._x+(-e._x+i._x)*s+(2*e._x-5*t._x+4*i._x-r._x)*a+(-e._x+3*t._x-3*i._x+r._x)*o),c=.5*(2*t._y+(-e._y+i._y)*s+(2*e._y-5*t._y+4*i._y-r._y)*a+(-e._y+3*t._y-3*i._y+r._y)*o),f=.5*(2*t._z+(-e._z+i._z)*s+(2*e._z-5*t._z+4*i._z-r._z)*a+(-e._z+3*t._z-3*i._z+r._z)*o);return new n(l,c,f)}static Clamp(e,t,i){let r=new n;return n.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){let s=e._x;s=s>i._x?i._x:s,s=si._y?i._y:a,a=ai._z?i._z:o,o=o0&&y<0?(w.copyFrom(a),H=t,O=i):y>0&&B<0?(w.copyFrom(l),H=i,O=r):(w.copyFrom(o).scaleInPlace(-1),H=r,O=t);let k=Se.Vector3[9],X=Se.Vector3[4];if(H.subtractToRef(T,I),O.subtractToRef(T,k),n.CrossToRef(I,k,X),!(n.Dot(X,c)<0))return s.copyFrom(T),Math.abs(p*_);let Q=Se.Vector3[5];n.CrossToRef(w,X,Q),Q.normalize();let $=Se.Vector3[9];$.copyFrom(H).subtractInPlace(T);let q=$.length();if(qthis._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,r){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(r,this._w),this}maximizeInPlaceFromFloats(e,t,i,r){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(r,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 n(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 n(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 n)}normalizeToRef(e){let 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 n(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,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}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 n(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 n.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,r,s){return s.x=e,s.y=t,s.z=i,s.w=r,s}static Zero(){return new n(0,0,0,0)}static One(){return new n(1,1,1,1)}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.x=Ft(e,t),i.y=Ft(e,t),i.z=Ft(e,t),i.w=Ft(e,t),i}static Clamp(e,t,i){return n.ClampToRef(e,t,i,new n)}static ClampToRef(e,t,i,r){return r.x=Ke(e.x,t.x,i.x),r.y=Ke(e.y,t.y,i.y),r.z=Ke(e.z,t.z,i.z),r.w=Ke(e.w,t.w,i.w),r}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return n._ZeroReadOnly}static Normalize(e){return n.NormalizeToRef(e,new n)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){let i=new n;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){let i=new n;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,a=e.w-t.w;return i*i+r*r+s*s+a*a}static Center(e,t){return n.CenterToRef(e,t,new n)}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 n.TransformCoordinatesToRef(e,t,new n)}static TransformCoordinatesToRef(e,t,i){return n.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,s){let a=r.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],l=e*a[1]+t*a[5]+i*a[9]+a[13],c=e*a[2]+t*a[6]+i*a[10]+a[14],f=e*a[3]+t*a[7]+i*a[11]+a[15];return s.x=o,s.y=l,s.z=c,s.w=f,s}static TransformNormal(e,t){return n.TransformNormalToRef(e,t,new n)}static TransformNormalToRef(e,t,i){let r=t.m,s=e.x*r[0]+e.y*r[4]+e.z*r[8],a=e.x*r[1]+e.y*r[5]+e.z*r[9],o=e.x*r[2]+e.y*r[6]+e.z*r[10];return i.x=s,i.y=a,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,r,s,a){let o=s.m;return a.x=e*o[0]+t*o[4]+i*o[8],a.y=e*o[1]+t*o[5]+i*o[9],a.z=e*o[2]+t*o[6]+i*o[10],a.w=r,a}static FromVector3(e,t=0){return new n(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}};vt._V8PerformanceHack=new vt(.5,.5,.5,.5);vt._ZeroReadOnly=vt.Zero();Object.defineProperties(vt.prototype,{dimension:{value:[4]},rank:{value:1}});Ae=class n{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,r=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=r}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=Hi(this._x),t=Hi(this._y),i=Hi(this._z),r=Hi(this._w),s=e;return s=s*397^t,s=s*397^i,s=s*397^r,s}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 n.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=Ye){return e&&mt(this._x,e._x,t)&&mt(this._y,e._y,t)&&mt(this._z,e._z,t)&&mt(this._w,e._w,t)}isApprox(e,t=Ye){return e&&(mt(this._x,e._x,t)&&mt(this._y,e._y,t)&&mt(this._z,e._z,t)&&mt(this._w,e._w,t)||mt(this._x,-e._x,t)&&mt(this._y,-e._y,t)&&mt(this._z,-e._z,t)&&mt(this._w,-e._w,t))}clone(){return new n(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,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._isDirty=!0,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new n(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,r){return this._x+=e,this._y+=t,this._z+=i,this._w+=r,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,r){return this.subtractFromFloatsToRef(e,t,i,r,new n)}subtractFromFloatsToRef(e,t,i,r,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._w=this._w-r,s._isDirty=!0,s}subtract(e){return new n(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 n(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){let t=new n(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){let i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,r=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,s=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,a=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,r,s,a),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,r){return this._x*=e,this._y*=t,this._z*=i,this._w*=r,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 n)}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,r){return this._x===e&&this._y===t&&this._z===i&&this._w===r}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 n(-this._x,-this._y,-this._z,this._w)}invert(){let e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();let 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(){let e=new n(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){let t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){let e=v.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){let t=this._z,i=this._x,r=this._y,s=this._w,a=r*t-i*s,o=.4999999;if(a<-o)e._y=2*Math.atan2(r,s),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>o)e._y=2*Math.atan2(r,s),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{let l=s*s,c=t*t,f=i*i,d=r*r;e._z=Math.atan2(2*(i*r+t*s),-c-f+d+l),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(t*i+r*s),c-f-d+l),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){let t=this._z,i=this._x,r=this._y,s=this._w,a=Math.sqrt(i*i+r*r),o=Math.sqrt(t*t+s*s),l=2*Math.atan2(a,o),c=2*Math.atan2(t,s),f=2*Math.atan2(r,i),d=(c+f)/2,h=(c-f)/2;return e.set(h,l,d),e}toRotationMatrix(e){return U.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return n.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){let e=v.Zero(),t=this.toAxisAngleToRef(e);return{axis:e,angle:t}}toAxisAngleToRef(e){let t,i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),r=this._w;return i>0?(t=2*Math.atan2(i,r),e.set(this._x/i,this._y/i,this._z/i)):(t=0,e.set(1,0,0)),t}static FromRotationMatrix(e){let t=new n;return n.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){let i=e.m,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],f=i[2],d=i[6],h=i[10],u=r+l+h,m;return u>0?(m=.5/Math.sqrt(u+1),t._w=.25/m,t._x=(d-c)*m,t._y=(a-f)*m,t._z=(o-s)*m,t._isDirty=!0):r>l&&r>h?(m=2*Math.sqrt(1+r-l-h),t._w=(d-c)/m,t._x=.25*m,t._y=(s+o)/m,t._z=(a+f)/m,t._isDirty=!0):l>h?(m=2*Math.sqrt(1+l-r-h),t._w=(a-f)/m,t._x=(s+o)/m,t._y=.25*m,t._z=(c+d)/m,t._isDirty=!0):(m=2*Math.sqrt(1+h-r-l),t._w=(o-s)/m,t._x=(a+f)/m,t._y=(c+d)/m,t._z=.25*m,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){let r=n.Dot(e,t);return 1-r*r<=i}static SmoothToRef(e,t,i,r,s){let a=r===0?1:i/r;return a=Ke(a,0,1),n.SlerpToRef(e,t,a,s),s}static Zero(){return new n(0,0,0,0)}static Inverse(e){return new n(-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 n(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 n.RotationAxisToRef(e,t,new n)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);let r=Math.sin(t/2)/e.length();return i._x=e._x*r,i._y=e._y*r,i._z=e._z*r,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new n(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,r,s){return s.copyFromFloats(e,t,i,r),s}static FromEulerAngles(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerAnglesToRef(e,t,i,r){return n.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerVector(e){let t=new n;return n.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return n.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,r=Ye){let s=v.Dot(e,t)+1;return sMath.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(v.CrossToRef(e,t,G.Vector3[0]),i.set(G.Vector3[0].x,G.Vector3[0].y,G.Vector3[0].z,s)),i.normalize()}static RotationYawPitchRoll(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){let s=i*.5,a=t*.5,o=e*.5,l=Math.sin(s),c=Math.cos(s),f=Math.sin(a),d=Math.cos(a),h=Math.sin(o),u=Math.cos(o);return r._x=u*f*c+h*d*l,r._y=h*d*c-u*f*l,r._z=u*d*l-h*f*c,r._w=u*d*c+h*f*l,r._isDirty=!0,r}static RotationAlphaBetaGamma(e,t,i){let r=new n;return n.RotationAlphaBetaGammaToRef(e,t,i,r),r}static RotationAlphaBetaGammaToRef(e,t,i,r){let s=(i+e)*.5,a=(i-e)*.5,o=t*.5;return r._x=Math.cos(a)*Math.sin(o),r._y=Math.sin(a)*Math.sin(o),r._z=Math.sin(s)*Math.cos(o),r._w=Math.cos(s)*Math.cos(o),r._isDirty=!0,r}static RotationQuaternionFromAxis(e,t,i){let r=new n(0,0,0,0);return n.RotationQuaternionFromAxisToRef(e,t,i,r),r}static RotationQuaternionFromAxisToRef(e,t,i,r){let s=Se.Matrix[0];return e=e.normalizeToRef(Se.Vector3[0]),t=t.normalizeToRef(Se.Vector3[1]),i=i.normalizeToRef(Se.Vector3[2]),U.FromXYZAxesToRef(e,t,i,s),n.FromRotationMatrixToRef(s,r),r}static FromLookDirectionLH(e,t){let i=new n;return n.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){let r=Se.Matrix[0];return U.LookDirectionLHToRef(e,t,r),n.FromRotationMatrixToRef(r,i),i}static FromLookDirectionRH(e,t){let i=new n;return n.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){let r=Se.Matrix[0];return U.LookDirectionRHToRef(e,t,r),n.FromRotationMatrixToRef(r,i)}static Slerp(e,t,i){let r=n.Identity();return n.SlerpToRef(e,t,i,r),r}static SlerpToRef(e,t,i,r){let s,a,o=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,l=!1;if(o<0&&(l=!0,o=-o),o>.999999)a=1-i,s=l?-i:i;else{let c=Math.acos(o),f=1/Math.sin(c);a=Math.sin((1-i)*c)*f,s=l?-Math.sin(i*c)*f:Math.sin(i*c)*f}return r._x=a*e._x+s*t._x,r._y=a*e._y+s*t._y,r._z=a*e._z+s*t._z,r._w=a*e._w+s*t._w,r._isDirty=!0,r}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e._x*l+i._x*c+t._x*f+r._x*d,u=e._y*l+i._y*c+t._y*f+r._y*d,m=e._z*l+i._z*c+t._z*f+r._z*d,p=e._w*l+i._w*c+t._w*f+r._w*d;return new n(h,u,m,p)}static Hermite1stDerivative(e,t,i,r,s){let a=new n;return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;return a._x=(o-s)*6*e._x+(3*o-4*s+1)*t._x+(-o+s)*6*i._x+(3*o-2*s)*r._x,a._y=(o-s)*6*e._y+(3*o-4*s+1)*t._y+(-o+s)*6*i._y+(3*o-2*s)*r._y,a._z=(o-s)*6*e._z+(3*o-4*s+1)*t._z+(-o+s)*6*i._z+(3*o-2*s)*r._z,a._w=(o-s)*6*e._w+(3*o-4*s+1)*t._w+(-o+s)*6*i._w+(3*o-2*s)*r._w,a._isDirty=!0,a}static Normalize(e){let t=n.Zero();return n.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){let r=new n;return n.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){return r.copyFromFloats(Ke(e.x,t.x,i.x),Ke(e.y,t.y,i.y),Ke(e.z,t.z,i.z),Ke(e.w,t.w,i.w))}static Random(e=0,t=1){return new n(Ft(e,t),Ft(e,t),Ft(e,t),Ft(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Ft(e,t),Ft(e,t),Ft(e,t),Ft(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(n.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,a=e.w-t.w;return i*i+r*r+s*s+a*a}static Center(e,t){return n.CenterToRef(e,t,n.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)}};Ae._V8PerformanceHack=new Ae(.5,.5,.5,.5);Object.defineProperties(Ae.prototype,{dimension:{value:[4]},rank:{value:1}});U=class n{static get Use64Bits(){return Wi.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=rl._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,r=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:r}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,Wi.MatrixTrackPrecisionChange&&Wi.MatrixTrackedMatrices.push(this),this._m=new Wi.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;let 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;let e=this._m,t=e[0],i=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],d=e[9],h=e[10],u=e[11],m=e[12],p=e[13],_=e[14],g=e[15],T=h*g-_*u,b=d*g-p*u,R=d*_-p*h,S=f*g-m*u,I=f*_-h*m,x=f*p-m*d,P=+(o*T-l*b+c*R),L=-(a*T-l*S+c*I),y=+(a*b-o*S+c*x),B=-(a*R-o*I+l*x);return t*P+i*L+r*y+s*B}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]} ${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]} ${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]} -${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;let i=this._m;for(let r=0;r<16;r++)e[t+r]=i[r];return this}asArray(){return this._m}fromArray(e,t=0){return n.FromArrayToRef(e,t,this)}copyFromFloats(...e){return n.FromArrayToRef(e,0,this)}set(...e){let t=this._m;for(let i=0;i<16;i++)t[i]=e[i];return this.markAsUpdated(),this}setAll(e){let 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 n.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){let t=new n;return this.addToRef(e,t),t}addToRef(e,t){let i=this._m,r=t._m,s=e.m;for(let a=0;a<16;a++)r[a]=i[a]+s[a];return t.markAsUpdated(),t}addToSelf(e){let 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){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]+=i[r];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]+=e[i];return this.markAsUpdated(),this}subtract(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]-=i[r];return this.markAsUpdated(),this}subtractToRef(e,t){let i=this._m,r=e.m,s=t._m;for(let a=0;a<16;a++)s[a]=i[a]-r[a];return t.markAsUpdated(),t}subtractInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]-=i[r];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new n)}subtractFromFloatsToRef(...e){let t=e.pop(),i=this._m,r=t._m,s=e;for(let a=0;a<16;a++)r[a]=i[a]-s[a];return t.markAsUpdated(),t}invertToRef(e){return this._isIdentity===!0?(n.IdentityToRef(e),e):(g_(this,e.asArray())?e.markAsUpdated():e.copyFrom(this),e)}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new 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(){let e=this.m;return n.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);let t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){return SI(this,e,t),this}multiply(e){let t=new n;return this.multiplyToRef(e,t),t}multiplyInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]*=i[r];return this.markAsUpdated(),this}multiplyByFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){let t=e.pop(),i=this._m,r=t._m,s=e;for(let a=0;a<16;a++)r[a]=i[a]*s[a];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,i){return __(this,e,t,i),this}divide(e){return this.divideToRef(e,new n)}divideToRef(e,t){let i=this._m,r=e.m,s=t._m;for(let a=0;a<16;a++)s[a]=i[a]/r[a];return t.markAsUpdated(),t}divideInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]/=i[r];return this.markAsUpdated(),this}minimizeInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]=Math.min(t[r],i[r]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]=Math.min(t[r],i[r]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){let 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 n)}negateInPlace(){let e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=-t[r];return e.markAsUpdated(),e}equals(e){let t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;let i=this.m,r=t.m;return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]&&i[4]===r[4]&&i[5]===r[5]&&i[6]===r[6]&&i[7]===r[7]&&i[8]===r[8]&&i[9]===r[9]&&i[10]===r[10]&&i[11]===r[11]&&i[12]===r[12]&&i[13]===r[13]&&i[14]===r[14]&&i[15]===r[15]}equalsWithEpsilon(e,t=0){let i=this._m,r=e.m;for(let s=0;s<16;s++)if(!ut(i[s],r[s],t))return!1;return!0}equalsToFloats(...e){let t=this._m;for(let i=0;i<16;i++)if(t[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new n)}floorToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=Math.floor(t[r]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new n)}fractToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=t[r]-Math.floor(t[r]);return e.markAsUpdated(),e}clone(){let e=new n;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=Wi(this._m[0]);for(let t=1;t<16;t++)e=e*397^Wi(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new Ae,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,r,s=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;let a=this._m;if(i&&i.copyFromFloats(a[12],a[13],a[14]),e=e||Se.Vector3[0],e.x=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),e.y=Math.sqrt(a[4]*a[4]+a[5]*a[5]+a[6]*a[6]),e.z=Math.sqrt(a[8]*a[8]+a[9]*a[9]+a[10]*a[10]),r){let o=(s?r.absoluteScaling.x:r.scaling.x)<0?-1:1,l=(s?r.absoluteScaling.y:r.scaling.y)<0?-1:1,c=(s?r.absoluteScaling.z:r.scaling.z)<0?-1:1;e.x*=o,e.y*=l,e.z*=c}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){let o=1/e._x,l=1/e._y,c=1/e._z;n.FromValuesToRef(a[0]*o,a[1]*o,a[2]*o,0,a[4]*l,a[5]*l,a[6]*l,0,a[8]*c,a[9]*c,a[10]*c,0,0,0,0,1,Se.Matrix[0]),Ae.FromRotationMatrixToRef(Se.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;let t=e*4;return new vt(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){let 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(){let e=new n;return n.TransposeToRef(this,e),e}transposeToRef(e){return n.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,r,s){if(e<0||e>3)return this;let a=e*4;return this._m[a+0]=t,this._m[a+1]=i,this._m[a+2]=r,this._m[a+3]=s,this.markAsUpdated(),this}scale(e){let t=new n;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){let t=this._m;for(let i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){let t=Se.Matrix[0];this.invertToRef(t),t.transposeToRef(e);let i=e._m;return n.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(){let e=new n;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){let t=Se.Vector3[0];if(!this.decompose(t))return n.IdentityToRef(e),e;let i=this._m,r=1/t._x,s=1/t._y,a=1/t._z;return n.FromValuesToRef(i[0]*r,i[1]*r,i[2]*r,0,i[4]*s,i[5]*s,i[6]*s,0,i[8]*a,i[9]*a,i[10]*a,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){let e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){let e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){let i=new n;return n.FromArrayToRef(e,t,i),i}static FromArrayToRef(e,t,i){for(let r=0;r<16;r++)i._m[r]=e[r+t];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,t,i,r){return r._m[0]=e[0+t]*i,r._m[1]=e[1+t]*i,r._m[2]=e[2+t]*i,r._m[3]=e[3+t]*i,r._m[4]=e[4+t]*i,r._m[5]=e[5+t]*i,r._m[6]=e[6+t]*i,r._m[7]=e[7+t]*i,r._m[8]=e[8+t]*i,r._m[9]=e[9+t]*i,r._m[10]=e[10+t]*i,r._m[11]=e[11+t]*i,r._m[12]=e[12+t]*i,r._m[13]=e[13+t]*i,r._m[14]=e[14+t]*i,r._m[15]=e[15+t]*i,r.markAsUpdated(),r}static get IdentityReadOnly(){return n._IdentityReadOnly}static FromValuesToRef(e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g){let T=g._m;T[0]=e,T[1]=t,T[2]=i,T[3]=r,T[4]=s,T[5]=a,T[6]=o,T[7]=l,T[8]=c,T[9]=f,T[10]=d,T[11]=h,T[12]=u,T[13]=m,T[14]=p,T[15]=_,g.markAsUpdated()}static FromValues(e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_){let g=new n,T=g._m;return T[0]=e,T[1]=t,T[2]=i,T[3]=r,T[4]=s,T[5]=a,T[6]=o,T[7]=l,T[8]=c,T[9]=f,T[10]=d,T[11]=h,T[12]=u,T[13]=m,T[14]=p,T[15]=_,g.markAsUpdated(),g}static Compose(e,t,i){let r=new n;return n.ComposeToRef(e,t,i,r),r}static ComposeToRef(e,t,i,r){let s=r._m,a=t._x,o=t._y,l=t._z,c=t._w,f=a+a,d=o+o,h=l+l,u=a*f,m=a*d,p=a*h,_=o*d,g=o*h,T=l*h,b=c*f,R=c*d,S=c*h,I=e._x,x=e._y,P=e._z;return s[0]=(1-(_+T))*I,s[1]=(m+S)*I,s[2]=(p-R)*I,s[3]=0,s[4]=(m-S)*x,s[5]=(1-(u+T))*x,s[6]=(g+b)*x,s[7]=0,s[8]=(p+R)*P,s[9]=(g-b)*P,s[10]=(1-(u+_))*P,s[11]=0,s[12]=i._x,s[13]=i._y,s[14]=i._z,s[15]=1,r.markAsUpdated(),r}static Identity(){let e=n.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 n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){let e=n.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){let t=new n;return n.RotationXToRef(e,t),t}static Invert(e){let t=new n;return e.invertToRef(t),t}static RotationXToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(1,0,0,0,0,r,i,0,0,-i,r,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationY(e){let t=new n;return n.RotationYToRef(e,t),t}static RotationYToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(r,0,-i,0,0,1,0,0,i,0,r,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationZ(e){let t=new n;return n.RotationZToRef(e,t),t}static RotationZToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(r,i,0,0,-i,r,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationAxis(e,t){let i=new n;return n.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){let r=Math.sin(-t),s=Math.cos(-t),a=1-s;e=e.normalizeToRef(Se.Vector3[0]);let o=i._m;return o[0]=e._x*e._x*a+s,o[1]=e._x*e._y*a-e._z*r,o[2]=e._x*e._z*a+e._y*r,o[3]=0,o[4]=e._y*e._x*a+e._z*r,o[5]=e._y*e._y*a+s,o[6]=e._y*e._z*a-e._x*r,o[7]=0,o[8]=e._z*e._x*a-e._y*r,o[9]=e._z*e._y*a+e._x*r,o[10]=e._z*e._z*a+s,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,t,i,r=!1){let s=v.Dot(t,e),a=i._m;if(s<-1+Ye)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=r?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=r?-1:1,a[11]=0;else{let o=v.Cross(t,e),l=1/(1+s);a[0]=o._x*o._x*l+s,a[1]=o._y*o._x*l-o._z,a[2]=o._z*o._x*l+o._y,a[3]=0,a[4]=o._x*o._y*l+o._z,a[5]=o._y*o._y*l+s,a[6]=o._z*o._y*l-o._x,a[7]=0,a[8]=o._x*o._z*l-o._y,a[9]=o._y*o._z*l+o._x,a[10]=o._z*o._z*l+s,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){return Ae.RotationYawPitchRollToRef(e,t,i,Se.Quaternion[0]),Se.Quaternion[0].toRotationMatrix(r),r}static Scaling(e,t,i){let r=new n;return n.ScalingToRef(e,t,i,r),r}static ScalingToRef(e,t,i,r){return n.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,r),r._updateIdentityStatus(e===1&&t===1&&i===1),r}static Translation(e,t,i){let r=new n;return n.TranslationToRef(e,t,i,r),r}static TranslationToRef(e,t,i,r){return n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,r),r._updateIdentityStatus(e===0&&t===0&&i===0),r}static Lerp(e,t,i){let r=new n;return n.LerpToRef(e,t,i,r),r}static LerpToRef(e,t,i,r){let s=r._m,a=e.m,o=t.m;for(let l=0;l<16;l++)s[l]=a[l]*(1-i)+o[l]*i;return r.markAsUpdated(),r}static DecomposeLerp(e,t,i){let r=new n;return n.DecomposeLerpToRef(e,t,i,r),r}static DecomposeLerpToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Quaternion[0],o=Se.Vector3[1];e.decompose(s,a,o);let l=Se.Vector3[2],c=Se.Quaternion[1],f=Se.Vector3[3];t.decompose(l,c,f);let d=Se.Vector3[4];v.LerpToRef(s,l,i,d);let h=Se.Quaternion[2];Ae.SlerpToRef(a,c,i,h);let u=Se.Vector3[5];return v.LerpToRef(o,f,i,u),n.ComposeToRef(d,h,u,r),r}static LookAtLH(e,t,i){let r=new n;return n.LookAtLHToRef(e,t,i,r),r}static LookAtLHToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Vector3[1],o=Se.Vector3[2];t.subtractToRef(e,o),o.normalize(),v.CrossToRef(i,o,s);let l=s.lengthSquared();l===0?s.x=1:s.normalizeFromLength(Math.sqrt(l)),v.CrossToRef(o,s,a),a.normalize();let c=-v.Dot(s,e),f=-v.Dot(a,e),d=-v.Dot(o,e);return n.FromValuesToRef(s._x,a._x,o._x,0,s._y,a._y,o._y,0,s._z,a._z,o._z,0,c,f,d,1,r),r}static LookAtRH(e,t,i){let r=new n;return n.LookAtRHToRef(e,t,i,r),r}static LookAtRHToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Vector3[1],o=Se.Vector3[2];e.subtractToRef(t,o),o.normalize(),v.CrossToRef(i,o,s);let l=s.lengthSquared();l===0?s.x=1:s.normalizeFromLength(Math.sqrt(l)),v.CrossToRef(o,s,a),a.normalize();let c=-v.Dot(s,e),f=-v.Dot(a,e),d=-v.Dot(o,e);return n.FromValuesToRef(s._x,a._x,o._x,0,s._y,a._y,o._y,0,s._z,a._z,o._z,0,c,f,d,1,r),r}static LookDirectionLH(e,t){let i=new n;return n.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){let r=Se.Vector3[0];r.copyFrom(e),r.scaleInPlace(-1);let s=Se.Vector3[1];return v.CrossToRef(t,r,s),n.FromValuesToRef(s._x,s._y,s._z,0,t._x,t._y,t._z,0,r._x,r._y,r._z,0,0,0,0,1,i),i}static LookDirectionRH(e,t){let i=new n;return n.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){let r=Se.Vector3[2];return v.CrossToRef(t,e,r),n.FromValuesToRef(r._x,r._y,r._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,r,s){let a=new n;return n.OrthoLHToRef(e,t,i,r,a,s),a}static OrthoLHToRef(e,t,i,r,s,a){let o=i,l=r,c=2/e,f=2/t,d=2/(l-o),h=-(l+o)/(l-o);return n.FromValuesToRef(c,0,0,0,0,f,0,0,0,0,d,0,0,0,h,1,s),a&&s.multiplyToRef(co,s),s._updateIdentityStatus(c===1&&f===1&&d===1&&h===0),s}static OrthoOffCenterLH(e,t,i,r,s,a,o){let l=new n;return n.OrthoOffCenterLHToRef(e,t,i,r,s,a,l,o),l}static OrthoOffCenterLHToRef(e,t,i,r,s,a,o,l){let c=s,f=a,d=2/(t-e),h=2/(r-i),u=2/(f-c),m=-(f+c)/(f-c),p=(e+t)/(e-t),_=(r+i)/(i-r);return n.FromValuesToRef(d,0,0,0,0,h,0,0,0,0,u,0,p,_,m,1,o),l&&o.multiplyToRef(co,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,r,s,a,o,l,c,f,d){let h=-o*Math.cos(l),u=-o*Math.sin(l);return n.TranslationToRef(0,0,-c,Se.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,h,u,1,0,0,0,0,1,Se.Matrix[0]),Se.Matrix[1].multiplyToRef(Se.Matrix[0],Se.Matrix[0]),n.TranslationToRef(0,0,c,Se.Matrix[1]),Se.Matrix[0].multiplyToRef(Se.Matrix[1],Se.Matrix[0]),n.OrthoOffCenterLHToRef(e,t,i,r,s,a,f,d),Se.Matrix[0].multiplyToRef(f,f),f}static OrthoOffCenterRH(e,t,i,r,s,a,o){let l=new n;return n.OrthoOffCenterRHToRef(e,t,i,r,s,a,l,o),l}static OrthoOffCenterRHToRef(e,t,i,r,s,a,o,l){return n.OrthoOffCenterLHToRef(e,t,i,r,s,a,o,l),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,r,s,a,o,l,c,f,d){let h=o*Math.cos(l),u=o*Math.sin(l);return n.TranslationToRef(0,0,c,Se.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,h,u,1,0,0,0,0,1,Se.Matrix[0]),Se.Matrix[1].multiplyToRef(Se.Matrix[0],Se.Matrix[0]),n.TranslationToRef(0,0,-c,Se.Matrix[1]),Se.Matrix[0].multiplyToRef(Se.Matrix[1],Se.Matrix[0]),n.OrthoOffCenterRHToRef(e,t,i,r,s,a,f,d),Se.Matrix[0].multiplyToRef(f,f),f}static PerspectiveLH(e,t,i,r,s,a=0){let o=new n,l=i,c=r,f=2*l/e,d=2*l/t,h=(c+l)/(c-l),u=-2*c*l/(c-l),m=Math.tan(a);return n.FromValuesToRef(f,0,0,0,0,d,0,m,0,0,h,1,0,0,u,0,o),s&&o.multiplyToRef(co,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,r,s,a=0,o=!1){let l=new n;return n.PerspectiveFovLHToRef(e,t,i,r,l,!0,s,a,o),l}static PerspectiveFovLHToRef(e,t,i,r,s,a=!0,o,l=0,c=!1){let f=i,d=r,h=1/Math.tan(e*.5),u=a?h/t:h,m=a?h:h*t,p=c&&f===0?-1:d!==0?(d+f)/(d-f):1,_=c&&f===0?2*d:d!==0?-2*d*f/(d-f):-2*f,g=Math.tan(l);return n.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,1,0,0,_,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovReverseLHToRef(e,t,i,r,s,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,d=a?c:c*t,h=Math.tan(l);return n.FromValuesToRef(f,0,0,0,0,d,0,h,0,0,-i,1,0,0,1,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovRH(e,t,i,r,s,a=0,o=!1){let l=new n;return n.PerspectiveFovRHToRef(e,t,i,r,l,!0,s,a,o),l}static PerspectiveFovRHToRef(e,t,i,r,s,a=!0,o,l=0,c=!1){let f=i,d=r,h=1/Math.tan(e*.5),u=a?h/t:h,m=a?h:h*t,p=c&&f===0?1:d!==0?-(d+f)/(d-f):-1,_=c&&f===0?2*d:d!==0?-2*d*f/(d-f):-2*f,g=Math.tan(l);return n.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,-1,0,0,_,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovReverseRHToRef(e,t,i,r,s,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,d=a?c:c*t,h=Math.tan(l);return n.FromValuesToRef(f,0,0,0,0,d,0,h,0,0,-i,-1,0,0,-1,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static GetFinalMatrix(e,t,i,r,s,a){let o=e.width,l=e.height,c=e.x,f=e.y,d=n.FromValues(o/2,0,0,0,0,-l/2,0,0,0,0,a-s,0,c+o/2,l/2+f,s,1),h=new n;return t.multiplyToRef(i,h),h.multiplyToRef(r,h),h.multiplyToRef(d,h)}static GetAsMatrix2x2(e){let t=e.m,i=[t[0],t[1],t[4],t[5]];return ki.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){let t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return ki.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){let t=new n;return n.TransposeToRef(e,t),t}static TransposeToRef(e,t){let i=e.m,r=i[0],s=i[4],a=i[8],o=i[12],l=i[1],c=i[5],f=i[9],d=i[13],h=i[2],u=i[6],m=i[10],p=i[14],_=i[3],g=i[7],T=i[11],b=i[15],R=t._m;return R[0]=r,R[1]=s,R[2]=a,R[3]=o,R[4]=l,R[5]=c,R[6]=f,R[7]=d,R[8]=h,R[9]=u,R[10]=m,R[11]=p,R[12]=_,R[13]=g,R[14]=T,R[15]=b,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){let t=new n;return n.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();let i=e.normal.x,r=e.normal.y,s=e.normal.z,a=-2*i,o=-2*r,l=-2*s;return n.FromValuesToRef(a*i+1,o*i,l*i,0,a*r,o*r+1,l*r,0,a*s,o*s,l*s+1,0,a*e.d,o*e.d,l*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,r){return n.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,r),r}static FromQuaternionToRef(e,t){let i=e._x*e._x,r=e._y*e._y,s=e._z*e._z,a=e._x*e._y,o=e._z*e._w,l=e._z*e._x,c=e._y*e._w,f=e._y*e._z,d=e._x*e._w;return t._m[0]=1-2*(r+s),t._m[1]=2*(a+o),t._m[2]=2*(l-c),t._m[3]=0,t._m[4]=2*(a-o),t._m[5]=1-2*(s+i),t._m[6]=2*(f+d),t._m[7]=0,t._m[8]=2*(l+c),t._m[9]=2*(f-d),t._m[10]=1-2*(r+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}};G._IdentityReadOnly=G.Identity();Object.defineProperties(G.prototype,{dimension:{value:[4,4]},rank:{value:2}});Se=class{};Se.Vector3=ss(11,v.Zero);Se.Matrix=ss(2,G.Identity);Se.Quaternion=ss(3,Ae.Zero);k=class{};k.Vector2=ss(3,_e.Zero);k.Vector3=ss(13,v.Zero);k.Vector4=ss(3,vt.Zero);k.Quaternion=ss(3,Ae.Zero);k.Matrix=ss(8,G.Identity);je("BABYLON.Vector2",_e);je("BABYLON.Vector3",v);je("BABYLON.Vector4",vt);je("BABYLON.Matrix",G);co=G.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)});var AI,$i,RI,rl=A(()=>{ve();(function(n){n[n.LOCAL=0]="LOCAL",n[n.WORLD=1]="WORLD",n[n.BONE=2]="BONE"})(AI||(AI={}));$i=class{};$i.X=new v(1,0,0);$i.Y=new v(0,1,0);$i.Z=new v(0,0,1);(function(n){n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=2]="Z"})(RI||(RI={}))});function nl(n){return Math.pow(n,tl)}function sl(n){return n<=.04045?.0773993808*n:Math.pow(.947867299*(n+.055),2.4)}function al(n){return Math.pow(n,pI)}function ol(n){return n<=.0031308?12.92*n:1.055*Math.pow(n,.41666)-.055}var oe,Ne,Ri,et=A(()=>{Ln();Lt();Ci();bi();oe=class n{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 n.FromArrayToRef(e,t,this),this}toColor4(e=1){return new Ne(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 n(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 n(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=Ye){return ut(this.r,e.r,t)&&ut(this.g,e.g,t)&&ut(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 n(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=Ke(this.r,e,t),i.g=Ke(this.g,e,t),i.b=Ke(this.b,e,t),i}add(e){return new n(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 n(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 n(this.r-e,this.g-t,this.b-i)}subtractFromFloatsToRef(e,t,i,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r}clone(){return new n(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(){let e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+rn(e)+rn(t)+rn(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 n)}toHSVToRef(e){let t=this.r,i=this.g,r=this.b,s=Math.max(t,i,r),a=Math.min(t,i,r),o=0,l=0,c=s,f=s-a;return s!==0&&(l=f/s),s!=a&&(s==t?(o=(i-r)/f,i=0&&a<=1?(l=s,c=o):a>=1&&a<=2?(l=o,c=s):a>=2&&a<=3?(c=s,f=o):a>=3&&a<=4?(c=o,f=s):a>=4&&a<=5?(l=o,f=s):a>=5&&a<=6&&(l=s,f=o);let d=i-s;return r.r=l+d,r.g=c+d,r.b=f+d,r}static FromHSV(e,t,i){let r=new n(0,0,0);return n.HSVtoRGBToRef(e,t,i,r),r}static FromHexString(e){return new n(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new n(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 n(e/255,t/255,i/255)}static Lerp(e,t,i){let r=new n(0,0,0);return n.LerpToRef(e,t,i,r),r}static LerpToRef(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.r*l+i.r*c+t.r*f+r.r*d,u=e.g*l+i.g*c+t.g*f+r.g*d,m=e.b*l+i.b*c+t.b*f+r.b*d;return new n(h,u,m)}static Hermite1stDerivative(e,t,i,r,s){let a=n.Black();return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;a.r=(o-s)*6*e.r+(3*o-4*s+1)*t.r+(-o+s)*6*i.r+(3*o-2*s)*r.r,a.g=(o-s)*6*e.g+(3*o-4*s+1)*t.g+(-o+s)*6*i.g+(3*o-2*s)*r.g,a.b=(o-s)*6*e.b+(3*o-4*s+1)*t.b+(-o+s)*6*i.b+(3*o-2*s)*r.b}static Red(){return new n(1,0,0)}static Green(){return new n(0,1,0)}static Blue(){return new n(0,0,1)}static Black(){return new n(0,0,0)}static get BlackReadOnly(){return n._BlackReadOnly}static White(){return new n(1,1,1)}static Purple(){return new n(.5,0,.5)}static Magenta(){return new n(1,0,1)}static Yellow(){return new n(1,1,0)}static Gray(){return new n(.5,.5,.5)}static Teal(){return new n(0,1,1)}static Random(){return new n(Math.random(),Math.random(),Math.random())}};oe._V8PerformanceHack=new oe(.5,.5,.5);oe._BlackReadOnly=oe.Black();Object.defineProperties(oe.prototype,{dimension:{value:[3]},rank:{value:1}});Ne=class n{constructor(e=0,t=0,i=0,r=1){this.r=e,this.g=t,this.b=i,this.a=r}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 n(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,r){return this.r+=e,this.g+=t,this.b+=i,this.a+=r,this}subtract(e){return new n(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,r){return new n(this.r-e,this.g-t,this.b-i,this.a-r)}subtractFromFloatsToRef(e,t,i,r,s){return s.r=this.r-e,s.g=this.g-t,s.b=this.b-i,s.a=this.a-r,s}scale(e){return new n(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=Ke(this.r,e,t),i.g=Ke(this.g,e,t),i.b=Ke(this.b,e,t),i.a=Ke(this.a,e,t),i}multiply(e){return new n(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,r){return new n(this.r*e,this.g*t,this.b*i,this.a*r)}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,r){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(r,this.a),this}maximizeInPlaceFromFloats(e,t,i,r){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(r,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=Ye){return ut(this.r,e.r,t)&&ut(this.g,e.g,t)&&ut(this.b,e.b,t)&&ut(this.a,e.a,t)}equalsToFloats(e,t,i,r){return this.r===e&&this.g===t&&this.b===i&&this.a===r}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 n().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,r){return this.r=e,this.g=t,this.b=i,this.a=r,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){let t=Math.round(this.r*255),i=Math.round(this.g*255),r=Math.round(this.b*255);if(e)return"#"+rn(t)+rn(i)+rn(r);let s=Math.round(this.a*255);return"#"+rn(t)+rn(i)+rn(r)+rn(s)}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){let t=new n;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=sl(this.r),e.g=sl(this.g),e.b=sl(this.b)):(e.r=nl(this.r),e.g=nl(this.g),e.b=nl(this.b)),e.a=this.a,this}toGammaSpace(e=!1){let t=new n;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=ol(this.r),e.g=ol(this.g),e.b=ol(this.b)):(e.r=al(this.r),e.g=al(this.g),e.b=al(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new n(0,0,0,0):new n(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return n.LerpToRef(e,t,i,new n)}static LerpToRef(e,t,i,r){return r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i,r}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.r*l+i.r*c+t.r*f+r.r*d,u=e.g*l+i.g*c+t.g*f+r.g*d,m=e.b*l+i.b*c+t.b*f+r.b*d,p=e.a*l+i.a*c+t.a*f+r.a*d;return new n(h,u,m,p)}static Hermite1stDerivative(e,t,i,r,s){let a=new n;return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;a.r=(o-s)*6*e.r+(3*o-4*s+1)*t.r+(-o+s)*6*i.r+(3*o-2*s)*r.r,a.g=(o-s)*6*e.g+(3*o-4*s+1)*t.g+(-o+s)*6*i.g+(3*o-2*s)*r.g,a.b=(o-s)*6*e.b+(3*o-4*s+1)*t.b+(-o+s)*6*i.b+(3*o-2*s)*r.b,a.a=(o-s)*6*e.a+(3*o-4*s+1)*t.a+(-o+s)*6*i.a+(3*o-2*s)*r.a}static FromColor3(e,t=1){return new n(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new n(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,r){return new n(e/255,t/255,i/255,r/255)}static CheckColors4(e,t){if(e.length===t*3){let i=[];for(let r=0;rnew Ne(0,0,0,0));je("BABYLON.Color3",oe);je("BABYLON.Color4",Ne)});var er,fo=A(()=>{ve();er=class n{constructor(e,t,i,r){this.normal=new v(e,t,i),this.d=r}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new n(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(){let e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),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){let t=n._TmpMatrix;e.invertToRef(t);let i=t.m,r=this.normal.x,s=this.normal.y,a=this.normal.z,o=this.d,l=r*i[0]+s*i[1]+a*i[2]+o*i[3],c=r*i[4]+s*i[5]+a*i[6]+o*i[7],f=r*i[8]+s*i[9]+a*i[10]+o*i[11],d=r*i[12]+s*i[13]+a*i[14]+o*i[15];return new n(l,c,f,d)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,i){let r=t.x-e.x,s=t.y-e.y,a=t.z-e.z,o=i.x-e.x,l=i.y-e.y,c=i.z-e.z,f=s*c-a*l,d=a*o-r*c,h=r*l-s*o,u=Math.sqrt(f*f+d*d+h*h),m;return u!==0?m=1/u:m=0,this.normal.x=f*m,this.normal.y=d*m,this.normal.z=h*m,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 n(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){let r=new n(0,0,0,0);return r.copyFromPoints(e,t,i),r}static FromPositionAndNormal(e,t){let i=new n(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){let r=-(t.x*e.x+t.y*e.y+t.z*e.z);return v.Dot(i,t)+r}};er._TmpMatrix=G.Identity()});var oa,sh=A(()=>{fo();oa=class n{static GetPlanes(e){let t=[];for(let i=0;i<6;i++)t.push(new er(0,0,0,0));return n.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){let 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){let 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){let 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){let 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){let 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){let 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){n.GetNearPlaneToRef(e,t[0]),n.GetFarPlaneToRef(e,t[1]),n.GetLeftPlaneToRef(e,t[2]),n.GetRightPlaneToRef(e,t[3]),n.GetTopPlaneToRef(e,t[4]),n.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 II,ll,v_,cl,ho,uo=A(()=>{bi();ve();Ci();(function(n){n[n.CW=0]="CW",n[n.CCW=1]="CCW"})(II||(II={}));ll=class n{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){let i=t.subtract(e),r=Math.atan2(i.y,i.x);return new n(r)}static BetweenTwoVectors(e,t){let i=e.lengthSquared()*t.lengthSquared();if(i===0)return new n(Math.PI/2);i=Math.sqrt(i);let r=e.dot(t)/i;r=Ke(r,-1,1);let s=Math.acos(r);return new n(s)}static FromRadians(e){return new n(e)}static FromDegrees(e){return new n(e*Math.PI/180)}},v_=class{constructor(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;let r=Math.pow(t.x,2)+Math.pow(t.y,2),s=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,a=(r-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 _e((s*(t.y-i.y)-a*(e.y-t.y))/o,((e.x-t.x)*a-(t.x-i.x)*s)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=ll.BetweenTwoPoints(this.centerPoint,this.startPoint);let l=this.startAngle.degrees(),c=ll.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),f=ll.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-l>180&&(c-=360),c-l<-180&&(c+=360),f-c>180&&(f-=360),f-c<-180&&(f+=360),this.orientation=c-l<0?0:1,this.angle=ll.FromDegrees(this.orientation===0?l-f:f-l)}},cl=class n{constructor(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new _e(e,t))}addLineTo(e,t){if(this.closed)return this;let i=new _e(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this}addArcTo(e,t,i,r,s=36){if(this.closed)return this;let a=this._points[this._points.length-1],o=new _e(e,t),l=new _e(i,r),c=new v_(a,o,l),f=c.angle.radians()/s;c.orientation===0&&(f*=-1);let d=c.startAngle.radians()+f;for(let h=0;h(1-l)*(1-l)*c+2*l*(1-l)*f+l*l*d,o=this._points[this._points.length-1];for(let l=0;l<=s;l++){let c=l/s,f=a(c,o.x,e,i),d=a(c,o.y,t,r);this.addLineTo(f,d)}return this}addBezierCurveTo(e,t,i,r,s,a,o=36){if(this.closed)return this;let l=(f,d,h,u,m)=>(1-f)*(1-f)*(1-f)*d+3*f*(1-f)*(1-f)*h+3*f*f*(1-f)*u+f*f*f*m,c=this._points[this._points.length-1];for(let f=0;f<=o;f++){let d=f/o,h=l(d,c.x,e,i,s),u=l(d,c.y,t,r,a);this.addLineTo(h,u)}return this}isPointInside(e){let t=!1,i=this._points.length;for(let r=i-1,s=0;sNumber.EPSILON){if(c<0&&(a=this._points[s],l=-l,o=this._points[r],c=-c),e.yo.y)continue;if(e.y===a.y&&e.x===a.x)return!0;{let f=c*(e.x-a.x)-l*(e.y-a.y);if(f===0)return!0;if(f<0)continue;t=!t}}else{if(e.y!==a.y)continue;if(o.x<=e.x&&e.x<=a.x||a.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){let t=this._points[this._points.length-1],i=this._points[0];e+=i.subtract(t).length()}return e}area(){let e=this._points.length,t=0;for(let i=e-1,r=0;r1)return _e.Zero();let t=e*this.length(),i=0;for(let r=0;r=i&&t<=c){let f=l.normalize(),d=t-i;return new _e(a.x+f.x*d,a.y+f.y*d)}i=c}return _e.Zero()}static StartingAt(e,t){return new n(e,t)}},ho=class n{constructor(e,t=null,i,r=!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:G.Identity()};for(let s=0;st){let c=e;e=t,t=c}let i=this.getCurve(),r=this.getPointAt(e),s=this.getPreviousPointIndexAt(e),a=this.getPointAt(t),o=this.getPreviousPointIndexAt(t)+1,l=[];return e!==0&&(s++,l.push(r)),l.push(...i.slice(s,o)),(t!==1||e===1)&&l.push(a),new n(l,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)}update(e,t=null,i=!1){for(let r=0;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i}_normalVector(e,t){let i,r=e.length();if(r===0&&(r=1),t==null){let s;ut(Math.abs(e.y)/r,1,Ye)?ut(Math.abs(e.x)/r,1,Ye)?ut(Math.abs(e.z)/r,1,Ye)?s=v.Zero():s=new v(0,0,1):s=new v(1,0,0):s=new v(0,-1,0),i=v.Cross(e,s)}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;let 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 r=i[0],s,a=0,o=e*this.length();for(let l=1;lo){let d=(a-o)/c,h=r.subtract(s),u=s.add(h.scaleInPlace(d));return this._setPointAtData(e,1-d,u,l-1,t)}r=s}return this._pointAtData}_setPointAtData(e,t,i,r,s){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=s,s&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=G.Identity();let e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){let t=e+1,i=this._tangents[e].clone(),r=this._normals[e].clone(),s=this._binormals[e].clone(),a=this._tangents[t].clone(),o=this._normals[t].clone(),l=this._binormals[t].clone(),c=Ae.RotationQuaternionFromAxis(r,s,i),f=Ae.RotationQuaternionFromAxis(o,l,a);Ae.Slerp(c,f,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}});var as,ah=A(()=>{as=class n{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=this.width|0;return e=e*397^(this.height|0),e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new n(this.width*e,this.height*t)}clone(){return new n(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 n(0,0)}add(e){return new n(this.width+e.width,this.height+e.height)}subtract(e){return new n(this.width-e.width,this.height-e.height)}scale(e){return new n(this.width*e,this.height*e)}static Lerp(e,t,i){let r=e.width+(t.width-e.width)*i,s=e.height+(t.height-e.height)*i;return new n(r,s)}}});var xI=A(()=>{ve()});var nn,fl=A(()=>{nn=class n{constructor(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}toGlobal(e,t){return new n(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 n(this.x,this.y,this.width,this.height)}}});var CI=A(()=>{rl();et();Ci();sh();uo();fo();ah();ve();xI();fl()});var Pn,uV,os,ls,zc,On,Xc=A(()=>{ve();CI();Pn=[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))],uV=[()=>1,n=>n.y,n=>n.z,n=>n.x,n=>n.x*n.y,n=>n.y*n.z,n=>3*n.z*n.z-1,n=>n.x*n.z,n=>n.x*n.x-n.y*n.y],os=(n,e)=>Pn[n]*uV[n](e),ls=[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],zc=class n{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){k.Vector3[0].set(t.r,t.g,t.b);let r=k.Vector3[0],s=k.Vector3[1];r.scaleToRef(i,s),s.scaleToRef(os(0,e),k.Vector3[2]),this.l00.addInPlace(k.Vector3[2]),s.scaleToRef(os(1,e),k.Vector3[2]),this.l1_1.addInPlace(k.Vector3[2]),s.scaleToRef(os(2,e),k.Vector3[2]),this.l10.addInPlace(k.Vector3[2]),s.scaleToRef(os(3,e),k.Vector3[2]),this.l11.addInPlace(k.Vector3[2]),s.scaleToRef(os(4,e),k.Vector3[2]),this.l2_2.addInPlace(k.Vector3[2]),s.scaleToRef(os(5,e),k.Vector3[2]),this.l2_1.addInPlace(k.Vector3[2]),s.scaleToRef(os(6,e),k.Vector3[2]),this.l20.addInPlace(k.Vector3[2]),s.scaleToRef(os(7,e),k.Vector3[2]),this.l21.addInPlace(k.Vector3[2]),s.scaleToRef(os(8,e),k.Vector3[2]),this.l22.addInPlace(k.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(ls[0]),this.l1_1.scaleInPlace(ls[1]),this.l10.scaleInPlace(ls[2]),this.l11.scaleInPlace(ls[3]),this.l2_2.scaleInPlace(ls[4]),this.l2_1.scaleInPlace(ls[5]),this.l20.scaleInPlace(ls[6]),this.l21.scaleInPlace(ls[7]),this.l22.scaleInPlace(ls[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(Pn[0]),this.l1_1.scaleInPlace(Pn[1]),this.l10.scaleInPlace(Pn[2]),this.l11.scaleInPlace(Pn[3]),this.l2_2.scaleInPlace(Pn[4]),this.l2_1.scaleInPlace(Pn[5]),this.l20.scaleInPlace(Pn[6]),this.l21.scaleInPlace(Pn[7]),this.l22.scaleInPlace(Pn[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 n().updateFromArray(e)}static FromPolynomial(e){let t=new n;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}},On=class n{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=zc.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){k.Vector3[0].copyFromFloats(e.r,e.g,e.b);let t=k.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),k.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),k.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(k.Vector3[0]).addInPlace(k.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(k.Vector3[0]).subtractInPlace(k.Vector3[1]),this.zz.copyFrom(e.l00),k.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(k.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 n().updateFromHarmonics(e)}static FromArray(e){let t=new n;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 C(n,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,i);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(s=(r<3?a(s):r>3?a(e,t,s):a(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}var Qe=A(()=>{});function bI(n){let e=n.getClassName();return lh[e]||(lh[e]={}),lh[e]}function ch(n){let e=n.getClassName();if(oh[e])return oh[e];oh[e]={};let t=oh[e],i=n,r=e;for(;r;){let s=lh[r];for(let l in s)t[l]=s[l];let a,o=!1;do{if(a=Object.getPrototypeOf(i),!a.getClassName){o=!0;break}if(a.getClassName()!==r)break;i=a}while(a);if(o)break;r=a.getClassName(),i=a}return t}var oh,lh,T_=A(()=>{oh={},lh={}});function Dr(n,e){return(t,i)=>{let r=bI(t);r[i]||(r[i]={type:n,sourceName:e})}}function mV(n,e=null){return(t,i)=>{let r=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[r]},set:function(s){var a;typeof((a=this[r])==null?void 0:a.equals)=="function"&&this[r].equals(s)||this[r]!==s&&(this[r]=s,t[n].apply(this))},enumerable:!0,configurable:!0})}}function ee(n,e=null){return mV(n,e)}function D(n){return Dr(0,n)}function Ze(n){return Dr(1,n)}function Ht(n){return Dr(2,n)}function dl(n){return Dr(3,n)}function hl(n){return Dr(4,n)}function ai(n){return Dr(5,n)}function fh(n){return Dr(6,n)}function MI(n){return Dr(7,n)}function ul(n){return Dr(8,n)}function yI(n){return Dr(9,n)}function DI(n){return Dr(10,n)}function LI(n){return Dr(11,n)}function tr(n,e,t,i){let r=t.value;t.value=(...s)=>{let a=r;if(typeof _native!="undefined"&&_native[e]){let o=_native[e];i?a=(...l)=>i(...l)?o(...l):r(...l):a=o}return n[e]=a,a(...s)}}function Be(n,e=null){return(t,i)=>{let r=i;Object.defineProperty(t,e||"",{get:function(){return this[r].value},set:function(a){var o,l;typeof((l=(o=this[r])==null?void 0:o.value)==null?void 0:l.equals)=="function"&&this[r].value.equals(a)||this[r].value!==a&&(this[r].value=a,t[n].apply(this))},enumerable:!0,configurable:!0})}}var qe=A(()=>{T_();tr.filter=function(n){return(e,t,i)=>tr(e,t,i,n)}});function la(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}var Yc=A(()=>{});function pV(){return typeof _native!="undefined"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}var $t,mo=A(()=>{$t=class n{constructor(){this._xhr=pV(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(n.CustomRequestHeaders).length>0||n.CustomRequestModifiers.length>0}static _CleanUrl(e){return e=e.replace("file:http:","http:"),e=e.replace("file:https:","https:"),e}static _ShouldSkipRequestModifications(e){return n.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}static _CollectCustomizations(e,t={}){let i={...t};if(n._ShouldSkipRequestModifications(e))return{url:e,headers:i};for(let s in n.CustomRequestHeaders){let a=n.CustomRequestHeaders[s];a&&(i[s]=a)}let r={setRequestHeader:(s,a)=>{i[s]=a}};for(let s of n.CustomRequestModifiers){if(n._ShouldSkipRequestModifications(e))break;let a=s(r,e);typeof a=="string"&&(e=a)}return{url:e,headers:i}}static async FetchAsync(e,t={}){var r,s,a;let i=(r=t.method)!=null?r:"GET";if(typeof fetch!="undefined"){let{url:o,headers:l}=n._CollectCustomizations(n._CleanUrl(e),(s=t.headers)!=null?s:{});return await fetch(o,{method:i,headers:l,body:(a=t.body)!=null?a:void 0})}return await new Promise((o,l)=>{var f;let c=new n;c.responseType="arraybuffer",c.addEventListener("readystatechange",()=>{if(c.readyState===4)if(c.status>=200&&c.status<300){let d=typeof Headers!="undefined"?new Headers:void 0,h=c.getResponseHeader("Content-Type");h&&d&&d.set("Content-Type",h),o(typeof Response!="undefined"?new Response(c.response,{status:c.status,statusText:c.statusText,headers:d}):{ok:!0,status:c.status,statusText:c.statusText,headers:{get:u=>c.getResponseHeader(u)},arrayBuffer:async()=>await Promise.resolve(c.response)})}else l(new Error(`HTTP ${c.status} loading '${c.requestURL}': ${c.statusText}`))}),c.open(i,e,t.headers),c.send((f=t.body)!=null?f:null)})}get requestURL(){return this._requestURL}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){this._xhr.send(e)}open(e,t,i){let{url:r,headers:s}=n._CollectCustomizations(t,i);this._requestURL=n._CleanUrl(r),this._xhr.open(e,this._requestURL,!0);for(let a in s)this._xhr.setRequestHeader(a,s[a])}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}};$t.CustomRequestHeaders={};$t.CustomRequestModifiers=new Array;$t.SkipRequestModificationForBabylonCDN=!0});var ca,PI=A(()=>{ca=class{};ca.FilesToLoad={}});var dh,OI=A(()=>{dh=class{static ExponentialBackoff(e=3,t=500){return(i,r,s)=>r.status!==0||s>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,s)*t}}});var cs,Lr,ir,Kc=A(()=>{cs=class extends Error{};cs._setPrototypeOf=Object.setPrototypeOf||((n,e)=>(n.__proto__=e,n));Lr={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},ir=class n extends cs{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",cs._setPrototypeOf(this,n.prototype)}}});function _V(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",i,r,s,a,o,l,c,f=0;for(;f>2,o=(i&3)<<4|r>>4,l=(r&15)<<2|s>>6,c=s&63,isNaN(r)?l=c=64:isNaN(s)&&(c=64),t+=e.charAt(a)+e.charAt(o)+e.charAt(l)+e.charAt(c);return t}function gV(n){let e=S_(n),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let r=0;r{NI=n=>{if(typeof TextDecoder!="undefined")return new TextDecoder().decode(n);let e="";for(let t=0;t{let e=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);return typeof e.toBase64=="function"?e.toBase64():_V(e)},S_=n=>atob(n),FI=n=>typeof Uint8Array.fromBase64=="function"?Uint8Array.fromBase64(n).buffer:gV(n)});function EV(n,e,t,i){switch(e){case 5120:{let r=n.getInt8(t);return i&&(r=Math.max(r/127,-1)),r}case 5121:{let r=n.getUint8(t);return i&&(r=r/255),r}case 5122:{let r=n.getInt16(t,!0);return i&&(r=Math.max(r/32767,-1)),r}case 5123:{let r=n.getUint16(t,!0);return i&&(r=r/65535),r}case 5124:return n.getInt32(t,!0);case 5125:return n.getUint32(t,!0);case 5126:return n.getFloat32(t,!0);default:throw new Error(`Invalid component type ${e}`)}}function vV(n,e,t,i,r){switch(e){case 5120:{i&&(r=Math.round(r*127)),n.setInt8(t,r);break}case 5121:{i&&(r=Math.round(r*255)),n.setUint8(t,r);break}case 5122:{i&&(r=Math.round(r*32767)),n.setInt16(t,r,!0);break}case 5123:{i&&(r=Math.round(r*65535)),n.setUint16(t,r,!0);break}case 5124:{n.setInt32(t,r,!0);break}case 5125:{n.setUint32(t,r,!0);break}case 5126:{n.setFloat32(t,r,!0);break}default:throw new Error(`Invalid component type ${e}`)}}function Nn(n){switch(n){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5124:case 5125:case 5126:return 4;default:throw new Error(`Invalid type '${n}'`)}}function A_(n){switch(n){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(`Invalid component type '${n}'`)}}function po(n,e,t,i,r,s,a,o){let l=new Array(i),c=new Array(i);if(n instanceof Array){let f=e/4,d=t/4;for(let h=0;h{for(let u=0;un.length)throw new Error("Last accessed index is out of bounds.");if(p{for(let R=0;Rf.byteLength)throw new Error("Last accessed byte is out of bounds.");let u=e*o;if(r{for(let g=0;g{for(let h=0;h{ze()});function da(n){return FI(n.split(",")[1])}var VI,_l,uh,I_,TV,Mt,mh,UI,gl,_o,Fn,ph,GI,kI,fa,WI,HI,SV,Zc,AV,fs=A(()=>{mo();yr();ct();PI();OI();Kc();jc();zd();At();ze();Mn();aa();ii();pl();VI=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),_l=class n extends ir{constructor(e,t){super(e,Lr.LoadFileError),this.name="LoadFileError",cs._setPrototypeOf(this,n.prototype),t instanceof $t?this.request=t:this.file=t}},uh=class n extends ir{constructor(e,t){super(e,Lr.RequestFileError),this.request=t,this.name="RequestFileError",cs._setPrototypeOf(this,n.prototype)}},I_=class n extends ir{constructor(e,t){super(e,Lr.ReadFileError),this.file=t,this.name="ReadFileError",cs._setPrototypeOf(this,n.prototype)}},TV=n=>(n=n.replace(/#/gm,"%23"),n),Mt={DefaultRetryStrategy:dh.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:n=>n,ScriptBaseUrl:"",ScriptPreprocessUrl:n=>n,CleanUrl:TV},mh=(n,e)=>{if(!(n&&n.indexOf("data:")===0)&&Mt.CorsBehavior)if(typeof Mt.CorsBehavior=="string"||Mt.CorsBehavior instanceof String)e.crossOrigin=Mt.CorsBehavior;else{let t=Mt.CorsBehavior(n);t&&(e.crossOrigin=t)}},UI={getRequiredSize:null},gl=(n,e,t,i,r="",s,a=ue.LastCreatedEngine)=>{if(typeof HTMLImageElement=="undefined"&&!(a!=null&&a._features.forceBitmapOverHTMLImageElement))return t("LoadImage is only supported in web or BabylonNative environments."),null;let o,l=!1;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))if(typeof Blob!="undefined"&&typeof URL!="undefined"){let S;n instanceof ArrayBuffer?S=n:S=hh(n),o=URL.createObjectURL(new Blob([S],{type:r})),l=!0}else o=`data:${r};base64,`+ml(n);else n instanceof Blob?(o=URL.createObjectURL(n),l=!0):(o=Mt.CleanUrl(n),o=Mt.PreprocessUrl(o));let c=S=>{if(t){let I=o||n.toString();t(`Error while trying to load image: ${I.indexOf("http")===0||I.length<=128?I:I.slice(0,128)+"..."}`,S)}};if(a!=null&&a._features.forceBitmapOverHTMLImageElement)return Fn(o,S=>{a.createImageBitmap(new Blob([S],{type:r}),{premultiplyAlpha:"none",colorSpaceConversion:"none",...s}).then(I=>{e(I),l&&URL.revokeObjectURL(o)}).catch(I=>{t&&t("Error while trying to load image: "+n,I)})},void 0,i||void 0,!0,(S,I)=>{c(I)}),null;let f=new Image;if(UI.getRequiredSize){let S=UI.getRequiredSize(n);S.width&&(f.width=S.width),S.height&&(f.height=S.height)}mh(o,f);let d=[],h=()=>{for(let S of d)S.target.addEventListener(S.name,S.handler)},u=()=>{for(let S of d)S.target.removeEventListener(S.name,S.handler);d.length=0},m=()=>{u(),e(f),l&&f.src&&URL.revokeObjectURL(f.src)},p=S=>{u(),c(S),l&&f.src&&URL.revokeObjectURL(f.src)},_=S=>{if(S.blockedURI!==f.src||S.disposition==="report")return;u();let I=new Error(`CSP violation of policy ${S.effectiveDirective} ${S.blockedURI}. Current policy is ${S.originalPolicy}`);ue.UseFallbackTexture=!1,c(I),l&&f.src&&URL.revokeObjectURL(f.src),f.src=""};d.push({target:f,name:"load",handler:m}),d.push({target:f,name:"error",handler:p}),d.push({target:document,name:"securitypolicyviolation",handler:_}),h();let g=o.substring(0,5)==="blob:",T=o.substring(0,5)==="data:",b=()=>{g||T||!$t.IsCustomRequestAvailable?f.src=o:Fn(o,(S,I,x)=>{let P=!r&&x?x:r,L=new Blob([S],{type:P}),y=URL.createObjectURL(L);l=!0,f.src=y},void 0,i||void 0,!0,(S,I)=>{c(I)})},R=()=>{i&&i.loadImage(o,f)};if(!g&&!T&&i&&i.enableTexturesOffline)i.open(R,b);else{if(o.indexOf("file:")!==-1){let S=decodeURIComponent(o.substring(5).toLowerCase());if(ca.FilesToLoad[S]&&typeof URL!="undefined"){try{let I;try{I=URL.createObjectURL(ca.FilesToLoad[S])}catch(x){I=URL.createObjectURL(ca.FilesToLoad[S])}f.src=I,l=!0}catch(I){f.src=""}return f}}b()}return f},_o=(n,e,t,i,r)=>{let s=new FileReader,a={onCompleteObservable:new Y,abort:()=>s.abort()};return s.onloadend=()=>a.onCompleteObservable.notifyObservers(a),r&&(s.onerror=()=>{r(new I_(`Unable to read ${n.name}`,n))}),s.onload=o=>{e(o.target.result)},t&&(s.onprogress=t),i?s.readAsArrayBuffer(n):s.readAsText(n),a},Fn=(n,e,t,i,r,s,a)=>{if(n.name)return _o(n,e,t,r,s?f=>{s(void 0,f)}:void 0);let o=n;if(o.indexOf("file:")!==-1){let f=decodeURIComponent(o.substring(5).toLowerCase());f.indexOf("./")===0&&(f=f.substring(2));let d=ca.FilesToLoad[f];if(d)return _o(d,e,t,r,s?h=>s(void 0,new _l(h.message,h.file)):void 0)}let{match:l,type:c}=WI(o);if(l){let f={onCompleteObservable:new Y,abort:()=>()=>{}};try{let d=r?da(o):HI(o);e(d,void 0,c)}catch(d){s?s(void 0,d):W.Error(d.message||"Failed to parse the Data URL")}return en.SetImmediate(()=>{f.onCompleteObservable.notifyObservers(f)}),f}return ph(o,(f,d)=>{e(f,d==null?void 0:d.responseURL,d==null?void 0:d.getResponseHeader("content-type"))},t,i,r,s?f=>{s(f.request,new _l(f.message,f.request))}:void 0,a)},ph=(n,e,t,i,r,s,a)=>{var d;i!==null&&(i!=null||(i=(d=ue.LastCreatedScene)==null?void 0:d.offlineProvider)),n=Mt.CleanUrl(n),n=Mt.PreprocessUrl(n);let o=Mt.BaseUrl+n,l=!1,c={onCompleteObservable:new Y,abort:()=>l=!0},f=()=>{let h=new $t,u=null,m,p=()=>{h&&(t&&h.removeEventListener("progress",t),m&&h.removeEventListener("readystatechange",m),h.removeEventListener("loadend",_))},_=()=>{p(),c.onCompleteObservable.notifyObservers(c),c.onCompleteObservable.clear(),t=void 0,m=null,_=null,s=void 0,a=void 0,e=void 0};c.abort=()=>{l=!0,_&&_(),h&&h.readyState!==(XMLHttpRequest.DONE||4)&&h.abort(),u!==null&&(clearTimeout(u),u=null),h=null};let g=b=>{let R=b.message||"Unknown error";s&&h?s(new uh(R,h)):W.Error(R)},T=b=>{if(h){if(h.open("GET",o),a)try{a(h)}catch(R){g(R);return}r&&(h.responseType="arraybuffer"),t&&h.addEventListener("progress",t),_&&h.addEventListener("loadend",_),m=()=>{if(!(l||!h)&&h.readyState===(XMLHttpRequest.DONE||4)){if(m&&h.removeEventListener("readystatechange",m),h.status>=200&&h.status<300||h.status===0&&(!Bt()||kI())){let I=r?h.response:h.responseText;if(I!==null){try{e&&e(I,h)}catch(x){g(x)}return}}let R=Mt.DefaultRetryStrategy;if(R){let I=R(o,h,b);if(I!==-1){p(),h=new $t,u=setTimeout(()=>T(b+1),I);return}}let S=new uh("Error status: "+h.status+" "+h.statusText+" - Unable to load "+o,h);s&&s(S)}},h.addEventListener("readystatechange",m),h.send()}};T(0)};if(i&&i.enableSceneOffline&&!n.startsWith("blob:")){let h=m=>{m&&m.status>400?s&&s(m):f()},u=()=>{i&&i.loadFile(Mt.BaseUrl+n,m=>{!l&&e&&e(m),c.onCompleteObservable.notifyObservers(c)},t?m=>{!l&&t&&t(m)}:void 0,h,r)};i.open(u,h)}else f();return c},GI=n=>{let{match:e,type:t}=WI(n);if(e)return t||void 0;let i=n.lastIndexOf(".");switch(n.substring(i+1).toLowerCase()){case"glb":return"model/gltf-binary";case"bin":return"application/octet-stream";case"gltf":return"model/gltf+json";case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"ktx":return"image/ktx";case"ktx2":return"image/ktx2";case"avif":return"image/avif";default:return}},kI=()=>typeof location!="undefined"&&location.protocol==="file:",fa=n=>VI.test(n),WI=n=>{let e=VI.exec(n);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace(";base64,","")}};HI=n=>S_(n.split(",")[1]),SV=()=>{fe._FileToolsLoadImage=gl,qo.loadFile=Fn,n_.loadFile=Fn};SV();AV=(n,e,t,i,r,s,a,o,l,c)=>{Zc={DecodeBase64UrlToBinary:n,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:r,LoadFile:s,LoadImage:a,ReadFile:o,RequestFile:l,SetCorsBehavior:c},Object.defineProperty(Zc,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(f){t.DefaultRetryStrategy=f}}),Object.defineProperty(Zc,"BaseUrl",{get:function(){return t.BaseUrl},set:function(f){t.BaseUrl=f}}),Object.defineProperty(Zc,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(f){t.PreprocessUrl=f}}),Object.defineProperty(Zc,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(f){t.CorsBehavior=f}})};AV(da,HI,Mt,fa,kI,Fn,gl,_o,ph,mh)});var _h,zI=A(()=>{ah();_h=class n{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){var t,i,r;this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=as.Zero(),this._cachedBaseSize=as.Zero(),this._initialSamplingMode=2,this._texture=n._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine(),this.wrapU=(t=this._texture._cachedWrapU)!=null?t:this.wrapU,this.wrapV=(i=this._texture._cachedWrapV)!=null?i:this.wrapV,this.wrapR=(r=this._texture._cachedWrapR)!=null?r:this.wrapR)}isReady(){return this.delayLoadState===4?(this.delayLoad(),!1):this._texture?this._texture.isReady:!1}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return!this.isReady()||!this._texture?(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize):this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e,t=!1){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture,this._texture.generateMipMaps&&t)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}});var gh,XI=A(()=>{gh=class n{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),n._HandleParenthesisContent(i,t))):e=n._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:n.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(s=>s==="true");let i,r=e.split("||");for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let a=n._SimplifyNegation(r[s].trim()),o=a.split("&&");if(o.length>1)for(let l=0;l(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}});var nt,ha=A(()=>{XI();nt=class n{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>n.HasTags(e),e.addTags=t=>n.AddTagsTo(e,t),e.removeTags=t=>n.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>n.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;let t=e._tags;for(let 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){let i=[];for(let r in e._tags)Object.prototype.hasOwnProperty.call(e._tags,r)&&e._tags[r]===!0&&i.push(r);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;let i=t.split(" ");for(let r of i)n._AddTagTo(e,r)}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(n.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!n.HasTags(e))return;let i=t.split(" ");for(let r in i)n._RemoveTagFrom(e,i[r])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?n.HasTags(e):gh.Eval(t,i=>n.HasTags(e)&&e._tags[i])}}});var YI,Me,Kt=A(()=>{gi();ha();et();ve();T_();YI=function(n,e,t,i={}){let r=n();nt&&nt.HasTags(e)&&nt.AddTagsTo(r,nt.GetTags(e,!0));let s=ch(r),a={};for(let o in s){let l=s[o],c=e[o],f=l.type;if(c!=null&&(o!=="uniqueId"||Me.AllowLoadingUniqueId))switch(f){case 0:case 6:case 9:case 11:typeof c.slice=="function"?r[o]=c.slice():r[o]=c;break;case 1:i.cloneTexturesOnlyOnce&&a[c.uniqueId]?r[o]=a[c.uniqueId]:(r[o]=t||c.isRenderTarget?c:c.clone(),a[c.uniqueId]=r[o]);break;case 2:case 3:case 4:case 5:case 7:case 8:case 10:case 12:r[o]=t?c:c.clone();break}}return r},Me=class n{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i{throw Ie("ImageProcessingConfiguration")};Me._FresnelParametersParser=n=>{throw Ie("FresnelParameters")};Me._ColorCurvesParser=n=>{throw Ie("ColorCurves")};Me._TextureParser=(n,e,t)=>{throw Ie("Texture")}});var ft,qc=A(()=>{Qe();qe();ct();ve();At();Yc();fs();zI();Kt();ft=class n extends _h{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=la()),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=n.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this._dominantDirection=null,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new Y,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?n._IsScene(e)?this._scene=e:this._engine=e:this._scene=ue.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 G.IdentityReadOnly}getReflectionTextureMatrix(){return G.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,r,s,a){let o=this._getEngine();if(!o)return null;let l=o._getUseSRGBBuffer(!!s,t),c=o.getLoadedTexturesCache();for(let f=0;f=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){let 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;let t=Me.Serialize(this);return Me.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let i=e.length;if(i===0){t();return}for(let r=0;r{--i===0&&t()}):--i===0&&t()}}}static _IsScene(e){return e.getClassName()==="Scene"}};ft.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;C([D()],ft.prototype,"uniqueId",void 0);C([D()],ft.prototype,"name",void 0);C([D()],ft.prototype,"displayName",void 0);C([D()],ft.prototype,"metadata",void 0);C([D("hasAlpha")],ft.prototype,"_hasAlpha",void 0);C([D("getAlphaFromRGB")],ft.prototype,"_getAlphaFromRGB",void 0);C([D()],ft.prototype,"level",void 0);C([D("coordinatesIndex")],ft.prototype,"_coordinatesIndex",void 0);C([D()],ft.prototype,"optimizeUVAllocation",void 0);C([D("coordinatesMode")],ft.prototype,"_coordinatesMode",void 0);C([D()],ft.prototype,"wrapU",null);C([D()],ft.prototype,"wrapV",null);C([D()],ft.prototype,"wrapR",void 0);C([D()],ft.prototype,"anisotropicFilteringLevel",void 0);C([D()],ft.prototype,"isCube",null);C([D()],ft.prototype,"is3D",null);C([D()],ft.prototype,"is2DArray",null);C([D()],ft.prototype,"gammaSpace",null);C([D()],ft.prototype,"invertZ",void 0);C([D()],ft.prototype,"lodLevelInAlpha",void 0);C([D()],ft.prototype,"lodGenerationOffset",null);C([D()],ft.prototype,"lodGenerationScale",null);C([D()],ft.prototype,"linearSpecularLOD",null);C([Ze()],ft.prototype,"irradianceTexture",null);C([D()],ft.prototype,"isRenderTarget",void 0)});var ua,ds,x_=A(()=>{ve();bi();Xc();Ci();et();ua=class{constructor(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}},ds=class{static _NearestPow2Floor(e){return e<=1?1:1<0?this._NearestPow2Floor(i):0,s=!e.noMipmap&&((b=e._texture)==null?void 0:b.generateMipMaps)===!0,a=r>0&&r0&&r{Promise.all([f,c,d,h,u,m]).then(([S,I,x,P,L,y])=>{let B=l;g&&(S=this._DownsampleFace(S,t,r,4),I=this._DownsampleFace(I,t,r,4),x=this._DownsampleFace(x,t,r,4),P=this._DownsampleFace(P,t,r,4),L=this._DownsampleFace(L,t,r,4),y=this._DownsampleFace(y,t,r,4),B=r);let w={size:B,right:I,left:S,up:x,down:P,front:L,back:y,format:_,type:S instanceof Float32Array?1:0,gammaSpace:p};R(this.ConvertCubeMapToSphericalPolynomial(w))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static _DownsampleFace(e,t,i,r){let s=e instanceof Float32Array?e:Float32Array.from(e),a=i*i*r,o=new Float32Array(a),l=t/i,c=1/(l*l);for(let h=0;h0?this._NearestPow2Floor(t):0;if(i>0&&e.size>i){let m=e.format===5?4:3,p=["right","left","up","down","front","back"],_={};for(let g of p)_[g]=this._DownsampleFace(e[g],e.size,i,m);e={...e,..._,size:i}}let r=new zc,s=0,a=2/e.size,o=a,l=.5*a,c=l-1;for(let m=0;m<6;m++){let p=this._FileFaces[m],_=e[p.name],g=c,T=e.format===5?4:3;for(let b=0;bB){let O=B/H;P*=O,L*=O,y*=O}}else P=Ke(P,0,B),L=Ke(L,0,B),y=Ke(y,0,B);let w=new oe(P,L,y);r.addLight(I,w,x),s+=x,R+=a}g+=o}}let u=4*Math.PI*6/6/s;return r.scaleInPlace(u),r.convertIncidentRadianceToIrradiance(),r.convertIrradianceToLambertianRadiance(),On.FromHarmonics(r)}};ds._FileFaces=[new ua("right",new v(1,0,0),new v(0,0,-1),new v(0,-1,0)),new ua("left",new v(-1,0,0),new v(0,0,1),new v(0,-1,0)),new ua("up",new v(0,1,0),new v(1,0,0),new v(0,0,1)),new ua("down",new v(0,-1,0),new v(1,0,0),new v(0,0,-1)),new ua("front",new v(0,0,1),new v(1,0,0),new v(0,-1,0)),new ua("back",new v(0,0,-1),new v(-1,0,0),new v(0,-1,0))];ds.MAX_HDRI_VALUE=4096;ds.PRESERVE_CLAMPED_COLORS=!1});var hs,C_=A(()=>{ze();Lt();hs=class{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];let t=Ai(e);if(t)return t;W.Warn(e+" not found, you may have missed an import.");let i=e.split("."),r=window||this;for(let s=0,a=i.length;s=0;){let d=n[c];d<0?d=0:d>1&&(d=1),f[c]=d*255}n=f}let s=document.createElement("canvas");s.width=i,s.height=r;let a=s.getContext("2d");if(!a)return null;let o=a.createImageData(i,r);if(o.data.set(n),a.putImageData(o,0,0),t){let c=document.createElement("canvas");c.width=i,c.height=r;let f=c.getContext("2d");return f?(f.translate(0,r),f.scale(1,-1),f.drawImage(s,0,0),c.toDataURL("image/png")):null}return s.toDataURL("image/png")}function jI(n,e=0,t=0){let i=n.getInternalTexture();if(!i)return null;let r=n._readPixelsSync(e,t);return r?KI(r,n.getSize(),i.invertY):null}async function ZI(n,e=0,t=0){let i=n.getInternalTexture();if(!i)return null;let r=await n.readPixels(e,t);return r?KI(r,n.getSize(),i.invertY):null}var qI=A(()=>{});var He,hi=A(()=>{He=!1});var ne,oi=A(()=>{Qe();qe();ct();ve();qc();Lt();gi();Mn();C_();fo();jc();qI();hi();Kt();ne=class n extends ft{static _CreateVideoTexture(e,t,i,r=!1,s=!1,a=n.TRILINEAR_SAMPLINGMODE,o={},l,c=5){throw Ie("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,i,r,s=n.TRILINEAR_SAMPLINGMODE,a=null,o=null,l=null,c=!1,f,d,h,u,m){var x,P,L,y,B,w,H,O,V,X,j;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 Y,this._isBlocking=!0,this.name=e||"",this.url=e;let p,_=!1,g=null,T=!0;typeof i=="object"&&i!==null?(p=(x=i.noMipmap)!=null?x:!1,r=(P=i.invertY)!=null?P:!He,s=(L=i.samplingMode)!=null?L:n.TRILINEAR_SAMPLINGMODE,a=(y=i.onLoad)!=null?y:null,o=(B=i.onError)!=null?B:null,l=(w=i.buffer)!=null?w:null,c=(H=i.deleteBuffer)!=null?H:!1,f=i.format,d=i.mimeType,h=i.loaderOptions,u=i.creationFlags,_=(O=i.useSRGBBuffer)!=null?O:!1,g=(V=i.internalTexture)!=null?V:null,T=(X=i.gammaSpace)!=null?X:T,m=(j=i.forcedExtension)!=null?j:m):p=!!i,this._gammaSpace=T,this._noMipmap=p,this._invertY=r===void 0?!He:r,this._initialSamplingMode=s,this._buffer=l,this._deleteBuffer=c,this._mimeType=d,this._loaderOptions=h,this._creationFlags=u,this._useSRGBBuffer=_,this._forcedExtension=m,f!==void 0&&(this._format=f);let b=this.getScene(),R=this._getEngine();if(!R)return;R.onBeforeTextureInitObservable.notifyObservers(this);let S=()=>{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),a&&a(),!this.isBlocking&&b&&b.resetCachedMaterial()},I=(Q,$)=>{this._loadingError=!0,this._errorObject={message:Q,exception:$},o&&o(Q,$),n.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!g){this._delayedOnLoad=S,this._delayedOnError=I;return}if(this._texture=g!=null?g:this._getFromCache(this.url,p,s,this._invertY,_,this.isCube),this._texture)if(this._texture.isReady)en.SetImmediate(()=>S());else{let Q=this._texture.onLoadedObservable.add(S);this._texture.onErrorObservable.add($=>{var q;I($.message,$.exception),(q=this._texture)==null||q.onLoadedObservable.remove(Q)})}else if(!b||!b.useDelayedTextureLoading){try{this._texture=R.createTexture(this.url,p,this._invertY,b,s,S,I,this._buffer,void 0,this._format,this._forcedExtension,d,h,u,_)}catch(Q){throw I("error loading",Q),Q}c&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=S,this._delayedOnError=I}updateURL(e,t=null,i,r){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,o=>o.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=r,this.delayLoadState=4;let s=this._delayedOnLoad,a=()=>{s?s():this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),i&&i()};this._delayedOnLoad=a,this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;let e=this.getScene();if(!e)return;let t=this.url;!t&&(this.name.indexOf("://")>0||this.name.startsWith("data:"))&&(t=this.name),this.delayLoadState=1,this._texture=this._getFromCache(t,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?en.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(t,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null}_prepareRowForTextureGeneration(e,t,i,r){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,r),r.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,r.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,r.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=G.Zero(),this._rowGenerationMatrix=new G,this._t0=v.Zero(),this._t1=v.Zero(),this._t2=v.Zero()),G.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(G.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,k.Matrix[0]),G.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,k.Matrix[1]),G.ScalingToRef(this._cachedUScale,this._cachedVScale,0,k.Matrix[2]),G.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,k.Matrix[3]),k.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(k.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(k.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(k.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),G.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));let t=this.getScene();if(!t)return this._cachedTextureMatrix;let i=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&i!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,r=>r.hasTexture(this)),this._cachedTextureMatrix}getReflectionTextureMatrix(){let 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===n.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=G.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=G.Zero());let 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 n.PLANAR_MODE:{G.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 n.PROJECTION_MODE:{G.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);let i=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:G.IdentityToRef(this._cachedReflectionTextureMatrix);break}return t&&e.markAllMaterialsAsDirty(1,i=>i.hasTexture(this)),this._cachedReflectionTextureMatrix}clone(){let 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 Me.Clone(()=>new n(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){var i,r;let e=this.name;n.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");let t=super.serialize(n._SerializeInternalTextureUniqueId);if(!t)return null;if(n.SerializeBuffers||n.ForceSerializeBuffers)if(typeof this._buffer=="string"&&this._buffer.startsWith("data:"))t.base64String=this._buffer,t.name=t.name.replace("data:","");else if(this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array){let s=this.mimeType||"image/png";t.base64String=`data:${s};base64,${ml(this._buffer)}`}else(n.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?jI(this):ZI(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,n._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=(i=this._texture)==null?void 0:i.uniqueId),t.internalTextureLabel=(r=this._texture)==null?void 0:r.label,t.noMipmap=this._noMipmap,this.name=e,t}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,i){if(e.customType){let c=hs.Instantiate(e.customType).Parse(e,t,i);return e.samplingMode&&c.updateSamplingMode&&c._samplingMode&&c._samplingMode!==e.samplingMode&&c.updateSamplingMode(e.samplingMode),c}if(e.isCube&&!e.isRenderTarget)return n._CubeTextureParser(e,t,i);let r=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!r)return null;let s;if(r){let l=t.getEngine().getLoadedTexturesCache();for(let c of l)if(c.uniqueId===e.internalTextureUniqueId){s=c;break}}let a=l=>{if(l&&l._texture&&(l._texture._cachedWrapU=null,l._texture._cachedWrapV=null,l._texture._cachedWrapR=null),e.samplingMode){let c=e.samplingMode;l&&l.samplingMode!==c&&l.updateSamplingMode(c)}if(l&&e.animations)for(let c=0;c{var c,f,d,h,u;let l=!0;if(e.noMipmap&&(l=!1),e.mirrorPlane){let m=n._CreateMirror(e.name,e.renderTargetSize,t,l);return m._waitingRenderList=e.renderList,m.mirrorPlane=er.FromArray(e.mirrorPlane),a(m),m}else if(e.isRenderTarget&&!e.base64String){let m=null;if(e.isCube){if(t.reflectionProbes)for(let p=0;p{a(m)}},_=e.base64String,g=_.startsWith("data:")?_.substring(5):_;m=n.CreateFromBase64String("",g,t,p),m.name=e.name}else{let p;e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?p=e.name:p=i+e.name,e.url&&(e.url.startsWith("data:")||n.UseSerializedUrlIfAny)&&(p=e.url);let _={noMipmap:!l,invertY:e.invertY,samplingMode:e.samplingMode,useSRGBBuffer:(h=e._useSRGBBuffer)!=null?h:!1,creationFlags:(u=e._creationFlags)!=null?u:0,onLoad:()=>{a(m)},internalTexture:s};m=new n(p,t,_)}return m}},e,t)}static CreateFromBase64String(e,t,i,r,s,a=n.TRILINEAR_SAMPLINGMODE,o=null,l=null,c=5,f,d){return new n("data:"+t,i,r,s,a,o,l,e,!1,c,void 0,void 0,f,d)}static LoadFromDataString(e,t,i,r=!1,s,a=!0,o=n.TRILINEAR_SAMPLINGMODE,l=null,c=null,f=5,d,h){return e.substring(0,5)!=="data:"&&(e="data:"+e),new n(e,i,s,a,o,l,c,t,r,f,void 0,void 0,d,h)}};ne.SerializeBuffers=!0;ne.ForceSerializeBuffers=!1;ne.OnTextureLoadErrorObservable=new Y;ne._SerializeInternalTextureUniqueId=!1;ne._CubeTextureParser=(n,e,t)=>{throw Ie("CubeTexture")};ne._CreateMirror=(n,e,t,i)=>{throw Ie("MirrorTexture")};ne._CreateRenderTargetTexture=(n,e,t,i,r)=>{throw Ie("RenderTargetTexture")};ne.NEAREST_SAMPLINGMODE=1;ne.NEAREST_NEAREST_MIPLINEAR=8;ne.BILINEAR_SAMPLINGMODE=2;ne.LINEAR_LINEAR_MIPNEAREST=11;ne.TRILINEAR_SAMPLINGMODE=3;ne.LINEAR_LINEAR_MIPLINEAR=3;ne.NEAREST_NEAREST_MIPNEAREST=4;ne.NEAREST_LINEAR_MIPNEAREST=5;ne.NEAREST_LINEAR_MIPLINEAR=6;ne.NEAREST_LINEAR=7;ne.NEAREST_NEAREST=1;ne.LINEAR_NEAREST_MIPNEAREST=9;ne.LINEAR_NEAREST_MIPLINEAR=10;ne.LINEAR_LINEAR=2;ne.LINEAR_NEAREST=12;ne.EXPLICIT_MODE=0;ne.SPHERICAL_MODE=1;ne.PLANAR_MODE=2;ne.CUBIC_MODE=3;ne.PROJECTION_MODE=4;ne.SKYBOX_MODE=5;ne.INVCUBIC_MODE=6;ne.EQUIRECTANGULAR_MODE=7;ne.FIXED_EQUIRECTANGULAR_MODE=8;ne.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;ne.CLAMP_ADDRESSMODE=0;ne.WRAP_ADDRESSMODE=1;ne.MIRROR_ADDRESSMODE=2;ne.UseSerializedUrlIfAny=!1;C([D()],ne.prototype,"url",void 0);C([D()],ne.prototype,"uOffset",void 0);C([D()],ne.prototype,"vOffset",void 0);C([D()],ne.prototype,"uScale",void 0);C([D()],ne.prototype,"vScale",void 0);C([D()],ne.prototype,"uAng",void 0);C([D()],ne.prototype,"vAng",void 0);C([D()],ne.prototype,"wAng",void 0);C([D()],ne.prototype,"uRotationCenter",void 0);C([D()],ne.prototype,"vRotationCenter",void 0);C([D()],ne.prototype,"wRotationCenter",void 0);C([D()],ne.prototype,"homogeneousRotationInUVTransform",void 0);C([D()],ne.prototype,"isBlocking",null);je("BABYLON.Texture",ne);Me._TextureParser=ne.Parse});var sn,M,yt=A(()=>{c_();ze();pl();sn=class{get isDisposed(){return this._isDisposed}constructor(e,t,i,r=0,s=!1,a=!1,o=!1,l,c){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=a,this._divisor=l||1,this._label=c,t instanceof ao?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?r:r*Float32Array.BYTES_PER_ELEMENT,s||this.create()}createVertexBuffer(e,t,i,r,s,a=!1,o){let l=a?t:t*Float32Array.BYTES_PER_ELEMENT,c=r?a?r:r*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new M(this._engine,this,e,this._updatable,!0,c,s===void 0?this._instanced:s,l,i,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data,e&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label)))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0){this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label);return}W.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,i,r=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?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)}},M=class n{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){let t=e!=0;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){let 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,r,s,a,o,l,c,f,d=!1,h=!1,u=1,m=!1){var g,T,b,R,S;this._isDisposed=!1;let p;if(this.engine=e,typeof r=="object"&&r!==null?(p=(g=r.updatable)!=null?g:!1,s=r.postponeInternalCreation,a=r.stride,o=r.instanced,l=r.offset,c=r.size,f=r.type,d=(T=r.normalized)!=null?T:!1,h=(b=r.useBytes)!=null?b:!1,u=(R=r.divisor)!=null?R:1,m=(S=r.takeBufferOwnership)!=null?S:!1,this._label=r.label):p=!!r,t instanceof sn?(this._buffer=t,this._ownsBuffer=m):(this._buffer=new sn(e,t,p,a,s,o,h,u,this._label),this._ownsBuffer=!0),this.uniqueId=n._Counter++,this._kind=i,f===void 0){let I=this.getData();this.type=I?n.GetDataType(I):n.FLOAT}else this.type=f;let _=Nn(this.type);h?(this._size=c||(a?a/_:n.DeduceStride(i)),this.byteStride=a||this._buffer.byteStride||this._size*_,this.byteOffset=l||0):(this._size=c||a||n.DeduceStride(i),this.byteStride=a?a*_:this._buffer.byteStride||this._size*_,this.byteOffset=(l||0)*_),this.normalized=d,this._instanced=o!==void 0?o:!1,this._instanceDivisor=o?u: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){let i=this.getData();return i?R_(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/Nn(this.type)}getOffset(){return this.byteOffset/Nn(this.type)}getSize(e=!1){return e?this._size*Nn(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){po(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,(i,r)=>{for(let s=0;s{for(let d=0;d{yt();ct();us=class{constructor(e){this._vertexBuffers={},this._activePostProcesses=[],this.onBeforeRenderObservable=new Y,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[M.PositionKind])return;let e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[M.PositionKind]=new M(this._scene.getEngine(),e,M.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){let 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)}_getActivePostProcesses(e){let t=this._activePostProcesses;t.length=0;for(let i=0;i{ze();QI=(n,e,t)=>!n||n.getClassName&&n.getClassName()==="Mesh"?null:n.getClassName&&(n.getClassName()==="SubMesh"||n.getClassName()==="PhysicsBody")?n.clone(e):n.clone?n.clone():Array.isArray(n)?n.slice():t&&typeof n=="object"?{...n}:null;wn=class{static DeepCopy(e,t,i,r,s=!1){let a=RV(e);for(let o of a){if(o[0]==="_"&&(!r||r.indexOf(o)===-1)||o.endsWith("Observable")||i&&i.indexOf(o)!==-1)continue;let l=e[o],c=typeof l;if(c!=="function")try{if(c==="object")if(l instanceof Uint8Array)t[o]=Uint8Array.from(l);else if(l instanceof Array){if(t[o]=[],l.length>0)if(typeof l[0]=="object")for(let f=0;f{ct();yr();ze();Qc();rs();gi();mo();At();fs();Mn();C_();Yc();Dn();re=class{static get BaseUrl(){return Mt.BaseUrl}static set BaseUrl(e){Mt.BaseUrl=e}static get CleanUrl(){return Mt.CleanUrl}static set CleanUrl(e){Mt.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("://"){Fn(e,s=>{i(s)},void 0,void 0,t,(s,a)=>{r(a)})})}static GetAssetUrl(e){if(!e)return"";if(Ue.AssetBaseUrl&&e.startsWith(Ue._DefaultAssetsUrl)){let t=Ue.AssetBaseUrl.endsWith("/")?Ue.AssetBaseUrl.slice(0,-1):Ue.AssetBaseUrl;return e.replace(Ue._DefaultAssetsUrl,t)}return e}static GetBabylonScriptURL(e,t){if(!e)return"";if(e.startsWith(Ue._DefaultCdnUrl)){if(Ue.ScriptBaseUrl){let i=Ue.ScriptBaseUrl.endsWith("/")?Ue.ScriptBaseUrl.slice(0,-1):Ue.ScriptBaseUrl;e=e.replace(Ue._DefaultCdnUrl,i)}else if(Ue._CdnVersion){let i=`${Ue._DefaultCdnUrl}/v${Ue._CdnVersion}`;e.startsWith(i)||(e=e.replace(Ue._DefaultCdnUrl,i))}}return e=Ue.ScriptPreprocessUrl(e),t&&!Ue.IsAbsoluteUrl(e)&&(e=Ue.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,r){e=Ue.GetBabylonScriptURL(e),Ue.LoadScript(e,t,i)}static async LoadBabylonScriptAsync(e){return e=Ue.GetBabylonScriptURL(e),await Ue.LoadScriptAsync(e)}static _LoadScriptNative(e,t,i){let r=new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${e}`);i==null||i(r.message,r)}static _LoadScriptWeb(e,t,i,r,s=!1){let a=new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${e}`);i==null||i(a.message,a)}static async LoadScriptAsync(e,t){return await new Promise((i,r)=>{this.LoadScript(e,()=>{i()},(s,a)=>{r(a||new Error(s))},t)})}static ReadFileAsDataURL(e,t,i){let r=new FileReader,s={onCompleteObservable:new Y,abort:()=>r.abort()};return r.onloadend=()=>{s.onCompleteObservable.notifyObservers(s)},r.onload=a=>{t(a.target.result)},r.onprogress=i,r.readAsDataURL(e),s}static ReadFile(e,t,i,r,s){return _o(e,t,i,r,s)}static FileAsURL(e){let t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,i,r){wn.DeepCopy(e,t,i,r)}static IsEmpty(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let i=0;i{let l=atob(this.toDataURL(a,o).split(",")[1]),c=l.length,f=new Uint8Array(c);for(let d=0;dt(s)):e.toBlob(function(s){t(s)},i,r)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){let i=new Date;t="screenshot_"+((i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2))+".png"}Ue.Download(e,t)}else if(e&&typeof URL!="undefined"){let i=URL.createObjectURL(e),r=window.open("");if(!r)return;let s=r.document.createElement("img");s.onload=function(){URL.revokeObjectURL(i)},s.src=i,r.document.body.appendChild(s)}}static EncodeScreenshotCanvasData(e,t,i="image/png",r,s){if(typeof r=="string"||!t)this.ToBlob(e,function(a){a&&Ue.DownloadBlob(a,r),t&&t("")},i,s);else if(t){if(Ue._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:s}).then(o=>{let l=new FileReader;l.readAsDataURL(o),l.onloadend=()=>{let c=l.result;t(c)}});return}let a=e.toDataURL(i,s);t(a)}}static Download(e,t){if(typeof URL=="undefined")return;let i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",()=>{r.parentElement&&r.parentElement.removeChild(r)}),r.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,r,s="image/png",a=!1,o){throw Ie("ScreenshotTools")}static async CreateScreenshotAsync(e,t,i,r="image/png",s){throw Ie("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,r,s="image/png",a=1,o=!1,l,c=!1,f=!1,d=!0,h,u){throw Ie("ScreenshotTools")}static async CreateScreenshotUsingRenderTargetAsync(e,t,i,r="image/png",s=1,a=!1,o,l=!1,c=!1,f=!0,d,h){throw Ie("ScreenshotTools")}static RandomId(){return la()}static IsBase64(e){return fa(e)}static DecodeBase64(e){return da(e)}static get errorsCount(){return W.errorsCount}static Log(e){W.Log(e)}static Warn(e){W.Warn(e)}static Error(e){W.Error(e)}static get LogCache(){return W.LogCache}static ClearLogCache(){W.ClearLogCache()}static set LogLevels(e){W.LogLevels=e}static set PerformanceLogLevel(e){var t;if((e&Ue.PerformanceUserMarkLogLevel)===Ue.PerformanceUserMarkLogLevel){_native!=null&&_native.enablePerformanceLogging?(_native.enablePerformanceLogging(1),Ue.StartPerformanceCounter=Ue._StartMarkNative,Ue.EndPerformanceCounter=Ue._EndMarkNative):(Ue.StartPerformanceCounter=Ue._StartUserMark,Ue.EndPerformanceCounter=Ue._EndUserMark);return}if((e&Ue.PerformanceConsoleLogLevel)===Ue.PerformanceConsoleLogLevel){_native!=null&&_native.enablePerformanceLogging?(_native.enablePerformanceLogging(2),Ue.StartPerformanceCounter=Ue._StartMarkNative,Ue.EndPerformanceCounter=Ue._EndMarkNative):(Ue.StartPerformanceCounter=Ue._StartPerformanceConsole,Ue.EndPerformanceCounter=Ue._EndPerformanceConsole);return}Ue.StartPerformanceCounter=Ue._StartPerformanceCounterDisabled,Ue.EndPerformanceCounter=Ue._EndPerformanceCounterDisabled,(t=_native==null?void 0:_native.disablePerformanceLogging)==null||t.call(_native)}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!Ue._Performance){if(!Bt())return;Ue._Performance=window.performance}!t||!Ue._Performance.mark||Ue._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){!t||!Ue._Performance.mark||(Ue._Performance.mark(e+"-End"),Ue._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(Ue._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(Ue._EndUserMark(e,t),console.timeEnd(e))}static _StartMarkNative(e,t=!0){if(t&&(_native!=null&&_native.startPerformanceCounter))if(Ue._NativePerformanceCounterHandles.has(e))Ue.Warn(`Performance counter with name ${e} is already started.`);else{let i=_native.startPerformanceCounter(e);Ue._NativePerformanceCounterHandles.set(e,i)}}static _EndMarkNative(e,t=!0){if(t&&(_native!=null&&_native.endPerformanceCounter)){let i=Ue._NativePerformanceCounterHandles.get(e);i?(_native.endPerformanceCounter(i),Ue._NativePerformanceCounterHandles.delete(e)):Ue.Warn(`Performance counter with name ${e} was not started.`)}}static get Now(){return kt.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(let i of e)if(t(i))return i;return null}static getFullClassName(e,t=!1){let i=null,r=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){let s=t?e:Object.getPrototypeOf(e);i=s.constructor.__bjsclassName__,r=s.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(r!=null?r+".":"")+i:null}static async DelayAsync(e){await new Promise(t=>{setTimeout(()=>{t()},e)})}static IsSafari(){return is()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}};Ue=re;re.AssetBaseUrl="";re.UseCustomRequestHeaders=!1;re.CustomRequestHeaders=$t.CustomRequestHeaders;re.GetDOMTextContent=Md;re._DefaultCdnUrl="https://cdn.babylonjs.com";re._CdnVersion="9.6.0";re._DefaultAssetsUrl="https://assets.babylonjs.com/core";re.LoadScript=typeof _native=="undefined"?Ue._LoadScriptWeb:Ue._LoadScriptNative;re.GetAbsoluteUrl=typeof document=="object"?n=>{let e=document.createElement("a");return e.href=n,e.href}:typeof URL=="function"&&typeof location=="object"?n=>new URL(n,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")};re.NoneLogLevel=W.NoneLogLevel;re.MessageLogLevel=W.MessageLogLevel;re.WarningLogLevel=W.WarningLogLevel;re.ErrorLogLevel=W.ErrorLogLevel;re.AllLogLevel=W.AllLogLevel;re.IsWindowObjectExist=Bt;re.PerformanceNoneLogLevel=0;re.PerformanceUserMarkLogLevel=1;re.PerformanceConsoleLogLevel=2;re._NativePerformanceCounterHandles=new Map;re.StartPerformanceCounter=Ue._StartPerformanceCounterDisabled;re.EndPerformanceCounter=Ue._EndPerformanceCounterDisabled;vh=class n{constructor(e,t,i,r=0){this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}executeNext(){this._done||(this.index+1{s&&s()?o.breakLoop():setTimeout(()=>{for(let l=0;l=e)break;if(i(c),s&&s()){o.breakLoop();break}}o.executeNext()},a)},r)}};re.Mix=kc;re.IsExponentOfTwo=oo;ue.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"});var Ut,ma=A(()=>{ze();Tt();Ut=class n{constructor(e,t,i=!1,r,s=!1,a){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||s,this._dynamic=i,this._name=r!=null?r:"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._trackUBOsInFrame=!1,(a===void 0&&this._engine._features.trackUbosInFrame||a===!0)&&(this._buffers=[],this._bufferIndex=-1,this._bufferUpdatedLastFrame=!1,this._createBufferOnWrite=!1,this._currentFrameId=0,this._trackUBOsInFrame=!0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}getUniformNames(){return this._uniformNames}_fillAlignment(e){let t;if(e<=2?t=e:t=4,this._uniformLocationPointer%t!==0){let i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;let r=this._uniformLocationPointer-i;for(let s=0;s0&&typeof t=="number"&&(this._uniformArraySizes[e]={strideSize:t,arraySize:i}),this._uniformLocations[e]!==void 0||(this._uniformNames.push(e),this._noUBO))return;let r;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),t==16)t=t*i;else{let a=(4-t)*i;t=t*i+a}r=[];for(let s=0;s1&&this._buffers[this._bufferIndex][1])if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1])){this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._bufferUpdatedLastFrame=!0,this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame}}_createNewBuffer(){this._bufferIndex+10?(this._buffers.length===1?this._needSync=!this._bufferUpdatedLastFrame:this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let r=this._uniformLocations[e];if(r===void 0){if(this._buffer){W.Error("Cannot add an uniform after UBO has been created. uniformName="+e);return}this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let s=0;s1&&this._buffers[t][1]&&this._bufferData.set(this._buffers[t][1]),this._valueCache={},this._currentFrameId=this._engine.frameId,!0;return!1}has(e){return this._uniformLocations[e]!==void 0}dispose(){if(this._noUBO)return;let e=this._engine._uniformBuffers,t=e.indexOf(this);if(t!==-1&&(e[t]=e[e.length-1],e.pop()),this._trackUBOsInFrame&&this._buffers)for(let i=0;i{Ct=class n{constructor(e){this.length=0,this.data=new Array(e),this._id=n._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;tthis.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t=this.length?-1:t}contains(e){return this.indexOf(e)!==-1}};Ct._GlobalId=0;an=class extends Ct{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{on();ve();Jc=class n{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=n.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=n.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=n.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,r=null,s=null){this.index=e,this._opaqueSubMeshes=new Ct(256),this._transparentSubMeshes=new Ct(256),this._alphaTestSubMeshes=new Ct(256),this._depthOnlySubMeshes=new Ct(256),this._particleSystems=new Ct(256),this._spriteManagers=new Ct(256),this._empty=!0,this._edgesRenderers=new an(16),this.disableDepthPrePass=!1,this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=s}render(e,t,i,r,s=!0,a=!0,o=!0,l=!0,c){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}let f=this._scene.getEngine();s&&this._depthOnlySubMeshes.length!==0&&(f.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),f.setColorWrite(!0)),a&&this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),o&&this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);let d=f.getStencilBuffer();if(f.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(r),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),l&&(c||this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency)){if(f.setStencilBuffer(d),c)c(this._transparentSubMeshes,this);else if(this._scene.useOrderIndependentTransparency){let h=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);h.length&&this._renderTransparent(h)}else this._renderTransparent(this._transparentSubMeshes);f.setAlphaMode(0)}if(f.setStencilBuffer(!1),a&&this._edgesRenderers.length){for(let h=0;ht._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamerat._distanceToCamera?1:0}static PainterSortCompare(e,t){let i=e.getMesh(),r=t.getMesh();return i.material&&r.material?i.material.uniqueId-r.material.uniqueId:i.uniqueId-r.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),i===void 0&&(i=e.getMaterial()),i!=null&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTestingForMesh(t)?(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(this._particleSystems.length===0)return;let t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let i=0;i{JI();b_=class{},Pr=class n{get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e;for(let t of this._renderingGroups)t.disableDepthPrePass=e}get maintainStateBetweenFrames(){return this._maintainStateBetweenFrames}set maintainStateBetweenFrames(e){e!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=e,this._maintainStateBetweenFrames||this.restoreDispachedFlags())}restoreDispachedFlags(){for(let e of this._scene.meshes)if(e.subMeshes)for(let t of e.subMeshes)t._wasDispatched=!1;if(this._scene.spriteManagers)for(let e of this._scene.spriteManagers)e._wasDispatched=!1;for(let e of this._scene.particleSystems)e._wasDispatched=!1}constructor(e){this._useSceneAutoClearSetup=!1,this._disableDepthPrePass=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new b_,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=n.MIN_RENDERINGGROUPS;t{it=class{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}};it.FALLOFF_DEFAULT=0;it.FALLOFF_PHYSICAL=1;it.FALLOFF_GLTF=2;it.FALLOFF_STANDARD=3;it.LIGHTMAP_DEFAULT=0;it.LIGHTMAP_SPECULAR=1;it.LIGHTMAP_SHADOWSONLY=2;it.INTENSITYMODE_AUTOMATIC=0;it.INTENSITYMODE_LUMINOUSPOWER=1;it.INTENSITYMODE_LUMINOUSINTENSITY=2;it.INTENSITYMODE_ILLUMINANCE=3;it.INTENSITYMODE_LUMINANCE=4;it.LIGHTTYPEID_POINTLIGHT=0;it.LIGHTTYPEID_DIRECTIONALLIGHT=1;it.LIGHTTYPEID_SPOTLIGHT=2;it.LIGHTTYPEID_HEMISPHERICLIGHT=3;it.LIGHTTYPEID_RECT_AREALIGHT=4;it.LIGHTTYPEID_CLUSTERED_CONTAINER=5});var Or,M_=A(()=>{ma();ct();Th();Ln();Mn();ze();on();$c();Or=class n{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=rh(e,this._renderListHasChanged)),this._renderList=e)}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._scene.markAllMaterialsAsDirty(64))}get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e,this._renderingManager.disableDepthPrePass=e}get name(){return this._name}set name(e){if(this._name!==e){if(this._name=e,this._sceneUBOs)for(let t=0;tthis._checkReadiness(),()=>{if(this._freezeActiveMeshesCancel=null,e)for(let t=0;t{this._freezeActiveMeshesCancel=null,i?(W.Error("ObjectRenderer: Timeout while waiting for the renderer to be ready."),t&&W.Error(t)):(W.Error("ObjectRenderer: An unexpected error occurred while waiting for the renderer to be ready."),t&&(W.Error(t),t.stack&&W.Error(t.stack)))})}_unfreezeActiveMeshes(){var e;(e=this._freezeActiveMeshesCancel)==null||e.call(this),this._freezeActiveMeshesCancel=null;for(let t=0;t{let a=this._renderList?this._renderList.length:0;if(s===0&&a>0||a===0)for(let o of this._scene.meshes)o._markSubMeshesAsLightDirty()},this.particleSystemList=null,this.getCustomRenderList=null,this.renderMeshes=!0,this.renderDepthOnlyMeshes=!0,this.renderOpaqueMeshes=!0,this.renderAlphaTestMeshes=!0,this.renderTransparentMeshes=!0,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.enableBoundingBoxRendering=!1,this.enableOutlineRendering=!0,this._disableImageProcessing=!1,this.dontSetTransformationMatrix=!1,this._disableDepthPrePass=!1,this.onBeforeRenderObservable=new Y,this.onAfterRenderObservable=new Y,this.onBeforeRenderingManagerRenderObservable=new Y,this.onAfterRenderingManagerRenderObservable=new Y,this.onInitRenderingObservable=new Y,this.onFinishRenderingObservable=new Y,this.onFastPathRenderObservable=new Y,this._currentRefreshId=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._activeMeshes=new Ct(256),this._activeBoundingBoxes=new Ct(32),this._currentFrameId=-1,this._currentSceneUBOIndex=0,this._isFrozen=!1,this._freezeActiveMeshesCancel=null,this._currentSceneCamera=null,this.name=e,this._scene=t,this._engine=this._scene.getEngine(),this._useUBO=this._engine.supportsUniformBuffers,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,enableClusteredLights:!1,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new Pr(t),this._renderingManager._useSceneAutoClearSetup=!0,this.options.enableClusteredLights&&this.onInitRenderingObservable.add(()=>{for(let r of this._scene.lights)r.getTypeID()===it.LIGHTTYPEID_CLUSTERED_CONTAINER&&r.isSupported&&r._updateBatches(this.activeCamera).render()}),this._scene.addObjectRenderer(this)}_releaseRenderPassId(){for(let e=0;e=this._sceneUBOs.length){let s=this._sceneUBOs.length;this._sceneUBOs.push(this._createSceneUBO(`Scene ubo #${s} for ${this.name}`,t)),this._sceneUBOIsMultiview.push(t)}else this._sceneUBOIsMultiview[this._currentSceneUBOIndex]!==t&&(this._sceneUBOs[this._currentSceneUBOIndex].dispose(),this._sceneUBOs[this._currentSceneUBOIndex]=this._createSceneUBO(`Scene ubo #${this._currentSceneUBOIndex} for ${this.name}`,t),this._sceneUBOIsMultiview[this._currentSceneUBOIndex]=t);let i=this._sceneUBOs[this._currentSceneUBOIndex++];return i.unbindEffect(),i}resetRefreshCounter(){this._currentRefreshId=-1}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}shouldRender(){return this._engine.snapshotRendering?!0: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);let i=this._checkReadiness();return this.finishRender(),i}prepareRenderList(){let e=this._scene;if(this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(let t=0;t1&&(e.incrementRenderId(),e.resetCachedMaterial())}let s=this.particleSystemList||e.particleSystems;for(let a of s)a.isReady()||(i=!1);return this._engine.currentRenderPassId=t,i}_prepareRenderingManager(e=0,t=!1){var h,u;let i=this._scene,r=null,s,a,o=this.renderList?this.renderList:i.frameGraph?i.meshes:i.getActiveMeshes().data,l=this.renderList||i.frameGraph?o.length:i.getActiveMeshes().length;if(this.getCustomRenderList&&(r=this.getCustomRenderList(e,o,l)),r)s=r.length,a=this.forceLayerMaskCheck;else{if(this._defaultRenderListPrepared&&!t&&!this._engine.isWebGPU)return o;this._defaultRenderListPrepared=!0,r=o,s=l,a=!this.renderList||this.forceLayerMaskCheck}let c=i.activeCamera,f=(h=this.cameraForLOD)!=null?h:c,d=(u=i.getBoundingBoxRenderer)==null?void 0:u.call(i);if(i._activeMeshesFrozen&&this._isFrozen){if(this._renderingManager.resetSprites(),this.enableBoundingBoxRendering&&d){d.reset();for(let m=0;m{Mn();Hi=class{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 r;this.effect=e,t!==void 0&&(this.defines=t),i&&((r=this.drawContext)==null||r.reset())}dispose(e=!1){var t;if(this.effect){let i=this.effect;e?i.dispose():en.SetImmediate(()=>{i.getEngine().onEndFrameObservable.addOnce(()=>{i.dispose()})}),this.effect=null}(t=this.drawContext)==null||t.dispose()}}});var ex={};De(ex,{postprocessVertexShader:()=>IV});var y_,$I,IV,D_=A(()=>{N();y_="postprocessVertexShader",$I=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5); +${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;let i=this._m;for(let r=0;r<16;r++)e[t+r]=i[r];return this}asArray(){return this._m}fromArray(e,t=0){return n.FromArrayToRef(e,t,this)}copyFromFloats(...e){return n.FromArrayToRef(e,0,this)}set(...e){let t=this._m;for(let i=0;i<16;i++)t[i]=e[i];return this.markAsUpdated(),this}setAll(e){let 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 n.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){let t=new n;return this.addToRef(e,t),t}addToRef(e,t){let i=this._m,r=t._m,s=e.m;for(let a=0;a<16;a++)r[a]=i[a]+s[a];return t.markAsUpdated(),t}addToSelf(e){let 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){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]+=i[r];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]+=e[i];return this.markAsUpdated(),this}subtract(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]-=i[r];return this.markAsUpdated(),this}subtractToRef(e,t){let i=this._m,r=e.m,s=t._m;for(let a=0;a<16;a++)s[a]=i[a]-r[a];return t.markAsUpdated(),t}subtractInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]-=i[r];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new n)}subtractFromFloatsToRef(...e){let t=e.pop(),i=this._m,r=t._m,s=e;for(let a=0;a<16;a++)r[a]=i[a]-s[a];return t.markAsUpdated(),t}invertToRef(e){return this._isIdentity===!0?(n.IdentityToRef(e),e):(T_(this,e.asArray())?e.markAsUpdated():e.copyFrom(this),e)}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new 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(){let e=this.m;return n.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);let t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){return MI(this,e,t),this}multiply(e){let t=new n;return this.multiplyToRef(e,t),t}multiplyInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]*=i[r];return this.markAsUpdated(),this}multiplyByFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){let t=e.pop(),i=this._m,r=t._m,s=e;for(let a=0;a<16;a++)r[a]=i[a]*s[a];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,i){return v_(this,e,t,i),this}divide(e){return this.divideToRef(e,new n)}divideToRef(e,t){let i=this._m,r=e.m,s=t._m;for(let a=0;a<16;a++)s[a]=i[a]/r[a];return t.markAsUpdated(),t}divideInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]/=i[r];return this.markAsUpdated(),this}minimizeInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]=Math.min(t[r],i[r]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){let t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){let t=this._m,i=e.m;for(let r=0;r<16;r++)t[r]=Math.min(t[r],i[r]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){let 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 n)}negateInPlace(){let e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=-t[r];return e.markAsUpdated(),e}equals(e){let t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;let i=this.m,r=t.m;return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]&&i[4]===r[4]&&i[5]===r[5]&&i[6]===r[6]&&i[7]===r[7]&&i[8]===r[8]&&i[9]===r[9]&&i[10]===r[10]&&i[11]===r[11]&&i[12]===r[12]&&i[13]===r[13]&&i[14]===r[14]&&i[15]===r[15]}equalsWithEpsilon(e,t=0){let i=this._m,r=e.m;for(let s=0;s<16;s++)if(!mt(i[s],r[s],t))return!1;return!0}equalsToFloats(...e){let t=this._m;for(let i=0;i<16;i++)if(t[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new n)}floorToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=Math.floor(t[r]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new n)}fractToRef(e){let t=this._m,i=e._m;for(let r=0;r<16;r++)i[r]=t[r]-Math.floor(t[r]);return e.markAsUpdated(),e}clone(){let e=new n;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=Hi(this._m[0]);for(let t=1;t<16;t++)e=e*397^Hi(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new Ae,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,r,s=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;let a=this._m;if(i&&i.copyFromFloats(a[12],a[13],a[14]),e=e||Se.Vector3[0],e.x=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),e.y=Math.sqrt(a[4]*a[4]+a[5]*a[5]+a[6]*a[6]),e.z=Math.sqrt(a[8]*a[8]+a[9]*a[9]+a[10]*a[10]),r){let o=(s?r.absoluteScaling.x:r.scaling.x)<0?-1:1,l=(s?r.absoluteScaling.y:r.scaling.y)<0?-1:1,c=(s?r.absoluteScaling.z:r.scaling.z)<0?-1:1;e.x*=o,e.y*=l,e.z*=c}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){let o=1/e._x,l=1/e._y,c=1/e._z;n.FromValuesToRef(a[0]*o,a[1]*o,a[2]*o,0,a[4]*l,a[5]*l,a[6]*l,0,a[8]*c,a[9]*c,a[10]*c,0,0,0,0,1,Se.Matrix[0]),Ae.FromRotationMatrixToRef(Se.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;let t=e*4;return new vt(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){let 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(){let e=new n;return n.TransposeToRef(this,e),e}transposeToRef(e){return n.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,r,s){if(e<0||e>3)return this;let a=e*4;return this._m[a+0]=t,this._m[a+1]=i,this._m[a+2]=r,this._m[a+3]=s,this.markAsUpdated(),this}scale(e){let t=new n;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){let t=this._m;for(let i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){let t=Se.Matrix[0];this.invertToRef(t),t.transposeToRef(e);let i=e._m;return n.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(){let e=new n;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){let t=Se.Vector3[0];if(!this.decompose(t))return n.IdentityToRef(e),e;let i=this._m,r=1/t._x,s=1/t._y,a=1/t._z;return n.FromValuesToRef(i[0]*r,i[1]*r,i[2]*r,0,i[4]*s,i[5]*s,i[6]*s,0,i[8]*a,i[9]*a,i[10]*a,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){let e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){let e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){let i=new n;return n.FromArrayToRef(e,t,i),i}static FromArrayToRef(e,t,i){for(let r=0;r<16;r++)i._m[r]=e[r+t];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,t,i,r){return r._m[0]=e[0+t]*i,r._m[1]=e[1+t]*i,r._m[2]=e[2+t]*i,r._m[3]=e[3+t]*i,r._m[4]=e[4+t]*i,r._m[5]=e[5+t]*i,r._m[6]=e[6+t]*i,r._m[7]=e[7+t]*i,r._m[8]=e[8+t]*i,r._m[9]=e[9+t]*i,r._m[10]=e[10+t]*i,r._m[11]=e[11+t]*i,r._m[12]=e[12+t]*i,r._m[13]=e[13+t]*i,r._m[14]=e[14+t]*i,r._m[15]=e[15+t]*i,r.markAsUpdated(),r}static get IdentityReadOnly(){return n._IdentityReadOnly}static FromValuesToRef(e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g){let T=g._m;T[0]=e,T[1]=t,T[2]=i,T[3]=r,T[4]=s,T[5]=a,T[6]=o,T[7]=l,T[8]=c,T[9]=f,T[10]=d,T[11]=h,T[12]=u,T[13]=m,T[14]=p,T[15]=_,g.markAsUpdated()}static FromValues(e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_){let g=new n,T=g._m;return T[0]=e,T[1]=t,T[2]=i,T[3]=r,T[4]=s,T[5]=a,T[6]=o,T[7]=l,T[8]=c,T[9]=f,T[10]=d,T[11]=h,T[12]=u,T[13]=m,T[14]=p,T[15]=_,g.markAsUpdated(),g}static Compose(e,t,i){let r=new n;return n.ComposeToRef(e,t,i,r),r}static ComposeToRef(e,t,i,r){let s=r._m,a=t._x,o=t._y,l=t._z,c=t._w,f=a+a,d=o+o,h=l+l,u=a*f,m=a*d,p=a*h,_=o*d,g=o*h,T=l*h,b=c*f,R=c*d,S=c*h,I=e._x,x=e._y,P=e._z;return s[0]=(1-(_+T))*I,s[1]=(m+S)*I,s[2]=(p-R)*I,s[3]=0,s[4]=(m-S)*x,s[5]=(1-(u+T))*x,s[6]=(g+b)*x,s[7]=0,s[8]=(p+R)*P,s[9]=(g-b)*P,s[10]=(1-(u+_))*P,s[11]=0,s[12]=i._x,s[13]=i._y,s[14]=i._z,s[15]=1,r.markAsUpdated(),r}static Identity(){let e=n.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 n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){let e=n.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){let t=new n;return n.RotationXToRef(e,t),t}static Invert(e){let t=new n;return e.invertToRef(t),t}static RotationXToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(1,0,0,0,0,r,i,0,0,-i,r,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationY(e){let t=new n;return n.RotationYToRef(e,t),t}static RotationYToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(r,0,-i,0,0,1,0,0,i,0,r,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationZ(e){let t=new n;return n.RotationZToRef(e,t),t}static RotationZToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return n.FromValuesToRef(r,i,0,0,-i,r,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(r===1&&i===0),t}static RotationAxis(e,t){let i=new n;return n.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){let r=Math.sin(-t),s=Math.cos(-t),a=1-s;e=e.normalizeToRef(Se.Vector3[0]);let o=i._m;return o[0]=e._x*e._x*a+s,o[1]=e._x*e._y*a-e._z*r,o[2]=e._x*e._z*a+e._y*r,o[3]=0,o[4]=e._y*e._x*a+e._z*r,o[5]=e._y*e._y*a+s,o[6]=e._y*e._z*a-e._x*r,o[7]=0,o[8]=e._z*e._x*a-e._y*r,o[9]=e._z*e._y*a+e._x*r,o[10]=e._z*e._z*a+s,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,t,i,r=!1){let s=v.Dot(t,e),a=i._m;if(s<-1+Ye)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=r?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=r?-1:1,a[11]=0;else{let o=v.Cross(t,e),l=1/(1+s);a[0]=o._x*o._x*l+s,a[1]=o._y*o._x*l-o._z,a[2]=o._z*o._x*l+o._y,a[3]=0,a[4]=o._x*o._y*l+o._z,a[5]=o._y*o._y*l+s,a[6]=o._z*o._y*l-o._x,a[7]=0,a[8]=o._x*o._z*l-o._y,a[9]=o._y*o._z*l+o._x,a[10]=o._z*o._z*l+s,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){let r=new n;return n.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){return Ae.RotationYawPitchRollToRef(e,t,i,Se.Quaternion[0]),Se.Quaternion[0].toRotationMatrix(r),r}static Scaling(e,t,i){let r=new n;return n.ScalingToRef(e,t,i,r),r}static ScalingToRef(e,t,i,r){return n.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,r),r._updateIdentityStatus(e===1&&t===1&&i===1),r}static Translation(e,t,i){let r=new n;return n.TranslationToRef(e,t,i,r),r}static TranslationToRef(e,t,i,r){return n.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,r),r._updateIdentityStatus(e===0&&t===0&&i===0),r}static Lerp(e,t,i){let r=new n;return n.LerpToRef(e,t,i,r),r}static LerpToRef(e,t,i,r){let s=r._m,a=e.m,o=t.m;for(let l=0;l<16;l++)s[l]=a[l]*(1-i)+o[l]*i;return r.markAsUpdated(),r}static DecomposeLerp(e,t,i){let r=new n;return n.DecomposeLerpToRef(e,t,i,r),r}static DecomposeLerpToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Quaternion[0],o=Se.Vector3[1];e.decompose(s,a,o);let l=Se.Vector3[2],c=Se.Quaternion[1],f=Se.Vector3[3];t.decompose(l,c,f);let d=Se.Vector3[4];v.LerpToRef(s,l,i,d);let h=Se.Quaternion[2];Ae.SlerpToRef(a,c,i,h);let u=Se.Vector3[5];return v.LerpToRef(o,f,i,u),n.ComposeToRef(d,h,u,r),r}static LookAtLH(e,t,i){let r=new n;return n.LookAtLHToRef(e,t,i,r),r}static LookAtLHToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Vector3[1],o=Se.Vector3[2];t.subtractToRef(e,o),o.normalize(),v.CrossToRef(i,o,s);let l=s.lengthSquared();l===0?s.x=1:s.normalizeFromLength(Math.sqrt(l)),v.CrossToRef(o,s,a),a.normalize();let c=-v.Dot(s,e),f=-v.Dot(a,e),d=-v.Dot(o,e);return n.FromValuesToRef(s._x,a._x,o._x,0,s._y,a._y,o._y,0,s._z,a._z,o._z,0,c,f,d,1,r),r}static LookAtRH(e,t,i){let r=new n;return n.LookAtRHToRef(e,t,i,r),r}static LookAtRHToRef(e,t,i,r){let s=Se.Vector3[0],a=Se.Vector3[1],o=Se.Vector3[2];e.subtractToRef(t,o),o.normalize(),v.CrossToRef(i,o,s);let l=s.lengthSquared();l===0?s.x=1:s.normalizeFromLength(Math.sqrt(l)),v.CrossToRef(o,s,a),a.normalize();let c=-v.Dot(s,e),f=-v.Dot(a,e),d=-v.Dot(o,e);return n.FromValuesToRef(s._x,a._x,o._x,0,s._y,a._y,o._y,0,s._z,a._z,o._z,0,c,f,d,1,r),r}static LookDirectionLH(e,t){let i=new n;return n.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){let r=Se.Vector3[0];r.copyFrom(e),r.scaleInPlace(-1);let s=Se.Vector3[1];return v.CrossToRef(t,r,s),n.FromValuesToRef(s._x,s._y,s._z,0,t._x,t._y,t._z,0,r._x,r._y,r._z,0,0,0,0,1,i),i}static LookDirectionRH(e,t){let i=new n;return n.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){let r=Se.Vector3[2];return v.CrossToRef(t,e,r),n.FromValuesToRef(r._x,r._y,r._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,r,s){let a=new n;return n.OrthoLHToRef(e,t,i,r,a,s),a}static OrthoLHToRef(e,t,i,r,s,a){let o=i,l=r,c=2/e,f=2/t,d=2/(l-o),h=-(l+o)/(l-o);return n.FromValuesToRef(c,0,0,0,0,f,0,0,0,0,d,0,0,0,h,1,s),a&&s.multiplyToRef(co,s),s._updateIdentityStatus(c===1&&f===1&&d===1&&h===0),s}static OrthoOffCenterLH(e,t,i,r,s,a,o){let l=new n;return n.OrthoOffCenterLHToRef(e,t,i,r,s,a,l,o),l}static OrthoOffCenterLHToRef(e,t,i,r,s,a,o,l){let c=s,f=a,d=2/(t-e),h=2/(r-i),u=2/(f-c),m=-(f+c)/(f-c),p=(e+t)/(e-t),_=(r+i)/(i-r);return n.FromValuesToRef(d,0,0,0,0,h,0,0,0,0,u,0,p,_,m,1,o),l&&o.multiplyToRef(co,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,r,s,a,o,l,c,f,d){let h=-o*Math.cos(l),u=-o*Math.sin(l);return n.TranslationToRef(0,0,-c,Se.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,h,u,1,0,0,0,0,1,Se.Matrix[0]),Se.Matrix[1].multiplyToRef(Se.Matrix[0],Se.Matrix[0]),n.TranslationToRef(0,0,c,Se.Matrix[1]),Se.Matrix[0].multiplyToRef(Se.Matrix[1],Se.Matrix[0]),n.OrthoOffCenterLHToRef(e,t,i,r,s,a,f,d),Se.Matrix[0].multiplyToRef(f,f),f}static OrthoOffCenterRH(e,t,i,r,s,a,o){let l=new n;return n.OrthoOffCenterRHToRef(e,t,i,r,s,a,l,o),l}static OrthoOffCenterRHToRef(e,t,i,r,s,a,o,l){return n.OrthoOffCenterLHToRef(e,t,i,r,s,a,o,l),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,r,s,a,o,l,c,f,d){let h=o*Math.cos(l),u=o*Math.sin(l);return n.TranslationToRef(0,0,c,Se.Matrix[1]),n.FromValuesToRef(1,0,0,0,0,1,0,0,h,u,1,0,0,0,0,1,Se.Matrix[0]),Se.Matrix[1].multiplyToRef(Se.Matrix[0],Se.Matrix[0]),n.TranslationToRef(0,0,-c,Se.Matrix[1]),Se.Matrix[0].multiplyToRef(Se.Matrix[1],Se.Matrix[0]),n.OrthoOffCenterRHToRef(e,t,i,r,s,a,f,d),Se.Matrix[0].multiplyToRef(f,f),f}static PerspectiveLH(e,t,i,r,s,a=0){let o=new n,l=i,c=r,f=2*l/e,d=2*l/t,h=(c+l)/(c-l),u=-2*c*l/(c-l),m=Math.tan(a);return n.FromValuesToRef(f,0,0,0,0,d,0,m,0,0,h,1,0,0,u,0,o),s&&o.multiplyToRef(co,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,r,s,a=0,o=!1){let l=new n;return n.PerspectiveFovLHToRef(e,t,i,r,l,!0,s,a,o),l}static PerspectiveFovLHToRef(e,t,i,r,s,a=!0,o,l=0,c=!1){let f=i,d=r,h=1/Math.tan(e*.5),u=a?h/t:h,m=a?h:h*t,p=c&&f===0?-1:d!==0?(d+f)/(d-f):1,_=c&&f===0?2*d:d!==0?-2*d*f/(d-f):-2*f,g=Math.tan(l);return n.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,1,0,0,_,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovReverseLHToRef(e,t,i,r,s,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,d=a?c:c*t,h=Math.tan(l);return n.FromValuesToRef(f,0,0,0,0,d,0,h,0,0,-i,1,0,0,1,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovRH(e,t,i,r,s,a=0,o=!1){let l=new n;return n.PerspectiveFovRHToRef(e,t,i,r,l,!0,s,a,o),l}static PerspectiveFovRHToRef(e,t,i,r,s,a=!0,o,l=0,c=!1){let f=i,d=r,h=1/Math.tan(e*.5),u=a?h/t:h,m=a?h:h*t,p=c&&f===0?1:d!==0?-(d+f)/(d-f):-1,_=c&&f===0?2*d:d!==0?-2*d*f/(d-f):-2*f,g=Math.tan(l);return n.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,-1,0,0,_,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static PerspectiveFovReverseRHToRef(e,t,i,r,s,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,d=a?c:c*t,h=Math.tan(l);return n.FromValuesToRef(f,0,0,0,0,d,0,h,0,0,-i,-1,0,0,-1,0,s),o&&s.multiplyToRef(co,s),s._updateIdentityStatus(!1),s}static GetFinalMatrix(e,t,i,r,s,a){let o=e.width,l=e.height,c=e.x,f=e.y,d=n.FromValues(o/2,0,0,0,0,-l/2,0,0,0,0,a-s,0,c+o/2,l/2+f,s,1),h=new n;return t.multiplyToRef(i,h),h.multiplyToRef(r,h),h.multiplyToRef(d,h)}static GetAsMatrix2x2(e){let t=e.m,i=[t[0],t[1],t[4],t[5]];return Wi.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){let t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return Wi.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){let t=new n;return n.TransposeToRef(e,t),t}static TransposeToRef(e,t){let i=e.m,r=i[0],s=i[4],a=i[8],o=i[12],l=i[1],c=i[5],f=i[9],d=i[13],h=i[2],u=i[6],m=i[10],p=i[14],_=i[3],g=i[7],T=i[11],b=i[15],R=t._m;return R[0]=r,R[1]=s,R[2]=a,R[3]=o,R[4]=l,R[5]=c,R[6]=f,R[7]=d,R[8]=h,R[9]=u,R[10]=m,R[11]=p,R[12]=_,R[13]=g,R[14]=T,R[15]=b,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){let t=new n;return n.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();let i=e.normal.x,r=e.normal.y,s=e.normal.z,a=-2*i,o=-2*r,l=-2*s;return n.FromValuesToRef(a*i+1,o*i,l*i,0,a*r,o*r+1,l*r,0,a*s,o*s,l*s+1,0,a*e.d,o*e.d,l*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,r){return n.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,r),r}static FromQuaternionToRef(e,t){let i=e._x*e._x,r=e._y*e._y,s=e._z*e._z,a=e._x*e._y,o=e._z*e._w,l=e._z*e._x,c=e._y*e._w,f=e._y*e._z,d=e._x*e._w;return t._m[0]=1-2*(r+s),t._m[1]=2*(a+o),t._m[2]=2*(l-c),t._m[3]=0,t._m[4]=2*(a-o),t._m[5]=1-2*(s+i),t._m[6]=2*(f+d),t._m[7]=0,t._m[8]=2*(l+c),t._m[9]=2*(f-d),t._m[10]=1-2*(r+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}};U._IdentityReadOnly=U.Identity();Object.defineProperties(U.prototype,{dimension:{value:[4,4]},rank:{value:2}});Se=class{};Se.Vector3=as(11,v.Zero);Se.Matrix=as(2,U.Identity);Se.Quaternion=as(3,Ae.Zero);G=class{};G.Vector2=as(3,_e.Zero);G.Vector3=as(13,v.Zero);G.Vector4=as(3,vt.Zero);G.Quaternion=as(3,Ae.Zero);G.Matrix=as(8,U.Identity);je("BABYLON.Vector2",_e);je("BABYLON.Vector3",v);je("BABYLON.Vector4",vt);je("BABYLON.Matrix",U);co=U.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)});var yI,tr,DI,nl=A(()=>{ve();(function(n){n[n.LOCAL=0]="LOCAL",n[n.WORLD=1]="WORLD",n[n.BONE=2]="BONE"})(yI||(yI={}));tr=class{};tr.X=new v(1,0,0);tr.Y=new v(0,1,0);tr.Z=new v(0,0,1);(function(n){n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=2]="Z"})(DI||(DI={}))});function sl(n){return Math.pow(n,il)}function al(n){return n<=.04045?.0773993808*n:Math.pow(.947867299*(n+.055),2.4)}function ol(n){return Math.pow(n,AI)}function ll(n){return n<=.0031308?12.92*n:1.055*Math.pow(n,.41666)-.055}var oe,Ne,Ii,et=A(()=>{Ln();Lt();bi();Mi();oe=class n{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 n.FromArrayToRef(e,t,this),this}toColor4(e=1){return new Ne(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 n(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 n(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=Ye){return mt(this.r,e.r,t)&&mt(this.g,e.g,t)&&mt(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 n(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=Ke(this.r,e,t),i.g=Ke(this.g,e,t),i.b=Ke(this.b,e,t),i}add(e){return new n(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 n(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 n(this.r-e,this.g-t,this.b-i)}subtractFromFloatsToRef(e,t,i,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r}clone(){return new n(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(){let e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+sn(e)+sn(t)+sn(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 n)}toHSVToRef(e){let t=this.r,i=this.g,r=this.b,s=Math.max(t,i,r),a=Math.min(t,i,r),o=0,l=0,c=s,f=s-a;return s!==0&&(l=f/s),s!=a&&(s==t?(o=(i-r)/f,i=0&&a<=1?(l=s,c=o):a>=1&&a<=2?(l=o,c=s):a>=2&&a<=3?(c=s,f=o):a>=3&&a<=4?(c=o,f=s):a>=4&&a<=5?(l=o,f=s):a>=5&&a<=6&&(l=s,f=o);let d=i-s;return r.r=l+d,r.g=c+d,r.b=f+d,r}static FromHSV(e,t,i){let r=new n(0,0,0);return n.HSVtoRGBToRef(e,t,i,r),r}static FromHexString(e){return new n(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new n(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 n(e/255,t/255,i/255)}static Lerp(e,t,i){let r=new n(0,0,0);return n.LerpToRef(e,t,i,r),r}static LerpToRef(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.r*l+i.r*c+t.r*f+r.r*d,u=e.g*l+i.g*c+t.g*f+r.g*d,m=e.b*l+i.b*c+t.b*f+r.b*d;return new n(h,u,m)}static Hermite1stDerivative(e,t,i,r,s){let a=n.Black();return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;a.r=(o-s)*6*e.r+(3*o-4*s+1)*t.r+(-o+s)*6*i.r+(3*o-2*s)*r.r,a.g=(o-s)*6*e.g+(3*o-4*s+1)*t.g+(-o+s)*6*i.g+(3*o-2*s)*r.g,a.b=(o-s)*6*e.b+(3*o-4*s+1)*t.b+(-o+s)*6*i.b+(3*o-2*s)*r.b}static Red(){return new n(1,0,0)}static Green(){return new n(0,1,0)}static Blue(){return new n(0,0,1)}static Black(){return new n(0,0,0)}static get BlackReadOnly(){return n._BlackReadOnly}static White(){return new n(1,1,1)}static Purple(){return new n(.5,0,.5)}static Magenta(){return new n(1,0,1)}static Yellow(){return new n(1,1,0)}static Gray(){return new n(.5,.5,.5)}static Teal(){return new n(0,1,1)}static Random(){return new n(Math.random(),Math.random(),Math.random())}};oe._V8PerformanceHack=new oe(.5,.5,.5);oe._BlackReadOnly=oe.Black();Object.defineProperties(oe.prototype,{dimension:{value:[3]},rank:{value:1}});Ne=class n{constructor(e=0,t=0,i=0,r=1){this.r=e,this.g=t,this.b=i,this.a=r}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 n(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,r){return this.r+=e,this.g+=t,this.b+=i,this.a+=r,this}subtract(e){return new n(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,r){return new n(this.r-e,this.g-t,this.b-i,this.a-r)}subtractFromFloatsToRef(e,t,i,r,s){return s.r=this.r-e,s.g=this.g-t,s.b=this.b-i,s.a=this.a-r,s}scale(e){return new n(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=Ke(this.r,e,t),i.g=Ke(this.g,e,t),i.b=Ke(this.b,e,t),i.a=Ke(this.a,e,t),i}multiply(e){return new n(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,r){return new n(this.r*e,this.g*t,this.b*i,this.a*r)}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,r){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(r,this.a),this}maximizeInPlaceFromFloats(e,t,i,r){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(r,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=Ye){return mt(this.r,e.r,t)&&mt(this.g,e.g,t)&&mt(this.b,e.b,t)&&mt(this.a,e.a,t)}equalsToFloats(e,t,i,r){return this.r===e&&this.g===t&&this.b===i&&this.a===r}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 n().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,r){return this.r=e,this.g=t,this.b=i,this.a=r,this}set(e,t,i,r){return this.copyFromFloats(e,t,i,r)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){let t=Math.round(this.r*255),i=Math.round(this.g*255),r=Math.round(this.b*255);if(e)return"#"+sn(t)+sn(i)+sn(r);let s=Math.round(this.a*255);return"#"+sn(t)+sn(i)+sn(r)+sn(s)}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){let t=new n;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=al(this.r),e.g=al(this.g),e.b=al(this.b)):(e.r=sl(this.r),e.g=sl(this.g),e.b=sl(this.b)),e.a=this.a,this}toGammaSpace(e=!1){let t=new n;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=ll(this.r),e.g=ll(this.g),e.b=ll(this.b)):(e.r=ol(this.r),e.g=ol(this.g),e.b=ol(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new n(0,0,0,0):new n(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return n.LerpToRef(e,t,i,new n)}static LerpToRef(e,t,i,r){return r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i,r}static Hermite(e,t,i,r,s){let a=s*s,o=s*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+s,d=o-a,h=e.r*l+i.r*c+t.r*f+r.r*d,u=e.g*l+i.g*c+t.g*f+r.g*d,m=e.b*l+i.b*c+t.b*f+r.b*d,p=e.a*l+i.a*c+t.a*f+r.a*d;return new n(h,u,m,p)}static Hermite1stDerivative(e,t,i,r,s){let a=new n;return this.Hermite1stDerivativeToRef(e,t,i,r,s,a),a}static Hermite1stDerivativeToRef(e,t,i,r,s,a){let o=s*s;a.r=(o-s)*6*e.r+(3*o-4*s+1)*t.r+(-o+s)*6*i.r+(3*o-2*s)*r.r,a.g=(o-s)*6*e.g+(3*o-4*s+1)*t.g+(-o+s)*6*i.g+(3*o-2*s)*r.g,a.b=(o-s)*6*e.b+(3*o-4*s+1)*t.b+(-o+s)*6*i.b+(3*o-2*s)*r.b,a.a=(o-s)*6*e.a+(3*o-4*s+1)*t.a+(-o+s)*6*i.a+(3*o-2*s)*r.a}static FromColor3(e,t=1){return new n(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new n(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,r){return new n(e/255,t/255,i/255,r/255)}static CheckColors4(e,t){if(e.length===t*3){let i=[];for(let r=0;rnew Ne(0,0,0,0));je("BABYLON.Color3",oe);je("BABYLON.Color4",Ne)});var ir,fo=A(()=>{ve();ir=class n{constructor(e,t,i,r){this.normal=new v(e,t,i),this.d=r}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new n(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(){let e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),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){let t=n._TmpMatrix;e.invertToRef(t);let i=t.m,r=this.normal.x,s=this.normal.y,a=this.normal.z,o=this.d,l=r*i[0]+s*i[1]+a*i[2]+o*i[3],c=r*i[4]+s*i[5]+a*i[6]+o*i[7],f=r*i[8]+s*i[9]+a*i[10]+o*i[11],d=r*i[12]+s*i[13]+a*i[14]+o*i[15];return new n(l,c,f,d)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,i){let r=t.x-e.x,s=t.y-e.y,a=t.z-e.z,o=i.x-e.x,l=i.y-e.y,c=i.z-e.z,f=s*c-a*l,d=a*o-r*c,h=r*l-s*o,u=Math.sqrt(f*f+d*d+h*h),m;return u!==0?m=1/u:m=0,this.normal.x=f*m,this.normal.y=d*m,this.normal.z=h*m,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 n(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){let r=new n(0,0,0,0);return r.copyFromPoints(e,t,i),r}static FromPositionAndNormal(e,t){let i=new n(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){let r=-(t.x*e.x+t.y*e.y+t.z*e.z);return v.Dot(i,t)+r}};ir._TmpMatrix=U.Identity()});var oa,ah=A(()=>{fo();oa=class n{static GetPlanes(e){let t=[];for(let i=0;i<6;i++)t.push(new ir(0,0,0,0));return n.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){let 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){let 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){let 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){let 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){let 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){let 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){n.GetNearPlaneToRef(e,t[0]),n.GetFarPlaneToRef(e,t[1]),n.GetLeftPlaneToRef(e,t[2]),n.GetRightPlaneToRef(e,t[3]),n.GetTopPlaneToRef(e,t[4]),n.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 LI,cl,A_,fl,ho,uo=A(()=>{Mi();ve();bi();(function(n){n[n.CW=0]="CW",n[n.CCW=1]="CCW"})(LI||(LI={}));cl=class n{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){let i=t.subtract(e),r=Math.atan2(i.y,i.x);return new n(r)}static BetweenTwoVectors(e,t){let i=e.lengthSquared()*t.lengthSquared();if(i===0)return new n(Math.PI/2);i=Math.sqrt(i);let r=e.dot(t)/i;r=Ke(r,-1,1);let s=Math.acos(r);return new n(s)}static FromRadians(e){return new n(e)}static FromDegrees(e){return new n(e*Math.PI/180)}},A_=class{constructor(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;let r=Math.pow(t.x,2)+Math.pow(t.y,2),s=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,a=(r-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 _e((s*(t.y-i.y)-a*(e.y-t.y))/o,((e.x-t.x)*a-(t.x-i.x)*s)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=cl.BetweenTwoPoints(this.centerPoint,this.startPoint);let l=this.startAngle.degrees(),c=cl.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),f=cl.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-l>180&&(c-=360),c-l<-180&&(c+=360),f-c>180&&(f-=360),f-c<-180&&(f+=360),this.orientation=c-l<0?0:1,this.angle=cl.FromDegrees(this.orientation===0?l-f:f-l)}},fl=class n{constructor(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new _e(e,t))}addLineTo(e,t){if(this.closed)return this;let i=new _e(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this}addArcTo(e,t,i,r,s=36){if(this.closed)return this;let a=this._points[this._points.length-1],o=new _e(e,t),l=new _e(i,r),c=new A_(a,o,l),f=c.angle.radians()/s;c.orientation===0&&(f*=-1);let d=c.startAngle.radians()+f;for(let h=0;h(1-l)*(1-l)*c+2*l*(1-l)*f+l*l*d,o=this._points[this._points.length-1];for(let l=0;l<=s;l++){let c=l/s,f=a(c,o.x,e,i),d=a(c,o.y,t,r);this.addLineTo(f,d)}return this}addBezierCurveTo(e,t,i,r,s,a,o=36){if(this.closed)return this;let l=(f,d,h,u,m)=>(1-f)*(1-f)*(1-f)*d+3*f*(1-f)*(1-f)*h+3*f*f*(1-f)*u+f*f*f*m,c=this._points[this._points.length-1];for(let f=0;f<=o;f++){let d=f/o,h=l(d,c.x,e,i,s),u=l(d,c.y,t,r,a);this.addLineTo(h,u)}return this}isPointInside(e){let t=!1,i=this._points.length;for(let r=i-1,s=0;sNumber.EPSILON){if(c<0&&(a=this._points[s],l=-l,o=this._points[r],c=-c),e.yo.y)continue;if(e.y===a.y&&e.x===a.x)return!0;{let f=c*(e.x-a.x)-l*(e.y-a.y);if(f===0)return!0;if(f<0)continue;t=!t}}else{if(e.y!==a.y)continue;if(o.x<=e.x&&e.x<=a.x||a.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){let t=this._points[this._points.length-1],i=this._points[0];e+=i.subtract(t).length()}return e}area(){let e=this._points.length,t=0;for(let i=e-1,r=0;r1)return _e.Zero();let t=e*this.length(),i=0;for(let r=0;r=i&&t<=c){let f=l.normalize(),d=t-i;return new _e(a.x+f.x*d,a.y+f.y*d)}i=c}return _e.Zero()}static StartingAt(e,t){return new n(e,t)}},ho=class n{constructor(e,t=null,i,r=!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:U.Identity()};for(let s=0;st){let c=e;e=t,t=c}let i=this.getCurve(),r=this.getPointAt(e),s=this.getPreviousPointIndexAt(e),a=this.getPointAt(t),o=this.getPreviousPointIndexAt(t)+1,l=[];return e!==0&&(s++,l.push(r)),l.push(...i.slice(s,o)),(t!==1||e===1)&&l.push(a),new n(l,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)}update(e,t=null,i=!1){for(let r=0;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i}_normalVector(e,t){let i,r=e.length();if(r===0&&(r=1),t==null){let s;mt(Math.abs(e.y)/r,1,Ye)?mt(Math.abs(e.x)/r,1,Ye)?mt(Math.abs(e.z)/r,1,Ye)?s=v.Zero():s=new v(0,0,1):s=new v(1,0,0):s=new v(0,-1,0),i=v.Cross(e,s)}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;let 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 r=i[0],s,a=0,o=e*this.length();for(let l=1;lo){let d=(a-o)/c,h=r.subtract(s),u=s.add(h.scaleInPlace(d));return this._setPointAtData(e,1-d,u,l-1,t)}r=s}return this._pointAtData}_setPointAtData(e,t,i,r,s){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=s,s&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=U.Identity();let e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){let t=e+1,i=this._tangents[e].clone(),r=this._normals[e].clone(),s=this._binormals[e].clone(),a=this._tangents[t].clone(),o=this._normals[t].clone(),l=this._binormals[t].clone(),c=Ae.RotationQuaternionFromAxis(r,s,i),f=Ae.RotationQuaternionFromAxis(o,l,a);Ae.Slerp(c,f,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}});var os,oh=A(()=>{os=class n{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=this.width|0;return e=e*397^(this.height|0),e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new n(this.width*e,this.height*t)}clone(){return new n(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 n(0,0)}add(e){return new n(this.width+e.width,this.height+e.height)}subtract(e){return new n(this.width-e.width,this.height-e.height)}scale(e){return new n(this.width*e,this.height*e)}static Lerp(e,t,i){let r=e.width+(t.width-e.width)*i,s=e.height+(t.height-e.height)*i;return new n(r,s)}}});var PI=A(()=>{ve()});var an,dl=A(()=>{an=class n{constructor(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}toGlobal(e,t){return new n(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 n(this.x,this.y,this.width,this.height)}}});var OI=A(()=>{nl();et();bi();ah();uo();fo();oh();ve();PI();dl()});var Pn,PV,ls,cs,zc,On,Xc=A(()=>{ve();OI();Pn=[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))],PV=[()=>1,n=>n.y,n=>n.z,n=>n.x,n=>n.x*n.y,n=>n.y*n.z,n=>3*n.z*n.z-1,n=>n.x*n.z,n=>n.x*n.x-n.y*n.y],ls=(n,e)=>Pn[n]*PV[n](e),cs=[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],zc=class n{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){G.Vector3[0].set(t.r,t.g,t.b);let r=G.Vector3[0],s=G.Vector3[1];r.scaleToRef(i,s),s.scaleToRef(ls(0,e),G.Vector3[2]),this.l00.addInPlace(G.Vector3[2]),s.scaleToRef(ls(1,e),G.Vector3[2]),this.l1_1.addInPlace(G.Vector3[2]),s.scaleToRef(ls(2,e),G.Vector3[2]),this.l10.addInPlace(G.Vector3[2]),s.scaleToRef(ls(3,e),G.Vector3[2]),this.l11.addInPlace(G.Vector3[2]),s.scaleToRef(ls(4,e),G.Vector3[2]),this.l2_2.addInPlace(G.Vector3[2]),s.scaleToRef(ls(5,e),G.Vector3[2]),this.l2_1.addInPlace(G.Vector3[2]),s.scaleToRef(ls(6,e),G.Vector3[2]),this.l20.addInPlace(G.Vector3[2]),s.scaleToRef(ls(7,e),G.Vector3[2]),this.l21.addInPlace(G.Vector3[2]),s.scaleToRef(ls(8,e),G.Vector3[2]),this.l22.addInPlace(G.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(cs[0]),this.l1_1.scaleInPlace(cs[1]),this.l10.scaleInPlace(cs[2]),this.l11.scaleInPlace(cs[3]),this.l2_2.scaleInPlace(cs[4]),this.l2_1.scaleInPlace(cs[5]),this.l20.scaleInPlace(cs[6]),this.l21.scaleInPlace(cs[7]),this.l22.scaleInPlace(cs[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(Pn[0]),this.l1_1.scaleInPlace(Pn[1]),this.l10.scaleInPlace(Pn[2]),this.l11.scaleInPlace(Pn[3]),this.l2_2.scaleInPlace(Pn[4]),this.l2_1.scaleInPlace(Pn[5]),this.l20.scaleInPlace(Pn[6]),this.l21.scaleInPlace(Pn[7]),this.l22.scaleInPlace(Pn[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 n().updateFromArray(e)}static FromPolynomial(e){let t=new n;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}},On=class n{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=zc.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){G.Vector3[0].copyFromFloats(e.r,e.g,e.b);let t=G.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),G.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),G.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(G.Vector3[0]).addInPlace(G.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(G.Vector3[0]).subtractInPlace(G.Vector3[1]),this.zz.copyFrom(e.l00),G.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(G.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 n().updateFromHarmonics(e)}static FromArray(e){let t=new n;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 C(n,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,i);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(s=(r<3?a(s):r>3?a(e,t,s):a(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}var Qe=A(()=>{});function NI(n){let e=n.getClassName();return ch[e]||(ch[e]={}),ch[e]}function fh(n){let e=n.getClassName();if(lh[e])return lh[e];lh[e]={};let t=lh[e],i=n,r=e;for(;r;){let s=ch[r];for(let l in s)t[l]=s[l];let a,o=!1;do{if(a=Object.getPrototypeOf(i),!a.getClassName){o=!0;break}if(a.getClassName()!==r)break;i=a}while(a);if(o)break;r=a.getClassName(),i=a}return t}var lh,ch,R_=A(()=>{lh={},ch={}});function Pr(n,e){return(t,i)=>{let r=NI(t);r[i]||(r[i]={type:n,sourceName:e})}}function OV(n,e=null){return(t,i)=>{let r=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[r]},set:function(s){var a;typeof((a=this[r])==null?void 0:a.equals)=="function"&&this[r].equals(s)||this[r]!==s&&(this[r]=s,t[n].apply(this))},enumerable:!0,configurable:!0})}}function ee(n,e=null){return OV(n,e)}function D(n){return Pr(0,n)}function Ze(n){return Pr(1,n)}function Ht(n){return Pr(2,n)}function hl(n){return Pr(3,n)}function ul(n){return Pr(4,n)}function ai(n){return Pr(5,n)}function dh(n){return Pr(6,n)}function FI(n){return Pr(7,n)}function ml(n){return Pr(8,n)}function wI(n){return Pr(9,n)}function BI(n){return Pr(10,n)}function UI(n){return Pr(11,n)}function rr(n,e,t,i){let r=t.value;t.value=(...s)=>{let a=r;if(typeof _native!="undefined"&&_native[e]){let o=_native[e];i?a=(...l)=>i(...l)?o(...l):r(...l):a=o}return n[e]=a,a(...s)}}function Be(n,e=null){return(t,i)=>{let r=i;Object.defineProperty(t,e||"",{get:function(){return this[r].value},set:function(a){var o,l;typeof((l=(o=this[r])==null?void 0:o.value)==null?void 0:l.equals)=="function"&&this[r].value.equals(a)||this[r].value!==a&&(this[r].value=a,t[n].apply(this))},enumerable:!0,configurable:!0})}}var qe=A(()=>{R_();rr.filter=function(n){return(e,t,i)=>rr(e,t,i,n)}});function la(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}var Yc=A(()=>{});function NV(){return typeof _native!="undefined"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}var $t,mo=A(()=>{$t=class n{constructor(){this._xhr=NV(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(n.CustomRequestHeaders).length>0||n.CustomRequestModifiers.length>0}static _CleanUrl(e){return e=e.replace("file:http:","http:"),e=e.replace("file:https:","https:"),e}static _ShouldSkipRequestModifications(e){return n.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}static _CollectCustomizations(e,t={}){let i={...t};if(n._ShouldSkipRequestModifications(e))return{url:e,headers:i};for(let s in n.CustomRequestHeaders){let a=n.CustomRequestHeaders[s];a&&(i[s]=a)}let r={setRequestHeader:(s,a)=>{i[s]=a}};for(let s of n.CustomRequestModifiers){if(n._ShouldSkipRequestModifications(e))break;let a=s(r,e);typeof a=="string"&&(e=a)}return{url:e,headers:i}}static async FetchAsync(e,t={}){var r,s,a;let i=(r=t.method)!=null?r:"GET";if(typeof fetch!="undefined"){let{url:o,headers:l}=n._CollectCustomizations(n._CleanUrl(e),(s=t.headers)!=null?s:{});return await fetch(o,{method:i,headers:l,body:(a=t.body)!=null?a:void 0})}return await new Promise((o,l)=>{var f;let c=new n;c.responseType="arraybuffer",c.addEventListener("readystatechange",()=>{if(c.readyState===4)if(c.status>=200&&c.status<300){let d=typeof Headers!="undefined"?new Headers:void 0,h=c.getResponseHeader("Content-Type");h&&d&&d.set("Content-Type",h),o(typeof Response!="undefined"?new Response(c.response,{status:c.status,statusText:c.statusText,headers:d}):{ok:!0,status:c.status,statusText:c.statusText,headers:{get:u=>c.getResponseHeader(u)},arrayBuffer:async()=>await Promise.resolve(c.response)})}else l(new Error(`HTTP ${c.status} loading '${c.requestURL}': ${c.statusText}`))}),c.open(i,e,t.headers),c.send((f=t.body)!=null?f:null)})}get requestURL(){return this._requestURL}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){this._xhr.send(e)}open(e,t,i){let{url:r,headers:s}=n._CollectCustomizations(t,i);this._requestURL=n._CleanUrl(r),this._xhr.open(e,this._requestURL,!0);for(let a in s)this._xhr.setRequestHeader(a,s[a])}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}};$t.CustomRequestHeaders={};$t.CustomRequestModifiers=new Array;$t.SkipRequestModificationForBabylonCDN=!0});var ca,VI=A(()=>{ca=class{};ca.FilesToLoad={}});var hh,GI=A(()=>{hh=class{static ExponentialBackoff(e=3,t=500){return(i,r,s)=>r.status!==0||s>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,s)*t}}});var fs,Or,nr,Kc=A(()=>{fs=class extends Error{};fs._setPrototypeOf=Object.setPrototypeOf||((n,e)=>(n.__proto__=e,n));Or={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},nr=class n extends fs{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",fs._setPrototypeOf(this,n.prototype)}}});function FV(n){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",i,r,s,a,o,l,c,f=0;for(;f>2,o=(i&3)<<4|r>>4,l=(r&15)<<2|s>>6,c=s&63,isNaN(r)?l=c=64:isNaN(s)&&(c=64),t+=e.charAt(a)+e.charAt(o)+e.charAt(l)+e.charAt(c);return t}function wV(n){let e=I_(n),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let r=0;r{kI=n=>{if(typeof TextDecoder!="undefined")return new TextDecoder().decode(n);let e="";for(let t=0;t{let e=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);return typeof e.toBase64=="function"?e.toBase64():FV(e)},I_=n=>atob(n),WI=n=>typeof Uint8Array.fromBase64=="function"?Uint8Array.fromBase64(n).buffer:wV(n)});function BV(n,e,t,i){switch(e){case 5120:{let r=n.getInt8(t);return i&&(r=Math.max(r/127,-1)),r}case 5121:{let r=n.getUint8(t);return i&&(r=r/255),r}case 5122:{let r=n.getInt16(t,!0);return i&&(r=Math.max(r/32767,-1)),r}case 5123:{let r=n.getUint16(t,!0);return i&&(r=r/65535),r}case 5124:return n.getInt32(t,!0);case 5125:return n.getUint32(t,!0);case 5126:return n.getFloat32(t,!0);default:throw new Error(`Invalid component type ${e}`)}}function UV(n,e,t,i,r){switch(e){case 5120:{i&&(r=Math.round(r*127)),n.setInt8(t,r);break}case 5121:{i&&(r=Math.round(r*255)),n.setUint8(t,r);break}case 5122:{i&&(r=Math.round(r*32767)),n.setInt16(t,r,!0);break}case 5123:{i&&(r=Math.round(r*65535)),n.setUint16(t,r,!0);break}case 5124:{n.setInt32(t,r,!0);break}case 5125:{n.setUint32(t,r,!0);break}case 5126:{n.setFloat32(t,r,!0);break}default:throw new Error(`Invalid component type ${e}`)}}function Nn(n){switch(n){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5124:case 5125:case 5126:return 4;default:throw new Error(`Invalid type '${n}'`)}}function x_(n){switch(n){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(`Invalid component type '${n}'`)}}function po(n,e,t,i,r,s,a,o){let l=new Array(i),c=new Array(i);if(n instanceof Array){let f=e/4,d=t/4;for(let h=0;h{for(let u=0;un.length)throw new Error("Last accessed index is out of bounds.");if(p{for(let R=0;Rf.byteLength)throw new Error("Last accessed byte is out of bounds.");let u=e*o;if(r{for(let g=0;g{for(let h=0;h{ze()});function da(n){return WI(n.split(",")[1])}var YI,gl,mh,b_,VV,Mt,ph,XI,El,_o,Fn,_h,KI,jI,fa,ZI,qI,GV,Zc,kV,ds=A(()=>{mo();Lr();ft();VI();GI();Kc();jc();Xd();At();ze();Mn();aa();ii();_l();YI=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),gl=class n extends nr{constructor(e,t){super(e,Or.LoadFileError),this.name="LoadFileError",fs._setPrototypeOf(this,n.prototype),t instanceof $t?this.request=t:this.file=t}},mh=class n extends nr{constructor(e,t){super(e,Or.RequestFileError),this.request=t,this.name="RequestFileError",fs._setPrototypeOf(this,n.prototype)}},b_=class n extends nr{constructor(e,t){super(e,Or.ReadFileError),this.file=t,this.name="ReadFileError",fs._setPrototypeOf(this,n.prototype)}},VV=n=>(n=n.replace(/#/gm,"%23"),n),Mt={DefaultRetryStrategy:hh.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:n=>n,ScriptBaseUrl:"",ScriptPreprocessUrl:n=>n,CleanUrl:VV},ph=(n,e)=>{if(!(n&&n.indexOf("data:")===0)&&Mt.CorsBehavior)if(typeof Mt.CorsBehavior=="string"||Mt.CorsBehavior instanceof String)e.crossOrigin=Mt.CorsBehavior;else{let t=Mt.CorsBehavior(n);t&&(e.crossOrigin=t)}},XI={getRequiredSize:null},El=(n,e,t,i,r="",s,a=ue.LastCreatedEngine)=>{if(typeof HTMLImageElement=="undefined"&&!(a!=null&&a._features.forceBitmapOverHTMLImageElement))return t("LoadImage is only supported in web or BabylonNative environments."),null;let o,l=!1;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))if(typeof Blob!="undefined"&&typeof URL!="undefined"){let S;n instanceof ArrayBuffer?S=n:S=uh(n),o=URL.createObjectURL(new Blob([S],{type:r})),l=!0}else o=`data:${r};base64,`+pl(n);else n instanceof Blob?(o=URL.createObjectURL(n),l=!0):(o=Mt.CleanUrl(n),o=Mt.PreprocessUrl(o));let c=S=>{if(t){let I=o||n.toString();t(`Error while trying to load image: ${I.indexOf("http")===0||I.length<=128?I:I.slice(0,128)+"..."}`,S)}};if(a!=null&&a._features.forceBitmapOverHTMLImageElement)return Fn(o,S=>{a.createImageBitmap(new Blob([S],{type:r}),{premultiplyAlpha:"none",colorSpaceConversion:"none",...s}).then(I=>{e(I),l&&URL.revokeObjectURL(o)}).catch(I=>{t&&t("Error while trying to load image: "+n,I)})},void 0,i||void 0,!0,(S,I)=>{c(I)}),null;let f=new Image;if(XI.getRequiredSize){let S=XI.getRequiredSize(n);S.width&&(f.width=S.width),S.height&&(f.height=S.height)}ph(o,f);let d=[],h=()=>{for(let S of d)S.target.addEventListener(S.name,S.handler)},u=()=>{for(let S of d)S.target.removeEventListener(S.name,S.handler);d.length=0},m=()=>{u(),e(f),l&&f.src&&URL.revokeObjectURL(f.src)},p=S=>{u(),c(S),l&&f.src&&URL.revokeObjectURL(f.src)},_=S=>{if(S.blockedURI!==f.src||S.disposition==="report")return;u();let I=new Error(`CSP violation of policy ${S.effectiveDirective} ${S.blockedURI}. Current policy is ${S.originalPolicy}`);ue.UseFallbackTexture=!1,c(I),l&&f.src&&URL.revokeObjectURL(f.src),f.src=""};d.push({target:f,name:"load",handler:m}),d.push({target:f,name:"error",handler:p}),d.push({target:document,name:"securitypolicyviolation",handler:_}),h();let g=o.substring(0,5)==="blob:",T=o.substring(0,5)==="data:",b=()=>{g||T||!$t.IsCustomRequestAvailable?f.src=o:Fn(o,(S,I,x)=>{let P=!r&&x?x:r,L=new Blob([S],{type:P}),y=URL.createObjectURL(L);l=!0,f.src=y},void 0,i||void 0,!0,(S,I)=>{c(I)})},R=()=>{i&&i.loadImage(o,f)};if(!g&&!T&&i&&i.enableTexturesOffline)i.open(R,b);else{if(o.indexOf("file:")!==-1){let S=decodeURIComponent(o.substring(5).toLowerCase());if(ca.FilesToLoad[S]&&typeof URL!="undefined"){try{let I;try{I=URL.createObjectURL(ca.FilesToLoad[S])}catch(x){I=URL.createObjectURL(ca.FilesToLoad[S])}f.src=I,l=!0}catch(I){f.src=""}return f}}b()}return f},_o=(n,e,t,i,r)=>{let s=new FileReader,a={onCompleteObservable:new Y,abort:()=>s.abort()};return s.onloadend=()=>a.onCompleteObservable.notifyObservers(a),r&&(s.onerror=()=>{r(new b_(`Unable to read ${n.name}`,n))}),s.onload=o=>{e(o.target.result)},t&&(s.onprogress=t),i?s.readAsArrayBuffer(n):s.readAsText(n),a},Fn=(n,e,t,i,r,s,a)=>{if(n.name)return _o(n,e,t,r,s?f=>{s(void 0,f)}:void 0);let o=n;if(o.indexOf("file:")!==-1){let f=decodeURIComponent(o.substring(5).toLowerCase());f.indexOf("./")===0&&(f=f.substring(2));let d=ca.FilesToLoad[f];if(d)return _o(d,e,t,r,s?h=>s(void 0,new gl(h.message,h.file)):void 0)}let{match:l,type:c}=ZI(o);if(l){let f={onCompleteObservable:new Y,abort:()=>()=>{}};try{let d=r?da(o):qI(o);e(d,void 0,c)}catch(d){s?s(void 0,d):W.Error(d.message||"Failed to parse the Data URL")}return rn.SetImmediate(()=>{f.onCompleteObservable.notifyObservers(f)}),f}return _h(o,(f,d)=>{e(f,d==null?void 0:d.responseURL,d==null?void 0:d.getResponseHeader("content-type"))},t,i,r,s?f=>{s(f.request,new gl(f.message,f.request))}:void 0,a)},_h=(n,e,t,i,r,s,a)=>{var d;i!==null&&(i!=null||(i=(d=ue.LastCreatedScene)==null?void 0:d.offlineProvider)),n=Mt.CleanUrl(n),n=Mt.PreprocessUrl(n);let o=Mt.BaseUrl+n,l=!1,c={onCompleteObservable:new Y,abort:()=>l=!0},f=()=>{let h=new $t,u=null,m,p=()=>{h&&(t&&h.removeEventListener("progress",t),m&&h.removeEventListener("readystatechange",m),h.removeEventListener("loadend",_))},_=()=>{p(),c.onCompleteObservable.notifyObservers(c),c.onCompleteObservable.clear(),t=void 0,m=null,_=null,s=void 0,a=void 0,e=void 0};c.abort=()=>{l=!0,_&&_(),h&&h.readyState!==(XMLHttpRequest.DONE||4)&&h.abort(),u!==null&&(clearTimeout(u),u=null),h=null};let g=b=>{let R=b.message||"Unknown error";s&&h?s(new mh(R,h)):W.Error(R)},T=b=>{if(h){if(h.open("GET",o),a)try{a(h)}catch(R){g(R);return}r&&(h.responseType="arraybuffer"),t&&h.addEventListener("progress",t),_&&h.addEventListener("loadend",_),m=()=>{if(!(l||!h)&&h.readyState===(XMLHttpRequest.DONE||4)){if(m&&h.removeEventListener("readystatechange",m),h.status>=200&&h.status<300||h.status===0&&(!Bt()||jI())){let I=r?h.response:h.responseText;if(I!==null){try{e&&e(I,h)}catch(x){g(x)}return}}let R=Mt.DefaultRetryStrategy;if(R){let I=R(o,h,b);if(I!==-1){p(),h=new $t,u=setTimeout(()=>T(b+1),I);return}}let S=new mh("Error status: "+h.status+" "+h.statusText+" - Unable to load "+o,h);s&&s(S)}},h.addEventListener("readystatechange",m),h.send()}};T(0)};if(i&&i.enableSceneOffline&&!n.startsWith("blob:")){let h=m=>{m&&m.status>400?s&&s(m):f()},u=()=>{i&&i.loadFile(Mt.BaseUrl+n,m=>{!l&&e&&e(m),c.onCompleteObservable.notifyObservers(c)},t?m=>{!l&&t&&t(m)}:void 0,h,r)};i.open(u,h)}else f();return c},KI=n=>{let{match:e,type:t}=ZI(n);if(e)return t||void 0;let i=n.lastIndexOf(".");switch(n.substring(i+1).toLowerCase()){case"glb":return"model/gltf-binary";case"bin":return"application/octet-stream";case"gltf":return"model/gltf+json";case"jpg":case"jpeg":return"image/jpeg";case"png":return"image/png";case"webp":return"image/webp";case"ktx":return"image/ktx";case"ktx2":return"image/ktx2";case"avif":return"image/avif";default:return}},jI=()=>typeof location!="undefined"&&location.protocol==="file:",fa=n=>YI.test(n),ZI=n=>{let e=YI.exec(n);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace(";base64,","")}};qI=n=>I_(n.split(",")[1]),GV=()=>{fe._FileToolsLoadImage=El,Qo.loadFile=Fn,o_.loadFile=Fn};GV();kV=(n,e,t,i,r,s,a,o,l,c)=>{Zc={DecodeBase64UrlToBinary:n,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:r,LoadFile:s,LoadImage:a,ReadFile:o,RequestFile:l,SetCorsBehavior:c},Object.defineProperty(Zc,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(f){t.DefaultRetryStrategy=f}}),Object.defineProperty(Zc,"BaseUrl",{get:function(){return t.BaseUrl},set:function(f){t.BaseUrl=f}}),Object.defineProperty(Zc,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(f){t.PreprocessUrl=f}}),Object.defineProperty(Zc,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(f){t.CorsBehavior=f}})};kV(da,qI,Mt,fa,jI,Fn,El,_o,_h,ph)});var gh,QI=A(()=>{oh();gh=class n{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){var t,i,r;this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=os.Zero(),this._cachedBaseSize=os.Zero(),this._initialSamplingMode=2,this._texture=n._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine(),this.wrapU=(t=this._texture._cachedWrapU)!=null?t:this.wrapU,this.wrapV=(i=this._texture._cachedWrapV)!=null?i:this.wrapV,this.wrapR=(r=this._texture._cachedWrapR)!=null?r:this.wrapR)}isReady(){return this.delayLoadState===4?(this.delayLoad(),!1):this._texture?this._texture.isReady:!1}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return!this.isReady()||!this._texture?(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize):this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e,t=!1){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture,this._texture.generateMipMaps&&t)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}});var Eh,JI=A(()=>{Eh=class n{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),n._HandleParenthesisContent(i,t))):e=n._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:n.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(s=>s==="true");let i,r=e.split("||");for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let a=n._SimplifyNegation(r[s].trim()),o=a.split("&&");if(o.length>1)for(let l=0;l(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}});var nt,ha=A(()=>{JI();nt=class n{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>n.HasTags(e),e.addTags=t=>n.AddTagsTo(e,t),e.removeTags=t=>n.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>n.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;let t=e._tags;for(let 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){let i=[];for(let r in e._tags)Object.prototype.hasOwnProperty.call(e._tags,r)&&e._tags[r]===!0&&i.push(r);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;let i=t.split(" ");for(let r of i)n._AddTagTo(e,r)}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(n.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!n.HasTags(e))return;let i=t.split(" ");for(let r in i)n._RemoveTagFrom(e,i[r])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?n.HasTags(e):Eh.Eval(t,i=>n.HasTags(e)&&e._tags[i])}}});var $I,Me,Kt=A(()=>{Ei();ha();et();ve();R_();$I=function(n,e,t,i={}){let r=n();nt&&nt.HasTags(e)&&nt.AddTagsTo(r,nt.GetTags(e,!0));let s=fh(r),a={};for(let o in s){let l=s[o],c=e[o],f=l.type;if(c!=null&&(o!=="uniqueId"||Me.AllowLoadingUniqueId))switch(f){case 0:case 6:case 9:case 11:typeof c.slice=="function"?r[o]=c.slice():r[o]=c;break;case 1:i.cloneTexturesOnlyOnce&&a[c.uniqueId]?r[o]=a[c.uniqueId]:(r[o]=t||c.isRenderTarget?c:c.clone(),a[c.uniqueId]=r[o]);break;case 2:case 3:case 4:case 5:case 7:case 8:case 10:case 12:r[o]=t?c:c.clone();break}}return r},Me=class n{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i{throw Ie("ImageProcessingConfiguration")};Me._FresnelParametersParser=n=>{throw Ie("FresnelParameters")};Me._ColorCurvesParser=n=>{throw Ie("ColorCurves")};Me._TextureParser=(n,e,t)=>{throw Ie("Texture")}});var dt,qc=A(()=>{Qe();qe();ft();ve();At();Yc();ds();QI();Kt();dt=class n extends gh{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=la()),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=n.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this._dominantDirection=null,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new Y,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?n._IsScene(e)?this._scene=e:this._engine=e:this._scene=ue.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 U.IdentityReadOnly}getReflectionTextureMatrix(){return U.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,r,s,a){let o=this._getEngine();if(!o)return null;let l=o._getUseSRGBBuffer(!!s,t),c=o.getLoadedTexturesCache();for(let f=0;f=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){let 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;let t=Me.Serialize(this);return Me.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let i=e.length;if(i===0){t();return}for(let r=0;r{--i===0&&t()}):--i===0&&t()}}}static _IsScene(e){return e.getClassName()==="Scene"}};dt.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;C([D()],dt.prototype,"uniqueId",void 0);C([D()],dt.prototype,"name",void 0);C([D()],dt.prototype,"displayName",void 0);C([D()],dt.prototype,"metadata",void 0);C([D("hasAlpha")],dt.prototype,"_hasAlpha",void 0);C([D("getAlphaFromRGB")],dt.prototype,"_getAlphaFromRGB",void 0);C([D()],dt.prototype,"level",void 0);C([D("coordinatesIndex")],dt.prototype,"_coordinatesIndex",void 0);C([D()],dt.prototype,"optimizeUVAllocation",void 0);C([D("coordinatesMode")],dt.prototype,"_coordinatesMode",void 0);C([D()],dt.prototype,"wrapU",null);C([D()],dt.prototype,"wrapV",null);C([D()],dt.prototype,"wrapR",void 0);C([D()],dt.prototype,"anisotropicFilteringLevel",void 0);C([D()],dt.prototype,"isCube",null);C([D()],dt.prototype,"is3D",null);C([D()],dt.prototype,"is2DArray",null);C([D()],dt.prototype,"gammaSpace",null);C([D()],dt.prototype,"invertZ",void 0);C([D()],dt.prototype,"lodLevelInAlpha",void 0);C([D()],dt.prototype,"lodGenerationOffset",null);C([D()],dt.prototype,"lodGenerationScale",null);C([D()],dt.prototype,"linearSpecularLOD",null);C([Ze()],dt.prototype,"irradianceTexture",null);C([D()],dt.prototype,"isRenderTarget",void 0)});var ua,hs,M_=A(()=>{ve();Mi();Xc();bi();et();ua=class{constructor(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}},hs=class{static _NearestPow2Floor(e){return e<=1?1:1<0?this._NearestPow2Floor(i):0,s=!e.noMipmap&&((b=e._texture)==null?void 0:b.generateMipMaps)===!0,a=r>0&&r0&&r{Promise.all([f,c,d,h,u,m]).then(([S,I,x,P,L,y])=>{let B=l;g&&(S=this._DownsampleFace(S,t,r,4),I=this._DownsampleFace(I,t,r,4),x=this._DownsampleFace(x,t,r,4),P=this._DownsampleFace(P,t,r,4),L=this._DownsampleFace(L,t,r,4),y=this._DownsampleFace(y,t,r,4),B=r);let w={size:B,right:I,left:S,up:x,down:P,front:L,back:y,format:_,type:S instanceof Float32Array?1:0,gammaSpace:p};R(this.ConvertCubeMapToSphericalPolynomial(w))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static _DownsampleFace(e,t,i,r){let s=e instanceof Float32Array?e:Float32Array.from(e),a=i*i*r,o=new Float32Array(a),l=t/i,c=1/(l*l);for(let h=0;h0?this._NearestPow2Floor(t):0;if(i>0&&e.size>i){let m=e.format===5?4:3,p=["right","left","up","down","front","back"],_={};for(let g of p)_[g]=this._DownsampleFace(e[g],e.size,i,m);e={...e,..._,size:i}}let r=new zc,s=0,a=2/e.size,o=a,l=.5*a,c=l-1;for(let m=0;m<6;m++){let p=this._FileFaces[m],_=e[p.name],g=c,T=e.format===5?4:3;for(let b=0;bB){let O=B/H;P*=O,L*=O,y*=O}}else P=Ke(P,0,B),L=Ke(L,0,B),y=Ke(y,0,B);let w=new oe(P,L,y);r.addLight(I,w,x),s+=x,R+=a}g+=o}}let u=4*Math.PI*6/6/s;return r.scaleInPlace(u),r.convertIncidentRadianceToIrradiance(),r.convertIrradianceToLambertianRadiance(),On.FromHarmonics(r)}};hs._FileFaces=[new ua("right",new v(1,0,0),new v(0,0,-1),new v(0,-1,0)),new ua("left",new v(-1,0,0),new v(0,0,1),new v(0,-1,0)),new ua("up",new v(0,1,0),new v(1,0,0),new v(0,0,1)),new ua("down",new v(0,-1,0),new v(1,0,0),new v(0,0,-1)),new ua("front",new v(0,0,1),new v(1,0,0),new v(0,-1,0)),new ua("back",new v(0,0,-1),new v(-1,0,0),new v(0,-1,0))];hs.MAX_HDRI_VALUE=4096;hs.PRESERVE_CLAMPED_COLORS=!1});var us,y_=A(()=>{ze();Lt();us=class{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];let t=Ri(e);if(t)return t;W.Warn(e+" not found, you may have missed an import.");let i=e.split("."),r=window||this;for(let s=0,a=i.length;s=0;){let d=n[c];d<0?d=0:d>1&&(d=1),f[c]=d*255}n=f}let s=document.createElement("canvas");s.width=i,s.height=r;let a=s.getContext("2d");if(!a)return null;let o=a.createImageData(i,r);if(o.data.set(n),a.putImageData(o,0,0),t){let c=document.createElement("canvas");c.width=i,c.height=r;let f=c.getContext("2d");return f?(f.translate(0,r),f.scale(1,-1),f.drawImage(s,0,0),c.toDataURL("image/png")):null}return s.toDataURL("image/png")}function tx(n,e=0,t=0){let i=n.getInternalTexture();if(!i)return null;let r=n._readPixelsSync(e,t);return r?ex(r,n.getSize(),i.invertY):null}async function ix(n,e=0,t=0){let i=n.getInternalTexture();if(!i)return null;let r=await n.readPixels(e,t);return r?ex(r,n.getSize(),i.invertY):null}var rx=A(()=>{});var He,ui=A(()=>{He=!1});var ne,oi=A(()=>{Qe();qe();ft();ve();qc();Lt();Ei();Mn();y_();fo();jc();rx();ui();Kt();ne=class n extends dt{static _CreateVideoTexture(e,t,i,r=!1,s=!1,a=n.TRILINEAR_SAMPLINGMODE,o={},l,c=5){throw Ie("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,i,r,s=n.TRILINEAR_SAMPLINGMODE,a=null,o=null,l=null,c=!1,f,d,h,u,m){var x,P,L,y,B,w,H,O,k,X,j;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 Y,this._isBlocking=!0,this.name=e||"",this.url=e;let p,_=!1,g=null,T=!0;typeof i=="object"&&i!==null?(p=(x=i.noMipmap)!=null?x:!1,r=(P=i.invertY)!=null?P:!He,s=(L=i.samplingMode)!=null?L:n.TRILINEAR_SAMPLINGMODE,a=(y=i.onLoad)!=null?y:null,o=(B=i.onError)!=null?B:null,l=(w=i.buffer)!=null?w:null,c=(H=i.deleteBuffer)!=null?H:!1,f=i.format,d=i.mimeType,h=i.loaderOptions,u=i.creationFlags,_=(O=i.useSRGBBuffer)!=null?O:!1,g=(k=i.internalTexture)!=null?k:null,T=(X=i.gammaSpace)!=null?X:T,m=(j=i.forcedExtension)!=null?j:m):p=!!i,this._gammaSpace=T,this._noMipmap=p,this._invertY=r===void 0?!He:r,this._initialSamplingMode=s,this._buffer=l,this._deleteBuffer=c,this._mimeType=d,this._loaderOptions=h,this._creationFlags=u,this._useSRGBBuffer=_,this._forcedExtension=m,f!==void 0&&(this._format=f);let b=this.getScene(),R=this._getEngine();if(!R)return;R.onBeforeTextureInitObservable.notifyObservers(this);let S=()=>{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),a&&a(),!this.isBlocking&&b&&b.resetCachedMaterial()},I=(Q,$)=>{this._loadingError=!0,this._errorObject={message:Q,exception:$},o&&o(Q,$),n.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!g){this._delayedOnLoad=S,this._delayedOnError=I;return}if(this._texture=g!=null?g:this._getFromCache(this.url,p,s,this._invertY,_,this.isCube),this._texture)if(this._texture.isReady)rn.SetImmediate(()=>S());else{let Q=this._texture.onLoadedObservable.add(S);this._texture.onErrorObservable.add($=>{var q;I($.message,$.exception),(q=this._texture)==null||q.onLoadedObservable.remove(Q)})}else if(!b||!b.useDelayedTextureLoading){try{this._texture=R.createTexture(this.url,p,this._invertY,b,s,S,I,this._buffer,void 0,this._format,this._forcedExtension,d,h,u,_)}catch(Q){throw I("error loading",Q),Q}c&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=S,this._delayedOnError=I}updateURL(e,t=null,i,r){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,o=>o.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=r,this.delayLoadState=4;let s=this._delayedOnLoad,a=()=>{s?s():this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),i&&i()};this._delayedOnLoad=a,this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;let e=this.getScene();if(!e)return;let t=this.url;!t&&(this.name.indexOf("://")>0||this.name.startsWith("data:"))&&(t=this.name),this.delayLoadState=1,this._texture=this._getFromCache(t,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?rn.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(t,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null}_prepareRowForTextureGeneration(e,t,i,r){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,r),r.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,r.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,r.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=U.Zero(),this._rowGenerationMatrix=new U,this._t0=v.Zero(),this._t1=v.Zero(),this._t2=v.Zero()),U.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(U.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,G.Matrix[0]),U.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,G.Matrix[1]),U.ScalingToRef(this._cachedUScale,this._cachedVScale,0,G.Matrix[2]),U.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,G.Matrix[3]),G.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(G.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(G.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(G.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),U.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));let t=this.getScene();if(!t)return this._cachedTextureMatrix;let i=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&i!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,r=>r.hasTexture(this)),this._cachedTextureMatrix}getReflectionTextureMatrix(){let 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===n.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=U.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=U.Zero());let 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 n.PLANAR_MODE:{U.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 n.PROJECTION_MODE:{U.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);let i=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:U.IdentityToRef(this._cachedReflectionTextureMatrix);break}return t&&e.markAllMaterialsAsDirty(1,i=>i.hasTexture(this)),this._cachedReflectionTextureMatrix}clone(){let 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 Me.Clone(()=>new n(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){var i,r;let e=this.name;n.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");let t=super.serialize(n._SerializeInternalTextureUniqueId);if(!t)return null;if(n.SerializeBuffers||n.ForceSerializeBuffers)if(typeof this._buffer=="string"&&this._buffer.startsWith("data:"))t.base64String=this._buffer,t.name=t.name.replace("data:","");else if(this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array){let s=this.mimeType||"image/png";t.base64String=`data:${s};base64,${pl(this._buffer)}`}else(n.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?tx(this):ix(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,n._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=(i=this._texture)==null?void 0:i.uniqueId),t.internalTextureLabel=(r=this._texture)==null?void 0:r.label,t.noMipmap=this._noMipmap,this.name=e,t}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,i){if(e.customType){let c=us.Instantiate(e.customType).Parse(e,t,i);return e.samplingMode&&c.updateSamplingMode&&c._samplingMode&&c._samplingMode!==e.samplingMode&&c.updateSamplingMode(e.samplingMode),c}if(e.isCube&&!e.isRenderTarget)return n._CubeTextureParser(e,t,i);let r=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!r)return null;let s;if(r){let l=t.getEngine().getLoadedTexturesCache();for(let c of l)if(c.uniqueId===e.internalTextureUniqueId){s=c;break}}let a=l=>{if(l&&l._texture&&(l._texture._cachedWrapU=null,l._texture._cachedWrapV=null,l._texture._cachedWrapR=null),e.samplingMode){let c=e.samplingMode;l&&l.samplingMode!==c&&l.updateSamplingMode(c)}if(l&&e.animations)for(let c=0;c{var c,f,d,h,u;let l=!0;if(e.noMipmap&&(l=!1),e.mirrorPlane){let m=n._CreateMirror(e.name,e.renderTargetSize,t,l);return m._waitingRenderList=e.renderList,m.mirrorPlane=ir.FromArray(e.mirrorPlane),a(m),m}else if(e.isRenderTarget&&!e.base64String){let m=null;if(e.isCube){if(t.reflectionProbes)for(let p=0;p{a(m)}},_=e.base64String,g=_.startsWith("data:")?_.substring(5):_;m=n.CreateFromBase64String("",g,t,p),m.name=e.name}else{let p;e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?p=e.name:p=i+e.name,e.url&&(e.url.startsWith("data:")||n.UseSerializedUrlIfAny)&&(p=e.url);let _={noMipmap:!l,invertY:e.invertY,samplingMode:e.samplingMode,useSRGBBuffer:(h=e._useSRGBBuffer)!=null?h:!1,creationFlags:(u=e._creationFlags)!=null?u:0,onLoad:()=>{a(m)},internalTexture:s};m=new n(p,t,_)}return m}},e,t)}static CreateFromBase64String(e,t,i,r,s,a=n.TRILINEAR_SAMPLINGMODE,o=null,l=null,c=5,f,d){return new n("data:"+t,i,r,s,a,o,l,e,!1,c,void 0,void 0,f,d)}static LoadFromDataString(e,t,i,r=!1,s,a=!0,o=n.TRILINEAR_SAMPLINGMODE,l=null,c=null,f=5,d,h){return e.substring(0,5)!=="data:"&&(e="data:"+e),new n(e,i,s,a,o,l,c,t,r,f,void 0,void 0,d,h)}};ne.SerializeBuffers=!0;ne.ForceSerializeBuffers=!1;ne.OnTextureLoadErrorObservable=new Y;ne._SerializeInternalTextureUniqueId=!1;ne._CubeTextureParser=(n,e,t)=>{throw Ie("CubeTexture")};ne._CreateMirror=(n,e,t,i)=>{throw Ie("MirrorTexture")};ne._CreateRenderTargetTexture=(n,e,t,i,r)=>{throw Ie("RenderTargetTexture")};ne.NEAREST_SAMPLINGMODE=1;ne.NEAREST_NEAREST_MIPLINEAR=8;ne.BILINEAR_SAMPLINGMODE=2;ne.LINEAR_LINEAR_MIPNEAREST=11;ne.TRILINEAR_SAMPLINGMODE=3;ne.LINEAR_LINEAR_MIPLINEAR=3;ne.NEAREST_NEAREST_MIPNEAREST=4;ne.NEAREST_LINEAR_MIPNEAREST=5;ne.NEAREST_LINEAR_MIPLINEAR=6;ne.NEAREST_LINEAR=7;ne.NEAREST_NEAREST=1;ne.LINEAR_NEAREST_MIPNEAREST=9;ne.LINEAR_NEAREST_MIPLINEAR=10;ne.LINEAR_LINEAR=2;ne.LINEAR_NEAREST=12;ne.EXPLICIT_MODE=0;ne.SPHERICAL_MODE=1;ne.PLANAR_MODE=2;ne.CUBIC_MODE=3;ne.PROJECTION_MODE=4;ne.SKYBOX_MODE=5;ne.INVCUBIC_MODE=6;ne.EQUIRECTANGULAR_MODE=7;ne.FIXED_EQUIRECTANGULAR_MODE=8;ne.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;ne.CLAMP_ADDRESSMODE=0;ne.WRAP_ADDRESSMODE=1;ne.MIRROR_ADDRESSMODE=2;ne.UseSerializedUrlIfAny=!1;C([D()],ne.prototype,"url",void 0);C([D()],ne.prototype,"uOffset",void 0);C([D()],ne.prototype,"vOffset",void 0);C([D()],ne.prototype,"uScale",void 0);C([D()],ne.prototype,"vScale",void 0);C([D()],ne.prototype,"uAng",void 0);C([D()],ne.prototype,"vAng",void 0);C([D()],ne.prototype,"wAng",void 0);C([D()],ne.prototype,"uRotationCenter",void 0);C([D()],ne.prototype,"vRotationCenter",void 0);C([D()],ne.prototype,"wRotationCenter",void 0);C([D()],ne.prototype,"homogeneousRotationInUVTransform",void 0);C([D()],ne.prototype,"isBlocking",null);je("BABYLON.Texture",ne);Me._TextureParser=ne.Parse});var on,M,yt=A(()=>{h_();ze();_l();on=class{get isDisposed(){return this._isDisposed}constructor(e,t,i,r=0,s=!1,a=!1,o=!1,l,c){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=a,this._divisor=l||1,this._label=c,t instanceof ao?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?r:r*Float32Array.BYTES_PER_ELEMENT,s||this.create()}createVertexBuffer(e,t,i,r,s,a=!1,o){let l=a?t:t*Float32Array.BYTES_PER_ELEMENT,c=r?a?r:r*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new M(this._engine,this,e,this._updatable,!0,c,s===void 0?this._instanced:s,l,i,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data,e&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label)))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0){this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label);return}W.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,i,r=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?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)}},M=class n{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){let t=e!=0;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){let 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,r,s,a,o,l,c,f,d=!1,h=!1,u=1,m=!1){var g,T,b,R,S;this._isDisposed=!1;let p;if(this.engine=e,typeof r=="object"&&r!==null?(p=(g=r.updatable)!=null?g:!1,s=r.postponeInternalCreation,a=r.stride,o=r.instanced,l=r.offset,c=r.size,f=r.type,d=(T=r.normalized)!=null?T:!1,h=(b=r.useBytes)!=null?b:!1,u=(R=r.divisor)!=null?R:1,m=(S=r.takeBufferOwnership)!=null?S:!1,this._label=r.label):p=!!r,t instanceof on?(this._buffer=t,this._ownsBuffer=m):(this._buffer=new on(e,t,p,a,s,o,h,u,this._label),this._ownsBuffer=!0),this.uniqueId=n._Counter++,this._kind=i,f===void 0){let I=this.getData();this.type=I?n.GetDataType(I):n.FLOAT}else this.type=f;let _=Nn(this.type);h?(this._size=c||(a?a/_:n.DeduceStride(i)),this.byteStride=a||this._buffer.byteStride||this._size*_,this.byteOffset=l||0):(this._size=c||a||n.DeduceStride(i),this.byteStride=a?a*_:this._buffer.byteStride||this._size*_,this.byteOffset=(l||0)*_),this.normalized=d,this._instanced=o!==void 0?o:!1,this._instanceDivisor=o?u: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){let i=this.getData();return i?C_(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/Nn(this.type)}getOffset(){return this.byteOffset/Nn(this.type)}getSize(e=!1){return e?this._size*Nn(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){po(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,(i,r)=>{for(let s=0;s{for(let d=0;d{yt();ft();ms=class{constructor(e){this._vertexBuffers={},this._activePostProcesses=[],this.onBeforeRenderObservable=new Y,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[M.PositionKind])return;let e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[M.PositionKind]=new M(this._scene.getEngine(),e,M.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){let 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)}_getActivePostProcesses(e){let t=this._activePostProcesses;t.length=0;for(let i=0;i{ze();nx=(n,e,t)=>!n||n.getClassName&&n.getClassName()==="Mesh"?null:n.getClassName&&(n.getClassName()==="SubMesh"||n.getClassName()==="PhysicsBody")?n.clone(e):n.clone?n.clone():Array.isArray(n)?n.slice():t&&typeof n=="object"?{...n}:null;wn=class{static DeepCopy(e,t,i,r,s=!1){let a=WV(e);for(let o of a){if(o[0]==="_"&&(!r||r.indexOf(o)===-1)||o.endsWith("Observable")||i&&i.indexOf(o)!==-1)continue;let l=e[o],c=typeof l;if(c!=="function")try{if(c==="object")if(l instanceof Uint8Array)t[o]=Uint8Array.from(l);else if(l instanceof Array){if(t[o]=[],l.length>0)if(typeof l[0]=="object")for(let f=0;f{ft();Lr();ze();Qc();ns();Ei();mo();At();ds();Mn();y_();Yc();Dn();re=class{static get BaseUrl(){return Mt.BaseUrl}static set BaseUrl(e){Mt.BaseUrl=e}static get CleanUrl(){return Mt.CleanUrl}static set CleanUrl(e){Mt.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("://"){Fn(e,s=>{i(s)},void 0,void 0,t,(s,a)=>{r(a)})})}static GetAssetUrl(e){if(!e)return"";if(Ve.AssetBaseUrl&&e.startsWith(Ve._DefaultAssetsUrl)){let t=Ve.AssetBaseUrl.endsWith("/")?Ve.AssetBaseUrl.slice(0,-1):Ve.AssetBaseUrl;return e.replace(Ve._DefaultAssetsUrl,t)}return e}static GetBabylonScriptURL(e,t){if(!e)return"";if(e.startsWith(Ve._DefaultCdnUrl)){if(Ve.ScriptBaseUrl){let i=Ve.ScriptBaseUrl.endsWith("/")?Ve.ScriptBaseUrl.slice(0,-1):Ve.ScriptBaseUrl;e=e.replace(Ve._DefaultCdnUrl,i)}else if(Ve._CdnVersion){let i=`${Ve._DefaultCdnUrl}/v${Ve._CdnVersion}`;e.startsWith(i)||(e=e.replace(Ve._DefaultCdnUrl,i))}}return e=Ve.ScriptPreprocessUrl(e),t&&!Ve.IsAbsoluteUrl(e)&&(e=Ve.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,r){e=Ve.GetBabylonScriptURL(e),Ve.LoadScript(e,t,i)}static async LoadBabylonScriptAsync(e){return e=Ve.GetBabylonScriptURL(e),await Ve.LoadScriptAsync(e)}static _LoadScriptNative(e,t,i){let r=new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${e}`);i==null||i(r.message,r)}static _LoadScriptWeb(e,t,i,r,s=!1){let a=new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${e}`);i==null||i(a.message,a)}static async LoadScriptAsync(e,t){return await new Promise((i,r)=>{this.LoadScript(e,()=>{i()},(s,a)=>{r(a||new Error(s))},t)})}static ReadFileAsDataURL(e,t,i){let r=new FileReader,s={onCompleteObservable:new Y,abort:()=>r.abort()};return r.onloadend=()=>{s.onCompleteObservable.notifyObservers(s)},r.onload=a=>{t(a.target.result)},r.onprogress=i,r.readAsDataURL(e),s}static ReadFile(e,t,i,r,s){return _o(e,t,i,r,s)}static FileAsURL(e){let t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,i,r){wn.DeepCopy(e,t,i,r)}static IsEmpty(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let i=0;i{let l=atob(this.toDataURL(a,o).split(",")[1]),c=l.length,f=new Uint8Array(c);for(let d=0;dt(s)):e.toBlob(function(s){t(s)},i,r)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){let i=new Date;t="screenshot_"+((i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2))+".png"}Ve.Download(e,t)}else if(e&&typeof URL!="undefined"){let i=URL.createObjectURL(e),r=window.open("");if(!r)return;let s=r.document.createElement("img");s.onload=function(){URL.revokeObjectURL(i)},s.src=i,r.document.body.appendChild(s)}}static EncodeScreenshotCanvasData(e,t,i="image/png",r,s){if(typeof r=="string"||!t)this.ToBlob(e,function(a){a&&Ve.DownloadBlob(a,r),t&&t("")},i,s);else if(t){if(Ve._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:s}).then(o=>{let l=new FileReader;l.readAsDataURL(o),l.onloadend=()=>{let c=l.result;t(c)}});return}let a=e.toDataURL(i,s);t(a)}}static Download(e,t){if(typeof URL=="undefined")return;let i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",()=>{r.parentElement&&r.parentElement.removeChild(r)}),r.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,r,s="image/png",a=!1,o){throw Ie("ScreenshotTools")}static async CreateScreenshotAsync(e,t,i,r="image/png",s){throw Ie("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,r,s="image/png",a=1,o=!1,l,c=!1,f=!1,d=!0,h,u){throw Ie("ScreenshotTools")}static async CreateScreenshotUsingRenderTargetAsync(e,t,i,r="image/png",s=1,a=!1,o,l=!1,c=!1,f=!0,d,h){throw Ie("ScreenshotTools")}static RandomId(){return la()}static IsBase64(e){return fa(e)}static DecodeBase64(e){return da(e)}static get errorsCount(){return W.errorsCount}static Log(e){W.Log(e)}static Warn(e){W.Warn(e)}static Error(e){W.Error(e)}static get LogCache(){return W.LogCache}static ClearLogCache(){W.ClearLogCache()}static set LogLevels(e){W.LogLevels=e}static set PerformanceLogLevel(e){var t;if((e&Ve.PerformanceUserMarkLogLevel)===Ve.PerformanceUserMarkLogLevel){_native!=null&&_native.enablePerformanceLogging?(_native.enablePerformanceLogging(1),Ve.StartPerformanceCounter=Ve._StartMarkNative,Ve.EndPerformanceCounter=Ve._EndMarkNative):(Ve.StartPerformanceCounter=Ve._StartUserMark,Ve.EndPerformanceCounter=Ve._EndUserMark);return}if((e&Ve.PerformanceConsoleLogLevel)===Ve.PerformanceConsoleLogLevel){_native!=null&&_native.enablePerformanceLogging?(_native.enablePerformanceLogging(2),Ve.StartPerformanceCounter=Ve._StartMarkNative,Ve.EndPerformanceCounter=Ve._EndMarkNative):(Ve.StartPerformanceCounter=Ve._StartPerformanceConsole,Ve.EndPerformanceCounter=Ve._EndPerformanceConsole);return}Ve.StartPerformanceCounter=Ve._StartPerformanceCounterDisabled,Ve.EndPerformanceCounter=Ve._EndPerformanceCounterDisabled,(t=_native==null?void 0:_native.disablePerformanceLogging)==null||t.call(_native)}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!Ve._Performance){if(!Bt())return;Ve._Performance=window.performance}!t||!Ve._Performance.mark||Ve._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){!t||!Ve._Performance.mark||(Ve._Performance.mark(e+"-End"),Ve._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(Ve._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(Ve._EndUserMark(e,t),console.timeEnd(e))}static _StartMarkNative(e,t=!0){if(t&&(_native!=null&&_native.startPerformanceCounter))if(Ve._NativePerformanceCounterHandles.has(e))Ve.Warn(`Performance counter with name ${e} is already started.`);else{let i=_native.startPerformanceCounter(e);Ve._NativePerformanceCounterHandles.set(e,i)}}static _EndMarkNative(e,t=!0){if(t&&(_native!=null&&_native.endPerformanceCounter)){let i=Ve._NativePerformanceCounterHandles.get(e);i?(_native.endPerformanceCounter(i),Ve._NativePerformanceCounterHandles.delete(e)):Ve.Warn(`Performance counter with name ${e} was not started.`)}}static get Now(){return kt.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(let i of e)if(t(i))return i;return null}static getFullClassName(e,t=!1){let i=null,r=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){let s=t?e:Object.getPrototypeOf(e);i=s.constructor.__bjsclassName__,r=s.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(r!=null?r+".":"")+i:null}static async DelayAsync(e){await new Promise(t=>{setTimeout(()=>{t()},e)})}static IsSafari(){return rs()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}};Ve=re;re.AssetBaseUrl="";re.UseCustomRequestHeaders=!1;re.CustomRequestHeaders=$t.CustomRequestHeaders;re.GetDOMTextContent=yd;re._DefaultCdnUrl="https://cdn.babylonjs.com";re._CdnVersion="9.6.0";re._DefaultAssetsUrl="https://assets.babylonjs.com/core";re.LoadScript=typeof _native=="undefined"?Ve._LoadScriptWeb:Ve._LoadScriptNative;re.GetAbsoluteUrl=typeof document=="object"?n=>{let e=document.createElement("a");return e.href=n,e.href}:typeof URL=="function"&&typeof location=="object"?n=>new URL(n,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")};re.NoneLogLevel=W.NoneLogLevel;re.MessageLogLevel=W.MessageLogLevel;re.WarningLogLevel=W.WarningLogLevel;re.ErrorLogLevel=W.ErrorLogLevel;re.AllLogLevel=W.AllLogLevel;re.IsWindowObjectExist=Bt;re.PerformanceNoneLogLevel=0;re.PerformanceUserMarkLogLevel=1;re.PerformanceConsoleLogLevel=2;re._NativePerformanceCounterHandles=new Map;re.StartPerformanceCounter=Ve._StartPerformanceCounterDisabled;re.EndPerformanceCounter=Ve._EndPerformanceCounterDisabled;Th=class n{constructor(e,t,i,r=0){this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}executeNext(){this._done||(this.index+1{s&&s()?o.breakLoop():setTimeout(()=>{for(let l=0;l=e)break;if(i(c),s&&s()){o.breakLoop();break}}o.executeNext()},a)},r)}};re.Mix=kc;re.IsExponentOfTwo=oo;ue.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"});var Ut,ma=A(()=>{ze();Tt();Ut=class n{constructor(e,t,i=!1,r,s=!1,a){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||s,this._dynamic=i,this._name=r!=null?r:"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._trackUBOsInFrame=!1,(a===void 0&&this._engine._features.trackUbosInFrame||a===!0)&&(this._buffers=[],this._bufferIndex=-1,this._bufferUpdatedLastFrame=!1,this._createBufferOnWrite=!1,this._currentFrameId=0,this._trackUBOsInFrame=!0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}getUniformNames(){return this._uniformNames}_fillAlignment(e){let t;if(e<=2?t=e:t=4,this._uniformLocationPointer%t!==0){let i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;let r=this._uniformLocationPointer-i;for(let s=0;s0&&typeof t=="number"&&(this._uniformArraySizes[e]={strideSize:t,arraySize:i}),this._uniformLocations[e]!==void 0||(this._uniformNames.push(e),this._noUBO))return;let r;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),t==16)t=t*i;else{let a=(4-t)*i;t=t*i+a}r=[];for(let s=0;s1&&this._buffers[this._bufferIndex][1])if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1])){this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._bufferUpdatedLastFrame=!0,this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame}}_createNewBuffer(){this._bufferIndex+10?(this._buffers.length===1?this._needSync=!this._bufferUpdatedLastFrame:this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let r=this._uniformLocations[e];if(r===void 0){if(this._buffer){W.Error("Cannot add an uniform after UBO has been created. uniformName="+e);return}this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let s=0;s1&&this._buffers[t][1]&&this._bufferData.set(this._buffers[t][1]),this._valueCache={},this._currentFrameId=this._engine.frameId,!0;return!1}has(e){return this._uniformLocations[e]!==void 0}dispose(){if(this._noUBO)return;let e=this._engine._uniformBuffers,t=e.indexOf(this);if(t!==-1&&(e[t]=e[e.length-1],e.pop()),this._trackUBOsInFrame&&this._buffers)for(let i=0;i{Ct=class n{constructor(e){this.length=0,this.data=new Array(e),this._id=n._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;tthis.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t=this.length?-1:t}contains(e){return this.indexOf(e)!==-1}};Ct._GlobalId=0;ln=class extends Ct{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{cn();ve();Jc=class n{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=n.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=n.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=n.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,r=null,s=null){this.index=e,this._opaqueSubMeshes=new Ct(256),this._transparentSubMeshes=new Ct(256),this._alphaTestSubMeshes=new Ct(256),this._depthOnlySubMeshes=new Ct(256),this._particleSystems=new Ct(256),this._spriteManagers=new Ct(256),this._empty=!0,this._edgesRenderers=new ln(16),this.disableDepthPrePass=!1,this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=s}render(e,t,i,r,s=!0,a=!0,o=!0,l=!0,c){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}let f=this._scene.getEngine();s&&this._depthOnlySubMeshes.length!==0&&(f.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),f.setColorWrite(!0)),a&&this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),o&&this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);let d=f.getStencilBuffer();if(f.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(r),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),l&&(c||this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency)){if(f.setStencilBuffer(d),c)c(this._transparentSubMeshes,this);else if(this._scene.useOrderIndependentTransparency){let h=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);h.length&&this._renderTransparent(h)}else this._renderTransparent(this._transparentSubMeshes);f.setAlphaMode(0)}if(f.setStencilBuffer(!1),a&&this._edgesRenderers.length){for(let h=0;ht._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamerat._distanceToCamera?1:0}static PainterSortCompare(e,t){let i=e.getMesh(),r=t.getMesh();return i.material&&r.material?i.material.uniqueId-r.material.uniqueId:i.uniqueId-r.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),i===void 0&&(i=e.getMaterial()),i!=null&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTestingForMesh(t)?(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(this._particleSystems.length===0)return;let t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let i=0;i{sx();D_=class{},Nr=class n{get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e;for(let t of this._renderingGroups)t.disableDepthPrePass=e}get maintainStateBetweenFrames(){return this._maintainStateBetweenFrames}set maintainStateBetweenFrames(e){e!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=e,this._maintainStateBetweenFrames||this.restoreDispachedFlags())}restoreDispachedFlags(){for(let e of this._scene.meshes)if(e.subMeshes)for(let t of e.subMeshes)t._wasDispatched=!1;if(this._scene.spriteManagers)for(let e of this._scene.spriteManagers)e._wasDispatched=!1;for(let e of this._scene.particleSystems)e._wasDispatched=!1}constructor(e){this._useSceneAutoClearSetup=!1,this._disableDepthPrePass=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new D_,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=n.MIN_RENDERINGGROUPS;t{it=class{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}};it.FALLOFF_DEFAULT=0;it.FALLOFF_PHYSICAL=1;it.FALLOFF_GLTF=2;it.FALLOFF_STANDARD=3;it.LIGHTMAP_DEFAULT=0;it.LIGHTMAP_SPECULAR=1;it.LIGHTMAP_SHADOWSONLY=2;it.INTENSITYMODE_AUTOMATIC=0;it.INTENSITYMODE_LUMINOUSPOWER=1;it.INTENSITYMODE_LUMINOUSINTENSITY=2;it.INTENSITYMODE_ILLUMINANCE=3;it.INTENSITYMODE_LUMINANCE=4;it.LIGHTTYPEID_POINTLIGHT=0;it.LIGHTTYPEID_DIRECTIONALLIGHT=1;it.LIGHTTYPEID_SPOTLIGHT=2;it.LIGHTTYPEID_HEMISPHERICLIGHT=3;it.LIGHTTYPEID_RECT_AREALIGHT=4;it.LIGHTTYPEID_CLUSTERED_CONTAINER=5});var Fr,L_=A(()=>{ma();ft();Sh();Ln();Mn();ze();cn();$c();Fr=class n{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=nh(e,this._renderListHasChanged)),this._renderList=e)}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._scene.markAllMaterialsAsDirty(64))}get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e,this._renderingManager.disableDepthPrePass=e}get name(){return this._name}set name(e){if(this._name!==e){if(this._name=e,this._sceneUBOs)for(let t=0;tthis._checkReadiness(),()=>{if(this._freezeActiveMeshesCancel=null,e)for(let t=0;t{this._freezeActiveMeshesCancel=null,i?(W.Error("ObjectRenderer: Timeout while waiting for the renderer to be ready."),t&&W.Error(t)):(W.Error("ObjectRenderer: An unexpected error occurred while waiting for the renderer to be ready."),t&&(W.Error(t),t.stack&&W.Error(t.stack)))})}_unfreezeActiveMeshes(){var e;(e=this._freezeActiveMeshesCancel)==null||e.call(this),this._freezeActiveMeshesCancel=null;for(let t=0;t{let a=this._renderList?this._renderList.length:0;if(s===0&&a>0||a===0)for(let o of this._scene.meshes)o._markSubMeshesAsLightDirty()},this.particleSystemList=null,this.getCustomRenderList=null,this.renderMeshes=!0,this.renderDepthOnlyMeshes=!0,this.renderOpaqueMeshes=!0,this.renderAlphaTestMeshes=!0,this.renderTransparentMeshes=!0,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.enableBoundingBoxRendering=!1,this.enableOutlineRendering=!0,this._disableImageProcessing=!1,this.dontSetTransformationMatrix=!1,this._disableDepthPrePass=!1,this.onBeforeRenderObservable=new Y,this.onAfterRenderObservable=new Y,this.onBeforeRenderingManagerRenderObservable=new Y,this.onAfterRenderingManagerRenderObservable=new Y,this.onInitRenderingObservable=new Y,this.onFinishRenderingObservable=new Y,this.onFastPathRenderObservable=new Y,this._currentRefreshId=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._activeMeshes=new Ct(256),this._activeBoundingBoxes=new Ct(32),this._currentFrameId=-1,this._currentSceneUBOIndex=0,this._isFrozen=!1,this._freezeActiveMeshesCancel=null,this._currentSceneCamera=null,this.name=e,this._scene=t,this._engine=this._scene.getEngine(),this._useUBO=this._engine.supportsUniformBuffers,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,enableClusteredLights:!1,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new Nr(t),this._renderingManager._useSceneAutoClearSetup=!0,this.options.enableClusteredLights&&this.onInitRenderingObservable.add(()=>{for(let r of this._scene.lights)r.getTypeID()===it.LIGHTTYPEID_CLUSTERED_CONTAINER&&r.isSupported&&r._updateBatches(this.activeCamera).render()}),this._scene.addObjectRenderer(this)}_releaseRenderPassId(){for(let e=0;e=this._sceneUBOs.length){let s=this._sceneUBOs.length;this._sceneUBOs.push(this._createSceneUBO(`Scene ubo #${s} for ${this.name}`,t)),this._sceneUBOIsMultiview.push(t)}else this._sceneUBOIsMultiview[this._currentSceneUBOIndex]!==t&&(this._sceneUBOs[this._currentSceneUBOIndex].dispose(),this._sceneUBOs[this._currentSceneUBOIndex]=this._createSceneUBO(`Scene ubo #${this._currentSceneUBOIndex} for ${this.name}`,t),this._sceneUBOIsMultiview[this._currentSceneUBOIndex]=t);let i=this._sceneUBOs[this._currentSceneUBOIndex++];return i.unbindEffect(),i}resetRefreshCounter(){this._currentRefreshId=-1}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}shouldRender(){return this._engine.snapshotRendering?!0: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);let i=this._checkReadiness();return this.finishRender(),i}prepareRenderList(){let e=this._scene;if(this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(let t=0;t1&&(e.incrementRenderId(),e.resetCachedMaterial())}let s=this.particleSystemList||e.particleSystems;for(let a of s)a.isReady()||(i=!1);return this._engine.currentRenderPassId=t,i}_prepareRenderingManager(e=0,t=!1){var h,u;let i=this._scene,r=null,s,a,o=this.renderList?this.renderList:i.frameGraph?i.meshes:i.getActiveMeshes().data,l=this.renderList||i.frameGraph?o.length:i.getActiveMeshes().length;if(this.getCustomRenderList&&(r=this.getCustomRenderList(e,o,l)),r)s=r.length,a=this.forceLayerMaskCheck;else{if(this._defaultRenderListPrepared&&!t&&!this._engine.isWebGPU)return o;this._defaultRenderListPrepared=!0,r=o,s=l,a=!this.renderList||this.forceLayerMaskCheck}let c=i.activeCamera,f=(h=this.cameraForLOD)!=null?h:c,d=(u=i.getBoundingBoxRenderer)==null?void 0:u.call(i);if(i._activeMeshesFrozen&&this._isFrozen){if(this._renderingManager.resetSprites(),this.enableBoundingBoxRendering&&d){d.reset();for(let m=0;m{Mn();zi=class{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 r;this.effect=e,t!==void 0&&(this.defines=t),i&&((r=this.drawContext)==null||r.reset())}dispose(e=!1){var t;if(this.effect){let i=this.effect;e?i.dispose():rn.SetImmediate(()=>{i.getEngine().onEndFrameObservable.addOnce(()=>{i.dispose()})}),this.effect=null}(t=this.drawContext)==null||t.dispose()}}});var ox={};De(ox,{postprocessVertexShader:()=>HV});var P_,ax,HV,O_=A(()=>{N();P_="postprocessVertexShader",ax=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5); #define CUSTOM_VERTEX_DEFINITIONS void main(void) { #define CUSTOM_VERTEX_MAIN_BEGIN vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStore[y_]||(E.ShadersStore[y_]=$I);IV={name:y_,shader:$I}});var ix={};De(ix,{postprocessVertexShaderWGSL:()=>xV});var L_,tx,xV,P_=A(()=>{N();L_="postprocessVertexShader",tx=`attribute position: vec2;uniform scale: vec2;varying vUV: vec2;const madd=vec2(0.5,0.5); +}`;E.ShadersStore[P_]||(E.ShadersStore[P_]=ax);HV={name:P_,shader:ax}});var cx={};De(cx,{postprocessVertexShaderWGSL:()=>zV});var N_,lx,zV,F_=A(()=>{N();N_="postprocessVertexShader",lx=`attribute position: vec2;uniform scale: vec2;varying vUV: vec2;const madd=vec2(0.5,0.5); #define CUSTOM_VERTEX_DEFINITIONS @vertex fn main(input : VertexInputs)->FragmentInputs { @@ -42,16 +42,16 @@ fn main(input : VertexInputs)->FragmentInputs { vertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStoreWGSL[L_]||(E.ShadersStoreWGSL[L_]=tx);xV={name:L_,shader:tx}});var O_,Sh,li,Eo=A(()=>{yt();fl();ct();no();go();D_();P_();O_={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]},Sh=class{constructor(e,t=O_){var s,a;this._fullscreenViewport=new nn(0,0,1,1);let i=(s=t.positions)!=null?s:O_.positions,r=(a=t.indices)!=null?a:O_.indices;this.engine=e,this._vertexBuffers={[M.PositionKind]:new M(e,i,M.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(r),this._indexBufferLength=r.length,this._onContextRestoredObserver=e.onContextRestoredObservable.add(()=>{this._indexBuffer=e.createIndexBuffer(r);for(let 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,t=!1,i=!1){this.engine.setState(!0),this.engine.depthCullingState.depthTest=t,this.engine.stencilState.stencilTest=i,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,this._indexBufferLength)}_isRenderTargetTexture(e){return e.renderTarget!==void 0}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();let 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(){let e=this._vertexBuffers[M.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[M.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}},li=class n{static RegisterShaderCodeProcessing(e,t){if(!t){delete n._CustomShaderCodeProcessing[e!=null?e:""];return}n._CustomShaderCodeProcessing[e!=null?e:""]=t}static _GetShaderCodeProcessing(e){var t;return(t=n._CustomShaderCodeProcessing[e])!=null?t:n._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,r;this.alphaMode=0,this.onEffectCreatedObservable=new Y(void 0,!0),this.onApplyObservable=new Y,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,allowEmptySourceTexture:(r=e.allowEmptySourceTexture)!=null?r:!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(!this.options.allowEmptySourceTexture&&this.options.samplers.indexOf("textureSampler")===-1&&this.options.samplers.push("textureSampler"),this.options.uniforms.indexOf("scale")===-1&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add(()=>{this.effect.setFloat2("scale",1,1)})),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add(()=>{this.bind()}),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add(()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()})),this._drawWrapper=new Hi(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;let t=Array.isArray(this.options.defines)?this.options.defines.join(` -`):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){}_postConstructor(e,t=null,i,r){this._importPromises.length=0,r&&this._importPromises.push(...r);let s=this.options.engine.isWebGPU&&!n.ForceGLSL;this._gatherImports(s,this._importPromises),i!==void 0&&i(s,this._importPromises),s&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,r,s,a,o,l){var h,u;let c=n._GetShaderCodeProcessing(this.name);if(c!=null&&c.defineCustomBindings){let m=(h=t==null?void 0:t.slice())!=null?h:[];m.push(...this.options.uniforms);let p=(u=i==null?void 0:i.slice())!=null?u:[];p.push(...this.options.samplers),e=c.defineCustomBindings(this.name,e,m,p),t=m,i=p}this.options.defines=e||"";let f=this._shadersLoaded||this._importPromises.length===0?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0},d;this.options.extraInitializationsAsync?d=async()=>{f==null||f(),await this.options.extraInitializationsAsync()}:d=f,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o!=null?o:this._shaderPath.vertex,fragment:l!=null?l: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:s!=null?s:this.options.onCompiled,onError:a!=null?a:null,indexParameters:r||this.options.indexParameters,processCodeAfterIncludes:c!=null&&c.processCodeAfterIncludes?(m,p)=>c.processCodeAfterIncludes(this.name,m,p):null,processFinalCode:c!=null&&c.processFinalCode?(m,p)=>c.processFinalCode(this.name,m,p):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:d},this.options.engine):this._drawWrapper.effect=new Nt(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,s||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,d),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(e=!1){var t,i;this.options.useAsPostProcess&&!e&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),(i=(t=n._GetShaderCodeProcessing(this.name))==null?void 0:t.bindCustomBindings)==null||i.call(t,this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this._drawWrapper.dispose(!0)}};li.ForceGLSL=!1;li._CustomShaderCodeProcessing={}});var F_={};De(F_,{passPixelShader:()=>CV});var N_,rx,CV,w_=A(()=>{N();N_="passPixelShader",rx=`varying vec2 vUV;uniform sampler2D textureSampler; +`;E.ShadersStoreWGSL[N_]||(E.ShadersStoreWGSL[N_]=lx);zV={name:N_,shader:lx}});var w_,Ah,li,Eo=A(()=>{yt();dl();ft();no();go();O_();F_();w_={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]},Ah=class{constructor(e,t=w_){var s,a;this._fullscreenViewport=new an(0,0,1,1);let i=(s=t.positions)!=null?s:w_.positions,r=(a=t.indices)!=null?a:w_.indices;this.engine=e,this._vertexBuffers={[M.PositionKind]:new M(e,i,M.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(r),this._indexBufferLength=r.length,this._onContextRestoredObserver=e.onContextRestoredObservable.add(()=>{this._indexBuffer=e.createIndexBuffer(r);for(let 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,t=!1,i=!1){this.engine.setState(!0),this.engine.depthCullingState.depthTest=t,this.engine.stencilState.stencilTest=i,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,this._indexBufferLength)}_isRenderTargetTexture(e){return e.renderTarget!==void 0}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();let 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(){let e=this._vertexBuffers[M.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[M.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}},li=class n{static RegisterShaderCodeProcessing(e,t){if(!t){delete n._CustomShaderCodeProcessing[e!=null?e:""];return}n._CustomShaderCodeProcessing[e!=null?e:""]=t}static _GetShaderCodeProcessing(e){var t;return(t=n._CustomShaderCodeProcessing[e])!=null?t:n._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,r;this.alphaMode=0,this.onEffectCreatedObservable=new Y(void 0,!0),this.onApplyObservable=new Y,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,allowEmptySourceTexture:(r=e.allowEmptySourceTexture)!=null?r:!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(!this.options.allowEmptySourceTexture&&this.options.samplers.indexOf("textureSampler")===-1&&this.options.samplers.push("textureSampler"),this.options.uniforms.indexOf("scale")===-1&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add(()=>{this.effect.setFloat2("scale",1,1)})),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add(()=>{this.bind()}),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add(()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()})),this._drawWrapper=new zi(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;let t=Array.isArray(this.options.defines)?this.options.defines.join(` +`):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){}_postConstructor(e,t=null,i,r){this._importPromises.length=0,r&&this._importPromises.push(...r);let s=this.options.engine.isWebGPU&&!n.ForceGLSL;this._gatherImports(s,this._importPromises),i!==void 0&&i(s,this._importPromises),s&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,r,s,a,o,l){var h,u;let c=n._GetShaderCodeProcessing(this.name);if(c!=null&&c.defineCustomBindings){let m=(h=t==null?void 0:t.slice())!=null?h:[];m.push(...this.options.uniforms);let p=(u=i==null?void 0:i.slice())!=null?u:[];p.push(...this.options.samplers),e=c.defineCustomBindings(this.name,e,m,p),t=m,i=p}this.options.defines=e||"";let f=this._shadersLoaded||this._importPromises.length===0?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0},d;this.options.extraInitializationsAsync?d=async()=>{f==null||f(),await this.options.extraInitializationsAsync()}:d=f,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o!=null?o:this._shaderPath.vertex,fragment:l!=null?l: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:s!=null?s:this.options.onCompiled,onError:a!=null?a:null,indexParameters:r||this.options.indexParameters,processCodeAfterIncludes:c!=null&&c.processCodeAfterIncludes?(m,p)=>c.processCodeAfterIncludes(this.name,m,p):null,processFinalCode:c!=null&&c.processFinalCode?(m,p)=>c.processFinalCode(this.name,m,p):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:d},this.options.engine):this._drawWrapper.effect=new Nt(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,s||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,d),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(e=!1){var t,i;this.options.useAsPostProcess&&!e&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),(i=(t=n._GetShaderCodeProcessing(this.name))==null?void 0:t.bindCustomBindings)==null||i.call(t,this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this._drawWrapper.dispose(!0)}};li.ForceGLSL=!1;li._CustomShaderCodeProcessing={}});var U_={};De(U_,{passPixelShader:()=>XV});var B_,fx,XV,V_=A(()=>{N();B_="passPixelShader",fx=`varying vec2 vUV;uniform sampler2D textureSampler; #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) -{gl_FragColor=texture2D(textureSampler,vUV);}`;E.ShadersStore[N_]||(E.ShadersStore[N_]=rx);CV={name:N_,shader:rx}});var nx={};De(nx,{Dispose:()=>U_,DumpData:()=>Ah,DumpDataAsync:()=>tf,DumpFramebuffer:()=>B_,DumpTools:()=>DV,EncodeImageAsync:()=>yV});async function bV(){var o,l;let n=(l=(o=ue.LastCreatedEngine)==null?void 0:o.createCanvas(100,100))!=null?l:new OffscreenCanvas(100,100);n instanceof OffscreenCanvas&&W.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");let{ThinEngine:e}=await Promise.resolve().then(()=>(Ji(),eI));if(!e.IsSupported)throw new Error("DumpData: No WebGL context available. Cannot dump data.");let t={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1},i=new e(n,!1,t);ue.Instances.pop(),ue.OnEnginesDisposedObservable.add(c=>{i&&c!==i&&!i.isDisposed&&ue.Instances.length===0&&U_()}),i.getCaps().parallelShaderCompile=void 0;let r=new Sh(i),{passPixelShader:s}=await Promise.resolve().then(()=>(w_(),F_)),a=new li({engine:i,name:s.name,fragmentShader:s.shader,samplerNames:["textureSampler"]});return{canvas:n,dumpEngine:{engine:i,renderer:r,wrapper:a}}}async function MV(){return pa||(pa=bV()),await pa}async function B_(n,e,t,i,r="image/png",s,a){let o=await t.readPixels(0,0,n,e),l=new Uint8Array(o.buffer);Ah(n,e,l,i,r,s,!0,void 0,a)}async function tf(n,e,t,i="image/png",r,s=!1,a=!1,o){if(t instanceof Float32Array){let f=new Uint8Array(t.length),d=t.length;for(;d--;){let h=t[d];f[d]=Math.round(Ke(h)*255)}t=f}let l=await ef.EncodeImageAsync(t,n,e,i,s,o);r!==void 0&&re.DownloadBlob(l,r),l.type!==i&&W.Warn(`DumpData: The requested mimeType '${i}' is not supported. The result has mimeType '${l.type}' instead.`);let c=await l.arrayBuffer();return a?c:`data:${i};base64,${ml(c)}`}function Ah(n,e,t,i,r="image/png",s,a=!1,o=!1,l){s===void 0&&!i&&(s=""),tf(n,e,t,r,s,a,o,l).then(c=>{i&&i(c)})}function U_(){pa&&(pa==null||pa.then(n=>{n.canvas instanceof HTMLCanvasElement&&n.canvas.remove(),n.dumpEngine&&(n.dumpEngine.engine.dispose(),n.dumpEngine.renderer.dispose(),n.dumpEngine.wrapper.dispose())}),pa=null)}var pa,ef,yV,DV,LV,V_=A(()=>{Qe();Eo();Tt();bi();At();ze();jc();qe();pa=null;ef=class{static async EncodeImageAsync(e,t,i,r,s,a){let o=await MV(),l=o.dumpEngine;l.engine.setSize(t,i,!0);let c=l.engine.createRawTexture(e,t,i,5,!1,!s,1);return l.renderer.setViewport(),l.renderer.applyEffectWrapper(l.wrapper),l.wrapper.effect._bindTexture("textureSampler",c),l.renderer.draw(),c.dispose(),await new Promise((f,d)=>{re.ToBlob(o.canvas,h=>{h?f(h):d(new Error("EncodeImageAsync: Failed to convert canvas to blob."))},r,a)})}};C([tr],ef,"EncodeImageAsync",null);yV=ef.EncodeImageAsync;DV={DumpData:Ah,DumpDataAsync:tf,DumpFramebuffer:B_,Dispose:U_},LV=()=>{re.DumpData=Ah,re.DumpDataAsync=tf,re.DumpFramebuffer=B_};LV()});var ri,_a=A(()=>{ct();ve();oi();Eh();Dn();no();ze();M_();Nt.prototype.setDepthStencilTexture=function(n,e){this._engine.setDepthStencilTexture(this._samplers[n],this._uniforms[n],e,n)};ri=class n extends ne{get renderListPredicate(){return this._objectRenderer.renderListPredicate}set renderListPredicate(e){this._objectRenderer.renderListPredicate=e}get renderList(){return this._objectRenderer.renderList}set renderList(e){this._objectRenderer.renderList=e}get particleSystemList(){return this._objectRenderer.particleSystemList}set particleSystemList(e){this._objectRenderer.particleSystemList=e}get getCustomRenderList(){return this._objectRenderer.getCustomRenderList}set getCustomRenderList(e){this._objectRenderer.getCustomRenderList=e}get renderParticles(){return this._objectRenderer.renderParticles}set renderParticles(e){this._objectRenderer.renderParticles=e}get renderSprites(){return this._objectRenderer.renderSprites}set renderSprites(e){this._objectRenderer.renderSprites=e}get enableBoundingBoxRendering(){return this._objectRenderer.enableBoundingBoxRendering}set enableBoundingBoxRendering(e){this._objectRenderer.enableBoundingBoxRendering=e}get enableOutlineRendering(){return this._objectRenderer.enableOutlineRendering}set enableOutlineRendering(e){this._objectRenderer.enableOutlineRendering=e}get forceLayerMaskCheck(){return this._objectRenderer.forceLayerMaskCheck}set forceLayerMaskCheck(e){this._objectRenderer.forceLayerMaskCheck=e}get activeCamera(){return this._objectRenderer.activeCamera}set activeCamera(e){this._objectRenderer.activeCamera=e}get cameraForLOD(){return this._objectRenderer.cameraForLOD}set cameraForLOD(e){this._objectRenderer.cameraForLOD=e}get disableImageProcessing(){return this._objectRenderer.disableImageProcessing}set disableImageProcessing(e){this._objectRenderer.disableImageProcessing=e}get customIsReadyFunction(){return this._objectRenderer.customIsReadyFunction}set customIsReadyFunction(e){this._objectRenderer.customIsReadyFunction=e}get customRenderFunction(){return this._objectRenderer.customRenderFunction}set customRenderFunction(e){this._objectRenderer.customRenderFunction=e}get postProcesses(){return this._postProcesses}get _prePassEnabled(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled}set onAfterUnbind(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)}get onBeforeRenderObservable(){return this._objectRenderer.onBeforeRenderObservable}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}get onAfterRenderObservable(){return this._objectRenderer.onAfterRenderObservable}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}set onClear(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)}get _waitingRenderList(){return this._objectRenderer._waitingRenderList}set _waitingRenderList(e){this._objectRenderer._waitingRenderList=e}get renderPassId(){return this._objectRenderer.renderPassId}get renderPassIds(){return this._objectRenderer.renderPassIds}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;let 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,r=!1,s=!0,a=0,o=!1,l=ne.TRILINEAR_SAMPLINGMODE,c=!0,f=!1,d=!1,h=5,u=!1,m,p,_=!1,g=!1){var x,P,L,y,B,w,H;let T,b=!0,R,S=!1;if(typeof r=="object"){let O=r;r=!!O.generateMipMaps,s=(x=O.doNotChangeAspectRatio)!=null?x:!0,a=(P=O.type)!=null?P:0,o=!!O.isCube,l=(L=O.samplingMode)!=null?L:ne.TRILINEAR_SAMPLINGMODE,c=(y=O.generateDepthBuffer)!=null?y:!0,f=!!O.generateStencilBuffer,d=!!O.isMulti,h=(B=O.format)!=null?B:5,u=!!O.delayAllocation,m=O.samples,p=O.creationFlags,_=!!O.noColorAttachment,g=!!O.useSRGBBuffer,T=O.colorAttachment,b=(w=O.gammaSpace)!=null?w:b,R=O.existingObjectRenderer,S=!!O.enableClusteredLights}if(super(null,i,!r,void 0,l,void 0,void 0,void 0,void 0,h),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new Y,this.onAfterUnbindObservable=new Y,this.onClearObservable=new Y,this.onResizeObservable=new Y,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this._dontDisposeObjectRenderer=!1,this.boundingBoxPosition=v.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,i=this.getScene(),!i)return;let I=this.getScene().getEngine();this._gammaSpace=b,this._coordinatesMode=ne.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!R,this._processSizeParameter(t),this._objectRenderer=R!=null?R:new Or(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:s,enableClusteredLights:S}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{var V;let O=this._scene;if(!this._disableEngineStages)for(let X of O._beforeRenderTargetClearStage)X.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(I):this.skipInitialClear||I.clear((V=this.clearColor)!=null?V:O.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||O.updateTransformMatrix(!0),!this._disableEngineStages)for(let X of O._beforeRenderTargetDrawStage)X.action(this,this._currentFaceIndex,this._currentLayer);I._debugPushGroup&&I._debugPushGroup(`Render to ${this.name} (face #${this._currentFaceIndex} layer #${this._currentLayer})`)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{var V,X,j,Q;if(I._debugPopGroup&&I._debugPopGroup(),!this._disableEngineStages)for(let $ of this._scene._afterRenderTargetDrawStage)$.action(this,this._currentFaceIndex,this._currentLayer);let O=(X=(V=this._texture)==null?void 0:V.generateMipMaps)!=null?X:!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,(j=this._renderTarget)!=null?j:void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,(Q=this._renderTarget)!=null?Q:void 0,this._currentFaceIndex),!this._disableEngineStages)for(let $ of this._scene._afterRenderTargetPostProcessStage)$.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=O),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),I):W.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))}),this._onFastPathRenderObserver=this._objectRenderer.onFastPathRenderObservable.add(()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(I):this.skipInitialClear||I.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=I.onResizeObservable.add(()=>{}),this._generateMipMaps=!!r,this._doNotChangeAspectRatio=s,!d&&(this._renderTargetOptions={generateMipMaps:r,type:a,format:(H=this._format)!=null?H:void 0,samplingMode:this.samplingMode,generateDepthBuffer:c,generateStencilBuffer:f,samples:m,creationFlags:p,noColorAttachment:_,useSRGBBuffer:g,colorAttachment:T,label:this.name},this.samplingMode===ne.NEAREST_SAMPLINGMODE&&(this.wrapU=ne.CLAMP_ADDRESSMODE,this.wrapV=ne.CLAMP_ADDRESSMODE),u||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=ne.INVCUBIC_MODE,this._textureMatrix=G.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,m!==void 0&&(this.samples=m)))}createDepthStencilTexture(e=0,t=!0,i=!1,r=1,s=14,a){var o;(o=this._renderTarget)==null||o.createDepthStencilTexture(e,t,i,r,s,a)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;let 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){let t=this.getScene();if(!t)return;this._postProcessManager=new us(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(let t of this._postProcesses)t.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;let 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(){let e=this._size.layers;if(e)return e;let t=this._size.depth;return t||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){let t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){var r;let t=this.isCube;(r=this._renderTarget)==null||r.dispose(),this._renderTarget=null;let 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,Promise.resolve().then(()=>(V_(),nx)).then(t=>this._dumpTools=t)),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());let e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){let i=this.getScene();if(!i)return;this.useCameraPostProcesses!==void 0&&(e=this.useCameraPostProcesses);let r=i.getEngine();if(r._debugPushGroup&&r._debugPushGroup(`Render to ${this.name}`),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.onAfterRenderObservable.notifyObservers(t)})}_prepareFrame(e,t,i,r){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses)||this._bindFrameBuffer(t,i):(!r||!e.postProcessManager._prepareFrame(this._texture))&&this._bindFrameBuffer(t,i)}_renderToTarget(e,t,i,r=0){let s=this.getScene();if(!s)return;let a=s.getEngine();this._currentFaceIndex=e,this._currentLayer=r,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(s,e,r,t),this._objectRenderer.render(e+r,!0),this._unbindFrameBuffer(a,e),this._texture&&this.isCube&&e===5&&a.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,i=null,r=null){this._objectRenderer.setRenderingOrder(e,t,i,r)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){let e=this.getSize(),t=new n(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;let e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t=0&&e.customRenderTargets.splice(t,1);for(let r of e.cameras)t=r.customRenderTargets.indexOf(this),t>=0&&r.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}};ri.REFRESHRATE_RENDER_ONCE=Or.REFRESHRATE_RENDER_ONCE;ri.REFRESHRATE_RENDER_ONEVERYFRAME=Or.REFRESHRATE_RENDER_ONEVERYFRAME;ri.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Or.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;ne._CreateRenderTargetTexture=(n,e,t,i,r)=>new ri(n,e,t,i)});var _t,ms=A(()=>{Qe();on();ct();ve();no();qe();Kt();Lt();ii();Dn();Eo();fe.prototype.setTextureFromPostProcess=function(n,e,t){var r;let i=null;e&&(e._forcedOutputTexture?i=e._forcedOutputTexture:e._textures.data[e._currentRenderTextureInd]&&(i=e._textures.data[e._currentRenderTextureInd])),this._bindTexture(n,(r=i==null?void 0:i.texture)!=null?r:null,t)};fe.prototype.setTextureFromPostProcessOutput=function(n,e,t){var i,r;this._bindTexture(n,(r=(i=e==null?void 0:e._outputTexture)==null?void 0:i.texture)!=null?r:null,t)};Nt.prototype.setTextureFromPostProcess=function(n,e){this._engine.setTextureFromPostProcess(this._samplers[n],e,n)};Nt.prototype.setTextureFromPostProcessOutput=function(n,e){this._engine.setTextureFromPostProcessOutput(this._samplers[n],e,n)};_t=class n{static get ForceGLSL(){return li.ForceGLSL}static set ForceGLSL(e){li.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){li.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,r,s,a,o=1,l,c,f=null,d=0,h="postprocess",u,m=!1,p=5,_,g){var S,I,x,P,L,y,B,w,H,O,V,X;this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this.doNotSerialize=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Ct(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new _e(1,1),this._texelSize=_e.Zero(),this.onActivateObservable=new Y,this.onSizeChangedObservable=new Y,this.onApplyObservable=new Y,this.onBeforeRenderObservable=new Y,this.onAfterRenderObservable=new Y,this.onDisposeObservable=new Y;let T=1,b=null,R;if(i&&!Array.isArray(i)){let j=i;i=(S=j.uniforms)!=null?S:null,r=(I=j.samplers)!=null?I:null,T=(x=j.size)!=null?x:1,a=(P=j.camera)!=null?P:null,o=(L=j.samplingMode)!=null?L:1,l=j.engine,c=j.reusable,f=Array.isArray(j.defines)?j.defines.join(` -`):(y=j.defines)!=null?y:null,d=(B=j.textureType)!=null?B:0,h=(w=j.vertexUrl)!=null?w:"postprocess",u=j.indexParameters,m=(H=j.blockCompilation)!=null?H:!1,p=(O=j.textureFormat)!=null?O:5,_=(V=j.shaderLanguage)!=null?V:0,b=(X=j.uniformBuffers)!=null?X:null,g=j.extraInitializations,R=j.effectWrapper}else s&&(typeof s=="number"?T=s:T={width:s.width,height:s.height});if(this._useExistingThinPostProcess=!!R,this._effectWrapper=R!=null?R:new li({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:l||(a==null?void 0:a.getScene().getEngine()),uniforms:i,samplers:r,uniformBuffers:b,defines:f,vertexUrl:h,indexParameters:u,blockCompilation:!0,shaderLanguage:_,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,a!=null?(this._camera=a,this._scene=a.getScene(),a.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.addPostProcess(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=T,this.renderTargetSamplingMode=o||1,this._reusable=c||!1,this._textureType=d,this._textureFormat=p,this._shaderLanguage=_||0,this._samplers=r||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=h,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=b||[],this._indexParameters=u,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;let j=[];this._gatherImports(this._engine.isWebGPU&&!n.ForceGLSL,j),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(m,f,g,j)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([Promise.resolve().then(()=>(P_(),ix))])):t.push(Promise.all([Promise.resolve().then(()=>(D_(),ex))]))}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 Ct(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,r,s,a,o,l){this._effectWrapper.updateEffect(e,t,i,r,s,a,o,l),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join(` -`):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let s=0;s=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let i=!1;for(let r=0;r0&&this._textures.reset(),this.width=e,this.height=t;let a=null;if(i){for(let c=0;c{g.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(g,this.samples)}),this._flushTextureCache(),this._renderId++}return u||(u=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(l/f,c/d),this._engine.bindFramebuffer(u,0,l,c,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(u,0,void 0,void 0,this.forceFullscreenViewport)),(_=(p=this._engine)._debugInsertMarker)==null||_.call(p,`post process ${this.name} input`),this.onActivateObservable.notifyObservers(r),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),u}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),this._engine.setAlphaMode(this.alphaMode);let e;return this._shareOutputWithPostProcess?e=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?e=this._forcedOutputTexture:e=this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e==null?void 0:e.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(!0),this._effectWrapper.drawWrapper.effect}_disposeTextures(){if(this._shareOutputWithPostProcess||this._forcedOutputTexture){this._disposeTextureCache();return}this._disposeTextureCache(),this._textures.dispose()}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return this._prePassEffectConfiguration?(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0):!1}dispose(e){e=e||this._camera,this._useExistingThinPostProcess||this._effectWrapper.dispose(),this._disposeTextures(),this._scene&&this._scene.removePostProcess(this);let t;if(this._parentContainer&&(t=this._parentContainer.postProcesses.indexOf(this),t>-1&&this._parentContainer.postProcesses.splice(t,1),this._parentContainer=null),t=this._engine.postProcesses.indexOf(this),t!==-1&&this._engine.postProcesses.splice(t,1),this.onDisposeObservable.notifyObservers(),!!e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),t===0&&e._postProcesses.length>0){let 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(){let e=Me.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(){let e=this.serialize();e._engine=this._engine,e.cameraId=null;let t=n.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){let r=Ai(e.customType);if(!r||!r._Parse)return null;let s=t?t.getCameraById(e.cameraId):null;return r._Parse(e,s,t,i)}static _Parse(e,t,i,r){return Me.Parse(()=>new n(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,r)}};C([D()],_t.prototype,"uniqueId",void 0);C([D()],_t.prototype,"name",null);C([D()],_t.prototype,"width",void 0);C([D()],_t.prototype,"height",void 0);C([D()],_t.prototype,"renderTargetSamplingMode",void 0);C([ul()],_t.prototype,"clearColor",void 0);C([D()],_t.prototype,"autoClear",void 0);C([D()],_t.prototype,"forceAutoClearInAlphaMode",void 0);C([D()],_t.prototype,"alphaMode",null);C([D()],_t.prototype,"alphaConstants",void 0);C([D()],_t.prototype,"enablePixelPerfectMode",void 0);C([D()],_t.prototype,"forceFullscreenViewport",void 0);C([D()],_t.prototype,"scaleMode",void 0);C([D()],_t.prototype,"alwaysForcePOT",void 0);C([D("samples")],_t.prototype,"_samples",void 0);C([D()],_t.prototype,"adaptScaleToCurrentViewport",void 0);je("BABYLON.PostProcess",_t)});var ax={};De(ax,{passPixelShaderWGSL:()=>PV});var G_,sx,PV,ox=A(()=>{N();G_="passPixelShader",sx=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; +{gl_FragColor=texture2D(textureSampler,vUV);}`;E.ShadersStore[B_]||(E.ShadersStore[B_]=fx);XV={name:B_,shader:fx}});var dx={};De(dx,{Dispose:()=>k_,DumpData:()=>Rh,DumpDataAsync:()=>tf,DumpFramebuffer:()=>G_,DumpTools:()=>ZV,EncodeImageAsync:()=>jV});async function YV(){var o,l;let n=(l=(o=ue.LastCreatedEngine)==null?void 0:o.createCanvas(100,100))!=null?l:new OffscreenCanvas(100,100);n instanceof OffscreenCanvas&&W.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");let{ThinEngine:e}=await Promise.resolve().then(()=>(er(),oI));if(!e.IsSupported)throw new Error("DumpData: No WebGL context available. Cannot dump data.");let t={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1},i=new e(n,!1,t);ue.Instances.pop(),ue.OnEnginesDisposedObservable.add(c=>{i&&c!==i&&!i.isDisposed&&ue.Instances.length===0&&k_()}),i.getCaps().parallelShaderCompile=void 0;let r=new Ah(i),{passPixelShader:s}=await Promise.resolve().then(()=>(V_(),U_)),a=new li({engine:i,name:s.name,fragmentShader:s.shader,samplerNames:["textureSampler"]});return{canvas:n,dumpEngine:{engine:i,renderer:r,wrapper:a}}}async function KV(){return pa||(pa=YV()),await pa}async function G_(n,e,t,i,r="image/png",s,a){let o=await t.readPixels(0,0,n,e),l=new Uint8Array(o.buffer);Rh(n,e,l,i,r,s,!0,void 0,a)}async function tf(n,e,t,i="image/png",r,s=!1,a=!1,o){if(t instanceof Float32Array){let f=new Uint8Array(t.length),d=t.length;for(;d--;){let h=t[d];f[d]=Math.round(Ke(h)*255)}t=f}let l=await ef.EncodeImageAsync(t,n,e,i,s,o);r!==void 0&&re.DownloadBlob(l,r),l.type!==i&&W.Warn(`DumpData: The requested mimeType '${i}' is not supported. The result has mimeType '${l.type}' instead.`);let c=await l.arrayBuffer();return a?c:`data:${i};base64,${pl(c)}`}function Rh(n,e,t,i,r="image/png",s,a=!1,o=!1,l){s===void 0&&!i&&(s=""),tf(n,e,t,r,s,a,o,l).then(c=>{i&&i(c)})}function k_(){pa&&(pa==null||pa.then(n=>{n.canvas instanceof HTMLCanvasElement&&n.canvas.remove(),n.dumpEngine&&(n.dumpEngine.engine.dispose(),n.dumpEngine.renderer.dispose(),n.dumpEngine.wrapper.dispose())}),pa=null)}var pa,ef,jV,ZV,qV,W_=A(()=>{Qe();Eo();Tt();Mi();At();ze();jc();qe();pa=null;ef=class{static async EncodeImageAsync(e,t,i,r,s,a){let o=await KV(),l=o.dumpEngine;l.engine.setSize(t,i,!0);let c=l.engine.createRawTexture(e,t,i,5,!1,!s,1);return l.renderer.setViewport(),l.renderer.applyEffectWrapper(l.wrapper),l.wrapper.effect._bindTexture("textureSampler",c),l.renderer.draw(),c.dispose(),await new Promise((f,d)=>{re.ToBlob(o.canvas,h=>{h?f(h):d(new Error("EncodeImageAsync: Failed to convert canvas to blob."))},r,a)})}};C([rr],ef,"EncodeImageAsync",null);jV=ef.EncodeImageAsync;ZV={DumpData:Rh,DumpDataAsync:tf,DumpFramebuffer:G_,Dispose:k_},qV=()=>{re.DumpData=Rh,re.DumpDataAsync=tf,re.DumpFramebuffer=G_};qV()});var ri,_a=A(()=>{ft();ve();oi();vh();Dn();no();ze();L_();Nt.prototype.setDepthStencilTexture=function(n,e){this._engine.setDepthStencilTexture(this._samplers[n],this._uniforms[n],e,n)};ri=class n extends ne{get renderListPredicate(){return this._objectRenderer.renderListPredicate}set renderListPredicate(e){this._objectRenderer.renderListPredicate=e}get renderList(){return this._objectRenderer.renderList}set renderList(e){this._objectRenderer.renderList=e}get particleSystemList(){return this._objectRenderer.particleSystemList}set particleSystemList(e){this._objectRenderer.particleSystemList=e}get getCustomRenderList(){return this._objectRenderer.getCustomRenderList}set getCustomRenderList(e){this._objectRenderer.getCustomRenderList=e}get renderParticles(){return this._objectRenderer.renderParticles}set renderParticles(e){this._objectRenderer.renderParticles=e}get renderSprites(){return this._objectRenderer.renderSprites}set renderSprites(e){this._objectRenderer.renderSprites=e}get enableBoundingBoxRendering(){return this._objectRenderer.enableBoundingBoxRendering}set enableBoundingBoxRendering(e){this._objectRenderer.enableBoundingBoxRendering=e}get enableOutlineRendering(){return this._objectRenderer.enableOutlineRendering}set enableOutlineRendering(e){this._objectRenderer.enableOutlineRendering=e}get forceLayerMaskCheck(){return this._objectRenderer.forceLayerMaskCheck}set forceLayerMaskCheck(e){this._objectRenderer.forceLayerMaskCheck=e}get activeCamera(){return this._objectRenderer.activeCamera}set activeCamera(e){this._objectRenderer.activeCamera=e}get cameraForLOD(){return this._objectRenderer.cameraForLOD}set cameraForLOD(e){this._objectRenderer.cameraForLOD=e}get disableImageProcessing(){return this._objectRenderer.disableImageProcessing}set disableImageProcessing(e){this._objectRenderer.disableImageProcessing=e}get customIsReadyFunction(){return this._objectRenderer.customIsReadyFunction}set customIsReadyFunction(e){this._objectRenderer.customIsReadyFunction=e}get customRenderFunction(){return this._objectRenderer.customRenderFunction}set customRenderFunction(e){this._objectRenderer.customRenderFunction=e}get postProcesses(){return this._postProcesses}get _prePassEnabled(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled}set onAfterUnbind(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)}get onBeforeRenderObservable(){return this._objectRenderer.onBeforeRenderObservable}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}get onAfterRenderObservable(){return this._objectRenderer.onAfterRenderObservable}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}set onClear(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)}get _waitingRenderList(){return this._objectRenderer._waitingRenderList}set _waitingRenderList(e){this._objectRenderer._waitingRenderList=e}get renderPassId(){return this._objectRenderer.renderPassId}get renderPassIds(){return this._objectRenderer.renderPassIds}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;let 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,r=!1,s=!0,a=0,o=!1,l=ne.TRILINEAR_SAMPLINGMODE,c=!0,f=!1,d=!1,h=5,u=!1,m,p,_=!1,g=!1){var x,P,L,y,B,w,H;let T,b=!0,R,S=!1;if(typeof r=="object"){let O=r;r=!!O.generateMipMaps,s=(x=O.doNotChangeAspectRatio)!=null?x:!0,a=(P=O.type)!=null?P:0,o=!!O.isCube,l=(L=O.samplingMode)!=null?L:ne.TRILINEAR_SAMPLINGMODE,c=(y=O.generateDepthBuffer)!=null?y:!0,f=!!O.generateStencilBuffer,d=!!O.isMulti,h=(B=O.format)!=null?B:5,u=!!O.delayAllocation,m=O.samples,p=O.creationFlags,_=!!O.noColorAttachment,g=!!O.useSRGBBuffer,T=O.colorAttachment,b=(w=O.gammaSpace)!=null?w:b,R=O.existingObjectRenderer,S=!!O.enableClusteredLights}if(super(null,i,!r,void 0,l,void 0,void 0,void 0,void 0,h),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new Y,this.onAfterUnbindObservable=new Y,this.onClearObservable=new Y,this.onResizeObservable=new Y,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this._dontDisposeObjectRenderer=!1,this.boundingBoxPosition=v.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,i=this.getScene(),!i)return;let I=this.getScene().getEngine();this._gammaSpace=b,this._coordinatesMode=ne.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!R,this._processSizeParameter(t),this._objectRenderer=R!=null?R:new Fr(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:s,enableClusteredLights:S}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{var k;let O=this._scene;if(!this._disableEngineStages)for(let X of O._beforeRenderTargetClearStage)X.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(I):this.skipInitialClear||I.clear((k=this.clearColor)!=null?k:O.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||O.updateTransformMatrix(!0),!this._disableEngineStages)for(let X of O._beforeRenderTargetDrawStage)X.action(this,this._currentFaceIndex,this._currentLayer);I._debugPushGroup&&I._debugPushGroup(`Render to ${this.name} (face #${this._currentFaceIndex} layer #${this._currentLayer})`)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{var k,X,j,Q;if(I._debugPopGroup&&I._debugPopGroup(),!this._disableEngineStages)for(let $ of this._scene._afterRenderTargetDrawStage)$.action(this,this._currentFaceIndex,this._currentLayer);let O=(X=(k=this._texture)==null?void 0:k.generateMipMaps)!=null?X:!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,(j=this._renderTarget)!=null?j:void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,(Q=this._renderTarget)!=null?Q:void 0,this._currentFaceIndex),!this._disableEngineStages)for(let $ of this._scene._afterRenderTargetPostProcessStage)$.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=O),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),I):W.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))}),this._onFastPathRenderObserver=this._objectRenderer.onFastPathRenderObservable.add(()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(I):this.skipInitialClear||I.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=I.onResizeObservable.add(()=>{}),this._generateMipMaps=!!r,this._doNotChangeAspectRatio=s,!d&&(this._renderTargetOptions={generateMipMaps:r,type:a,format:(H=this._format)!=null?H:void 0,samplingMode:this.samplingMode,generateDepthBuffer:c,generateStencilBuffer:f,samples:m,creationFlags:p,noColorAttachment:_,useSRGBBuffer:g,colorAttachment:T,label:this.name},this.samplingMode===ne.NEAREST_SAMPLINGMODE&&(this.wrapU=ne.CLAMP_ADDRESSMODE,this.wrapV=ne.CLAMP_ADDRESSMODE),u||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=ne.INVCUBIC_MODE,this._textureMatrix=U.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,m!==void 0&&(this.samples=m)))}createDepthStencilTexture(e=0,t=!0,i=!1,r=1,s=14,a){var o;(o=this._renderTarget)==null||o.createDepthStencilTexture(e,t,i,r,s,a)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;let 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){let t=this.getScene();if(!t)return;this._postProcessManager=new ms(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(let t of this._postProcesses)t.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;let 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(){let e=this._size.layers;if(e)return e;let t=this._size.depth;return t||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){let t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){var r;let t=this.isCube;(r=this._renderTarget)==null||r.dispose(),this._renderTarget=null;let 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,Promise.resolve().then(()=>(W_(),dx)).then(t=>this._dumpTools=t)),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());let e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){let i=this.getScene();if(!i)return;this.useCameraPostProcesses!==void 0&&(e=this.useCameraPostProcesses);let r=i.getEngine();if(r._debugPushGroup&&r._debugPushGroup(`Render to ${this.name}`),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.onAfterRenderObservable.notifyObservers(t)})}_prepareFrame(e,t,i,r){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses)||this._bindFrameBuffer(t,i):(!r||!e.postProcessManager._prepareFrame(this._texture))&&this._bindFrameBuffer(t,i)}_renderToTarget(e,t,i,r=0){let s=this.getScene();if(!s)return;let a=s.getEngine();this._currentFaceIndex=e,this._currentLayer=r,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(s,e,r,t),this._objectRenderer.render(e+r,!0),this._unbindFrameBuffer(a,e),this._texture&&this.isCube&&e===5&&a.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,i=null,r=null){this._objectRenderer.setRenderingOrder(e,t,i,r)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){let e=this.getSize(),t=new n(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;let e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t=0&&e.customRenderTargets.splice(t,1);for(let r of e.cameras)t=r.customRenderTargets.indexOf(this),t>=0&&r.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}};ri.REFRESHRATE_RENDER_ONCE=Fr.REFRESHRATE_RENDER_ONCE;ri.REFRESHRATE_RENDER_ONEVERYFRAME=Fr.REFRESHRATE_RENDER_ONEVERYFRAME;ri.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Fr.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;ne._CreateRenderTargetTexture=(n,e,t,i,r)=>new ri(n,e,t,i)});var gt,ps=A(()=>{Qe();cn();ft();ve();no();qe();Kt();Lt();ii();Dn();Eo();fe.prototype.setTextureFromPostProcess=function(n,e,t){var r;let i=null;e&&(e._forcedOutputTexture?i=e._forcedOutputTexture:e._textures.data[e._currentRenderTextureInd]&&(i=e._textures.data[e._currentRenderTextureInd])),this._bindTexture(n,(r=i==null?void 0:i.texture)!=null?r:null,t)};fe.prototype.setTextureFromPostProcessOutput=function(n,e,t){var i,r;this._bindTexture(n,(r=(i=e==null?void 0:e._outputTexture)==null?void 0:i.texture)!=null?r:null,t)};Nt.prototype.setTextureFromPostProcess=function(n,e){this._engine.setTextureFromPostProcess(this._samplers[n],e,n)};Nt.prototype.setTextureFromPostProcessOutput=function(n,e){this._engine.setTextureFromPostProcessOutput(this._samplers[n],e,n)};gt=class n{static get ForceGLSL(){return li.ForceGLSL}static set ForceGLSL(e){li.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){li.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,r,s,a,o=1,l,c,f=null,d=0,h="postprocess",u,m=!1,p=5,_,g){var S,I,x,P,L,y,B,w,H,O,k,X;this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this.doNotSerialize=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Ct(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new _e(1,1),this._texelSize=_e.Zero(),this.onActivateObservable=new Y,this.onSizeChangedObservable=new Y,this.onApplyObservable=new Y,this.onBeforeRenderObservable=new Y,this.onAfterRenderObservable=new Y,this.onDisposeObservable=new Y;let T=1,b=null,R;if(i&&!Array.isArray(i)){let j=i;i=(S=j.uniforms)!=null?S:null,r=(I=j.samplers)!=null?I:null,T=(x=j.size)!=null?x:1,a=(P=j.camera)!=null?P:null,o=(L=j.samplingMode)!=null?L:1,l=j.engine,c=j.reusable,f=Array.isArray(j.defines)?j.defines.join(` +`):(y=j.defines)!=null?y:null,d=(B=j.textureType)!=null?B:0,h=(w=j.vertexUrl)!=null?w:"postprocess",u=j.indexParameters,m=(H=j.blockCompilation)!=null?H:!1,p=(O=j.textureFormat)!=null?O:5,_=(k=j.shaderLanguage)!=null?k:0,b=(X=j.uniformBuffers)!=null?X:null,g=j.extraInitializations,R=j.effectWrapper}else s&&(typeof s=="number"?T=s:T={width:s.width,height:s.height});if(this._useExistingThinPostProcess=!!R,this._effectWrapper=R!=null?R:new li({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:l||(a==null?void 0:a.getScene().getEngine()),uniforms:i,samplers:r,uniformBuffers:b,defines:f,vertexUrl:h,indexParameters:u,blockCompilation:!0,shaderLanguage:_,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,a!=null?(this._camera=a,this._scene=a.getScene(),a.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.addPostProcess(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=T,this.renderTargetSamplingMode=o||1,this._reusable=c||!1,this._textureType=d,this._textureFormat=p,this._shaderLanguage=_||0,this._samplers=r||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=h,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=b||[],this._indexParameters=u,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;let j=[];this._gatherImports(this._engine.isWebGPU&&!n.ForceGLSL,j),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(m,f,g,j)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([Promise.resolve().then(()=>(F_(),cx))])):t.push(Promise.all([Promise.resolve().then(()=>(O_(),ox))]))}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 Ct(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,r,s,a,o,l){this._effectWrapper.updateEffect(e,t,i,r,s,a,o,l),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join(` +`):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let s=0;s=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let i=!1;for(let r=0;r0&&this._textures.reset(),this.width=e,this.height=t;let a=null;if(i){for(let c=0;c{g.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(g,this.samples)}),this._flushTextureCache(),this._renderId++}return u||(u=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(l/f,c/d),this._engine.bindFramebuffer(u,0,l,c,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(u,0,void 0,void 0,this.forceFullscreenViewport)),(_=(p=this._engine)._debugInsertMarker)==null||_.call(p,`post process ${this.name} input`),this.onActivateObservable.notifyObservers(r),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),u}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),this._engine.setAlphaMode(this.alphaMode);let e;return this._shareOutputWithPostProcess?e=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?e=this._forcedOutputTexture:e=this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e==null?void 0:e.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(!0),this._effectWrapper.drawWrapper.effect}_disposeTextures(){if(this._shareOutputWithPostProcess||this._forcedOutputTexture){this._disposeTextureCache();return}this._disposeTextureCache(),this._textures.dispose()}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return this._prePassEffectConfiguration?(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0):!1}dispose(e){e=e||this._camera,this._useExistingThinPostProcess||this._effectWrapper.dispose(),this._disposeTextures(),this._scene&&this._scene.removePostProcess(this);let t;if(this._parentContainer&&(t=this._parentContainer.postProcesses.indexOf(this),t>-1&&this._parentContainer.postProcesses.splice(t,1),this._parentContainer=null),t=this._engine.postProcesses.indexOf(this),t!==-1&&this._engine.postProcesses.splice(t,1),this.onDisposeObservable.notifyObservers(),!!e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),t===0&&e._postProcesses.length>0){let 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(){let e=Me.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(){let e=this.serialize();e._engine=this._engine,e.cameraId=null;let t=n.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){let r=Ri(e.customType);if(!r||!r._Parse)return null;let s=t?t.getCameraById(e.cameraId):null;return r._Parse(e,s,t,i)}static _Parse(e,t,i,r){return Me.Parse(()=>new n(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,r)}};C([D()],gt.prototype,"uniqueId",void 0);C([D()],gt.prototype,"name",null);C([D()],gt.prototype,"width",void 0);C([D()],gt.prototype,"height",void 0);C([D()],gt.prototype,"renderTargetSamplingMode",void 0);C([ml()],gt.prototype,"clearColor",void 0);C([D()],gt.prototype,"autoClear",void 0);C([D()],gt.prototype,"forceAutoClearInAlphaMode",void 0);C([D()],gt.prototype,"alphaMode",null);C([D()],gt.prototype,"alphaConstants",void 0);C([D()],gt.prototype,"enablePixelPerfectMode",void 0);C([D()],gt.prototype,"forceFullscreenViewport",void 0);C([D()],gt.prototype,"scaleMode",void 0);C([D()],gt.prototype,"alwaysForcePOT",void 0);C([D("samples")],gt.prototype,"_samples",void 0);C([D()],gt.prototype,"adaptScaleToCurrentViewport",void 0);je("BABYLON.PostProcess",gt)});var ux={};De(ux,{passPixelShaderWGSL:()=>QV});var H_,hx,QV,mx=A(()=>{N();H_="passPixelShader",hx=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; #define CUSTOM_FRAGMENT_DEFINITIONS @fragment -fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);}`;E.ShadersStoreWGSL[G_]||(E.ShadersStoreWGSL[G_]=sx);PV={name:G_,shader:sx}});var cx={};De(cx,{passCubePixelShaderWGSL:()=>OV});var k_,lx,OV,fx=A(()=>{N();k_="passCubePixelShader",lx=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_cube; +fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,input.vUV);}`;E.ShadersStoreWGSL[H_]||(E.ShadersStoreWGSL[H_]=hx);QV={name:H_,shader:hx}});var _x={};De(_x,{passCubePixelShaderWGSL:()=>JV});var z_,px,JV,gx=A(()=>{N();z_="passCubePixelShader",px=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_cube; #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs {var uv: vec2f=input.vUV*2.0-1.0; @@ -73,7 +73,7 @@ fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(u #ifdef NEGATIVEZ fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv,-1.001)); #endif -}`;E.ShadersStoreWGSL[k_]||(E.ShadersStoreWGSL[k_]=lx);OV={name:k_,shader:lx}});var hx={};De(hx,{passCubePixelShader:()=>NV});var W_,dx,NV,ux=A(()=>{N();W_="passCubePixelShader",dx=`varying vec2 vUV;uniform samplerCube textureSampler; +}`;E.ShadersStoreWGSL[z_]||(E.ShadersStoreWGSL[z_]=px);JV={name:z_,shader:px}});var vx={};De(vx,{passCubePixelShader:()=>$V});var X_,Ex,$V,Tx=A(()=>{N();X_="passCubePixelShader",Ex=`varying vec2 vUV;uniform samplerCube textureSampler; #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) {vec2 uv=vUV*2.0-1.0; @@ -95,8 +95,8 @@ gl_FragColor=textureCube(textureSampler,vec3(uv,1.001)); #ifdef NEGATIVEZ gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001)); #endif -}`;E.ShadersStore[W_]||(E.ShadersStore[W_]=dx);NV={name:W_,shader:dx}});var ps,rf,H_=A(()=>{Eo();At();ps=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(ox(),ax))]))):t.push(Promise.all([Promise.resolve().then(()=>(w_(),F_))])),super._gatherImports(e,t)}constructor(e,t=null,i){let r={name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,...i};r.engine||(r.engine=ue.LastCreatedEngine),super(r)}};ps.FragmentUrl="pass";rf=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(fx(),cx))]))):t.push(Promise.all([Promise.resolve().then(()=>(ux(),hx))])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,defines:"#define POSITIVEX"}),this._face=0}get face(){return this._face}set face(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ");break}}};rf.FragmentUrl="passCube"});var vo,z_,X_=A(()=>{Qe();ms();ii();Lt();Kt();H_();qe();vo=class n extends _t{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,r,s,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:s,reusable:a,textureType:o,blockCompilation:l,...t};super(e,ps.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new ps(e,s,c):void 0,...c})}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};je("BABYLON.PassPostProcess",vo);z_=class n extends _t{get face(){return this._effectWrapper.face}set face(e){this._effectWrapper.face=e}getClassName(){return"PassCubePostProcess"}constructor(e,t,i=null,r,s,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:s,reusable:a,textureType:o,blockCompilation:l,...t};super(e,ps.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new rf(e,s,c):void 0,...c})}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};C([D()],z_.prototype,"face",null);fe._RescalePostProcessFactory=n=>new vo("rescale",1,null,2,n,!1,0)});function px(n,e,t,i,r,s,a,o){let l=e.getEngine();return e.isReady=!1,r=r!=null?r:e.samplingMode,i=i!=null?i:e.type,s=s!=null?s:e.format,a=a!=null?a:e.width,o=o!=null?o:e.height,i===-1&&(i=0),new Promise(c=>{let f=new _t("postprocess",n,null,null,1,null,r,l,!1,void 0,i,void 0,null,!1,s);f.externalTextureSamplerBinding=!0;let d=l.createRenderTargetTexture({width:a,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:r,type:i,format:s});f.onEffectCreatedObservable.addOnce(h=>{h.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",e),u.setFloat2("scale",1,1)},t.postProcessManager.directRender([f],d,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(e),f&&f.dispose(),d._swapAndDie(e),e.type=i,e.format=5,e.isReady=!0,c(e)})})})}function To(n){Rh||(Rh=new Float32Array(1),mx=new Int32Array(Rh.buffer)),Rh[0]=n;let e=mx[0],t=e>>16&32768,i=e>>12&2047,r=e>>23&255;return r<103?t:r>142?(t|=31744,t|=(r==255?0:1)&&e&8388607,t):r<113?(i|=2048,t|=(i>>114-r)+(i>>113-r&1),t):(t|=r-112<<10|i>>1,t+=i&1,t)}function _s(n){let e=(n&32768)>>15,t=(n&31744)>>10,i=n&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))}var Rh,mx,Y_=A(()=>{oi();_a();X_();ms();bi()});function j_(n){return n.split(" ").filter(e=>e!=="").map(e=>parseFloat(e))}function K_(n,e,t){for(;t.length!==e;){let i=j_(n.lines[n.index++]);t.push(...i)}}function FV(n,e,t){let i=0,r=0,s=0,a=0,o=0,l=0;for(let g=0;g0&&!i.lines[i.index].includes("TILT=");)i.index++;i.lines[i.index].includes("INCLUDE"),i.index++;let s=j_(i.lines[i.index++]);r.numberOfLights=s[0],r.lumensPerLamp=s[1],r.candelaMultiplier=s[2],r.numberOfVerticalAngles=s[3],r.numberOfHorizontalAngles=s[4],r.photometricType=s[5],r.unitsType=s[6],r.width=s[7],r.length=s[8],r.height=s[9];let a=j_(i.lines[i.index++]);r.ballastFactor=a[0],r.fileGenerationType=a[1],r.inputWatts=a[2];for(let m=0;m0)for(let m=0;m=u)&&(p%=u*2,p>u&&(p=u*2-p)),d[_+p*l]=FV(r,_,p)}return{width:c/2,height:1,data:d}}var gx=A(()=>{bi()});var Ex={};De(Ex,{_IESTextureLoader:()=>Z_});var Z_,vx=A(()=>{gx();Z_=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".ies not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=_x(r);i(s.width,s.height,!!t.useMipMaps,!1,()=>{let a=t.getEngine();t.type=1,t.format=6,t._gammaSpace=!1,a._uploadDataToTextureDirectly(t,s.data)})}}});var Tx={};De(Tx,{_DDSTextureLoader:()=>q_});var q_,Sx=A(()=>{Xc();Q_();q_=class{constructor(){this.supportCascades=!0}loadCubeData(e,t,i,r){let s=t.getEngine(),a,o=!1,l=1e3;if(Array.isArray(e))for(let c=0;c1)&&t.generateMipMaps,s._unpackFlipY(a.isCompressed),ln.UploadDDSLevels(s,t,f,a,o,6,-1,c),!a.isFourCC&&a.mipmapCount===1?s.generateMipMapsForCubemap(t):l=a.mipmapCount-1}else{let c=e;a=ln.GetDDSInfo(c),t.width=a.width,t.height=a.height,i&&(a.sphericalPolynomial=new On),o=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&t.generateMipMaps,s._unpackFlipY(a.isCompressed),ln.UploadDDSLevels(s,t,c,a,o,6),!a.isFourCC&&a.mipmapCount===1?s.generateMipMapsForCubemap(t,!1):l=a.mipmapCount-1}s._setCubeMapTextureParams(t,o,l),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r({isDDS:!0,width:t.width,info:a,data:e,texture:t})}loadData(e,t,i){let r=ln.GetDDSInfo(e),s=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&Math.max(r.width,r.height)>>r.mipmapCount-1===1;i(r.width,r.height,s,r.isFourCC,()=>{ln.UploadDDSLevels(t.getEngine(),t,e,r,s,1)})}}});function Ax(){let n={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7:6,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16,cTFFXT1_RGB:17,cTFPVRTC2_4_RGB:18,cTFPVRTC2_4_RGBA:19,cTFETC2_EAC_R11:20,cTFETC2_EAC_RG11:21},e=null;onmessage=a=>{if(a.data.action==="init"){if(a.data.url)try{importScripts(a.data.url)}catch(o){postMessage({action:"error",error:o})}e||(e=BASIS({wasmBinary:a.data.wasmBinary})),e!==null&&e.then(o=>{BASIS=o,o.initializeBasis(),postMessage({action:"init"})})}else if(a.data.action==="transcode"){let o=a.data.config,l=a.data.imageData,c=new BASIS.BasisFile(l),f=i(c),d=a.data.ignoreSupportedFormats?null:t(a.data.config,f),h=!1;d===null&&(h=!0,d=f.hasAlpha?n.cTFBC3:n.cTFBC1);let u=!0;c.startTranscoding()||(u=!1);let m=[];for(let p=0;p>2&3],d[b++]=f[T>>4&3],d[b]=f[T>>6&3]}}return d}}async function Rx(n,e,t){return await new Promise((i,r)=>{let s=a=>{a.data.action==="init"?(n.removeEventListener("message",s),i(n)):a.data.action==="error"&&r(a.data.error||"error initializing worker")};n.addEventListener("message",s),n.postMessage({action:"init",url:t?re.GetBabylonScriptURL(t):void 0,wasmBinary:e},[e])})}var Ix=A(()=>{Tt()});var gs,ga,wV,J_,So,BV,UV,VV,xh,Ih,Ch,$_,xx=A(()=>{Tt();oi();_r();Ix();(function(n){n[n.cTFETC1=0]="cTFETC1",n[n.cTFETC2=1]="cTFETC2",n[n.cTFBC1=2]="cTFBC1",n[n.cTFBC3=3]="cTFBC3",n[n.cTFBC4=4]="cTFBC4",n[n.cTFBC5=5]="cTFBC5",n[n.cTFBC7=6]="cTFBC7",n[n.cTFPVRTC1_4_RGB=8]="cTFPVRTC1_4_RGB",n[n.cTFPVRTC1_4_RGBA=9]="cTFPVRTC1_4_RGBA",n[n.cTFASTC_4x4=10]="cTFASTC_4x4",n[n.cTFATC_RGB=11]="cTFATC_RGB",n[n.cTFATC_RGBA_INTERPOLATED_ALPHA=12]="cTFATC_RGBA_INTERPOLATED_ALPHA",n[n.cTFRGBA32=13]="cTFRGBA32",n[n.cTFRGB565=14]="cTFRGB565",n[n.cTFBGR565=15]="cTFBGR565",n[n.cTFRGBA4444=16]="cTFRGBA4444",n[n.cTFFXT1_RGB=17]="cTFFXT1_RGB",n[n.cTFPVRTC2_4_RGB=18]="cTFPVRTC2_4_RGB",n[n.cTFPVRTC2_4_RGBA=19]="cTFPVRTC2_4_RGBA",n[n.cTFETC2_EAC_R11=20]="cTFETC2_EAC_R11",n[n.cTFETC2_EAC_RG11=21]="cTFETC2_EAC_RG11"})(gs||(gs={}));ga={JSModuleURL:`${re._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,WasmModuleURL:`${re._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`},wV=(n,e)=>{let t;switch(n){case gs.cTFETC1:t=36196;break;case gs.cTFBC1:t=33776;break;case gs.cTFBC4:t=33779;break;case gs.cTFASTC_4x4:t=37808;break;case gs.cTFETC2:t=37496;break;case gs.cTFBC7:t=36492;break}if(t===void 0)throw"The chosen Basis transcoder format is not currently supported";return t},J_=null,So=null,BV=0,UV=!1,VV=async()=>(J_||(J_=new Promise((n,e)=>{So?n(So):re.LoadFileAsync(re.GetBabylonScriptURL(ga.WasmModuleURL)).then(t=>{if(typeof URL!="function")return e("Basis transcoder requires an environment with a URL constructor");let i=URL.createObjectURL(new Blob([`(${Ax})()`],{type:"application/javascript"}));So=new Worker(i),Rx(So,t,ga.JSModuleURL).then(n,e)}).catch(e)})),await J_),xh=async(n,e)=>{let t=n instanceof ArrayBuffer?new Uint8Array(n):n;return await new Promise((i,r)=>{VV().then(()=>{let s=BV++,a=l=>{l.data.action==="transcode"&&l.data.id===s&&(So.removeEventListener("message",a),l.data.success?i(l.data):r("Transcode is not supported on this device"))};So.addEventListener("message",a);let o=new Uint8Array(t.byteLength);o.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),So.postMessage({action:"transcode",id:s,imageData:o,config:e,ignoreSupportedFormats:UV},[o.buffer])},s=>{r(s)})})},Ih=(n,e)=>{var i,r;let t=(i=e._gl)==null?void 0:i.TEXTURE_2D;n.isCube&&(t=(r=e._gl)==null?void 0:r.TEXTURE_CUBE_MAP),e._bindTextureDirectly(t,n,!0)},Ch=(n,e)=>{let t=n.getEngine();for(let i=0;i{t._releaseTexture(s),Ih(n,t)})}else n._invertVScale=!n.invertY,n.width=r.width+3&-4,n.height=r.height+3&-4,n.samplingMode=2,Ih(n,t),t._uploadDataToTextureDirectly(n,new Uint16Array(r.transcodedPixels.buffer),i,0,4,!0);else{n.width=r.width,n.height=r.height,n.generateMipMaps=e.fileInfo.images[i].levels.length>1;let s=$_.GetInternalFormatFromBasisFormat(e.format,t);n.format=s,Ih(n,t);let a=e.fileInfo.images[i].levels;for(let o=0;oeg});var eg,bx=A(()=>{xx();Tt();eg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){if(Array.isArray(e))return;let a=t.getEngine().getCaps(),o={supportedCompressionFormats:{etc1:!!a.etc1,s3tc:!!a.s3tc,pvrtc:!!a.pvrtc,etc2:!!a.etc2,astc:!!a.astc,bc7:!!a.bptc}};xh(e,o).then(l=>{let c=l.fileInfo.images[0].levels.length>1&&t.generateMipMaps;Ch(t,l),t.getEngine()._setCubeMapTextureParams(t,c),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}).catch(l=>{re.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0,s&&s(l)})}loadData(e,t,i){let r=t.getEngine().getCaps(),s={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,astc:!!r.astc,bc7:!!r.bptc}};xh(e,s).then(a=>{let o=a.fileInfo.images[0].levels[0],l=a.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(o.width,o.height,l,a.format!==-1,()=>{Ch(t,a)})}).catch(a=>{re.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),re.Warn(`Failed to transcode Basis file: ${a}`),i(0,0,!1,!1,()=>{},!0)})}}});var nf,Mx=A(()=>{nf=class{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach((t,i)=>this.add(t,i))}get(e){let 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){let 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){let 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(let t in this._data){let i=this._data[t];e(t,i)}}first(e){for(let t in this._data){let i=this._data[t],r=e(t,i);if(r)return r}return null}}});function bh(n){n.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}var tg=A(()=>{});var ui,yx=A(()=>{Qe();qe();et();Kt();tg();ui=class n{constructor(){this._dirty=!0,this._tempColor=new Ne(0,0,0,0),this._globalCurve=new Ne(0,0,0,0),this._highlightsCurve=new Ne(0,0,0,0),this._midtonesCurve=new Ne(0,0,0,0),this._shadowsCurve=new Ne(0,0,0,0),this._positiveCurve=new Ne(0,0,0,0),this._negativeCurve=new Ne(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",r="vCameraColorCurveNeutral",s="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(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(s,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,r,s){e!=null&&(e=n._Clamp(e,0,360),t=n._Clamp(t,-100,100),i=n._Clamp(i,-100,100),r=n._Clamp(r,-100,100),t=n._ApplyColorGradingSliderNonlinear(t),t*=.5,r=n._ApplyColorGradingSliderNonlinear(r),t<0&&(t*=-1,e=(e+180)%360),n._FromHSBToRef(e,t,50+.25*r,s),s.scaleToRef(2,s),s.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,r){let s=n._Clamp(e,0,360),a=n._Clamp(t/100,0,1),o=n._Clamp(i/100,0,1);if(a===0)r.r=o,r.g=o,r.b=o;else{s/=60;let l=Math.floor(s),c=s-l,f=o*(1-a),d=o*(1-a*c),h=o*(1-a*(1-c));switch(l){case 0:r.r=o,r.g=h,r.b=f;break;case 1:r.r=d,r.g=o,r.b=f;break;case 2:r.r=f,r.g=o,r.b=h;break;case 3:r.r=f,r.g=d,r.b=o;break;case 4:r.r=h,r.g=f,r.b=o;break;default:r.r=o,r.g=f,r.b=d;break}}r.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return Me.Clone(()=>new n,this)}serialize(){return Me.Serialize(this)}static Parse(e){return Me.Parse(()=>new n,e,null,null)}};ui.PrepareUniforms=bh;C([D()],ui.prototype,"_globalHue",void 0);C([D()],ui.prototype,"_globalDensity",void 0);C([D()],ui.prototype,"_globalSaturation",void 0);C([D()],ui.prototype,"_globalExposure",void 0);C([D()],ui.prototype,"_highlightsHue",void 0);C([D()],ui.prototype,"_highlightsDensity",void 0);C([D()],ui.prototype,"_highlightsSaturation",void 0);C([D()],ui.prototype,"_highlightsExposure",void 0);C([D()],ui.prototype,"_midtonesHue",void 0);C([D()],ui.prototype,"_midtonesDensity",void 0);C([D()],ui.prototype,"_midtonesSaturation",void 0);C([D()],ui.prototype,"_midtonesExposure",void 0);Me._ColorCurvesParser=ui.Parse});function Dx(n,e){e.EXPOSURE&&n.push("exposureLinear"),e.CONTRAST&&n.push("contrast"),e.COLORGRADING&&n.push("colorTransformSettings"),(e.VIGNETTE||e.DITHER)&&n.push("vInverseScreenSize"),e.VIGNETTE&&(n.push("vignetteSettings1"),n.push("vignetteSettings2")),e.COLORCURVES&&bh(n),e.DITHER&&n.push("ditherIntensity")}function Lx(n,e){e.COLORGRADING&&n.push("txColorTransform")}var Px=A(()=>{tg()});var Je,sf=A(()=>{Qe();qe();ct();et();yx();Dn();Kt();Px();Lt();Je=class n{constructor(){this.colorCurves=new ui,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=n.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new Ne(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=n.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.outputTextureWidth=0,this.outputTextureHeight=0,this.onUpdateParameters=new Y}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===n._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case n.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case n.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&&ui.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){let i=1/(this.outputTextureWidth||e.getEngine().getRenderWidth()),r=1/(this.outputTextureHeight||e.getEngine().getRenderHeight());if(e.setFloat2("vInverseScreenSize",i,r),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){let s=t!=null?t:r/i,a=Math.tan(this.vignetteCameraFov*.5),o=a*s,l=Math.sqrt(o*a);o=kc(o,l,this.vignetteStretch),a=kc(a,l,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,a,-o*this.vignetteCenterX,-a*this.vignetteCenterY);let c=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,c)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);let i=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(i-1)/i,.5/i,i,this.colorGradingTexture.level)}}clone(){return Me.Clone(()=>new n,this)}serialize(){return Me.Serialize(this)}static Parse(e){let t=Me.Parse(()=>new n,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}};Je.TONEMAPPING_STANDARD=0;Je.TONEMAPPING_ACES=1;Je.TONEMAPPING_KHR_PBR_NEUTRAL=2;Je.PrepareUniforms=Dx;Je.PrepareSamplers=Lx;Je._VIGNETTEMODE_MULTIPLY=0;Je._VIGNETTEMODE_OPAQUE=1;C([MI()],Je.prototype,"colorCurves",void 0);C([D()],Je.prototype,"_colorCurvesEnabled",void 0);C([Ze("colorGradingTexture")],Je.prototype,"_colorGradingTexture",void 0);C([D()],Je.prototype,"_colorGradingEnabled",void 0);C([D()],Je.prototype,"_colorGradingWithGreenDepth",void 0);C([D()],Je.prototype,"_colorGradingBGR",void 0);C([D()],Je.prototype,"_exposure",void 0);C([D()],Je.prototype,"_toneMappingEnabled",void 0);C([D()],Je.prototype,"_toneMappingType",void 0);C([D()],Je.prototype,"_contrast",void 0);C([D()],Je.prototype,"vignetteStretch",void 0);C([D()],Je.prototype,"vignetteCenterX",void 0);C([D()],Je.prototype,"vignetteCenterY",void 0);C([D()],Je.prototype,"vignetteWeight",void 0);C([ul()],Je.prototype,"vignetteColor",void 0);C([D()],Je.prototype,"vignetteCameraFov",void 0);C([D()],Je.prototype,"_vignetteBlendMode",void 0);C([D()],Je.prototype,"_vignetteEnabled",void 0);C([D()],Je.prototype,"_ditheringEnabled",void 0);C([D()],Je.prototype,"_ditheringIntensity",void 0);C([D()],Je.prototype,"_skipFinalColorClamp",void 0);C([D()],Je.prototype,"_applyByPostProcess",void 0);C([D()],Je.prototype,"_isEnabled",void 0);C([D()],Je.prototype,"outputTextureWidth",void 0);C([D()],Je.prototype,"outputTextureHeight",void 0);Me._ImageProcessingConfigurationParser=Je.Parse;je("BABYLON.ImageProcessingConfiguration",Je)});var cn,af=A(()=>{ve();yt();cn=class{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(M.NormalKind))return null;let i=this.pickedMesh.getIndices();(i==null?void 0:i.length)===0&&(i=null);let r,s=k.Vector3[0],a=k.Vector3[1],o=k.Vector3[2];if(t){let c=this.pickedMesh.getVerticesData(M.NormalKind),f=i?v.FromArrayToRef(c,i[this.faceId*3]*3,s):s.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),d=i?v.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),h=i?v.FromArrayToRef(c,i[this.faceId*3+2]*3,o):o.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]);f=f.scale(this.bu),d=d.scale(this.bv),h=h.scale(1-this.bu-this.bv),r=new v(f.x+d.x+h.x,f.y+d.y+h.y,f.z+d.z+h.z)}else{let c=this.pickedMesh.getVerticesData(M.PositionKind),f=i?v.FromArrayToRef(c,i[this.faceId*3]*3,s):s.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),d=i?v.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),h=i?v.FromArrayToRef(c,i[this.faceId*3+2]*3,o):o.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]),u=f.subtract(d),m=h.subtract(d);r=v.Cross(u,m)}let l=(c,f)=>{if(this.thinInstanceIndex!==-1){let h=c._thinInstanceDataStorage.matrixData,u=this.thinInstanceIndex<<4;if(h&&h.length>u){let m=k.Matrix[0];G.FromArrayToRef(h,u,m),v.TransformNormalToRef(f,m,f)}}let d=c.getWorldMatrix();c.nonUniformScaling&&(k.Matrix[0].copyFrom(d),d=k.Matrix[0],d.setTranslationFromFloats(0,0,0),d.invert(),d.transposeToRef(k.Matrix[1]),d=k.Matrix[1]),v.TransformNormalToRef(f,d,f)};if(e&&l(this.pickedMesh,r),this.ray){let c=k.Vector3[0].copyFrom(r);e||l(this.pickedMesh,c),v.Dot(c,this.ray.direction)>0&&r.negateInPlace()}return r.normalize(),r}getTextureCoordinates(e=M.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;let t=this.pickedMesh.getIndices();if(!t)return null;let i=this.pickedMesh.getVerticesData(e);if(!i)return null;let r=_e.FromArray(i,t[this.faceId*3]*2),s=_e.FromArray(i,t[this.faceId*3+1]*2),a=_e.FromArray(i,t[this.faceId*3+2]*2);return r=r.scale(this.bu),s=s.scale(this.bv),a=a.scale(1-this.bu-this.bv),new _e(r.x+s.x+a.x,r.y+s.y+a.y)}}});var mi,ig=A(()=>{mi=class n{constructor(e,t,i,r,s,a){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=s,this.additionalData=a}static CreateNew(e,t,i){let r=e.getScene();return new n(e,r.pointerX,r.pointerY,r.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,r){return new n(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,r)}static CreateNewFromScene(e,t){return new n(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,r){return new n(e,t.x,t.y,null,i,r)}}});function of(n,e,t){let i=t.asArray(),r=e.asArray();for(let s=0;s<16;s++)i[s]=r[s];return i[12]-=n.x,i[13]-=n.y,i[14]-=n.z,t.markAsUpdated(),t}function wx(n,e,t){return Hc(e,Fr),of(n,Fr,wr),Hc(wr,t),t}function Mh(n,e,t){if(!Br.eyeAtCamera)return wx(n,e,t);let i=t.asArray(),r=e.asArray();for(let s=0;s<16;s++)i[s]=r[s];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function rg(n,e,t,i){return lo(Mh(n,e,i),t,i),i}function Bx(n,e,t,i,r){for(let s=0;s{no();ve();E_();ma();Nr=new G,Fr=new G,wr=new G,Br={getScene:()=>{},eyeAtCamera:!0};lf=Ut,ng=Nt,Ux=lf.prototype._updateMatrixForUniform,Vx=Nt.prototype.setMatrix});var be,wt,El=A(()=>{be=class{};be.NAME_EFFECTLAYER="EffectLayer";be.NAME_LAYER="Layer";be.NAME_LENSFLARESYSTEM="LensFlareSystem";be.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";be.NAME_PARTICLESYSTEM="ParticleSystem";be.NAME_GAMEPAD="Gamepad";be.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";be.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";be.NAME_PREPASSRENDERER="PrePassRenderer";be.NAME_DEPTHRENDERER="DepthRenderer";be.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";be.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";be.NAME_SPRITE="Sprite";be.NAME_SUBSURFACE="SubSurface";be.NAME_OUTLINERENDERER="Outline";be.NAME_PROCEDURALTEXTURE="ProceduralTexture";be.NAME_SHADOWGENERATOR="ShadowGenerator";be.NAME_OCTREE="Octree";be.NAME_PHYSICSENGINE="PhysicsEngine";be.NAME_AUDIO="Audio";be.NAME_FLUIDRENDERER="FluidRenderer";be.NAME_IBLCDFGENERATOR="iblCDFGenerator";be.NAME_CLUSTEREDLIGHTING="ClusteredLighting";be.STEP_ISREADYFORMESH_EFFECTLAYER=0;be.STEP_ISREADYFORMESH_DEPTHRENDERER=1;be.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;be.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;be.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;be.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;be.STEP_BEFORECAMERADRAW_PREPASS=0;be.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;be.STEP_BEFORECAMERADRAW_LAYER=2;be.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;be.STEP_BEFORERENDERTARGETDRAW_LAYER=1;be.STEP_BEFORERENDERINGMESH_PREPASS=0;be.STEP_BEFORERENDERINGMESH_OUTLINE=1;be.STEP_AFTERRENDERINGMESH_PREPASS=0;be.STEP_AFTERRENDERINGMESH_OUTLINE=1;be.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;be.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;be.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;be.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;be.STEP_BEFORECLEAR_PREPASS=1;be.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;be.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;be.STEP_AFTERRENDERTARGETDRAW_LAYER=1;be.STEP_AFTERCAMERADRAW_PREPASS=0;be.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;be.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;be.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;be.STEP_AFTERCAMERADRAW_LAYER=4;be.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;be.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;be.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;be.STEP_AFTERRENDER_AUDIO=0;be.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;be.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;be.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;be.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;be.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;be.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;be.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;be.STEP_POINTERMOVE_SPRITE=0;be.STEP_POINTERDOWN_SPRITE=0;be.STEP_POINTERUP_SPRITE=0;wt=class n extends Array{constructor(e){super(...e)}static Create(){return Object.create(n.prototype)}registerStep(e,t,i){let r=0,s;for(;r{ve();ye=class{};ye.POINTERDOWN=1;ye.POINTERUP=2;ye.POINTERMOVE=4;ye.POINTERWHEEL=8;ye.POINTERPICK=16;ye.POINTERTAP=32;ye.POINTERDOUBLETAP=64;yh=class{constructor(e,t){this.type=e,this.event=t}},Dh=class extends yh{constructor(e,t,i,r){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new _e(i,r)}},Ur=class extends yh{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,i,r=null){super(e,t),this._pickInfo=i,this._inputManager=r}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}});var Es,Wx=A(()=>{Es=class n{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(let e in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(let e in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,e)){let t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(let t in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,t)&&parseInt(t)===e)return!0;return!1}};Es.Triggers={}});var dn,vl,ff,Lh=A(()=>{dn=class{};dn.KEYDOWN=1;dn.KEYUP=2;vl=class{constructor(e,t){this.type=e,this.event=t}},ff=class extends vl{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 Ce,Ve,Hx,zx,Xx,Yx,Kx,Ao=A(()=>{(function(n){n[n.Generic=0]="Generic",n[n.Keyboard=1]="Keyboard",n[n.Mouse=2]="Mouse",n[n.Touch=3]="Touch",n[n.DualShock=4]="DualShock",n[n.Xbox=5]="Xbox",n[n.Switch=6]="Switch",n[n.DualSense=7]="DualSense"})(Ce||(Ce={}));(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.Move=12]="Move"})(Ve||(Ve={}));(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.DeltaHorizontal=10]="DeltaHorizontal",n[n.DeltaVertical=11]="DeltaVertical"})(Hx||(Hx={}));(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Share=8]="Share",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(zx||(zx={}));(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Create=8]="Create",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(Xx||(Xx={}));(function(n){n[n.A=0]="A",n[n.B=1]="B",n[n.X=2]="X",n[n.Y=3]="Y",n[n.LB=4]="LB",n[n.RB=5]="RB",n[n.LT=6]="LT",n[n.RT=7]="RT",n[n.Back=8]="Back",n[n.Start=9]="Start",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.LStickXAxis=17]="LStickXAxis",n[n.LStickYAxis=18]="LStickYAxis",n[n.RStickXAxis=19]="RStickXAxis",n[n.RStickYAxis=20]="RStickYAxis"})(Yx||(Yx={}));(function(n){n[n.B=0]="B",n[n.A=1]="A",n[n.Y=2]="Y",n[n.X=3]="X",n[n.L=4]="L",n[n.R=5]="R",n[n.ZL=6]="ZL",n[n.ZR=7]="ZR",n[n.Minus=8]="Minus",n[n.Plus=9]="Plus",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.Capture=17]="Capture",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(Kx||(Kx={}))});var jx,hn,Ph=A(()=>{(function(n){n[n.PointerMove=0]="PointerMove",n[n.PointerDown=1]="PointerDown",n[n.PointerUp=2]="PointerUp"})(jx||(jx={}));hn=class{};hn.DOM_DELTA_PIXEL=0;hn.DOM_DELTA_LINE=1;hn.DOM_DELTA_PAGE=2});var un,ag=A(()=>{Ph();Ao();un=class{static CreateDeviceEvent(e,t,i,r,s,a,o){switch(e){case Ce.Keyboard:return this._CreateKeyboardEvent(i,r,s,a);case Ce.Mouse:if(i===Ve.MouseWheelX||i===Ve.MouseWheelY||i===Ve.MouseWheelZ)return this._CreateWheelEvent(e,t,i,r,s,a);case Ce.Touch:return this._CreatePointerEvent(e,t,i,r,s,a,o);default:throw`Unable to generate event for device ${Ce[e]}`}}static _CreatePointerEvent(e,t,i,r,s,a,o){let l=this._CreateMouseEvent(e,t,i,r,s,a);e===Ce.Mouse?(l.deviceType=Ce.Mouse,l.pointerId=1,l.pointerType="mouse"):(l.deviceType=Ce.Touch,l.pointerId=o!=null?o:t,l.pointerType="touch");let c=0;return c+=s.pollInput(e,t,Ve.LeftClick),c+=s.pollInput(e,t,Ve.RightClick)*2,c+=s.pollInput(e,t,Ve.MiddleClick)*4,l.buttons=c,i===Ve.Move?l.type="pointermove":i>=Ve.LeftClick&&i<=Ve.RightClick&&(l.type=r===1?"pointerdown":"pointerup",l.button=i-2),l}static _CreateWheelEvent(e,t,i,r,s,a){let o=this._CreateMouseEvent(e,t,i,r,s,a);switch(o.pointerId=1,o.type="wheel",o.deltaMode=hn.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case Ve.MouseWheelX:o.deltaX=r;break;case Ve.MouseWheelY:o.deltaY=r;break;case Ve.MouseWheelZ:o.deltaZ=r;break}return o}static _CreateMouseEvent(e,t,i,r,s,a){let o=this._CreateEvent(a),l=s.pollInput(e,t,Ve.Horizontal),c=s.pollInput(e,t,Ve.Vertical);return a?(o.movementX=0,o.movementY=0,o.offsetX=o.movementX-a.getBoundingClientRect().x,o.offsetY=o.movementY-a.getBoundingClientRect().y):(o.movementX=s.pollInput(e,t,10),o.movementY=s.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,s),o.clientX=l,o.clientY=c,o.x=l,o.y=c,o.deviceType=e,o.deviceSlot=t,o.inputIndex=i,o}static _CreateKeyboardEvent(e,t,i,r){let s=this._CreateEvent(r);return this._CheckNonCharacterKeys(s,i),s.deviceType=Ce.Keyboard,s.deviceSlot=0,s.inputIndex=e,s.type=t===1?"keydown":"keyup",s.key=String.fromCharCode(e),s.keyCode=e,s}static _CheckNonCharacterKeys(e,t){let i=t.isDeviceAvailable(Ce.Keyboard),r=i&&t.pollInput(Ce.Keyboard,0,18)===1,s=i&&t.pollInput(Ce.Keyboard,0,17)===1,a=i&&(t.pollInput(Ce.Keyboard,0,91)===1||t.pollInput(Ce.Keyboard,0,92)===1||t.pollInput(Ce.Keyboard,0,93)===1),o=i&&t.pollInput(Ce.Keyboard,0,16)===1;e.altKey=r,e.ctrlKey=s,e.metaKey=a,e.shiftKey=o}static _CreateEvent(e){let t={};return t.preventDefault=()=>{},t.target=e,t}}});var Oh,Zx=A(()=>{ag();Ao();Oh=class{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(r,s,a,o)=>{let l=un.CreateDeviceEvent(r,s,a,o,this);i(r,s,l)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===Ce.Mouse||e===Ce.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}});var qx,Qx,Nh,Jx=A(()=>{yr();Tt();ag();Ao();qx=255,Qx=Object.keys(Ve).length/2,Nh=class{constructor(e,t,i,r){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=re.IsSafari(),this._usingMacOs=is()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=s=>{},this._keyboardUpEvent=s=>{},this._keyboardBlurEvent=s=>{},this._pointerMoveEvent=s=>{},this._pointerDownEvent=s=>{},this._pointerUpEvent=s=>{},this._pointerCancelEvent=s=>{},this._pointerCancelTouch=s=>{},this._pointerLeaveEvent=s=>{},this._pointerWheelEvent=s=>{},this._pointerBlurEvent=s=>{},this._pointerMacOsChromeOutEvent=s=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=is()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=is()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=s=>{},this._gamepadDisconnectedEvent=s=>{},this._eventPrefix=re.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=r,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOs&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,i){let r=this._inputs[e][t];if(!r)throw`Unable to find device ${Ce[e]}`;e>=Ce.DualShock&&e<=Ce.DualSense&&this._updateDevice(e,t,i);let s=r[i];if(s===void 0)throw`Unable to find input ${i} for device ${Ce[e]} in slot ${t}`;return i===Ve.Move&&re.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),s}isDeviceAvailable(e){return this._inputs[e]!==void 0}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){let e=this==null?void 0:this._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs){for(let t of this._inputs)if(t)for(let i in t){let r=+i,s=t[r];if(s)for(let a=0;a{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Ce.Keyboard,0,qx));let t=this._inputs[Ce.Keyboard][0];if(t){t[e.keyCode]=1;let 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(Ce.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Ce.Keyboard,0,qx));let t=this._inputs[Ce.Keyboard][0];if(t){t[e.keyCode]=0;let i=e;if(i.inputIndex=e.keyCode,this._usingMacOs&&e.key==="Meta"&&this._metaKeys.length>0){for(let r of this._metaKeys){let s=un.CreateDeviceEvent(Ce.Keyboard,0,r,0,this,this._elementToAttachTo);t[r]=0,this._onInputChanged(Ce.Keyboard,0,s)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(Ce.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){let e=this._inputs[Ce.Keyboard][0];for(let t=0;t{let r=this._getPointerType(i),s=r===Ce.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===Ce.Touch&&s===-1){let o=this._activeTouchIds.indexOf(-1);if(o>=0)s=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(r,s);else{re.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][s]||this._addPointerDevice(r,s,i.clientX,i.clientY);let a=this._inputs[r][s];if(a){let o=i;o.inputIndex=Ve.Move,a[Ve.Horizontal]=i.clientX,a[Ve.Vertical]=i.clientY,r===Ce.Touch&&a[Ve.LeftClick]===0&&(a[Ve.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(r,s,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,a[i.button+2]=a[i.button+2]?0:1,this._onInputChanged(r,s,o))}},this._pointerDownEvent=i=>{let r=this._getPointerType(i),s=r===Ce.Mouse?0:i.pointerId;if(r===Ce.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)s=o,this._activeTouchIds[o]=i.pointerId;else{re.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][s]?r===Ce.Touch&&this._onDeviceConnected(r,s):this._addPointerDevice(r,s,i.clientX,i.clientY);let a=this._inputs[r][s];if(a){let o=a[Ve.Horizontal],l=a[Ve.Vertical];if(r===Ce.Mouse){if(i.pointerId===void 0&&(i.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch(f){}}else if(i.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(i.pointerId)}catch(f){}a[Ve.Horizontal]=i.clientX,a[Ve.Vertical]=i.clientY,a[i.button+2]=1;let c=i;c.inputIndex=i.button+2,this._onInputChanged(r,s,c),(o!==i.clientX||l!==i.clientY)&&(c.inputIndex=Ve.Move,this._onInputChanged(r,s,c))}},this._pointerUpEvent=i=>{var c,f,d,h,u;let r=this._getPointerType(i),s=r===Ce.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===Ce.Touch){if(s===-1)return;this._activeTouchIds[s]=-1}let a=(c=this._inputs[r])==null?void 0:c[s],o=i.button,l=a&&a[o+2]!==0;if(!l&&this._isUsingFirefox&&this._usingMacOs&&a&&(o=o===2?0:2,l=a[o+2]!==0),l){let m=a[Ve.Horizontal],p=a[Ve.Vertical];a[Ve.Horizontal]=i.clientX,a[Ve.Vertical]=i.clientY,a[o+2]=0;let _=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),(m!==i.clientX||p!==i.clientY)&&(_.inputIndex=Ve.Move,this._onInputChanged(r,s,_)),_.inputIndex=o+2,r===Ce.Mouse&&this._mouseId>=0&&((d=(f=this._elementToAttachTo).hasPointerCapture)!=null&&d.call(f,this._mouseId))?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&((u=(h=this._elementToAttachTo).hasPointerCapture)!=null&&u.call(h,i.pointerId))&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(r,s,_),r===Ce.Touch&&this._onDeviceDisconnected(r,s)}},this._pointerCancelTouch=i=>{var a,o;let r=this._activeTouchIds.indexOf(i);if(r===-1)return;(o=(a=this._elementToAttachTo).hasPointerCapture)!=null&&o.call(a,i)&&this._elementToAttachTo.releasePointerCapture(i),this._inputs[Ce.Touch][r][Ve.LeftClick]=0;let s=un.CreateDeviceEvent(Ce.Touch,r,Ve.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(Ce.Touch,r,s),this._activeTouchIds[r]=-1,this._onDeviceDisconnected(Ce.Touch,r)},this._pointerCancelEvent=i=>{var r,s;if(i.pointerType==="mouse"){let a=this._inputs[Ce.Mouse][0];this._mouseId>=0&&((s=(r=this._elementToAttachTo).hasPointerCapture)!=null&&s.call(r,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let o=Ve.LeftClick;o<=Ve.BrowserForward;o++)if(a[o]===1){a[o]=0;let l=un.CreateDeviceEvent(Ce.Mouse,0,o,0,this,this._elementToAttachTo);this._onInputChanged(Ce.Mouse,0,l)}}else this._pointerCancelTouch(i.pointerId)},this._pointerLeaveEvent=i=>{i.pointerType==="pen"&&this._pointerCancelTouch(i.pointerId)},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let e=!1,t=function(){};try{let i=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,i),this._elementToAttachTo.removeEventListener("test",t,i)}catch(i){}this._pointerBlurEvent=()=>{var i,r,s,a,o;if(this.isDeviceAvailable(Ce.Mouse)){let l=this._inputs[Ce.Mouse][0];this._mouseId>=0&&((r=(i=this._elementToAttachTo).hasPointerCapture)!=null&&r.call(i,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let c=Ve.LeftClick;c<=Ve.BrowserForward;c++)if(l[c]===1){l[c]=0;let f=un.CreateDeviceEvent(Ce.Mouse,0,c,0,this,this._elementToAttachTo);this._onInputChanged(Ce.Mouse,0,f)}}if(this.isDeviceAvailable(Ce.Touch)){let l=this._inputs[Ce.Touch];for(let c=0;c{let r=Ce.Mouse,s=0;this._inputs[r]||(this._inputs[r]=[]),this._inputs[r][s]||(this._pointerActive=!0,this._registerDevice(r,s,Qx));let a=this._inputs[r][s];if(a){a[Ve.MouseWheelX]=i.deltaX||0,a[Ve.MouseWheelY]=i.deltaY||i.wheelDelta||0,a[Ve.MouseWheelZ]=i.deltaZ||0;let o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),a[Ve.MouseWheelX]!==0&&(o.inputIndex=Ve.MouseWheelX,this._onInputChanged(r,s,o)),a[Ve.MouseWheelY]!==0&&(o.inputIndex=Ve.MouseWheelY,this._onInputChanged(r,s,o)),a[Ve.MouseWheelZ]!==0&&(o.inputIndex=Ve.MouseWheelZ,this._onInputChanged(r,s,o))}},this._usingMacOs&&this._isUsingChromium&&(this._pointerMacOsChromeOutEvent=i=>{i.buttons>1&&this._pointerCancelEvent(i)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,e?{passive:!1}:!1),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(()=>{if(this.isDeviceAvailable(Ce.Mouse)){let i=this._inputs[Ce.Mouse][0];i[Ve.MouseWheelX]=0,i[Ve.MouseWheelY]=0,i[Ve.MouseWheelZ]=0}})}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){let 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){let r=navigator.getGamepads()[t];if(r&&e===this._gamepads[t]){let s=this._inputs[e][t];i>=r.buttons.length?s[i]=r.axes[i-r.buttons.length].valueOf():s[i]=r.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?Ce.DualSense:Ce.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?Ce.Xbox:e.indexOf("057e")!==-1?Ce.Switch:Ce.Generic}_getPointerType(e){let t=Ce.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=Ce.Touch),t}}});var df,$x=A(()=>{ct();df=class{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new Y,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}});var Fh,eC=A(()=>{Ao();Zx();Jx();$x();Fh=class{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=a=>{for(let o=0;o{let o=this._registeredManagers.indexOf(a);o>-1&&this._registeredManagers.splice(o,1)};let t=Object.keys(Ce).length/2;this._devices=new Array(t);let i=(a,o)=>{this._devices[a]||(this._devices[a]=new Array),this._devices[a][o]||(this._devices[a][o]=o);for(let l of this._registeredManagers){let c=new df(this._deviceInputSystem,a,o);l._addDevice(c)}},r=(a,o)=>{var l;(l=this._devices[a])!=null&&l[o]&&delete this._devices[a][o];for(let c of this._registeredManagers)c._removeDevice(a,o)},s=(a,o,l)=>{if(l)for(let c of this._registeredManagers)c._onInputChanged(a,o,l)};typeof _native!="undefined"?this._deviceInputSystem=new Oh(i,r,s):this._deviceInputSystem=new Nh(e,i,r,s)}dispose(){this._deviceInputSystem.dispose()}}});var wh,tC=A(()=>{Ao();ct();eC();wh=class{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){let t=Object.keys(Ce).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new Fh(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new Y(i=>{for(let r of this._devices)if(r)for(let s of r)s&&this.onDeviceConnectedObservable.notifyObserver(i,s)}),this.onDeviceDisconnectedObservable=new Y,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add(()=>{this.dispose()})}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=[]),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){var r,s;let i=(r=this._devices[e])==null?void 0:r[t];this.onDeviceDisconnectedObservable.notifyObservers(i),(s=this._devices[e])!=null&&s[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){var r,s;(s=(r=this._devices[e])==null?void 0:r[t])==null||s.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case Ce.Keyboard:case Ce.Mouse:this._firstDevice[e]=0;break;case Ce.Touch:case Ce.DualSense:case Ce.DualShock:case Ce.Xbox:case Ce.Switch:case Ce.Generic:{delete this._firstDevice[e];let t=this._devices[e];if(t){for(let i=0;i{Tl=class{};Tl._IsPickingAvailable=!1});var Bh,Mi,iC=A(()=>{fn();Wx();af();ve();ig();Lh();Ao();tC();At();og();Bh=class{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}},Mi=class n{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 _e(0,0),this._previousStartingPointerPosition=new _e(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||ue.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 _e(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){let 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){let i=this._scene,r=i.getEngine(),s=r.getInputElement();s&&(s.tabIndex=r.canvasTabIndex,i.doNotHandleCursors||(s.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(let l of i._pointerMoveStage){e=e||this._pickMove(t);let c=!!(e!=null&&e.pickedMesh);e=l.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,c,s)}let a=t.inputIndex>=Ve.MouseWheelX&&t.inputIndex<=Ve.MouseWheelZ?ye.POINTERWHEEL:ye.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,a));let o;e?(o=new Ur(a,t,e),this._setRayOnPointerInfo(e,t)):(o=new Ur(a,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,a)}_setRayOnPointerInfo(e,t){let i=this._scene;e&&Tl._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,G.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){let r=this._scene,s=new Dh(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(s.originalPickingInfo=e,s.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(s.nearInteractionPickingInfo=e)),r.onPrePointerObservable.notifyObservers(s,i),!!s.skipOnPointerObservable}_pickMove(e){let 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){let s=i.getEngine().getInputElement();if(e!=null&&e.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&s&&this._pointerOverMesh){let a=this._pointerOverMesh._getActionManagerForTrigger();a&&a.hasPointerTriggers&&(s.style.cursor=a.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){let i=new PointerEvent("pointermove",t);i.inputIndex=Ve.Move,!this._checkPrePointerObservable(e,i,ye.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){let i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,ye.POINTERDOWN)&&this._processPointerDown(e,i)}_processPointerDown(e,t){let i=this._scene;if(e!=null&&e.pickedMesh){this._pickedDownMesh=e.pickedMesh;let a=e.pickedMesh._getActionManagerForTrigger();if(a){if(a.hasPickTriggers)switch(a.processTrigger(5,new mi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:a.processTrigger(2,new mi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:a.processTrigger(4,new mi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:a.processTrigger(3,new mi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break}a.hasSpecificTrigger(8)&&window.setTimeout(()=>{let o=i.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,l=>l.isPickable&&l.isVisible&&l.isReady()&&l.actionManager&&l.actionManager.hasSpecificTrigger(8)&&l===this._pickedDownMesh,!1,i.cameraToUseForPointers);o!=null&&o.pickedMesh&&a&&this._activePointerIdsCount!==0&&Date.now()-this._startingPointerTime>n.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,a.processTrigger(8,mi.CreateNew(o.pickedMesh,t)))},n.LongPressDelay)}}else for(let a of i._pointerDownStage)e=a.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let r,s=ye.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,s),r=new Ur(s,t,e),this._setRayOnPointerInfo(e,t)):r=new Ur(s,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(r,s)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){let r=new PointerEvent("pointerup",t);r.inputIndex=Ve.Move;let s=new Bh;i?s.doubleClick=!0:s.singleClick=!0,!this._checkPrePointerObservable(e,r,ye.POINTERUP)&&this._processPointerUp(e,r,s)}_processPointerUp(e,t,i){let r=this._scene;if(e!=null&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(r.onPointerPick&&r.onPointerPick(t,e),i.singleClick&&!i.ignore&&r.onPointerObservable.observers.length>this._cameraObserverCount)){let a=ye.POINTERPICK,o=new Ur(a,t,e);this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(o,a)}let s=e.pickedMesh._getActionManagerForTrigger();if(s&&!i.ignore){s.processTrigger(7,mi.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&s.processTrigger(1,mi.CreateNew(e.pickedMesh,t,e));let a=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&a&&a.processTrigger(6,mi.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(let s of r._pointerUpStage)e=s.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){let s=this._pickedDownMesh._getActionManagerForTrigger(16);s&&s.processTrigger(16,mi.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){let s=new Ur(ye.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(s,ye.POINTERUP),r.onPointerUp&&r.onPointerUp(t,e,ye.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let a=0;if(i.singleClick?a=ye.POINTERTAP:i.doubleClick&&(a=ye.POINTERDOUBLETAP),a){let o=new Ur(a,t,e);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(a)&&r.onPointerObservable.notifyObservers(o,a)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,r=null){let s=this._scene,a=s.getEngine();r||(r=a.getInputElement()),this._alreadyAttached&&this.detachControl(),r&&(this._alreadyAttachedTo=r),this._deviceSourceManager=new wh(a),this._initActionManager=o=>{if(!this._meshPickProceed){let l=s.skipPointerUpPicking||s._registeredActions===0&&!this._checkForPicking()&&!s.onPointerUp?null:s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,s.pointerUpPredicate,s.pointerUpFastCheck,s.cameraToUseForPointers,s.pointerUpTrianglePredicate);this._currentPickResult=l,l&&(o=l.hit&&l.pickedMesh?l.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return o},this._delayedSimpleClick=(o,l,c)=>{if((Date.now()-this._previousStartingPointerTime>n.DoubleClickDelay&&!this._doubleClickOccured||o!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,l.singleClick=!0,l.ignore=!1,this._delayedClicks[o])){let f=this._delayedClicks[o].evt,d=ye.POINTERTAP,h=new Ur(d,f,this._currentPickResult);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(d)&&s.onPointerObservable.notifyObservers(h,d),this._delayedClicks[o]=null}},this._initClickEvent=(o,l,c,f)=>{var p,_;let d=new Bh;this._currentPickResult=null;let h=null,u=o.hasSpecificMask(ye.POINTERPICK)||l.hasSpecificMask(ye.POINTERPICK)||o.hasSpecificMask(ye.POINTERTAP)||l.hasSpecificMask(ye.POINTERTAP)||o.hasSpecificMask(ye.POINTERDOUBLETAP)||l.hasSpecificMask(ye.POINTERDOUBLETAP);!u&&Es&&(h=this._initActionManager(h,d),h&&(u=h.hasPickTriggers));let m=!1;if(u=u&&!this._isMultiTouchGesture,u){let g=c.button;if(d.hasSwiped=this._isPointerSwiping(),!d.hasSwiped){let T=!n.ExclusiveDoubleClickMode;if(T||(T=!o.hasSpecificMask(ye.POINTERDOUBLETAP)&&!l.hasSpecificMask(ye.POINTERDOUBLETAP),T&&!Es.HasSpecificTrigger(6)&&(h=this._initActionManager(h,d),h&&(T=!h.hasSpecificTrigger(6)))),T)(Date.now()-this._previousStartingPointerTime>n.DoubleClickDelay||g!==this._previousButtonPressed)&&(d.singleClick=!0,f(d,this._currentPickResult),m=!0);else{let R={evt:c,clickInfo:d,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,g,d,f),n.DoubleClickDelay)};this._delayedClicks[g]=R}let b=o.hasSpecificMask(ye.POINTERDOUBLETAP)||l.hasSpecificMask(ye.POINTERDOUBLETAP);!b&&Es.HasSpecificTrigger(6)&&(h=this._initActionManager(h,d),h&&(b=h.hasSpecificTrigger(6))),b&&(g===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime{if(this._updatePointerPosition(o),!this._isSwiping&&this._swipeButtonPressed!==-1&&(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>n.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>n.DragMovementThreshold),a.isPointerLock&&a._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=Ve.MouseWheelX&&o.inputIndex<=Ve.MouseWheelZ?ye.POINTERWHEEL:ye.POINTERMOVE)||!s.cameraToUseForPointers&&!s.activeCamera)return;if(s.skipPointerMovePicking){this._processPointerMove(new cn,o);return}s.pointerMovePredicate||(s.pointerMovePredicate=c=>c.isPickable&&c.isVisible&&c.isReady()&&c.isEnabled()&&(c.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||c._getActionManagerForTrigger()!==null)&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&c.layerMask)!==0));let l=s._registeredActions>0||s.constantlyUpdateMeshUnderPointer?this._pickMove(o):null;this._processPointerMove(l,o)},this._onPointerDown=o=>{var f;let l=this._activePointerIds.indexOf(-1);if(l===-1?this._activePointerIds.push(o.pointerId):this._activePointerIds[l]=o.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,n.ExclusiveDoubleClickMode){for(let d=0;dd.isPickable&&d.isVisible&&d.isReady()&&d.isEnabled()&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&d.layerMask)!==0)),this._pickedDownMesh=null;let c;s.skipPointerDownPicking||s._registeredActions===0&&!this._checkForPicking()&&!s.onPointerDown?c=new cn:c=s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,s.pointerDownPredicate,s.pointerDownFastCheck,s.cameraToUseForPointers,s.pointerDownTrianglePredicate),this._processPointerDown(c,o)},this._onPointerUp=o=>{let l=this._activePointerIds.indexOf(o.pointerId);l!==-1&&(this._activePointerIds[l]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(o),s.preventDefaultOnPointerUp&&r&&(o.preventDefault(),r.focus()),this._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,o,(c,f)=>{if(s.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!c.ignore)){if(this._checkPrePointerObservable(null,o,ye.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}c.hasSwiped||(c.singleClick&&s.onPrePointerObservable.hasSpecificMask(ye.POINTERTAP)&&this._checkPrePointerObservable(null,o,ye.POINTERTAP)&&(this._skipPointerTap=!0),c.doubleClick&&s.onPrePointerObservable.hasSpecificMask(ye.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,ye.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),!(!s.cameraToUseForPointers&&!s.activeCamera)&&(s.pointerUpPredicate||(s.pointerUpPredicate=d=>d.isPickable&&d.isVisible&&d.isReady()&&d.isEnabled()&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&d.layerMask)!==0)),!this._meshPickProceed&&(Es&&Es.HasTriggers||this._checkForPicking()||s.onPointerUp)&&this._initActionManager(null,c),f||(f=this._currentPickResult),this._processPointerUp(f,o,c),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))}))},this._onKeyDown=o=>{let l=dn.KEYDOWN;if(s.onPreKeyboardObservable.hasObservers()){let c=new ff(l,o);if(s.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(s.onKeyboardObservable.hasObservers()){let c=new vl(l,o);s.onKeyboardObservable.notifyObservers(c,l)}s.actionManager&&s.actionManager.processTrigger(14,mi.CreateNewFromScene(s,o))},this._onKeyUp=o=>{let l=dn.KEYUP;if(s.onPreKeyboardObservable.hasObservers()){let c=new ff(l,o);if(s.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(s.onKeyboardObservable.hasObservers()){let c=new vl(l,o);s.onKeyboardObservable.notifyObservers(c,l)}s.actionManager&&s.actionManager.processTrigger(15,mi.CreateNewFromScene(s,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===Ce.Mouse?o.onInputChangedObservable.add(l=>{this._originMouseEvent=l,l.inputIndex===Ve.LeftClick||l.inputIndex===Ve.MiddleClick||l.inputIndex===Ve.RightClick||l.inputIndex===Ve.BrowserBack||l.inputIndex===Ve.BrowserForward?t&&o.getInput(l.inputIndex)===1?this._onPointerDown(l):e&&o.getInput(l.inputIndex)===0&&this._onPointerUp(l):i&&(l.inputIndex===Ve.Move?this._onPointerMove(l):(l.inputIndex===Ve.MouseWheelX||l.inputIndex===Ve.MouseWheelY||l.inputIndex===Ve.MouseWheelZ)&&this._onPointerMove(l))}):o.deviceType===Ce.Touch?o.onInputChangedObservable.add(l=>{l.inputIndex===Ve.LeftClick&&(t&&o.getInput(l.inputIndex)===1?(this._onPointerDown(l),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&o.getInput(l.inputIndex)===0&&(this._onPointerUp(l),this._activePointerIdsCount===0&&(this._isMultiTouchGesture=!1))),i&&l.inputIndex===Ve.Move&&this._onPointerMove(l)}):o.deviceType===Ce.Keyboard&&o.onInputChangedObservable.add(l=>{l.type==="keydown"?this._onKeyDown(l):l.type==="keyup"&&this._onKeyUp(l)})}),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,r){if(this._meshUnderPointerId[t]===e&&(!e||!e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;let s=this._meshUnderPointerId[t],a;s&&(a=s._getActionManagerForTrigger(10),a&&a.processTrigger(10,new mi(s,this._pointerX,this._pointerY,e,r,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,a=e._getActionManagerForTrigger(9),a&&a.processTrigger(9,new mi(e,this._pointerX,this._pointerY,e,r,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null),this._scene.onMeshUnderPointerUpdatedObservable.hasObservers()&&this._scene.onMeshUnderPointerUpdatedObservable.notifyObservers({mesh:e,pointerId:t})}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(let t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}};Mi.DragMovementThreshold=10;Mi.LongPressDelay=500;Mi.DoubleClickDelay=300;Mi.ExclusiveDoubleClickMode=!1});var Bn,lg=A(()=>{rs();Bn=class n{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){n.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){n.Enabled&&(this._startMonitoringTime=kt.Now)}endMonitoring(e=!0){if(!n.Enabled)return;e&&this.fetchNewFrame();let t=kt.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;let e=kt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}};Bn.Enabled=!0});var vs,Uh=A(()=>{vs=class{static get UniqueId(){let e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}};vs._UniqueIdCounter=1});var Vh,rC=A(()=>{Vh=class{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}});var GV,kV,nC,gt,gr=A(()=>{Tt();rs();ct();on();Mx();ha();ve();sf();ma();af();ig();Eh();cf();Th();El();yr();At();gi();iC();lg();et();sh();Uh();fs();$c();Ln();rC();ze();Lt();Mn();GV=new vt,kV=new vt;(function(n){n[n.BackwardCompatible=0]="BackwardCompatible",n[n.Intermediate=1]="Intermediate",n[n.Aggressive=2]="Aggressive"})(nC||(nC={}));gt=class n{static DefaultMaterialFactory(e){throw Ie("StandardMaterial")}static CollisionCoordinatorFactory(){throw Ie("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1;break}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.onEnvironmentTextureChangedObservable.notifyObservers(e),this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(let t of this.skeletons)e=e.concat(t.bones);return e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return Mi.DragMovementThreshold}static set DragMovementThreshold(e){Mi.DragMovementThreshold=e}static get LongPressDelay(){return Mi.LongPressDelay}static set LongPressDelay(e){Mi.LongPressDelay=e}static get DoubleClickDelay(){return Mi.DoubleClickDelay}static set DoubleClickDelay(e){Mi.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return Mi.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){Mi.ExclusiveDoubleClickMode=e}get _eyePosition(){var e,t,i;return(i=(t=this._forcedViewPosition)!=null?t:(e=this.activeCamera)==null?void 0:e.globalPosition)!=null?i:v.ZeroReadOnly}bindEyePosition(e,t="vEyePosition",i=!1){let r=this._eyePosition,s=this.useRightHandedSystem===(this._mirroredCameraPosition!=null),a=this.floatingOriginOffset,o=GV.set(r.x,r.y,r.z,s?-1:1),l=o.subtractFromFloatsToRef(a.x,a.y,a.z,0,kV);return e&&(i?e.setFloat3(t,l.x,l.y,l.z):e.setVector4(t,l)),o}finalizeSceneUbo(){let e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null),i=this.floatingOriginOffset;return e.updateFloat4("vEyePosition",t.x-i.x,t.y-i.y,t.z-i.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=rh(e,()=>{this.onActiveCamerasChanged.notifyObservers(this)})),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get _hasDefaultMaterial(){return n.DefaultMaterialFactory!==n._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=n.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph){this._frameGraph=e,e||(this.customRenderFunction=this._currentCustomRenderFunction);return}this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph,this.activeCamera=null)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=n.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(let e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);let t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(let t of this._components)if(t.name===e)return t;return null}get uniqueId(){return this._uniqueId}constructor(e,t){this._inputManager=new Mi(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new Ne(.2,.2,.3,1),this.onClearColorChangedObservable=new Y,this.ambientColor=new oe(0,0,0),this.environmentIntensity=1,this.iblIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new Y,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.objectRenderers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new Y,this._onDisposeObserver=null,this.onBeforeRenderObservable=new Y,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new Y,this.onAfterRenderCameraObservable=new Y,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new Y,this.onAfterAnimationsObservable=new Y,this.onBeforeDrawPhaseObservable=new Y,this.onAfterDrawPhaseObservable=new Y,this.onReadyObservable=new Y,this.onBeforeCameraRenderObservable=new Y,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new Y,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new Y,this.onAfterActiveMeshesEvaluationObservable=new Y,this.onBeforeParticlesRenderingObservable=new Y,this.onAfterParticlesRenderingObservable=new Y,this.onDataLoadedObservable=new Y,this.onNewCameraAddedObservable=new Y,this.onCameraRemovedObservable=new Y,this.onNewLightAddedObservable=new Y,this.onLightRemovedObservable=new Y,this.onNewGeometryAddedObservable=new Y,this.onGeometryRemovedObservable=new Y,this.onNewTransformNodeAddedObservable=new Y,this.onTransformNodeRemovedObservable=new Y,this.onNewMeshAddedObservable=new Y,this.onMeshRemovedObservable=new Y,this.onNewSkeletonAddedObservable=new Y,this.onSkeletonRemovedObservable=new Y,this.onNewParticleSystemAddedObservable=new Y,this.onParticleSystemRemovedObservable=new Y,this.onNewAnimationGroupAddedObservable=new Y,this.onAnimationGroupRemovedObservable=new Y,this.onNewMaterialAddedObservable=new Y,this.onNewMultiMaterialAddedObservable=new Y,this.onMaterialRemovedObservable=new Y,this.onMultiMaterialRemovedObservable=new Y,this.onNewTextureAddedObservable=new Y,this.onTextureRemovedObservable=new Y,this.onNewFrameGraphAddedObservable=new Y,this.onFrameGraphRemovedObservable=new Y,this.onNewObjectRendererAddedObservable=new Y,this.onObjectRendererRemovedObservable=new Y,this.onNewPostProcessAddedObservable=new Y,this.onPostProcessRemovedObservable=new Y,this.onNewEffectLayerAddedObservable=new Y,this.onEffectLayerRemovedObservable=new Y,this.onBeforeRenderTargetsRenderObservable=new Y,this.onAfterRenderTargetsRenderObservable=new Y,this.onBeforeStepObservable=new Y,this.onAfterStepObservable=new Y,this.onActiveCameraChanged=new Y,this.onActiveCamerasChanged=new Y,this.onBeforeRenderingGroupObservable=new Y,this.onAfterRenderingGroupObservable=new Y,this.onMeshImportedObservable=new Y,this.onAnimationFileImportedObservable=new Y,this.onEnvironmentTextureChangedObservable=new Y,this.onMeshUnderPointerUpdatedObservable=new Y,this._registeredForLateAnimationBindings=new an(256),this._pointerPickingConfiguration=new Vh,this.onPrePointerObservable=new Y,this.onPointerObservable=new Y,this.onPreKeyboardObservable=new Y,this.onKeyboardObservable=new Y,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=n.FOGMODE_NONE,this.fogColor=new oe(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.frameGraphs=[],this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new v(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new an(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new Bn,this._activeIndices=new Bn,this._activeParticles=new Bn,this._activeBones=new Bn,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=[],this._isDisposed=!1,this._isReadyChecks=[],this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new Ct(256),this._processedMaterials=new Ct(256),this._renderTargets=new an(256),this._materialsRenderTargets=new an(256),this._activeParticleSystems=new Ct(256),this._activeSkeletons=new an(32),this._softwareSkinnedMeshes=new an(32),this._activeAnimatables=new Array,this._transformMatrix=G.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=wt.Create(),this._beforeClearStage=wt.Create(),this._beforeRenderTargetClearStage=wt.Create(),this._gatherRenderTargetsStage=wt.Create(),this._gatherActiveCameraRenderTargetsStage=wt.Create(),this._isReadyForMeshStage=wt.Create(),this._beforeEvaluateActiveMeshStage=wt.Create(),this._evaluateSubMeshStage=wt.Create(),this._preActiveMeshStage=wt.Create(),this._cameraDrawRenderTargetStage=wt.Create(),this._beforeCameraDrawStage=wt.Create(),this._beforeRenderTargetDrawStage=wt.Create(),this._beforeRenderingGroupDrawStage=wt.Create(),this._beforeRenderingMeshStage=wt.Create(),this._afterRenderingMeshStage=wt.Create(),this._afterRenderingGroupDrawStage=wt.Create(),this._afterCameraDrawStage=wt.Create(),this._afterCameraPostProcessStage=wt.Create(),this._afterRenderTargetDrawStage=wt.Create(),this._afterRenderTargetPostProcessStage=wt.Create(),this._afterRenderStage=wt.Create(),this._pointerMoveStage=wt.Create(),this._pointerDownStage=wt.Create(),this._pointerUpStage=wt.Create(),this._geometriesByUniqueId=null,this._uniqueId=0,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this.onReadyTimeoutObservable=new Y,this.onReadyTimeoutDuration=120*1e3,this._timeoutChecksStartTime=0,this._floatingOriginScene=void 0,this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._freezeActiveMeshesCancel=null,this._useCurrentFrameBuffer=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._getFloatingOriginScene=()=>this._floatingOriginScene,this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[],this._uniqueId=this.getUniqueId();let i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,defaultCameraLayerMask:268435455,defaultRenderableLayerMask:268435455,...t};this.defaultCameraLayerMask=i.defaultCameraLayerMask,this.defaultRenderableLayerMask=i.defaultRenderableLayerMask,e=this._engine=e||ue.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(ue._LastCreatedScene=this,e.scenes.push(this)),(e.getCreationOptions().useLargeWorldRendering||t!=null&&t.useFloatingOrigin)&&(kx(),this._floatingOriginScene=this,Br.getScene=this._getFloatingOriginScene),this._uid=null,this._renderingManager=new Pr(this),us&&(this.postProcessManager=new us(this)),Bt()&&this.attachControl(),this._createUbo(),Je&&(this._imageProcessingConfiguration=new Je),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 a,o,l;if(this._isDisposed)return!1;let t,i=this.getEngine(),r=i.currentRenderPassId;i.currentRenderPassId=(o=(a=this.activeCamera)==null?void 0:a.renderPassId)!=null?o:r;let s=!0;for(this._pendingData.length>0&&(s=!1),(l=this.prePassRenderer)==null||l.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&s&&(s=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t0;for(let h of this._isReadyForMeshStage)h.action(c,f)||(s=!1);if(!e)continue;let d=c.material||this.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(let h of c.subMeshes){let u=h.getMaterial();u&&u.hasRenderTargetTextures&&u.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(u)===-1&&(this._processedMaterials.push(u),this._materialsRenderTargets.concatWithNoDuplicate(u.getRenderTargetTextures()))}else d.hasRenderTargetTextures&&d.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(d)===-1&&(this._processedMaterials.push(d),this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))}if(e){for(t=0;t0)for(let c of this.activeCameras)c.isReady(!0)||(s=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(s=!1));for(let c of this.particleSystems)c.isReady()||(s=!1);if(this.proceduralTexturesEnabled)for(let c of this.proceduralTextures)c.isReady()||(s=!1);if(this.layers)for(let c of this.layers)c.isReady()||(s=!1);if(this.effectLayers)for(let c of this.effectLayers)c.isLayerReady()||(s=!1);for(let c of this._isReadyChecks)c.isReady()||(s=!1);return i.areAllEffectsReady()||(s=!1),i.currentRenderPassId=r,s}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){let 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){let 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}addIsReadyCheck(e){this._isReadyChecks.indexOf(e)===-1&&this._isReadyChecks.push(e)}removeIsReadyCheck(e){let t=this._isReadyChecks.indexOf(e);t!==-1&&this._isReadyChecks.splice(t,1)}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),this._executeWhenReadyTimeoutId===null&&this._checkIsReady(t)}async whenReadyAsync(e=!1){return await new Promise(t=>{this.executeWhenReady(()=>{t()},e)})}_clearReadynessChecksData(){this._timeoutChecksStartTime=0,this.onReadyTimeoutObservable.clear(),this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null}_checkIsReady(e=!1){if(this._registerTransientComponents(),this._timeoutChecksStartTime===0)this._timeoutChecksStartTime=kt.Now;else if(this.onReadyTimeoutDuration>0&&kt.Now-this._timeoutChecksStartTime>this.onReadyTimeoutDuration){this.onReadyTimeoutObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this.isReady(e)){this.onReadyObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this._isDisposed){this._clearReadynessChecksData();return}this._executeWhenReadyTimeoutId=setTimeout(()=>{this.incrementRenderId(),this._checkIsReady(e)},100)}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=kt.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getInverseProjectionMatrix(){return this._inverseProjectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,i,r){this._multiviewSceneUboIsActive=!!(i&&r&&this._multiviewSceneUbo),!(this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag)&&(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._inverseProjectionMatrix||(this._inverseProjectionMatrix=new G),this._projectionMatrix.invertToRef(this._inverseProjectionMatrix),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?oa.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=oa.GetPlanes(this._transformMatrix),this._multiviewSceneUboIsActive&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix),this._sceneUbo.updateMatrix("inverseProjection",this._inverseProjectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUboIsActive&&this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e,t){let i=typeof t=="boolean"?t:t==null?void 0:t.trackUBOsInFrame,r=new Ut(this._engine,void 0,!1,e!=null?e:"scene",void 0,i);return r.addUniform("viewProjection",16),r.addUniform("view",16),r.addUniform("projection",16),r.addUniform("vEyePosition",4),r.addUniform("inverseProjection",16),r}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}get floatingOriginMode(){return this._floatingOriginScene!==void 0}get floatingOriginOffset(){return this.floatingOriginMode?this._eyePosition:v.ZeroReadOnly}getUniqueId(){return vs.UniqueId}addMesh(e,t=!1){if(!this._blockEntityCollection&&(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),re.SetImmediate(()=>{this.onNewMeshAddedObservable.notifyObservers(e)}),t)){let i=e.getChildMeshes();for(let r of i)this.addMesh(r)}}removeMesh(e,t=!1){let i=this.meshes.indexOf(e);if(i!==-1&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t){let r=e.getChildMeshes();for(let s of r)this.removeMesh(s)}return i}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneTransformNodesArray!==-1||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){let t=e._indexInSceneTransformNodesArray;if(t!==-1){if(t!==this.transformNodes.length-1){let 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){let t=this.skeletons.indexOf(e);return t!==-1&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){let t=this.morphTargetManagers.indexOf(e);return t!==-1&&this.morphTargetManagers.splice(t,1),t}removeLight(e){let t=this.lights.indexOf(e);if(t!==-1){for(let i of this.meshes)i._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes(),this.onLightRemovedObservable.notifyObservers(e)}return t}removeCamera(e){let t=this.cameras.indexOf(e);if(t!==-1&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){let 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){let t=this.particleSystems.indexOf(e);return t!==-1&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),this.onParticleSystemRemovedObservable.notifyObservers(e),t}removeAnimation(e){let t=this.animations.indexOf(e);return t!==-1&&this.animations.splice(t,1),t}stopAnimation(e,t,i){}removeAnimationGroup(e){let t=this.animationGroups.indexOf(e);return t!==-1&&this.animationGroups.splice(t,1),this.onAnimationGroupRemovedObservable.notifyObservers(e),t}removeMultiMaterial(e){let t=this.multiMaterials.indexOf(e);return t!==-1&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){let t=e._indexInSceneMaterialArray;if(t!==-1&&t{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(it.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),re.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),re.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||(this.particleSystems.push(e),re.SetImmediate(()=>{this.onNewParticleSystemAddedObservable.notifyObservers(e)}))}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||(this.animationGroups.push(e),re.SetImmediate(()=>{this.onNewAnimationGroupAddedObservable.notifyObservers(e)}))}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),re.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),re.SetImmediate(()=>{this.onNewMaterialAddedObservable.notifyObservers(e)}))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}addFrameGraph(e){this.frameGraphs.push(e),re.SetImmediate(()=>{this.onNewFrameGraphAddedObservable.notifyObservers(e)})}addObjectRenderer(e){this.objectRenderers.push(e),re.SetImmediate(()=>{this.onNewObjectRendererAddedObservable.notifyObservers(e)})}addPostProcess(e){this._blockEntityCollection||(this.postProcesses.push(e),re.SetImmediate(()=>{this.onNewPostProcessAddedObservable.notifyObservers(e)}))}addEffectLayer(e){this._blockEntityCollection||(this.effectLayers.push(e),re.SetImmediate(()=>{this.onNewEffectLayerAddedObservable.notifyObservers(e)}))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){let t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){let t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;ti.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.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){let 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=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];for(t=this.skeletons.length-1;t>=0;t--){let i=this.skeletons[t];for(let r=i.bones.length-1;r>=0;r--)if(i.bones[r].id===e)return i.bones[r]}return null}getNodeById(e){let t=this.getMeshById(e);if(t)return t;let i=this.getTransformNodeById(e);if(i)return i;let r=this.getLightById(e);if(r)return r;let s=this.getCameraById(e);if(s)return s;let a=this.getBoneById(e);return a||null}getNodeByName(e){let t=this.getMeshByName(e);if(t)return t;let i=this.getTransformNodeByName(e);if(i)return i;let r=this.getLightByName(e);if(r)return r;let s=this.getCameraByName(e);if(s)return s;let a=this.getBoneByName(e);return a||null}getMeshByName(e){for(let t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t{let o=!0,l=!0;for(let c of a)o&&(o=c.objectRenderer._isFrozen),l&&(l=c.objectRenderer._freezeActiveMeshesCancel!==null);if(o)return!0;if(!l)throw new Error("Freezing active meshes was cancelled");return!1},()=>{this._freezeActiveMeshesCancel=null,this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=s,this._skipEvaluateActiveMeshesCompletely=e,t==null||t()},(o,l)=>{if(this._freezeActiveMeshesCancel=null,this.unfreezeActiveMeshes(),l){let c="Scene: Timeout while waiting for meshes to be frozen.";i?i(c):(W.Error(c),o&&W.Error(o))}else{let c="Scene: An unexpected error occurred while trying to freeze active meshes.";i?i(c):(W.Error(c),o&&(W.Error(o),o.stack&&W.Error(o.stack)))}}),this}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=s,this._skipEvaluateActiveMeshesCompletely=e,r)for(let a=0;ae.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){let r=this._activeMeshes.length;for(let s=0;s0&&(s.layerMask&this.activeCamera.layerMask)!==0&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),o!==s&&o._activate(this._renderId,!1);for(let l of this._preActiveMeshStage)l.action(s);s._activate(this._renderId,!1)&&(s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(o=s):o._internalAbstractMeshDataInfo._onlyForInstances=!1,o._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(s,o)),s._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let r=0;r0){let r=this.getActiveSubMeshCandidates(t),s=r.length;i=i||s===1;for(let a=0;a0&&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(let h of this._gatherActiveCameraRenderTargetsStage)h.action(this._renderTargets);let s=!1;if(this.renderTargetsEnabled){this._intermediateRendering=!0;let h;if(this._renderTargets.length>0){re.StartPerformanceCounter("Render targets",this._renderTargets.length>0);let u=(f=this.getBoundingBoxRenderer)==null?void 0:f.call(this);for(let m=0;m0?u.renderList.data.slice():[],h.length=u.renderList.length),p.render(_,this.dumpNextRenderTargets),s=!0}}u&&h&&(u.renderList.data=h,u.renderList.length=h.length),re.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}if(this._cameraDrawRenderTargetStage.length>0){let u=(d=this.getBoundingBoxRenderer)==null?void 0:d.call(this);u&&!h&&(h=u.renderList.length>0?u.renderList.data.slice():[],h.length=u.renderList.length);for(let m of this._cameraDrawRenderTargetStage)s=m.action(this.activeCamera)||s;u&&h&&(u.renderList.data=h,u.renderList.length=h.length)}this._intermediateRendering=!1}s&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(let h of this._beforeCameraDrawStage)h.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this);let a=r.snapshotRendering&&r.snapshotRenderingMode===1;a&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!a),this.onAfterDrawPhaseObservable.notifyObservers(this);for(let h of this._afterCameraDrawStage)h.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){let h=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,h)}for(let h of this._afterCameraPostProcessStage)h.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-1&&(r.trigger===13&&r._executeCurrent(mi.CreateNew(t,void 0,a)),(!t.actionManager.hasSpecificTrigger(13,c=>{let f=c.mesh?c.mesh:c;return a===f})||r.trigger===13)&&t._intersectionsInProgress.splice(l,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(n.MinDeltaTime,Math.min(this._engine.getDeltaTime(),n.MaxDeltaTime))+this._timeAccumulator,t=this._engine.getTimeStep(),i=1e3/t/1e3,r=0,s=this._engine.getLockstepMaxSteps(),a=Math.floor(e/t);for(a=Math.min(a,s);e>0&&r0);for(let l=0;l0),this._renderId++}this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(let l of this._beforeClearStage)l.action();if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();else{let l=this.getActiveMeshCandidates(),c=l.length;if(this._activeMeshesFrozen){if(!this._skipEvaluateActiveMeshesCompletely)for(let f=0;f0)for(let a=0;a0);for(let o=0;o0),this._renderId++}this._engine.currentRenderPassId=(s=a==null?void 0:a.renderPassId)!=null?s:0,this.activeCamera=a,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(let o of this._beforeClearStage)o.action();this._clearFrameBuffer(this.activeCamera);for(let o of this._gatherRenderTargetsStage)o.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let o=0;o0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(let a of this._afterRenderStage)a.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let a=0;as.dispose(!0)),this._disposeList(this.transformNodes,s=>s.dispose(!0));let i=this.cameras;this._disposeList(i),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._disposeList(this.frameGraphs),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let r=this._engine.scenes.indexOf(this);if(r>-1&&this._engine.scenes.splice(r,1),this._floatingOriginScene=void 0,this._engine.scenes.length===0&&Gx(),ue._LastCreatedScene===this){ue._LastCreatedScene=null;let s=ue.Instances.length-1;for(;s>=0;){let a=ue.Instances[s];if(a.scenes.length>0){ue._LastCreatedScene=a.scenes[this._engine.scenes.length-1];break}s--}}r=this._engine._virtualScenes.indexOf(this),r>-1&&this._engine._virtualScenes.splice(r,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onNewFrameGraphAddedObservable.clear(),this.onFrameGraphRemovedObservable.clear(),this.onNewObjectRendererAddedObservable.clear(),this.onObjectRendererRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this.onEnvironmentTextureChangedObservable.clear(),this.onMeshUnderPointerUpdatedObservable.clear(),this._isDisposed=!0}_disposeList(e,t){let i=e.slice(0);t=t!=null?t:(r=>r.dispose());for(let r of i)t(r);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e!0);let r=this.meshes.filter(e);for(let s of r){if(s.computeWorldMatrix(!0),!s.subMeshes||s.subMeshes.length===0||s.infiniteDistance)continue;let a=s.getBoundingInfo(),o=a.boundingBox.minimumWorld,l=a.boundingBox.maximumWorld;v.CheckExtends(o,t,i),v.CheckExtends(l,t,i)}return t.x===Number.MAX_VALUE?{min:v.Zero(),max:v.Zero()}:{min:t,max:i}}createPickingRay(e,t,i,r,s=!1){throw Ie("Ray")}createPickingRayToRef(e,t,i,r,s,a=!1,o=!1){throw Ie("Ray")}createPickingRayInCameraSpace(e,t,i){throw Ie("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,r){throw Ie("Ray")}pick(e,t,i,r,s,a){let o=Ie("Ray",!0);return o&&W.Warn(o),new cn}pickWithBoundingInfo(e,t,i,r,s){let a=Ie("Ray",!0);return a&&W.Warn(a),new cn}pickWithRay(e,t,i,r){throw Ie("Ray")}multiPick(e,t,i,r,s){throw Ie("Ray")}multiPickWithRay(e,t,i){throw Ie("Ray")}setPointerOverMesh(e,t,i){this._inputManager.setPointerOverMesh(e,t,i)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(let e of this.geometries)e._rebuild();for(let e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(let e of this._components)e.rebuild();for(let e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(let e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(let e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,i){if(t===void 0)return e;let r=[];for(let s in e){let a=e[s];nt&&nt.MatchesQuery(a,t)&&(!i||i(a))&&r.push(a)}return r}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,r=null){this._renderingManager.setRenderingOrder(e,t,i,r)}setRenderingAutoClearDepthStencil(e,t,i=!0,r=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(127))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(let i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,r,s,a,o){let l=Fn(e,t,i,r?this.offlineProvider:void 0,s,a,o);return this._activeRequests.push(l),l.onCompleteObservable.add(c=>{this._activeRequests.splice(this._activeRequests.indexOf(c),1)}),l}async _loadFileAsync(e,t,i,r,s){return await new Promise((a,o)=>{this._loadFile(e,l=>{a(l)},t,i,r,(l,c)=>{o(c)},s)})}_requestFile(e,t,i,r,s,a,o){let l=ph(e,t,i,r?this.offlineProvider:void 0,s,a,o);return this._activeRequests.push(l),l.onCompleteObservable.add(c=>{this._activeRequests.splice(this._activeRequests.indexOf(c),1)}),l}async _requestFileAsync(e,t,i,r,s){return await new Promise((a,o)=>{this._requestFile(e,l=>{a(l)},t,i,r,l=>{o(l)},s)})}_readFile(e,t,i,r,s){let a=_o(e,t,i,r,s);return this._activeRequests.push(a),a.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),a}async _readFileAsync(e,t,i){return await new Promise((r,s)=>{this._readFile(e,a=>{r(a)},t,i,a=>{s(a)})})}getPerfCollector(){throw Ie("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}};gt.FOGMODE_NONE=0;gt.FOGMODE_EXP=1;gt.FOGMODE_EXP2=2;gt.FOGMODE_LINEAR=3;gt.MinDeltaTime=1;gt.MaxDeltaTime=1e3;gt._OriginalDefaultMaterialFactory=gt.DefaultMaterialFactory;je("BABYLON.Scene",gt)});var sC,WV,Vr=A(()=>{N();sC="helperFunctions",WV=`const PI: f32=3.141592653589793;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08; +}`;E.ShadersStore[X_]||(E.ShadersStore[X_]=Ex);$V={name:X_,shader:Ex}});var _s,rf,Y_=A(()=>{Eo();At();_s=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(mx(),ux))]))):t.push(Promise.all([Promise.resolve().then(()=>(V_(),U_))])),super._gatherImports(e,t)}constructor(e,t=null,i){let r={name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,...i};r.engine||(r.engine=ue.LastCreatedEngine),super(r)}};_s.FragmentUrl="pass";rf=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(gx(),_x))]))):t.push(Promise.all([Promise.resolve().then(()=>(Tx(),vx))])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,defines:"#define POSITIVEX"}),this._face=0}get face(){return this._face}set face(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ");break}}};rf.FragmentUrl="passCube"});var vo,K_,j_=A(()=>{Qe();ps();ii();Lt();Kt();Y_();qe();vo=class n extends gt{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,r,s,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:s,reusable:a,textureType:o,blockCompilation:l,...t};super(e,_s.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new _s(e,s,c):void 0,...c})}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};je("BABYLON.PassPostProcess",vo);K_=class n extends gt{get face(){return this._effectWrapper.face}set face(e){this._effectWrapper.face=e}getClassName(){return"PassCubePostProcess"}constructor(e,t,i=null,r,s,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:s,reusable:a,textureType:o,blockCompilation:l,...t};super(e,_s.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new rf(e,s,c):void 0,...c})}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};C([D()],K_.prototype,"face",null);fe._RescalePostProcessFactory=n=>new vo("rescale",1,null,2,n,!1,0)});function Ax(n,e,t,i,r,s,a,o){let l=e.getEngine();return e.isReady=!1,r=r!=null?r:e.samplingMode,i=i!=null?i:e.type,s=s!=null?s:e.format,a=a!=null?a:e.width,o=o!=null?o:e.height,i===-1&&(i=0),new Promise(c=>{let f=new gt("postprocess",n,null,null,1,null,r,l,!1,void 0,i,void 0,null,!1,s);f.externalTextureSamplerBinding=!0;let d=l.createRenderTargetTexture({width:a,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:r,type:i,format:s});f.onEffectCreatedObservable.addOnce(h=>{h.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",e),u.setFloat2("scale",1,1)},t.postProcessManager.directRender([f],d,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(e),f&&f.dispose(),d._swapAndDie(e),e.type=i,e.format=5,e.isReady=!0,c(e)})})})}function To(n){Ih||(Ih=new Float32Array(1),Sx=new Int32Array(Ih.buffer)),Ih[0]=n;let e=Sx[0],t=e>>16&32768,i=e>>12&2047,r=e>>23&255;return r<103?t:r>142?(t|=31744,t|=(r==255?0:1)&&e&8388607,t):r<113?(i|=2048,t|=(i>>114-r)+(i>>113-r&1),t):(t|=r-112<<10|i>>1,t+=i&1,t)}function gs(n){let e=(n&32768)>>15,t=(n&31744)>>10,i=n&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))}var Ih,Sx,Z_=A(()=>{oi();_a();j_();ps();Mi()});function Q_(n){return n.split(" ").filter(e=>e!=="").map(e=>parseFloat(e))}function q_(n,e,t){for(;t.length!==e;){let i=Q_(n.lines[n.index++]);t.push(...i)}}function eG(n,e,t){let i=0,r=0,s=0,a=0,o=0,l=0;for(let g=0;g0&&!i.lines[i.index].includes("TILT=");)i.index++;i.lines[i.index].includes("INCLUDE"),i.index++;let s=Q_(i.lines[i.index++]);r.numberOfLights=s[0],r.lumensPerLamp=s[1],r.candelaMultiplier=s[2],r.numberOfVerticalAngles=s[3],r.numberOfHorizontalAngles=s[4],r.photometricType=s[5],r.unitsType=s[6],r.width=s[7],r.length=s[8],r.height=s[9];let a=Q_(i.lines[i.index++]);r.ballastFactor=a[0],r.fileGenerationType=a[1],r.inputWatts=a[2];for(let m=0;m0)for(let m=0;m=u)&&(p%=u*2,p>u&&(p=u*2-p)),d[_+p*l]=eG(r,_,p)}return{width:c/2,height:1,data:d}}var Ix=A(()=>{Mi()});var xx={};De(xx,{_IESTextureLoader:()=>J_});var J_,Cx=A(()=>{Ix();J_=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".ies not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=Rx(r);i(s.width,s.height,!!t.useMipMaps,!1,()=>{let a=t.getEngine();t.type=1,t.format=6,t._gammaSpace=!1,a._uploadDataToTextureDirectly(t,s.data)})}}});var bx={};De(bx,{_DDSTextureLoader:()=>$_});var $_,Mx=A(()=>{Xc();eg();$_=class{constructor(){this.supportCascades=!0}loadCubeData(e,t,i,r){let s=t.getEngine(),a,o=!1,l=1e3;if(Array.isArray(e))for(let c=0;c1)&&t.generateMipMaps,s._unpackFlipY(a.isCompressed),fn.UploadDDSLevels(s,t,f,a,o,6,-1,c),!a.isFourCC&&a.mipmapCount===1?s.generateMipMapsForCubemap(t):l=a.mipmapCount-1}else{let c=e;a=fn.GetDDSInfo(c),t.width=a.width,t.height=a.height,i&&(a.sphericalPolynomial=new On),o=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&t.generateMipMaps,s._unpackFlipY(a.isCompressed),fn.UploadDDSLevels(s,t,c,a,o,6),!a.isFourCC&&a.mipmapCount===1?s.generateMipMapsForCubemap(t,!1):l=a.mipmapCount-1}s._setCubeMapTextureParams(t,o,l),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r({isDDS:!0,width:t.width,info:a,data:e,texture:t})}loadData(e,t,i){let r=fn.GetDDSInfo(e),s=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&Math.max(r.width,r.height)>>r.mipmapCount-1===1;i(r.width,r.height,s,r.isFourCC,()=>{fn.UploadDDSLevels(t.getEngine(),t,e,r,s,1)})}}});function yx(){let n={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7:6,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16,cTFFXT1_RGB:17,cTFPVRTC2_4_RGB:18,cTFPVRTC2_4_RGBA:19,cTFETC2_EAC_R11:20,cTFETC2_EAC_RG11:21},e=null;onmessage=a=>{if(a.data.action==="init"){if(a.data.url)try{importScripts(a.data.url)}catch(o){postMessage({action:"error",error:o})}e||(e=BASIS({wasmBinary:a.data.wasmBinary})),e!==null&&e.then(o=>{BASIS=o,o.initializeBasis(),postMessage({action:"init"})})}else if(a.data.action==="transcode"){let o=a.data.config,l=a.data.imageData,c=new BASIS.BasisFile(l),f=i(c),d=a.data.ignoreSupportedFormats?null:t(a.data.config,f),h=!1;d===null&&(h=!0,d=f.hasAlpha?n.cTFBC3:n.cTFBC1);let u=!0;c.startTranscoding()||(u=!1);let m=[];for(let p=0;p>2&3],d[b++]=f[T>>4&3],d[b]=f[T>>6&3]}}return d}}async function Dx(n,e,t){return await new Promise((i,r)=>{let s=a=>{a.data.action==="init"?(n.removeEventListener("message",s),i(n)):a.data.action==="error"&&r(a.data.error||"error initializing worker")};n.addEventListener("message",s),n.postMessage({action:"init",url:t?re.GetBabylonScriptURL(t):void 0,wasmBinary:e},[e])})}var Lx=A(()=>{Tt()});var Es,ga,tG,tg,So,iG,rG,nG,Ch,xh,bh,ig,Px=A(()=>{Tt();oi();vr();Lx();(function(n){n[n.cTFETC1=0]="cTFETC1",n[n.cTFETC2=1]="cTFETC2",n[n.cTFBC1=2]="cTFBC1",n[n.cTFBC3=3]="cTFBC3",n[n.cTFBC4=4]="cTFBC4",n[n.cTFBC5=5]="cTFBC5",n[n.cTFBC7=6]="cTFBC7",n[n.cTFPVRTC1_4_RGB=8]="cTFPVRTC1_4_RGB",n[n.cTFPVRTC1_4_RGBA=9]="cTFPVRTC1_4_RGBA",n[n.cTFASTC_4x4=10]="cTFASTC_4x4",n[n.cTFATC_RGB=11]="cTFATC_RGB",n[n.cTFATC_RGBA_INTERPOLATED_ALPHA=12]="cTFATC_RGBA_INTERPOLATED_ALPHA",n[n.cTFRGBA32=13]="cTFRGBA32",n[n.cTFRGB565=14]="cTFRGB565",n[n.cTFBGR565=15]="cTFBGR565",n[n.cTFRGBA4444=16]="cTFRGBA4444",n[n.cTFFXT1_RGB=17]="cTFFXT1_RGB",n[n.cTFPVRTC2_4_RGB=18]="cTFPVRTC2_4_RGB",n[n.cTFPVRTC2_4_RGBA=19]="cTFPVRTC2_4_RGBA",n[n.cTFETC2_EAC_R11=20]="cTFETC2_EAC_R11",n[n.cTFETC2_EAC_RG11=21]="cTFETC2_EAC_RG11"})(Es||(Es={}));ga={JSModuleURL:`${re._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,WasmModuleURL:`${re._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`},tG=(n,e)=>{let t;switch(n){case Es.cTFETC1:t=36196;break;case Es.cTFBC1:t=33776;break;case Es.cTFBC4:t=33779;break;case Es.cTFASTC_4x4:t=37808;break;case Es.cTFETC2:t=37496;break;case Es.cTFBC7:t=36492;break}if(t===void 0)throw"The chosen Basis transcoder format is not currently supported";return t},tg=null,So=null,iG=0,rG=!1,nG=async()=>(tg||(tg=new Promise((n,e)=>{So?n(So):re.LoadFileAsync(re.GetBabylonScriptURL(ga.WasmModuleURL)).then(t=>{if(typeof URL!="function")return e("Basis transcoder requires an environment with a URL constructor");let i=URL.createObjectURL(new Blob([`(${yx})()`],{type:"application/javascript"}));So=new Worker(i),Dx(So,t,ga.JSModuleURL).then(n,e)}).catch(e)})),await tg),Ch=async(n,e)=>{let t=n instanceof ArrayBuffer?new Uint8Array(n):n;return await new Promise((i,r)=>{nG().then(()=>{let s=iG++,a=l=>{l.data.action==="transcode"&&l.data.id===s&&(So.removeEventListener("message",a),l.data.success?i(l.data):r("Transcode is not supported on this device"))};So.addEventListener("message",a);let o=new Uint8Array(t.byteLength);o.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),So.postMessage({action:"transcode",id:s,imageData:o,config:e,ignoreSupportedFormats:rG},[o.buffer])},s=>{r(s)})})},xh=(n,e)=>{var i,r;let t=(i=e._gl)==null?void 0:i.TEXTURE_2D;n.isCube&&(t=(r=e._gl)==null?void 0:r.TEXTURE_CUBE_MAP),e._bindTextureDirectly(t,n,!0)},bh=(n,e)=>{let t=n.getEngine();for(let i=0;i{t._releaseTexture(s),xh(n,t)})}else n._invertVScale=!n.invertY,n.width=r.width+3&-4,n.height=r.height+3&-4,n.samplingMode=2,xh(n,t),t._uploadDataToTextureDirectly(n,new Uint16Array(r.transcodedPixels.buffer),i,0,4,!0);else{n.width=r.width,n.height=r.height,n.generateMipMaps=e.fileInfo.images[i].levels.length>1;let s=ig.GetInternalFormatFromBasisFormat(e.format,t);n.format=s,xh(n,t);let a=e.fileInfo.images[i].levels;for(let o=0;org});var rg,Nx=A(()=>{Px();Tt();rg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){if(Array.isArray(e))return;let a=t.getEngine().getCaps(),o={supportedCompressionFormats:{etc1:!!a.etc1,s3tc:!!a.s3tc,pvrtc:!!a.pvrtc,etc2:!!a.etc2,astc:!!a.astc,bc7:!!a.bptc}};Ch(e,o).then(l=>{let c=l.fileInfo.images[0].levels.length>1&&t.generateMipMaps;bh(t,l),t.getEngine()._setCubeMapTextureParams(t,c),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}).catch(l=>{re.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0,s&&s(l)})}loadData(e,t,i){let r=t.getEngine().getCaps(),s={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,astc:!!r.astc,bc7:!!r.bptc}};Ch(e,s).then(a=>{let o=a.fileInfo.images[0].levels[0],l=a.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(o.width,o.height,l,a.format!==-1,()=>{bh(t,a)})}).catch(a=>{re.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),re.Warn(`Failed to transcode Basis file: ${a}`),i(0,0,!1,!1,()=>{},!0)})}}});var nf,Fx=A(()=>{nf=class{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach((t,i)=>this.add(t,i))}get(e){let 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){let 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){let 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(let t in this._data){let i=this._data[t];e(t,i)}}first(e){for(let t in this._data){let i=this._data[t],r=e(t,i);if(r)return r}return null}}});function Mh(n){n.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}var ng=A(()=>{});var mi,wx=A(()=>{Qe();qe();et();Kt();ng();mi=class n{constructor(){this._dirty=!0,this._tempColor=new Ne(0,0,0,0),this._globalCurve=new Ne(0,0,0,0),this._highlightsCurve=new Ne(0,0,0,0),this._midtonesCurve=new Ne(0,0,0,0),this._shadowsCurve=new Ne(0,0,0,0),this._positiveCurve=new Ne(0,0,0,0),this._negativeCurve=new Ne(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",r="vCameraColorCurveNeutral",s="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(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(s,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,r,s){e!=null&&(e=n._Clamp(e,0,360),t=n._Clamp(t,-100,100),i=n._Clamp(i,-100,100),r=n._Clamp(r,-100,100),t=n._ApplyColorGradingSliderNonlinear(t),t*=.5,r=n._ApplyColorGradingSliderNonlinear(r),t<0&&(t*=-1,e=(e+180)%360),n._FromHSBToRef(e,t,50+.25*r,s),s.scaleToRef(2,s),s.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,r){let s=n._Clamp(e,0,360),a=n._Clamp(t/100,0,1),o=n._Clamp(i/100,0,1);if(a===0)r.r=o,r.g=o,r.b=o;else{s/=60;let l=Math.floor(s),c=s-l,f=o*(1-a),d=o*(1-a*c),h=o*(1-a*(1-c));switch(l){case 0:r.r=o,r.g=h,r.b=f;break;case 1:r.r=d,r.g=o,r.b=f;break;case 2:r.r=f,r.g=o,r.b=h;break;case 3:r.r=f,r.g=d,r.b=o;break;case 4:r.r=h,r.g=f,r.b=o;break;default:r.r=o,r.g=f,r.b=d;break}}r.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return Me.Clone(()=>new n,this)}serialize(){return Me.Serialize(this)}static Parse(e){return Me.Parse(()=>new n,e,null,null)}};mi.PrepareUniforms=Mh;C([D()],mi.prototype,"_globalHue",void 0);C([D()],mi.prototype,"_globalDensity",void 0);C([D()],mi.prototype,"_globalSaturation",void 0);C([D()],mi.prototype,"_globalExposure",void 0);C([D()],mi.prototype,"_highlightsHue",void 0);C([D()],mi.prototype,"_highlightsDensity",void 0);C([D()],mi.prototype,"_highlightsSaturation",void 0);C([D()],mi.prototype,"_highlightsExposure",void 0);C([D()],mi.prototype,"_midtonesHue",void 0);C([D()],mi.prototype,"_midtonesDensity",void 0);C([D()],mi.prototype,"_midtonesSaturation",void 0);C([D()],mi.prototype,"_midtonesExposure",void 0);Me._ColorCurvesParser=mi.Parse});function Bx(n,e){e.EXPOSURE&&n.push("exposureLinear"),e.CONTRAST&&n.push("contrast"),e.COLORGRADING&&n.push("colorTransformSettings"),(e.VIGNETTE||e.DITHER)&&n.push("vInverseScreenSize"),e.VIGNETTE&&(n.push("vignetteSettings1"),n.push("vignetteSettings2")),e.COLORCURVES&&Mh(n),e.DITHER&&n.push("ditherIntensity")}function Ux(n,e){e.COLORGRADING&&n.push("txColorTransform")}var Vx=A(()=>{ng()});var Je,sf=A(()=>{Qe();qe();ft();et();wx();Dn();Kt();Vx();Lt();Je=class n{constructor(){this.colorCurves=new mi,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=n.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new Ne(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=n.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.outputTextureWidth=0,this.outputTextureHeight=0,this.onUpdateParameters=new Y}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===n._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case n.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case n.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&&mi.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){let i=1/(this.outputTextureWidth||e.getEngine().getRenderWidth()),r=1/(this.outputTextureHeight||e.getEngine().getRenderHeight());if(e.setFloat2("vInverseScreenSize",i,r),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){let s=t!=null?t:r/i,a=Math.tan(this.vignetteCameraFov*.5),o=a*s,l=Math.sqrt(o*a);o=kc(o,l,this.vignetteStretch),a=kc(a,l,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,a,-o*this.vignetteCenterX,-a*this.vignetteCenterY);let c=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,c)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);let i=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(i-1)/i,.5/i,i,this.colorGradingTexture.level)}}clone(){return Me.Clone(()=>new n,this)}serialize(){return Me.Serialize(this)}static Parse(e){let t=Me.Parse(()=>new n,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}};Je.TONEMAPPING_STANDARD=0;Je.TONEMAPPING_ACES=1;Je.TONEMAPPING_KHR_PBR_NEUTRAL=2;Je.PrepareUniforms=Bx;Je.PrepareSamplers=Ux;Je._VIGNETTEMODE_MULTIPLY=0;Je._VIGNETTEMODE_OPAQUE=1;C([FI()],Je.prototype,"colorCurves",void 0);C([D()],Je.prototype,"_colorCurvesEnabled",void 0);C([Ze("colorGradingTexture")],Je.prototype,"_colorGradingTexture",void 0);C([D()],Je.prototype,"_colorGradingEnabled",void 0);C([D()],Je.prototype,"_colorGradingWithGreenDepth",void 0);C([D()],Je.prototype,"_colorGradingBGR",void 0);C([D()],Je.prototype,"_exposure",void 0);C([D()],Je.prototype,"_toneMappingEnabled",void 0);C([D()],Je.prototype,"_toneMappingType",void 0);C([D()],Je.prototype,"_contrast",void 0);C([D()],Je.prototype,"vignetteStretch",void 0);C([D()],Je.prototype,"vignetteCenterX",void 0);C([D()],Je.prototype,"vignetteCenterY",void 0);C([D()],Je.prototype,"vignetteWeight",void 0);C([ml()],Je.prototype,"vignetteColor",void 0);C([D()],Je.prototype,"vignetteCameraFov",void 0);C([D()],Je.prototype,"_vignetteBlendMode",void 0);C([D()],Je.prototype,"_vignetteEnabled",void 0);C([D()],Je.prototype,"_ditheringEnabled",void 0);C([D()],Je.prototype,"_ditheringIntensity",void 0);C([D()],Je.prototype,"_skipFinalColorClamp",void 0);C([D()],Je.prototype,"_applyByPostProcess",void 0);C([D()],Je.prototype,"_isEnabled",void 0);C([D()],Je.prototype,"outputTextureWidth",void 0);C([D()],Je.prototype,"outputTextureHeight",void 0);Me._ImageProcessingConfigurationParser=Je.Parse;je("BABYLON.ImageProcessingConfiguration",Je)});var Xi,af=A(()=>{ve();yt();Xi=class{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(M.NormalKind))return null;let i=this.pickedMesh.getIndices();(i==null?void 0:i.length)===0&&(i=null);let r,s=G.Vector3[0],a=G.Vector3[1],o=G.Vector3[2];if(t){let c=this.pickedMesh.getVerticesData(M.NormalKind),f=i?v.FromArrayToRef(c,i[this.faceId*3]*3,s):s.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),d=i?v.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),h=i?v.FromArrayToRef(c,i[this.faceId*3+2]*3,o):o.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]);f=f.scale(this.bu),d=d.scale(this.bv),h=h.scale(1-this.bu-this.bv),r=new v(f.x+d.x+h.x,f.y+d.y+h.y,f.z+d.z+h.z)}else{let c=this.pickedMesh.getVerticesData(M.PositionKind),f=i?v.FromArrayToRef(c,i[this.faceId*3]*3,s):s.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),d=i?v.FromArrayToRef(c,i[this.faceId*3+1]*3,a):a.copyFromFloats(c[(this.faceId*3+1)*3],c[(this.faceId*3+1)*3+1],c[(this.faceId*3+1)*3+2]),h=i?v.FromArrayToRef(c,i[this.faceId*3+2]*3,o):o.copyFromFloats(c[(this.faceId*3+2)*3],c[(this.faceId*3+2)*3+1],c[(this.faceId*3+2)*3+2]),u=f.subtract(d),m=h.subtract(d);r=v.Cross(u,m)}let l=(c,f)=>{if(this.thinInstanceIndex!==-1){let h=c._thinInstanceDataStorage.matrixData,u=this.thinInstanceIndex<<4;if(h&&h.length>u){let m=G.Matrix[0];U.FromArrayToRef(h,u,m),v.TransformNormalToRef(f,m,f)}}let d=c.getWorldMatrix();c.nonUniformScaling&&(G.Matrix[0].copyFrom(d),d=G.Matrix[0],d.setTranslationFromFloats(0,0,0),d.invert(),d.transposeToRef(G.Matrix[1]),d=G.Matrix[1]),v.TransformNormalToRef(f,d,f)};if(e&&l(this.pickedMesh,r),this.ray){let c=G.Vector3[0].copyFrom(r);e||l(this.pickedMesh,c),v.Dot(c,this.ray.direction)>0&&r.negateInPlace()}return r.normalize(),r}getTextureCoordinates(e=M.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;let t=this.pickedMesh.getIndices();if(!t)return null;let i=this.pickedMesh.getVerticesData(e);if(!i)return null;let r=_e.FromArray(i,t[this.faceId*3]*2),s=_e.FromArray(i,t[this.faceId*3+1]*2),a=_e.FromArray(i,t[this.faceId*3+2]*2);return r=r.scale(this.bu),s=s.scale(this.bv),a=a.scale(1-this.bu-this.bv),new _e(r.x+s.x+a.x,r.y+s.y+a.y)}}});var pi,sg=A(()=>{pi=class n{constructor(e,t,i,r,s,a){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=s,this.additionalData=a}static CreateNew(e,t,i){let r=e.getScene();return new n(e,r.pointerX,r.pointerY,r.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,r){return new n(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,r)}static CreateNewFromScene(e,t){return new n(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,r){return new n(e,t.x,t.y,null,i,r)}}});function of(n,e,t){let i=t.asArray(),r=e.asArray();for(let s=0;s<16;s++)i[s]=r[s];return i[12]-=n.x,i[13]-=n.y,i[14]-=n.z,t.markAsUpdated(),t}function Hx(n,e,t){return Hc(e,Br),of(n,Br,Ur),Hc(Ur,t),t}function yh(n,e,t){if(!Vr.eyeAtCamera)return Hx(n,e,t);let i=t.asArray(),r=e.asArray();for(let s=0;s<16;s++)i[s]=r[s];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function ag(n,e,t,i){return lo(yh(n,e,i),t,i),i}function zx(n,e,t,i,r){for(let s=0;s{no();ve();S_();ma();wr=new U,Br=new U,Ur=new U,Vr={getScene:()=>{},eyeAtCamera:!0};lf=Ut,og=Nt,Xx=lf.prototype._updateMatrixForUniform,Yx=Nt.prototype.setMatrix});var be,wt,vl=A(()=>{be=class{};be.NAME_EFFECTLAYER="EffectLayer";be.NAME_LAYER="Layer";be.NAME_LENSFLARESYSTEM="LensFlareSystem";be.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";be.NAME_PARTICLESYSTEM="ParticleSystem";be.NAME_GAMEPAD="Gamepad";be.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";be.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";be.NAME_PREPASSRENDERER="PrePassRenderer";be.NAME_DEPTHRENDERER="DepthRenderer";be.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";be.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";be.NAME_SPRITE="Sprite";be.NAME_SUBSURFACE="SubSurface";be.NAME_OUTLINERENDERER="Outline";be.NAME_PROCEDURALTEXTURE="ProceduralTexture";be.NAME_SHADOWGENERATOR="ShadowGenerator";be.NAME_OCTREE="Octree";be.NAME_PHYSICSENGINE="PhysicsEngine";be.NAME_AUDIO="Audio";be.NAME_FLUIDRENDERER="FluidRenderer";be.NAME_IBLCDFGENERATOR="iblCDFGenerator";be.NAME_CLUSTEREDLIGHTING="ClusteredLighting";be.STEP_ISREADYFORMESH_EFFECTLAYER=0;be.STEP_ISREADYFORMESH_DEPTHRENDERER=1;be.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;be.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;be.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;be.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;be.STEP_BEFORECAMERADRAW_PREPASS=0;be.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;be.STEP_BEFORECAMERADRAW_LAYER=2;be.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;be.STEP_BEFORERENDERTARGETDRAW_LAYER=1;be.STEP_BEFORERENDERINGMESH_PREPASS=0;be.STEP_BEFORERENDERINGMESH_OUTLINE=1;be.STEP_AFTERRENDERINGMESH_PREPASS=0;be.STEP_AFTERRENDERINGMESH_OUTLINE=1;be.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;be.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;be.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;be.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;be.STEP_BEFORECLEAR_PREPASS=1;be.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;be.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;be.STEP_AFTERRENDERTARGETDRAW_LAYER=1;be.STEP_AFTERCAMERADRAW_PREPASS=0;be.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;be.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;be.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;be.STEP_AFTERCAMERADRAW_LAYER=4;be.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;be.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;be.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;be.STEP_AFTERRENDER_AUDIO=0;be.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;be.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;be.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;be.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;be.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;be.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;be.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;be.STEP_POINTERMOVE_SPRITE=0;be.STEP_POINTERDOWN_SPRITE=0;be.STEP_POINTERUP_SPRITE=0;wt=class n extends Array{constructor(e){super(...e)}static Create(){return Object.create(n.prototype)}registerStep(e,t,i){let r=0,s;for(;r{ve();ye=class{};ye.POINTERDOWN=1;ye.POINTERUP=2;ye.POINTERMOVE=4;ye.POINTERWHEEL=8;ye.POINTERPICK=16;ye.POINTERTAP=32;ye.POINTERDOUBLETAP=64;Dh=class{constructor(e,t){this.type=e,this.event=t}},Lh=class extends Dh{constructor(e,t,i,r){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new _e(i,r)}},Gr=class extends Dh{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,i,r=null){super(e,t),this._pickInfo=i,this._inputManager=r}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}});var vs,Zx=A(()=>{vs=class n{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(let e in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(let e in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,e)){let t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(let t in n.Triggers)if(Object.prototype.hasOwnProperty.call(n.Triggers,t)&&parseInt(t)===e)return!0;return!1}};vs.Triggers={}});var hn,Tl,ff,Ph=A(()=>{hn=class{};hn.KEYDOWN=1;hn.KEYUP=2;Tl=class{constructor(e,t){this.type=e,this.event=t}},ff=class extends Tl{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 Ce,Ge,qx,Qx,Jx,$x,eC,Ao=A(()=>{(function(n){n[n.Generic=0]="Generic",n[n.Keyboard=1]="Keyboard",n[n.Mouse=2]="Mouse",n[n.Touch=3]="Touch",n[n.DualShock=4]="DualShock",n[n.Xbox=5]="Xbox",n[n.Switch=6]="Switch",n[n.DualSense=7]="DualSense"})(Ce||(Ce={}));(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.Move=12]="Move"})(Ge||(Ge={}));(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.DeltaHorizontal=10]="DeltaHorizontal",n[n.DeltaVertical=11]="DeltaVertical"})(qx||(qx={}));(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Share=8]="Share",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(Qx||(Qx={}));(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Create=8]="Create",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(Jx||(Jx={}));(function(n){n[n.A=0]="A",n[n.B=1]="B",n[n.X=2]="X",n[n.Y=3]="Y",n[n.LB=4]="LB",n[n.RB=5]="RB",n[n.LT=6]="LT",n[n.RT=7]="RT",n[n.Back=8]="Back",n[n.Start=9]="Start",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.LStickXAxis=17]="LStickXAxis",n[n.LStickYAxis=18]="LStickYAxis",n[n.RStickXAxis=19]="RStickXAxis",n[n.RStickYAxis=20]="RStickYAxis"})($x||($x={}));(function(n){n[n.B=0]="B",n[n.A=1]="A",n[n.Y=2]="Y",n[n.X=3]="X",n[n.L=4]="L",n[n.R=5]="R",n[n.ZL=6]="ZL",n[n.ZR=7]="ZR",n[n.Minus=8]="Minus",n[n.Plus=9]="Plus",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.Capture=17]="Capture",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(eC||(eC={}))});var tC,un,Oh=A(()=>{(function(n){n[n.PointerMove=0]="PointerMove",n[n.PointerDown=1]="PointerDown",n[n.PointerUp=2]="PointerUp"})(tC||(tC={}));un=class{};un.DOM_DELTA_PIXEL=0;un.DOM_DELTA_LINE=1;un.DOM_DELTA_PAGE=2});var mn,cg=A(()=>{Oh();Ao();mn=class{static CreateDeviceEvent(e,t,i,r,s,a,o){switch(e){case Ce.Keyboard:return this._CreateKeyboardEvent(i,r,s,a);case Ce.Mouse:if(i===Ge.MouseWheelX||i===Ge.MouseWheelY||i===Ge.MouseWheelZ)return this._CreateWheelEvent(e,t,i,r,s,a);case Ce.Touch:return this._CreatePointerEvent(e,t,i,r,s,a,o);default:throw`Unable to generate event for device ${Ce[e]}`}}static _CreatePointerEvent(e,t,i,r,s,a,o){let l=this._CreateMouseEvent(e,t,i,r,s,a);e===Ce.Mouse?(l.deviceType=Ce.Mouse,l.pointerId=1,l.pointerType="mouse"):(l.deviceType=Ce.Touch,l.pointerId=o!=null?o:t,l.pointerType="touch");let c=0;return c+=s.pollInput(e,t,Ge.LeftClick),c+=s.pollInput(e,t,Ge.RightClick)*2,c+=s.pollInput(e,t,Ge.MiddleClick)*4,l.buttons=c,i===Ge.Move?l.type="pointermove":i>=Ge.LeftClick&&i<=Ge.RightClick&&(l.type=r===1?"pointerdown":"pointerup",l.button=i-2),l}static _CreateWheelEvent(e,t,i,r,s,a){let o=this._CreateMouseEvent(e,t,i,r,s,a);switch(o.pointerId=1,o.type="wheel",o.deltaMode=un.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case Ge.MouseWheelX:o.deltaX=r;break;case Ge.MouseWheelY:o.deltaY=r;break;case Ge.MouseWheelZ:o.deltaZ=r;break}return o}static _CreateMouseEvent(e,t,i,r,s,a){let o=this._CreateEvent(a),l=s.pollInput(e,t,Ge.Horizontal),c=s.pollInput(e,t,Ge.Vertical);return a?(o.movementX=0,o.movementY=0,o.offsetX=o.movementX-a.getBoundingClientRect().x,o.offsetY=o.movementY-a.getBoundingClientRect().y):(o.movementX=s.pollInput(e,t,10),o.movementY=s.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,s),o.clientX=l,o.clientY=c,o.x=l,o.y=c,o.deviceType=e,o.deviceSlot=t,o.inputIndex=i,o}static _CreateKeyboardEvent(e,t,i,r){let s=this._CreateEvent(r);return this._CheckNonCharacterKeys(s,i),s.deviceType=Ce.Keyboard,s.deviceSlot=0,s.inputIndex=e,s.type=t===1?"keydown":"keyup",s.key=String.fromCharCode(e),s.keyCode=e,s}static _CheckNonCharacterKeys(e,t){let i=t.isDeviceAvailable(Ce.Keyboard),r=i&&t.pollInput(Ce.Keyboard,0,18)===1,s=i&&t.pollInput(Ce.Keyboard,0,17)===1,a=i&&(t.pollInput(Ce.Keyboard,0,91)===1||t.pollInput(Ce.Keyboard,0,92)===1||t.pollInput(Ce.Keyboard,0,93)===1),o=i&&t.pollInput(Ce.Keyboard,0,16)===1;e.altKey=r,e.ctrlKey=s,e.metaKey=a,e.shiftKey=o}static _CreateEvent(e){let t={};return t.preventDefault=()=>{},t.target=e,t}}});var Nh,iC=A(()=>{cg();Ao();Nh=class{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(r,s,a,o)=>{let l=mn.CreateDeviceEvent(r,s,a,o,this);i(r,s,l)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===Ce.Mouse||e===Ce.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}});var rC,nC,Fh,sC=A(()=>{Lr();Tt();cg();Ao();rC=255,nC=Object.keys(Ge).length/2,Fh=class{constructor(e,t,i,r){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=re.IsSafari(),this._usingMacOs=rs()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=s=>{},this._keyboardUpEvent=s=>{},this._keyboardBlurEvent=s=>{},this._pointerMoveEvent=s=>{},this._pointerDownEvent=s=>{},this._pointerUpEvent=s=>{},this._pointerCancelEvent=s=>{},this._pointerCancelTouch=s=>{},this._pointerLeaveEvent=s=>{},this._pointerWheelEvent=s=>{},this._pointerBlurEvent=s=>{},this._pointerMacOsChromeOutEvent=s=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=rs()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=rs()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=s=>{},this._gamepadDisconnectedEvent=s=>{},this._eventPrefix=re.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=r,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOs&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,i){let r=this._inputs[e][t];if(!r)throw`Unable to find device ${Ce[e]}`;e>=Ce.DualShock&&e<=Ce.DualSense&&this._updateDevice(e,t,i);let s=r[i];if(s===void 0)throw`Unable to find input ${i} for device ${Ce[e]} in slot ${t}`;return i===Ge.Move&&re.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),s}isDeviceAvailable(e){return this._inputs[e]!==void 0}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){let e=this==null?void 0:this._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs){for(let t of this._inputs)if(t)for(let i in t){let r=+i,s=t[r];if(s)for(let a=0;a{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Ce.Keyboard,0,rC));let t=this._inputs[Ce.Keyboard][0];if(t){t[e.keyCode]=1;let 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(Ce.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(Ce.Keyboard,0,rC));let t=this._inputs[Ce.Keyboard][0];if(t){t[e.keyCode]=0;let i=e;if(i.inputIndex=e.keyCode,this._usingMacOs&&e.key==="Meta"&&this._metaKeys.length>0){for(let r of this._metaKeys){let s=mn.CreateDeviceEvent(Ce.Keyboard,0,r,0,this,this._elementToAttachTo);t[r]=0,this._onInputChanged(Ce.Keyboard,0,s)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(Ce.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){let e=this._inputs[Ce.Keyboard][0];for(let t=0;t{let r=this._getPointerType(i),s=r===Ce.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===Ce.Touch&&s===-1){let o=this._activeTouchIds.indexOf(-1);if(o>=0)s=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(r,s);else{re.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][s]||this._addPointerDevice(r,s,i.clientX,i.clientY);let a=this._inputs[r][s];if(a){let o=i;o.inputIndex=Ge.Move,a[Ge.Horizontal]=i.clientX,a[Ge.Vertical]=i.clientY,r===Ce.Touch&&a[Ge.LeftClick]===0&&(a[Ge.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(r,s,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,a[i.button+2]=a[i.button+2]?0:1,this._onInputChanged(r,s,o))}},this._pointerDownEvent=i=>{let r=this._getPointerType(i),s=r===Ce.Mouse?0:i.pointerId;if(r===Ce.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)s=o,this._activeTouchIds[o]=i.pointerId;else{re.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][s]?r===Ce.Touch&&this._onDeviceConnected(r,s):this._addPointerDevice(r,s,i.clientX,i.clientY);let a=this._inputs[r][s];if(a){let o=a[Ge.Horizontal],l=a[Ge.Vertical];if(r===Ce.Mouse){if(i.pointerId===void 0&&(i.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch(f){}}else if(i.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(i.pointerId)}catch(f){}a[Ge.Horizontal]=i.clientX,a[Ge.Vertical]=i.clientY,a[i.button+2]=1;let c=i;c.inputIndex=i.button+2,this._onInputChanged(r,s,c),(o!==i.clientX||l!==i.clientY)&&(c.inputIndex=Ge.Move,this._onInputChanged(r,s,c))}},this._pointerUpEvent=i=>{var c,f,d,h,u;let r=this._getPointerType(i),s=r===Ce.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===Ce.Touch){if(s===-1)return;this._activeTouchIds[s]=-1}let a=(c=this._inputs[r])==null?void 0:c[s],o=i.button,l=a&&a[o+2]!==0;if(!l&&this._isUsingFirefox&&this._usingMacOs&&a&&(o=o===2?0:2,l=a[o+2]!==0),l){let m=a[Ge.Horizontal],p=a[Ge.Vertical];a[Ge.Horizontal]=i.clientX,a[Ge.Vertical]=i.clientY,a[o+2]=0;let _=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),(m!==i.clientX||p!==i.clientY)&&(_.inputIndex=Ge.Move,this._onInputChanged(r,s,_)),_.inputIndex=o+2,r===Ce.Mouse&&this._mouseId>=0&&((d=(f=this._elementToAttachTo).hasPointerCapture)!=null&&d.call(f,this._mouseId))?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&((u=(h=this._elementToAttachTo).hasPointerCapture)!=null&&u.call(h,i.pointerId))&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(r,s,_),r===Ce.Touch&&this._onDeviceDisconnected(r,s)}},this._pointerCancelTouch=i=>{var a,o;let r=this._activeTouchIds.indexOf(i);if(r===-1)return;(o=(a=this._elementToAttachTo).hasPointerCapture)!=null&&o.call(a,i)&&this._elementToAttachTo.releasePointerCapture(i),this._inputs[Ce.Touch][r][Ge.LeftClick]=0;let s=mn.CreateDeviceEvent(Ce.Touch,r,Ge.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(Ce.Touch,r,s),this._activeTouchIds[r]=-1,this._onDeviceDisconnected(Ce.Touch,r)},this._pointerCancelEvent=i=>{var r,s;if(i.pointerType==="mouse"){let a=this._inputs[Ce.Mouse][0];this._mouseId>=0&&((s=(r=this._elementToAttachTo).hasPointerCapture)!=null&&s.call(r,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let o=Ge.LeftClick;o<=Ge.BrowserForward;o++)if(a[o]===1){a[o]=0;let l=mn.CreateDeviceEvent(Ce.Mouse,0,o,0,this,this._elementToAttachTo);this._onInputChanged(Ce.Mouse,0,l)}}else this._pointerCancelTouch(i.pointerId)},this._pointerLeaveEvent=i=>{i.pointerType==="pen"&&this._pointerCancelTouch(i.pointerId)},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let e=!1,t=function(){};try{let i=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,i),this._elementToAttachTo.removeEventListener("test",t,i)}catch(i){}this._pointerBlurEvent=()=>{var i,r,s,a,o;if(this.isDeviceAvailable(Ce.Mouse)){let l=this._inputs[Ce.Mouse][0];this._mouseId>=0&&((r=(i=this._elementToAttachTo).hasPointerCapture)!=null&&r.call(i,this._mouseId))&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let c=Ge.LeftClick;c<=Ge.BrowserForward;c++)if(l[c]===1){l[c]=0;let f=mn.CreateDeviceEvent(Ce.Mouse,0,c,0,this,this._elementToAttachTo);this._onInputChanged(Ce.Mouse,0,f)}}if(this.isDeviceAvailable(Ce.Touch)){let l=this._inputs[Ce.Touch];for(let c=0;c{let r=Ce.Mouse,s=0;this._inputs[r]||(this._inputs[r]=[]),this._inputs[r][s]||(this._pointerActive=!0,this._registerDevice(r,s,nC));let a=this._inputs[r][s];if(a){a[Ge.MouseWheelX]=i.deltaX||0,a[Ge.MouseWheelY]=i.deltaY||i.wheelDelta||0,a[Ge.MouseWheelZ]=i.deltaZ||0;let o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),a[Ge.MouseWheelX]!==0&&(o.inputIndex=Ge.MouseWheelX,this._onInputChanged(r,s,o)),a[Ge.MouseWheelY]!==0&&(o.inputIndex=Ge.MouseWheelY,this._onInputChanged(r,s,o)),a[Ge.MouseWheelZ]!==0&&(o.inputIndex=Ge.MouseWheelZ,this._onInputChanged(r,s,o))}},this._usingMacOs&&this._isUsingChromium&&(this._pointerMacOsChromeOutEvent=i=>{i.buttons>1&&this._pointerCancelEvent(i)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,e?{passive:!1}:!1),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(()=>{if(this.isDeviceAvailable(Ce.Mouse)){let i=this._inputs[Ce.Mouse][0];i[Ge.MouseWheelX]=0,i[Ge.MouseWheelY]=0,i[Ge.MouseWheelZ]=0}})}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){let 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){let r=navigator.getGamepads()[t];if(r&&e===this._gamepads[t]){let s=this._inputs[e][t];i>=r.buttons.length?s[i]=r.axes[i-r.buttons.length].valueOf():s[i]=r.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?Ce.DualSense:Ce.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?Ce.Xbox:e.indexOf("057e")!==-1?Ce.Switch:Ce.Generic}_getPointerType(e){let t=Ce.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=Ce.Touch),t}}});var df,aC=A(()=>{ft();df=class{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new Y,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}});var wh,oC=A(()=>{Ao();iC();sC();aC();wh=class{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=a=>{for(let o=0;o{let o=this._registeredManagers.indexOf(a);o>-1&&this._registeredManagers.splice(o,1)};let t=Object.keys(Ce).length/2;this._devices=new Array(t);let i=(a,o)=>{this._devices[a]||(this._devices[a]=new Array),this._devices[a][o]||(this._devices[a][o]=o);for(let l of this._registeredManagers){let c=new df(this._deviceInputSystem,a,o);l._addDevice(c)}},r=(a,o)=>{var l;(l=this._devices[a])!=null&&l[o]&&delete this._devices[a][o];for(let c of this._registeredManagers)c._removeDevice(a,o)},s=(a,o,l)=>{if(l)for(let c of this._registeredManagers)c._onInputChanged(a,o,l)};typeof _native!="undefined"?this._deviceInputSystem=new Nh(i,r,s):this._deviceInputSystem=new Fh(e,i,r,s)}dispose(){this._deviceInputSystem.dispose()}}});var Bh,lC=A(()=>{Ao();ft();oC();Bh=class{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){let t=Object.keys(Ce).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new wh(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new Y(i=>{for(let r of this._devices)if(r)for(let s of r)s&&this.onDeviceConnectedObservable.notifyObserver(i,s)}),this.onDeviceDisconnectedObservable=new Y,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add(()=>{this.dispose()})}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=[]),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){var r,s;let i=(r=this._devices[e])==null?void 0:r[t];this.onDeviceDisconnectedObservable.notifyObservers(i),(s=this._devices[e])!=null&&s[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){var r,s;(s=(r=this._devices[e])==null?void 0:r[t])==null||s.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case Ce.Keyboard:case Ce.Mouse:this._firstDevice[e]=0;break;case Ce.Touch:case Ce.DualSense:case Ce.DualShock:case Ce.Xbox:case Ce.Switch:case Ce.Generic:{delete this._firstDevice[e];let t=this._devices[e];if(t){for(let i=0;i{Ro=class{};Ro._IsPickingAvailable=!1});var Uh,yi,cC=A(()=>{dn();Zx();af();ve();sg();Ph();Ao();lC();At();fg();Uh=class{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}},yi=class n{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 _e(0,0),this._previousStartingPointerPosition=new _e(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||ue.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 _e(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){let 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){let i=this._scene,r=i.getEngine(),s=r.getInputElement();s&&(s.tabIndex=r.canvasTabIndex,i.doNotHandleCursors||(s.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(let l of i._pointerMoveStage){e=e||this._pickMove(t);let c=!!(e!=null&&e.pickedMesh);e=l.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,c,s)}let a=t.inputIndex>=Ge.MouseWheelX&&t.inputIndex<=Ge.MouseWheelZ?ye.POINTERWHEEL:ye.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,a));let o;e?(o=new Gr(a,t,e),this._setRayOnPointerInfo(e,t)):(o=new Gr(a,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,a)}_setRayOnPointerInfo(e,t){let i=this._scene;e&&Ro._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,U.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){let r=this._scene,s=new Lh(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(s.originalPickingInfo=e,s.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(s.nearInteractionPickingInfo=e)),r.onPrePointerObservable.notifyObservers(s,i),!!s.skipOnPointerObservable}_pickMove(e){let 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){let s=i.getEngine().getInputElement();if(e!=null&&e.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&s&&this._pointerOverMesh){let a=this._pointerOverMesh._getActionManagerForTrigger();a&&a.hasPointerTriggers&&(s.style.cursor=a.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){let i=new PointerEvent("pointermove",t);i.inputIndex=Ge.Move,!this._checkPrePointerObservable(e,i,ye.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){let i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,ye.POINTERDOWN)&&this._processPointerDown(e,i)}_processPointerDown(e,t){let i=this._scene;if(e!=null&&e.pickedMesh){this._pickedDownMesh=e.pickedMesh;let a=e.pickedMesh._getActionManagerForTrigger();if(a){if(a.hasPickTriggers)switch(a.processTrigger(5,new pi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:a.processTrigger(2,new pi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:a.processTrigger(4,new pi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:a.processTrigger(3,new pi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break}a.hasSpecificTrigger(8)&&window.setTimeout(()=>{let o=i.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,l=>l.isPickable&&l.isVisible&&l.isReady()&&l.actionManager&&l.actionManager.hasSpecificTrigger(8)&&l===this._pickedDownMesh,!1,i.cameraToUseForPointers);o!=null&&o.pickedMesh&&a&&this._activePointerIdsCount!==0&&Date.now()-this._startingPointerTime>n.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,a.processTrigger(8,pi.CreateNew(o.pickedMesh,t)))},n.LongPressDelay)}}else for(let a of i._pointerDownStage)e=a.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let r,s=ye.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,s),r=new Gr(s,t,e),this._setRayOnPointerInfo(e,t)):r=new Gr(s,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(r,s)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){let r=new PointerEvent("pointerup",t);r.inputIndex=Ge.Move;let s=new Uh;i?s.doubleClick=!0:s.singleClick=!0,!this._checkPrePointerObservable(e,r,ye.POINTERUP)&&this._processPointerUp(e,r,s)}_processPointerUp(e,t,i){let r=this._scene;if(e!=null&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(r.onPointerPick&&r.onPointerPick(t,e),i.singleClick&&!i.ignore&&r.onPointerObservable.observers.length>this._cameraObserverCount)){let a=ye.POINTERPICK,o=new Gr(a,t,e);this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(o,a)}let s=e.pickedMesh._getActionManagerForTrigger();if(s&&!i.ignore){s.processTrigger(7,pi.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&s.processTrigger(1,pi.CreateNew(e.pickedMesh,t,e));let a=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&a&&a.processTrigger(6,pi.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(let s of r._pointerUpStage)e=s.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){let s=this._pickedDownMesh._getActionManagerForTrigger(16);s&&s.processTrigger(16,pi.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){let s=new Gr(ye.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(s,ye.POINTERUP),r.onPointerUp&&r.onPointerUp(t,e,ye.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let a=0;if(i.singleClick?a=ye.POINTERTAP:i.doubleClick&&(a=ye.POINTERDOUBLETAP),a){let o=new Gr(a,t,e);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(a)&&r.onPointerObservable.notifyObservers(o,a)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,r=null){let s=this._scene,a=s.getEngine();r||(r=a.getInputElement()),this._alreadyAttached&&this.detachControl(),r&&(this._alreadyAttachedTo=r),this._deviceSourceManager=new Bh(a),this._initActionManager=o=>{if(!this._meshPickProceed){let l=s.skipPointerUpPicking||s._registeredActions===0&&!this._checkForPicking()&&!s.onPointerUp?null:s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,s.pointerUpPredicate,s.pointerUpFastCheck,s.cameraToUseForPointers,s.pointerUpTrianglePredicate);this._currentPickResult=l,l&&(o=l.hit&&l.pickedMesh?l.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return o},this._delayedSimpleClick=(o,l,c)=>{if((Date.now()-this._previousStartingPointerTime>n.DoubleClickDelay&&!this._doubleClickOccured||o!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,l.singleClick=!0,l.ignore=!1,this._delayedClicks[o])){let f=this._delayedClicks[o].evt,d=ye.POINTERTAP,h=new Gr(d,f,this._currentPickResult);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(d)&&s.onPointerObservable.notifyObservers(h,d),this._delayedClicks[o]=null}},this._initClickEvent=(o,l,c,f)=>{var p,_;let d=new Uh;this._currentPickResult=null;let h=null,u=o.hasSpecificMask(ye.POINTERPICK)||l.hasSpecificMask(ye.POINTERPICK)||o.hasSpecificMask(ye.POINTERTAP)||l.hasSpecificMask(ye.POINTERTAP)||o.hasSpecificMask(ye.POINTERDOUBLETAP)||l.hasSpecificMask(ye.POINTERDOUBLETAP);!u&&vs&&(h=this._initActionManager(h,d),h&&(u=h.hasPickTriggers));let m=!1;if(u=u&&!this._isMultiTouchGesture,u){let g=c.button;if(d.hasSwiped=this._isPointerSwiping(),!d.hasSwiped){let T=!n.ExclusiveDoubleClickMode;if(T||(T=!o.hasSpecificMask(ye.POINTERDOUBLETAP)&&!l.hasSpecificMask(ye.POINTERDOUBLETAP),T&&!vs.HasSpecificTrigger(6)&&(h=this._initActionManager(h,d),h&&(T=!h.hasSpecificTrigger(6)))),T)(Date.now()-this._previousStartingPointerTime>n.DoubleClickDelay||g!==this._previousButtonPressed)&&(d.singleClick=!0,f(d,this._currentPickResult),m=!0);else{let R={evt:c,clickInfo:d,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,g,d,f),n.DoubleClickDelay)};this._delayedClicks[g]=R}let b=o.hasSpecificMask(ye.POINTERDOUBLETAP)||l.hasSpecificMask(ye.POINTERDOUBLETAP);!b&&vs.HasSpecificTrigger(6)&&(h=this._initActionManager(h,d),h&&(b=h.hasSpecificTrigger(6))),b&&(g===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime{if(this._updatePointerPosition(o),!this._isSwiping&&this._swipeButtonPressed!==-1&&(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>n.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>n.DragMovementThreshold),a.isPointerLock&&a._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=Ge.MouseWheelX&&o.inputIndex<=Ge.MouseWheelZ?ye.POINTERWHEEL:ye.POINTERMOVE)||!s.cameraToUseForPointers&&!s.activeCamera)return;if(s.skipPointerMovePicking){this._processPointerMove(new Xi,o);return}s.pointerMovePredicate||(s.pointerMovePredicate=c=>c.isPickable&&c.isVisible&&c.isReady()&&c.isEnabled()&&(c.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||c._getActionManagerForTrigger()!==null)&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&c.layerMask)!==0));let l=s._registeredActions>0||s.constantlyUpdateMeshUnderPointer?this._pickMove(o):null;this._processPointerMove(l,o)},this._onPointerDown=o=>{var f;let l=this._activePointerIds.indexOf(-1);if(l===-1?this._activePointerIds.push(o.pointerId):this._activePointerIds[l]=o.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,n.ExclusiveDoubleClickMode){for(let d=0;dd.isPickable&&d.isVisible&&d.isReady()&&d.isEnabled()&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&d.layerMask)!==0)),this._pickedDownMesh=null;let c;s.skipPointerDownPicking||s._registeredActions===0&&!this._checkForPicking()&&!s.onPointerDown?c=new Xi:c=s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,s.pointerDownPredicate,s.pointerDownFastCheck,s.cameraToUseForPointers,s.pointerDownTrianglePredicate),this._processPointerDown(c,o)},this._onPointerUp=o=>{let l=this._activePointerIds.indexOf(o.pointerId);l!==-1&&(this._activePointerIds[l]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(o),s.preventDefaultOnPointerUp&&r&&(o.preventDefault(),r.focus()),this._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,o,(c,f)=>{if(s.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!c.ignore)){if(this._checkPrePointerObservable(null,o,ye.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}c.hasSwiped||(c.singleClick&&s.onPrePointerObservable.hasSpecificMask(ye.POINTERTAP)&&this._checkPrePointerObservable(null,o,ye.POINTERTAP)&&(this._skipPointerTap=!0),c.doubleClick&&s.onPrePointerObservable.hasSpecificMask(ye.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,ye.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),!(!s.cameraToUseForPointers&&!s.activeCamera)&&(s.pointerUpPredicate||(s.pointerUpPredicate=d=>d.isPickable&&d.isVisible&&d.isReady()&&d.isEnabled()&&(!s.cameraToUseForPointers||(s.cameraToUseForPointers.layerMask&d.layerMask)!==0)),!this._meshPickProceed&&(vs&&vs.HasTriggers||this._checkForPicking()||s.onPointerUp)&&this._initActionManager(null,c),f||(f=this._currentPickResult),this._processPointerUp(f,o,c),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))}))},this._onKeyDown=o=>{let l=hn.KEYDOWN;if(s.onPreKeyboardObservable.hasObservers()){let c=new ff(l,o);if(s.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(s.onKeyboardObservable.hasObservers()){let c=new Tl(l,o);s.onKeyboardObservable.notifyObservers(c,l)}s.actionManager&&s.actionManager.processTrigger(14,pi.CreateNewFromScene(s,o))},this._onKeyUp=o=>{let l=hn.KEYUP;if(s.onPreKeyboardObservable.hasObservers()){let c=new ff(l,o);if(s.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(s.onKeyboardObservable.hasObservers()){let c=new Tl(l,o);s.onKeyboardObservable.notifyObservers(c,l)}s.actionManager&&s.actionManager.processTrigger(15,pi.CreateNewFromScene(s,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===Ce.Mouse?o.onInputChangedObservable.add(l=>{this._originMouseEvent=l,l.inputIndex===Ge.LeftClick||l.inputIndex===Ge.MiddleClick||l.inputIndex===Ge.RightClick||l.inputIndex===Ge.BrowserBack||l.inputIndex===Ge.BrowserForward?t&&o.getInput(l.inputIndex)===1?this._onPointerDown(l):e&&o.getInput(l.inputIndex)===0&&this._onPointerUp(l):i&&(l.inputIndex===Ge.Move?this._onPointerMove(l):(l.inputIndex===Ge.MouseWheelX||l.inputIndex===Ge.MouseWheelY||l.inputIndex===Ge.MouseWheelZ)&&this._onPointerMove(l))}):o.deviceType===Ce.Touch?o.onInputChangedObservable.add(l=>{l.inputIndex===Ge.LeftClick&&(t&&o.getInput(l.inputIndex)===1?(this._onPointerDown(l),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&o.getInput(l.inputIndex)===0&&(this._onPointerUp(l),this._activePointerIdsCount===0&&(this._isMultiTouchGesture=!1))),i&&l.inputIndex===Ge.Move&&this._onPointerMove(l)}):o.deviceType===Ce.Keyboard&&o.onInputChangedObservable.add(l=>{l.type==="keydown"?this._onKeyDown(l):l.type==="keyup"&&this._onKeyUp(l)})}),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,r){if(this._meshUnderPointerId[t]===e&&(!e||!e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;let s=this._meshUnderPointerId[t],a;s&&(a=s._getActionManagerForTrigger(10),a&&a.processTrigger(10,new pi(s,this._pointerX,this._pointerY,e,r,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,a=e._getActionManagerForTrigger(9),a&&a.processTrigger(9,new pi(e,this._pointerX,this._pointerY,e,r,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null),this._scene.onMeshUnderPointerUpdatedObservable.hasObservers()&&this._scene.onMeshUnderPointerUpdatedObservable.notifyObservers({mesh:e,pointerId:t})}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(let t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}};yi.DragMovementThreshold=10;yi.LongPressDelay=500;yi.DoubleClickDelay=300;yi.ExclusiveDoubleClickMode=!1});var Bn,dg=A(()=>{ns();Bn=class n{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){n.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){n.Enabled&&(this._startMonitoringTime=kt.Now)}endMonitoring(e=!0){if(!n.Enabled)return;e&&this.fetchNewFrame();let t=kt.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;let e=kt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}};Bn.Enabled=!0});var Ts,Vh=A(()=>{Ts=class{static get UniqueId(){let e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}};Ts._UniqueIdCounter=1});var Gh,fC=A(()=>{Gh=class{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}});var sG,aG,dC,st,sr=A(()=>{Tt();ns();ft();cn();Fx();ha();ve();sf();ma();af();sg();vh();cf();Sh();vl();Lr();At();Ei();cC();dg();et();ah();Vh();ds();$c();Ln();fC();ze();Lt();Mn();sG=new vt,aG=new vt;(function(n){n[n.BackwardCompatible=0]="BackwardCompatible",n[n.Intermediate=1]="Intermediate",n[n.Aggressive=2]="Aggressive"})(dC||(dC={}));st=class n{static DefaultMaterialFactory(e){throw Ie("StandardMaterial")}static CollisionCoordinatorFactory(){throw Ie("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1;break}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.onEnvironmentTextureChangedObservable.notifyObservers(e),this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(let t of this.skeletons)e=e.concat(t.bones);return e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return yi.DragMovementThreshold}static set DragMovementThreshold(e){yi.DragMovementThreshold=e}static get LongPressDelay(){return yi.LongPressDelay}static set LongPressDelay(e){yi.LongPressDelay=e}static get DoubleClickDelay(){return yi.DoubleClickDelay}static set DoubleClickDelay(e){yi.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return yi.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){yi.ExclusiveDoubleClickMode=e}get _eyePosition(){var e,t,i;return(i=(t=this._forcedViewPosition)!=null?t:(e=this.activeCamera)==null?void 0:e.globalPosition)!=null?i:v.ZeroReadOnly}bindEyePosition(e,t="vEyePosition",i=!1){let r=this._eyePosition,s=this.useRightHandedSystem===(this._mirroredCameraPosition!=null),a=this.floatingOriginOffset,o=sG.set(r.x,r.y,r.z,s?-1:1),l=o.subtractFromFloatsToRef(a.x,a.y,a.z,0,aG);return e&&(i?e.setFloat3(t,l.x,l.y,l.z):e.setVector4(t,l)),o}finalizeSceneUbo(){let e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null),i=this.floatingOriginOffset;return e.updateFloat4("vEyePosition",t.x-i.x,t.y-i.y,t.z-i.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=nh(e,()=>{this.onActiveCamerasChanged.notifyObservers(this)})),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get _hasDefaultMaterial(){return n.DefaultMaterialFactory!==n._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=n.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph){this._frameGraph=e,e||(this.customRenderFunction=this._currentCustomRenderFunction);return}this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph,this.activeCamera=null)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=n.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(let e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);let t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(let t of this._components)if(t.name===e)return t;return null}get uniqueId(){return this._uniqueId}constructor(e,t){this._inputManager=new yi(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new Ne(.2,.2,.3,1),this.onClearColorChangedObservable=new Y,this.ambientColor=new oe(0,0,0),this.environmentIntensity=1,this.iblIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new Y,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.objectRenderers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new Y,this._onDisposeObserver=null,this.onBeforeRenderObservable=new Y,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new Y,this.onAfterRenderCameraObservable=new Y,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new Y,this.onAfterAnimationsObservable=new Y,this.onBeforeDrawPhaseObservable=new Y,this.onAfterDrawPhaseObservable=new Y,this.onReadyObservable=new Y,this.onBeforeCameraRenderObservable=new Y,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new Y,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new Y,this.onAfterActiveMeshesEvaluationObservable=new Y,this.onBeforeParticlesRenderingObservable=new Y,this.onAfterParticlesRenderingObservable=new Y,this.onDataLoadedObservable=new Y,this.onNewCameraAddedObservable=new Y,this.onCameraRemovedObservable=new Y,this.onNewLightAddedObservable=new Y,this.onLightRemovedObservable=new Y,this.onNewGeometryAddedObservable=new Y,this.onGeometryRemovedObservable=new Y,this.onNewTransformNodeAddedObservable=new Y,this.onTransformNodeRemovedObservable=new Y,this.onNewMeshAddedObservable=new Y,this.onMeshRemovedObservable=new Y,this.onNewSkeletonAddedObservable=new Y,this.onSkeletonRemovedObservable=new Y,this.onNewParticleSystemAddedObservable=new Y,this.onParticleSystemRemovedObservable=new Y,this.onNewAnimationGroupAddedObservable=new Y,this.onAnimationGroupRemovedObservable=new Y,this.onNewMaterialAddedObservable=new Y,this.onNewMultiMaterialAddedObservable=new Y,this.onMaterialRemovedObservable=new Y,this.onMultiMaterialRemovedObservable=new Y,this.onNewTextureAddedObservable=new Y,this.onTextureRemovedObservable=new Y,this.onNewFrameGraphAddedObservable=new Y,this.onFrameGraphRemovedObservable=new Y,this.onNewObjectRendererAddedObservable=new Y,this.onObjectRendererRemovedObservable=new Y,this.onNewPostProcessAddedObservable=new Y,this.onPostProcessRemovedObservable=new Y,this.onNewEffectLayerAddedObservable=new Y,this.onEffectLayerRemovedObservable=new Y,this.onBeforeRenderTargetsRenderObservable=new Y,this.onAfterRenderTargetsRenderObservable=new Y,this.onBeforeStepObservable=new Y,this.onAfterStepObservable=new Y,this.onActiveCameraChanged=new Y,this.onActiveCamerasChanged=new Y,this.onBeforeRenderingGroupObservable=new Y,this.onAfterRenderingGroupObservable=new Y,this.onMeshImportedObservable=new Y,this.onAnimationFileImportedObservable=new Y,this.onEnvironmentTextureChangedObservable=new Y,this.onMeshUnderPointerUpdatedObservable=new Y,this._registeredForLateAnimationBindings=new ln(256),this._pointerPickingConfiguration=new Gh,this.onPrePointerObservable=new Y,this.onPointerObservable=new Y,this.onPreKeyboardObservable=new Y,this.onKeyboardObservable=new Y,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=n.FOGMODE_NONE,this.fogColor=new oe(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.frameGraphs=[],this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new v(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new ln(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new Bn,this._activeIndices=new Bn,this._activeParticles=new Bn,this._activeBones=new Bn,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=[],this._isDisposed=!1,this._isReadyChecks=[],this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new Ct(256),this._processedMaterials=new Ct(256),this._renderTargets=new ln(256),this._materialsRenderTargets=new ln(256),this._activeParticleSystems=new Ct(256),this._activeSkeletons=new ln(32),this._softwareSkinnedMeshes=new ln(32),this._activeAnimatables=new Array,this._transformMatrix=U.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=wt.Create(),this._beforeClearStage=wt.Create(),this._beforeRenderTargetClearStage=wt.Create(),this._gatherRenderTargetsStage=wt.Create(),this._gatherActiveCameraRenderTargetsStage=wt.Create(),this._isReadyForMeshStage=wt.Create(),this._beforeEvaluateActiveMeshStage=wt.Create(),this._evaluateSubMeshStage=wt.Create(),this._preActiveMeshStage=wt.Create(),this._cameraDrawRenderTargetStage=wt.Create(),this._beforeCameraDrawStage=wt.Create(),this._beforeRenderTargetDrawStage=wt.Create(),this._beforeRenderingGroupDrawStage=wt.Create(),this._beforeRenderingMeshStage=wt.Create(),this._afterRenderingMeshStage=wt.Create(),this._afterRenderingGroupDrawStage=wt.Create(),this._afterCameraDrawStage=wt.Create(),this._afterCameraPostProcessStage=wt.Create(),this._afterRenderTargetDrawStage=wt.Create(),this._afterRenderTargetPostProcessStage=wt.Create(),this._afterRenderStage=wt.Create(),this._pointerMoveStage=wt.Create(),this._pointerDownStage=wt.Create(),this._pointerUpStage=wt.Create(),this._geometriesByUniqueId=null,this._uniqueId=0,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this.onReadyTimeoutObservable=new Y,this.onReadyTimeoutDuration=120*1e3,this._timeoutChecksStartTime=0,this._floatingOriginScene=void 0,this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._freezeActiveMeshesCancel=null,this._useCurrentFrameBuffer=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._getFloatingOriginScene=()=>this._floatingOriginScene,this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[],this._uniqueId=this.getUniqueId();let i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,defaultCameraLayerMask:268435455,defaultRenderableLayerMask:268435455,...t};this.defaultCameraLayerMask=i.defaultCameraLayerMask,this.defaultRenderableLayerMask=i.defaultRenderableLayerMask,e=this._engine=e||ue.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(ue._LastCreatedScene=this,e.scenes.push(this)),(e.getCreationOptions().useLargeWorldRendering||t!=null&&t.useFloatingOrigin)&&(jx(),this._floatingOriginScene=this,Vr.getScene=this._getFloatingOriginScene),this._uid=null,this._renderingManager=new Nr(this),ms&&(this.postProcessManager=new ms(this)),Bt()&&this.attachControl(),this._createUbo(),Je&&(this._imageProcessingConfiguration=new Je),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 a,o,l;if(this._isDisposed)return!1;let t,i=this.getEngine(),r=i.currentRenderPassId;i.currentRenderPassId=(o=(a=this.activeCamera)==null?void 0:a.renderPassId)!=null?o:r;let s=!0;for(this._pendingData.length>0&&(s=!1),(l=this.prePassRenderer)==null||l.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&s&&(s=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t0;for(let h of this._isReadyForMeshStage)h.action(c,f)||(s=!1);if(!e)continue;let d=c.material||this.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(let h of c.subMeshes){let u=h.getMaterial();u&&u.hasRenderTargetTextures&&u.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(u)===-1&&(this._processedMaterials.push(u),this._materialsRenderTargets.concatWithNoDuplicate(u.getRenderTargetTextures()))}else d.hasRenderTargetTextures&&d.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(d)===-1&&(this._processedMaterials.push(d),this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))}if(e){for(t=0;t0)for(let c of this.activeCameras)c.isReady(!0)||(s=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(s=!1));for(let c of this.particleSystems)c.isReady()||(s=!1);if(this.proceduralTexturesEnabled)for(let c of this.proceduralTextures)c.isReady()||(s=!1);if(this.layers)for(let c of this.layers)c.isReady()||(s=!1);if(this.effectLayers)for(let c of this.effectLayers)c.isLayerReady()||(s=!1);for(let c of this._isReadyChecks)c.isReady()||(s=!1);return i.areAllEffectsReady()||(s=!1),i.currentRenderPassId=r,s}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){let 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){let 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}addIsReadyCheck(e){this._isReadyChecks.indexOf(e)===-1&&this._isReadyChecks.push(e)}removeIsReadyCheck(e){let t=this._isReadyChecks.indexOf(e);t!==-1&&this._isReadyChecks.splice(t,1)}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),this._executeWhenReadyTimeoutId===null&&this._checkIsReady(t)}async whenReadyAsync(e=!1){return await new Promise(t=>{this.executeWhenReady(()=>{t()},e)})}_clearReadynessChecksData(){this._timeoutChecksStartTime=0,this.onReadyTimeoutObservable.clear(),this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null}_checkIsReady(e=!1){if(this._registerTransientComponents(),this._timeoutChecksStartTime===0)this._timeoutChecksStartTime=kt.Now;else if(this.onReadyTimeoutDuration>0&&kt.Now-this._timeoutChecksStartTime>this.onReadyTimeoutDuration){this.onReadyTimeoutObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this.isReady(e)){this.onReadyObservable.notifyObservers(this),this._clearReadynessChecksData();return}if(this._isDisposed){this._clearReadynessChecksData();return}this._executeWhenReadyTimeoutId=setTimeout(()=>{this.incrementRenderId(),this._checkIsReady(e)},100)}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=kt.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getInverseProjectionMatrix(){return this._inverseProjectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,i,r){this._multiviewSceneUboIsActive=!!(i&&r&&this._multiviewSceneUbo),!(this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag)&&(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._inverseProjectionMatrix||(this._inverseProjectionMatrix=new U),this._projectionMatrix.invertToRef(this._inverseProjectionMatrix),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?oa.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=oa.GetPlanes(this._transformMatrix),this._multiviewSceneUboIsActive&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,r):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix),this._sceneUbo.updateMatrix("inverseProjection",this._inverseProjectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUboIsActive&&this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e,t){let i=typeof t=="boolean"?t:t==null?void 0:t.trackUBOsInFrame,r=new Ut(this._engine,void 0,!1,e!=null?e:"scene",void 0,i);return r.addUniform("viewProjection",16),r.addUniform("view",16),r.addUniform("projection",16),r.addUniform("vEyePosition",4),r.addUniform("inverseProjection",16),r}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}get floatingOriginMode(){return this._floatingOriginScene!==void 0}get floatingOriginOffset(){return this.floatingOriginMode?this._eyePosition:v.ZeroReadOnly}getUniqueId(){return Ts.UniqueId}addMesh(e,t=!1){if(!this._blockEntityCollection&&(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),re.SetImmediate(()=>{this.onNewMeshAddedObservable.notifyObservers(e)}),t)){let i=e.getChildMeshes();for(let r of i)this.addMesh(r)}}removeMesh(e,t=!1){let i=this.meshes.indexOf(e);if(i!==-1&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t){let r=e.getChildMeshes();for(let s of r)this.removeMesh(s)}return i}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneTransformNodesArray!==-1||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){let t=e._indexInSceneTransformNodesArray;if(t!==-1){if(t!==this.transformNodes.length-1){let 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){let t=this.skeletons.indexOf(e);return t!==-1&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){let t=this.morphTargetManagers.indexOf(e);return t!==-1&&this.morphTargetManagers.splice(t,1),t}removeLight(e){let t=this.lights.indexOf(e);if(t!==-1){for(let i of this.meshes)i._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes(),this.onLightRemovedObservable.notifyObservers(e)}return t}removeCamera(e){let t=this.cameras.indexOf(e);if(t!==-1&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){let 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){let t=this.particleSystems.indexOf(e);return t!==-1&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),this.onParticleSystemRemovedObservable.notifyObservers(e),t}removeAnimation(e){let t=this.animations.indexOf(e);return t!==-1&&this.animations.splice(t,1),t}stopAnimation(e,t,i){}removeAnimationGroup(e){let t=this.animationGroups.indexOf(e);return t!==-1&&this.animationGroups.splice(t,1),this.onAnimationGroupRemovedObservable.notifyObservers(e),t}removeMultiMaterial(e){let t=this.multiMaterials.indexOf(e);return t!==-1&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){let t=e._indexInSceneMaterialArray;if(t!==-1&&t{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(it.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),re.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),re.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||(this.particleSystems.push(e),re.SetImmediate(()=>{this.onNewParticleSystemAddedObservable.notifyObservers(e)}))}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||(this.animationGroups.push(e),re.SetImmediate(()=>{this.onNewAnimationGroupAddedObservable.notifyObservers(e)}))}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),re.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),re.SetImmediate(()=>{this.onNewMaterialAddedObservable.notifyObservers(e)}))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}addFrameGraph(e){this.frameGraphs.push(e),re.SetImmediate(()=>{this.onNewFrameGraphAddedObservable.notifyObservers(e)})}addObjectRenderer(e){this.objectRenderers.push(e),re.SetImmediate(()=>{this.onNewObjectRendererAddedObservable.notifyObservers(e)})}addPostProcess(e){this._blockEntityCollection||(this.postProcesses.push(e),re.SetImmediate(()=>{this.onNewPostProcessAddedObservable.notifyObservers(e)}))}addEffectLayer(e){this._blockEntityCollection||(this.effectLayers.push(e),re.SetImmediate(()=>{this.onNewEffectLayerAddedObservable.notifyObservers(e)}))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){let t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){let t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;ti.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.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){let 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=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];for(t=this.skeletons.length-1;t>=0;t--){let i=this.skeletons[t];for(let r=i.bones.length-1;r>=0;r--)if(i.bones[r].id===e)return i.bones[r]}return null}getNodeById(e){let t=this.getMeshById(e);if(t)return t;let i=this.getTransformNodeById(e);if(i)return i;let r=this.getLightById(e);if(r)return r;let s=this.getCameraById(e);if(s)return s;let a=this.getBoneById(e);return a||null}getNodeByName(e){let t=this.getMeshByName(e);if(t)return t;let i=this.getTransformNodeByName(e);if(i)return i;let r=this.getLightByName(e);if(r)return r;let s=this.getCameraByName(e);if(s)return s;let a=this.getBoneByName(e);return a||null}getMeshByName(e){for(let t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t{let o=!0,l=!0;for(let c of a)o&&(o=c.objectRenderer._isFrozen),l&&(l=c.objectRenderer._freezeActiveMeshesCancel!==null);if(o)return!0;if(!l)throw new Error("Freezing active meshes was cancelled");return!1},()=>{this._freezeActiveMeshesCancel=null,this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=s,this._skipEvaluateActiveMeshesCompletely=e,t==null||t()},(o,l)=>{if(this._freezeActiveMeshesCancel=null,this.unfreezeActiveMeshes(),l){let c="Scene: Timeout while waiting for meshes to be frozen.";i?i(c):(W.Error(c),o&&W.Error(o))}else{let c="Scene: An unexpected error occurred while trying to freeze active meshes.";i?i(c):(W.Error(c),o&&(W.Error(o),o.stack&&W.Error(o.stack)))}}),this}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=s,this._skipEvaluateActiveMeshesCompletely=e,r)for(let a=0;ae.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){let r=this._activeMeshes.length;for(let s=0;s0&&(s.layerMask&this.activeCamera.layerMask)!==0&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),o!==s&&o._activate(this._renderId,!1);for(let l of this._preActiveMeshStage)l.action(s);s._activate(this._renderId,!1)&&(s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(o=s):o._internalAbstractMeshDataInfo._onlyForInstances=!1,o._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(s,o)),s._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let r=0;r0){let r=this.getActiveSubMeshCandidates(t),s=r.length;i=i||s===1;for(let a=0;a0&&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(let h of this._gatherActiveCameraRenderTargetsStage)h.action(this._renderTargets);let s=!1;if(this.renderTargetsEnabled){this._intermediateRendering=!0;let h;if(this._renderTargets.length>0){re.StartPerformanceCounter("Render targets",this._renderTargets.length>0);let u=(f=this.getBoundingBoxRenderer)==null?void 0:f.call(this);for(let m=0;m0?u.renderList.data.slice():[],h.length=u.renderList.length),p.render(_,this.dumpNextRenderTargets),s=!0}}u&&h&&(u.renderList.data=h,u.renderList.length=h.length),re.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}if(this._cameraDrawRenderTargetStage.length>0){let u=(d=this.getBoundingBoxRenderer)==null?void 0:d.call(this);u&&!h&&(h=u.renderList.length>0?u.renderList.data.slice():[],h.length=u.renderList.length);for(let m of this._cameraDrawRenderTargetStage)s=m.action(this.activeCamera)||s;u&&h&&(u.renderList.data=h,u.renderList.length=h.length)}this._intermediateRendering=!1}s&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(let h of this._beforeCameraDrawStage)h.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this);let a=r.snapshotRendering&&r.snapshotRenderingMode===1;a&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!a),this.onAfterDrawPhaseObservable.notifyObservers(this);for(let h of this._afterCameraDrawStage)h.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){let h=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,h)}for(let h of this._afterCameraPostProcessStage)h.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-1&&(r.trigger===13&&r._executeCurrent(pi.CreateNew(t,void 0,a)),(!t.actionManager.hasSpecificTrigger(13,c=>{let f=c.mesh?c.mesh:c;return a===f})||r.trigger===13)&&t._intersectionsInProgress.splice(l,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(n.MinDeltaTime,Math.min(this._engine.getDeltaTime(),n.MaxDeltaTime))+this._timeAccumulator,t=this._engine.getTimeStep(),i=1e3/t/1e3,r=0,s=this._engine.getLockstepMaxSteps(),a=Math.floor(e/t);for(a=Math.min(a,s);e>0&&r0);for(let l=0;l0),this._renderId++}this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(let l of this._beforeClearStage)l.action();if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();else{let l=this.getActiveMeshCandidates(),c=l.length;if(this._activeMeshesFrozen){if(!this._skipEvaluateActiveMeshesCompletely)for(let f=0;f0)for(let a=0;a0);for(let o=0;o0),this._renderId++}this._engine.currentRenderPassId=(s=a==null?void 0:a.renderPassId)!=null?s:0,this.activeCamera=a,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(let o of this._beforeClearStage)o.action();this._clearFrameBuffer(this.activeCamera);for(let o of this._gatherRenderTargetsStage)o.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let o=0;o0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(let a of this._afterRenderStage)a.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let a=0;as.dispose(!0)),this._disposeList(this.transformNodes,s=>s.dispose(!0));let i=this.cameras;this._disposeList(i),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._disposeList(this.frameGraphs),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let r=this._engine.scenes.indexOf(this);if(r>-1&&this._engine.scenes.splice(r,1),this._floatingOriginScene=void 0,this._engine.scenes.length===0&&Kx(),ue._LastCreatedScene===this){ue._LastCreatedScene=null;let s=ue.Instances.length-1;for(;s>=0;){let a=ue.Instances[s];if(a.scenes.length>0){ue._LastCreatedScene=a.scenes[this._engine.scenes.length-1];break}s--}}r=this._engine._virtualScenes.indexOf(this),r>-1&&this._engine._virtualScenes.splice(r,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onNewFrameGraphAddedObservable.clear(),this.onFrameGraphRemovedObservable.clear(),this.onNewObjectRendererAddedObservable.clear(),this.onObjectRendererRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this.onEnvironmentTextureChangedObservable.clear(),this.onMeshUnderPointerUpdatedObservable.clear(),this._isDisposed=!0}_disposeList(e,t){let i=e.slice(0);t=t!=null?t:(r=>r.dispose());for(let r of i)t(r);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e!0);let r=this.meshes.filter(e);for(let s of r){if(s.computeWorldMatrix(!0),!s.subMeshes||s.subMeshes.length===0||s.infiniteDistance)continue;let a=s.getBoundingInfo(),o=a.boundingBox.minimumWorld,l=a.boundingBox.maximumWorld;v.CheckExtends(o,t,i),v.CheckExtends(l,t,i)}return t.x===Number.MAX_VALUE?{min:v.Zero(),max:v.Zero()}:{min:t,max:i}}createPickingRay(e,t,i,r,s=!1){throw Ie("Ray")}createPickingRayToRef(e,t,i,r,s,a=!1,o=!1){throw Ie("Ray")}createPickingRayInCameraSpace(e,t,i){throw Ie("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,r){throw Ie("Ray")}pick(e,t,i,r,s,a){let o=Ie("Ray",!0);return o&&W.Warn(o),new Xi}pickWithBoundingInfo(e,t,i,r,s){let a=Ie("Ray",!0);return a&&W.Warn(a),new Xi}pickWithRay(e,t,i,r){throw Ie("Ray")}multiPick(e,t,i,r,s){throw Ie("Ray")}multiPickWithRay(e,t,i){throw Ie("Ray")}setPointerOverMesh(e,t,i){this._inputManager.setPointerOverMesh(e,t,i)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(let e of this.geometries)e._rebuild();for(let e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(let e of this._components)e.rebuild();for(let e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(let e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(let e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,i){if(t===void 0)return e;let r=[];for(let s in e){let a=e[s];nt&&nt.MatchesQuery(a,t)&&(!i||i(a))&&r.push(a)}return r}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,r=null){this._renderingManager.setRenderingOrder(e,t,i,r)}setRenderingAutoClearDepthStencil(e,t,i=!0,r=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(127))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(let i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,r,s,a,o){let l=Fn(e,t,i,r?this.offlineProvider:void 0,s,a,o);return this._activeRequests.push(l),l.onCompleteObservable.add(c=>{this._activeRequests.splice(this._activeRequests.indexOf(c),1)}),l}async _loadFileAsync(e,t,i,r,s){return await new Promise((a,o)=>{this._loadFile(e,l=>{a(l)},t,i,r,(l,c)=>{o(c)},s)})}_requestFile(e,t,i,r,s,a,o){let l=_h(e,t,i,r?this.offlineProvider:void 0,s,a,o);return this._activeRequests.push(l),l.onCompleteObservable.add(c=>{this._activeRequests.splice(this._activeRequests.indexOf(c),1)}),l}async _requestFileAsync(e,t,i,r,s){return await new Promise((a,o)=>{this._requestFile(e,l=>{a(l)},t,i,r,l=>{o(l)},s)})}_readFile(e,t,i,r,s){let a=_o(e,t,i,r,s);return this._activeRequests.push(a),a.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),a}async _readFileAsync(e,t,i){return await new Promise((r,s)=>{this._readFile(e,a=>{r(a)},t,i,a=>{s(a)})})}getPerfCollector(){throw Ie("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}};st.FOGMODE_NONE=0;st.FOGMODE_EXP=1;st.FOGMODE_EXP2=2;st.FOGMODE_LINEAR=3;st.MinDeltaTime=1;st.MaxDeltaTime=1e3;st._OriginalDefaultMaterialFactory=st.DefaultMaterialFactory;je("BABYLON.Scene",st)});var hC,oG,kr=A(()=>{N();hC="helperFunctions",oG=`const PI: f32=3.141592653589793;const TWO_PI: f32=6.283185307179586;const HALF_PI: f32=1.5707963267948966;const RECIPROCAL_PI: f32=0.3183098861837907;const RECIPROCAL_PI2: f32=0.15915494309189535;const RECIPROCAL_PI4: f32=0.07957747154594767;const HALF_MIN: f32=5.96046448e-08; const LinearEncodePowerApprox: f32=2.2;const GammaEncodePowerApprox: f32=1.0/LinearEncodePowerApprox;const LuminanceEncodeApprox: vec3f=vec3f(0.2126,0.7152,0.0722);const Epsilon:f32=0.0000001;fn square(x: f32)->f32 {return x*x;} fn saturate(x: f32)->f32 {return clamp(x,0.0,1.0);} fn saturateVec3(x: vec3f)->vec3f {return clamp(x,vec3f(),vec3f(1.0));} @@ -182,11 +182,11 @@ fn max3(v: vec3f)->f32 {return max(v.x,max(v.y,v.z));} fn uint2float(i: u32)->f32 {return bitcast(0x3F800000u | (i>>9u))-1.0;} fn plasticSequence(rstate: u32)->vec2f {return vec2f(uint2float(rstate*3242174889u), uint2float(rstate*2447445414u));} -`;E.IncludesShadersStoreWGSL[sC]||(E.IncludesShadersStoreWGSL[sC]=WV)});var fg={};De(fg,{rgbdDecodePixelShaderWGSL:()=>HV});var cg,aC,HV,dg=A(()=>{N();Vr();cg="rgbdDecodePixelShader",aC=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; +`;E.IncludesShadersStoreWGSL[hC]||(E.IncludesShadersStoreWGSL[hC]=oG)});var ug={};De(ug,{rgbdDecodePixelShaderWGSL:()=>lG});var hg,uC,lG,mg=A(()=>{N();kr();hg="rgbdDecodePixelShader",uC=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment -fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(fromRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV)),1.0);}`;E.ShadersStoreWGSL[cg]||(E.ShadersStoreWGSL[cg]=aC);HV={name:cg,shader:aC}});var oC,zV,Gr=A(()=>{N();oC="helperFunctions",zV=`const float PI=3.141592653589793;const float TWO_PI=6.283185307179586;const float HALF_PI=1.5707963267948966;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float RECIPROCAL_PI4=0.07957747154594767;const float HALF_MIN=5.96046448e-08; +fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(fromRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV)),1.0);}`;E.ShadersStoreWGSL[hg]||(E.ShadersStoreWGSL[hg]=uC);lG={name:hg,shader:uC}});var mC,cG,Wr=A(()=>{N();mC="helperFunctions",cG=`const float PI=3.141592653589793;const float TWO_PI=6.283185307179586;const float HALF_PI=1.5707963267948966;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float RECIPROCAL_PI4=0.07957747154594767;const float HALF_MIN=5.96046448e-08; const float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001; #define saturate(x) clamp(x,0.0,1.0) #define absEps(x) abs(x)+Epsilon @@ -304,28 +304,28 @@ float uint2float(uint i) {return uintBitsToFloat(0x3F800000u | (i>>9u))-1.0;} vec2 plasticSequence(const uint rstate) {return vec2(uint2float(rstate*3242174889u), uint2float(rstate*2447445414u));} #endif -`;E.IncludesShadersStore[oC]||(E.IncludesShadersStore[oC]=zV)});var ug={};De(ug,{rgbdDecodePixelShader:()=>XV});var hg,lC,XV,mg=A(()=>{N();Gr();hg="rgbdDecodePixelShader",lC=`varying vec2 vUV;uniform sampler2D textureSampler; +`;E.IncludesShadersStore[mC]||(E.IncludesShadersStore[mC]=cG)});var _g={};De(_g,{rgbdDecodePixelShader:()=>fG});var pg,pC,fG,gg=A(()=>{N();Wr();pg="rgbdDecodePixelShader",pC=`varying vec2 vUV;uniform sampler2D textureSampler; #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) -{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}`;E.ShadersStore[hg]||(E.ShadersStore[hg]=lC);XV={name:hg,shader:lC}});var fC={};De(fC,{rgbdEncodePixelShader:()=>YV});var pg,cC,YV,dC=A(()=>{N();Gr();pg="rgbdEncodePixelShader",cC=`varying vec2 vUV;uniform sampler2D textureSampler; +{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}`;E.ShadersStore[pg]||(E.ShadersStore[pg]=pC);fG={name:pg,shader:pC}});var gC={};De(gC,{rgbdEncodePixelShader:()=>dG});var Eg,_C,dG,EC=A(()=>{N();Wr();Eg="rgbdEncodePixelShader",_C=`varying vec2 vUV;uniform sampler2D textureSampler; #include #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) -{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}`;E.ShadersStore[pg]||(E.ShadersStore[pg]=cC);YV={name:pg,shader:cC}});var uC={};De(uC,{rgbdEncodePixelShaderWGSL:()=>KV});var _g,hC,KV,mC=A(()=>{N();Vr();_g="rgbdEncodePixelShader",hC=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; +{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}`;E.ShadersStore[Eg]||(E.ShadersStore[Eg]=_C);dG={name:Eg,shader:_C}});var TC={};De(TC,{rgbdEncodePixelShaderWGSL:()=>hG});var vg,vC,hG,SC=A(()=>{N();kr();vg="rgbdEncodePixelShader",vC=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; #include #define CUSTOM_FRAGMENT_DEFINITIONS @fragment -fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=toRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb);}`;E.ShadersStoreWGSL[_g]||(E.ShadersStoreWGSL[_g]=hC);KV={name:_g,shader:hC}});var Sl,gg=A(()=>{ms();Y_();Sl=class{static ExpandRGBDTexture(e){let t=e._texture;if(!t||!e.isRGBD)return;let i=t.getEngine(),r=i.getCaps(),s=t.isReady,a=!1;r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?(a=!0,t.type=2):r.textureFloatRender&&r.textureFloatLinearFiltering&&(a=!0,t.type=1),a&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);let o=async()=>{let l=i.isWebGPU,c=l?1:0;t.isReady=!1,l?await Promise.resolve().then(()=>(dg(),fg)):await Promise.resolve().then(()=>(mg(),ug));let f=new _t("rgbdDecode","rgbdDecode",null,null,1,null,3,i,!1,void 0,t.type,void 0,null,!1,void 0,c);f.externalTextureSamplerBinding=!0;let d=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:5});f.onEffectCreatedObservable.addOnce(h=>{h.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",t),u.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([f],d,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),f&&f.dispose(),d._swapAndDie(t),t.isReady=!0})})};a&&(s?o():e.onLoadObservable.addOnce(o))}static async EncodeTextureToRGBD(e,t,i=0){return t.getEngine().isWebGPU?await Promise.resolve().then(()=>(mC(),uC)):await Promise.resolve().then(()=>(dC(),fC)),await px("rgbdEncode",e,t,i,1,5)}}});var Eg=A(()=>{x_();qc();ft.prototype._sphericalPolynomialTargetSize=0;ft.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)};Object.defineProperty(ft.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=ds.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomialPromise===null?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then(n=>{this._texture._sphericalPolynomial=n,this._texture._sphericalPolynomialComputed=!0})),null}return null},set:function(n){this._texture&&(this._texture._sphericalPolynomial=n)},enumerable:!0,configurable:!0})});function EC(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=0;for(let a=0;a<_C.length;a++)if(e.getUint8(t++)!==_C[a])return W.Error("Not a babylon environment map"),null;let i="",r;for(;r=e.getUint8(t++);)i+=String.fromCharCode(r);let s=JSON.parse(i);return s=hf(s),s.binaryDataPosition=t,s.specular&&(s.specular.lodGenerationScale=s.specular.lodGenerationScale||.8),s}function hf(n){if(n.version>pC)throw new Error(`Unsupported babylon environment map version "${n.version}". Latest supported version is "${pC}".`);return n.version===2||(n={...n,version:2,imageType:Gh}),n}function jV(n,e){e=hf(e);let t=e.specular,i=Math.log2(e.width);if(i=Math.round(i)+1,t.mipmaps.length!==6*i)throw new Error(`Unsupported specular mipmaps number "${t.mipmaps.length}"`);let r=new Array(i);for(let s=0;s{if(t){let u=e.createTexture(null,!0,!0,null,1,null,m=>{h(m)},n);i==null||i.onEffectCreatedObservable.addOnce(m=>{m.executeWhenCompiled(()=>{i.externalTextureSamplerBinding=!0,i.onApply=p=>{p._bindTexture("textureSampler",u),p.setFloat2("scale",1,e._features.needsInvertingBitmap&&n instanceof ImageBitmap?-1:1)},e.scenes.length&&(e.scenes[0].postProcessManager.directRender([i],c,!0,s,a),e.restoreDefaultFramebuffer(),u.dispose(),URL.revokeObjectURL(r),d())})})}else{if(e._uploadImageToTexture(f,n,s,a),o){let u=l[a];u&&e._uploadImageToTexture(u._texture,n,s,0)}d()}})}async function qV(n,e,t=Gh){let i=n.getEngine();n.format=5,n.type=0,n.generateMipMaps=!0,n._cachedAnisotropicFilteringLevel=null,i.updateTextureSamplingMode(3,n),await TC(n,e,!0,t),n.isReady=!0}async function QV(n,e,t,i=Gh,r=null){let s=n.getEngine(),a=new bt(s,5),o=new ft(s,a);n._irradianceTexture=o,o._dominantDirection=r,a.isCube=!0,a.format=5,a.type=0,a.generateMipMaps=!0,a._cachedAnisotropicFilteringLevel=null,a.generateMipMaps=!0,a.width=t,a.height=t,s.updateTextureSamplingMode(3,a),await TC(a,[e],!1,i),s.generateMipMapsForCubemap(a),a.isReady=!0}async function TC(n,e,t,i=Gh){if(!re.IsExponentOfTwo(n.width))throw new Error("Texture size must be a power of two");let r=vI(n.width)+1,s=n.getEngine(),a=!1,o=!1,l=null,c=null,f=null,d=s.getCaps();d.textureLOD?s._features.supportRenderAndCopyToLodForFloatTextures?d.textureHalfFloatRender&&d.textureHalfFloatLinearFiltering?(a=!0,n.type=2):d.textureFloatRender&&d.textureFloatLinearFiltering&&(a=!0,n.type=1):a=!1:(a=!1,o=t);let h=0;if(a)s.isWebGPU?(h=1,await Promise.resolve().then(()=>(dg(),fg))):await Promise.resolve().then(()=>(mg(),ug)),l=new _t("rgbdDecode","rgbdDecode",null,null,1,null,3,s,!1,void 0,n.type,void 0,null,!1,void 0,h),n._isRGBD=!1,n.invertY=!1,c=s.createRenderTargetCubeTexture(n.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:3,type:n.type,format:5});else if(n._isRGBD=!0,n.invertY=!0,o){f={};let p=n._lodGenerationScale,_=n._lodGenerationOffset;for(let g=0;g<3;g++){let b=1-g/2,R=_,S=(r-1)*p+_,I=R+(S-R)*b,x=Math.round(Math.min(Math.max(I,0),S)),P=new bt(s,2);P.isCube=!0,P.invertY=!0,P.generateMipMaps=!1,s.updateTextureSamplingMode(2,P);let L=new ft(null);switch(L._isCube=!0,L._texture=P,f[x]=L,g){case 0:n._lodTextureLow=L;break;case 1:n._lodTextureMid=L;break;case 2:n._lodTextureHigh=L;break}}}let u=[];for(let m=0;mawait gC(S,s,a,l,b,p,m,o,f,c,n));else{let S=new Image;S.src=b,R=new Promise((I,x)=>{S.onload=()=>{gC(S,s,a,l,b,p,m,o,f,c,n).then(()=>I()).catch(P=>{x(P)})},S.onerror=P=>{x(P)}})}u.push(R)}if(await Promise.all(u),e.length{Tt();ve();bi();Xc();_r();qc();gr();ms();ze();gg();V_();Eg();pl();Gh="image/png",pC=2,_C=[134,22,135,150,246,214,150,54]});var RC={};De(RC,{_ENVTextureLoader:()=>vg});var vg,IC=A(()=>{AC();vg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){if(Array.isArray(e))return;let a=EC(e);if(a){t.width=a.width,t.height=a.width;try{SC(t,a),vC(t,e,a).then(()=>{t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()},o=>{s==null||s("Can not upload environment levels",o)})}catch(o){s==null||s("Can not upload environment file",o)}}else s&&s("Can not parse the environment file",null)}loadData(){throw".env not supported in 2d."}}});var Ts,xC=A(()=>{ve();Ts=class{static ConvertPanoramaToCubemap(e,t,i,r,s=!1,a=!0){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";let o;if(e.length!=t*i*3){if(e.length!=t*i*4)throw"ConvertPanoramaToCubemap: input size is wrong";o=4}else o=3;let l=this.CreateCubemapTexture(r,this.FACE_FRONT,e,t,i,s,a,o),c=this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i,s,a,o),f=this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i,s,a,o),d=this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i,s,a,o),h=this.CreateCubemapTexture(r,this.FACE_UP,e,t,i,s,a,o),u=this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i,s,a,o);return{front:l,back:c,left:f,right:d,up:h,down:u,size:r,type:1,format:4,gammaSpace:!1}}static CreateCubemapTexture(e,t,i,r,s,a,o,l){let c=new ArrayBuffer(e*e*4*3),f=new Float32Array(c),d=a?Math.max(1,Math.round(r/4/e)):1,h=1/d,u=h*h,m=t[1].subtract(t[0]).scale(h/e),p=t[3].subtract(t[2]).scale(h/e),_=1/e,g=0;for(let T=0;TMath.PI;)o-=2*Math.PI;let c=o/Math.PI,f=l/Math.PI;c=c*.5+.5;let d=Math.round(c*i);d<0?d=0:d>=i&&(d=i-1);let h=Math.round(f*r);h<0?h=0:h>=r&&(h=r-1);let u=a?r-h-1:h,m=t[u*i*s+d*s+0],p=t[u*i*s+d*s+1],_=t[u*i*s+d*s+2];return{r:m,g:p,b:_}}};Ts.FACE_LEFT=[new v(-1,-1,-1),new v(1,-1,-1),new v(-1,1,-1),new v(1,1,-1)];Ts.FACE_RIGHT=[new v(1,-1,1),new v(-1,-1,1),new v(1,1,1),new v(-1,1,1)];Ts.FACE_FRONT=[new v(1,-1,-1),new v(1,-1,1),new v(1,1,-1),new v(1,1,1)];Ts.FACE_BACK=[new v(-1,-1,1),new v(-1,-1,-1),new v(-1,1,1),new v(-1,1,-1)];Ts.FACE_DOWN=[new v(1,1,-1),new v(1,1,1),new v(-1,1,-1),new v(-1,1,1)];Ts.FACE_UP=[new v(-1,-1,-1),new v(-1,-1,1),new v(1,-1,-1),new v(1,-1,1)]});function JV(n,e){return e>1023?n*Math.pow(2,1023)*Math.pow(2,e-1023):e<-1074?n*Math.pow(2,-1074)*Math.pow(2,e+1074):n*Math.pow(2,e)}function CC(n,e,t,i,r,s){r>0?(r=JV(1,r-136),n[s+0]=e*r,n[s+1]=t*r,n[s+2]=i*r):(n[s+0]=0,n[s+1]=0,n[s+2]=0)}function Tg(n,e){let t="",i;for(let r=e;r32767)throw"HDR Bad header format, unsupported size";return r+=e.length+1,{height:l,width:o,dataPosition:r}}function MC(n,e){return $V(n,e)}function $V(n,e){let t=e.height,i=e.width,r,s,a,o,l,c=e.dataPosition,f,d,h,u=new ArrayBuffer(i*4),m=new Uint8Array(u),p=new ArrayBuffer(e.width*e.height*4*3),_=new Float32Array(p);for(;t>0;){if(r=n[c++],s=n[c++],a=n[c++],o=n[c++],r!=2||s!=2||a&128||e.width<8||e.width>32767)return eG(n,e);if((a<<8|o)!=i)throw"HDR Bad header format, wrong scan line width";for(f=0,h=0;h<4;h++)for(d=(h+1)*i;f128){if(l=r-128,l==0||l>d-f)throw"HDR Bad Format, bad scanline data (run)";for(;l-- >0;)m[f++]=s}else{if(l=r,l==0||l>d-f)throw"HDR Bad Format, bad scanline data (non-run)";if(m[f++]=s,--l>0)for(let g=0;g0;){for(l=0;l{xC()});var DC={};De(DC,{_HDRTextureLoader:()=>Sg});var Sg,LC=A(()=>{yC();Sg=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".hdr not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=bC(r),a=MC(r,s),o=s.width*s.height,l=new Float32Array(o*4);for(let c=0;c{let c=t.getEngine();t.type=1,t.format=5,t._gammaSpace=!1,c._uploadDataToTextureDirectly(t,l)})}}});var mn,PC=A(()=>{ze();mn=class n{constructor(e,t){if(this.data=e,this.isInvalid=!1,!n.IsValid(e)){this.isInvalid=!0,W.Error("texture missing KTX identifier");return}let i=Uint32Array.BYTES_PER_ELEMENT,r=new DataView(this.data.buffer,this.data.byteOffset+12,13*i),a=r.getUint32(0,!0)===67305985;if(this.glType=r.getUint32(1*i,a),this.glTypeSize=r.getUint32(2*i,a),this.glFormat=r.getUint32(3*i,a),this.glInternalFormat=r.getUint32(4*i,a),this.glBaseInternalFormat=r.getUint32(5*i,a),this.pixelWidth=r.getUint32(6*i,a),this.pixelHeight=r.getUint32(7*i,a),this.pixelDepth=r.getUint32(8*i,a),this.numberOfArrayElements=r.getUint32(9*i,a),this.numberOfFaces=r.getUint32(10*i,a),this.numberOfMipmapLevels=r.getUint32(11*i,a),this.bytesOfKeyValueData=r.getUint32(12*i,a),this.glType!==0){W.Error("only compressed formats currently supported"),this.isInvalid=!0;return}else this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels);if(this.pixelHeight===0||this.pixelDepth!==0){W.Error("only 2D textures currently supported"),this.isInvalid=!0;return}if(this.numberOfArrayElements!==0){W.Error("texture arrays not currently supported"),this.isInvalid=!0;return}if(this.numberOfFaces!==t){W.Error("number of faces expected"+t+", but found "+this.numberOfFaces),this.isInvalid=!0;return}this.loadType=n.COMPRESSED_2D}uploadLevels(e,t){switch(this.loadType){case n.COMPRESSED_2D:this._upload2DCompressedLevels(e,t);break;case n.TEX_2D:case n.COMPRESSED_3D:case n.TEX_3D:}}_upload2DCompressedLevels(e,t){let i=n.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,s=this.pixelHeight,a=t?this.numberOfMipmapLevels:1;for(let o=0;o=12){let t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===49&&t[6]===49&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}};mn.HEADER_LEN=64;mn.COMPRESSED_2D=0;mn.COMPRESSED_3D=1;mn.TEX_2D=2;mn.TEX_3D=3});var Ag,uf,OC=A(()=>{Ag=class{constructor(e){this._pendingActions=new Array,this._workerInfos=e.map(t=>({workerPromise:Promise.resolve(t),idle:!0}))}dispose(){for(let e of this._workerInfos)e.workerPromise.then(t=>{t.terminate()});this._workerInfos.length=0,this._pendingActions.length=0}push(e){this._executeOnIdleWorker(e)||this._pendingActions.push(e)}_executeOnIdleWorker(e){for(let t of this._workerInfos)if(t.idle)return this._execute(t,e),!0;return!1}_execute(e,t){e.idle=!1,e.workerPromise.then(i=>{t(i,()=>{let r=this._pendingActions.shift();r?this._execute(e,r):e.idle=!0})})}},uf=class n extends Ag{constructor(e,t,i=n.DefaultOptions){super([]),this._maxWorkers=e,this._createWorkerAsync=t,this._options=i}push(e){if(!this._executeOnIdleWorker(e))if(this._workerInfos.length{t(i,()=>{r(),e.idle&&(e.timeoutId=setTimeout(()=>{e.workerPromise.then(a=>{a.terminate()});let s=this._workerInfos.indexOf(e);s!==-1&&this._workerInfos.splice(s,1)},this._options.idleTimeElapsedBeforeRelease))})})}};uf.DefaultOptions={idleTimeElapsedBeforeRelease:1e3}});var NC,Al,FC,wC=A(()=>{(function(n){n[n.ETC1S=0]="ETC1S",n[n.UASTC4x4=1]="UASTC4x4"})(NC||(NC={}));(function(n){n[n.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",n[n.ASTC_4x4_RGBA=0]="ASTC_4x4_RGBA",n[n.BC7_RGBA=1]="BC7_RGBA",n[n.BC3_RGBA=2]="BC3_RGBA",n[n.BC1_RGB=3]="BC1_RGB",n[n.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",n[n.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",n[n.ETC2_RGBA=6]="ETC2_RGBA",n[n.ETC1_RGB=7]="ETC1_RGB",n[n.RGBA32=8]="RGBA32",n[n.R8=9]="R8",n[n.RG8=10]="RG8"})(Al||(Al={}));(function(n){n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.RGBA8Format=32856]="RGBA8Format",n[n.R8Format=33321]="R8Format",n[n.RG8Format=33323]="RG8Format"})(FC||(FC={}))});function mf(n,e){let t=(e==null?void 0:e.jsDecoderModule)||KTX2DECODER;n&&(n.wasmBaseUrl&&(t.Transcoder.WasmBaseUrl=n.wasmBaseUrl),n.wasmUASTCToASTC&&(t.LiteTranscoder_UASTC_ASTC.WasmModuleURL=n.wasmUASTCToASTC),n.wasmUASTCToBC7&&(t.LiteTranscoder_UASTC_BC7.WasmModuleURL=n.wasmUASTCToBC7),n.wasmUASTCToRGBA_UNORM&&(t.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=n.wasmUASTCToRGBA_UNORM),n.wasmUASTCToRGBA_SRGB&&(t.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=n.wasmUASTCToRGBA_SRGB),n.wasmUASTCToR8_UNORM&&(t.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=n.wasmUASTCToR8_UNORM),n.wasmUASTCToRG8_UNORM&&(t.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=n.wasmUASTCToRG8_UNORM),n.jsMSCTranscoder&&(t.MSCTranscoder.JSModuleURL=n.jsMSCTranscoder),n.wasmMSCTranscoder&&(t.MSCTranscoder.WasmModuleURL=n.wasmMSCTranscoder),n.wasmZSTDDecoder&&(t.ZSTDDecoder.WasmModuleURL=n.wasmZSTDDecoder)),e&&(e.wasmUASTCToASTC&&(t.LiteTranscoder_UASTC_ASTC.WasmBinary=e.wasmUASTCToASTC),e.wasmUASTCToBC7&&(t.LiteTranscoder_UASTC_BC7.WasmBinary=e.wasmUASTCToBC7),e.wasmUASTCToRGBA_UNORM&&(t.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary=e.wasmUASTCToRGBA_UNORM),e.wasmUASTCToRGBA_SRGB&&(t.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary=e.wasmUASTCToRGBA_SRGB),e.wasmUASTCToR8_UNORM&&(t.LiteTranscoder_UASTC_R8_UNORM.WasmBinary=e.wasmUASTCToR8_UNORM),e.wasmUASTCToRG8_UNORM&&(t.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary=e.wasmUASTCToRG8_UNORM),e.jsMSCTranscoder&&(t.MSCTranscoder.JSModule=e.jsMSCTranscoder),e.wasmMSCTranscoder&&(t.MSCTranscoder.WasmBinary=e.wasmMSCTranscoder),e.wasmZSTDDecoder&&(t.ZSTDDecoder.WasmBinary=e.wasmZSTDDecoder))}function BC(n){typeof n=="undefined"&&typeof KTX2DECODER!="undefined"&&(n=KTX2DECODER);let e;onmessage=t=>{if(t.data)switch(t.data.action){case"init":{let i=t.data.urls;i&&(i.jsDecoderModule&&typeof n=="undefined"&&(importScripts(i.jsDecoderModule),n=KTX2DECODER),mf(i)),t.data.wasmBinaries&&mf(void 0,{...t.data.wasmBinaries,jsDecoderModule:n}),e=new n.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":{n.KTX2Decoder.DefaultDecoderOptions=t.data.options;break}case"decode":e.decode(t.data.data,t.data.caps,t.data.options).then(i=>{let r=[];for(let s=0;s{postMessage({action:"decoded",success:!1,msg:i})});break}}}async function UC(n,e,t){return await new Promise((i,r)=>{let s=o=>{n.removeEventListener("error",s),n.removeEventListener("message",a),r(o)},a=o=>{o.data.action==="init"&&(n.removeEventListener("error",s),n.removeEventListener("message",a),i(n))};n.addEventListener("error",s),n.addEventListener("message",a),n.postMessage({action:"init",urls:t,wasmBinaries:e})})}var VC=A(()=>{});var Rg,Ss,GC=A(()=>{OC();Tt();wC();VC();Rg=class{constructor(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}get isDirty(){return this._isDirty}get useRGBAIfASTCBC7NotAvailableWhenUASTC(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC}set useRGBAIfASTCBC7NotAvailableWhenUASTC(e){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==e&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=e,this._isDirty=!0)}get useRGBAIfOnlyBC1BC3AvailableWhenUASTC(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC}set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(e){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==e&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=e,this._isDirty=!0)}get forceRGBA(){return this._forceRGBA}set forceRGBA(e){this._forceRGBA!==e&&(this._forceRGBA=e,this._isDirty=!0)}get forceR8(){return this._forceR8}set forceR8(e){this._forceR8!==e&&(this._forceR8=e,this._isDirty=!0)}get forceRG8(){return this._forceRG8}set forceRG8(e){this._forceRG8!==e&&(this._forceRG8=e,this._isDirty=!0)}get bypassTranscoders(){return this._bypassTranscoders}set bypassTranscoders(e){this._bypassTranscoders!==e&&(this._bypassTranscoders=e,this._isDirty=!0)}_getKTX2DecoderOptions(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;let e={};return this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==void 0&&(e.useRGBAIfASTCBC7NotAvailableWhenUASTC=this._useRGBAIfASTCBC7NotAvailableWhenUASTC),this._forceRGBA!==void 0&&(e.forceRGBA=this._forceRGBA),this._forceR8!==void 0&&(e.forceR8=this._forceR8),this._forceRG8!==void 0&&(e.forceRG8=this._forceRG8),this._bypassTranscoders!==void 0&&(e.bypassTranscoders=this._bypassTranscoders),this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(e.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[Al.BC1_RGB,Al.BC3_RGBA],yes:{transcodeFormat:Al.RGBA32,engineFormat:32856,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}},Ss=class n{static GetDefaultNumWorkers(){return typeof navigator!="object"||!navigator.hardwareConcurrency?1:Math.min(Math.floor(navigator.hardwareConcurrency*.5),4)}static _Initialize(e){if(n._WorkerPoolPromise||n._DecoderModulePromise)return;let t={wasmBaseUrl:re.ScriptBaseUrl,jsDecoderModule:re.GetBabylonScriptURL(this.URLConfig.jsDecoderModule,!0),wasmUASTCToASTC:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC,!0),wasmUASTCToBC7:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7,!0),wasmUASTCToRGBA_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM,!0),wasmUASTCToRGBA_SRGB:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB,!0),wasmUASTCToR8_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM,!0),wasmUASTCToRG8_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM,!0),jsMSCTranscoder:re.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder,!0),wasmMSCTranscoder:re.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder,!0),wasmZSTDDecoder:re.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder,!0)};e&&typeof Worker=="function"&&typeof URL!="undefined"?n._WorkerPoolPromise=new Promise(i=>{let r=`${mf}(${BC})()`,s=URL.createObjectURL(new Blob([r],{type:"application/javascript"}));i(new uf(e,async()=>await UC(new Worker(s),void 0,t)))}):typeof n._KTX2DecoderModule=="undefined"?n._DecoderModulePromise=re.LoadBabylonScriptAsync(t.jsDecoderModule).then(()=>(n._KTX2DecoderModule=KTX2DECODER,n._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,n._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,mf(t,n._KTX2DecoderModule),new n._KTX2DecoderModule.KTX2Decoder)):(n._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,n._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,n._DecoderModulePromise=Promise.resolve(new n._KTX2DecoderModule.KTX2Decoder))}constructor(e,t=n.DefaultNumWorkers){var r,s;this._engine=e;let i=typeof t=="object"&&t.workerPool||n.WorkerPool;if(i)n._WorkerPoolPromise=Promise.resolve(i);else{typeof t=="object"?n._KTX2DecoderModule=(r=t==null?void 0:t.binariesAndModulesContainer)==null?void 0:r.jsDecoderModule:typeof KTX2DECODER!="undefined"&&(n._KTX2DecoderModule=KTX2DECODER);let a=typeof t=="number"?t:(s=t.numWorkers)!=null?s:n.DefaultNumWorkers;n._Initialize(a)}}async _uploadAsync(e,t,i){let r=this._engine.getCaps(),s={astc:!!r.astc,bptc:!!r.bptc,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,etc1:!!r.etc1};if(n._WorkerPoolPromise){let a=await n._WorkerPoolPromise;return await new Promise((o,l)=>{a.push((c,f)=>{let d=m=>{c.removeEventListener("error",d),c.removeEventListener("message",h),l(m),f()},h=m=>{if(m.data.action==="decoded"){if(c.removeEventListener("error",d),c.removeEventListener("message",h),!m.data.success)l({message:m.data.msg});else try{this._createTexture(m.data.decodedData,t,i),o()}catch(p){l({message:p})}f()}};c.addEventListener("error",d),c.addEventListener("message",h),c.postMessage({action:"setDefaultDecoderOptions",options:n.DefaultDecoderOptions._getKTX2DecoderOptions()});let u=new Uint8Array(e.byteLength);u.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),c.postMessage({action:"decode",data:u,caps:s,options:i},[u.buffer])})})}else if(n._DecoderModulePromise){let a=await n._DecoderModulePromise;return n.DefaultDecoderOptions.isDirty&&(n._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions=n.DefaultDecoderOptions._getKTX2DecoderOptions()),await new Promise((o,l)=>{a.decode(e,r).then(c=>{this._createTexture(c,t),o()}).catch(c=>{l({message:c})})})}throw new Error("KTX2 decoder module is not available")}_createTexture(e,t,i){this._engine._bindTextureDirectly(3553,t),i&&(i.transcodedFormat=e.transcodedFormat,i.isInGammaSpace=e.isInGammaSpace,i.hasAlpha=e.hasAlpha,i.transcoderName=e.transcoderName);let s=!0;switch(e.transcodedFormat){case 32856:t.type=0,t.format=5;break;case 33321:t.type=0,t.format=6;break;case 33323:t.type=0,t.format=7;break;default:t.format=e.transcodedFormat,s=!1;break}if(t._gammaSpace=e.isInGammaSpace,t.generateMipMaps=e.mipmaps.length>1,t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(let a=0;a=12){let t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===50&&t[6]===48&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}};Ss.URLConfig={jsDecoderModule:"https://cdn.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null};Ss.DefaultNumWorkers=Ss.GetDefaultNumWorkers();Ss.DefaultDecoderOptions=new Rg});var xg={};De(xg,{_KTXTextureLoader:()=>Ig});function tG(n){switch(n){case 35916:return 33776;case 35918:return 33778;case 35919:return 33779;case 37493:return 37492;case 37497:return 37496;case 37495:return 37494;case 37840:return 37808;case 37841:return 37809;case 37842:return 37810;case 37843:return 37811;case 37844:return 37812;case 37845:return 37813;case 37846:return 37814;case 37847:return 37815;case 37848:return 37816;case 37849:return 37817;case 37850:return 37818;case 37851:return 37819;case 37852:return 37820;case 37853:return 37821;case 36493:return 36492}return null}var Ig,Cg=A(()=>{PC();GC();ze();Ig=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r){if(Array.isArray(e))return;t._invertVScale=!t.invertY;let s=t.getEngine(),a=new mn(e,6),o=a.numberOfMipmapLevels>1&&t.generateMipMaps;s._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,s._setCubeMapTextureParams(t,o,a.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}loadData(e,t,i,r){if(mn.IsValid(e)){t._invertVScale=!t.invertY;let s=new mn(e,1),a=tG(s.glInternalFormat);a?(t.format=a,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=s.glInternalFormat,i(s.pixelWidth,s.pixelHeight,t.generateMipMaps,!0,()=>{s.uploadLevels(t,t.generateMipMaps)},s.isInvalid)}else Ss.IsValid(e)?new Ss(t.getEngine())._uploadAsync(e,t,r).then(()=>{i(t.width,t.height,t.generateMipMaps,!0,()=>{},!1)},a=>{W.Warn(`Failed to load KTX2 texture data: ${a.message}`),i(0,0,!1,!1,()=>{},!0)}):(W.Error("texture missing KTX identifier"),i(0,0,!1,!1,()=>{},!0))}}});function kh(n){let e=0;return{id_length:n[e++],colormap_type:n[e++],image_type:n[e++],colormap_index:n[e++]|n[e++]<<8,colormap_length:n[e++]|n[e++]<<8,colormap_size:n[e++],origin:[n[e++]|n[e++]<<8,n[e++]|n[e++]<<8],width:n[e++]|n[e++]<<8,height:n[e++]|n[e++]<<8,pixel_size:n[e++],flags:n[e]}}function bg(n,e){if(e.length<19){W.Error("Unable to load TGA file - Not enough data to contain header");return}let t=18,i=kh(e);if(i.id_length+t>e.length){W.Error("Unable to load TGA file - Not enough data");return}t+=i.id_length;let r=!1,s=!1,a=!1;switch(i.image_type){case sG:r=!0;case iG:s=!0;break;case aG:r=!0;case rG:break;case oG:r=!0;case nG:a=!0;break}let o,l=i.pixel_size>>3,c=i.width*i.height*l,f;if(s&&(f=e.subarray(t,t+=i.colormap_length*(i.colormap_size>>3))),r){o=new Uint8Array(c);let R,S,I,x=0,P=new Uint8Array(l);for(;t>cG){default:case hG:d=0,u=1,_=i.width,h=0,m=1,p=i.height;break;case fG:d=0,u=1,_=i.width,h=i.height-1,m=-1,p=-1;break;case uG:d=i.width-1,u=-1,_=-1,h=0,m=1,p=i.height;break;case dG:d=i.width-1,u=-1,_=-1,h=i.height-1,m=-1,p=-1;break}let g="_getImageData"+(a?"Grey":"")+i.pixel_size+"bits",T=TG[g](i,f,o,h,m,p,d,u,_);n.getEngine()._uploadDataToTextureDirectly(n,T)}function mG(n,e,t,i,r,s,a,o,l){let c=t,f=e,d=n.width,h=n.height,u,m=0,p,_,g=new Uint8Array(d*h*4);for(_=i;_!==s;_+=r)for(p=a;p!==l;p+=o,m++)u=c[m],g[(p+d*_)*4+3]=255,g[(p+d*_)*4+2]=f[u*3+0],g[(p+d*_)*4+1]=f[u*3+1],g[(p+d*_)*4+0]=f[u*3+2];return g}function pG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h,u=0,m,p,_=new Uint8Array(f*d*4);for(p=i;p!==s;p+=r)for(m=a;m!==l;m+=o,u+=2){h=c[u+0]+(c[u+1]<<8);let g=((h&31744)>>10)*255/31|0,T=((h&992)>>5)*255/31|0,b=(h&31)*255/31|0;_[(m+f*p)*4+0]=g,_[(m+f*p)*4+1]=T,_[(m+f*p)*4+2]=b,_[(m+f*p)*4+3]=h&32768?0:255}return _}function _G(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=3)p[(u+f*m)*4+3]=255,p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+1]=c[h+1],p[(u+f*m)*4+0]=c[h+2];return p}function gG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=4)p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+1]=c[h+1],p[(u+f*m)*4+0]=c[h+2],p[(u+f*m)*4+3]=c[h+3];return p}function EG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h,u=0,m,p,_=new Uint8Array(f*d*4);for(p=i;p!==s;p+=r)for(m=a;m!==l;m+=o,u++)h=c[u],_[(m+f*p)*4+0]=h,_[(m+f*p)*4+1]=h,_[(m+f*p)*4+2]=h,_[(m+f*p)*4+3]=255;return _}function vG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=2)p[(u+f*m)*4+0]=c[h+0],p[(u+f*m)*4+1]=c[h+0],p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+3]=c[h+1];return p}var iG,rG,nG,sG,aG,oG,lG,cG,fG,dG,hG,uG,TG,kC=A(()=>{ze();iG=1,rG=2,nG=3,sG=9,aG=10,oG=11,lG=48,cG=4,fG=0,dG=1,hG=2,uG=3;TG={GetTGAHeader:kh,UploadContent:bg,_getImageData8bits:mG,_getImageData16bits:pG,_getImageData24bits:_G,_getImageData32bits:gG,_getImageDataGrey8bits:EG,_getImageDataGrey16bits:vG}});var WC={};De(WC,{_TGATextureLoader:()=>Mg});var Mg,HC=A(()=>{kC();Mg=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".env not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=kh(r);i(s.width,s.height,t.generateMipMaps,!1,()=>{bg(t,r)})}}});var pf=A(()=>{});function AG(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}let s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,f=0;for(;(c&8388608)===0;)c<<=1,f-=8388608;c&=-8388609,f+=947912704,s[l]=c|f}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function zh(n,e){let t=new Uint8Array(n),i=0;for(;t[e.value+i]!=0;)i+=1;let r=new TextDecoder().decode(t.slice(e.value,e.value+i));return e.value=e.value+i+1,r}function pn(n,e){let t=n.getInt32(e.value,!0);return e.value+=4,t}function Er(n,e){let t=n.getUint32(e.value,!0);return e.value+=4,t}function _f(n,e){let t=n.getUint8(e.value);return e.value+=1,t}function Rl(n,e){let t=n.getUint16(e.value,!0);return e.value+=2,t}function Dg(n,e){let t=n[e.value];return e.value+=1,t}function YC(n,e){let t;return"getBigInt64"in DataView.prototype?t=Number(n.getBigInt64(e.value,!0)):t=n.getUint32(e.value+4,!0)+Number(n.getUint32(e.value,!0)<<32),e.value+=8,t}function Ii(n,e){let t=n.getFloat32(e.value,!0);return e.value+=4,t}function KC(n,e){return RG(Rl(n,e))}function RG(n){let e=(n&31744)>>10,t=n&1023;return(n>>15?-1:1)*(e?e===31?t?NaN:1/0:Math.pow(2,e-15)*(1+t/1024):6103515625e-14*(t/1024))}function IG(n){if(Math.abs(n)>65504)throw new Error("Value out of range.Consider using float instead of half-float.");n=Ke(n,-65504,65504),Wh.floatView[0]=n;let e=Wh.uint32View[0],t=e>>23&511;return Wh.baseTable[t]+((e&8388607)>>Wh.shiftTable[t])}function jC(n,e){return IG(Ii(n,e))}function xG(n,e,t){let i=new TextDecoder().decode(new Uint8Array(n).slice(e.value,e.value+t));return e.value=e.value+t,i}function CG(n,e){let t=pn(n,e),i=Er(n,e);return[t,i]}function bG(n,e){let t=Er(n,e),i=Er(n,e);return[t,i]}function MG(n,e){let t=Ii(n,e),i=Ii(n,e);return[t,i]}function yG(n,e){let t=Ii(n,e),i=Ii(n,e),r=Ii(n,e);return[t,i,r]}function DG(n,e,t){let i=e.value,r=[];for(;e.values||(e[r++]=n[t++],r>s));)e[r++]=n[i++]}var Un,yg,Wh,gf=A(()=>{bi();pf();(function(n){n[n.NO_COMPRESSION=0]="NO_COMPRESSION",n[n.RLE_COMPRESSION=1]="RLE_COMPRESSION",n[n.ZIPS_COMPRESSION=2]="ZIPS_COMPRESSION",n[n.ZIP_COMPRESSION=3]="ZIP_COMPRESSION",n[n.PIZ_COMPRESSION=4]="PIZ_COMPRESSION",n[n.PXR24_COMPRESSION=5]="PXR24_COMPRESSION"})(Un||(Un={}));(function(n){n[n.INCREASING_Y=0]="INCREASING_Y",n[n.DECREASING_Y=1]="DECREASING_Y"})(yg||(yg={}));Wh=AG()});function Og(n,e){if(n.getUint32(0,!0)!=FG)throw new Error("Incorrect OpenEXR format");let t=n.getUint8(4),i=n.getUint8(5),r={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)};e.value=8;let s={},a=!0;for(;a;){let o=zh(n.buffer,e);if(!o)a=!1;else{let l=zh(n.buffer,e),c=Er(n,e),f=ZC(n,e,l,c);f===void 0?W.Warn(`Unknown header attribute type ${l}'.`):s[o]=f}}if((i&-5)!=0)throw new Error("Unsupported file format");return{version:t,spec:r,...s}}var FG,qC=A(()=>{ze();gf();FG=20000630});function nb(n,e){let t=0;for(let r=0;r<65536;++r)(r==0||n[r>>3]&1<<(r&7))&&(e[t++]=r);let i=t-1;for(;t<65536;)e[t++]=0;return i}function VG(n){for(let e=0;e<16384;e++)n[e]={},n[e].len=0,n[e].lit=0,n[e].p=null}function eb(n,e,t,i,r){for(;t>t&(1<>i;if(c=new Uint8Array([c])[0],o.value+c>l)return null;let f=a[o.value-1];for(;c-- >0;)a[o.value++]=f}else if(o.value0;--t){let i=e+Ef[t]>>1;Ef[t]=e,e=i}for(let t=0;t<65537;++t){let i=n[t];i>0&&(n[t]=i|Ef[i]++<<6)}}function kG(n,e,t,i,r,s){let a=e,o=0,l=0;for(;i<=r;i++){if(a.value-e.value>t)return;let c=eb(6,o,l,n,a),f=c.l;if(o=c.c,l=c.lc,s[i]=f,f==63){if(a.value-e.value>t)throw new Error("Error in HufUnpackEncTable");c=eb(8,o,l,n,a);let d=c.l+6;if(o=c.c,l=c.lc,i+d>r+1)throw new Error("Error in HufUnpackEncTable");for(;d--;)s[i++]=0;i--}else if(f>=59){let d=f-59+2;if(i+d>r+1)throw new Error("Error in HufUnpackEncTable");for(;d--;)s[i++]=0;i--}}GG(s)}function sb(n){return n&63}function ab(n){return n>>6}function WG(n,e,t,i){for(;e<=t;e++){let r=ab(n[e]),s=sb(n[e]);if(r>>s)throw new Error("Invalid table entry");if(s>14){let a=i[r>>s-14];if(a.len)throw new Error("Invalid table entry");if(a.lit++,a.p){let o=a.p;a.p=new Array(a.lit);for(let l=0;l0;o--){let l=i[(r<<14-s)+a];if(l.len||l.p)throw new Error("Invalid table entry");l.len=s,l.lit=e,a++}}}return!0}function HG(n,e,t,i,r,s,a,o,l){let c=0,f=0,d=a,h=Math.trunc(i.value+(r+7)/8);for(;i.value=14;){let p=c>>f-14&16383,_=e[p];if(_.len){f-=_.len;let g=Ng(_.lit,s,c,f,t,i,o,l,d);g&&(c=g.c,f=g.lc)}else{if(!_.p)throw new Error("hufDecode issues");let g;for(g=0;g<_.lit;g++){let T=sb(n[_.p[g]]);for(;f=T&&ab(n[_.p[g]])==(c>>f-T&(1<>=u,f-=u;f>0;){let m=e[c<<14-f&16383];if(m.len){f-=m.len;let p=Ng(m.lit,s,c,f,t,i,o,l,d);p&&(c=p.c,f=p.lc)}else throw new Error("HufDecode issues")}return!0}function ob(n,e,t,i,r,s){let a={value:0},o=t.value,l=Er(e,t),c=Er(e,t);t.value+=4;let f=Er(e,t);if(t.value+=4,l<0||l>=65537||c<0||c>=65537)throw new Error("Wrong HUF_ENCSIZE");let d=new Array(65537),h=new Array(16384);VG(h);let u=i-(t.value-o);if(kG(n,t,u,l,c,d),f>8*(i-(t.value-o)))throw new Error("Wrong hufUncompress");WG(d,l,c,h),HG(d,h,n,t,f,c,s,r,a)}function wg(n){return n&65535}function tb(n){let e=wg(n);return e>32767?e-65536:e}function Il(n,e){let t=tb(n),r=tb(e),s=t+(r&1)+(r>>1),a=s,o=s-r;return{a,b:o}}function xl(n,e){let t=wg(n),i=wg(e),r=t-(i>>1)&$C;return{a:i+r-UG&$C,b:r}}function lb(n,e,t,i,r,s,a){let o=a<16384,l=t>r?r:t,c=1,f,d;for(;c<=l;)c<<=1;for(c>>=1,f=c,c>>=1;c>=1;){d=0;let h=d+s*(r-f),u=s*c,m=s*f,p=i*c,_=i*f,g,T,b,R;for(;d<=h;d+=m){let S=d,I=d+i*(t-f);for(;S<=I;S+=_){let x=S+p,P=S+u,L=P+p;if(o){let y=Il(n[S+e],n[P+e]);g=y.a,b=y.b,y=Il(n[x+e],n[L+e]),T=y.a,R=y.b,y=Il(g,T),n[S+e]=y.a,n[x+e]=y.b,y=Il(b,R),n[P+e]=y.a,n[L+e]=y.b}else{let y=xl(n[S+e],n[P+e]);g=y.a,b=y.b,y=xl(n[x+e],n[L+e]),T=y.a,R=y.b,y=xl(g,T),n[S+e]=y.a,n[x+e]=y.b,y=xl(b,R),n[P+e]=y.a,n[L+e]=y.b}}if(t&c){let x=S+u,P;o?P=Il(n[S+e],n[x+e]):P=xl(n[S+e],n[x+e]),g=P.a,n[x+e]=P.b,n[S+e]=g}}if(r&c){let S=d,I=d+i*(t-f);for(;S<=I;S+=_){let x=S+p,P;o?P=Il(n[S+e],n[x+e]):P=xl(n[S+e],n[x+e]),g=P.a,n[x+e]=P.b,n[S+e]=g}}f=c,c>>=1}return d}function cb(n,e,t){for(let i=0;i{gf();pf();rb=16,UG=1<0;){let s=r.getInt8(i++);if(s<0){let a=-s;e-=a+1;for(let o=0;o{});function Bg(n){return new DataView(n.array.buffer,n.offset.value,n.size)}function mb(n){let e=n.viewer.buffer.slice(n.offset.value,n.offset.value+n.size),t=new Uint8Array(db(e)),i=new Uint8Array(t.length);return Lg(t),Pg(t,i),new DataView(i.buffer)}function Ug(n){let e=n.array.slice(n.offset.value,n.offset.value+n.size),t=fflate.unzlibSync(e),i=new Uint8Array(t.length);return Lg(t),Pg(t,i),new DataView(i.buffer)}function pb(n){let e=n.array.slice(n.offset.value,n.offset.value+n.size),t=fflate.unzlibSync(e),i=n.lines*n.channels*n.width,r=n.type==1?new Uint16Array(i):new Uint32Array(i),s=0,a=0,o=new Array(4);for(let l=0;l=8192)throw new Error("Wrong PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let m=0;m{fb();hb();gf();pf()});var kr,Vn,Vg=A(()=>{(function(n){n[n.Float=0]="Float",n[n.HalfFloat=1]="HalfFloat"})(kr||(kr={}));Vn=class{};Vn.DefaultOutputType=kr.HalfFloat;Vn.FFLATEUrl="https://unpkg.com/fflate@0.8.2"});async function Gg(n,e,t,i){let r={size:0,viewer:e,array:new Uint8Array(e.buffer),offset:t,width:n.dataWindow.xMax-n.dataWindow.xMin+1,height:n.dataWindow.yMax-n.dataWindow.yMin+1,channels:n.channels.length,channelLineOffsets:{},scanOrder:()=>0,bytesPerLine:0,outLineWidth:0,lines:0,scanlineBlockSize:0,inputSize:null,type:0,uncompress:null,getter:()=>0,format:5,outputChannels:0,decodeChannels:{},blockCount:null,byteArray:null,linearSpace:!1,textureType:0};switch(n.compression){case Un.NO_COMPRESSION:r.lines=1,r.uncompress=Bg;break;case Un.RLE_COMPRESSION:r.lines=1,r.uncompress=mb;break;case Un.ZIPS_COMPRESSION:r.lines=1,r.uncompress=Ug,await re.LoadScriptAsync(Vn.FFLATEUrl);break;case Un.ZIP_COMPRESSION:r.lines=16,r.uncompress=Ug,await re.LoadScriptAsync(Vn.FFLATEUrl);break;case Un.PIZ_COMPRESSION:r.lines=32,r.uncompress=_b;break;case Un.PXR24_COMPRESSION:r.lines=16,r.uncompress=pb,await re.LoadScriptAsync(Vn.FFLATEUrl);break;default:throw new Error(Un[n.compression]+" is unsupported")}r.scanlineBlockSize=r.lines;let s={};for(let c of n.channels)switch(c.name){case"R":case"G":case"B":case"A":s[c.name]=!0,r.type=c.pixelType;break;case"Y":s[c.name]=!0,r.type=c.pixelType;break;default:break}let a=!1;if(s.R&&s.G&&s.B&&s.A)r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(s.R&&s.G&&s.B)a=!0,r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(s.R&&s.G)r.outputChannels=2,r.decodeChannels={R:0,G:1};else if(s.R)r.outputChannels=1,r.decodeChannels={R:0};else if(s.Y)r.outputChannels=1,r.decodeChannels={Y:0};else throw new Error("EXRLoader.parse: file contains unsupported data channels.");if(r.type===1)switch(i){case kr.Float:r.getter=KC,r.inputSize=2;break;case kr.HalfFloat:r.getter=Rl,r.inputSize=2;break}else if(r.type===2)switch(i){case kr.Float:r.getter=Ii,r.inputSize=4;break;case kr.HalfFloat:r.getter=jC,r.inputSize=4}else throw new Error("Unsupported pixelType "+r.type+" for "+n.compression);r.blockCount=r.height/r.scanlineBlockSize;for(let c=0;cc:r.scanOrder=c=>r.height-1-c,r.outputChannels==4?(r.format=5,r.linearSpace=!0):(r.format=6,r.linearSpace=!1),r}function kg(n,e,t,i){let r={value:0};for(let s=0;sn.height?n.height-a:n.scanlineBlockSize;let l=n.size=n.height)continue;let h=c*n.bytesPerLine,u=(n.height-1-d)*n.outLineWidth;for(let m=0;m{gf();gb();pf();Tt();Vg()});var vb={};De(vb,{ReadExrDataAsync:()=>zG,_ExrTextureLoader:()=>Wg});async function zG(n){let e=new DataView(n),t={value:0},i=Og(e,t);try{let r=await Gg(i,e,t,kr.Float);return kg(r,i,e,t),r.byteArray?{width:i.dataWindow.xMax-i.dataWindow.xMin+1,height:i.dataWindow.yMax-i.dataWindow.yMin+1,data:new Float32Array(r.byteArray)}:(W.Error("Failed to decode EXR data: No byte array available."),{width:0,height:0,data:null})}catch(r){W.Error("Failed to load EXR data: ",r)}return{width:0,height:0,data:null}}var Wg,Tb=A(()=>{qC();Eb();Vg();ze();Wg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){throw".exr not supported in Cube."}loadData(e,t,i){let r=new DataView(e.buffer),s={value:0},a=Og(r,s);Gg(a,r,s,Vn.DefaultOutputType).then(o=>{kg(o,a,r,s);let l=a.dataWindow.xMax-a.dataWindow.xMin+1,c=a.dataWindow.yMax-a.dataWindow.yMin+1;i(l,c,t.generateMipMaps,!1,()=>{let f=t.getEngine();t.format=a.format,t.type=o.textureType,t.invertY=!1,t._gammaSpace=!a.linearSpace,o.byteArray&&f._uploadDataToTextureDirectly(t,o.byteArray,0,0,void 0,!0)})}).catch(o=>{W.Error("Failed to load EXR texture: ",o)})}}});function As(n,e){XG(n)&&W.Warn(`Extension with the name '${n}' already exists`),Yh.set(n,e)}function XG(n){return Yh.delete(n)}function Kh(n,e){(e==="image/ktx"||e==="image/ktx2")&&(n=".ktx"),Yh.has(n)||(n.endsWith(".ies")&&As(".ies",async()=>await Promise.resolve().then(()=>(vx(),Ex)).then(i=>new i._IESTextureLoader)),n.endsWith(".dds")&&As(".dds",async()=>await Promise.resolve().then(()=>(Sx(),Tx)).then(i=>new i._DDSTextureLoader)),n.endsWith(".basis")&&As(".basis",async()=>await Promise.resolve().then(()=>(bx(),Cx)).then(i=>new i._BasisTextureLoader)),n.endsWith(".env")&&As(".env",async()=>await Promise.resolve().then(()=>(IC(),RC)).then(i=>new i._ENVTextureLoader)),n.endsWith(".hdr")&&As(".hdr",async()=>await Promise.resolve().then(()=>(LC(),DC)).then(i=>new i._HDRTextureLoader)),(n.endsWith(".ktx")||n.endsWith(".ktx2"))&&(As(".ktx",async()=>await Promise.resolve().then(()=>(Cg(),xg)).then(i=>new i._KTXTextureLoader)),As(".ktx2",async()=>await Promise.resolve().then(()=>(Cg(),xg)).then(i=>new i._KTXTextureLoader))),n.endsWith(".tga")&&As(".tga",async()=>await Promise.resolve().then(()=>(HC(),WC)).then(i=>new i._TGATextureLoader)),n.endsWith(".exr")&&As(".exr",async()=>await Promise.resolve().then(()=>(Tb(),vb)).then(i=>new i._ExrTextureLoader)));let t=Yh.get(n);return t?Promise.resolve(t(e)):null}var Yh,Hg=A(()=>{ze();Yh=new Map});function Sb(n){let e=n.split("?")[0],t=e.lastIndexOf(".");return t>-1?e.substring(t).toLowerCase():""}var Ab=A(()=>{});var Rb=A(()=>{_r();ze();fs();Yc();ii();Hg();Ab();fe.prototype._partialLoadFile=function(n,e,t,i,r=null){let s=o=>{t[e]=o,t._internalCount++,t._internalCount===6&&i(t)},a=(o,l)=>{r&&o&&r(o.status+" "+o.statusText,l)};this._loadFile(n,s,void 0,void 0,!0,a)};fe.prototype._cascadeLoadFiles=function(n,e,t,i=null){let r=[];r._internalCount=0;for(let s=0;s<6;s++)this._partialLoadFile(t[s],s,r,e,i)};fe.prototype._cascadeLoadImgs=function(n,e,t,i,r=null,s){let a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(i[o],o,a,n,e,t,r,s)};fe.prototype._partialLoadImg=function(n,e,t,i,r,s,a=null,o){let l=la();gl(n,d=>{t[e]=d,t._internalCount++,i&&i.removePendingData(l),t._internalCount===6&&s&&s(r,t)},(d,h)=>{i&&i.removePendingData(l),a&&a(d,h)},i?i.offlineProvider:null,o),i&&i.addPendingData(l)};fe.prototype.createCubeTextureBase=function(n,e,t,i,r=null,s=null,a,o=null,l=!1,c=0,f=0,d=null,h=null,u=null,m=!1,p=null){let _=d||new bt(this,7);_.isCube=!0,_.url=n,_.generateMipMaps=!i,_._lodGenerationScale=c,_._lodGenerationOffset=f,_._useSRGBBuffer=!!m&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!i),_!==d&&(_.label=n.substring(0,60)),this._doNotHandleContextLost||(_._extension=o,_._files=t,_._buffer=p);let g=n;this._transformTextureUrl&&!d&&(n=this._transformTextureUrl(n));let T=o!=null?o:Sb(n),b=Kh(T),R=(I,x)=>{_.dispose(),s?s(I,x):I&&W.Warn(I)},S=(I,x)=>{n===g?I&&R(I.status+" "+I.statusText,x):(W.Warn(`Failed to load ${n}, falling back to the ${g}`),this.createCubeTextureBase(g,e,t,!!i,r,R,a,o,l,c,f,_,h,u,m,p))};if(b)b.then(I=>{let x=P=>{h&&h(_,P),I.loadCubeData(P,_,l,r,(L,y)=>{R(L,y)})};p?x(p):t&&t.length===6?I.supportCascades?this._cascadeLoadFiles(e,P=>x(P.map(L=>new Uint8Array(L))),t,R):R("Textures type does not support cascades."):this._loadFile(n,P=>x(new Uint8Array(P)),void 0,e?e.offlineProvider||null:void 0,!0,S)});else{if(!t||t.length===0)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(e,_,(I,x)=>{u&&u(I,x)},t,R)}return this._internalTexturesCache.push(_),_}});var Gb={};De(Gb,{DDSTools:()=>ln});function jh(n){return n.charCodeAt(0)+(n.charCodeAt(1)<<8)+(n.charCodeAt(2)<<16)+(n.charCodeAt(3)<<24)}function KG(n){return String.fromCharCode(n&255,n>>8&255,n>>16&255,n>>24&255)}var YG,Ib,xb,Cb,bb,Mb,yb,Db,Lb,zg,Pb,Ob,Nb,Fb,jG,Xg,ZG,qG,wb,Bb,Yg,Ub,Kg,Vb,QG,JG,$G,ek,tk,ik,rk,ln,Q_=A(()=>{bi();ze();x_();Y_();Rb();YG=542327876,Ib=131072,xb=512,Cb=4,bb=64,Mb=131072;yb=jh("DXT1"),Db=jh("DXT3"),Lb=jh("DXT5"),zg=jh("DX10"),Pb=113,Ob=116,Nb=2,Fb=10,jG=88,Xg=31,ZG=0,qG=1,wb=2,Bb=3,Yg=4,Ub=7,Kg=20,Vb=21,QG=22,JG=23,$G=24,ek=25,tk=26,ik=28,rk=32,ln=class n{static GetDDSInfo(e){let t=new Int32Array(e.buffer,e.byteOffset,Xg),i=new Int32Array(e.buffer,e.byteOffset,Xg+4),r=1;t[wb]&Ib&&(r=Math.max(1,t[Ub]));let s=t[Vb],a=s===zg?i[rk]:0,o=0;switch(s){case Pb:o=2;break;case Ob:o=1;break;case zg:if(a===Fb){o=2;break}if(a===Nb){o=1;break}}return{width:t[Yg],height:t[Bb],mipmapCount:r,isFourCC:(t[Kg]&Cb)===Cb,isRGB:(t[Kg]&bb)===bb,isLuminance:(t[Kg]&Mb)===Mb,isCube:(t[ik]&xb)===xb,isCompressed:s===yb||s===Db||s===Lb,dxgiFormat:a,textureType:o}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,i,r,s,a){let o=new Float32Array(r),l=new Uint16Array(s,i),c=0;for(let f=0;f>8)}static _GetRGBArrayBuffer(e,t,i,r,s,a,o,l){let c=new Uint8Array(r),f=new Uint8Array(s,i),d=0;for(let h=0;h0?r.sphericalPolynomial=ds.ConvertCubeMapToSphericalPolynomial({size:h[Yg],right:f[0],left:f[1],up:f[2],down:f[3],front:f[4],back:f[5],format:5,type:1,gammaSpace:!1}):r.sphericalPolynomial=void 0}};ln.StoreLODInAlphaChannel=!1});var kb=A(()=>{Ji();_r();ze();Xc();qc();We.prototype.createPrefilteredCubeTexture=function(n,e,t,i,r=null,s=null,a,o=null,l=!0){let c=async f=>{var g;if(!f){r&&r(null);return}let d=f.texture;if(l?f.info.sphericalPolynomial&&(d._sphericalPolynomial=f.info.sphericalPolynomial):d._sphericalPolynomial=(g=d._sphericalPolynomial)!=null?g:new On,d._source=9,this.getCaps().textureLOD){r&&r(d);return}let h=3,u=this._gl,m=f.width;if(!m)return;let{DDSTools:p}=await Promise.resolve().then(()=>(Q_(),Gb)),_=[];for(let T=0;T{Ji();Jd();We.prototype.createUniformBuffer=function(n,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");let i=new yn(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};We.prototype.createDynamicUniformBuffer=function(n,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");let i=new yn(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};We.prototype.updateUniformBuffer=function(n,e,t,i){this.bindUniformBuffer(n),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(n){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,n?n.underlyingResource:null)};We.prototype.bindUniformBufferBase=function(n,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,n?n.underlyingResource:null)};We.prototype.bindUniformBlock=function(n,e,t){let i=n.program,r=this._gl.getUniformBlockIndex(i,e);r!==4294967295&&this._gl.uniformBlockBinding(i,r,t)}});var Hb=A(()=>{yr();ii();fe.prototype.displayLoadingUI=function(){if(!Bt())return;let n=this.loadingScreen;n&&n.displayLoadingUI()};fe.prototype.hideLoadingUI=function(){if(!Bt())return;let n=this._loadingScreen;n&&n.hideLoadingUI()};Object.defineProperty(fe.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=fe.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(n){this._loadingScreen=n},enumerable:!0,configurable:!0});Object.defineProperty(fe.prototype,"loadingUIText",{set:function(n){this.loadingScreen.loadingUIText=n},enumerable:!0,configurable:!0});Object.defineProperty(fe.prototype,"loadingUIBackgroundColor",{set:function(n){this.loadingScreen.loadingUIBackgroundColor=n},enumerable:!0,configurable:!0})});var zb=A(()=>{ii();fe.prototype.getInputElement=function(){return this._renderingCanvas};fe.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};fe.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};fe.prototype.getAspectRatio=function(n,e=!1){let t=n.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};fe.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};fe.prototype._verifyPointerLock=function(){var n;(n=this._onPointerLockChange)==null||n.call(this)}});var jg=A(()=>{ii();fe.prototype.setAlphaEquation=function(n,e=0){if(this._alphaEquation[e]!==n){switch(n){case 0:this._alphaState.setAlphaEquationParameters(32774,32774,e);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778,e);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779,e);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776,e);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775,e);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774,e);break}this._alphaEquation[e]=n}}});var Xb=A(()=>{ii();jg();fe.prototype.getInputElement=function(){return this._renderingCanvas};fe.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};fe.prototype.setDepthFunction=function(n){this._depthCullingState.depthFunc=n};fe.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};fe.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};fe.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};fe.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};fe.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};fe.prototype.setDepthWrite=function(n){this._depthCullingState.depthMask=n};fe.prototype.setAlphaConstants=function(n,e,t,i){this._alphaState.setAlphaBlendConstants(n,e,t,i)};fe.prototype.getAlphaMode=function(n=0){return this._alphaMode[n]};fe.prototype.getAlphaEquation=function(n=0){return this._alphaEquation[n]}});var Yb=A(()=>{ii();jg();fe.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};fe.prototype.setStencilBuffer=function(n){this._stencilState.stencilTest=n};fe.prototype.getStencilMask=function(){return this._stencilState.stencilMask};fe.prototype.setStencilMask=function(n){this._stencilState.stencilMask=n};fe.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};fe.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};fe.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};fe.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};fe.prototype.setStencilFunction=function(n){this._stencilState.stencilFunc=n};fe.prototype.setStencilBackFunction=function(n){this._stencilState.stencilBackFunc=n};fe.prototype.setStencilFunctionReference=function(n){this._stencilState.stencilFuncRef=n};fe.prototype.setStencilFunctionMask=function(n){this._stencilState.stencilFuncMask=n};fe.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};fe.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};fe.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};fe.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};fe.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};fe.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};fe.prototype.setStencilOperationFail=function(n){this._stencilState.stencilOpStencilFail=n};fe.prototype.setStencilBackOperationFail=function(n){this._stencilState.stencilBackOpStencilFail=n};fe.prototype.setStencilOperationDepthFail=function(n){this._stencilState.stencilOpDepthFail=n};fe.prototype.setStencilBackOperationDepthFail=function(n){this._stencilState.stencilBackOpDepthFail=n};fe.prototype.setStencilOperationPass=function(n){this._stencilState.stencilOpStencilDepthPass=n};fe.prototype.setStencilBackOperationPass=function(n){this._stencilState.stencilBackOpStencilDepthPass=n};fe.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()};fe.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)}});var Kb=A(()=>{ii();fe.prototype.getRenderPassNames=function(){return this._renderPassNames};fe.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};fe.prototype.createRenderPassId=function(n){let e=++fe._RenderPassIdCounter;return this._renderPassNames[e]=n!=null?n:"NONAME",e};fe.prototype.releaseRenderPassId=function(n){this._renderPassNames[n]=void 0;for(let e=0;e{ii();fe.prototype._loadFileAsync=async function(n,e,t){return await new Promise((i,r)=>{this._loadFile(n,s=>{i(s)},void 0,e,t,(s,a)=>{r(a)})})}});var Zb=A(()=>{Hg();ii();fe.GetCompatibleTextureLoader=Kh});function nk(n){!n||!n.setAttribute||(n.setAttribute("touch-action","none"),n.style.touchAction="none",n.style.webkitTapHighlightColor="transparent")}function qb(n,e,t){n._onCanvasFocus=()=>{n.onCanvasFocusObservable.notifyObservers(n)},n._onCanvasBlur=()=>{n.onCanvasBlurObservable.notifyObservers(n)},n._onCanvasContextMenu=r=>{n.disableContextMenu&&r.preventDefault()},e.addEventListener("focus",n._onCanvasFocus),e.addEventListener("blur",n._onCanvasBlur),e.addEventListener("contextmenu",n._onCanvasContextMenu),n._onBlur=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.disable(),n._windowIsBackground=!0},n._onFocus=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.enable(),n._windowIsBackground=!1},n._onCanvasPointerOut=r=>{document.elementFromPoint(r.clientX,r.clientY)!==e&&n.onCanvasPointerOutObservable.notifyObservers(r)};let i=n.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",n._onBlur),i.addEventListener("focus",n._onFocus)),e.addEventListener("pointerout",n._onCanvasPointerOut),t.doNotHandleTouchAction||nk(e),!fe.audioEngine&&t.audioEngine&&fe.AudioEngineFactory&&(fe.audioEngine=fe.AudioEngineFactory(n.getRenderingCanvas(),n.getAudioContext(),n.getAudioDestination())),sa()&&(n._onFullscreenChange=()=>{n.isFullscreen=!!document.fullscreenElement,n.isFullscreen&&n._pointerLockRequested&&e&&Zg(e)},document.addEventListener("fullscreenchange",n._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",n._onFullscreenChange,!1),n._onPointerLockChange=()=>{n.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",n._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",n._onPointerLockChange,!1)),n.enableOfflineSupport=fe.OfflineProviderFactory!==void 0,n._deterministicLockstep=!!t.deterministicLockstep,n._lockstepMaxSteps=t.lockstepMaxSteps||0,n._timeStep=t.timeStep||1/60}function Qb(n,e){ue.Instances.length===1&&fe.audioEngine&&(fe.audioEngine.dispose(),fe.audioEngine=null);let t=n.getHostWindow();t&&typeof t.removeEventListener=="function"&&(t.removeEventListener("blur",n._onBlur),t.removeEventListener("focus",n._onFocus)),e&&(e.removeEventListener("focus",n._onCanvasFocus),e.removeEventListener("blur",n._onCanvasBlur),e.removeEventListener("pointerout",n._onCanvasPointerOut),e.removeEventListener("contextmenu",n._onCanvasContextMenu)),sa()&&(document.removeEventListener("fullscreenchange",n._onFullscreenChange),document.removeEventListener("mozfullscreenchange",n._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",n._onFullscreenChange),document.removeEventListener("msfullscreenchange",n._onFullscreenChange),document.removeEventListener("pointerlockchange",n._onPointerLockChange),document.removeEventListener("mspointerlockchange",n._onPointerLockChange),document.removeEventListener("mozpointerlockchange",n._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",n._onPointerLockChange))}function Jb(n){let e=document.createElement("span");e.textContent="Hg",e.style.font=n;let t=document.createElement("div");t.style.display="inline-block",t.style.width="1px",t.style.height="0px",t.style.verticalAlign="bottom";let i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(e),i.appendChild(t),document.body.appendChild(i);let r,s;try{s=t.getBoundingClientRect().top-e.getBoundingClientRect().top,t.style.verticalAlign="baseline",r=t.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:r,height:s,descent:s-r}}async function $b(n,e,t){return await new Promise((i,r)=>{let s=new Image;s.onload=()=>{s.decode().then(()=>{n.createImageBitmap(s,t).then(a=>{i(a)})})},s.onerror=()=>{r(`Error loading image ${s.src}`)},s.src=e})}function eM(n,e,t,i){let s=n.createCanvas(t,i).getContext("2d");if(!s)throw new Error("Unable to get 2d context for resizeImageBitmap");return s.drawImage(e,0,0),s.getImageData(0,0,t,i).data}function tM(n){let e=n.requestFullscreen||n.webkitRequestFullscreen;e&&e.call(n)}function iM(){let n=document;document.exitFullscreen?document.exitFullscreen():n.webkitCancelFullScreen&&n.webkitCancelFullScreen()}function Zg(n){if(n.requestPointerLock){let e=n.requestPointerLock();e instanceof Promise?e.then(()=>{n.focus()}).catch(()=>{}):n.focus()}}function rM(){document.exitPointerLock&&document.exitPointerLock()}var nM=A(()=>{yr();ii();At()});var Ee,qg=A(()=>{_r();At();Ji();tI();Jd();ze();d_();iI();aI();oI();lI();cI();hI();uI();mI();kb();Wb();Hb();zb();Xb();Yb();Kb();p_();jb();Zb();ii();nM();lg();Mn();Ee=class n extends We{static get NpmPackage(){return fe.NpmPackage}static get Version(){return fe.Version}static get Instances(){return ue.Instances}static get LastCreatedEngine(){return ue.LastCreatedEngine}static get LastCreatedScene(){return ue.LastCreatedScene}static DefaultLoadingScreenFactory(e){return fe.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!n._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,r=!1){super(e,t,i,r),this.customAnimationFrameRequester=null,this._performanceMonitor=new eh,this._drawCalls=new Bn,e&&(this._features.supportRenderPasses=!0)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),qb(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return eM(this,e,t,i)}async _createImageBitmapFromSource(e,t){return await $b(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&tM(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&iM()}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,r){let s=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),s}scissorClear(e,t,i,r,s){this.enableScissor(e,t,i,r),this.clear(s,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,r){let s=this._gl;s.enable(s.SCISSOR_TEST),s.scissor(e,t,i,r)}disableScissor(){let e=this._gl;e.disable(e.SCISSOR_TEST)}getVertexShaderSource(e){let t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){let 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(let e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(let e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return Jb(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;let{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&Zg(this._renderingCanvas)}exitPointerlock(){rM()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){let t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,i,r,s,a=null){s=s||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);let o=super.createShaderProgram(e,t,i,r,s,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,r,s=null){let a=r.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");if(r.attachShader(a,t),r.attachShader(a,i),this.webGLVersion>1&&s){let o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(a,s),e.transformFeedback=o}return r.linkProgram(a),this.webGLVersion>1&&s&&this.bindTransformFeedback(null),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),a}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e);for(let t of this.scenes){for(let i of t.postProcesses)i._outputTexture===e&&(i._outputTexture=null);for(let i of t.cameras)for(let r of i._postProcesses)r&&r._outputTexture===e&&(r._outputTexture=null)}}_rescaleTexture(e,t,i,r,s){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);let a=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&n._RescalePostProcessFactory&&(this._rescalePostProcess=n._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;let o=()=>{this._rescalePostProcess.onApply=function(f){f._bindTexture("textureSampler",e)};let c=i;c||(c=this.scenes[this.scenes.length-1]),c.postProcessManager.directRender([this._rescalePostProcess],a,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,r,0,0,t.width,t.height,0),this.unBindFramebuffer(a),a.dispose(),s&&s()},l=this._rescalePostProcess.getEffect();l?l.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(c=>{c.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,r=0,s=0){let a=new el(e,this._gl),o=new bt(this,0,!0);return o._hardwareTexture=a,o.baseWidth=r,o.baseHeight=s,o.width=r,o.height=s,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,r=0){let s=this._gl,a=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),l=this._getRGBABufferInternalSizedFormat(e.type,o),c=e.isCube?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);let f=s.TEXTURE_2D;e.isCube&&(f=s.TEXTURE_CUBE_MAP_POSITIVE_X+i),s.texImage2D(f,r,l,o,a,t),this._bindTextureDirectly(c,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){W.Error("WebGL 1 does not support texture comparison.");return}let 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){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");let i=new yn(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,t=0,i=10){let r=this._gl;return await new Promise((s,a)=>{bn(()=>{let o=r.clientWaitSync(e,t,0);if(o==r.WAIT_FAILED)throw new Error("clientWaitSync failed");return o!=r.TIMEOUT_EXPIRED},s,a,i)})}_readPixelsAsync(e,t,i,r,s,a,o){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");let l=this._gl,c=l.createBuffer();l.bindBuffer(l.PIXEL_PACK_BUFFER,c),l.bufferData(l.PIXEL_PACK_BUFFER,o.byteLength,l.STREAM_READ),l.readPixels(e,t,i,r,s,a,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);let f=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);return f?(l.flush(),this._clientWaitAsync(f,0,10).then(()=>(l.deleteSync(f),l.bindBuffer(l.PIXEL_PACK_BUFFER,c),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,o),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),l.deleteBuffer(c),o))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),Qb(this,this._renderingCanvas),super.dispose()}};Ee.ALPHA_DISABLE=0;Ee.ALPHA_ADD=1;Ee.ALPHA_COMBINE=2;Ee.ALPHA_SUBTRACT=3;Ee.ALPHA_MULTIPLY=4;Ee.ALPHA_MAXIMIZED=5;Ee.ALPHA_ONEONE=6;Ee.ALPHA_PREMULTIPLIED=7;Ee.ALPHA_PREMULTIPLIED_PORTERDUFF=8;Ee.ALPHA_INTERPOLATE=9;Ee.ALPHA_SCREENMODE=10;Ee.DELAYLOADSTATE_NONE=0;Ee.DELAYLOADSTATE_LOADED=1;Ee.DELAYLOADSTATE_LOADING=2;Ee.DELAYLOADSTATE_NOTLOADED=4;Ee.NEVER=512;Ee.ALWAYS=519;Ee.LESS=513;Ee.EQUAL=514;Ee.LEQUAL=515;Ee.GREATER=516;Ee.GEQUAL=518;Ee.NOTEQUAL=517;Ee.KEEP=7680;Ee.REPLACE=7681;Ee.INCR=7682;Ee.DECR=7683;Ee.INVERT=5386;Ee.INCR_WRAP=34055;Ee.DECR_WRAP=34056;Ee.TEXTURE_CLAMP_ADDRESSMODE=0;Ee.TEXTURE_WRAP_ADDRESSMODE=1;Ee.TEXTURE_MIRROR_ADDRESSMODE=2;Ee.TEXTUREFORMAT_ALPHA=0;Ee.TEXTUREFORMAT_LUMINANCE=1;Ee.TEXTUREFORMAT_LUMINANCE_ALPHA=2;Ee.TEXTUREFORMAT_RGB=4;Ee.TEXTUREFORMAT_RGBA=5;Ee.TEXTUREFORMAT_RED=6;Ee.TEXTUREFORMAT_R=6;Ee.TEXTUREFORMAT_R16_UNORM=33322;Ee.TEXTUREFORMAT_RG16_UNORM=33324;Ee.TEXTUREFORMAT_RGB16_UNORM=32852;Ee.TEXTUREFORMAT_RGBA16_UNORM=32859;Ee.TEXTUREFORMAT_R16_SNORM=36760;Ee.TEXTUREFORMAT_RG16_SNORM=36761;Ee.TEXTUREFORMAT_RGB16_SNORM=36762;Ee.TEXTUREFORMAT_RGBA16_SNORM=36763;Ee.TEXTUREFORMAT_RG=7;Ee.TEXTUREFORMAT_RED_INTEGER=8;Ee.TEXTUREFORMAT_R_INTEGER=8;Ee.TEXTUREFORMAT_RG_INTEGER=9;Ee.TEXTUREFORMAT_RGB_INTEGER=10;Ee.TEXTUREFORMAT_RGBA_INTEGER=11;Ee.TEXTURETYPE_UNSIGNED_BYTE=0;Ee.TEXTURETYPE_UNSIGNED_INT=0;Ee.TEXTURETYPE_FLOAT=1;Ee.TEXTURETYPE_HALF_FLOAT=2;Ee.TEXTURETYPE_BYTE=3;Ee.TEXTURETYPE_SHORT=4;Ee.TEXTURETYPE_UNSIGNED_SHORT=5;Ee.TEXTURETYPE_INT=6;Ee.TEXTURETYPE_UNSIGNED_INTEGER=7;Ee.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;Ee.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;Ee.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;Ee.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;Ee.TEXTURETYPE_UNSIGNED_INT_24_8=12;Ee.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;Ee.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;Ee.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;Ee.TEXTURE_NEAREST_SAMPLINGMODE=1;Ee.TEXTURE_BILINEAR_SAMPLINGMODE=2;Ee.TEXTURE_TRILINEAR_SAMPLINGMODE=3;Ee.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;Ee.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;Ee.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;Ee.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;Ee.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;Ee.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;Ee.TEXTURE_NEAREST_LINEAR=7;Ee.TEXTURE_NEAREST_NEAREST=1;Ee.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;Ee.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;Ee.TEXTURE_LINEAR_LINEAR=2;Ee.TEXTURE_LINEAR_NEAREST=12;Ee.TEXTURE_EXPLICIT_MODE=0;Ee.TEXTURE_SPHERICAL_MODE=1;Ee.TEXTURE_PLANAR_MODE=2;Ee.TEXTURE_CUBIC_MODE=3;Ee.TEXTURE_PROJECTION_MODE=4;Ee.TEXTURE_SKYBOX_MODE=5;Ee.TEXTURE_INVCUBIC_MODE=6;Ee.TEXTURE_EQUIRECTANGULAR_MODE=7;Ee.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;Ee.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;Ee.SCALEMODE_FLOOR=1;Ee.SCALEMODE_NEAREST=2;Ee.SCALEMODE_CEILING=3});var Qg,dt,vr=A(()=>{Qe();ve();qe();ct();At();gi();Kt();Qg=class{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new Y,this._onClonedObservable=new Y,this._inheritVisibility=!1,this._isVisible=!0}},dt=class n{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,r){let s=this._NodeConstructors[e];return s?s(t,i,r):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;let t=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){let i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}get inheritVisibility(){return this._nodeDataStorage._inheritVisibility}set inheritVisibility(e){this._nodeDataStorage._inheritVisibility=e}get isVisible(){return this.inheritVisibility&&this._parentNode&&!this._parentNode.isVisible?!1:this._nodeDataStorage._isVisible}set isVisible(e){this._nodeDataStorage._isVisible=e}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){let 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 Qg,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new Y,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=G.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new Y,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||ue.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(()=>{this._behaviors.includes(e)&&e.attach(this)}):e.attach(this),this._behaviors.push(e),this)}removeBehavior(e){let 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(let t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return this._parentNode?this._parentNode._isDirty||this._parentUpdateId!==this._parentNode._childUpdateId?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._parentNode&&!this.isSynchronizedWithParent()?!1:this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){if(this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children)for(let e of this._children)e._syncParentEnabledState()}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return this.parent?this.parent===e?!0:this.parent.isDescendantOf(e):!1}_getDescendants(e,t=!1,i){if(this._children)for(let r=0;r(!t||t(r))&&r.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;tnew n(e,this.getScene()),this);if(t&&(r.parent=t),!i){let s=this.getDescendants(!0);for(let a=0;a{throw Ie("AnimationRange")};dt._NodeConstructors={};C([D()],dt.prototype,"name",void 0);C([D()],dt.prototype,"id",void 0);C([D()],dt.prototype,"uniqueId",void 0);C([D()],dt.prototype,"state",void 0);C([D()],dt.prototype,"metadata",void 0)});function Jg(n,e,t){try{let i=n.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function sM(n=25){let e;return(t,i,r)=>{let s=performance.now();e===void 0||s-e>n?(e=s,setTimeout(()=>{Jg(t,i,r)},0)):Jg(t,i,r)}}function aM(n,e,t,i,r){let s=()=>{let a,o=l=>{l.done?t(l.value):a===void 0?a=!0:s()};do a=void 0,!r||!r.aborted?e(n,o,i):i(new Error("Aborted")),a===void 0&&(a=!1);while(a)};s()}function Tf(n,e){let t;return aM(n,Jg,i=>t=i,i=>{throw i},e),t}async function oM(n,e,t){return await new Promise((i,r)=>{aM(n,e,i,r,t)})}function lM(n,e){return(...t)=>Tf(n(...t),e)}var $g=A(()=>{});var Ge,Rs=A(()=>{Qe();qe();on();Tt();ct();ve();vr();ze();Lt();gi();fl();sh();Kt();Ge=class n extends dt{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,r,s,a;let e,t;if(this.mode===n.PERSPECTIVE_CAMERA)this.fovMode===n.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{let o=this.getEngine().getRenderWidth()/2,l=this.getEngine().getRenderHeight()/2;e=((i=this.orthoRight)!=null?i:o)-((r=this.orthoLeft)!=null?r:-o),t=((s=this.orthoTop)!=null?s:l)-((a=this.orthoBottom)!=null?a:-l)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(let t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(let t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(let t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(let t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}setFocalLength(e,t=36){this.fov=2*Math.atan(t/(2*e))}set mode(e){this._mode=e;for(let t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,i,r=!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=n.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new nn(0,0,1,1),this.layerMask=268435455,this.fovMode=n.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=n.RIG_MODE_NONE,this.ignoreCameraMaxZ=!1,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new Y,this.onProjectionMatrixChangedObservable=new Y,this.onAfterCheckInputsObservable=new Y,this.onRestoreStateObservable=new Y,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new G,this._postProcesses=new Array,this._activeMeshes=new Ct(256),this._globalPosition=v.Zero(),this._computedViewMatrix=G.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=G.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=Ae.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.layerMask=this.getScene().defaultCameraLayerMask,this.getScene().addCamera(this),r&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return this._stateStored?(this.fov=this._storedFov,!0):!1}restoreState(){return this._restoreStateValues()?(this.onRestoreStateObservable.notifyObservers(this),!0):!1}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let i=0;i-1?(W.Error("You're trying to reuse a post process not defined as reusable."),0):(t==null||t<0?this._postProcesses.push(e):this._postProcesses[t]===null?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){let 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 G.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.getTranslationToRef(this._globalPosition),this._computedViewMatrix)}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,e!==void 0&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){var a,o,l,c,f,d,h,u,m,p,_,g,T,b,R,S,I,x,P;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;let t=this.ignoreCameraMaxZ?0:this.maxZ;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=t,this._refreshFrustumPlanes=!0;let i=this.getEngine(),r=this.getScene(),s=i.useReverseDepthBuffer;if(this.mode===n.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let L;r.useRightHandedSystem?L=G.PerspectiveFovRHToRef:L=G.PerspectiveFovLHToRef,L(this.fov,i.getAspectRatio(this),s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,this.fovMode===n.FOVMODE_VERTICAL_FIXED,i.isNDCHalfZRange,this.projectionPlaneTilt,s)}else{let L=i.getRenderWidth()/2,y=i.getRenderHeight()/2;r.useRightHandedSystem?this.oblique?G.ObliqueOffCenterRHToRef((a=this.orthoLeft)!=null?a:-L,(o=this.orthoRight)!=null?o:L,(l=this.orthoBottom)!=null?l:-y,(c=this.orthoTop)!=null?c:y,s?t:this.minZ,s?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):G.OrthoOffCenterRHToRef((f=this.orthoLeft)!=null?f:-L,(d=this.orthoRight)!=null?d:L,(h=this.orthoBottom)!=null?h:-y,(u=this.orthoTop)!=null?u:y,s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange):this.oblique?G.ObliqueOffCenterLHToRef((m=this.orthoLeft)!=null?m:-L,(p=this.orthoRight)!=null?p:L,(_=this.orthoBottom)!=null?_:-y,(g=this.orthoTop)!=null?g:y,s?t:this.minZ,s?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):G.OrthoOffCenterLHToRef((T=this.orthoLeft)!=null?T:-L,(b=this.orthoRight)!=null?b:L,(R=this.orthoBottom)!=null?R:-y,(S=this.orthoTop)!=null?S:y,s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=(I=this.oblique)==null?void 0:I.angle,this._cache.obliqueLength=(x=this.oblique)==null?void 0:x.length,this._cache.obliqueOffset=(P=this.oblique)==null?void 0:P.offset,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){let 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?oa.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=oa.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let i=!1;for(let r of this.rigCameras)r._updateFrustumPlanes(),i=i||e.isInFrustum(r._frustumPlanes);return i}else return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw Ie("Ray")}getForwardRayToRef(e,t=100,i,r){throw Ie("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){let r=this._rigCameras.pop();r&&r.dispose()}if(this._parentContainer){let r=this._parentContainer.cameras.indexOf(this);r>-1&&this._parentContainer.cameras.splice(r,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==n.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let r=this._postProcesses.length;for(;--r>=0;){let s=this._postProcesses[r];s&&s.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;){let i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=re.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==n.RIG_MODE_NONE){let i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);let r=this.createRigCamera(this.name+"_R",1);r&&(r._isRightCamera=!0),i&&r&&(this._rigCameras.push(i),this._rigCameras.push(r))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return G.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=re.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;en._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){let i=e.type,r=n.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),s=Me.Parse(r,e,t);if(e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),s.inputs&&(s.inputs.parse(e),s._setupInputs()),e.upVector&&(s.upVector=v.FromArray(e.upVector)),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(v.FromArray(e.position))),e.target&&s.setTarget&&s.setTarget(v.FromArray(e.target)),e.cameraRigMode){let a=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};s.setCameraRigMode(e.cameraRigMode,a)}if(e.animations){for(let a=0;a{throw Ie("UniversalCamera")};Ge.PERSPECTIVE_CAMERA=0;Ge.ORTHOGRAPHIC_CAMERA=1;Ge.FOVMODE_VERTICAL_FIXED=0;Ge.FOVMODE_HORIZONTAL_FIXED=1;Ge.RIG_MODE_NONE=0;Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;Ge.RIG_MODE_STEREOSCOPIC_INTERLACED=14;Ge.RIG_MODE_VR=20;Ge.RIG_MODE_CUSTOM=22;Ge.ForceAttachControlToAlwaysPreventDefault=!1;C([ai("position")],Ge.prototype,"_position",void 0);C([ai("upVector")],Ge.prototype,"_upVector",void 0);C([D()],Ge.prototype,"orthoLeft",null);C([D()],Ge.prototype,"orthoRight",null);C([D()],Ge.prototype,"orthoBottom",null);C([D()],Ge.prototype,"orthoTop",null);C([D()],Ge.prototype,"fov",void 0);C([D()],Ge.prototype,"projectionPlaneTilt",void 0);C([D()],Ge.prototype,"minZ",void 0);C([D()],Ge.prototype,"maxZ",void 0);C([D()],Ge.prototype,"inertia",void 0);C([D()],Ge.prototype,"mode",null);C([D()],Ge.prototype,"layerMask",void 0);C([D()],Ge.prototype,"fovMode",void 0);C([D()],Ge.prototype,"cameraRigMode",void 0);C([D()],Ge.prototype,"interaxialDistance",void 0);C([D()],Ge.prototype,"isStereoscopicSideBySide",void 0);C([D()],Ge.prototype,"ignoreCameraMaxZ",void 0)});var Io,eE=A(()=>{Io=class{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}});var va,tE=A(()=>{Ln();ve();Ci();va=class n{constructor(e,t,i){this.vectors=Ei(8,v.Zero),this.center=v.Zero(),this.centerWorld=v.Zero(),this.extendSize=v.Zero(),this.extendSizeWorld=v.Zero(),this.directions=Ei(3,v.Zero),this.vectorsWorld=Ei(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){let r=e.x,s=e.y,a=e.z,o=t.x,l=t.y,c=t.z,f=this.vectors;this.minimum.copyFromFloats(r,s,a),this.maximum.copyFromFloats(o,l,c),f[0].copyFromFloats(r,s,a),f[1].copyFromFloats(o,l,c),f[2].copyFromFloats(o,s,a),f[3].copyFromFloats(r,l,a),f[4].copyFromFloats(r,s,c),f[5].copyFromFloats(o,l,a),f[6].copyFromFloats(r,l,c),f[7].copyFromFloats(o,s,c),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||G.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){let t=n._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),r=i.length();i.normalizeFromLength(r);let s=r*e,a=i.scaleInPlace(s*.5),o=this.center.subtractToRef(a,t[1]),l=this.center.addToRef(a,t[2]);return this.reConstruct(o,l,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){let t=this.minimumWorld,i=this.maximumWorld,r=this.directions,s=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)s[o].copyFrom(a[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){let l=s[o];v.TransformCoordinatesToRef(a[o],e,l),t.minimizeInPlace(l),i.maximizeInPlace(l)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}v.FromArrayToRef(e.m,0,r[0]),v.FromArrayToRef(e.m,4,r[1]),v.FromArrayToRef(e.m,8,r[2]),this._worldMatrix=e}isInFrustum(e){return n.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return n.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){let t=this.minimumWorld,i=this.maximumWorld,r=t.x,s=t.y,a=t.z,o=i.x,l=i.y,c=i.z,f=e.x,d=e.y,h=e.z,u=-Ye;return!(o-ff-r||l-dd-s||c-hh-a)}intersectsSphere(e){return n.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){let i=this.minimumWorld,r=this.maximumWorld,s=i.x,a=i.y,o=i.z,l=r.x,c=r.y,f=r.z,d=e.x,h=e.y,u=e.z,m=t.x,p=t.y,_=t.z;return!(lm||cp||f_)}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,r){let s=n._TmpVector3[0];return v.ClampToRef(i,e,t,s),v.DistanceSquared(i,s)<=r*r}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){let r=t[i];for(let s=0;s<8;++s)if(r.dotCoordinate(e[s])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let r=!0,s=t[i];for(let a=0;a<8;++a)if(s.dotCoordinate(e[a])>=0){r=!1;break}if(r)return!1}return!0}};va._TmpVector3=Ei(3,v.Zero)});var Cl,cM=A(()=>{Ln();ve();Cl=class n{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);let r=v.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=r*.5,this._update(i||G.IdentityReadOnly)}scale(e){let t=this.radius*e,i=n._TmpVector3,r=i[0].setAll(t),s=this.center.subtractToRef(r,i[1]),a=this.center.addToRef(r,i[2]);return this.reConstruct(s,a,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);let t=n._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){let t=this.centerWorld,i=this.radiusWorld;for(let r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){let t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){let t=v.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld{Ln();ve();tE();cM();iE={min:0,max:0},rE={min:0,max:0},fM=(n,e,t)=>{let i=v.Dot(e.centerWorld,n),r=Math.abs(v.Dot(e.directions[0],n))*e.extendSize.x,s=Math.abs(v.Dot(e.directions[1],n))*e.extendSize.y,a=Math.abs(v.Dot(e.directions[2],n))*e.extendSize.z,o=r+s+a;t.min=i-o,t.max=i+o},zi=(n,e,t)=>(fM(n,e,iE),fM(n,t,rE),!(iE.min>rE.max||rE.min>iE.max)),vi=class n{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new va(e,t,i),this.boundingSphere=new Cl(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){let i=n._TmpVector3[0].copyFrom(e).subtractInPlace(t),r=n._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this}encapsulate(e){let t=v.Minimize(this.minimum,e),i=v.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){let t=k.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);let i=k.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(){let e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,n._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(!Cl.Intersects(this.boundingSphere,e.boundingSphere)||!va.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;let i=this.boundingBox,r=e.boundingBox;return!(!zi(i.directions[0],i,r)||!zi(i.directions[1],i,r)||!zi(i.directions[2],i,r)||!zi(r.directions[0],i,r)||!zi(r.directions[1],i,r)||!zi(r.directions[2],i,r)||!zi(v.Cross(i.directions[0],r.directions[0]),i,r)||!zi(v.Cross(i.directions[0],r.directions[1]),i,r)||!zi(v.Cross(i.directions[0],r.directions[2]),i,r)||!zi(v.Cross(i.directions[1],r.directions[0]),i,r)||!zi(v.Cross(i.directions[1],r.directions[1]),i,r)||!zi(v.Cross(i.directions[1],r.directions[2]),i,r)||!zi(v.Cross(i.directions[2],r.directions[0]),i,r)||!zi(v.Cross(i.directions[2],r.directions[1]),i,r)||!zi(v.Cross(i.directions[2],r.directions[2]),i,r))}};vi._TmpVector3=Ei(2,v.Zero)});function dM(n,e,t,i,r=null){let s=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Ml.extractMinAndMaxIndexed(n,e,t,i,s,a),r&&(s.x-=s.x*r.x+r.y,s.y-=s.y*r.x+r.y,s.z-=s.z*r.x+r.y,a.x+=a.x*r.x+r.y,a.y+=a.y*r.x+r.y,a.z+=a.z*r.x+r.y),{minimum:s,maximum:a}}function Zh(n,e,t,i=null,r){let s=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r||(r=3),Ml.extractMinAndMax(n,e,t,r,s,a),i&&(s.x-=s.x*i.x+i.y,s.y-=s.y*i.x+i.y,s.z-=s.z*i.x+i.y,a.x+=a.x*i.x+i.y,a.y+=a.y*i.x+i.y,a.z+=a.z*i.x+i.y),{minimum:s,maximum:a}}var Ml,qh=A(()=>{Qe();ve();qe();Ml=class{static extractMinAndMaxIndexed(e,t,i,r,s,a){for(let o=i;o!Array.isArray(n[0])&&!Array.isArray(n[1]))],Ml,"extractMinAndMaxIndexed",null);C([tr.filter((...n)=>!Array.isArray(n[0]))],Ml,"extractMinAndMax",null)});var rr,Sf=A(()=>{yt();eE();bl();qh();go();rr=class n{get materialDefines(){var t;let e=this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:(t=this._getDrawWrapper())==null?void 0:t.defines;return typeof e=="string"?null:e}set materialDefines(e){var i;let 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 Hi(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){var r;t&&((r=this._drawWrappers[e])==null||r.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,r=!0){let s=this._drawWrapper;s.setEffect(e,t,r),i!==void 0&&(s.materialContext=i),e||(s.defines=null,s.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(let i of this._drawWrappers)i==null||i.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,r,s,a,o,l=!0){return new n(e,t,i,r,s,a,o,l)}constructor(e,t,i,r,s,a,o,l=!0,c=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=s,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=a,this._renderingMesh=o||a,c&&a.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=a.subMeshes.length-1,l&&(this.refreshBoundingInfo(),a.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(){let e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){var i;let t=(i=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId))!=null?i:this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){let r=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==r&&(this._currentMaterial=r,this.resetDrawCache()),r}}else return e&&this._mesh.getScene()._hasDefaultMaterial?this._mesh.getScene().defaultMaterial:null;return t}_isMultiMaterial(e){return e.getSubMaterial!==void 0}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(M.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;let t=this._renderingMesh.getIndices(),i;if(this.indexStart===0&&this.indexCount===t.length){let r=this._renderingMesh.getBoundingInfo();i={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else i=dM(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new vi(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){let t=this.getBoundingInfo();return t?t.isInFrustum(e,this._mesh.cullingStrategy):!1}isCompletelyInFrustum(e){let 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){let i=Math.floor(this.indexCount/3)*6,s=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i),a=0;if(e.length===0)for(let o=this.indexStart;ol&&(l=h)}return new n(e,o,l-o+1,t,i,r,s,a)}}});var Af,de,Vt=A(()=>{Qe();ve();yt();gi();et();ze();qe();$g();Kc();Sf();Af=class{},de=class n{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=lM(this._applyToCoroutine.bind(this)),this.uniqueId=n._UniqueIdGenerator,n._UniqueIdGenerator++}set(e,t){switch(e.length||W.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case M.PositionKind:this.positions=e;break;case M.NormalKind:this.normals=e;break;case M.TangentKind:this.tangents=e;break;case M.UVKind:this.uvs=e;break;case M.UV2Kind:this.uvs2=e;break;case M.UV3Kind:this.uvs3=e;break;case M.UV4Kind:this.uvs4=e;break;case M.UV5Kind:this.uvs5=e;break;case M.UV6Kind:this.uvs6=e;break;case M.ColorKind:this.colors=e;break;case M.MatricesIndicesKind:this.matricesIndices=e;break;case M.MatricesWeightsKind:this.matricesWeights=e;break;case M.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case M.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(M.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(M.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(M.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(M.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(M.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(M.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(M.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(M.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(M.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){let r=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(M.ColorKind,this.colors,t,r),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(M.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(M.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(M.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(M.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){let r=e;r.subMeshes=[];for(let s of this.materialInfos)new rr(s.materialIndex,s.verticesStart,s.verticesCount,s.indexStart,s.indexCount,r)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(M.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(M.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(M.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(M.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(M.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(M.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(M.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(M.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(M.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(M.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(M.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(M.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(M.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(M.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,r=e.length){let s=k.Vector3[0],a=k.Vector3[1];for(let o=i;o({vertexData:o})):[{vertexData:e}];return Tf(this._mergeCoroutine(void 0,a,t,!1,i,r,s))}*_mergeCoroutine(e,t,i=!1,r,s,a=!1,o=!1){var u,m,p,_;this._validate();let l=t.map(g=>g.vertexData),c=this;if(o)for(let g of l)g&&(g._validate(),!this.normals&&g.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&g.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&g.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&g.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&g.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&g.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&g.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&g.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&g.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&g.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&g.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&g.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&g.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(let g of l)if(g){if(o)this.normals&&!g.normals&&(g.normals=new Float32Array(g.positions.length)),this.tangents&&!g.tangents&&(g.tangents=new Float32Array(g.positions.length/3*4)),this.uvs&&!g.uvs&&(g.uvs=new Float32Array(g.positions.length/3*2)),this.uvs2&&!g.uvs2&&(g.uvs2=new Float32Array(g.positions.length/3*2)),this.uvs3&&!g.uvs3&&(g.uvs3=new Float32Array(g.positions.length/3*2)),this.uvs4&&!g.uvs4&&(g.uvs4=new Float32Array(g.positions.length/3*2)),this.uvs5&&!g.uvs5&&(g.uvs5=new Float32Array(g.positions.length/3*2)),this.uvs6&&!g.uvs6&&(g.uvs6=new Float32Array(g.positions.length/3*2)),this.colors&&!g.colors&&(g.colors=new Float32Array(g.positions.length/3*4),g.colors.fill(1)),this.matricesIndices&&!g.matricesIndices&&(g.matricesIndices=new Float32Array(g.positions.length/3*4)),this.matricesWeights&&!g.matricesWeights&&(g.matricesWeights=new Float32Array(g.positions.length/3*4)),this.matricesIndicesExtra&&!g.matricesIndicesExtra&&(g.matricesIndicesExtra=new Float32Array(g.positions.length/3*4)),this.matricesWeightsExtra&&!g.matricesWeightsExtra&&(g.matricesWeightsExtra=new Float32Array(g.positions.length/3*4));else if(g._validate(),!this.normals!=!g.normals||!this.tangents!=!g.tangents||!this.uvs!=!g.uvs||!this.uvs2!=!g.uvs2||!this.uvs3!=!g.uvs3||!this.uvs4!=!g.uvs4||!this.uvs5!=!g.uvs5||!this.uvs6!=!g.uvs6||!this.colors!=!g.colors||!this.matricesIndices!=!g.matricesIndices||!this.matricesWeights!=!g.matricesWeights||!this.matricesIndicesExtra!=!g.matricesIndicesExtra||!this.matricesWeightsExtra!=!g.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(a){let g,T=0,b=0,R=[],S=null,I=[];for(let P of this.splitBasedOnMaterialID())I.push({vertexData:P,transform:e});for(let P of t)if(P.vertexData)for(let L of P.vertexData.splitBasedOnMaterialID())I.push({vertexData:L,transform:P.transform});I.sort((P,L)=>{let y=P.vertexData.materialInfos?P.vertexData.materialInfos[0].materialIndex:0,B=L.vertexData.materialInfos?L.vertexData.materialInfos[0].materialIndex:0;return y>B?1:y===B?0:-1});for(let P of I){let L=P.vertexData;if(L.materialInfos?g=L.materialInfos[0].materialIndex:g=0,S&&S.materialIndex===g)S.indexCount+=L.indices.length,S.verticesCount+=L.positions.length/3;else{let y=new Af;y.materialIndex=g,y.indexStart=T,y.indexCount=L.indices.length,y.verticesStart=b,y.verticesCount=L.positions.length/3,R.push(y),S=y}T+=L.indices.length,b+=L.positions.length/3}let x=I.splice(0,1)[0];c=x.vertexData,e=x.transform,l=I.map(P=>P.vertexData),t=I,this.materialInfos=R}let f=l.reduce((g,T)=>{var b,R;return g+((R=(b=T.indices)==null?void 0:b.length)!=null?R:0)},(m=(u=c.indices)==null?void 0:u.length)!=null?m:0),h=s||l.some(g=>g.indices===c.indices)?(p=c.indices)==null?void 0:p.slice():c.indices;if(f>0){let g=(_=h==null?void 0:h.length)!=null?_:0;if(h||(h=new Array(f)),h.length!==f){if(Array.isArray(h))h.length=f;else{let b=i||h instanceof Uint32Array?new Uint32Array(f):new Uint16Array(f);b.set(h),h=b}e&&e.determinant()<0&&n._FlipFaces(h,0,g)}let T=c.positions?c.positions.length/3:0;for(let{vertexData:b,transform:R}of t)if(b.indices){for(let S=0;S[g.vertexData.positions,g.transform])),r&&(yield),c.normals&&(this.normals=n._MergeElement(M.NormalKind,c.normals,e,t.map(g=>[g.vertexData.normals,g.transform])),r&&(yield)),c.tangents&&(this.tangents=n._MergeElement(M.TangentKind,c.tangents,e,t.map(g=>[g.vertexData.tangents,g.transform])),r&&(yield)),c.uvs&&(this.uvs=n._MergeElement(M.UVKind,c.uvs,e,t.map(g=>[g.vertexData.uvs,g.transform])),r&&(yield)),c.uvs2&&(this.uvs2=n._MergeElement(M.UV2Kind,c.uvs2,e,t.map(g=>[g.vertexData.uvs2,g.transform])),r&&(yield)),c.uvs3&&(this.uvs3=n._MergeElement(M.UV3Kind,c.uvs3,e,t.map(g=>[g.vertexData.uvs3,g.transform])),r&&(yield)),c.uvs4&&(this.uvs4=n._MergeElement(M.UV4Kind,c.uvs4,e,t.map(g=>[g.vertexData.uvs4,g.transform])),r&&(yield)),c.uvs5&&(this.uvs5=n._MergeElement(M.UV5Kind,c.uvs5,e,t.map(g=>[g.vertexData.uvs5,g.transform])),r&&(yield)),c.uvs6&&(this.uvs6=n._MergeElement(M.UV6Kind,c.uvs6,e,t.map(g=>[g.vertexData.uvs6,g.transform])),r&&(yield)),c.colors&&(this.colors=n._MergeElement(M.ColorKind,c.colors,e,t.map(g=>[g.vertexData.colors,g.transform])),(c.hasVertexAlpha!==void 0||t.some(g=>g.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=c.hasVertexAlpha||t.some(g=>g.vertexData.hasVertexAlpha)),r&&(yield)),c.matricesIndices&&(this.matricesIndices=n._MergeElement(M.MatricesIndicesKind,c.matricesIndices,e,t.map(g=>[g.vertexData.matricesIndices,g.transform])),r&&(yield)),c.matricesWeights&&(this.matricesWeights=n._MergeElement(M.MatricesWeightsKind,c.matricesWeights,e,t.map(g=>[g.vertexData.matricesWeights,g.transform])),r&&(yield)),c.matricesIndicesExtra&&(this.matricesIndicesExtra=n._MergeElement(M.MatricesIndicesExtraKind,c.matricesIndicesExtra,e,t.map(g=>[g.vertexData.matricesIndicesExtra,g.transform])),r&&(yield)),c.matricesWeightsExtra&&(this.matricesWeightsExtra=n._MergeElement(M.MatricesWeightsExtraKind,c.matricesWeightsExtra,e,t.map(g=>[g.vertexData.matricesWeightsExtra,g.transform]))),this}static _MergeElement(e,t,i,r){let s=r.filter(l=>l[0]!==null&&l[0]!==void 0);if(!t&&s.length==0)return t;if(!t)return this._MergeElement(e,s[0][0],s[0][1],s.slice(1));let a=s.reduce((l,c)=>l+c[0].length,t.length),o=e===M.PositionKind?n._TransformVector3Coordinates:e===M.NormalKind?n._TransformVector3Normals:e===M.TangentKind?n._TransformVector4Normals:()=>{};if(t instanceof Float32Array){let l=new Float32Array(a);l.set(t),i&&o(l,i,0,t.length);let c=t.length;for(let[f,d]of s)l.set(f,c),d&&o(l,d,c,f.length),c+=f.length;return l}else{let l=new Array(a);for(let f=0;f{let a=M.DeduceStride(r);if(s.length%a!==0)throw new Error("The "+r+"s array count must be a multiple of "+a);return s.length/a},t=e(M.PositionKind,this.positions),i=(r,s)=>{let a=e(r,s);if(a!==t)throw new Error("The "+r+"s element count ("+a+") does not match the positions count ("+t+")")};this.normals&&i(M.NormalKind,this.normals),this.tangents&&i(M.TangentKind,this.tangents),this.uvs&&i(M.UVKind,this.uvs),this.uvs2&&i(M.UV2Kind,this.uvs2),this.uvs3&&i(M.UV3Kind,this.uvs3),this.uvs4&&i(M.UV4Kind,this.uvs4),this.uvs5&&i(M.UV5Kind,this.uvs5),this.uvs6&&i(M.UV6Kind,this.uvs6),this.colors&&i(M.ColorKind,this.colors),this.matricesIndices&&i(M.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(M.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(M.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(M.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){let e=this.serialize();return n.Parse(e)}serialize(){let e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndicesExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtraExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=this.indices?Array.from(this.indices):[],this.materialInfos){e.materialInfos=[];for(let t of this.materialInfos){let 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 n._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return n._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){let r=new n;if(e.isVerticesDataPresent(M.PositionKind)&&(r.positions=e.getVerticesData(M.PositionKind,t,i)),e.isVerticesDataPresent(M.NormalKind)&&(r.normals=e.getVerticesData(M.NormalKind,t,i)),e.isVerticesDataPresent(M.TangentKind)&&(r.tangents=e.getVerticesData(M.TangentKind,t,i)),e.isVerticesDataPresent(M.UVKind)&&(r.uvs=e.getVerticesData(M.UVKind,t,i)),e.isVerticesDataPresent(M.UV2Kind)&&(r.uvs2=e.getVerticesData(M.UV2Kind,t,i)),e.isVerticesDataPresent(M.UV3Kind)&&(r.uvs3=e.getVerticesData(M.UV3Kind,t,i)),e.isVerticesDataPresent(M.UV4Kind)&&(r.uvs4=e.getVerticesData(M.UV4Kind,t,i)),e.isVerticesDataPresent(M.UV5Kind)&&(r.uvs5=e.getVerticesData(M.UV5Kind,t,i)),e.isVerticesDataPresent(M.UV6Kind)&&(r.uvs6=e.getVerticesData(M.UV6Kind,t,i)),e.isVerticesDataPresent(M.ColorKind)){let s=e.geometry||e,a=s.getVertexBuffer(M.ColorKind),o=s.getVerticesData(M.ColorKind,t,i);if(a.getSize()===3){let l=new Float32Array(o.length*4/3);for(let c=0,f=0;c!Array.isArray(n[0]))],de,"_TransformVector3Coordinates",null);C([tr.filter((...n)=>!Array.isArray(n[0]))],de,"_TransformVector3Normals",null);C([tr.filter((...n)=>!Array.isArray(n[0]))],de,"_TransformVector4Normals",null);C([tr.filter((...n)=>!Array.isArray(n[0]))],de,"_FlipFaces",null)});var ci,Qh=A(()=>{ci=class n{static get ForceFullSceneLoadingForIncremental(){return n._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){n._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return n._ShowLoadingScreen}static set ShowLoadingScreen(e){n._ShowLoadingScreen=e}static get loggingLevel(){return n._LoggingLevel}static set loggingLevel(e){n._LoggingLevel=e}static get CleanBoneMatrixWeights(){return n._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){n._CleanBoneMatrixWeights=e}};ci._ForceFullSceneLoadingForIncremental=!1;ci._ShowLoadingScreen=!0;ci._CleanBoneMatrixWeights=!1;ci._LoggingLevel=0});var Ti,Jh=A(()=>{ve();et();Vt();yt();Sf();Qh();bl();Tt();ha();qh();At();hi();pl();Ti=class n{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){let t=new n(n.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,r=!1,s=null,a=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||ue.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=r,a!==null&&(this._totalVertices=a),i?this.setAllVerticesData(i,r):a===null&&(this._totalVertices=0),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),s&&(this.applyToMesh(s),s.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{t._rebuild()})}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,r){i&&Array.isArray(t)&&(t=new Float32Array(t));let s=new M(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:r,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(s)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){let r=e.getKind();this._vertexBuffers[r]&&i&&this._vertexBuffers[r].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[r]=e;let s=this._meshes,a=s.length;if(r===M.PositionKind){this._totalVertices=t!=null?t:e._maxVerticesCount,this._updateExtend(this.useBoundingInfoFromGeometry&&this._boundingInfo?null:e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();let o=this._extend&&this._extend.minimum||new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=this._extend&&this._extend.maximum||new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let c=0;c65535:e.is32Bits=r;for(let s of this._meshes)s._createGlobalSubMesh(!0),s.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,r=!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(let s of this._meshes)s._createGlobalSubMesh(!r),s.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;let 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){let i=this._meshes,r=i.indexOf(e);r!==-1&&(i.splice(r,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,i.length===0&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;let t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();let 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(M.PositionKind),!e))return;this._extend=Zh(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){for(let t in this._vertexBuffers){let i=this._vertexBuffers[t];i._buffer.getBuffer()||i.create(),t===M.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo())}!this._indexBuffer&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(let 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);let r=this._meshes,s=r.length;for(let a=0;a0){for(let r=0;r0){for(let r=0;r0){for(let r=0;r-1&&this._parentContainer.geometries.splice(r,1),this._parentContainer=null}this._isDisposed=!0}copy(e){let t=new n(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let r=!1,s;for(s in this._vertexBuffers){let a=this.getVertexBuffer(s),o=a.getData();if(!o)continue;let l=a.isUpdatable(),c=a.getSize(),{type:f,byteOffset:d,byteStride:h,normalized:u}=a;r=r||l;let m=this._totalVertices;if(a.getIsInstanced()){let g;o instanceof Array?g=o.length*4:g=o.byteLength,m=g/h}let p=wI(o,c,f,d,h,m,!0),_=new M(this._engine,p,s,{updatable:l,useBytes:!1,stride:c,size:c,offset:0,type:f,normalized:u,takeBufferOwnership:!0,instanced:a.getIsInstanced()});t.setVerticesBuffer(_,m)}t._updatable=r,t.delayLoadState=this.delayLoadState,t.delayLoadingFile=this.delayLoadingFile,t._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(s);return t._boundingInfo=new vi(this._extend.minimum,this._extend.maximum),t}serialize(){let e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,nt&&nt.HasTags(this)&&(e.tags=nt.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._totalIndices=this._indices.length,this._indices=[],this._resetPointsArrayCache();for(let e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){let e=this.serialize();return this.isVerticesDataPresent(M.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(M.PositionKind)),this.isVertexBufferUpdatable(M.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(M.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(M.NormalKind)),this.isVertexBufferUpdatable(M.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(M.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(M.TangentKind)),this.isVertexBufferUpdatable(M.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(M.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(M.UVKind)),this.isVertexBufferUpdatable(M.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(M.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(M.UV2Kind)),this.isVertexBufferUpdatable(M.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(M.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(M.UV3Kind)),this.isVertexBufferUpdatable(M.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(M.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(M.UV4Kind)),this.isVertexBufferUpdatable(M.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(M.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(M.UV5Kind)),this.isVertexBufferUpdatable(M.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(M.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(M.UV6Kind)),this.isVertexBufferUpdatable(M.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(M.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(M.ColorKind)),this.isVertexBufferUpdatable(M.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(M.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(M.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(M.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(M.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(M.MatricesWeightsKind)),this.isVertexBufferUpdatable(M.MatricesWeightsKind)&&(e.matricesWeightsUpdatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){let i=e._geometry;return i?i.copy(t):null}static RandomId(){return re.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i0){let o=new Float32Array(e,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);t.setVerticesData(M.PositionKind,o,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){let o=new Float32Array(e,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);t.setVerticesData(M.NormalKind,o,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){let o=new Float32Array(e,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);t.setVerticesData(M.TangentKind,o,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){let o=new Float32Array(e,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);t.setVerticesData(M.ColorKind,o,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){let o=new Int32Array(e,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),l=[];for(let c=0;c>8),l.push((f&16711680)>>16),l.push(f>>24&255)}t.setVerticesData(M.MatricesIndicesKind,l,!1)}if(a.matricesIndicesExtraAttrDesc&&a.matricesIndicesExtraAttrDesc.count>0){let o=new Int32Array(e,a.matricesIndicesExtraAttrDesc.offset,a.matricesIndicesExtraAttrDesc.count),l=[];for(let c=0;c>8),l.push((f&16711680)>>16),l.push(f>>24&255)}t.setVerticesData(M.MatricesIndicesExtraKind,l,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){let o=new Float32Array(e,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);t.setVerticesData(M.MatricesWeightsKind,o,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){let o=new Int32Array(e,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);t.setIndices(o,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){let o=new Int32Array(e,a.subMeshesAttrDesc.offset,a.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let l=0;l>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(M.MatricesIndicesKind,a,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(M.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable||e.matricesIndicesUpdatable);if(e.matricesIndicesExtra)if(e.matricesIndicesExtraExpanded||e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,delete e.matricesIndicesExtraExpanded,t.setVerticesData(M.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable);else{let a=[];for(let o=0;o>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(M.MatricesIndicesExtraKind,a,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(n._CleanMatricesWeights(e,t),t.setVerticesData(M.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(M.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let a=0;a-1){let d=t.getScene().getLastSkeletonById(e.skeletonId);if(!d)return;r=d.bones.length}else return;let s=t.getVerticesData(M.MatricesIndicesKind),a=t.getVerticesData(M.MatricesIndicesExtraKind),o=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,f=o.length;for(let d=0;dc-1)&&(u=c-1),h>.001){let m=1/h;for(let p=0;p<4;p++)o[d+p]*=m;if(l)for(let p=0;p<4;p++)l[d+p]*=m}else u>=4?(l[d+u-4]=1-h,a[d+u-4]=r):(o[d+u]=1-h,s[d+u]=r)}t.setVerticesData(M.MatricesIndicesKind,s),e.matricesWeightsExtra&&t.setVerticesData(M.MatricesIndicesExtraKind,a)}static Parse(e,t,i){let r=new n(e.id,t,void 0,e.updatable);return r._loadedUniqueId=e.uniqueId,nt&&nt.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=4,r.delayLoadingFile=i+e.delayLoadingFile,r._boundingInfo=new vi(v.FromArray(e.boundingBoxMinimum),v.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(M.UVKind),e.hasUVs2&&r._delayInfo.push(M.UV2Kind),e.hasUVs3&&r._delayInfo.push(M.UV3Kind),e.hasUVs4&&r._delayInfo.push(M.UV4Kind),e.hasUVs5&&r._delayInfo.push(M.UV5Kind),e.hasUVs6&&r._delayInfo.push(M.UV6Kind),e.hasColors&&r._delayInfo.push(M.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(M.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(M.MatricesWeightsKind),r._delayLoadingFunction=de.ImportVertexData):de.ImportVertexData(e,r),t.pushGeometry(r,!0),r}}});var st,yl=A(()=>{Qe();qe();Kt();ct();ve();vr();Lt();st=class n extends dt{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&n.BILLBOARDMODE_USE_POSITION)!==0)}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,i=!0){super(e,t,!1),this._forward=new 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=n.BILLBOARDMODE_NONE,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=G.Zero(),this._usePivotMatrix=!1,this._absolutePosition=v.Zero(),this._absoluteScaling=v.Zero(),this._absoluteRotationQuaternion=Ae.Identity(),this._pivotMatrix=G.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new Y,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=G.Identity()),this._poseMatrix}_isSynchronized(){let e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==n.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();let e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=G.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,i){let r=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);r&&i&&i(this,r);for(let s of this.getChildTransformNodes(!0))s.instantiateHierarchy(r,t,i);return r}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||Ae.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,r;if(e.x===void 0){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],r=arguments[2]}else t=e.x,i=e.y,r=e.z;if(this.parent){let s=k.Matrix[0];this.parent.getWorldMatrix().invertToRef(s),v.TransformCoordinatesFromFloatsToRef(t,i,r,s,this.position)}else this.position.x=t,this.position.y=i,this.position.z=r;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=v.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();let e=k.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,r=0,s=0){let a=n._LookAtVectorCache,o=s===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,a),this.setDirection(a,t,i,r),s===1&&this.parent)if(this.rotationQuaternion){let l=k.Matrix[0];this.rotationQuaternion.toRotationMatrix(l);let c=k.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(c),c.invert(),l.multiplyToRef(c,l),this.rotationQuaternion.fromRotationMatrix(l)}else{let l=k.Quaternion[0];Ae.FromEulerVectorToRef(this.rotation,l);let c=k.Matrix[0];l.toRotationMatrix(c);let f=k.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(f),f.invert(),c.multiplyToRef(f,c),l.fromRotationMatrix(c),l.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){let 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,r=0){let s=-Math.atan2(e.z,e.x)+Math.PI/2,a=Math.sqrt(e.x*e.x+e.z*e.z),o=-Math.atan2(e.y,a);return this.rotationQuaternion?Ae.RotationYawPitchRollToRef(s+t,o+i,r,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=s+t,this.rotation.z=r),this}setPivotPoint(e,t=0){this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);let i=this.getWorldMatrix();if(t==1){let r=k.Matrix[0];i.invertToRef(r),e=v.TransformCoordinates(e,r)}return this.setPivotMatrix(G.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){let 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(){let 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(let t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,i=!1){if(!e&&!this.parent)return this;let r=k.Quaternion[0],s=k.Vector3[0],a=k.Vector3[1],o=k.Matrix[1];G.IdentityToRef(o);let l=k.Matrix[0];this.computeWorldMatrix(!0);let c=this.rotationQuaternion;return c||(c=n._TmpRotation,Ae.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,c)),G.ComposeToRef(this.scaling,c,this.position,l),this.parent&&l.multiplyToRef(this.parent.computeWorldMatrix(!0),l),e&&(e.computeWorldMatrix(!0).invertToRef(o),l.multiplyToRef(o,l)),l.decompose(a,r,s,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(a),this.position.copyFrom(s),this.parent=e,i&&this.setPivotMatrix(G.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.parent!==this?this:(e.setParent(null,t),this)}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling===e?!1:(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,e?this.parent=this._currentParentWhenAttachingToBone:this.parent=null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,i){e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0));let r;if(!i||i===0)r=Ae.RotationAxisToRef(e,t,n._RotationAxisCache),this.rotationQuaternion.multiplyToRef(r,this.rotationQuaternion);else{if(this.parent){let s=this.parent.getWorldMatrix(),a=k.Matrix[0];s.invertToRef(a),e=v.TransformNormal(e,a),s.determinant()<0&&(t*=-1)}r=Ae.RotationAxisToRef(e,t,n._RotationAxisCache),r.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=Ae.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));let r=k.Vector3[0],s=k.Vector3[1],a=k.Vector3[2],o=k.Quaternion[0],l=k.Matrix[0],c=k.Matrix[1],f=k.Matrix[2],d=k.Matrix[3];return e.subtractToRef(this.position,r),G.TranslationToRef(r.x,r.y,r.z,l),G.TranslationToRef(-r.x,-r.y,-r.z,c),G.RotationAxisToRef(t,i,f),c.multiplyToRef(f,d),d.multiplyToRef(l,d),d.decompose(s,o,a),this.position.addInPlace(a),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){let r=e.scale(t);if(!i||i===0){let s=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(s)}else this.setAbsolutePosition(this.getAbsolutePosition().add(r));return this}addRotation(e,t,i){let r;this.rotationQuaternion?r=this.rotationQuaternion:(r=k.Quaternion[1],Ae.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));let s=k.Quaternion[0];return Ae.RotationYawPitchRollToRef(t,e,i,s),r.multiplyInPlace(s),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==n.BILLBOARDMODE_NONE}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;let 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();let r=this._cache;r.pivotMatrixUpdated=!1,r.billboardMode=this.billboardMode,r.infiniteDistance=this.infiniteDistance,r.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;let s=this._getEffectiveParent(),a=n._TmpScaling,o=this._position;if(this._infiniteDistance&&!this.parent&&t){let f=t.getWorldMatrix().m;o=n._TmpTranslation,o.copyFromFloats(this._position.x+f[12],this._position.y+f[13],this._position.z+f[14])}a.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant);let l;if(this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,l=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(Ae.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(l=n._TmpRotation,Ae.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),this._usePivotMatrix){let c=k.Matrix[1];G.ScalingToRef(a.x,a.y,a.z,c);let f=k.Matrix[0];l.toRotationMatrix(f),this._pivotMatrix.multiplyToRef(c,k.Matrix[4]),k.Matrix[4].multiplyToRef(f,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(o.x,o.y,o.z)}else G.ComposeToRef(a,l,o,this._localMatrix);if(s&&s.getWorldMatrix){if(e&&s.computeWorldMatrix(e),this.billboardMode){if(this._transformToBoneReferal){let h=this.parent;h.getSkeleton().prepare(),h.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),k.Matrix[7])}else k.Matrix[7].copyFrom(s.getWorldMatrix());let c=k.Vector3[5],f=k.Vector3[6],d=k.Quaternion[0];k.Matrix[7].decompose(f,d,c),G.ScalingToRef(f.x,f.y,f.z,k.Matrix[7]),k.Matrix[7].setTranslation(c),n.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(d,c),this._localMatrix.setTranslation(c)),this._localMatrix.multiplyToRef(k.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){let c=this.parent;c.getSkeleton().prepare(),this._localMatrix.multiplyToRef(c.getFinalMatrix(),k.Matrix[6]),k.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(s.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(t&&this.billboardMode)if(r.useBillboardPosition){let c=k.Vector3[0];this._worldMatrix.getTranslationToRef(c);let f=t.globalPosition;this._worldMatrix.invertToRef(k.Matrix[1]);let d=k.Vector3[1];v.TransformCoordinatesToRef(f,k.Matrix[1],d),d.normalize();let h=-Math.atan2(d.z,d.x)+Math.PI/2,u=Math.sqrt(d.x*d.x+d.z*d.z),m=-Math.atan2(d.y,u);if(Ae.RotationYawPitchRollToRef(h,m,0,k.Quaternion[0]),(this.billboardMode&n.BILLBOARDMODE_ALL)!==n.BILLBOARDMODE_ALL){let p=k.Vector3[1];k.Quaternion[0].toEulerAnglesToRef(p),(this.billboardMode&n.BILLBOARDMODE_X)!==n.BILLBOARDMODE_X&&(p.x=0),(this.billboardMode&n.BILLBOARDMODE_Y)!==n.BILLBOARDMODE_Y&&(p.y=0),(this.billboardMode&n.BILLBOARDMODE_Z)!==n.BILLBOARDMODE_Z&&(p.z=0),G.RotationYawPitchRollToRef(p.y,p.x,p.z,k.Matrix[0])}else G.FromQuaternionToRef(k.Quaternion[0],k.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(k.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(k.Vector3[0])}else{let c=k.Vector3[0];this._worldMatrix.getTranslationToRef(c),k.Matrix[1].copyFrom(t.getViewMatrix());let f=this.getScene().useRightHandedSystem;if(f&&k.Matrix[1].multiplyToRef(n._TmpRHRestore,k.Matrix[1]),k.Matrix[1].setTranslationFromFloats(0,0,0),k.Matrix[1].invertToRef(k.Matrix[0]),(this.billboardMode&n.BILLBOARDMODE_ALL)!==n.BILLBOARDMODE_ALL){k.Matrix[0].decompose(void 0,k.Quaternion[0],void 0);let d=k.Vector3[1];k.Quaternion[0].toEulerAnglesToRef(d),(this.billboardMode&n.BILLBOARDMODE_X)!==n.BILLBOARDMODE_X&&(d.x=0),(this.billboardMode&n.BILLBOARDMODE_Y)!==n.BILLBOARDMODE_Y&&(d.y=0),(this.billboardMode&n.BILLBOARDMODE_Z)!==n.BILLBOARDMODE_Z&&(d.z=0),f&&(d.y+=Math.PI),G.RotationYawPitchRollToRef(d.y,d.x,d.z,k.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(k.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(k.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):s&&s._nonUniformScaling?this._updateNonUniformScalingState(s._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=G.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){let t=this.getChildren();for(let i=0;inew n(e,this.getScene()),this);if(r.name=e,r.id=e,t&&(r.parent=t),!i){let s=this.getDescendants(!0);for(let a=0;anew n(e.name,t),e,t,i);if(e.localMatrix?r.setPreTransformMatrix(G.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(G.FromArray(e.pivotMatrix)),r.setEnabled(e.isEnabled),r._waitingParsedUniqueId=e.uniqueId,e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),e.freezeWorldMatrix&&(r._waitingFreezeWorldMatrix=e.freezeWorldMatrix),e.animations){for(let s=0;s(!t||t(r))&&r instanceof n),i}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){let i=this._parentContainer.transformNodes.indexOf(this);i>-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){let i=this.getChildTransformNodes(!0);for(let r of i)r.parent=null,r.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,i){let r=null,s=null;t&&(this.rotationQuaternion?(s=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(r=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));let a=this.getHierarchyBoundingVectors(e,i),o=a.max.subtract(a.min),l=Math.max(o.x,o.y,o.z);if(l===0)return this;let c=1/l;return this.scaling.scaleInPlace(c),t&&(this.rotationQuaternion&&s?this.rotationQuaternion.copyFrom(s):this.rotation&&r&&this.rotation.copyFrom(r)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}};st.BILLBOARDMODE_NONE=0;st.BILLBOARDMODE_X=1;st.BILLBOARDMODE_Y=2;st.BILLBOARDMODE_Z=4;st.BILLBOARDMODE_ALL=7;st.BILLBOARDMODE_USE_POSITION=128;st.BillboardUseParentOrientation=!1;st._TmpRotation=Ae.Zero();st._TmpScaling=v.Zero();st._TmpTranslation=v.Zero();st._TmpRHRestore=G.Scaling(1,1,-1);st._LookAtVectorCache=new v(0,0,0);st._RotationAxisCache=new Ae;C([ai("position")],st.prototype,"_position",void 0);C([ai("rotation")],st.prototype,"_rotation",void 0);C([DI("rotationQuaternion")],st.prototype,"_rotationQuaternion",void 0);C([ai("scaling")],st.prototype,"_scaling",void 0);C([D("billboardMode")],st.prototype,"_billboardMode",void 0);C([D()],st.prototype,"scalingDeterminant",void 0);C([D("infiniteDistance")],st.prototype,"_infiniteDistance",void 0);C([D()],st.prototype,"ignoreNonUniformScaling",void 0);C([D()],st.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0)});var $h,hM=A(()=>{ve();$h=class{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 uM(n){return Math.floor(n/8)}function mM(n){return 1<{eu=class{constructor(e){this.size=e,this._byteArray=new Uint8Array(Math.ceil(this.size/8))}get(e){if(e>=this.size)throw new RangeError("Bit index out of range");let t=uM(e),i=mM(e);return(this._byteArray[t]&i)!==0}set(e,t){if(e>=this.size)throw new RangeError("Bit index out of range");let i=uM(e),r=mM(e);t?this._byteArray[i]|=r:this._byteArray[i]&=~r}}});var _M={};De(_M,{OptimizeIndices:()=>sk});function sk(n){let e=[],t=n.length/3;for(let l=0;l{let c=[l];for(;c.length>0;){let f=c.pop();if(!r.get(f)){r.set(f,!0),s.push(e[f]);for(let d of e[f]){let h=i.get(d);if(!h)return;for(let u of h)r.get(u)||c.push(u)}}}};for(let l=0;l{pM()});function ak(n,e,t){let i;switch(e){case M.PositionKind:i=r=>r.getPositions();break;case M.NormalKind:i=r=>r.getNormals();break;case M.TangentKind:i=r=>r.getTangents();break;case M.UVKind:i=r=>r.getUVs();break;case M.UV2Kind:i=r=>r.getUV2s();break;case M.ColorKind:i=r=>r.getColors();break;default:return}for(let r=0;r0&&(G.FromFloat32ArrayToRefScaled(t,Math.floor(i[h+u]*16),m,c),l.addToSelf(c));if(s&&a)for(u=0;u<4;u++)m=a[h+u],m>0&&(G.FromFloat32ArrayToRefScaled(t,Math.floor(s[h+u]*16),m,c),l.addToSelf(c));f(n[d],n[d+1],n[d+2],l,o),o.toArray(n,d)}}var nE,sE,zt,Dl=A(()=>{Qe();ct();ve();yt();Vt();yl();af();bl();ma();hM();gi();qh();et();Ci();rl();Lt();qe();ii();nE=class{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}},sE=class{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new nE,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=new Map,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new $h,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}},zt=class n extends st{static get BILLBOARDMODE_NONE(){return st.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return st.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return st.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return st.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return st.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return st.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;let t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(t===1&&e!==1||t!==1&&e===1)&&this._markSubMeshesAsDirty(i=>{i.markAsMiscDirty(),i.markAsPrePassDirty()})}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,e==null),this._unBindEffect()))}getMaterialForRenderPass(e){var t;return(t=this._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:t[e]}setMaterialForRenderPass(e,t){var r;this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);let i=this._internalAbstractMeshDataInfo._materialForRenderPass[e];(r=i==null?void 0:i.meshMap)!=null&&r[this.uniqueId]&&(i.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t,t&&t.meshMap&&(t.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){let 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 sE,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this._waitingSkeletonId=null,this._waitingSkeletonUniqueId=null,this.cullingStrategy=n.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new Y,this.onCollisionPositionChangeObservable=new Y,this.onMaterialChangedObservable=new Y,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=n.DefaultIsPickable,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=oe.Red(),this.outlineWidth=.02,this.overlayColor=oe.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 Ne(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 Y,this._onCollisionPositionChange=(i,r,s=null)=>{r.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>fe.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),s&&this.onCollideObservable.notifyObservers(s),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),this.layerMask=t.defaultRenderableLayerMask,t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new Ut(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){let 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);let 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!==st.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}_releaseRenderPassId(e){}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),!!this.subMeshes){for(let t of this.subMeshes)t._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(let e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){let t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e),r=!1;if(i===-1){if(!t)return;this._lightSources.push(e)}else{if(t)return;r=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(r)}_unBindEffect(){for(let e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){let i=this._lightSources.indexOf(e);i!==-1&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(let t of this.subMeshes)for(let i=0;it.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(let 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,r){return this}updateVerticesData(e,t,i,r){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 vi(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(M.MatricesIndicesKind)&&this.isVerticesDataPresent(M.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===st.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){let r=new G;(this.rotationQuaternion?this.rotationQuaternion:Ae.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);let a=v.Zero(),o=this.definedFacingForward?-1:1;return v.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,r,a),a}rotatePOV(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this}calcRotatePOV(e,t,i){let r=this.definedFacingForward?1:-1;return new v(e*r,t,i*r)}_refreshBoundingInfo(e,t){if(e){let i=Zh(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new vi(i.minimum,i.maximum)}if(this.subMeshes)for(let i=0;i{if(r){let o=r._vertexData||(r._vertexData={});return o[a]||this.copyVerticesData(a,o),o[a]}return this.getVerticesData(a)};if(t||(t=s(i)),!t)return null;if(r?(r._outputData?r._outputData.set(t):r._outputData=new Float32Array(t),t=r._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&ak(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){let a=s(M.MatricesIndicesKind),o=s(M.MatricesWeightsKind);if(o&&a){let l=this.numBoneInfluencers>4,c=l?s(M.MatricesIndicesExtraKind):null,f=l?s(M.MatricesWeightsExtraKind):null,d=this.skeleton.getTransformMatrices(this);n._ApplySkeleton(t,i,d,a,o,c,f)}}if(e.updatePositionsArray!==!1&&i===M.PositionKind){let a=this._internalAbstractMeshDataInfo._positions||[],o=a.length;if(a.length=t.length/3,o1||!r.IsGlobal)&&r.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){let r=this.getBoundingInfo(),s=e.getBoundingInfo();if(r.intersects(s,t))return!0;if(i){for(let a of this.getChildMeshes())if(a.intersectsMesh(e,t,!0))return!0}return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e,t=!0){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);let r=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=r.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,r.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId,t),this}_collideForSubMesh(e,t,i){var r;if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];let s=e.verticesStart,a=e.verticesStart+e.verticesCount;for(let o=s;o1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;let t=k.Matrix[0],i=k.Matrix[1];return G.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,r=!1,s,a=!1){let o=new cn,l=this.getClassName(),c=l==="InstancedLinesMesh"||l==="LinesMesh"||l==="GreasedLineMesh"?this.intersectionThreshold:0,f=this.getBoundingInfo();if(!this.subMeshes||!a&&(!e.intersectsSphere(f.boundingSphere,c)||!e.intersectsBox(f.boundingBox,c)))return o;if(r)return o.hit=!a,o.pickedMesh=a?null:this,o.distance=a?0:v.Distance(e.origin,f.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let d=null,h=this._scene.getIntersectingSubMeshCandidates(this,e),u=h.length,m=!1;for(let p=0;p1&&!a&&!_.canIntersects(e))continue;let g=_.intersects(e,this._positions,this.getIndices(),t,i);if(g&&(t||!d||g.distanceo!==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-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;i65535){l=!0;break}l?e.depthSortedIndices=new Uint32Array(i):e.depthSortedIndices=new Uint16Array(i)}if(e.facetDepthSortFunction=function(l,c){return c.sqDistance-l.sqDistance},!e.facetDepthSortFrom){let l=this.getScene().activeCamera;e.facetDepthSortFrom=l?l.position:v.Zero()}e.depthSortedFacets=[];for(let l=0;lYe?s.maximum.x-s.minimum.x:Ye,e.bbSize.y=s.maximum.y-s.minimum.y>Ye?s.maximum.y-s.minimum.y:Ye,e.bbSize.z=s.maximum.z-s.minimum.z>Ye?s.maximum.z-s.minimum.z:Ye;let a=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(a=a>e.bbSize.z?a:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/a),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/a),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/a),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=s,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,r&&de.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);let l=e.depthSortedIndices.length/3|0;for(let c=0;cs.subDiv.max||o<0||o>s.subDiv.max||l<0||l>s.subDiv.max?null:s.facetPartitioning[a+s.subDiv.max*o+s.subDiv.max*s.subDiv.max*l]}getClosestFacetAtCoordinates(e,t,i,r,s=!1,a=!0){let o=this.getWorldMatrix(),l=k.Matrix[5];o.invertToRef(l);let c=k.Vector3[8];v.TransformCoordinatesFromFloatsToRef(e,t,i,l,c);let f=this.getClosestFacetAtLocalCoordinates(c.x,c.y,c.z,r,s,a);return r&&v.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,o,r),f}getClosestFacetAtLocalCoordinates(e,t,i,r,s=!1,a=!0){let o=null,l,c,f,d,h,u,m,p,_=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),T=this.getFacetsAtLocalCoordinates(e,t,i);if(!T)return null;let b=Number.MAX_VALUE,R,S,I,x;for(let P=0;P=0||s&&!a&&d<=0)&&(d=I.x*x.x+I.y*x.y+I.z*x.z,h=-(I.x*e+I.y*t+I.z*i-d)/(I.x*I.x+I.y*I.y+I.z*I.z),u=e+I.x*h,m=t+I.y*h,p=i+I.z*h,l=u-e,c=m-t,f=p-i,R=l*l+c*c+f*f,R(gM(),_M));return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=$i.Y);let i=k.Vector3[0],r=k.Vector3[1];return v.CrossToRef(t,e,r),v.CrossToRef(e,r,i),this.rotationQuaternion?Ae.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):v.RotationFromAxisToRef(i,e,r,this.rotation),this}_checkOcclusionQuery(e=!1){return!1}disableEdgesRendering(){throw Ie("EdgesRenderer")}enableEdgesRendering(e,t,i){throw Ie("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}};zt.OCCLUSION_TYPE_NONE=0;zt.OCCLUSION_TYPE_OPTIMISTIC=1;zt.OCCLUSION_TYPE_STRICT=2;zt.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;zt.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;zt.CULLINGSTRATEGY_STANDARD=0;zt.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;zt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;zt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;zt.DefaultIsPickable=!0;C([tr.filter((...n)=>!Array.isArray(n[0])&&!Array.isArray(n[3])&&!Array.isArray(n[4])&&!Array.isArray(n[5])&&!Array.isArray(n[6]))],zt,"_ApplySkeleton",null);je("BABYLON.AbstractMesh",zt)});var yi,EM=A(()=>{Qe();Kt();qe();yi=class{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=519,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681,this.backFunc=519,this.backOpStencilFail=7680,this.backOpDepthFail=7680,this.backOpStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get backFunc(){return this._backFunc}set backFunc(e){this._backFunc=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail=e}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail=e}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){Me.Clone(()=>e,this)}serialize(){return Me.Serialize(this)}parse(e,t,i){Me.Parse(()=>this,e,t,i)}};C([D()],yi.prototype,"func",null);C([D()],yi.prototype,"backFunc",null);C([D()],yi.prototype,"funcRef",null);C([D()],yi.prototype,"funcMask",null);C([D()],yi.prototype,"opStencilFail",null);C([D()],yi.prototype,"opDepthFail",null);C([D()],yi.prototype,"opStencilDepthPass",null);C([D()],yi.prototype,"backOpStencilFail",null);C([D()],yi.prototype,"backOpDepthFail",null);C([D()],yi.prototype,"backOpStencilDepthPass",null);C([D()],yi.prototype,"mask",null);C([D()],yi.prototype,"enabled",null)});function Di(n){n.indexOf("vClipPlane")===-1&&n.push("vClipPlane"),n.indexOf("vClipPlane2")===-1&&n.push("vClipPlane2"),n.indexOf("vClipPlane3")===-1&&n.push("vClipPlane3"),n.indexOf("vClipPlane4")===-1&&n.push("vClipPlane4"),n.indexOf("vClipPlane5")===-1&&n.push("vClipPlane5"),n.indexOf("vClipPlane6")===-1&&n.push("vClipPlane6")}function Gn(n,e,t){var c,f,d,h,u,m;let i=!!((c=n.clipPlane)!=null?c:e.clipPlane),r=!!((f=n.clipPlane2)!=null?f:e.clipPlane2),s=!!((d=n.clipPlane3)!=null?d:e.clipPlane3),a=!!((h=n.clipPlane4)!=null?h:e.clipPlane4),o=!!((u=n.clipPlane5)!=null?u:e.clipPlane5),l=!!((m=n.clipPlane6)!=null?m:e.clipPlane6);i&&t.push("#define CLIPPLANE"),r&&t.push("#define CLIPPLANE2"),s&&t.push("#define CLIPPLANE3"),a&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),l&&t.push("#define CLIPPLANE6")}function vM(n,e,t){var f,d,h,u,m,p;let i=!1,r=!!((f=n.clipPlane)!=null?f:e.clipPlane),s=!!((d=n.clipPlane2)!=null?d:e.clipPlane2),a=!!((h=n.clipPlane3)!=null?h:e.clipPlane3),o=!!((u=n.clipPlane4)!=null?u:e.clipPlane4),l=!!((m=n.clipPlane5)!=null?m:e.clipPlane5),c=!!((p=n.clipPlane6)!=null?p:e.clipPlane6);return t.CLIPPLANE!==r&&(t.CLIPPLANE=r,i=!0),t.CLIPPLANE2!==s&&(t.CLIPPLANE2=s,i=!0),t.CLIPPLANE3!==a&&(t.CLIPPLANE3=a,i=!0),t.CLIPPLANE4!==o&&(t.CLIPPLANE4=o,i=!0),t.CLIPPLANE5!==l&&(t.CLIPPLANE5=l,i=!0),t.CLIPPLANE6!==c&&(t.CLIPPLANE6=c,i=!0),i}function Li(n,e,t){var r,s,a,o,l,c;let i=(r=e.clipPlane)!=null?r:t.clipPlane;Ll(n,"vClipPlane",i),i=(s=e.clipPlane2)!=null?s:t.clipPlane2,Ll(n,"vClipPlane2",i),i=(a=e.clipPlane3)!=null?a:t.clipPlane3,Ll(n,"vClipPlane3",i),i=(o=e.clipPlane4)!=null?o:t.clipPlane4,Ll(n,"vClipPlane4",i),i=(l=e.clipPlane5)!=null?l:t.clipPlane5,Ll(n,"vClipPlane5",i),i=(c=e.clipPlane6)!=null?c:t.clipPlane6,Ll(n,"vClipPlane6",i)}function Ll(n,e,t){var i;if(t){let r=((i=Br.getScene())==null?void 0:i.floatingOriginOffset)||v.ZeroReadOnly;n.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+v.Dot(t.normal,r))}}var kn=A(()=>{cf();ve()});var ie,Wr=A(()=>{ii();ie=class{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,fe.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}};ie._DiffuseTextureEnabled=!0;ie._BaseWeightTextureEnabled=!0;ie._BaseDiffuseRoughnessTextureEnabled=!0;ie._DetailTextureEnabled=!0;ie._DecalMapEnabled=!0;ie._AmbientTextureEnabled=!0;ie._OpacityTextureEnabled=!0;ie._ReflectionTextureEnabled=!0;ie._EmissiveTextureEnabled=!0;ie._SpecularTextureEnabled=!0;ie._BumpTextureEnabled=!0;ie._LightmapTextureEnabled=!0;ie._RefractionTextureEnabled=!0;ie._ColorGradingTextureEnabled=!0;ie._FresnelEnabled=!0;ie._ClearCoatTextureEnabled=!0;ie._ClearCoatBumpTextureEnabled=!0;ie._ClearCoatTintTextureEnabled=!0;ie._SheenTextureEnabled=!0;ie._AnisotropicTextureEnabled=!0;ie._ThicknessTextureEnabled=!0;ie._RefractionIntensityTextureEnabled=!0;ie._TranslucencyIntensityTextureEnabled=!0;ie._TranslucencyColorTextureEnabled=!0;ie._IridescenceTextureEnabled=!0});function Ta(n,e,t){if(!n||n.LOGARITHMICDEPTH||n.indexOf&&n.indexOf("LOGARITHMICDEPTH")>=0){let i=t.activeCamera;i.mode===1&&W.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}var TM=A(()=>{ze()});function Sa(n,e,t,i=!1){t&&n.fogEnabled&&(!e||e.applyFog)&&n.fogMode!==0&&(t.setFloat4("vFogInfos",n.fogMode,n.fogStart,n.fogEnd,n.fogDensity),i?(n.fogColor.toLinearSpaceToRef(SM,n.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",SM)):t.setColor3("vFogColor",n.fogColor))}function Wn(n,e,t,i,r,s,a,o,l,c){let f=n.numMaxInfluencers||n.numInfluencers;return f<=0?0:(e.push("#define MORPHTARGETS"),n.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),n.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),n.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),n.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),n.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),n.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),n.supportsPositions&&r&&e.push("#define MORPHTARGETS_POSITION"),n.supportsNormals&&s&&e.push("#define MORPHTARGETS_NORMAL"),n.supportsTangents&&a&&e.push("#define MORPHTARGETS_TANGENT"),n.supportsUVs&&o&&e.push("#define MORPHTARGETS_UV"),n.supportsUV2s&&l&&e.push("#define MORPHTARGETS_UV2"),n.supportsColors&&c&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+f),n.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),xo.NUM_MORPH_INFLUENCERS=f,xo.NORMAL=s,xo.TANGENT=a,xo.UV=o,xo.UV2=l,xo.COLOR=c,Co(t,i,xo,r),f)}function Co(n,e,t,i=!0){let r=t.NUM_MORPH_INFLUENCERS;if(r>0&&ue.LastCreatedEngine){let s=ue.LastCreatedEngine.getCaps().maxVertexAttribs,a=e.morphTargetManager;if(a!=null&&a.isUsingTextureForTargets)return;let o=a&&a.supportsPositions&&i,l=a&&a.supportsNormals&&t.NORMAL,c=a&&a.supportsTangents&&t.TANGENT,f=a&&a.supportsUVs&&t.UV1,d=a&&a.supportsUV2s&&t.UV2,h=a&&a.supportsColors&&t.VERTEXCOLOR;for(let u=0;us&&W.Error("Cannot add more vertex attributes for mesh "+e.name)}}function _n(n,e=!1){n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"),e&&(n.push("previousWorld0"),n.push("previousWorld1"),n.push("previousWorld2"),n.push("previousWorld3"))}function Pi(n,e){let t=n.morphTargetManager;!n||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function Aa(n,e){e.bindToEffect(n,"Scene")}function Pl(n,e,t,i,r=null,s=!1,a=!1,o=!1,l=!1,c=!1,f=!1,d=0){if(n.texturesEnabled&&r&&ie.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",r.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",r.level*n.iblIntensity,d),o&&r.boundingBoxSize){let h=r;t.updateVector3("vReflectionPosition",h.boundingBoxPosition),t.updateVector3("vReflectionSize",h.boundingBoxSize)}if(s){let h=r.getSize().width;t.updateFloat2("vReflectionFilteringInfo",h,Math.log2(h))}if(c&&!e.USEIRRADIANCEMAP){let h=r.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&h)if(e.SPHERICAL_HARMONICS){let u=h.preScaledHarmonics;t.updateVector3("vSphericalL00",u.l00),t.updateVector3("vSphericalL1_1",u.l1_1),t.updateVector3("vSphericalL10",u.l10),t.updateVector3("vSphericalL11",u.l11),t.updateVector3("vSphericalL2_2",u.l2_2),t.updateVector3("vSphericalL2_1",u.l2_1),t.updateVector3("vSphericalL20",u.l20),t.updateVector3("vSphericalL21",u.l21),t.updateVector3("vSphericalL22",u.l22)}else t.updateFloat3("vSphericalX",h.x.x,h.x.y,h.x.z),t.updateFloat3("vSphericalY",h.y.x,h.y.y,h.y.z),t.updateFloat3("vSphericalZ",h.z.x,h.z.y,h.z.z),t.updateFloat3("vSphericalXX_ZZ",h.xx.x-h.zz.x,h.xx.y-h.zz.y,h.xx.z-h.zz.z),t.updateFloat3("vSphericalYY_ZZ",h.yy.x-h.zz.x,h.yy.y-h.zz.y,h.yy.z-h.zz.z),t.updateFloat3("vSphericalZZ",h.zz.x,h.zz.y,h.zz.z),t.updateFloat3("vSphericalXY",h.xy.x,h.xy.y,h.xy.z),t.updateFloat3("vSphericalYZ",h.yz.x,h.yz.y,h.yz.z),t.updateFloat3("vSphericalZX",h.zx.x,h.zx.y,h.zx.z)}else l&&e.USEIRRADIANCEMAP&&e.USE_IRRADIANCE_DOMINANT_DIRECTION&&r.irradianceTexture&&t.updateVector3("vReflectionDominantDirection",r.irradianceTexture._dominantDirection);a&&t.updateFloat3("vReflectionMicrosurfaceInfos",r.getSize().width,r.lodGenerationScale,r.lodGenerationOffset)}f&&t.updateColor3("vReflectionColor",i)}function tu(n,e,t,i=null,r=!1){if(i&&ie.ReflectionTextureEnabled){e.LODBASEDMICROSFURACE?t.setTexture("reflectionSampler",i):(t.setTexture("reflectionSampler",i._lodTextureMid||i),t.setTexture("reflectionSamplerLow",i._lodTextureLow||i),t.setTexture("reflectionSamplerHigh",i._lodTextureHigh||i)),e.USEIRRADIANCEMAP&&t.setTexture("irradianceSampler",i.irradianceTexture);let s=n.iblCdfGenerator;r&&s&&t.setTexture("icdfSampler",s.getIcdfTexture())}}function at(n,e,t){e._needUVs=!0,e[t]=!0,n.optimizeUVAllocation&&n.getTextureMatrix().isIdentityAs3x2()?(e[t+"DIRECTUV"]=n.coordinatesIndex+1,e["MAINUV"+(n.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function ot(n,e,t){let i=n.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function Ol(n,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&n.push("bakedVertexAnimationSettingsInstanced")}function lk(n,e){return e.set(n),e}function nr(n,e,t){if(!(!e||!n)&&(n.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(n.computeBonesUsingShaders=!1),n.useBones&&n.computeBonesUsingShaders&&n.skeleton)){let i=n.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureInfo")>-1){let r=i.getTransformMatrixTexture(n);e.setTexture("boneSampler",r),e.setFloat2("boneTextureInfo",i._textureWidth,i._textureHeight)}else{let r=i.getTransformMatrices(n);r&&(e.setMatrices("mBones",r),t&&n.getScene().prePassRenderer&&n.getScene().prePassRenderer.getIndex(2)&&(t.previousBones[n.uniqueId]||(t.previousBones[n.uniqueId]=r.slice()),e.setMatrices("mPreviousBones",t.previousBones[n.uniqueId]),lk(r,t.previousBones[n.uniqueId])))}}}function ck(n,e,t,i,r,s=!0){n._bindLight(e,t,i,r,s)}function Nl(n,e,t,i,r=4){let s=Math.min(e.lightSources.length,r);for(let a=0;a0&&(i.addCPUSkinningFallback(0,e),n.push("matricesIndices"),n.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(n.push("matricesIndicesExtra"),n.push("matricesWeightsExtra")))}function wl(n,e){(e.INSTANCES||e.THIN_INSTANCES)&&_n(n,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&n.push("instanceColor")}function Bl(n,e,t=4,i=0){let r=0;for(let s=0;s0&&(r=i+s,e.addFallback(r,"LIGHT"+s)),n.SHADOWS||(n["SHADOW"+s]&&e.addFallback(i,"SHADOW"+s),n["SHADOWPCF"+s]&&e.addFallback(i,"SHADOWPCF"+s),n["SHADOWPCSS"+s]&&e.addFallback(i,"SHADOWPCSS"+s),n["SHADOWPOISSON"+s]&&e.addFallback(i,"SHADOWPOISSON"+s),n["SHADOWESM"+s]&&e.addFallback(i,"SHADOWESM"+s),n["SHADOWCLOSEESM"+s]&&e.addFallback(i,"SHADOWCLOSEESM"+s));return r}function fk(n,e){return e.fogEnabled&&n.applyFog&&e.fogMode!==0}function Ul(n,e,t,i,r,s,a,o=!1,l=!1,c,f){var d;if(a._areMiscDirty){a.LOGARITHMICDEPTH=t,a.POINTSIZE=i,a.FOG=r&&fk(n,e),a.NONUNIFORMSCALING=n.nonUniformScaling,a.ALPHATEST=s,a.DECAL_AFTER_DETAIL=o,a.USE_VERTEX_PULLING=l,a.RIGHT_HANDED=e.useRightHandedSystem;let h=(d=c==null?void 0:c.geometry)==null?void 0:d.getIndexBuffer(),u=c?c.isUnIndexed:!1;a.VERTEX_PULLING_USE_INDEX_BUFFER=!!h&&!u,a.VERTEX_PULLING_INDEX_BUFFER_32BITS=h&&!u?h.is32Bits:!1,a.VERTEXOUTPUT_INVARIANT=!!f}}function Vl(n,e,t,i=!1){if(!n.lightsEnabled||i)return!0;let r=e.lightSources,s=Math.min(r.length,t);for(let a=0;a0?(t.NUM_SAMPLES=""+r,a._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,n.iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===ne.INVCUBIC_MODE,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&n.useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case ne.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case ne.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case ne.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case ne.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case ne.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case ne.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case ne.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case ne.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case ne.CUBIC_MODE:case ne.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize;break}e.coordinatesMode!==ne.SKYBOX_MODE&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,e.irradianceTexture._dominantDirection?t.USE_IRRADIANCE_DOMINANT_DIRECTION=!0:t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=s))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;return!0}function dk(n,e,t,i,r,s,a){var o;switch(a.needNormals=!0,r["LIGHT"+i]===void 0&&(a.needRebuild=!0),r["LIGHT"+i]=!0,r["SPOTLIGHT"+i]=!1,r["HEMILIGHT"+i]=!1,r["POINTLIGHT"+i]=!1,r["DIRLIGHT"+i]=!1,r["AREALIGHT"+i]=!1,r["CLUSTLIGHT"+i]=!1,t.prepareLightSpecificDefines(r,i),r["LIGHT_FALLOFF_PHYSICAL"+i]=!1,r["LIGHT_FALLOFF_GLTF"+i]=!1,r["LIGHT_FALLOFF_STANDARD"+i]=!1,t.falloffType){case it.FALLOFF_GLTF:r["LIGHT_FALLOFF_GLTF"+i]=!0;break;case it.FALLOFF_PHYSICAL:r["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case it.FALLOFF_STANDARD:r["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(s&&!t.specular.equalsFloats(0,0,0)&&(a.specularEnabled=!0),r["SHADOW"+i]=!1,r["SHADOWCSM"+i]=!1,r["SHADOWCSMDEBUG"+i]=!1,r["SHADOWCSMNUM_CASCADES"+i]=!1,r["SHADOWCSMUSESHADOWMAXZ"+i]=!1,r["SHADOWCSMNOBLEND"+i]=!1,r["SHADOWCSM_RIGHTHANDED"+i]=!1,r["SHADOWPCF"+i]=!1,r["SHADOWPCSS"+i]=!1,r["SHADOWPOISSON"+i]=!1,r["SHADOWESM"+i]=!1,r["SHADOWCLOSEESM"+i]=!1,r["SHADOWCUBE"+i]=!1,r["SHADOWLOWQUALITY"+i]=!1,r["SHADOWMEDIUMQUALITY"+i]=!1,e&&e.receiveShadows&&n.shadowsEnabled&&t.shadowEnabled){let l=(o=t.getShadowGenerator(n.activeCamera))!=null?o:t.getShadowGenerator();if(l){let c=l.getShadowMap();c&&c.renderList&&c.renderList.length>0&&(a.shadowEnabled=!0,l.prepareDefines(r,i))}}t.lightmapMode!=it.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+i]=!0,r["LIGHTMAPNOSPECULAR"+i]=t.lightmapMode==it.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+i]=!1,r["LIGHTMAPNOSPECULAR"+i]=!1)}function kl(n,e,t,i,r,s=null,a=!1){let o=pk(n,i);s!==!1&&(o=vM(t,n,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==r&&(i.INSTANCES=r,o=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,o=!0),o&&i.markAsUnprocessed()}function hk(n,e){if(n.useBones&&n.computeBonesUsingShaders&&n.skeleton){e.NUM_BONE_INFLUENCERS=n.numBoneInfluencers;let t=e.BONETEXTURE!==void 0;if(n.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=n.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;let i=n.getScene().prePassRenderer;if(i&&i.enabled){let r=i.excludedSkinnedMesh.indexOf(n)===-1;e.BONES_VELOCITY_ENABLED=r}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function uk(n,e){let t=n.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_UV2=t.supportsUV2s&&e.UV2,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,e.MORPHTARGETS_POSITION=t.supportsPositions,e.MORPHTARGETS_COLOR=t.supportsColors,e.MORPHTARGETTEXTURE_HASUVS=t.hasUVs,e.MORPHTARGETTEXTURE_HASUV2S=t.hasUV2s,e.MORPHTARGETTEXTURE_HASTANGENTS=t.hasTangents,e.MORPHTARGETTEXTURE_HASNORMALS=t.hasNormals,e.MORPHTARGETTEXTURE_HASPOSITIONS=t.hasPositions,e.MORPHTARGETTEXTURE_HASCOLORS=t.hasColors,e.NUM_MORPH_INFLUENCERS=t.numMaxInfluencers||t.numInfluencers,e.MORPHTARGETS=e.NUM_MORPH_INFLUENCERS>0,e.MORPHTARGETS_TEXTURE=t.isUsingTextureForTargets):(e.MORPHTARGETS_UV=!1,e.MORPHTARGETS_UV2=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_POSITION=!1,e.MORPHTARGETS_COLOR=!1,e.MORPHTARGETTEXTURE_HASUVS=!1,e.MORPHTARGETTEXTURE_HASUV2S=!1,e.MORPHTARGETTEXTURE_HASTANGENTS=!1,e.MORPHTARGETTEXTURE_HASNORMALS=!1,e.MORPHTARGETTEXTURE_HASPOSITIONS=!1,e.MORPHTARGETTEXTURE_HAS_COLORS=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function mk(n,e){let t=n.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function Wl(n,e,t,i,r=!1,s=!0,a=!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&&n.isVerticesDataPresent("normal"),e._needNormals&&n.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let o=1;o<=6;++o)e["UV"+o]=e._needUVs?n.isVerticesDataPresent(`uv${o===1?"":o}`):!1;if(t){let o=n.useVertexColors&&n.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=n.hasVertexAlpha&&o&&s}return n.isVerticesDataPresent("instanceColor")&&(n.hasInstances||n.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&hk(n,e),r&&uk(n,e),a&&mk(n,e),!0}function Hl(n,e){if(n.activeCamera){let t=e.MULTIVIEW;e.MULTIVIEW=n.activeCamera.outputRenderTarget!==null&&n.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function zl(n,e,t){let i=e.ORDER_INDEPENDENT_TRANSPARENCY,r=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;e.ORDER_INDEPENDENT_TRANSPARENCY=n.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!n.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||r!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function Xl(n,e,t){let i=e.PREPASS;if(!e._arePrePassDirty)return;let r=[{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_LEGACY",index:"PREPASS_IRRADIANCE_LEGACY_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"},{type:14,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"}];if(n.prePassRenderer&&n.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=n.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=n.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let s=0;s{ze();At();$c();kn();Wr();oi();TM();SM={r:0,g:0,b:0},xo={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1}});var ae,Ni=A(()=>{Qe();qe();Tt();ct();At();Sf();ma();ze();fo();go();EM();Oi();Kt();l_();ae=class n{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(e){this._useVertexPulling!==e&&(this._useVertexPulling=e,this.markAsDirty(n.MiscDirtyFlag))}get _supportGlowLayer(){return!1}set _glowModeEnabled(e){}get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;let t=this._alpha;this._alpha=e,(t===1||e===1)&&this.markAsDirty(n.MiscDirtyFlag+n.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(n.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(n.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 Y),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 Y),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new Y),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode[0]!==e&&(this._alphaMode[0]=e,this.markAsDirty(n.TextureDirtyFlag))}get alphaMode(){return this._alphaMode[0]}get alphaModes(){return this._alphaMode}setAlphaMode(e,t=0){this._alphaMode[t]!==e&&(this._alphaMode[t]=e,this.markAsDirty(n.TextureDirtyFlag))}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(n.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case n.WireFrameFillMode:case n.LineListDrawMode:case n.LineLoopDrawMode:case n.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?n.WireFrameFillMode:n.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case n.PointFillMode:case n.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?n.PointFillMode:n.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(n.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){let t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&W.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}get isVertexOutputInvariant(){return this._isVertexOutputInvariant}set isVertexOutputInvariant(e){this._isVertexOutputInvariant!==e&&(this._isVertexOutputInvariant=e,this._markAllSubMeshesAsMiscDirty())}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,i,r=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this._useVertexPulling=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new Y,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 yi,this._isVertexOutputInvariant=n.ForceVertexOutputInvariant,this._useUBO=!1,this._fillMode=n.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._transparencyMode=null,this.name=e;let s=t||ue.LastCreatedScene;s&&(this._scene=s,this._dirtyCallbacks={},this._forceGLSL=r,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[127]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||re.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new Hi(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new Ut(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={}),n.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){var t;let e=this.getScene().getEngine();(t=this._uniformBuffer)==null||t.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new Ut(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new Ut(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){let r=t.materialDefines;return r?(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh):!1}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return this.sideOrientation!==null?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _hasTransparencyMode(){return this._transparencyMode!=null}get _transparencyModeIsBlend(){return this._transparencyMode===n.MATERIAL_ALPHABLEND||this._transparencyMode===n.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===n.MATERIAL_ALPHATEST||this._transparencyMode===n.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===n.MATERIAL_OPAQUE||this._transparencyMode===n.MATERIAL_ALPHATEST}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsBlend:e.visibility<1?!0:this._disableAlphaBlending?!1:e.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:!1}needAlphaTestingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsTest:!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){let t=this.getScene().meshes;for(let i of t)if(i.subMeshes){for(let r of i.subMeshes)if(r.getMaterial()===this)for(let s of r._drawWrappers)s&&this._materialContext===s.materialContext&&(s._wasPreviouslyReady=!1,s._wasPreviouslyUsingInstances=null,s._forceRebindOnNextCall=e)}e&&this.markAsDirty(n.AllDirtyFlag)}_preBind(e,t=null){let i=this._scene.getEngine(),s=(t==null?this.sideOrientation:t)===n.ClockWiseSideOrientation,a=e||this._getDrawWrapper();return Zd(a)&&a.materialContext&&(a.materialContext.useVertexPulling=this.useVertexPulling),i.enableEffect(a),i.setState(this.backFaceCulling,this.zOffset,!1,s,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),s}bind(e,t){}buildUniformLayout(){let e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,i){let r=i._drawWrapper;this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),r._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()),e.setMatrix("inverseProjection",this.getScene().getInverseProjectionMatrix()))}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,Aa(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){let r=this._scene.getEngine();this._cachedDepthWriteState=r.getDepthWrite(),r.setDepthWrite(!1)}if(this.disableColorWrite){let r=this._scene.getEngine();this._cachedColorWriteState=r.getColorWrite(),r.setColorWrite(!1)}if(this.depthFunction!==0){let r=this._scene.getEngine();this._cachedDepthFunctionState=r.getDepthFunction()||0,r.setDepthFunction(this.depthFunction)}}unbind(){this._scene.getSceneUniformBuffer().unbindEffect(),this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){let i={};if(this._serializePlugins(i),n._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(let r of this.pluginManager._plugins){let s=e.pluginManager.getPlugin(r.name);s&&r.copyTo(s)}}getBindedMeshes(){if(this.meshMap){let e=[];for(let t in this.meshMap){let i=this.meshMap[t];i&&e.push(i)}return e}else return this._scene.meshes.filter(t=>t.material===this)}forceCompilation(e,t,i,r){let s={clipPlane:!1,useInstances:!1,...i},a=this.getScene(),o=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;let l=()=>{if(!this._scene||!this._scene.getEngine())return;let c=a.clipPlane;if(s.clipPlane&&(a.clipPlane=new er(0,0,0,1)),this._storeEffectOnSubMeshes){let f=!0,d=null;if(e.subMeshes){let h=new rr(0,0,0,0,0,e,void 0,!1,!1);h.materialDefines&&(h.materialDefines._renderId=-1),this.isReadyForSubMesh(e,h,s.useInstances)||(h.effect&&h.effect.getCompilationError()&&h.effect.allFallbacksProcessed()?d=h.effect.getCompilationError():(f=!1,setTimeout(l,16)))}f&&(this.allowShaderHotSwapping=o,d&&r&&r(d),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=o,t&&t(this)):setTimeout(l,16);s.clipPlane&&(a.clipPlane=c)};l()}async forceCompilationAsync(e,t){return await new Promise((i,r)=>{this.forceCompilation(e,()=>{i()},t,s=>{r(s)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(n._DirtyCallbackArray.length=0,e&n.ImageProcessingDirtyFlag&&n._DirtyCallbackArray.push(n._ImageProcessingDirtyCallBack),e&n.TextureDirtyFlag&&n._DirtyCallbackArray.push(n._TextureDirtyCallBack),e&n.LightDirtyFlag&&n._DirtyCallbackArray.push(n._LightsDirtyCallBack),e&n.FresnelDirtyFlag&&n._DirtyCallbackArray.push(n._FresnelDirtyCallBack),e&n.AttributesDirtyFlag&&n._DirtyCallbackArray.push(n._AttributeDirtyCallBack),e&n.MiscDirtyFlag&&n._DirtyCallbackArray.push(n._MiscDirtyCallBack),e&n.PrePassDirtyFlag&&n._DirtyCallbackArray.push(n._PrePassDirtyCallBack),n._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(n._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){let e=this.getScene().meshes;for(let t of e)if(t.subMeshes)for(let i of t.subMeshes)i.getMaterial()===this&&i.resetDrawCache()}_markAllSubMeshesAsDirty(e){let t=this.getScene();if(t.blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;let i=t.meshes;for(let r of i)if(r.subMeshes){for(let s of r.subMeshes)if((s.getMaterial()||(t._hasDefaultMaterial?t.defaultMaterial:null))===this)for(let o of s._drawWrappers)!o||!o.defines||!o.defines.markAllAsDirty||this._materialContext===o.materialContext&&e(o.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;let e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(n._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(n._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(n._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(n._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(n._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(n._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(n._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(n._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(n._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(n._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;let e=this._scene.onScenePerformancePriorityChangedObservable.addOnce(()=>{this.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)})}}setPrePassRenderer(e){return!1}dispose(e,t,i){let r=this.getScene();if(r.stopAnimation(this),r.freeProcessedMaterials(),r.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){let s=this._parentContainer.materials.indexOf(this);s>-1&&this._parentContainer.materials.splice(s,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(let s in this.meshMap){let a=this.meshMap[s];this._disposeMeshResources(a)}else{let s=r.meshes;for(let a of s)this._disposeMeshResources(a)}this._uniformBuffer.dispose(),this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}_disposeMeshResources(e){var r;if(!e)return;let t=e.geometry,i=e._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(e.subMeshes&&i)for(let s of e.subMeshes){let a=s._drawWrappers;for(let o=0;on.markAllAsDirty();ae._ImageProcessingDirtyCallBack=n=>n.markAsImageProcessingDirty();ae._TextureDirtyCallBack=n=>n.markAsTexturesDirty();ae._FresnelDirtyCallBack=n=>n.markAsFresnelDirty();ae._MiscDirtyCallBack=n=>n.markAsMiscDirty();ae._PrePassDirtyCallBack=n=>n.markAsPrePassDirty();ae._LightsDirtyCallBack=n=>n.markAsLightDirty();ae._AttributeDirtyCallBack=n=>n.markAsAttributesDirty();ae._FresnelAndMiscDirtyCallBack=n=>{ae._FresnelDirtyCallBack(n),ae._MiscDirtyCallBack(n)};ae._TextureAndMiscDirtyCallBack=n=>{ae._TextureDirtyCallBack(n),ae._MiscDirtyCallBack(n)};ae._DirtyCallbackArray=[];ae._RunDirtyCallBacks=n=>{for(let e of ae._DirtyCallbackArray)e(n)};C([D()],ae.prototype,"id",void 0);C([D()],ae.prototype,"uniqueId",void 0);C([D()],ae.prototype,"name",void 0);C([D()],ae.prototype,"metadata",void 0);C([D()],ae.prototype,"checkReadyOnEveryCall",void 0);C([D()],ae.prototype,"checkReadyOnlyOnce",void 0);C([D()],ae.prototype,"state",void 0);C([D("alpha")],ae.prototype,"_alpha",void 0);C([D("backFaceCulling")],ae.prototype,"_backFaceCulling",void 0);C([D("cullBackFaces")],ae.prototype,"_cullBackFaces",void 0);C([D()],ae.prototype,"sideOrientation",void 0);C([D()],ae.prototype,"_alphaMode",void 0);C([D()],ae.prototype,"_needDepthPrePass",void 0);C([D()],ae.prototype,"disableDepthWrite",void 0);C([D()],ae.prototype,"disableColorWrite",void 0);C([D()],ae.prototype,"forceDepthWrite",void 0);C([D()],ae.prototype,"depthFunction",void 0);C([D()],ae.prototype,"separateCullingPass",void 0);C([D("fogEnabled")],ae.prototype,"_fogEnabled",void 0);C([D()],ae.prototype,"pointSize",void 0);C([D()],ae.prototype,"zOffset",void 0);C([D()],ae.prototype,"zOffsetUnits",void 0);C([D()],ae.prototype,"pointsCloud",null);C([D()],ae.prototype,"fillMode",null);C([D()],ae.prototype,"useLogarithmicDepth",null);C([D()],ae.prototype,"_isVertexOutputInvariant",void 0);C([D()],ae.prototype,"transparencyMode",null)});var jl,AM=A(()=>{Ni();ha();Lt();jl=class n extends ae{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){let t=e.push;e.push=(...r)=>{let s=t.apply(e,r);return this._markAllSubMeshesAsTexturesDirty(),s};let i=e.splice;e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);return this._markAllSubMeshesAsTexturesDirty(),a}}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=0&&r.multiMaterials.splice(s,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){let i=new n(e.name,t);if(i.id=e.id,i._loadedUniqueId=e.uniqueId,nt&&nt.AddTagsTo(i,e.tags),e.materialsUniqueIds)i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds;else for(let r of e.materials)i.subMaterials.push(t.getLastMaterialById(r));return i}};je("BABYLON.MultiMaterial",jl)});var iu,RM=A(()=>{iu=class{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}});var Zl,ru,aE,nu,oE,lE,Hn,U,Rt=A(()=>{ct();Tt();Qc();ha();$g();Rs();ve();et();vr();yt();Vt();Jh();Dl();Sf();Ni();AM();Qh();Kt();ze();Lt();gi();El();RM();Zl=class{},ru=class{constructor(){this.batchCache=new nu(this),this.batchCacheReplacementModeInFrozenMode=new nu(this),this.instancesBufferSize=512*4}},aE=class{constructor(){this.renderPasses={}}},nu=class{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}},oE=class{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}},lE=class{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}},Hn={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1},U=class n extends zt{static _GetDefaultSideOrientation(e){return e||n.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(M.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(M.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 Y),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new Y),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new Y),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new Y),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new Y),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===1||!this._scene.useRightHandedSystem&&e===0}get _effectiveSideOrientation(){return this._internalMeshDataInfo._effectiveSideOrientation}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&this.material.sideOrientation===null||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){let e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesData:void 0}get previousWorldMatrixInstancedBuffer(){let e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesPreviousData:void 0}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,i=!0,r=!1){var a,o;let s=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),wn.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){let l=e._ranges;for(let c in l)Object.prototype.hasOwnProperty.call(l,c)&&l[c]&&this.createAnimationRange(c,l[c].from,l[c].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,nt&&nt.HasTags(e)&&nt.AddTagsTo(this,nt.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){let l=e.getDescendants(!0);for(let c=0;c{m&&_&&(this._uniformBuffer?this.transferToEffect(p):_.bindOnlyWorldMatrix(p))};let o,l=!1;if(i&&i._addToSceneRootNodes===void 0){let m=i;o=(c=m.parent)!=null?c:null,r=(f=m.source)!=null?f:null,s=(d=m.doNotCloneChildren)!=null?d:!1,a=(h=m.clonePhysicsImpostor)!=null?h:!0,l=(u=m.cloneThinInstances)!=null?u:!1}else o=i;r&&this._copySource(r,s,a,l),o!==null&&(this.parent=o),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=m=>{m.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 Y(this._internalMeshDataInfo._onMeshReadyObserverAdded),r&&r.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){let r=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));r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),i&&i(this,r);for(let s of this.getChildTransformNodes(!0))s.getClassName()==="InstancedMesh"&&r.getClassName()==="Mesh"&&s.sourceMesh===this?s.instantiateHierarchy(r,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:r},i):s.instantiateHierarchy(r,t,i);return r}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;i0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){let e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((t,i)=>t.distanceOrScreenCoveragei.distanceOrScreenCoverage?-e:0)}addLODLevel(e,t){if(t&&t._masterMesh)return W.Warn("You cannot use a mesh as LOD level twice"),this;let i=new iu(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){let t=this._internalMeshDataInfo;for(let i=0;io*a)return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this;for(let l=0;l0||this.hasThinInstances);this.computeWorldMatrix();let a=this.material||r.defaultMaterial;if(a){if(a._storeEffectOnSubMeshes)for(let p of this.subMeshes){let _=p.getMaterial();if(_){if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,p,s))return!1}else if(!_.isReady(this,s))return!1}}else if(!a.isReady(this,s))return!1}let o=i.currentRenderPassId;for(let p of this.lightSources){let _=p.getShadowGenerators();if(!_)continue;let g=_.values();for(let T=g.next();T.done!==!0;T=g.next()){let b=T.value;if(b&&(!((l=b.getShadowMap())!=null&&l.renderList)||(c=b.getShadowMap())!=null&&c.renderList&&((d=(f=b.getShadowMap())==null?void 0:f.renderList)==null?void 0:d.indexOf(this))!==-1)){let S=(h=b.getShadowMap().renderPassIds)!=null?h:[i.currentRenderPassId];for(let I=0;I0){let i=this.getIndices();if(!i)return null;let r=i.length,s=!1;if(e)s=!0;else for(let a of this.subMeshes){if(a.indexStart+a.indexCount>r){s=!0;break}if(a.verticesStart+a.verticesCount>t){s=!0;break}}if(!s)return this.subMeshes[0]}return this.releaseSubMeshes(),new rr(0,0,t,0,this.getTotalIndices()||(this.isUnIndexed?t:0),this)}subdivide(e){if(e<1)return;let t=this.getTotalIndices(),i=t/e|0,r=0;for(;i%3!==0;)i++;this.releaseSubMeshes();for(let s=0;s=t);s++)rr.CreateFromIndices(0,r,r+i>=t?t-r:i,this,void 0,!1),r+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,r){if(this._geometry)this._geometry.setVerticesData(e,t,i,r);else{let s=new de;s.set(t,e);let a=this.getScene();new Ti(Ti.RandomId(),a,s,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){let i=this.getVertexBuffer(e);!i||i.isUpdatable()===t||this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0,i=null){return this._geometry||(this._geometry=Ti.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,i,t),this}updateVerticesData(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){let i=this.getVerticesData(M.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(M.PositionKind,i,!1,!1),t){let r=this.getIndices(),s=this.getVerticesData(M.NormalKind);if(!s)return this;de.ComputeNormals(i,r,s),this.updateVerticesData(M.NormalKind,s,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;let e=this._geometry,t=this._geometry.copy(Ti.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,r=null){let s=this._geometry;s||(s=new Ti(Ti.RandomId(),this.getScene(),void 0,void 0,this)),s.setIndexBuffer(e,t,i,r)}setIndices(e,t=null,i=!1,r=!1){if(this._geometry)this._geometry.setIndices(e,t,i,r);else{let s=new de;s.indices=e;let a=this.getScene();new Ti(Ti.RandomId(),a,s,i,this,t)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,r=!0){if(!this._geometry)return this;let s=this.getScene().getEngine(),a;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case ae.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),s);break;default:a=null;break}else switch(this._getRenderingFillMode(i)){case ae.PointFillMode:a=null;break;case ae.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),s);break;default:case ae.TriangleFillMode:a=this._geometry.getIndexBuffer();break}return this._bindDirect(t,a,r)}_bindDirect(e,t,i=!0){if(!this._geometry)return this;if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances)this._geometry._bind(e,t);else{if(!this._instanceDataStorage.useMonoDataStorageRenderPass&&this._userInstancedBuffersStorage.renderPasses&&this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId]){let r=this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];for(let s in r)this._userInstancedBuffersStorage.vertexBuffers[s]=r[s]}this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);let s=this.getScene().getEngine(),a=s._currentMaterialContext,o=a&&a.useVertexPulling;return this._unIndexed&&t!==ae.WireFrameFillMode||t==ae.PointFillMode?s.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==ae.WireFrameFillMode?s.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):o?s.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):s.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){let i=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._getInstanceDataStorage();if(this._instanceDataStorage.isFrozen){if(t)return i.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,i.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,i.batchCacheReplacementModeInFrozenMode;if(i.previousBatch)return i.previousBatch}let r=this.getScene(),s=r._isInIntermediateRendering(),a=s?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=i.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!a&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,i.visibleInstances&&!t){let l=i.visibleInstances,c=r.getRenderId(),f=s?l.intermediateDefaultRenderId:l.defaultRenderId;o.visibleInstances[e]=l[c],!o.visibleInstances[e]&&f&&(o.visibleInstances[e]=l[f])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&o.visibleInstances[e]!==null&&o.visibleInstances[e]!==void 0,i.previousBatch=o,o}_updateInstancedBuffers(e,t,i,r,s,a){var T;let o=t.visibleInstances[e._id],l=o?o.length:0,c=t.parent,f=this._instanceDataStorage,d=c.instancesBuffer,h=c.instancesPreviousBuffer,u=0,m=0,p=t.renderSelf[e._id],_=this._scene.floatingOriginOffset,g=!d||i!==c.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!c.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!f.isFrozen||g)){let b=this.getWorldMatrix();if(p){this._scene.needsPreviousWorldMatrices&&(f.masterMeshPreviousWorldMatrix?(f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u),f.masterMeshPreviousWorldMatrix.copyFrom(b)):(f.masterMeshPreviousWorldMatrix=b.clone(),f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u))),b.copyToArray(c.instancesData,u);let R=b.asArray();c.instancesData[u+12]=R[12]-_.x,c.instancesData[u+13]=R[13]-_.y,c.instancesData[u+14]=R[14]-_.z,u+=16,m++}if(o){if(n.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&((T=e.getMaterial())!=null&&T.needAlphaBlendingForMesh(e.getRenderingMesh()))){let R=this._scene.activeCamera.globalPosition;for(let S=0;SS._distanceToCamera>I._distanceToCamera?-1:S._distanceToCamera1&&r.activeCamera===r.activeCameras[0]||a<=1,l=this._occlusionDataStorage&&this._occlusionDataStorage.occlusionForRenderPassId!==-1&&this._occlusionDataStorage.occlusionForRenderPassId!==s.currentRenderPassId;if(o&&this._checkOcclusionQuery(l)&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;let c=this._getInstancesRenderList(e._id,!!i);if(c.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;let f=0,d=null;this.ignoreCameraMaxZ&&r.activeCamera&&!r._isInIntermediateRendering()&&(f=r.activeCamera.maxZ,d=r.activeCamera,r.activeCamera.maxZ=0,r.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);let h=e.getRenderingMesh(),u=c.hardwareInstancedRendering[e._id]||h.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,m=this._instanceDataStorage,p=e.getMaterial();if(!p)return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;if(!m.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==p){if(p._storeEffectOnSubMeshes){if(!p.isReadyForSubMesh(this,e,u))return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this}else if(!p.isReady(this,u))return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=p}else if(p._storeEffectOnSubMeshes&&!((y=e._drawWrapper)!=null&&y._wasPreviouslyReady)||!p._storeEffectOnSubMeshes&&!p._getDrawWrapper()._wasPreviouslyReady)return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;if(t){let w=this._internalMeshDataInfo._effectiveMaterial;if(w.alphaModes.length===1)s.setAlphaMode(w.alphaMode);else for(let H=0;Hg&&r++,S!==0&&b++,T+=S,g=S}if(c[b]++,b>a&&(a=b),T===0)s++;else{let R=1/T,S=0;for(let I=0;If&&o++}}let d=this.skeleton.bones.length,h=this.getVerticesData(M.MatricesIndicesKind),u=this.getVerticesData(M.MatricesIndicesExtraKind),m=0;for(let _=0;_=d||T<0)&&m++}let p="Number of Weights = "+i/4+` +fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=toRGBD(textureSample(textureSampler,textureSamplerSampler,input.vUV).rgb);}`;E.ShadersStoreWGSL[vg]||(E.ShadersStoreWGSL[vg]=vC);hG={name:vg,shader:vC}});var Sl,Tg=A(()=>{ps();Z_();Sl=class{static ExpandRGBDTexture(e){let t=e._texture;if(!t||!e.isRGBD)return;let i=t.getEngine(),r=i.getCaps(),s=t.isReady,a=!1;r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?(a=!0,t.type=2):r.textureFloatRender&&r.textureFloatLinearFiltering&&(a=!0,t.type=1),a&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);let o=async()=>{let l=i.isWebGPU,c=l?1:0;t.isReady=!1,l?await Promise.resolve().then(()=>(mg(),ug)):await Promise.resolve().then(()=>(gg(),_g));let f=new gt("rgbdDecode","rgbdDecode",null,null,1,null,3,i,!1,void 0,t.type,void 0,null,!1,void 0,c);f.externalTextureSamplerBinding=!0;let d=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:5});f.onEffectCreatedObservable.addOnce(h=>{h.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",t),u.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([f],d,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),f&&f.dispose(),d._swapAndDie(t),t.isReady=!0})})};a&&(s?o():e.onLoadObservable.addOnce(o))}static async EncodeTextureToRGBD(e,t,i=0){return t.getEngine().isWebGPU?await Promise.resolve().then(()=>(SC(),TC)):await Promise.resolve().then(()=>(EC(),gC)),await Ax("rgbdEncode",e,t,i,1,5)}}});var Sg=A(()=>{M_();qc();dt.prototype._sphericalPolynomialTargetSize=0;dt.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)};Object.defineProperty(dt.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial||this._texture._sphericalPolynomialComputed)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomialPromise||(this._texture._sphericalPolynomialPromise=hs.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomialPromise===null?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then(n=>{this._texture._sphericalPolynomial=n,this._texture._sphericalPolynomialComputed=!0})),null}return null},set:function(n){this._texture&&(this._texture._sphericalPolynomial=n)},enumerable:!0,configurable:!0})});function xC(n){let e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=0;for(let a=0;aAC)throw new Error(`Unsupported babylon environment map version "${n.version}". Latest supported version is "${AC}".`);return n.version===2||(n={...n,version:2,imageType:kh}),n}function uG(n,e){e=hf(e);let t=e.specular,i=Math.log2(e.width);if(i=Math.round(i)+1,t.mipmaps.length!==6*i)throw new Error(`Unsupported specular mipmaps number "${t.mipmaps.length}"`);let r=new Array(i);for(let s=0;s{if(t){let u=e.createTexture(null,!0,!0,null,1,null,m=>{h(m)},n);i==null||i.onEffectCreatedObservable.addOnce(m=>{m.executeWhenCompiled(()=>{i.externalTextureSamplerBinding=!0,i.onApply=p=>{p._bindTexture("textureSampler",u),p.setFloat2("scale",1,e._features.needsInvertingBitmap&&n instanceof ImageBitmap?-1:1)},e.scenes.length&&(e.scenes[0].postProcessManager.directRender([i],c,!0,s,a),e.restoreDefaultFramebuffer(),u.dispose(),URL.revokeObjectURL(r),d())})})}else{if(e._uploadImageToTexture(f,n,s,a),o){let u=l[a];u&&e._uploadImageToTexture(u._texture,n,s,0)}d()}})}async function pG(n,e,t=kh){let i=n.getEngine();n.format=5,n.type=0,n.generateMipMaps=!0,n._cachedAnisotropicFilteringLevel=null,i.updateTextureSamplingMode(3,n),await bC(n,e,!0,t),n.isReady=!0}async function _G(n,e,t,i=kh,r=null){let s=n.getEngine(),a=new bt(s,5),o=new dt(s,a);n._irradianceTexture=o,o._dominantDirection=r,a.isCube=!0,a.format=5,a.type=0,a.generateMipMaps=!0,a._cachedAnisotropicFilteringLevel=null,a.generateMipMaps=!0,a.width=t,a.height=t,s.updateTextureSamplingMode(3,a),await bC(a,[e],!1,i),s.generateMipMapsForCubemap(a),a.isReady=!0}async function bC(n,e,t,i=kh){if(!re.IsExponentOfTwo(n.width))throw new Error("Texture size must be a power of two");let r=CI(n.width)+1,s=n.getEngine(),a=!1,o=!1,l=null,c=null,f=null,d=s.getCaps();d.textureLOD?s._features.supportRenderAndCopyToLodForFloatTextures?d.textureHalfFloatRender&&d.textureHalfFloatLinearFiltering?(a=!0,n.type=2):d.textureFloatRender&&d.textureFloatLinearFiltering&&(a=!0,n.type=1):a=!1:(a=!1,o=t);let h=0;if(a)s.isWebGPU?(h=1,await Promise.resolve().then(()=>(mg(),ug))):await Promise.resolve().then(()=>(gg(),_g)),l=new gt("rgbdDecode","rgbdDecode",null,null,1,null,3,s,!1,void 0,n.type,void 0,null,!1,void 0,h),n._isRGBD=!1,n.invertY=!1,c=s.createRenderTargetCubeTexture(n.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:3,type:n.type,format:5});else if(n._isRGBD=!0,n.invertY=!0,o){f={};let p=n._lodGenerationScale,_=n._lodGenerationOffset;for(let g=0;g<3;g++){let b=1-g/2,R=_,S=(r-1)*p+_,I=R+(S-R)*b,x=Math.round(Math.min(Math.max(I,0),S)),P=new bt(s,2);P.isCube=!0,P.invertY=!0,P.generateMipMaps=!1,s.updateTextureSamplingMode(2,P);let L=new dt(null);switch(L._isCube=!0,L._texture=P,f[x]=L,g){case 0:n._lodTextureLow=L;break;case 1:n._lodTextureMid=L;break;case 2:n._lodTextureHigh=L;break}}}let u=[];for(let m=0;mawait IC(S,s,a,l,b,p,m,o,f,c,n));else{let S=new Image;S.src=b,R=new Promise((I,x)=>{S.onload=()=>{IC(S,s,a,l,b,p,m,o,f,c,n).then(()=>I()).catch(P=>{x(P)})},S.onerror=P=>{x(P)}})}u.push(R)}if(await Promise.all(u),e.length{Tt();ve();Mi();Xc();vr();qc();sr();ps();ze();Tg();W_();Sg();_l();kh="image/png",AC=2,RC=[134,22,135,150,246,214,150,54]});var DC={};De(DC,{_ENVTextureLoader:()=>Ag});var Ag,LC=A(()=>{yC();Ag=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){if(Array.isArray(e))return;let a=xC(e);if(a){t.width=a.width,t.height=a.width;try{MC(t,a),CC(t,e,a).then(()=>{t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()},o=>{s==null||s("Can not upload environment levels",o)})}catch(o){s==null||s("Can not upload environment file",o)}}else s&&s("Can not parse the environment file",null)}loadData(){throw".env not supported in 2d."}}});var Ss,PC=A(()=>{ve();Ss=class{static ConvertPanoramaToCubemap(e,t,i,r,s=!1,a=!0){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";let o;if(e.length!=t*i*3){if(e.length!=t*i*4)throw"ConvertPanoramaToCubemap: input size is wrong";o=4}else o=3;let l=this.CreateCubemapTexture(r,this.FACE_FRONT,e,t,i,s,a,o),c=this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i,s,a,o),f=this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i,s,a,o),d=this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i,s,a,o),h=this.CreateCubemapTexture(r,this.FACE_UP,e,t,i,s,a,o),u=this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i,s,a,o);return{front:l,back:c,left:f,right:d,up:h,down:u,size:r,type:1,format:4,gammaSpace:!1}}static CreateCubemapTexture(e,t,i,r,s,a,o,l){let c=new ArrayBuffer(e*e*4*3),f=new Float32Array(c),d=a?Math.max(1,Math.round(r/4/e)):1,h=1/d,u=h*h,m=t[1].subtract(t[0]).scale(h/e),p=t[3].subtract(t[2]).scale(h/e),_=1/e,g=0;for(let T=0;TMath.PI;)o-=2*Math.PI;let c=o/Math.PI,f=l/Math.PI;c=c*.5+.5;let d=Math.round(c*i);d<0?d=0:d>=i&&(d=i-1);let h=Math.round(f*r);h<0?h=0:h>=r&&(h=r-1);let u=a?r-h-1:h,m=t[u*i*s+d*s+0],p=t[u*i*s+d*s+1],_=t[u*i*s+d*s+2];return{r:m,g:p,b:_}}};Ss.FACE_LEFT=[new v(-1,-1,-1),new v(1,-1,-1),new v(-1,1,-1),new v(1,1,-1)];Ss.FACE_RIGHT=[new v(1,-1,1),new v(-1,-1,1),new v(1,1,1),new v(-1,1,1)];Ss.FACE_FRONT=[new v(1,-1,-1),new v(1,-1,1),new v(1,1,-1),new v(1,1,1)];Ss.FACE_BACK=[new v(-1,-1,1),new v(-1,-1,-1),new v(-1,1,1),new v(-1,1,-1)];Ss.FACE_DOWN=[new v(1,1,-1),new v(1,1,1),new v(-1,1,-1),new v(-1,1,1)];Ss.FACE_UP=[new v(-1,-1,-1),new v(-1,-1,1),new v(1,-1,-1),new v(1,-1,1)]});function gG(n,e){return e>1023?n*Math.pow(2,1023)*Math.pow(2,e-1023):e<-1074?n*Math.pow(2,-1074)*Math.pow(2,e+1074):n*Math.pow(2,e)}function OC(n,e,t,i,r,s){r>0?(r=gG(1,r-136),n[s+0]=e*r,n[s+1]=t*r,n[s+2]=i*r):(n[s+0]=0,n[s+1]=0,n[s+2]=0)}function Rg(n,e){let t="",i;for(let r=e;r32767)throw"HDR Bad header format, unsupported size";return r+=e.length+1,{height:l,width:o,dataPosition:r}}function FC(n,e){return EG(n,e)}function EG(n,e){let t=e.height,i=e.width,r,s,a,o,l,c=e.dataPosition,f,d,h,u=new ArrayBuffer(i*4),m=new Uint8Array(u),p=new ArrayBuffer(e.width*e.height*4*3),_=new Float32Array(p);for(;t>0;){if(r=n[c++],s=n[c++],a=n[c++],o=n[c++],r!=2||s!=2||a&128||e.width<8||e.width>32767)return vG(n,e);if((a<<8|o)!=i)throw"HDR Bad header format, wrong scan line width";for(f=0,h=0;h<4;h++)for(d=(h+1)*i;f128){if(l=r-128,l==0||l>d-f)throw"HDR Bad Format, bad scanline data (run)";for(;l-- >0;)m[f++]=s}else{if(l=r,l==0||l>d-f)throw"HDR Bad Format, bad scanline data (non-run)";if(m[f++]=s,--l>0)for(let g=0;g0;){for(l=0;l{PC()});var BC={};De(BC,{_HDRTextureLoader:()=>Ig});var Ig,UC=A(()=>{wC();Ig=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".hdr not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=NC(r),a=FC(r,s),o=s.width*s.height,l=new Float32Array(o*4);for(let c=0;c{let c=t.getEngine();t.type=1,t.format=5,t._gammaSpace=!1,c._uploadDataToTextureDirectly(t,l)})}}});var pn,VC=A(()=>{ze();pn=class n{constructor(e,t){if(this.data=e,this.isInvalid=!1,!n.IsValid(e)){this.isInvalid=!0,W.Error("texture missing KTX identifier");return}let i=Uint32Array.BYTES_PER_ELEMENT,r=new DataView(this.data.buffer,this.data.byteOffset+12,13*i),a=r.getUint32(0,!0)===67305985;if(this.glType=r.getUint32(1*i,a),this.glTypeSize=r.getUint32(2*i,a),this.glFormat=r.getUint32(3*i,a),this.glInternalFormat=r.getUint32(4*i,a),this.glBaseInternalFormat=r.getUint32(5*i,a),this.pixelWidth=r.getUint32(6*i,a),this.pixelHeight=r.getUint32(7*i,a),this.pixelDepth=r.getUint32(8*i,a),this.numberOfArrayElements=r.getUint32(9*i,a),this.numberOfFaces=r.getUint32(10*i,a),this.numberOfMipmapLevels=r.getUint32(11*i,a),this.bytesOfKeyValueData=r.getUint32(12*i,a),this.glType!==0){W.Error("only compressed formats currently supported"),this.isInvalid=!0;return}else this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels);if(this.pixelHeight===0||this.pixelDepth!==0){W.Error("only 2D textures currently supported"),this.isInvalid=!0;return}if(this.numberOfArrayElements!==0){W.Error("texture arrays not currently supported"),this.isInvalid=!0;return}if(this.numberOfFaces!==t){W.Error("number of faces expected"+t+", but found "+this.numberOfFaces),this.isInvalid=!0;return}this.loadType=n.COMPRESSED_2D}uploadLevels(e,t){switch(this.loadType){case n.COMPRESSED_2D:this._upload2DCompressedLevels(e,t);break;case n.TEX_2D:case n.COMPRESSED_3D:case n.TEX_3D:}}_upload2DCompressedLevels(e,t){let i=n.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,s=this.pixelHeight,a=t?this.numberOfMipmapLevels:1;for(let o=0;o=12){let t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===49&&t[6]===49&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}};pn.HEADER_LEN=64;pn.COMPRESSED_2D=0;pn.COMPRESSED_3D=1;pn.TEX_2D=2;pn.TEX_3D=3});var xg,uf,GC=A(()=>{xg=class{constructor(e){this._pendingActions=new Array,this._workerInfos=e.map(t=>({workerPromise:Promise.resolve(t),idle:!0}))}dispose(){for(let e of this._workerInfos)e.workerPromise.then(t=>{t.terminate()});this._workerInfos.length=0,this._pendingActions.length=0}push(e){this._executeOnIdleWorker(e)||this._pendingActions.push(e)}_executeOnIdleWorker(e){for(let t of this._workerInfos)if(t.idle)return this._execute(t,e),!0;return!1}_execute(e,t){e.idle=!1,e.workerPromise.then(i=>{t(i,()=>{let r=this._pendingActions.shift();r?this._execute(e,r):e.idle=!0})})}},uf=class n extends xg{constructor(e,t,i=n.DefaultOptions){super([]),this._maxWorkers=e,this._createWorkerAsync=t,this._options=i}push(e){if(!this._executeOnIdleWorker(e))if(this._workerInfos.length{t(i,()=>{r(),e.idle&&(e.timeoutId=setTimeout(()=>{e.workerPromise.then(a=>{a.terminate()});let s=this._workerInfos.indexOf(e);s!==-1&&this._workerInfos.splice(s,1)},this._options.idleTimeElapsedBeforeRelease))})})}};uf.DefaultOptions={idleTimeElapsedBeforeRelease:1e3}});var kC,Al,WC,HC=A(()=>{(function(n){n[n.ETC1S=0]="ETC1S",n[n.UASTC4x4=1]="UASTC4x4"})(kC||(kC={}));(function(n){n[n.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",n[n.ASTC_4x4_RGBA=0]="ASTC_4x4_RGBA",n[n.BC7_RGBA=1]="BC7_RGBA",n[n.BC3_RGBA=2]="BC3_RGBA",n[n.BC1_RGB=3]="BC1_RGB",n[n.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",n[n.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",n[n.ETC2_RGBA=6]="ETC2_RGBA",n[n.ETC1_RGB=7]="ETC1_RGB",n[n.RGBA32=8]="RGBA32",n[n.R8=9]="R8",n[n.RG8=10]="RG8"})(Al||(Al={}));(function(n){n[n.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",n[n.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",n[n.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",n[n.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",n[n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",n[n.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",n[n.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",n[n.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",n[n.RGBA8Format=32856]="RGBA8Format",n[n.R8Format=33321]="R8Format",n[n.RG8Format=33323]="RG8Format"})(WC||(WC={}))});function mf(n,e){let t=(e==null?void 0:e.jsDecoderModule)||KTX2DECODER;n&&(n.wasmBaseUrl&&(t.Transcoder.WasmBaseUrl=n.wasmBaseUrl),n.wasmUASTCToASTC&&(t.LiteTranscoder_UASTC_ASTC.WasmModuleURL=n.wasmUASTCToASTC),n.wasmUASTCToBC7&&(t.LiteTranscoder_UASTC_BC7.WasmModuleURL=n.wasmUASTCToBC7),n.wasmUASTCToRGBA_UNORM&&(t.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=n.wasmUASTCToRGBA_UNORM),n.wasmUASTCToRGBA_SRGB&&(t.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=n.wasmUASTCToRGBA_SRGB),n.wasmUASTCToR8_UNORM&&(t.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=n.wasmUASTCToR8_UNORM),n.wasmUASTCToRG8_UNORM&&(t.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=n.wasmUASTCToRG8_UNORM),n.jsMSCTranscoder&&(t.MSCTranscoder.JSModuleURL=n.jsMSCTranscoder),n.wasmMSCTranscoder&&(t.MSCTranscoder.WasmModuleURL=n.wasmMSCTranscoder),n.wasmZSTDDecoder&&(t.ZSTDDecoder.WasmModuleURL=n.wasmZSTDDecoder)),e&&(e.wasmUASTCToASTC&&(t.LiteTranscoder_UASTC_ASTC.WasmBinary=e.wasmUASTCToASTC),e.wasmUASTCToBC7&&(t.LiteTranscoder_UASTC_BC7.WasmBinary=e.wasmUASTCToBC7),e.wasmUASTCToRGBA_UNORM&&(t.LiteTranscoder_UASTC_RGBA_UNORM.WasmBinary=e.wasmUASTCToRGBA_UNORM),e.wasmUASTCToRGBA_SRGB&&(t.LiteTranscoder_UASTC_RGBA_SRGB.WasmBinary=e.wasmUASTCToRGBA_SRGB),e.wasmUASTCToR8_UNORM&&(t.LiteTranscoder_UASTC_R8_UNORM.WasmBinary=e.wasmUASTCToR8_UNORM),e.wasmUASTCToRG8_UNORM&&(t.LiteTranscoder_UASTC_RG8_UNORM.WasmBinary=e.wasmUASTCToRG8_UNORM),e.jsMSCTranscoder&&(t.MSCTranscoder.JSModule=e.jsMSCTranscoder),e.wasmMSCTranscoder&&(t.MSCTranscoder.WasmBinary=e.wasmMSCTranscoder),e.wasmZSTDDecoder&&(t.ZSTDDecoder.WasmBinary=e.wasmZSTDDecoder))}function zC(n){typeof n=="undefined"&&typeof KTX2DECODER!="undefined"&&(n=KTX2DECODER);let e;onmessage=t=>{if(t.data)switch(t.data.action){case"init":{let i=t.data.urls;i&&(i.jsDecoderModule&&typeof n=="undefined"&&(importScripts(i.jsDecoderModule),n=KTX2DECODER),mf(i)),t.data.wasmBinaries&&mf(void 0,{...t.data.wasmBinaries,jsDecoderModule:n}),e=new n.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":{n.KTX2Decoder.DefaultDecoderOptions=t.data.options;break}case"decode":e.decode(t.data.data,t.data.caps,t.data.options).then(i=>{let r=[];for(let s=0;s{postMessage({action:"decoded",success:!1,msg:i})});break}}}async function XC(n,e,t){return await new Promise((i,r)=>{let s=o=>{n.removeEventListener("error",s),n.removeEventListener("message",a),r(o)},a=o=>{o.data.action==="init"&&(n.removeEventListener("error",s),n.removeEventListener("message",a),i(n))};n.addEventListener("error",s),n.addEventListener("message",a),n.postMessage({action:"init",urls:t,wasmBinaries:e})})}var YC=A(()=>{});var Cg,As,KC=A(()=>{GC();Tt();HC();YC();Cg=class{constructor(){this._isDirty=!0,this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=!0,this._ktx2DecoderOptions={}}get isDirty(){return this._isDirty}get useRGBAIfASTCBC7NotAvailableWhenUASTC(){return this._useRGBAIfASTCBC7NotAvailableWhenUASTC}set useRGBAIfASTCBC7NotAvailableWhenUASTC(e){this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==e&&(this._useRGBAIfASTCBC7NotAvailableWhenUASTC=e,this._isDirty=!0)}get useRGBAIfOnlyBC1BC3AvailableWhenUASTC(){return this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC}set useRGBAIfOnlyBC1BC3AvailableWhenUASTC(e){this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC!==e&&(this._useRGBAIfOnlyBC1BC3AvailableWhenUASTC=e,this._isDirty=!0)}get forceRGBA(){return this._forceRGBA}set forceRGBA(e){this._forceRGBA!==e&&(this._forceRGBA=e,this._isDirty=!0)}get forceR8(){return this._forceR8}set forceR8(e){this._forceR8!==e&&(this._forceR8=e,this._isDirty=!0)}get forceRG8(){return this._forceRG8}set forceRG8(e){this._forceRG8!==e&&(this._forceRG8=e,this._isDirty=!0)}get bypassTranscoders(){return this._bypassTranscoders}set bypassTranscoders(e){this._bypassTranscoders!==e&&(this._bypassTranscoders=e,this._isDirty=!0)}_getKTX2DecoderOptions(){if(!this._isDirty)return this._ktx2DecoderOptions;this._isDirty=!1;let e={};return this._useRGBAIfASTCBC7NotAvailableWhenUASTC!==void 0&&(e.useRGBAIfASTCBC7NotAvailableWhenUASTC=this._useRGBAIfASTCBC7NotAvailableWhenUASTC),this._forceRGBA!==void 0&&(e.forceRGBA=this._forceRGBA),this._forceR8!==void 0&&(e.forceR8=this._forceR8),this._forceRG8!==void 0&&(e.forceRG8=this._forceRG8),this._bypassTranscoders!==void 0&&(e.bypassTranscoders=this._bypassTranscoders),this.useRGBAIfOnlyBC1BC3AvailableWhenUASTC&&(e.transcodeFormatDecisionTree={UASTC:{transcodeFormat:[Al.BC1_RGB,Al.BC3_RGBA],yes:{transcodeFormat:Al.RGBA32,engineFormat:32856,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}},As=class n{static GetDefaultNumWorkers(){return typeof navigator!="object"||!navigator.hardwareConcurrency?1:Math.min(Math.floor(navigator.hardwareConcurrency*.5),4)}static _Initialize(e){if(n._WorkerPoolPromise||n._DecoderModulePromise)return;let t={wasmBaseUrl:re.ScriptBaseUrl,jsDecoderModule:re.GetBabylonScriptURL(this.URLConfig.jsDecoderModule,!0),wasmUASTCToASTC:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC,!0),wasmUASTCToBC7:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7,!0),wasmUASTCToRGBA_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM,!0),wasmUASTCToRGBA_SRGB:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB,!0),wasmUASTCToR8_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM,!0),wasmUASTCToRG8_UNORM:re.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM,!0),jsMSCTranscoder:re.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder,!0),wasmMSCTranscoder:re.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder,!0),wasmZSTDDecoder:re.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder,!0)};e&&typeof Worker=="function"&&typeof URL!="undefined"?n._WorkerPoolPromise=new Promise(i=>{let r=`${mf}(${zC})()`,s=URL.createObjectURL(new Blob([r],{type:"application/javascript"}));i(new uf(e,async()=>await XC(new Worker(s),void 0,t)))}):typeof n._KTX2DecoderModule=="undefined"?n._DecoderModulePromise=re.LoadBabylonScriptAsync(t.jsDecoderModule).then(()=>(n._KTX2DecoderModule=KTX2DECODER,n._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,n._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,mf(t,n._KTX2DecoderModule),new n._KTX2DecoderModule.KTX2Decoder)):(n._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,n._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,n._DecoderModulePromise=Promise.resolve(new n._KTX2DecoderModule.KTX2Decoder))}constructor(e,t=n.DefaultNumWorkers){var r,s;this._engine=e;let i=typeof t=="object"&&t.workerPool||n.WorkerPool;if(i)n._WorkerPoolPromise=Promise.resolve(i);else{typeof t=="object"?n._KTX2DecoderModule=(r=t==null?void 0:t.binariesAndModulesContainer)==null?void 0:r.jsDecoderModule:typeof KTX2DECODER!="undefined"&&(n._KTX2DecoderModule=KTX2DECODER);let a=typeof t=="number"?t:(s=t.numWorkers)!=null?s:n.DefaultNumWorkers;n._Initialize(a)}}async _uploadAsync(e,t,i){let r=this._engine.getCaps(),s={astc:!!r.astc,bptc:!!r.bptc,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,etc1:!!r.etc1};if(n._WorkerPoolPromise){let a=await n._WorkerPoolPromise;return await new Promise((o,l)=>{a.push((c,f)=>{let d=m=>{c.removeEventListener("error",d),c.removeEventListener("message",h),l(m),f()},h=m=>{if(m.data.action==="decoded"){if(c.removeEventListener("error",d),c.removeEventListener("message",h),!m.data.success)l({message:m.data.msg});else try{this._createTexture(m.data.decodedData,t,i),o()}catch(p){l({message:p})}f()}};c.addEventListener("error",d),c.addEventListener("message",h),c.postMessage({action:"setDefaultDecoderOptions",options:n.DefaultDecoderOptions._getKTX2DecoderOptions()});let u=new Uint8Array(e.byteLength);u.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),c.postMessage({action:"decode",data:u,caps:s,options:i},[u.buffer])})})}else if(n._DecoderModulePromise){let a=await n._DecoderModulePromise;return n.DefaultDecoderOptions.isDirty&&(n._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions=n.DefaultDecoderOptions._getKTX2DecoderOptions()),await new Promise((o,l)=>{a.decode(e,r).then(c=>{this._createTexture(c,t),o()}).catch(c=>{l({message:c})})})}throw new Error("KTX2 decoder module is not available")}_createTexture(e,t,i){this._engine._bindTextureDirectly(3553,t),i&&(i.transcodedFormat=e.transcodedFormat,i.isInGammaSpace=e.isInGammaSpace,i.hasAlpha=e.hasAlpha,i.transcoderName=e.transcoderName);let s=!0;switch(e.transcodedFormat){case 32856:t.type=0,t.format=5;break;case 33321:t.type=0,t.format=6;break;case 33323:t.type=0,t.format=7;break;default:t.format=e.transcodedFormat,s=!1;break}if(t._gammaSpace=e.isInGammaSpace,t.generateMipMaps=e.mipmaps.length>1,t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(let a=0;a=12){let t=new Uint8Array(e.buffer,e.byteOffset,12);if(t[0]===171&&t[1]===75&&t[2]===84&&t[3]===88&&t[4]===32&&t[5]===50&&t[6]===48&&t[7]===187&&t[8]===13&&t[9]===10&&t[10]===26&&t[11]===10)return!0}return!1}};As.URLConfig={jsDecoderModule:"https://cdn.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,wasmUASTCToR8_UNORM:null,wasmUASTCToRG8_UNORM:null,jsMSCTranscoder:null,wasmMSCTranscoder:null,wasmZSTDDecoder:null};As.DefaultNumWorkers=As.GetDefaultNumWorkers();As.DefaultDecoderOptions=new Cg});var Mg={};De(Mg,{_KTXTextureLoader:()=>bg});function TG(n){switch(n){case 35916:return 33776;case 35918:return 33778;case 35919:return 33779;case 37493:return 37492;case 37497:return 37496;case 37495:return 37494;case 37840:return 37808;case 37841:return 37809;case 37842:return 37810;case 37843:return 37811;case 37844:return 37812;case 37845:return 37813;case 37846:return 37814;case 37847:return 37815;case 37848:return 37816;case 37849:return 37817;case 37850:return 37818;case 37851:return 37819;case 37852:return 37820;case 37853:return 37821;case 36493:return 36492}return null}var bg,yg=A(()=>{VC();KC();ze();bg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r){if(Array.isArray(e))return;t._invertVScale=!t.invertY;let s=t.getEngine(),a=new pn(e,6),o=a.numberOfMipmapLevels>1&&t.generateMipMaps;s._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,s._setCubeMapTextureParams(t,o,a.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}loadData(e,t,i,r){if(pn.IsValid(e)){t._invertVScale=!t.invertY;let s=new pn(e,1),a=TG(s.glInternalFormat);a?(t.format=a,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=s.glInternalFormat,i(s.pixelWidth,s.pixelHeight,t.generateMipMaps,!0,()=>{s.uploadLevels(t,t.generateMipMaps)},s.isInvalid)}else As.IsValid(e)?new As(t.getEngine())._uploadAsync(e,t,r).then(()=>{i(t.width,t.height,t.generateMipMaps,!0,()=>{},!1)},a=>{W.Warn(`Failed to load KTX2 texture data: ${a.message}`),i(0,0,!1,!1,()=>{},!0)}):(W.Error("texture missing KTX identifier"),i(0,0,!1,!1,()=>{},!0))}}});function Wh(n){let e=0;return{id_length:n[e++],colormap_type:n[e++],image_type:n[e++],colormap_index:n[e++]|n[e++]<<8,colormap_length:n[e++]|n[e++]<<8,colormap_size:n[e++],origin:[n[e++]|n[e++]<<8,n[e++]|n[e++]<<8],width:n[e++]|n[e++]<<8,height:n[e++]|n[e++]<<8,pixel_size:n[e++],flags:n[e]}}function Dg(n,e){if(e.length<19){W.Error("Unable to load TGA file - Not enough data to contain header");return}let t=18,i=Wh(e);if(i.id_length+t>e.length){W.Error("Unable to load TGA file - Not enough data");return}t+=i.id_length;let r=!1,s=!1,a=!1;switch(i.image_type){case IG:r=!0;case SG:s=!0;break;case xG:r=!0;case AG:break;case CG:r=!0;case RG:a=!0;break}let o,l=i.pixel_size>>3,c=i.width*i.height*l,f;if(s&&(f=e.subarray(t,t+=i.colormap_length*(i.colormap_size>>3))),r){o=new Uint8Array(c);let R,S,I,x=0,P=new Uint8Array(l);for(;t>MG){default:case LG:d=0,u=1,_=i.width,h=0,m=1,p=i.height;break;case yG:d=0,u=1,_=i.width,h=i.height-1,m=-1,p=-1;break;case PG:d=i.width-1,u=-1,_=-1,h=0,m=1,p=i.height;break;case DG:d=i.width-1,u=-1,_=-1,h=i.height-1,m=-1,p=-1;break}let g="_getImageData"+(a?"Grey":"")+i.pixel_size+"bits",T=VG[g](i,f,o,h,m,p,d,u,_);n.getEngine()._uploadDataToTextureDirectly(n,T)}function OG(n,e,t,i,r,s,a,o,l){let c=t,f=e,d=n.width,h=n.height,u,m=0,p,_,g=new Uint8Array(d*h*4);for(_=i;_!==s;_+=r)for(p=a;p!==l;p+=o,m++)u=c[m],g[(p+d*_)*4+3]=255,g[(p+d*_)*4+2]=f[u*3+0],g[(p+d*_)*4+1]=f[u*3+1],g[(p+d*_)*4+0]=f[u*3+2];return g}function NG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h,u=0,m,p,_=new Uint8Array(f*d*4);for(p=i;p!==s;p+=r)for(m=a;m!==l;m+=o,u+=2){h=c[u+0]+(c[u+1]<<8);let g=((h&31744)>>10)*255/31|0,T=((h&992)>>5)*255/31|0,b=(h&31)*255/31|0;_[(m+f*p)*4+0]=g,_[(m+f*p)*4+1]=T,_[(m+f*p)*4+2]=b,_[(m+f*p)*4+3]=h&32768?0:255}return _}function FG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=3)p[(u+f*m)*4+3]=255,p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+1]=c[h+1],p[(u+f*m)*4+0]=c[h+2];return p}function wG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=4)p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+1]=c[h+1],p[(u+f*m)*4+0]=c[h+2],p[(u+f*m)*4+3]=c[h+3];return p}function BG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h,u=0,m,p,_=new Uint8Array(f*d*4);for(p=i;p!==s;p+=r)for(m=a;m!==l;m+=o,u++)h=c[u],_[(m+f*p)*4+0]=h,_[(m+f*p)*4+1]=h,_[(m+f*p)*4+2]=h,_[(m+f*p)*4+3]=255;return _}function UG(n,e,t,i,r,s,a,o,l){let c=t,f=n.width,d=n.height,h=0,u,m,p=new Uint8Array(f*d*4);for(m=i;m!==s;m+=r)for(u=a;u!==l;u+=o,h+=2)p[(u+f*m)*4+0]=c[h+0],p[(u+f*m)*4+1]=c[h+0],p[(u+f*m)*4+2]=c[h+0],p[(u+f*m)*4+3]=c[h+1];return p}var SG,AG,RG,IG,xG,CG,bG,MG,yG,DG,LG,PG,VG,jC=A(()=>{ze();SG=1,AG=2,RG=3,IG=9,xG=10,CG=11,bG=48,MG=4,yG=0,DG=1,LG=2,PG=3;VG={GetTGAHeader:Wh,UploadContent:Dg,_getImageData8bits:OG,_getImageData16bits:NG,_getImageData24bits:FG,_getImageData32bits:wG,_getImageDataGrey8bits:BG,_getImageDataGrey16bits:UG}});var ZC={};De(ZC,{_TGATextureLoader:()=>Lg});var Lg,qC=A(()=>{jC();Lg=class{constructor(){this.supportCascades=!1}loadCubeData(){throw".env not supported in Cube."}loadData(e,t,i){let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s=Wh(r);i(s.width,s.height,t.generateMipMaps,!1,()=>{Dg(t,r)})}}});var pf=A(()=>{});function kG(){let n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),i=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let c=l-127;c<-27?(i[l]=0,i[l|256]=32768,r[l]=24,r[l|256]=24):c<-14?(i[l]=1024>>-c-14,i[l|256]=1024>>-c-14|32768,r[l]=-c-1,r[l|256]=-c-1):c<=15?(i[l]=c+15<<10,i[l|256]=c+15<<10|32768,r[l]=13,r[l|256]=13):c<128?(i[l]=31744,i[l|256]=64512,r[l]=24,r[l|256]=24):(i[l]=31744,i[l|256]=64512,r[l]=13,r[l|256]=13)}let s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,f=0;for(;(c&8388608)===0;)c<<=1,f-=8388608;c&=-8388609,f+=947912704,s[l]=c|f}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function Xh(n,e){let t=new Uint8Array(n),i=0;for(;t[e.value+i]!=0;)i+=1;let r=new TextDecoder().decode(t.slice(e.value,e.value+i));return e.value=e.value+i+1,r}function _n(n,e){let t=n.getInt32(e.value,!0);return e.value+=4,t}function Tr(n,e){let t=n.getUint32(e.value,!0);return e.value+=4,t}function _f(n,e){let t=n.getUint8(e.value);return e.value+=1,t}function Rl(n,e){let t=n.getUint16(e.value,!0);return e.value+=2,t}function Og(n,e){let t=n[e.value];return e.value+=1,t}function $C(n,e){let t;return"getBigInt64"in DataView.prototype?t=Number(n.getBigInt64(e.value,!0)):t=n.getUint32(e.value+4,!0)+Number(n.getUint32(e.value,!0)<<32),e.value+=8,t}function xi(n,e){let t=n.getFloat32(e.value,!0);return e.value+=4,t}function eb(n,e){return WG(Rl(n,e))}function WG(n){let e=(n&31744)>>10,t=n&1023;return(n>>15?-1:1)*(e?e===31?t?NaN:1/0:Math.pow(2,e-15)*(1+t/1024):6103515625e-14*(t/1024))}function HG(n){if(Math.abs(n)>65504)throw new Error("Value out of range.Consider using float instead of half-float.");n=Ke(n,-65504,65504),Hh.floatView[0]=n;let e=Hh.uint32View[0],t=e>>23&511;return Hh.baseTable[t]+((e&8388607)>>Hh.shiftTable[t])}function tb(n,e){return HG(xi(n,e))}function zG(n,e,t){let i=new TextDecoder().decode(new Uint8Array(n).slice(e.value,e.value+t));return e.value=e.value+t,i}function XG(n,e){let t=_n(n,e),i=Tr(n,e);return[t,i]}function YG(n,e){let t=Tr(n,e),i=Tr(n,e);return[t,i]}function KG(n,e){let t=xi(n,e),i=xi(n,e);return[t,i]}function jG(n,e){let t=xi(n,e),i=xi(n,e),r=xi(n,e);return[t,i,r]}function ZG(n,e,t){let i=e.value,r=[];for(;e.values||(e[r++]=n[t++],r>s));)e[r++]=n[i++]}var Un,Pg,Hh,gf=A(()=>{Mi();pf();(function(n){n[n.NO_COMPRESSION=0]="NO_COMPRESSION",n[n.RLE_COMPRESSION=1]="RLE_COMPRESSION",n[n.ZIPS_COMPRESSION=2]="ZIPS_COMPRESSION",n[n.ZIP_COMPRESSION=3]="ZIP_COMPRESSION",n[n.PIZ_COMPRESSION=4]="PIZ_COMPRESSION",n[n.PXR24_COMPRESSION=5]="PXR24_COMPRESSION"})(Un||(Un={}));(function(n){n[n.INCREASING_Y=0]="INCREASING_Y",n[n.DECREASING_Y=1]="DECREASING_Y"})(Pg||(Pg={}));Hh=kG()});function wg(n,e){if(n.getUint32(0,!0)!=ek)throw new Error("Incorrect OpenEXR format");let t=n.getUint8(4),i=n.getUint8(5),r={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)};e.value=8;let s={},a=!0;for(;a;){let o=Xh(n.buffer,e);if(!o)a=!1;else{let l=Xh(n.buffer,e),c=Tr(n,e),f=ib(n,e,l,c);f===void 0?W.Warn(`Unknown header attribute type ${l}'.`):s[o]=f}}if((i&-5)!=0)throw new Error("Unsupported file format");return{version:t,spec:r,...s}}var ek,rb=A(()=>{ze();gf();ek=20000630});function db(n,e){let t=0;for(let r=0;r<65536;++r)(r==0||n[r>>3]&1<<(r&7))&&(e[t++]=r);let i=t-1;for(;t<65536;)e[t++]=0;return i}function nk(n){for(let e=0;e<16384;e++)n[e]={},n[e].len=0,n[e].lit=0,n[e].p=null}function ob(n,e,t,i,r){for(;t>t&(1<>i;if(c=new Uint8Array([c])[0],o.value+c>l)return null;let f=a[o.value-1];for(;c-- >0;)a[o.value++]=f}else if(o.value0;--t){let i=e+Ef[t]>>1;Ef[t]=e,e=i}for(let t=0;t<65537;++t){let i=n[t];i>0&&(n[t]=i|Ef[i]++<<6)}}function ak(n,e,t,i,r,s){let a=e,o=0,l=0;for(;i<=r;i++){if(a.value-e.value>t)return;let c=ob(6,o,l,n,a),f=c.l;if(o=c.c,l=c.lc,s[i]=f,f==63){if(a.value-e.value>t)throw new Error("Error in HufUnpackEncTable");c=ob(8,o,l,n,a);let d=c.l+6;if(o=c.c,l=c.lc,i+d>r+1)throw new Error("Error in HufUnpackEncTable");for(;d--;)s[i++]=0;i--}else if(f>=59){let d=f-59+2;if(i+d>r+1)throw new Error("Error in HufUnpackEncTable");for(;d--;)s[i++]=0;i--}}sk(s)}function hb(n){return n&63}function ub(n){return n>>6}function ok(n,e,t,i){for(;e<=t;e++){let r=ub(n[e]),s=hb(n[e]);if(r>>s)throw new Error("Invalid table entry");if(s>14){let a=i[r>>s-14];if(a.len)throw new Error("Invalid table entry");if(a.lit++,a.p){let o=a.p;a.p=new Array(a.lit);for(let l=0;l0;o--){let l=i[(r<<14-s)+a];if(l.len||l.p)throw new Error("Invalid table entry");l.len=s,l.lit=e,a++}}}return!0}function lk(n,e,t,i,r,s,a,o,l){let c=0,f=0,d=a,h=Math.trunc(i.value+(r+7)/8);for(;i.value=14;){let p=c>>f-14&16383,_=e[p];if(_.len){f-=_.len;let g=Bg(_.lit,s,c,f,t,i,o,l,d);g&&(c=g.c,f=g.lc)}else{if(!_.p)throw new Error("hufDecode issues");let g;for(g=0;g<_.lit;g++){let T=hb(n[_.p[g]]);for(;f=T&&ub(n[_.p[g]])==(c>>f-T&(1<>=u,f-=u;f>0;){let m=e[c<<14-f&16383];if(m.len){f-=m.len;let p=Bg(m.lit,s,c,f,t,i,o,l,d);p&&(c=p.c,f=p.lc)}else throw new Error("HufDecode issues")}return!0}function mb(n,e,t,i,r,s){let a={value:0},o=t.value,l=Tr(e,t),c=Tr(e,t);t.value+=4;let f=Tr(e,t);if(t.value+=4,l<0||l>=65537||c<0||c>=65537)throw new Error("Wrong HUF_ENCSIZE");let d=new Array(65537),h=new Array(16384);nk(h);let u=i-(t.value-o);if(ak(n,t,u,l,c,d),f>8*(i-(t.value-o)))throw new Error("Wrong hufUncompress");ok(d,l,c,h),lk(d,h,n,t,f,c,s,r,a)}function Vg(n){return n&65535}function lb(n){let e=Vg(n);return e>32767?e-65536:e}function Il(n,e){let t=lb(n),r=lb(e),s=t+(r&1)+(r>>1),a=s,o=s-r;return{a,b:o}}function xl(n,e){let t=Vg(n),i=Vg(e),r=t-(i>>1)&ab;return{a:i+r-rk&ab,b:r}}function pb(n,e,t,i,r,s,a){let o=a<16384,l=t>r?r:t,c=1,f,d;for(;c<=l;)c<<=1;for(c>>=1,f=c,c>>=1;c>=1;){d=0;let h=d+s*(r-f),u=s*c,m=s*f,p=i*c,_=i*f,g,T,b,R;for(;d<=h;d+=m){let S=d,I=d+i*(t-f);for(;S<=I;S+=_){let x=S+p,P=S+u,L=P+p;if(o){let y=Il(n[S+e],n[P+e]);g=y.a,b=y.b,y=Il(n[x+e],n[L+e]),T=y.a,R=y.b,y=Il(g,T),n[S+e]=y.a,n[x+e]=y.b,y=Il(b,R),n[P+e]=y.a,n[L+e]=y.b}else{let y=xl(n[S+e],n[P+e]);g=y.a,b=y.b,y=xl(n[x+e],n[L+e]),T=y.a,R=y.b,y=xl(g,T),n[S+e]=y.a,n[x+e]=y.b,y=xl(b,R),n[P+e]=y.a,n[L+e]=y.b}}if(t&c){let x=S+u,P;o?P=Il(n[S+e],n[x+e]):P=xl(n[S+e],n[x+e]),g=P.a,n[x+e]=P.b,n[S+e]=g}}if(r&c){let S=d,I=d+i*(t-f);for(;S<=I;S+=_){let x=S+p,P;o?P=Il(n[S+e],n[x+e]):P=xl(n[S+e],n[x+e]),g=P.a,n[x+e]=P.b,n[S+e]=g}}f=c,c>>=1}return d}function _b(n,e,t){for(let i=0;i{gf();pf();fb=16,rk=1<0;){let s=r.getInt8(i++);if(s<0){let a=-s;e-=a+1;for(let o=0;o{});function Gg(n){return new DataView(n.array.buffer,n.offset.value,n.size)}function Sb(n){let e=n.viewer.buffer.slice(n.offset.value,n.offset.value+n.size),t=new Uint8Array(Eb(e)),i=new Uint8Array(t.length);return Ng(t),Fg(t,i),new DataView(i.buffer)}function kg(n){let e=n.array.slice(n.offset.value,n.offset.value+n.size),t=fflate.unzlibSync(e),i=new Uint8Array(t.length);return Ng(t),Fg(t,i),new DataView(i.buffer)}function Ab(n){let e=n.array.slice(n.offset.value,n.offset.value+n.size),t=fflate.unzlibSync(e),i=n.lines*n.channels*n.width,r=n.type==1?new Uint16Array(i):new Uint32Array(i),s=0,a=0,o=new Array(4);for(let l=0;l=8192)throw new Error("Wrong PIZ_COMPRESSION BITMAP_SIZE");if(o<=l)for(let m=0;m{gb();vb();gf();pf()});var Hr,Vn,Wg=A(()=>{(function(n){n[n.Float=0]="Float",n[n.HalfFloat=1]="HalfFloat"})(Hr||(Hr={}));Vn=class{};Vn.DefaultOutputType=Hr.HalfFloat;Vn.FFLATEUrl="https://unpkg.com/fflate@0.8.2"});async function Hg(n,e,t,i){let r={size:0,viewer:e,array:new Uint8Array(e.buffer),offset:t,width:n.dataWindow.xMax-n.dataWindow.xMin+1,height:n.dataWindow.yMax-n.dataWindow.yMin+1,channels:n.channels.length,channelLineOffsets:{},scanOrder:()=>0,bytesPerLine:0,outLineWidth:0,lines:0,scanlineBlockSize:0,inputSize:null,type:0,uncompress:null,getter:()=>0,format:5,outputChannels:0,decodeChannels:{},blockCount:null,byteArray:null,linearSpace:!1,textureType:0};switch(n.compression){case Un.NO_COMPRESSION:r.lines=1,r.uncompress=Gg;break;case Un.RLE_COMPRESSION:r.lines=1,r.uncompress=Sb;break;case Un.ZIPS_COMPRESSION:r.lines=1,r.uncompress=kg,await re.LoadScriptAsync(Vn.FFLATEUrl);break;case Un.ZIP_COMPRESSION:r.lines=16,r.uncompress=kg,await re.LoadScriptAsync(Vn.FFLATEUrl);break;case Un.PIZ_COMPRESSION:r.lines=32,r.uncompress=Rb;break;case Un.PXR24_COMPRESSION:r.lines=16,r.uncompress=Ab,await re.LoadScriptAsync(Vn.FFLATEUrl);break;default:throw new Error(Un[n.compression]+" is unsupported")}r.scanlineBlockSize=r.lines;let s={};for(let c of n.channels)switch(c.name){case"R":case"G":case"B":case"A":s[c.name]=!0,r.type=c.pixelType;break;case"Y":s[c.name]=!0,r.type=c.pixelType;break;default:break}let a=!1;if(s.R&&s.G&&s.B&&s.A)r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(s.R&&s.G&&s.B)a=!0,r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(s.R&&s.G)r.outputChannels=2,r.decodeChannels={R:0,G:1};else if(s.R)r.outputChannels=1,r.decodeChannels={R:0};else if(s.Y)r.outputChannels=1,r.decodeChannels={Y:0};else throw new Error("EXRLoader.parse: file contains unsupported data channels.");if(r.type===1)switch(i){case Hr.Float:r.getter=eb,r.inputSize=2;break;case Hr.HalfFloat:r.getter=Rl,r.inputSize=2;break}else if(r.type===2)switch(i){case Hr.Float:r.getter=xi,r.inputSize=4;break;case Hr.HalfFloat:r.getter=tb,r.inputSize=4}else throw new Error("Unsupported pixelType "+r.type+" for "+n.compression);r.blockCount=r.height/r.scanlineBlockSize;for(let c=0;cc:r.scanOrder=c=>r.height-1-c,r.outputChannels==4?(r.format=5,r.linearSpace=!0):(r.format=6,r.linearSpace=!1),r}function zg(n,e,t,i){let r={value:0};for(let s=0;sn.height?n.height-a:n.scanlineBlockSize;let l=n.size=n.height)continue;let h=c*n.bytesPerLine,u=(n.height-1-d)*n.outLineWidth;for(let m=0;m{gf();Ib();pf();Tt();Wg()});var Cb={};De(Cb,{ReadExrDataAsync:()=>ck,_ExrTextureLoader:()=>Xg});async function ck(n){let e=new DataView(n),t={value:0},i=wg(e,t);try{let r=await Hg(i,e,t,Hr.Float);return zg(r,i,e,t),r.byteArray?{width:i.dataWindow.xMax-i.dataWindow.xMin+1,height:i.dataWindow.yMax-i.dataWindow.yMin+1,data:new Float32Array(r.byteArray)}:(W.Error("Failed to decode EXR data: No byte array available."),{width:0,height:0,data:null})}catch(r){W.Error("Failed to load EXR data: ",r)}return{width:0,height:0,data:null}}var Xg,bb=A(()=>{rb();xb();Wg();ze();Xg=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,s){throw".exr not supported in Cube."}loadData(e,t,i){let r=new DataView(e.buffer),s={value:0},a=wg(r,s);Hg(a,r,s,Vn.DefaultOutputType).then(o=>{zg(o,a,r,s);let l=a.dataWindow.xMax-a.dataWindow.xMin+1,c=a.dataWindow.yMax-a.dataWindow.yMin+1;i(l,c,t.generateMipMaps,!1,()=>{let f=t.getEngine();t.format=a.format,t.type=o.textureType,t.invertY=!1,t._gammaSpace=!a.linearSpace,o.byteArray&&f._uploadDataToTextureDirectly(t,o.byteArray,0,0,void 0,!0)})}).catch(o=>{W.Error("Failed to load EXR texture: ",o)})}}});function Rs(n,e){fk(n)&&W.Warn(`Extension with the name '${n}' already exists`),Kh.set(n,e)}function fk(n){return Kh.delete(n)}function jh(n,e){(e==="image/ktx"||e==="image/ktx2")&&(n=".ktx"),Kh.has(n)||(n.endsWith(".ies")&&Rs(".ies",async()=>await Promise.resolve().then(()=>(Cx(),xx)).then(i=>new i._IESTextureLoader)),n.endsWith(".dds")&&Rs(".dds",async()=>await Promise.resolve().then(()=>(Mx(),bx)).then(i=>new i._DDSTextureLoader)),n.endsWith(".basis")&&Rs(".basis",async()=>await Promise.resolve().then(()=>(Nx(),Ox)).then(i=>new i._BasisTextureLoader)),n.endsWith(".env")&&Rs(".env",async()=>await Promise.resolve().then(()=>(LC(),DC)).then(i=>new i._ENVTextureLoader)),n.endsWith(".hdr")&&Rs(".hdr",async()=>await Promise.resolve().then(()=>(UC(),BC)).then(i=>new i._HDRTextureLoader)),(n.endsWith(".ktx")||n.endsWith(".ktx2"))&&(Rs(".ktx",async()=>await Promise.resolve().then(()=>(yg(),Mg)).then(i=>new i._KTXTextureLoader)),Rs(".ktx2",async()=>await Promise.resolve().then(()=>(yg(),Mg)).then(i=>new i._KTXTextureLoader))),n.endsWith(".tga")&&Rs(".tga",async()=>await Promise.resolve().then(()=>(qC(),ZC)).then(i=>new i._TGATextureLoader)),n.endsWith(".exr")&&Rs(".exr",async()=>await Promise.resolve().then(()=>(bb(),Cb)).then(i=>new i._ExrTextureLoader)));let t=Kh.get(n);return t?Promise.resolve(t(e)):null}var Kh,Yg=A(()=>{ze();Kh=new Map});function Mb(n){let e=n.split("?")[0],t=e.lastIndexOf(".");return t>-1?e.substring(t).toLowerCase():""}var yb=A(()=>{});var Db=A(()=>{vr();ze();ds();Yc();ii();Yg();yb();fe.prototype._partialLoadFile=function(n,e,t,i,r=null){let s=o=>{t[e]=o,t._internalCount++,t._internalCount===6&&i(t)},a=(o,l)=>{r&&o&&r(o.status+" "+o.statusText,l)};this._loadFile(n,s,void 0,void 0,!0,a)};fe.prototype._cascadeLoadFiles=function(n,e,t,i=null){let r=[];r._internalCount=0;for(let s=0;s<6;s++)this._partialLoadFile(t[s],s,r,e,i)};fe.prototype._cascadeLoadImgs=function(n,e,t,i,r=null,s){let a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(i[o],o,a,n,e,t,r,s)};fe.prototype._partialLoadImg=function(n,e,t,i,r,s,a=null,o){let l=la();El(n,d=>{t[e]=d,t._internalCount++,i&&i.removePendingData(l),t._internalCount===6&&s&&s(r,t)},(d,h)=>{i&&i.removePendingData(l),a&&a(d,h)},i?i.offlineProvider:null,o),i&&i.addPendingData(l)};fe.prototype.createCubeTextureBase=function(n,e,t,i,r=null,s=null,a,o=null,l=!1,c=0,f=0,d=null,h=null,u=null,m=!1,p=null){let _=d||new bt(this,7);_.isCube=!0,_.url=n,_.generateMipMaps=!i,_._lodGenerationScale=c,_._lodGenerationOffset=f,_._useSRGBBuffer=!!m&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!i),_!==d&&(_.label=n.substring(0,60)),this._doNotHandleContextLost||(_._extension=o,_._files=t,_._buffer=p);let g=n;this._transformTextureUrl&&!d&&(n=this._transformTextureUrl(n));let T=o!=null?o:Mb(n),b=jh(T),R=(I,x)=>{_.dispose(),s?s(I,x):I&&W.Warn(I)},S=(I,x)=>{n===g?I&&R(I.status+" "+I.statusText,x):(W.Warn(`Failed to load ${n}, falling back to the ${g}`),this.createCubeTextureBase(g,e,t,!!i,r,R,a,o,l,c,f,_,h,u,m,p))};if(b)b.then(I=>{let x=P=>{h&&h(_,P),I.loadCubeData(P,_,l,r,(L,y)=>{R(L,y)})};p?x(p):t&&t.length===6?I.supportCascades?this._cascadeLoadFiles(e,P=>x(P.map(L=>new Uint8Array(L))),t,R):R("Textures type does not support cascades."):this._loadFile(n,P=>x(new Uint8Array(P)),void 0,e?e.offlineProvider||null:void 0,!0,S)});else{if(!t||t.length===0)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(e,_,(I,x)=>{u&&u(I,x)},t,R)}return this._internalTexturesCache.push(_),_}});var Kb={};De(Kb,{DDSTools:()=>fn});function Zh(n){return n.charCodeAt(0)+(n.charCodeAt(1)<<8)+(n.charCodeAt(2)<<16)+(n.charCodeAt(3)<<24)}function hk(n){return String.fromCharCode(n&255,n>>8&255,n>>16&255,n>>24&255)}var dk,Lb,Pb,Ob,Nb,Fb,wb,Bb,Ub,Kg,Vb,Gb,kb,Wb,uk,jg,mk,pk,Hb,zb,Zg,Xb,qg,Yb,_k,gk,Ek,vk,Tk,Sk,Ak,fn,eg=A(()=>{Mi();ze();M_();Z_();Db();dk=542327876,Lb=131072,Pb=512,Ob=4,Nb=64,Fb=131072;wb=Zh("DXT1"),Bb=Zh("DXT3"),Ub=Zh("DXT5"),Kg=Zh("DX10"),Vb=113,Gb=116,kb=2,Wb=10,uk=88,jg=31,mk=0,pk=1,Hb=2,zb=3,Zg=4,Xb=7,qg=20,Yb=21,_k=22,gk=23,Ek=24,vk=25,Tk=26,Sk=28,Ak=32,fn=class n{static GetDDSInfo(e){let t=new Int32Array(e.buffer,e.byteOffset,jg),i=new Int32Array(e.buffer,e.byteOffset,jg+4),r=1;t[Hb]&Lb&&(r=Math.max(1,t[Xb]));let s=t[Yb],a=s===Kg?i[Ak]:0,o=0;switch(s){case Vb:o=2;break;case Gb:o=1;break;case Kg:if(a===Wb){o=2;break}if(a===kb){o=1;break}}return{width:t[Zg],height:t[zb],mipmapCount:r,isFourCC:(t[qg]&Ob)===Ob,isRGB:(t[qg]&Nb)===Nb,isLuminance:(t[qg]&Fb)===Fb,isCube:(t[Sk]&Pb)===Pb,isCompressed:s===wb||s===Bb||s===Ub,dxgiFormat:a,textureType:o}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,i,r,s,a){let o=new Float32Array(r),l=new Uint16Array(s,i),c=0;for(let f=0;f>8)}static _GetRGBArrayBuffer(e,t,i,r,s,a,o,l){let c=new Uint8Array(r),f=new Uint8Array(s,i),d=0;for(let h=0;h0?r.sphericalPolynomial=hs.ConvertCubeMapToSphericalPolynomial({size:h[Zg],right:f[0],left:f[1],up:f[2],down:f[3],front:f[4],back:f[5],format:5,type:1,gammaSpace:!1}):r.sphericalPolynomial=void 0}};fn.StoreLODInAlphaChannel=!1});var jb=A(()=>{er();vr();ze();Xc();qc();We.prototype.createPrefilteredCubeTexture=function(n,e,t,i,r=null,s=null,a,o=null,l=!0){let c=async f=>{var g;if(!f){r&&r(null);return}let d=f.texture;if(l?f.info.sphericalPolynomial&&(d._sphericalPolynomial=f.info.sphericalPolynomial):d._sphericalPolynomial=(g=d._sphericalPolynomial)!=null?g:new On,d._source=9,this.getCaps().textureLOD){r&&r(d);return}let h=3,u=this._gl,m=f.width;if(!m)return;let{DDSTools:p}=await Promise.resolve().then(()=>(eg(),Kb)),_=[];for(let T=0;T{er();$d();We.prototype.createUniformBuffer=function(n,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");let i=new yn(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};We.prototype.createDynamicUniformBuffer=function(n,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");let i=new yn(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};We.prototype.updateUniformBuffer=function(n,e,t,i){this.bindUniformBuffer(n),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(n){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,n?n.underlyingResource:null)};We.prototype.bindUniformBufferBase=function(n,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,n?n.underlyingResource:null)};We.prototype.bindUniformBlock=function(n,e,t){let i=n.program,r=this._gl.getUniformBlockIndex(i,e);r!==4294967295&&this._gl.uniformBlockBinding(i,r,t)}});var qb=A(()=>{Lr();ii();fe.prototype.displayLoadingUI=function(){if(!Bt())return;let n=this.loadingScreen;n&&n.displayLoadingUI()};fe.prototype.hideLoadingUI=function(){if(!Bt())return;let n=this._loadingScreen;n&&n.hideLoadingUI()};Object.defineProperty(fe.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=fe.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(n){this._loadingScreen=n},enumerable:!0,configurable:!0});Object.defineProperty(fe.prototype,"loadingUIText",{set:function(n){this.loadingScreen.loadingUIText=n},enumerable:!0,configurable:!0});Object.defineProperty(fe.prototype,"loadingUIBackgroundColor",{set:function(n){this.loadingScreen.loadingUIBackgroundColor=n},enumerable:!0,configurable:!0})});var Qb=A(()=>{ii();fe.prototype.getInputElement=function(){return this._renderingCanvas};fe.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};fe.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};fe.prototype.getAspectRatio=function(n,e=!1){let t=n.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};fe.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};fe.prototype._verifyPointerLock=function(){var n;(n=this._onPointerLockChange)==null||n.call(this)}});var Qg=A(()=>{ii();fe.prototype.setAlphaEquation=function(n,e=0){if(this._alphaEquation[e]!==n){switch(n){case 0:this._alphaState.setAlphaEquationParameters(32774,32774,e);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778,e);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779,e);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776,e);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775,e);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774,e);break}this._alphaEquation[e]=n}}});var Jb=A(()=>{ii();Qg();fe.prototype.getInputElement=function(){return this._renderingCanvas};fe.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};fe.prototype.setDepthFunction=function(n){this._depthCullingState.depthFunc=n};fe.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};fe.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};fe.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};fe.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};fe.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};fe.prototype.setDepthWrite=function(n){this._depthCullingState.depthMask=n};fe.prototype.setAlphaConstants=function(n,e,t,i){this._alphaState.setAlphaBlendConstants(n,e,t,i)};fe.prototype.getAlphaMode=function(n=0){return this._alphaMode[n]};fe.prototype.getAlphaEquation=function(n=0){return this._alphaEquation[n]}});var $b=A(()=>{ii();Qg();fe.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};fe.prototype.setStencilBuffer=function(n){this._stencilState.stencilTest=n};fe.prototype.getStencilMask=function(){return this._stencilState.stencilMask};fe.prototype.setStencilMask=function(n){this._stencilState.stencilMask=n};fe.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};fe.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};fe.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};fe.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};fe.prototype.setStencilFunction=function(n){this._stencilState.stencilFunc=n};fe.prototype.setStencilBackFunction=function(n){this._stencilState.stencilBackFunc=n};fe.prototype.setStencilFunctionReference=function(n){this._stencilState.stencilFuncRef=n};fe.prototype.setStencilFunctionMask=function(n){this._stencilState.stencilFuncMask=n};fe.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};fe.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};fe.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};fe.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};fe.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};fe.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};fe.prototype.setStencilOperationFail=function(n){this._stencilState.stencilOpStencilFail=n};fe.prototype.setStencilBackOperationFail=function(n){this._stencilState.stencilBackOpStencilFail=n};fe.prototype.setStencilOperationDepthFail=function(n){this._stencilState.stencilOpDepthFail=n};fe.prototype.setStencilBackOperationDepthFail=function(n){this._stencilState.stencilBackOpDepthFail=n};fe.prototype.setStencilOperationPass=function(n){this._stencilState.stencilOpStencilDepthPass=n};fe.prototype.setStencilBackOperationPass=function(n){this._stencilState.stencilBackOpStencilDepthPass=n};fe.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()};fe.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)}});var eM=A(()=>{ii();fe.prototype.getRenderPassNames=function(){return this._renderPassNames};fe.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};fe.prototype.createRenderPassId=function(n){let e=++fe._RenderPassIdCounter;return this._renderPassNames[e]=n!=null?n:"NONAME",e};fe.prototype.releaseRenderPassId=function(n){this._renderPassNames[n]=void 0;for(let e=0;e{ii();fe.prototype._loadFileAsync=async function(n,e,t){return await new Promise((i,r)=>{this._loadFile(n,s=>{i(s)},void 0,e,t,(s,a)=>{r(a)})})}});var iM=A(()=>{Yg();ii();fe.GetCompatibleTextureLoader=jh});function Rk(n){!n||!n.setAttribute||(n.setAttribute("touch-action","none"),n.style.touchAction="none",n.style.webkitTapHighlightColor="transparent")}function rM(n,e,t){n._onCanvasFocus=()=>{n.onCanvasFocusObservable.notifyObservers(n)},n._onCanvasBlur=()=>{n.onCanvasBlurObservable.notifyObservers(n)},n._onCanvasContextMenu=r=>{n.disableContextMenu&&r.preventDefault()},e.addEventListener("focus",n._onCanvasFocus),e.addEventListener("blur",n._onCanvasBlur),e.addEventListener("contextmenu",n._onCanvasContextMenu),n._onBlur=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.disable(),n._windowIsBackground=!0},n._onFocus=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.enable(),n._windowIsBackground=!1},n._onCanvasPointerOut=r=>{document.elementFromPoint(r.clientX,r.clientY)!==e&&n.onCanvasPointerOutObservable.notifyObservers(r)};let i=n.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",n._onBlur),i.addEventListener("focus",n._onFocus)),e.addEventListener("pointerout",n._onCanvasPointerOut),t.doNotHandleTouchAction||Rk(e),!fe.audioEngine&&t.audioEngine&&fe.AudioEngineFactory&&(fe.audioEngine=fe.AudioEngineFactory(n.getRenderingCanvas(),n.getAudioContext(),n.getAudioDestination())),sa()&&(n._onFullscreenChange=()=>{n.isFullscreen=!!document.fullscreenElement,n.isFullscreen&&n._pointerLockRequested&&e&&Jg(e)},document.addEventListener("fullscreenchange",n._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",n._onFullscreenChange,!1),n._onPointerLockChange=()=>{n.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",n._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",n._onPointerLockChange,!1)),n.enableOfflineSupport=fe.OfflineProviderFactory!==void 0,n._deterministicLockstep=!!t.deterministicLockstep,n._lockstepMaxSteps=t.lockstepMaxSteps||0,n._timeStep=t.timeStep||1/60}function nM(n,e){ue.Instances.length===1&&fe.audioEngine&&(fe.audioEngine.dispose(),fe.audioEngine=null);let t=n.getHostWindow();t&&typeof t.removeEventListener=="function"&&(t.removeEventListener("blur",n._onBlur),t.removeEventListener("focus",n._onFocus)),e&&(e.removeEventListener("focus",n._onCanvasFocus),e.removeEventListener("blur",n._onCanvasBlur),e.removeEventListener("pointerout",n._onCanvasPointerOut),e.removeEventListener("contextmenu",n._onCanvasContextMenu)),sa()&&(document.removeEventListener("fullscreenchange",n._onFullscreenChange),document.removeEventListener("mozfullscreenchange",n._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",n._onFullscreenChange),document.removeEventListener("msfullscreenchange",n._onFullscreenChange),document.removeEventListener("pointerlockchange",n._onPointerLockChange),document.removeEventListener("mspointerlockchange",n._onPointerLockChange),document.removeEventListener("mozpointerlockchange",n._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",n._onPointerLockChange))}function sM(n){let e=document.createElement("span");e.textContent="Hg",e.style.font=n;let t=document.createElement("div");t.style.display="inline-block",t.style.width="1px",t.style.height="0px",t.style.verticalAlign="bottom";let i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(e),i.appendChild(t),document.body.appendChild(i);let r,s;try{s=t.getBoundingClientRect().top-e.getBoundingClientRect().top,t.style.verticalAlign="baseline",r=t.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:r,height:s,descent:s-r}}async function aM(n,e,t){return await new Promise((i,r)=>{let s=new Image;s.onload=()=>{s.decode().then(()=>{n.createImageBitmap(s,t).then(a=>{i(a)})})},s.onerror=()=>{r(`Error loading image ${s.src}`)},s.src=e})}function oM(n,e,t,i){let s=n.createCanvas(t,i).getContext("2d");if(!s)throw new Error("Unable to get 2d context for resizeImageBitmap");return s.drawImage(e,0,0),s.getImageData(0,0,t,i).data}function lM(n){let e=n.requestFullscreen||n.webkitRequestFullscreen;e&&e.call(n)}function cM(){let n=document;document.exitFullscreen?document.exitFullscreen():n.webkitCancelFullScreen&&n.webkitCancelFullScreen()}function Jg(n){if(n.requestPointerLock){let e=n.requestPointerLock();e instanceof Promise?e.then(()=>{n.focus()}).catch(()=>{}):n.focus()}}function fM(){document.exitPointerLock&&document.exitPointerLock()}var dM=A(()=>{Lr();ii();At()});var Ee,$g=A(()=>{vr();At();er();lI();$d();ze();m_();cI();uI();mI();pI();_I();vI();TI();SI();jb();Zb();qb();Qb();Jb();$b();eM();E_();tM();iM();ii();dM();dg();Mn();Ee=class n extends We{static get NpmPackage(){return fe.NpmPackage}static get Version(){return fe.Version}static get Instances(){return ue.Instances}static get LastCreatedEngine(){return ue.LastCreatedEngine}static get LastCreatedScene(){return ue.LastCreatedScene}static DefaultLoadingScreenFactory(e){return fe.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!n._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,r=!1){super(e,t,i,r),this.customAnimationFrameRequester=null,this._performanceMonitor=new th,this._drawCalls=new Bn,e&&(this._features.supportRenderPasses=!0)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),rM(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return oM(this,e,t,i)}async _createImageBitmapFromSource(e,t){return await aM(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&lM(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&cM()}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,r){let s=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),s}scissorClear(e,t,i,r,s){this.enableScissor(e,t,i,r),this.clear(s,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,r){let s=this._gl;s.enable(s.SCISSOR_TEST),s.scissor(e,t,i,r)}disableScissor(){let e=this._gl;e.disable(e.SCISSOR_TEST)}getVertexShaderSource(e){let t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){let 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(let e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(let e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return sM(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;let{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&Jg(this._renderingCanvas)}exitPointerlock(){fM()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){let t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,i,r,s,a=null){s=s||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);let o=super.createShaderProgram(e,t,i,r,s,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,r,s=null){let a=r.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");if(r.attachShader(a,t),r.attachShader(a,i),this.webGLVersion>1&&s){let o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(a,s),e.transformFeedback=o}return r.linkProgram(a),this.webGLVersion>1&&s&&this.bindTransformFeedback(null),e.context=r,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),a}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e);for(let t of this.scenes){for(let i of t.postProcesses)i._outputTexture===e&&(i._outputTexture=null);for(let i of t.cameras)for(let r of i._postProcesses)r&&r._outputTexture===e&&(r._outputTexture=null)}}_rescaleTexture(e,t,i,r,s){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);let a=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&n._RescalePostProcessFactory&&(this._rescalePostProcess=n._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;let o=()=>{this._rescalePostProcess.onApply=function(f){f._bindTexture("textureSampler",e)};let c=i;c||(c=this.scenes[this.scenes.length-1]),c.postProcessManager.directRender([this._rescalePostProcess],a,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,r,0,0,t.width,t.height,0),this.unBindFramebuffer(a),a.dispose(),s&&s()},l=this._rescalePostProcess.getEffect();l?l.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(c=>{c.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,r=0,s=0){let a=new tl(e,this._gl),o=new bt(this,0,!0);return o._hardwareTexture=a,o.baseWidth=r,o.baseHeight=s,o.width=r,o.height=s,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,r=0){let s=this._gl,a=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),l=this._getRGBABufferInternalSizedFormat(e.type,o),c=e.isCube?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);let f=s.TEXTURE_2D;e.isCube&&(f=s.TEXTURE_CUBE_MAP_POSITIVE_X+i),s.texImage2D(f,r,l,o,a,t),this._bindTextureDirectly(c,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){W.Error("WebGL 1 does not support texture comparison.");return}let 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){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");let i=new yn(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,t=0,i=10){let r=this._gl;return await new Promise((s,a)=>{bn(()=>{let o=r.clientWaitSync(e,t,0);if(o==r.WAIT_FAILED)throw new Error("clientWaitSync failed");return o!=r.TIMEOUT_EXPIRED},s,a,i)})}_readPixelsAsync(e,t,i,r,s,a,o){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");let l=this._gl,c=l.createBuffer();l.bindBuffer(l.PIXEL_PACK_BUFFER,c),l.bufferData(l.PIXEL_PACK_BUFFER,o.byteLength,l.STREAM_READ),l.readPixels(e,t,i,r,s,a,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null);let f=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);return f?(l.flush(),this._clientWaitAsync(f,0,10).then(()=>(l.deleteSync(f),l.bindBuffer(l.PIXEL_PACK_BUFFER,c),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,o),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),l.deleteBuffer(c),o))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),nM(this,this._renderingCanvas),super.dispose()}};Ee.ALPHA_DISABLE=0;Ee.ALPHA_ADD=1;Ee.ALPHA_COMBINE=2;Ee.ALPHA_SUBTRACT=3;Ee.ALPHA_MULTIPLY=4;Ee.ALPHA_MAXIMIZED=5;Ee.ALPHA_ONEONE=6;Ee.ALPHA_PREMULTIPLIED=7;Ee.ALPHA_PREMULTIPLIED_PORTERDUFF=8;Ee.ALPHA_INTERPOLATE=9;Ee.ALPHA_SCREENMODE=10;Ee.DELAYLOADSTATE_NONE=0;Ee.DELAYLOADSTATE_LOADED=1;Ee.DELAYLOADSTATE_LOADING=2;Ee.DELAYLOADSTATE_NOTLOADED=4;Ee.NEVER=512;Ee.ALWAYS=519;Ee.LESS=513;Ee.EQUAL=514;Ee.LEQUAL=515;Ee.GREATER=516;Ee.GEQUAL=518;Ee.NOTEQUAL=517;Ee.KEEP=7680;Ee.REPLACE=7681;Ee.INCR=7682;Ee.DECR=7683;Ee.INVERT=5386;Ee.INCR_WRAP=34055;Ee.DECR_WRAP=34056;Ee.TEXTURE_CLAMP_ADDRESSMODE=0;Ee.TEXTURE_WRAP_ADDRESSMODE=1;Ee.TEXTURE_MIRROR_ADDRESSMODE=2;Ee.TEXTUREFORMAT_ALPHA=0;Ee.TEXTUREFORMAT_LUMINANCE=1;Ee.TEXTUREFORMAT_LUMINANCE_ALPHA=2;Ee.TEXTUREFORMAT_RGB=4;Ee.TEXTUREFORMAT_RGBA=5;Ee.TEXTUREFORMAT_RED=6;Ee.TEXTUREFORMAT_R=6;Ee.TEXTUREFORMAT_R16_UNORM=33322;Ee.TEXTUREFORMAT_RG16_UNORM=33324;Ee.TEXTUREFORMAT_RGB16_UNORM=32852;Ee.TEXTUREFORMAT_RGBA16_UNORM=32859;Ee.TEXTUREFORMAT_R16_SNORM=36760;Ee.TEXTUREFORMAT_RG16_SNORM=36761;Ee.TEXTUREFORMAT_RGB16_SNORM=36762;Ee.TEXTUREFORMAT_RGBA16_SNORM=36763;Ee.TEXTUREFORMAT_RG=7;Ee.TEXTUREFORMAT_RED_INTEGER=8;Ee.TEXTUREFORMAT_R_INTEGER=8;Ee.TEXTUREFORMAT_RG_INTEGER=9;Ee.TEXTUREFORMAT_RGB_INTEGER=10;Ee.TEXTUREFORMAT_RGBA_INTEGER=11;Ee.TEXTURETYPE_UNSIGNED_BYTE=0;Ee.TEXTURETYPE_UNSIGNED_INT=0;Ee.TEXTURETYPE_FLOAT=1;Ee.TEXTURETYPE_HALF_FLOAT=2;Ee.TEXTURETYPE_BYTE=3;Ee.TEXTURETYPE_SHORT=4;Ee.TEXTURETYPE_UNSIGNED_SHORT=5;Ee.TEXTURETYPE_INT=6;Ee.TEXTURETYPE_UNSIGNED_INTEGER=7;Ee.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;Ee.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;Ee.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;Ee.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;Ee.TEXTURETYPE_UNSIGNED_INT_24_8=12;Ee.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;Ee.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;Ee.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;Ee.TEXTURE_NEAREST_SAMPLINGMODE=1;Ee.TEXTURE_BILINEAR_SAMPLINGMODE=2;Ee.TEXTURE_TRILINEAR_SAMPLINGMODE=3;Ee.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;Ee.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;Ee.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;Ee.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;Ee.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;Ee.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;Ee.TEXTURE_NEAREST_LINEAR=7;Ee.TEXTURE_NEAREST_NEAREST=1;Ee.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;Ee.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;Ee.TEXTURE_LINEAR_LINEAR=2;Ee.TEXTURE_LINEAR_NEAREST=12;Ee.TEXTURE_EXPLICIT_MODE=0;Ee.TEXTURE_SPHERICAL_MODE=1;Ee.TEXTURE_PLANAR_MODE=2;Ee.TEXTURE_CUBIC_MODE=3;Ee.TEXTURE_PROJECTION_MODE=4;Ee.TEXTURE_SKYBOX_MODE=5;Ee.TEXTURE_INVCUBIC_MODE=6;Ee.TEXTURE_EQUIRECTANGULAR_MODE=7;Ee.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;Ee.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;Ee.SCALEMODE_FLOOR=1;Ee.SCALEMODE_NEAREST=2;Ee.SCALEMODE_CEILING=3});var eE,ht,Sr=A(()=>{Qe();ve();qe();ft();At();Ei();Kt();eE=class{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new Y,this._onClonedObservable=new Y,this._inheritVisibility=!1,this._isVisible=!0}},ht=class n{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,r){let s=this._NodeConstructors[e];return s?s(t,i,r):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;let t=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){let i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}get inheritVisibility(){return this._nodeDataStorage._inheritVisibility}set inheritVisibility(e){this._nodeDataStorage._inheritVisibility=e}get isVisible(){return this.inheritVisibility&&this._parentNode&&!this._parentNode.isVisible?!1:this._nodeDataStorage._isVisible}set isVisible(e){this._nodeDataStorage._isVisible=e}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){let 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 eE,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new Y,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=U.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new Y,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||ue.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(()=>{this._behaviors.includes(e)&&e.attach(this)}):e.attach(this),this._behaviors.push(e),this)}removeBehavior(e){let 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(let t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return this._parentNode?this._parentNode._isDirty||this._parentUpdateId!==this._parentNode._childUpdateId?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._parentNode&&!this.isSynchronizedWithParent()?!1:this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){if(this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children)for(let e of this._children)e._syncParentEnabledState()}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return this.parent?this.parent===e?!0:this.parent.isDescendantOf(e):!1}_getDescendants(e,t=!1,i){if(this._children)for(let r=0;r(!t||t(r))&&r.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;tnew n(e,this.getScene()),this);if(t&&(r.parent=t),!i){let s=this.getDescendants(!0);for(let a=0;a{throw Ie("AnimationRange")};ht._NodeConstructors={};C([D()],ht.prototype,"name",void 0);C([D()],ht.prototype,"id",void 0);C([D()],ht.prototype,"uniqueId",void 0);C([D()],ht.prototype,"state",void 0);C([D()],ht.prototype,"metadata",void 0)});function tE(n,e,t){try{let i=n.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function hM(n=25){let e;return(t,i,r)=>{let s=performance.now();e===void 0||s-e>n?(e=s,setTimeout(()=>{tE(t,i,r)},0)):tE(t,i,r)}}function uM(n,e,t,i,r){let s=()=>{let a,o=l=>{l.done?t(l.value):a===void 0?a=!0:s()};do a=void 0,!r||!r.aborted?e(n,o,i):i(new Error("Aborted")),a===void 0&&(a=!1);while(a)};s()}function Tf(n,e){let t;return uM(n,tE,i=>t=i,i=>{throw i},e),t}async function mM(n,e,t){return await new Promise((i,r)=>{uM(n,e,i,r,t)})}function pM(n,e){return(...t)=>Tf(n(...t),e)}var iE=A(()=>{});var Ue,Gn=A(()=>{Qe();qe();cn();Tt();ft();ve();Sr();ze();Lt();Ei();dl();ah();Kt();Ue=class n extends ht{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,r,s,a;let e,t;if(this.mode===n.PERSPECTIVE_CAMERA)this.fovMode===n.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{let o=this.getEngine().getRenderWidth()/2,l=this.getEngine().getRenderHeight()/2;e=((i=this.orthoRight)!=null?i:o)-((r=this.orthoLeft)!=null?r:-o),t=((s=this.orthoTop)!=null?s:l)-((a=this.orthoBottom)!=null?a:-l)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(let t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(let t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(let t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(let t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}setFocalLength(e,t=36){this.fov=2*Math.atan(t/(2*e))}set mode(e){this._mode=e;for(let t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,i,r=!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=n.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new an(0,0,1,1),this.layerMask=268435455,this.fovMode=n.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=n.RIG_MODE_NONE,this.ignoreCameraMaxZ=!1,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new Y,this.onProjectionMatrixChangedObservable=new Y,this.onAfterCheckInputsObservable=new Y,this.onRestoreStateObservable=new Y,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new U,this._postProcesses=new Array,this._activeMeshes=new Ct(256),this._globalPosition=v.Zero(),this._computedViewMatrix=U.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=U.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=Ae.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.layerMask=this.getScene().defaultCameraLayerMask,this.getScene().addCamera(this),r&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return this._stateStored?(this.fov=this._storedFov,!0):!1}restoreState(){return this._restoreStateValues()?(this.onRestoreStateObservable.notifyObservers(this),!0):!1}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let i=0;i-1?(W.Error("You're trying to reuse a post process not defined as reusable."),0):(t==null||t<0?this._postProcesses.push(e):this._postProcesses[t]===null?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){let 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 U.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.getTranslationToRef(this._globalPosition),this._computedViewMatrix)}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,e!==void 0&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){var a,o,l,c,f,d,h,u,m,p,_,g,T,b,R,S,I,x,P;if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;let t=this.ignoreCameraMaxZ?0:this.maxZ;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=t,this._refreshFrustumPlanes=!0;let i=this.getEngine(),r=this.getScene(),s=i.useReverseDepthBuffer;if(this.mode===n.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let L;r.useRightHandedSystem?L=U.PerspectiveFovRHToRef:L=U.PerspectiveFovLHToRef,L(this.fov,i.getAspectRatio(this),s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,this.fovMode===n.FOVMODE_VERTICAL_FIXED,i.isNDCHalfZRange,this.projectionPlaneTilt,s)}else{let L=i.getRenderWidth()/2,y=i.getRenderHeight()/2;r.useRightHandedSystem?this.oblique?U.ObliqueOffCenterRHToRef((a=this.orthoLeft)!=null?a:-L,(o=this.orthoRight)!=null?o:L,(l=this.orthoBottom)!=null?l:-y,(c=this.orthoTop)!=null?c:y,s?t:this.minZ,s?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):U.OrthoOffCenterRHToRef((f=this.orthoLeft)!=null?f:-L,(d=this.orthoRight)!=null?d:L,(h=this.orthoBottom)!=null?h:-y,(u=this.orthoTop)!=null?u:y,s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange):this.oblique?U.ObliqueOffCenterLHToRef((m=this.orthoLeft)!=null?m:-L,(p=this.orthoRight)!=null?p:L,(_=this.orthoBottom)!=null?_:-y,(g=this.orthoTop)!=null?g:y,s?t:this.minZ,s?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):U.OrthoOffCenterLHToRef((T=this.orthoLeft)!=null?T:-L,(b=this.orthoRight)!=null?b:L,(R=this.orthoBottom)!=null?R:-y,(S=this.orthoTop)!=null?S:y,s?t:this.minZ,s?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=(I=this.oblique)==null?void 0:I.angle,this._cache.obliqueLength=(x=this.oblique)==null?void 0:x.length,this._cache.obliqueOffset=(P=this.oblique)==null?void 0:P.offset,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){let 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?oa.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=oa.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let i=!1;for(let r of this.rigCameras)r._updateFrustumPlanes(),i=i||e.isInFrustum(r._frustumPlanes);return i}else return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw Ie("Ray")}getForwardRayToRef(e,t=100,i,r){throw Ie("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){let r=this._rigCameras.pop();r&&r.dispose()}if(this._parentContainer){let r=this._parentContainer.cameras.indexOf(this);r>-1&&this._parentContainer.cameras.splice(r,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==n.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let r=this._postProcesses.length;for(;--r>=0;){let s=this._postProcesses[r];s&&s.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;){let i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=re.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==n.RIG_MODE_NONE){let i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);let r=this.createRigCamera(this.name+"_R",1);r&&(r._isRightCamera=!0),i&&r&&(this._rigCameras.push(i),this._rigCameras.push(r))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return U.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=re.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;en._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){let i=e.type,r=n.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),s=Me.Parse(r,e,t);if(e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),s.inputs&&(s.inputs.parse(e),s._setupInputs()),e.upVector&&(s.upVector=v.FromArray(e.upVector)),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(v.FromArray(e.position))),e.target&&s.setTarget&&s.setTarget(v.FromArray(e.target)),e.cameraRigMode){let a=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};s.setCameraRigMode(e.cameraRigMode,a)}if(e.animations){for(let a=0;a{throw Ie("UniversalCamera")};Ue.PERSPECTIVE_CAMERA=0;Ue.ORTHOGRAPHIC_CAMERA=1;Ue.FOVMODE_VERTICAL_FIXED=0;Ue.FOVMODE_HORIZONTAL_FIXED=1;Ue.RIG_MODE_NONE=0;Ue.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;Ue.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;Ue.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;Ue.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;Ue.RIG_MODE_STEREOSCOPIC_INTERLACED=14;Ue.RIG_MODE_VR=20;Ue.RIG_MODE_CUSTOM=22;Ue.ForceAttachControlToAlwaysPreventDefault=!1;C([ai("position")],Ue.prototype,"_position",void 0);C([ai("upVector")],Ue.prototype,"_upVector",void 0);C([D()],Ue.prototype,"orthoLeft",null);C([D()],Ue.prototype,"orthoRight",null);C([D()],Ue.prototype,"orthoBottom",null);C([D()],Ue.prototype,"orthoTop",null);C([D()],Ue.prototype,"fov",void 0);C([D()],Ue.prototype,"projectionPlaneTilt",void 0);C([D()],Ue.prototype,"minZ",void 0);C([D()],Ue.prototype,"maxZ",void 0);C([D()],Ue.prototype,"inertia",void 0);C([D()],Ue.prototype,"mode",null);C([D()],Ue.prototype,"layerMask",void 0);C([D()],Ue.prototype,"fovMode",void 0);C([D()],Ue.prototype,"cameraRigMode",void 0);C([D()],Ue.prototype,"interaxialDistance",void 0);C([D()],Ue.prototype,"isStereoscopicSideBySide",void 0);C([D()],Ue.prototype,"ignoreCameraMaxZ",void 0)});var xo,rE=A(()=>{xo=class{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}});var va,nE=A(()=>{Ln();ve();bi();va=class n{constructor(e,t,i){this.vectors=vi(8,v.Zero),this.center=v.Zero(),this.centerWorld=v.Zero(),this.extendSize=v.Zero(),this.extendSizeWorld=v.Zero(),this.directions=vi(3,v.Zero),this.vectorsWorld=vi(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){let r=e.x,s=e.y,a=e.z,o=t.x,l=t.y,c=t.z,f=this.vectors;this.minimum.copyFromFloats(r,s,a),this.maximum.copyFromFloats(o,l,c),f[0].copyFromFloats(r,s,a),f[1].copyFromFloats(o,l,c),f[2].copyFromFloats(o,s,a),f[3].copyFromFloats(r,l,a),f[4].copyFromFloats(r,s,c),f[5].copyFromFloats(o,l,a),f[6].copyFromFloats(r,l,c),f[7].copyFromFloats(o,s,c),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||U.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){let t=n._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),r=i.length();i.normalizeFromLength(r);let s=r*e,a=i.scaleInPlace(s*.5),o=this.center.subtractToRef(a,t[1]),l=this.center.addToRef(a,t[2]);return this.reConstruct(o,l,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){let t=this.minimumWorld,i=this.maximumWorld,r=this.directions,s=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)s[o].copyFrom(a[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){let l=s[o];v.TransformCoordinatesToRef(a[o],e,l),t.minimizeInPlace(l),i.maximizeInPlace(l)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}v.FromArrayToRef(e.m,0,r[0]),v.FromArrayToRef(e.m,4,r[1]),v.FromArrayToRef(e.m,8,r[2]),this._worldMatrix=e}isInFrustum(e){return n.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return n.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){let t=this.minimumWorld,i=this.maximumWorld,r=t.x,s=t.y,a=t.z,o=i.x,l=i.y,c=i.z,f=e.x,d=e.y,h=e.z,u=-Ye;return!(o-ff-r||l-dd-s||c-hh-a)}intersectsSphere(e){return n.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){let i=this.minimumWorld,r=this.maximumWorld,s=i.x,a=i.y,o=i.z,l=r.x,c=r.y,f=r.z,d=e.x,h=e.y,u=e.z,m=t.x,p=t.y,_=t.z;return!(lm||cp||f_)}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,r){let s=n._TmpVector3[0];return v.ClampToRef(i,e,t,s),v.DistanceSquared(i,s)<=r*r}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){let r=t[i];for(let s=0;s<8;++s)if(r.dotCoordinate(e[s])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let r=!0,s=t[i];for(let a=0;a<8;++a)if(s.dotCoordinate(e[a])>=0){r=!1;break}if(r)return!1}return!0}};va._TmpVector3=vi(3,v.Zero)});var Cl,_M=A(()=>{Ln();ve();Cl=class n{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);let r=v.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=r*.5,this._update(i||U.IdentityReadOnly)}scale(e){let t=this.radius*e,i=n._TmpVector3,r=i[0].setAll(t),s=this.center.subtractToRef(r,i[1]),a=this.center.addToRef(r,i[2]);return this.reConstruct(s,a,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);let t=n._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){let t=this.centerWorld,i=this.radiusWorld;for(let r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){let t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){let t=v.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld{Ln();ve();nE();_M();sE={min:0,max:0},aE={min:0,max:0},gM=(n,e,t)=>{let i=v.Dot(e.centerWorld,n),r=Math.abs(v.Dot(e.directions[0],n))*e.extendSize.x,s=Math.abs(v.Dot(e.directions[1],n))*e.extendSize.y,a=Math.abs(v.Dot(e.directions[2],n))*e.extendSize.z,o=r+s+a;t.min=i-o,t.max=i+o},Yi=(n,e,t)=>(gM(n,e,sE),gM(n,t,aE),!(sE.min>aE.max||aE.min>sE.max)),Ti=class n{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new va(e,t,i),this.boundingSphere=new Cl(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){let i=n._TmpVector3[0].copyFrom(e).subtractInPlace(t),r=n._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this}encapsulate(e){let t=v.Minimize(this.minimum,e),i=v.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){let t=G.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);let i=G.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(){let e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,n._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(!Cl.Intersects(this.boundingSphere,e.boundingSphere)||!va.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;let i=this.boundingBox,r=e.boundingBox;return!(!Yi(i.directions[0],i,r)||!Yi(i.directions[1],i,r)||!Yi(i.directions[2],i,r)||!Yi(r.directions[0],i,r)||!Yi(r.directions[1],i,r)||!Yi(r.directions[2],i,r)||!Yi(v.Cross(i.directions[0],r.directions[0]),i,r)||!Yi(v.Cross(i.directions[0],r.directions[1]),i,r)||!Yi(v.Cross(i.directions[0],r.directions[2]),i,r)||!Yi(v.Cross(i.directions[1],r.directions[0]),i,r)||!Yi(v.Cross(i.directions[1],r.directions[1]),i,r)||!Yi(v.Cross(i.directions[1],r.directions[2]),i,r)||!Yi(v.Cross(i.directions[2],r.directions[0]),i,r)||!Yi(v.Cross(i.directions[2],r.directions[1]),i,r)||!Yi(v.Cross(i.directions[2],r.directions[2]),i,r))}};Ti._TmpVector3=vi(2,v.Zero)});function EM(n,e,t,i,r=null){let s=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Ml.extractMinAndMaxIndexed(n,e,t,i,s,a),r&&(s.x-=s.x*r.x+r.y,s.y-=s.y*r.x+r.y,s.z-=s.z*r.x+r.y,a.x+=a.x*r.x+r.y,a.y+=a.y*r.x+r.y,a.z+=a.z*r.x+r.y),{minimum:s,maximum:a}}function qh(n,e,t,i=null,r){let s=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r||(r=3),Ml.extractMinAndMax(n,e,t,r,s,a),i&&(s.x-=s.x*i.x+i.y,s.y-=s.y*i.x+i.y,s.z-=s.z*i.x+i.y,a.x+=a.x*i.x+i.y,a.y+=a.y*i.x+i.y,a.z+=a.z*i.x+i.y),{minimum:s,maximum:a}}var Ml,Qh=A(()=>{Qe();ve();qe();Ml=class{static extractMinAndMaxIndexed(e,t,i,r,s,a){for(let o=i;o!Array.isArray(n[0])&&!Array.isArray(n[1]))],Ml,"extractMinAndMaxIndexed",null);C([rr.filter((...n)=>!Array.isArray(n[0]))],Ml,"extractMinAndMax",null)});var ar,Sf=A(()=>{yt();rE();bl();Qh();go();ar=class n{get materialDefines(){var t;let e=this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:(t=this._getDrawWrapper())==null?void 0:t.defines;return typeof e=="string"?null:e}set materialDefines(e){var i;let 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 zi(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){var r;t&&((r=this._drawWrappers[e])==null||r.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,r=!0){let s=this._drawWrapper;s.setEffect(e,t,r),i!==void 0&&(s.materialContext=i),e||(s.defines=null,s.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(let i of this._drawWrappers)i==null||i.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,r,s,a,o,l=!0){return new n(e,t,i,r,s,a,o,l)}constructor(e,t,i,r,s,a,o,l=!0,c=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=s,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=a,this._renderingMesh=o||a,c&&a.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=a.subMeshes.length-1,l&&(this.refreshBoundingInfo(),a.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(){let e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){var i;let t=(i=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId))!=null?i:this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){let r=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==r&&(this._currentMaterial=r,this.resetDrawCache()),r}}else return e&&this._mesh.getScene()._hasDefaultMaterial?this._mesh.getScene().defaultMaterial:null;return t}_isMultiMaterial(e){return e.getSubMaterial!==void 0}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(M.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;let t=this._renderingMesh.getIndices(),i;if(this.indexStart===0&&this.indexCount===t.length){let r=this._renderingMesh.getBoundingInfo();i={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else i=EM(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Ti(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){let t=this.getBoundingInfo();return t?t.isInFrustum(e,this._mesh.cullingStrategy):!1}isCompletelyInFrustum(e){let 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){let i=Math.floor(this.indexCount/3)*6,s=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i),a=0;if(e.length===0)for(let o=this.indexStart;ol&&(l=h)}return new n(e,o,l-o+1,t,i,r,s,a)}}});var Af,de,Vt=A(()=>{Qe();ve();yt();Ei();et();ze();qe();iE();Kc();Sf();Af=class{},de=class n{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=pM(this._applyToCoroutine.bind(this)),this.uniqueId=n._UniqueIdGenerator,n._UniqueIdGenerator++}set(e,t){switch(e.length||W.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case M.PositionKind:this.positions=e;break;case M.NormalKind:this.normals=e;break;case M.TangentKind:this.tangents=e;break;case M.UVKind:this.uvs=e;break;case M.UV2Kind:this.uvs2=e;break;case M.UV3Kind:this.uvs3=e;break;case M.UV4Kind:this.uvs4=e;break;case M.UV5Kind:this.uvs5=e;break;case M.UV6Kind:this.uvs6=e;break;case M.ColorKind:this.colors=e;break;case M.MatricesIndicesKind:this.matricesIndices=e;break;case M.MatricesWeightsKind:this.matricesWeights=e;break;case M.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case M.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(M.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(M.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(M.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(M.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(M.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(M.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(M.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(M.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(M.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){let r=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(M.ColorKind,this.colors,t,r),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(M.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(M.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(M.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(M.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){let r=e;r.subMeshes=[];for(let s of this.materialInfos)new ar(s.materialIndex,s.verticesStart,s.verticesCount,s.indexStart,s.indexCount,r)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(M.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(M.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(M.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(M.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(M.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(M.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(M.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(M.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(M.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(M.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(M.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(M.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(M.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(M.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,r=e.length){let s=G.Vector3[0],a=G.Vector3[1];for(let o=i;o({vertexData:o})):[{vertexData:e}];return Tf(this._mergeCoroutine(void 0,a,t,!1,i,r,s))}*_mergeCoroutine(e,t,i=!1,r,s,a=!1,o=!1){var u,m,p,_;this._validate();let l=t.map(g=>g.vertexData),c=this;if(o)for(let g of l)g&&(g._validate(),!this.normals&&g.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&g.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&g.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&g.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&g.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&g.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&g.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&g.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&g.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&g.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&g.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&g.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&g.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(let g of l)if(g){if(o)this.normals&&!g.normals&&(g.normals=new Float32Array(g.positions.length)),this.tangents&&!g.tangents&&(g.tangents=new Float32Array(g.positions.length/3*4)),this.uvs&&!g.uvs&&(g.uvs=new Float32Array(g.positions.length/3*2)),this.uvs2&&!g.uvs2&&(g.uvs2=new Float32Array(g.positions.length/3*2)),this.uvs3&&!g.uvs3&&(g.uvs3=new Float32Array(g.positions.length/3*2)),this.uvs4&&!g.uvs4&&(g.uvs4=new Float32Array(g.positions.length/3*2)),this.uvs5&&!g.uvs5&&(g.uvs5=new Float32Array(g.positions.length/3*2)),this.uvs6&&!g.uvs6&&(g.uvs6=new Float32Array(g.positions.length/3*2)),this.colors&&!g.colors&&(g.colors=new Float32Array(g.positions.length/3*4),g.colors.fill(1)),this.matricesIndices&&!g.matricesIndices&&(g.matricesIndices=new Float32Array(g.positions.length/3*4)),this.matricesWeights&&!g.matricesWeights&&(g.matricesWeights=new Float32Array(g.positions.length/3*4)),this.matricesIndicesExtra&&!g.matricesIndicesExtra&&(g.matricesIndicesExtra=new Float32Array(g.positions.length/3*4)),this.matricesWeightsExtra&&!g.matricesWeightsExtra&&(g.matricesWeightsExtra=new Float32Array(g.positions.length/3*4));else if(g._validate(),!this.normals!=!g.normals||!this.tangents!=!g.tangents||!this.uvs!=!g.uvs||!this.uvs2!=!g.uvs2||!this.uvs3!=!g.uvs3||!this.uvs4!=!g.uvs4||!this.uvs5!=!g.uvs5||!this.uvs6!=!g.uvs6||!this.colors!=!g.colors||!this.matricesIndices!=!g.matricesIndices||!this.matricesWeights!=!g.matricesWeights||!this.matricesIndicesExtra!=!g.matricesIndicesExtra||!this.matricesWeightsExtra!=!g.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(a){let g,T=0,b=0,R=[],S=null,I=[];for(let P of this.splitBasedOnMaterialID())I.push({vertexData:P,transform:e});for(let P of t)if(P.vertexData)for(let L of P.vertexData.splitBasedOnMaterialID())I.push({vertexData:L,transform:P.transform});I.sort((P,L)=>{let y=P.vertexData.materialInfos?P.vertexData.materialInfos[0].materialIndex:0,B=L.vertexData.materialInfos?L.vertexData.materialInfos[0].materialIndex:0;return y>B?1:y===B?0:-1});for(let P of I){let L=P.vertexData;if(L.materialInfos?g=L.materialInfos[0].materialIndex:g=0,S&&S.materialIndex===g)S.indexCount+=L.indices.length,S.verticesCount+=L.positions.length/3;else{let y=new Af;y.materialIndex=g,y.indexStart=T,y.indexCount=L.indices.length,y.verticesStart=b,y.verticesCount=L.positions.length/3,R.push(y),S=y}T+=L.indices.length,b+=L.positions.length/3}let x=I.splice(0,1)[0];c=x.vertexData,e=x.transform,l=I.map(P=>P.vertexData),t=I,this.materialInfos=R}let f=l.reduce((g,T)=>{var b,R;return g+((R=(b=T.indices)==null?void 0:b.length)!=null?R:0)},(m=(u=c.indices)==null?void 0:u.length)!=null?m:0),h=s||l.some(g=>g.indices===c.indices)?(p=c.indices)==null?void 0:p.slice():c.indices;if(f>0){let g=(_=h==null?void 0:h.length)!=null?_:0;if(h||(h=new Array(f)),h.length!==f){if(Array.isArray(h))h.length=f;else{let b=i||h instanceof Uint32Array?new Uint32Array(f):new Uint16Array(f);b.set(h),h=b}e&&e.determinant()<0&&n._FlipFaces(h,0,g)}let T=c.positions?c.positions.length/3:0;for(let{vertexData:b,transform:R}of t)if(b.indices){for(let S=0;S[g.vertexData.positions,g.transform])),r&&(yield),c.normals&&(this.normals=n._MergeElement(M.NormalKind,c.normals,e,t.map(g=>[g.vertexData.normals,g.transform])),r&&(yield)),c.tangents&&(this.tangents=n._MergeElement(M.TangentKind,c.tangents,e,t.map(g=>[g.vertexData.tangents,g.transform])),r&&(yield)),c.uvs&&(this.uvs=n._MergeElement(M.UVKind,c.uvs,e,t.map(g=>[g.vertexData.uvs,g.transform])),r&&(yield)),c.uvs2&&(this.uvs2=n._MergeElement(M.UV2Kind,c.uvs2,e,t.map(g=>[g.vertexData.uvs2,g.transform])),r&&(yield)),c.uvs3&&(this.uvs3=n._MergeElement(M.UV3Kind,c.uvs3,e,t.map(g=>[g.vertexData.uvs3,g.transform])),r&&(yield)),c.uvs4&&(this.uvs4=n._MergeElement(M.UV4Kind,c.uvs4,e,t.map(g=>[g.vertexData.uvs4,g.transform])),r&&(yield)),c.uvs5&&(this.uvs5=n._MergeElement(M.UV5Kind,c.uvs5,e,t.map(g=>[g.vertexData.uvs5,g.transform])),r&&(yield)),c.uvs6&&(this.uvs6=n._MergeElement(M.UV6Kind,c.uvs6,e,t.map(g=>[g.vertexData.uvs6,g.transform])),r&&(yield)),c.colors&&(this.colors=n._MergeElement(M.ColorKind,c.colors,e,t.map(g=>[g.vertexData.colors,g.transform])),(c.hasVertexAlpha!==void 0||t.some(g=>g.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=c.hasVertexAlpha||t.some(g=>g.vertexData.hasVertexAlpha)),r&&(yield)),c.matricesIndices&&(this.matricesIndices=n._MergeElement(M.MatricesIndicesKind,c.matricesIndices,e,t.map(g=>[g.vertexData.matricesIndices,g.transform])),r&&(yield)),c.matricesWeights&&(this.matricesWeights=n._MergeElement(M.MatricesWeightsKind,c.matricesWeights,e,t.map(g=>[g.vertexData.matricesWeights,g.transform])),r&&(yield)),c.matricesIndicesExtra&&(this.matricesIndicesExtra=n._MergeElement(M.MatricesIndicesExtraKind,c.matricesIndicesExtra,e,t.map(g=>[g.vertexData.matricesIndicesExtra,g.transform])),r&&(yield)),c.matricesWeightsExtra&&(this.matricesWeightsExtra=n._MergeElement(M.MatricesWeightsExtraKind,c.matricesWeightsExtra,e,t.map(g=>[g.vertexData.matricesWeightsExtra,g.transform]))),this}static _MergeElement(e,t,i,r){let s=r.filter(l=>l[0]!==null&&l[0]!==void 0);if(!t&&s.length==0)return t;if(!t)return this._MergeElement(e,s[0][0],s[0][1],s.slice(1));let a=s.reduce((l,c)=>l+c[0].length,t.length),o=e===M.PositionKind?n._TransformVector3Coordinates:e===M.NormalKind?n._TransformVector3Normals:e===M.TangentKind?n._TransformVector4Normals:()=>{};if(t instanceof Float32Array){let l=new Float32Array(a);l.set(t),i&&o(l,i,0,t.length);let c=t.length;for(let[f,d]of s)l.set(f,c),d&&o(l,d,c,f.length),c+=f.length;return l}else{let l=new Array(a);for(let f=0;f{let a=M.DeduceStride(r);if(s.length%a!==0)throw new Error("The "+r+"s array count must be a multiple of "+a);return s.length/a},t=e(M.PositionKind,this.positions),i=(r,s)=>{let a=e(r,s);if(a!==t)throw new Error("The "+r+"s element count ("+a+") does not match the positions count ("+t+")")};this.normals&&i(M.NormalKind,this.normals),this.tangents&&i(M.TangentKind,this.tangents),this.uvs&&i(M.UVKind,this.uvs),this.uvs2&&i(M.UV2Kind,this.uvs2),this.uvs3&&i(M.UV3Kind,this.uvs3),this.uvs4&&i(M.UV4Kind,this.uvs4),this.uvs5&&i(M.UV5Kind,this.uvs5),this.uvs6&&i(M.UV6Kind,this.uvs6),this.colors&&i(M.ColorKind,this.colors),this.matricesIndices&&i(M.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(M.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(M.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(M.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){let e=this.serialize();return n.Parse(e)}serialize(){let e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndicesExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtraExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=this.indices?Array.from(this.indices):[],this.materialInfos){e.materialInfos=[];for(let t of this.materialInfos){let 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 n._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return n._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){let r=new n;if(e.isVerticesDataPresent(M.PositionKind)&&(r.positions=e.getVerticesData(M.PositionKind,t,i)),e.isVerticesDataPresent(M.NormalKind)&&(r.normals=e.getVerticesData(M.NormalKind,t,i)),e.isVerticesDataPresent(M.TangentKind)&&(r.tangents=e.getVerticesData(M.TangentKind,t,i)),e.isVerticesDataPresent(M.UVKind)&&(r.uvs=e.getVerticesData(M.UVKind,t,i)),e.isVerticesDataPresent(M.UV2Kind)&&(r.uvs2=e.getVerticesData(M.UV2Kind,t,i)),e.isVerticesDataPresent(M.UV3Kind)&&(r.uvs3=e.getVerticesData(M.UV3Kind,t,i)),e.isVerticesDataPresent(M.UV4Kind)&&(r.uvs4=e.getVerticesData(M.UV4Kind,t,i)),e.isVerticesDataPresent(M.UV5Kind)&&(r.uvs5=e.getVerticesData(M.UV5Kind,t,i)),e.isVerticesDataPresent(M.UV6Kind)&&(r.uvs6=e.getVerticesData(M.UV6Kind,t,i)),e.isVerticesDataPresent(M.ColorKind)){let s=e.geometry||e,a=s.getVertexBuffer(M.ColorKind),o=s.getVerticesData(M.ColorKind,t,i);if(a.getSize()===3){let l=new Float32Array(o.length*4/3);for(let c=0,f=0;c!Array.isArray(n[0]))],de,"_TransformVector3Coordinates",null);C([rr.filter((...n)=>!Array.isArray(n[0]))],de,"_TransformVector3Normals",null);C([rr.filter((...n)=>!Array.isArray(n[0]))],de,"_TransformVector4Normals",null);C([rr.filter((...n)=>!Array.isArray(n[0]))],de,"_FlipFaces",null)});var ci,Jh=A(()=>{ci=class n{static get ForceFullSceneLoadingForIncremental(){return n._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){n._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return n._ShowLoadingScreen}static set ShowLoadingScreen(e){n._ShowLoadingScreen=e}static get loggingLevel(){return n._LoggingLevel}static set loggingLevel(e){n._LoggingLevel=e}static get CleanBoneMatrixWeights(){return n._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){n._CleanBoneMatrixWeights=e}};ci._ForceFullSceneLoadingForIncremental=!1;ci._ShowLoadingScreen=!0;ci._CleanBoneMatrixWeights=!1;ci._LoggingLevel=0});var Si,$h=A(()=>{ve();et();Vt();yt();Sf();Jh();bl();Tt();ha();Qh();At();ui();_l();Si=class n{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){let t=new n(n.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,r=!1,s=null,a=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||ue.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=r,a!==null&&(this._totalVertices=a),i?this.setAllVerticesData(i,r):a===null&&(this._totalVertices=0),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),s&&(this.applyToMesh(s),s.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{t._rebuild()})}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,r){i&&Array.isArray(t)&&(t=new Float32Array(t));let s=new M(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:r,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(s)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){let r=e.getKind();this._vertexBuffers[r]&&i&&this._vertexBuffers[r].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[r]=e;let s=this._meshes,a=s.length;if(r===M.PositionKind){this._totalVertices=t!=null?t:e._maxVerticesCount,this._updateExtend(this.useBoundingInfoFromGeometry&&this._boundingInfo?null:e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();let o=this._extend&&this._extend.minimum||new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=this._extend&&this._extend.maximum||new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let c=0;c65535:e.is32Bits=r;for(let s of this._meshes)s._createGlobalSubMesh(!0),s.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,r=!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(let s of this._meshes)s._createGlobalSubMesh(!r),s.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;let 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){let i=this._meshes,r=i.indexOf(e);r!==-1&&(i.splice(r,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,i.length===0&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;let t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();let 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(M.PositionKind),!e))return;this._extend=qh(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){for(let t in this._vertexBuffers){let i=this._vertexBuffers[t];i._buffer.getBuffer()||i.create(),t===M.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo())}!this._indexBuffer&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(let 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);let r=this._meshes,s=r.length;for(let a=0;a0){for(let r=0;r0){for(let r=0;r0){for(let r=0;r-1&&this._parentContainer.geometries.splice(r,1),this._parentContainer=null}this._isDisposed=!0}copy(e){let t=new n(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let r=!1,s;for(s in this._vertexBuffers){let a=this.getVertexBuffer(s),o=a.getData();if(!o)continue;let l=a.isUpdatable(),c=a.getSize(),{type:f,byteOffset:d,byteStride:h,normalized:u}=a;r=r||l;let m=this._totalVertices;if(a.getIsInstanced()){let g;o instanceof Array?g=o.length*4:g=o.byteLength,m=g/h}let p=HI(o,c,f,d,h,m,!0),_=new M(this._engine,p,s,{updatable:l,useBytes:!1,stride:c,size:c,offset:0,type:f,normalized:u,takeBufferOwnership:!0,instanced:a.getIsInstanced()});t.setVerticesBuffer(_,m)}t._updatable=r,t.delayLoadState=this.delayLoadState,t.delayLoadingFile=this.delayLoadingFile,t._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(s);return t._boundingInfo=new Ti(this._extend.minimum,this._extend.maximum),t}serialize(){let e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,nt&&nt.HasTags(this)&&(e.tags=nt.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._totalIndices=this._indices.length,this._indices=[],this._resetPointsArrayCache();for(let e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){let e=this.serialize();return this.isVerticesDataPresent(M.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(M.PositionKind)),this.isVertexBufferUpdatable(M.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(M.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(M.NormalKind)),this.isVertexBufferUpdatable(M.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(M.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(M.TangentKind)),this.isVertexBufferUpdatable(M.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(M.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(M.UVKind)),this.isVertexBufferUpdatable(M.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(M.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(M.UV2Kind)),this.isVertexBufferUpdatable(M.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(M.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(M.UV3Kind)),this.isVertexBufferUpdatable(M.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(M.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(M.UV4Kind)),this.isVertexBufferUpdatable(M.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(M.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(M.UV5Kind)),this.isVertexBufferUpdatable(M.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(M.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(M.UV6Kind)),this.isVertexBufferUpdatable(M.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(M.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(M.ColorKind)),this.isVertexBufferUpdatable(M.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(M.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(M.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(M.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(M.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(M.MatricesWeightsKind)),this.isVertexBufferUpdatable(M.MatricesWeightsKind)&&(e.matricesWeightsUpdatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){let i=e._geometry;return i?i.copy(t):null}static RandomId(){return re.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i0){let o=new Float32Array(e,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);t.setVerticesData(M.PositionKind,o,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){let o=new Float32Array(e,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);t.setVerticesData(M.NormalKind,o,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){let o=new Float32Array(e,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);t.setVerticesData(M.TangentKind,o,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){let o=new Float32Array(e,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);if(He)for(let l=1;l0){let o=new Float32Array(e,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);t.setVerticesData(M.ColorKind,o,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){let o=new Int32Array(e,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),l=[];for(let c=0;c>8),l.push((f&16711680)>>16),l.push(f>>24&255)}t.setVerticesData(M.MatricesIndicesKind,l,!1)}if(a.matricesIndicesExtraAttrDesc&&a.matricesIndicesExtraAttrDesc.count>0){let o=new Int32Array(e,a.matricesIndicesExtraAttrDesc.offset,a.matricesIndicesExtraAttrDesc.count),l=[];for(let c=0;c>8),l.push((f&16711680)>>16),l.push(f>>24&255)}t.setVerticesData(M.MatricesIndicesExtraKind,l,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){let o=new Float32Array(e,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);t.setVerticesData(M.MatricesWeightsKind,o,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){let o=new Int32Array(e,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);t.setIndices(o,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){let o=new Int32Array(e,a.subMeshesAttrDesc.offset,a.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let l=0;l>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(M.MatricesIndicesKind,a,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(M.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable||e.matricesIndicesUpdatable);if(e.matricesIndicesExtra)if(e.matricesIndicesExtraExpanded||e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,delete e.matricesIndicesExtraExpanded,t.setVerticesData(M.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable);else{let a=[];for(let o=0;o>8),a.push((l&16711680)>>16),a.push(l>>24&255)}t.setVerticesData(M.MatricesIndicesExtraKind,a,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(n._CleanMatricesWeights(e,t),t.setVerticesData(M.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(M.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let a=0;a-1){let d=t.getScene().getLastSkeletonById(e.skeletonId);if(!d)return;r=d.bones.length}else return;let s=t.getVerticesData(M.MatricesIndicesKind),a=t.getVerticesData(M.MatricesIndicesExtraKind),o=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,f=o.length;for(let d=0;dc-1)&&(u=c-1),h>.001){let m=1/h;for(let p=0;p<4;p++)o[d+p]*=m;if(l)for(let p=0;p<4;p++)l[d+p]*=m}else u>=4?(l[d+u-4]=1-h,a[d+u-4]=r):(o[d+u]=1-h,s[d+u]=r)}t.setVerticesData(M.MatricesIndicesKind,s),e.matricesWeightsExtra&&t.setVerticesData(M.MatricesIndicesExtraKind,a)}static Parse(e,t,i){let r=new n(e.id,t,void 0,e.updatable);return r._loadedUniqueId=e.uniqueId,nt&&nt.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=4,r.delayLoadingFile=i+e.delayLoadingFile,r._boundingInfo=new Ti(v.FromArray(e.boundingBoxMinimum),v.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(M.UVKind),e.hasUVs2&&r._delayInfo.push(M.UV2Kind),e.hasUVs3&&r._delayInfo.push(M.UV3Kind),e.hasUVs4&&r._delayInfo.push(M.UV4Kind),e.hasUVs5&&r._delayInfo.push(M.UV5Kind),e.hasUVs6&&r._delayInfo.push(M.UV6Kind),e.hasColors&&r._delayInfo.push(M.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(M.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(M.MatricesWeightsKind),r._delayLoadingFunction=de.ImportVertexData):de.ImportVertexData(e,r),t.pushGeometry(r,!0),r}}});var at,yl=A(()=>{Qe();qe();Kt();ft();ve();Sr();Lt();at=class n extends ht{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&n.BILLBOARDMODE_USE_POSITION)!==0)}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,i=!0){super(e,t,!1),this._forward=new 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=n.BILLBOARDMODE_NONE,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=U.Zero(),this._usePivotMatrix=!1,this._absolutePosition=v.Zero(),this._absoluteScaling=v.Zero(),this._absoluteRotationQuaternion=Ae.Identity(),this._pivotMatrix=U.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new Y,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=U.Identity()),this._poseMatrix}_isSynchronized(){let e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==n.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();let e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=U.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,i){let r=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);r&&i&&i(this,r);for(let s of this.getChildTransformNodes(!0))s.instantiateHierarchy(r,t,i);return r}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||Ae.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,r;if(e.x===void 0){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],r=arguments[2]}else t=e.x,i=e.y,r=e.z;if(this.parent){let s=G.Matrix[0];this.parent.getWorldMatrix().invertToRef(s),v.TransformCoordinatesFromFloatsToRef(t,i,r,s,this.position)}else this.position.x=t,this.position.y=i,this.position.z=r;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=v.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();let e=G.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,r=0,s=0){let a=n._LookAtVectorCache,o=s===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,a),this.setDirection(a,t,i,r),s===1&&this.parent)if(this.rotationQuaternion){let l=G.Matrix[0];this.rotationQuaternion.toRotationMatrix(l);let c=G.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(c),c.invert(),l.multiplyToRef(c,l),this.rotationQuaternion.fromRotationMatrix(l)}else{let l=G.Quaternion[0];Ae.FromEulerVectorToRef(this.rotation,l);let c=G.Matrix[0];l.toRotationMatrix(c);let f=G.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(f),f.invert(),c.multiplyToRef(f,c),l.fromRotationMatrix(c),l.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){let 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,r=0){let s=-Math.atan2(e.z,e.x)+Math.PI/2,a=Math.sqrt(e.x*e.x+e.z*e.z),o=-Math.atan2(e.y,a);return this.rotationQuaternion?Ae.RotationYawPitchRollToRef(s+t,o+i,r,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=s+t,this.rotation.z=r),this}setPivotPoint(e,t=0){this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);let i=this.getWorldMatrix();if(t==1){let r=G.Matrix[0];i.invertToRef(r),e=v.TransformCoordinates(e,r)}return this.setPivotMatrix(U.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){let 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(){let 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(let t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,i=!1){if(!e&&!this.parent)return this;let r=G.Quaternion[0],s=G.Vector3[0],a=G.Vector3[1],o=G.Matrix[1];U.IdentityToRef(o);let l=G.Matrix[0];this.computeWorldMatrix(!0);let c=this.rotationQuaternion;return c||(c=n._TmpRotation,Ae.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,c)),U.ComposeToRef(this.scaling,c,this.position,l),this.parent&&l.multiplyToRef(this.parent.computeWorldMatrix(!0),l),e&&(e.computeWorldMatrix(!0).invertToRef(o),l.multiplyToRef(o,l)),l.decompose(a,r,s,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(a),this.position.copyFrom(s),this.parent=e,i&&this.setPivotMatrix(U.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.parent!==this?this:(e.setParent(null,t),this)}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling===e?!1:(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,e?this.parent=this._currentParentWhenAttachingToBone:this.parent=null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,i){e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0));let r;if(!i||i===0)r=Ae.RotationAxisToRef(e,t,n._RotationAxisCache),this.rotationQuaternion.multiplyToRef(r,this.rotationQuaternion);else{if(this.parent){let s=this.parent.getWorldMatrix(),a=G.Matrix[0];s.invertToRef(a),e=v.TransformNormal(e,a),s.determinant()<0&&(t*=-1)}r=Ae.RotationAxisToRef(e,t,n._RotationAxisCache),r.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=Ae.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));let r=G.Vector3[0],s=G.Vector3[1],a=G.Vector3[2],o=G.Quaternion[0],l=G.Matrix[0],c=G.Matrix[1],f=G.Matrix[2],d=G.Matrix[3];return e.subtractToRef(this.position,r),U.TranslationToRef(r.x,r.y,r.z,l),U.TranslationToRef(-r.x,-r.y,-r.z,c),U.RotationAxisToRef(t,i,f),c.multiplyToRef(f,d),d.multiplyToRef(l,d),d.decompose(s,o,a),this.position.addInPlace(a),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){let r=e.scale(t);if(!i||i===0){let s=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(s)}else this.setAbsolutePosition(this.getAbsolutePosition().add(r));return this}addRotation(e,t,i){let r;this.rotationQuaternion?r=this.rotationQuaternion:(r=G.Quaternion[1],Ae.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));let s=G.Quaternion[0];return Ae.RotationYawPitchRollToRef(t,e,i,s),r.multiplyInPlace(s),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==n.BILLBOARDMODE_NONE}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;let 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();let r=this._cache;r.pivotMatrixUpdated=!1,r.billboardMode=this.billboardMode,r.infiniteDistance=this.infiniteDistance,r.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;let s=this._getEffectiveParent(),a=n._TmpScaling,o=this._position;if(this._infiniteDistance&&!this.parent&&t){let f=t.getWorldMatrix().m;o=n._TmpTranslation,o.copyFromFloats(this._position.x+f[12],this._position.y+f[13],this._position.z+f[14])}a.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant);let l;if(this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,l=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(Ae.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(l=n._TmpRotation,Ae.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),this._usePivotMatrix){let c=G.Matrix[1];U.ScalingToRef(a.x,a.y,a.z,c);let f=G.Matrix[0];l.toRotationMatrix(f),this._pivotMatrix.multiplyToRef(c,G.Matrix[4]),G.Matrix[4].multiplyToRef(f,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(o.x,o.y,o.z)}else U.ComposeToRef(a,l,o,this._localMatrix);if(s&&s.getWorldMatrix){if(e&&s.computeWorldMatrix(e),this.billboardMode){if(this._transformToBoneReferal){let h=this.parent;h.getSkeleton().prepare(),h.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),G.Matrix[7])}else G.Matrix[7].copyFrom(s.getWorldMatrix());let c=G.Vector3[5],f=G.Vector3[6],d=G.Quaternion[0];G.Matrix[7].decompose(f,d,c),U.ScalingToRef(f.x,f.y,f.z,G.Matrix[7]),G.Matrix[7].setTranslation(c),n.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(d,c),this._localMatrix.setTranslation(c)),this._localMatrix.multiplyToRef(G.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){let c=this.parent;c.getSkeleton().prepare(),this._localMatrix.multiplyToRef(c.getFinalMatrix(),G.Matrix[6]),G.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(s.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(t&&this.billboardMode)if(r.useBillboardPosition){let c=G.Vector3[0];this._worldMatrix.getTranslationToRef(c);let f=t.globalPosition;this._worldMatrix.invertToRef(G.Matrix[1]);let d=G.Vector3[1];v.TransformCoordinatesToRef(f,G.Matrix[1],d),d.normalize();let h=-Math.atan2(d.z,d.x)+Math.PI/2,u=Math.sqrt(d.x*d.x+d.z*d.z),m=-Math.atan2(d.y,u);if(Ae.RotationYawPitchRollToRef(h,m,0,G.Quaternion[0]),(this.billboardMode&n.BILLBOARDMODE_ALL)!==n.BILLBOARDMODE_ALL){let p=G.Vector3[1];G.Quaternion[0].toEulerAnglesToRef(p),(this.billboardMode&n.BILLBOARDMODE_X)!==n.BILLBOARDMODE_X&&(p.x=0),(this.billboardMode&n.BILLBOARDMODE_Y)!==n.BILLBOARDMODE_Y&&(p.y=0),(this.billboardMode&n.BILLBOARDMODE_Z)!==n.BILLBOARDMODE_Z&&(p.z=0),U.RotationYawPitchRollToRef(p.y,p.x,p.z,G.Matrix[0])}else U.FromQuaternionToRef(G.Quaternion[0],G.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(G.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(G.Vector3[0])}else{let c=G.Vector3[0];this._worldMatrix.getTranslationToRef(c),G.Matrix[1].copyFrom(t.getViewMatrix());let f=this.getScene().useRightHandedSystem;if(f&&G.Matrix[1].multiplyToRef(n._TmpRHRestore,G.Matrix[1]),G.Matrix[1].setTranslationFromFloats(0,0,0),G.Matrix[1].invertToRef(G.Matrix[0]),(this.billboardMode&n.BILLBOARDMODE_ALL)!==n.BILLBOARDMODE_ALL){G.Matrix[0].decompose(void 0,G.Quaternion[0],void 0);let d=G.Vector3[1];G.Quaternion[0].toEulerAnglesToRef(d),(this.billboardMode&n.BILLBOARDMODE_X)!==n.BILLBOARDMODE_X&&(d.x=0),(this.billboardMode&n.BILLBOARDMODE_Y)!==n.BILLBOARDMODE_Y&&(d.y=0),(this.billboardMode&n.BILLBOARDMODE_Z)!==n.BILLBOARDMODE_Z&&(d.z=0),f&&(d.y+=Math.PI),U.RotationYawPitchRollToRef(d.y,d.x,d.z,G.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(G.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(G.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):s&&s._nonUniformScaling?this._updateNonUniformScalingState(s._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=U.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){let t=this.getChildren();for(let i=0;inew n(e,this.getScene()),this);if(r.name=e,r.id=e,t&&(r.parent=t),!i){let s=this.getDescendants(!0);for(let a=0;anew n(e.name,t),e,t,i);if(e.localMatrix?r.setPreTransformMatrix(U.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(U.FromArray(e.pivotMatrix)),r.setEnabled(e.isEnabled),r._waitingParsedUniqueId=e.uniqueId,e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),e.freezeWorldMatrix&&(r._waitingFreezeWorldMatrix=e.freezeWorldMatrix),e.animations){for(let s=0;s(!t||t(r))&&r instanceof n),i}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){let i=this._parentContainer.transformNodes.indexOf(this);i>-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){let i=this.getChildTransformNodes(!0);for(let r of i)r.parent=null,r.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,i){let r=null,s=null;t&&(this.rotationQuaternion?(s=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(r=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));let a=this.getHierarchyBoundingVectors(e,i),o=a.max.subtract(a.min),l=Math.max(o.x,o.y,o.z);if(l===0)return this;let c=1/l;return this.scaling.scaleInPlace(c),t&&(this.rotationQuaternion&&s?this.rotationQuaternion.copyFrom(s):this.rotation&&r&&this.rotation.copyFrom(r)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}};at.BILLBOARDMODE_NONE=0;at.BILLBOARDMODE_X=1;at.BILLBOARDMODE_Y=2;at.BILLBOARDMODE_Z=4;at.BILLBOARDMODE_ALL=7;at.BILLBOARDMODE_USE_POSITION=128;at.BillboardUseParentOrientation=!1;at._TmpRotation=Ae.Zero();at._TmpScaling=v.Zero();at._TmpTranslation=v.Zero();at._TmpRHRestore=U.Scaling(1,1,-1);at._LookAtVectorCache=new v(0,0,0);at._RotationAxisCache=new Ae;C([ai("position")],at.prototype,"_position",void 0);C([ai("rotation")],at.prototype,"_rotation",void 0);C([BI("rotationQuaternion")],at.prototype,"_rotationQuaternion",void 0);C([ai("scaling")],at.prototype,"_scaling",void 0);C([D("billboardMode")],at.prototype,"_billboardMode",void 0);C([D()],at.prototype,"scalingDeterminant",void 0);C([D("infiniteDistance")],at.prototype,"_infiniteDistance",void 0);C([D()],at.prototype,"ignoreNonUniformScaling",void 0);C([D()],at.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0)});var eu,vM=A(()=>{ve();eu=class{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 TM(n){return Math.floor(n/8)}function SM(n){return 1<{tu=class{constructor(e){this.size=e,this._byteArray=new Uint8Array(Math.ceil(this.size/8))}get(e){if(e>=this.size)throw new RangeError("Bit index out of range");let t=TM(e),i=SM(e);return(this._byteArray[t]&i)!==0}set(e,t){if(e>=this.size)throw new RangeError("Bit index out of range");let i=TM(e),r=SM(e);t?this._byteArray[i]|=r:this._byteArray[i]&=~r}}});var RM={};De(RM,{OptimizeIndices:()=>Ik});function Ik(n){let e=[],t=n.length/3;for(let l=0;l{let c=[l];for(;c.length>0;){let f=c.pop();if(!r.get(f)){r.set(f,!0),s.push(e[f]);for(let d of e[f]){let h=i.get(d);if(!h)return;for(let u of h)r.get(u)||c.push(u)}}}};for(let l=0;l{AM()});function xk(n,e,t){let i;switch(e){case M.PositionKind:i=r=>r.getPositions();break;case M.NormalKind:i=r=>r.getNormals();break;case M.TangentKind:i=r=>r.getTangents();break;case M.UVKind:i=r=>r.getUVs();break;case M.UV2Kind:i=r=>r.getUV2s();break;case M.ColorKind:i=r=>r.getColors();break;default:return}for(let r=0;r0&&(U.FromFloat32ArrayToRefScaled(t,Math.floor(i[h+u]*16),m,c),l.addToSelf(c));if(s&&a)for(u=0;u<4;u++)m=a[h+u],m>0&&(U.FromFloat32ArrayToRefScaled(t,Math.floor(s[h+u]*16),m,c),l.addToSelf(c));f(n[d],n[d+1],n[d+2],l,o),o.toArray(n,d)}}var oE,lE,zt,Dl=A(()=>{Qe();ft();ve();yt();Vt();yl();af();bl();ma();vM();Ei();Qh();et();bi();nl();Lt();qe();ii();oE=class{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}},lE=class{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new oE,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=new Map,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new eu,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}},zt=class n extends at{static get BILLBOARDMODE_NONE(){return at.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return at.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return at.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return at.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return at.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return at.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;let t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(t===1&&e!==1||t!==1&&e===1)&&this._markSubMeshesAsDirty(i=>{i.markAsMiscDirty(),i.markAsPrePassDirty()})}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,e==null),this._unBindEffect()))}getMaterialForRenderPass(e){var t;return(t=this._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:t[e]}setMaterialForRenderPass(e,t){var r;this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);let i=this._internalAbstractMeshDataInfo._materialForRenderPass[e];(r=i==null?void 0:i.meshMap)!=null&&r[this.uniqueId]&&(i.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t,t&&t.meshMap&&(t.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){let 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 lE,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this._waitingSkeletonId=null,this._waitingSkeletonUniqueId=null,this.cullingStrategy=n.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new Y,this.onCollisionPositionChangeObservable=new Y,this.onMaterialChangedObservable=new Y,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=n.DefaultIsPickable,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=oe.Red(),this.outlineWidth=.02,this.overlayColor=oe.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 Ne(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 Y,this._onCollisionPositionChange=(i,r,s=null)=>{r.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>fe.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),s&&this.onCollideObservable.notifyObservers(s),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),this.layerMask=t.defaultRenderableLayerMask,t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new Ut(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){let 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);let 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!==at.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}_releaseRenderPassId(e){}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),!!this.subMeshes){for(let t of this.subMeshes)t._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(let e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){let t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e),r=!1;if(i===-1){if(!t)return;this._lightSources.push(e)}else{if(t)return;r=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(r)}_unBindEffect(){for(let e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){let i=this._lightSources.indexOf(e);i!==-1&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(let t of this.subMeshes)for(let i=0;it.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(let 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,r){return this}updateVerticesData(e,t,i,r){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 Ti(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(M.MatricesIndicesKind)&&this.isVerticesDataPresent(M.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===at.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){let r=new U;(this.rotationQuaternion?this.rotationQuaternion:Ae.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);let a=v.Zero(),o=this.definedFacingForward?-1:1;return v.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,r,a),a}rotatePOV(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this}calcRotatePOV(e,t,i){let r=this.definedFacingForward?1:-1;return new v(e*r,t,i*r)}_refreshBoundingInfo(e,t){if(e){let i=qh(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Ti(i.minimum,i.maximum)}if(this.subMeshes)for(let i=0;i{if(r){let o=r._vertexData||(r._vertexData={});return o[a]||this.copyVerticesData(a,o),o[a]}return this.getVerticesData(a)};if(t||(t=s(i)),!t)return null;if(r?(r._outputData?r._outputData.set(t):r._outputData=new Float32Array(t),t=r._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&xk(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){let a=s(M.MatricesIndicesKind),o=s(M.MatricesWeightsKind);if(o&&a){let l=this.numBoneInfluencers>4,c=l?s(M.MatricesIndicesExtraKind):null,f=l?s(M.MatricesWeightsExtraKind):null,d=this.skeleton.getTransformMatrices(this);n._ApplySkeleton(t,i,d,a,o,c,f)}}if(e.updatePositionsArray!==!1&&i===M.PositionKind){let a=this._internalAbstractMeshDataInfo._positions||[],o=a.length;if(a.length=t.length/3,o1||!r.IsGlobal)&&r.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){let r=this.getBoundingInfo(),s=e.getBoundingInfo();if(r.intersects(s,t))return!0;if(i){for(let a of this.getChildMeshes())if(a.intersectsMesh(e,t,!0))return!0}return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e,t=!0){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);let r=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=r.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,r.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId,t),this}_collideForSubMesh(e,t,i){var r;if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];let s=e.verticesStart,a=e.verticesStart+e.verticesCount;for(let o=s;o1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;let t=G.Matrix[0],i=G.Matrix[1];return U.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,r=!1,s,a=!1){let o=new Xi,l=this.getClassName(),c=l==="InstancedLinesMesh"||l==="LinesMesh"||l==="GreasedLineMesh"?this.intersectionThreshold:0,f=this.getBoundingInfo();if(!this.subMeshes||!a&&(!e.intersectsSphere(f.boundingSphere,c)||!e.intersectsBox(f.boundingBox,c)))return o;if(r)return o.hit=!a,o.pickedMesh=a?null:this,o.distance=a?0:v.Distance(e.origin,f.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let d=null,h=this._scene.getIntersectingSubMeshCandidates(this,e),u=h.length,m=!1;for(let p=0;p1&&!a&&!_.canIntersects(e))continue;let g=_.intersects(e,this._positions,this.getIndices(),t,i);if(g&&(t||!d||g.distanceo!==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-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;i65535){l=!0;break}l?e.depthSortedIndices=new Uint32Array(i):e.depthSortedIndices=new Uint16Array(i)}if(e.facetDepthSortFunction=function(l,c){return c.sqDistance-l.sqDistance},!e.facetDepthSortFrom){let l=this.getScene().activeCamera;e.facetDepthSortFrom=l?l.position:v.Zero()}e.depthSortedFacets=[];for(let l=0;lYe?s.maximum.x-s.minimum.x:Ye,e.bbSize.y=s.maximum.y-s.minimum.y>Ye?s.maximum.y-s.minimum.y:Ye,e.bbSize.z=s.maximum.z-s.minimum.z>Ye?s.maximum.z-s.minimum.z:Ye;let a=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(a=a>e.bbSize.z?a:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/a),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/a),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/a),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=s,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,r&&de.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);let l=e.depthSortedIndices.length/3|0;for(let c=0;cs.subDiv.max||o<0||o>s.subDiv.max||l<0||l>s.subDiv.max?null:s.facetPartitioning[a+s.subDiv.max*o+s.subDiv.max*s.subDiv.max*l]}getClosestFacetAtCoordinates(e,t,i,r,s=!1,a=!0){let o=this.getWorldMatrix(),l=G.Matrix[5];o.invertToRef(l);let c=G.Vector3[8];v.TransformCoordinatesFromFloatsToRef(e,t,i,l,c);let f=this.getClosestFacetAtLocalCoordinates(c.x,c.y,c.z,r,s,a);return r&&v.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,o,r),f}getClosestFacetAtLocalCoordinates(e,t,i,r,s=!1,a=!0){let o=null,l,c,f,d,h,u,m,p,_=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),T=this.getFacetsAtLocalCoordinates(e,t,i);if(!T)return null;let b=Number.MAX_VALUE,R,S,I,x;for(let P=0;P=0||s&&!a&&d<=0)&&(d=I.x*x.x+I.y*x.y+I.z*x.z,h=-(I.x*e+I.y*t+I.z*i-d)/(I.x*I.x+I.y*I.y+I.z*I.z),u=e+I.x*h,m=t+I.y*h,p=i+I.z*h,l=u-e,c=m-t,f=p-i,R=l*l+c*c+f*f,R(IM(),RM));return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=tr.Y);let i=G.Vector3[0],r=G.Vector3[1];return v.CrossToRef(t,e,r),v.CrossToRef(e,r,i),this.rotationQuaternion?Ae.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):v.RotationFromAxisToRef(i,e,r,this.rotation),this}_checkOcclusionQuery(e=!1){return!1}disableEdgesRendering(){throw Ie("EdgesRenderer")}enableEdgesRendering(e,t,i){throw Ie("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}};zt.OCCLUSION_TYPE_NONE=0;zt.OCCLUSION_TYPE_OPTIMISTIC=1;zt.OCCLUSION_TYPE_STRICT=2;zt.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;zt.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;zt.CULLINGSTRATEGY_STANDARD=0;zt.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;zt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;zt.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;zt.DefaultIsPickable=!0;C([rr.filter((...n)=>!Array.isArray(n[0])&&!Array.isArray(n[3])&&!Array.isArray(n[4])&&!Array.isArray(n[5])&&!Array.isArray(n[6]))],zt,"_ApplySkeleton",null);je("BABYLON.AbstractMesh",zt)});var Di,xM=A(()=>{Qe();Kt();qe();Di=class{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=519,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681,this.backFunc=519,this.backOpStencilFail=7680,this.backOpDepthFail=7680,this.backOpStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get backFunc(){return this._backFunc}set backFunc(e){this._backFunc=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail=e}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail=e}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){Me.Clone(()=>e,this)}serialize(){return Me.Serialize(this)}parse(e,t,i){Me.Parse(()=>this,e,t,i)}};C([D()],Di.prototype,"func",null);C([D()],Di.prototype,"backFunc",null);C([D()],Di.prototype,"funcRef",null);C([D()],Di.prototype,"funcMask",null);C([D()],Di.prototype,"opStencilFail",null);C([D()],Di.prototype,"opDepthFail",null);C([D()],Di.prototype,"opStencilDepthPass",null);C([D()],Di.prototype,"backOpStencilFail",null);C([D()],Di.prototype,"backOpDepthFail",null);C([D()],Di.prototype,"backOpStencilDepthPass",null);C([D()],Di.prototype,"mask",null);C([D()],Di.prototype,"enabled",null)});function Li(n){n.indexOf("vClipPlane")===-1&&n.push("vClipPlane"),n.indexOf("vClipPlane2")===-1&&n.push("vClipPlane2"),n.indexOf("vClipPlane3")===-1&&n.push("vClipPlane3"),n.indexOf("vClipPlane4")===-1&&n.push("vClipPlane4"),n.indexOf("vClipPlane5")===-1&&n.push("vClipPlane5"),n.indexOf("vClipPlane6")===-1&&n.push("vClipPlane6")}function kn(n,e,t){var c,f,d,h,u,m;let i=!!((c=n.clipPlane)!=null?c:e.clipPlane),r=!!((f=n.clipPlane2)!=null?f:e.clipPlane2),s=!!((d=n.clipPlane3)!=null?d:e.clipPlane3),a=!!((h=n.clipPlane4)!=null?h:e.clipPlane4),o=!!((u=n.clipPlane5)!=null?u:e.clipPlane5),l=!!((m=n.clipPlane6)!=null?m:e.clipPlane6);i&&t.push("#define CLIPPLANE"),r&&t.push("#define CLIPPLANE2"),s&&t.push("#define CLIPPLANE3"),a&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),l&&t.push("#define CLIPPLANE6")}function CM(n,e,t){var f,d,h,u,m,p;let i=!1,r=!!((f=n.clipPlane)!=null?f:e.clipPlane),s=!!((d=n.clipPlane2)!=null?d:e.clipPlane2),a=!!((h=n.clipPlane3)!=null?h:e.clipPlane3),o=!!((u=n.clipPlane4)!=null?u:e.clipPlane4),l=!!((m=n.clipPlane5)!=null?m:e.clipPlane5),c=!!((p=n.clipPlane6)!=null?p:e.clipPlane6);return t.CLIPPLANE!==r&&(t.CLIPPLANE=r,i=!0),t.CLIPPLANE2!==s&&(t.CLIPPLANE2=s,i=!0),t.CLIPPLANE3!==a&&(t.CLIPPLANE3=a,i=!0),t.CLIPPLANE4!==o&&(t.CLIPPLANE4=o,i=!0),t.CLIPPLANE5!==l&&(t.CLIPPLANE5=l,i=!0),t.CLIPPLANE6!==c&&(t.CLIPPLANE6=c,i=!0),i}function Pi(n,e,t){var r,s,a,o,l,c;let i=(r=e.clipPlane)!=null?r:t.clipPlane;Ll(n,"vClipPlane",i),i=(s=e.clipPlane2)!=null?s:t.clipPlane2,Ll(n,"vClipPlane2",i),i=(a=e.clipPlane3)!=null?a:t.clipPlane3,Ll(n,"vClipPlane3",i),i=(o=e.clipPlane4)!=null?o:t.clipPlane4,Ll(n,"vClipPlane4",i),i=(l=e.clipPlane5)!=null?l:t.clipPlane5,Ll(n,"vClipPlane5",i),i=(c=e.clipPlane6)!=null?c:t.clipPlane6,Ll(n,"vClipPlane6",i)}function Ll(n,e,t){var i;if(t){let r=((i=Vr.getScene())==null?void 0:i.floatingOriginOffset)||v.ZeroReadOnly;n.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+v.Dot(t.normal,r))}}var Wn=A(()=>{cf();ve()});var ie,zr=A(()=>{ii();ie=class{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,fe.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,fe.MarkAllMaterialsAsDirty(1))}};ie._DiffuseTextureEnabled=!0;ie._BaseWeightTextureEnabled=!0;ie._BaseDiffuseRoughnessTextureEnabled=!0;ie._DetailTextureEnabled=!0;ie._DecalMapEnabled=!0;ie._AmbientTextureEnabled=!0;ie._OpacityTextureEnabled=!0;ie._ReflectionTextureEnabled=!0;ie._EmissiveTextureEnabled=!0;ie._SpecularTextureEnabled=!0;ie._BumpTextureEnabled=!0;ie._LightmapTextureEnabled=!0;ie._RefractionTextureEnabled=!0;ie._ColorGradingTextureEnabled=!0;ie._FresnelEnabled=!0;ie._ClearCoatTextureEnabled=!0;ie._ClearCoatBumpTextureEnabled=!0;ie._ClearCoatTintTextureEnabled=!0;ie._SheenTextureEnabled=!0;ie._AnisotropicTextureEnabled=!0;ie._ThicknessTextureEnabled=!0;ie._RefractionIntensityTextureEnabled=!0;ie._TranslucencyIntensityTextureEnabled=!0;ie._TranslucencyColorTextureEnabled=!0;ie._IridescenceTextureEnabled=!0});function Ta(n,e,t){if(!n||n.LOGARITHMICDEPTH||n.indexOf&&n.indexOf("LOGARITHMICDEPTH")>=0){let i=t.activeCamera;i.mode===1&&W.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}var bM=A(()=>{ze()});function Sa(n,e,t,i=!1){t&&n.fogEnabled&&(!e||e.applyFog)&&n.fogMode!==0&&(t.setFloat4("vFogInfos",n.fogMode,n.fogStart,n.fogEnd,n.fogDensity),i?(n.fogColor.toLinearSpaceToRef(MM,n.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",MM)):t.setColor3("vFogColor",n.fogColor))}function Hn(n,e,t,i,r,s,a,o,l,c){let f=n.numMaxInfluencers||n.numInfluencers;return f<=0?0:(e.push("#define MORPHTARGETS"),n.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),n.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),n.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),n.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),n.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),n.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),n.supportsPositions&&r&&e.push("#define MORPHTARGETS_POSITION"),n.supportsNormals&&s&&e.push("#define MORPHTARGETS_NORMAL"),n.supportsTangents&&a&&e.push("#define MORPHTARGETS_TANGENT"),n.supportsUVs&&o&&e.push("#define MORPHTARGETS_UV"),n.supportsUV2s&&l&&e.push("#define MORPHTARGETS_UV2"),n.supportsColors&&c&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+f),n.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),Co.NUM_MORPH_INFLUENCERS=f,Co.NORMAL=s,Co.TANGENT=a,Co.UV=o,Co.UV2=l,Co.COLOR=c,bo(t,i,Co,r),f)}function bo(n,e,t,i=!0){let r=t.NUM_MORPH_INFLUENCERS;if(r>0&&ue.LastCreatedEngine){let s=ue.LastCreatedEngine.getCaps().maxVertexAttribs,a=e.morphTargetManager;if(a!=null&&a.isUsingTextureForTargets)return;let o=a&&a.supportsPositions&&i,l=a&&a.supportsNormals&&t.NORMAL,c=a&&a.supportsTangents&&t.TANGENT,f=a&&a.supportsUVs&&t.UV1,d=a&&a.supportsUV2s&&t.UV2,h=a&&a.supportsColors&&t.VERTEXCOLOR;for(let u=0;us&&W.Error("Cannot add more vertex attributes for mesh "+e.name)}}function gn(n,e=!1){n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"),e&&(n.push("previousWorld0"),n.push("previousWorld1"),n.push("previousWorld2"),n.push("previousWorld3"))}function Oi(n,e){let t=n.morphTargetManager;!n||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function Aa(n,e){e.bindToEffect(n,"Scene")}function Pl(n,e,t,i,r=null,s=!1,a=!1,o=!1,l=!1,c=!1,f=!1,d=0){if(n.texturesEnabled&&r&&ie.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",r.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",r.level*n.iblIntensity,d),o&&r.boundingBoxSize){let h=r;t.updateVector3("vReflectionPosition",h.boundingBoxPosition),t.updateVector3("vReflectionSize",h.boundingBoxSize)}if(s){let h=r.getSize().width;t.updateFloat2("vReflectionFilteringInfo",h,Math.log2(h))}if(c&&!e.USEIRRADIANCEMAP){let h=r.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&h)if(e.SPHERICAL_HARMONICS){let u=h.preScaledHarmonics;t.updateVector3("vSphericalL00",u.l00),t.updateVector3("vSphericalL1_1",u.l1_1),t.updateVector3("vSphericalL10",u.l10),t.updateVector3("vSphericalL11",u.l11),t.updateVector3("vSphericalL2_2",u.l2_2),t.updateVector3("vSphericalL2_1",u.l2_1),t.updateVector3("vSphericalL20",u.l20),t.updateVector3("vSphericalL21",u.l21),t.updateVector3("vSphericalL22",u.l22)}else t.updateFloat3("vSphericalX",h.x.x,h.x.y,h.x.z),t.updateFloat3("vSphericalY",h.y.x,h.y.y,h.y.z),t.updateFloat3("vSphericalZ",h.z.x,h.z.y,h.z.z),t.updateFloat3("vSphericalXX_ZZ",h.xx.x-h.zz.x,h.xx.y-h.zz.y,h.xx.z-h.zz.z),t.updateFloat3("vSphericalYY_ZZ",h.yy.x-h.zz.x,h.yy.y-h.zz.y,h.yy.z-h.zz.z),t.updateFloat3("vSphericalZZ",h.zz.x,h.zz.y,h.zz.z),t.updateFloat3("vSphericalXY",h.xy.x,h.xy.y,h.xy.z),t.updateFloat3("vSphericalYZ",h.yz.x,h.yz.y,h.yz.z),t.updateFloat3("vSphericalZX",h.zx.x,h.zx.y,h.zx.z)}else l&&e.USEIRRADIANCEMAP&&e.USE_IRRADIANCE_DOMINANT_DIRECTION&&r.irradianceTexture&&t.updateVector3("vReflectionDominantDirection",r.irradianceTexture._dominantDirection);a&&t.updateFloat3("vReflectionMicrosurfaceInfos",r.getSize().width,r.lodGenerationScale,r.lodGenerationOffset)}f&&t.updateColor3("vReflectionColor",i)}function iu(n,e,t,i=null,r=!1){if(i&&ie.ReflectionTextureEnabled){e.LODBASEDMICROSFURACE?t.setTexture("reflectionSampler",i):(t.setTexture("reflectionSampler",i._lodTextureMid||i),t.setTexture("reflectionSamplerLow",i._lodTextureLow||i),t.setTexture("reflectionSamplerHigh",i._lodTextureHigh||i)),e.USEIRRADIANCEMAP&&t.setTexture("irradianceSampler",i.irradianceTexture);let s=n.iblCdfGenerator;r&&s&&t.setTexture("icdfSampler",s.getIcdfTexture())}}function ot(n,e,t){e._needUVs=!0,e[t]=!0,n.optimizeUVAllocation&&n.getTextureMatrix().isIdentityAs3x2()?(e[t+"DIRECTUV"]=n.coordinatesIndex+1,e["MAINUV"+(n.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function lt(n,e,t){let i=n.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function Ol(n,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&n.push("bakedVertexAnimationSettingsInstanced")}function bk(n,e){return e.set(n),e}function or(n,e,t){if(!(!e||!n)&&(n.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(n.computeBonesUsingShaders=!1),n.useBones&&n.computeBonesUsingShaders&&n.skeleton)){let i=n.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureInfo")>-1){let r=i.getTransformMatrixTexture(n);e.setTexture("boneSampler",r),e.setFloat2("boneTextureInfo",i._textureWidth,i._textureHeight)}else{let r=i.getTransformMatrices(n);r&&(e.setMatrices("mBones",r),t&&n.getScene().prePassRenderer&&n.getScene().prePassRenderer.getIndex(2)&&(t.previousBones[n.uniqueId]||(t.previousBones[n.uniqueId]=r.slice()),e.setMatrices("mPreviousBones",t.previousBones[n.uniqueId]),bk(r,t.previousBones[n.uniqueId])))}}}function Mk(n,e,t,i,r,s=!0){n._bindLight(e,t,i,r,s)}function Nl(n,e,t,i,r=4){let s=Math.min(e.lightSources.length,r);for(let a=0;a0&&(i.addCPUSkinningFallback(0,e),n.push("matricesIndices"),n.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(n.push("matricesIndicesExtra"),n.push("matricesWeightsExtra")))}function wl(n,e){(e.INSTANCES||e.THIN_INSTANCES)&&gn(n,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&n.push("instanceColor")}function Bl(n,e,t=4,i=0){let r=0;for(let s=0;s0&&(r=i+s,e.addFallback(r,"LIGHT"+s)),n.SHADOWS||(n["SHADOW"+s]&&e.addFallback(i,"SHADOW"+s),n["SHADOWPCF"+s]&&e.addFallback(i,"SHADOWPCF"+s),n["SHADOWPCSS"+s]&&e.addFallback(i,"SHADOWPCSS"+s),n["SHADOWPOISSON"+s]&&e.addFallback(i,"SHADOWPOISSON"+s),n["SHADOWESM"+s]&&e.addFallback(i,"SHADOWESM"+s),n["SHADOWCLOSEESM"+s]&&e.addFallback(i,"SHADOWCLOSEESM"+s));return r}function yk(n,e){return e.fogEnabled&&n.applyFog&&e.fogMode!==0}function Ul(n,e,t,i,r,s,a,o=!1,l=!1,c,f){var d;if(a._areMiscDirty){a.LOGARITHMICDEPTH=t,a.POINTSIZE=i,a.FOG=r&&yk(n,e),a.NONUNIFORMSCALING=n.nonUniformScaling,a.ALPHATEST=s,a.DECAL_AFTER_DETAIL=o,a.USE_VERTEX_PULLING=l,a.RIGHT_HANDED=e.useRightHandedSystem;let h=(d=c==null?void 0:c.geometry)==null?void 0:d.getIndexBuffer(),u=c?c.isUnIndexed:!1;a.VERTEX_PULLING_USE_INDEX_BUFFER=!!h&&!u,a.VERTEX_PULLING_INDEX_BUFFER_32BITS=h&&!u?h.is32Bits:!1,a.VERTEXOUTPUT_INVARIANT=!!f}}function Vl(n,e,t,i=!1){if(!n.lightsEnabled||i)return!0;let r=e.lightSources,s=Math.min(r.length,t);for(let a=0;a0?(t.NUM_SAMPLES=""+r,a._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,n.iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===ne.INVCUBIC_MODE,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&n.useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case ne.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case ne.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case ne.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case ne.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case ne.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case ne.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case ne.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case ne.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case ne.CUBIC_MODE:case ne.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize;break}e.coordinatesMode!==ne.SKYBOX_MODE&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,e.irradianceTexture._dominantDirection?t.USE_IRRADIANCE_DOMINANT_DIRECTION=!0:t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=s))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1;return!0}function Dk(n,e,t,i,r,s,a){var o;switch(a.needNormals=!0,r["LIGHT"+i]===void 0&&(a.needRebuild=!0),r["LIGHT"+i]=!0,r["SPOTLIGHT"+i]=!1,r["HEMILIGHT"+i]=!1,r["POINTLIGHT"+i]=!1,r["DIRLIGHT"+i]=!1,r["AREALIGHT"+i]=!1,r["CLUSTLIGHT"+i]=!1,t.prepareLightSpecificDefines(r,i),r["LIGHT_FALLOFF_PHYSICAL"+i]=!1,r["LIGHT_FALLOFF_GLTF"+i]=!1,r["LIGHT_FALLOFF_STANDARD"+i]=!1,t.falloffType){case it.FALLOFF_GLTF:r["LIGHT_FALLOFF_GLTF"+i]=!0;break;case it.FALLOFF_PHYSICAL:r["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case it.FALLOFF_STANDARD:r["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(s&&!t.specular.equalsFloats(0,0,0)&&(a.specularEnabled=!0),r["SHADOW"+i]=!1,r["SHADOWCSM"+i]=!1,r["SHADOWCSMDEBUG"+i]=!1,r["SHADOWCSMNUM_CASCADES"+i]=!1,r["SHADOWCSMUSESHADOWMAXZ"+i]=!1,r["SHADOWCSMNOBLEND"+i]=!1,r["SHADOWCSM_RIGHTHANDED"+i]=!1,r["SHADOWPCF"+i]=!1,r["SHADOWPCSS"+i]=!1,r["SHADOWPOISSON"+i]=!1,r["SHADOWESM"+i]=!1,r["SHADOWCLOSEESM"+i]=!1,r["SHADOWCUBE"+i]=!1,r["SHADOWLOWQUALITY"+i]=!1,r["SHADOWMEDIUMQUALITY"+i]=!1,e&&e.receiveShadows&&n.shadowsEnabled&&t.shadowEnabled){let l=(o=t.getShadowGenerator(n.activeCamera))!=null?o:t.getShadowGenerator();if(l){let c=l.getShadowMap();c&&c.renderList&&c.renderList.length>0&&(a.shadowEnabled=!0,l.prepareDefines(r,i))}}t.lightmapMode!=it.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+i]=!0,r["LIGHTMAPNOSPECULAR"+i]=t.lightmapMode==it.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+i]=!1,r["LIGHTMAPNOSPECULAR"+i]=!1)}function kl(n,e,t,i,r,s=null,a=!1){let o=Nk(n,i);s!==!1&&(o=CM(t,n,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==r&&(i.INSTANCES=r,o=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,o=!0),o&&i.markAsUnprocessed()}function Lk(n,e){if(n.useBones&&n.computeBonesUsingShaders&&n.skeleton){e.NUM_BONE_INFLUENCERS=n.numBoneInfluencers;let t=e.BONETEXTURE!==void 0;if(n.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=n.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;let i=n.getScene().prePassRenderer;if(i&&i.enabled){let r=i.excludedSkinnedMesh.indexOf(n)===-1;e.BONES_VELOCITY_ENABLED=r}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function Pk(n,e){let t=n.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_UV2=t.supportsUV2s&&e.UV2,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,e.MORPHTARGETS_POSITION=t.supportsPositions,e.MORPHTARGETS_COLOR=t.supportsColors,e.MORPHTARGETTEXTURE_HASUVS=t.hasUVs,e.MORPHTARGETTEXTURE_HASUV2S=t.hasUV2s,e.MORPHTARGETTEXTURE_HASTANGENTS=t.hasTangents,e.MORPHTARGETTEXTURE_HASNORMALS=t.hasNormals,e.MORPHTARGETTEXTURE_HASPOSITIONS=t.hasPositions,e.MORPHTARGETTEXTURE_HASCOLORS=t.hasColors,e.NUM_MORPH_INFLUENCERS=t.numMaxInfluencers||t.numInfluencers,e.MORPHTARGETS=e.NUM_MORPH_INFLUENCERS>0,e.MORPHTARGETS_TEXTURE=t.isUsingTextureForTargets):(e.MORPHTARGETS_UV=!1,e.MORPHTARGETS_UV2=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_POSITION=!1,e.MORPHTARGETS_COLOR=!1,e.MORPHTARGETTEXTURE_HASUVS=!1,e.MORPHTARGETTEXTURE_HASUV2S=!1,e.MORPHTARGETTEXTURE_HASTANGENTS=!1,e.MORPHTARGETTEXTURE_HASNORMALS=!1,e.MORPHTARGETTEXTURE_HASPOSITIONS=!1,e.MORPHTARGETTEXTURE_HAS_COLORS=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function Ok(n,e){let t=n.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function Wl(n,e,t,i,r=!1,s=!0,a=!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&&n.isVerticesDataPresent("normal"),e._needNormals&&n.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let o=1;o<=6;++o)e["UV"+o]=e._needUVs?n.isVerticesDataPresent(`uv${o===1?"":o}`):!1;if(t){let o=n.useVertexColors&&n.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=n.hasVertexAlpha&&o&&s}return n.isVerticesDataPresent("instanceColor")&&(n.hasInstances||n.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&Lk(n,e),r&&Pk(n,e),a&&Ok(n,e),!0}function Hl(n,e){if(n.activeCamera){let t=e.MULTIVIEW;e.MULTIVIEW=n.activeCamera.outputRenderTarget!==null&&n.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function zl(n,e,t){let i=e.ORDER_INDEPENDENT_TRANSPARENCY,r=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;e.ORDER_INDEPENDENT_TRANSPARENCY=n.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!n.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||r!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function Xl(n,e,t){let i=e.PREPASS;if(!e._arePrePassDirty)return;let r=[{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_LEGACY",index:"PREPASS_IRRADIANCE_LEGACY_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"},{type:14,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"}];if(n.prePassRenderer&&n.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=n.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=n.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let s=0;s{ze();At();$c();Wn();zr();oi();bM();MM={r:0,g:0,b:0},Co={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1}});var ae,Fi=A(()=>{Qe();qe();Tt();ft();At();Sf();ma();ze();fo();go();xM();Ni();Kt();d_();ae=class n{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(e){this._useVertexPulling!==e&&(this._useVertexPulling=e,this.markAsDirty(n.MiscDirtyFlag))}get _supportGlowLayer(){return!1}set _glowModeEnabled(e){}get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;let t=this._alpha;this._alpha=e,(t===1||e===1)&&this.markAsDirty(n.MiscDirtyFlag+n.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(n.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(n.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 Y),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 Y),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new Y),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode[0]!==e&&(this._alphaMode[0]=e,this.markAsDirty(n.TextureDirtyFlag))}get alphaMode(){return this._alphaMode[0]}get alphaModes(){return this._alphaMode}setAlphaMode(e,t=0){this._alphaMode[t]!==e&&(this._alphaMode[t]=e,this.markAsDirty(n.TextureDirtyFlag))}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(n.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case n.WireFrameFillMode:case n.LineListDrawMode:case n.LineLoopDrawMode:case n.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?n.WireFrameFillMode:n.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case n.PointFillMode:case n.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?n.PointFillMode:n.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(n.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){let t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&W.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}get isVertexOutputInvariant(){return this._isVertexOutputInvariant}set isVertexOutputInvariant(e){this._isVertexOutputInvariant!==e&&(this._isVertexOutputInvariant=e,this._markAllSubMeshesAsMiscDirty())}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,i,r=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this._useVertexPulling=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new Y,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 Di,this._isVertexOutputInvariant=n.ForceVertexOutputInvariant,this._useUBO=!1,this._fillMode=n.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._transparencyMode=null,this.name=e;let s=t||ue.LastCreatedScene;s&&(this._scene=s,this._dirtyCallbacks={},this._forceGLSL=r,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[127]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||re.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new zi(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new Ut(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={}),n.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){var t;let e=this.getScene().getEngine();(t=this._uniformBuffer)==null||t.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new Ut(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new Ut(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){let r=t.materialDefines;return r?(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=r,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh):!1}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return this.sideOrientation!==null?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _hasTransparencyMode(){return this._transparencyMode!=null}get _transparencyModeIsBlend(){return this._transparencyMode===n.MATERIAL_ALPHABLEND||this._transparencyMode===n.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===n.MATERIAL_ALPHATEST||this._transparencyMode===n.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===n.MATERIAL_OPAQUE||this._transparencyMode===n.MATERIAL_ALPHATEST}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsBlend:e.visibility<1?!0:this._disableAlphaBlending?!1:e.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:!1}needAlphaTestingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsTest:!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){let t=this.getScene().meshes;for(let i of t)if(i.subMeshes){for(let r of i.subMeshes)if(r.getMaterial()===this)for(let s of r._drawWrappers)s&&this._materialContext===s.materialContext&&(s._wasPreviouslyReady=!1,s._wasPreviouslyUsingInstances=null,s._forceRebindOnNextCall=e)}e&&this.markAsDirty(n.AllDirtyFlag)}_preBind(e,t=null){let i=this._scene.getEngine(),s=(t==null?this.sideOrientation:t)===n.ClockWiseSideOrientation,a=e||this._getDrawWrapper();return qd(a)&&a.materialContext&&(a.materialContext.useVertexPulling=this.useVertexPulling),i.enableEffect(a),i.setState(this.backFaceCulling,this.zOffset,!1,s,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),s}bind(e,t){}buildUniformLayout(){let e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,i){let r=i._drawWrapper;this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),r._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()),e.setMatrix("inverseProjection",this.getScene().getInverseProjectionMatrix()))}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,Aa(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){let r=this._scene.getEngine();this._cachedDepthWriteState=r.getDepthWrite(),r.setDepthWrite(!1)}if(this.disableColorWrite){let r=this._scene.getEngine();this._cachedColorWriteState=r.getColorWrite(),r.setColorWrite(!1)}if(this.depthFunction!==0){let r=this._scene.getEngine();this._cachedDepthFunctionState=r.getDepthFunction()||0,r.setDepthFunction(this.depthFunction)}}unbind(){this._scene.getSceneUniformBuffer().unbindEffect(),this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){let i={};if(this._serializePlugins(i),n._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(let r of this.pluginManager._plugins){let s=e.pluginManager.getPlugin(r.name);s&&r.copyTo(s)}}getBindedMeshes(){if(this.meshMap){let e=[];for(let t in this.meshMap){let i=this.meshMap[t];i&&e.push(i)}return e}else return this._scene.meshes.filter(t=>t.material===this)}forceCompilation(e,t,i,r){let s={clipPlane:!1,useInstances:!1,...i},a=this.getScene(),o=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;let l=()=>{if(!this._scene||!this._scene.getEngine())return;let c=a.clipPlane;if(s.clipPlane&&(a.clipPlane=new ir(0,0,0,1)),this._storeEffectOnSubMeshes){let f=!0,d=null;if(e.subMeshes){let h=new ar(0,0,0,0,0,e,void 0,!1,!1);h.materialDefines&&(h.materialDefines._renderId=-1),this.isReadyForSubMesh(e,h,s.useInstances)||(h.effect&&h.effect.getCompilationError()&&h.effect.allFallbacksProcessed()?d=h.effect.getCompilationError():(f=!1,setTimeout(l,16)))}f&&(this.allowShaderHotSwapping=o,d&&r&&r(d),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=o,t&&t(this)):setTimeout(l,16);s.clipPlane&&(a.clipPlane=c)};l()}async forceCompilationAsync(e,t){return await new Promise((i,r)=>{this.forceCompilation(e,()=>{i()},t,s=>{r(s)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(n._DirtyCallbackArray.length=0,e&n.ImageProcessingDirtyFlag&&n._DirtyCallbackArray.push(n._ImageProcessingDirtyCallBack),e&n.TextureDirtyFlag&&n._DirtyCallbackArray.push(n._TextureDirtyCallBack),e&n.LightDirtyFlag&&n._DirtyCallbackArray.push(n._LightsDirtyCallBack),e&n.FresnelDirtyFlag&&n._DirtyCallbackArray.push(n._FresnelDirtyCallBack),e&n.AttributesDirtyFlag&&n._DirtyCallbackArray.push(n._AttributeDirtyCallBack),e&n.MiscDirtyFlag&&n._DirtyCallbackArray.push(n._MiscDirtyCallBack),e&n.PrePassDirtyFlag&&n._DirtyCallbackArray.push(n._PrePassDirtyCallBack),n._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(n._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){let e=this.getScene().meshes;for(let t of e)if(t.subMeshes)for(let i of t.subMeshes)i.getMaterial()===this&&i.resetDrawCache()}_markAllSubMeshesAsDirty(e){let t=this.getScene();if(t.blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;let i=t.meshes;for(let r of i)if(r.subMeshes){for(let s of r.subMeshes)if((s.getMaterial()||(t._hasDefaultMaterial?t.defaultMaterial:null))===this)for(let o of s._drawWrappers)!o||!o.defines||!o.defines.markAllAsDirty||this._materialContext===o.materialContext&&e(o.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;let e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(n._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(n._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(n._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(n._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(n._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(n._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(n._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(n._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(n._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(n._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;let e=this._scene.onScenePerformancePriorityChangedObservable.addOnce(()=>{this.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)})}}setPrePassRenderer(e){return!1}dispose(e,t,i){let r=this.getScene();if(r.stopAnimation(this),r.freeProcessedMaterials(),r.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){let s=this._parentContainer.materials.indexOf(this);s>-1&&this._parentContainer.materials.splice(s,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(let s in this.meshMap){let a=this.meshMap[s];this._disposeMeshResources(a)}else{let s=r.meshes;for(let a of s)this._disposeMeshResources(a)}this._uniformBuffer.dispose(),this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}_disposeMeshResources(e){var r;if(!e)return;let t=e.geometry,i=e._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(e.subMeshes&&i)for(let s of e.subMeshes){let a=s._drawWrappers;for(let o=0;on.markAllAsDirty();ae._ImageProcessingDirtyCallBack=n=>n.markAsImageProcessingDirty();ae._TextureDirtyCallBack=n=>n.markAsTexturesDirty();ae._FresnelDirtyCallBack=n=>n.markAsFresnelDirty();ae._MiscDirtyCallBack=n=>n.markAsMiscDirty();ae._PrePassDirtyCallBack=n=>n.markAsPrePassDirty();ae._LightsDirtyCallBack=n=>n.markAsLightDirty();ae._AttributeDirtyCallBack=n=>n.markAsAttributesDirty();ae._FresnelAndMiscDirtyCallBack=n=>{ae._FresnelDirtyCallBack(n),ae._MiscDirtyCallBack(n)};ae._TextureAndMiscDirtyCallBack=n=>{ae._TextureDirtyCallBack(n),ae._MiscDirtyCallBack(n)};ae._DirtyCallbackArray=[];ae._RunDirtyCallBacks=n=>{for(let e of ae._DirtyCallbackArray)e(n)};C([D()],ae.prototype,"id",void 0);C([D()],ae.prototype,"uniqueId",void 0);C([D()],ae.prototype,"name",void 0);C([D()],ae.prototype,"metadata",void 0);C([D()],ae.prototype,"checkReadyOnEveryCall",void 0);C([D()],ae.prototype,"checkReadyOnlyOnce",void 0);C([D()],ae.prototype,"state",void 0);C([D("alpha")],ae.prototype,"_alpha",void 0);C([D("backFaceCulling")],ae.prototype,"_backFaceCulling",void 0);C([D("cullBackFaces")],ae.prototype,"_cullBackFaces",void 0);C([D()],ae.prototype,"sideOrientation",void 0);C([D()],ae.prototype,"_alphaMode",void 0);C([D()],ae.prototype,"_needDepthPrePass",void 0);C([D()],ae.prototype,"disableDepthWrite",void 0);C([D()],ae.prototype,"disableColorWrite",void 0);C([D()],ae.prototype,"forceDepthWrite",void 0);C([D()],ae.prototype,"depthFunction",void 0);C([D()],ae.prototype,"separateCullingPass",void 0);C([D("fogEnabled")],ae.prototype,"_fogEnabled",void 0);C([D()],ae.prototype,"pointSize",void 0);C([D()],ae.prototype,"zOffset",void 0);C([D()],ae.prototype,"zOffsetUnits",void 0);C([D()],ae.prototype,"pointsCloud",null);C([D()],ae.prototype,"fillMode",null);C([D()],ae.prototype,"useLogarithmicDepth",null);C([D()],ae.prototype,"_isVertexOutputInvariant",void 0);C([D()],ae.prototype,"transparencyMode",null)});var jl,yM=A(()=>{Fi();ha();Lt();jl=class n extends ae{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){let t=e.push;e.push=(...r)=>{let s=t.apply(e,r);return this._markAllSubMeshesAsTexturesDirty(),s};let i=e.splice;e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);return this._markAllSubMeshesAsTexturesDirty(),a}}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=0&&r.multiMaterials.splice(s,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){let i=new n(e.name,t);if(i.id=e.id,i._loadedUniqueId=e.uniqueId,nt&&nt.AddTagsTo(i,e.tags),e.materialsUniqueIds)i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds;else for(let r of e.materials)i.subMaterials.push(t.getLastMaterialById(r));return i}};je("BABYLON.MultiMaterial",jl)});var ru,DM=A(()=>{ru=class{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}});var Zl,nu,cE,su,fE,dE,zn,V,Rt=A(()=>{ft();Tt();Qc();ha();iE();Gn();ve();et();Sr();yt();Vt();$h();Dl();Sf();Fi();yM();Jh();Kt();ze();Lt();Ei();vl();DM();Zl=class{},nu=class{constructor(){this.batchCache=new su(this),this.batchCacheReplacementModeInFrozenMode=new su(this),this.instancesBufferSize=512*4}},cE=class{constructor(){this.renderPasses={}}},su=class{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}},fE=class{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}},dE=class{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}},zn={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1},V=class n extends zt{static _GetDefaultSideOrientation(e){return e||n.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(M.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(M.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 Y),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new Y),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new Y),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new Y),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new Y),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===1||!this._scene.useRightHandedSystem&&e===0}get _effectiveSideOrientation(){return this._internalMeshDataInfo._effectiveSideOrientation}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&this.material.sideOrientation===null||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){let e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesData:void 0}get previousWorldMatrixInstancedBuffer(){let e=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];return e?e.instancesPreviousData:void 0}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,i=!0,r=!1){var a,o;let s=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),wn.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){let l=e._ranges;for(let c in l)Object.prototype.hasOwnProperty.call(l,c)&&l[c]&&this.createAnimationRange(c,l[c].from,l[c].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,nt&&nt.HasTags(e)&&nt.AddTagsTo(this,nt.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){let l=e.getDescendants(!0);for(let c=0;c{m&&_&&(this._uniformBuffer?this.transferToEffect(p):_.bindOnlyWorldMatrix(p))};let o,l=!1;if(i&&i._addToSceneRootNodes===void 0){let m=i;o=(c=m.parent)!=null?c:null,r=(f=m.source)!=null?f:null,s=(d=m.doNotCloneChildren)!=null?d:!1,a=(h=m.clonePhysicsImpostor)!=null?h:!0,l=(u=m.cloneThinInstances)!=null?u:!1}else o=i;r&&this._copySource(r,s,a,l),o!==null&&(this.parent=o),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=m=>{m.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 Y(this._internalMeshDataInfo._onMeshReadyObserverAdded),r&&r.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){let r=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));r.parent=e||this.parent,r.position=this.position.clone(),r.scaling=this.scaling.clone(),this.rotationQuaternion?r.rotationQuaternion=this.rotationQuaternion.clone():r.rotation=this.rotation.clone(),i&&i(this,r);for(let s of this.getChildTransformNodes(!0))s.getClassName()==="InstancedMesh"&&r.getClassName()==="Mesh"&&s.sourceMesh===this?s.instantiateHierarchy(r,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:r},i):s.instantiateHierarchy(r,t,i);return r}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;i0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){let e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((t,i)=>t.distanceOrScreenCoveragei.distanceOrScreenCoverage?-e:0)}addLODLevel(e,t){if(t&&t._masterMesh)return W.Warn("You cannot use a mesh as LOD level twice"),this;let i=new ru(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){let t=this._internalMeshDataInfo;for(let i=0;io*a)return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this;for(let l=0;l0||this.hasThinInstances);this.computeWorldMatrix();let a=this.material||r.defaultMaterial;if(a){if(a._storeEffectOnSubMeshes)for(let p of this.subMeshes){let _=p.getMaterial();if(_){if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,p,s))return!1}else if(!_.isReady(this,s))return!1}}else if(!a.isReady(this,s))return!1}let o=i.currentRenderPassId;for(let p of this.lightSources){let _=p.getShadowGenerators();if(!_)continue;let g=_.values();for(let T=g.next();T.done!==!0;T=g.next()){let b=T.value;if(b&&(!((l=b.getShadowMap())!=null&&l.renderList)||(c=b.getShadowMap())!=null&&c.renderList&&((d=(f=b.getShadowMap())==null?void 0:f.renderList)==null?void 0:d.indexOf(this))!==-1)){let S=(h=b.getShadowMap().renderPassIds)!=null?h:[i.currentRenderPassId];for(let I=0;I0){let i=this.getIndices();if(!i)return null;let r=i.length,s=!1;if(e)s=!0;else for(let a of this.subMeshes){if(a.indexStart+a.indexCount>r){s=!0;break}if(a.verticesStart+a.verticesCount>t){s=!0;break}}if(!s)return this.subMeshes[0]}return this.releaseSubMeshes(),new ar(0,0,t,0,this.getTotalIndices()||(this.isUnIndexed?t:0),this)}subdivide(e){if(e<1)return;let t=this.getTotalIndices(),i=t/e|0,r=0;for(;i%3!==0;)i++;this.releaseSubMeshes();for(let s=0;s=t);s++)ar.CreateFromIndices(0,r,r+i>=t?t-r:i,this,void 0,!1),r+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,r){if(this._geometry)this._geometry.setVerticesData(e,t,i,r);else{let s=new de;s.set(t,e);let a=this.getScene();new Si(Si.RandomId(),a,s,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){let i=this.getVertexBuffer(e);!i||i.isUpdatable()===t||this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0,i=null){return this._geometry||(this._geometry=Si.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,i,t),this}updateVerticesData(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){let i=this.getVerticesData(M.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(M.PositionKind,i,!1,!1),t){let r=this.getIndices(),s=this.getVerticesData(M.NormalKind);if(!s)return this;de.ComputeNormals(i,r,s),this.updateVerticesData(M.NormalKind,s,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;let e=this._geometry,t=this._geometry.copy(Si.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,r=null){let s=this._geometry;s||(s=new Si(Si.RandomId(),this.getScene(),void 0,void 0,this)),s.setIndexBuffer(e,t,i,r)}setIndices(e,t=null,i=!1,r=!1){if(this._geometry)this._geometry.setIndices(e,t,i,r);else{let s=new de;s.indices=e;let a=this.getScene();new Si(Si.RandomId(),a,s,i,this,t)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,r=!0){if(!this._geometry)return this;let s=this.getScene().getEngine(),a;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case ae.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),s);break;default:a=null;break}else switch(this._getRenderingFillMode(i)){case ae.PointFillMode:a=null;break;case ae.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),s);break;default:case ae.TriangleFillMode:a=this._geometry.getIndexBuffer();break}return this._bindDirect(t,a,r)}_bindDirect(e,t,i=!0){if(!this._geometry)return this;if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances)this._geometry._bind(e,t);else{if(!this._instanceDataStorage.useMonoDataStorageRenderPass&&this._userInstancedBuffersStorage.renderPasses&&this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId]){let r=this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];for(let s in r)this._userInstancedBuffersStorage.vertexBuffers[s]=r[s]}this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);let s=this.getScene().getEngine(),a=s._currentMaterialContext,o=a&&a.useVertexPulling;return this._unIndexed&&t!==ae.WireFrameFillMode||t==ae.PointFillMode?s.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==ae.WireFrameFillMode?s.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):o?s.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):s.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){let i=this._instanceDataStorage.useMonoDataStorageRenderPass?this._instanceDataStorage.dataStorageRenderPass:this._getInstanceDataStorage();if(this._instanceDataStorage.isFrozen){if(t)return i.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,i.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,i.batchCacheReplacementModeInFrozenMode;if(i.previousBatch)return i.previousBatch}let r=this.getScene(),s=r._isInIntermediateRendering(),a=s?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=i.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!a&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,i.visibleInstances&&!t){let l=i.visibleInstances,c=r.getRenderId(),f=s?l.intermediateDefaultRenderId:l.defaultRenderId;o.visibleInstances[e]=l[c],!o.visibleInstances[e]&&f&&(o.visibleInstances[e]=l[f])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&o.visibleInstances[e]!==null&&o.visibleInstances[e]!==void 0,i.previousBatch=o,o}_updateInstancedBuffers(e,t,i,r,s,a){var T;let o=t.visibleInstances[e._id],l=o?o.length:0,c=t.parent,f=this._instanceDataStorage,d=c.instancesBuffer,h=c.instancesPreviousBuffer,u=0,m=0,p=t.renderSelf[e._id],_=this._scene.floatingOriginOffset,g=!d||i!==c.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!c.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!f.isFrozen||g)){let b=this.getWorldMatrix();if(p){this._scene.needsPreviousWorldMatrices&&(f.masterMeshPreviousWorldMatrix?(f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u),f.masterMeshPreviousWorldMatrix.copyFrom(b)):(f.masterMeshPreviousWorldMatrix=b.clone(),f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u))),b.copyToArray(c.instancesData,u);let R=b.asArray();c.instancesData[u+12]=R[12]-_.x,c.instancesData[u+13]=R[13]-_.y,c.instancesData[u+14]=R[14]-_.z,u+=16,m++}if(o){if(n.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&((T=e.getMaterial())!=null&&T.needAlphaBlendingForMesh(e.getRenderingMesh()))){let R=this._scene.activeCamera.globalPosition;for(let S=0;SS._distanceToCamera>I._distanceToCamera?-1:S._distanceToCamera1&&r.activeCamera===r.activeCameras[0]||a<=1,l=this._occlusionDataStorage&&this._occlusionDataStorage.occlusionForRenderPassId!==-1&&this._occlusionDataStorage.occlusionForRenderPassId!==s.currentRenderPassId;if(o&&this._checkOcclusionQuery(l)&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;let c=this._getInstancesRenderList(e._id,!!i);if(c.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;let f=0,d=null;this.ignoreCameraMaxZ&&r.activeCamera&&!r._isInIntermediateRendering()&&(f=r.activeCamera.maxZ,d=r.activeCamera,r.activeCamera.maxZ=0,r.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);let h=e.getRenderingMesh(),u=c.hardwareInstancedRendering[e._id]||h.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,m=this._instanceDataStorage,p=e.getMaterial();if(!p)return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;if(!m.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==p){if(p._storeEffectOnSubMeshes){if(!p.isReadyForSubMesh(this,e,u))return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this}else if(!p.isReady(this,u))return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=p}else if(p._storeEffectOnSubMeshes&&!((y=e._drawWrapper)!=null&&y._wasPreviouslyReady)||!p._storeEffectOnSubMeshes&&!p._getDrawWrapper()._wasPreviouslyReady)return d&&(d.maxZ=f,r.updateTransformMatrix(!0)),this;if(t){let w=this._internalMeshDataInfo._effectiveMaterial;if(w.alphaModes.length===1)s.setAlphaMode(w.alphaMode);else for(let H=0;Hg&&r++,S!==0&&b++,T+=S,g=S}if(c[b]++,b>a&&(a=b),T===0)s++;else{let R=1/T,S=0;for(let I=0;If&&o++}}let d=this.skeleton.bones.length,h=this.getVerticesData(M.MatricesIndicesKind),u=this.getVerticesData(M.MatricesIndicesExtraKind),m=0;for(let _=0;_=d||T<0)&&m++}let p="Number of Weights = "+i/4+` Maximum influences = `+a+` Missing Weights = `+s+` Not Sorted = `+r+` Not Normalized = `+o+` WeightCounts = [`+c+`] Number of bones = `+d+` -Bad Bone Indices = `+m;return{skinned:!0,valid:s===0&&o===0&&m===0,report:p}}_checkDelayState(){let 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);let t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return re.LoadFile(this.delayLoadingFile,i=>{i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this);for(let r of this.instances)r.refreshBoundingInfo(),r._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){let t=this.getScene().materials,i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;let r=this.getScene().multiMaterials;for(i=r.length-1;i>-1;i--)if(r[i].id===e)return this.material=r[i],this;return this}getAnimatables(){let e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(M.PositionKind))return this;let t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(M.PositionKind),r=v.Zero(),s;for(s=0;s{let h=d.width,u=d.height,p=this.getEngine().createCanvas(h,u).getContext("2d");p.drawImage(d,0,0);let _=p.getImageData(0,0,h,u).data;this.applyDisplacementMapFromBuffer(_,h,u,t,i,s,a,o),r&&r(this)};return re.LoadImage(e,f,l||(()=>{}),c.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,r,s,a,o,l=!1){if(!this.isVerticesDataPresent(M.PositionKind)||!this.isVerticesDataPresent(M.NormalKind)||!this.isVerticesDataPresent(M.UVKind))return W.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;let c=this.getVerticesData(M.PositionKind,!0,!0),f=this.getVerticesData(M.NormalKind),d=this.getVerticesData(M.UVKind),h=v.Zero(),u=v.Zero(),m=_e.Zero();a=a||_e.Zero(),o=o||new _e(1,1);for(let p=0;p{var c;return!((c=this.getVertexBuffer(l))!=null&&c.getIsInstanced())}),i=this.getIndices(!1,!0),r={},s=(l,c)=>{let f=new Float32Array(i.length*c),d=0;for(let h=0;h{let o=r.length-1-a,l=r[o];for(let c=0;c{for(let o=0;o-1&&(r._waitingMorphTargetManagerId=e.morphTargetManagerId),e.skeletonId!==void 0&&e.skeletonId!==null&&(r.skeleton=t.getLastSkeletonById(e.skeletonId),r._waitingSkeletonId=e.skeletonId,e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.skeletonUniqueId!==void 0&&e.skeletonUniqueId!==null&&(r._waitingSkeletonUniqueId=e.skeletonUniqueId),e.animations){for(let a=0;a4,c=l?this.getVerticesData(M.MatricesIndicesExtraKind):null,f=l?this.getVerticesData(M.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),h=v.Zero(),u=new G,m=new G,p=0,_;for(let g=0;g0&&(G.FromFloat32ArrayToRefScaled(d,Math.floor(a[p+_]*16),T,m),u.addToSelf(m));if(l)for(_=0;_<4;_++)T=f[p+_],T>0&&(G.FromFloat32ArrayToRefScaled(d,Math.floor(c[p+_]*16),T,m),u.addToSelf(m));v.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],u,h),h.toArray(r,g),t&&(v.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],u,h),h.toArray(s,g)),u.reset()}return this.updateVerticesData(M.PositionKind,r),t&&this.updateVerticesData(M.NormalKind,s),this}static MinMax(e){let t=null,i=null;for(let r of e){let a=r.getBoundingInfo().boundingBox;!t||!i?(t=a.minimumWorld.clone(),i=a.maximumWorld.clone()):(t.minimizeInPlace(a.minimumWorld),i.maximizeInPlace(a.maximumWorld))}return!t||!i?{min:v.Zero(),max:v.Zero()}:{min:t,max:i}}static Center(e){let t=e instanceof Array?n.MinMax(e):e;return v.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,r,s,a){return Tf(n._MergeMeshesCoroutine(e,t,i,r,s,a,!1))}static async MergeMeshesAsync(e,t=!0,i,r,s,a){return await oM(n._MergeMeshesCoroutine(e,t,i,r,s,a,!0),sM())}static*_MergeMeshesCoroutine(e,t=!0,i,r,s,a,o){if(e=e.filter(Boolean),e.length===0)return null;let l;if(!i){let x=0;for(l=0;l=65536)return W.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}let c=e[0];a&&(s=!1,e.sort((x,P)=>{var L,y,B,w;return((y=(L=x.material)==null?void 0:L.uniqueId)!=null?y:-1)-((w=(B=P.material)==null?void 0:B.uniqueId)!=null?w:-1)}));let f=new Array,d=new Array,h=new Array,u=e[0].sideOrientation;for(l=0;lMath.max(L,y.start+y.count),0);if(a)if(x.material){let L=x.material;if(L instanceof jl){for(let y=0;y1){let x=0;for(let P=1;P{let P=x.computeWorldMatrix(!0);return{vertexData:de.ExtractFromMesh(x,!1,!1),transform:P}},{vertexData:p,transform:_}=m(e[0]);o&&(yield);let g=new Array(e.length-1);for(let x=1;x{throw Ie("GroundMesh")};U._GoldbergMeshParser=(n,e)=>{throw Ie("GoldbergMesh")};U._LinesMeshParser=(n,e)=>{throw Ie("LinesMesh")};U._GreasedLineMeshParser=(n,e)=>{throw Ie("GreasedLineMesh")};U._GreasedLineRibbonMeshParser=(n,e)=>{throw Ie("GreasedLineRibbonMesh")};U._TrailMeshParser=(n,e)=>{throw Ie("TrailMesh")};U._GaussianSplattingMeshParser=(n,e)=>{throw Ie("GaussianSplattingMesh")};U._GaussianSplattingPartProxyMeshParser=(n,e)=>{throw Ie("GaussianSplattingPartProxyMesh")};U._GaussianSplattingCompoundMeshParser=(n,e)=>{throw Ie("GaussianSplattingCompoundMesh")};je("BABYLON.Mesh",U)});var ql,cE=A(()=>{fn();rs();Ci();ql=class{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._attachedCamera=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;let t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ye.POINTERDOWN){this._isPointerDown=!0;return}i.type===ye.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;let i=kt.Now,r=0;this._lastFrameTime!=null&&(r=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();let s=i-this._lastInteractionTime-this._idleRotationWaitTime,a=Math.max(Math.min(s/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*a,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(r/1e3))})}detach(){if(!this._attachedCamera)return;let 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:kt.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha){uo();sr=class n{constructor(){this._easingMode=n.EASINGMODE_EASEIN}setEasingMode(e){let 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 n.EASINGMODE_EASEIN:return this.easeInCore(e);case n.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}};sr.EASINGMODE_EASEIN=0;sr.EASINGMODE_EASEOUT=1;sr.EASINGMODE_EASEINOUT=2;su=class extends sr{constructor(e=1){super(),this.amplitude=e}easeInCore(e){let t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}},au=class extends sr{easeInCore(e){return e*e*e}},ou=class extends sr{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)}}});var xa,fE=A(()=>{xa=class n{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new n(this.name,this.from,this.to)}}});var dE,hE,uE,mE,pE,_E,gn,Oe,Is=A(()=>{ve();et();bi();Lt();fE();vr();ah();mo();Kt();dE=Object.freeze(new Ae(0,0,0,0)),hE=Object.freeze(v.Zero()),uE=Object.freeze(_e.Zero()),mE=Object.freeze(as.Zero()),pE=Object.freeze(oe.Black()),_E=Object.freeze(new Ne(0,0,0,0)),gn={key:0,repeatCount:0,loopMode:2},Oe=class n{static _PrepareAnimation(e,t,i,r,s,a,o,l){let c;if(!isNaN(parseFloat(s))&&isFinite(s)?c=n.ANIMATIONTYPE_FLOAT:s instanceof Ae?c=n.ANIMATIONTYPE_QUATERNION:s instanceof v?c=n.ANIMATIONTYPE_VECTOR3:s instanceof _e?c=n.ANIMATIONTYPE_VECTOR2:s instanceof oe?c=n.ANIMATIONTYPE_COLOR3:s instanceof Ne?c=n.ANIMATIONTYPE_COLOR4:s instanceof as&&(c=n.ANIMATIONTYPE_SIZE),c==null)return null;let f=new n(e,t,i,c,o),d=[{frame:0,value:s},{frame:r,value:a}];return f.setKeys(d),l!==void 0&&f.setEasingFunction(l),f}static CreateAnimation(e,t,i,r){let s=new n(e+"Animation",e,i,t,n.ANIMATIONLOOPMODE_CONSTANT);return s.setEasingFunction(r),s}static CreateAndStartAnimation(e,t,i,r,s,a,o,l,c,f,d){let h=n._PrepareAnimation(e,i,r,s,a,o,l,c);return!h||(t.getScene&&(d=t.getScene()),!d)?null:d.beginDirectAnimation(t,[h],0,s,h.loopMode!==n.ANIMATIONLOOPMODE_CONSTANT,1,f)}static CreateAndStartHierarchyAnimation(e,t,i,r,s,a,o,l,c,f,d){let h=n._PrepareAnimation(e,r,s,a,o,l,c,f);return h?t.getScene().beginDirectHierarchyAnimation(t,i,[h],0,a,h.loopMode===1,1,d):null}static CreateMergeAndStartAnimation(e,t,i,r,s,a,o,l,c,f){let d=n._PrepareAnimation(e,i,r,s,a,o,l,c);return d?(t.animations.push(d),t.getScene().beginAnimation(t,0,s,d.loopMode===1,1,f)):null}static MakeAnimationAdditive(e,t,i,r=!1,s){var T,b;let a;typeof t=="object"?a=t:a={referenceFrame:t!=null?t:0,range:i,cloneOriginalAnimation:r,clonedAnimationName:s};let o=e;if(a.cloneOriginalAnimation&&(o=e.clone(),o.name=a.clonedAnimationName||o.name),!o._keys.length)return o;let l=a.referenceFrame&&a.referenceFrame>=0?a.referenceFrame:0,c=0,f=o._keys[0],d=o._keys.length-1,h=o._keys[d],u={referenceValue:f.value,referencePosition:k.Vector3[0],referenceQuaternion:k.Quaternion[0],referenceScaling:k.Vector3[1],keyPosition:k.Vector3[2],keyQuaternion:k.Quaternion[1],keyScaling:k.Vector3[3]},m=f.frame,p=h.frame;if(a.range){let R=o.getRange(a.range);R&&(m=R.from,p=R.to)}else m=(T=a.fromFrame)!=null?T:m,p=(b=a.toFrame)!=null?b:p;if(m!==f.frame&&(c=o.createKeyForFrame(m)),p!==h.frame&&(d=o.createKeyForFrame(p)),o._keys.length===1){let R=o._getKeyValue(o._keys[0]);u.referenceValue=R.clone?R.clone():R}else if(l<=f.frame){let R=o._getKeyValue(f.value);u.referenceValue=R.clone?R.clone():R}else if(l>=h.frame){let R=o._getKeyValue(h.value);u.referenceValue=R.clone?R.clone():R}else{gn.key=0;let R=o._interpolate(l,gn);u.referenceValue=R.clone?R.clone():R}o.dataType===n.ANIMATIONTYPE_QUATERNION?u.referenceValue.normalize().conjugateInPlace():o.dataType===n.ANIMATIONTYPE_MATRIX&&(u.referenceValue.decompose(u.referenceScaling,u.referenceQuaternion,u.referencePosition),u.referenceQuaternion.normalize().conjugateInPlace());let _=Number.MAX_VALUE,g=a.clipKeys?[]:null;for(let R=c;R<=d;R++){let S=o._keys[R];if((g||a.cloneOriginalAnimation)&&(S={frame:S.frame,value:S.value.clone?S.value.clone():S.value,inTangent:S.inTangent,outTangent:S.outTangent,interpolation:S.interpolation,lockedTangent:S.lockedTangent,easingFunction:S.easingFunction},g&&(_===Number.MAX_VALUE&&(_=S.frame),S.frame-=_,g.push(S))),!(R&&o.dataType!==n.ANIMATIONTYPE_FLOAT&&S.value===f.value))switch(o.dataType){case n.ANIMATIONTYPE_MATRIX:S.value.decompose(u.keyScaling,u.keyQuaternion,u.keyPosition),u.keyPosition.subtractInPlace(u.referencePosition),u.keyScaling.divideInPlace(u.referenceScaling),u.referenceQuaternion.multiplyToRef(u.keyQuaternion,u.keyQuaternion),G.ComposeToRef(u.keyScaling,u.keyQuaternion,u.keyPosition,S.value);break;case n.ANIMATIONTYPE_QUATERNION:u.referenceValue.multiplyToRef(S.value,S.value);break;case n.ANIMATIONTYPE_VECTOR2:case n.ANIMATIONTYPE_VECTOR3:case n.ANIMATIONTYPE_COLOR3:case n.ANIMATIONTYPE_COLOR4:S.value.subtractToRef(u.referenceValue,S.value);break;case n.ANIMATIONTYPE_SIZE:S.value.width-=u.referenceValue.width,S.value.height-=u.referenceValue.height;break;default:S.value-=u.referenceValue}}return g&&o.setKeys(g,!0),o}static TransitionTo(e,t,i,r,s,a,o,l=null,c=!0,f){if(o<=0)return i[e]=t,l&&l(),null;let d=s*(o/1e3);return a.setKeys(f!=null?f:[{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:d,value:t}]),i.animations||(i.animations=[]),i.animations.push(a),r.beginAnimation(i,0,d,!1,1,l!=null?l:void 0,void 0,c)}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(let e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,i,r,s,a){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=r,this.loopMode=s,this.enableBlending=a,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this._coreAnimation=null,this.targetPropertyPath=t.split("."),this.dataType=r,this.loopMode=s===void 0?n.ANIMATIONLOOPMODE_CYCLE:s,this.uniqueId=n._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(let r in this._ranges)i||(t+=", "),i=!1,t+=r;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=0;a--)this._keys[a].frame>=r&&this._keys[a].frame<=s&&this._keys.splice(a,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;t0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;let r=this._keys,s;if(this._coreAnimation)s=this._coreAnimation._key;else{let p=r.length;for(s=t.key;s>=0&&e=r[s+1].frame;)++s;if(t.key=s,s<0)return i?void 0:this._getKeyValue(r[0].value);if(s+1>p-1)return i?void 0:this._getKeyValue(r[p-1].value);this._key=s}let a=r[s],o=r[s+1];if(i&&(e===a.frame||e===o.frame))return;let l=this._getKeyValue(a.value),c=this._getKeyValue(o.value);if(a.interpolation===1)return o.frame>e?l:c;let f=a.outTangent!==void 0&&o.inTangent!==void 0,d=o.frame-a.frame,h=(e-a.frame)/d,u=a.easingFunction||this.getEasingFunction();switch(u&&(h=u.ease(h)),this.dataType){case n.ANIMATIONTYPE_FLOAT:{let p=f?this.floatInterpolateFunctionWithTangents(l,a.outTangent*d,c,o.inTangent*d,h):this.floatInterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return((m=t.offsetValue)!=null?m:0)*t.repeatCount+p}break}case n.ANIMATIONTYPE_QUATERNION:{let p=f?this.quaternionInterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.quaternionInterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.addInPlace((t.offsetValue||dE).scale(t.repeatCount))}return p}case n.ANIMATIONTYPE_VECTOR3:{let p=f?this.vector3InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.vector3InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||hE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_VECTOR2:{let p=f?this.vector2InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.vector2InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||uE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(l,c,h);case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(l,c,h).add((t.offsetValue||mE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_COLOR3:{let p=f?this.color3InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.color3InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||pE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_COLOR4:{let p=f?this.color4InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.color4InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||_E).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return n.AllowMatricesInterpolation?this.matrixInterpolateFunction(l,c,h,t.workValue):l;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return l}break}}return 0}matrixInterpolateFunction(e,t,i,r){return n.AllowMatrixDecomposeForInterpolation?r?(G.DecomposeLerpToRef(e,t,i,r),r):G.DecomposeLerp(e,t,i):r?(G.LerpToRef(e,t,i,r),r):G.Lerp(e,t,i)}clone(e=!1){let t=new n(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys,!1,e),this._ranges){t._ranges={};for(let i in this._ranges){let r=this._ranges[i];r&&(t._ranges[i]=r.clone())}}return t}setKeys(e,t=!1,i=!1){if(t)this._keys=e;else if(this._keys=e.slice(0),i)for(let r=0;r=2&&(l=o.values[1]),o.values.length>=3&&(c=o.values[2]),o.values.length>=4&&(f=o.values[3]);break;case n.ANIMATIONTYPE_QUATERNION:if(s=Ae.FromArray(o.values),o.values.length>=8){let h=Ae.FromArray(o.values.slice(4,8));h.equals(Ae.Zero())||(l=h)}if(o.values.length>=12){let h=Ae.FromArray(o.values.slice(8,12));h.equals(Ae.Zero())||(c=h)}o.values.length>=13&&(f=o.values[12]);break;case n.ANIMATIONTYPE_MATRIX:s=G.FromArray(o.values),o.values.length>=17&&(f=o.values[16]);break;case n.ANIMATIONTYPE_COLOR3:s=oe.FromArray(o.values),o.values[3]&&(l=oe.FromArray(o.values[3])),o.values[4]&&(c=oe.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break;case n.ANIMATIONTYPE_COLOR4:s=Ne.FromArray(o.values),o.values[4]&&(l=Ne.FromArray(o.values[4])),o.values[5]&&(c=Ne.FromArray(o.values[5])),o.values[6]&&(f=Ne.FromArray(o.values[6]));break;case n.ANIMATIONTYPE_VECTOR3:default:s=v.FromArray(o.values),o.values[3]&&(l=v.FromArray(o.values[3])),o.values[4]&&(c=v.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break}let d={};d.frame=o.frame,d.value=s,l!=null&&(d.inTangent=l),c!=null&&(d.outTangent=c),f!=null&&(d.interpolation=f),r.push(d)}if(t.setKeys(r),e.ranges)for(a=0;a{let s=new $t;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){let a=JSON.parse(s.responseText);if(a.animations&&(a=a.animations),a.length){let o=[];for(let l of a)o.push(this.Parse(l));i(o)}else{let o=this.Parse(a);e&&(o.name=e),i(o)}}else r("Unable to load the animation")}),s.open("GET",t),s.send()})}static async ParseFromSnippetAsync(e){return await new Promise((t,i)=>{let r=new $t;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){let s=JSON.parse(JSON.parse(r.responseText).jsonPayload);if(s.animations){let a=JSON.parse(s.animations),o=[];for(let l of a.animations){let c=this.Parse(l);c.snippetId=e,o.push(c)}t(o)}else{let a=JSON.parse(s.animation),o=this.Parse(a);o.snippetId=e,t(o)}}else i("Unable to load the snippet "+e)}),r.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),r.send()})}};Oe._UniqueIdGenerator=0;Oe.AllowMatricesInterpolation=!1;Oe.AllowMatrixDecomposeForInterpolation=!0;Oe.InheritOriginalValueFromActiveAnimations=!1;Oe.SnippetUrl="https://snippet.babylonjs.com";Oe.ANIMATIONTYPE_FLOAT=0;Oe.ANIMATIONTYPE_VECTOR3=1;Oe.ANIMATIONTYPE_QUATERNION=2;Oe.ANIMATIONTYPE_MATRIX=3;Oe.ANIMATIONTYPE_COLOR3=4;Oe.ANIMATIONTYPE_COLOR4=7;Oe.ANIMATIONTYPE_VECTOR2=5;Oe.ANIMATIONTYPE_SIZE=6;Oe.ANIMATIONLOOPMODE_RELATIVE=0;Oe.ANIMATIONLOOPMODE_CYCLE=1;Oe.ANIMATIONLOOPMODE_CONSTANT=2;Oe.ANIMATIONLOOPMODE_YOYO=4;Oe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;Oe.CreateFromSnippetAsync=Oe.ParseFromSnippetAsync;je("BABYLON.Animation",Oe);dt._AnimationRangeFactory=(n,e,t)=>new xa(n,e,t)});var Ql,IM=A(()=>{lu();Is();Ql=class n{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._attachedCamera=null,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;let t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(i=>{if(i&&(i.computeWorldMatrix(!0),i.getBoundingInfo)){let r=i.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=r*.05,this.upperRadiusTransitionRange=r*.05}}):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))})}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return this._attachedCamera?this._attachedCamera.radius===e&&!this._radiusIsAnimating:!1}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(n.EasingFunction.setEasingMode(n.EasingMode),this._radiusBounceTransition=Oe.CreateAnimation("radius",Oe.ANIMATIONTYPE_FLOAT,60,n.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;let t=Oe.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()}};Ql.EasingFunction=new su(.3);Ql.EasingMode=sr.EASINGMODE_EASEOUT});var Ca,xM=A(()=>{lu();ct();fn();rs();ve();Is();Ca=class n{constructor(){this.onTargetFramingAnimationEndObservable=new Y,this._mode=n.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._attachedCamera=null,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;let t=this._attachedCamera.getScene();n.EasingFunction.setEasingMode(n.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ye.POINTERDOWN){this._isPointerDown=!0;return}i.type===ye.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;let 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);let r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)}zoomOnMeshHierarchy(e,t=!1,i=null){e.computeWorldMatrix(!0);let r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)}zoomOnMeshesHierarchy(e,t=!1,i=null){let r=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let a=0;a{this.stopAllAnimations(),r&&r(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()}),f&&this._animatables.push(f),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){let i=this._attachedCamera;if(!i)return 0;let r=i._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return i.lowerRadiusLimit&&this._mode===n.IgnoreBoundsSizeMode&&(r=ri.upperRadiusLimit?i.upperRadiusLimit:r),r}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;let e=kt.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=Oe.CreateAnimation("beta",Oe.ANIMATIONTYPE_FLOAT,60,n.EasingFunction));let r=Oe.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,()=>{this._clearAnimationLocks(),this.stopAllAnimations()});r&&this._animatables.push(r)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=kt.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}};Ca.EasingFunction=new ou;Ca.EasingMode=sr.EASINGMODE_EASEINOUT;Ca.IgnoreBoundsSizeMode=0;Ca.FitFrustumSidesMode=1});var cu,gE,ar,EE=A(()=>{Qe();qe();Rs();ve();Ci();rl();vr();dt.AddNodeConstructor("TargetCamera",(n,e)=>()=>new ar(n,v.Zero(),e));cu=G.Zero(),gE=Ae.Identity(),ar=class n extends Ge{constructor(e,t,i,r=!0){super(e,t,i,r),this.cameraDirection=new v(0,0,0),this.cameraRotation=new _e(0,0),this.updateUpVectorFromRotation=!1,this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this._panningEpsilon=Ye,this._rotationEpsilon=Ye,this.lockedTarget=null,this._currentTarget=v.Zero(),this._initialFocalDistance=1,this._viewMatrix=G.Zero(),this._cameraTransformMatrix=G.Zero(),this._cameraRotationMatrix=G.Zero(),this._transformedReferencePoint=v.Zero(),this._deferredPositionUpdate=new v,this._deferredRotationQuaternionUpdate=new Ae,this._deferredRotationUpdate=new v,this._deferredUpdated=!1,this._deferOnly=!1,this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0,this._referencePoint=v.Forward(this.getScene().useRightHandedSystem),this.rotation=new v(0,this.getScene().useRightHandedSystem?Math.PI:0,0)}getFrontPosition(e){this.getWorldMatrix();let t=k.Vector3[0],i=k.Vector3[1];return i.set(0,0,this._scene.useRightHandedSystem?-1:1),this.getDirectionToRef(i,t),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){let e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return super._restoreStateValues()?(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&this._storedRotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0):!1}_initCache(){super._initCache(),this._cache.lockedTarget=new 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 Ae(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();let 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;let 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(){let 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+=Ye),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),this.getScene().useRightHandedSystem?G.LookAtRHToRef(this.position,e,v.UpReadOnly,cu):G.LookAtLHToRef(this.position,e,v.UpReadOnly,cu),cu.invert();let t=this.rotationQuaternion||gE;Ae.FromRotationMatrixToRef(cu,t),t.toEulerAnglesToRef(this.rotation),this.rotation.z=0}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent){this.parent.getWorldMatrix().invertToRef(k.Matrix[0]),v.TransformNormalToRef(this.cameraDirection,k.Matrix[0],k.Vector3[0]),this._deferredPositionUpdate.addInPlace(k.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(){let 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()&&(Ae.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate)));let r=this.speed*this._panningEpsilon,s=this.speed*this._rotationEpsilon;t&&(Math.abs(this.cameraDirection.x){ze();Kt();Rs();Fi={},Jl=class{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){let t=e.getSimpleName();if(this.attached[t]){W.Warn("camera input of type "+t+" already exists on camera");return}this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault)}remove(e){for(let t in this.attached){let i=this.attached[t];if(i===e){i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck();return}}}removeByType(e){for(let t in this.attached){let i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){let t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=Ge.ForceAttachControlToAlwaysPreventDefault?!1:e,this.attachedToElement=!0,this.noPreventDefault=e;for(let t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(let t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(let e in this.attached){let 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){let t={};for(let i in this.attached){let r=this.attached[i],s=Me.Serialize(r);t[r.getClassName()]=s}e.inputsmgr=t}parse(e){let t=e.inputsmgr;if(t){this.clear();for(let i in t){let r=Fi[i];if(r){let s=t[i],a=Me.Parse(()=>new r,s,null);this.add(a)}}}else for(let i in this.attached){let r=Fi[this.attached[i].getClassName()];if(r){let s=Me.Parse(()=>new r,e,null);this.remove(this.attached[i]),this.add(s)}}}}});var Rf,CM=A(()=>{Qe();qe();Tt();fn();Rf=class{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement(),r=0,s=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 d,h;let l=o.event,c=l.pointerType==="touch";if(o.type!==ye.POINTERMOVE&&this.buttons.indexOf(l.button)===-1)return;let f=l.target;if(this._altKey=l.altKey,this._ctrlKey=l.ctrlKey,this._metaKey=l.metaKey,this._shiftKey=l.shiftKey,this._buttonsPressed=l.buttons,t.isPointerLock){let u=l.movementX,m=l.movementY;this.onTouch(null,u,m),this._pointA=null,this._pointB=null}else{if(o.type!==ye.POINTERDOWN&&o.type!==ye.POINTERDOUBLETAP&&c&&((d=this._pointA)==null?void 0:d.pointerId)!==l.pointerId&&((h=this._pointB)==null?void 0:h.pointerId)!==l.pointerId)return;if(o.type===ye.POINTERDOWN&&(this._currentMousePointerIdDown===-1||c)){try{f==null||f.setPointerCapture(l.pointerId)}catch(u){}if(this._pointA===null)this._pointA={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType,button:l.button};else if(this._pointB===null)this._pointB={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType,button:l.button};else return;this._currentMousePointerIdDown===-1&&!c&&(this._currentMousePointerIdDown=l.pointerId),this.onButtonDown(l),e||(l.preventDefault(),i&&i.focus())}else if(o.type===ye.POINTERDOUBLETAP)this.onDoubleTap(l.pointerType);else if(o.type===ye.POINTERUP&&(this._currentMousePointerIdDown===l.pointerId||c)){try{f==null||f.releasePointerCapture(l.pointerId)}catch(u){}c||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==l.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==l.pointerId?this._pointB=null:this._pointA=this._pointB=null,(r!==0||s)&&(this.onMultiTouch(this._pointA,this._pointB,r,0,s,null),r=0,s=null),this._currentMousePointerIdDown=-1,this.onButtonUp(l),e||l.preventDefault()}else if(o.type===ye.POINTERMOVE){if(e||l.preventDefault(),this._pointA&&this._pointB===null){let u=l.clientX-this._pointA.x,m=l.clientY-this._pointA.y;this._pointA.x=l.clientX,this._pointA.y=l.clientY,this.onTouch(this._pointA,u,m)}else if(this._pointA&&this._pointB){let u=this._pointA.pointerId===l.pointerId?this._pointA:this._pointB;u.x=l.clientX,u.y=l.clientY;let m=this._pointA.x-this._pointB.x,p=this._pointA.y-this._pointB.y,_=m*m+p*p,g={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:l.pointerId,type:o.type};this.onMultiTouch(this._pointA,this._pointB,r,_,s,g),s=g,r=_}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE|ye.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,r=0,s=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);let a=this.camera.getScene().getEngine().getHostWindow();a&&re.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){let e=this.camera.getScene().getEngine().getHostWindow();e&&re.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){let e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentMousePointerIdDown=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,r,s,a){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}};C([D()],Rf.prototype,"buttons",void 0)});var bo,bM=A(()=>{Qe();qe();CM();bo=class extends Rf{constructor(){super(...arguments),this.pinchZoom=!0,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this._isPinching=!1,this._twoFingerActivityCount=0,this._shouldStartPinchZoom=!1}_computePinchZoom(e,t){}_computeMultiTouchPanning(e,t){}onMultiTouch(e,t,i,r,s,a){i===0&&s===null||r===0&&a===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,r),this._computeMultiTouchPanning(s,a)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._shouldStartPinchZoom?(this._computePinchZoom(i,r),this._isPinching=!0):this._computeMultiTouchPanning(s,a)):this.multiTouchPanning?this._computeMultiTouchPanning(s,a):this.pinchZoom&&this._computePinchZoom(i,r))}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._twoFingerActivityCount=0,this._isPinching=!1}};C([D()],bo.prototype,"pinchZoom",void 0);C([D()],bo.prototype,"multiTouchPanning",void 0);C([D()],bo.prototype,"multiTouchPanAndZoom",void 0)});var Tr,MM=A(()=>{Qe();qe();zn();bM();Tr=class n extends bo{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.panningSensibility=1e3,this.pinchInwards=!0,this._isPanClick=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(this.panningSensibility!==0&&e&&t){let i=t.x-e.x,r=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=r/this.panningSensibility}}_computePinchZoom(e,t){let i=this.camera.radius||n.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,r,s,a){this._shouldStartPinchZoom=this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(r)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance,super.onMultiTouch(e,t,i,r,s,a)}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton,super.onButtonDown(e)}onButtonUp(e){super.onButtonUp(e)}onLostFocus(){this._isPanClick=!1,super.onLostFocus()}};Tr.MinimumRadiusForPinch=.001;C([D()],Tr.prototype,"buttons",void 0);C([D()],Tr.prototype,"angularSensibilityX",void 0);C([D()],Tr.prototype,"angularSensibilityY",void 0);C([D()],Tr.prototype,"pinchPrecision",void 0);C([D()],Tr.prototype,"pinchDeltaPercentage",void 0);C([D()],Tr.prototype,"useNaturalPinchZoom",void 0);C([D()],Tr.prototype,"panningSensibility",void 0);Fi.ArcRotateCameraPointersInput=Tr});var or,yM=A(()=>{Qe();qe();zn();Lh();Tt();or=class{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=re.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=>{let i=t.event;if(!i.metaKey){if(t.type===dn.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){let r=this._keys.indexOf(i.keyCode);r>=0&&this._keys.splice(r,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){let e=this.camera;for(let t=0;t{Qe();qe();zn();fn();fo();ve();Ci();Ph();bi();Tt();gk=40,ba=class{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,r=e*.01*this.wheelDeltaPercentage*t;return e>0?i=r/(1+this.wheelDeltaPercentage):i=r*(1+this.wheelDeltaPercentage),i}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==ye.POINTERWHEEL)return;let i=t.event,r,s=i.deltaMode===hn.DOM_DELTA_LINE?gk:1,a=-(i.deltaY*s);if(this.customComputeDeltaFromMouseWheel)r=this.customComputeDeltaFromMouseWheel(a,this,i);else if(this.wheelDeltaPercentage){if(r=this._computeDeltaFromMouseWheelLegacyEvent(a,this.camera.radius),r>0){let o=this.camera.radius,l=this.camera.inertialRadiusOffset+r;for(let c=0;c<20&&!(o<=l||Math.abs(l*this.camera.inertia)<.001);c++)o-=l,l*=this.camera.inertia;o=Ke(o,0,Number.MAX_VALUE),r=this._computeDeltaFromMouseWheelLegacyEvent(a,o)}}else r=a/(this.wheelPrecision*40);r&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(r)):this.camera.inertialRadiusOffset+=r),i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,ye.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;let 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(){let e=this.camera,t=e.target.subtract(e.position);this._hitPlane=er.FromPositionAndNormal(e.target,t)}_getPosition(){var s;let e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,G.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 r=0;return this._hitPlane&&(r=(s=i.intersectsPlane(this._hitPlane))!=null?s:0),i.origin.addInPlace(i.direction.scaleInPlace(r))}_zoomToMouse(e){var l,c;let t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){let f=(l=t.lowerRadiusLimit)!=null?l:0;t.radius-(t.inertialRadiusOffset+e)/if&&(e=(t.radius-f)*i-t.inertialRadiusOffset)}let s=e/i/t.radius,a=this._getPosition(),o=k.Vector3[6];a.subtractToRef(t.target,o),o.scaleInPlace(s),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x){MM();yM();DM();zn();fu=class extends Jl{constructor(e){super(e)}addMouseWheel(){return this.add(new ba),this}addPointers(){return this.add(new Tr),this}addKeyboard(){return this.add(new or),this}}});function Ek(n){let e=Math.PI/2;return n.x===0&&n.z===0||(e=Math.acos(n.x/Math.sqrt(Math.pow(n.x,2)+Math.pow(n.z,2)))),n.z<0&&(e=2*Math.PI-e),e}function vk(n,e){return Math.acos(n/e)}function wi(n,e){return isNaN(n)?e:n}var ht,du=A(()=>{Qe();qe();ct();ve();bi();vr();Rt();cE();IM();xM();Rs();EE();LM();Ci();Tt();Lt();dt.AddNodeConstructor("ArcRotateCamera",(n,e)=>()=>new ht(n,0,0,1,v.Zero(),e));ht=class n extends ar{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 G,this._upToYMatrix=new G,this._upVector=v.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){G.RotationAlignToRef(v.UpReadOnly,this._upVector,this._yToUpMatrix),G.RotationAlignToRef(this._upVector,v.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){let e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){let t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){let e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){let t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){let e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){let t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){let e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){let t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){let e=this.inputs.attached.pointers;return e?e.useNaturalPinchZoom:!1}set useNaturalPinchZoom(e){let t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){let e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){let t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){let e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){let e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){let e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){let e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){let e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){let t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){let e=this.inputs.attached.mousewheel;return e?e.zoomToMouseLocation:!1}set zoomToMouseLocation(e){let t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){let e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){let t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get isInterpolating(){return this._isInterpolating}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return this._bouncingBehavior!=null}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Ql,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 Ca,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 ql,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,r,s,a,o=!0){super(e,v.Zero(),a,o),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.lowerTargetYLimit=-1/0,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=v.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=_e.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new G,this.panningAxis=new v(1,1,0),this._transformedDirection=new v,this.mapPanning=!1,this._isInterpolating=!1,this.onMeshTargetChangedObservable=new Y,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._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget=new v(NaN,NaN,NaN),this._goalTargetScreenOffset=new _e(NaN,NaN),this._onCollisionPositionChange=(l,c,f=null)=>{f?(this.setPosition(c),this.onCollide&&this.onCollide(f)):this._previousPosition.copyFrom(this._position);let d=Math.cos(this.alpha),h=Math.sin(this.alpha),u=Math.cos(this.beta),m=Math.sin(this.beta);m===0&&(m=1e-4);let p=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*d*m,this.radius*u,this.radius*h*m),p.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let _=this.upVector;this.allowUpsideDown&&this.beta<0&&(_=_.clone(),_=_.negate()),this._computeViewMatrix(this._position,p,_),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=v.Zero(),s&&this.setTarget(s),this.alpha=t,this.beta=i,this.radius=r,this.getViewMatrix(),this.inputs=new fu(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=_e.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){let t=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?t.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(t)}let e=this._getLockedTargetPosition();return e||this._target}storeState(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>Ye&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset,this.restoreStateInterpolationFactor),!0):super._restoreStateValues()?(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0):!1}stopInterpolation(){this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget.set(NaN,NaN,NaN),this._goalTargetScreenOffset.set(NaN,NaN)}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,r=this.target,s=this.targetScreenOffset,a){var o,l,c,f,d,h,u;this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,a!=null?this._currentInterpolationFactor=a:this.restoreStateInterpolationFactor!==0?this._currentInterpolationFactor=this.restoreStateInterpolationFactor:this._currentInterpolationFactor=.1,this._goalAlpha=wi(e,this._goalAlpha),this._goalBeta=wi(t,this._goalBeta),this._goalRadius=wi(i,this._goalRadius),this._goalTarget.set(wi(r.x,this._goalTarget.x),wi(r.y,this._goalTarget.y),wi(r.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(wi(s.x,this._goalTargetScreenOffset.x),wi(s.y,this._goalTargetScreenOffset.y)),this._goalAlpha=Ke(this._goalAlpha,(o=this.lowerAlphaLimit)!=null?o:-1/0,(l=this.upperAlphaLimit)!=null?l:1/0),this._goalBeta=Ke(this._goalBeta,(c=this.lowerBetaLimit)!=null?c:-1/0,(f=this.upperBetaLimit)!=null?f:1/0),this._goalRadius=Ke(this._goalRadius,(d=this.lowerRadiusLimit)!=null?d:-1/0,(h=this.upperRadiusLimit)!=null?h:1/0),this._goalTarget.y=Ke(this._goalTarget.y,(u=this.lowerTargetYLimit)!=null?u:-1/0,1/0),this._isInterpolating=!0}_isSynchronizedViewMatrix(){return super._isSynchronizedViewMatrix()?this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset):!1}attachControl(e,t,i=!0,r=2){let s=arguments;t=re.BackCompatCameraNoPreventDefault(s),this._useCtrlForPanning=i,this._panningMouseButton=r,typeof s[0]=="boolean"&&(s.length>1&&(this._useCtrlForPanning=s[1]),s.length>2&&(this._panningMouseButton=s[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(this._collisionTriggered)return;this.inputs.checkInputs();let e=!1;if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){e=!0;let t=this.invertRotation?-1:1,i=this._calculateHandednessMultiplier(),r=this.inertialAlphaOffset*i;this.beta<0&&(r*=-1),this.alpha+=r*t,this.beta+=this.inertialBetaOffset*t,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0),this.target.y=Math.max(this.target.y,this.lowerTargetYLimit)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&v.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);let e=this.alpha;this.alpha=Ek(this._computationVector),this.beta=vk(this._computationVector.y,this.radius);let t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=t*2*Math.PI,this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,r=!1){var s;if(r=(s=this.overrideCloneAlphaBetaRadius)!=null?s:r,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{let a=e,o=this._getTargetPosition();if(o&&!i&&o.equals(a))return;this._targetHost=null,this._target=a,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}r||this.rebuildAnglesAndRadius()}_getViewMatrix(){let e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);r===0&&(r=1e-4),this.radius===0&&(this.radius=1e-4);let s=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&v.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),s.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){let a=this.getScene().collisionCoordinator;this._collider||(this._collider=a.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,a.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let a=this.upVector;this.allowUpsideDown&&r<0&&(a=a.negate()),this._computeViewMatrix(this._position,s,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget.copyFrom(s),this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;let i=U.MinMax(e),r=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);if(r=Math.max(Math.min(r,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=r*this.zoomOnFactor,this.mode===Ge.ORTHOGRAPHIC_CAMERA){let s=this.getScene().getEngine().getAspectRatio(this),a=r*this.zoomOnFactor/2;this.orthoLeft=-a*s,this.orthoRight=a*s,this.orthoBottom=-a,this.orthoTop=a}this.focusOn({min:i.min,max:i.max,distance:r},t)}focusOn(e,t=!1){let i,r;if(e.min===void 0){let s=e||this.getScene().meshes;i=U.MinMax(s),r=v.Distance(i.min,i.max)}else{let s=e;i=s,r=s.distance}this._target=U.Center(i),t||(this.maxZ=r*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ge.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ge.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}let r=new n(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r.isRigCamera=!0,r.rigParent=this,r.upVector=this.upVector,r.mode=this.mode,r.orthoLeft=this.orthoLeft,r.orthoRight=this.orthoRight,r.orthoBottom=this.orthoBottom,r.orthoTop=this.orthoTop,r}_updateRigCameras(){let e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ge.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ge.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ge.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){let r=v.Distance(e,t),a=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),l=o*a,f=r*.5*i,d=f*Math.sqrt(1+1/(l*l)),h=f*Math.sqrt(1+1/(o*o));return Math.max(d,h)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}};C([D()],ht.prototype,"alpha",void 0);C([D()],ht.prototype,"beta",void 0);C([D()],ht.prototype,"radius",void 0);C([D()],ht.prototype,"overrideCloneAlphaBetaRadius",void 0);C([ai("target")],ht.prototype,"_target",void 0);C([fh("targetHost")],ht.prototype,"_targetHost",void 0);C([D()],ht.prototype,"inertialAlphaOffset",void 0);C([D()],ht.prototype,"inertialBetaOffset",void 0);C([D()],ht.prototype,"inertialRadiusOffset",void 0);C([D()],ht.prototype,"lowerAlphaLimit",void 0);C([D()],ht.prototype,"upperAlphaLimit",void 0);C([D()],ht.prototype,"lowerBetaLimit",void 0);C([D()],ht.prototype,"upperBetaLimit",void 0);C([D()],ht.prototype,"lowerRadiusLimit",void 0);C([D()],ht.prototype,"upperRadiusLimit",void 0);C([D()],ht.prototype,"lowerTargetYLimit",void 0);C([D()],ht.prototype,"inertialPanningX",void 0);C([D()],ht.prototype,"inertialPanningY",void 0);C([D()],ht.prototype,"pinchToPanMaxDistance",void 0);C([D()],ht.prototype,"panningDistanceLimit",void 0);C([ai()],ht.prototype,"panningOriginTarget",void 0);C([D()],ht.prototype,"panningInertia",void 0);C([D()],ht.prototype,"zoomToMouseLocation",null);C([D()],ht.prototype,"zoomOnFactor",void 0);C([hl()],ht.prototype,"targetScreenOffset",void 0);C([D()],ht.prototype,"allowUpsideDown",void 0);C([D()],ht.prototype,"useInputToRestoreState",void 0);C([D()],ht.prototype,"restoreStateInterpolationFactor",void 0);je("BABYLON.ArcRotateCamera",ht)});var tt,Ma=A(()=>{Qe();qe();ve();et();vr();ma();Lt();$c();Kt();tt=class n extends dt{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t,i){super(e,t,!1),this.diffuse=new oe(1,1,1),this.specular=new oe(1,1,1),this.falloffType=n.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=n.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._currentViewDepth=0,this._clusteredContainer=null,this._isLight=!0,i||this.getScene().addLight(this),this._uniformBuffer=new Ut(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],i||this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,i,r,s=!0){var l;let a=e.toString(),o=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+a),this._renderId!==t.getRenderId()||this._lastUseSpecular!==r||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=r;let c=this.getScaledIntensity();this.transferToEffect(i,a),this.diffuse.scaleToRef(c,Ri.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Ri.Color3[0],this.range,a),r&&(this.specular.scaleToRef(c,Ri.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Ri.Color3[1],this.radius,a)),o=!0}if(this.transferTexturesToEffect(i,a),t.shadowsEnabled&&this.shadowEnabled&&s){let c=(l=this.getShadowGenerator(t.activeCamera))!=null?l:this.getShadowGenerator();c&&(c.bindShadowLight(a,i),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric","Clustered"][this.getTypeID()],this.animations)for(let i=0;i0&&this.includedOnlyMeshes.indexOf(e)===-1||this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1||this.includeOnlyWithLayerMask!==0&&(this.includeOnlyWithLayerMask&e.layerMask)===0||this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&e.layerMask):!0}dispose(e,t=!1){if(this._shadowGenerators){let i=this._shadowGenerators.values();for(let r=i.next();r.done!==!0;r=i.next())r.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){let i=this._parentContainer.lights.indexOf(this);i>-1&&this._parentContainer.lights.splice(i,1),this._parentContainer=null}for(let 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){let i=n.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;let r=Me.Clone(i,this);return e&&(r.name=e),t&&(r.parent=t),r.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(r),r}serialize(){let e=Me.Serialize(this);if(e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0){e.excludedMeshesIds=[];for(let t of this.excludedMeshes)e.excludedMeshesIds.push(t.id)}if(this.includedOnlyMeshes.length>0){e.includedOnlyMeshesIds=[];for(let t of this.includedOnlyMeshes)e.includedOnlyMeshesIds.push(t.id)}return Me.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){let r=dt.Construct("Light_Type_"+e,t,i);return r||null}static Parse(e,t){let i=n.GetConstructorFromName(e.type,e.name,t);if(!i)return null;let r=Me.Parse(i,e,t);if(e.excludedMeshesIds&&(r._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(r._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),e.falloffType!==void 0&&(r.falloffType=e.falloffType),e.lightmapMode!==void 0&&(r.lightmapMode=e.lightmapMode),e.animations){for(let s=0;s{let s=t.apply(e,r);if(this._clusteredContainer)return s;for(let a of r)a._resyncLightSource(this);return s};let i=e.splice;if(e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);if(this._clusteredContainer)return a;for(let o of a)o._resyncLightSource(this);return a},!this._clusteredContainer)for(let r of e)r._resyncLightSource(this)}_hookArrayForIncludedOnly(e){let t=e.push;e.push=(...r)=>{let s=t.apply(e,r);return this._resyncMeshes(),s};let i=e.splice;e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);return this._resyncMeshes(),a},this._resyncMeshes()}_resyncMeshes(){if(!this._clusteredContainer)for(let e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(let e of this.getScene().meshes)e.lightSources.indexOf(this)!==-1&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0,t=this.getTypeID(),i=this.intensityMode;switch(i===n.INTENSITYMODE_AUTOMATIC&&(t===n.LIGHTTYPEID_DIRECTIONALLIGHT?i=n.INTENSITYMODE_ILLUMINANCE:i=n.INTENSITYMODE_LUMINOUSINTENSITY),t){case n.LIGHTTYPEID_POINTLIGHT:case n.LIGHTTYPEID_SPOTLIGHT:switch(i){case n.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case n.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case n.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case n.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case n.INTENSITYMODE_ILLUMINANCE:e=1;break;case n.INTENSITYMODE_LUMINANCE:{let r=this.radius;r=Math.max(r,.001),e=2*Math.PI*(1-Math.cos(r));break}}break;case n.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){let e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}areLightTexturesReady(){return!0}_isReady(){return!0}};tt.FALLOFF_DEFAULT=it.FALLOFF_DEFAULT;tt.FALLOFF_PHYSICAL=it.FALLOFF_PHYSICAL;tt.FALLOFF_GLTF=it.FALLOFF_GLTF;tt.FALLOFF_STANDARD=it.FALLOFF_STANDARD;tt.LIGHTMAP_DEFAULT=it.LIGHTMAP_DEFAULT;tt.LIGHTMAP_SPECULAR=it.LIGHTMAP_SPECULAR;tt.LIGHTMAP_SHADOWSONLY=it.LIGHTMAP_SHADOWSONLY;tt.INTENSITYMODE_AUTOMATIC=it.INTENSITYMODE_AUTOMATIC;tt.INTENSITYMODE_LUMINOUSPOWER=it.INTENSITYMODE_LUMINOUSPOWER;tt.INTENSITYMODE_LUMINOUSINTENSITY=it.INTENSITYMODE_LUMINOUSINTENSITY;tt.INTENSITYMODE_ILLUMINANCE=it.INTENSITYMODE_ILLUMINANCE;tt.INTENSITYMODE_LUMINANCE=it.INTENSITYMODE_LUMINANCE;tt.LIGHTTYPEID_POINTLIGHT=it.LIGHTTYPEID_POINTLIGHT;tt.LIGHTTYPEID_DIRECTIONALLIGHT=it.LIGHTTYPEID_DIRECTIONALLIGHT;tt.LIGHTTYPEID_SPOTLIGHT=it.LIGHTTYPEID_SPOTLIGHT;tt.LIGHTTYPEID_HEMISPHERICLIGHT=it.LIGHTTYPEID_HEMISPHERICLIGHT;tt.LIGHTTYPEID_RECT_AREALIGHT=it.LIGHTTYPEID_RECT_AREALIGHT;C([Ht()],tt.prototype,"diffuse",void 0);C([Ht()],tt.prototype,"specular",void 0);C([D()],tt.prototype,"falloffType",void 0);C([D()],tt.prototype,"intensity",void 0);C([D()],tt.prototype,"range",null);C([D()],tt.prototype,"intensityMode",null);C([D()],tt.prototype,"radius",null);C([D()],tt.prototype,"_renderPriority",void 0);C([ee("_reorderLightsInScene")],tt.prototype,"renderPriority",void 0);C([D("shadowEnabled")],tt.prototype,"_shadowEnabled",void 0);C([D("excludeWithLayerMask")],tt.prototype,"_excludeWithLayerMask",void 0);C([D("includeOnlyWithLayerMask")],tt.prototype,"_includeOnlyWithLayerMask",void 0);C([D("lightmapMode")],tt.prototype,"_lightmapMode",void 0)});var Sr,hu=A(()=>{Qe();qe();ve();et();vr();Ma();Lt();dt.AddNodeConstructor("Light_Type_3",(n,e)=>()=>new Sr(n,v.Zero(),e));Sr=class extends tt{constructor(e,t,i,r){super(e,i,r),this.groundColor=new oe(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){let 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){let i=v.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=G.Identity()),this._worldMatrix}getTypeID(){return tt.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}};C([Ht()],Sr.prototype,"groundColor",void 0);C([ai()],Sr.prototype,"direction",void 0);je("BABYLON.HemisphericLight",Sr)});var Hr,uu=A(()=>{Qe();qe();ve();Ma();rl();Hr=class extends tt{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=G.Identity(),this._projectionMatrix=G.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();let e=v.Cross(this.direction,$i.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=G.Identity()),G.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==null?void 0:e.minZ)||0}getDepthMaxZ(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:(e==null?void 0:e.maxZ)||1e4}setShadowProjectionMatrix(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this}_syncParentEnabledState(){super._syncParentEnabledState(),(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){let t=k.Vector3[0],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);let r=k.Vector3[1];return i.addToRef(t,r),G.LookAtLHToRef(i,r,v.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e!=null?e:this._viewMatrix,t!=null?t:[]),this._projectionMatrix}};C([ai()],Hr.prototype,"position",null);C([ai()],Hr.prototype,"direction",null);C([D()],Hr.prototype,"shadowMinZ",null);C([D()],Hr.prototype,"shadowMaxZ",null)});var lr,PM=A(()=>{Qe();qe();ve();vr();Ma();uu();Lt();dt.AddNodeConstructor("Light_Type_1",(n,e)=>()=>new lr(n,v.Zero(),e));lr=class extends Hr{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,i,r){super(e,i,r),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return tt.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)}_setDefaultFixedFrustumShadowProjectionMatrix(e){let t=this.getScene().activeCamera;G.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:t?t.minZ:0,this.shadowMaxZ!==void 0?this.shadowMaxZ:t?t.maxZ:1e4,e,this.getScene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,i){let r=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){let f=v.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let d=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let u=0;uthis._orthoRight&&(this._orthoRight=f.x),f.y>this._orthoTop&&(this._orthoTop=f.y),this.autoCalcShadowZBounds&&(f.zh&&(h=f.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=d,this._shadowMaxZ=h)}let s=this._orthoRight-this._orthoLeft,a=this._orthoTop-this._orthoBottom,o=this.shadowMinZ!==void 0?this.shadowMinZ:(r==null?void 0:r.minZ)||0,l=this.shadowMaxZ!==void 0?this.shadowMaxZ:(r==null?void 0:r.maxZ)||1e4,c=this.getScene().getEngine().useReverseDepthBuffer;G.OrthoOffCenterLHToRef(this._orthoLeft-s*this.shadowOrthoScale,this._orthoRight+s*this.shadowOrthoScale,this._orthoBottom-a*this.shadowOrthoScale,this._orthoTop+a*this.shadowOrthoScale,c?l:o,c?o:l,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){let t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){let t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}};C([D()],lr.prototype,"shadowFrustumSize",null);C([D()],lr.prototype,"shadowOrthoScale",null);C([D()],lr.prototype,"autoUpdateExtends",void 0);C([D()],lr.prototype,"autoCalcShadowZBounds",void 0);C([D("orthoLeft")],lr.prototype,"_orthoLeft",void 0);C([D("orthoRight")],lr.prototype,"_orthoRight",void 0);C([D("orthoTop")],lr.prototype,"_orthoTop",void 0);C([D("orthoBottom")],lr.prototype,"_orthoBottom",void 0);je("BABYLON.DirectionalLight",lr)});var ya,OM=A(()=>{Qe();qe();ve();vr();Ma();uu();Lt();dt.AddNodeConstructor("Light_Type_0",(n,e)=>()=>new ya(n,v.Zero(),e));ya=class extends Hr{get shadowAngle(){return this._shadowAngle}set shadowAngle(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()}get direction(){return this._direction}set direction(e){let t=this.needCube();if(this._direction=e,this.needCube()!==t&&this._shadowGenerators){let i=this._shadowGenerators.values();for(let r=i.next();r.done!==!0;r=i.next())r.value.recreateShadowMap()}}constructor(e,t,i,r){super(e,i,r),this._shadowAngle=Math.PI/2,this.position=t}getClassName(){return"PointLight"}getTypeID(){return tt.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){let r=this.getScene().activeCamera,s=this.getDepthMinZ(r),a=this.getDepthMaxZ(r),o=this.getScene().getEngine().useReverseDepthBuffer;G.PerspectiveFovLHToRef(this.shadowAngle,1,o?a:s,o?s:a,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){let i=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x-i.x,this.transformedPosition.y-i.y,this.transformedPosition.z-i.z,0,t):this._uniformBuffer.updateFloat4("vLightData",this.position.x-i.x,this.position.y-i.y,this.position.z-i.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this}transferToNodeMaterialEffect(e,t){let i=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?e.setFloat3(t,this.transformedPosition.x-i.x,this.transformedPosition.y-i.y,this.transformedPosition.z-i.z):e.setFloat3(t,this.position.x-i.x,this.position.y-i.y,this.position.z-i.z),this}prepareLightSpecificDefines(e,t){e["POINTLIGHT"+t]=!0}};C([D()],ya.prototype,"shadowAngle",null);je("BABYLON.PointLight",ya)});var ni,vE=A(()=>{Qe();qe();ve();vr();Ma();uu();oi();Lt();dt.AddNodeConstructor("Light_Type_2",(n,e)=>()=>new ni(n,v.Zero(),v.Zero(),0,0,e));ni=class n extends Hr{get iesProfileTexture(){return this._iesProfileTexture}set iesProfileTexture(e){this._iesProfileTexture!==e&&(this._iesProfileTexture=e,this._iesProfileTexture&&n._IsTexture(this._iesProfileTexture)&&this._iesProfileTexture.onLoadObservable.addOnce(()=>{this._markMeshesAsLightDirty()}))}get angle(){return this._angle}set angle(e){this._angle=e,this._cosHalfAngle=Math.cos(e*.5),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()}get innerAngle(){return this._innerAngle}set innerAngle(e){this._innerAngle=e,this._computeAngleValues()}get shadowAngleScale(){return this._shadowAngleScale}set shadowAngleScale(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()}get projectionTextureMatrix(){return this._projectionTextureMatrix}get projectionTextureLightNear(){return this._projectionTextureLightNear}set projectionTextureLightNear(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0}get projectionTextureLightFar(){return this._projectionTextureLightFar}set projectionTextureLightFar(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0}get projectionTextureUpDirection(){return this._projectionTextureUpDirection}set projectionTextureUpDirection(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0}get projectionTexture(){return this._projectionTexture}set projectionTexture(e){this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(n._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled(()=>{this._markMeshesAsLightDirty()}):n._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce(()=>{this._markMeshesAsLightDirty()})))}static _IsProceduralTexture(e){return e.onGeneratedObservable!==void 0}static _IsTexture(e){return e.onLoadObservable!==void 0}get projectionTextureProjectionLightMatrix(){return this._projectionTextureProjectionLightMatrix}set projectionTextureProjectionLightMatrix(e){this._projectionTextureProjectionLightMatrix=e,this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0}constructor(e,t,i,r,s,a,o){super(e,a,o),this._innerAngle=0,this._iesProfileTexture=null,this._projectionTextureMatrix=G.Zero(),this._projectionTextureLightNear=1e-6,this._projectionTextureLightFar=1e3,this._projectionTextureUpDirection=v.Up(),this._projectionTextureViewLightDirty=!0,this._projectionTextureProjectionLightDirty=!0,this._projectionTextureDirty=!0,this._projectionTextureViewTargetVector=v.Zero(),this._projectionTextureViewLightMatrix=G.Zero(),this._projectionTextureProjectionLightMatrix=G.Zero(),this._projectionTextureScalingMatrix=G.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),this.position=t,this.direction=i,this.angle=r,this.exponent=s}getClassName(){return"SpotLight"}getTypeID(){return tt.LIGHTTYPEID_SPOTLIGHT}_setDirection(e){super._setDirection(e),this._projectionTextureViewLightDirty=!0}_setPosition(e){super._setPosition(e),this._projectionTextureViewLightDirty=!0}_setDefaultShadowProjectionMatrix(e,t,i){let r=this.getScene().activeCamera;if(!r)return;this._shadowAngleScale=this._shadowAngleScale||1;let s=this._shadowAngleScale*this._angle,a=this.shadowMinZ!==void 0?this.shadowMinZ:r.minZ,o=this.shadowMaxZ!==void 0?this.shadowMaxZ:r.maxZ,l=this.getScene().getEngine().useReverseDepthBuffer;G.PerspectiveFovLHToRef(s,1,l?o:a,l?a:o,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,l)}_computeProjectionTextureViewLightMatrix(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.getAbsolutePosition().addToRef(this.getShadowDirection(),this._projectionTextureViewTargetVector),G.LookAtLHToRef(this.getAbsolutePosition(),this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)}_computeProjectionTextureProjectionLightMatrix(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;let e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),r=-i*t,s=1/Math.tan(this._angle/2);G.FromValuesToRef(s/1,0,0,0,0,s,0,0,0,0,i,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)}_computeProjectionTextureMatrix(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof ne){let e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;G.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}_computeAngleValues(){this._lightAngleScale=1/Math.max(.001,Math.cos(this._innerAngle*.5)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale}transferTexturesToEffect(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightTexture"+t,this.projectionTexture)),this._iesProfileTexture&&this._iesProfileTexture.isReady()&&e.setTexture("iesLightTexture"+t,this._iesProfileTexture),this}transferToEffect(e,t){let i,r=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x-r.x,this.transformedPosition.y-r.y,this.transformedPosition.z-r.z,this.exponent,t),i=v.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x-r.x,this.position.y-r.y,this.position.z-r.z,this.exponent,t),i=v.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this}transferToNodeMaterialEffect(e,t){let i;return this.computeTransformedInformation()?i=v.Normalize(this.transformedDirection):i=v.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.z),this}dispose(){super.dispose(),this._projectionTexture&&this._projectionTexture.dispose(),this._iesProfileTexture&&(this._iesProfileTexture.dispose(),this._iesProfileTexture=null)}getDepthMinZ(e){var r;let t=this._scene.getEngine(),i=this.shadowMinZ!==void 0?this.shadowMinZ:(r=e==null?void 0:e.minZ)!=null?r:0;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?i:this._scene.getEngine().isNDCHalfZRange?0:i}getDepthMaxZ(e){var r;let t=this._scene.getEngine(),i=this.shadowMaxZ!==void 0?this.shadowMaxZ:(r=e==null?void 0:e.maxZ)!=null?r:1e4;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:i}areLightTexturesReady(){return!(this._projectionTexture&&!this._projectionTexture.isReadyOrNotBlocking()||this._iesProfileTexture&&!this._iesProfileTexture.isReadyOrNotBlocking())}prepareLightSpecificDefines(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!!(this.projectionTexture&&this.projectionTexture.isReady()),e["IESLIGHTTEXTURE"+t]=!!(this._iesProfileTexture&&this._iesProfileTexture.isReady())}};C([D()],ni.prototype,"angle",null);C([D()],ni.prototype,"innerAngle",null);C([D()],ni.prototype,"shadowAngleScale",null);C([D()],ni.prototype,"exponent",void 0);C([D()],ni.prototype,"projectionTextureLightNear",null);C([D()],ni.prototype,"projectionTextureLightFar",null);C([D()],ni.prototype,"projectionTextureUpDirection",null);C([Ze("projectedLightTexture")],ni.prototype,"_projectionTexture",void 0);je("BABYLON.SpotLight",ni)});function NM(n){let e=n.pathArray,t=n.closeArray||!1,i=n.closePath||!1,r=n.invertUV||!1,s=Math.floor(e[0].length/2),a=n.offset||s;a=a>s?s:Math.floor(a);let o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=n.uvs,c=n.colors,f=[],d=[],h=[],u=[],m=[],p=[],_=[],g=[],T,b=[],R=[],S,I,x;if(e.length<2){let he=[],ke=[];for(I=0;I0&&(H=B[x].subtract(B[x-1]).length(),O=H+_[S],m[S].push(O),_[S]=O),x++;i&&(x--,f.push(B[0].x,B[0].y,B[0].z),H=B[x].subtract(B[0]).length(),O=H+_[S],m[S].push(O),_[S]=O),b[S]=w+L,R[S]=P,P+=w+L}let V,X,j,Q;for(I=0;I{let m=i[0].length,p=o,_=0,g=p._originalBuilderSideOrientation===U.DOUBLESIDE?2:1;for(let T=1;T<=g;++T)for(let b=0;b{ve();Rt();yt();Vt();hi();de.CreateRibbon=NM;U.CreateRibbon=(n,e,t=!1,i,r,s,a=!1,o,l)=>En(n,{pathArray:e,closeArray:t,closePath:i,offset:r,updatable:a,sideOrientation:o,instance:l},s)});function FM(n){let e=[],t=[],i=[],r=[],s=n.radius||.5,a=n.tessellation||64,o=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,l=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE;e.push(0,0,0),r.push(.5,.5);let c=Math.PI*2*o,f=o===1?c/a:c/(a-1),d=0;for(let m=0;m{Rt();Vt();hi();de.CreateDisc=FM;U.CreateDisc=(n,e,t,i=null,r,s)=>TE(n,{radius:e,tessellation:t,sideOrientation:s,updatable:r},i)});var $l,BM=A(()=>{ve();yt();Rt();U._GroundMeshParser=(n,e)=>$l.Parse(n,e);$l=class n extends U{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);let i=this;i.createOrUpdateSubmeshesOctree&&i.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){let i=this.getWorldMatrix(),r=k.Matrix[5];i.invertToRef(r);let s=k.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,r,s),e=s.x,t=s.z,e=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());let a=this._getFacetAt(e,t),o=-(a.x*e+a.z*t+a.w)/a.y;return v.TransformCoordinatesFromFloatsToRef(0,o,0,i,s),s.y}getNormalAtCoordinates(e,t){let i=new v(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){let r=this.getWorldMatrix(),s=k.Matrix[5];r.invertToRef(s);let a=k.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,s,a),e=a.x,t=a.z,ethis._maxX||tthis._maxZ)return this;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());let o=this._getFacetAt(e,t);return v.TransformNormalFromFloatsToRef(o.x,o.y,o.z,r,i),this}updateCoordinateHeights(){return(!this._heightQuads||this._heightQuads.length==0)&&this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){let i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),s=this._heightQuads[r*this._subdivisionsX+i],a;return tn.maxHeight){c=!0;let d=n.maxHeight;n.maxHeight=n.minHeight,n.minHeight=d}for(s=0;s<=n.subdivisions;s++)for(a=0;a<=n.subdivisions;a++){let d=new v(a*n.width/n.subdivisions-n.width/2,0,(n.subdivisions-s)*n.height/n.subdivisions-n.height/2),h=(d.x+n.width/2)/n.width*(n.bufferWidth-1)|0,u=(1-(d.z+n.height/2)/n.height)*(n.bufferHeight-1)|0,m=(h+u*n.bufferWidth)*4,p=n.buffer[m]/255,_=n.buffer[m+1]/255,g=n.buffer[m+2]/255,T=n.buffer[m+3]/255;c&&(p=1-p,_=1-_,g=1-g);let b=p*o.r+_*o.g+g*o.b;T>=l?d.y=n.minHeight+(n.maxHeight-n.minHeight)*b:d.y=n.minHeight-Ye,n.heightBuffer&&(n.heightBuffer[s*(n.subdivisions+1)+a]=d.y),t.push(d.x,d.y,d.z),i.push(0,0,0),r.push(a/n.subdivisions,1-s/n.subdivisions)}for(s=0;s=n.minHeight,_=t[h*3+1]>=n.minHeight,g=t[u*3+1]>=n.minHeight;p&&_&&g&&(e.push(d),e.push(h),e.push(u)),t[m*3+1]>=n.minHeight&&p&&g&&(e.push(m),e.push(d),e.push(u))}de.ComputeNormals(t,e,i);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function AE(n,e={},t){let i=new $l(n,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,SE(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function RE(n,e,t=null){let i=new U(n,t);return UM(e).applyToMesh(i,e.updatable),i}function IE(n,e,t={},i=null){let r=t.width||10,s=t.height||10,a=t.subdivisions||1,o=t.minHeight||0,l=t.maxHeight||1,c=t.colorFilter||new oe(.3,.59,.11),f=t.alphaFilter||0,d=t.updatable,h=t.onReady;i=i||ue.LastCreatedScene;let u=new $l(n,i);u._subdivisionsX=a,u._subdivisionsY=a,u._width=r,u._height=s,u._maxX=u._width/2,u._maxZ=u._height/2,u._minX=-u._maxX,u._minZ=-u._maxZ,u._setReady(!1);let m;t.passHeightBufferInCallback&&(m=new Float32Array((a+1)*(a+1)));let p=(_,g,T)=>{VM({width:r,height:s,subdivisions:a,minHeight:o,maxHeight:l,colorFilter:c,buffer:_,bufferWidth:g,bufferHeight:T,alphaFilter:f,heightBuffer:m}).applyToMesh(u,d),h&&h(u,m),u._setReady(!0)};if(typeof e=="string"){i.addPendingData(u);let _=T=>{let b=T.width,R=T.height;if(i.isDisposed){i.removePendingData(u);return}let S=i==null?void 0:i.getEngine().resizeImageBitmap(T,b,R);p(S,b,R),i.removePendingData(u)},g=(T,b)=>{i.removePendingData(u),t.onError&&t.onError(T,b)};re.LoadImage(e,_,g,i.offlineProvider)}else p(e.data,e.width,e.height);return u}var xE=A(()=>{ve();et();Rt();Vt();BM();Tt();At();Ci();hi();de.CreateGround=SE;de.CreateTiledGround=UM;de.CreateGroundFromHeightMap=VM;U.CreateGround=(n,e,t,i,r,s)=>AE(n,{width:e,height:t,subdivisions:i,updatable:s},r);U.CreateTiledGround=(n,e,t,i,r,s,a,o,l)=>RE(n,{xmin:e,zmin:t,xmax:i,zmax:r,subdivisions:s,precision:a,updatable:l},o);U.CreateGroundFromHeightMap=(n,e,t,i,r,s,a,o,l,c,f)=>IE(n,e,{width:t,height:i,subdivisions:r,minHeight:s,maxHeight:a,updatable:l,onReady:c,alphaFilter:f},o)});function mu(n){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],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],r=[],s=n.width||n.size||1,a=n.height||n.size||1,o=n.depth||n.size||1,l=n.wrap||!1,c=n.topBaseAt===void 0?1:n.topBaseAt,f=n.bottomBaseAt===void 0?0:n.bottomBaseAt;c=(c+4)%4,f=(f+4)%4;let d=[2,0,3,1],h=[2,0,1,3],u=d[c],m=h[f],p=[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],p=[-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 x=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],P=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],L=[17,18,19,16],y=[22,23,20,21];for(;u>0;)x.unshift(x.pop()),L.unshift(L.pop()),u--;for(;m>0;)P.unshift(P.pop()),y.unshift(y.pop()),m--;x=x.flat(),P=P.flat(),p=p.concat(x).concat(P),t.push(L[0],L[2],L[3],L[0],L[1],L[2]),t.push(y[0],y[2],y[3],y[0],y[1],y[2])}let _=[s/2,a/2,o/2],g=p.reduce((x,P,L)=>x.concat(P*_[L%3]),[]),T=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,b=n.faceUV||new Array(6),R=n.faceColors,S=[];for(let x=0;x<6;x++)b[x]===void 0&&(b[x]=new vt(0,0,1,1)),R&&R[x]===void 0&&(R[x]=new Ne(1,1,1,1));for(let x=0;x<6;x++)if(r.push(b[x].z,He?1-b[x].w:b[x].w),r.push(b[x].x,He?1-b[x].w:b[x].w),r.push(b[x].x,He?1-b[x].y:b[x].y),r.push(b[x].z,He?1-b[x].y:b[x].y),R)for(let P=0;P<4;P++)S.push(R[x].r,R[x].g,R[x].b,R[x].a);de._ComputeSides(T,g,t,i,r,n.frontUVs,n.backUVs);let I=new de;if(I.indices=t,I.positions=g,I.normals=i,I.uvs=r,R){let x=T===de.DOUBLESIDE?S.concat(S):S;I.colors=x}return I}function CE(n,e={},t=null){let i=new U(n,t);return e.sideOrientation=U._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,mu(e).applyToMesh(i,e.updatable),i}var bE=A(()=>{ve();et();Rt();Vt();hi();xE();de.CreateBox=mu;U.CreateBox=(n,e,t=null,i,r)=>CE(n,{size:e,sideOrientation:r,updatable:i},t)});function ec(n){let e=n.pattern||U.NO_FLIP,t=n.tileWidth||n.tileSize||1,i=n.tileHeight||n.tileSize||1,r=n.alignHorizontal||0,s=n.alignVertical||0,a=n.width||n.size||1,o=Math.floor(a/t),l=a-o*t,c=n.height||n.size||1,f=Math.floor(c/i),d=c-f*i,h=t*o/2,u=i*f/2,m=0,p=0,_=0,g=0,T=0,b=0;if(l>0||d>0){switch(_=-h,g=-u,T=h,b=u,r){case U.CENTER:l/=2,_-=l,T+=l;break;case U.LEFT:T+=l,m=-l/2;break;case U.RIGHT:_-=l,m=l/2;break}switch(s){case U.CENTER:d/=2,g-=d,b+=d;break;case U.BOTTOM:b+=d,p=-d/2;break;case U.TOP:g-=d,p=d/2;break}}let R=[],S=[],I=[];I[0]=[0,0,1,0,1,1,0,1],I[1]=[0,0,1,0,1,1,0,1],(e===U.ROTATE_TILE||e===U.ROTATE_ROW)&&(I[1]=[1,1,0,1,0,0,1,0]),(e===U.FLIP_TILE||e===U.FLIP_ROW)&&(I[1]=[1,0,0,0,0,1,1,1]),(e===U.FLIP_N_ROTATE_TILE||e===U.FLIP_N_ROTATE_ROW)&&(I[1]=[0,1,1,1,1,0,0,0]);let x=[],P=[],L=[],y=0;for(let O=0;O0||d>0){let O=d>0&&(s===U.CENTER||s===U.TOP),V=d>0&&(s===U.CENTER||s===U.BOTTOM),X=l>0&&(r===U.CENTER||r===U.RIGHT),j=l>0&&(r===U.CENTER||r===U.LEFT),Q,$,q,z,K;if(O&&X&&(R.push(_+m,g+p,0),R.push(-h+m,g+p,0),R.push(-h+m,g+d+p,0),R.push(_+m,g+d+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=1-l/t,q=1-d/i,z=1,K=1,Q=[$,q,z,q,z,K,$,K],e===U.ROTATE_ROW&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),e===U.FLIP_ROW&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),e===U.FLIP_N_ROTATE_ROW&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O&&j&&(R.push(h+m,g+p,0),R.push(T+m,g+p,0),R.push(T+m,g+d+p,0),R.push(h+m,g+d+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=0,q=1-d/i,z=l/t,K=1,Q=[$,q,z,q,z,K,$,K],(e===U.ROTATE_ROW||e===U.ROTATE_TILE&&o%2===0)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===U.FLIP_ROW||e===U.FLIP_TILE&&o%2===0)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===U.FLIP_N_ROTATE_ROW||e===U.FLIP_N_ROTATE_TILE&&o%2===0)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),V&&X&&(R.push(_+m,u+p,0),R.push(-h+m,u+p,0),R.push(-h+m,b+p,0),R.push(_+m,b+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=1-l/t,q=0,z=1,K=d/i,Q=[$,q,z,q,z,K,$,K],(e===U.ROTATE_ROW&&f%2===1||e===U.ROTATE_TILE&&f%1===0)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===U.FLIP_ROW&&f%2===1||e===U.FLIP_TILE&&f%2===0)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===U.FLIP_N_ROTATE_ROW&&f%2===1||e===U.FLIP_N_ROTATE_TILE&&f%2===0)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),V&&j&&(R.push(h+m,u+p,0),R.push(T+m,u+p,0),R.push(T+m,b+p,0),R.push(h+m,b+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=0,q=0,z=l/t,K=d/i,Q=[$,q,z,q,z,K,$,K],(e===U.ROTATE_ROW&&f%2===1||e===U.ROTATE_TILE&&(f+o)%2===1)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===U.FLIP_ROW&&f%2===1||e===U.FLIP_TILE&&(f+o)%2===1)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===U.FLIP_N_ROTATE_ROW&&f%2===1||e===U.FLIP_N_ROTATE_TILE&&(f+o)%2===1)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O){let J=[];$=0,q=1-d/i,z=1,K=1,J[0]=[$,q,z,q,z,K,$,K],J[1]=[$,q,z,q,z,K,$,K],(e===U.ROTATE_TILE||e===U.ROTATE_ROW)&&(J[1]=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===U.FLIP_TILE||e===U.FLIP_ROW)&&(J[1]=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===U.FLIP_N_ROTATE_TILE||e===U.FLIP_N_ROTATE_ROW)&&(J[1]=[$,1-q,z,1-q,z,1-K,$,1-K]);for(let te=0;te{Rt();Vt();de.CreateTiledPlane=ec});function kM(n){let t=n.faceUV||new Array(6),i=n.faceColors,r=n.pattern||U.NO_FLIP,s=n.width||n.size||1,a=n.height||n.size||1,o=n.depth||n.size||1,l=n.tileWidth||n.tileSize||1,c=n.tileHeight||n.tileSize||1,f=n.alignHorizontal||0,d=n.alignVertical||0,h=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE;for(let O=0;O<6;O++)t[O]===void 0&&(t[O]=new vt(0,0,1,1)),i&&i[O]===void 0&&(i[O]=new Ne(1,1,1,1));let u=s/2,m=a/2,p=o/2,_=[];for(let O=0;O<2;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:s,height:a,alignVertical:d,alignHorizontal:f,sideOrientation:h});for(let O=2;O<4;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:o,height:a,alignVertical:d,alignHorizontal:f,sideOrientation:h});let g=d;d===U.BOTTOM?g=U.TOP:d===U.TOP&&(g=U.BOTTOM);for(let O=4;O<6;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:s,height:o,alignVertical:g,alignHorizontal:f,sideOrientation:h});let T=[],b=[],R=[],S=[],I=[],x=[],P=[],L=[],y,B=0;for(let O=0;O<6;O++){let V=_[O].positions.length;x[O]=[],P[O]=[];for(let X=0;XX+B)),B+=x[O].length,i){let X=i[O];for(let j=0;j{ve();et();Rt();Vt();ME();hi();pu=1,yE=-1;de.CreateTiledBox=kM});function zM(n){let e=(n.segments||32)|0,t=n.diameterX||n.diameter||1,i=n.diameterY||n.diameter||1,r=n.diameterZ||n.diameter||1,s=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,a=n.slice&&n.slice<=0?1:n.slice||1,o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=!!n.dedupTopBottomIndices,c=new v(t/2,i/2,r/2),f=2+e,d=2*f,h=[],u=[],m=[],p=[];for(let g=0;g<=f;g++){let T=g/f,b=T*Math.PI*a;for(let R=0;R<=d;R++){let S=R/d,I=S*Math.PI*2*s,x=G.RotationZ(-b),P=G.RotationY(I),L=v.TransformCoordinates(v.Up(),x),y=v.TransformCoordinates(L,P),B=y.multiply(c),w=y.divide(c).normalize();u.push(B.x,B.y,B.z),m.push(w.x,w.y,w.z),p.push(S,He?1-T:T)}if(g>0){let R=u.length/3;for(let S=R-2*(d+1);S+d+21&&(h.push(S),h.push(S+1),h.push(S+d+1)),(g{ve();Rt();Vt();hi();de.CreateSphere=zM;U.CreateSphere=(n,e,t,i,r,s)=>DE(n,{segments:e,diameterX:t,diameterY:t,diameterZ:t,sideOrientation:s,updatable:r},i)});function YM(n){let e=n.height||2,t=n.diameterTop===0?0:n.diameterTop||n.diameter||1,i=n.diameterBottom===0?0:n.diameterBottom||n.diameter||1;t=t||1e-5,i=i||1e-5;let r=(n.tessellation||24)|0,s=(n.subdivisions||1)|0,a=!!n.hasRings,o=!!n.enclose,l=n.cap===0?0:n.cap||U.CAP_ALL,c=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,f=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,d=n.faceUV||new Array(3),h=n.faceColors,u=c!==1&&o?2:0,m=a?s:1,p=2+(1+u)*m,_;for(_=0;_{let se=me?t/2:i/2;if(se===0)return;let le,xe,ce,he=me?d[p-1]:d[0],ke=null;h&&(ke=me?h[p-1]:h[0]);let $e=T.length/3,Fe=me?e/2:-e/2,Xe=new v(0,Fe,0);T.push(Xe.x,Xe.y,Xe.z),b.push(0,me?1:-1,0);let xt=he.y+(he.w-he.y)*.5;R.push(he.x+(he.z-he.x)*.5,He?1-xt:xt),ke&&S.push(ke.r,ke.g,ke.b,ke.a);let Dt=new _e(.5,.5);for(ce=0;ce<=r;ce++){le=Math.PI*2*ce*c/r;let Yt=Math.cos(-le),di=Math.sin(-le);xe=new v(Yt*se,Fe,di*se);let pr=new _e(Yt*Dt.x+.5,di*Dt.y+.5);T.push(xe.x,xe.y,xe.z),b.push(0,me?1:-1,0);let xd=he.y+(he.w-he.y)*pr.y;R.push(he.x+(he.z-he.x)*pr.x,He?1-xd:xd),ke&&S.push(ke.r,ke.g,ke.b,ke.a)}for(ce=0;ce{ve();et();Rt();Vt();gr();rl();hi();de.CreateCylinder=YM;U.CreateCylinder=(n,e,t,i,r,s,a,o,l)=>((a===void 0||!(a instanceof gt))&&(a!==void 0&&(l=o||U.DEFAULTSIDE,o=a),a=s,s=1),LE(n,{height:e,diameterTop:t,diameterBottom:i,tessellation:r,subdivisions:s,sideOrientation:l,updatable:o},a))});function jM(n){let e=[],t=[],i=[],r=[],s=n.diameter||1,a=n.thickness||.5,o=(n.tessellation||16)|0,l=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,c=o+1;for(let d=0;d<=o;d++){let h=d/o,u=d*Math.PI*2/o-Math.PI/2,m=G.Translation(s/2,0,0).multiply(G.RotationY(u));for(let p=0;p<=o;p++){let _=1-p/o,g=p*Math.PI*2/o+Math.PI,T=Math.cos(g),b=Math.sin(g),R=new v(T,b,0),S=R.scale(a/2),I=new _e(h,_);S=v.TransformCoordinates(S,m),R=v.TransformNormal(R,m),t.push(S.x,S.y,S.z),i.push(R.x,R.y,R.z),r.push(I.x,He?1-I.y:I.y);let x=(d+1)%c,P=(p+1)%c;e.push(d*c+p),e.push(d*c+P),e.push(x*c+p),e.push(d*c+P),e.push(x*c+P),e.push(x*c+p)}}de._ComputeSides(l,t,e,i,r,n.frontUVs,n.backUVs);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function PE(n,e={},t){let i=new U(n,t);return e.sideOrientation=U._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,jM(e).applyToMesh(i,e.updatable),i}var ZM=A(()=>{ve();Rt();Vt();hi();de.CreateTorus=jM;U.CreateTorus=(n,e,t,i,r,s,a)=>PE(n,{diameter:e,thickness:t,tessellation:i,sideOrientation:a,updatable:s},r)});function qM(n){let e=[],t=[],i=[],r=[],s=n.radius||2,a=n.tube||.5,o=n.radialSegments||32,l=n.tubularSegments||32,c=n.p||2,f=n.q||3,d=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,h=_=>{let g=Math.cos(_),T=Math.sin(_),b=f/c*_,R=Math.cos(b),S=s*(2+R)*.5*g,I=s*(2+R)*T*.5,x=s*Math.sin(b)*.5;return new v(S,I,x)},u,m;for(u=0;u<=o;u++){let g=u%o/o*2*c*Math.PI,T=h(g),b=h(g+.01),R=b.subtract(T),S=b.add(T),I=v.Cross(R,S);for(S=v.Cross(I,R),I.normalize(),S.normalize(),m=0;m{ve();Rt();Vt();hi();de.CreateTorusKnot=qM;U.CreateTorusKnot=(n,e,t,i,r,s,a,o,l,c)=>OE(n,{radius:e,tube:t,radialSegments:i,tubularSegments:r,p:s,q:a,sideOrientation:c,updatable:l},o)});var xs,NE=A(()=>{ve();ze();Dl();Rt();Qc();yl();yt();Tt();Lt();U._instancedMeshFactory=(n,e)=>{let t=new xs(n,e);if(e.instancedBuffers){t.instancedBuffers={};for(let i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t};xs=class extends zt{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(let i of t.getAnimationRanges())i!=null&&this.createAnimationRange(i.name,i.from,i.to);if(this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),!t.skeleton&&!t.morphTargetManager&&t.hasBoundingInfo){let i=t.getBoundingInfo();this.buildBoundingInfo(i.minimum,i.maximum)}else 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&&re.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&&re.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&&re.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&&re.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||W.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}get geometry(){return this._sourceMesh._geometry}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)}getVertexBuffer(e,t){return this._sourceMesh.getVertexBuffer(e,t)}setVerticesData(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh}updateVerticesData(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),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};let r=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,M.PositionKind),r),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||W.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!==this._sourceMesh&&this._currentLOD.billboardMode!==st.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new G);let e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,k.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(k.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;let t=this.sourceMesh.getLODLevels();if(!t||t.length===0)this._currentLOD=this.sourceMesh;else{let 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{Bi=class{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,ethis._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;let i=this._mesh.getScene();for(let r=0;r0&&(s.computeBonesUsingShaders=!1);continue}if(!(!s.computeBonesUsingShaders||s.numBoneInfluencers===0)){if(s.material.getEffect()===t)s.computeBonesUsingShaders=!1;else if(s.subMeshes){for(let a of s.subMeshes)if(a.effect===t){s.computeBonesUsingShaders=!1;break}}}}}else{let i=this._defines[this._currentRank];if(i)for(let r=0;r{ve();Ni();Xn=class extends ae{constructor(e,t,i=!0,r=!1){super(e,t,void 0,r),this._normalMatrix=new G,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){let 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,r=1){return i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,r)}dispose(e,t,i){this._activeEffect=void 0,super.dispose(e,t,i)}}});function La(n){let e=n.getVertexBuffers();if(!e)return null;let t=JM.get(n);if(!t)t=new Map,JM.set(n,t);else{let i=!1;for(let r in e)if(!t.has(r)){i=!0;break}if(!i)return t}for(let i in e){let r=e[i];if(r){let s=r.byteOffset,a=r.byteStride,o=r.type,l=r.normalized;t.set(i,{offset:s,stride:a,type:o,normalized:l})}}return t}function Pa(n,e){e.forEach((t,i)=>{let r=`vp_${i}_info`;n.setFloat4(r,t.offset,t.stride,t.type,t.normalized?1:0)})}var JM,Cf=A(()=>{JM=new WeakMap});var FE,vn,wE=A(()=>{Kt();gr();ve();yt();oi();Lt();Da();mo();xf();At();kn();Oi();Cf();FE={effect:null,subMesh:null},vn=class n extends Xn{constructor(e,t,i,r={},s=!0){super(e,t,s),this._textures={},this._internalTextures={},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 G,this._cachedWorldViewProjectionMatrix=new G,this._multiview=!1,this._vertexPullingMetadata=null,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,...r}}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}setInternalTexture(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._internalTextures[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,r)=>(i.push(r.r,r.g,r.b),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,r)=>(i.push(r.r,r.g,r.b,r.a),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,r)=>(r.toArray(i,i.length),i),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);let i=new Float32Array(t.length*16);for(let r=0;rs===e||s.startsWith(i));return r>=0&&this.options.defines.splice(r,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 I,x,P,L;let r=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){let y=r?i._drawWrapper:this._drawWrapper;if(y.effect&&y._wasPreviouslyReady&&y._wasPreviouslyUsingInstances===t)return!0}let s=this.getScene(),a=s.getEngine(),o=[],l=[],c=null,f=this._shaderPath,d=this._options.uniforms,h=this._options.uniformBuffers,u=this._options.samplers;a.getCaps().multiview&&s.activeCamera&&s.activeCamera.outputRenderTarget&&s.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,o.push("#define MULTIVIEW"),d.indexOf("viewProjection")!==-1&&d.indexOf("viewProjectionR")===-1&&d.push("viewProjectionR"));for(let y=0;y4&&(l.push(M.MatricesIndicesExtraKind),l.push(M.MatricesWeightsExtraKind));let y=e.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),c=new Bi,c.addCPUSkinningFallback(0,e),y.isUsingTextureForMatrices?(o.push("#define BONETEXTURE"),d.indexOf("boneTextureInfo")===-1&&d.push("boneTextureInfo"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(o.push("#define BonesPerMesh "+(y.bones.length+1)),d.indexOf("mBones")===-1&&d.push("mBones"))}else o.push("#define NUM_BONE_INFLUENCERS 0");let m=0,p=e?e.morphTargetManager:null;if(p){let y=o.indexOf("#define UV1")!==-1,B=o.indexOf("#define UV2")!==-1,w=o.indexOf("#define TANGENT")!==-1,H=o.indexOf("#define NORMAL")!==-1,O=o.indexOf("#define VERTEXCOLOR")!==-1;m=Wn(p,o,l,e,!0,H,w,y,B,O),p.isUsingTextureForTargets&&(d.indexOf("morphTargetTextureIndices")===-1&&d.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),m>0&&(d=d.slice(),d.push("morphTargetInfluences"),d.push("morphTargetCount"),d.push("morphTargetTextureInfo"),d.push("morphTargetTextureIndices"))}else o.push("#define NUM_MORPH_INFLUENCERS 0");if(e){let y=e.bakedVertexAnimationManager;y&&y.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),d.indexOf("bakedVertexAnimationSettings")===-1&&d.push("bakedVertexAnimationSettings"),d.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&d.push("bakedVertexAnimationTextureSizeInverted"),d.indexOf("bakedVertexAnimationTime")===-1&&d.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture"),t&&l.push("bakedVertexAnimationSettingsInstanced"))}for(let y in this._textures)if(!this._textures[y].isReady())return!1;for(let y in this._internalTextures)if(!this._internalTextures[y].isReady)return!1;e&&this.needAlphaTestingForMesh(e)&&o.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&(Di(d),Gn(this,s,o)),s.fogEnabled&&(e!=null&&e.applyFog)&&s.fogMode!==gt.FOGMODE_NONE&&(o.push("#define FOG"),d.indexOf("view")===-1&&d.push("view"),d.indexOf("vFogInfos")===-1&&d.push("vFogInfos"),d.indexOf("vFogColor")===-1&&d.push("vFogColor")),this._useLogarithmicDepth&&(o.push("#define LOGARITHMICDEPTH"),d.indexOf("logarithmicDepthConstant")===-1&&d.push("logarithmicDepthConstant"));let _=i?i.getRenderingMesh():e;if(_&&this.useVertexPulling){let y=_.geometry;y&&(this._vertexPullingMetadata=La(y),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((w,H)=>{d.push(`vp_${H}_info`)})),o.push("#define USE_VERTEX_PULLING");let B=(I=_.geometry)==null?void 0:I.getIndexBuffer();B&&!_.isUnIndexed&&(o.push("#define VERTEX_PULLING_USE_INDEX_BUFFER"),B.is32Bits&&o.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS"))}this.customShaderNameResolve&&(d=d.slice(),h=h.slice(),u=u.slice(),f=this.customShaderNameResolve(this.name,d,h,u,o,l));let g=r?i._getDrawWrapper(void 0,!0):this._drawWrapper,T=(x=g==null?void 0:g.effect)!=null?x:null,b=(P=g==null?void 0:g.defines)!=null?P:null,R=o.join(` -`),S=T;return b!==R&&(S=a.createEffect(f,{attributes:l,uniformsNames:d,uniformBuffersNames:h,samplers:u,defines:R,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:m},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},a),r?i.setEffect(S,R,this._materialContext):g&&g.setEffect(S,R),this._onEffectCreatedObservable&&(FE.effect=S,FE.subMesh=(L=i!=null?i:e==null?void 0:e.subMeshes[0])!=null?L:null,this._onEffectCreatedObservable.notifyObservers(FE))),g._wasPreviouslyUsingInstances=!!t,S!=null&&S.isReady()?(T!==S&&s.resetCachedMaterial(),g._wasPreviouslyReady=!0,!0):!1}bindOnlyWorldMatrix(e,t){let i=t!=null?t:this.getEffect();if(!i)return;let r=this._options.uniforms;r.indexOf("world")!==-1&&i.setMatrix("world",e);let s=this.getScene();r.indexOf("worldView")!==-1&&(e.multiplyToRef(s.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),r.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(s.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),r.indexOf("view")!==-1&&i.setMatrix("view",s.getViewMatrix())}bindForSubMesh(e,t,i){var r;this.bind(e,t,(r=i._drawWrapperOverride)==null?void 0:r.effect,i)}bind(e,t,i,r){var d;let s=r&&this._storeEffectOnSubMeshes,a=i!=null?i:s?r.effect:this.getEffect();if(!a)return;let o=this.getScene();this._activeEffect=a,this.bindOnlyWorldMatrix(e,i);let l=this._options.uniformBuffers,c=!1;if(a&&l&&l.length>0&&o.getEngine().supportsUniformBuffers)for(let h=0;hnew n(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};let i=Object.keys(this._options);for(let r of i){let s=this._options[r];Array.isArray(s)&&(this._options[r]=s.slice(0))}this.stencil.copyTo(t.stencil);for(let r in this._textures)t.setTexture(r,this._textures[r]);for(let r in this._internalTextures)t.setInternalTexture(r,this._internalTextures[r]);for(let r in this._textureArrays)t.setTextureArray(r,this._textureArrays[r]);for(let r in this._externalTextures)t.setExternalTexture(r,this._externalTextures[r]);for(let r in this._ints)t.setInt(r,this._ints[r]);for(let r in this._uints)t.setUInt(r,this._uints[r]);for(let r in this._floats)t.setFloat(r,this._floats[r]);for(let r in this._floatsArrays)t.setFloats(r,this._floatsArrays[r]);for(let r in this._colors3)t.setColor3(r,this._colors3[r]);for(let r in this._colors3Arrays)t._colors3Arrays[r]=this._colors3Arrays[r];for(let r in this._colors4)t.setColor4(r,this._colors4[r]);for(let r in this._colors4Arrays)t._colors4Arrays[r]=this._colors4Arrays[r];for(let r in this._vectors2)t.setVector2(r,this._vectors2[r]);for(let r in this._vectors3)t.setVector3(r,this._vectors3[r]);for(let r in this._vectors4)t.setVector4(r,this._vectors4[r]);for(let r in this._quaternions)t.setQuaternion(r,this._quaternions[r]);for(let r in this._quaternionsArrays)t._quaternionsArrays[r]=this._quaternionsArrays[r];for(let r in this._matrices)t.setMatrix(r,this._matrices[r]);for(let r in this._matrixArrays)t._matrixArrays[r]=this._matrixArrays[r].slice();for(let r in this._matrices3x3)t.setMatrix3x3(r,this._matrices3x3[r]);for(let r in this._matrices2x2)t.setMatrix2x2(r,this._matrices2x2[r]);for(let r in this._vectors2Arrays)t.setArray2(r,this._vectors2Arrays[r]);for(let r in this._vectors3Arrays)t.setArray3(r,this._vectors3Arrays[r]);for(let r in this._vectors4Arrays)t.setArray4(r,this._vectors4Arrays[r]);for(let r in this._uniformBuffers)t.setUniformBuffer(r,this._uniformBuffers[r]);for(let r in this._textureSamplers)t.setTextureSampler(r,this._textureSamplers[r]);for(let r in this._storageBuffers)t.setStorageBuffer(r,this._storageBuffers[r]);return t}dispose(e,t,i){if(t){let r;for(r in this._textures)this._textures[r].dispose();for(r in this._internalTextures)this._internalTextures[r].dispose();for(r in this._textureArrays){let s=this._textureArrays[r];for(let a=0;anew n(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes),e,t,i),s;e.stencil&&r.stencil.parse(e.stencil,t,i);for(s in e.textures)r.setTexture(s,ne.Parse(e.textures[s],t,i));for(s in e.textureArrays){let a=e.textureArrays[s],o=[];for(let l=0;l(c%3===0?o.push([l]):o[o.length-1].push(l),o),[]).map(o=>({r:o[0],g:o[1],b:o[2]}));r.setColor3Array(s,a)}for(s in e.colors4){let a=e.colors4[s];r.setColor4(s,{r:a[0],g:a[1],b:a[2],a:a[3]})}for(s in e.colors4Arrays){let a=e.colors4Arrays[s].reduce((o,l,c)=>(c%4===0?o.push([l]):o[o.length-1].push(l),o),[]).map(o=>({r:o[0],g:o[1],b:o[2],a:o[3]}));r.setColor4Array(s,a)}for(s in e.vectors2){let a=e.vectors2[s];r.setVector2(s,{x:a[0],y:a[1]})}for(s in e.vectors3){let a=e.vectors3[s];r.setVector3(s,{x:a[0],y:a[1],z:a[2]})}for(s in e.vectors4){let a=e.vectors4[s];r.setVector4(s,{x:a[0],y:a[1],z:a[2],w:a[3]})}for(s in e.quaternions)r.setQuaternion(s,Ae.FromArray(e.quaternions[s]));for(s in e.matrices)r.setMatrix(s,G.FromArray(e.matrices[s]));for(s in e.matrixArray)r._matrixArrays[s]=new Float32Array(e.matrixArray[s]);for(s in e.matrices3x3)r.setMatrix3x3(s,e.matrices3x3[s]);for(s in e.matrices2x2)r.setMatrix2x2(s,e.matrices2x2[s]);for(s in e.vectors2Arrays)r.setArray2(s,e.vectors2Arrays[s]);for(s in e.vectors3Arrays)r.setArray3(s,e.vectors3Arrays[s]);for(s in e.vectors4Arrays)r.setArray4(s,e.vectors4Arrays[s]);for(s in e.quaternionsArrays)r.setArray4(s,e.quaternionsArrays[s]);return r}static async ParseFromFileAsync(e,t,i,r=""){return await new Promise((s,a)=>{let o=new $t;o.addEventListener("readystatechange",()=>{if(o.readyState==4)if(o.status==200){let l=JSON.parse(o.responseText),c=this.Parse(l,i||ue.LastCreatedScene,r);e&&(c.name=e),s(c)}else a("Unable to load the ShaderMaterial")}),o.open("GET",t),o.send()})}static async ParseFromSnippetAsync(e,t,i=""){return await new Promise((r,s)=>{let a=new $t;a.addEventListener("readystatechange",()=>{if(a.readyState==4)if(a.status==200){let o=JSON.parse(JSON.parse(a.responseText).jsonPayload),l=JSON.parse(o.shaderMaterial),c=this.Parse(l,t||ue.LastCreatedScene,i);c.snippetId=e,r(c)}else s("Unable to load the snippet "+e)}),a.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),a.send()})}};vn.SnippetUrl="https://snippet.babylonjs.com";vn.CreateFromSnippetAsync=vn.ParseFromSnippetAsync;je("BABYLON.ShaderMaterial",vn)});var $M,Tk,Cs=A(()=>{N();$M="bonesDeclaration",Tk=`#if NUM_BONE_INFLUENCERS>0 +Bad Bone Indices = `+m;return{skinned:!0,valid:s===0&&o===0&&m===0,report:p}}_checkDelayState(){let 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);let t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return re.LoadFile(this.delayLoadingFile,i=>{i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this);for(let r of this.instances)r.refreshBoundingInfo(),r._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){let t=this.getScene().materials,i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;let r=this.getScene().multiMaterials;for(i=r.length-1;i>-1;i--)if(r[i].id===e)return this.material=r[i],this;return this}getAnimatables(){let e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(M.PositionKind))return this;let t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(M.PositionKind),r=v.Zero(),s;for(s=0;s{let h=d.width,u=d.height,p=this.getEngine().createCanvas(h,u).getContext("2d");p.drawImage(d,0,0);let _=p.getImageData(0,0,h,u).data;this.applyDisplacementMapFromBuffer(_,h,u,t,i,s,a,o),r&&r(this)};return re.LoadImage(e,f,l||(()=>{}),c.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,r,s,a,o,l=!1){if(!this.isVerticesDataPresent(M.PositionKind)||!this.isVerticesDataPresent(M.NormalKind)||!this.isVerticesDataPresent(M.UVKind))return W.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;let c=this.getVerticesData(M.PositionKind,!0,!0),f=this.getVerticesData(M.NormalKind),d=this.getVerticesData(M.UVKind),h=v.Zero(),u=v.Zero(),m=_e.Zero();a=a||_e.Zero(),o=o||new _e(1,1);for(let p=0;p{var c;return!((c=this.getVertexBuffer(l))!=null&&c.getIsInstanced())}),i=this.getIndices(!1,!0),r={},s=(l,c)=>{let f=new Float32Array(i.length*c),d=0;for(let h=0;h{let o=r.length-1-a,l=r[o];for(let c=0;c{for(let o=0;o-1&&(r._waitingMorphTargetManagerId=e.morphTargetManagerId),e.skeletonId!==void 0&&e.skeletonId!==null&&(r.skeleton=t.getLastSkeletonById(e.skeletonId),r._waitingSkeletonId=e.skeletonId,e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.skeletonUniqueId!==void 0&&e.skeletonUniqueId!==null&&(r._waitingSkeletonUniqueId=e.skeletonUniqueId),e.animations){for(let a=0;a4,c=l?this.getVerticesData(M.MatricesIndicesExtraKind):null,f=l?this.getVerticesData(M.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),h=v.Zero(),u=new U,m=new U,p=0,_;for(let g=0;g0&&(U.FromFloat32ArrayToRefScaled(d,Math.floor(a[p+_]*16),T,m),u.addToSelf(m));if(l)for(_=0;_<4;_++)T=f[p+_],T>0&&(U.FromFloat32ArrayToRefScaled(d,Math.floor(c[p+_]*16),T,m),u.addToSelf(m));v.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],u,h),h.toArray(r,g),t&&(v.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],u,h),h.toArray(s,g)),u.reset()}return this.updateVerticesData(M.PositionKind,r),t&&this.updateVerticesData(M.NormalKind,s),this}static MinMax(e){let t=null,i=null;for(let r of e){let a=r.getBoundingInfo().boundingBox;!t||!i?(t=a.minimumWorld.clone(),i=a.maximumWorld.clone()):(t.minimizeInPlace(a.minimumWorld),i.maximizeInPlace(a.maximumWorld))}return!t||!i?{min:v.Zero(),max:v.Zero()}:{min:t,max:i}}static Center(e){let t=e instanceof Array?n.MinMax(e):e;return v.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,r,s,a){return Tf(n._MergeMeshesCoroutine(e,t,i,r,s,a,!1))}static async MergeMeshesAsync(e,t=!0,i,r,s,a){return await mM(n._MergeMeshesCoroutine(e,t,i,r,s,a,!0),hM())}static*_MergeMeshesCoroutine(e,t=!0,i,r,s,a,o){if(e=e.filter(Boolean),e.length===0)return null;let l;if(!i){let x=0;for(l=0;l=65536)return W.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}let c=e[0];a&&(s=!1,e.sort((x,P)=>{var L,y,B,w;return((y=(L=x.material)==null?void 0:L.uniqueId)!=null?y:-1)-((w=(B=P.material)==null?void 0:B.uniqueId)!=null?w:-1)}));let f=new Array,d=new Array,h=new Array,u=e[0].sideOrientation;for(l=0;lMath.max(L,y.start+y.count),0);if(a)if(x.material){let L=x.material;if(L instanceof jl){for(let y=0;y1){let x=0;for(let P=1;P{let P=x.computeWorldMatrix(!0);return{vertexData:de.ExtractFromMesh(x,!1,!1),transform:P}},{vertexData:p,transform:_}=m(e[0]);o&&(yield);let g=new Array(e.length-1);for(let x=1;x{throw Ie("GroundMesh")};V._GoldbergMeshParser=(n,e)=>{throw Ie("GoldbergMesh")};V._LinesMeshParser=(n,e)=>{throw Ie("LinesMesh")};V._GreasedLineMeshParser=(n,e)=>{throw Ie("GreasedLineMesh")};V._GreasedLineRibbonMeshParser=(n,e)=>{throw Ie("GreasedLineRibbonMesh")};V._TrailMeshParser=(n,e)=>{throw Ie("TrailMesh")};V._GaussianSplattingMeshParser=(n,e)=>{throw Ie("GaussianSplattingMesh")};V._GaussianSplattingPartProxyMeshParser=(n,e)=>{throw Ie("GaussianSplattingPartProxyMesh")};V._GaussianSplattingCompoundMeshParser=(n,e)=>{throw Ie("GaussianSplattingCompoundMesh")};je("BABYLON.Mesh",V)});var ql,hE=A(()=>{dn();ns();bi();ql=class{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._attachedCamera=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;let t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ye.POINTERDOWN){this._isPointerDown=!0;return}i.type===ye.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;let i=kt.Now,r=0;this._lastFrameTime!=null&&(r=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();let s=i-this._lastInteractionTime-this._idleRotationWaitTime,a=Math.max(Math.min(s/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*a,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(r/1e3))})}detach(){if(!this._attachedCamera)return;let 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:kt.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha){uo();lr=class n{constructor(){this._easingMode=n.EASINGMODE_EASEIN}setEasingMode(e){let 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 n.EASINGMODE_EASEIN:return this.easeInCore(e);case n.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}};lr.EASINGMODE_EASEIN=0;lr.EASINGMODE_EASEOUT=1;lr.EASINGMODE_EASEINOUT=2;au=class extends lr{constructor(e=1){super(),this.amplitude=e}easeInCore(e){let t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}},ou=class extends lr{easeInCore(e){return e*e*e}},lu=class extends lr{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)}}});var xa,uE=A(()=>{xa=class n{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new n(this.name,this.from,this.to)}}});var mE,pE,_E,gE,EE,vE,En,Oe,Is=A(()=>{ve();et();Mi();Lt();uE();Sr();oh();mo();Kt();mE=Object.freeze(new Ae(0,0,0,0)),pE=Object.freeze(v.Zero()),_E=Object.freeze(_e.Zero()),gE=Object.freeze(os.Zero()),EE=Object.freeze(oe.Black()),vE=Object.freeze(new Ne(0,0,0,0)),En={key:0,repeatCount:0,loopMode:2},Oe=class n{static _PrepareAnimation(e,t,i,r,s,a,o,l){let c;if(!isNaN(parseFloat(s))&&isFinite(s)?c=n.ANIMATIONTYPE_FLOAT:s instanceof Ae?c=n.ANIMATIONTYPE_QUATERNION:s instanceof v?c=n.ANIMATIONTYPE_VECTOR3:s instanceof _e?c=n.ANIMATIONTYPE_VECTOR2:s instanceof oe?c=n.ANIMATIONTYPE_COLOR3:s instanceof Ne?c=n.ANIMATIONTYPE_COLOR4:s instanceof os&&(c=n.ANIMATIONTYPE_SIZE),c==null)return null;let f=new n(e,t,i,c,o),d=[{frame:0,value:s},{frame:r,value:a}];return f.setKeys(d),l!==void 0&&f.setEasingFunction(l),f}static CreateAnimation(e,t,i,r){let s=new n(e+"Animation",e,i,t,n.ANIMATIONLOOPMODE_CONSTANT);return s.setEasingFunction(r),s}static CreateAndStartAnimation(e,t,i,r,s,a,o,l,c,f,d){let h=n._PrepareAnimation(e,i,r,s,a,o,l,c);return!h||(t.getScene&&(d=t.getScene()),!d)?null:d.beginDirectAnimation(t,[h],0,s,h.loopMode!==n.ANIMATIONLOOPMODE_CONSTANT,1,f)}static CreateAndStartHierarchyAnimation(e,t,i,r,s,a,o,l,c,f,d){let h=n._PrepareAnimation(e,r,s,a,o,l,c,f);return h?t.getScene().beginDirectHierarchyAnimation(t,i,[h],0,a,h.loopMode===1,1,d):null}static CreateMergeAndStartAnimation(e,t,i,r,s,a,o,l,c,f){let d=n._PrepareAnimation(e,i,r,s,a,o,l,c);return d?(t.animations.push(d),t.getScene().beginAnimation(t,0,s,d.loopMode===1,1,f)):null}static MakeAnimationAdditive(e,t,i,r=!1,s){var T,b;let a;typeof t=="object"?a=t:a={referenceFrame:t!=null?t:0,range:i,cloneOriginalAnimation:r,clonedAnimationName:s};let o=e;if(a.cloneOriginalAnimation&&(o=e.clone(),o.name=a.clonedAnimationName||o.name),!o._keys.length)return o;let l=a.referenceFrame&&a.referenceFrame>=0?a.referenceFrame:0,c=0,f=o._keys[0],d=o._keys.length-1,h=o._keys[d],u={referenceValue:f.value,referencePosition:G.Vector3[0],referenceQuaternion:G.Quaternion[0],referenceScaling:G.Vector3[1],keyPosition:G.Vector3[2],keyQuaternion:G.Quaternion[1],keyScaling:G.Vector3[3]},m=f.frame,p=h.frame;if(a.range){let R=o.getRange(a.range);R&&(m=R.from,p=R.to)}else m=(T=a.fromFrame)!=null?T:m,p=(b=a.toFrame)!=null?b:p;if(m!==f.frame&&(c=o.createKeyForFrame(m)),p!==h.frame&&(d=o.createKeyForFrame(p)),o._keys.length===1){let R=o._getKeyValue(o._keys[0]);u.referenceValue=R.clone?R.clone():R}else if(l<=f.frame){let R=o._getKeyValue(f.value);u.referenceValue=R.clone?R.clone():R}else if(l>=h.frame){let R=o._getKeyValue(h.value);u.referenceValue=R.clone?R.clone():R}else{En.key=0;let R=o._interpolate(l,En);u.referenceValue=R.clone?R.clone():R}o.dataType===n.ANIMATIONTYPE_QUATERNION?u.referenceValue.normalize().conjugateInPlace():o.dataType===n.ANIMATIONTYPE_MATRIX&&(u.referenceValue.decompose(u.referenceScaling,u.referenceQuaternion,u.referencePosition),u.referenceQuaternion.normalize().conjugateInPlace());let _=Number.MAX_VALUE,g=a.clipKeys?[]:null;for(let R=c;R<=d;R++){let S=o._keys[R];if((g||a.cloneOriginalAnimation)&&(S={frame:S.frame,value:S.value.clone?S.value.clone():S.value,inTangent:S.inTangent,outTangent:S.outTangent,interpolation:S.interpolation,lockedTangent:S.lockedTangent,easingFunction:S.easingFunction},g&&(_===Number.MAX_VALUE&&(_=S.frame),S.frame-=_,g.push(S))),!(R&&o.dataType!==n.ANIMATIONTYPE_FLOAT&&S.value===f.value))switch(o.dataType){case n.ANIMATIONTYPE_MATRIX:S.value.decompose(u.keyScaling,u.keyQuaternion,u.keyPosition),u.keyPosition.subtractInPlace(u.referencePosition),u.keyScaling.divideInPlace(u.referenceScaling),u.referenceQuaternion.multiplyToRef(u.keyQuaternion,u.keyQuaternion),U.ComposeToRef(u.keyScaling,u.keyQuaternion,u.keyPosition,S.value);break;case n.ANIMATIONTYPE_QUATERNION:u.referenceValue.multiplyToRef(S.value,S.value);break;case n.ANIMATIONTYPE_VECTOR2:case n.ANIMATIONTYPE_VECTOR3:case n.ANIMATIONTYPE_COLOR3:case n.ANIMATIONTYPE_COLOR4:S.value.subtractToRef(u.referenceValue,S.value);break;case n.ANIMATIONTYPE_SIZE:S.value.width-=u.referenceValue.width,S.value.height-=u.referenceValue.height;break;default:S.value-=u.referenceValue}}return g&&o.setKeys(g,!0),o}static TransitionTo(e,t,i,r,s,a,o,l=null,c=!0,f){if(o<=0)return i[e]=t,l&&l(),null;let d=s*(o/1e3);return a.setKeys(f!=null?f:[{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:d,value:t}]),i.animations||(i.animations=[]),i.animations.push(a),r.beginAnimation(i,0,d,!1,1,l!=null?l:void 0,void 0,c)}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(let e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,i,r,s,a){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=r,this.loopMode=s,this.enableBlending=a,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this._coreAnimation=null,this.targetPropertyPath=t.split("."),this.dataType=r,this.loopMode=s===void 0?n.ANIMATIONLOOPMODE_CYCLE:s,this.uniqueId=n._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(let r in this._ranges)i||(t+=", "),i=!1,t+=r;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=0;a--)this._keys[a].frame>=r&&this._keys[a].frame<=s&&this._keys.splice(a,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;t0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;let r=this._keys,s;if(this._coreAnimation)s=this._coreAnimation._key;else{let p=r.length;for(s=t.key;s>=0&&e=r[s+1].frame;)++s;if(t.key=s,s<0)return i?void 0:this._getKeyValue(r[0].value);if(s+1>p-1)return i?void 0:this._getKeyValue(r[p-1].value);this._key=s}let a=r[s],o=r[s+1];if(i&&(e===a.frame||e===o.frame))return;let l=this._getKeyValue(a.value),c=this._getKeyValue(o.value);if(a.interpolation===1)return o.frame>e?l:c;let f=a.outTangent!==void 0&&o.inTangent!==void 0,d=o.frame-a.frame,h=(e-a.frame)/d,u=a.easingFunction||this.getEasingFunction();switch(u&&(h=u.ease(h)),this.dataType){case n.ANIMATIONTYPE_FLOAT:{let p=f?this.floatInterpolateFunctionWithTangents(l,a.outTangent*d,c,o.inTangent*d,h):this.floatInterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return((m=t.offsetValue)!=null?m:0)*t.repeatCount+p}break}case n.ANIMATIONTYPE_QUATERNION:{let p=f?this.quaternionInterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.quaternionInterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.addInPlace((t.offsetValue||mE).scale(t.repeatCount))}return p}case n.ANIMATIONTYPE_VECTOR3:{let p=f?this.vector3InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.vector3InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||pE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_VECTOR2:{let p=f?this.vector2InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.vector2InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||_E).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(l,c,h);case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(l,c,h).add((t.offsetValue||gE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_COLOR3:{let p=f?this.color3InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.color3InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||EE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_COLOR4:{let p=f?this.color4InterpolateFunctionWithTangents(l,a.outTangent.scale(d),c,o.inTangent.scale(d),h):this.color4InterpolateFunction(l,c,h);switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return p;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||vE).scale(t.repeatCount))}break}case n.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case n.ANIMATIONLOOPMODE_CYCLE:case n.ANIMATIONLOOPMODE_CONSTANT:case n.ANIMATIONLOOPMODE_YOYO:return n.AllowMatricesInterpolation?this.matrixInterpolateFunction(l,c,h,t.workValue):l;case n.ANIMATIONLOOPMODE_RELATIVE:case n.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return l}break}}return 0}matrixInterpolateFunction(e,t,i,r){return n.AllowMatrixDecomposeForInterpolation?r?(U.DecomposeLerpToRef(e,t,i,r),r):U.DecomposeLerp(e,t,i):r?(U.LerpToRef(e,t,i,r),r):U.Lerp(e,t,i)}clone(e=!1){let t=new n(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys,!1,e),this._ranges){t._ranges={};for(let i in this._ranges){let r=this._ranges[i];r&&(t._ranges[i]=r.clone())}}return t}setKeys(e,t=!1,i=!1){if(t)this._keys=e;else if(this._keys=e.slice(0),i)for(let r=0;r=2&&(l=o.values[1]),o.values.length>=3&&(c=o.values[2]),o.values.length>=4&&(f=o.values[3]);break;case n.ANIMATIONTYPE_QUATERNION:if(s=Ae.FromArray(o.values),o.values.length>=8){let h=Ae.FromArray(o.values.slice(4,8));h.equals(Ae.Zero())||(l=h)}if(o.values.length>=12){let h=Ae.FromArray(o.values.slice(8,12));h.equals(Ae.Zero())||(c=h)}o.values.length>=13&&(f=o.values[12]);break;case n.ANIMATIONTYPE_MATRIX:s=U.FromArray(o.values),o.values.length>=17&&(f=o.values[16]);break;case n.ANIMATIONTYPE_COLOR3:s=oe.FromArray(o.values),o.values[3]&&(l=oe.FromArray(o.values[3])),o.values[4]&&(c=oe.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break;case n.ANIMATIONTYPE_COLOR4:s=Ne.FromArray(o.values),o.values[4]&&(l=Ne.FromArray(o.values[4])),o.values[5]&&(c=Ne.FromArray(o.values[5])),o.values[6]&&(f=Ne.FromArray(o.values[6]));break;case n.ANIMATIONTYPE_VECTOR3:default:s=v.FromArray(o.values),o.values[3]&&(l=v.FromArray(o.values[3])),o.values[4]&&(c=v.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break}let d={};d.frame=o.frame,d.value=s,l!=null&&(d.inTangent=l),c!=null&&(d.outTangent=c),f!=null&&(d.interpolation=f),r.push(d)}if(t.setKeys(r),e.ranges)for(a=0;a{let s=new $t;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){let a=JSON.parse(s.responseText);if(a.animations&&(a=a.animations),a.length){let o=[];for(let l of a)o.push(this.Parse(l));i(o)}else{let o=this.Parse(a);e&&(o.name=e),i(o)}}else r("Unable to load the animation")}),s.open("GET",t),s.send()})}static async ParseFromSnippetAsync(e){return await new Promise((t,i)=>{let r=new $t;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){let s=JSON.parse(JSON.parse(r.responseText).jsonPayload);if(s.animations){let a=JSON.parse(s.animations),o=[];for(let l of a.animations){let c=this.Parse(l);c.snippetId=e,o.push(c)}t(o)}else{let a=JSON.parse(s.animation),o=this.Parse(a);o.snippetId=e,t(o)}}else i("Unable to load the snippet "+e)}),r.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),r.send()})}};Oe._UniqueIdGenerator=0;Oe.AllowMatricesInterpolation=!1;Oe.AllowMatrixDecomposeForInterpolation=!0;Oe.InheritOriginalValueFromActiveAnimations=!1;Oe.SnippetUrl="https://snippet.babylonjs.com";Oe.ANIMATIONTYPE_FLOAT=0;Oe.ANIMATIONTYPE_VECTOR3=1;Oe.ANIMATIONTYPE_QUATERNION=2;Oe.ANIMATIONTYPE_MATRIX=3;Oe.ANIMATIONTYPE_COLOR3=4;Oe.ANIMATIONTYPE_COLOR4=7;Oe.ANIMATIONTYPE_VECTOR2=5;Oe.ANIMATIONTYPE_SIZE=6;Oe.ANIMATIONLOOPMODE_RELATIVE=0;Oe.ANIMATIONLOOPMODE_CYCLE=1;Oe.ANIMATIONLOOPMODE_CONSTANT=2;Oe.ANIMATIONLOOPMODE_YOYO=4;Oe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;Oe.CreateFromSnippetAsync=Oe.ParseFromSnippetAsync;je("BABYLON.Animation",Oe);ht._AnimationRangeFactory=(n,e,t)=>new xa(n,e,t)});var Ql,LM=A(()=>{cu();Is();Ql=class n{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._attachedCamera=null,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;let t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(i=>{if(i&&(i.computeWorldMatrix(!0),i.getBoundingInfo)){let r=i.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=r*.05,this.upperRadiusTransitionRange=r*.05}}):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))})}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return this._attachedCamera?this._attachedCamera.radius===e&&!this._radiusIsAnimating:!1}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(n.EasingFunction.setEasingMode(n.EasingMode),this._radiusBounceTransition=Oe.CreateAnimation("radius",Oe.ANIMATIONTYPE_FLOAT,60,n.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;let t=Oe.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()}};Ql.EasingFunction=new au(.3);Ql.EasingMode=lr.EASINGMODE_EASEOUT});var Ca,PM=A(()=>{cu();ft();dn();ns();ve();Is();Ca=class n{constructor(){this.onTargetFramingAnimationEndObservable=new Y,this._mode=n.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._attachedCamera=null,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}get attachedNode(){return this._attachedCamera}init(){}attach(e){this._attachedCamera=e;let t=this._attachedCamera.getScene();n.EasingFunction.setEasingMode(n.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===ye.POINTERDOWN){this._isPointerDown=!0;return}i.type===ye.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;let 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);let r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)}zoomOnMeshHierarchy(e,t=!1,i=null){e.computeWorldMatrix(!0);let r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)}zoomOnMeshesHierarchy(e,t=!1,i=null){let r=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new v(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let a=0;a{this.stopAllAnimations(),r&&r(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()}),f&&this._animatables.push(f),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){let i=this._attachedCamera;if(!i)return 0;let r=i._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return i.lowerRadiusLimit&&this._mode===n.IgnoreBoundsSizeMode&&(r=ri.upperRadiusLimit?i.upperRadiusLimit:r),r}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;let e=kt.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=Oe.CreateAnimation("beta",Oe.ANIMATIONTYPE_FLOAT,60,n.EasingFunction));let r=Oe.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,()=>{this._clearAnimationLocks(),this.stopAllAnimations()});r&&this._animatables.push(r)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=kt.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}};Ca.EasingFunction=new lu;Ca.EasingMode=lr.EASINGMODE_EASEINOUT;Ca.IgnoreBoundsSizeMode=0;Ca.FitFrustumSidesMode=1});var fu,TE,cr,SE=A(()=>{Qe();qe();Gn();ve();bi();nl();Sr();ht.AddNodeConstructor("TargetCamera",(n,e)=>()=>new cr(n,v.Zero(),e));fu=U.Zero(),TE=Ae.Identity(),cr=class n extends Ue{constructor(e,t,i,r=!0){super(e,t,i,r),this.cameraDirection=new v(0,0,0),this.cameraRotation=new _e(0,0),this.updateUpVectorFromRotation=!1,this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this._panningEpsilon=Ye,this._rotationEpsilon=Ye,this.lockedTarget=null,this._currentTarget=v.Zero(),this._initialFocalDistance=1,this._viewMatrix=U.Zero(),this._cameraTransformMatrix=U.Zero(),this._cameraRotationMatrix=U.Zero(),this._transformedReferencePoint=v.Zero(),this._deferredPositionUpdate=new v,this._deferredRotationQuaternionUpdate=new Ae,this._deferredRotationUpdate=new v,this._deferredUpdated=!1,this._deferOnly=!1,this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0,this._referencePoint=v.Forward(this.getScene().useRightHandedSystem),this.rotation=new v(0,this.getScene().useRightHandedSystem?Math.PI:0,0)}getFrontPosition(e){this.getWorldMatrix();let t=G.Vector3[0],i=G.Vector3[1];return i.set(0,0,this._scene.useRightHandedSystem?-1:1),this.getDirectionToRef(i,t),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){let e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return super._restoreStateValues()?(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&this._storedRotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0):!1}_initCache(){super._initCache(),this._cache.lockedTarget=new 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 Ae(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();let 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;let 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(){let 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+=Ye),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),this.getScene().useRightHandedSystem?U.LookAtRHToRef(this.position,e,v.UpReadOnly,fu):U.LookAtLHToRef(this.position,e,v.UpReadOnly,fu),fu.invert();let t=this.rotationQuaternion||TE;Ae.FromRotationMatrixToRef(fu,t),t.toEulerAnglesToRef(this.rotation),this.rotation.z=0}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent){this.parent.getWorldMatrix().invertToRef(G.Matrix[0]),v.TransformNormalToRef(this.cameraDirection,G.Matrix[0],G.Vector3[0]),this._deferredPositionUpdate.addInPlace(G.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(){let 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()&&(Ae.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate)));let r=this.speed*this._panningEpsilon,s=this.speed*this._rotationEpsilon;t&&(Math.abs(this.cameraDirection.x){ze();Kt();Gn();wi={},Jl=class{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){let t=e.getSimpleName();if(this.attached[t]){W.Warn("camera input of type "+t+" already exists on camera");return}this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault)}remove(e){for(let t in this.attached){let i=this.attached[t];if(i===e){i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck();return}}}removeByType(e){for(let t in this.attached){let i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){let t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=Ue.ForceAttachControlToAlwaysPreventDefault?!1:e,this.attachedToElement=!0,this.noPreventDefault=e;for(let t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(let t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(let e in this.attached){let 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){let t={};for(let i in this.attached){let r=this.attached[i],s=Me.Serialize(r);t[r.getClassName()]=s}e.inputsmgr=t}parse(e){let t=e.inputsmgr;if(t){this.clear();for(let i in t){let r=wi[i];if(r){let s=t[i],a=Me.Parse(()=>new r,s,null);this.add(a)}}}else for(let i in this.attached){let r=wi[this.attached[i].getClassName()];if(r){let s=Me.Parse(()=>new r,e,null);this.remove(this.attached[i]),this.add(s)}}}}});var Rf,OM=A(()=>{Qe();qe();Tt();dn();Rf=class{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement(),r=0,s=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 d,h;let l=o.event,c=l.pointerType==="touch";if(o.type!==ye.POINTERMOVE&&this.buttons.indexOf(l.button)===-1)return;let f=l.target;if(this._altKey=l.altKey,this._ctrlKey=l.ctrlKey,this._metaKey=l.metaKey,this._shiftKey=l.shiftKey,this._buttonsPressed=l.buttons,t.isPointerLock){let u=l.movementX,m=l.movementY;this.onTouch(null,u,m),this._pointA=null,this._pointB=null}else{if(o.type!==ye.POINTERDOWN&&o.type!==ye.POINTERDOUBLETAP&&c&&((d=this._pointA)==null?void 0:d.pointerId)!==l.pointerId&&((h=this._pointB)==null?void 0:h.pointerId)!==l.pointerId)return;if(o.type===ye.POINTERDOWN&&(this._currentMousePointerIdDown===-1||c)){try{f==null||f.setPointerCapture(l.pointerId)}catch(u){}if(this._pointA===null)this._pointA={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType,button:l.button};else if(this._pointB===null)this._pointB={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType,button:l.button};else return;this._currentMousePointerIdDown===-1&&!c&&(this._currentMousePointerIdDown=l.pointerId),this.onButtonDown(l),e||(l.preventDefault(),i&&i.focus())}else if(o.type===ye.POINTERDOUBLETAP)this.onDoubleTap(l.pointerType);else if(o.type===ye.POINTERUP&&(this._currentMousePointerIdDown===l.pointerId||c)){try{f==null||f.releasePointerCapture(l.pointerId)}catch(u){}c||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==l.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==l.pointerId?this._pointB=null:this._pointA=this._pointB=null,(r!==0||s)&&(this.onMultiTouch(this._pointA,this._pointB,r,0,s,null),r=0,s=null),this._currentMousePointerIdDown=-1,this.onButtonUp(l),e||l.preventDefault()}else if(o.type===ye.POINTERMOVE){if(e||l.preventDefault(),this._pointA&&this._pointB===null){let u=l.clientX-this._pointA.x,m=l.clientY-this._pointA.y;this._pointA.x=l.clientX,this._pointA.y=l.clientY,this.onTouch(this._pointA,u,m)}else if(this._pointA&&this._pointB){let u=this._pointA.pointerId===l.pointerId?this._pointA:this._pointB;u.x=l.clientX,u.y=l.clientY;let m=this._pointA.x-this._pointB.x,p=this._pointA.y-this._pointB.y,_=m*m+p*p,g={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:l.pointerId,type:o.type};this.onMultiTouch(this._pointA,this._pointB,r,_,s,g),s=g,r=_}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE|ye.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,r=0,s=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);let a=this.camera.getScene().getEngine().getHostWindow();a&&re.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){let e=this.camera.getScene().getEngine().getHostWindow();e&&re.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){let e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentMousePointerIdDown=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,r,s,a){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}};C([D()],Rf.prototype,"buttons",void 0)});var Mo,NM=A(()=>{Qe();qe();OM();Mo=class extends Rf{constructor(){super(...arguments),this.pinchZoom=!0,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this._isPinching=!1,this._twoFingerActivityCount=0,this._shouldStartPinchZoom=!1}_computePinchZoom(e,t){}_computeMultiTouchPanning(e,t){}onMultiTouch(e,t,i,r,s,a){i===0&&s===null||r===0&&a===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,r),this._computeMultiTouchPanning(s,a)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._shouldStartPinchZoom?(this._computePinchZoom(i,r),this._isPinching=!0):this._computeMultiTouchPanning(s,a)):this.multiTouchPanning?this._computeMultiTouchPanning(s,a):this.pinchZoom&&this._computePinchZoom(i,r))}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._twoFingerActivityCount=0,this._isPinching=!1}};C([D()],Mo.prototype,"pinchZoom",void 0);C([D()],Mo.prototype,"multiTouchPanning",void 0);C([D()],Mo.prototype,"multiTouchPanAndZoom",void 0)});var Ar,FM=A(()=>{Qe();qe();Xn();NM();Ar=class n extends Mo{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.panningSensibility=1e3,this.pinchInwards=!0,this._isPanClick=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(this.panningSensibility!==0&&e&&t){let i=t.x-e.x,r=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=r/this.panningSensibility}}_computePinchZoom(e,t){let i=this.camera.radius||n.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,r,s,a){this._shouldStartPinchZoom=this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(r)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance,super.onMultiTouch(e,t,i,r,s,a)}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton,super.onButtonDown(e)}onButtonUp(e){super.onButtonUp(e)}onLostFocus(){this._isPanClick=!1,super.onLostFocus()}};Ar.MinimumRadiusForPinch=.001;C([D()],Ar.prototype,"buttons",void 0);C([D()],Ar.prototype,"angularSensibilityX",void 0);C([D()],Ar.prototype,"angularSensibilityY",void 0);C([D()],Ar.prototype,"pinchPrecision",void 0);C([D()],Ar.prototype,"pinchDeltaPercentage",void 0);C([D()],Ar.prototype,"useNaturalPinchZoom",void 0);C([D()],Ar.prototype,"panningSensibility",void 0);wi.ArcRotateCameraPointersInput=Ar});var fr,wM=A(()=>{Qe();qe();Xn();Ph();Tt();fr=class{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=re.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=>{let i=t.event;if(!i.metaKey){if(t.type===hn.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){let r=this._keys.indexOf(i.keyCode);r>=0&&this._keys.splice(r,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){let e=this.camera;for(let t=0;t{Qe();qe();Xn();dn();fo();ve();bi();Oh();Mi();Tt();wk=40,ba=class{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,r=e*.01*this.wheelDeltaPercentage*t;return e>0?i=r/(1+this.wheelDeltaPercentage):i=r*(1+this.wheelDeltaPercentage),i}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==ye.POINTERWHEEL)return;let i=t.event,r,s=i.deltaMode===un.DOM_DELTA_LINE?wk:1,a=-(i.deltaY*s);if(this.customComputeDeltaFromMouseWheel)r=this.customComputeDeltaFromMouseWheel(a,this,i);else if(this.wheelDeltaPercentage){if(r=this._computeDeltaFromMouseWheelLegacyEvent(a,this.camera.radius),r>0){let o=this.camera.radius,l=this.camera.inertialRadiusOffset+r;for(let c=0;c<20&&!(o<=l||Math.abs(l*this.camera.inertia)<.001);c++)o-=l,l*=this.camera.inertia;o=Ke(o,0,Number.MAX_VALUE),r=this._computeDeltaFromMouseWheelLegacyEvent(a,o)}}else r=a/(this.wheelPrecision*40);r&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(r)):this.camera.inertialRadiusOffset+=r),i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,ye.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;let 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(){let e=this.camera,t=e.target.subtract(e.position);this._hitPlane=ir.FromPositionAndNormal(e.target,t)}_getPosition(){var s;let e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,U.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 r=0;return this._hitPlane&&(r=(s=i.intersectsPlane(this._hitPlane))!=null?s:0),i.origin.addInPlace(i.direction.scaleInPlace(r))}_zoomToMouse(e){var l,c;let t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){let f=(l=t.lowerRadiusLimit)!=null?l:0;t.radius-(t.inertialRadiusOffset+e)/if&&(e=(t.radius-f)*i-t.inertialRadiusOffset)}let s=e/i/t.radius,a=this._getPosition(),o=G.Vector3[6];a.subtractToRef(t.target,o),o.scaleInPlace(s),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x){FM();wM();BM();Xn();du=class extends Jl{constructor(e){super(e)}addMouseWheel(){return this.add(new ba),this}addPointers(){return this.add(new Ar),this}addKeyboard(){return this.add(new fr),this}}});function Bk(n){let e=Math.PI/2;return n.x===0&&n.z===0||(e=Math.acos(n.x/Math.sqrt(Math.pow(n.x,2)+Math.pow(n.z,2)))),n.z<0&&(e=2*Math.PI-e),e}function Uk(n,e){return Math.acos(n/e)}function Bi(n,e){return isNaN(n)?e:n}var ut,hu=A(()=>{Qe();qe();ft();ve();Mi();Sr();Rt();hE();LM();PM();Gn();SE();UM();bi();Tt();Lt();ht.AddNodeConstructor("ArcRotateCamera",(n,e)=>()=>new ut(n,0,0,1,v.Zero(),e));ut=class n extends cr{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 U,this._upToYMatrix=new U,this._upVector=v.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){U.RotationAlignToRef(v.UpReadOnly,this._upVector,this._yToUpMatrix),U.RotationAlignToRef(this._upVector,v.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){let e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){let t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){let e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){let t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){let e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){let t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){let e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){let t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){let e=this.inputs.attached.pointers;return e?e.useNaturalPinchZoom:!1}set useNaturalPinchZoom(e){let t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){let e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){let t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){let e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){let e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){let e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){let e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){let e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){let t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){let e=this.inputs.attached.mousewheel;return e?e.zoomToMouseLocation:!1}set zoomToMouseLocation(e){let t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){let e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){let t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get isInterpolating(){return this._isInterpolating}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return this._bouncingBehavior!=null}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Ql,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 Ca,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 ql,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,r,s,a,o=!0){super(e,v.Zero(),a,o),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.lowerTargetYLimit=-1/0,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=v.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=_e.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new U,this.panningAxis=new v(1,1,0),this._transformedDirection=new v,this.mapPanning=!1,this._isInterpolating=!1,this.onMeshTargetChangedObservable=new Y,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._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget=new v(NaN,NaN,NaN),this._goalTargetScreenOffset=new _e(NaN,NaN),this._onCollisionPositionChange=(l,c,f=null)=>{f?(this.setPosition(c),this.onCollide&&this.onCollide(f)):this._previousPosition.copyFrom(this._position);let d=Math.cos(this.alpha),h=Math.sin(this.alpha),u=Math.cos(this.beta),m=Math.sin(this.beta);m===0&&(m=1e-4);let p=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*d*m,this.radius*u,this.radius*h*m),p.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let _=this.upVector;this.allowUpsideDown&&this.beta<0&&(_=_.clone(),_=_.negate()),this._computeViewMatrix(this._position,p,_),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=v.Zero(),s&&this.setTarget(s),this.alpha=t,this.beta=i,this.radius=r,this.getViewMatrix(),this.inputs=new du(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=_e.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){let t=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?t.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(t)}let e=this._getLockedTargetPosition();return e||this._target}storeState(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>Ye&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset,this.restoreStateInterpolationFactor),!0):super._restoreStateValues()?(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0):!1}stopInterpolation(){this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget.set(NaN,NaN,NaN),this._goalTargetScreenOffset.set(NaN,NaN)}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,r=this.target,s=this.targetScreenOffset,a){var o,l,c,f,d,h,u;this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,a!=null?this._currentInterpolationFactor=a:this.restoreStateInterpolationFactor!==0?this._currentInterpolationFactor=this.restoreStateInterpolationFactor:this._currentInterpolationFactor=.1,this._goalAlpha=Bi(e,this._goalAlpha),this._goalBeta=Bi(t,this._goalBeta),this._goalRadius=Bi(i,this._goalRadius),this._goalTarget.set(Bi(r.x,this._goalTarget.x),Bi(r.y,this._goalTarget.y),Bi(r.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(Bi(s.x,this._goalTargetScreenOffset.x),Bi(s.y,this._goalTargetScreenOffset.y)),this._goalAlpha=Ke(this._goalAlpha,(o=this.lowerAlphaLimit)!=null?o:-1/0,(l=this.upperAlphaLimit)!=null?l:1/0),this._goalBeta=Ke(this._goalBeta,(c=this.lowerBetaLimit)!=null?c:-1/0,(f=this.upperBetaLimit)!=null?f:1/0),this._goalRadius=Ke(this._goalRadius,(d=this.lowerRadiusLimit)!=null?d:-1/0,(h=this.upperRadiusLimit)!=null?h:1/0),this._goalTarget.y=Ke(this._goalTarget.y,(u=this.lowerTargetYLimit)!=null?u:-1/0,1/0),this._isInterpolating=!0}_isSynchronizedViewMatrix(){return super._isSynchronizedViewMatrix()?this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset):!1}attachControl(e,t,i=!0,r=2){let s=arguments;t=re.BackCompatCameraNoPreventDefault(s),this._useCtrlForPanning=i,this._panningMouseButton=r,typeof s[0]=="boolean"&&(s.length>1&&(this._useCtrlForPanning=s[1]),s.length>2&&(this._panningMouseButton=s[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(this._collisionTriggered)return;this.inputs.checkInputs();let e=!1;if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){e=!0;let t=this.invertRotation?-1:1,i=this._calculateHandednessMultiplier(),r=this.inertialAlphaOffset*i;this.beta<0&&(r*=-1),this.alpha+=r*t,this.beta+=this.inertialBetaOffset*t,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0),this.target.y=Math.max(this.target.y,this.lowerTargetYLimit)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&v.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);let e=this.alpha;this.alpha=Bk(this._computationVector),this.beta=Uk(this._computationVector.y,this.radius);let t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=t*2*Math.PI,this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,r=!1){var s;if(r=(s=this.overrideCloneAlphaBetaRadius)!=null?s:r,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{let a=e,o=this._getTargetPosition();if(o&&!i&&o.equals(a))return;this._targetHost=null,this._target=a,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}r||this.rebuildAnglesAndRadius()}_getViewMatrix(){let e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);r===0&&(r=1e-4),this.radius===0&&(this.radius=1e-4);let s=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&v.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),s.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){let a=this.getScene().collisionCoordinator;this._collider||(this._collider=a.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,a.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let a=this.upVector;this.allowUpsideDown&&r<0&&(a=a.negate()),this._computeViewMatrix(this._position,s,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget.copyFrom(s),this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;let i=V.MinMax(e),r=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);if(r=Math.max(Math.min(r,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=r*this.zoomOnFactor,this.mode===Ue.ORTHOGRAPHIC_CAMERA){let s=this.getScene().getEngine().getAspectRatio(this),a=r*this.zoomOnFactor/2;this.orthoLeft=-a*s,this.orthoRight=a*s,this.orthoBottom=-a,this.orthoTop=a}this.focusOn({min:i.min,max:i.max,distance:r},t)}focusOn(e,t=!1){let i,r;if(e.min===void 0){let s=e||this.getScene().meshes;i=V.MinMax(s),r=v.Distance(i.min,i.max)}else{let s=e;i=s,r=s.distance}this._target=V.Center(i),t||(this.maxZ=r*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case Ue.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ue.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ue.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ue.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ue.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case Ue.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}let r=new n(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r.isRigCamera=!0,r.rigParent=this,r.upVector=this.upVector,r.mode=this.mode,r.orthoLeft=this.orthoLeft,r.orthoRight=this.orthoRight,r.orthoBottom=this.orthoBottom,r.orthoTop=this.orthoTop,r}_updateRigCameras(){let e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case Ue.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ue.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ue.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ue.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ue.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ue.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){let r=v.Distance(e,t),a=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),l=o*a,f=r*.5*i,d=f*Math.sqrt(1+1/(l*l)),h=f*Math.sqrt(1+1/(o*o));return Math.max(d,h)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}};C([D()],ut.prototype,"alpha",void 0);C([D()],ut.prototype,"beta",void 0);C([D()],ut.prototype,"radius",void 0);C([D()],ut.prototype,"overrideCloneAlphaBetaRadius",void 0);C([ai("target")],ut.prototype,"_target",void 0);C([dh("targetHost")],ut.prototype,"_targetHost",void 0);C([D()],ut.prototype,"inertialAlphaOffset",void 0);C([D()],ut.prototype,"inertialBetaOffset",void 0);C([D()],ut.prototype,"inertialRadiusOffset",void 0);C([D()],ut.prototype,"lowerAlphaLimit",void 0);C([D()],ut.prototype,"upperAlphaLimit",void 0);C([D()],ut.prototype,"lowerBetaLimit",void 0);C([D()],ut.prototype,"upperBetaLimit",void 0);C([D()],ut.prototype,"lowerRadiusLimit",void 0);C([D()],ut.prototype,"upperRadiusLimit",void 0);C([D()],ut.prototype,"lowerTargetYLimit",void 0);C([D()],ut.prototype,"inertialPanningX",void 0);C([D()],ut.prototype,"inertialPanningY",void 0);C([D()],ut.prototype,"pinchToPanMaxDistance",void 0);C([D()],ut.prototype,"panningDistanceLimit",void 0);C([ai()],ut.prototype,"panningOriginTarget",void 0);C([D()],ut.prototype,"panningInertia",void 0);C([D()],ut.prototype,"zoomToMouseLocation",null);C([D()],ut.prototype,"zoomOnFactor",void 0);C([ul()],ut.prototype,"targetScreenOffset",void 0);C([D()],ut.prototype,"allowUpsideDown",void 0);C([D()],ut.prototype,"useInputToRestoreState",void 0);C([D()],ut.prototype,"restoreStateInterpolationFactor",void 0);je("BABYLON.ArcRotateCamera",ut)});var tt,Ma=A(()=>{Qe();qe();ve();et();Sr();ma();Lt();$c();Kt();tt=class n extends ht{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t,i){super(e,t,!1),this.diffuse=new oe(1,1,1),this.specular=new oe(1,1,1),this.falloffType=n.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=n.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._currentViewDepth=0,this._clusteredContainer=null,this._isLight=!0,i||this.getScene().addLight(this),this._uniformBuffer=new Ut(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],i||this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,i,r,s=!0){var l;let a=e.toString(),o=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+a),this._renderId!==t.getRenderId()||this._lastUseSpecular!==r||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=r;let c=this.getScaledIntensity();this.transferToEffect(i,a),this.diffuse.scaleToRef(c,Ii.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Ii.Color3[0],this.range,a),r&&(this.specular.scaleToRef(c,Ii.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Ii.Color3[1],this.radius,a)),o=!0}if(this.transferTexturesToEffect(i,a),t.shadowsEnabled&&this.shadowEnabled&&s){let c=(l=this.getShadowGenerator(t.activeCamera))!=null?l:this.getShadowGenerator();c&&(c.bindShadowLight(a,i),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric","Clustered"][this.getTypeID()],this.animations)for(let i=0;i0&&this.includedOnlyMeshes.indexOf(e)===-1||this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1||this.includeOnlyWithLayerMask!==0&&(this.includeOnlyWithLayerMask&e.layerMask)===0||this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&e.layerMask):!0}dispose(e,t=!1){if(this._shadowGenerators){let i=this._shadowGenerators.values();for(let r=i.next();r.done!==!0;r=i.next())r.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){let i=this._parentContainer.lights.indexOf(this);i>-1&&this._parentContainer.lights.splice(i,1),this._parentContainer=null}for(let 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){let i=n.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;let r=Me.Clone(i,this);return e&&(r.name=e),t&&(r.parent=t),r.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(r),r}serialize(){let e=Me.Serialize(this);if(e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0){e.excludedMeshesIds=[];for(let t of this.excludedMeshes)e.excludedMeshesIds.push(t.id)}if(this.includedOnlyMeshes.length>0){e.includedOnlyMeshesIds=[];for(let t of this.includedOnlyMeshes)e.includedOnlyMeshesIds.push(t.id)}return Me.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){let r=ht.Construct("Light_Type_"+e,t,i);return r||null}static Parse(e,t){let i=n.GetConstructorFromName(e.type,e.name,t);if(!i)return null;let r=Me.Parse(i,e,t);if(e.excludedMeshesIds&&(r._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(r._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),e.falloffType!==void 0&&(r.falloffType=e.falloffType),e.lightmapMode!==void 0&&(r.lightmapMode=e.lightmapMode),e.animations){for(let s=0;s{let s=t.apply(e,r);if(this._clusteredContainer)return s;for(let a of r)a._resyncLightSource(this);return s};let i=e.splice;if(e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);if(this._clusteredContainer)return a;for(let o of a)o._resyncLightSource(this);return a},!this._clusteredContainer)for(let r of e)r._resyncLightSource(this)}_hookArrayForIncludedOnly(e){let t=e.push;e.push=(...r)=>{let s=t.apply(e,r);return this._resyncMeshes(),s};let i=e.splice;e.splice=(r,s)=>{let a=i.call(e,r,s!=null?s:e.length);return this._resyncMeshes(),a},this._resyncMeshes()}_resyncMeshes(){if(!this._clusteredContainer)for(let e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(let e of this.getScene().meshes)e.lightSources.indexOf(this)!==-1&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0,t=this.getTypeID(),i=this.intensityMode;switch(i===n.INTENSITYMODE_AUTOMATIC&&(t===n.LIGHTTYPEID_DIRECTIONALLIGHT?i=n.INTENSITYMODE_ILLUMINANCE:i=n.INTENSITYMODE_LUMINOUSINTENSITY),t){case n.LIGHTTYPEID_POINTLIGHT:case n.LIGHTTYPEID_SPOTLIGHT:switch(i){case n.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case n.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case n.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case n.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case n.INTENSITYMODE_ILLUMINANCE:e=1;break;case n.INTENSITYMODE_LUMINANCE:{let r=this.radius;r=Math.max(r,.001),e=2*Math.PI*(1-Math.cos(r));break}}break;case n.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){let e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}areLightTexturesReady(){return!0}_isReady(){return!0}};tt.FALLOFF_DEFAULT=it.FALLOFF_DEFAULT;tt.FALLOFF_PHYSICAL=it.FALLOFF_PHYSICAL;tt.FALLOFF_GLTF=it.FALLOFF_GLTF;tt.FALLOFF_STANDARD=it.FALLOFF_STANDARD;tt.LIGHTMAP_DEFAULT=it.LIGHTMAP_DEFAULT;tt.LIGHTMAP_SPECULAR=it.LIGHTMAP_SPECULAR;tt.LIGHTMAP_SHADOWSONLY=it.LIGHTMAP_SHADOWSONLY;tt.INTENSITYMODE_AUTOMATIC=it.INTENSITYMODE_AUTOMATIC;tt.INTENSITYMODE_LUMINOUSPOWER=it.INTENSITYMODE_LUMINOUSPOWER;tt.INTENSITYMODE_LUMINOUSINTENSITY=it.INTENSITYMODE_LUMINOUSINTENSITY;tt.INTENSITYMODE_ILLUMINANCE=it.INTENSITYMODE_ILLUMINANCE;tt.INTENSITYMODE_LUMINANCE=it.INTENSITYMODE_LUMINANCE;tt.LIGHTTYPEID_POINTLIGHT=it.LIGHTTYPEID_POINTLIGHT;tt.LIGHTTYPEID_DIRECTIONALLIGHT=it.LIGHTTYPEID_DIRECTIONALLIGHT;tt.LIGHTTYPEID_SPOTLIGHT=it.LIGHTTYPEID_SPOTLIGHT;tt.LIGHTTYPEID_HEMISPHERICLIGHT=it.LIGHTTYPEID_HEMISPHERICLIGHT;tt.LIGHTTYPEID_RECT_AREALIGHT=it.LIGHTTYPEID_RECT_AREALIGHT;C([Ht()],tt.prototype,"diffuse",void 0);C([Ht()],tt.prototype,"specular",void 0);C([D()],tt.prototype,"falloffType",void 0);C([D()],tt.prototype,"intensity",void 0);C([D()],tt.prototype,"range",null);C([D()],tt.prototype,"intensityMode",null);C([D()],tt.prototype,"radius",null);C([D()],tt.prototype,"_renderPriority",void 0);C([ee("_reorderLightsInScene")],tt.prototype,"renderPriority",void 0);C([D("shadowEnabled")],tt.prototype,"_shadowEnabled",void 0);C([D("excludeWithLayerMask")],tt.prototype,"_excludeWithLayerMask",void 0);C([D("includeOnlyWithLayerMask")],tt.prototype,"_includeOnlyWithLayerMask",void 0);C([D("lightmapMode")],tt.prototype,"_lightmapMode",void 0)});var Rr,uu=A(()=>{Qe();qe();ve();et();Sr();Ma();Lt();ht.AddNodeConstructor("Light_Type_3",(n,e)=>()=>new Rr(n,v.Zero(),e));Rr=class extends tt{constructor(e,t,i,r){super(e,i,r),this.groundColor=new oe(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){let 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){let i=v.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=U.Identity()),this._worldMatrix}getTypeID(){return tt.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}};C([Ht()],Rr.prototype,"groundColor",void 0);C([ai()],Rr.prototype,"direction",void 0);je("BABYLON.HemisphericLight",Rr)});var Xr,mu=A(()=>{Qe();qe();ve();Ma();nl();Xr=class extends tt{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=U.Identity(),this._projectionMatrix=U.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();let e=v.Cross(this.direction,tr.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=U.Identity()),U.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==null?void 0:e.minZ)||0}getDepthMaxZ(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:(e==null?void 0:e.maxZ)||1e4}setShadowProjectionMatrix(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this}_syncParentEnabledState(){super._syncParentEnabledState(),(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){let t=G.Vector3[0],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);let r=G.Vector3[1];return i.addToRef(t,r),U.LookAtLHToRef(i,r,v.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e!=null?e:this._viewMatrix,t!=null?t:[]),this._projectionMatrix}};C([ai()],Xr.prototype,"position",null);C([ai()],Xr.prototype,"direction",null);C([D()],Xr.prototype,"shadowMinZ",null);C([D()],Xr.prototype,"shadowMaxZ",null)});var dr,VM=A(()=>{Qe();qe();ve();Sr();Ma();mu();Lt();ht.AddNodeConstructor("Light_Type_1",(n,e)=>()=>new dr(n,v.Zero(),e));dr=class extends Xr{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,i,r){super(e,i,r),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return tt.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)}_setDefaultFixedFrustumShadowProjectionMatrix(e){let t=this.getScene().activeCamera;U.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:t?t.minZ:0,this.shadowMaxZ!==void 0?this.shadowMaxZ:t?t.maxZ:1e4,e,this.getScene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,i){let r=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){let f=v.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let d=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let u=0;uthis._orthoRight&&(this._orthoRight=f.x),f.y>this._orthoTop&&(this._orthoTop=f.y),this.autoCalcShadowZBounds&&(f.zh&&(h=f.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=d,this._shadowMaxZ=h)}let s=this._orthoRight-this._orthoLeft,a=this._orthoTop-this._orthoBottom,o=this.shadowMinZ!==void 0?this.shadowMinZ:(r==null?void 0:r.minZ)||0,l=this.shadowMaxZ!==void 0?this.shadowMaxZ:(r==null?void 0:r.maxZ)||1e4,c=this.getScene().getEngine().useReverseDepthBuffer;U.OrthoOffCenterLHToRef(this._orthoLeft-s*this.shadowOrthoScale,this._orthoRight+s*this.shadowOrthoScale,this._orthoBottom-a*this.shadowOrthoScale,this._orthoTop+a*this.shadowOrthoScale,c?l:o,c?o:l,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){let t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){let t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}};C([D()],dr.prototype,"shadowFrustumSize",null);C([D()],dr.prototype,"shadowOrthoScale",null);C([D()],dr.prototype,"autoUpdateExtends",void 0);C([D()],dr.prototype,"autoCalcShadowZBounds",void 0);C([D("orthoLeft")],dr.prototype,"_orthoLeft",void 0);C([D("orthoRight")],dr.prototype,"_orthoRight",void 0);C([D("orthoTop")],dr.prototype,"_orthoTop",void 0);C([D("orthoBottom")],dr.prototype,"_orthoBottom",void 0);je("BABYLON.DirectionalLight",dr)});var ya,GM=A(()=>{Qe();qe();ve();Sr();Ma();mu();Lt();ht.AddNodeConstructor("Light_Type_0",(n,e)=>()=>new ya(n,v.Zero(),e));ya=class extends Xr{get shadowAngle(){return this._shadowAngle}set shadowAngle(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()}get direction(){return this._direction}set direction(e){let t=this.needCube();if(this._direction=e,this.needCube()!==t&&this._shadowGenerators){let i=this._shadowGenerators.values();for(let r=i.next();r.done!==!0;r=i.next())r.value.recreateShadowMap()}}constructor(e,t,i,r){super(e,i,r),this._shadowAngle=Math.PI/2,this.position=t}getClassName(){return"PointLight"}getTypeID(){return tt.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){let r=this.getScene().activeCamera,s=this.getDepthMinZ(r),a=this.getDepthMaxZ(r),o=this.getScene().getEngine().useReverseDepthBuffer;U.PerspectiveFovLHToRef(this.shadowAngle,1,o?a:s,o?s:a,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){let i=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x-i.x,this.transformedPosition.y-i.y,this.transformedPosition.z-i.z,0,t):this._uniformBuffer.updateFloat4("vLightData",this.position.x-i.x,this.position.y-i.y,this.position.z-i.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this}transferToNodeMaterialEffect(e,t){let i=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?e.setFloat3(t,this.transformedPosition.x-i.x,this.transformedPosition.y-i.y,this.transformedPosition.z-i.z):e.setFloat3(t,this.position.x-i.x,this.position.y-i.y,this.position.z-i.z),this}prepareLightSpecificDefines(e,t){e["POINTLIGHT"+t]=!0}};C([D()],ya.prototype,"shadowAngle",null);je("BABYLON.PointLight",ya)});var ni,AE=A(()=>{Qe();qe();ve();Sr();Ma();mu();oi();Lt();ht.AddNodeConstructor("Light_Type_2",(n,e)=>()=>new ni(n,v.Zero(),v.Zero(),0,0,e));ni=class n extends Xr{get iesProfileTexture(){return this._iesProfileTexture}set iesProfileTexture(e){this._iesProfileTexture!==e&&(this._iesProfileTexture=e,this._iesProfileTexture&&n._IsTexture(this._iesProfileTexture)&&this._iesProfileTexture.onLoadObservable.addOnce(()=>{this._markMeshesAsLightDirty()}))}get angle(){return this._angle}set angle(e){this._angle=e,this._cosHalfAngle=Math.cos(e*.5),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()}get innerAngle(){return this._innerAngle}set innerAngle(e){this._innerAngle=e,this._computeAngleValues()}get shadowAngleScale(){return this._shadowAngleScale}set shadowAngleScale(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()}get projectionTextureMatrix(){return this._projectionTextureMatrix}get projectionTextureLightNear(){return this._projectionTextureLightNear}set projectionTextureLightNear(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0}get projectionTextureLightFar(){return this._projectionTextureLightFar}set projectionTextureLightFar(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0}get projectionTextureUpDirection(){return this._projectionTextureUpDirection}set projectionTextureUpDirection(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0}get projectionTexture(){return this._projectionTexture}set projectionTexture(e){this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(n._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled(()=>{this._markMeshesAsLightDirty()}):n._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce(()=>{this._markMeshesAsLightDirty()})))}static _IsProceduralTexture(e){return e.onGeneratedObservable!==void 0}static _IsTexture(e){return e.onLoadObservable!==void 0}get projectionTextureProjectionLightMatrix(){return this._projectionTextureProjectionLightMatrix}set projectionTextureProjectionLightMatrix(e){this._projectionTextureProjectionLightMatrix=e,this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0}constructor(e,t,i,r,s,a,o){super(e,a,o),this._innerAngle=0,this._iesProfileTexture=null,this._projectionTextureMatrix=U.Zero(),this._projectionTextureLightNear=1e-6,this._projectionTextureLightFar=1e3,this._projectionTextureUpDirection=v.Up(),this._projectionTextureViewLightDirty=!0,this._projectionTextureProjectionLightDirty=!0,this._projectionTextureDirty=!0,this._projectionTextureViewTargetVector=v.Zero(),this._projectionTextureViewLightMatrix=U.Zero(),this._projectionTextureProjectionLightMatrix=U.Zero(),this._projectionTextureScalingMatrix=U.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),this.position=t,this.direction=i,this.angle=r,this.exponent=s}getClassName(){return"SpotLight"}getTypeID(){return tt.LIGHTTYPEID_SPOTLIGHT}_setDirection(e){super._setDirection(e),this._projectionTextureViewLightDirty=!0}_setPosition(e){super._setPosition(e),this._projectionTextureViewLightDirty=!0}_setDefaultShadowProjectionMatrix(e,t,i){let r=this.getScene().activeCamera;if(!r)return;this._shadowAngleScale=this._shadowAngleScale||1;let s=this._shadowAngleScale*this._angle,a=this.shadowMinZ!==void 0?this.shadowMinZ:r.minZ,o=this.shadowMaxZ!==void 0?this.shadowMaxZ:r.maxZ,l=this.getScene().getEngine().useReverseDepthBuffer;U.PerspectiveFovLHToRef(s,1,l?o:a,l?a:o,e,!0,this._scene.getEngine().isNDCHalfZRange,void 0,l)}_computeProjectionTextureViewLightMatrix(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.getAbsolutePosition().addToRef(this.getShadowDirection(),this._projectionTextureViewTargetVector),U.LookAtLHToRef(this.getAbsolutePosition(),this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)}_computeProjectionTextureProjectionLightMatrix(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;let e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),r=-i*t,s=1/Math.tan(this._angle/2);U.FromValuesToRef(s/1,0,0,0,0,s,0,0,0,0,i,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)}_computeProjectionTextureMatrix(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof ne){let e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;U.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}_computeAngleValues(){this._lightAngleScale=1/Math.max(.001,Math.cos(this._innerAngle*.5)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale}transferTexturesToEffect(e,t){return this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightTexture"+t,this.projectionTexture)),this._iesProfileTexture&&this._iesProfileTexture.isReady()&&e.setTexture("iesLightTexture"+t,this._iesProfileTexture),this}transferToEffect(e,t){let i,r=this._scene.floatingOriginOffset;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x-r.x,this.transformedPosition.y-r.y,this.transformedPosition.z-r.z,this.exponent,t),i=v.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x-r.x,this.position.y-r.y,this.position.z-r.z,this.exponent,t),i=v.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this}transferToNodeMaterialEffect(e,t){let i;return this.computeTransformedInformation()?i=v.Normalize(this.transformedDirection):i=v.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.z),this}dispose(){super.dispose(),this._projectionTexture&&this._projectionTexture.dispose(),this._iesProfileTexture&&(this._iesProfileTexture.dispose(),this._iesProfileTexture=null)}getDepthMinZ(e){var r;let t=this._scene.getEngine(),i=this.shadowMinZ!==void 0?this.shadowMinZ:(r=e==null?void 0:e.minZ)!=null?r:0;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?i:this._scene.getEngine().isNDCHalfZRange?0:i}getDepthMaxZ(e){var r;let t=this._scene.getEngine(),i=this.shadowMaxZ!==void 0?this.shadowMaxZ:(r=e==null?void 0:e.maxZ)!=null?r:1e4;return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:i}areLightTexturesReady(){return!(this._projectionTexture&&!this._projectionTexture.isReadyOrNotBlocking()||this._iesProfileTexture&&!this._iesProfileTexture.isReadyOrNotBlocking())}prepareLightSpecificDefines(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!!(this.projectionTexture&&this.projectionTexture.isReady()),e["IESLIGHTTEXTURE"+t]=!!(this._iesProfileTexture&&this._iesProfileTexture.isReady())}};C([D()],ni.prototype,"angle",null);C([D()],ni.prototype,"innerAngle",null);C([D()],ni.prototype,"shadowAngleScale",null);C([D()],ni.prototype,"exponent",void 0);C([D()],ni.prototype,"projectionTextureLightNear",null);C([D()],ni.prototype,"projectionTextureLightFar",null);C([D()],ni.prototype,"projectionTextureUpDirection",null);C([Ze("projectedLightTexture")],ni.prototype,"_projectionTexture",void 0);je("BABYLON.SpotLight",ni)});function kM(n){let e=n.pathArray,t=n.closeArray||!1,i=n.closePath||!1,r=n.invertUV||!1,s=Math.floor(e[0].length/2),a=n.offset||s;a=a>s?s:Math.floor(a);let o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=n.uvs,c=n.colors,f=[],d=[],h=[],u=[],m=[],p=[],_=[],g=[],T,b=[],R=[],S,I,x;if(e.length<2){let he=[],ke=[];for(I=0;I0&&(H=B[x].subtract(B[x-1]).length(),O=H+_[S],m[S].push(O),_[S]=O),x++;i&&(x--,f.push(B[0].x,B[0].y,B[0].z),H=B[x].subtract(B[0]).length(),O=H+_[S],m[S].push(O),_[S]=O),b[S]=w+L,R[S]=P,P+=w+L}let k,X,j,Q;for(I=0;I{let m=i[0].length,p=o,_=0,g=p._originalBuilderSideOrientation===V.DOUBLESIDE?2:1;for(let T=1;T<=g;++T)for(let b=0;b{ve();Rt();yt();Vt();ui();de.CreateRibbon=kM;V.CreateRibbon=(n,e,t=!1,i,r,s,a=!1,o,l)=>vn(n,{pathArray:e,closeArray:t,closePath:i,offset:r,updatable:a,sideOrientation:o,instance:l},s)});function WM(n){let e=[],t=[],i=[],r=[],s=n.radius||.5,a=n.tessellation||64,o=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,l=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE;e.push(0,0,0),r.push(.5,.5);let c=Math.PI*2*o,f=o===1?c/a:c/(a-1),d=0;for(let m=0;m{Rt();Vt();ui();de.CreateDisc=WM;V.CreateDisc=(n,e,t,i=null,r,s)=>RE(n,{radius:e,tessellation:t,sideOrientation:s,updatable:r},i)});var $l,zM=A(()=>{ve();yt();Rt();V._GroundMeshParser=(n,e)=>$l.Parse(n,e);$l=class n extends V{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);let i=this;i.createOrUpdateSubmeshesOctree&&i.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){let i=this.getWorldMatrix(),r=G.Matrix[5];i.invertToRef(r);let s=G.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,r,s),e=s.x,t=s.z,e=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());let a=this._getFacetAt(e,t),o=-(a.x*e+a.z*t+a.w)/a.y;return v.TransformCoordinatesFromFloatsToRef(0,o,0,i,s),s.y}getNormalAtCoordinates(e,t){let i=new v(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){let r=this.getWorldMatrix(),s=G.Matrix[5];r.invertToRef(s);let a=G.Vector3[8];if(v.TransformCoordinatesFromFloatsToRef(e,0,t,s,a),e=a.x,t=a.z,ethis._maxX||tthis._maxZ)return this;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());let o=this._getFacetAt(e,t);return v.TransformNormalFromFloatsToRef(o.x,o.y,o.z,r,i),this}updateCoordinateHeights(){return(!this._heightQuads||this._heightQuads.length==0)&&this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){let i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),s=this._heightQuads[r*this._subdivisionsX+i],a;return tn.maxHeight){c=!0;let d=n.maxHeight;n.maxHeight=n.minHeight,n.minHeight=d}for(s=0;s<=n.subdivisions;s++)for(a=0;a<=n.subdivisions;a++){let d=new v(a*n.width/n.subdivisions-n.width/2,0,(n.subdivisions-s)*n.height/n.subdivisions-n.height/2),h=(d.x+n.width/2)/n.width*(n.bufferWidth-1)|0,u=(1-(d.z+n.height/2)/n.height)*(n.bufferHeight-1)|0,m=(h+u*n.bufferWidth)*4,p=n.buffer[m]/255,_=n.buffer[m+1]/255,g=n.buffer[m+2]/255,T=n.buffer[m+3]/255;c&&(p=1-p,_=1-_,g=1-g);let b=p*o.r+_*o.g+g*o.b;T>=l?d.y=n.minHeight+(n.maxHeight-n.minHeight)*b:d.y=n.minHeight-Ye,n.heightBuffer&&(n.heightBuffer[s*(n.subdivisions+1)+a]=d.y),t.push(d.x,d.y,d.z),i.push(0,0,0),r.push(a/n.subdivisions,1-s/n.subdivisions)}for(s=0;s=n.minHeight,_=t[h*3+1]>=n.minHeight,g=t[u*3+1]>=n.minHeight;p&&_&&g&&(e.push(d),e.push(h),e.push(u)),t[m*3+1]>=n.minHeight&&p&&g&&(e.push(m),e.push(d),e.push(u))}de.ComputeNormals(t,e,i);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function xE(n,e={},t){let i=new $l(n,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,IE(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function CE(n,e,t=null){let i=new V(n,t);return XM(e).applyToMesh(i,e.updatable),i}function bE(n,e,t={},i=null){let r=t.width||10,s=t.height||10,a=t.subdivisions||1,o=t.minHeight||0,l=t.maxHeight||1,c=t.colorFilter||new oe(.3,.59,.11),f=t.alphaFilter||0,d=t.updatable,h=t.onReady;i=i||ue.LastCreatedScene;let u=new $l(n,i);u._subdivisionsX=a,u._subdivisionsY=a,u._width=r,u._height=s,u._maxX=u._width/2,u._maxZ=u._height/2,u._minX=-u._maxX,u._minZ=-u._maxZ,u._setReady(!1);let m;t.passHeightBufferInCallback&&(m=new Float32Array((a+1)*(a+1)));let p=(_,g,T)=>{YM({width:r,height:s,subdivisions:a,minHeight:o,maxHeight:l,colorFilter:c,buffer:_,bufferWidth:g,bufferHeight:T,alphaFilter:f,heightBuffer:m}).applyToMesh(u,d),h&&h(u,m),u._setReady(!0)};if(typeof e=="string"){i.addPendingData(u);let _=T=>{let b=T.width,R=T.height;if(i.isDisposed){i.removePendingData(u);return}let S=i==null?void 0:i.getEngine().resizeImageBitmap(T,b,R);p(S,b,R),i.removePendingData(u)},g=(T,b)=>{i.removePendingData(u),t.onError&&t.onError(T,b)};re.LoadImage(e,_,g,i.offlineProvider)}else p(e.data,e.width,e.height);return u}var ME=A(()=>{ve();et();Rt();Vt();zM();Tt();At();bi();ui();de.CreateGround=IE;de.CreateTiledGround=XM;de.CreateGroundFromHeightMap=YM;V.CreateGround=(n,e,t,i,r,s)=>xE(n,{width:e,height:t,subdivisions:i,updatable:s},r);V.CreateTiledGround=(n,e,t,i,r,s,a,o,l)=>CE(n,{xmin:e,zmin:t,xmax:i,zmax:r,subdivisions:s,precision:a,updatable:l},o);V.CreateGroundFromHeightMap=(n,e,t,i,r,s,a,o,l,c,f)=>bE(n,e,{width:t,height:i,subdivisions:r,minHeight:s,maxHeight:a,updatable:l,onReady:c,alphaFilter:f},o)});function pu(n){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],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],r=[],s=n.width||n.size||1,a=n.height||n.size||1,o=n.depth||n.size||1,l=n.wrap||!1,c=n.topBaseAt===void 0?1:n.topBaseAt,f=n.bottomBaseAt===void 0?0:n.bottomBaseAt;c=(c+4)%4,f=(f+4)%4;let d=[2,0,3,1],h=[2,0,1,3],u=d[c],m=h[f],p=[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],p=[-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 x=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],P=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],L=[17,18,19,16],y=[22,23,20,21];for(;u>0;)x.unshift(x.pop()),L.unshift(L.pop()),u--;for(;m>0;)P.unshift(P.pop()),y.unshift(y.pop()),m--;x=x.flat(),P=P.flat(),p=p.concat(x).concat(P),t.push(L[0],L[2],L[3],L[0],L[1],L[2]),t.push(y[0],y[2],y[3],y[0],y[1],y[2])}let _=[s/2,a/2,o/2],g=p.reduce((x,P,L)=>x.concat(P*_[L%3]),[]),T=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,b=n.faceUV||new Array(6),R=n.faceColors,S=[];for(let x=0;x<6;x++)b[x]===void 0&&(b[x]=new vt(0,0,1,1)),R&&R[x]===void 0&&(R[x]=new Ne(1,1,1,1));for(let x=0;x<6;x++)if(r.push(b[x].z,He?1-b[x].w:b[x].w),r.push(b[x].x,He?1-b[x].w:b[x].w),r.push(b[x].x,He?1-b[x].y:b[x].y),r.push(b[x].z,He?1-b[x].y:b[x].y),R)for(let P=0;P<4;P++)S.push(R[x].r,R[x].g,R[x].b,R[x].a);de._ComputeSides(T,g,t,i,r,n.frontUVs,n.backUVs);let I=new de;if(I.indices=t,I.positions=g,I.normals=i,I.uvs=r,R){let x=T===de.DOUBLESIDE?S.concat(S):S;I.colors=x}return I}function yE(n,e={},t=null){let i=new V(n,t);return e.sideOrientation=V._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,pu(e).applyToMesh(i,e.updatable),i}var DE=A(()=>{ve();et();Rt();Vt();ui();ME();de.CreateBox=pu;V.CreateBox=(n,e,t=null,i,r)=>yE(n,{size:e,sideOrientation:r,updatable:i},t)});function ec(n){let e=n.pattern||V.NO_FLIP,t=n.tileWidth||n.tileSize||1,i=n.tileHeight||n.tileSize||1,r=n.alignHorizontal||0,s=n.alignVertical||0,a=n.width||n.size||1,o=Math.floor(a/t),l=a-o*t,c=n.height||n.size||1,f=Math.floor(c/i),d=c-f*i,h=t*o/2,u=i*f/2,m=0,p=0,_=0,g=0,T=0,b=0;if(l>0||d>0){switch(_=-h,g=-u,T=h,b=u,r){case V.CENTER:l/=2,_-=l,T+=l;break;case V.LEFT:T+=l,m=-l/2;break;case V.RIGHT:_-=l,m=l/2;break}switch(s){case V.CENTER:d/=2,g-=d,b+=d;break;case V.BOTTOM:b+=d,p=-d/2;break;case V.TOP:g-=d,p=d/2;break}}let R=[],S=[],I=[];I[0]=[0,0,1,0,1,1,0,1],I[1]=[0,0,1,0,1,1,0,1],(e===V.ROTATE_TILE||e===V.ROTATE_ROW)&&(I[1]=[1,1,0,1,0,0,1,0]),(e===V.FLIP_TILE||e===V.FLIP_ROW)&&(I[1]=[1,0,0,0,0,1,1,1]),(e===V.FLIP_N_ROTATE_TILE||e===V.FLIP_N_ROTATE_ROW)&&(I[1]=[0,1,1,1,1,0,0,0]);let x=[],P=[],L=[],y=0;for(let O=0;O0||d>0){let O=d>0&&(s===V.CENTER||s===V.TOP),k=d>0&&(s===V.CENTER||s===V.BOTTOM),X=l>0&&(r===V.CENTER||r===V.RIGHT),j=l>0&&(r===V.CENTER||r===V.LEFT),Q,$,q,z,K;if(O&&X&&(R.push(_+m,g+p,0),R.push(-h+m,g+p,0),R.push(-h+m,g+d+p,0),R.push(_+m,g+d+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=1-l/t,q=1-d/i,z=1,K=1,Q=[$,q,z,q,z,K,$,K],e===V.ROTATE_ROW&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),e===V.FLIP_ROW&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),e===V.FLIP_N_ROTATE_ROW&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O&&j&&(R.push(h+m,g+p,0),R.push(T+m,g+p,0),R.push(T+m,g+d+p,0),R.push(h+m,g+d+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=0,q=1-d/i,z=l/t,K=1,Q=[$,q,z,q,z,K,$,K],(e===V.ROTATE_ROW||e===V.ROTATE_TILE&&o%2===0)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===V.FLIP_ROW||e===V.FLIP_TILE&&o%2===0)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===V.FLIP_N_ROTATE_ROW||e===V.FLIP_N_ROTATE_TILE&&o%2===0)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k&&X&&(R.push(_+m,u+p,0),R.push(-h+m,u+p,0),R.push(-h+m,b+p,0),R.push(_+m,b+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=1-l/t,q=0,z=1,K=d/i,Q=[$,q,z,q,z,K,$,K],(e===V.ROTATE_ROW&&f%2===1||e===V.ROTATE_TILE&&f%1===0)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===V.FLIP_ROW&&f%2===1||e===V.FLIP_TILE&&f%2===0)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===V.FLIP_N_ROTATE_ROW&&f%2===1||e===V.FLIP_N_ROTATE_TILE&&f%2===0)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),k&&j&&(R.push(h+m,u+p,0),R.push(T+m,u+p,0),R.push(T+m,b+p,0),R.push(h+m,b+p,0),L.push(y,y+1,y+3,y+1,y+2,y+3),y+=4,$=0,q=0,z=l/t,K=d/i,Q=[$,q,z,q,z,K,$,K],(e===V.ROTATE_ROW&&f%2===1||e===V.ROTATE_TILE&&(f+o)%2===1)&&(Q=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===V.FLIP_ROW&&f%2===1||e===V.FLIP_TILE&&(f+o)%2===1)&&(Q=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===V.FLIP_N_ROTATE_ROW&&f%2===1||e===V.FLIP_N_ROTATE_TILE&&(f+o)%2===1)&&(Q=[$,1-q,z,1-q,z,1-K,$,1-K]),x=x.concat(Q),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),S.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O){let J=[];$=0,q=1-d/i,z=1,K=1,J[0]=[$,q,z,q,z,K,$,K],J[1]=[$,q,z,q,z,K,$,K],(e===V.ROTATE_TILE||e===V.ROTATE_ROW)&&(J[1]=[1-$,1-q,1-z,1-q,1-z,1-K,1-$,1-K]),(e===V.FLIP_TILE||e===V.FLIP_ROW)&&(J[1]=[1-$,q,1-z,q,1-z,K,1-$,K]),(e===V.FLIP_N_ROTATE_TILE||e===V.FLIP_N_ROTATE_ROW)&&(J[1]=[$,1-q,z,1-q,z,1-K,$,1-K]);for(let te=0;te{Rt();Vt();de.CreateTiledPlane=ec});function jM(n){let t=n.faceUV||new Array(6),i=n.faceColors,r=n.pattern||V.NO_FLIP,s=n.width||n.size||1,a=n.height||n.size||1,o=n.depth||n.size||1,l=n.tileWidth||n.tileSize||1,c=n.tileHeight||n.tileSize||1,f=n.alignHorizontal||0,d=n.alignVertical||0,h=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE;for(let O=0;O<6;O++)t[O]===void 0&&(t[O]=new vt(0,0,1,1)),i&&i[O]===void 0&&(i[O]=new Ne(1,1,1,1));let u=s/2,m=a/2,p=o/2,_=[];for(let O=0;O<2;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:s,height:a,alignVertical:d,alignHorizontal:f,sideOrientation:h});for(let O=2;O<4;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:o,height:a,alignVertical:d,alignHorizontal:f,sideOrientation:h});let g=d;d===V.BOTTOM?g=V.TOP:d===V.TOP&&(g=V.BOTTOM);for(let O=4;O<6;O++)_[O]=ec({pattern:r,tileWidth:l,tileHeight:c,width:s,height:o,alignVertical:g,alignHorizontal:f,sideOrientation:h});let T=[],b=[],R=[],S=[],I=[],x=[],P=[],L=[],y,B=0;for(let O=0;O<6;O++){let k=_[O].positions.length;x[O]=[],P[O]=[];for(let X=0;XX+B)),B+=x[O].length,i){let X=i[O];for(let j=0;j{ve();et();Rt();Vt();LE();ui();_u=1,PE=-1;de.CreateTiledBox=jM});function QM(n){let e=(n.segments||32)|0,t=n.diameterX||n.diameter||1,i=n.diameterY||n.diameter||1,r=n.diameterZ||n.diameter||1,s=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,a=n.slice&&n.slice<=0?1:n.slice||1,o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=!!n.dedupTopBottomIndices,c=new v(t/2,i/2,r/2),f=2+e,d=2*f,h=[],u=[],m=[],p=[];for(let g=0;g<=f;g++){let T=g/f,b=T*Math.PI*a;for(let R=0;R<=d;R++){let S=R/d,I=S*Math.PI*2*s,x=U.RotationZ(-b),P=U.RotationY(I),L=v.TransformCoordinates(v.Up(),x),y=v.TransformCoordinates(L,P),B=y.multiply(c),w=y.divide(c).normalize();u.push(B.x,B.y,B.z),m.push(w.x,w.y,w.z),p.push(S,He?1-T:T)}if(g>0){let R=u.length/3;for(let S=R-2*(d+1);S+d+21&&(h.push(S),h.push(S+1),h.push(S+d+1)),(g{ve();Rt();Vt();ui();de.CreateSphere=QM;V.CreateSphere=(n,e,t,i,r,s)=>OE(n,{segments:e,diameterX:t,diameterY:t,diameterZ:t,sideOrientation:s,updatable:r},i)});function $M(n){let e=n.height||2,t=n.diameterTop===0?0:n.diameterTop||n.diameter||1,i=n.diameterBottom===0?0:n.diameterBottom||n.diameter||1;t=t||1e-5,i=i||1e-5;let r=(n.tessellation||24)|0,s=(n.subdivisions||1)|0,a=!!n.hasRings,o=!!n.enclose,l=n.cap===0?0:n.cap||V.CAP_ALL,c=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,f=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,d=n.faceUV||new Array(3),h=n.faceColors,u=c!==1&&o?2:0,m=a?s:1,p=2+(1+u)*m,_;for(_=0;_{let se=me?t/2:i/2;if(se===0)return;let le,xe,ce,he=me?d[p-1]:d[0],ke=null;h&&(ke=me?h[p-1]:h[0]);let $e=T.length/3,Fe=me?e/2:-e/2,Xe=new v(0,Fe,0);T.push(Xe.x,Xe.y,Xe.z),b.push(0,me?1:-1,0);let xt=he.y+(he.w-he.y)*.5;R.push(he.x+(he.z-he.x)*.5,He?1-xt:xt),ke&&S.push(ke.r,ke.g,ke.b,ke.a);let Dt=new _e(.5,.5);for(ce=0;ce<=r;ce++){le=Math.PI*2*ce*c/r;let Yt=Math.cos(-le),hi=Math.sin(-le);xe=new v(Yt*se,Fe,hi*se);let Er=new _e(Yt*Dt.x+.5,hi*Dt.y+.5);T.push(xe.x,xe.y,xe.z),b.push(0,me?1:-1,0);let Cd=he.y+(he.w-he.y)*Er.y;R.push(he.x+(he.z-he.x)*Er.x,He?1-Cd:Cd),ke&&S.push(ke.r,ke.g,ke.b,ke.a)}for(ce=0;ce{ve();et();Rt();Vt();sr();nl();ui();de.CreateCylinder=$M;V.CreateCylinder=(n,e,t,i,r,s,a,o,l)=>((a===void 0||!(a instanceof st))&&(a!==void 0&&(l=o||V.DEFAULTSIDE,o=a),a=s,s=1),NE(n,{height:e,diameterTop:t,diameterBottom:i,tessellation:r,subdivisions:s,sideOrientation:l,updatable:o},a))});function t0(n){let e=[],t=[],i=[],r=[],s=n.diameter||1,a=n.thickness||.5,o=(n.tessellation||16)|0,l=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,c=o+1;for(let d=0;d<=o;d++){let h=d/o,u=d*Math.PI*2/o-Math.PI/2,m=U.Translation(s/2,0,0).multiply(U.RotationY(u));for(let p=0;p<=o;p++){let _=1-p/o,g=p*Math.PI*2/o+Math.PI,T=Math.cos(g),b=Math.sin(g),R=new v(T,b,0),S=R.scale(a/2),I=new _e(h,_);S=v.TransformCoordinates(S,m),R=v.TransformNormal(R,m),t.push(S.x,S.y,S.z),i.push(R.x,R.y,R.z),r.push(I.x,He?1-I.y:I.y);let x=(d+1)%c,P=(p+1)%c;e.push(d*c+p),e.push(d*c+P),e.push(x*c+p),e.push(d*c+P),e.push(x*c+P),e.push(x*c+p)}}de._ComputeSides(l,t,e,i,r,n.frontUVs,n.backUVs);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function FE(n,e={},t){let i=new V(n,t);return e.sideOrientation=V._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,t0(e).applyToMesh(i,e.updatable),i}var i0=A(()=>{ve();Rt();Vt();ui();de.CreateTorus=t0;V.CreateTorus=(n,e,t,i,r,s,a)=>FE(n,{diameter:e,thickness:t,tessellation:i,sideOrientation:a,updatable:s},r)});function r0(n){let e=[],t=[],i=[],r=[],s=n.radius||2,a=n.tube||.5,o=n.radialSegments||32,l=n.tubularSegments||32,c=n.p||2,f=n.q||3,d=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,h=_=>{let g=Math.cos(_),T=Math.sin(_),b=f/c*_,R=Math.cos(b),S=s*(2+R)*.5*g,I=s*(2+R)*T*.5,x=s*Math.sin(b)*.5;return new v(S,I,x)},u,m;for(u=0;u<=o;u++){let g=u%o/o*2*c*Math.PI,T=h(g),b=h(g+.01),R=b.subtract(T),S=b.add(T),I=v.Cross(R,S);for(S=v.Cross(I,R),I.normalize(),S.normalize(),m=0;m{ve();Rt();Vt();ui();de.CreateTorusKnot=r0;V.CreateTorusKnot=(n,e,t,i,r,s,a,o,l,c)=>wE(n,{radius:e,tube:t,radialSegments:i,tubularSegments:r,p:s,q:a,sideOrientation:c,updatable:l},o)});var xs,BE=A(()=>{ve();ze();Dl();Rt();Qc();yl();yt();Tt();Lt();V._instancedMeshFactory=(n,e)=>{let t=new xs(n,e);if(e.instancedBuffers){t.instancedBuffers={};for(let i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t};xs=class extends zt{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(let i of t.getAnimationRanges())i!=null&&this.createAnimationRange(i.name,i.from,i.to);if(this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),!t.skeleton&&!t.morphTargetManager&&t.hasBoundingInfo){let i=t.getBoundingInfo();this.buildBoundingInfo(i.minimum,i.maximum)}else 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&&re.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&&re.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&&re.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&&re.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||W.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}get geometry(){return this._sourceMesh._geometry}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)}getVertexBuffer(e,t){return this._sourceMesh.getVertexBuffer(e,t)}setVerticesData(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh}updateVerticesData(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),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};let r=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,M.PositionKind),r),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||W.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!==this._sourceMesh&&this._currentLOD.billboardMode!==at.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new U);let e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,G.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(G.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;let t=this.sourceMesh.getLODLevels();if(!t||t.length===0)this._currentLOD=this.sourceMesh;else{let 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{Ui=class{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,ethis._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;let i=this._mesh.getScene();for(let r=0;r0&&(s.computeBonesUsingShaders=!1);continue}if(!(!s.computeBonesUsingShaders||s.numBoneInfluencers===0)){if(s.material.getEffect()===t)s.computeBonesUsingShaders=!1;else if(s.subMeshes){for(let a of s.subMeshes)if(a.effect===t){s.computeBonesUsingShaders=!1;break}}}}}else{let i=this._defines[this._currentRank];if(i)for(let r=0;r{ve();Fi();Yn=class extends ae{constructor(e,t,i=!0,r=!1){super(e,t,void 0,r),this._normalMatrix=new U,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){let 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,r=1){return i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,r)}dispose(e,t,i){this._activeEffect=void 0,super.dispose(e,t,i)}}});function La(n){let e=n.getVertexBuffers();if(!e)return null;let t=s0.get(n);if(!t)t=new Map,s0.set(n,t);else{let i=!1;for(let r in e)if(!t.has(r)){i=!0;break}if(!i)return t}for(let i in e){let r=e[i];if(r){let s=r.byteOffset,a=r.byteStride,o=r.type,l=r.normalized;t.set(i,{offset:s,stride:a,type:o,normalized:l})}}return t}function Pa(n,e){e.forEach((t,i)=>{let r=`vp_${i}_info`;n.setFloat4(r,t.offset,t.stride,t.type,t.normalized?1:0)})}var s0,Cf=A(()=>{s0=new WeakMap});var UE,Tn,VE=A(()=>{Kt();sr();ve();yt();oi();Lt();Da();mo();xf();At();Wn();Ni();Cf();UE={effect:null,subMesh:null},Tn=class n extends Yn{constructor(e,t,i,r={},s=!0){super(e,t,s),this._textures={},this._internalTextures={},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 U,this._cachedWorldViewProjectionMatrix=new U,this._multiview=!1,this._vertexPullingMetadata=null,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,...r}}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}setInternalTexture(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._internalTextures[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,r)=>(i.push(r.r,r.g,r.b),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,r)=>(i.push(r.r,r.g,r.b,r.a),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,r)=>(r.toArray(i,i.length),i),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);let i=new Float32Array(t.length*16);for(let r=0;rs===e||s.startsWith(i));return r>=0&&this.options.defines.splice(r,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 I,x,P,L;let r=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){let y=r?i._drawWrapper:this._drawWrapper;if(y.effect&&y._wasPreviouslyReady&&y._wasPreviouslyUsingInstances===t)return!0}let s=this.getScene(),a=s.getEngine(),o=[],l=[],c=null,f=this._shaderPath,d=this._options.uniforms,h=this._options.uniformBuffers,u=this._options.samplers;a.getCaps().multiview&&s.activeCamera&&s.activeCamera.outputRenderTarget&&s.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,o.push("#define MULTIVIEW"),d.indexOf("viewProjection")!==-1&&d.indexOf("viewProjectionR")===-1&&d.push("viewProjectionR"));for(let y=0;y4&&(l.push(M.MatricesIndicesExtraKind),l.push(M.MatricesWeightsExtraKind));let y=e.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),c=new Ui,c.addCPUSkinningFallback(0,e),y.isUsingTextureForMatrices?(o.push("#define BONETEXTURE"),d.indexOf("boneTextureInfo")===-1&&d.push("boneTextureInfo"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(o.push("#define BonesPerMesh "+(y.bones.length+1)),d.indexOf("mBones")===-1&&d.push("mBones"))}else o.push("#define NUM_BONE_INFLUENCERS 0");let m=0,p=e?e.morphTargetManager:null;if(p){let y=o.indexOf("#define UV1")!==-1,B=o.indexOf("#define UV2")!==-1,w=o.indexOf("#define TANGENT")!==-1,H=o.indexOf("#define NORMAL")!==-1,O=o.indexOf("#define VERTEXCOLOR")!==-1;m=Hn(p,o,l,e,!0,H,w,y,B,O),p.isUsingTextureForTargets&&(d.indexOf("morphTargetTextureIndices")===-1&&d.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),m>0&&(d=d.slice(),d.push("morphTargetInfluences"),d.push("morphTargetCount"),d.push("morphTargetTextureInfo"),d.push("morphTargetTextureIndices"))}else o.push("#define NUM_MORPH_INFLUENCERS 0");if(e){let y=e.bakedVertexAnimationManager;y&&y.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),d.indexOf("bakedVertexAnimationSettings")===-1&&d.push("bakedVertexAnimationSettings"),d.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&d.push("bakedVertexAnimationTextureSizeInverted"),d.indexOf("bakedVertexAnimationTime")===-1&&d.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture"),t&&l.push("bakedVertexAnimationSettingsInstanced"))}for(let y in this._textures)if(!this._textures[y].isReady())return!1;for(let y in this._internalTextures)if(!this._internalTextures[y].isReady)return!1;e&&this.needAlphaTestingForMesh(e)&&o.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&(Li(d),kn(this,s,o)),s.fogEnabled&&(e!=null&&e.applyFog)&&s.fogMode!==st.FOGMODE_NONE&&(o.push("#define FOG"),d.indexOf("view")===-1&&d.push("view"),d.indexOf("vFogInfos")===-1&&d.push("vFogInfos"),d.indexOf("vFogColor")===-1&&d.push("vFogColor")),this._useLogarithmicDepth&&(o.push("#define LOGARITHMICDEPTH"),d.indexOf("logarithmicDepthConstant")===-1&&d.push("logarithmicDepthConstant"));let _=i?i.getRenderingMesh():e;if(_&&this.useVertexPulling){let y=_.geometry;y&&(this._vertexPullingMetadata=La(y),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((w,H)=>{d.push(`vp_${H}_info`)})),o.push("#define USE_VERTEX_PULLING");let B=(I=_.geometry)==null?void 0:I.getIndexBuffer();B&&!_.isUnIndexed&&(o.push("#define VERTEX_PULLING_USE_INDEX_BUFFER"),B.is32Bits&&o.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS"))}this.customShaderNameResolve&&(d=d.slice(),h=h.slice(),u=u.slice(),f=this.customShaderNameResolve(this.name,d,h,u,o,l));let g=r?i._getDrawWrapper(void 0,!0):this._drawWrapper,T=(x=g==null?void 0:g.effect)!=null?x:null,b=(P=g==null?void 0:g.defines)!=null?P:null,R=o.join(` +`),S=T;return b!==R&&(S=a.createEffect(f,{attributes:l,uniformsNames:d,uniformBuffersNames:h,samplers:u,defines:R,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:m},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},a),r?i.setEffect(S,R,this._materialContext):g&&g.setEffect(S,R),this._onEffectCreatedObservable&&(UE.effect=S,UE.subMesh=(L=i!=null?i:e==null?void 0:e.subMeshes[0])!=null?L:null,this._onEffectCreatedObservable.notifyObservers(UE))),g._wasPreviouslyUsingInstances=!!t,S!=null&&S.isReady()?(T!==S&&s.resetCachedMaterial(),g._wasPreviouslyReady=!0,!0):!1}bindOnlyWorldMatrix(e,t){let i=t!=null?t:this.getEffect();if(!i)return;let r=this._options.uniforms;r.indexOf("world")!==-1&&i.setMatrix("world",e);let s=this.getScene();r.indexOf("worldView")!==-1&&(e.multiplyToRef(s.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),r.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(s.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),r.indexOf("view")!==-1&&i.setMatrix("view",s.getViewMatrix())}bindForSubMesh(e,t,i){var r;this.bind(e,t,(r=i._drawWrapperOverride)==null?void 0:r.effect,i)}bind(e,t,i,r){var d;let s=r&&this._storeEffectOnSubMeshes,a=i!=null?i:s?r.effect:this.getEffect();if(!a)return;let o=this.getScene();this._activeEffect=a,this.bindOnlyWorldMatrix(e,i);let l=this._options.uniformBuffers,c=!1;if(a&&l&&l.length>0&&o.getEngine().supportsUniformBuffers)for(let h=0;hnew n(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};let i=Object.keys(this._options);for(let r of i){let s=this._options[r];Array.isArray(s)&&(this._options[r]=s.slice(0))}this.stencil.copyTo(t.stencil);for(let r in this._textures)t.setTexture(r,this._textures[r]);for(let r in this._internalTextures)t.setInternalTexture(r,this._internalTextures[r]);for(let r in this._textureArrays)t.setTextureArray(r,this._textureArrays[r]);for(let r in this._externalTextures)t.setExternalTexture(r,this._externalTextures[r]);for(let r in this._ints)t.setInt(r,this._ints[r]);for(let r in this._uints)t.setUInt(r,this._uints[r]);for(let r in this._floats)t.setFloat(r,this._floats[r]);for(let r in this._floatsArrays)t.setFloats(r,this._floatsArrays[r]);for(let r in this._colors3)t.setColor3(r,this._colors3[r]);for(let r in this._colors3Arrays)t._colors3Arrays[r]=this._colors3Arrays[r];for(let r in this._colors4)t.setColor4(r,this._colors4[r]);for(let r in this._colors4Arrays)t._colors4Arrays[r]=this._colors4Arrays[r];for(let r in this._vectors2)t.setVector2(r,this._vectors2[r]);for(let r in this._vectors3)t.setVector3(r,this._vectors3[r]);for(let r in this._vectors4)t.setVector4(r,this._vectors4[r]);for(let r in this._quaternions)t.setQuaternion(r,this._quaternions[r]);for(let r in this._quaternionsArrays)t._quaternionsArrays[r]=this._quaternionsArrays[r];for(let r in this._matrices)t.setMatrix(r,this._matrices[r]);for(let r in this._matrixArrays)t._matrixArrays[r]=this._matrixArrays[r].slice();for(let r in this._matrices3x3)t.setMatrix3x3(r,this._matrices3x3[r]);for(let r in this._matrices2x2)t.setMatrix2x2(r,this._matrices2x2[r]);for(let r in this._vectors2Arrays)t.setArray2(r,this._vectors2Arrays[r]);for(let r in this._vectors3Arrays)t.setArray3(r,this._vectors3Arrays[r]);for(let r in this._vectors4Arrays)t.setArray4(r,this._vectors4Arrays[r]);for(let r in this._uniformBuffers)t.setUniformBuffer(r,this._uniformBuffers[r]);for(let r in this._textureSamplers)t.setTextureSampler(r,this._textureSamplers[r]);for(let r in this._storageBuffers)t.setStorageBuffer(r,this._storageBuffers[r]);return t}dispose(e,t,i){if(t){let r;for(r in this._textures)this._textures[r].dispose();for(r in this._internalTextures)this._internalTextures[r].dispose();for(r in this._textureArrays){let s=this._textureArrays[r];for(let a=0;anew n(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes),e,t,i),s;e.stencil&&r.stencil.parse(e.stencil,t,i);for(s in e.textures)r.setTexture(s,ne.Parse(e.textures[s],t,i));for(s in e.textureArrays){let a=e.textureArrays[s],o=[];for(let l=0;l(c%3===0?o.push([l]):o[o.length-1].push(l),o),[]).map(o=>({r:o[0],g:o[1],b:o[2]}));r.setColor3Array(s,a)}for(s in e.colors4){let a=e.colors4[s];r.setColor4(s,{r:a[0],g:a[1],b:a[2],a:a[3]})}for(s in e.colors4Arrays){let a=e.colors4Arrays[s].reduce((o,l,c)=>(c%4===0?o.push([l]):o[o.length-1].push(l),o),[]).map(o=>({r:o[0],g:o[1],b:o[2],a:o[3]}));r.setColor4Array(s,a)}for(s in e.vectors2){let a=e.vectors2[s];r.setVector2(s,{x:a[0],y:a[1]})}for(s in e.vectors3){let a=e.vectors3[s];r.setVector3(s,{x:a[0],y:a[1],z:a[2]})}for(s in e.vectors4){let a=e.vectors4[s];r.setVector4(s,{x:a[0],y:a[1],z:a[2],w:a[3]})}for(s in e.quaternions)r.setQuaternion(s,Ae.FromArray(e.quaternions[s]));for(s in e.matrices)r.setMatrix(s,U.FromArray(e.matrices[s]));for(s in e.matrixArray)r._matrixArrays[s]=new Float32Array(e.matrixArray[s]);for(s in e.matrices3x3)r.setMatrix3x3(s,e.matrices3x3[s]);for(s in e.matrices2x2)r.setMatrix2x2(s,e.matrices2x2[s]);for(s in e.vectors2Arrays)r.setArray2(s,e.vectors2Arrays[s]);for(s in e.vectors3Arrays)r.setArray3(s,e.vectors3Arrays[s]);for(s in e.vectors4Arrays)r.setArray4(s,e.vectors4Arrays[s]);for(s in e.quaternionsArrays)r.setArray4(s,e.quaternionsArrays[s]);return r}static async ParseFromFileAsync(e,t,i,r=""){return await new Promise((s,a)=>{let o=new $t;o.addEventListener("readystatechange",()=>{if(o.readyState==4)if(o.status==200){let l=JSON.parse(o.responseText),c=this.Parse(l,i||ue.LastCreatedScene,r);e&&(c.name=e),s(c)}else a("Unable to load the ShaderMaterial")}),o.open("GET",t),o.send()})}static async ParseFromSnippetAsync(e,t,i=""){return await new Promise((r,s)=>{let a=new $t;a.addEventListener("readystatechange",()=>{if(a.readyState==4)if(a.status==200){let o=JSON.parse(JSON.parse(a.responseText).jsonPayload),l=JSON.parse(o.shaderMaterial),c=this.Parse(l,t||ue.LastCreatedScene,i);c.snippetId=e,r(c)}else s("Unable to load the snippet "+e)}),a.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),a.send()})}};Tn.SnippetUrl="https://snippet.babylonjs.com";Tn.CreateFromSnippetAsync=Tn.ParseFromSnippetAsync;je("BABYLON.ShaderMaterial",Tn)});var a0,Vk,Cs=A(()=>{N();a0="bonesDeclaration",Vk=`#if NUM_BONE_INFLUENCERS>0 #ifndef USE_VERTEX_PULLING attribute matricesIndices : vec4f;attribute matricesWeights : vec4f; #if NUM_BONE_INFLUENCERS>4 @@ -348,7 +348,7 @@ let textureWidth=i32(uniforms.boneTextureInfo.x);let y=offset/textureWidth;let x #endif #endif #endif -`;E.IncludesShadersStoreWGSL[$M]||(E.IncludesShadersStoreWGSL[$M]=Tk)});var e0,Sk,bs=A(()=>{N();e0="bakedVertexAnimationDeclaration",Sk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStoreWGSL[a0]||(E.IncludesShadersStoreWGSL[a0]=Vk)});var o0,Gk,bs=A(()=>{N();o0="bakedVertexAnimationDeclaration",Gk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE uniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationSettings: vec4;var bakedVertexAnimationTexture : texture_2d; #ifdef INSTANCES attribute bakedVertexAnimationSettingsInstanced : vec4; @@ -356,7 +356,7 @@ attribute bakedVertexAnimationSettingsInstanced : vec4; fn readMatrixFromRawSamplerVAT(smp : texture_2d,index : f32,frame : f32)->mat4x4 {let offset=i32(index)*4;let frameUV=i32(frame);let m0=textureLoad(smp,vec2(offset+0,frameUV),0);let m1=textureLoad(smp,vec2(offset+1,frameUV),0);let m2=textureLoad(smp,vec2(offset+2,frameUV),0);let m3=textureLoad(smp,vec2(offset+3,frameUV),0);return mat4x4(m0,m1,m2,m3);} #endif -`;E.IncludesShadersStoreWGSL[e0]||(E.IncludesShadersStoreWGSL[e0]=Sk)});var t0,Ak,Ms=A(()=>{N();t0="clipPlaneVertexDeclaration",Ak=`#ifdef CLIPPLANE +`;E.IncludesShadersStoreWGSL[o0]||(E.IncludesShadersStoreWGSL[o0]=Gk)});var l0,kk,Ms=A(()=>{N();l0="clipPlaneVertexDeclaration",kk=`#ifdef CLIPPLANE uniform vClipPlane: vec4;varying fClipDistance: f32; #endif #ifdef CLIPPLANE2 @@ -374,10 +374,10 @@ uniform vClipPlane5: vec4;varying fClipDistance5: f32; #ifdef CLIPPLANE6 uniform vClipPlane6: vec4;varying fClipDistance6: f32; #endif -`;E.IncludesShadersStoreWGSL[t0]||(E.IncludesShadersStoreWGSL[t0]=Ak)});var i0,Rk,bf=A(()=>{N();i0="fogVertexDeclaration",Rk=`#ifdef FOG +`;E.IncludesShadersStoreWGSL[l0]||(E.IncludesShadersStoreWGSL[l0]=kk)});var c0,Wk,bf=A(()=>{N();c0="fogVertexDeclaration",Wk=`#ifdef FOG varying vFogDistance: vec3f; #endif -`;E.IncludesShadersStoreWGSL[i0]||(E.IncludesShadersStoreWGSL[i0]=Rk)});var r0,Ik,Oa=A(()=>{N();r0="instancesDeclaration",Ik=`#ifdef INSTANCES +`;E.IncludesShadersStoreWGSL[c0]||(E.IncludesShadersStoreWGSL[c0]=Wk)});var f0,Hk,Oa=A(()=>{N();f0="instancesDeclaration",Hk=`#ifdef INSTANCES attribute world0 : vec4;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4; #ifdef INSTANCESCOLOR attribute instanceColor : vec4; @@ -399,7 +399,7 @@ uniform world : mat4x4; uniform previousWorld : mat4x4; #endif #endif -`;E.IncludesShadersStoreWGSL[r0]||(E.IncludesShadersStoreWGSL[r0]=Ik)});var n0,xk,ys=A(()=>{N();n0="instancesVertex",xk=`#ifdef INSTANCES +`;E.IncludesShadersStoreWGSL[f0]||(E.IncludesShadersStoreWGSL[f0]=Hk)});var d0,zk,ys=A(()=>{N();d0="instancesVertex",zk=`#ifdef INSTANCES var finalWorld=mat4x4(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3); #if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) var finalPreviousWorld=mat4x4( @@ -426,7 +426,7 @@ var finalWorld=mesh.world; var finalPreviousWorld=uniforms.previousWorld; #endif #endif -`;E.IncludesShadersStoreWGSL[n0]||(E.IncludesShadersStoreWGSL[n0]=xk)});var s0,Ck,Ds=A(()=>{N();s0="bonesVertex",Ck=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStoreWGSL[d0]||(E.IncludesShadersStoreWGSL[d0]=zk)});var h0,Xk,Ds=A(()=>{N();h0="bonesVertex",Xk=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE #if NUM_BONE_INFLUENCERS>0 var influence : mat4x4; #ifdef BONETEXTURE @@ -479,7 +479,7 @@ influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndicesExtra[3])]*v finalWorld=finalWorld*influence; #endif #endif -`;E.IncludesShadersStoreWGSL[s0]||(E.IncludesShadersStoreWGSL[s0]=Ck)});var a0,bk,Ls=A(()=>{N();a0="bakedVertexAnimation",bk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStoreWGSL[h0]||(E.IncludesShadersStoreWGSL[h0]=Xk)});var u0,Yk,Ls=A(()=>{N();u0="bakedVertexAnimation",Yk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE { #ifdef INSTANCES let VATStartFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.x;let VATEndFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.y;let VATOffsetFrame: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.z;let VATSpeed: f32=vertexInputs.bakedVertexAnimationSettingsInstanced.w; @@ -510,7 +510,7 @@ VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTextur #endif finalWorld=finalWorld*VATInfluence;} #endif -`;E.IncludesShadersStoreWGSL[a0]||(E.IncludesShadersStoreWGSL[a0]=bk)});var o0,Mk,Ps=A(()=>{N();o0="clipPlaneVertex",Mk=`#ifdef CLIPPLANE +`;E.IncludesShadersStoreWGSL[u0]||(E.IncludesShadersStoreWGSL[u0]=Yk)});var m0,Kk,Ps=A(()=>{N();m0="clipPlaneVertex",Kk=`#ifdef CLIPPLANE vertexOutputs.fClipDistance=dot(worldPos,uniforms.vClipPlane); #endif #ifdef CLIPPLANE2 @@ -528,14 +528,14 @@ vertexOutputs.fClipDistance5=dot(worldPos,uniforms.vClipPlane5); #ifdef CLIPPLANE6 vertexOutputs.fClipDistance6=dot(worldPos,uniforms.vClipPlane6); #endif -`;E.IncludesShadersStoreWGSL[o0]||(E.IncludesShadersStoreWGSL[o0]=Mk)});var l0,yk,Mf=A(()=>{N();l0="fogVertex",yk=`#ifdef FOG +`;E.IncludesShadersStoreWGSL[m0]||(E.IncludesShadersStoreWGSL[m0]=Kk)});var p0,jk,Mf=A(()=>{N();p0="fogVertex",jk=`#ifdef FOG #ifdef SCENE_UBO vertexOutputs.vFogDistance=(scene.view*worldPos).xyz; #else vertexOutputs.vFogDistance=(uniforms.view*worldPos).xyz; #endif #endif -`;E.IncludesShadersStoreWGSL[l0]||(E.IncludesShadersStoreWGSL[l0]=yk)});var c0,Dk,yf=A(()=>{N();c0="vertexColorMixing",Dk=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +`;E.IncludesShadersStoreWGSL[p0]||(E.IncludesShadersStoreWGSL[p0]=jk)});var _0,Zk,yf=A(()=>{N();_0="vertexColorMixing",Zk=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) vertexOutputs.vColor=vec4f(1.0); #ifdef VERTEXCOLOR #ifdef VERTEXALPHA @@ -548,7 +548,7 @@ vertexOutputs.vColor=vec4f(vertexOutputs.vColor.rgb*colorUpdated.rgb,vertexOutpu vertexOutputs.vColor*=vertexInputs.instanceColor; #endif #endif -`;E.IncludesShadersStoreWGSL[c0]||(E.IncludesShadersStoreWGSL[c0]=Dk)});var d0={};De(d0,{colorVertexShaderWGSL:()=>Lk});var BE,f0,Lk,h0=A(()=>{N();Cs();bs();Ms();bf();Oa();ys();Ds();Ls();Ps();Mf();yf();BE="colorVertexShader",f0=`attribute position: vec3f; +`;E.IncludesShadersStoreWGSL[_0]||(E.IncludesShadersStoreWGSL[_0]=Zk)});var E0={};De(E0,{colorVertexShaderWGSL:()=>qk});var GE,g0,qk,v0=A(()=>{N();Cs();bs();Ms();bf();Oa();ys();Ds();Ls();Ps();Mf();yf();GE="colorVertexShader",g0=`attribute position: vec3f; #ifdef VERTEXCOLOR attribute color: vec4f; #endif @@ -579,7 +579,7 @@ var worldPos: vec4f=finalWorld* vec4f(vertexInputs.position,1.0);vertexOutputs.p #include #include #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStoreWGSL[BE]||(E.ShadersStoreWGSL[BE]=f0);Lk={name:BE,shader:f0}});var u0,Pk,Os=A(()=>{N();u0="clipPlaneFragmentDeclaration",Pk=`#ifdef CLIPPLANE +}`;E.ShadersStoreWGSL[GE]||(E.ShadersStoreWGSL[GE]=g0);qk={name:GE,shader:g0}});var T0,Qk,Os=A(()=>{N();T0="clipPlaneFragmentDeclaration",Qk=`#ifdef CLIPPLANE varying fClipDistance: f32; #endif #ifdef CLIPPLANE2 @@ -597,7 +597,7 @@ varying fClipDistance5: f32; #ifdef CLIPPLANE6 varying fClipDistance6: f32; #endif -`;E.IncludesShadersStoreWGSL[u0]||(E.IncludesShadersStoreWGSL[u0]=Pk)});var m0,Ok,Df=A(()=>{N();m0="fogFragmentDeclaration",Ok=`#ifdef FOG +`;E.IncludesShadersStoreWGSL[T0]||(E.IncludesShadersStoreWGSL[T0]=Qk)});var S0,Jk,Df=A(()=>{N();S0="fogFragmentDeclaration",Jk=`#ifdef FOG #define FOGMODE_NONE 0. #define FOGMODE_EXP 1. #define FOGMODE_EXP2 2. @@ -611,7 +611,7 @@ else if (FOGMODE_EXP2==uniforms.vFogInfos.x) {fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);} return clamp(fogCoeff,0.0,1.0);} #endif -`;E.IncludesShadersStoreWGSL[m0]||(E.IncludesShadersStoreWGSL[m0]=Ok)});var p0,Nk,Ns=A(()=>{N();p0="clipPlaneFragment",Nk=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +`;E.IncludesShadersStoreWGSL[S0]||(E.IncludesShadersStoreWGSL[S0]=Jk)});var A0,$k,Ns=A(()=>{N();A0="clipPlaneFragment",$k=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) if (false) {} #endif #ifdef CLIPPLANE @@ -638,14 +638,14 @@ else if (fragmentInputs.fClipDistance5>0.0) else if (fragmentInputs.fClipDistance6>0.0) {discard;} #endif -`;E.IncludesShadersStoreWGSL[p0]||(E.IncludesShadersStoreWGSL[p0]=Nk)});var _0,Fk,Lf=A(()=>{N();_0="fogFragment",Fk=`#ifdef FOG +`;E.IncludesShadersStoreWGSL[A0]||(E.IncludesShadersStoreWGSL[A0]=$k)});var R0,eW,Lf=A(()=>{N();R0="fogFragment",eW=`#ifdef FOG var fog: f32=CalcFogFactor(); #ifdef PBR fog=toLinearSpace(fog); #endif color= vec4f(mix(uniforms.vFogColor,color.rgb,fog),color.a); #endif -`;E.IncludesShadersStoreWGSL[_0]||(E.IncludesShadersStoreWGSL[_0]=Fk)});var E0={};De(E0,{colorPixelShaderWGSL:()=>wk});var UE,g0,wk,v0=A(()=>{N();Os();Df();Ns();Lf();UE="colorPixelShader",g0=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +`;E.IncludesShadersStoreWGSL[R0]||(E.IncludesShadersStoreWGSL[R0]=eW)});var x0={};De(x0,{colorPixelShaderWGSL:()=>tW});var kE,I0,tW,C0=A(()=>{N();Os();Df();Ns();Lf();kE="colorPixelShader",I0=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) #define VERTEXCOLOR varying vColor: vec4f; #else @@ -665,7 +665,7 @@ fragmentOutputs.color=uniforms.color; #endif #include(color,fragmentOutputs.color) #define CUSTOM_FRAGMENT_MAIN_END -}`;E.ShadersStoreWGSL[UE]||(E.ShadersStoreWGSL[UE]=g0);wk={name:UE,shader:g0}});var T0,Bk,Fs=A(()=>{N();T0="bonesDeclaration",Bk=`#if NUM_BONE_INFLUENCERS>0 +}`;E.ShadersStoreWGSL[kE]||(E.ShadersStoreWGSL[kE]=I0);tW={name:kE,shader:I0}});var b0,iW,Fs=A(()=>{N();b0="bonesDeclaration",iW=`#if NUM_BONE_INFLUENCERS>0 attribute vec4 matricesIndices;attribute vec4 matricesWeights; #if NUM_BONE_INFLUENCERS>4 attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra; @@ -694,7 +694,7 @@ return mat4(m0,m1,m2,m3); #endif #endif #endif -`;E.IncludesShadersStore[T0]||(E.IncludesShadersStore[T0]=Bk)});var S0,Uk,ws=A(()=>{N();S0="bakedVertexAnimationDeclaration",Uk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStore[b0]||(E.IncludesShadersStore[b0]=iW)});var M0,rW,ws=A(()=>{N();M0="bakedVertexAnimationDeclaration",rW=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE uniform float bakedVertexAnimationTime; #if !defined(WEBGL2) && !defined(WEBGPU) uniform vec2 bakedVertexAnimationTextureSizeInverted; @@ -713,7 +713,7 @@ float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSize #endif } #endif -`;E.IncludesShadersStore[S0]||(E.IncludesShadersStore[S0]=Uk)});var A0,Vk,Bs=A(()=>{N();A0="clipPlaneVertexDeclaration",Vk=`#ifdef CLIPPLANE +`;E.IncludesShadersStore[M0]||(E.IncludesShadersStore[M0]=rW)});var y0,nW,Bs=A(()=>{N();y0="clipPlaneVertexDeclaration",nW=`#ifdef CLIPPLANE uniform vec4 vClipPlane;varying float fClipDistance; #endif #ifdef CLIPPLANE2 @@ -731,10 +731,10 @@ uniform vec4 vClipPlane5;varying float fClipDistance5; #ifdef CLIPPLANE6 uniform vec4 vClipPlane6;varying float fClipDistance6; #endif -`;E.IncludesShadersStore[A0]||(E.IncludesShadersStore[A0]=Vk)});var R0,Gk,Pf=A(()=>{N();R0="fogVertexDeclaration",Gk=`#ifdef FOG +`;E.IncludesShadersStore[y0]||(E.IncludesShadersStore[y0]=nW)});var D0,sW,Pf=A(()=>{N();D0="fogVertexDeclaration",sW=`#ifdef FOG varying vec3 vFogDistance; #endif -`;E.IncludesShadersStore[R0]||(E.IncludesShadersStore[R0]=Gk)});var I0,kk,Na=A(()=>{N();I0="instancesDeclaration",kk=`#ifdef INSTANCES +`;E.IncludesShadersStore[D0]||(E.IncludesShadersStore[D0]=sW)});var L0,aW,Na=A(()=>{N();L0="instancesDeclaration",aW=`#ifdef INSTANCES attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; #ifdef INSTANCESCOLOR attribute vec4 instanceColor; @@ -756,7 +756,7 @@ uniform mat4 world; uniform mat4 previousWorld; #endif #endif -`;E.IncludesShadersStore[I0]||(E.IncludesShadersStore[I0]=kk)});var x0,Wk,Us=A(()=>{N();x0="instancesVertex",Wk=`#ifdef INSTANCES +`;E.IncludesShadersStore[L0]||(E.IncludesShadersStore[L0]=aW)});var P0,oW,Us=A(()=>{N();P0="instancesVertex",oW=`#ifdef INSTANCES mat4 finalWorld=mat4(world0,world1,world2,world3); #if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1, @@ -774,7 +774,7 @@ mat4 finalWorld=world; mat4 finalPreviousWorld=previousWorld; #endif #endif -`;E.IncludesShadersStore[x0]||(E.IncludesShadersStore[x0]=Wk)});var C0,Hk,Vs=A(()=>{N();C0="bonesVertex",Hk=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStore[P0]||(E.IncludesShadersStore[P0]=oW)});var O0,lW,Vs=A(()=>{N();O0="bonesVertex",lW=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE #if NUM_BONE_INFLUENCERS>0 mat4 influence; #ifdef BONETEXTURE @@ -827,7 +827,7 @@ influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; finalWorld=finalWorld*influence; #endif #endif -`;E.IncludesShadersStore[C0]||(E.IncludesShadersStore[C0]=Hk)});var b0,zk,Gs=A(()=>{N();b0="bakedVertexAnimation",zk=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +`;E.IncludesShadersStore[O0]||(E.IncludesShadersStore[O0]=lW)});var N0,cW,Gs=A(()=>{N();N0="bakedVertexAnimation",cW=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE { #ifdef INSTANCES #define BVASNAME bakedVertexAnimationSettingsInstanced @@ -858,7 +858,7 @@ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIn #endif finalWorld=finalWorld*VATInfluence;} #endif -`;E.IncludesShadersStore[b0]||(E.IncludesShadersStore[b0]=zk)});var M0,Xk,ks=A(()=>{N();M0="clipPlaneVertex",Xk=`#ifdef CLIPPLANE +`;E.IncludesShadersStore[N0]||(E.IncludesShadersStore[N0]=cW)});var F0,fW,ks=A(()=>{N();F0="clipPlaneVertex",fW=`#ifdef CLIPPLANE fClipDistance=dot(worldPos,vClipPlane); #endif #ifdef CLIPPLANE2 @@ -876,10 +876,10 @@ fClipDistance5=dot(worldPos,vClipPlane5); #ifdef CLIPPLANE6 fClipDistance6=dot(worldPos,vClipPlane6); #endif -`;E.IncludesShadersStore[M0]||(E.IncludesShadersStore[M0]=Xk)});var y0,Yk,Of=A(()=>{N();y0="fogVertex",Yk=`#ifdef FOG +`;E.IncludesShadersStore[F0]||(E.IncludesShadersStore[F0]=fW)});var w0,dW,Of=A(()=>{N();w0="fogVertex",dW=`#ifdef FOG vFogDistance=(view*worldPos).xyz; #endif -`;E.IncludesShadersStore[y0]||(E.IncludesShadersStore[y0]=Yk)});var D0,Kk,Nf=A(()=>{N();D0="vertexColorMixing",Kk=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +`;E.IncludesShadersStore[w0]||(E.IncludesShadersStore[w0]=dW)});var B0,hW,Nf=A(()=>{N();B0="vertexColorMixing",hW=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) vColor=vec4(1.0); #ifdef VERTEXCOLOR #ifdef VERTEXALPHA @@ -892,7 +892,7 @@ vColor.rgb*=colorUpdated.rgb; vColor*=instanceColor; #endif #endif -`;E.IncludesShadersStore[D0]||(E.IncludesShadersStore[D0]=Kk)});var P0={};De(P0,{colorVertexShader:()=>jk});var VE,L0,jk,O0=A(()=>{N();Fs();ws();Bs();Pf();Na();Us();Vs();Gs();ks();Of();Nf();VE="colorVertexShader",L0=`attribute vec3 position; +`;E.IncludesShadersStore[B0]||(E.IncludesShadersStore[B0]=hW)});var V0={};De(V0,{colorVertexShader:()=>uW});var WE,U0,uW,G0=A(()=>{N();Fs();ws();Bs();Pf();Na();Us();Vs();Gs();ks();Of();Nf();WE="colorVertexShader",U0=`attribute vec3 position; #ifdef VERTEXCOLOR attribute vec4 color; #endif @@ -930,7 +930,7 @@ gl_Position=viewProjection*worldPos; #include #include #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStore[VE]||(E.ShadersStore[VE]=L0);jk={name:VE,shader:L0}});var N0,Zk,Ws=A(()=>{N();N0="clipPlaneFragmentDeclaration",Zk=`#ifdef CLIPPLANE +}`;E.ShadersStore[WE]||(E.ShadersStore[WE]=U0);uW={name:WE,shader:U0}});var k0,mW,Ws=A(()=>{N();k0="clipPlaneFragmentDeclaration",mW=`#ifdef CLIPPLANE varying float fClipDistance; #endif #ifdef CLIPPLANE2 @@ -948,7 +948,7 @@ varying float fClipDistance5; #ifdef CLIPPLANE6 varying float fClipDistance6; #endif -`;E.IncludesShadersStore[N0]||(E.IncludesShadersStore[N0]=Zk)});var F0,qk,Ff=A(()=>{N();F0="fogFragmentDeclaration",qk=`#ifdef FOG +`;E.IncludesShadersStore[k0]||(E.IncludesShadersStore[k0]=mW)});var W0,pW,Ff=A(()=>{N();W0="fogFragmentDeclaration",pW=`#ifdef FOG #define FOGMODE_NONE 0. #define FOGMODE_EXP 1. #define FOGMODE_EXP2 2. @@ -963,7 +963,7 @@ else if (FOGMODE_EXP2==vFogInfos.x) {fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);} return clamp(fogCoeff,0.0,1.0);} #endif -`;E.IncludesShadersStore[F0]||(E.IncludesShadersStore[F0]=qk)});var w0,Qk,Hs=A(()=>{N();w0="clipPlaneFragment",Qk=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +`;E.IncludesShadersStore[W0]||(E.IncludesShadersStore[W0]=pW)});var H0,_W,Hs=A(()=>{N();H0="clipPlaneFragment",_W=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) if (false) {} #endif #ifdef CLIPPLANE @@ -990,14 +990,14 @@ else if (fClipDistance5>0.0) else if (fClipDistance6>0.0) {discard;} #endif -`;E.IncludesShadersStore[w0]||(E.IncludesShadersStore[w0]=Qk)});var B0,Jk,wf=A(()=>{N();B0="fogFragment",Jk=`#ifdef FOG +`;E.IncludesShadersStore[H0]||(E.IncludesShadersStore[H0]=_W)});var z0,gW,wf=A(()=>{N();z0="fogFragment",gW=`#ifdef FOG float fog=CalcFogFactor(); #ifdef PBR fog=toLinearSpace(fog); #endif color.rgb=mix(vFogColor,color.rgb,fog); #endif -`;E.IncludesShadersStore[B0]||(E.IncludesShadersStore[B0]=Jk)});var V0={};De(V0,{colorPixelShader:()=>$k});var GE,U0,$k,G0=A(()=>{N();Ws();Ff();Hs();wf();GE="colorPixelShader",U0=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +`;E.IncludesShadersStore[z0]||(E.IncludesShadersStore[z0]=gW)});var Y0={};De(Y0,{colorPixelShader:()=>EW});var HE,X0,EW,K0=A(()=>{N();Ws();Ff();Hs();wf();HE="colorPixelShader",X0=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) #define VERTEXCOLOR varying vec4 vColor; #else @@ -1016,18 +1016,18 @@ gl_FragColor=color; #endif #include(color,gl_FragColor) #define CUSTOM_FRAGMENT_MAIN_END -}`;E.ShadersStore[GE]||(E.ShadersStore[GE]=U0);$k={name:GE,shader:U0}});var Mo,kE,k0=A(()=>{et();yt();Rt();NE();Ni();wE();U._LinesMeshParser=(n,e)=>Mo.Parse(n,e);Mo=class n extends U{_isShaderMaterial(e){return e?e.getClassName()==="ShaderMaterial":!1}constructor(e,t=null,i=null,r=null,s,a,o,l){super(e,t,i,r,s),this.useVertexColor=a,this.useVertexAlpha=o,this.color=new oe(1,1,1),this.alpha=1,this._shaderLanguage=0,this._ownsMaterial=!1,r&&(this.color=r.color.clone(),this.alpha=r.alpha,this.useVertexColor=r.useVertexColor,this.useVertexAlpha=r.useVertexAlpha),this.intersectionThreshold=.1;let c=[],f={attributes:[M.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:c,useClipPlane:null,shaderLanguage:0};if(this.useVertexAlpha?f.defines.push("#define VERTEXALPHA"):f.needAlphaBlending=!1,this.useVertexColor?(f.defines.push("#define VERTEXCOLOR"),f.attributes.push(M.ColorKind)):(f.uniforms.push("color"),this._color4=new Ne),l)this.material=l;else{this.getScene().getEngine().isWebGPU&&!n.ForceGLSL&&(this._shaderLanguage=1),f.shaderLanguage=this._shaderLanguage,f.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(h0(),d0)),Promise.resolve().then(()=>(v0(),E0))]):await Promise.all([Promise.resolve().then(()=>(O0(),P0)),Promise.resolve().then(()=>(G0(),V0))])};let h=new vn("colorShader",this.getScene(),"color",f,!1);h.doNotSerialize=!0,this._ownsMaterial=!0,this._setInternalMaterial(h)}}getClassName(){return"LinesMesh"}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){let t=this.material;if(t===e)return;let i=t&&this._ownsMaterial;this._ownsMaterial=!1,this._setInternalMaterial(e),i&&(t==null||t.dispose())}_setInternalMaterial(e){this._setMaterial(e),this.material&&(this.material.fillMode=ae.LineListDrawMode,this.material.disableLighting=!0)}get checkCollisions(){return!1}set checkCollisions(e){}_bind(e,t){if(!this._geometry)return this;let 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.material)){let{r,g:s,b:a}=this.color;this._color4.set(r,s,a,this.alpha),this.material.setColor4("color",this._color4)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;let r=this.getScene().getEngine();return this._unIndexed?r.drawArraysType(ae.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(ae.LineListDrawMode,e.indexStart,e.indexCount,i),this}dispose(e,t=!1,i){var r,s;i||(this._ownsMaterial?(r=this.material)==null||r.dispose(!1,!1,!0):t&&((s=this.material)==null||s.dispose(!1,!1,!0))),super.dispose(e)}clone(e,t=null,i){if(t&&t._addToSceneRootNodes===void 0){let r=t;return r.source=this,new n(e,this.getScene(),r.parent,r.source,r.doNotCloneChildren)}return new n(e,this.getScene(),t,this,i)}createInstance(e){let t=new kE(e,this);if(this.instancedBuffers){t.instancedBuffers={};for(let 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){let i=new n(e.name,t);return i.color=oe.FromArray(e.color),i.alpha=e.alpha,i}};Mo.ForceGLSL=!1;kE=class extends xs{constructor(e,t){super(e,t),this.intersectionThreshold=t.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}});function W0(n){let e=[],t=[],i=n.lines,r=n.colors,s=[],a=0;for(let l=0;l0&&(e.push(a-1),e.push(a)),a++}}let o=new de;return o.indices=e,o.positions=t,r&&(o.colors=s),o}function H0(n){let e=n.dashSize||3,t=n.gapSize||1,i=n.dashNb||200,r=n.points,s=[],a=[],o=v.Zero(),l=0,c,f,d=0,h;for(h=0;h{let d=v.Zero(),h=f.length/6,u=0,m,p,_=0,g,T;for(g=0;g{ve();Rt();Vt();k0();yt();ze();de.CreateLineSystem=W0;de.CreateDashedLines=H0;U.CreateLines=(n,e,t=null,i=!1,r=null)=>HE(n,{points:e,updatable:i,instance:r},t);U.CreateDashedLines=(n,e,t,i,r,s=null,a,o)=>zE(n,{points:e,dashSize:t,gapSize:i,dashNb:r,updatable:a,instance:o},s)});var XE,Bf,_u,X0=A(()=>{ze();ve();yt();Rt();Vt();uo();Ci();At();XE=class extends _e{constructor(e,t){super(e.x,e.y),this.index=t}},Bf=class{constructor(){this.elements=[]}add(e){let t=[];for(let i of e){let r=new XE(i,this.elements.length);t.push(r),this.elements.push(r)}return t}computeBounds(){let e=new _e(this.elements[0].x,this.elements[0].y),t=new _e(this.elements[0].x,this.elements[0].y);for(let i of this.elements)i.xt.x&&(t.x=i.x),i.yt.y&&(t.y=i.y);return{min:e,max:t,width:t.x-e.x,height:t.y-e.y}}},_u=class{_addToepoint(e){for(let t of e)this._epoints.push(t.x,t.y)}constructor(e,t,i,r=earcut){this._points=new Bf,this._outlinepoints=new Bf,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=r,this._name=e,this._scene=i||ue.LastCreatedScene;let s;t instanceof cl?s=t.getPoints():s=t,this._addToepoint(s),this._points.add(s),this._outlinepoints.add(s),typeof this.bjsEarcut=="undefined"&&W.Warn("Earcut was not found, the polygon will not be built.")}addHole(e){this._points.add(e);let t=new Bf;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){let r=new U(this._name,this._scene),s=this.buildVertexData(t,i);return r.setVerticesData(M.PositionKind,s.positions,e),r.setVerticesData(M.NormalKind,s.normals,e),r.setVerticesData(M.UVKind,s.uvs,e),r.setIndices(s.indices),r}buildVertexData(e=0,t=2){let i=new de,r=[],s=[],a=[],o=this._points.computeBounds();for(let f of this._points.elements)r.push(0,1,0),s.push(f.x,0,f.y),a.push((f.x-o.min.x)/o.width,(f.y-o.min.y)/o.height);let l=[],c=this.bjsEarcut(this._epoints,this._eholes,2);for(let f=0;f0){let f=s.length/3;for(let h of this._points.elements)r.push(0,-1,0),s.push(h.x,-e,h.y),a.push(1-(h.x-o.min.x)/o.width,1-(h.y-o.min.y)/o.height);let d=l.length;for(let h=0;hc?xc?P{ve();et();Rt();Vt();X0();yt();At();hi();de.CreatePolygon=Y0;U.CreatePolygon=(n,e,t,i,r,s,a=earcut)=>gu(n,{shape:e,holes:i,updatable:r,sideOrientation:s},t,a);U.ExtrudePolygon=(n,e,t,i,r,s,a,o=earcut)=>Uf(n,{shape:e,holes:r,depth:t,updatable:s,sideOrientation:a},i,o)});function KE(n,e,t=null){let i=e.path,r=e.shape,s=e.scale||1,a=e.rotation||0,o=e.cap===0?0:e.cap||U.NO_CAP,l=e.updatable,c=U._GetDefaultSideOrientation(e.sideOrientation),f=e.instance||null,d=e.invertUV||!1,h=e.closeShape||!1,u=e.closePath||!1,m=e.capFunction||null;return K0(n,r,i,s,a,null,null,u,h,o,!1,t,!!l,c,f,d,e.frontUVs||null,e.backUVs||null,e.firstNormal||null,!!e.adjustFrame,m)}function jE(n,e,t=null){var T;let i=e.path,r=e.shape,s=v.Zero(),a=(b,R)=>{var I,x;let S=(x=(I=e.scaleFunction)==null?void 0:I.call(e,b,R))!=null?x:1;return s.copyFromFloats(S,S,S)},o=e.rotationFunction||(()=>0),l=e.closePath||e.ribbonCloseArray||!1,c=e.closeShape||e.ribbonClosePath||!1,f=e.cap===0?0:e.cap||U.NO_CAP,d=e.updatable,h=e.firstNormal||null,u=e.adjustFrame||!1,m=U._GetDefaultSideOrientation(e.sideOrientation),p=e.instance,_=e.invertUV||!1,g=e.capFunction||null;return K0(n,r,i,null,null,(T=e.scaleVectorFunction)!=null?T:a,o,l,c,f,!0,t,!!d,m,p||null,_,e.frontUVs||null,e.backUVs||null,h,u,g||null)}function K0(n,e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g,T,b,R){let S=(B,w,H,O,V,X,j,Q,$,q,z)=>{let K=H.getTangents(),J=H.getNormals(),te=H.getBinormals(),Pe=H.getDistances();if(z){for(let Fe=0;Fe0){let Xe=K[Fe-1];v.Dot(Xe,K[Fe])<0&&K[Fe].scaleInPlace(-1),Xe=J[Fe-1],v.Dot(Xe,J[Fe])<0&&J[Fe].scaleInPlace(-1),Xe=te[Fe-1],v.Dot(Xe,te[Fe])<0&&te[Fe].scaleInPlace(-1)}}let ge=0,me=()=>V!==null?V:v.OneReadOnly,le=q&&Q?Q:()=>X!==null?X:0,xe=q&&j?j:me,ce=$===U.NO_CAP||$===U.CAP_END?0:2,he=k.Matrix[0];for(let Fe=0;Fe{let Xe=Array(),xt=v.Zero(),Dt;for(Dt=0;Dt3?0:c,x=S(e,t,P,L,I,r,s,a,c,f,b);let y=En(n,{pathArray:x,closeArray:o,closePath:l,updatable:h,sideOrientation:u,invertUV:p,frontUVs:_||void 0,backUVs:g||void 0},d);return y._creationDataStorage.pathArray=x,y._creationDataStorage.path3D=P,y._creationDataStorage.cap=c,y}var j0=A(()=>{ve();Rt();If();uo();U.ExtrudeShape=(n,e,t,i,r,s,a=null,o,l,c)=>{let f={shape:e,path:t,scale:i,rotation:r,cap:s===0?0:s||U.NO_CAP,sideOrientation:l,instance:c,updatable:o};return KE(n,f,a)};U.ExtrudeShapeCustom=(n,e,t,i,r,s,a,o,l,c,f,d)=>{let h={shape:e,path:t,scaleFunction:i,rotationFunction:r,ribbonCloseArray:s,ribbonClosePath:a,cap:o===0?0:o||U.NO_CAP,sideOrientation:f,instance:d,updatable:c};return jE(n,h,l)}});function ZE(n,e,t=null){let i=e.arc?e.arc<=0||e.arc>1?1:e.arc:1,r=e.closed===void 0?!0:e.closed,s=e.shape,a=e.radius||1,o=e.tessellation||64,l=e.clip||0,c=e.updatable,f=U._GetDefaultSideOrientation(e.sideOrientation),d=e.cap||U.NO_CAP,h=Math.PI*2,u=[],m=e.invertUV||!1,p,_,g=h/o*i,T,b;for(p=0;p<=o-l;p++){for(b=[],(d==U.CAP_START||d==U.CAP_ALL)&&(b.push(new v(0,s[0].y,0)),b.push(new v(Math.cos(p*g)*s[0].x*a,s[0].y,Math.sin(p*g)*s[0].x*a))),_=0;_{ve();Rt();If();U.CreateLathe=(n,e,t,i,r,s,a)=>ZE(n,{shape:e,radius:t,tessellation:i,sideOrientation:a,updatable:s},r)});function q0(n){let e=[],t=[],i=[],r=[],s=n.width!==void 0?n.width:n.size!==void 0?n.size:1,a=n.height!==void 0?n.height:n.size!==void 0?n.size:1,o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=s/2,c=a/2;t.push(-l,-c,0),i.push(0,0,-1),r.push(0,He?1:0),t.push(l,-c,0),i.push(0,0,-1),r.push(1,He?1:0),t.push(l,c,0),i.push(0,0,-1),r.push(1,He?0:1),t.push(-l,c,0),i.push(0,0,-1),r.push(0,He?0:1),e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),de._ComputeSides(o,t,e,i,r,n.frontUVs,n.backUVs);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function qE(n,e={},t=null){let i=new U(n,t);return e.sideOrientation=U._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,q0(e).applyToMesh(i,e.updatable),e.sourcePlane&&(i.translate(e.sourcePlane.normal,-e.sourcePlane.d),i.setDirection(e.sourcePlane.normal.scale(-1))),i}var Q0=A(()=>{Rt();Vt();hi();de.CreatePlane=q0;U.CreatePlane=(n,e,t,i,r)=>qE(n,{size:e,width:e,height:e,sideOrientation:r,updatable:i},t)});function QE(n,e,t=null){let i=e.path,r=e.instance,s=1;e.radius!==void 0?s=e.radius:r&&(s=r._creationDataStorage.radius);let a=e.tessellation||64,o=e.radiusFunction||null,l=e.cap||U.NO_CAP,c=e.invertUV||!1,f=e.updatable,d=U._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;let h=(g,T,b,R,S,I,x,P)=>{let L=T.getTangents(),y=T.getNormals(),B=T.getDistances(),H=Math.PI*2/S*P,V=I||(()=>R),X,j,Q,$,q=k.Matrix[0],z=x===U.NO_CAP||x===U.CAP_END?0:2;for(let J=0;J{let Pe=Array();for(let ge=0;ge3?0:l,m=h(i,u,p,s,a,o,l,e.arc);let _=En(n,{pathArray:m,closePath:!0,closeArray:!1,updatable:f,sideOrientation:d,invertUV:c,frontUVs:e.frontUVs,backUVs:e.backUVs},t);return _._creationDataStorage.pathArray=m,_._creationDataStorage.path3D=u,_._creationDataStorage.tessellation=a,_._creationDataStorage.cap=l,_._creationDataStorage.arc=e.arc,_._creationDataStorage.radius=s,_}var J0=A(()=>{ve();Rt();If();uo();U.CreateTube=(n,e,t,i,r,s,a,o,l,c)=>QE(n,{path:e,radius:t,tessellation:i,radiusFunction:r,arc:1,cap:s,updatable:o,sideOrientation:l,instance:c},a)});function $0(n){let 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]]};let t=n.type&&(n.type<0||n.type>=e.length)?0:n.type||0,i=n.size,r=n.sizeX||i||1,s=n.sizeY||i||1,a=n.sizeZ||i||1,o=n.custom||e[t],l=o.face.length,c=n.faceUV||new Array(l),f=n.faceColors,d=n.flat===void 0?!0:n.flat,h=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,u=[],m=[],p=[],_=[],g=[],T=0,b=0,R=[],S,I,x,P,L,y,B,w;if(d)for(I=0;I{ve();et();Rt();Vt();hi();de.CreatePolyhedron=$0;U.CreatePolyhedron=(n,e,t)=>Vf(n,e,t)});function ey(n){let e=n.sideOrientation||de.DEFAULTSIDE,t=n.radius||1,i=n.flat===void 0?!0:n.flat,r=(n.subdivisions||4)|0,s=n.radiusX||t,a=n.radiusY||t,o=n.radiusZ||t,l=(1+Math.sqrt(5))/2,c=[-1,l,-0,1,l,0,-1,-l,0,1,-l,0,0,-1,-l,0,1,-l,0,-1,l,0,1,l,l,0,1,l,0,-1,-l,0,1,-l,0,-1],f=[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],d=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],h=[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],u=138/1024,m=239/1024,p=60/1024,_=26/1024,g=-40/1024,T=20/1024,b=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],R=[],S=[],I=[],x=[],P=0,L=new Array(3),y=new Array(3),B;for(B=0;B<3;B++)L[B]=v.Zero(),y[B]=_e.Zero();for(let H=0;H<20;H++){for(B=0;B<3;B++){let V=f[3*H+B];L[B].copyFromFloats(c[3*d[V]],c[3*d[V]+1],c[3*d[V]+2]),L[B].normalize(),y[B].copyFromFloats(h[2*V]*u+p+b[H]*g,h[2*V+1]*m+_+b[H]*T)}let O=(V,X,j,Q)=>{let $=v.Lerp(L[0],L[2],X/r),q=v.Lerp(L[1],L[2],X/r),z=r===X?L[2]:v.Lerp($,q,V/(r-X));z.normalize();let K;if(i){let ge=v.Lerp(L[0],L[2],Q/r),me=v.Lerp(L[1],L[2],Q/r);K=v.Lerp(ge,me,j/(r-Q))}else K=new v(z.x,z.y,z.z);K.x/=s,K.y/=a,K.z/=o,K.normalize();let J=_e.Lerp(y[0],y[2],X/r),te=_e.Lerp(y[1],y[2],X/r),Pe=r===X?y[2]:_e.Lerp(J,te,V/(r-X));S.push(z.x*s,z.y*a,z.z*o),I.push(K.x,K.y,K.z),x.push(Pe.x,He?1-Pe.y:Pe.y),R.push(P),P++};for(let V=0;V{ve();Rt();Vt();hi();de.CreateIcoSphere=ey;U.CreateIcoSphere=(n,e,t)=>$E(n,e,t)});function ev(n,e,t){var j,Q,$,q,z;let i=!!e.skeleton,r=!!((j=e.morphTargetManager)!=null&&j.numTargets),s=t.localMode||i,a=e.getIndices(),o=i||r?e.getPositionData(!0,!0):e.getVerticesData(M.PositionKind),l=i||r?e.getNormalsData(!0,!0):e.getVerticesData(M.NormalKind),c=s?i?e.getVerticesData(M.PositionKind):o:null,f=s?i?e.getVerticesData(M.NormalKind):l:null,d=e.getVerticesData(M.UVKind),h=i?e.getVerticesData(M.MatricesIndicesKind):null,u=i?e.getVerticesData(M.MatricesWeightsKind):null,m=i?e.getVerticesData(M.MatricesIndicesExtraKind):null,p=i?e.getVerticesData(M.MatricesWeightsExtraKind):null,_=t.position||v.Zero(),g=t.normal||v.Up(),T=t.size||v.One(),b=t.angle||0;if(!g){let K=new v(0,0,1),J=e.getScene().activeCamera,te=v.TransformCoordinates(K,J.getWorldMatrix());g=J.globalPosition.subtract(te)}let R=-Math.atan2(g.z,g.x)-Math.PI/2,S=Math.sqrt(g.x*g.x+g.z*g.z),I=Math.atan2(g.y,S),x=new de;x.indices=[],x.positions=[],x.normals=[],x.uvs=[],x.matricesIndices=i?[]:null,x.matricesWeights=i?[]:null,x.matricesIndicesExtra=m?[]:null,x.matricesWeightsExtra=p?[]:null;let P=0,L=(K,J)=>{let te=new Eu;if(!a||!o||!l)return te;let Pe=a[K];if(te.vertexIdx=Pe*3,te.vertexIdxForBones=Pe*4,te.position=new v(o[Pe*3],o[Pe*3+1],o[Pe*3+2]),v.TransformCoordinatesToRef(te.position,J,te.position),te.normal=new v(l[Pe*3],l[Pe*3+1],l[Pe*3+2]),v.TransformNormalToRef(te.normal,J,te.normal),t.captureUVS&&d){let ge=d[Pe*2+1];te.uv=new _e(d[Pe*2],He?1-ge:ge)}return te},y=[0,0,0,0],B=(K,J)=>{if(K.length===0)return K;let te=.5*Math.abs(v.Dot(T,J)),Pe=(se,le,xe,ce)=>{for(let he=0;he{var jA,ZA,qA,QA,JA,$A,eR,tR,iR,rR,nR,sR,aR,oR,lR,cR;let xe=v.GetClipFactor(se.position,le.position,J,te),ce=y,he=y;if(h&&u){let Uc=se.matrixIndicesOverride?0:se.vertexIdxForBones,kp=(jA=se.matrixIndicesOverride)!=null?jA:h,fR=(ZA=se.matrixWeightsOverride)!=null?ZA:u,Wp=le.matrixIndicesOverride?0:le.vertexIdxForBones,dR=(qA=le.matrixIndicesOverride)!=null?qA:h,hR=(QA=le.matrixWeightsOverride)!=null?QA:u;ce=[0,0,0,0],he=[0,0,0,0];let eo=0;for(let $r=0;$r<4;++$r)if(fR[Uc+$r]>0){let Vc=Pe(dR,kp[Uc+$r],Wp,4);ce[eo]=kp[Uc+$r],he[eo]=tn(fR[Uc+$r],Vc>=0?hR[Vc]:0,xe),eo++}for(let $r=0;$r<4&&eo<4;++$r){let Vc=dR[Wp+$r];Pe(kp,Vc,Uc,4)===-1&&(ce[eo]=Vc,he[eo]=tn(0,hR[Wp+$r],xe),eo++)}let Cd=he[0]+he[1]+he[2]+he[3];he[0]/=Cd,he[1]/=Cd,he[2]/=Cd,he[3]/=Cd}let ke=se.localPositionOverride?se.localPositionOverride[0]:(JA=c==null?void 0:c[se.vertexIdx])!=null?JA:0,$e=se.localPositionOverride?se.localPositionOverride[1]:($A=c==null?void 0:c[se.vertexIdx+1])!=null?$A:0,Fe=se.localPositionOverride?se.localPositionOverride[2]:(eR=c==null?void 0:c[se.vertexIdx+2])!=null?eR:0,Xe=le.localPositionOverride?le.localPositionOverride[0]:(tR=c==null?void 0:c[le.vertexIdx])!=null?tR:0,xt=le.localPositionOverride?le.localPositionOverride[1]:(iR=c==null?void 0:c[le.vertexIdx+1])!=null?iR:0,Dt=le.localPositionOverride?le.localPositionOverride[2]:(rR=c==null?void 0:c[le.vertexIdx+2])!=null?rR:0,Yt=se.localNormalOverride?se.localNormalOverride[0]:(nR=f==null?void 0:f[se.vertexIdx])!=null?nR:0,di=se.localNormalOverride?se.localNormalOverride[1]:(sR=f==null?void 0:f[se.vertexIdx+1])!=null?sR:0,pr=se.localNormalOverride?se.localNormalOverride[2]:(aR=f==null?void 0:f[se.vertexIdx+2])!=null?aR:0,xd=le.localNormalOverride?le.localNormalOverride[0]:(oR=f==null?void 0:f[le.vertexIdx])!=null?oR:0,V2=le.localNormalOverride?le.localNormalOverride[1]:(lR=f==null?void 0:f[le.vertexIdx+1])!=null?lR:0,G2=le.localNormalOverride?le.localNormalOverride[2]:(cR=f==null?void 0:f[le.vertexIdx+2])!=null?cR:0,Bp=Yt+(xd-Yt)*xe,Up=di+(V2-di)*xe,Vp=pr+(G2-pr)*xe,Gp=Math.sqrt(Bp*Bp+Up*Up+Vp*Vp);return new Eu(v.Lerp(se.position,le.position,xe),v.Lerp(se.normal,le.normal,xe).normalize(),_e.Lerp(se.uv,le.uv,xe),-1,-1,c?[ke+(Xe-ke)*xe,$e+(xt-$e)*xe,Fe+(Dt-Fe)*xe]:null,f?[Bp/Gp,Up/Gp,Vp/Gp]:null,ce,he)},me=null;K.length>3&&(me=[]);for(let se=0;se0,xt=$e>0,Dt=Fe>0;switch((Xe?1:0)+(xt?1:0)+(Dt?1:0)){case 0:K.length>3?(me.push(K[se]),me.push(K[se+1]),me.push(K[se+2])):me=K;break;case 1:if(me=me!=null?me:new Array,Xe&&(le=K[se+1],xe=K[se+2],ce=ge(K[se],le),he=ge(K[se],xe)),xt){le=K[se],xe=K[se+2],ce=ge(K[se+1],le),he=ge(K[se+1],xe),me.push(ce),me.push(xe.clone()),me.push(le.clone()),me.push(xe.clone()),me.push(ce.clone()),me.push(he);break}Dt&&(le=K[se],xe=K[se+1],ce=ge(K[se+2],le),he=ge(K[se+2],xe)),le&&xe&&ce&&he&&(me.push(le.clone()),me.push(xe.clone()),me.push(ce),me.push(he),me.push(ce.clone()),me.push(xe.clone()));break;case 2:me=me!=null?me:new Array,Xe||(le=K[se].clone(),xe=ge(le,K[se+1]),ce=ge(le,K[se+2]),me.push(le),me.push(xe),me.push(ce)),xt||(le=K[se+1].clone(),xe=ge(le,K[se+2]),ce=ge(le,K[se]),me.push(le),me.push(xe),me.push(ce)),Dt||(le=K[se+2].clone(),xe=ge(le,K[se]),ce=ge(le,K[se+1]),me.push(le),me.push(xe),me.push(ce));break;case 3:break}}return me},w=e instanceof U?e:null,H=w==null?void 0:w._thinInstanceDataStorage.matrixData,O=(w==null?void 0:w.thinInstanceCount)||1,V=k.Matrix[0];V.copyFrom(G.IdentityReadOnly);for(let K=0;K{ve();bi();Rt();yt();Vt();hi();eW=new v(1,0,0),tW=new v(-1,0,0),iW=new v(0,1,0),rW=new v(0,-1,0),nW=new v(0,0,1),sW=new v(0,0,-1),Eu=class n{constructor(e=v.Zero(),t=v.Up(),i=_e.Zero(),r=0,s=0,a=null,o=null,l=null,c=null){this.position=e,this.normal=t,this.uv=i,this.vertexIdx=r,this.vertexIdxForBones=s,this.localPositionOverride=a,this.localNormalOverride=o,this.matrixIndicesOverride=l,this.matrixWeightsOverride=c}clone(){var e,t,i,r;return new n(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(),(r=this.matrixWeightsOverride)==null?void 0:r.slice())}};U.CreateDecal=(n,e,t,i,r,s)=>ev(n,e,{position:t,normal:i,size:r,angle:s})});function ry(n={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){let e=Math.max(n.subdivisions?n.subdivisions:2,1)|0,t=Math.max(n.tessellation?n.tessellation:16,3)|0,i=Math.max(n.height?n.height:1,0),r=Math.max(n.radius?n.radius:.25,0),s=Math.max(n.capSubdivisions?n.capSubdivisions:6,1)|0,a=t,o=e,l=Math.max(n.radiusTop?n.radiusTop:r,0),c=Math.max(n.radiusBottom?n.radiusBottom:r,0),f=i-(l+c),d=0,h=2*Math.PI,u=Math.max(n.topCapSubdivisions?n.topCapSubdivisions:s,1),m=Math.max(n.bottomCapSubdivisions?n.bottomCapSubdivisions:s,1),p=Math.acos((c-l)/i),_=[],g=[],T=[],b=[],R=0,S=[],I=f*.5,x=Math.PI*.5,P,L,y=v.Zero(),B=v.Zero(),w=Math.cos(p),H=Math.sin(p),O=new _e(l*H,I+l*w).subtract(new _e(c*H,-I+c*w)).length(),V=l*p+O+c*(x-p),X=0;for(L=0;L<=u;L++){let q=[],z=x-p*(L/u);X+=l*p/u;let K=Math.cos(z),J=Math.sin(z),te=K*l;for(P=0;P<=a;P++){let Pe=P/a,ge=Pe*h+d,me=Math.sin(ge),se=Math.cos(ge);B.x=te*me,B.y=I+J*l,B.z=te*se,g.push(B.x,B.y,B.z),y.set(K*me,J,K*se),T.push(y.x,y.y,y.z),b.push(Pe,He?X/V:1-X/V),q.push(R),R++}S.push(q)}let j=i-l-c+w*l-w*c,Q=H*(c-l)/j;for(L=1;L<=o;L++){let q=[];X+=O/o;let z=H*(L*(c-l)/o+l);for(P=0;P<=a;P++){let K=P/a,J=K*h+d,te=Math.sin(J),Pe=Math.cos(J);B.x=z*te,B.y=I+w*l-L*j/o,B.z=z*Pe,g.push(B.x,B.y,B.z),y.set(te,Q,Pe).normalize(),T.push(y.x,y.y,y.z),b.push(K,He?X/V:1-X/V),q.push(R),R++}S.push(q)}for(L=1;L<=m;L++){let q=[],z=x-p-(Math.PI-p)*(L/m);X+=c*p/m;let K=Math.cos(z),J=Math.sin(z),te=K*c;for(P=0;P<=a;P++){let Pe=P/a,ge=Pe*h+d,me=Math.sin(ge),se=Math.cos(ge);B.x=te*me,B.y=-I+J*c,B.z=te*se,g.push(B.x,B.y,B.z),y.set(K*me,J,K*se),T.push(y.x,y.y,y.z),b.push(Pe,He?X/V:1-X/V),q.push(R),R++}S.push(q)}for(P=0;P{Vt();ve();Rt();hi();U.CreateCapsule=(n,e,t)=>tv(n,e,t);de.CreateCapsule=ry});var Ot,sy=A(()=>{ze();ve();Ot=class n{constructor(e=0,t=0){this.x=e,this.y=t,e!==Math.floor(e)&&(e=Math.floor(e),W.Warn("x is not an integer, floor(x) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("y is not an integer, floor(y) used"))}clone(){return new n(this.x,this.y)}rotate60About(e){let t=this.x;return this.x=e.x+e.y-this.y,this.y=t+this.y-e.x,this}rotateNeg60About(e){let 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),W.Warn("m not an integer only floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("n not an integer only floor(n) used"));let 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),W.Warn("m is not an integer, floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("n is not an integer, floor(n) used"));let i=this.x;return this.x=this.y-t,this.y=e+t-i-this.y,this}toCartesianOrigin(e,t){let 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 n(0,0)}}});var tc,Gf,ic,iv=A(()=>{ve();bi();Ci();sy();tc=class{constructor(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new Gf("icosahedron","Regular",[[0,Wt,-1],[-Wt,1,0],[-1,0,-Wt],[1,0,-Wt],[Wt,1,0],[0,Wt,1],[-1,0,Wt],[-Wt,-1,0],[0,-Wt,-1],[Wt,-1,0],[1,0,Wt],[0,-Wt,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,t={},i=this.m,r=this.n,s=i;r!==0&&(s=nh(i,r));let a=i/s,o=r/s,l,c,f,d,h,u=Ot.Zero(),m=new Ot(i,r),p=new Ot(-r,i+r),_=Ot.Zero(),g=Ot.Zero(),T=Ot.Zero(),b=[],R,S,I,x,P=[],L=this.vertByDist,y=(B,w,H,O)=>{R=B+"|"+H,S=w+"|"+O,R in t||S in t?R in t&&!(S in t)?t[S]=t[R]:S in t&&!(R in t)&&(t[R]=t[S]):(t[R]=e,t[S]=e,e++),L[H][0]>2?P[t[R]]=[-L[H][0],L[H][1],t[R]]:P[t[R]]=[b[L[H][0]],L[H][1],t[R]]};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 B=0;B<20;B++){if(b=this.IDATA.face[B],f=b[2],d=b[1],h=b[0],I=u.x+"|"+u.y,R=B+"|"+I,R in t||(t[R]=f,P[f]=[b[L[I][0]],L[I][1]]),I=m.x+"|"+m.y,R=B+"|"+I,R in t||(t[R]=d,P[d]=[b[L[I][0]],L[I][1]]),I=p.x+"|"+p.y,R=B+"|"+I,R in t||(t[R]=h,P[h]=[b[L[I][0]],L[I][1]]),l=this.IDATA.edgematch[B][0],c=this.IDATA.edgematch[B][1],c==="B")for(let w=1;w2?P[t[R]]=[-L[I][0],L[I][1],t[R]]:P[t[R]]=[b[L[I][0]],L[I][1],t[R]])}this.closestTo=P,this.vecToidx=t}calcCoeffs(){let e=this.m,t=this.n,i=Math.sqrt(3)/3,r=e*e+t*t+e*t;this.coau=(e+t)/r,this.cobu=-t/r,this.coav=-i*(e-t)/r,this.cobv=i*(2*e+t)/r}createInnerFacets(){let e=this.m,t=this.n;for(let i=0;i0&&r0){let S=nh(e,t),I=e/S,x=t/S;for(let L=1;LS.x-I.x),i.sort((S,I)=>S.y-I.y);let o=new Array(e+t+1),l=new Array(e+t+1);for(let S=0;S{let x=S.clone();return I==="A"&&x.rotateNeg120(e,t),I==="B"&&x.rotate120(e,t),x.x<0?x.y:x.x+x.y},u=[],m=[],p=[],_=[],g={},T=[],b=-1,R=-1;for(let S=0;SS[2]-I[2]),T.sort((S,I)=>S[3]-I[3]),T.sort((S,I)=>S[1]-I[1]),T.sort((S,I)=>S[0]-I[0]);for(let S=0;St.vecToidx[e+r]))}mapABOBtoDATA(e,t){let i=t.IDATA.edgematch[e][0];for(let r=0;r-1?i[a][1]>0&&t[i[a][0]].push([a,i[a][1]]):t[12].push([a,i[a][0]]);let r=[];for(let a=0;a<12;a++)r[a]=a;let s=12;for(let a=0;a<12;a++){t[a].sort((o,l)=>o[1]-l[1]);for(let o=0;oa[3]-o[3]);for(let a=0;a0;)s=t[l],this.face[s].indexOf(o)>-1?(a=(this.face[s].indexOf(o)+1)%3,o=this.face[s][a],i.push(o),r.push(s),t.splice(l,1),l=0):l++;return this.adjacentFaces.push(i),r}toGoldbergPolyhedronData(){let e=new Gf("GeoDual","Goldberg",[],[]);e.name="GD dual";let t=this.vertex.length,i=new Array(t);for(let c=0;ci){let c=r;r=i,i=c,W.Warn("n > m therefore m and n swapped")}let s=new tc;s.build(i,r);let o={custom:ic.BuildGeodesicData(s),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 Vf(n,o,t)}var oy=A(()=>{JE();ze();iv()});var kf,ly=A(()=>{ve();yt();Rt();et();ze();U._GoldbergMeshParser=(n,e)=>kf.Parse(n,e);kf=class n extends U{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&&(W.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(W.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(W.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;i1&&(d=1),c.push(d,h);for(let u=0;u<6;u++)d=a.x+o*Math.cos(l+u*Math.PI/3),h=a.y+o*Math.sin(l+u*Math.PI/3),d<0&&(d=0),d>1&&(d=1),f.push(d,h);for(let u=r;uNe.FromArray(s)),i.faceCenters=i.faceCenters.map(s=>v.FromArray(s)),i.faceZaxis=i.faceZaxis.map(s=>v.FromArray(s)),i.faceXaxis=i.faceXaxis.map(s=>v.FromArray(s)),i.faceYaxis=i.faceYaxis.map(s=>v.FromArray(s));let r=new n(e.name,t);return r.goldbergData=i,r}}});function aW(n,e){let t=n.size,i=n.sizeX||t||1,r=n.sizeY||t||1,s=n.sizeZ||t||1,a=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,o=[],l=[],c=[],f=[],d=1/0,h=-1/0,u=1/0,m=-1/0;for(let g=0;go){let m=l;l=o,o=m,W.Warn("n > m therefore m and n swapped")}let c=new tc;c.build(o,l);let f=ic.BuildGeodesicData(c),d=f.toGoldbergPolyhedronData(),h=new kf(n,t);e.sideOrientation=U._GetDefaultSideOrientation(e.sideOrientation),h._originalBuilderSideOrientation=e.sideOrientation,aW(e,d).applyToMesh(h,e.updatable),h.goldbergData.nbSharedFaces=f.sharedNodes,h.goldbergData.nbUnsharedFaces=f.poleNodes,h.goldbergData.adjacentFaces=f.adjacentFaces,h.goldbergData.nbFaces=h.goldbergData.nbSharedFaces+h.goldbergData.nbUnsharedFaces,h.goldbergData.nbFacesAtPole=(h.goldbergData.nbUnsharedFaces-12)/12;for(let m=0;m{ve();et();Rt();Vt();ze();iv();ly();hi()});function oW(n,e,t,i,r,s){let a=s.glyphs[n]||s.glyphs["?"];if(!a)return null;let o=new rv(r);if(a.o){let l=a.o.split(" ");for(let c=0,f=l.length;c{uo();ve();Rt();yl();YE();rv=class{constructor(e){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=e}moveTo(e,t){this._currentPath=new cl(e,t),this._tempPaths.push(this._currentPath)}lineTo(e,t){this._currentPath.addLineTo(e,t)}quadraticCurveTo(e,t,i,r){this._currentPath.addQuadraticCurveTo(e,t,i,r,this._resolution)}bezierCurveTo(e,t,i,r,s,a){this._currentPath.addBezierCurveTo(e,t,i,r,s,a,this._resolution)}extractHoles(){for(let e of this._tempPaths)e.area()>0?this._holes.push(e):this._paths.push(e);if(!this._paths.length&&this._holes.length){let e=this._holes;this._holes=this._paths,this._paths=e}this._tempPaths.length=0}get paths(){return this._paths}get holes(){return this._holes}}});var zs,nv=A(()=>{If();wM();bE();HM();XM();KM();ZM();QM();z0();YE();j0();Z0();Q0();ME();xE();J0();JE();ty();iy();ny();oy();fy();hy();zs={CreateBox:CE,CreateTiledBox:WM,CreateSphere:DE,CreateDisc:TE,CreateIcoSphere:$E,CreateRibbon:En,CreateCylinder:LE,CreateTorus:PE,CreateTorusKnot:OE,CreateLineSystem:WE,CreateLines:HE,CreateDashedLines:zE,ExtrudeShape:KE,ExtrudeShapeCustom:jE,CreateLathe:ZE,CreateTiledPlane:GM,CreatePlane:qE,CreateGround:AE,CreateTiledGround:RE,CreateGroundFromHeightMap:IE,CreatePolygon:gu,ExtrudePolygon:Uf,CreateTube:QE,CreatePolyhedron:Vf,CreateGeodesic:ay,CreateGoldberg:cy,CreateDecal:ev,CreateCapsule:tv,CreateText:dy}});var cr,vu=A(()=>{cr=class{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,r,s){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]=r.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());let a=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==a.frameId&&(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=r.clone()}}}});var Zt,zr=A(()=>{Zt=class{constructor(e){if(this.VERTEXOUTPUT_INVARIANT=!1,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(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(let e of Object.keys(this))e[0]!=="_"&&this._keys.push(e);if(this._externalProperties)for(let 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{et();yt();Rt();BE();Fi();VE();V._LinesMeshParser=(n,e)=>yo.Parse(n,e);yo=class n extends V{_isShaderMaterial(e){return e?e.getClassName()==="ShaderMaterial":!1}constructor(e,t=null,i=null,r=null,s,a,o,l){super(e,t,i,r,s),this.useVertexColor=a,this.useVertexAlpha=o,this.color=new oe(1,1,1),this.alpha=1,this._shaderLanguage=0,this._ownsMaterial=!1,r&&(this.color=r.color.clone(),this.alpha=r.alpha,this.useVertexColor=r.useVertexColor,this.useVertexAlpha=r.useVertexAlpha),this.intersectionThreshold=.1;let c=[],f={attributes:[M.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:c,useClipPlane:null,shaderLanguage:0};if(this.useVertexAlpha?f.defines.push("#define VERTEXALPHA"):f.needAlphaBlending=!1,this.useVertexColor?(f.defines.push("#define VERTEXCOLOR"),f.attributes.push(M.ColorKind)):(f.uniforms.push("color"),this._color4=new Ne),l)this.material=l;else{this.getScene().getEngine().isWebGPU&&!n.ForceGLSL&&(this._shaderLanguage=1),f.shaderLanguage=this._shaderLanguage,f.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(v0(),E0)),Promise.resolve().then(()=>(C0(),x0))]):await Promise.all([Promise.resolve().then(()=>(G0(),V0)),Promise.resolve().then(()=>(K0(),Y0))])};let h=new Tn("colorShader",this.getScene(),"color",f,!1);h.doNotSerialize=!0,this._ownsMaterial=!0,this._setInternalMaterial(h)}}getClassName(){return"LinesMesh"}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){let t=this.material;if(t===e)return;let i=t&&this._ownsMaterial;this._ownsMaterial=!1,this._setInternalMaterial(e),i&&(t==null||t.dispose())}_setInternalMaterial(e){this._setMaterial(e),this.material&&(this.material.fillMode=ae.LineListDrawMode,this.material.disableLighting=!0)}get checkCollisions(){return!1}set checkCollisions(e){}_bind(e,t){if(!this._geometry)return this;let 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.material)){let{r,g:s,b:a}=this.color;this._color4.set(r,s,a,this.alpha),this.material.setColor4("color",this._color4)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;let r=this.getScene().getEngine();return this._unIndexed?r.drawArraysType(ae.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(ae.LineListDrawMode,e.indexStart,e.indexCount,i),this}dispose(e,t=!1,i){var r,s;i||(this._ownsMaterial?(r=this.material)==null||r.dispose(!1,!1,!0):t&&((s=this.material)==null||s.dispose(!1,!1,!0))),super.dispose(e)}clone(e,t=null,i){if(t&&t._addToSceneRootNodes===void 0){let r=t;return r.source=this,new n(e,this.getScene(),r.parent,r.source,r.doNotCloneChildren)}return new n(e,this.getScene(),t,this,i)}createInstance(e){let t=new zE(e,this);if(this.instancedBuffers){t.instancedBuffers={};for(let 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){let i=new n(e.name,t);return i.color=oe.FromArray(e.color),i.alpha=e.alpha,i}};yo.ForceGLSL=!1;zE=class extends xs{constructor(e,t){super(e,t),this.intersectionThreshold=t.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}});function Z0(n){let e=[],t=[],i=n.lines,r=n.colors,s=[],a=0;for(let l=0;l0&&(e.push(a-1),e.push(a)),a++}}let o=new de;return o.indices=e,o.positions=t,r&&(o.colors=s),o}function q0(n){let e=n.dashSize||3,t=n.gapSize||1,i=n.dashNb||200,r=n.points,s=[],a=[],o=v.Zero(),l=0,c,f,d=0,h;for(h=0;h{let d=v.Zero(),h=f.length/6,u=0,m,p,_=0,g,T;for(g=0;g{ve();Rt();Vt();j0();yt();ze();de.CreateLineSystem=Z0;de.CreateDashedLines=q0;V.CreateLines=(n,e,t=null,i=!1,r=null)=>YE(n,{points:e,updatable:i,instance:r},t);V.CreateDashedLines=(n,e,t,i,r,s=null,a,o)=>KE(n,{points:e,dashSize:t,gapSize:i,dashNb:r,updatable:a,instance:o},s)});var jE,Bf,gu,J0=A(()=>{ze();ve();yt();Rt();Vt();uo();bi();At();jE=class extends _e{constructor(e,t){super(e.x,e.y),this.index=t}},Bf=class{constructor(){this.elements=[]}add(e){let t=[];for(let i of e){let r=new jE(i,this.elements.length);t.push(r),this.elements.push(r)}return t}computeBounds(){let e=new _e(this.elements[0].x,this.elements[0].y),t=new _e(this.elements[0].x,this.elements[0].y);for(let i of this.elements)i.xt.x&&(t.x=i.x),i.yt.y&&(t.y=i.y);return{min:e,max:t,width:t.x-e.x,height:t.y-e.y}}},gu=class{_addToepoint(e){for(let t of e)this._epoints.push(t.x,t.y)}constructor(e,t,i,r=earcut){this._points=new Bf,this._outlinepoints=new Bf,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=r,this._name=e,this._scene=i||ue.LastCreatedScene;let s;t instanceof fl?s=t.getPoints():s=t,this._addToepoint(s),this._points.add(s),this._outlinepoints.add(s),typeof this.bjsEarcut=="undefined"&&W.Warn("Earcut was not found, the polygon will not be built.")}addHole(e){this._points.add(e);let t=new Bf;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){let r=new V(this._name,this._scene),s=this.buildVertexData(t,i);return r.setVerticesData(M.PositionKind,s.positions,e),r.setVerticesData(M.NormalKind,s.normals,e),r.setVerticesData(M.UVKind,s.uvs,e),r.setIndices(s.indices),r}buildVertexData(e=0,t=2){let i=new de,r=[],s=[],a=[],o=this._points.computeBounds();for(let f of this._points.elements)r.push(0,1,0),s.push(f.x,0,f.y),a.push((f.x-o.min.x)/o.width,(f.y-o.min.y)/o.height);let l=[],c=this.bjsEarcut(this._epoints,this._eholes,2);for(let f=0;f0){let f=s.length/3;for(let h of this._points.elements)r.push(0,-1,0),s.push(h.x,-e,h.y),a.push(1-(h.x-o.min.x)/o.width,1-(h.y-o.min.y)/o.height);let d=l.length;for(let h=0;hc?xc?P{ve();et();Rt();Vt();J0();yt();At();ui();de.CreatePolygon=$0;V.CreatePolygon=(n,e,t,i,r,s,a=earcut)=>Eu(n,{shape:e,holes:i,updatable:r,sideOrientation:s},t,a);V.ExtrudePolygon=(n,e,t,i,r,s,a,o=earcut)=>Uf(n,{shape:e,holes:r,depth:t,updatable:s,sideOrientation:a},i,o)});function qE(n,e,t=null){let i=e.path,r=e.shape,s=e.scale||1,a=e.rotation||0,o=e.cap===0?0:e.cap||V.NO_CAP,l=e.updatable,c=V._GetDefaultSideOrientation(e.sideOrientation),f=e.instance||null,d=e.invertUV||!1,h=e.closeShape||!1,u=e.closePath||!1,m=e.capFunction||null;return ey(n,r,i,s,a,null,null,u,h,o,!1,t,!!l,c,f,d,e.frontUVs||null,e.backUVs||null,e.firstNormal||null,!!e.adjustFrame,m)}function QE(n,e,t=null){var T;let i=e.path,r=e.shape,s=v.Zero(),a=(b,R)=>{var I,x;let S=(x=(I=e.scaleFunction)==null?void 0:I.call(e,b,R))!=null?x:1;return s.copyFromFloats(S,S,S)},o=e.rotationFunction||(()=>0),l=e.closePath||e.ribbonCloseArray||!1,c=e.closeShape||e.ribbonClosePath||!1,f=e.cap===0?0:e.cap||V.NO_CAP,d=e.updatable,h=e.firstNormal||null,u=e.adjustFrame||!1,m=V._GetDefaultSideOrientation(e.sideOrientation),p=e.instance,_=e.invertUV||!1,g=e.capFunction||null;return ey(n,r,i,null,null,(T=e.scaleVectorFunction)!=null?T:a,o,l,c,f,!0,t,!!d,m,p||null,_,e.frontUVs||null,e.backUVs||null,h,u,g||null)}function ey(n,e,t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g,T,b,R){let S=(B,w,H,O,k,X,j,Q,$,q,z)=>{let K=H.getTangents(),J=H.getNormals(),te=H.getBinormals(),Pe=H.getDistances();if(z){for(let Fe=0;Fe0){let Xe=K[Fe-1];v.Dot(Xe,K[Fe])<0&&K[Fe].scaleInPlace(-1),Xe=J[Fe-1],v.Dot(Xe,J[Fe])<0&&J[Fe].scaleInPlace(-1),Xe=te[Fe-1],v.Dot(Xe,te[Fe])<0&&te[Fe].scaleInPlace(-1)}}let ge=0,me=()=>k!==null?k:v.OneReadOnly,le=q&&Q?Q:()=>X!==null?X:0,xe=q&&j?j:me,ce=$===V.NO_CAP||$===V.CAP_END?0:2,he=G.Matrix[0];for(let Fe=0;Fe{let Xe=Array(),xt=v.Zero(),Dt;for(Dt=0;Dt3?0:c,x=S(e,t,P,L,I,r,s,a,c,f,b);let y=vn(n,{pathArray:x,closeArray:o,closePath:l,updatable:h,sideOrientation:u,invertUV:p,frontUVs:_||void 0,backUVs:g||void 0},d);return y._creationDataStorage.pathArray=x,y._creationDataStorage.path3D=P,y._creationDataStorage.cap=c,y}var ty=A(()=>{ve();Rt();If();uo();V.ExtrudeShape=(n,e,t,i,r,s,a=null,o,l,c)=>{let f={shape:e,path:t,scale:i,rotation:r,cap:s===0?0:s||V.NO_CAP,sideOrientation:l,instance:c,updatable:o};return qE(n,f,a)};V.ExtrudeShapeCustom=(n,e,t,i,r,s,a,o,l,c,f,d)=>{let h={shape:e,path:t,scaleFunction:i,rotationFunction:r,ribbonCloseArray:s,ribbonClosePath:a,cap:o===0?0:o||V.NO_CAP,sideOrientation:f,instance:d,updatable:c};return QE(n,h,l)}});function JE(n,e,t=null){let i=e.arc?e.arc<=0||e.arc>1?1:e.arc:1,r=e.closed===void 0?!0:e.closed,s=e.shape,a=e.radius||1,o=e.tessellation||64,l=e.clip||0,c=e.updatable,f=V._GetDefaultSideOrientation(e.sideOrientation),d=e.cap||V.NO_CAP,h=Math.PI*2,u=[],m=e.invertUV||!1,p,_,g=h/o*i,T,b;for(p=0;p<=o-l;p++){for(b=[],(d==V.CAP_START||d==V.CAP_ALL)&&(b.push(new v(0,s[0].y,0)),b.push(new v(Math.cos(p*g)*s[0].x*a,s[0].y,Math.sin(p*g)*s[0].x*a))),_=0;_{ve();Rt();If();V.CreateLathe=(n,e,t,i,r,s,a)=>JE(n,{shape:e,radius:t,tessellation:i,sideOrientation:a,updatable:s},r)});function ry(n){let e=[],t=[],i=[],r=[],s=n.width!==void 0?n.width:n.size!==void 0?n.size:1,a=n.height!==void 0?n.height:n.size!==void 0?n.size:1,o=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,l=s/2,c=a/2;t.push(-l,-c,0),i.push(0,0,-1),r.push(0,He?1:0),t.push(l,-c,0),i.push(0,0,-1),r.push(1,He?1:0),t.push(l,c,0),i.push(0,0,-1),r.push(1,He?0:1),t.push(-l,c,0),i.push(0,0,-1),r.push(0,He?0:1),e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),de._ComputeSides(o,t,e,i,r,n.frontUVs,n.backUVs);let f=new de;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function $E(n,e={},t=null){let i=new V(n,t);return e.sideOrientation=V._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,ry(e).applyToMesh(i,e.updatable),e.sourcePlane&&(i.translate(e.sourcePlane.normal,-e.sourcePlane.d),i.setDirection(e.sourcePlane.normal.scale(-1))),i}var ny=A(()=>{Rt();Vt();ui();de.CreatePlane=ry;V.CreatePlane=(n,e,t,i,r)=>$E(n,{size:e,width:e,height:e,sideOrientation:r,updatable:i},t)});function ev(n,e,t=null){let i=e.path,r=e.instance,s=1;e.radius!==void 0?s=e.radius:r&&(s=r._creationDataStorage.radius);let a=e.tessellation||64,o=e.radiusFunction||null,l=e.cap||V.NO_CAP,c=e.invertUV||!1,f=e.updatable,d=V._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;let h=(g,T,b,R,S,I,x,P)=>{let L=T.getTangents(),y=T.getNormals(),B=T.getDistances(),H=Math.PI*2/S*P,k=I||(()=>R),X,j,Q,$,q=G.Matrix[0],z=x===V.NO_CAP||x===V.CAP_END?0:2;for(let J=0;J{let Pe=Array();for(let ge=0;ge3?0:l,m=h(i,u,p,s,a,o,l,e.arc);let _=vn(n,{pathArray:m,closePath:!0,closeArray:!1,updatable:f,sideOrientation:d,invertUV:c,frontUVs:e.frontUVs,backUVs:e.backUVs},t);return _._creationDataStorage.pathArray=m,_._creationDataStorage.path3D=u,_._creationDataStorage.tessellation=a,_._creationDataStorage.cap=l,_._creationDataStorage.arc=e.arc,_._creationDataStorage.radius=s,_}var sy=A(()=>{ve();Rt();If();uo();V.CreateTube=(n,e,t,i,r,s,a,o,l,c)=>ev(n,{path:e,radius:t,tessellation:i,radiusFunction:r,arc:1,cap:s,updatable:o,sideOrientation:l,instance:c},a)});function ay(n){let 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]]};let t=n.type&&(n.type<0||n.type>=e.length)?0:n.type||0,i=n.size,r=n.sizeX||i||1,s=n.sizeY||i||1,a=n.sizeZ||i||1,o=n.custom||e[t],l=o.face.length,c=n.faceUV||new Array(l),f=n.faceColors,d=n.flat===void 0?!0:n.flat,h=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,u=[],m=[],p=[],_=[],g=[],T=0,b=0,R=[],S,I,x,P,L,y,B,w;if(d)for(I=0;I{ve();et();Rt();Vt();ui();de.CreatePolyhedron=ay;V.CreatePolyhedron=(n,e,t)=>Vf(n,e,t)});function oy(n){let e=n.sideOrientation||de.DEFAULTSIDE,t=n.radius||1,i=n.flat===void 0?!0:n.flat,r=(n.subdivisions||4)|0,s=n.radiusX||t,a=n.radiusY||t,o=n.radiusZ||t,l=(1+Math.sqrt(5))/2,c=[-1,l,-0,1,l,0,-1,-l,0,1,-l,0,0,-1,-l,0,1,-l,0,-1,l,0,1,l,l,0,1,l,0,-1,-l,0,1,-l,0,-1],f=[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],d=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],h=[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],u=138/1024,m=239/1024,p=60/1024,_=26/1024,g=-40/1024,T=20/1024,b=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],R=[],S=[],I=[],x=[],P=0,L=new Array(3),y=new Array(3),B;for(B=0;B<3;B++)L[B]=v.Zero(),y[B]=_e.Zero();for(let H=0;H<20;H++){for(B=0;B<3;B++){let k=f[3*H+B];L[B].copyFromFloats(c[3*d[k]],c[3*d[k]+1],c[3*d[k]+2]),L[B].normalize(),y[B].copyFromFloats(h[2*k]*u+p+b[H]*g,h[2*k+1]*m+_+b[H]*T)}let O=(k,X,j,Q)=>{let $=v.Lerp(L[0],L[2],X/r),q=v.Lerp(L[1],L[2],X/r),z=r===X?L[2]:v.Lerp($,q,k/(r-X));z.normalize();let K;if(i){let ge=v.Lerp(L[0],L[2],Q/r),me=v.Lerp(L[1],L[2],Q/r);K=v.Lerp(ge,me,j/(r-Q))}else K=new v(z.x,z.y,z.z);K.x/=s,K.y/=a,K.z/=o,K.normalize();let J=_e.Lerp(y[0],y[2],X/r),te=_e.Lerp(y[1],y[2],X/r),Pe=r===X?y[2]:_e.Lerp(J,te,k/(r-X));S.push(z.x*s,z.y*a,z.z*o),I.push(K.x,K.y,K.z),x.push(Pe.x,He?1-Pe.y:Pe.y),R.push(P),P++};for(let k=0;k{ve();Rt();Vt();ui();de.CreateIcoSphere=oy;V.CreateIcoSphere=(n,e,t)=>iv(n,e,t)});function rv(n,e,t){var j,Q,$,q,z;let i=!!e.skeleton,r=!!((j=e.morphTargetManager)!=null&&j.numTargets),s=t.localMode||i,a=e.getIndices(),o=i||r?e.getPositionData(!0,!0):e.getVerticesData(M.PositionKind),l=i||r?e.getNormalsData(!0,!0):e.getVerticesData(M.NormalKind),c=s?i?e.getVerticesData(M.PositionKind):o:null,f=s?i?e.getVerticesData(M.NormalKind):l:null,d=e.getVerticesData(M.UVKind),h=i?e.getVerticesData(M.MatricesIndicesKind):null,u=i?e.getVerticesData(M.MatricesWeightsKind):null,m=i?e.getVerticesData(M.MatricesIndicesExtraKind):null,p=i?e.getVerticesData(M.MatricesWeightsExtraKind):null,_=t.position||v.Zero(),g=t.normal||v.Up(),T=t.size||v.One(),b=t.angle||0;if(!g){let K=new v(0,0,1),J=e.getScene().activeCamera,te=v.TransformCoordinates(K,J.getWorldMatrix());g=J.globalPosition.subtract(te)}let R=-Math.atan2(g.z,g.x)-Math.PI/2,S=Math.sqrt(g.x*g.x+g.z*g.z),I=Math.atan2(g.y,S),x=new de;x.indices=[],x.positions=[],x.normals=[],x.uvs=[],x.matricesIndices=i?[]:null,x.matricesWeights=i?[]:null,x.matricesIndicesExtra=m?[]:null,x.matricesWeightsExtra=p?[]:null;let P=0,L=(K,J)=>{let te=new vu;if(!a||!o||!l)return te;let Pe=a[K];if(te.vertexIdx=Pe*3,te.vertexIdxForBones=Pe*4,te.position=new v(o[Pe*3],o[Pe*3+1],o[Pe*3+2]),v.TransformCoordinatesToRef(te.position,J,te.position),te.normal=new v(l[Pe*3],l[Pe*3+1],l[Pe*3+2]),v.TransformNormalToRef(te.normal,J,te.normal),t.captureUVS&&d){let ge=d[Pe*2+1];te.uv=new _e(d[Pe*2],He?1-ge:ge)}return te},y=[0,0,0,0],B=(K,J)=>{if(K.length===0)return K;let te=.5*Math.abs(v.Dot(T,J)),Pe=(se,le,xe,ce)=>{for(let he=0;he{var tR,iR,rR,nR,sR,aR,oR,lR,cR,fR,dR,hR,uR,mR,pR,_R;let xe=v.GetClipFactor(se.position,le.position,J,te),ce=y,he=y;if(h&&u){let Uc=se.matrixIndicesOverride?0:se.vertexIdxForBones,zp=(tR=se.matrixIndicesOverride)!=null?tR:h,gR=(iR=se.matrixWeightsOverride)!=null?iR:u,Xp=le.matrixIndicesOverride?0:le.vertexIdxForBones,ER=(rR=le.matrixIndicesOverride)!=null?rR:h,vR=(nR=le.matrixWeightsOverride)!=null?nR:u;ce=[0,0,0,0],he=[0,0,0,0];let eo=0;for(let tn=0;tn<4;++tn)if(gR[Uc+tn]>0){let Vc=Pe(ER,zp[Uc+tn],Xp,4);ce[eo]=zp[Uc+tn],he[eo]=nn(gR[Uc+tn],Vc>=0?vR[Vc]:0,xe),eo++}for(let tn=0;tn<4&&eo<4;++tn){let Vc=ER[Xp+tn];Pe(zp,Vc,Uc,4)===-1&&(ce[eo]=Vc,he[eo]=nn(0,vR[Xp+tn],xe),eo++)}let bd=he[0]+he[1]+he[2]+he[3];he[0]/=bd,he[1]/=bd,he[2]/=bd,he[3]/=bd}let ke=se.localPositionOverride?se.localPositionOverride[0]:(sR=c==null?void 0:c[se.vertexIdx])!=null?sR:0,$e=se.localPositionOverride?se.localPositionOverride[1]:(aR=c==null?void 0:c[se.vertexIdx+1])!=null?aR:0,Fe=se.localPositionOverride?se.localPositionOverride[2]:(oR=c==null?void 0:c[se.vertexIdx+2])!=null?oR:0,Xe=le.localPositionOverride?le.localPositionOverride[0]:(lR=c==null?void 0:c[le.vertexIdx])!=null?lR:0,xt=le.localPositionOverride?le.localPositionOverride[1]:(cR=c==null?void 0:c[le.vertexIdx+1])!=null?cR:0,Dt=le.localPositionOverride?le.localPositionOverride[2]:(fR=c==null?void 0:c[le.vertexIdx+2])!=null?fR:0,Yt=se.localNormalOverride?se.localNormalOverride[0]:(dR=f==null?void 0:f[se.vertexIdx])!=null?dR:0,hi=se.localNormalOverride?se.localNormalOverride[1]:(hR=f==null?void 0:f[se.vertexIdx+1])!=null?hR:0,Er=se.localNormalOverride?se.localNormalOverride[2]:(uR=f==null?void 0:f[se.vertexIdx+2])!=null?uR:0,Cd=le.localNormalOverride?le.localNormalOverride[0]:(mR=f==null?void 0:f[le.vertexIdx])!=null?mR:0,nV=le.localNormalOverride?le.localNormalOverride[1]:(pR=f==null?void 0:f[le.vertexIdx+1])!=null?pR:0,sV=le.localNormalOverride?le.localNormalOverride[2]:(_R=f==null?void 0:f[le.vertexIdx+2])!=null?_R:0,Gp=Yt+(Cd-Yt)*xe,kp=hi+(nV-hi)*xe,Wp=Er+(sV-Er)*xe,Hp=Math.sqrt(Gp*Gp+kp*kp+Wp*Wp);return new vu(v.Lerp(se.position,le.position,xe),v.Lerp(se.normal,le.normal,xe).normalize(),_e.Lerp(se.uv,le.uv,xe),-1,-1,c?[ke+(Xe-ke)*xe,$e+(xt-$e)*xe,Fe+(Dt-Fe)*xe]:null,f?[Gp/Hp,kp/Hp,Wp/Hp]:null,ce,he)},me=null;K.length>3&&(me=[]);for(let se=0;se0,xt=$e>0,Dt=Fe>0;switch((Xe?1:0)+(xt?1:0)+(Dt?1:0)){case 0:K.length>3?(me.push(K[se]),me.push(K[se+1]),me.push(K[se+2])):me=K;break;case 1:if(me=me!=null?me:new Array,Xe&&(le=K[se+1],xe=K[se+2],ce=ge(K[se],le),he=ge(K[se],xe)),xt){le=K[se],xe=K[se+2],ce=ge(K[se+1],le),he=ge(K[se+1],xe),me.push(ce),me.push(xe.clone()),me.push(le.clone()),me.push(xe.clone()),me.push(ce.clone()),me.push(he);break}Dt&&(le=K[se],xe=K[se+1],ce=ge(K[se+2],le),he=ge(K[se+2],xe)),le&&xe&&ce&&he&&(me.push(le.clone()),me.push(xe.clone()),me.push(ce),me.push(he),me.push(ce.clone()),me.push(xe.clone()));break;case 2:me=me!=null?me:new Array,Xe||(le=K[se].clone(),xe=ge(le,K[se+1]),ce=ge(le,K[se+2]),me.push(le),me.push(xe),me.push(ce)),xt||(le=K[se+1].clone(),xe=ge(le,K[se+2]),ce=ge(le,K[se]),me.push(le),me.push(xe),me.push(ce)),Dt||(le=K[se+2].clone(),xe=ge(le,K[se]),ce=ge(le,K[se+1]),me.push(le),me.push(xe),me.push(ce));break;case 3:break}}return me},w=e instanceof V?e:null,H=w==null?void 0:w._thinInstanceDataStorage.matrixData,O=(w==null?void 0:w.thinInstanceCount)||1,k=G.Matrix[0];k.copyFrom(U.IdentityReadOnly);for(let K=0;K{ve();Mi();Rt();yt();Vt();ui();vW=new v(1,0,0),TW=new v(-1,0,0),SW=new v(0,1,0),AW=new v(0,-1,0),RW=new v(0,0,1),IW=new v(0,0,-1),vu=class n{constructor(e=v.Zero(),t=v.Up(),i=_e.Zero(),r=0,s=0,a=null,o=null,l=null,c=null){this.position=e,this.normal=t,this.uv=i,this.vertexIdx=r,this.vertexIdxForBones=s,this.localPositionOverride=a,this.localNormalOverride=o,this.matrixIndicesOverride=l,this.matrixWeightsOverride=c}clone(){var e,t,i,r;return new n(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(),(r=this.matrixWeightsOverride)==null?void 0:r.slice())}};V.CreateDecal=(n,e,t,i,r,s)=>rv(n,e,{position:t,normal:i,size:r,angle:s})});function fy(n={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){let e=Math.max(n.subdivisions?n.subdivisions:2,1)|0,t=Math.max(n.tessellation?n.tessellation:16,3)|0,i=Math.max(n.height?n.height:1,0),r=Math.max(n.radius?n.radius:.25,0),s=Math.max(n.capSubdivisions?n.capSubdivisions:6,1)|0,a=t,o=e,l=Math.max(n.radiusTop?n.radiusTop:r,0),c=Math.max(n.radiusBottom?n.radiusBottom:r,0),f=i-(l+c),d=0,h=2*Math.PI,u=Math.max(n.topCapSubdivisions?n.topCapSubdivisions:s,1),m=Math.max(n.bottomCapSubdivisions?n.bottomCapSubdivisions:s,1),p=Math.acos((c-l)/i),_=[],g=[],T=[],b=[],R=0,S=[],I=f*.5,x=Math.PI*.5,P,L,y=v.Zero(),B=v.Zero(),w=Math.cos(p),H=Math.sin(p),O=new _e(l*H,I+l*w).subtract(new _e(c*H,-I+c*w)).length(),k=l*p+O+c*(x-p),X=0;for(L=0;L<=u;L++){let q=[],z=x-p*(L/u);X+=l*p/u;let K=Math.cos(z),J=Math.sin(z),te=K*l;for(P=0;P<=a;P++){let Pe=P/a,ge=Pe*h+d,me=Math.sin(ge),se=Math.cos(ge);B.x=te*me,B.y=I+J*l,B.z=te*se,g.push(B.x,B.y,B.z),y.set(K*me,J,K*se),T.push(y.x,y.y,y.z),b.push(Pe,He?X/k:1-X/k),q.push(R),R++}S.push(q)}let j=i-l-c+w*l-w*c,Q=H*(c-l)/j;for(L=1;L<=o;L++){let q=[];X+=O/o;let z=H*(L*(c-l)/o+l);for(P=0;P<=a;P++){let K=P/a,J=K*h+d,te=Math.sin(J),Pe=Math.cos(J);B.x=z*te,B.y=I+w*l-L*j/o,B.z=z*Pe,g.push(B.x,B.y,B.z),y.set(te,Q,Pe).normalize(),T.push(y.x,y.y,y.z),b.push(K,He?X/k:1-X/k),q.push(R),R++}S.push(q)}for(L=1;L<=m;L++){let q=[],z=x-p-(Math.PI-p)*(L/m);X+=c*p/m;let K=Math.cos(z),J=Math.sin(z),te=K*c;for(P=0;P<=a;P++){let Pe=P/a,ge=Pe*h+d,me=Math.sin(ge),se=Math.cos(ge);B.x=te*me,B.y=-I+J*c,B.z=te*se,g.push(B.x,B.y,B.z),y.set(K*me,J,K*se),T.push(y.x,y.y,y.z),b.push(Pe,He?X/k:1-X/k),q.push(R),R++}S.push(q)}for(P=0;P{Vt();ve();Rt();ui();V.CreateCapsule=(n,e,t)=>nv(n,e,t);de.CreateCapsule=fy});var Ot,hy=A(()=>{ze();ve();Ot=class n{constructor(e=0,t=0){this.x=e,this.y=t,e!==Math.floor(e)&&(e=Math.floor(e),W.Warn("x is not an integer, floor(x) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("y is not an integer, floor(y) used"))}clone(){return new n(this.x,this.y)}rotate60About(e){let t=this.x;return this.x=e.x+e.y-this.y,this.y=t+this.y-e.x,this}rotateNeg60About(e){let 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),W.Warn("m not an integer only floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("n not an integer only floor(n) used"));let 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),W.Warn("m is not an integer, floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),W.Warn("n is not an integer, floor(n) used"));let i=this.x;return this.x=this.y-t,this.y=e+t-i-this.y,this}toCartesianOrigin(e,t){let 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 n(0,0)}}});var tc,Gf,ic,sv=A(()=>{ve();Mi();bi();hy();tc=class{constructor(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new Gf("icosahedron","Regular",[[0,Wt,-1],[-Wt,1,0],[-1,0,-Wt],[1,0,-Wt],[Wt,1,0],[0,Wt,1],[-1,0,Wt],[-Wt,-1,0],[0,-Wt,-1],[Wt,-1,0],[1,0,Wt],[0,-Wt,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,t={},i=this.m,r=this.n,s=i;r!==0&&(s=sh(i,r));let a=i/s,o=r/s,l,c,f,d,h,u=Ot.Zero(),m=new Ot(i,r),p=new Ot(-r,i+r),_=Ot.Zero(),g=Ot.Zero(),T=Ot.Zero(),b=[],R,S,I,x,P=[],L=this.vertByDist,y=(B,w,H,O)=>{R=B+"|"+H,S=w+"|"+O,R in t||S in t?R in t&&!(S in t)?t[S]=t[R]:S in t&&!(R in t)&&(t[R]=t[S]):(t[R]=e,t[S]=e,e++),L[H][0]>2?P[t[R]]=[-L[H][0],L[H][1],t[R]]:P[t[R]]=[b[L[H][0]],L[H][1],t[R]]};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 B=0;B<20;B++){if(b=this.IDATA.face[B],f=b[2],d=b[1],h=b[0],I=u.x+"|"+u.y,R=B+"|"+I,R in t||(t[R]=f,P[f]=[b[L[I][0]],L[I][1]]),I=m.x+"|"+m.y,R=B+"|"+I,R in t||(t[R]=d,P[d]=[b[L[I][0]],L[I][1]]),I=p.x+"|"+p.y,R=B+"|"+I,R in t||(t[R]=h,P[h]=[b[L[I][0]],L[I][1]]),l=this.IDATA.edgematch[B][0],c=this.IDATA.edgematch[B][1],c==="B")for(let w=1;w2?P[t[R]]=[-L[I][0],L[I][1],t[R]]:P[t[R]]=[b[L[I][0]],L[I][1],t[R]])}this.closestTo=P,this.vecToidx=t}calcCoeffs(){let e=this.m,t=this.n,i=Math.sqrt(3)/3,r=e*e+t*t+e*t;this.coau=(e+t)/r,this.cobu=-t/r,this.coav=-i*(e-t)/r,this.cobv=i*(2*e+t)/r}createInnerFacets(){let e=this.m,t=this.n;for(let i=0;i0&&r0){let S=sh(e,t),I=e/S,x=t/S;for(let L=1;LS.x-I.x),i.sort((S,I)=>S.y-I.y);let o=new Array(e+t+1),l=new Array(e+t+1);for(let S=0;S{let x=S.clone();return I==="A"&&x.rotateNeg120(e,t),I==="B"&&x.rotate120(e,t),x.x<0?x.y:x.x+x.y},u=[],m=[],p=[],_=[],g={},T=[],b=-1,R=-1;for(let S=0;SS[2]-I[2]),T.sort((S,I)=>S[3]-I[3]),T.sort((S,I)=>S[1]-I[1]),T.sort((S,I)=>S[0]-I[0]);for(let S=0;St.vecToidx[e+r]))}mapABOBtoDATA(e,t){let i=t.IDATA.edgematch[e][0];for(let r=0;r-1?i[a][1]>0&&t[i[a][0]].push([a,i[a][1]]):t[12].push([a,i[a][0]]);let r=[];for(let a=0;a<12;a++)r[a]=a;let s=12;for(let a=0;a<12;a++){t[a].sort((o,l)=>o[1]-l[1]);for(let o=0;oa[3]-o[3]);for(let a=0;a0;)s=t[l],this.face[s].indexOf(o)>-1?(a=(this.face[s].indexOf(o)+1)%3,o=this.face[s][a],i.push(o),r.push(s),t.splice(l,1),l=0):l++;return this.adjacentFaces.push(i),r}toGoldbergPolyhedronData(){let e=new Gf("GeoDual","Goldberg",[],[]);e.name="GD dual";let t=this.vertex.length,i=new Array(t);for(let c=0;ci){let c=r;r=i,i=c,W.Warn("n > m therefore m and n swapped")}let s=new tc;s.build(i,r);let o={custom:ic.BuildGeodesicData(s),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 Vf(n,o,t)}var my=A(()=>{tv();ze();sv()});var kf,py=A(()=>{ve();yt();Rt();et();ze();V._GoldbergMeshParser=(n,e)=>kf.Parse(n,e);kf=class n extends V{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&&(W.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(W.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(W.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;i1&&(d=1),c.push(d,h);for(let u=0;u<6;u++)d=a.x+o*Math.cos(l+u*Math.PI/3),h=a.y+o*Math.sin(l+u*Math.PI/3),d<0&&(d=0),d>1&&(d=1),f.push(d,h);for(let u=r;uNe.FromArray(s)),i.faceCenters=i.faceCenters.map(s=>v.FromArray(s)),i.faceZaxis=i.faceZaxis.map(s=>v.FromArray(s)),i.faceXaxis=i.faceXaxis.map(s=>v.FromArray(s)),i.faceYaxis=i.faceYaxis.map(s=>v.FromArray(s));let r=new n(e.name,t);return r.goldbergData=i,r}}});function xW(n,e){let t=n.size,i=n.sizeX||t||1,r=n.sizeY||t||1,s=n.sizeZ||t||1,a=n.sideOrientation===0?0:n.sideOrientation||de.DEFAULTSIDE,o=[],l=[],c=[],f=[],d=1/0,h=-1/0,u=1/0,m=-1/0;for(let g=0;go){let m=l;l=o,o=m,W.Warn("n > m therefore m and n swapped")}let c=new tc;c.build(o,l);let f=ic.BuildGeodesicData(c),d=f.toGoldbergPolyhedronData(),h=new kf(n,t);e.sideOrientation=V._GetDefaultSideOrientation(e.sideOrientation),h._originalBuilderSideOrientation=e.sideOrientation,xW(e,d).applyToMesh(h,e.updatable),h.goldbergData.nbSharedFaces=f.sharedNodes,h.goldbergData.nbUnsharedFaces=f.poleNodes,h.goldbergData.adjacentFaces=f.adjacentFaces,h.goldbergData.nbFaces=h.goldbergData.nbSharedFaces+h.goldbergData.nbUnsharedFaces,h.goldbergData.nbFacesAtPole=(h.goldbergData.nbUnsharedFaces-12)/12;for(let m=0;m{ve();et();Rt();Vt();ze();sv();py();ui()});function CW(n,e,t,i,r,s){let a=s.glyphs[n]||s.glyphs["?"];if(!a)return null;let o=new av(r);if(a.o){let l=a.o.split(" ");for(let c=0,f=l.length;c{uo();ve();Rt();yl();ZE();av=class{constructor(e){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=e}moveTo(e,t){this._currentPath=new fl(e,t),this._tempPaths.push(this._currentPath)}lineTo(e,t){this._currentPath.addLineTo(e,t)}quadraticCurveTo(e,t,i,r){this._currentPath.addQuadraticCurveTo(e,t,i,r,this._resolution)}bezierCurveTo(e,t,i,r,s,a){this._currentPath.addBezierCurveTo(e,t,i,r,s,a,this._resolution)}extractHoles(){for(let e of this._tempPaths)e.area()>0?this._holes.push(e):this._paths.push(e);if(!this._paths.length&&this._holes.length){let e=this._holes;this._holes=this._paths,this._paths=e}this._tempPaths.length=0}get paths(){return this._paths}get holes(){return this._holes}}});var zs,ov=A(()=>{If();HM();DE();qM();JM();e0();i0();n0();Q0();ZE();ty();iy();ny();LE();ME();sy();tv();ly();cy();dy();my();gy();vy();zs={CreateBox:yE,CreateTiledBox:ZM,CreateSphere:OE,CreateDisc:RE,CreateIcoSphere:iv,CreateRibbon:vn,CreateCylinder:NE,CreateTorus:FE,CreateTorusKnot:wE,CreateLineSystem:XE,CreateLines:YE,CreateDashedLines:KE,ExtrudeShape:qE,ExtrudeShapeCustom:QE,CreateLathe:JE,CreateTiledPlane:KM,CreatePlane:$E,CreateGround:xE,CreateTiledGround:CE,CreateGroundFromHeightMap:bE,CreatePolygon:Eu,ExtrudePolygon:Uf,CreateTube:ev,CreatePolyhedron:Vf,CreateGeodesic:uy,CreateGoldberg:_y,CreateDecal:rv,CreateCapsule:nv,CreateText:Ey}});var hr,Tu=A(()=>{hr=class{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,r,s){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]=r.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());let a=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==a.frameId&&(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=r.clone()}}}});var Zt,Yr=A(()=>{Zt=class{constructor(e){if(this.VERTEXOUTPUT_INVARIANT=!1,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(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(let e of Object.keys(this))e[0]!=="_"&&this._keys.push(e);if(this._externalProperties)for(let 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{zr()});function hW(){fW.length=0,dW=!1,ae.OnEventObservable.remove(uy),uy=null}var cW,nc,fW,dW,uy,my=A(()=>{Ni();At();zd();N();cW=new RegExp("^([gimus]+)!"),nc=class n{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let r=0;rthis._handlePluginEvent(r,s),this._plugins.push(e),this._plugins.sort((r,s)=>r.priority-s.priority),this._codeInjectionPoints={};let i={};i[n._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(let r of this._plugins)r.collectDefines(i),this._collectPointNames("vertex",r.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",r.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;t0&&r.uniforms.push(...this._uniformList),this._samplerList.length>0&&r.samplers.push(...this._samplerList),this._uboList.length>0&&r.uniformBuffersNames.push(...this._uboList),r.customCode=this._injectCustomCode(r,r.customCode);break}case 8:{let r=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];let s=this._material.shaderLanguage===1;for(let a of this._plugins){let o=a.getUniforms(this._material.shaderLanguage);if(o){if(o.ubo)for(let l of o.ubo){if(l.size&&l.type){let c=(i=l.arraySize)!=null?i:0;if(r.ubo.addUniform(l.name,l.size,c),s){let f;switch(l.type){case"mat4":f="mat4x4f";break;case"float":f="f32";break;default:f=`${l.type}f`;break}c>0?this._uboDeclaration+=`uniform ${l.name}: array<${f}, ${c}>; +`);break}}return e}}});function rc(n){return class extends n{constructor(){super(...arguments),this.IMAGEPROCESSING=!1,this.VIGNETTE=!1,this.VIGNETTEBLENDMODEMULTIPLY=!1,this.VIGNETTEBLENDMODEOPAQUE=!1,this.TONEMAPPING=0,this.CONTRAST=!1,this.COLORCURVES=!1,this.COLORGRADING=!1,this.COLORGRADING3D=!1,this.SAMPLER3DGREENDEPTH=!1,this.SAMPLER3DBGRMAP=!1,this.DITHER=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.SKIPFINALCOLORCLAMP=!1,this.EXPOSURE=!1}}}var Su=A(()=>{Yr()});function LW(){yW.length=0,DW=!1,ae.OnEventObservable.remove(Ty),Ty=null}var MW,nc,yW,DW,Ty,Sy=A(()=>{Fi();At();Xd();N();MW=new RegExp("^([gimus]+)!"),nc=class n{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let r=0;rthis._handlePluginEvent(r,s),this._plugins.push(e),this._plugins.sort((r,s)=>r.priority-s.priority),this._codeInjectionPoints={};let i={};i[n._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(let r of this._plugins)r.collectDefines(i),this._collectPointNames("vertex",r.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",r.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;t0&&r.uniforms.push(...this._uniformList),this._samplerList.length>0&&r.samplers.push(...this._samplerList),this._uboList.length>0&&r.uniformBuffersNames.push(...this._uboList),r.customCode=this._injectCustomCode(r,r.customCode);break}case 8:{let r=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];let s=this._material.shaderLanguage===1;for(let a of this._plugins){let o=a.getUniforms(this._material.shaderLanguage);if(o){if(o.ubo)for(let l of o.ubo){if(l.size&&l.type){let c=(i=l.arraySize)!=null?i:0;if(r.ubo.addUniform(l.name,l.size,c),s){let f;switch(l.type){case"mat4":f="mat4x4f";break;case"float":f="f32";break;default:f=`${l.type}f`;break}c>0?this._uboDeclaration+=`uniform ${l.name}: array<${f}, ${c}>; `:this._uboDeclaration+=`uniform ${l.name}: ${f}; `}else this._uboDeclaration+=`${l.type} ${l.name}${c>0?`[${c}]`:""}; `}this._uniformList.push(l.name)}o.vertex&&(this._vertexDeclaration+=o.vertex+` `),o.fragment&&(this._fragmentDeclaration+=o.fragment+` `),o.externalUniforms&&this._uniformList.push(...o.externalUniforms)}a.getSamplers(this._samplerList),a.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(let i in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][i]=!0}_injectCustomCode(e,t){return(i,r)=>{var o,l;t&&(r=t(i,r)),this._uboDeclaration&&(r=r.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(r=r.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(r=r.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));let s=(o=this._codeInjectionPoints)==null?void 0:o[i];if(!s)return r;let a=null;for(let c in s){let f="";for(let d of this._activePlugins){let h=this._material.shaderLanguage,u=(l=d.getCustomCode(i,h))==null?void 0:l[c];u&&(d.resolveIncludes&&(a===null&&(a={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:E.GetShadersRepository(h),includesShadersStore:E.GetIncludesShadersStore(h),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}),a.isFragment=i==="fragment",Gc(u,a,m=>u=m)),f+=u+` -`)}if(f.length>0)if(c.charAt(0)==="!"){c=c.substring(1);let d="g";if(c.charAt(0)==="!")d="",c=c.substring(1);else{let p=cW.exec(c);p&&p.length>=2&&(d=p[1],c=c.substring(d.length+1))}d.indexOf("g")<0&&(d+="g");let h=r,u=new RegExp(c,d),m=u.exec(h);for(;m!==null;){let p=f;for(let _=0;_0)if(c.charAt(0)==="!"){c=c.substring(1);let d="g";if(c.charAt(0)==="!")d="",c=c.substring(1);else{let p=MW.exec(c);p&&p.length>=2&&(d=p[1],c=c.substring(d.length+1))}d.indexOf("g")<0&&(d+="g");let h=r,u=new RegExp(c,d),m=u.exec(h);for(;m!==null;){let p=f;for(let _=0;_{hW()});fW=[],dW=!1,uy=null});var si,Fa=A(()=>{Qe();qe();my();Kt();Lt();si=class{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,r,s=!0,a=!1,o=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this.doNotSerialize=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=o,e.pluginManager||(e.pluginManager=new nc(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=r,this._pluginManager=e.pluginManager,s&&this._pluginManager._addPlugin(this),a&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[127]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,i,r){return!0}hardBindForSubMesh(e,t,i,r){}bindForSubMesh(e,t,i,r){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(let t of Object.keys(this._pluginDefineNames)){if(t[0]==="_")continue;let 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){Me.Clone(()=>e,this)}serialize(){return Me.Serialize(this)}parse(e,t,i){Me.Parse(()=>this,e,t,i)}};C([D()],si.prototype,"name",void 0);C([D()],si.prototype,"priority",void 0);C([D()],si.prototype,"resolveIncludes",void 0);C([D()],si.prototype,"registerForExtraEvents",void 0);je("BABYLON.MaterialPluginBase",si)});var sv,Xr,av=A(()=>{Qe();Ni();qe();Wr();zr();Fa();Oi();sv=class extends Zt{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}},Xr=class extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new sv,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=ae.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&&ie.DetailTextureEnabled&&!this._texture.isReady()):!0}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;let i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&ie.DetailTextureEnabled&&this._isEnabled?(at(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&this._texture&&ie.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),ot(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&ie.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"}]}}};C([Ze("detailTexture"),ee("_markAllSubMeshesAsTexturesDirty")],Xr.prototype,"texture",void 0);C([D()],Xr.prototype,"diffuseBlendLevel",void 0);C([D()],Xr.prototype,"roughnessBlendLevel",void 0);C([D()],Xr.prototype,"bumpLevel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Xr.prototype,"normalBlendMethod",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Xr.prototype,"isEnabled",void 0)});var py,Ui,Su=A(()=>{ve();(function(n){n[n.Zero=0]="Zero",n[n.One=1]="One",n[n.MaxViewZ=2]="MaxViewZ",n[n.NoClear=3]="NoClear"})(py||(py={}));Ui=class n{static CreateConfiguration(e){return n._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:G.Zero(),currentViewProjection:G.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},n._Configurations[e]}static DeleteConfiguration(e){delete n._Configurations[e]}static GetConfiguration(e){return n._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(let i of t)if(i.subMeshes)for(let r of i.subMeshes)r._removeDrawWrapper(e)}static PrepareDefines(e,t,i){if(!i._arePrePassDirty)return;let r=n._Configurations[e];if(!r)return;i.PREPASS=!0;let s=0;for(let a=0;a{});function ac(n){return class extends n{constructor(){super(...arguments),this.PREPASS=!1,this.PREPASS_COLOR=!1,this.PREPASS_COLOR_INDEX=-1,this.PREPASS_IRRADIANCE_LEGACY=!1,this.PREPASS_IRRADIANCE_LEGACY_INDEX=-1,this.PREPASS_IRRADIANCE=!1,this.PREPASS_IRRADIANCE_INDEX=-1,this.PREPASS_ALBEDO=!1,this.PREPASS_ALBEDO_INDEX=-1,this.PREPASS_ALBEDO_SQRT=!1,this.PREPASS_ALBEDO_SQRT_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.PREPASS_NORMALIZED_VIEW_DEPTH=!1,this.PREPASS_NORMALIZED_VIEW_DEPTH_INDEX=-1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_NORMAL_WORLDSPACE=!1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_VELOCITY=!1,this.PREPASS_VELOCITY_INDEX=-1,this.PREPASS_VELOCITY_LINEAR=!1,this.PREPASS_VELOCITY_LINEAR_INDEX=-1,this.PREPASS_REFLECTIVITY=!1,this.PREPASS_REFLECTIVITY_INDEX=-1,this.SCENE_MRT_COUNT=0}}}var Ru=A(()=>{});function oc(n){return class extends n{constructor(...e){super(...e),yI()(this,"_imageProcessingConfiguration")}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),!e&&this.getScene?this._imageProcessingConfiguration=this.getScene().imageProcessingConfiguration:e&&(this._imageProcessingConfiguration=e),this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()})))}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}}}var Iu=A(()=>{qe()});var _y,uW,yo=A(()=>{N();_y="sceneUboDeclaration",uW=`struct Scene {viewProjection : mat4x4, +`+d)}}return r}}};nc._MaterialPluginClassToMainDefine={};nc._MaterialPluginCounter=0;ue.OnEnginesDisposedObservable.add(()=>{LW()});yW=[],DW=!1,Ty=null});var si,Fa=A(()=>{Qe();qe();Sy();Kt();Lt();si=class{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,r,s=!0,a=!1,o=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this.doNotSerialize=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=o,e.pluginManager||(e.pluginManager=new nc(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=r,this._pluginManager=e.pluginManager,s&&this._pluginManager._addPlugin(this),a&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[127]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,i,r){return!0}hardBindForSubMesh(e,t,i,r){}bindForSubMesh(e,t,i,r){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(let t of Object.keys(this._pluginDefineNames)){if(t[0]==="_")continue;let 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){Me.Clone(()=>e,this)}serialize(){return Me.Serialize(this)}parse(e,t,i){Me.Parse(()=>this,e,t,i)}};C([D()],si.prototype,"name",void 0);C([D()],si.prototype,"priority",void 0);C([D()],si.prototype,"resolveIncludes",void 0);C([D()],si.prototype,"registerForExtraEvents",void 0);je("BABYLON.MaterialPluginBase",si)});var lv,Kr,cv=A(()=>{Qe();Fi();qe();zr();Yr();Fa();Ni();lv=class extends Zt{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}},Kr=class extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new lv,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=ae.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&&ie.DetailTextureEnabled&&!this._texture.isReady()):!0}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;let i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&ie.DetailTextureEnabled&&this._isEnabled?(ot(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&this._texture&&ie.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),lt(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&ie.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"}]}}};C([Ze("detailTexture"),ee("_markAllSubMeshesAsTexturesDirty")],Kr.prototype,"texture",void 0);C([D()],Kr.prototype,"diffuseBlendLevel",void 0);C([D()],Kr.prototype,"roughnessBlendLevel",void 0);C([D()],Kr.prototype,"bumpLevel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Kr.prototype,"normalBlendMethod",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Kr.prototype,"isEnabled",void 0)});var Ay,Vi,Au=A(()=>{ve();(function(n){n[n.Zero=0]="Zero",n[n.One=1]="One",n[n.MaxViewZ=2]="MaxViewZ",n[n.NoClear=3]="NoClear"})(Ay||(Ay={}));Vi=class n{static CreateConfiguration(e){return n._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:U.Zero(),currentViewProjection:U.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},n._Configurations[e]}static DeleteConfiguration(e){delete n._Configurations[e]}static GetConfiguration(e){return n._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(let i of t)if(i.subMeshes)for(let r of i.subMeshes)r._removeDrawWrapper(e)}static PrepareDefines(e,t,i){if(!i._arePrePassDirty)return;let r=n._Configurations[e];if(!r)return;i.PREPASS=!0;let s=0;for(let a=0;a{});function ac(n){return class extends n{constructor(){super(...arguments),this.PREPASS=!1,this.PREPASS_COLOR=!1,this.PREPASS_COLOR_INDEX=-1,this.PREPASS_IRRADIANCE_LEGACY=!1,this.PREPASS_IRRADIANCE_LEGACY_INDEX=-1,this.PREPASS_IRRADIANCE=!1,this.PREPASS_IRRADIANCE_INDEX=-1,this.PREPASS_ALBEDO=!1,this.PREPASS_ALBEDO_INDEX=-1,this.PREPASS_ALBEDO_SQRT=!1,this.PREPASS_ALBEDO_SQRT_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.PREPASS_NORMALIZED_VIEW_DEPTH=!1,this.PREPASS_NORMALIZED_VIEW_DEPTH_INDEX=-1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_NORMAL_WORLDSPACE=!1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_VELOCITY=!1,this.PREPASS_VELOCITY_INDEX=-1,this.PREPASS_VELOCITY_LINEAR=!1,this.PREPASS_VELOCITY_LINEAR_INDEX=-1,this.PREPASS_REFLECTIVITY=!1,this.PREPASS_REFLECTIVITY_INDEX=-1,this.SCENE_MRT_COUNT=0}}}var Iu=A(()=>{});function oc(n){return class extends n{constructor(...e){super(...e),wI()(this,"_imageProcessingConfiguration")}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),!e&&this.getScene?this._imageProcessingConfiguration=this.getScene().imageProcessingConfiguration:e&&(this._imageProcessingConfiguration=e),this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()})))}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}}}var xu=A(()=>{qe()});var Ry,PW,Do=A(()=>{N();Ry="sceneUboDeclaration",PW=`struct Scene {viewProjection : mat4x4, #ifdef MULTIVIEW viewProjectionR : mat4x4, #endif @@ -1037,17 +1037,17 @@ vEyePosition : vec4, inverseProjection : mat4x4,}; #define SCENE_UBO var scene : Scene; -`;E.IncludesShadersStoreWGSL[_y]||(E.IncludesShadersStoreWGSL[_y]=uW)});var gy,mW,Wf=A(()=>{N();gy="meshUboDeclaration",mW=`struct Mesh {world : mat4x4, +`;E.IncludesShadersStoreWGSL[Ry]||(E.IncludesShadersStoreWGSL[Ry]=PW)});var Iy,OW,Wf=A(()=>{N();Iy="meshUboDeclaration",OW=`struct Mesh {world : mat4x4, visibility : f32,};var mesh : Mesh; #define WORLD_UBO -`;E.IncludesShadersStoreWGSL[gy]||(E.IncludesShadersStoreWGSL[gy]=mW)});var Ey,pW,ov=A(()=>{N();yo();Wf();Ey="defaultUboDeclaration",pW=`uniform diffuseLeftColor: vec4f;uniform diffuseRightColor: vec4f;uniform opacityParts: vec4f;uniform reflectionLeftColor: vec4f;uniform reflectionRightColor: vec4f;uniform refractionLeftColor: vec4f;uniform refractionRightColor: vec4f;uniform emissiveLeftColor: vec4f;uniform emissiveRightColor: vec4f;uniform vDiffuseInfos: vec2f;uniform vAmbientInfos: vec2f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vSpecularInfos: vec2f;uniform vBumpInfos: vec3f;uniform diffuseMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform specularMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform pointSize: f32;uniform alphaCutOff: f32;uniform refractionMatrix: mat4x4f;uniform vRefractionInfos: vec4f;uniform vRefractionPosition: vec3f;uniform vRefractionSize: vec3f;uniform vSpecularColor: vec4f;uniform vEmissiveColor: vec3f;uniform vDiffuseColor: vec4f;uniform vAmbientColor: vec3f;uniform cameraInfo: vec4f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f; +`;E.IncludesShadersStoreWGSL[Iy]||(E.IncludesShadersStoreWGSL[Iy]=OW)});var xy,NW,fv=A(()=>{N();Do();Wf();xy="defaultUboDeclaration",NW=`uniform diffuseLeftColor: vec4f;uniform diffuseRightColor: vec4f;uniform opacityParts: vec4f;uniform reflectionLeftColor: vec4f;uniform reflectionRightColor: vec4f;uniform refractionLeftColor: vec4f;uniform refractionRightColor: vec4f;uniform emissiveLeftColor: vec4f;uniform emissiveRightColor: vec4f;uniform vDiffuseInfos: vec2f;uniform vAmbientInfos: vec2f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vSpecularInfos: vec2f;uniform vBumpInfos: vec3f;uniform diffuseMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform specularMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform pointSize: f32;uniform alphaCutOff: f32;uniform refractionMatrix: mat4x4f;uniform vRefractionInfos: vec4f;uniform vRefractionPosition: vec3f;uniform vRefractionSize: vec3f;uniform vSpecularColor: vec4f;uniform vEmissiveColor: vec3f;uniform vDiffuseColor: vec4f;uniform vAmbientColor: vec3f;uniform cameraInfo: vec4f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f; #define ADDITIONAL_UBO_DECLARATION #include #include -`;E.IncludesShadersStoreWGSL[Ey]||(E.IncludesShadersStoreWGSL[Ey]=pW)});var vy,_W,xu=A(()=>{N();vy="uvAttributeDeclaration",_W=`#if defined(UV{X}) && !defined(USE_VERTEX_PULLING) +`;E.IncludesShadersStoreWGSL[xy]||(E.IncludesShadersStoreWGSL[xy]=NW)});var Cy,FW,Cu=A(()=>{N();Cy="uvAttributeDeclaration",FW=`#if defined(UV{X}) && !defined(USE_VERTEX_PULLING) attribute uv{X}: vec2f; #endif -`;E.IncludesShadersStoreWGSL[vy]||(E.IncludesShadersStoreWGSL[vy]=_W)});var Ty,gW,Cu=A(()=>{N();Ty="prePassVertexDeclaration",gW=`#ifdef PREPASS +`;E.IncludesShadersStoreWGSL[Cy]||(E.IncludesShadersStoreWGSL[Cy]=FW)});var by,wW,bu=A(()=>{N();by="prePassVertexDeclaration",wW=`#ifdef PREPASS #ifdef PREPASS_LOCAL_POSITION varying vPosition : vec3f; #endif @@ -1061,18 +1061,18 @@ varying vNormViewDepth: f32; uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; #endif #endif -`;E.IncludesShadersStoreWGSL[Ty]||(E.IncludesShadersStoreWGSL[Ty]=gW)});var Sy,EW,lc=A(()=>{N();Sy="mainUVVaryingDeclaration",EW=`#ifdef MAINUV{X} +`;E.IncludesShadersStoreWGSL[by]||(E.IncludesShadersStoreWGSL[by]=wW)});var My,BW,lc=A(()=>{N();My="mainUVVaryingDeclaration",BW=`#ifdef MAINUV{X} varying vMainUV{X}: vec2f; #endif -`;E.IncludesShadersStoreWGSL[Sy]||(E.IncludesShadersStoreWGSL[Sy]=EW)});var Ay,vW,bu=A(()=>{N();Ay="samplerVertexDeclaration",vW=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +`;E.IncludesShadersStoreWGSL[My]||(E.IncludesShadersStoreWGSL[My]=BW)});var yy,UW,Mu=A(()=>{N();yy="samplerVertexDeclaration",UW=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 varying v_VARYINGNAME_UV: vec2f; #endif -`;E.IncludesShadersStoreWGSL[Ay]||(E.IncludesShadersStoreWGSL[Ay]=vW)});var Ry,TW,lv=A(()=>{N();Ry="bumpVertexDeclaration",TW=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +`;E.IncludesShadersStoreWGSL[yy]||(E.IncludesShadersStoreWGSL[yy]=UW)});var Dy,VW,dv=A(()=>{N();Dy="bumpVertexDeclaration",VW=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) #if defined(TANGENT) && defined(NORMAL) varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f; #endif #endif -`;E.IncludesShadersStoreWGSL[Ry]||(E.IncludesShadersStoreWGSL[Ry]=TW)});var Iy,SW,xy=A(()=>{N();Iy="lightVxFragmentDeclaration",SW=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[Dy]||(E.IncludesShadersStoreWGSL[Dy]=VW)});var Ly,GW,Py=A(()=>{N();Ly="lightVxFragmentDeclaration",GW=`#ifdef LIGHT{X} uniform vLightData{X}: vec4f;uniform vLightDiffuse{X}: vec4f; #ifdef SPECULARTERM uniform vLightSpecular{X}: vec4f; @@ -1099,7 +1099,7 @@ uniform vLightGround{X}: vec3f; uniform vLightWidth{X}: vec4f;uniform vLightHeight{X}: vec4f; #endif #endif -`;E.IncludesShadersStoreWGSL[Iy]||(E.IncludesShadersStoreWGSL[Iy]=SW)});var Cy,AW,Mu=A(()=>{N();Cy="lightVxUboDeclaration",AW=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[Ly]||(E.IncludesShadersStoreWGSL[Ly]=GW)});var Oy,kW,yu=A(()=>{N();Oy="lightVxUboDeclaration",kW=`#ifdef LIGHT{X} struct Light{X} {vLightData: vec4f, vLightDiffuse: vec4f, @@ -1130,7 +1130,7 @@ varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;uniform lightM #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Cy]||(E.IncludesShadersStoreWGSL[Cy]=AW)});var by,RW,wa=A(()=>{N();by="morphTargetsVertexGlobalDeclaration",RW=`#ifdef MORPHTARGETS +`;E.IncludesShadersStoreWGSL[Oy]||(E.IncludesShadersStoreWGSL[Oy]=kW)});var Ny,WW,wa=A(()=>{N();Ny="morphTargetsVertexGlobalDeclaration",WW=`#ifdef MORPHTARGETS uniform morphTargetInfluences : array; #ifdef MORPHTARGETS_TEXTURE uniform morphTargetTextureIndices : array;uniform morphTargetTextureInfo : vec3;var morphTargets : texture_2d_array;fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec3 @@ -1142,7 +1142,7 @@ let textureWidth: i32=i32(uniforms.morphTargetTextureInfo.y); let y: i32=i32(vertexIndex)/textureWidth;let x: i32=i32(vertexIndex) % textureWidth;return textureLoad(morphTargets,vec2i(x,y),i32(uniforms.morphTargetTextureIndices[targetIndex]),0);} #endif #endif -`;E.IncludesShadersStoreWGSL[by]||(E.IncludesShadersStoreWGSL[by]=RW)});var My,IW,Ba=A(()=>{N();My="morphTargetsVertexDeclaration",IW=`#ifdef MORPHTARGETS +`;E.IncludesShadersStoreWGSL[Ny]||(E.IncludesShadersStoreWGSL[Ny]=WW)});var Fy,HW,Ba=A(()=>{N();Fy="morphTargetsVertexDeclaration",HW=`#ifdef MORPHTARGETS #ifndef MORPHTARGETS_TEXTURE #ifdef MORPHTARGETS_POSITION attribute position{X} : vec3; @@ -1166,10 +1166,10 @@ attribute color{X} : vec4; uniform morphTargetCount: f32; #endif #endif -`;E.IncludesShadersStoreWGSL[My]||(E.IncludesShadersStoreWGSL[My]=IW)});var yy,xW,Do=A(()=>{N();yy="logDepthDeclaration",xW=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStoreWGSL[Fy]||(E.IncludesShadersStoreWGSL[Fy]=HW)});var wy,zW,Lo=A(()=>{N();wy="logDepthDeclaration",zW=`#ifdef LOGARITHMICDEPTH uniform logarithmicDepthConstant: f32;varying vFragmentDepth: f32; #endif -`;E.IncludesShadersStoreWGSL[yy]||(E.IncludesShadersStoreWGSL[yy]=xW)});var Dy,CW,yu=A(()=>{N();Dy="vertexPullingDeclaration",CW=`#ifdef USE_VERTEX_PULLING +`;E.IncludesShadersStoreWGSL[wy]||(E.IncludesShadersStoreWGSL[wy]=zW)});var By,XW,Du=A(()=>{N();By="vertexPullingDeclaration",XW=`#ifdef USE_VERTEX_PULLING #ifdef VERTEX_PULLING_USE_INDEX_BUFFER var indices : array; #endif @@ -1347,7 +1347,7 @@ vp_readMatrixWeightExtraValue(offset+cs*3u,dataType,normalized) #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Dy]||(E.IncludesShadersStoreWGSL[Dy]=CW)});var Ly,bW,Du=A(()=>{N();Ly="vertexPullingVertex",bW=`#ifdef USE_VERTEX_PULLING +`;E.IncludesShadersStoreWGSL[By]||(E.IncludesShadersStoreWGSL[By]=XW)});var Uy,YW,Lu=A(()=>{N();Uy="vertexPullingVertex",YW=`#ifdef USE_VERTEX_PULLING let vpVertexIndex: u32=vp_readVertexIndex(vertexInputs.vertexIndex);positionUpdated=vp_readPosition(uniforms.vp_position_info,vpVertexIndex); #ifdef NORMAL normalUpdated=vp_readNormal(uniforms.vp_normal_info,vpVertexIndex); @@ -1401,12 +1401,12 @@ var vp_matricesIndicesExtra: vec4f=vp_readBoneIndicesExtra(uniforms.vp_matricesI #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Ly]||(E.IncludesShadersStoreWGSL[Ly]=bW)});var Py,MW,Ua=A(()=>{N();Py="morphTargetsVertexGlobal",MW=`#ifdef MORPHTARGETS +`;E.IncludesShadersStoreWGSL[Uy]||(E.IncludesShadersStoreWGSL[Uy]=YW)});var Vy,KW,Ua=A(()=>{N();Vy="morphTargetsVertexGlobal",KW=`#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE var vertexID : f32; #endif #endif -`;E.IncludesShadersStoreWGSL[Py]||(E.IncludesShadersStoreWGSL[Py]=MW)});var Oy,yW,Va=A(()=>{N();Oy="morphTargetsVertex",yW=`#ifdef MORPHTARGETS +`;E.IncludesShadersStoreWGSL[Vy]||(E.IncludesShadersStoreWGSL[Vy]=KW)});var Gy,jW,Va=A(()=>{N();Gy="morphTargetsVertex",jW=`#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE #if {X}==0 for (var i=0; i=uniforms.morphTargetCount) {break;} @@ -1516,7 +1516,7 @@ colorUpdated=colorUpdated+(vertexInputs.color{X}-vertexInputs.color)*uniforms.mo #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Oy]||(E.IncludesShadersStoreWGSL[Oy]=yW)});var Ny,DW,Lu=A(()=>{N();Ny="prePassVertex",DW=`#ifdef PREPASS_DEPTH +`;E.IncludesShadersStoreWGSL[Gy]||(E.IncludesShadersStoreWGSL[Gy]=jW)});var ky,ZW,Pu=A(()=>{N();ky="prePassVertex",ZW=`#ifdef PREPASS_DEPTH vertexOutputs.vViewPos=(scene.view*worldPos).rgb; #endif #ifdef PREPASS_NORMALIZED_VIEW_DEPTH @@ -1555,7 +1555,7 @@ vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWor vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0); #endif #endif -`;E.IncludesShadersStoreWGSL[Ny]||(E.IncludesShadersStoreWGSL[Ny]=DW)});var Fy,LW,Pu=A(()=>{N();Fy="uvVariableDeclaration",LW=`#ifdef MAINUV{X} +`;E.IncludesShadersStoreWGSL[ky]||(E.IncludesShadersStoreWGSL[ky]=ZW)});var Wy,qW,Ou=A(()=>{N();Wy="uvVariableDeclaration",qW=`#ifdef MAINUV{X} #if !defined(UV{X}) var uv{X}: vec2f=vec2f(0.,0.); #elif defined(USE_VERTEX_PULLING) @@ -1565,7 +1565,7 @@ var uv{X}: vec2f=vertexInputs.uv{X}; #endif vertexOutputs.vMainUV{X}=uv{X}; #endif -`;E.IncludesShadersStoreWGSL[Fy]||(E.IncludesShadersStoreWGSL[Fy]=LW)});var wy,PW,Ou=A(()=>{N();wy="samplerVertexImplementation",PW=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +`;E.IncludesShadersStoreWGSL[Wy]||(E.IncludesShadersStoreWGSL[Wy]=qW)});var Hy,QW,Nu=A(()=>{N();Hy="samplerVertexImplementation",QW=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 if (uniforms.v_INFONAME_==0.) {vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(uvUpdated,1.0,0.0)).xy;} #ifdef UV2 @@ -1589,12 +1589,12 @@ else if (uniforms.v_INFONAME_==5.) {vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv6,1.0,0.0)).xy;} #endif #endif -`;E.IncludesShadersStoreWGSL[wy]||(E.IncludesShadersStoreWGSL[wy]=PW)});var By,OW,Nu=A(()=>{N();By="bumpVertex",OW=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +`;E.IncludesShadersStoreWGSL[Hy]||(E.IncludesShadersStoreWGSL[Hy]=QW)});var zy,JW,Fu=A(()=>{N();zy="bumpVertex",JW=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) #if defined(TANGENT) && defined(NORMAL) var tbnNormal: vec3f=normalize(normalUpdated);var tbnTangent: vec3f=normalize(tangentUpdated.xyz);var tbnBitangent: vec3f=cross(tbnNormal,tbnTangent)*tangentUpdated.w;var matTemp= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz)* mat3x3f(tbnTangent,tbnBitangent,tbnNormal);vertexOutputs.vTBN0=matTemp[0];vertexOutputs.vTBN1=matTemp[1];vertexOutputs.vTBN2=matTemp[2]; #endif #endif -`;E.IncludesShadersStoreWGSL[By]||(E.IncludesShadersStoreWGSL[By]=OW)});var Uy,NW,Fu=A(()=>{N();Uy="shadowsVertex",NW=`#ifdef SHADOWS +`;E.IncludesShadersStoreWGSL[zy]||(E.IncludesShadersStoreWGSL[zy]=JW)});var Xy,$W,wu=A(()=>{N();Xy="shadowsVertex",$W=`#ifdef SHADOWS #if defined(SHADOWCSM{X}) #ifdef SCENE_UBO vertexOutputs.vPositionFromCamera{X}=scene.view*worldPos; @@ -1642,10 +1642,10 @@ vertexOutputs.vDepthMetric{X}=(vertexOutputs.vPositionFromLight{X}.z+light{X}.de #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Uy]||(E.IncludesShadersStoreWGSL[Uy]=NW)});var Vy,FW,wu=A(()=>{N();Vy="logDepthVertex",FW=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStoreWGSL[Xy]||(E.IncludesShadersStoreWGSL[Xy]=$W)});var Yy,eH,Bu=A(()=>{N();Yy="logDepthVertex",eH=`#ifdef LOGARITHMICDEPTH vertexOutputs.vFragmentDepth=1.0+vertexOutputs.position.w;vertexOutputs.position.z=log2(max(0.000001,vertexOutputs.vFragmentDepth))*uniforms.logarithmicDepthConstant; #endif -`;E.IncludesShadersStoreWGSL[Vy]||(E.IncludesShadersStoreWGSL[Vy]=FW)});var ky={};De(ky,{defaultVertexShaderWGSL:()=>wW});var cv,Gy,wW,Wy=A(()=>{N();ov();xu();Vr();Cs();bs();Oa();Cu();lc();bu();lv();Ms();bf();xy();Mu();wa();Ba();Do();yu();Du();Ua();Va();ys();Ds();Ls();Lu();Pu();Ou();Nu();Ps();Mf();Fu();yf();wu();cv="defaultVertexShader",Gy=`#include +`;E.IncludesShadersStoreWGSL[Yy]||(E.IncludesShadersStoreWGSL[Yy]=eH)});var jy={};De(jy,{defaultVertexShaderWGSL:()=>tH});var hv,Ky,tH,Zy=A(()=>{N();fv();Cu();kr();Cs();bs();Oa();bu();lc();Mu();dv();Ms();bf();Py();yu();wa();Ba();Lo();Du();Lu();Ua();Va();ys();Ds();Ls();Pu();Ou();Nu();Fu();Ps();Mf();wu();yf();Bu();hv="defaultVertexShader",Ky=`#include #define CUSTOM_VERTEX_BEGIN #ifndef USE_VERTEX_PULLING attribute position: vec3f; @@ -1826,7 +1826,7 @@ vertexOutputs.vMainUV2=uv2Updated; #include #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStoreWGSL[cv]||(E.ShadersStoreWGSL[cv]=Gy);wW={name:cv,shader:Gy}});var Hy,BW,Bu=A(()=>{N();Hy="prePassDeclaration",BW=`#ifdef PREPASS +`;E.ShadersStoreWGSL[hv]||(E.ShadersStoreWGSL[hv]=Ky);tH={name:hv,shader:Ky}});var qy,iH,Uu=A(()=>{N();qy="prePassDeclaration",iH=`#ifdef PREPASS #ifdef PREPASS_LOCAL_POSITION varying vPosition : vec3f; #endif @@ -1840,11 +1840,11 @@ varying vNormViewDepth: f32; varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; #endif #endif -`;E.IncludesShadersStoreWGSL[Hy]||(E.IncludesShadersStoreWGSL[Hy]=BW)});var zy,UW,Uu=A(()=>{N();zy="oitDeclaration",UW=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY +`;E.IncludesShadersStoreWGSL[qy]||(E.IncludesShadersStoreWGSL[qy]=iH)});var Qy,rH,Vu=A(()=>{N();Qy="oitDeclaration",rH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY #define MAX_DEPTH 99999.0 var oitDepthSamplerSampler: sampler;var oitDepthSampler: texture_2d;var oitFrontColorSamplerSampler: sampler;var oitFrontColorSampler: texture_2d; #endif -`;E.IncludesShadersStoreWGSL[zy]||(E.IncludesShadersStoreWGSL[zy]=UW)});var Xy,VW,Vu=A(()=>{N();Xy="lightUboDeclaration",VW=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[Qy]||(E.IncludesShadersStoreWGSL[Qy]=rH)});var Jy,nH,Gu=A(()=>{N();Jy="lightUboDeclaration",nH=`#ifdef LIGHT{X} struct Light{X} {vLightData: vec4f, vLightDiffuse: vec4f, @@ -1921,7 +1921,7 @@ uniform lightMatrix{X}: mat4x4f; #endif #endif #endif -`;E.IncludesShadersStoreWGSL[Xy]||(E.IncludesShadersStoreWGSL[Xy]=VW)});var Yy,GW,fv=A(()=>{N();Yy="ltcHelperFunctions",GW=`fn LTCUv(N: vec3f,V: vec3f,roughness: f32)->vec2f {var LUTSIZE: f32=64.0;var LUTSCALE: f32=( LUTSIZE-1.0 )/LUTSIZE;var LUTBIAS:f32=0.5/LUTSIZE;var dotNV:f32=saturate( dot( N,V ) );var uv:vec2f=vec2f( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;} +`;E.IncludesShadersStoreWGSL[Jy]||(E.IncludesShadersStoreWGSL[Jy]=nH)});var $y,sH,uv=A(()=>{N();$y="ltcHelperFunctions",sH=`fn LTCUv(N: vec3f,V: vec3f,roughness: f32)->vec2f {var LUTSIZE: f32=64.0;var LUTSCALE: f32=( LUTSIZE-1.0 )/LUTSIZE;var LUTBIAS:f32=0.5/LUTSIZE;var dotNV:f32=saturate( dot( N,V ) );var uv:vec2f=vec2f( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;} fn LTCClippedSphereFormFactor( f:vec3f )->f32 {var l: f32=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );} fn LTCEdgeVectorFormFactor( v1:vec3f,v2:vec3f )->vec3f {var x:f32=dot( v1,v2 );var y:f32=abs( x );var a:f32=0.8543985+( 0.4965155+0.0145206*y )*y;var b:f32=3.4175940+( 4.1616724+y )*y;var v:f32=a/b;var thetaSintheta:f32=0.0;if( x>0.0 ) {thetaSintheta=v;} @@ -1965,7 +1965,7 @@ vec3f(1,0,0), vec3f(0,1,0), vec3f(0,0,1) );result.Diffuse=LTCEvaluateWithEmission(normal,viewDir,position,mInvEmpty,rectCoords0,rectCoords1,rectCoords2,rectCoords3,emissionTexture,emissionTextureSampler);return result;} -`;E.IncludesShadersStoreWGSL[Yy]||(E.IncludesShadersStoreWGSL[Yy]=GW)});var Ky,kW,dv=A(()=>{N();Ky="clusteredLightingFunctions",kW=`struct ClusteredLight {vLightData: vec4f, +`;E.IncludesShadersStoreWGSL[$y]||(E.IncludesShadersStoreWGSL[$y]=sH)});var eD,aH,mv=A(()=>{N();eD="clusteredLightingFunctions",aH=`struct ClusteredLight {vLightData: vec4f, vLightDiffuse: vec4f, vLightSpecular: vec4f, vLightDirection: vec4f, @@ -1978,7 +1978,7 @@ textureLoad(lightDataTexture,vec2u(3,index),0), textureLoad(lightDataTexture,vec2u(4,index),0) );} fn getClusteredSliceIndex(sliceData: vec2f,viewDepth: f32)->i32 {return i32(log(viewDepth)*sliceData.x+sliceData.y);} -`;E.IncludesShadersStoreWGSL[Ky]||(E.IncludesShadersStoreWGSL[Ky]=kW)});var jy,WW,Zy=A(()=>{N();fv();dv();jy="lightsFragmentFunctions",WW=`struct lightingInfo +`;E.IncludesShadersStoreWGSL[eD]||(E.IncludesShadersStoreWGSL[eD]=aH)});var tD,oH,iD=A(()=>{N();uv();mv();tD="lightsFragmentFunctions",oH=`struct lightingInfo {diffuse: vec3f, #ifdef SPECULARTERM specular: vec3f, @@ -2075,7 +2075,7 @@ result.specular+=info.specular; batchOffset+=CLUSTLIGHT_BATCH;} return result;} #endif -`;E.IncludesShadersStoreWGSL[jy]||(E.IncludesShadersStoreWGSL[jy]=WW)});var qy,HW,Gu=A(()=>{N();qy="shadowsFragmentFunctions",HW=`#ifdef SHADOWS +`;E.IncludesShadersStoreWGSL[tD]||(E.IncludesShadersStoreWGSL[tD]=oH)});var rD,lH,ku=A(()=>{N();rD="shadowsFragmentFunctions",lH=`#ifdef SHADOWS #ifndef SHADOWFLOAT fn unpack(color: vec4f)->f32 {const bit_shift: vec4f= vec4f(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);} @@ -2367,7 +2367,7 @@ fn computeShadowWithCSMPCSS32(layer: i32,vPositionFromLight: vec4f,depthMetric: fn computeShadowWithCSMPCSS64(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32 {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} #endif -`;E.IncludesShadersStoreWGSL[qy]||(E.IncludesShadersStoreWGSL[qy]=HW)});var Qy,zW,Lo=A(()=>{N();Qy="samplerFragmentDeclaration",zW=`#ifdef _DEFINENAME_ +`;E.IncludesShadersStoreWGSL[rD]||(E.IncludesShadersStoreWGSL[rD]=lH)});var nD,cH,Po=A(()=>{N();nD="samplerFragmentDeclaration",cH=`#ifdef _DEFINENAME_ #if _DEFINENAME_DIRECTUV==1 #define v_VARYINGNAME_UV vMainUV1 #elif _DEFINENAME_DIRECTUV==2 @@ -2385,11 +2385,11 @@ varying v_VARYINGNAME_UV: vec2f; #endif var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d; #endif -`;E.IncludesShadersStoreWGSL[Qy]||(E.IncludesShadersStoreWGSL[Qy]=zW)});var Jy,XW,$y=A(()=>{N();Jy="fresnelFunction",XW=`#ifdef FRESNEL +`;E.IncludesShadersStoreWGSL[nD]||(E.IncludesShadersStoreWGSL[nD]=cH)});var sD,fH,aD=A(()=>{N();sD="fresnelFunction",fH=`#ifdef FRESNEL fn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32 {let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);} #endif -`;E.IncludesShadersStoreWGSL[Jy]||(E.IncludesShadersStoreWGSL[Jy]=XW)});var eD,YW,Hf=A(()=>{N();eD="reflectionFunction",YW=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f +`;E.IncludesShadersStoreWGSL[sD]||(E.IncludesShadersStoreWGSL[sD]=fH)});var oD,dH,Hf=A(()=>{N();oD="reflectionFunction",dH=`fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0); } fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(1.0-s,t,0); } @@ -2453,7 +2453,7 @@ return vec3f(0,0,0); #endif } #endif -`;E.IncludesShadersStoreWGSL[eD]||(E.IncludesShadersStoreWGSL[eD]=YW)});var tD,KW,ku=A(()=>{N();tD="imageProcessingDeclaration",KW=`#ifdef EXPOSURE +`;E.IncludesShadersStoreWGSL[oD]||(E.IncludesShadersStoreWGSL[oD]=dH)});var lD,hH,Wu=A(()=>{N();lD="imageProcessingDeclaration",hH=`#ifdef EXPOSURE uniform exposureLinear: f32; #endif #ifdef CONTRAST @@ -2479,7 +2479,7 @@ uniform colorTransformSettings: vec4f; #ifdef DITHER uniform ditherIntensity: f32; #endif -`;E.IncludesShadersStoreWGSL[tD]||(E.IncludesShadersStoreWGSL[tD]=KW)});var iD,jW,Wu=A(()=>{N();iD="imageProcessingFunctions",jW=`#if TONEMAPPING==3 +`;E.IncludesShadersStoreWGSL[lD]||(E.IncludesShadersStoreWGSL[lD]=hH)});var cD,uH,Hu=A(()=>{N();cD="imageProcessingFunctions",uH=`#if TONEMAPPING==3 const PBRNeutralStartCompression: f32=0.8-0.04;const PBRNeutralDesaturation: f32=0.15;fn PBRNeutralToneMapping( color: vec3f )->vec3f {var x: f32=min(color.r,min(color.g,color.b));var offset: f32=select(0.04,x-6.25*x*x,x<0.08);var result=color;result-=offset;var peak: f32=max(result.r,max(result.g,result.b));if (peak{N();rD="bumpFragmentMainFunctions",ZW=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) +return vec4f(rgb,result.a);}`;E.IncludesShadersStoreWGSL[cD]||(E.IncludesShadersStoreWGSL[cD]=uH)});var fD,mH,zu=A(()=>{N();fD="bumpFragmentMainFunctions",mH=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) #if defined(TANGENT) && defined(NORMAL) varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f; #endif @@ -2581,7 +2581,7 @@ fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f {var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);} #endif -`;E.IncludesShadersStoreWGSL[rD]||(E.IncludesShadersStoreWGSL[rD]=ZW)});var nD,qW,zu=A(()=>{N();Lo();nD="bumpFragmentFunctions",qW=`#if defined(BUMP) +`;E.IncludesShadersStoreWGSL[fD]||(E.IncludesShadersStoreWGSL[fD]=mH)});var dD,pH,Xu=A(()=>{N();Po();dD="bumpFragmentFunctions",pH=`#if defined(BUMP) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) #endif #if defined(DETAIL) @@ -2611,7 +2611,7 @@ return -texCoordOffset; #endif } #endif -`;E.IncludesShadersStoreWGSL[nD]||(E.IncludesShadersStoreWGSL[nD]=qW)});var sD,QW,Xu=A(()=>{N();sD="bumpFragment",QW=`var uvOffset: vec2f= vec2f(0.0,0.0); +`;E.IncludesShadersStoreWGSL[dD]||(E.IncludesShadersStoreWGSL[dD]=pH)});var hD,_H,Yu=A(()=>{N();hD="bumpFragment",_H=`var uvOffset: vec2f= vec2f(0.0,0.0); #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) #ifdef NORMALXYSCALE var normalScale: f32=1.0; @@ -2663,7 +2663,7 @@ normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y); #elif defined(DETAIL) detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z); #endif -`;E.IncludesShadersStoreWGSL[sD]||(E.IncludesShadersStoreWGSL[sD]=QW)});var aD,JW,hv=A(()=>{N();aD="decalFragment",JW=`#ifdef DECAL +`;E.IncludesShadersStoreWGSL[hD]||(E.IncludesShadersStoreWGSL[hD]=_H)});var uD,gH,pv=A(()=>{N();uD="decalFragment",gH=`#ifdef DECAL var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a; #ifdef GAMMADECAL decalTempColor=toLinearSpaceVec3(decalColor.rgb); @@ -2673,13 +2673,13 @@ decalTempAlpha=decalColor.a*decalColor.a; #endif surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha); #endif -`;E.IncludesShadersStoreWGSL[aD]||(E.IncludesShadersStoreWGSL[aD]=JW)});var oD,$W,Yu=A(()=>{N();oD="depthPrePass",$W=`#ifdef DEPTHPREPASS +`;E.IncludesShadersStoreWGSL[uD]||(E.IncludesShadersStoreWGSL[uD]=gH)});var mD,EH,Ku=A(()=>{N();mD="depthPrePass",EH=`#ifdef DEPTHPREPASS #if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY) fragmentOutputs.color= vec4f(0.,0.,0.,1.0); #endif return fragmentOutputs; #endif -`;E.IncludesShadersStoreWGSL[oD]||(E.IncludesShadersStoreWGSL[oD]=$W)});var lD,eH,uv=A(()=>{N();lD="lightFragment",eH=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[mD]||(E.IncludesShadersStoreWGSL[mD]=EH)});var pD,vH,_v=A(()=>{N();pD="lightFragment",vH=`#ifdef LIGHT{X} #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) #else var diffuse{X}: vec4f=light{X}.vLightDiffuse; @@ -3066,10 +3066,10 @@ sheenBase+=info.sheen.rgb*shadow; #endif #endif #endif -`;E.IncludesShadersStoreWGSL[lD]||(E.IncludesShadersStoreWGSL[lD]=eH)});var cD,tH,Ku=A(()=>{N();cD="logDepthFragment",tH=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStoreWGSL[pD]||(E.IncludesShadersStoreWGSL[pD]=vH)});var _D,TH,ju=A(()=>{N();_D="logDepthFragment",TH=`#ifdef LOGARITHMICDEPTH fragmentOutputs.fragDepth=log2(fragmentInputs.vFragmentDepth)*uniforms.logarithmicDepthConstant*0.5; #endif -`;E.IncludesShadersStoreWGSL[cD]||(E.IncludesShadersStoreWGSL[cD]=tH)});var fD,iH,ju=A(()=>{N();fD="oitFragment",iH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY +`;E.IncludesShadersStoreWGSL[_D]||(E.IncludesShadersStoreWGSL[_D]=TH)});var gD,SH,Zu=A(()=>{N();gD="oitFragment",SH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY var fragDepth: f32=fragmentInputs.position.z; #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS var halfFloat: u32=pack2x16float( vec2f(fragDepth));var full: vec2f=unpack2x16float(halfFloat);fragDepth=full.x; @@ -3094,7 +3094,7 @@ if (fragDepth>nearestDepth && fragDepthrH});var mv,dD,rH,uD=A(()=>{N();ov();Bu();Uu();lc();Vr();Vu();Zy();Gu();Lo();$y();Hf();ku();Wu();Hu();zu();Os();Do();Df();Ns();Xu();hv();Yu();uv();Ku();Lf();ju();mv="defaultPixelShader",dD=`#include +`;E.IncludesShadersStoreWGSL[gD]||(E.IncludesShadersStoreWGSL[gD]=SH)});var vD={};De(vD,{defaultPixelShaderWGSL:()=>AH});var gv,ED,AH,TD=A(()=>{N();fv();Uu();Vu();lc();kr();Gu();iD();ku();Po();aD();Hf();Wu();Hu();zu();Xu();Os();Lo();Df();Ns();Yu();pv();Ku();_v();ju();Lf();Zu();gv="defaultPixelShader",ED=`#include #include[SCENE_MRT_COUNT] #include #define CUSTOM_FRAGMENT_BEGIN @@ -3460,10 +3460,10 @@ if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.f #endif #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStoreWGSL[mv]||(E.ShadersStoreWGSL[mv]=dD);rH={name:mv,shader:dD}});var mD,nH,Zu=A(()=>{N();mD="decalVertexDeclaration",nH=`#ifdef DECAL +`;E.ShadersStoreWGSL[gv]||(E.ShadersStoreWGSL[gv]=ED);AH={name:gv,shader:ED}});var SD,RH,qu=A(()=>{N();SD="decalVertexDeclaration",RH=`#ifdef DECAL uniform vec4 vDecalInfos;uniform mat4 decalMatrix; #endif -`;E.IncludesShadersStore[mD]||(E.IncludesShadersStore[mD]=nH)});var pD,sH,_D=A(()=>{N();Zu();pD="defaultVertexDeclaration",sH=`uniform mat4 viewProjection; +`;E.IncludesShadersStore[SD]||(E.IncludesShadersStore[SD]=RH)});var AD,IH,RD=A(()=>{N();qu();AD="defaultVertexDeclaration",IH=`uniform mat4 viewProjection; #ifdef MULTIVIEW mat4 viewProjectionR; #endif @@ -3501,28 +3501,28 @@ uniform vec4 vDetailInfos;uniform mat4 detailMatrix; uniform vec4 cameraInfo; #include #define ADDITIONAL_VERTEX_DECLARATION -`;E.IncludesShadersStore[pD]||(E.IncludesShadersStore[pD]=sH)});var gD,aH,Po=A(()=>{N();gD="sceneUboDeclaration",aH=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection; +`;E.IncludesShadersStore[AD]||(E.IncludesShadersStore[AD]=IH)});var ID,xH,Oo=A(()=>{N();ID="sceneUboDeclaration",xH=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection; #ifdef MULTIVIEW mat4 viewProjectionR; #endif mat4 view;mat4 projection;vec4 vEyePosition;mat4 inverseProjection;}; -`;E.IncludesShadersStore[gD]||(E.IncludesShadersStore[gD]=aH)});var ED,oH,zf=A(()=>{N();ED="meshUboDeclaration",oH=`#ifdef WEBGL2 +`;E.IncludesShadersStore[ID]||(E.IncludesShadersStore[ID]=xH)});var xD,CH,zf=A(()=>{N();xD="meshUboDeclaration",CH=`#ifdef WEBGL2 uniform mat4 world;uniform float visibility; #else layout(std140,column_major) uniform;uniform Mesh {mat4 world;float visibility;}; #endif #define WORLD_UBO -`;E.IncludesShadersStore[ED]||(E.IncludesShadersStore[ED]=oH)});var vD,lH,pv=A(()=>{N();Po();zf();vD="defaultUboDeclaration",lH=`layout(std140,column_major) uniform;uniform Material +`;E.IncludesShadersStore[xD]||(E.IncludesShadersStore[xD]=CH)});var CD,bH,Ev=A(()=>{N();Oo();zf();CD="defaultUboDeclaration",bH=`layout(std140,column_major) uniform;uniform Material {vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;vec4 cameraInfo;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionPosition;vec3 vReflectionSize; #define ADDITIONAL_UBO_DECLARATION }; #include #include -`;E.IncludesShadersStore[vD]||(E.IncludesShadersStore[vD]=lH)});var TD,cH,qu=A(()=>{N();TD="uvAttributeDeclaration",cH=`#ifdef UV{X} +`;E.IncludesShadersStore[CD]||(E.IncludesShadersStore[CD]=bH)});var bD,MH,Qu=A(()=>{N();bD="uvAttributeDeclaration",MH=`#ifdef UV{X} attribute vec2 uv{X}; #endif -`;E.IncludesShadersStore[TD]||(E.IncludesShadersStore[TD]=cH)});var SD,fH,Qu=A(()=>{N();SD="prePassVertexDeclaration",fH=`#ifdef PREPASS +`;E.IncludesShadersStore[bD]||(E.IncludesShadersStore[bD]=MH)});var MD,yH,Ju=A(()=>{N();MD="prePassVertexDeclaration",yH=`#ifdef PREPASS #ifdef PREPASS_LOCAL_POSITION varying vec3 vPosition; #endif @@ -3536,18 +3536,18 @@ varying float vNormViewDepth; uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition; #endif #endif -`;E.IncludesShadersStore[SD]||(E.IncludesShadersStore[SD]=fH)});var AD,dH,cc=A(()=>{N();AD="mainUVVaryingDeclaration",dH=`#ifdef MAINUV{X} +`;E.IncludesShadersStore[MD]||(E.IncludesShadersStore[MD]=yH)});var yD,DH,cc=A(()=>{N();yD="mainUVVaryingDeclaration",DH=`#ifdef MAINUV{X} varying vec2 vMainUV{X}; #endif -`;E.IncludesShadersStore[AD]||(E.IncludesShadersStore[AD]=dH)});var RD,hH,Ju=A(()=>{N();RD="samplerVertexDeclaration",hH=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +`;E.IncludesShadersStore[yD]||(E.IncludesShadersStore[yD]=DH)});var DD,LH,$u=A(()=>{N();DD="samplerVertexDeclaration",LH=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 varying vec2 v_VARYINGNAME_UV; #endif -`;E.IncludesShadersStore[RD]||(E.IncludesShadersStore[RD]=hH)});var ID,uH,_v=A(()=>{N();ID="bumpVertexDeclaration",uH=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +`;E.IncludesShadersStore[DD]||(E.IncludesShadersStore[DD]=LH)});var LD,PH,vv=A(()=>{N();LD="bumpVertexDeclaration",PH=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) #if defined(TANGENT) && defined(NORMAL) varying mat3 vTBN; #endif #endif -`;E.IncludesShadersStore[ID]||(E.IncludesShadersStore[ID]=uH)});var xD,mH,$u=A(()=>{N();xD="lightVxFragmentDeclaration",mH=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[LD]||(E.IncludesShadersStore[LD]=PH)});var PD,OH,em=A(()=>{N();PD="lightVxFragmentDeclaration",OH=`#ifdef LIGHT{X} uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; #ifdef SPECULARTERM uniform vec4 vLightSpecular{X}; @@ -3574,7 +3574,7 @@ uniform vec3 vLightGround{X}; uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X}; #endif #endif -`;E.IncludesShadersStore[xD]||(E.IncludesShadersStore[xD]=mH)});var CD,pH,em=A(()=>{N();CD="lightVxUboDeclaration",pH=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[PD]||(E.IncludesShadersStore[PD]=OH)});var OD,NH,tm=A(()=>{N();OD="lightVxUboDeclaration",NH=`#ifdef LIGHT{X} uniform Light{X} {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; #ifdef SPOTLIGHT{X} @@ -3599,7 +3599,7 @@ varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 li #endif #endif #endif -`;E.IncludesShadersStore[CD]||(E.IncludesShadersStore[CD]=pH)});var bD,_H,Ga=A(()=>{N();bD="morphTargetsVertexGlobalDeclaration",_H=`#ifdef MORPHTARGETS +`;E.IncludesShadersStore[OD]||(E.IncludesShadersStore[OD]=NH)});var ND,FH,Ga=A(()=>{N();ND="morphTargetsVertexGlobalDeclaration",FH=`#ifdef MORPHTARGETS uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS]; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex) @@ -3620,7 +3620,7 @@ float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphT } #endif #endif -`;E.IncludesShadersStore[bD]||(E.IncludesShadersStore[bD]=_H)});var MD,gH,ka=A(()=>{N();MD="morphTargetsVertexDeclaration",gH=`#ifdef MORPHTARGETS +`;E.IncludesShadersStore[ND]||(E.IncludesShadersStore[ND]=FH)});var FD,wH,ka=A(()=>{N();FD="morphTargetsVertexDeclaration",wH=`#ifdef MORPHTARGETS #ifndef MORPHTARGETS_TEXTURE #ifdef MORPHTARGETS_POSITION attribute vec3 position{X}; @@ -3644,15 +3644,15 @@ attribute vec4 color{X}; uniform float morphTargetCount; #endif #endif -`;E.IncludesShadersStore[MD]||(E.IncludesShadersStore[MD]=gH)});var yD,EH,Oo=A(()=>{N();yD="logDepthDeclaration",EH=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStore[FD]||(E.IncludesShadersStore[FD]=wH)});var wD,BH,No=A(()=>{N();wD="logDepthDeclaration",BH=`#ifdef LOGARITHMICDEPTH uniform float logarithmicDepthConstant;varying float vFragmentDepth; #endif -`;E.IncludesShadersStore[yD]||(E.IncludesShadersStore[yD]=EH)});var DD,vH,Wa=A(()=>{N();DD="morphTargetsVertexGlobal",vH=`#ifdef MORPHTARGETS +`;E.IncludesShadersStore[wD]||(E.IncludesShadersStore[wD]=BH)});var BD,UH,Wa=A(()=>{N();BD="morphTargetsVertexGlobal",UH=`#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE float vertexID; #endif #endif -`;E.IncludesShadersStore[DD]||(E.IncludesShadersStore[DD]=vH)});var LD,TH,Ha=A(()=>{N();LD="morphTargetsVertex",TH=`#ifdef MORPHTARGETS +`;E.IncludesShadersStore[BD]||(E.IncludesShadersStore[BD]=UH)});var UD,VH,Ha=A(()=>{N();UD="morphTargetsVertex",VH=`#ifdef MORPHTARGETS #ifdef MORPHTARGETS_TEXTURE #if {X}==0 for (int i=0; i=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x; @@ -3712,7 +3712,7 @@ colorUpdated+=(color{X}-color)*morphTargetInfluences[{X}]; #endif #endif #endif -`;E.IncludesShadersStore[LD]||(E.IncludesShadersStore[LD]=TH)});var PD,SH,tm=A(()=>{N();PD="prePassVertex",SH=`#ifdef PREPASS_DEPTH +`;E.IncludesShadersStore[UD]||(E.IncludesShadersStore[UD]=VH)});var VD,GH,im=A(()=>{N();VD="prePassVertex",GH=`#ifdef PREPASS_DEPTH vViewPos=(view*worldPos).rgb; #endif #ifdef PREPASS_NORMALIZED_VIEW_DEPTH @@ -3751,13 +3751,13 @@ vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*ve vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); #endif #endif -`;E.IncludesShadersStore[PD]||(E.IncludesShadersStore[PD]=SH)});var OD,AH,im=A(()=>{N();OD="uvVariableDeclaration",AH=`#if !defined(UV{X}) && defined(MAINUV{X}) +`;E.IncludesShadersStore[VD]||(E.IncludesShadersStore[VD]=GH)});var GD,kH,rm=A(()=>{N();GD="uvVariableDeclaration",kH=`#if !defined(UV{X}) && defined(MAINUV{X}) vec2 uv{X}=vec2(0.,0.); #endif #ifdef MAINUV{X} vMainUV{X}=uv{X}; #endif -`;E.IncludesShadersStore[OD]||(E.IncludesShadersStore[OD]=AH)});var ND,RH,rm=A(()=>{N();ND="samplerVertexImplementation",RH=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +`;E.IncludesShadersStore[GD]||(E.IncludesShadersStore[GD]=kH)});var kD,WH,nm=A(()=>{N();kD="samplerVertexImplementation",WH=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 if (v_INFONAME_==0.) {v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));} #ifdef UV2 @@ -3781,12 +3781,12 @@ else if (v_INFONAME_==5.) {v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));} #endif #endif -`;E.IncludesShadersStore[ND]||(E.IncludesShadersStore[ND]=RH)});var FD,IH,nm=A(()=>{N();FD="bumpVertex",IH=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +`;E.IncludesShadersStore[kD]||(E.IncludesShadersStore[kD]=WH)});var WD,HH,sm=A(()=>{N();WD="bumpVertex",HH=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) #if defined(TANGENT) && defined(NORMAL) vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal); #endif #endif -`;E.IncludesShadersStore[FD]||(E.IncludesShadersStore[FD]=IH)});var wD,xH,sm=A(()=>{N();wD="shadowsVertex",xH=`#ifdef SHADOWS +`;E.IncludesShadersStore[WD]||(E.IncludesShadersStore[WD]=HH)});var HD,zH,am=A(()=>{N();HD="shadowsVertex",zH=`#ifdef SHADOWS #if defined(SHADOWCSM{X}) vPositionFromCamera{X}=view*worldPos;for (int i=0; i{N();BD="pointCloudVertex",CH=`#if defined(POINTSIZE) && !defined(WEBGPU) +`;E.IncludesShadersStore[HD]||(E.IncludesShadersStore[HD]=zH)});var zD,XH,Tv=A(()=>{N();zD="pointCloudVertex",XH=`#if defined(POINTSIZE) && !defined(WEBGPU) gl_PointSize=pointSize; #endif -`;E.IncludesShadersStore[BD]||(E.IncludesShadersStore[BD]=CH)});var UD,bH,am=A(()=>{N();UD="logDepthVertex",bH=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStore[zD]||(E.IncludesShadersStore[zD]=XH)});var XD,YH,om=A(()=>{N();XD="logDepthVertex",YH=`#ifdef LOGARITHMICDEPTH vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant; #endif -`;E.IncludesShadersStore[UD]||(E.IncludesShadersStore[UD]=bH)});var GD={};De(GD,{defaultVertexShader:()=>MH});var Ev,VD,MH,kD=A(()=>{N();_D();pv();qu();Gr();Fs();ws();Na();Qu();cc();Ju();_v();Bs();Pf();$u();em();Ga();ka();Oo();Wa();Ha();Us();Vs();Gs();tm();im();rm();nm();ks();Of();sm();Nf();gv();am();Ev="defaultVertexShader",VD=`#define CUSTOM_VERTEX_EXTENSION +`;E.IncludesShadersStore[XD]||(E.IncludesShadersStore[XD]=YH)});var KD={};De(KD,{defaultVertexShader:()=>KH});var Sv,YD,KH,jD=A(()=>{N();RD();Ev();Qu();Wr();Fs();ws();Na();Ju();cc();$u();vv();Bs();Pf();em();tm();Ga();ka();No();Wa();Ha();Us();Vs();Gs();im();rm();nm();sm();ks();Of();am();Nf();Tv();om();Sv="defaultVertexShader",YD=`#define CUSTOM_VERTEX_EXTENSION #include<__decl__defaultVertex> #define CUSTOM_VERTEX_BEGIN attribute vec3 position; @@ -3964,10 +3964,10 @@ vMainUV2=uv2Updated; #include #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStore[Ev]||(E.ShadersStore[Ev]=VD);MH={name:Ev,shader:VD}});var WD,yH,om=A(()=>{N();WD="decalFragmentDeclaration",yH=`#ifdef DECAL +`;E.ShadersStore[Sv]||(E.ShadersStore[Sv]=YD);KH={name:Sv,shader:YD}});var ZD,jH,lm=A(()=>{N();ZD="decalFragmentDeclaration",jH=`#ifdef DECAL uniform vec4 vDecalInfos; #endif -`;E.IncludesShadersStore[WD]||(E.IncludesShadersStore[WD]=yH)});var HD,DH,zD=A(()=>{N();om();HD="defaultFragmentDeclaration",DH=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility; +`;E.IncludesShadersStore[ZD]||(E.IncludesShadersStore[ZD]=jH)});var qD,ZH,QD=A(()=>{N();lm();qD="defaultFragmentDeclaration",ZH=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility; #ifdef DIFFUSE uniform vec2 vDiffuseInfos; #endif @@ -4035,7 +4035,7 @@ uniform vec4 vDetailInfos; #endif #include #define ADDITIONAL_FRAGMENT_DECLARATION -`;E.IncludesShadersStore[HD]||(E.IncludesShadersStore[HD]=DH)});var XD,LH,lm=A(()=>{N();XD="prePassDeclaration",LH=`#ifdef PREPASS +`;E.IncludesShadersStore[qD]||(E.IncludesShadersStore[qD]=ZH)});var JD,qH,cm=A(()=>{N();JD="prePassDeclaration",qH=`#ifdef PREPASS #extension GL_EXT_draw_buffers : require layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor; #ifdef PREPASS_LOCAL_POSITION @@ -4051,14 +4051,14 @@ varying highp float vNormViewDepth; varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition; #endif #endif -`;E.IncludesShadersStore[XD]||(E.IncludesShadersStore[XD]=LH)});var YD,PH,cm=A(()=>{N();YD="oitDeclaration",PH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY +`;E.IncludesShadersStore[JD]||(E.IncludesShadersStore[JD]=qH)});var $D,QH,fm=A(()=>{N();$D="oitDeclaration",QH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY #extension GL_EXT_draw_buffers : require layout(location=0) out vec2 depth; layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor; #define MAX_DEPTH 99999.0 highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler; #endif -`;E.IncludesShadersStore[YD]||(E.IncludesShadersStore[YD]=PH)});var KD,OH,fm=A(()=>{N();KD="lightFragmentDeclaration",OH=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[$D]||(E.IncludesShadersStore[$D]=QH)});var eL,JH,dm=A(()=>{N();eL="lightFragmentDeclaration",JH=`#ifdef LIGHT{X} uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; #ifdef SPECULARTERM uniform vec4 vLightSpecular{X}; @@ -4132,7 +4132,7 @@ uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X}; #endif #endif -`;E.IncludesShadersStore[KD]||(E.IncludesShadersStore[KD]=OH)});var jD,NH,dm=A(()=>{N();jD="lightUboDeclaration",NH=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[eL]||(E.IncludesShadersStore[eL]=JH)});var tL,$H,hm=A(()=>{N();tL="lightUboDeclaration",$H=`#ifdef LIGHT{X} uniform Light{X} {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; #ifdef SPOTLIGHT{X} @@ -4204,7 +4204,7 @@ uniform mat4 lightMatrix{X}; #endif #endif #endif -`;E.IncludesShadersStore[jD]||(E.IncludesShadersStore[jD]=NH)});var ZD,FH,vv=A(()=>{N();ZD="ltcHelperFunctions",FH=`vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;} +`;E.IncludesShadersStore[tL]||(E.IncludesShadersStore[tL]=$H)});var iL,e4,Av=A(()=>{N();iL="ltcHelperFunctions",e4=`vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;} float LTCClippedSphereFormFactor( const in vec3 f ) {float l=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );} vec3 LTCEdgeVectorFormFactor( const in vec3 v1,const in vec3 v2 ) {float x=dot( v1,v2 );float y=abs( x );float a=0.8543985+( 0.4965155+0.0145206*y )*y;float b=3.4175940+( 4.1616724+y )*y;float v=a/b;float thetaSintheta=0.0;if( x>0.0 ) {thetaSintheta=v;} @@ -4242,7 +4242,7 @@ vec3( 0,1, 0 ), vec3( t1.z,0,t1.w ) );result.Specular=LTCEvaluateWithEmission( normal,viewDir,position,mInv,rectCoords,texFilteredMap );result.Fresnel=t2; #endif -result.Diffuse=LTCEvaluateWithEmission( normal,viewDir,position,mat3( 1.0 ),rectCoords,texFilteredMap );return result;}`;E.IncludesShadersStore[ZD]||(E.IncludesShadersStore[ZD]=FH)});var qD,wH,Tv=A(()=>{N();qD="clusteredLightingFunctions",wH=`struct ClusteredLight {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;vec4 vLightDirection;vec4 vLightFalloff;}; +result.Diffuse=LTCEvaluateWithEmission( normal,viewDir,position,mat3( 1.0 ),rectCoords,texFilteredMap );return result;}`;E.IncludesShadersStore[iL]||(E.IncludesShadersStore[iL]=e4)});var rL,t4,Rv=A(()=>{N();rL="clusteredLightingFunctions",t4=`struct ClusteredLight {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;vec4 vLightDirection;vec4 vLightFalloff;}; #define inline ClusteredLight getClusteredLight(sampler2D lightDataTexture,int index) {return ClusteredLight( texelFetch(lightDataTexture,ivec2(0,index),0), @@ -4252,7 +4252,7 @@ texelFetch(lightDataTexture,ivec2(3,index),0), texelFetch(lightDataTexture,ivec2(4,index),0) );} int getClusteredSliceIndex(vec2 sliceData,float viewDepth) {return int(log(viewDepth)*sliceData.x+sliceData.y);} -`;E.IncludesShadersStore[qD]||(E.IncludesShadersStore[qD]=wH)});var QD,BH,JD=A(()=>{N();vv();Tv();QD="lightsFragmentFunctions",BH=`struct lightingInfo +`;E.IncludesShadersStore[rL]||(E.IncludesShadersStore[rL]=t4)});var nL,i4,sL=A(()=>{N();Av();Rv();nL="lightsFragmentFunctions",i4=`struct lightingInfo {vec3 diffuse; #ifdef SPECULARTERM vec3 specular; @@ -4356,7 +4356,7 @@ result.specular+=info.specular; batchOffset+=CLUSTLIGHT_BATCH;} return result;} #endif -`;E.IncludesShadersStore[QD]||(E.IncludesShadersStore[QD]=BH)});var $D,UH,hm=A(()=>{N();$D="shadowsFragmentFunctions",UH=`#ifdef SHADOWS +`;E.IncludesShadersStore[nL]||(E.IncludesShadersStore[nL]=i4)});var aL,r4,um=A(()=>{N();aL="shadowsFragmentFunctions",r4=`#ifdef SHADOWS #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) #define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l) #else @@ -4699,7 +4699,7 @@ float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depth {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} #endif #endif -`;E.IncludesShadersStore[$D]||(E.IncludesShadersStore[$D]=UH)});var eL,VH,No=A(()=>{N();eL="samplerFragmentDeclaration",VH=`#ifdef _DEFINENAME_ +`;E.IncludesShadersStore[aL]||(E.IncludesShadersStore[aL]=r4)});var oL,n4,Fo=A(()=>{N();oL="samplerFragmentDeclaration",n4=`#ifdef _DEFINENAME_ #if _DEFINENAME_DIRECTUV==1 #define v_VARYINGNAME_UV vMainUV1 #elif _DEFINENAME_DIRECTUV==2 @@ -4717,11 +4717,11 @@ varying vec2 v_VARYINGNAME_UV; #endif uniform sampler2D _SAMPLERNAME_Sampler; #endif -`;E.IncludesShadersStore[eL]||(E.IncludesShadersStore[eL]=VH)});var tL,GH,iL=A(()=>{N();tL="fresnelFunction",GH=`#ifdef FRESNEL +`;E.IncludesShadersStore[oL]||(E.IncludesShadersStore[oL]=n4)});var lL,s4,cL=A(()=>{N();lL="fresnelFunction",s4=`#ifdef FRESNEL float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power) {float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);} #endif -`;E.IncludesShadersStore[tL]||(E.IncludesShadersStore[tL]=GH)});var rL,kH,Xf=A(()=>{N();rL="reflectionFunction",kH=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction) +`;E.IncludesShadersStore[lL]||(E.IncludesShadersStore[lL]=s4)});var fL,a4,Xf=A(()=>{N();fL="reflectionFunction",a4=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction) {float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0); } vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction) {float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(1.0-s,t,0); } @@ -4783,7 +4783,7 @@ return vec3(0,0,0); #endif } #endif -`;E.IncludesShadersStore[rL]||(E.IncludesShadersStore[rL]=kH)});var nL,WH,um=A(()=>{N();nL="imageProcessingDeclaration",WH=`#ifdef EXPOSURE +`;E.IncludesShadersStore[fL]||(E.IncludesShadersStore[fL]=a4)});var dL,o4,mm=A(()=>{N();dL="imageProcessingDeclaration",o4=`#ifdef EXPOSURE uniform float exposureLinear; #endif #ifdef CONTRAST @@ -4809,7 +4809,7 @@ uniform vec4 colorTransformSettings; #ifdef DITHER uniform float ditherIntensity; #endif -`;E.IncludesShadersStore[nL]||(E.IncludesShadersStore[nL]=WH)});var sL,HH,mm=A(()=>{N();sL="imageProcessingFunctions",HH=`#if defined(COLORGRADING) && !defined(COLORGRADING3D) +`;E.IncludesShadersStore[dL]||(E.IncludesShadersStore[dL]=o4)});var hL,l4,pm=A(()=>{N();hL="imageProcessingFunctions",l4=`#if defined(COLORGRADING) && !defined(COLORGRADING3D) /** * Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL. * sampler3dSetting.x=textureOffset (0.5/textureSize). @@ -4897,7 +4897,7 @@ float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*- float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither)); #endif #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND -return result;}`;E.IncludesShadersStore[sL]||(E.IncludesShadersStore[sL]=HH)});var aL,zH,pm=A(()=>{N();aL="bumpFragmentMainFunctions",zH=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) +return result;}`;E.IncludesShadersStore[hL]||(E.IncludesShadersStore[hL]=l4)});var uL,c4,_m=A(()=>{N();uL="bumpFragmentMainFunctions",c4=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) #if defined(TANGENT) && defined(NORMAL) varying mat3 vTBN; #endif @@ -4958,7 +4958,7 @@ vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale) mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams) {vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);} #endif -`;E.IncludesShadersStore[aL]||(E.IncludesShadersStore[aL]=zH)});var oL,XH,_m=A(()=>{N();No();oL="bumpFragmentFunctions",XH=`#if defined(BUMP) +`;E.IncludesShadersStore[uL]||(E.IncludesShadersStore[uL]=c4)});var mL,f4,gm=A(()=>{N();Fo();mL="bumpFragmentFunctions",f4=`#if defined(BUMP) #include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) #endif #if defined(DETAIL) @@ -4988,7 +4988,7 @@ return -texCoordOffset; #endif } #endif -`;E.IncludesShadersStore[oL]||(E.IncludesShadersStore[oL]=XH)});var lL,YH,gm=A(()=>{N();lL="bumpFragment",YH=`vec2 uvOffset=vec2(0.0,0.0); +`;E.IncludesShadersStore[mL]||(E.IncludesShadersStore[mL]=f4)});var pL,d4,Em=A(()=>{N();pL="bumpFragment",d4=`vec2 uvOffset=vec2(0.0,0.0); #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) #ifdef NORMALXYSCALE float normalScale=1.0; @@ -5040,7 +5040,7 @@ normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y); #elif defined(DETAIL) detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); #endif -`;E.IncludesShadersStore[lL]||(E.IncludesShadersStore[lL]=YH)});var cL,KH,Sv=A(()=>{N();cL="decalFragment",KH=`#ifdef DECAL +`;E.IncludesShadersStore[pL]||(E.IncludesShadersStore[pL]=d4)});var _L,h4,Iv=A(()=>{N();_L="decalFragment",h4=`#ifdef DECAL #ifdef GAMMADECAL decalColor.rgb=toLinearSpace(decalColor.rgb); #endif @@ -5049,10 +5049,10 @@ decalColor.a*=decalColor.a; #endif surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a); #endif -`;E.IncludesShadersStore[cL]||(E.IncludesShadersStore[cL]=KH)});var fL,jH,Em=A(()=>{N();fL="depthPrePass",jH=`#ifdef DEPTHPREPASS +`;E.IncludesShadersStore[_L]||(E.IncludesShadersStore[_L]=h4)});var gL,u4,vm=A(()=>{N();gL="depthPrePass",u4=`#ifdef DEPTHPREPASS gl_FragColor=vec4(0.,0.,0.,1.0);return; #endif -`;E.IncludesShadersStore[fL]||(E.IncludesShadersStore[fL]=jH)});var dL,ZH,Av=A(()=>{N();dL="lightFragment",ZH=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[gL]||(E.IncludesShadersStore[gL]=u4)});var EL,m4,xv=A(()=>{N();EL="lightFragment",m4=`#ifdef LIGHT{X} #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) #else vec4 diffuse{X}=light{X}.vLightDiffuse; @@ -5430,10 +5430,10 @@ sheenBase+=info.sheen.rgb*shadow; #endif #endif #endif -`;E.IncludesShadersStore[dL]||(E.IncludesShadersStore[dL]=ZH)});var hL,qH,vm=A(()=>{N();hL="logDepthFragment",qH=`#ifdef LOGARITHMICDEPTH +`;E.IncludesShadersStore[EL]||(E.IncludesShadersStore[EL]=m4)});var vL,p4,Tm=A(()=>{N();vL="logDepthFragment",p4=`#ifdef LOGARITHMICDEPTH gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5; #endif -`;E.IncludesShadersStore[hL]||(E.IncludesShadersStore[hL]=qH)});var uL,QH,Tm=A(()=>{N();uL="oitFragment",QH=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY +`;E.IncludesShadersStore[vL]||(E.IncludesShadersStore[vL]=p4)});var TL,_4,Sm=A(()=>{N();TL="oitFragment",_4=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY float fragDepth=gl_FragCoord.z; #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x; @@ -5458,7 +5458,7 @@ if (fragDepth>nearestDepth && fragDepthJH});var Rv,mL,JH,_L=A(()=>{N();zD();pv();lm();cm();cc();Gr();fm();dm();JD();hm();No();iL();Xf();um();mm();pm();_m();Ws();Oo();Ff();Hs();gm();Sv();Em();Av();vm();wf();Tm();Rv="defaultPixelShader",mL=`#define CUSTOM_FRAGMENT_EXTENSION +`;E.IncludesShadersStore[TL]||(E.IncludesShadersStore[TL]=_4)});var AL={};De(AL,{defaultPixelShader:()=>g4});var Cv,SL,g4,RL=A(()=>{N();QD();Ev();cm();fm();cc();Wr();dm();hm();sL();um();Fo();cL();Xf();mm();pm();_m();gm();Ws();No();Ff();Hs();Em();Iv();vm();xv();Tm();wf();Sm();Cv="defaultPixelShader",SL=`#define CUSTOM_FRAGMENT_EXTENSION #include<__decl__defaultFragment> #if defined(BUMP) || !defined(NORMAL) #extension GL_OES_standard_derivatives : enable @@ -5807,10 +5807,10 @@ if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier; #endif #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStore[Rv]||(E.ShadersStore[Rv]=mL);JH={name:Rv,shader:mL}});var Iv,xv,Cv,bv,Re,Xs=A(()=>{Qe();qe();on();gr();et();yt();vu();Tu();sf();Ni();zr();xf();Lt();Wr();Da();av();kn();Cf();Oi();Kt();Su();Au();Ru();Iu();Iv={effect:null,subMesh:null},xv=class extends ac(sc(Zt)){},Cv=class extends rc(xv){constructor(e){super(e),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.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_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.NONUNIFORMSCALING=!1,this.PREMULTIPLYALPHA=!1,this.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,this.ALPHABLEND=!0,this.RGBDLIGHTMAP=!1,this.RGBDREFLECTION=!1,this.RGBDREFRACTION=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.IS_REFLECTION_LINEAR=!1,this.IS_REFRACTION_LINEAR=!1,this.DECAL_AFTER_DETAIL=!1,this.rebuild()}},bv=class extends oc(Xn){},Re=class n extends bv{get isPrePassCapable(){return!this.disableDepthWrite}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||n.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 oe(0,0,0),this.diffuseColor=new oe(1,1,1),this.specularColor=new oe(1,1,1),this.emissiveColor=new oe(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._vertexPullingMetadata=null,this._renderTargets=new Ct(16),this._globalAmbientColor=new oe(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new Xr(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new cr,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),n.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),n.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 n.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget||n.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===ae.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==ae.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();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new Cv(this._eventInfo.defineNames));let s=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let o=s.getEngine();if(a._needNormals=Gl(s,e,a,!0,this._maxSimultaneousLights,this._disableLighting),!Vl(s,e,this._maxSimultaneousLights,this._disableLighting))return!1;Hl(s,a);let l=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(s,a,this.canRenderToMRT&&!l),zl(s,a,l),Ui.PrepareDefines(o.currentRenderPassId,e,a),a._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a._needUVs=!1;for(let f=1;f<=6;++f)a["MAINUV"+f]=!1;if(s.texturesEnabled){if(a.DIFFUSEDIRECTUV=0,a.BUMPDIRECTUV=0,a.AMBIENTDIRECTUV=0,a.OPACITYDIRECTUV=0,a.EMISSIVEDIRECTUV=0,a.SPECULARDIRECTUV=0,a.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&n.DiffuseTextureEnabled)if(this._diffuseTexture.isReadyOrNotBlocking())at(this._diffuseTexture,a,"DIFFUSE");else return!1;else a.DIFFUSE=!1;if(this._ambientTexture&&n.AmbientTextureEnabled)if(this._ambientTexture.isReadyOrNotBlocking())at(this._ambientTexture,a,"AMBIENT");else return!1;else a.AMBIENT=!1;if(this._opacityTexture&&n.OpacityTextureEnabled)if(this._opacityTexture.isReadyOrNotBlocking())at(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB;else return!1;else a.OPACITY=!1;if(this._reflectionTexture&&n.ReflectionTextureEnabled?(a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha):(a.ROUGHNESS=!1,a.REFLECTIONOVERALPHA=!1),!Ra(s,this._reflectionTexture,a))return!1;if(this._emissiveTexture&&n.EmissiveTextureEnabled)if(this._emissiveTexture.isReadyOrNotBlocking())at(this._emissiveTexture,a,"EMISSIVE");else return!1;else a.EMISSIVE=!1;if(this._lightmapTexture&&n.LightmapTextureEnabled)if(this._lightmapTexture.isReadyOrNotBlocking())at(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD;else return!1;else a.LIGHTMAP=!1;if(this._specularTexture&&n.SpecularTextureEnabled)if(this._specularTexture.isReadyOrNotBlocking())at(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha;else return!1;else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&n.BumpTextureEnabled){if(this._bumpTexture.isReady())at(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=s.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion;else return!1;a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&n.RefractionTextureEnabled)if(this._refractionTexture.isReadyOrNotBlocking())a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize;else return!1;else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,a.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(a._areFresnelDirty&&(n.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),a.AREALIGHTUSED||a.CLUSTLIGHT_BATCH){for(let f=0;f{m.push(`vp_${L}_info`)}))}else this._vertexPullingMetadata=null;let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,a,h,T));let b=a.toString(),R=t.effect,S=s.getEngine().createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(Wy(),ky)),Promise.resolve().then(()=>(uD(),hD))]):await Promise.all([Promise.resolve().then(()=>(kD(),GD)),Promise.resolve().then(()=>(_L(),pL))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,S)if(this._onEffectCreatedObservable&&(Iv.effect=S,Iv.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Iv)),this.allowShaderHotSwapping&&R&&!S.isReady()){if(a.markAsUnprocessed(),c=this.isFrozen,f)return a._areLightsDisposed=!0,!1}else s.resetCachedMaterial(),t.setEffect(S,a,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(a._renderId=s.getRenderId(),r._wasPreviouslyReady=!c,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}buildUniformLayout(){let 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("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("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),e.addUniform("cameraInfo",4),Kl(e,!1,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var f;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Ui.Bind(r.getEngine().currentRenderPassId,this._activeEffect,t,e,this);let o=r.activeCamera;o?this._uniformBuffer.updateFloat4("cameraInfo",o.minZ,o.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let l=this._mustRebind(r,a,i,t.visibility);nr(t,a),this._vertexPullingMetadata&&Pa(a,this._vertexPullingMetadata);let c=this._uniformBuffer;if(l){if(this.bindViewProjection(a),!c.useUbo||!this.isFrozen||!c.isSync||i._drawWrapper._forceRebindOnNextCall){if(n.FresnelEnabled&&s.FRESNEL){if(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(c.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),c.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled){let d=Ri.Color3[0];d.set(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),c.updateColor4("opacityParts",d,this.opacityFresnelParameters.power)}this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(c.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),c.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(c.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),c.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(c.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),c.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))}if(r.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&(c.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ot(this._diffuseTexture,c,"diffuse")),this._ambientTexture&&n.AmbientTextureEnabled&&(c.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),ot(this._ambientTexture,c,"ambient")),this._opacityTexture&&n.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ot(this._opacityTexture,c,"opacity")),this._hasAlphaChannel()&&c.updateFloat("alphaCutOff",this.alphaCutOff),Pl(r,s,c,oe.White(),this._reflectionTexture,!1,!1,!0,!1,!1,!1,this.roughness),(!this._reflectionTexture||!n.ReflectionTextureEnabled)&&c.updateFloat2("vReflectionInfos",0,this.roughness),this._emissiveTexture&&n.EmissiveTextureEnabled&&(c.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ot(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&n.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ot(this._lightmapTexture,c,"lightmap")),this._specularTexture&&n.SpecularTextureEnabled&&(c.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),ot(this._specularTexture,c,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&(c.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),ot(this._bumpTexture,c,"bump"),r._mirroredCameraPosition?c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&n.RefractionTextureEnabled)){let d=1;if(this._refractionTexture.isCube||(c.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),c.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){let h=this._refractionTexture;c.updateVector3("vRefractionPosition",h.boundingBoxPosition),c.updateVector3("vRefractionSize",h.boundingBoxSize)}}this.pointsCloud&&c.updateFloat("pointSize",this.pointSize),c.updateColor4("vSpecularColor",this.specularColor,this.specularPower),c.updateColor3("vEmissiveColor",n.EmissiveTextureEnabled?this.emissiveColor:oe.BlackReadOnly),c.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),c.updateColor3("vAmbientColor",this._globalAmbientColor)}r.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&n.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&n.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&n.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&n.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&n.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&n.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&n.RefractionTextureEnabled&&(this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(a),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Li(a,this,r),this.bindEyePosition(a)}else r.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(l||!this.isFrozen)&&(r.lightsEnabled&&!this._disableLighting&&Nl(r,t,a,s,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==gt.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||s.PREPASS||s.CLUSTLIGHT_BATCH)&&this.bindView(a),Sa(r,t,a),s.NUM_MORPH_INFLUENCERS&&Pi(t,a),s.BAKED_VERTEX_ANIMATION_TEXTURE&&((f=t.bakedVertexAnimationManager)==null||f.bind(a,s.INSTANCES)),this.useLogarithmicDepth&&Ta(s,a,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),c.update()}getAnimatables(){let 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(){let 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,r,s,a,o,l,c,f,d;t&&((i=this._diffuseTexture)==null||i.dispose(),(r=this._ambientTexture)==null||r.dispose(),(s=this._opacityTexture)==null||s.dispose(),(a=this._reflectionTexture)==null||a.dispose(),(o=this._emissiveTexture)==null||o.dispose(),(l=this._specularTexture)==null||l.dispose(),(c=this._bumpTexture)==null||c.dispose(),(f=this._lightmapTexture)==null||f.dispose(),(d=this._refractionTexture)==null||d.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.name=e,r.id=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),r}static get DiffuseTextureEnabled(){return ie.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){ie.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return ie.DetailTextureEnabled}static set DetailTextureEnabled(e){ie.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return ie.AmbientTextureEnabled}static set AmbientTextureEnabled(e){ie.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return ie.OpacityTextureEnabled}static set OpacityTextureEnabled(e){ie.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return ie.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){ie.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return ie.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){ie.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return ie.SpecularTextureEnabled}static set SpecularTextureEnabled(e){ie.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return ie.BumpTextureEnabled}static set BumpTextureEnabled(e){ie.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return ie.LightmapTextureEnabled}static set LightmapTextureEnabled(e){ie.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return ie.RefractionTextureEnabled}static set RefractionTextureEnabled(e){ie.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return ie.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){ie.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return ie.FresnelEnabled}static set FresnelEnabled(e){ie.FresnelEnabled=e}};Re.ForceGLSL=!1;C([Ze("diffuseTexture")],Re.prototype,"_diffuseTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"diffuseTexture",void 0);C([Ze("ambientTexture")],Re.prototype,"_ambientTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"ambientTexture",void 0);C([Ze("opacityTexture")],Re.prototype,"_opacityTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"opacityTexture",void 0);C([Ze("reflectionTexture")],Re.prototype,"_reflectionTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"reflectionTexture",void 0);C([Ze("emissiveTexture")],Re.prototype,"_emissiveTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"emissiveTexture",void 0);C([Ze("specularTexture")],Re.prototype,"_specularTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"specularTexture",void 0);C([Ze("bumpTexture")],Re.prototype,"_bumpTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"bumpTexture",void 0);C([Ze("lightmapTexture")],Re.prototype,"_lightmapTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"lightmapTexture",void 0);C([Ze("refractionTexture")],Re.prototype,"_refractionTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"refractionTexture",void 0);C([Ht("ambient")],Re.prototype,"ambientColor",void 0);C([Ht("diffuse")],Re.prototype,"diffuseColor",void 0);C([Ht("specular")],Re.prototype,"specularColor",void 0);C([Ht("emissive")],Re.prototype,"emissiveColor",void 0);C([D()],Re.prototype,"specularPower",void 0);C([D("useAlphaFromDiffuseTexture")],Re.prototype,"_useAlphaFromDiffuseTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"useAlphaFromDiffuseTexture",void 0);C([D("useEmissiveAsIllumination")],Re.prototype,"_useEmissiveAsIllumination",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useEmissiveAsIllumination",void 0);C([D("linkEmissiveWithDiffuse")],Re.prototype,"_linkEmissiveWithDiffuse",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"linkEmissiveWithDiffuse",void 0);C([D("useSpecularOverAlpha")],Re.prototype,"_useSpecularOverAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useSpecularOverAlpha",void 0);C([D("useReflectionOverAlpha")],Re.prototype,"_useReflectionOverAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useReflectionOverAlpha",void 0);C([D("disableLighting")],Re.prototype,"_disableLighting",void 0);C([ee("_markAllSubMeshesAsLightsDirty")],Re.prototype,"disableLighting",void 0);C([D("useObjectSpaceNormalMap")],Re.prototype,"_useObjectSpaceNormalMap",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useObjectSpaceNormalMap",void 0);C([D("useParallax")],Re.prototype,"_useParallax",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useParallax",void 0);C([D("useParallaxOcclusion")],Re.prototype,"_useParallaxOcclusion",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useParallaxOcclusion",void 0);C([D()],Re.prototype,"parallaxScaleBias",void 0);C([D("roughness")],Re.prototype,"_roughness",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"roughness",void 0);C([D()],Re.prototype,"indexOfRefraction",void 0);C([D()],Re.prototype,"invertRefractionY",void 0);C([D()],Re.prototype,"alphaCutOff",void 0);C([D("useLightmapAsShadowmap")],Re.prototype,"_useLightmapAsShadowmap",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useLightmapAsShadowmap",void 0);C([dl("diffuseFresnelParameters")],Re.prototype,"_diffuseFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"diffuseFresnelParameters",void 0);C([dl("opacityFresnelParameters")],Re.prototype,"_opacityFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelAndMiscDirty")],Re.prototype,"opacityFresnelParameters",void 0);C([dl("reflectionFresnelParameters")],Re.prototype,"_reflectionFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"reflectionFresnelParameters",void 0);C([dl("refractionFresnelParameters")],Re.prototype,"_refractionFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"refractionFresnelParameters",void 0);C([dl("emissiveFresnelParameters")],Re.prototype,"_emissiveFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"emissiveFresnelParameters",void 0);C([D("useReflectionFresnelFromSpecular")],Re.prototype,"_useReflectionFresnelFromSpecular",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"useReflectionFresnelFromSpecular",void 0);C([D("useGlossinessFromSpecularMapAlpha")],Re.prototype,"_useGlossinessFromSpecularMapAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useGlossinessFromSpecularMapAlpha",void 0);C([D("maxSimultaneousLights")],Re.prototype,"_maxSimultaneousLights",void 0);C([ee("_markAllSubMeshesAsLightsDirty")],Re.prototype,"maxSimultaneousLights",void 0);C([D("invertNormalMapX")],Re.prototype,"_invertNormalMapX",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"invertNormalMapX",void 0);C([D("invertNormalMapY")],Re.prototype,"_invertNormalMapY",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"invertNormalMapY",void 0);C([D("twoSidedLighting")],Re.prototype,"_twoSidedLighting",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"twoSidedLighting",void 0);C([D("applyDecalMapAfterDetailMap")],Re.prototype,"_applyDecalMapAfterDetailMap",void 0);C([ee("_markAllSubMeshesAsMiscDirty")],Re.prototype,"applyDecalMapAfterDetailMap",void 0);je("BABYLON.StandardMaterial",Re);gt.DefaultMaterialFactory=n=>new Re("default material",n)});var gL,$H,Mv=A(()=>{N();gL="kernelBlurVaryingDeclaration",$H="varying sampleCoord{X}: vec2f;";E.IncludesShadersStoreWGSL[gL]||(E.IncludesShadersStoreWGSL[gL]=$H)});var EL,e4,Sm=A(()=>{N();EL="packingFunctions",e4=`fn pack(depth: f32)->vec4f +`;E.ShadersStore[Cv]||(E.ShadersStore[Cv]=SL);g4={name:Cv,shader:SL}});var bv,Mv,yv,Dv,Re,Xs=A(()=>{Qe();qe();cn();sr();et();yt();Tu();Su();sf();Fi();Yr();xf();Lt();zr();Da();cv();Wn();Cf();Ni();Kt();Au();Ru();Iu();xu();bv={effect:null,subMesh:null},Mv=class extends ac(sc(Zt)){},yv=class extends rc(Mv){constructor(e){super(e),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.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_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.NONUNIFORMSCALING=!1,this.PREMULTIPLYALPHA=!1,this.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,this.ALPHABLEND=!0,this.RGBDLIGHTMAP=!1,this.RGBDREFLECTION=!1,this.RGBDREFRACTION=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.IS_REFLECTION_LINEAR=!1,this.IS_REFRACTION_LINEAR=!1,this.DECAL_AFTER_DETAIL=!1,this.rebuild()}},Dv=class extends oc(Yn){},Re=class n extends Dv{get isPrePassCapable(){return!this.disableDepthWrite}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||n.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 oe(0,0,0),this.diffuseColor=new oe(1,1,1),this.specularColor=new oe(1,1,1),this.emissiveColor=new oe(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._vertexPullingMetadata=null,this._renderTargets=new Ct(16),this._globalAmbientColor=new oe(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new Kr(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new hr,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),n.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),n.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 n.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget||n.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===ae.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==ae.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();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new yv(this._eventInfo.defineNames));let s=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let o=s.getEngine();if(a._needNormals=Gl(s,e,a,!0,this._maxSimultaneousLights,this._disableLighting),!Vl(s,e,this._maxSimultaneousLights,this._disableLighting))return!1;Hl(s,a);let l=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(s,a,this.canRenderToMRT&&!l),zl(s,a,l),Vi.PrepareDefines(o.currentRenderPassId,e,a),a._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a._needUVs=!1;for(let f=1;f<=6;++f)a["MAINUV"+f]=!1;if(s.texturesEnabled){if(a.DIFFUSEDIRECTUV=0,a.BUMPDIRECTUV=0,a.AMBIENTDIRECTUV=0,a.OPACITYDIRECTUV=0,a.EMISSIVEDIRECTUV=0,a.SPECULARDIRECTUV=0,a.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&n.DiffuseTextureEnabled)if(this._diffuseTexture.isReadyOrNotBlocking())ot(this._diffuseTexture,a,"DIFFUSE");else return!1;else a.DIFFUSE=!1;if(this._ambientTexture&&n.AmbientTextureEnabled)if(this._ambientTexture.isReadyOrNotBlocking())ot(this._ambientTexture,a,"AMBIENT");else return!1;else a.AMBIENT=!1;if(this._opacityTexture&&n.OpacityTextureEnabled)if(this._opacityTexture.isReadyOrNotBlocking())ot(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB;else return!1;else a.OPACITY=!1;if(this._reflectionTexture&&n.ReflectionTextureEnabled?(a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha):(a.ROUGHNESS=!1,a.REFLECTIONOVERALPHA=!1),!Ra(s,this._reflectionTexture,a))return!1;if(this._emissiveTexture&&n.EmissiveTextureEnabled)if(this._emissiveTexture.isReadyOrNotBlocking())ot(this._emissiveTexture,a,"EMISSIVE");else return!1;else a.EMISSIVE=!1;if(this._lightmapTexture&&n.LightmapTextureEnabled)if(this._lightmapTexture.isReadyOrNotBlocking())ot(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD;else return!1;else a.LIGHTMAP=!1;if(this._specularTexture&&n.SpecularTextureEnabled)if(this._specularTexture.isReadyOrNotBlocking())ot(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha;else return!1;else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&n.BumpTextureEnabled){if(this._bumpTexture.isReady())ot(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=s.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion;else return!1;a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&n.RefractionTextureEnabled)if(this._refractionTexture.isReadyOrNotBlocking())a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize;else return!1;else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,a.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(a._areFresnelDirty&&(n.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),a.AREALIGHTUSED||a.CLUSTLIGHT_BATCH){for(let f=0;f{m.push(`vp_${L}_info`)}))}else this._vertexPullingMetadata=null;let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,a,h,T));let b=a.toString(),R=t.effect,S=s.getEngine().createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(Zy(),jy)),Promise.resolve().then(()=>(TD(),vD))]):await Promise.all([Promise.resolve().then(()=>(jD(),KD)),Promise.resolve().then(()=>(RL(),AL))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,S)if(this._onEffectCreatedObservable&&(bv.effect=S,bv.subMesh=t,this._onEffectCreatedObservable.notifyObservers(bv)),this.allowShaderHotSwapping&&R&&!S.isReady()){if(a.markAsUnprocessed(),c=this.isFrozen,f)return a._areLightsDisposed=!0,!1}else s.resetCachedMaterial(),t.setEffect(S,a,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(a._renderId=s.getRenderId(),r._wasPreviouslyReady=!c,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}buildUniformLayout(){let 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("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("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),e.addUniform("cameraInfo",4),Kl(e,!1,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var f;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Vi.Bind(r.getEngine().currentRenderPassId,this._activeEffect,t,e,this);let o=r.activeCamera;o?this._uniformBuffer.updateFloat4("cameraInfo",o.minZ,o.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let l=this._mustRebind(r,a,i,t.visibility);or(t,a),this._vertexPullingMetadata&&Pa(a,this._vertexPullingMetadata);let c=this._uniformBuffer;if(l){if(this.bindViewProjection(a),!c.useUbo||!this.isFrozen||!c.isSync||i._drawWrapper._forceRebindOnNextCall){if(n.FresnelEnabled&&s.FRESNEL){if(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(c.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),c.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled){let d=Ii.Color3[0];d.set(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),c.updateColor4("opacityParts",d,this.opacityFresnelParameters.power)}this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(c.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),c.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(c.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),c.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(c.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),c.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))}if(r.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&(c.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),lt(this._diffuseTexture,c,"diffuse")),this._ambientTexture&&n.AmbientTextureEnabled&&(c.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),lt(this._ambientTexture,c,"ambient")),this._opacityTexture&&n.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),lt(this._opacityTexture,c,"opacity")),this._hasAlphaChannel()&&c.updateFloat("alphaCutOff",this.alphaCutOff),Pl(r,s,c,oe.White(),this._reflectionTexture,!1,!1,!0,!1,!1,!1,this.roughness),(!this._reflectionTexture||!n.ReflectionTextureEnabled)&&c.updateFloat2("vReflectionInfos",0,this.roughness),this._emissiveTexture&&n.EmissiveTextureEnabled&&(c.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),lt(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&n.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),lt(this._lightmapTexture,c,"lightmap")),this._specularTexture&&n.SpecularTextureEnabled&&(c.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),lt(this._specularTexture,c,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&(c.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),lt(this._bumpTexture,c,"bump"),r._mirroredCameraPosition?c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):c.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&n.RefractionTextureEnabled)){let d=1;if(this._refractionTexture.isCube||(c.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),c.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){let h=this._refractionTexture;c.updateVector3("vRefractionPosition",h.boundingBoxPosition),c.updateVector3("vRefractionSize",h.boundingBoxSize)}}this.pointsCloud&&c.updateFloat("pointSize",this.pointSize),c.updateColor4("vSpecularColor",this.specularColor,this.specularPower),c.updateColor3("vEmissiveColor",n.EmissiveTextureEnabled?this.emissiveColor:oe.BlackReadOnly),c.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),c.updateColor3("vAmbientColor",this._globalAmbientColor)}r.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&n.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&n.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&n.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&n.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&n.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&n.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&n.RefractionTextureEnabled&&(this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(a),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Pi(a,this,r),this.bindEyePosition(a)}else r.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(l||!this.isFrozen)&&(r.lightsEnabled&&!this._disableLighting&&Nl(r,t,a,s,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==st.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||s.PREPASS||s.CLUSTLIGHT_BATCH)&&this.bindView(a),Sa(r,t,a),s.NUM_MORPH_INFLUENCERS&&Oi(t,a),s.BAKED_VERTEX_ANIMATION_TEXTURE&&((f=t.bakedVertexAnimationManager)==null||f.bind(a,s.INSTANCES)),this.useLogarithmicDepth&&Ta(s,a,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),c.update()}getAnimatables(){let 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(){let 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,r,s,a,o,l,c,f,d;t&&((i=this._diffuseTexture)==null||i.dispose(),(r=this._ambientTexture)==null||r.dispose(),(s=this._opacityTexture)==null||s.dispose(),(a=this._reflectionTexture)==null||a.dispose(),(o=this._emissiveTexture)==null||o.dispose(),(l=this._specularTexture)==null||l.dispose(),(c=this._bumpTexture)==null||c.dispose(),(f=this._lightmapTexture)==null||f.dispose(),(d=this._refractionTexture)==null||d.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.name=e,r.id=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),r}static get DiffuseTextureEnabled(){return ie.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){ie.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return ie.DetailTextureEnabled}static set DetailTextureEnabled(e){ie.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return ie.AmbientTextureEnabled}static set AmbientTextureEnabled(e){ie.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return ie.OpacityTextureEnabled}static set OpacityTextureEnabled(e){ie.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return ie.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){ie.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return ie.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){ie.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return ie.SpecularTextureEnabled}static set SpecularTextureEnabled(e){ie.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return ie.BumpTextureEnabled}static set BumpTextureEnabled(e){ie.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return ie.LightmapTextureEnabled}static set LightmapTextureEnabled(e){ie.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return ie.RefractionTextureEnabled}static set RefractionTextureEnabled(e){ie.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return ie.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){ie.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return ie.FresnelEnabled}static set FresnelEnabled(e){ie.FresnelEnabled=e}};Re.ForceGLSL=!1;C([Ze("diffuseTexture")],Re.prototype,"_diffuseTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"diffuseTexture",void 0);C([Ze("ambientTexture")],Re.prototype,"_ambientTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"ambientTexture",void 0);C([Ze("opacityTexture")],Re.prototype,"_opacityTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"opacityTexture",void 0);C([Ze("reflectionTexture")],Re.prototype,"_reflectionTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"reflectionTexture",void 0);C([Ze("emissiveTexture")],Re.prototype,"_emissiveTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"emissiveTexture",void 0);C([Ze("specularTexture")],Re.prototype,"_specularTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"specularTexture",void 0);C([Ze("bumpTexture")],Re.prototype,"_bumpTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"bumpTexture",void 0);C([Ze("lightmapTexture")],Re.prototype,"_lightmapTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"lightmapTexture",void 0);C([Ze("refractionTexture")],Re.prototype,"_refractionTexture",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"refractionTexture",void 0);C([Ht("ambient")],Re.prototype,"ambientColor",void 0);C([Ht("diffuse")],Re.prototype,"diffuseColor",void 0);C([Ht("specular")],Re.prototype,"specularColor",void 0);C([Ht("emissive")],Re.prototype,"emissiveColor",void 0);C([D()],Re.prototype,"specularPower",void 0);C([D("useAlphaFromDiffuseTexture")],Re.prototype,"_useAlphaFromDiffuseTexture",void 0);C([ee("_markAllSubMeshesAsTexturesAndMiscDirty")],Re.prototype,"useAlphaFromDiffuseTexture",void 0);C([D("useEmissiveAsIllumination")],Re.prototype,"_useEmissiveAsIllumination",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useEmissiveAsIllumination",void 0);C([D("linkEmissiveWithDiffuse")],Re.prototype,"_linkEmissiveWithDiffuse",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"linkEmissiveWithDiffuse",void 0);C([D("useSpecularOverAlpha")],Re.prototype,"_useSpecularOverAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useSpecularOverAlpha",void 0);C([D("useReflectionOverAlpha")],Re.prototype,"_useReflectionOverAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useReflectionOverAlpha",void 0);C([D("disableLighting")],Re.prototype,"_disableLighting",void 0);C([ee("_markAllSubMeshesAsLightsDirty")],Re.prototype,"disableLighting",void 0);C([D("useObjectSpaceNormalMap")],Re.prototype,"_useObjectSpaceNormalMap",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useObjectSpaceNormalMap",void 0);C([D("useParallax")],Re.prototype,"_useParallax",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useParallax",void 0);C([D("useParallaxOcclusion")],Re.prototype,"_useParallaxOcclusion",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useParallaxOcclusion",void 0);C([D()],Re.prototype,"parallaxScaleBias",void 0);C([D("roughness")],Re.prototype,"_roughness",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"roughness",void 0);C([D()],Re.prototype,"indexOfRefraction",void 0);C([D()],Re.prototype,"invertRefractionY",void 0);C([D()],Re.prototype,"alphaCutOff",void 0);C([D("useLightmapAsShadowmap")],Re.prototype,"_useLightmapAsShadowmap",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useLightmapAsShadowmap",void 0);C([hl("diffuseFresnelParameters")],Re.prototype,"_diffuseFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"diffuseFresnelParameters",void 0);C([hl("opacityFresnelParameters")],Re.prototype,"_opacityFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelAndMiscDirty")],Re.prototype,"opacityFresnelParameters",void 0);C([hl("reflectionFresnelParameters")],Re.prototype,"_reflectionFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"reflectionFresnelParameters",void 0);C([hl("refractionFresnelParameters")],Re.prototype,"_refractionFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"refractionFresnelParameters",void 0);C([hl("emissiveFresnelParameters")],Re.prototype,"_emissiveFresnelParameters",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"emissiveFresnelParameters",void 0);C([D("useReflectionFresnelFromSpecular")],Re.prototype,"_useReflectionFresnelFromSpecular",void 0);C([ee("_markAllSubMeshesAsFresnelDirty")],Re.prototype,"useReflectionFresnelFromSpecular",void 0);C([D("useGlossinessFromSpecularMapAlpha")],Re.prototype,"_useGlossinessFromSpecularMapAlpha",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"useGlossinessFromSpecularMapAlpha",void 0);C([D("maxSimultaneousLights")],Re.prototype,"_maxSimultaneousLights",void 0);C([ee("_markAllSubMeshesAsLightsDirty")],Re.prototype,"maxSimultaneousLights",void 0);C([D("invertNormalMapX")],Re.prototype,"_invertNormalMapX",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"invertNormalMapX",void 0);C([D("invertNormalMapY")],Re.prototype,"_invertNormalMapY",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"invertNormalMapY",void 0);C([D("twoSidedLighting")],Re.prototype,"_twoSidedLighting",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],Re.prototype,"twoSidedLighting",void 0);C([D("applyDecalMapAfterDetailMap")],Re.prototype,"_applyDecalMapAfterDetailMap",void 0);C([ee("_markAllSubMeshesAsMiscDirty")],Re.prototype,"applyDecalMapAfterDetailMap",void 0);je("BABYLON.StandardMaterial",Re);st.DefaultMaterialFactory=n=>new Re("default material",n)});var IL,E4,Lv=A(()=>{N();IL="kernelBlurVaryingDeclaration",E4="varying sampleCoord{X}: vec2f;";E.IncludesShadersStoreWGSL[IL]||(E.IncludesShadersStoreWGSL[IL]=E4)});var xL,v4,Am=A(()=>{N();xL="packingFunctions",v4=`fn pack(depth: f32)->vec4f {const bit_shift: vec4f= vec4f(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const bit_mask: vec4f= vec4f(0.0,1.0/255.0,1.0/255.0,1.0/255.0);var res: vec4f=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} fn unpack(color: vec4f)->f32 -{const bit_shift: vec4f= vec4f(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`;E.IncludesShadersStoreWGSL[EL]||(E.IncludesShadersStoreWGSL[EL]=e4)});var vL,t4,TL=A(()=>{N();vL="kernelBlurFragment",t4=`#ifdef DOF +{const bit_shift: vec4f= vec4f(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`;E.IncludesShadersStoreWGSL[xL]||(E.IncludesShadersStoreWGSL[xL]=v4)});var CL,T4,bL=A(()=>{N();CL="kernelBlurFragment",T4=`#ifdef DOF factor=sampleCoC(fragmentInputs.sampleCoord{X}); computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight; #else @@ -5821,7 +5821,7 @@ blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs. #else blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCoord{X})*computedWeight; #endif -`;E.IncludesShadersStoreWGSL[vL]||(E.IncludesShadersStoreWGSL[vL]=t4)});var SL,i4,AL=A(()=>{N();SL="kernelBlurFragment2",i4=`#ifdef DOF +`;E.IncludesShadersStoreWGSL[CL]||(E.IncludesShadersStoreWGSL[CL]=T4)});var ML,S4,yL=A(()=>{N();ML="kernelBlurFragment2",S4=`#ifdef DOF factor=sampleCoC(fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight; #else computedWeight=KERNEL_DEP_WEIGHT{X}; @@ -5831,7 +5831,7 @@ blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs. #else blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X})*computedWeight; #endif -`;E.IncludesShadersStoreWGSL[SL]||(E.IncludesShadersStoreWGSL[SL]=i4)});var IL={};De(IL,{kernelBlurPixelShaderWGSL:()=>r4});var yv,RL,r4,xL=A(()=>{N();Mv();Sm();TL();AL();yv="kernelBlurPixelShader",RL=`var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform delta: vec2f;varying sampleCenter: vec2f; +`;E.IncludesShadersStoreWGSL[ML]||(E.IncludesShadersStoreWGSL[ML]=S4)});var LL={};De(LL,{kernelBlurPixelShaderWGSL:()=>A4});var Pv,DL,A4,PL=A(()=>{N();Lv();Am();bL();yL();Pv="kernelBlurPixelShader",DL=`var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform delta: vec2f;varying sampleCenter: vec2f; #ifdef DOF var circleOfConfusionSamplerSampler: sampler;var circleOfConfusionSampler: texture_2d;fn sampleCoC(offset: vec2f)->f32 {var coc: f32=textureSample(circleOfConfusionSampler,circleOfConfusionSamplerSampler,offset).r;return coc; } #endif @@ -5866,7 +5866,7 @@ fragmentOutputs.color=blend; #ifdef DOF fragmentOutputs.color/=sumOfWeights; #endif -}`;E.ShadersStoreWGSL[yv]||(E.ShadersStoreWGSL[yv]=RL);r4={name:yv,shader:RL}});var CL,n4,bL=A(()=>{N();CL="kernelBlurVertex",n4="vertexOutputs.sampleCoord{X}=vertexOutputs.sampleCenter+uniforms.delta*KERNEL_OFFSET{X};";E.IncludesShadersStoreWGSL[CL]||(E.IncludesShadersStoreWGSL[CL]=n4)});var yL={};De(yL,{kernelBlurVertexShaderWGSL:()=>s4});var Dv,ML,s4,DL=A(()=>{N();Mv();bL();Dv="kernelBlurVertexShader",ML=`attribute position: vec2f;uniform delta: vec2f;varying sampleCenter: vec2f; +}`;E.ShadersStoreWGSL[Pv]||(E.ShadersStoreWGSL[Pv]=DL);A4={name:Pv,shader:DL}});var OL,R4,NL=A(()=>{N();OL="kernelBlurVertex",R4="vertexOutputs.sampleCoord{X}=vertexOutputs.sampleCenter+uniforms.delta*KERNEL_OFFSET{X};";E.IncludesShadersStoreWGSL[OL]||(E.IncludesShadersStoreWGSL[OL]=R4)});var wL={};De(wL,{kernelBlurVertexShaderWGSL:()=>I4});var Ov,FL,I4,BL=A(()=>{N();Lv();NL();Ov="kernelBlurVertexShader",FL=`attribute position: vec2f;uniform delta: vec2f;varying sampleCenter: vec2f; #include[0..varyingCount] #define CUSTOM_VERTEX_DEFINITIONS @vertex @@ -5876,10 +5876,10 @@ vertexOutputs.sampleCenter=(vertexInputs.position*madd+madd); #include[0..varyingCount] vertexOutputs.position= vec4f(vertexInputs.position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStoreWGSL[Dv]||(E.ShadersStoreWGSL[Dv]=ML);s4={name:Dv,shader:ML}});var LL,a4,Lv=A(()=>{N();LL="kernelBlurVaryingDeclaration",a4="varying vec2 sampleCoord{X};";E.IncludesShadersStore[LL]||(E.IncludesShadersStore[LL]=a4)});var PL,o4,Am=A(()=>{N();PL="packingFunctions",o4=`vec4 pack(float depth) +}`;E.ShadersStoreWGSL[Ov]||(E.ShadersStoreWGSL[Ov]=FL);I4={name:Ov,shader:FL}});var UL,x4,Nv=A(()=>{N();UL="kernelBlurVaryingDeclaration",x4="varying vec2 sampleCoord{X};";E.IncludesShadersStore[UL]||(E.IncludesShadersStore[UL]=x4)});var VL,C4,Rm=A(()=>{N();VL="packingFunctions",C4=`vec4 pack(float depth) {const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} float unpack(vec4 color) -{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`;E.IncludesShadersStore[PL]||(E.IncludesShadersStore[PL]=o4)});var OL,l4,NL=A(()=>{N();OL="kernelBlurFragment",l4=`#ifdef DOF +{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`;E.IncludesShadersStore[VL]||(E.IncludesShadersStore[VL]=C4)});var GL,b4,kL=A(()=>{N();GL="kernelBlurFragment",b4=`#ifdef DOF factor=sampleCoC(sampleCoord{X}); computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight; #else @@ -5890,7 +5890,7 @@ blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight; #else blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight; #endif -`;E.IncludesShadersStore[OL]||(E.IncludesShadersStore[OL]=l4)});var FL,c4,wL=A(()=>{N();FL="kernelBlurFragment2",c4=`#ifdef DOF +`;E.IncludesShadersStore[GL]||(E.IncludesShadersStore[GL]=b4)});var WL,M4,HL=A(()=>{N();WL="kernelBlurFragment2",M4=`#ifdef DOF factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight; #else computedWeight=KERNEL_DEP_WEIGHT{X}; @@ -5900,7 +5900,7 @@ blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})) #else blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight; #endif -`;E.IncludesShadersStore[FL]||(E.IncludesShadersStore[FL]=c4)});var UL={};De(UL,{kernelBlurPixelShader:()=>f4});var Pv,BL,f4,VL=A(()=>{N();Lv();Am();NL();wL();Pv="kernelBlurPixelShader",BL=`uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter; +`;E.IncludesShadersStore[WL]||(E.IncludesShadersStore[WL]=M4)});var XL={};De(XL,{kernelBlurPixelShader:()=>y4});var Fv,zL,y4,YL=A(()=>{N();Nv();Rm();kL();HL();Fv="kernelBlurPixelShader",zL=`uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter; #ifdef DOF uniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; } #endif @@ -5935,7 +5935,7 @@ gl_FragColor=blend; #ifdef DOF gl_FragColor/=sumOfWeights; #endif -}`;E.ShadersStore[Pv]||(E.ShadersStore[Pv]=BL);f4={name:Pv,shader:BL}});var GL,d4,kL=A(()=>{N();GL="kernelBlurVertex",d4="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";E.IncludesShadersStore[GL]||(E.IncludesShadersStore[GL]=d4)});var HL={};De(HL,{kernelBlurVertexShader:()=>h4});var Ov,WL,h4,zL=A(()=>{N();Lv();kL();Ov="kernelBlurVertexShader",WL=`attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter; +}`;E.ShadersStore[Fv]||(E.ShadersStore[Fv]=zL);y4={name:Fv,shader:zL}});var KL,D4,jL=A(()=>{N();KL="kernelBlurVertex",D4="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";E.IncludesShadersStore[KL]||(E.IncludesShadersStore[KL]=D4)});var qL={};De(qL,{kernelBlurVertexShader:()=>L4});var wv,ZL,L4,QL=A(()=>{N();Nv();jL();wv="kernelBlurVertexShader",ZL=`attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter; #include[0..varyingCount] const vec2 madd=vec2(0.5,0.5); #define CUSTOM_VERTEX_DEFINITIONS @@ -5945,13 +5945,13 @@ sampleCenter=(position*madd+madd); #include[0..varyingCount] gl_Position=vec4(position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStore[Ov]||(E.ShadersStore[Ov]=WL);h4={name:Ov,shader:WL}});var Xi,Nv=A(()=>{Eo();At();Xi=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(xL(),IL)),Promise.resolve().then(()=>(DL(),yL))]))):t.push(Promise.all([Promise.resolve().then(()=>(VL(),UL)),Promise.resolve().then(()=>(zL(),HL))]))}constructor(e,t=null,i,r,s){let a=!!(s!=null&&s.blockCompilation);super({...s,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,samplers:n.Samplers,vertexUrl:n.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this._staticDefines=s?Array.isArray(s.defines)?s.defines.join(` +}`;E.ShadersStore[wv]||(E.ShadersStore[wv]=ZL);L4={name:wv,shader:ZL}});var Ki,Bv=A(()=>{Eo();At();Ki=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(PL(),LL)),Promise.resolve().then(()=>(BL(),wL))]))):t.push(Promise.all([Promise.resolve().then(()=>(YL(),XL)),Promise.resolve().then(()=>(QL(),qL))]))}constructor(e,t=null,i,r,s){let a=!!(s!=null&&s.blockCompilation);super({...s,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,samplers:n.Samplers,vertexUrl:n.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this._staticDefines=s?Array.isArray(s.defines)?s.defines.join(` `):s.defines||"":"",this.options.blockCompilation=a,i!==void 0&&(this.direction=i),r!==void 0&&(this.kernel=r)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(e=!1){super.bind(e),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,1/this.textureHeight*this.direction.y)}_updateParameters(e,t){let i=this._kernel,r=(i-1)/2,s=[],a=[],o=0;for(let _=0;_0)return Math.max(i,3);return Math.max(t,3)}_gaussianWeight(e){let t=.3333333333333333,i=Math.sqrt(2*Math.PI)*t,r=-(e*e/(2*t*t));return 1/i*Math.exp(r)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}};Xi.VertexUrl="kernelBlur";Xi.FragmentUrl="kernelBlur";Xi.Uniforms=["delta","direction"];Xi.Samplers=["circleOfConfusionSampler"]});var Yr,Fv=A(()=>{Qe();ms();oi();Lt();qe();Kt();Nv();Yr=class n extends _t{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,r,s=null,a=ne.BILINEAR_SAMPLINGMODE,o,l,c=0,f="",d=!1,h=5){let u=typeof r=="number"?d:!!r.blockCompilation,m={uniforms:Xi.Uniforms,samplers:Xi.Samplers,size:typeof r=="number"?r:void 0,camera:s,samplingMode:a,engine:o,reusable:l,textureType:c,vertexUrl:Xi.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:h,defines:f,...r,blockCompilation:!0};super(e,Xi.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new Xi(e,o,void 0,void 0,m):void 0,...m}),this._effectWrapper.options.blockCompilation=u,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,r,s,a){this._effectWrapper._updateParameters(s,a)}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1),e,i,r)}};C([hl()],Yr.prototype,"direction",null);C([D()],Yr.prototype,"kernel",null);C([D()],Yr.prototype,"packedFloat",null);je("BABYLON.BlurPostProcess",Yr)});var XL,u4,YL=A(()=>{N();XL="bayerDitherFunctions",u4=`fn bayerDither2(_P: vec2f)->f32 {return ((2.0*_P.y+_P.x+1.0)%(4.0));} +`,p++;this.packedFloat&&(m+="#define PACKEDFLOAT 1"),this.options.blockCompilation=!1,this.updateEffect(m,null,null,{varyingCount:u,depCount:p},e,t)}_nearestBestKernel(e){let t=Math.round(e);for(let 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){let t=.3333333333333333,i=Math.sqrt(2*Math.PI)*t,r=-(e*e/(2*t*t));return 1/i*Math.exp(r)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}};Ki.VertexUrl="kernelBlur";Ki.FragmentUrl="kernelBlur";Ki.Uniforms=["delta","direction"];Ki.Samplers=["circleOfConfusionSampler"]});var jr,Uv=A(()=>{Qe();ps();oi();Lt();qe();Kt();Bv();jr=class n extends gt{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,r,s=null,a=ne.BILINEAR_SAMPLINGMODE,o,l,c=0,f="",d=!1,h=5){let u=typeof r=="number"?d:!!r.blockCompilation,m={uniforms:Ki.Uniforms,samplers:Ki.Samplers,size:typeof r=="number"?r:void 0,camera:s,samplingMode:a,engine:o,reusable:l,textureType:c,vertexUrl:Ki.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:h,defines:f,...r,blockCompilation:!0};super(e,Ki.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new Ki(e,o,void 0,void 0,m):void 0,...m}),this._effectWrapper.options.blockCompilation=u,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,r,s,a){this._effectWrapper._updateParameters(s,a)}static _Parse(e,t,i,r){return Me.Parse(()=>new n(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1),e,i,r)}};C([ul()],jr.prototype,"direction",null);C([D()],jr.prototype,"kernel",null);C([D()],jr.prototype,"packedFloat",null);je("BABYLON.BlurPostProcess",jr)});var JL,P4,$L=A(()=>{N();JL="bayerDitherFunctions",P4=`fn bayerDither2(_P: vec2f)->f32 {return ((2.0*_P.y+_P.x+1.0)%(4.0));} fn bayerDither4(_P: vec2f)->f32 {var P1: vec2f=((_P)%(2.0)); var P2: vec2f=floor(0.5*((_P)%(4.0))); return 4.0*bayerDither2(P1)+bayerDither2(P2);} @@ -5959,7 +5959,7 @@ fn bayerDither8(_P: vec2f)->f32 {var P1: vec2f=((_P)%(2.0)); var P2: vec2f=floor(0.5 *((_P)%(4.0))); var P4: vec2f=floor(0.25*((_P)%(8.0))); return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);} -`;E.IncludesShadersStoreWGSL[XL]||(E.IncludesShadersStoreWGSL[XL]=u4)});var KL,m4,jL=A(()=>{N();Sm();YL();KL="shadowMapFragmentExtraDeclaration",m4=`#if SM_FLOAT==0 +`;E.IncludesShadersStoreWGSL[JL]||(E.IncludesShadersStoreWGSL[JL]=P4)});var eP,O4,tP=A(()=>{N();Am();$L();eP="shadowMapFragmentExtraDeclaration",O4=`#if SM_FLOAT==0 #include #endif #if SM_SOFTTRANSPARENTSHADOW==1 @@ -5974,7 +5974,7 @@ uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 varying zSM: f32; #endif -`;E.IncludesShadersStoreWGSL[KL]||(E.IncludesShadersStoreWGSL[KL]=m4)});var ZL,p4,qL=A(()=>{N();ZL="shadowMapFragment",p4=`var depthSM: f32=fragmentInputs.vDepthMetricSM; +`;E.IncludesShadersStoreWGSL[eP]||(E.IncludesShadersStoreWGSL[eP]=O4)});var iP,N4,rP=A(()=>{N();iP="shadowMapFragment",N4=`var depthSM: f32=fragmentInputs.vDepthMetricSM; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 #if SM_USEDISTANCE==1 depthSM=(length(fragmentInputs.vPositionWSM-uniforms.lightDataSM)+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; @@ -6002,7 +6002,7 @@ fragmentOutputs.color= vec4f(depthSM,1.0,1.0,1.0); #else fragmentOutputs.color=pack(depthSM); #endif -`;E.IncludesShadersStoreWGSL[ZL]||(E.IncludesShadersStoreWGSL[ZL]=p4)});var JL={};De(JL,{shadowMapPixelShaderWGSL:()=>_4});var wv,QL,_4,$L=A(()=>{N();jL();Os();Ns();qL();wv="shadowMapPixelShader",QL=`#include +`;E.IncludesShadersStoreWGSL[iP]||(E.IncludesShadersStoreWGSL[iP]=N4)});var sP={};De(sP,{shadowMapPixelShaderWGSL:()=>F4});var Vv,nP,F4,aP=A(()=>{N();tP();Os();Ns();rP();Vv="shadowMapPixelShader",nP=`#include #ifdef ALPHATEXTURE varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; #endif @@ -6028,7 +6028,7 @@ if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.s #endif #endif #include -}`;E.ShadersStoreWGSL[wv]||(E.ShadersStoreWGSL[wv]=QL);_4={name:wv,shader:QL}});var eP,g4,tP=A(()=>{N();eP="shadowMapVertexExtraDeclaration",g4=`#if SM_NORMALBIAS==1 +}`;E.ShadersStoreWGSL[Vv]||(E.ShadersStoreWGSL[Vv]=nP);F4={name:Vv,shader:nP}});var oP,w4,lP=A(()=>{N();oP="shadowMapVertexExtraDeclaration",w4=`#if SM_NORMALBIAS==1 uniform lightDataSM: vec3f; #endif uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f;varying vDepthMetricSM: f32; @@ -6038,7 +6038,7 @@ varying vPositionWSM: vec3f; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 varying zSM: f32; #endif -`;E.IncludesShadersStoreWGSL[eP]||(E.IncludesShadersStoreWGSL[eP]=g4)});var iP,E4,rP=A(()=>{N();iP="shadowMapVertexNormalBias",E4=`#if SM_NORMALBIAS==1 +`;E.IncludesShadersStoreWGSL[oP]||(E.IncludesShadersStoreWGSL[oP]=w4)});var cP,B4,fP=A(()=>{N();cP="shadowMapVertexNormalBias",B4=`#if SM_NORMALBIAS==1 #if SM_DIRECTIONINLIGHTDATA==1 var worldLightDirSM: vec3f=normalize(-uniforms.lightDataSM.xyz); #else @@ -6046,7 +6046,7 @@ var directionToLightSM: vec3f=uniforms.lightDataSM.xyz-worldPos.xyz;var worldLig #endif var ndlSM: f32=dot(vNormalW,worldLightDirSM);var sinNLSM: f32=sqrt(1.0-ndlSM*ndlSM);var normalBiasSM: f32=uniforms.biasAndScaleSM.y*sinNLSM;worldPos=vec4f(worldPos.xyz-vNormalW*normalBiasSM,worldPos.w); #endif -`;E.IncludesShadersStoreWGSL[iP]||(E.IncludesShadersStoreWGSL[iP]=E4)});var nP,v4,sP=A(()=>{N();nP="shadowMapVertexMetric",v4=`#if SM_USEDISTANCE==1 +`;E.IncludesShadersStoreWGSL[cP]||(E.IncludesShadersStoreWGSL[cP]=B4)});var dP,U4,hP=A(()=>{N();dP="shadowMapVertexMetric",U4=`#if SM_USEDISTANCE==1 vertexOutputs.vPositionWSM=worldPos.xyz; #endif #if SM_DEPTHTEXTURE==1 @@ -6070,7 +6070,7 @@ vertexOutputs.vDepthMetricSM=(-vertexOutputs.position.z+uniforms.depthValuesSM.x vertexOutputs.vDepthMetricSM=(vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; #endif #endif -`;E.IncludesShadersStoreWGSL[nP]||(E.IncludesShadersStoreWGSL[nP]=v4)});var oP={};De(oP,{shadowMapVertexShaderWGSL:()=>T4});var Bv,aP,T4,lP=A(()=>{N();Cs();bs();wa();Ba();Vr();yo();Wf();tP();Ms();Ua();Va();ys();Ds();Ls();rP();sP();Ps();Bv="shadowMapVertexShader",aP=`attribute position: vec3f; +`;E.IncludesShadersStoreWGSL[dP]||(E.IncludesShadersStoreWGSL[dP]=U4)});var mP={};De(mP,{shadowMapVertexShaderWGSL:()=>V4});var Gv,uP,V4,pP=A(()=>{N();Cs();bs();wa();Ba();kr();Do();Wf();lP();Ms();Ua();Va();ys();Ds();Ls();fP();hP();Ps();Gv="shadowMapVertexShader",uP=`attribute position: vec3f; #ifdef NORMAL attribute normal: vec3f; #endif @@ -6136,14 +6136,14 @@ vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; #endif #endif #include -}`;E.ShadersStoreWGSL[Bv]||(E.ShadersStoreWGSL[Bv]=aP);T4={name:Bv,shader:aP}});var fP={};De(fP,{depthBoxBlurPixelShaderWGSL:()=>S4});var Uv,cP,S4,dP=A(()=>{N();Uv="depthBoxBlurPixelShader",cP=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform screenSize: vec2f; +}`;E.ShadersStoreWGSL[Gv]||(E.ShadersStoreWGSL[Gv]=uP);V4={name:Gv,shader:uP}});var gP={};De(gP,{depthBoxBlurPixelShaderWGSL:()=>G4});var kv,_P,G4,EP=A(()=>{N();kv="depthBoxBlurPixelShader",_P=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform screenSize: vec2f; #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs {var colorDepth: vec4f=vec4f(0.0);for (var x: i32=-OFFSET; x<=OFFSET; x++) {for (var y: i32=-OFFSET; y<=OFFSET; y++) {colorDepth+=textureSample(textureSampler,textureSamplerSampler,input.vUV+ vec2f(f32(x),f32(y))/uniforms.screenSize);}} -fragmentOutputs.color=(colorDepth/ f32((OFFSET*2+1)*(OFFSET*2+1)));}`;E.ShadersStoreWGSL[Uv]||(E.ShadersStoreWGSL[Uv]=cP);S4={name:Uv,shader:cP}});var uP={};De(uP,{shadowMapFragmentSoftTransparentShadowWGSL:()=>A4});var Vv,hP,A4,mP=A(()=>{N();Vv="shadowMapFragmentSoftTransparentShadow",hP=`#if SM_SOFTTRANSPARENTSHADOW==1 +fragmentOutputs.color=(colorDepth/ f32((OFFSET*2+1)*(OFFSET*2+1)));}`;E.ShadersStoreWGSL[kv]||(E.ShadersStoreWGSL[kv]=_P);G4={name:kv,shader:_P}});var TP={};De(TP,{shadowMapFragmentSoftTransparentShadowWGSL:()=>k4});var Wv,vP,k4,SP=A(()=>{N();Wv="shadowMapFragmentSoftTransparentShadow",vP=`#if SM_SOFTTRANSPARENTSHADOW==1 if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x*alpha) {discard;} #endif -`;E.IncludesShadersStoreWGSL[Vv]||(E.IncludesShadersStoreWGSL[Vv]=hP);A4={name:Vv,shader:hP}});var pP,R4,_P=A(()=>{N();pP="bayerDitherFunctions",R4=`float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);} +`;E.IncludesShadersStoreWGSL[Wv]||(E.IncludesShadersStoreWGSL[Wv]=vP);k4={name:Wv,shader:vP}});var AP,W4,RP=A(()=>{N();AP="bayerDitherFunctions",W4=`float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);} float bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0); vec2 P2=floor(0.5*mod(_P,4.0)); return 4.0*bayerDither2(P1)+bayerDither2(P2);} @@ -6151,7 +6151,7 @@ float bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0); vec2 P2=floor(0.5 *mod(_P,4.0)); vec2 P4=floor(0.25*mod(_P,8.0)); return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);} -`;E.IncludesShadersStore[pP]||(E.IncludesShadersStore[pP]=R4)});var gP,I4,EP=A(()=>{N();Am();_P();gP="shadowMapFragmentExtraDeclaration",I4=`#if SM_FLOAT==0 +`;E.IncludesShadersStore[AP]||(E.IncludesShadersStore[AP]=W4)});var IP,H4,xP=A(()=>{N();Rm();RP();IP="shadowMapFragmentExtraDeclaration",H4=`#if SM_FLOAT==0 #include #endif #if SM_SOFTTRANSPARENTSHADOW==1 @@ -6166,7 +6166,7 @@ uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 varying float zSM; #endif -`;E.IncludesShadersStore[gP]||(E.IncludesShadersStore[gP]=I4)});var vP,x4,TP=A(()=>{N();vP="shadowMapFragment",x4=`float depthSM=vDepthMetricSM; +`;E.IncludesShadersStore[IP]||(E.IncludesShadersStore[IP]=H4)});var CP,z4,bP=A(()=>{N();CP="shadowMapFragment",z4=`float depthSM=vDepthMetricSM; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 #if SM_USEDISTANCE==1 depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; @@ -6194,7 +6194,7 @@ gl_FragColor=vec4(depthSM,1.0,1.0,1.0); #else gl_FragColor=pack(depthSM); #endif -return;`;E.IncludesShadersStore[vP]||(E.IncludesShadersStore[vP]=x4)});var AP={};De(AP,{shadowMapPixelShader:()=>C4});var Gv,SP,C4,RP=A(()=>{N();EP();Ws();Hs();TP();Gv="shadowMapPixelShader",SP=`#include +return;`;E.IncludesShadersStore[CP]||(E.IncludesShadersStore[CP]=z4)});var yP={};De(yP,{shadowMapPixelShader:()=>X4});var Hv,MP,X4,DP=A(()=>{N();xP();Ws();Hs();bP();Hv="shadowMapPixelShader",MP=`#include #ifdef ALPHATEXTURE varying vec2 vUV;uniform sampler2D diffuseSampler; #endif @@ -6221,18 +6221,18 @@ if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowS #endif #endif #include -}`;E.ShadersStore[Gv]||(E.ShadersStore[Gv]=SP);C4={name:Gv,shader:SP}});var IP,b4,kv=A(()=>{N();IP="sceneVertexDeclaration",b4=`uniform mat4 viewProjection; +}`;E.ShadersStore[Hv]||(E.ShadersStore[Hv]=MP);X4={name:Hv,shader:MP}});var LP,Y4,zv=A(()=>{N();LP="sceneVertexDeclaration",Y4=`uniform mat4 viewProjection; #ifdef MULTIVIEW uniform mat4 viewProjectionR; #endif uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition; -`;E.IncludesShadersStore[IP]||(E.IncludesShadersStore[IP]=b4)});var xP,M4,CP=A(()=>{N();xP="meshVertexDeclaration",M4=`uniform mat4 world;uniform float visibility; -`;E.IncludesShadersStore[xP]||(E.IncludesShadersStore[xP]=M4)});var bP,y4,MP=A(()=>{N();kv();CP();bP="shadowMapVertexDeclaration",y4=`#include +`;E.IncludesShadersStore[LP]||(E.IncludesShadersStore[LP]=Y4)});var PP,K4,OP=A(()=>{N();PP="meshVertexDeclaration",K4=`uniform mat4 world;uniform float visibility; +`;E.IncludesShadersStore[PP]||(E.IncludesShadersStore[PP]=K4)});var NP,j4,FP=A(()=>{N();zv();OP();NP="shadowMapVertexDeclaration",j4=`#include #include -`;E.IncludesShadersStore[bP]||(E.IncludesShadersStore[bP]=y4)});var yP,D4,DP=A(()=>{N();Po();zf();yP="shadowMapUboDeclaration",D4=`layout(std140,column_major) uniform; +`;E.IncludesShadersStore[NP]||(E.IncludesShadersStore[NP]=j4)});var wP,Z4,BP=A(()=>{N();Oo();zf();wP="shadowMapUboDeclaration",Z4=`layout(std140,column_major) uniform; #include #include -`;E.IncludesShadersStore[yP]||(E.IncludesShadersStore[yP]=D4)});var LP,L4,PP=A(()=>{N();LP="shadowMapVertexExtraDeclaration",L4=`#if SM_NORMALBIAS==1 +`;E.IncludesShadersStore[wP]||(E.IncludesShadersStore[wP]=Z4)});var UP,q4,VP=A(()=>{N();UP="shadowMapVertexExtraDeclaration",q4=`#if SM_NORMALBIAS==1 uniform vec3 lightDataSM; #endif uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM; @@ -6242,7 +6242,7 @@ varying vec3 vPositionWSM; #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 varying float zSM; #endif -`;E.IncludesShadersStore[LP]||(E.IncludesShadersStore[LP]=L4)});var OP,P4,NP=A(()=>{N();OP="shadowMapVertexNormalBias",P4=`#if SM_NORMALBIAS==1 +`;E.IncludesShadersStore[UP]||(E.IncludesShadersStore[UP]=q4)});var GP,Q4,kP=A(()=>{N();GP="shadowMapVertexNormalBias",Q4=`#if SM_NORMALBIAS==1 #if SM_DIRECTIONINLIGHTDATA==1 vec3 worldLightDirSM=normalize(-lightDataSM.xyz); #else @@ -6250,7 +6250,7 @@ vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normal #endif float ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM; #endif -`;E.IncludesShadersStore[OP]||(E.IncludesShadersStore[OP]=P4)});var FP,O4,wP=A(()=>{N();FP="shadowMapVertexMetric",O4=`#if SM_USEDISTANCE==1 +`;E.IncludesShadersStore[GP]||(E.IncludesShadersStore[GP]=Q4)});var WP,J4,HP=A(()=>{N();WP="shadowMapVertexMetric",J4=`#if SM_USEDISTANCE==1 vPositionWSM=worldPos.xyz; #endif #if SM_DEPTHTEXTURE==1 @@ -6274,7 +6274,7 @@ vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; #endif #endif -`;E.IncludesShadersStore[FP]||(E.IncludesShadersStore[FP]=O4)});var UP={};De(UP,{shadowMapVertexShader:()=>N4});var Wv,BP,N4,VP=A(()=>{N();Fs();ws();Ga();ka();Gr();MP();DP();PP();Bs();Wa();Ha();Us();Vs();Gs();NP();wP();ks();Wv="shadowMapVertexShader",BP=`attribute vec3 position; +`;E.IncludesShadersStore[WP]||(E.IncludesShadersStore[WP]=J4)});var XP={};De(XP,{shadowMapVertexShader:()=>$4});var Xv,zP,$4,YP=A(()=>{N();Fs();ws();Ga();ka();Wr();FP();BP();VP();Bs();Wa();Ha();Us();Vs();Gs();kP();HP();ks();Xv="shadowMapVertexShader",zP=`attribute vec3 position; #ifdef NORMAL attribute vec3 normal; #endif @@ -6339,16 +6339,16 @@ vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); #endif #endif #include -}`;E.ShadersStore[Wv]||(E.ShadersStore[Wv]=BP);N4={name:Wv,shader:BP}});var kP={};De(kP,{depthBoxBlurPixelShader:()=>F4});var Hv,GP,F4,WP=A(()=>{N();Hv="depthBoxBlurPixelShader",GP=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize; +}`;E.ShadersStore[Xv]||(E.ShadersStore[Xv]=zP);$4={name:Xv,shader:zP}});var jP={};De(jP,{depthBoxBlurPixelShader:()=>ez});var Yv,KP,ez,ZP=A(()=>{N();Yv="depthBoxBlurPixelShader",KP=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize; #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) {vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++) for (int y=-OFFSET; y<=OFFSET; y++) -colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}`;E.ShadersStore[Hv]||(E.ShadersStore[Hv]=GP);F4={name:Hv,shader:GP}});var zP={};De(zP,{shadowMapFragmentSoftTransparentShadow:()=>w4});var zv,HP,w4,XP=A(()=>{N();zv="shadowMapFragmentSoftTransparentShadow",HP=`#if SM_SOFTTRANSPARENTSHADOW==1 +colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}`;E.ShadersStore[Yv]||(E.ShadersStore[Yv]=KP);ez={name:Yv,shader:KP}});var QP={};De(QP,{shadowMapFragmentSoftTransparentShadow:()=>tz});var Kv,qP,tz,JP=A(()=>{N();Kv="shadowMapFragmentSoftTransparentShadow",qP=`#if SM_SOFTTRANSPARENTSHADOW==1 if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alpha) discard; #endif -`;E.IncludesShadersStore[zv]||(E.IncludesShadersStore[zv]=HP);w4={name:zv,shader:HP}});var St,Rm=A(()=>{ve();et();yt();Ma();oi();_a();ms();Fv();ct();gi();Da();Th();go();kn();Oi();cf();St=class n{get bias(){return this._bias}set bias(e){this._bias=e}get normalBias(){return this._normalBias}set normalBias(e){this._normalBias=e}get blurBoxOffset(){return this._blurBoxOffset}set blurBoxOffset(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())}get blurScale(){return this._blurScale}set blurScale(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())}get blurKernel(){return this._blurKernel}set blurKernel(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())}get useKernelBlur(){return this._useKernelBlur}set useKernelBlur(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())}get depthScale(){return this._depthScale!==void 0?this._depthScale:this._light.getDepthScale()}set depthScale(e){this._depthScale=e}_validateFilter(e){return e}get filter(){return this._filter}set filter(e){if(e=this._validateFilter(e),this._light.needCube()){if(e===n.FILTER_BLUREXPONENTIALSHADOWMAP){this.useExponentialShadowMap=!0;return}else if(e===n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP){this.useCloseExponentialShadowMap=!0;return}else if(e===n.FILTER_PCF||e===n.FILTER_PCSS){this.usePoissonSampling=!0;return}}if((e===n.FILTER_PCF||e===n.FILTER_PCSS)&&!this._scene.getEngine()._features.supportShadowSamplers){this.usePoissonSampling=!0;return}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get usePoissonSampling(){return this.filter===n.FILTER_POISSONSAMPLING}set usePoissonSampling(e){let t=this._validateFilter(n.FILTER_POISSONSAMPLING);!e&&this.filter!==n.FILTER_POISSONSAMPLING||(this.filter=e?t:n.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===n.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_EXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_EXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===n.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_BLUREXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_BLUREXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===n.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_CLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_CLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===n.FILTER_PCF}set usePercentageCloserFiltering(e){let t=this._validateFilter(n.FILTER_PCF);!e&&this.filter!==n.FILTER_PCF||(this.filter=e?t:n.FILTER_NONE)}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get useContactHardeningShadow(){return this.filter===n.FILTER_PCSS}set useContactHardeningShadow(e){let t=this._validateFilter(n.FILTER_PCSS);!e&&this.filter!==n.FILTER_PCSS||(this.filter=e?t:n.FILTER_NONE)}get contactHardeningLightSizeUVRatio(){return this._contactHardeningLightSizeUVRatio}set contactHardeningLightSizeUVRatio(e){this._contactHardeningLightSizeUVRatio=e}get darkness(){return this._darkness}set darkness(e){this.setDarkness(e)}getDarkness(){return this._darkness}setDarkness(e){return e>=1?this._darkness=1:e<=0?this._darkness=0:this._darkness=e,this}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){this.setTransparencyShadow(e)}setTransparencyShadow(e){return this._transparencyShadow=e,this}getShadowMap(){return this._shadowMap}getShadowMapForRendering(){return this._shadowMap2?this._shadowMap2:this._shadowMap}getClassName(){return n.CLASSNAME}addShadowCaster(e,t=!0){if(!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.indexOf(e)===-1&&this._shadowMap.renderList.push(e),t)for(let i of e.getChildMeshes())this._shadowMap.renderList.indexOf(i)===-1&&this._shadowMap.renderList.push(i);return this}removeShadowCaster(e,t=!0){if(!this._shadowMap||!this._shadowMap.renderList)return this;let i=this._shadowMap.renderList.indexOf(e);if(i!==-1&&this._shadowMap.renderList.splice(i,1),t)for(let r of e.getChildren())this.removeShadowCaster(r);return this}getLight(){return this._light}get shaderLanguage(){return this._shaderLanguage}_getCamera(){var e;return(e=this._camera)!=null?e:this._scene.activeCamera}get mapSize(){return this._mapSize}set mapSize(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}get light(){return this._light}set light(e){this._light!==e&&(this.dispose(!1),this._light=e,this._createInstance())}get useFloat32TextureType(){return this._usefullFloatFirst}set useFloat32TextureType(e){this._usefullFloatFirst!==e&&(this.dispose(!1),this._usefullFloatFirst=e,this._createInstance())}get camera(){return this._camera}set camera(e){this._camera!==e&&(this.dispose(!1),this._camera=e,this._createInstance())}get useRedTextureFormat(){return this._useRedTextureType}set useRedTextureFormat(e){this._useRedTextureType!==e&&(this.dispose(!1),this._useRedTextureType=e,this._createInstance())}constructor(e,t,i,r,s,a=!1){this.onBeforeShadowMapRenderObservable=new Y,this.onAfterShadowMapRenderObservable=new Y,this.onBeforeShadowMapRenderMeshObservable=new Y,this.onAfterShadowMapRenderMeshObservable=new Y,this.doNotSerialize=!1,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=n.FILTER_NONE,this._filteringQuality=n.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=v.Zero(),this._viewMatrix=G.Zero(),this._projectionMatrix=G.Zero(),this._transformMatrix=G.Zero(),this._cachedPosition=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=G.Identity(),this._shadersLoaded=!1,this._mapSize=e,this._light=t,this._usefullFloatFirst=!!i,this._scene=t.getScene(),this._camera=r!=null?r:null,this._useRedTextureType=!!s,this._forceGLSL=a,this._createInstance()}_createInstance(){this._initShaderSourceAsync(this._forceGLSL);let e=this._light._shadowGenerators;e||(e=this._light._shadowGenerators=new Map),e.set(this._camera,this),this.id=this._light.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[this._scene.createSceneUniformBuffer(`Scene for Shadow Generator (light "${this._light.name}")`,{forceMono:!0})]),n._SceneComponentInitialization(this._scene);let t=this._scene.getEngine().getCaps();this._usefullFloatFirst?t.textureFloatRender&&t.textureFloatLinearFiltering?this._textureType=1:t.textureHalfFloatRender&&t.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:t.textureHalfFloatRender&&t.textureHalfFloatLinearFiltering?this._textureType=2:t.textureFloatRender&&t.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}_initializeGenerator(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()}_createTargetRenderTexture(){var t;let e=this._scene.getEngine();(t=this._shadowMap)==null||t.dispose(),e._features.supportDepthStencilTexture?(this._shadowMap=new ri(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForShadowGenerator-${this._light.name}`)):this._shadowMap=new ri(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(this._createTargetRenderTexture(),this._shadowMap===null)return;this._shadowMap.wrapU=ne.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=ne.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=(r,s,a,o)=>this._renderForShadowMap(r,s,a,o),this._shadowMap.customIsReadyFunction=(r,s,a)=>{if(!a||!r.subMeshes)return!0;let o=!0;for(let l of r.subMeshes){let c=l.getRenderingMesh(),d=this._scene.getEngine(),h=l.getMaterial();if(!h||l.verticesCount===0||this.customAllowRendering&&!this.customAllowRendering(l))continue;let u=c._getInstancesRenderList(l._id,!!l.getReplacementMesh());if(u.mustReturn)continue;let m=d.getCaps().instancedArrays&&(u.visibleInstances[l._id]!==null&&u.visibleInstances[l._id]!==void 0||c.hasThinInstances),p=h.needAlphaBlendingForMesh(c);o=this.isReady(l,m,p)&&o}return o};let e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add(()=>{var r;this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._enableGPUDebugMarkers&&((r=e._debugPushGroup)==null||r.call(e,`Shadow map generation for pass id ${e.currentRenderPassId}`))}),this._shadowMap.onBeforeRenderObservable.add(r=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[0]),this._currentFaceIndex=r,this._filter===n.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),Br.eyeAtCamera=!1,this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._sceneUBOs&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onAfterUnbindObservable.add(()=>{var s,a;if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),Br.eyeAtCamera=!0,this._scene.updateTransformMatrix(),this._filter===n.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap){(s=e._debugPopGroup)==null||s.call(e);return}let r=this.getShadowMapForRendering();r&&(this._scene.postProcessManager.directRender(this._blurPostProcesses,r.renderTarget,!0),e.unBindFramebuffer(r.renderTarget,!0)),e._enableGPUDebugMarkers&&((a=e._debugPopGroup)==null||a.call(e))});let t=new Ne(0,0,0,0),i=new Ne(1,1,1,1);this._shadowMap.onClearObservable.add(r=>{this._filter===n.FILTER_PCF?r.clear(i,!1,!0,!1):this.useExponentialShadowMap||this.useBlurExponentialShadowMap?r.clear(t,!0,!0,!1):r.clear(i,!0,!0,!1)}),this._shadowMap.onResizeObservable.add(r=>{this._storedUniqueId=this._shadowMap.uniqueId,this._mapSize=r.getRenderSize(),this._light._markMeshesAsLightDirty(),this.recreateShadowMap()});for(let r=Pr.MIN_RENDERINGGROUPS;r($L(),JL)),Promise.resolve().then(()=>(lP(),oP)),Promise.resolve().then(()=>(dP(),fP)),Promise.resolve().then(()=>(mP(),uP))])):await Promise.all([Promise.resolve().then(()=>(RP(),AP)),Promise.resolve().then(()=>(VP(),UP)),Promise.resolve().then(()=>(WP(),kP)),Promise.resolve().then(()=>(XP(),zP))]),this._shadersLoaded=!0}_initializeBlurRTTAndPostProcesses(){let e=this._scene.getEngine(),t=this._mapSize/this.blurScale;(!this.useKernelBlur||this.blurScale!==1)&&(this._shadowMap2=new ri(this._light.name+"_shadowMap2",t,this._scene,!1,!0,this._textureType,void 0,void 0,!1),this._shadowMap2.wrapU=ne.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=ne.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new Yr(this._light.name+"KernelBlurX",new _e(1,0),this.blurKernel,1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=t,this._kernelBlurXPostprocess.height=t,this._kernelBlurXPostprocess.externalTextureSamplerBinding=!0,this._kernelBlurXPostprocess.onApplyObservable.add(i=>{i.setTexture("textureSampler",this._shadowMap)}),this._kernelBlurYPostprocess=new Yr(this._light.name+"KernelBlurY",new _e(0,1),this.blurKernel,1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===0&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new _t(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add(i=>{i.setFloat2("screenSize",t,t),i.setTexture("textureSampler",this._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])}_renderForShadowMap(e,t,i,r){let s;if(r.length)for(s=0;s{r!==i&&!S?(i.getMeshUniformBuffer().bindToEffect(T,"Mesh"),i.transferToEffect(I)):(r.getMeshUniformBuffer().bindToEffect(T,"Mesh"),r.transferToEffect(S?I:R))}),this.forceBackFacesOnly&&a.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(T),this.onAfterShadowMapRenderMeshObservable.notifyObservers(i)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===n.FILTER_NONE||this.filter===n.FILTER_PCSS?this._shadowMap.updateSamplingMode(ne.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE))}forceCompilation(e,t){let i={useInstances:!1,...t},r=this.getShadowMap();if(!r){e&&e(this);return}let s=r.renderList;if(!s){e&&e(this);return}let a=[];for(let c of s)a.push(...c.subMeshes);if(a.length===0){e&&e(this);return}let o=0,l=()=>{var c,f;if(!(!this._scene||!this._scene.getEngine())){for(;this.isReady(a[o],i.useInstances,(f=(c=a[o].getMaterial())==null?void 0:c.needAlphaBlendingForMesh(a[o].getMesh()))!=null?f:!1);)if(o++,o>=a.length){e&&e(this);return}setTimeout(l,16)}};l()}async forceCompilationAsync(e){return await new Promise(t=>{this.forceCompilation(()=>{t()},e)})}_isReadyCustomDefines(e,t,i){}_prepareShadowDefines(e,t,i,r){i.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),i.push("#define SM_FLOAT "+(this._textureType!==0?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));let s=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&s.isVerticesDataPresent(M.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===tt.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&r?"1":"0")),this._isReadyCustomDefines(i,e,t),i}isReady(e,t,i){var o;if(!this._shadersLoaded)return!1;let r=e.getMaterial(),s=r==null?void 0:r.shadowDepthWrapper;if(this._opacityTexture=null,!r)return!1;let a=[];if(this._prepareShadowDefines(e,t,a,i),s){if(!s.isReadyForSubMesh(e,a,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{let l=e._getDrawWrapper(void 0,!0),c=l.effect,f=l.defines,d=[M.PositionKind],h=e.getMesh(),u=!1,m=!1,p=!1,_=!1;this.normalBias&&h.isVerticesDataPresent(M.NormalKind)&&(d.push(M.NormalKind),a.push("#define NORMAL"),u=!0,h.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));let g=r.needAlphaTestingForMesh(h);if((g||r.needAlphaBlendingForMesh(h))&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=r.opacityTexture:this._opacityTexture=r.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;let I=(o=r.alphaCutOff)!=null?o:n.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),g&&a.push(`#define ALPHATESTVALUE ${I}${I%1===0?".":""}`),h.isVerticesDataPresent(M.UVKind)&&(d.push(M.UVKind),a.push("#define UV1"),m=!0),h.isVerticesDataPresent(M.UV2Kind)&&this._opacityTexture.coordinatesIndex===1&&(d.push(M.UV2Kind),a.push("#define UV2"),p=!0)}let T=new Bi;if(h.useBones&&h.computeBonesUsingShaders&&h.skeleton){d.push(M.MatricesIndicesKind),d.push(M.MatricesWeightsKind),h.numBoneInfluencers>4&&(d.push(M.MatricesIndicesExtraKind),d.push(M.MatricesWeightsExtraKind));let I=h.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+h.numBoneInfluencers),h.numBoneInfluencers>0&&T.addCPUSkinningFallback(0,h),I.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(I.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");let b=h.morphTargetManager?Wn(h.morphTargetManager,a,d,h,!0,u,!1,m,p,_):0;if(Gn(r,this._scene,a),t&&(a.push("#define INSTANCES"),_n(d),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(let I of this.customShaderOptions.defines)a.indexOf(I)===-1&&a.push(I);let R=h.bakedVertexAnimationManager;R&&R.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&d.push("bakedVertexAnimationSettingsInstanced"));let S=a.join(` -`);if(f!==S){f=S;let I="shadowMap",x=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureInfo","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],P=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],L=["Scene","Mesh"];if(Di(x),this.customShaderOptions){if(I=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(let B of this.customShaderOptions.attributes)d.indexOf(B)===-1&&d.push(B);if(this.customShaderOptions.uniforms)for(let B of this.customShaderOptions.uniforms)x.indexOf(B)===-1&&x.push(B);if(this.customShaderOptions.samplers)for(let B of this.customShaderOptions.samplers)P.indexOf(B)===-1&&P.push(B)}let y=this._scene.getEngine();c=y.createEffect(I,{attributes:d,uniformsNames:x,uniformBuffersNames:L,samplers:P,defines:S,fallbacks:T,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._shaderLanguage},y),l.setEffect(c,f)}if(!c.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(!this._blurPostProcesses||!this._blurPostProcesses.length)&&this._initializeBlurRTTAndPostProcesses(),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())}prepareDefines(e,t){let i=this._scene,r=this._light;!i.shadowsEnabled||!r.shadowEnabled||(e["SHADOW"+t]=!0,this.useContactHardeningShadow?(e["SHADOWPCSS"+t]=!0,this._filteringQuality===n.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===n.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===n.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===n.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))}bindShadowLight(e,t){let i=this._light,r=this._scene;if(!r.shadowsEnabled||!i.shadowEnabled)return;let s=this._getCamera(),a=this.getShadowMap();if(!a)return;if(!i.needCube()){let l=r.floatingOriginOffset,c=this.getTransformMatrix(),f=r.floatingOriginMode?sg(l,this._viewMatrix,this._projectionMatrix,k.Matrix[0]):c;t.setMatrix("lightMatrix"+e,f)}let o=this.getShadowMapForRendering();this._filter===n.FILTER_PCF?(t.setDepthStencilTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a.getSize().width,1/a.getSize().width,this.frustumEdgeFalloff,e)):this._filter===n.FILTER_PCSS?(t.setDepthStencilTexture("shadowTexture"+e,o),t.setTexture("depthTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a.getSize().width,this._contactHardeningLightSizeUVRatio*a.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/a.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(s),this.getLight().getDepthMinZ(s)+this.getLight().getDepthMaxZ(s),e)}get viewMatrix(){return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}getTransformMatrix(){let e=this._scene;if(this._currentRenderId===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;let t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),v.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(v.Dot(this._lightDirection,v.Up()))===1&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),G.LookAtLHToRef(t,t.add(this._lightDirection),v.Up(),this._viewMatrix);let i=this.getShadowMap();if(i){let r=i.renderList;r&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,r)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix}recreateShadowMap(){let e=this._shadowMap;if(!e)return;let t=e.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),t){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(let i of t)this._shadowMap.renderList.push(i)}else this._shadowMap.renderList=null}_disposeBlurPostProcesses(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]}_disposeRTTandPostProcesses(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()}_disposeSceneUBOs(){if(this._sceneUBOs){for(let e of this._sceneUBOs)e.dispose();this._sceneUBOs=[]}}dispose(e=!0){if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){let t=this._light._shadowGenerators.entries();for(let i=t.next();i.done!==!0;i=t.next()){let[r,s]=i.value;s===this&&this._light._shadowGenerators.delete(r)}this._light._shadowGenerators.size===0&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}e&&(this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear())}serialize(){var i;let e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=(i=this._camera)==null?void 0:i.id,e.id=this.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(let r=0;r{throw Ie("ShadowGeneratorSceneComponent")}});var KP={};De(KP,{depthPixelShader:()=>B4});var Xv,YP,B4,Yv=A(()=>{N();Ws();Am();Hs();Xv="depthPixelShader",YP=`#ifdef ALPHATEST +`;E.IncludesShadersStore[Kv]||(E.IncludesShadersStore[Kv]=qP);tz={name:Kv,shader:qP}});var St,Im=A(()=>{ve();et();yt();Ma();oi();_a();ps();Uv();ft();Ei();Da();Sh();go();Wn();Ni();cf();St=class n{get bias(){return this._bias}set bias(e){this._bias=e}get normalBias(){return this._normalBias}set normalBias(e){this._normalBias=e}get blurBoxOffset(){return this._blurBoxOffset}set blurBoxOffset(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())}get blurScale(){return this._blurScale}set blurScale(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())}get blurKernel(){return this._blurKernel}set blurKernel(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())}get useKernelBlur(){return this._useKernelBlur}set useKernelBlur(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())}get depthScale(){return this._depthScale!==void 0?this._depthScale:this._light.getDepthScale()}set depthScale(e){this._depthScale=e}_validateFilter(e){return e}get filter(){return this._filter}set filter(e){if(e=this._validateFilter(e),this._light.needCube()){if(e===n.FILTER_BLUREXPONENTIALSHADOWMAP){this.useExponentialShadowMap=!0;return}else if(e===n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP){this.useCloseExponentialShadowMap=!0;return}else if(e===n.FILTER_PCF||e===n.FILTER_PCSS){this.usePoissonSampling=!0;return}}if((e===n.FILTER_PCF||e===n.FILTER_PCSS)&&!this._scene.getEngine()._features.supportShadowSamplers){this.usePoissonSampling=!0;return}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get usePoissonSampling(){return this.filter===n.FILTER_POISSONSAMPLING}set usePoissonSampling(e){let t=this._validateFilter(n.FILTER_POISSONSAMPLING);!e&&this.filter!==n.FILTER_POISSONSAMPLING||(this.filter=e?t:n.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===n.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_EXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_EXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===n.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_BLUREXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_BLUREXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===n.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_CLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_CLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){let t=this._validateFilter(n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==n.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:n.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===n.FILTER_PCF}set usePercentageCloserFiltering(e){let t=this._validateFilter(n.FILTER_PCF);!e&&this.filter!==n.FILTER_PCF||(this.filter=e?t:n.FILTER_NONE)}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get useContactHardeningShadow(){return this.filter===n.FILTER_PCSS}set useContactHardeningShadow(e){let t=this._validateFilter(n.FILTER_PCSS);!e&&this.filter!==n.FILTER_PCSS||(this.filter=e?t:n.FILTER_NONE)}get contactHardeningLightSizeUVRatio(){return this._contactHardeningLightSizeUVRatio}set contactHardeningLightSizeUVRatio(e){this._contactHardeningLightSizeUVRatio=e}get darkness(){return this._darkness}set darkness(e){this.setDarkness(e)}getDarkness(){return this._darkness}setDarkness(e){return e>=1?this._darkness=1:e<=0?this._darkness=0:this._darkness=e,this}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){this.setTransparencyShadow(e)}setTransparencyShadow(e){return this._transparencyShadow=e,this}getShadowMap(){return this._shadowMap}getShadowMapForRendering(){return this._shadowMap2?this._shadowMap2:this._shadowMap}getClassName(){return n.CLASSNAME}addShadowCaster(e,t=!0){if(!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.indexOf(e)===-1&&this._shadowMap.renderList.push(e),t)for(let i of e.getChildMeshes())this._shadowMap.renderList.indexOf(i)===-1&&this._shadowMap.renderList.push(i);return this}removeShadowCaster(e,t=!0){if(!this._shadowMap||!this._shadowMap.renderList)return this;let i=this._shadowMap.renderList.indexOf(e);if(i!==-1&&this._shadowMap.renderList.splice(i,1),t)for(let r of e.getChildren())this.removeShadowCaster(r);return this}getLight(){return this._light}get shaderLanguage(){return this._shaderLanguage}_getCamera(){var e;return(e=this._camera)!=null?e:this._scene.activeCamera}get mapSize(){return this._mapSize}set mapSize(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}get light(){return this._light}set light(e){this._light!==e&&(this.dispose(!1),this._light=e,this._createInstance())}get useFloat32TextureType(){return this._usefullFloatFirst}set useFloat32TextureType(e){this._usefullFloatFirst!==e&&(this.dispose(!1),this._usefullFloatFirst=e,this._createInstance())}get camera(){return this._camera}set camera(e){this._camera!==e&&(this.dispose(!1),this._camera=e,this._createInstance())}get useRedTextureFormat(){return this._useRedTextureType}set useRedTextureFormat(e){this._useRedTextureType!==e&&(this.dispose(!1),this._useRedTextureType=e,this._createInstance())}constructor(e,t,i,r,s,a=!1){this.onBeforeShadowMapRenderObservable=new Y,this.onAfterShadowMapRenderObservable=new Y,this.onBeforeShadowMapRenderMeshObservable=new Y,this.onAfterShadowMapRenderMeshObservable=new Y,this.doNotSerialize=!1,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=n.FILTER_NONE,this._filteringQuality=n.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=v.Zero(),this._viewMatrix=U.Zero(),this._projectionMatrix=U.Zero(),this._transformMatrix=U.Zero(),this._cachedPosition=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new v(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=U.Identity(),this._shadersLoaded=!1,this._mapSize=e,this._light=t,this._usefullFloatFirst=!!i,this._scene=t.getScene(),this._camera=r!=null?r:null,this._useRedTextureType=!!s,this._forceGLSL=a,this._createInstance()}_createInstance(){this._initShaderSourceAsync(this._forceGLSL);let e=this._light._shadowGenerators;e||(e=this._light._shadowGenerators=new Map),e.set(this._camera,this),this.id=this._light.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[this._scene.createSceneUniformBuffer(`Scene for Shadow Generator (light "${this._light.name}")`,{forceMono:!0})]),n._SceneComponentInitialization(this._scene);let t=this._scene.getEngine().getCaps();this._usefullFloatFirst?t.textureFloatRender&&t.textureFloatLinearFiltering?this._textureType=1:t.textureHalfFloatRender&&t.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:t.textureHalfFloatRender&&t.textureHalfFloatLinearFiltering?this._textureType=2:t.textureFloatRender&&t.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}_initializeGenerator(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()}_createTargetRenderTexture(){var t;let e=this._scene.getEngine();(t=this._shadowMap)==null||t.dispose(),e._features.supportDepthStencilTexture?(this._shadowMap=new ri(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForShadowGenerator-${this._light.name}`)):this._shadowMap=new ri(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(this._createTargetRenderTexture(),this._shadowMap===null)return;this._shadowMap.wrapU=ne.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=ne.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=(r,s,a,o)=>this._renderForShadowMap(r,s,a,o),this._shadowMap.customIsReadyFunction=(r,s,a)=>{if(!a||!r.subMeshes)return!0;let o=!0;for(let l of r.subMeshes){let c=l.getRenderingMesh(),d=this._scene.getEngine(),h=l.getMaterial();if(!h||l.verticesCount===0||this.customAllowRendering&&!this.customAllowRendering(l))continue;let u=c._getInstancesRenderList(l._id,!!l.getReplacementMesh());if(u.mustReturn)continue;let m=d.getCaps().instancedArrays&&(u.visibleInstances[l._id]!==null&&u.visibleInstances[l._id]!==void 0||c.hasThinInstances),p=h.needAlphaBlendingForMesh(c);o=this.isReady(l,m,p)&&o}return o};let e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add(()=>{var r;this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._enableGPUDebugMarkers&&((r=e._debugPushGroup)==null||r.call(e,`Shadow map generation for pass id ${e.currentRenderPassId}`))}),this._shadowMap.onBeforeRenderObservable.add(r=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[0]),this._currentFaceIndex=r,this._filter===n.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),Vr.eyeAtCamera=!1,this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._sceneUBOs&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onAfterUnbindObservable.add(()=>{var s,a;if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),Vr.eyeAtCamera=!0,this._scene.updateTransformMatrix(),this._filter===n.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap){(s=e._debugPopGroup)==null||s.call(e);return}let r=this.getShadowMapForRendering();r&&(this._scene.postProcessManager.directRender(this._blurPostProcesses,r.renderTarget,!0),e.unBindFramebuffer(r.renderTarget,!0)),e._enableGPUDebugMarkers&&((a=e._debugPopGroup)==null||a.call(e))});let t=new Ne(0,0,0,0),i=new Ne(1,1,1,1);this._shadowMap.onClearObservable.add(r=>{this._filter===n.FILTER_PCF?r.clear(i,!1,!0,!1):this.useExponentialShadowMap||this.useBlurExponentialShadowMap?r.clear(t,!0,!0,!1):r.clear(i,!0,!0,!1)}),this._shadowMap.onResizeObservable.add(r=>{this._storedUniqueId=this._shadowMap.uniqueId,this._mapSize=r.getRenderSize(),this._light._markMeshesAsLightDirty(),this.recreateShadowMap()});for(let r=Nr.MIN_RENDERINGGROUPS;r(aP(),sP)),Promise.resolve().then(()=>(pP(),mP)),Promise.resolve().then(()=>(EP(),gP)),Promise.resolve().then(()=>(SP(),TP))])):await Promise.all([Promise.resolve().then(()=>(DP(),yP)),Promise.resolve().then(()=>(YP(),XP)),Promise.resolve().then(()=>(ZP(),jP)),Promise.resolve().then(()=>(JP(),QP))]),this._shadersLoaded=!0}_initializeBlurRTTAndPostProcesses(){let e=this._scene.getEngine(),t=this._mapSize/this.blurScale;(!this.useKernelBlur||this.blurScale!==1)&&(this._shadowMap2=new ri(this._light.name+"_shadowMap2",t,this._scene,!1,!0,this._textureType,void 0,void 0,!1),this._shadowMap2.wrapU=ne.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=ne.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new jr(this._light.name+"KernelBlurX",new _e(1,0),this.blurKernel,1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=t,this._kernelBlurXPostprocess.height=t,this._kernelBlurXPostprocess.externalTextureSamplerBinding=!0,this._kernelBlurXPostprocess.onApplyObservable.add(i=>{i.setTexture("textureSampler",this._shadowMap)}),this._kernelBlurYPostprocess=new jr(this._light.name+"KernelBlurY",new _e(0,1),this.blurKernel,1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===0&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new gt(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,ne.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add(i=>{i.setFloat2("screenSize",t,t),i.setTexture("textureSampler",this._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])}_renderForShadowMap(e,t,i,r){let s;if(r.length)for(s=0;s{r!==i&&!S?(i.getMeshUniformBuffer().bindToEffect(T,"Mesh"),i.transferToEffect(I)):(r.getMeshUniformBuffer().bindToEffect(T,"Mesh"),r.transferToEffect(S?I:R))}),this.forceBackFacesOnly&&a.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(T),this.onAfterShadowMapRenderMeshObservable.notifyObservers(i)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===n.FILTER_NONE||this.filter===n.FILTER_PCSS?this._shadowMap.updateSamplingMode(ne.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE))}forceCompilation(e,t){let i={useInstances:!1,...t},r=this.getShadowMap();if(!r){e&&e(this);return}let s=r.renderList;if(!s){e&&e(this);return}let a=[];for(let c of s)a.push(...c.subMeshes);if(a.length===0){e&&e(this);return}let o=0,l=()=>{var c,f;if(!(!this._scene||!this._scene.getEngine())){for(;this.isReady(a[o],i.useInstances,(f=(c=a[o].getMaterial())==null?void 0:c.needAlphaBlendingForMesh(a[o].getMesh()))!=null?f:!1);)if(o++,o>=a.length){e&&e(this);return}setTimeout(l,16)}};l()}async forceCompilationAsync(e){return await new Promise(t=>{this.forceCompilation(()=>{t()},e)})}_isReadyCustomDefines(e,t,i){}_prepareShadowDefines(e,t,i,r){i.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),i.push("#define SM_FLOAT "+(this._textureType!==0?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));let s=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&s.isVerticesDataPresent(M.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===tt.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&r?"1":"0")),this._isReadyCustomDefines(i,e,t),i}isReady(e,t,i){var o;if(!this._shadersLoaded)return!1;let r=e.getMaterial(),s=r==null?void 0:r.shadowDepthWrapper;if(this._opacityTexture=null,!r)return!1;let a=[];if(this._prepareShadowDefines(e,t,a,i),s){if(!s.isReadyForSubMesh(e,a,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{let l=e._getDrawWrapper(void 0,!0),c=l.effect,f=l.defines,d=[M.PositionKind],h=e.getMesh(),u=!1,m=!1,p=!1,_=!1;this.normalBias&&h.isVerticesDataPresent(M.NormalKind)&&(d.push(M.NormalKind),a.push("#define NORMAL"),u=!0,h.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));let g=r.needAlphaTestingForMesh(h);if((g||r.needAlphaBlendingForMesh(h))&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=r.opacityTexture:this._opacityTexture=r.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;let I=(o=r.alphaCutOff)!=null?o:n.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),g&&a.push(`#define ALPHATESTVALUE ${I}${I%1===0?".":""}`),h.isVerticesDataPresent(M.UVKind)&&(d.push(M.UVKind),a.push("#define UV1"),m=!0),h.isVerticesDataPresent(M.UV2Kind)&&this._opacityTexture.coordinatesIndex===1&&(d.push(M.UV2Kind),a.push("#define UV2"),p=!0)}let T=new Ui;if(h.useBones&&h.computeBonesUsingShaders&&h.skeleton){d.push(M.MatricesIndicesKind),d.push(M.MatricesWeightsKind),h.numBoneInfluencers>4&&(d.push(M.MatricesIndicesExtraKind),d.push(M.MatricesWeightsExtraKind));let I=h.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+h.numBoneInfluencers),h.numBoneInfluencers>0&&T.addCPUSkinningFallback(0,h),I.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(I.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");let b=h.morphTargetManager?Hn(h.morphTargetManager,a,d,h,!0,u,!1,m,p,_):0;if(kn(r,this._scene,a),t&&(a.push("#define INSTANCES"),gn(d),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(let I of this.customShaderOptions.defines)a.indexOf(I)===-1&&a.push(I);let R=h.bakedVertexAnimationManager;R&&R.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&d.push("bakedVertexAnimationSettingsInstanced"));let S=a.join(` +`);if(f!==S){f=S;let I="shadowMap",x=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureInfo","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],P=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],L=["Scene","Mesh"];if(Li(x),this.customShaderOptions){if(I=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(let B of this.customShaderOptions.attributes)d.indexOf(B)===-1&&d.push(B);if(this.customShaderOptions.uniforms)for(let B of this.customShaderOptions.uniforms)x.indexOf(B)===-1&&x.push(B);if(this.customShaderOptions.samplers)for(let B of this.customShaderOptions.samplers)P.indexOf(B)===-1&&P.push(B)}let y=this._scene.getEngine();c=y.createEffect(I,{attributes:d,uniformsNames:x,uniformBuffersNames:L,samplers:P,defines:S,fallbacks:T,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._shaderLanguage},y),l.setEffect(c,f)}if(!c.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(!this._blurPostProcesses||!this._blurPostProcesses.length)&&this._initializeBlurRTTAndPostProcesses(),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())}prepareDefines(e,t){let i=this._scene,r=this._light;!i.shadowsEnabled||!r.shadowEnabled||(e["SHADOW"+t]=!0,this.useContactHardeningShadow?(e["SHADOWPCSS"+t]=!0,this._filteringQuality===n.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===n.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===n.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===n.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))}bindShadowLight(e,t){let i=this._light,r=this._scene;if(!r.shadowsEnabled||!i.shadowEnabled)return;let s=this._getCamera(),a=this.getShadowMap();if(!a)return;if(!i.needCube()){let l=r.floatingOriginOffset,c=this.getTransformMatrix(),f=r.floatingOriginMode?lg(l,this._viewMatrix,this._projectionMatrix,G.Matrix[0]):c;t.setMatrix("lightMatrix"+e,f)}let o=this.getShadowMapForRendering();this._filter===n.FILTER_PCF?(t.setDepthStencilTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a.getSize().width,1/a.getSize().width,this.frustumEdgeFalloff,e)):this._filter===n.FILTER_PCSS?(t.setDepthStencilTexture("shadowTexture"+e,o),t.setTexture("depthTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a.getSize().width,this._contactHardeningLightSizeUVRatio*a.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/a.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(s),this.getLight().getDepthMinZ(s)+this.getLight().getDepthMaxZ(s),e)}get viewMatrix(){return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}getTransformMatrix(){let e=this._scene;if(this._currentRenderId===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;let t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),v.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(v.Dot(this._lightDirection,v.Up()))===1&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),U.LookAtLHToRef(t,t.add(this._lightDirection),v.Up(),this._viewMatrix);let i=this.getShadowMap();if(i){let r=i.renderList;r&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,r)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix}recreateShadowMap(){let e=this._shadowMap;if(!e)return;let t=e.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),t){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(let i of t)this._shadowMap.renderList.push(i)}else this._shadowMap.renderList=null}_disposeBlurPostProcesses(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]}_disposeRTTandPostProcesses(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()}_disposeSceneUBOs(){if(this._sceneUBOs){for(let e of this._sceneUBOs)e.dispose();this._sceneUBOs=[]}}dispose(e=!0){if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){let t=this._light._shadowGenerators.entries();for(let i=t.next();i.done!==!0;i=t.next()){let[r,s]=i.value;s===this&&this._light._shadowGenerators.delete(r)}this._light._shadowGenerators.size===0&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}e&&(this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear())}serialize(){var i;let e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=(i=this._camera)==null?void 0:i.id,e.id=this.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(let r=0;r{throw Ie("ShadowGeneratorSceneComponent")}});var eO={};De(eO,{depthPixelShader:()=>iz});var jv,$P,iz,Zv=A(()=>{N();Ws();Rm();Hs();jv="depthPixelShader",$P=`#ifdef ALPHATEST varying vec2 vUV;uniform sampler2D diffuseSampler; #endif #include @@ -6388,10 +6388,10 @@ gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0); #endif #endif #endif -}`;E.ShadersStore[Xv]||(E.ShadersStore[Xv]=YP);B4={name:Xv,shader:YP}});var jP,U4,ZP=A(()=>{N();jP="pointCloudVertexDeclaration",U4=`#ifdef POINTSIZE +}`;E.ShadersStore[jv]||(E.ShadersStore[jv]=$P);iz={name:jv,shader:$P}});var tO,rz,iO=A(()=>{N();tO="pointCloudVertexDeclaration",rz=`#ifdef POINTSIZE uniform float pointSize; #endif -`;E.IncludesShadersStore[jP]||(E.IncludesShadersStore[jP]=U4)});var QP={};De(QP,{depthVertexShader:()=>V4});var Kv,qP,V4,jv=A(()=>{N();Fs();ws();Ga();ka();Bs();Na();ZP();Wa();Ha();Us();Vs();Gs();ks();gv();Kv="depthVertexShader",qP=`attribute vec3 position; +`;E.IncludesShadersStore[tO]||(E.IncludesShadersStore[tO]=rz)});var nO={};De(nO,{depthVertexShader:()=>nz});var qv,rO,nz,Qv=A(()=>{N();Fs();ws();Ga();ka();Bs();Na();iO();Wa();Ha();Us();Vs();Gs();ks();Tv();qv="depthVertexShader",rO=`attribute vec3 position; #include #include #include @@ -6449,7 +6449,7 @@ vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); #endif #include } -`;E.ShadersStore[Kv]||(E.ShadersStore[Kv]=qP);V4={name:Kv,shader:qP}});var $P={};De($P,{depthVertexShaderWGSL:()=>G4});var Zv,JP,G4,eO=A(()=>{N();Cs();bs();wa();Ba();Ms();Oa();Ua();Va();ys();Ds();Ls();Ps();Zv="depthVertexShader",JP=`attribute position: vec3f; +`;E.ShadersStore[qv]||(E.ShadersStore[qv]=rO);nz={name:qv,shader:rO}});var aO={};De(aO,{depthVertexShaderWGSL:()=>sz});var Jv,sO,sz,oO=A(()=>{N();Cs();bs();wa();Ba();Ms();Oa();Ua();Va();ys();Ds();Ls();Ps();Jv="depthVertexShader",sO=`attribute position: vec3f; #include #include #include @@ -6505,7 +6505,7 @@ vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; #endif #endif } -`;E.ShadersStoreWGSL[Zv]||(E.ShadersStoreWGSL[Zv]=JP);G4={name:Zv,shader:JP}});var iO={};De(iO,{depthPixelShaderWGSL:()=>k4});var qv,tO,k4,rO=A(()=>{N();Os();Sm();Ns();qv="depthPixelShader",tO=`#ifdef ALPHATEST +`;E.ShadersStoreWGSL[Jv]||(E.ShadersStoreWGSL[Jv]=sO);sz={name:Jv,shader:sO}});var cO={};De(cO,{depthPixelShaderWGSL:()=>az});var $v,lO,az,fO=A(()=>{N();Os();Am();Ns();$v="depthPixelShader",lO=`#ifdef ALPHATEST varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; #endif #include @@ -6544,8 +6544,8 @@ fragmentOutputs.color= vec4f(input.vDepthMetric,0.0,0.0,1.0); #endif #endif #endif -}`;E.ShadersStoreWGSL[qv]||(E.ShadersStoreWGSL[qv]=tO);k4={name:qv,shader:tO}});var fc,nO=A(()=>{et();yt();oi();_a();Rs();Yv();jv();gi();kn();Oi();Da();fc=class n{get shaderLanguage(){return this._shaderLanguage}get alphaBlendedDepth(){return this._alphaBlendedDepth}set alphaBlendedDepth(e){this._alphaBlendedDepth!==e&&(this._alphaBlendedDepth=e,this._alphaBlendedDepthMaterialCache.clear())}setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}_ensureGaussianSplattingDepthMaterial(e,t){var s;let i=(s=e._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:s[t],r=this._alphaBlendedDepthMaterialCache.get(e.uniqueId);if(i===void 0||r!==this.alphaBlendedDepth){let a=e.material;if(!a)return null;let o=e.isCompound;i=a.makeDepthRenderingMaterial(this._scene,this._shaderLanguage,this.alphaBlendedDepth,o),this.setMaterialForRendering(e,i),this._alphaBlendedDepthMaterialCache.set(e.uniqueId,this.alphaBlendedDepth)}return i}constructor(e,t=1,i=null,r=!1,s=ne.TRILINEAR_SAMPLINGMODE,a=!1,o,l){this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this._alphaBlendedDepth=!1,this._alphaBlendedDepthMaterialCache=new Map,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=e,this._storeNonLinearDepth=r,this._storeCameraSpaceZ=a,this.isPacked=t===0,this.isPacked?this.clearColor=new Ne(1,1,1,1):this.clearColor=new Ne(a?0:1,0,0,1),this._initShaderSourceAsync(),n._SceneComponentInitialization(this._scene);let c=e.getEngine();this._camera=i,s!==ne.NEAREST_SAMPLINGMODE&&(t===1&&!c._caps.textureFloatLinearFiltering&&(s=ne.NEAREST_SAMPLINGMODE),t===2&&!c._caps.textureHalfFloatLinearFiltering&&(s=ne.NEAREST_SAMPLINGMODE));let f=this.isPacked||!c._features.supportExtendedTextureFormats?5:6;this._depthMap=l!=null?l:new ri(o!=null?o:"DepthRenderer",{width:c.getRenderWidth(),height:c.getRenderHeight()},this._scene,!1,!0,t,!1,s,void 0,void 0,void 0,f),this._depthMap.wrapU=ne.CLAMP_ADDRESSMODE,this._depthMap.wrapV=ne.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(h=>{h.clear(this.clearColor,!0,!0,!0)}),this._depthMap.customIsReadyFunction=(h,u,m)=>{if((m||u===0)&&h.subMeshes)for(let p=0;p{var P;let u=h.getRenderingMesh(),m=h.getEffectiveMesh(),p=this._scene,_=p.getEngine(),g=h.getMaterial();if(m._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!g||m.infiniteDistance||g.disableDepthWrite||h.verticesCount===0||h._renderId===p.getRenderId())return;let T=m._getWorldMatrixDeterminant()<0,b=g._getEffectiveOrientation(u);T&&(b=b===0?1:0);let R=b===0;_.setState(g.backFaceCulling,0,!1,R,this.reverseCulling?!g.cullBackFaces:g.cullBackFaces);let S=u._getInstancesRenderList(h._id,!!h.getReplacementMesh());if(S.mustReturn)return;let I=_.getCaps().instancedArrays&&(S.visibleInstances[h._id]!==null&&S.visibleInstances[h._id]!==void 0||u.hasThinInstances),x=this._camera||p.activeCamera;if(this.isReady(h,I)&&x){if(h._renderId=p.getRenderId(),m.getClassName()==="GaussianSplattingMesh"){let X=this._ensureGaussianSplattingDepthMaterial(m,_.currentRenderPassId);if(X&&!X.isReadyForSubMesh(m,h,I))return;this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),m.render(h,!1);return}let y=(P=m._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:P[_.currentRenderPassId],B=h._getDrawWrapper();!B&&y&&(B=y._getDrawWrapper());let w=x.mode===Ge.ORTHOGRAPHIC_CAMERA;if(!B)return;let H=B.effect;_.enableEffect(B),I||u._bind(h,H,g.fillMode),y?y.bindForSubMesh(m.getWorldMatrix(),m,h):(H.setMatrix("viewProjection",p.getTransformMatrix()),H.setMatrix("world",m.getWorldMatrix()),this._storeCameraSpaceZ&&H.setMatrix("view",p.getViewMatrix()));let O,V;if(w?(O=!_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1,V=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1):(O=_.useReverseDepthBuffer&&_.isNDCHalfZRange?x.minZ:_.isNDCHalfZRange?0:x.minZ,V=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:x.maxZ),H.setFloat2("depthValues",O,O+V),!y){if(g.needAlphaTestingForMesh(m)){let j=g.getAlphaTestTexture();j&&(H.setTexture("diffuseSampler",j),H.setMatrix("diffuseMatrix",j.getTextureMatrix()))}nr(u,H),Li(H,g,p),Pi(u,H),u.morphTargetManager&&u.morphTargetManager.isUsingTextureForTargets&&u.morphTargetManager._bind(H);let X=h.getMesh().bakedVertexAnimationManager;X&&X.isEnabled&&X.bind(H,I),g.pointsCloud&&H.setFloat("pointSize",g.pointSize)}this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),u._processRendering(m,h,H,g.fillMode,S,I,(X,j)=>H.setMatrix("world",j))}};this._depthMap.customRenderFunction=(h,u,m,p)=>{let _=this._scene.getEngine(),g=_.getAlphaMode(),T;if(p.length)for(T=0;T(eO(),$P)),Promise.resolve().then(()=>(rO(),iO))])):await Promise.all([Promise.resolve().then(()=>(jv(),QP)),Promise.resolve().then(()=>(Yv(),KP))]),this._shadersLoaded=!0}isReady(e,t){var x,P;if(!this._shadersLoaded)return!1;let i=this._scene.getEngine(),r=e.getMesh(),s=r.getScene(),a=this._depthMap.renderPassId,o=(P=(x=r._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:x[a])!=null?P:null;if(r.getClassName()==="GaussianSplattingMesh"&&(o=this._ensureGaussianSplattingDepthMaterial(r,a)),o)return o.isReadyForSubMesh(r,e,t);let l=e.getMaterial();if(!l||l.disableDepthWrite)return!1;let c=[],f=[M.PositionKind],d=!1,h=!1,u=!1;l.needAlphaTestingForMesh(r)&&l.getAlphaTestTexture()&&(c.push("#define ALPHATEST"),r.isVerticesDataPresent(M.UVKind)&&(f.push(M.UVKind),c.push("#define UV1"),d=!0),r.isVerticesDataPresent(M.UV2Kind)&&(f.push(M.UV2Kind),c.push("#define UV2"),h=!0));let m=new Bi;if(r.useBones&&r.computeBonesUsingShaders&&r.skeleton){f.push(M.MatricesIndicesKind),f.push(M.MatricesWeightsKind),r.numBoneInfluencers>4&&(f.push(M.MatricesIndicesExtraKind),f.push(M.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),r.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,r);let L=r.skeleton;L.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(L.bones.length+1))}else c.push("#define NUM_BONE_INFLUENCERS 0");let p=r.morphTargetManager?Wn(r.morphTargetManager,c,f,r,!0,!1,!1,d,h,u):0;l.pointsCloud&&c.push("#define POINTSIZE"),t&&(c.push("#define INSTANCES"),_n(f),e.getRenderingMesh().hasThinInstances&&c.push("#define THIN_INSTANCES"));let _=r.bakedVertexAnimationManager;_&&_.isEnabled&&(c.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&f.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&c.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&c.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&c.push("#define PACKED"),Gn(l,s,c);let g=i.currentRenderPassId,b=this._depthMap.renderPassIds.includes(g)?g:this._depthMap.renderPassId,R=e._getDrawWrapper(b,!0),S=R.defines,I=c.join(` -`);if(S!==I){let L=["world","mBones","boneTextureInfo","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],y=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];Di(L),R.setEffect(i.createEffect("depth",{attributes:f,uniformsNames:L,uniformBuffersNames:[],samplers:y,defines:I,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage},i),I)}return R.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){let e=[];for(let t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(let t of e)delete this._scene._depthRenderer[t]}}};fc.ForceGLSL=!1;fc._SceneComponentInitialization=n=>{throw Ie("DepthRendererSceneComponent")}});var aO={};De(aO,{minmaxReduxPixelShaderWGSL:()=>W4});var Qv,sO,W4,Jv=A(()=>{N();Qv="minmaxReduxPixelShader",sO=`varying vUV: vec2f;var textureSampler: texture_2d; +}`;E.ShadersStoreWGSL[$v]||(E.ShadersStoreWGSL[$v]=lO);az={name:$v,shader:lO}});var fc,dO=A(()=>{et();yt();oi();_a();Gn();Zv();Qv();Ei();Wn();Ni();Da();fc=class n{get shaderLanguage(){return this._shaderLanguage}get alphaBlendedDepth(){return this._alphaBlendedDepth}set alphaBlendedDepth(e){this._alphaBlendedDepth!==e&&(this._alphaBlendedDepth=e,this._alphaBlendedDepthMaterialCache.clear())}setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}_ensureGaussianSplattingDepthMaterial(e,t){var s;let i=(s=e._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:s[t],r=this._alphaBlendedDepthMaterialCache.get(e.uniqueId);if(i===void 0||r!==this.alphaBlendedDepth){let a=e.material;if(!a)return null;let o=e.isCompound;i=a.makeDepthRenderingMaterial(this._scene,this._shaderLanguage,this.alphaBlendedDepth,o),this.setMaterialForRendering(e,i),this._alphaBlendedDepthMaterialCache.set(e.uniqueId,this.alphaBlendedDepth)}return i}constructor(e,t=1,i=null,r=!1,s=ne.TRILINEAR_SAMPLINGMODE,a=!1,o,l){this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this._alphaBlendedDepth=!1,this._alphaBlendedDepthMaterialCache=new Map,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=e,this._storeNonLinearDepth=r,this._storeCameraSpaceZ=a,this.isPacked=t===0,this.isPacked?this.clearColor=new Ne(1,1,1,1):this.clearColor=new Ne(a?0:1,0,0,1),this._initShaderSourceAsync(),n._SceneComponentInitialization(this._scene);let c=e.getEngine();this._camera=i,s!==ne.NEAREST_SAMPLINGMODE&&(t===1&&!c._caps.textureFloatLinearFiltering&&(s=ne.NEAREST_SAMPLINGMODE),t===2&&!c._caps.textureHalfFloatLinearFiltering&&(s=ne.NEAREST_SAMPLINGMODE));let f=this.isPacked||!c._features.supportExtendedTextureFormats?5:6;this._depthMap=l!=null?l:new ri(o!=null?o:"DepthRenderer",{width:c.getRenderWidth(),height:c.getRenderHeight()},this._scene,!1,!0,t,!1,s,void 0,void 0,void 0,f),this._depthMap.wrapU=ne.CLAMP_ADDRESSMODE,this._depthMap.wrapV=ne.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(h=>{h.clear(this.clearColor,!0,!0,!0)}),this._depthMap.customIsReadyFunction=(h,u,m)=>{if((m||u===0)&&h.subMeshes)for(let p=0;p{var P;let u=h.getRenderingMesh(),m=h.getEffectiveMesh(),p=this._scene,_=p.getEngine(),g=h.getMaterial();if(m._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!g||m.infiniteDistance||g.disableDepthWrite||h.verticesCount===0||h._renderId===p.getRenderId())return;let T=m._getWorldMatrixDeterminant()<0,b=g._getEffectiveOrientation(u);T&&(b=b===0?1:0);let R=b===0;_.setState(g.backFaceCulling,0,!1,R,this.reverseCulling?!g.cullBackFaces:g.cullBackFaces);let S=u._getInstancesRenderList(h._id,!!h.getReplacementMesh());if(S.mustReturn)return;let I=_.getCaps().instancedArrays&&(S.visibleInstances[h._id]!==null&&S.visibleInstances[h._id]!==void 0||u.hasThinInstances),x=this._camera||p.activeCamera;if(this.isReady(h,I)&&x){if(h._renderId=p.getRenderId(),m.getClassName()==="GaussianSplattingMesh"){let X=this._ensureGaussianSplattingDepthMaterial(m,_.currentRenderPassId);if(X&&!X.isReadyForSubMesh(m,h,I))return;this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),m.render(h,!1);return}let y=(P=m._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:P[_.currentRenderPassId],B=h._getDrawWrapper();!B&&y&&(B=y._getDrawWrapper());let w=x.mode===Ue.ORTHOGRAPHIC_CAMERA;if(!B)return;let H=B.effect;_.enableEffect(B),I||u._bind(h,H,g.fillMode),y?y.bindForSubMesh(m.getWorldMatrix(),m,h):(H.setMatrix("viewProjection",p.getTransformMatrix()),H.setMatrix("world",m.getWorldMatrix()),this._storeCameraSpaceZ&&H.setMatrix("view",p.getViewMatrix()));let O,k;if(w?(O=!_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1,k=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1):(O=_.useReverseDepthBuffer&&_.isNDCHalfZRange?x.minZ:_.isNDCHalfZRange?0:x.minZ,k=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:x.maxZ),H.setFloat2("depthValues",O,O+k),!y){if(g.needAlphaTestingForMesh(m)){let j=g.getAlphaTestTexture();j&&(H.setTexture("diffuseSampler",j),H.setMatrix("diffuseMatrix",j.getTextureMatrix()))}or(u,H),Pi(H,g,p),Oi(u,H),u.morphTargetManager&&u.morphTargetManager.isUsingTextureForTargets&&u.morphTargetManager._bind(H);let X=h.getMesh().bakedVertexAnimationManager;X&&X.isEnabled&&X.bind(H,I),g.pointsCloud&&H.setFloat("pointSize",g.pointSize)}this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),u._processRendering(m,h,H,g.fillMode,S,I,(X,j)=>H.setMatrix("world",j))}};this._depthMap.customRenderFunction=(h,u,m,p)=>{let _=this._scene.getEngine(),g=_.getAlphaMode(),T;if(p.length)for(T=0;T(oO(),aO)),Promise.resolve().then(()=>(fO(),cO))])):await Promise.all([Promise.resolve().then(()=>(Qv(),nO)),Promise.resolve().then(()=>(Zv(),eO))]),this._shadersLoaded=!0}isReady(e,t){var x,P;if(!this._shadersLoaded)return!1;let i=this._scene.getEngine(),r=e.getMesh(),s=r.getScene(),a=this._depthMap.renderPassId,o=(P=(x=r._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:x[a])!=null?P:null;if(r.getClassName()==="GaussianSplattingMesh"&&(o=this._ensureGaussianSplattingDepthMaterial(r,a)),o)return o.isReadyForSubMesh(r,e,t);let l=e.getMaterial();if(!l||l.disableDepthWrite)return!1;let c=[],f=[M.PositionKind],d=!1,h=!1,u=!1;l.needAlphaTestingForMesh(r)&&l.getAlphaTestTexture()&&(c.push("#define ALPHATEST"),r.isVerticesDataPresent(M.UVKind)&&(f.push(M.UVKind),c.push("#define UV1"),d=!0),r.isVerticesDataPresent(M.UV2Kind)&&(f.push(M.UV2Kind),c.push("#define UV2"),h=!0));let m=new Ui;if(r.useBones&&r.computeBonesUsingShaders&&r.skeleton){f.push(M.MatricesIndicesKind),f.push(M.MatricesWeightsKind),r.numBoneInfluencers>4&&(f.push(M.MatricesIndicesExtraKind),f.push(M.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),r.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,r);let L=r.skeleton;L.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(L.bones.length+1))}else c.push("#define NUM_BONE_INFLUENCERS 0");let p=r.morphTargetManager?Hn(r.morphTargetManager,c,f,r,!0,!1,!1,d,h,u):0;l.pointsCloud&&c.push("#define POINTSIZE"),t&&(c.push("#define INSTANCES"),gn(f),e.getRenderingMesh().hasThinInstances&&c.push("#define THIN_INSTANCES"));let _=r.bakedVertexAnimationManager;_&&_.isEnabled&&(c.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&f.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&c.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&c.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&c.push("#define PACKED"),kn(l,s,c);let g=i.currentRenderPassId,b=this._depthMap.renderPassIds.includes(g)?g:this._depthMap.renderPassId,R=e._getDrawWrapper(b,!0),S=R.defines,I=c.join(` +`);if(S!==I){let L=["world","mBones","boneTextureInfo","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],y=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];Li(L),R.setEffect(i.createEffect("depth",{attributes:f,uniformsNames:L,uniformBuffersNames:[],samplers:y,defines:I,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage},i),I)}return R.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){let e=[];for(let t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(let t of e)delete this._scene._depthRenderer[t]}}};fc.ForceGLSL=!1;fc._SceneComponentInitialization=n=>{throw Ie("DepthRendererSceneComponent")}});var uO={};De(uO,{minmaxReduxPixelShaderWGSL:()=>oz});var eT,hO,oz,tT=A(()=>{N();eT="minmaxReduxPixelShader",hO=`varying vUV: vec2f;var textureSampler: texture_2d; #if defined(INITIAL) uniform texSize: vec2f;@fragment fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*(uniforms.texSize-1.0));let f1=textureLoad(textureSampler,coord,0).r;let f2=textureLoad(textureSampler,coord+vec2i(1,0),0).r;let f3=textureLoad(textureSampler,coord+vec2i(1,1),0).r;let f4=textureLoad(textureSampler,coord+vec2i(0,1),0).r; @@ -6574,7 +6574,7 @@ fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs. fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);if (true) { discard;}} #endif -`;E.ShadersStoreWGSL[Qv]||(E.ShadersStoreWGSL[Qv]=sO);W4={name:Qv,shader:sO}});var lO={};De(lO,{minmaxReduxPixelShader:()=>H4});var $v,oO,H4,eT=A(()=>{N();$v="minmaxReduxPixelShader",oO=`varying vec2 vUV;uniform sampler2D textureSampler; +`;E.ShadersStoreWGSL[eT]||(E.ShadersStoreWGSL[eT]=hO);oz={name:eT,shader:hO}});var pO={};De(pO,{minmaxReduxPixelShader:()=>lz});var iT,mO,lz,rT=A(()=>{N();iT="minmaxReduxPixelShader",mO=`varying vec2 vUV;uniform sampler2D textureSampler; #if defined(INITIAL) uniform vec2 texSize;void main(void) {ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(textureSampler,coord,0).r;float f2=texelFetch(textureSampler,coord+ivec2(1,0),0).r;float f3=texelFetch(textureSampler,coord+ivec2(1,1),0).r;float f4=texelFetch(textureSampler,coord+ivec2(0,1),0).r; @@ -6603,12 +6603,12 @@ void main(void) {glFragColor=vec4(0.);if (true) { discard;}} #endif -`;E.ShadersStore[$v]||(E.ShadersStore[$v]=oO);H4={name:$v,shader:oO}});var cO,za,z4,X4,Tn,Im,fO=A(()=>{ct();Eo();At();(function(n){n[n.NormalizedViewDepth=0]="NormalizedViewDepth",n[n.ViewDepth=1]="ViewDepth",n[n.ScreenDepth=2]="ScreenDepth"})(cO||(cO={}));za=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(Jv(),aO)))):t.push(Promise.resolve().then(()=>(eT(),lO)))}constructor(e,t=null,i="",r){super({...r,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,defines:i}),this.textureWidth=0,this.textureHeight=0}bind(e=!1){super.bind(e);let t=this.drawWrapper.effect;this.textureWidth===1||this.textureHeight===1?t.setInt2("texSize",this.textureWidth,this.textureHeight):t.setFloat2("texSize",this.textureWidth,this.textureHeight)}};za.FragmentUrl="minmaxRedux";za.Uniforms=["texSize"];z4=new Float32Array(4),X4=new Uint8Array(4),Tn={min:0,max:0},Im=class{get depthRedux(){return this._depthRedux}set depthRedux(e){this._depthRedux!==e&&(this._depthRedux=e,this._recreatePostProcesses())}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}constructor(e,t=!0){this.onAfterReductionPerformed=new Y,this._textureWidth=0,this._textureHeight=0,this._scene=e,this._depthRedux=t,this.reductionSteps=[]}setTextureDimensions(e,t,i=0){return e===this._textureWidth&&t===this._textureHeight&&i===this._depthTextureType?!1:(this._textureWidth=e,this._textureHeight=t,this._depthTextureType=i,this._recreatePostProcesses(),!0)}readMinMax(e){let t=e.type===1||e.type===2,i=t?z4:X4;this._scene.getEngine()._readTexturePixels(e,1,1,-1,0,i,!1),Tn.min=i[0],Tn.max=i[1],t||(Tn.min=Tn.min/255,Tn.max=Tn.max/255),Tn.min>=Tn.max&&(Tn.min=0,Tn.max=1),this.onAfterReductionPerformed.notifyObservers(Tn)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._textureWidth=0,this._textureHeight=0);for(let t=0;t{ft();Eo();At();(function(n){n[n.NormalizedViewDepth=0]="NormalizedViewDepth",n[n.ViewDepth=1]="ViewDepth",n[n.ScreenDepth=2]="ScreenDepth"})(_O||(_O={}));za=class n extends li{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(tT(),uO)))):t.push(Promise.resolve().then(()=>(rT(),pO)))}constructor(e,t=null,i="",r){super({...r,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,defines:i}),this.textureWidth=0,this.textureHeight=0}bind(e=!1){super.bind(e);let t=this.drawWrapper.effect;this.textureWidth===1||this.textureHeight===1?t.setInt2("texSize",this.textureWidth,this.textureHeight):t.setFloat2("texSize",this.textureWidth,this.textureHeight)}};za.FragmentUrl="minmaxRedux";za.Uniforms=["texSize"];cz=new Float32Array(4),fz=new Uint8Array(4),Sn={min:0,max:0},xm=class{get depthRedux(){return this._depthRedux}set depthRedux(e){this._depthRedux!==e&&(this._depthRedux=e,this._recreatePostProcesses())}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}constructor(e,t=!0){this.onAfterReductionPerformed=new Y,this._textureWidth=0,this._textureHeight=0,this._scene=e,this._depthRedux=t,this.reductionSteps=[]}setTextureDimensions(e,t,i=0){return e===this._textureWidth&&t===this._textureHeight&&i===this._depthTextureType?!1:(this._textureWidth=e,this._textureHeight=t,this._depthTextureType=i,this._recreatePostProcesses(),!0)}readMinMax(e){let t=e.type===1||e.type===2,i=t?cz:fz;this._scene.getEngine()._readTexturePixels(e,1,1,-1,0,i,!1),Sn.min=i[0],Sn.max=i[1],t||(Sn.min=Sn.min/255,Sn.max=Sn.max/255),Sn.min>=Sn.max&&(Sn.min=0,Sn.max=1),this.onAfterReductionPerformed.notifyObservers(Sn)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._textureWidth=0,this._textureHeight=0);for(let t=0;t1||i>1;){t=Math.max(Math.round(t/2),1),i=Math.max(Math.round(i/2),1);let a=new za("Reduction phase "+s,e.getEngine(),"#define "+(t==1&&i==1?"LAST":t==1||i==1?"ONEBEFORELAST":"MAIN"));a.textureWidth=t,a.textureHeight=i,this.reductionSteps.push(a),s++}}}});var xm,dO=A(()=>{ms();Eh();fO();eT();Jv();xm=class{get onAfterReductionPerformed(){return this._thinMinMaxReducer.onAfterReductionPerformed}constructor(e){this._onAfterUnbindObserver=null,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new us(e.getScene()),this._thinMinMaxReducer=new Im(e.getScene()),this._reductionSteps=[],this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{this._postProcessManager._rebuild()})}get sourceTexture(){return this._sourceTexture}setSourceTexture(e,t,i=2,r=!0){if(e!==this._sourceTexture&&(this._thinMinMaxReducer.depthRedux=t,this.deactivate(),this._sourceTexture=e,this._forceFullscreenViewport=r,this._thinMinMaxReducer.setTextureDimensions(e.getRenderWidth(),e.getRenderHeight()))){this._disposePostProcesses();let s=this._thinMinMaxReducer.reductionSteps;for(let a=0;a{c.setTexture("textureSampler",this._sourceTexture)})),a===s.length-1&&this._reductionSteps[a-1].onAfterRenderObservable.add(()=>{this._thinMinMaxReducer.readMinMax(l.inputTexture.texture)})}}}get refreshRate(){return this._sourceTexture?this._sourceTexture.refreshRate:-1}set refreshRate(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)}get activated(){return this._activated}activate(){this._onAfterUnbindObserver||!this._sourceTexture||(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add(()=>{var t,i;let e=this._camera.getScene().getEngine();(t=e._debugPushGroup)==null||t.call(e,"min max reduction"),this._reductionSteps[0].activate(this._camera),this._postProcessManager.directRender(this._reductionSteps,this._reductionSteps[0].inputTexture,this._forceFullscreenViewport,0,0,!0,this._reductionSteps.length-1),e.unBindFramebuffer(this._reductionSteps[this._reductionSteps.length-1].inputTexture,!1),(i=e._debugPopGroup)==null||i.call(e)}),this._activated=!0)}deactivate(){!this._onAfterUnbindObserver||!this._sourceTexture||(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=void 0,this._disposePostProcesses(),this._postProcessManager.dispose(),this._postProcessManager=void 0,this._thinMinMaxReducer.dispose(),this._thinMinMaxReducer=void 0,this._sourceTexture=null)}_disposePostProcesses(){for(let e=0;e{nO();dO();Cm=class extends xm{get depthRenderer(){return this._depthRenderer}constructor(e){super(e)}setDepthRenderer(e=null,t=2,i=!0){let r=this._camera.getScene();this._depthRenderer&&(delete r._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),e===null&&(r._depthRenderer||(r._depthRenderer={}),this._depthRendererId="minmax_"+this._camera.uniqueId,e=this._depthRenderer=new fc(r,t,this._camera,!1,1,!1,`DepthRenderer ${this._depthRendererId}`),e.enabled=!1,r._depthRenderer[this._depthRendererId]=e),super.setSourceTexture(e.getDepthMap(),!0,t,i)}setSourceTexture(e,t,i=2,r=!0){super.setSourceTexture(e,t,i,r)}activate(){this._depthRenderer&&(this._depthRenderer.enabled=!0),super.activate()}deactivate(){super.deactivate(),this._depthRenderer&&(this._depthRenderer.enabled=!1)}dispose(e=!0){super.dispose(e),this._depthRenderer&&e&&(this._depthRenderer.dispose(),this._depthRenderer=null)}}});var uO,Y4,qt,dc,bm,Sn,mO=A(()=>{ve();_a();gi();Rm();bl();hO();ze();At();cf();uO=v.Up(),Y4=v.Zero(),qt=new v,dc=new v,bm=new G,Sn=class n extends St{_validateFilter(e){return e===St.FILTER_NONE||e===St.FILTER_PCF||e===St.FILTER_PCSS?e:(W.Error('Unsupported filter "'+e+'"!'),St.FILTER_NONE)}get numCascades(){return this._numCascades}set numCascades(e){e=Math.min(Math.max(e,n.MIN_CASCADES_COUNT),n.MAX_CASCADES_COUNT),e!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap(),this._recreateSceneUBOs())}get freezeShadowCastersBoundingInfo(){return this._freezeShadowCastersBoundingInfo}set freezeShadowCastersBoundingInfo(e){this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),!this._freezeShadowCastersBoundingInfoObservable&&!e&&(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(()=>this._computeShadowCastersBoundingInfo())),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()}_computeShadowCastersBoundingInfo(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){let e=this._shadowMap.renderList;for(let t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)}get minDistance(){return this._minDistance}get maxDistance(){return this._maxDistance}getClassName(){return n.CLASSNAME}getCascadeMinExtents(e){return e>=0&&e=0&&et.maxZ&&t.maxZ!==0||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0)}get debug(){return this._debug}set debug(e){this._debug=e,this._light._markMeshesAsLightDirty()}get depthClamp(){return this._depthClamp}set depthClamp(e){this._depthClamp=e}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()}get lambda(){return this._lambda}set lambda(e){let t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)}getCascadeViewMatrix(e){return e>=0&&e=0&&e=0&&e{let r=i.min,s=i.max;r>=s&&(r=0,s=1),(r!=this._minDistance||s!=this._maxDistance)&&this.setMinMaxDistance(r,s)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}}get autoCalcDepthBoundsRefreshRate(){var e,t,i;return(i=(t=(e=this._depthReducer)==null?void 0:e.depthRenderer)==null?void 0:t.getDepthMap().refreshRate)!=null?i:-1}set autoCalcDepthBoundsRefreshRate(e){var t;(t=this._depthReducer)!=null&&t.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)}splitFrustum(){this._breaksAreDirty=!0}_splitFrustum(){let e=this._getCamera();if(!e)return;let t=e.minZ,i=e.maxZ||this._shadowMaxZ,r=i-t,s=this._minDistance,a=this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance,o=t+s*r,l=t+a*r,c=l-o,f=l/o;for(let d=0;da||(!this._depthClamp||this.filter===St.FILTER_PCSS?(s=Math.min(s,l),this.filter!==St.FILTER_PCSS&&(a=Math.min(a,c))):(a=Math.min(a,c),s=Math.max(s,l),a=Math.max(s+1,a))),G.OrthoOffCenterLHToRef(this._cascadeMinExtents[r].x,this._cascadeMaxExtents[r].x,this._cascadeMinExtents[r].y,this._cascadeMaxExtents[r].y,i?a:s,i?s:a,this._projectionMatrices[r],e.getEngine().isNDCHalfZRange),this._cascadeMinExtents[r].z=s,this._cascadeMaxExtents[r].z=a,this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r],this._transformMatrices[r]),v.TransformCoordinatesToRef(Y4,this._transformMatrices[r],qt),qt.scaleInPlace(this._mapSize/2),dc.copyFromFloats(Math.round(qt.x),Math.round(qt.y),Math.round(qt.z)),dc.subtractInPlace(qt).scaleInPlace(2/this._mapSize),G.TranslationToRef(dc.x,dc.y,0,bm),this._projectionMatrices[r].multiplyToRef(bm,this._projectionMatrices[r]),this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r],this._transformMatrices[r]),this._transformMatrices[r].copyToArray(this._transformMatricesAsArray,r*16)}}_computeFrustumInWorldSpace(e){let t=this._getCamera();if(!t)return;let i=this._cascades[e].prevBreakDistance,r=this._cascades[e].breakDistance,s=this._scene.getEngine().isNDCHalfZRange;t.getViewMatrix();let a=t.maxZ===0,o=t.maxZ;a&&(t.maxZ=this._shadowMaxZ,t.getProjectionMatrix(!0));let l=G.Invert(t.getTransformationMatrix());a&&(t.maxZ=o,t.getProjectionMatrix(!0));let c=this._scene.getEngine().useReverseDepthBuffer?4:0;for(let f=0;f{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[t]),this._currentLayer=t,this._filter===St.FILTER_PCF&&e.setColorWrite(!1),Br.eyeAtCamera=!1,this._scene.setTransformMatrix(this.getCascadeViewMatrix(t),this.getCascadeProjectionMatrix(t)),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onBeforeBindObservable.add(()=>{var t;this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._enableGPUDebugMarkers&&((t=e._debugPushGroup)==null||t.call(e,`Cascaded shadow map generation for pass id ${e.currentRenderPassId}`)),this._breaksAreDirty&&this._splitFrustum(),this._computeMatrices()}),this._splitFrustum()}_bindCustomEffectForRenderSubMeshForShadowMap(e,t){t.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))}_isReadyCustomDefines(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==St.FILTER_PCSS?"1":"0"))}prepareDefines(e,t){super.prepareDefines(e,t);let i=this._scene,r=this._light;if(!i.shadowsEnabled||!r.shadowEnabled)return;e["SHADOWCSM"+t]=!0,e["SHADOWCSMDEBUG"+t]=this.debug,e["SHADOWCSMNUM_CASCADES"+t]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+t]=i.useRightHandedSystem;let s=this._getCamera();s&&this._shadowMaxZ<=(s.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+t]=!0),this.cascadeBlendPercentage===0&&(e["SHADOWCSMNOBLEND"+t]=!0)}bindShadowLight(e,t){let i=this._light,r=this._scene;if(!r.shadowsEnabled||!i.shadowEnabled)return;let s=this._getCamera();if(!s)return;let a=this.getShadowMap();if(!a)return;let o=a.getSize().width,l=this._transformMatricesAsArray,c=r.floatingOriginMode?Bx(this._scene.floatingOriginOffset,this._viewMatrices,this._projectionMatrices,this._numCascades,this._tempTransformMatricesAsArray):l;if(t.setMatrices("lightMatrix"+e,c),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,this.cascadeBlendPercentage===0?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===St.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o,1/o,this.frustumEdgeFalloff,e);else if(this._filter===St.FILTER_PCSS){for(let f=0;fnew n(r,s,void 0,a));return e.numCascades!==void 0&&(i.numCascades=e.numCascades),e.debug!==void 0&&(i.debug=e.debug),e.stabilizeCascades!==void 0&&(i.stabilizeCascades=e.stabilizeCascades),e.lambda!==void 0&&(i.lambda=e.lambda),e.cascadeBlendPercentage!==void 0&&(i.cascadeBlendPercentage=e.cascadeBlendPercentage),e.depthClamp!==void 0&&(i.depthClamp=e.depthClamp),e.autoCalcDepthBounds!==void 0&&(i.autoCalcDepthBounds=e.autoCalcDepthBounds),e.shadowMaxZ!==void 0&&(i.shadowMaxZ=e.shadowMaxZ),e.penumbraDarkness!==void 0&&(i.penumbraDarkness=e.penumbraDarkness),e.freezeShadowCastersBoundingInfo!==void 0&&(i.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),e.minDistance!==void 0&&e.maxDistance!==void 0&&i.setMinMaxDistance(e.minDistance,e.maxDistance),i}};Sn._FrustumCornersNdcSpace=[new v(-1,1,-1),new v(1,1,-1),new v(1,-1,-1),new v(-1,-1,-1),new v(-1,1,1),new v(1,1,1),new v(1,-1,1),new v(-1,-1,1)];Sn.CLASSNAME="CascadedShadowGenerator";Sn.DEFAULT_CASCADES_COUNT=4;Sn.MIN_CASCADES_COUNT=2;Sn.MAX_CASCADES_COUNT=4;Sn._SceneComponentInitialization=n=>{throw Ie("ShadowGeneratorSceneComponent")}});function Mm(n,e){K4[n]=e}var K4,tT=A(()=>{K4={}});var iT,pO=A(()=>{Rm();mO();El();tT();Mm(be.NAME_SHADOWGENERATOR,(n,e)=>{if(n.shadowGenerators!==void 0&&n.shadowGenerators!==null)for(let t=0,i=n.shadowGenerators.length;t{let e=n._getComponent(be.NAME_SHADOWGENERATOR);e||(e=new iT(n),n._addComponent(e))}});async function _O(n,e){let t=e.method||"GET";return await new Promise((i,r)=>{let s=new $t;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){let a={};if(e.responseHeaders)for(let o of e.responseHeaders)a[o]=s.getResponseHeader(o)||"";i({response:s.response,headerValues:a})}else r(`Unable to fetch data from ${n}. Error code: ${s.status}`)}),s.open(t,n),s.send()})}var gO=A(()=>{mo()});function j4(n){return!!n.createPlugin}function Z4(n){return!!n.name}function ym(){return Yn[".babylon"]}function q4(n){for(let e in Yn){let t=Yn[e];if(t.mimeType===n)return t}}function nT(n,e){let t=Yn[n];return t||(W.Warn("Unable to find a plugin to load "+n+" 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?ym():void 0)}function Q4(n){return!!Yn[n]}function J4(n){for(let e in Yn){let t=Yn[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(n))return Yn[e]}return ym()}function $4(n){let e=n.indexOf("?");e!==-1&&(n=n.substring(0,e));let t=n.lastIndexOf(".");return n.substring(t,n.length).toLowerCase()}function ez(n){return n.substring(0,5)==="data:"?n.substring(5):null}function sT(n,e,t){let r="Unable to load from "+(n.rawData?"binary data":n.url);return e?r+=`: ${e}`:t&&(r+=`: ${t}`),r}async function aT(n,e,t,i,r,s,a,o,l){var u;let c=ez(n.url);if(n.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";let f=!c&&!a?$4(n.url):"",d=a?nT(a,!0):c?J4(n.url):nT(f,!1);if(!d&&f){if(n.url&&!n.url.startsWith("blob:")){let m=await _O(n.url,{method:"HEAD",responseHeaders:["Content-Type"]}),p=m.headerValues?m.headerValues["Content-Type"]:"";p&&(d=q4(p))}d||(d=ym())}if(!d)throw new Error(`No plugin or fallback for ${a!=null?a:n.url}`);if(((u=l==null?void 0:l[d.plugin.name])==null?void 0:u.enabled)===!1)throw new Error(`The '${d.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(n.rawData&&!d.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(m=>{if(j4(d.plugin)){let _=d.plugin.createPlugin(l!=null?l:{});return _ instanceof Promise?(_.then(m).catch(g=>{r("Error instantiating plugin.",g)}),null):(m(_),_)}else return m(d.plugin),d.plugin})(m=>{var I;if(!m)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(vO.notifyObservers(m),c&&(m.canDirectLoad&&m.canDirectLoad(n.url)||!fa(n.url))){if(m.directLoad){let x=m.directLoad(e,c);x instanceof Promise?x.then(P=>{t(m,P)}).catch(P=>{r("Error in directLoad of _loadData: "+P,P)}):t(m,x)}else t(m,c);return}let p=d.isBinary,_=(x,P)=>{if(e.isDisposed){r("Scene has been disposed");return}t(m,x,P)},g=null,T=!1;(I=m.onDisposeObservable)==null||I.add(()=>{T=!0,g&&(g.abort(),g=null),s()});let b=()=>{if(T)return;let x=(P,L)=>{r(P==null?void 0:P.statusText,L)};if(!m.loadFile&&n.rawData)throw"Plugin does not support loading ArrayBufferView.";g=m.loadFile?m.loadFile(e,n.rawData||n.file||n.url,n.rootUrl,_,i,p,x,o):e._loadFile(n.file||n.url,_,i,!0,p,x)},R=e.getEngine(),S=R.enableOfflineSupport;if(S){let x=!1;for(let P of e.disableOfflineSupportExceptionRules)if(P.test(n.url)){x=!0;break}S=!x}S&&fe.OfflineProviderFactory?e.offlineProvider=fe.OfflineProviderFactory(n.url,b,R.disableManifestCheck):b()})}function oT(n,e){let t,i,r=null,s=null;if(!e)t=n,i=re.GetFilename(n),n=re.GetFolderPath(n);else if(Z4(e))t=`file:${e.name}`,i=e.name,r=e;else if(ArrayBuffer.isView(e))t="",i=la(),s=e;else if(e.startsWith("data:"))t=e,i="";else if(n){let a=e;if(a.substring(0,1)==="/")return re.Error("Wrong sceneFilename parameter"),null;t=n+a,i=a}else t=e,i=re.GetFilename(e),n=re.GetFolderPath(e);return{url:t,rootUrl:n,name:i,file:r,rawData:s}}function Xa(n){if(typeof n.extensions=="string"){let e=n.extensions;Yn[e.toLowerCase()]={plugin:n,isBinary:!1}}else{let e=n.extensions,t=Object.keys(e);for(let i of t)Yn[i.toLowerCase()]={plugin:n,isBinary:e[i].isBinary,mimeType:e[i].mimeType}}}async function Yf(n,e,t){let{meshNames:i,rootUrl:r="",onProgress:s,pluginExtension:a,name:o,pluginOptions:l}=t!=null?t:{};return await SO(i,r,n,e,s,a,o,l)}async function TO(n,e,t="",i=ue.LastCreatedScene,r=null,s=null,a=null,o=null,l="",c={}){if(!i)return W.Error("No scene available to import mesh to"),null;let f=oT(e,t);if(!f)return null;let d={};i.addPendingData(d);let h=()=>{i.removePendingData(d)},u=(_,g)=>{let T=sT(f,_,g);a?a(i,T,new ir(T,Lr.SceneLoaderError,g)):W.Error(T),h()},m=s?_=>{try{s(_)}catch(g){u("Error in onProgress callback: "+g,g)}}:void 0,p=(_,g,T,b,R,S,I,x)=>{if(i.importedMeshesFiles.push(f.url),r)try{r(_,g,T,b,R,S,I,x)}catch(P){u("Error in onSuccess callback: "+P,P)}i.removePendingData(d)};return await aT(f,i,(_,g,T)=>{if(_.rewriteRootURL&&(f.rootUrl=_.rewriteRootURL(f.rootUrl,T)),_.importMesh){let b=_,R=[],S=[],I=[];if(!b.importMesh(n,i,g,f.rootUrl,R,S,I,u))return;i.loadingPluginName=_.name,p(R,S,I,[],[],[],[],[])}else _.importMeshAsync(n,i,g,f.rootUrl,m,f.name).then(R=>{i.loadingPluginName=_.name,p(R.meshes,R.particleSystems,R.skeletons,R.animationGroups,R.transformNodes,R.geometries,R.lights,R.spriteManagers)}).catch(R=>{u(R.message,R)})},m,u,h,o,l,c)}async function SO(n,e,t,i,r,s,a,o){return await new Promise((l,c)=>{try{TO(n,e,t,i,(f,d,h,u,m,p,_,g)=>{l({meshes:f,particleSystems:d,skeletons:h,animationGroups:u,transformNodes:m,geometries:p,lights:_,spriteManagers:g})},r,(f,d,h)=>{c(h||new Error(d))},s,a,o).catch(c)}catch(f){c(f)}})}async function AO(n,e="",t=ue.LastCreatedEngine,i=null,r=null,s=null,a=null,o="",l={}){if(!t){re.Error("No engine available");return}await lT(n,e,new gt(t),i,r,s,a,o,l)}async function tz(n,e,t,i,r,s,a){return await new Promise((o,l)=>{AO(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a)})}async function lT(n,e="",t=ue.LastCreatedScene,i=null,r=null,s=null,a=null,o="",l={}){if(!t)return W.Error("No scene available to append to"),null;let c=oT(n,e);if(!c)return null;let f={};t.addPendingData(f);let d=()=>{t.removePendingData(f)};ci.ShowLoadingScreen&&!rT&&(rT=!0,t.getEngine().displayLoadingUI(),t.executeWhenReady(()=>{t.getEngine().hideLoadingUI(),rT=!1}));let h=(p,_)=>{let g=sT(c,p,_);s?s(t,g,new ir(g,Lr.SceneLoaderError,_)):W.Error(g),d()},u=r?p=>{try{r(p)}catch(_){h("Error in onProgress callback",_)}}:void 0,m=()=>{if(i)try{i(t)}catch(p){h("Error in onSuccess callback",p)}t.removePendingData(f)};return await aT(c,t,(p,_)=>{if(p.load){if(!p.load(t,_,c.rootUrl,h))return;t.loadingPluginName=p.name,m()}else p.loadAsync(t,_,c.rootUrl,u,c.name).then(()=>{t.loadingPluginName=p.name,m()}).catch(T=>{h(T.message,T)})},u,h,d,a,o,l)}async function iz(n,e,t,i,r,s,a){return await new Promise((o,l)=>{try{lT(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a).catch(l)}catch(c){l(c)}})}async function cT(n,e="",t=ue.LastCreatedScene,i=null,r=null,s=null,a=null,o="",l={}){if(!t)return W.Error("No scene available to load asset container to"),null;let c=oT(n,e);if(!c)return null;let f={};t.addPendingData(f);let d=()=>{t.removePendingData(f)},h=(p,_)=>{let g=sT(c,p,_);s?s(t,g,new ir(g,Lr.SceneLoaderError,_)):W.Error(g),d()},u=r?p=>{try{r(p)}catch(_){h("Error in onProgress callback",_)}}:void 0,m=p=>{if(i)try{i(p)}catch(_){h("Error in onSuccess callback",_)}t.removePendingData(f)};return await aT(c,t,(p,_)=>{if(p.loadAssetContainer){let T=p.loadAssetContainer(t,_,c.rootUrl,h);if(!T)return;T.populateRootNodes(),t.loadingPluginName=p.name,m(T)}else p.loadAssetContainerAsync?p.loadAssetContainerAsync(t,_,c.rootUrl,u,c.name).then(T=>{T.populateRootNodes(),t.loadingPluginName=p.name,m(T)}).catch(T=>{h(T.message,T)}):h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},u,h,d,a,o,l)}async function rz(n,e,t,i,r,s,a){return await new Promise((o,l)=>{try{cT(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a).catch(l)}catch(c){l(c)}})}async function RO(n,e="",t=ue.LastCreatedScene,i=!0,r=0,s=null,a=null,o=null,l=null,c=null,f="",d={}){if(!t){W.Error("No scene available to load animations to");return}if(i){for(let _ of t.animatables)_.reset();t.stopAllAnimations();let m=t.animationGroups.slice();for(let _ of m)_.dispose();let p=t.getNodes();for(let _ of p)_.animations&&(_.animations=[])}else switch(r){case 0:let m=t.animationGroups.slice();for(let p of m)p.dispose();break;case 1:for(let p of t.animationGroups)p.stop();break;case 2:for(let p of t.animationGroups)p.reset(),p.restart();break;case 3:break;default:W.Error("Unknown animation group loading mode value '"+r+"'");return}let h=t.animatables.length;await cT(n,e,t,m=>{m.mergeAnimationsTo(t,t.animatables.slice(h),s),m.dispose(),t.onAnimationFileImportedObservable.notifyObservers(t),a&&a(t)},o,l,c,f,d)}async function nz(n,e,t,i,r,s,a,o,l,c){return await new Promise((f,d)=>{try{RO(n,e,t,i,r,s,h=>{f(h)},a,(h,u,m)=>{d(m||new Error(u))},o,l,c).catch(d)}catch(h){d(h)}})}var EO,vO,Yn,rT,Fo,hc=A(()=>{Tt();ct();gr();At();ze();Qh();fs();Kc();Yc();ii();gO();(function(n){n[n.Clean=0]="Clean",n[n.Stop=1]="Stop",n[n.Sync=2]="Sync",n[n.NoSync=3]="NoSync"})(EO||(EO={}));vO=new Y,Yn={},rT=!1;Fo=class{static get ForceFullSceneLoadingForIncremental(){return ci.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){ci.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return ci.ShowLoadingScreen}static set ShowLoadingScreen(e){ci.ShowLoadingScreen=e}static get loggingLevel(){return ci.loggingLevel}static set loggingLevel(e){ci.loggingLevel=e}static get CleanBoneMatrixWeights(){return ci.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){ci.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return ym()}static GetPluginForExtension(e){var t;return(t=nT(e,!0))==null?void 0:t.plugin}static IsPluginForExtensionAvailable(e){return Q4(e)}static RegisterPlugin(e){Xa(e)}static ImportMesh(e,t,i,r,s,a,o,l,c,f){TO(e,t,i,r,s,a,o,l,c,f).catch(d=>o==null?void 0:o(ue.LastCreatedScene,d==null?void 0:d.message,d))}static async ImportMeshAsync(e,t,i,r,s,a,o){return await SO(e,t,i,r,s,a,o)}static Load(e,t,i,r,s,a,o,l){AO(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(ue.LastCreatedScene,c==null?void 0:c.message,c))}static async LoadAsync(e,t,i,r,s,a){return await tz(e,t,i,r,s,a)}static Append(e,t,i,r,s,a,o,l){lT(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(i!=null?i:ue.LastCreatedScene,c==null?void 0:c.message,c))}static async AppendAsync(e,t,i,r,s,a){return await iz(e,t,i,r,s,a)}static LoadAssetContainer(e,t,i,r,s,a,o,l){cT(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(i!=null?i:ue.LastCreatedScene,c==null?void 0:c.message,c))}static async LoadAssetContainerAsync(e,t,i,r,s,a){return await rz(e,t,i,r,s,a)}static ImportAnimations(e,t,i,r,s,a,o,l,c,f,d){RO(e,t,i,r,s,a,o,l,c,f,d).catch(h=>c==null?void 0:c(i!=null?i:ue.LastCreatedScene,h==null?void 0:h.message,h))}static async ImportAnimationsAsync(e,t,i,r,s,a,o,l,c,f,d){return await nz(e,t,i,r,s,a,l,f,d)}};Fo.NO_LOGGING=0;Fo.MINIMAL_LOGGING=1;Fo.SUMMARY_LOGGING=2;Fo.DETAILED_LOGGING=3;Fo.OnPluginActivatedObservable=vO});var Dm,fT,dT,Kn,Kf=A(()=>{Rt();yl();Dl();ze();At();NE();Ma();Rs();Tt();ha();Dm=class{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=[],this.spriteManagers=[]}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture=e}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(let t of this.skeletons)e=e.concat(t.bones);return e}},fT=class extends Dm{},dT=class{constructor(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}dispose(){let e=this.rootNodes;for(let r of e)r.dispose();e.length=0;let t=this.skeletons;for(let r of t)r.dispose();t.length=0;let i=this.animationGroups;for(let r of i)r.dispose();i.length=0}},Kn=class extends Dm{constructor(e){super(),this._wasAddedToScene=!1,e=e||ue.LastCreatedScene,e&&(this.scene=e,this.proceduralTextures=[],e.onDisposeObservable.add(()=>{this._wasAddedToScene||this.dispose()}),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{for(let t of this.geometries)t._rebuild();for(let t of this.meshes)t._rebuild();for(let t of this.particleSystems)t.rebuild();for(let t of this.textures)t._rebuild();for(let t of this.spriteManagers)t.rebuild()}))}_topologicalSort(e){let t=new Map;for(let o of e)t.set(o.uniqueId,o);let i={dependsOn:new Map,dependedBy:new Map};for(let o of e){let l=o.uniqueId;i.dependsOn.set(l,new Set),i.dependedBy.set(l,new Set)}for(let o of e){let l=o.uniqueId,c=i.dependsOn.get(l);if(o instanceof xs){let d=o.sourceMesh;t.has(d.uniqueId)&&(c.add(d.uniqueId),i.dependedBy.get(d.uniqueId).add(l))}let f=i.dependedBy.get(l);for(let d of o.getDescendants()){let h=d.uniqueId;t.has(h)&&(f.add(h),i.dependsOn.get(h).add(l))}}let r=[],s=[];for(let o of e){let l=o.uniqueId;i.dependsOn.get(l).size===0&&(s.push(o),t.delete(l))}let a=s;for(;a.length>0;){let o=a.shift();r.push(o);let l=i.dependedBy.get(o.uniqueId);for(let c of Array.from(l.values())){let f=i.dependsOn.get(c);f.delete(o.uniqueId),f.size===0&&t.get(c)&&(a.push(t.get(c)),t.delete(c))}}return t.size>0&&(W.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach(o=>{W.Error(o.name)})),r}_addNodeAndDescendantsToList(e,t,i,r){if(!(!i||r&&!r(i)||t.has(i.uniqueId))){e.push(i),t.add(i.uniqueId);for(let s of i.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,s,r)}}_isNodeInContainer(e){return e instanceof zt&&this.meshes.indexOf(e)!==-1||e instanceof st&&this.transformNodes.indexOf(e)!==-1||e instanceof tt&&this.lights.indexOf(e)!==-1||e instanceof Ge&&this.cameras.indexOf(e)!==-1}_isValidHierarchy(){for(let e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.transformNodes)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.lights)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.cameras)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;return!0}instantiateModelsToScene(e,t=!1,i){this._isValidHierarchy()||re.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");let r={},s={},a=new dT,o=[],l=[],c={doNotInstantiate:!0,...i},f=(p,_)=>{if(r[p.uniqueId]=_.uniqueId,s[_.uniqueId]=_,e&&(_.name=e(p.name)),_ instanceof U){let g=_;if(g.morphTargetManager){let T=p.morphTargetManager;g.morphTargetManager=T.clone();for(let b=0;b{if(f(p,_),p.parent){let g=r[p.parent.uniqueId],T=s[g];T?_.parent=T:_.parent=p.parent}if(_.position&&p.position&&_.position.copyFrom(p.position),_.rotationQuaternion&&p.rotationQuaternion&&_.rotationQuaternion.copyFrom(p.rotationQuaternion),_.rotation&&p.rotation&&_.rotation.copyFrom(p.rotation),_.scaling&&p.scaling&&_.scaling.copyFrom(p.scaling),_.material){let g=_;if(g.material)if(t){let T=p.material;if(l.indexOf(T)===-1){let b=T.clone(e?e(T.name):"Clone of "+T.name);if(l.push(T),r[T.uniqueId]=b.uniqueId,s[b.uniqueId]=b,T.getClassName()==="MultiMaterial"){let R=T;for(let S of R.subMaterials)S&&(b=S.clone(e?e(S.name):"Clone of "+S.name),l.push(S),r[S.uniqueId]=b.uniqueId,s[b.uniqueId]=b);R.subMaterials=R.subMaterials.map(S=>S&&s[r[S.uniqueId]])}}g.getClassName()!=="InstancedMesh"&&(g.material=s[r[T.uniqueId]])}else g.material.getClassName()==="MultiMaterial"?this.scene.multiMaterials.indexOf(g.material)===-1&&this.scene.addMultiMaterial(g.material):this.scene.materials.indexOf(g.material)===-1&&this.scene.addMaterial(g.material)}_.parent===null&&a.rootNodes.push(_)};for(let p of u)if(p.getClassName()==="InstancedMesh"){let _=p,g=_.sourceMesh,T=r[g.uniqueId],R=(typeof T=="number"?s[T]:g).createInstance(_.name);m(_,R)}else{let _=!0;p.getClassName()==="TransformNode"||p.getClassName()==="Node"||p.skeleton||!p.getTotalVertices||p.getTotalVertices()===0?_=!1:c.doNotInstantiate&&(typeof c.doNotInstantiate=="function"?_=!c.doNotInstantiate(p):_=!c.doNotInstantiate);let g=_?p.createInstance(`instance of ${p.name}`):p.clone(`Clone of ${p.name}`,null,!0);if(!g)throw new Error(`Could not clone or instantiate node on Asset Container ${p.name}`);m(p,g)}for(let p of this.skeletons){if(c.predicate&&!c.predicate(p))continue;let _=p.clone(e?e(p.name):"Clone of "+p.name);for(let g of this.meshes)if(g.skeleton===p&&!g.isAnInstance){let T=s[r[g.uniqueId]];if(!T||T.isAnInstance||(T.skeleton=_,o.indexOf(_)!==-1))continue;o.push(_);for(let b of _.bones)b._linkedTransformNode&&(b._linkedTransformNode=s[r[b._linkedTransformNode.uniqueId]])}a.skeletons.push(_)}for(let p of this.animationGroups){if(c.predicate&&!c.predicate(p))continue;let _=p.clone(e?e(p.name):"Clone of "+p.name,g=>s[r[g.uniqueId]]||g);a.animationGroups.push(_)}return a}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||re.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(let e of this.scene._serializableComponents)e.addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}}addToScene(e=null){let t=[];for(let i of this.cameras)e&&!e(i)||(this.scene.addCamera(i),t.push(i));for(let i of this.lights)e&&!e(i)||(this.scene.addLight(i),t.push(i));for(let i of this.meshes)e&&!e(i)||(this.scene.addMesh(i),t.push(i));for(let i of this.skeletons)e&&!e(i)||this.scene.addSkeleton(i);for(let i of this.animations)e&&!e(i)||this.scene.addAnimation(i);for(let i of this.animationGroups)e&&!e(i)||this.scene.addAnimationGroup(i);for(let i of this.multiMaterials)e&&!e(i)||this.scene.addMultiMaterial(i);for(let i of this.materials)e&&!e(i)||this.scene.addMaterial(i);for(let i of this.morphTargetManagers)e&&!e(i)||this.scene.addMorphTargetManager(i);for(let i of this.geometries)e&&!e(i)||this.scene.addGeometry(i);for(let i of this.transformNodes)e&&!e(i)||(this.scene.addTransformNode(i),t.push(i));for(let i of this.actionManagers)e&&!e(i)||this.scene.addActionManager(i);for(let i of this.textures)e&&!e(i)||this.scene.addTexture(i);for(let i of this.reflectionProbes)e&&!e(i)||this.scene.addReflectionProbe(i);for(let i of this.spriteManagers)e&&!e(i)||(this.scene.spriteManagers||(this.scene.spriteManagers=[]),this.scene.spriteManagers.push(i));if(t.length){let i=new Set(this.scene.meshes);for(let r of this.scene.lights)i.add(r);for(let r of this.scene.cameras)i.add(r);for(let r of this.scene.transformNodes)i.add(r);for(let r of this.skeletons)for(let s of r.bones)i.add(s);for(let r of t)r.parent&&!i.has(r.parent)&&(r.setParent?r.setParent(null):r.parent=null)}}removeAllFromScene(){this._isValidHierarchy()||re.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(let e of this.scene._serializableComponents)e.removeFromContainer(this)}removeFromScene(e=null){for(let t of this.cameras)e&&!e(t)||this.scene.removeCamera(t);for(let t of this.lights)e&&!e(t)||this.scene.removeLight(t);for(let t of this.meshes)e&&!e(t)||this.scene.removeMesh(t,!0);for(let t of this.skeletons)e&&!e(t)||this.scene.removeSkeleton(t);for(let t of this.animations)e&&!e(t)||this.scene.removeAnimation(t);for(let t of this.animationGroups)e&&!e(t)||this.scene.removeAnimationGroup(t);for(let t of this.multiMaterials)e&&!e(t)||this.scene.removeMultiMaterial(t);for(let t of this.materials)e&&!e(t)||this.scene.removeMaterial(t);for(let t of this.morphTargetManagers)e&&!e(t)||this.scene.removeMorphTargetManager(t);for(let t of this.geometries)e&&!e(t)||this.scene.removeGeometry(t);for(let t of this.transformNodes)e&&!e(t)||this.scene.removeTransformNode(t);for(let t of this.actionManagers)e&&!e(t)||this.scene.removeActionManager(t);for(let t of this.textures)e&&!e(t)||this.scene.removeTexture(t);for(let t of this.reflectionProbes)e&&!e(t)||this.scene.removeReflectionProbe(t);for(let t of this.spriteManagers)if(!(e&&!e(t))&&this.scene.spriteManagers){let i=this.scene.spriteManagers.indexOf(t);i!==-1&&this.scene.spriteManagers.splice(i,1)}}dispose(){let e=this.cameras.slice(0);for(let p of e)p.dispose();this.cameras.length=0;let t=this.lights.slice(0);for(let p of t)p.dispose();this.lights.length=0;let i=this.meshes.slice(0);for(let p of i)p.dispose();this.meshes.length=0;let r=this.skeletons.slice(0);for(let p of r)p.dispose();this.skeletons.length=0;let s=this.animationGroups.slice(0);for(let p of s)p.dispose();this.animationGroups.length=0;let a=this.multiMaterials.slice(0);for(let p of a)p.dispose();this.multiMaterials.length=0;let o=this.materials.slice(0);for(let p of o)p.dispose();this.materials.length=0;let l=this.geometries.slice(0);for(let p of l)p.dispose();this.geometries.length=0;let c=this.transformNodes.slice(0);for(let p of c)p.dispose();this.transformNodes.length=0;let f=this.actionManagers.slice(0);for(let p of f)p.dispose();this.actionManagers.length=0;let d=this.textures.slice(0);for(let p of d)p.dispose();this.textures.length=0;let h=this.reflectionProbes.slice(0);for(let p of h)p.dispose();this.reflectionProbes.length=0;let u=this.morphTargetManagers.slice(0);for(let p of u)p.dispose();this.morphTargetManagers.length=0;let m=this.spriteManagers.slice(0);for(let p of m)p.dispose();this.spriteManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(let p of this.scene._serializableComponents)p.removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}_moveAssets(e,t,i){if(!(!e||!t))for(let r of e){let s=!0;if(i){for(let a of i)if(r===a){s=!1;break}}s&&(t.push(r),r._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,e===void 0&&(e=new fT);for(let 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(){let e=new U("assetContainerRootMesh",this.scene);for(let t of this.meshes)t.parent||e.addChild(t);return this.meshes.unshift(e),e}mergeAnimationsTo(e=ue.LastCreatedScene,t,i=null){if(!e)return W.Error("No scene available to merge animations to"),[];let r=i||(l=>{let c,f=l.animations.length?l.animations[0].targetProperty:"",d=l.name.split(".").join("").split("_primitive")[0];switch(f){case"position":case"rotationQuaternion":c=e.getTransformNodeByName(l.name)||e.getTransformNodeByName(d);break;case"influence":c=e.getMorphTargetByName(l.name)||e.getMorphTargetByName(d);break;default:c=e.getNodeByName(l.name)||e.getNodeByName(d)}return c}),s=this.getNodes();for(let l of s){let c=r(l);if(c!==null){for(let f of l.animations){let d=c.animations.filter(h=>h.targetProperty===f.targetProperty);for(let h of d){let u=c.animations.indexOf(h,0);u>-1&&c.animations.splice(u,1)}}c.animations=c.animations.concat(l.animations)}}let a=[],o=this.animationGroups.slice();for(let l of o){a.push(l.clone(l.name,r));for(let c of l.animatables)c.stop()}for(let l of t){let c=r(l.target);c&&(e.beginAnimation(c,l.fromFrame,l.toFrame,l.loopAnimation,l.speedRatio,l.onAnimationEnd?l.onAnimationEnd:void 0,void 0,!0,void 0,l.onAnimationLoop?l.onAnimationLoop:void 0),e.stopAnimation(l.target))}return a}populateRootNodes(){this.rootNodes.length=0;for(let e of this.meshes)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.transformNodes)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.lights)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.cameras)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)}addAllAssetsToContainer(e){if(!e)return;let t=[],i=new Set;for(t.push(e);t.length>0;){let r=t.pop();if(r instanceof U?(r.geometry&&this.geometries.indexOf(r.geometry)===-1&&this.geometries.push(r.geometry),this.meshes.push(r)):r instanceof xs?this.meshes.push(r):r instanceof st?this.transformNodes.push(r):r instanceof tt?this.lights.push(r):r instanceof Ge&&this.cameras.push(r),r instanceof zt){if(r.material&&this.materials.indexOf(r.material)===-1){this.materials.push(r.material);for(let s of r.material.getActiveTextures())this.textures.indexOf(s)===-1&&this.textures.push(s)}r.skeleton&&this.skeletons.indexOf(r.skeleton)===-1&&this.skeletons.push(r.skeleton),r.morphTargetManager&&this.morphTargetManagers.indexOf(r.morphTargetManager)===-1&&this.morphTargetManagers.push(r.morphTargetManager)}for(let s of r.getChildren())i.has(s)||t.push(s);i.add(r)}this.populateRootNodes()}_getByTags(e,t,i){if(t===void 0)return e;let r=[];for(let s in e){let a=e[s];nt&&nt.MatchesQuery(a,t)&&(!i||i(a))&&r.push(a)}return r}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)}getMaterialsByTags(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)}}});var wo,IO=A(()=>{jc();wo=class{constructor(e){this.byteOffset=0,this.buffer=e}async loadAsync(e){let t=await this.buffer.readAsync(this.byteOffset,e);this._dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),this._dataByteOffset=0}readUint32(){let e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e}readUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t}readString(e){return NI(this.readUint8Array(e))}skipBytes(e){this._dataByteOffset+=e,this.byteOffset+=e}}});function hT(n,e,t,i){let r={externalResourceFunction:i};return t&&(r.uri=e==="file:"?t:e+t),ArrayBuffer.isView(n)?GLTFValidator.validateBytes(n,r):GLTFValidator.validateString(n,r)}function sz(){let n=[];onmessage=e=>{let t=e.data;switch(t.id){case"init":{importScripts(t.url);break}case"validate":{hT(t.data,t.rootUrl,t.fileName,i=>new Promise((r,s)=>{let a=n.length;n.push({resolve:r,reject:s}),postMessage({id:"getExternalResource",index:a,uri:i})})).then(i=>{postMessage({id:"validate.resolve",value:i})},i=>{postMessage({id:"validate.reject",reason:i})});break}case"getExternalResource.resolve":{n[t.index].resolve(t.value);break}case"getExternalResource.reject":{n[t.index].reject(t.reason);break}}}}var uc,xO=A(()=>{Tt();uc=class n{static ValidateAsync(e,t,i,r){return typeof Worker=="function"?new Promise((s,a)=>{let o=`${hT}(${sz})()`,l=URL.createObjectURL(new Blob([o],{type:"application/javascript"})),c=new Worker(l),f=h=>{c.removeEventListener("error",f),c.removeEventListener("message",d),a(h)},d=h=>{let u=h.data;switch(u.id){case"getExternalResource":{r(u.uri).then(m=>{c.postMessage({id:"getExternalResource.resolve",index:u.index,value:m},[m.buffer])},m=>{c.postMessage({id:"getExternalResource.reject",index:u.index,reason:m})});break}case"validate.resolve":{c.removeEventListener("error",f),c.removeEventListener("message",d),n._LastResults=u.value,s(u.value),c.terminate();break}case"validate.reject":c.removeEventListener("error",f),c.removeEventListener("message",d),a(u.reason),c.terminate()}};if(c.addEventListener("error",f),c.addEventListener("message",d),c.postMessage({id:"init",url:re.GetBabylonScriptURL(this.Configuration.url)}),ArrayBuffer.isView(e)){let h=e.slice();c.postMessage({id:"validate",data:h,rootUrl:t,fileName:i},[h.buffer])}else c.postMessage({id:"validate",data:e,rootUrl:t,fileName:i})}):(this._LoadScriptPromise||(this._LoadScriptPromise=re.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>hT(e,t,i,r)))}};uc.Configuration={url:`${re._DefaultCdnUrl}/gltf_validator.js`};uc._LastResults=null});var Ys,jf,CO=A(()=>{Ys="Z2xURg",jf={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad(n){return n.indexOf("asset")!==-1&&n.indexOf("version")!==-1||n.startsWith("data:base64,"+Ys)||n.startsWith("data:;base64,"+Ys)||n.startsWith("data:application/octet-stream;base64,"+Ys)||n.startsWith("data:model/gltf-binary;base64,"+Ys)}}});function bO(n,e,t){try{return Promise.resolve(new Uint8Array(n,e,t))}catch(i){return Promise.reject(i)}}function az(n,e,t){try{if(e<0||e>=n.byteLength)throw new RangeError("Offset is out of range.");if(e+t>n.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(n.buffer,n.byteOffset+e,t))}catch(i){return Promise.reject(i)}}var mc,Bo,Yi,Lm,oz,uT,Ya,mT=A(()=>{ct();Tt();hc();Kf();ze();IO();xO();CO();fs();Kc();(function(n){n[n.AUTO=0]="AUTO",n[n.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(mc||(mc={}));(function(n){n[n.NONE=0]="NONE",n[n.FIRST=1]="FIRST",n[n.ALL=2]="ALL"})(Bo||(Bo={}));(function(n){n[n.LOADING=0]="LOADING",n[n.READY=1]="READY",n[n.COMPLETE=2]="COMPLETE"})(Yi||(Yi={}));Lm=class{constructor(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=Bo.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=mc.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1}},oz=new Lm,uT=class extends Lm{constructor(){super(...arguments),this.extensionOptions={},this.preprocessUrlAsync=e=>Promise.resolve(e)}copyFrom(e){var t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g,T,b,R,S,I,x,P,L,y,B;e&&(this.alwaysComputeBoundingBox=(t=e.alwaysComputeBoundingBox)!=null?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=(i=e.alwaysComputeSkeletonRootNode)!=null?i:this.alwaysComputeSkeletonRootNode,this.animationStartMode=(r=e.animationStartMode)!=null?r:this.animationStartMode,this.capturePerformanceCounters=(s=e.capturePerformanceCounters)!=null?s:this.capturePerformanceCounters,this.compileMaterials=(a=e.compileMaterials)!=null?a:this.compileMaterials,this.compileShadowGenerators=(o=e.compileShadowGenerators)!=null?o:this.compileShadowGenerators,this.coordinateSystemMode=(l=e.coordinateSystemMode)!=null?l:this.coordinateSystemMode,this.createInstances=(c=e.createInstances)!=null?c:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=(f=e.extensionOptions)!=null?f:this.extensionOptions,this.loadAllMaterials=(d=e.loadAllMaterials)!=null?d:this.loadAllMaterials,this.loadMorphTargets=(h=e.loadMorphTargets)!=null?h:this.loadMorphTargets,this.loadNodeAnimations=(u=e.loadNodeAnimations)!=null?u:this.loadNodeAnimations,this.loadOnlyMaterials=(m=e.loadOnlyMaterials)!=null?m:this.loadOnlyMaterials,this.loadSkins=(p=e.loadSkins)!=null?p:this.loadSkins,this.loggingEnabled=(_=e.loggingEnabled)!=null?_:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=(g=e.preprocessUrlAsync)!=null?g:this.preprocessUrlAsync,this.skipMaterials=(T=e.skipMaterials)!=null?T:this.skipMaterials,this.targetFps=(b=e.targetFps)!=null?b:this.targetFps,this.transparencyAsCoverage=(R=e.transparencyAsCoverage)!=null?R:this.transparencyAsCoverage,this.useClipPlane=(S=e.useClipPlane)!=null?S:this.useClipPlane,this.useGltfTextureNames=(I=e.useGltfTextureNames)!=null?I:this.useGltfTextureNames,this.useOpenPBR=(x=e.useOpenPBR)!=null?x:this.useOpenPBR,this.useRangeRequests=(P=e.useRangeRequests)!=null?P:this.useRangeRequests,this.useSRGBBuffers=(L=e.useSRGBBuffers)!=null?L:this.useSRGBBuffers,this.validate=(y=e.validate)!=null?y:this.validate,this.dontUseTransmissionHelper=(B=e.dontUseTransmissionHelper)!=null?B:this.dontUseTransmissionHelper)}},Ya=class n extends uT{constructor(e){super(),this.onParsedObservable=new Y,this.onMeshLoadedObservable=new Y,this.onSkinLoadedObservable=new Y,this.onTextureLoadedObservable=new Y,this.onMaterialLoadedObservable=new Y,this.onCameraLoadedObservable=new Y,this.onCompleteObservable=new Y,this.onErrorObservable=new Y,this.onDisposeObservable=new Y,this.onExtensionLoadedObservable=new Y,this.onValidatedObservable=new Y,this._loader=null,this._state=null,this._requests=new Array,this.name=jf.name,this.extensions=jf.extensions,this.onLoaderStateChangedObservable=new Y,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled,this.copyFrom(Object.assign({...oz},e))}set onParsed(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))}set onMeshLoaded(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))}set onSkinLoaded(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(t=>e(t.node,t.skinnedNode)))}set onTextureLoaded(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))}set onMaterialLoaded(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))}set onCameraLoaded(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))}set onComplete(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)}set onError(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set onExtensionLoaded(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)}get loggingEnabled(){return this._loggingEnabled}set loggingEnabled(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)}get capturePerformanceCounters(){return this._capturePerformanceCounters}set capturePerformanceCounters(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))}set onValidated(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)}dispose(){this._loader&&(this._loader.dispose(),this._loader=null);for(let e of this._requests)e.abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=e=>Promise.resolve(e),this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()}loadFile(e,t,i,r,s,a,o,l){if(ArrayBuffer.isView(t))return this._loadBinary(e,t,i,r,o,l),null;this._progressCallback=s;let c=t.name||re.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&W.Warn("glTF validation is not supported when range requests are enabled");let f={abort:()=>{},onCompleteObservable:new Y},d={readAsync:(h,u)=>new Promise((m,p)=>{this._loadFile(e,t,_=>{m(new Uint8Array(_))},!0,_=>{p(_)},_=>{_.setRequestHeader("Range",`bytes=${h}-${h+u-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new wo(d)).then(h=>{f.onCompleteObservable.notifyObservers(f),r(h)},o?h=>o(void 0,h):void 0),f}return this._loadFile(e,t,f=>{this._validate(e,new Uint8Array(f,0,f.byteLength),i,c),this._unpackBinaryAsync(new wo({readAsync:(d,h)=>bO(f,d,h),byteLength:f.byteLength})).then(d=>{r(d)},o?d=>o(void 0,d):void 0)},!0,o)}else return this._loadFile(e,t,f=>{try{this._validate(e,f,i,c),r({json:this._parseJson(f)})}catch(d){o&&o()}},!1,o)}_loadBinary(e,t,i,r,s,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i,a),this._unpackBinaryAsync(new wo({readAsync:(o,l)=>az(t,o,l),byteLength:t.byteLength})).then(o=>{r(o)},s?o=>s(void 0,o):void 0)}importMeshAsync(e,t,i,r,s,a){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(i),this.onParsedObservable.clear(),this._log(`Loading ${a||""}`),this._loader=this._getLoader(i),this._loader.importMeshAsync(e,t,null,i,r,s,a)))}loadAsync(e,t,i,r,s){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,i,r,s)))}loadAssetContainerAsync(e,t,i,r,s){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t);let a=new Kn(e),o=[];this.onMaterialLoadedObservable.add(d=>{o.push(d)});let l=[];this.onTextureLoadedObservable.add(d=>{l.push(d)});let c=[];this.onCameraLoadedObservable.add(d=>{c.push(d)});let f=[];return this.onMeshLoadedObservable.add(d=>{d.morphTargetManager&&f.push(d.morphTargetManager)}),this._loader.importMeshAsync(null,e,a,t,i,r,s).then(d=>(Array.prototype.push.apply(a.geometries,d.geometries),Array.prototype.push.apply(a.meshes,d.meshes),Array.prototype.push.apply(a.particleSystems,d.particleSystems),Array.prototype.push.apply(a.skeletons,d.skeletons),Array.prototype.push.apply(a.animationGroups,d.animationGroups),Array.prototype.push.apply(a.materials,o),Array.prototype.push.apply(a.textures,l),Array.prototype.push.apply(a.lights,d.lights),Array.prototype.push.apply(a.transformNodes,d.transformNodes),Array.prototype.push.apply(a.cameras,c),Array.prototype.push.apply(a.morphTargetManagers,f),a))})}canDirectLoad(e){return jf.canDirectLoad(e)}directLoad(e,t){if(t.startsWith("base64,"+Ys)||t.startsWith(";base64,"+Ys)||t.startsWith("application/octet-stream;base64,"+Ys)||t.startsWith("model/gltf-binary;base64,"+Ys)){let i=da(t);return this._validate(e,new Uint8Array(i,0,i.byteLength)),this._unpackBinaryAsync(new wo({readAsync:(r,s)=>bO(i,r,s),byteLength:i.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})}createPlugin(e){return new n(e[jf.name])}get loaderState(){return this._state}whenCompleteAsync(){return new Promise((e,t)=>{this.onCompleteObservable.addOnce(()=>{e()}),this.onErrorObservable.addOnce(i=>{t(i)})})}_setState(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(Yi[this._state]))}_loadFile(e,t,i,r,s,a){let o=e._loadFile(t,i,l=>{this._onProgress(l,o)},!0,r,s,a);return o.onCompleteObservable.add(()=>{o._lengthComputable=!0,o._total=o._loaded}),this._requests.push(o),o}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let i=!0,r=0,s=0;for(let a of this._requests){if(a._lengthComputable===void 0||a._loaded===void 0||a._total===void 0)return;i=i&&a._lengthComputable,r+=a._loaded,s+=a._total}this._progressCallback({lengthComputable:i,loaded:r,total:i?s:0})}_validate(e,t,i="",r=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),uc.ValidateAsync(t,i,r,s=>this.preprocessUrlAsync(i+s).then(a=>e._loadFileAsync(a,void 0,!0,!0).then(o=>new Uint8Array(o,0,o.byteLength)))).then(s=>{this._endPerformanceCounter("Validate JSON"),this.onValidatedObservable.notifyObservers(s),this.onValidatedObservable.clear()},s=>{this._endPerformanceCounter("Validate JSON"),re.Warn(`Failed to validate: ${s.message}`),this.onValidatedObservable.clear()}))}_getLoader(e){let t=e.json.asset||{};this._log(`Asset version: ${t.version}`),t.minVersion&&this._log(`Asset minimum version: ${t.minVersion}`),t.generator&&this._log(`Asset generator: ${t.generator}`);let i=n._parseVersion(t.version);if(!i)throw new Error("Invalid version: "+t.version);if(t.minVersion!==void 0){let a=n._parseVersion(t.minVersion);if(!a)throw new Error("Invalid minimum version: "+t.minVersion);if(n._compareVersion(a,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}let s={1:n._CreateGLTF1Loader,2:n._CreateGLTF2Loader}[i.major];if(!s)throw new Error("Unsupported version: "+t.version);return s(this)}_parseJson(e){this._startPerformanceCounter("Parse JSON"),this._log(`JSON length: ${e.length}`);let t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t}_unpackBinaryAsync(e){return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(()=>{let t={Magic:1179937895},i=e.readUint32();if(i!==t.Magic)throw new ir("Unexpected magic: "+i,Lr.GLTFLoaderUnexpectedMagicError);let r=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${r}`);let s=e.readUint32();!this.useRangeRequests&&s!==e.buffer.byteLength&&W.Warn(`Length in header does not match actual data length: ${s} != ${e.buffer.byteLength}`);let a;switch(r){case 1:{a=this._unpackBinaryV1Async(e,s);break}case 2:{a=this._unpackBinaryV2Async(e,s);break}default:throw new Error("Unsupported version: "+r)}return this._endPerformanceCounter("Unpack Binary"),a})}_unpackBinaryV1Async(e,t){let i={JSON:0},r=e.readUint32(),s=e.readUint32();if(s!==i.JSON)throw new Error(`Unexpected content format: ${s}`);let a=t-e.byteOffset,o={json:this._parseJson(e.readString(r)),bin:null};if(a!==0){let l=e.byteOffset;o.bin={readAsync:(c,f)=>e.buffer.readAsync(l+c,f),byteLength:a}}return Promise.resolve(o)}_unpackBinaryV2Async(e,t){let i={JSON:1313821514,BIN:5130562},r=e.readUint32();if(e.readUint32()!==i.JSON)throw new Error("First chunk format is not JSON");return e.byteOffset+r===t?e.loadAsync(r).then(()=>({json:this._parseJson(e.readString(r)),bin:null})):e.loadAsync(r+8).then(()=>{let a={json:this._parseJson(e.readString(r)),bin:null},o=()=>{let l=e.readUint32();switch(e.readUint32()){case i.JSON:throw new Error("Unexpected JSON chunk");case i.BIN:{let f=e.byteOffset;a.bin={readAsync:(d,h)=>e.buffer.readAsync(f+d,h),byteLength:l},e.skipBytes(l);break}default:{e.skipBytes(l);break}}return e.byteOffset!==t?e.loadAsync(8).then(o):Promise.resolve(a)};return o()})}static _parseVersion(e){if(e==="1.0"||e==="1.0.1")return{major:1,minor:0};let t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null}static _compareVersion(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor{Pm=class{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}}});var Vi,yO=A(()=>{Qe();qe();zn();Lh();ve();Tt();Vi=class{constructor(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this.keysRotateUp=[],this.keysRotateDown=[],this._keys=new Array}attachControl(e){e=re.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=>{let i=t.event;if(!i.metaKey){if(t.type===dn.KEYDOWN)(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.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1)&&(this._keys.indexOf(i.keyCode)===-1&&this._keys.push(i.keyCode),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.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1){let r=this._keys.indexOf(i.keyCode);r>=0&&this._keys.splice(r,1),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){let e=this.camera;for(let t=0;t{Qe();ct();qe();zn();fn();Tt();Uo=class{constructor(e=!0){this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this._previousPosition=null,this.onPointerMovedObservable=new Y,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement();this._pointerInput||(this._pointerInput=r=>{let s=r.event,a=s.pointerType==="touch";if(!this.touchEnabled&&a||r.type!==ye.POINTERMOVE&&this.buttons.indexOf(s.button)===-1)return;let o=s.target;if(r.type===ye.POINTERDOWN){if(a&&this._activePointerId!==-1||!a&&this._currentActiveButton!==-1)return;this._activePointerId=s.pointerId;try{o==null||o.setPointerCapture(s.pointerId)}catch(l){}this._currentActiveButton===-1&&(this._currentActiveButton=s.button),this._previousPosition={x:s.clientX,y:s.clientY},e||(s.preventDefault(),i&&i.focus()),t.isPointerLock&&this._onMouseMove&&this._onMouseMove(r.event)}else if(r.type===ye.POINTERUP){if(a&&this._activePointerId!==s.pointerId||!a&&this._currentActiveButton!==s.button)return;try{o==null||o.releasePointerCapture(s.pointerId)}catch(l){}this._currentActiveButton=-1,this._previousPosition=null,e||s.preventDefault(),this._activePointerId=-1}else if(r.type===ye.POINTERMOVE&&(this._activePointerId===s.pointerId||!a)){if(t.isPointerLock&&this._onMouseMove)this._onMouseMove(r.event);else if(this._previousPosition){let l=this.camera._calculateHandednessMultiplier(),c=(s.clientX-this._previousPosition.x)*l,f=(s.clientY-this._previousPosition.y)*l;this._allowCameraRotation&&(this.camera.cameraRotation.y+=c/this.angularSensibility,this.camera.cameraRotation.x+=f/this.angularSensibility),this.onPointerMovedObservable.notifyObservers({offsetX:c,offsetY:f}),this._previousPosition={x:s.clientX,y:s.clientY},e||s.preventDefault()}}}),this._onMouseMove=r=>{if(!t.isPointerLock)return;let s=this.camera._calculateHandednessMultiplier();this.camera.cameraRotation.y+=r.movementX*s/this.angularSensibility,this.camera.cameraRotation.x+=r.movementY*s/this.angularSensibility,this._previousPosition=null,e||r.preventDefault()},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE),i&&(this._contextMenuBind=r=>this.onContextMenu(r),i.addEventListener("contextmenu",this._contextMenuBind,!1))}onContextMenu(e){e.preventDefault()}detachControl(){if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._contextMenuBind){let t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("contextmenu",this._contextMenuBind)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this._previousPosition=null}this._activePointerId=-1,this._currentActiveButton=-1}getClassName(){return"FreeCameraMouseInput"}getSimpleName(){return"mouse"}};C([D()],Uo.prototype,"buttons",void 0);C([D()],Uo.prototype,"angularSensibility",void 0);Fi.FreeCameraMouseInput=Uo});var Vo,LO=A(()=>{Qe();qe();ct();fn();Ph();Tt();Vo=class{constructor(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new Y,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==ye.POINTERWHEEL)return;let i=t.event,r=i.deltaMode===hn.DOM_DELTA_LINE?this._ffMultiplier:1;this._wheelDeltaX+=this.wheelPrecisionX*r*i.deltaX/this._normalize,this._wheelDeltaY-=this.wheelPrecisionY*r*i.deltaY/this._normalize,this._wheelDeltaZ+=this.wheelPrecisionZ*r*i.deltaZ/this._normalize,i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,ye.POINTERWHEEL)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()}checkInputs(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0}getClassName(){return"BaseCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}};C([D()],Vo.prototype,"wheelPrecisionX",void 0);C([D()],Vo.prototype,"wheelPrecisionY",void 0);C([D()],Vo.prototype,"wheelPrecisionZ",void 0)});var It,fr,PO=A(()=>{Qe();qe();zn();LO();ve();(function(n){n[n.MoveRelative=0]="MoveRelative",n[n.RotateRelative=1]="RotateRelative",n[n.MoveScene=2]="MoveScene"})(It||(It={}));fr=class extends Vo{constructor(){super(...arguments),this._moveRelative=v.Zero(),this._rotateRelative=v.Zero(),this._moveScene=v.Zero(),this._wheelXAction=It.MoveRelative,this._wheelXActionCoordinate=0,this._wheelYAction=It.MoveRelative,this._wheelYActionCoordinate=2,this._wheelZAction=null,this._wheelZActionCoordinate=null}getClassName(){return"FreeCameraMouseWheelInput"}set wheelXMoveRelative(e){e===null&&this._wheelXAction!==It.MoveRelative||(this._wheelXAction=It.MoveRelative,this._wheelXActionCoordinate=e)}get wheelXMoveRelative(){return this._wheelXAction!==It.MoveRelative?null:this._wheelXActionCoordinate}set wheelYMoveRelative(e){e===null&&this._wheelYAction!==It.MoveRelative||(this._wheelYAction=It.MoveRelative,this._wheelYActionCoordinate=e)}get wheelYMoveRelative(){return this._wheelYAction!==It.MoveRelative?null:this._wheelYActionCoordinate}set wheelZMoveRelative(e){e===null&&this._wheelZAction!==It.MoveRelative||(this._wheelZAction=It.MoveRelative,this._wheelZActionCoordinate=e)}get wheelZMoveRelative(){return this._wheelZAction!==It.MoveRelative?null:this._wheelZActionCoordinate}set wheelXRotateRelative(e){e===null&&this._wheelXAction!==It.RotateRelative||(this._wheelXAction=It.RotateRelative,this._wheelXActionCoordinate=e)}get wheelXRotateRelative(){return this._wheelXAction!==It.RotateRelative?null:this._wheelXActionCoordinate}set wheelYRotateRelative(e){e===null&&this._wheelYAction!==It.RotateRelative||(this._wheelYAction=It.RotateRelative,this._wheelYActionCoordinate=e)}get wheelYRotateRelative(){return this._wheelYAction!==It.RotateRelative?null:this._wheelYActionCoordinate}set wheelZRotateRelative(e){e===null&&this._wheelZAction!==It.RotateRelative||(this._wheelZAction=It.RotateRelative,this._wheelZActionCoordinate=e)}get wheelZRotateRelative(){return this._wheelZAction!==It.RotateRelative?null:this._wheelZActionCoordinate}set wheelXMoveScene(e){e===null&&this._wheelXAction!==It.MoveScene||(this._wheelXAction=It.MoveScene,this._wheelXActionCoordinate=e)}get wheelXMoveScene(){return this._wheelXAction!==It.MoveScene?null:this._wheelXActionCoordinate}set wheelYMoveScene(e){e===null&&this._wheelYAction!==It.MoveScene||(this._wheelYAction=It.MoveScene,this._wheelYActionCoordinate=e)}get wheelYMoveScene(){return this._wheelYAction!==It.MoveScene?null:this._wheelYActionCoordinate}set wheelZMoveScene(e){e===null&&this._wheelZAction!==It.MoveScene||(this._wheelZAction=It.MoveScene,this._wheelZActionCoordinate=e)}get wheelZMoveScene(){return this._wheelZAction!==It.MoveScene?null:this._wheelZActionCoordinate}checkInputs(){if(this._wheelDeltaX===0&&this._wheelDeltaY===0&&this._wheelDeltaZ==0)return;this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);let e=G.Zero();this.camera.getViewMatrix().invertToRef(e);let t=v.Zero();v.TransformNormalToRef(this._moveRelative,e,t),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(t),this.camera.cameraDirection.addInPlace(this._moveScene),super.checkInputs()}_updateCamera(){this._updateCameraProperty(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),this._updateCameraProperty(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),this._updateCameraProperty(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)}_updateCameraProperty(e,t,i){if(e===0||t===null||i===null)return;let r=null;switch(t){case It.MoveRelative:r=this._moveRelative;break;case It.RotateRelative:r=this._rotateRelative;break;case It.MoveScene:r=this._moveScene;break}switch(i){case 0:r.set(e,0,0);break;case 1:r.set(0,e,0);break;case 2:r.set(0,0,e);break}}};C([D()],fr.prototype,"wheelXMoveRelative",null);C([D()],fr.prototype,"wheelYMoveRelative",null);C([D()],fr.prototype,"wheelZMoveRelative",null);C([D()],fr.prototype,"wheelXRotateRelative",null);C([D()],fr.prototype,"wheelYRotateRelative",null);C([D()],fr.prototype,"wheelZRotateRelative",null);C([D()],fr.prototype,"wheelXMoveScene",null);C([D()],fr.prototype,"wheelYMoveScene",null);C([D()],fr.prototype,"wheelZMoveScene",null);Fi.FreeCameraMouseWheelInput=fr});var Go,OO=A(()=>{Qe();qe();zn();fn();ve();Tt();Go=class{constructor(e=!1){this.allowMouse=e,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this.singleFingerRotate=!1,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array,this._isSafari=re.IsSafari()}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=null;if(this._pointerInput===void 0&&(this._onLostFocus=()=>{this._offsetX=null,this._offsetY=null},this._pointerInput=i=>{let r=i.event,s=r.pointerType==="mouse"||this._isSafari&&typeof r.pointerType=="undefined";if(!(!this.allowMouse&&s)){if(i.type===ye.POINTERDOWN){if(e||r.preventDefault(),this._pointerPressed.push(r.pointerId),this._pointerPressed.length!==1)return;t={x:r.clientX,y:r.clientY}}else if(i.type===ye.POINTERUP){e||r.preventDefault();let a=this._pointerPressed.indexOf(r.pointerId);if(a===-1||(this._pointerPressed.splice(a,1),a!=0))return;t=null,this._offsetX=null,this._offsetY=null}else if(i.type===ye.POINTERMOVE){if(e||r.preventDefault(),!t||this._pointerPressed.indexOf(r.pointerId)!=0)return;this._offsetX=r.clientX-t.x,this._offsetY=-(r.clientY-t.y)}}}),this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE),this._onLostFocus){let r=this.camera.getEngine().getInputElement();r&&r.addEventListener("blur",this._onLostFocus)}}detachControl(){if(this._pointerInput){if(this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null),this._onLostFocus){let t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed.length=0,this._offsetX=null,this._offsetY=null}}checkInputs(){if(this._offsetX===null||this._offsetY===null||this._offsetX===0&&this._offsetY===0)return;let e=this.camera,t=e._calculateHandednessMultiplier();if(e.cameraRotation.y=this._offsetX*t/this.touchAngularSensibility,this.singleFingerRotate&&this._pointerPressed.length===1||!this.singleFingerRotate&&this._pointerPressed.length>1)e.cameraRotation.x=-(this._offsetY*t)/this.touchAngularSensibility;else{let r=e._computeLocalCameraSpeed(),s=k.Vector3[0];s.copyFromFloats(0,0,this.touchMoveSensibility!==0?r*this._offsetY/this.touchMoveSensibility:0),G.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),v.TransformCoordinatesToRef(s,e._cameraRotationMatrix,s),e.cameraDirection.addInPlace(s)}}getClassName(){return"FreeCameraTouchInput"}getSimpleName(){return"touch"}};C([D()],Go.prototype,"touchAngularSensibility",void 0);C([D()],Go.prototype,"touchMoveSensibility",void 0);Fi.FreeCameraTouchInput=Go});var Om,NO=A(()=>{zn();yO();DO();PO();OO();Om=class extends Jl{constructor(e){super(e),this._mouseInput=null,this._mouseWheelInput=null}addKeyboard(){return this.add(new Vi),this}addMouse(e=!0){return this._mouseInput||(this._mouseInput=new Uo(e),this.add(this._mouseInput)),this}removeMouse(){return this._mouseInput&&this.remove(this._mouseInput),this}addMouseWheel(){return this._mouseWheelInput||(this._mouseWheelInput=new fr,this.add(this._mouseWheelInput)),this}removeMouseWheel(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this}addTouch(){return this.add(new Go),this}clear(){super.clear(),this._mouseInput=null}}});var Ks,FO=A(()=>{Qe();qe();ve();EE();NO();Tt();Lt();ii();Ks=class extends ar{get angularSensibility(){let e=this.inputs.attached.mouse;return e?e.angularSensibility:0}set angularSensibility(e){let t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)}get keysUp(){let e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysUpward(){let e=this.inputs.attached.keyboard;return e?e.keysUpward:[]}set keysUpward(e){let t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)}get keysDown(){let e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysDownward(){let e=this.inputs.attached.keyboard;return e?e.keysDownward:[]}set keysDownward(e){let t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)}get keysLeft(){let e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){let e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get keysRotateLeft(){let e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]}set keysRotateLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)}get keysRotateRight(){let e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]}set keysRotateRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)}get keysRotateUp(){let e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]}set keysRotateUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateUp=e)}get keysRotateDown(){let e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]}set keysRotateDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateDown=e)}constructor(e,t,i,r=!0){super(e,t,i,r),this.ellipsoid=new v(.5,1,.5),this.ellipsoidOffset=new v(0,0,0),this.checkCollisions=!1,this.applyGravity=!1,this._needMoveForGravity=!1,this._oldPosition=v.Zero(),this._diffPosition=v.Zero(),this._newPosition=v.Zero(),this._collisionMask=-1,this._onCollisionPositionChange=(s,a,o=null)=>{this._newPosition.copyFrom(a),this._newPosition.subtractToRef(this._oldPosition,this._diffPosition),this._diffPosition.length()>fe.CollisionsEpsilon&&(this.position.addToRef(this._diffPosition,this._deferredPositionUpdate),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate),this.onCollide&&o&&this.onCollide(o))},this.inputs=new Om(this),this.inputs.addKeyboard().addMouse()}attachControl(e,t){t=re.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)}detachControl(){this.inputs.detachElement(),this.cameraDirection=new v(0,0,0),this.cameraRotation=new _e(0,0)}get collisionMask(){return this._collisionMask}set collisionMask(e){this._collisionMask=isNaN(e)?-1:e}_collideWithWorld(e){let t;this.parent?t=v.TransformCoordinates(this.position,this.parent.getWorldMatrix()):t=this.position,t.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);let i=this.getScene().collisionCoordinator;this._collider||(this._collider=i.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;let r=e;this.applyGravity&&(r=e.add(this.getScene().gravity)),i.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}_checkInputs(){this._localDirection||(this._localDirection=v.Zero(),this._transformedDirection=v.Zero()),this.inputs.checkInputs(),super._checkInputs()}set needMoveForGravity(e){this._needMoveForGravity=e}get needMoveForGravity(){return this._needMoveForGravity}_decideIfNeedsToMove(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):super._updatePosition()}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"FreeCamera"}};C([ai()],Ks.prototype,"ellipsoid",void 0);C([ai()],Ks.prototype,"ellipsoidOffset",void 0);C([D()],Ks.prototype,"checkCollisions",void 0);C([D()],Ks.prototype,"applyGravity",void 0);je("BABYLON.FreeCamera",Ks)});var Kr,Nm=A(()=>{ve();Ln();vr();Kr=class n extends dt{get _matrix(){return this._compose(),this._localMatrix}set _matrix(e){e.updateFlag===this._localMatrix.updateFlag&&!this._needToCompose||(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())}constructor(e,t,i=null,r=null,s=null,a=null,o=null){var l;super(e,t.getScene(),!1),this.name=e,this.children=[],this.animations=[],this._index=null,this._scalingDeterminant=1,this._needToDecompose=!0,this._needToCompose=!1,this._linkedTransformNode=null,this._waitingTransformNodeId=null,this._waitingTransformNodeUniqueId=null,this._skeleton=t,this._localMatrix=(l=r==null?void 0:r.clone())!=null?l:G.Identity(),this._restMatrix=s!=null?s:this._localMatrix.clone(),this._bindMatrix=a!=null?a:this._localMatrix.clone(),this._index=o,this._absoluteMatrix=new G,this._absoluteBindMatrix=new G,this._absoluteInverseBindMatrix=new G,this._finalMatrix=new G,t.bones.push(this),this.setParent(i,!1),this._updateAbsoluteBindMatrices()}getClassName(){return"Bone"}getSkeleton(){return this._skeleton}get parent(){return this._parentNode}getParent(){return this.parent}getChildren(){return this.children}getIndex(){return this._index===null?this.getSkeleton().bones.indexOf(this):this._index}set parent(e){this.setParent(e)}setParent(e,t=!0){if(this.parent!==e){if(this.parent){let i=this.parent.children.indexOf(this);i!==-1&&this.parent.children.splice(i,1)}this._parentNode=e,this.parent&&this.parent.children.push(this),t&&this._updateAbsoluteBindMatrices(),this.markAsDirty()}}getLocalMatrix(){return this._compose(),this._localMatrix}getBindMatrix(){return this._bindMatrix}getBaseMatrix(){return this.getBindMatrix()}getRestMatrix(){return this._restMatrix}getRestPose(){return this.getRestMatrix()}setRestMatrix(e){this._restMatrix.copyFrom(e)}setRestPose(e){this.setRestMatrix(e)}getBindPose(){return this.getBindMatrix()}setBindMatrix(e){this.updateMatrix(e)}setBindPose(e){this.setBindMatrix(e)}getFinalMatrix(){return this._finalMatrix}getWorldMatrix(){return this.getFinalMatrix()}returnToRest(){var e;if(this._linkedTransformNode){let t=k.Vector3[0],i=k.Quaternion[0],r=k.Vector3[1];this.getRestMatrix().decompose(t,i,r),this._linkedTransformNode.position.copyFrom(r),this._linkedTransformNode.rotationQuaternion=(e=this._linkedTransformNode.rotationQuaternion)!=null?e:Ae.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(i),this._linkedTransformNode.scaling.copyFrom(t)}else this._matrix=this._restMatrix}getAbsoluteInverseBindMatrix(){return this._absoluteInverseBindMatrix}getInvertedAbsoluteTransform(){return this.getAbsoluteInverseBindMatrix()}getAbsoluteMatrix(){return this._skeleton.computeAbsoluteMatrices(),this._absoluteMatrix}getAbsoluteTransform(){return this.getAbsoluteMatrix()}linkTransformNode(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++}getTransformNode(){return this._linkedTransformNode}get position(){return this._decompose(),this._localPosition}set position(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()}get rotation(){return this.getRotation()}set rotation(e){this.setRotation(e)}get rotationQuaternion(){return this._decompose(),this._localRotation}set rotationQuaternion(e){this.setRotationQuaternion(e)}get scaling(){return this.getScale()}set scaling(e){this.setScale(e)}get animationPropertiesOverride(){return this._skeleton.animationPropertiesOverride}_decompose(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=v.Zero(),this._localRotation=Ae.Zero(),this._localPosition=v.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))}_compose(){if(this._needToCompose){if(!this._localScaling){this._needToCompose=!1;return}this._needToCompose=!1,G.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)}}updateMatrix(e,t=!0,i=!0){this._bindMatrix.copyFrom(e),t&&this._updateAbsoluteBindMatrices(),i?this._matrix=e:this.markAsDirty()}_updateAbsoluteBindMatrices(e,t=!0){if(e||(e=this._bindMatrix),this.parent?e.multiplyToRef(this.parent._absoluteBindMatrix,this._absoluteBindMatrix):this._absoluteBindMatrix.copyFrom(e),this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix),t)for(let i=0;i{oi();Zf=class n extends ne{constructor(e,t,i,r,s,a=!0,o=!1,l=3,c=0,f,d,h,u){super(null,s,!a,o,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,f),this.format=r,this._engine&&(!this._engine._caps.textureFloatLinearFiltering&&c===1&&(l=1),!this._engine._caps.textureHalfFloatLinearFiltering&&c===2&&(l=1),this._texture=this._engine.createRawTexture(e,t,i,r,a,o,l,null,c,f!=null?f:0,d!=null?d:!1,u),this.wrapU=ne.CLAMP_ADDRESSMODE,this.wrapV=ne.CLAMP_ADDRESSMODE,this._waitingForData=!!h&&!e)}update(e){this.updateMipLevel(e,0)}updateMipLevel(e,t){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer,t),this._waitingForData=!1}clone(){if(!this._texture)return super.clone();let e=new n(null,this.getSize().width,this.getSize().height,this.format,this.getScene(),this._texture.generateMipMaps,this._invertY,this.samplingMode,this._texture.type,this._texture._creationFlags,this._useSRGBBuffer);return e._texture=this._texture,this._texture.incrementReferences(),e}isReady(){return super.isReady()&&!this._waitingForData}static CreateLuminanceTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,1,r,s,a,o)}static CreateLuminanceAlphaTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,2,r,s,a,o)}static CreateAlphaTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,0,r,s,a,o)}static CreateRGBTexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=0,f=!1){return new n(e,t,i,4,r,s,a,o,l,c,f)}static CreateRGBATexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=0,f=!1,d=!1){return new n(e,t,i,5,r,s,a,o,l,c,f,d)}static CreateRGBAStorageTexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=!1){return new n(e,t,i,5,r,s,a,o,l,1,c)}static CreateRTexture(e,t,i,r,s=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new n(e,t,i,6,r,s,a,o,l)}static CreateRStorageTexture(e,t,i,r,s=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new n(e,t,i,6,r,s,a,o,l,1)}}});var Fm,BO=A(()=>{Nm();ct();ve();wO();Is();fE();At();ze();Qc();Fm=class n{get useTextureToStoreBoneMatrices(){return this._useTextureToStoreBoneMatrices}set useTextureToStoreBoneMatrices(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}get isUsingTextureForMatrices(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones}get uniqueId(){return this._uniqueId}constructor(e,t,i){this.name=e,this.id=t,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=G.Identity(),this._currentRenderId=-1,this._textureWidth=0,this._textureHeight=1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new Y,this.metadata=null,this.bones=[],this._scene=i||ue.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;let r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}getClassName(){return"Skeleton"}getChildren(){return this.bones.filter(e=>!e.getParent())}getTransformMatrices(e){if(this.needInitialSkinMatrix){if(!e)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return e._bonesTransformMatrices||this.prepare(!0),e._bonesTransformMatrices}return(!this._transformMatrices||this._isDirty)&&this.prepare(!this._transformMatrices),this._transformMatrices}getTransformMatrixTexture(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture}getScene(){return this._scene}toString(e){let t=`Name: ${this.name}, nBones: ${this.bones.length}`;if(t+=`, nAnimationRanges: ${this._ranges?Object.keys(this._ranges).length:"none"}`,e){t+=", Ranges: {";let i=!0;for(let r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t}getBoneIndexByName(e){for(let t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)}_computeTransformMatrices(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(let i=0;i0){for(let r of this.bones)if(r._linkedTransformNode){let s=r._linkedTransformNode;r.position=s.position,s.rotationQuaternion?r.rotationQuaternion=s.rotationQuaternion:r.rotation=s.rotation,r.scaling=s.scaling}}let t=null;if(this.needInitialSkinMatrix)for(let r of this._meshesWithPoseMatrix){let s=r.getPoseMatrix(),a=this._isDirty;if(t===null&&(t=this._computeTextureSize()),(!r._bonesTransformMatrices||r._bonesTransformMatrices.length!==t)&&(r._bonesTransformMatrices=new Float32Array(t),a=!0),!!a){if(this._synchronizedWithMesh!==r){this._synchronizedWithMesh=r;for(let o of this.bones)o.getParent()||(o.getBindMatrix().multiplyToRef(s,k.Matrix[1]),o._updateAbsoluteBindMatrices(k.Matrix[1]));if(this.isUsingTextureForMatrices){let o=(i=r._transformMatrixTexture)==null?void 0:i.getSize(),l=o?o.width*o.height*4:0;(!r._transformMatrixTexture||l!==t)&&(r._transformMatrixTexture&&r._transformMatrixTexture.dispose(),r._transformMatrixTexture=Zf.CreateRGBATexture(r._bonesTransformMatrices,this._textureWidth,this._textureHeight,this._scene,!1,!1,1,1))}}this._computeTransformMatrices(r._bonesTransformMatrices,s),this.isUsingTextureForMatrices&&r._transformMatrixTexture&&r._transformMatrixTexture.update(r._bonesTransformMatrices)}}else{if(!this._isDirty)return;t===null&&(t=this._computeTextureSize()),(!this._transformMatrices||this._transformMatrices.length!==t)&&(this._transformMatrices=new Float32Array(t),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=Zf.CreateRGBATexture(this._transformMatrices,this._textureWidth,this._textureHeight,this._scene,!1,!1,1,1))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices)}this._isDirty=!1}getAnimatables(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(let e=0;e-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)}serialize(){var t,i;let e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix,this.metadata&&(e.metadata=this.metadata);for(let r=0;r0&&(o.animation=s.animations[0].serialize()),e.ranges=[];for(let l in this._ranges){let c=this._ranges[l];if(!c)continue;let f={};f.name=l,f.from=c.from,f.to=c.to,e.ranges.push(f)}}return e}static Parse(e,t){let i=new n(e.name,e.id,t);e.dimensionsAtRest&&(i.dimensionsAtRest=v.FromArray(e.dimensionsAtRest)),i.needInitialSkinMatrix=e.needInitialSkinMatrix,e.metadata&&(i.metadata=e.metadata);let r;for(r=0;r-1&&(o=i.bones[s.parentBoneIndex]);let l=s.rest?G.FromArray(s.rest):null,c=new Kr(s.name,i,o,G.FromArray(s.matrix),l,null,a);s.id!==void 0&&s.id!==null&&(c.id=s.id),s.length&&(c.length=s.length),s.metadata&&(c.metadata=s.metadata),s.animation&&c.animations.push(Oe.Parse(s.animation)),s.linkedTransformNodeId!==void 0&&s.linkedTransformNodeId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeId=s.linkedTransformNodeId),s.linkedTransformNodeUniqueId!==void 0&&s.linkedTransformNodeUniqueId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeUniqueId=s.linkedTransformNodeUniqueId)}if(e.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e}sortBones(){let e=[],t=new Array(this.bones.length);for(let i=0;i{Qe();ct();At();yt();qe();Kt();Lt();Ka=class n{get influence(){return this._influence}set influence(e){if(this._influence===e)return;let t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(t===0||e===0)}get animationPropertiesOverride(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}constructor(e,t=0,i=null,r=null){this.name=e,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uv2s=null,this._colors=null,this._uniqueId=0,this.onInfluenceChanged=new Y,this._onDataLayoutChanged=new Y,this.morphTargetManager=null,this._animationPropertiesOverride=null,this.id=e,this.morphTargetManager=r,this._scene=i||ue.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}get uniqueId(){return this._uniqueId}get hasPositions(){return!!this._positions}get hasNormals(){return!!this._normals}get hasTangents(){return!!this._tangents}get hasUVs(){return!!this._uvs}get hasUV2s(){return!!this._uv2s}get hasColors(){return!!this._colors}get vertexCount(){return this._positions?this._positions.length/3:this._normals?this._normals.length/3:this._tangents?this._tangents.length/3:this._uvs?this._uvs.length/2:this._uv2s?this._uv2s.length/2:this._colors?this._colors.length/4:0}setPositions(e){let t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)}getPositions(){return this._positions}setNormals(e){let t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)}getNormals(){return this._normals}setTangents(e){let t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)}getTangents(){return this._tangents}setUVs(e){let t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)}getUVs(){return this._uvs}setUV2s(e){let t=this.hasUV2s;this._uv2s=e,t!==this.hasUV2s&&this._onDataLayoutChanged.notifyObservers(void 0)}getUV2s(){return this._uv2s}setColors(e){let t=this.hasColors;this._colors=e,t!==this.hasColors&&this._onDataLayoutChanged.notifyObservers(void 0)}getColors(){return this._colors}clone(){let e=Me.Clone(()=>new n(this.name,this.influence,this._scene,this.morphTargetManager),this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e._uv2s=this._uv2s,e._colors=this._colors,e}serialize(){let e={};return e.name=this.name,e.influence=this.influence,this.id!=null&&(e.id=this.id),e.uniqueId=this.uniqueId,e.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),this.hasUV2s&&(e.uv2s=Array.prototype.slice.call(this.getUV2s())),this.hasColors&&(e.colors=Array.prototype.slice.call(this.getColors())),Me.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,t,i=null){let r=new n(e.name,e.influence,t,i);if(r.setPositions(e.positions),e.id!=null&&(r.id=e.id),e.normals&&r.setNormals(e.normals),e.tangents&&r.setTangents(e.tangents),e.uvs&&r.setUVs(e.uvs),e.uv2s&&r.setUV2s(e.uv2s),e.colors&&r.setColors(e.colors),e.animations){for(let s=0;s{oi();wm=class n extends ne{get depth(){return this._depth}constructor(e,t,i,r,s,a,o=!0,l=!1,c=ne.TRILINEAR_SAMPLINGMODE,f=0,d,h){super(null,a,!o,l),this.format=s,this._texture=a.getEngine().createRawTexture2DArray(e,t,i,r,s,o,l,c,null,f,d!=null?d:0,h),this._depth=r,this.is2DArray=!0}update(e){this.updateMipLevel(e,0)}updateMipLevel(e,t){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,t)}static CreateRGBATexture(e,t,i,r,s,a=!0,o=!1,l=3,c=0){return new n(e,t,i,r,5,s,a,o,l,c)}}});var ko,VO=A(()=>{on();ze();At();pT();UO();ko=class n{set areUpdatesFrozen(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(this._forceUpdateWhenUnfrozen),this._forceUpdateWhenUnfrozen=!1))}get areUpdatesFrozen(){return this._blockCounter>0}constructor(e=null,t){if(this.meshName=t,this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new Ct(16),this._supportsPositions=!1,this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._supportsUV2s=!1,this._supportsColors=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._mustSynchronize=!0,this._forceUpdateWhenUnfrozen=!1,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enablePositionMorphing=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this.enableUV2Morphing=!0,this.enableColorMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,this.metadata=null,this._influencesAreDirty=!1,this._needUpdateInfluences=!1,e||(e=ue.LastCreatedScene),this._scene=e,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();let i=this._scene.getEngine().getCaps();this._canUseTextureForTargets=i.canUseGLVertexID&&i.textureFloat&&i.maxVertexTextureImageUnits>0&&i.texture2DArrayMaxLayerCount>1}}get numMaxInfluencers(){return n.ConstantTargetCountForTextureMode>0&&this.isUsingTextureForTargets?n.ConstantTargetCountForTextureMode:this._numMaxInfluencers}set numMaxInfluencers(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._mustSynchronize=!0,this._syncActiveTargets())}get uniqueId(){return this._uniqueId}get vertexCount(){return this._vertexCount}get supportsPositions(){return this._supportsPositions&&this.enablePositionMorphing}get supportsNormals(){return this._supportsNormals&&this.enableNormalMorphing}get supportsTangents(){return this._supportsTangents&&this.enableTangentMorphing}get supportsUVs(){return this._supportsUVs&&this.enableUVMorphing}get supportsUV2s(){return this._supportsUV2s&&this.enableUV2Morphing}get supportsColors(){return this._supportsColors&&this.enableColorMorphing}get hasPositions(){return this._supportsPositions}get hasNormals(){return this._supportsNormals}get hasTangents(){return this._supportsTangents}get hasUVs(){return this._supportsUVs}get hasUV2s(){return this._supportsUV2s}get hasColors(){return this._supportsColors}get numTargets(){return this._targets.length}get numInfluencers(){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.length}get influences(){return this._influencesAreDirty&&this._syncActiveTargets(),this._influences}get useTextureToStoreTargets(){return this._useTextureToStoreTargets}set useTextureToStoreTargets(e){this._useTextureToStoreTargets!==e&&(this._useTextureToStoreTargets=e,this._mustSynchronize=!0,this._syncActiveTargets())}get isUsingTextureForTargets(){var e;return n.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!((e=this._scene)!=null&&e.getEngine().getCaps().disableMorphTargetTexture)}getActiveTarget(e){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.data[e]}getTarget(e){return this._targets[e]}getTargetByName(e){for(let t of this._targets)if(t.name===e)return t;return null}addTarget(e){this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(t=>{this.areUpdatesFrozen&&t&&(this._forceUpdateWhenUnfrozen=!0),this._influencesAreDirty=!0,this._needUpdateInfluences=this._needUpdateInfluences||t})),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(()=>{this._mustSynchronize=!0,this._syncActiveTargets()})),this._mustSynchronize=!0,this._syncActiveTargets()}removeTarget(e){let t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._mustSynchronize=!0,this._syncActiveTargets()),this._scene&&this._scene.stopAnimation(e)}_bind(e){this._influencesAreDirty&&this._syncActiveTargets(),e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setFloat("morphTargetCount",this.numInfluencers)}clone(){let e=new n(this._scene);e.areUpdatesFrozen=!0;for(let t of this._targets)e.addTarget(t.clone());return e.areUpdatesFrozen=!1,e.enablePositionMorphing=this.enablePositionMorphing,e.enableNormalMorphing=this.enableNormalMorphing,e.enableTangentMorphing=this.enableTangentMorphing,e.enableUVMorphing=this.enableUVMorphing,e.enableUV2Morphing=this.enableUV2Morphing,e.enableColorMorphing=this.enableColorMorphing,e.metadata=this.metadata,e}serialize(){let e={};e.id=this.uniqueId,e.meshName=this.meshName,e.targets=[];for(let t of this._targets)e.targets.push(t.serialize());return this.metadata&&(e.metadata=this.metadata),e}_syncActiveTargets(e=!1){if(this.areUpdatesFrozen)return;e=e||this._needUpdateInfluences,this._needUpdateInfluences=!1,this._influencesAreDirty=!1;let t=!!this._targetStoreTexture,i=this.isUsingTextureForTargets;(this._mustSynchronize||t!==i)&&(this._mustSynchronize=!1,this.synchronize());let r=0;this._activeTargets.reset(),(!this._morphTargetTextureIndices||this._morphTargetTextureIndices.length!==this._targets.length)&&(this._morphTargetTextureIndices=new Float32Array(this._targets.length));let s=-1;for(let a of this._targets)if(s++,!(a.influence===0&&this.optimizeInfluencers)){if(this._activeTargets.length>=n.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(a),this._morphTargetTextureIndices[r]=s,this._tempInfluences[r++]=a.influence}this._morphTargetTextureIndices.length!==r&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,r)),(!this._influences||this._influences.length!==r)&&(this._influences=new Float32Array(r));for(let a=0;ae.getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1);for(let i of this._targets){this._supportsPositions=this._supportsPositions&&i.hasPositions,this._supportsNormals=this._supportsNormals&&i.hasNormals,this._supportsTangents=this._supportsTangents&&i.hasTangents,this._supportsUVs=this._supportsUVs&&i.hasUVs,this._supportsUV2s=this._supportsUV2s&&i.hasUV2s,this._supportsColors=this._supportsColors&&i.hasColors;let r=i.vertexCount;if(this._vertexCount===0)this._vertexCount=r;else if(this._vertexCount!==r){W.Error(`Incompatible target. Targets must all have the same vertices count. Current vertex count: ${this._vertexCount}, vertex count for target "${i.name}": ${r}`);return}}if(this.isUsingTextureForTargets){this._textureVertexStride=0,this._supportsPositions&&this._textureVertexStride++,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._supportsUV2s&&this._textureVertexStride++,this._supportsColors&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;let i=e.getCaps().maxTextureSize;this._textureWidth>i&&(this._textureHeight=Math.ceil(this._textureWidth/i),this._textureWidth=i);let r=this._targets.length,s=new Float32Array(r*this._textureWidth*this._textureHeight*4),a;for(let o=0;o-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(let e of this._targets)this._scene.stopAnimation(e)}}static Parse(e,t){let i=new n(t);for(let r of e.targets)i.addTarget(Ka.Parse(r,t,i));return e.metadata&&(i.metadata=e.metadata),i}};ko.EnableTextureStorage=!0;ko.MaxActiveMorphTargetsInVertexAttributeMode=8;ko.ConstantTargetCountForTextureMode=0});function kO(n,e,t){gT(n)&&W.Warn(`Extension with the name '${n}' already exists`),_T.set(n,{isGLTFExtension:e,factory:t})}function gT(n){return _T.delete(n)}var _T,GO,WO=A(()=>{ze();_T=new Map,GO=_T});var F,ET=A(()=>{F=class{};F.AUTOSAMPLERSUFFIX="Sampler";F.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS";F.ALPHA_DISABLE=0;F.ALPHA_ADD=1;F.ALPHA_COMBINE=2;F.ALPHA_SUBTRACT=3;F.ALPHA_MULTIPLY=4;F.ALPHA_MAXIMIZED=5;F.ALPHA_ONEONE=6;F.ALPHA_PREMULTIPLIED=7;F.ALPHA_PREMULTIPLIED_PORTERDUFF=8;F.ALPHA_INTERPOLATE=9;F.ALPHA_SCREENMODE=10;F.ALPHA_ONEONE_ONEONE=11;F.ALPHA_ALPHATOCOLOR=12;F.ALPHA_REVERSEONEMINUS=13;F.ALPHA_SRC_DSTONEMINUSSRCALPHA=14;F.ALPHA_ONEONE_ONEZERO=15;F.ALPHA_EXCLUSION=16;F.ALPHA_LAYER_ACCUMULATE=17;F.ALPHA_MIN=18;F.ALPHA_MAX=19;F.ALPHA_DUAL_SRC0_ADD_SRC1xDST=20;F.ALPHA_EQUATION_ADD=0;F.ALPHA_EQUATION_SUBSTRACT=1;F.ALPHA_EQUATION_REVERSE_SUBTRACT=2;F.ALPHA_EQUATION_MAX=3;F.ALPHA_EQUATION_MIN=4;F.ALPHA_EQUATION_DARKEN=5;F.DELAYLOADSTATE_NONE=0;F.DELAYLOADSTATE_LOADED=1;F.DELAYLOADSTATE_LOADING=2;F.DELAYLOADSTATE_NOTLOADED=4;F.NEVER=512;F.ALWAYS=519;F.LESS=513;F.EQUAL=514;F.LEQUAL=515;F.GREATER=516;F.GEQUAL=518;F.NOTEQUAL=517;F.KEEP=7680;F.ZERO=0;F.REPLACE=7681;F.INCR=7682;F.DECR=7683;F.INVERT=5386;F.INCR_WRAP=34055;F.DECR_WRAP=34056;F.TEXTURE_CLAMP_ADDRESSMODE=0;F.TEXTURE_WRAP_ADDRESSMODE=1;F.TEXTURE_MIRROR_ADDRESSMODE=2;F.TEXTURE_CREATIONFLAG_STORAGE=1;F.TEXTUREFORMAT_ALPHA=0;F.TEXTUREFORMAT_LUMINANCE=1;F.TEXTUREFORMAT_LUMINANCE_ALPHA=2;F.TEXTUREFORMAT_RGB=4;F.TEXTUREFORMAT_RGBA=5;F.TEXTUREFORMAT_RED=6;F.TEXTUREFORMAT_R=6;F.TEXTUREFORMAT_R16_UNORM=33322;F.TEXTUREFORMAT_RG16_UNORM=33324;F.TEXTUREFORMAT_RGB16_UNORM=32852;F.TEXTUREFORMAT_RGBA16_UNORM=32859;F.TEXTUREFORMAT_R16_SNORM=36760;F.TEXTUREFORMAT_RG16_SNORM=36761;F.TEXTUREFORMAT_RGB16_SNORM=36762;F.TEXTUREFORMAT_RGBA16_SNORM=36763;F.TEXTUREFORMAT_RG=7;F.TEXTUREFORMAT_RED_INTEGER=8;F.TEXTUREFORMAT_R_INTEGER=8;F.TEXTUREFORMAT_RG_INTEGER=9;F.TEXTUREFORMAT_RGB_INTEGER=10;F.TEXTUREFORMAT_RGBA_INTEGER=11;F.TEXTUREFORMAT_BGRA=12;F.TEXTUREFORMAT_DEPTH24_STENCIL8=13;F.TEXTUREFORMAT_DEPTH32_FLOAT=14;F.TEXTUREFORMAT_DEPTH16=15;F.TEXTUREFORMAT_DEPTH24=16;F.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17;F.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18;F.TEXTUREFORMAT_STENCIL8=19;F.TEXTUREFORMAT_UNDEFINED=4294967295;F.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493;F.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495;F.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777;F.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917;F.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x4=37809;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x5=37810;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x5=37811;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x6=37812;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x5=37813;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x6=37814;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x8=37815;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x5=37816;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x6=37817;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x8=37818;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x10=37819;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x10=37820;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x12=37821;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853;F.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196;F.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493;F.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494;F.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495;F.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497;F.TEXTURETYPE_UNSIGNED_BYTE=0;F.TEXTURETYPE_UNSIGNED_INT=0;F.TEXTURETYPE_FLOAT=1;F.TEXTURETYPE_HALF_FLOAT=2;F.TEXTURETYPE_BYTE=3;F.TEXTURETYPE_SHORT=4;F.TEXTURETYPE_UNSIGNED_SHORT=5;F.TEXTURETYPE_INT=6;F.TEXTURETYPE_UNSIGNED_INTEGER=7;F.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;F.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;F.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;F.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;F.TEXTURETYPE_UNSIGNED_INT_24_8=12;F.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;F.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;F.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;F.TEXTURETYPE_UNDEFINED=16;F.TEXTURE_2D=3553;F.TEXTURE_2D_ARRAY=35866;F.TEXTURE_CUBE_MAP=34067;F.TEXTURE_CUBE_MAP_ARRAY=3735928559;F.TEXTURE_3D=32879;F.TEXTURE_NEAREST_SAMPLINGMODE=1;F.TEXTURE_NEAREST_NEAREST=1;F.TEXTURE_BILINEAR_SAMPLINGMODE=2;F.TEXTURE_LINEAR_LINEAR=2;F.TEXTURE_TRILINEAR_SAMPLINGMODE=3;F.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;F.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;F.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;F.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;F.TEXTURE_NEAREST_LINEAR=7;F.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;F.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;F.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;F.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;F.TEXTURE_LINEAR_NEAREST=12;F.TEXTURE_EXPLICIT_MODE=0;F.TEXTURE_SPHERICAL_MODE=1;F.TEXTURE_PLANAR_MODE=2;F.TEXTURE_CUBIC_MODE=3;F.TEXTURE_PROJECTION_MODE=4;F.TEXTURE_SKYBOX_MODE=5;F.TEXTURE_INVCUBIC_MODE=6;F.TEXTURE_EQUIRECTANGULAR_MODE=7;F.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;F.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;F.TEXTURE_FILTERING_QUALITY_OFFLINE=4096;F.TEXTURE_FILTERING_QUALITY_HIGH=64;F.TEXTURE_FILTERING_QUALITY_MEDIUM=16;F.TEXTURE_FILTERING_QUALITY_LOW=8;F.SCALEMODE_FLOOR=1;F.SCALEMODE_NEAREST=2;F.SCALEMODE_CEILING=3;F.MATERIAL_TextureDirtyFlag=1;F.MATERIAL_LightDirtyFlag=2;F.MATERIAL_FresnelDirtyFlag=4;F.MATERIAL_AttributesDirtyFlag=8;F.MATERIAL_MiscDirtyFlag=16;F.MATERIAL_PrePassDirtyFlag=32;F.MATERIAL_ImageProcessingDirtyFlag=64;F.MATERIAL_AllDirtyFlag=127;F.MATERIAL_TriangleFillMode=0;F.MATERIAL_WireFrameFillMode=1;F.MATERIAL_PointFillMode=2;F.MATERIAL_PointListDrawMode=3;F.MATERIAL_LineListDrawMode=4;F.MATERIAL_LineLoopDrawMode=5;F.MATERIAL_LineStripDrawMode=6;F.MATERIAL_TriangleStripDrawMode=7;F.MATERIAL_TriangleFanDrawMode=8;F.MATERIAL_ClockWiseSideOrientation=0;F.MATERIAL_CounterClockWiseSideOrientation=1;F.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR=0;F.MATERIAL_DIFFUSE_MODEL_BURLEY=1;F.MATERIAL_DIFFUSE_MODEL_LAMBERT=2;F.MATERIAL_DIFFUSE_MODEL_LEGACY=3;F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_GLTF=0;F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR=1;F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_GLTF=0;F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR=1;F.ACTION_NothingTrigger=0;F.ACTION_OnPickTrigger=1;F.ACTION_OnLeftPickTrigger=2;F.ACTION_OnRightPickTrigger=3;F.ACTION_OnCenterPickTrigger=4;F.ACTION_OnPickDownTrigger=5;F.ACTION_OnDoublePickTrigger=6;F.ACTION_OnPickUpTrigger=7;F.ACTION_OnPickOutTrigger=16;F.ACTION_OnLongPressTrigger=8;F.ACTION_OnPointerOverTrigger=9;F.ACTION_OnPointerOutTrigger=10;F.ACTION_OnEveryFrameTrigger=11;F.ACTION_OnIntersectionEnterTrigger=12;F.ACTION_OnIntersectionExitTrigger=13;F.ACTION_OnKeyDownTrigger=14;F.ACTION_OnKeyUpTrigger=15;F.PARTICLES_BILLBOARDMODE_Y=2;F.PARTICLES_BILLBOARDMODE_ALL=7;F.PARTICLES_BILLBOARDMODE_STRETCHED=8;F.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9;F.MESHES_CULLINGSTRATEGY_STANDARD=0;F.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;F.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;F.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;F.SCENELOADER_NO_LOGGING=0;F.SCENELOADER_MINIMAL_LOGGING=1;F.SCENELOADER_SUMMARY_LOGGING=2;F.SCENELOADER_DETAILED_LOGGING=3;F.PREPASS_IRRADIANCE_LEGACY_TEXTURE_TYPE=0;F.PREPASS_POSITION_TEXTURE_TYPE=1;F.PREPASS_VELOCITY_TEXTURE_TYPE=2;F.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3;F.PREPASS_COLOR_TEXTURE_TYPE=4;F.PREPASS_DEPTH_TEXTURE_TYPE=5;F.PREPASS_NORMAL_TEXTURE_TYPE=6;F.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7;F.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8;F.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9;F.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10;F.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11;F.PREPASS_ALBEDO_TEXTURE_TYPE=12;F.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE=13;F.PREPASS_IRRADIANCE_TEXTURE_TYPE=14;F.BUFFER_CREATIONFLAG_READ=1;F.BUFFER_CREATIONFLAG_WRITE=2;F.BUFFER_CREATIONFLAG_READWRITE=3;F.BUFFER_CREATIONFLAG_UNIFORM=4;F.BUFFER_CREATIONFLAG_VERTEX=8;F.BUFFER_CREATIONFLAG_INDEX=16;F.BUFFER_CREATIONFLAG_STORAGE=32;F.BUFFER_CREATIONFLAG_INDIRECT=64;F.RENDERPASS_MAIN=0;F.INPUT_ALT_KEY=18;F.INPUT_CTRL_KEY=17;F.INPUT_META_KEY1=91;F.INPUT_META_KEY2=92;F.INPUT_META_KEY3=93;F.INPUT_SHIFT_KEY=16;F.SNAPSHOTRENDERING_STANDARD=0;F.SNAPSHOTRENDERING_FAST=1;F.PERSPECTIVE_CAMERA=0;F.ORTHOGRAPHIC_CAMERA=1;F.FOVMODE_VERTICAL_FIXED=0;F.FOVMODE_HORIZONTAL_FIXED=1;F.RIG_MODE_NONE=0;F.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;F.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;F.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;F.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;F.RIG_MODE_STEREOSCOPIC_INTERLACED=14;F.RIG_MODE_VR=20;F.RIG_MODE_CUSTOM=22;F.MAX_SUPPORTED_UV_SETS=6;F.GL_ALPHA_EQUATION_ADD=32774;F.GL_ALPHA_EQUATION_MIN=32775;F.GL_ALPHA_EQUATION_MAX=32776;F.GL_ALPHA_EQUATION_SUBTRACT=32778;F.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779;F.GL_ALPHA_FUNCTION_SRC=768;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769;F.GL_ALPHA_FUNCTION_SRC_ALPHA=770;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771;F.GL_ALPHA_FUNCTION_DST_ALPHA=772;F.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773;F.GL_ALPHA_FUNCTION_DST_COLOR=774;F.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775;F.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776;F.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769;F.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770;F.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771;F.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772;F.GL_ALPHA_FUNCTION_SRC1_COLOR=35065;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066;F.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067;F.SnippetUrl="https://snippet.babylonjs.com";F.FOGMODE_NONE=0;F.FOGMODE_EXP=1;F.FOGMODE_EXP2=2;F.FOGMODE_LINEAR=3;F.BYTE=5120;F.UNSIGNED_BYTE=5121;F.SHORT=5122;F.UNSIGNED_SHORT=5123;F.INT=5124;F.UNSIGNED_INT=5125;F.FLOAT=5126;F.PositionKind="position";F.NormalKind="normal";F.TangentKind="tangent";F.UVKind="uv";F.UV2Kind="uv2";F.UV3Kind="uv3";F.UV4Kind="uv4";F.UV5Kind="uv5";F.UV6Kind="uv6";F.ColorKind="color";F.ColorInstanceKind="instanceColor";F.MatricesIndicesKind="matricesIndices";F.MatricesWeightsKind="matricesWeights";F.MatricesIndicesExtraKind="matricesIndicesExtra";F.MatricesWeightsExtraKind="matricesWeightsExtra";F.ANIMATIONTYPE_FLOAT=0;F.ANIMATIONTYPE_VECTOR3=1;F.ANIMATIONTYPE_QUATERNION=2;F.ANIMATIONTYPE_MATRIX=3;F.ANIMATIONTYPE_COLOR3=4;F.ANIMATIONTYPE_COLOR4=7;F.ANIMATIONTYPE_VECTOR2=5;F.ANIMATIONTYPE_SIZE=6;F.ShadowMinZ=0;F.ShadowMaxZ=1e4;F.OUTLINELAYER_SAMPLING_TRIDIRECTIONAL=0;F.OUTLINELAYER_SAMPLING_OCTADIRECTIONAL=1});var tbe,HO=A(()=>{tbe=[{regex:new RegExp("^/nodes/\\d+/extensions/")}]});function ja(n,e,t,i){let r=Le(n,e);return i?r[t][i]:r[t]}function Le(n,e,t){var i,r,s;return(s=(r=n._data)==null?void 0:r[(i=t==null?void 0:t.fillMode)!=null?i:F.MATERIAL_TriangleFillMode])==null?void 0:s.babylonMaterial}function pi(n,e){return{offset:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let s=ja(t,r,n,e);return new _e(s==null?void 0:s.uOffset,s==null?void 0:s.vOffset)},getTarget:Le,set:(t,i,r,s)=>{let a=ja(i,s,n,e);a.uOffset=t.x,a.vOffset=t.y},getPropertyName:[()=>`${n}${e?"."+e:""}.uOffset`,()=>`${n}${e?"."+e:""}.vOffset`]},rotation:{type:"number",get:(t,i,r)=>{var s;return(s=ja(t,r,n,e))==null?void 0:s.wAng},getTarget:Le,set:(t,i,r,s)=>ja(i,s,n,e).wAng=t,getPropertyName:[()=>`${n}${e?"."+e:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let s=ja(t,r,n,e);return new _e(s==null?void 0:s.uScale,s==null?void 0:s.vScale)},getTarget:Le,set:(t,i,r,s)=>{let a=ja(i,s,n,e);a.uScale=t.x,a.vScale=t.y},getPropertyName:[()=>`${n}${e?"."+e:""}.uScale`,()=>`${n}${e?"."+e:""}.vScale`]}}}function qf(n){let e=n.split("/").map(i=>i.replace(/{}/g,"__array__")),t=zO;for(let i of e)i&&(t=t[i]);if(t&&t.type&&t.get)return t}function Qf(n,e){let t=n.split("/").map(r=>r.replace(/{}/g,"__array__")),i=zO;for(let r of t)r&&(i=i[r]);i&&i.type&&i.get&&(i.interpolation=e)}var lz,cz,fz,dz,hz,uz,zO,vT=A(()=>{ve();ET();et();vE();HO();lz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonTransformNode),getPropertyName:[()=>"length"]},__array__:{__target__:!0,translation:{type:"Vector3",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.position},set:(n,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.position.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"position"]},rotation:{type:"Quaternion",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.rotationQuaternion},set:(n,e)=>{var t,i;return(i=(t=e._babylonTransformNode)==null?void 0:t.rotationQuaternion)==null?void 0:i.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"rotationQuaternion"]},scale:{type:"Vector3",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.scaling},set:(n,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.scaling.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"scaling"]},weights:{length:{type:"number",get:n=>n._numMorphTargets,getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},__array__:{__target__:!0,type:"number",get:(n,e)=>{var t,i;return e!==void 0?(i=(t=n._primitiveBabylonMeshes)==null?void 0:t[0].morphTargetManager)==null?void 0:i.getTarget(e).influence:void 0},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},type:"number[]",get:(n,e)=>[0],getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},matrix:{type:"Matrix",get:n=>{var e,t,i;return G.Compose((e=n._babylonTransformNode)==null?void 0:e.scaling,(t=n._babylonTransformNode)==null?void 0:t.rotationQuaternion,(i=n._babylonTransformNode)==null?void 0:i.position)},getTarget:n=>n._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:n=>{var r,s,a,o,l,c,f;let e=G.Identity(),t=n.parent;for(;t&&t.parent;)t=t.parent;let i=((r=n._babylonTransformNode)==null?void 0:r.position._isDirty)||((a=(s=n._babylonTransformNode)==null?void 0:s.rotationQuaternion)==null?void 0:a._isDirty)||((o=n._babylonTransformNode)==null?void 0:o.scaling._isDirty);if(t){let d=(l=t._babylonTransformNode)==null?void 0:l.computeWorldMatrix(!0).invert();d&&((f=(c=n._babylonTransformNode)==null?void 0:c.computeWorldMatrix(i))==null||f.multiplyToRef(d,e))}else n._babylonTransformNode&&e.copyFrom(n._babylonTransformNode.computeWorldMatrix(i));return e},getTarget:n=>n._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:n=>{var e,t;return(t=(e=n._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.intensity},getTarget:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(n,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.intensity=n)}}},color:{type:"Color3",get:n=>{var e,t;return(t=(e=n._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.diffuse},getTarget:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(n,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.diffuse=n)}}}},KHR_node_visibility:{visible:{type:"boolean",get:n=>n._primitiveBabylonMeshes?n._primitiveBabylonMeshes[0].isVisible:!1,getTarget:()=>{},set:(n,e)=>{e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes.forEach(t=>t.isVisible=n)}}}}}},cz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>"length"]},__array__:{}},fz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>{var t;return(t=e.primitives[0]._instanceData)==null?void 0:t.babylonSourceMesh}),getPropertyName:[()=>"length"]},__array__:{}},dz={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:n=>{var e,t,i,r;return new _e((t=(e=n._babylonCamera)==null?void 0:e.orthoLeft)!=null?t:0,(r=(i=n._babylonCamera)==null?void 0:i.orthoRight)!=null?r:0)},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.orthoLeft=n.x,e._babylonCamera.orthoRight=n.y)},getTarget:n=>n,getPropertyName:[()=>"orthoLeft",()=>"orthoRight"]},ymag:{componentsCount:2,type:"Vector2",get:n=>{var e,t,i,r;return new _e((t=(e=n._babylonCamera)==null?void 0:e.orthoBottom)!=null?t:0,(r=(i=n._babylonCamera)==null?void 0:i.orthoTop)!=null?r:0)},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.orthoBottom=n.x,e._babylonCamera.orthoTop=n.y)},getTarget:n=>n,getPropertyName:[()=>"orthoBottom",()=>"orthoTop"]},zfar:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.maxZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=n)},getTarget:n=>n,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.minZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=n)},getTarget:n=>n,getPropertyName:[()=>"minZ"]}},perspective:{aspectRatio:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.getEngine().getAspectRatio(n._babylonCamera)},getTarget:n=>n,getPropertyName:[()=>"aspectRatio"],isReadOnly:!0},yfov:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.fov},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.fov=n)},getTarget:n=>n,getPropertyName:[()=>"fov"]},zfar:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.maxZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=n)},getTarget:n=>n,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.minZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=n)},getTarget:n=>n,getPropertyName:[()=>"minZ"]}}}},hz={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).emissiveColor,set:(n,e,t,i)=>Le(e,t,i).emissiveColor.copyFrom(n),getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:pi("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(n,e,t)=>{var i;return(i=ja(n,t,"bumpTexture"))==null?void 0:i.level},set:(n,e,t,i)=>{let r=ja(e,i,"bumpTexture");r&&(r.level=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:pi("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(n,e,t)=>Le(n,e,t).ambientTextureStrength,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.ambientTextureStrength=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:pi("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(n,e,t)=>{let i=Le(n,e,t);return Ne.FromColor3(i.albedoColor,i.alpha)},set:(n,e,t,i)=>{let r=Le(e,t,i);r.albedoColor.set(n.r,n.g,n.b),r.alpha=n.a},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:pi("albedoTexture")}},metallicFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).metallic,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.metallic=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).roughness,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.roughness=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:pi("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(n,e,t)=>Le(n,e,t).anisotropy.intensity,set:(n,e,t,i)=>{Le(e,t,i).anisotropy.intensity=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(n,e,t)=>Le(n,e,t).anisotropy.angle,set:(n,e,t,i)=>{Le(e,t,i).anisotropy.angle=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:pi("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).clearCoat.intensity,set:(n,e,t,i)=>{Le(e,t,i).clearCoat.intensity=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).clearCoat.roughness,set:(n,e,t,i)=>{Le(e,t,i).clearCoat.roughness=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:pi("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(n,e,t)=>{var i;return(i=Le(n,e,t).clearCoat.bumpTexture)==null?void 0:i.level},getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).clearCoat.bumpTexture.level=n},extensions:{KHR_texture_transform:pi("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:pi("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.dispersion,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.dispersion=n}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(n,e,t)=>Le(n,e,t).emissiveIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).emissiveIntensity=n}},KHR_materials_ior:{ior:{type:"number",get:(n,e,t)=>Le(n,e,t).indexOfRefraction,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).indexOfRefraction=n}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.intensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.intensity=n},iridescenceIor:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.indexOfRefraction,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.indexOfRefraction=n},iridescenceTexture:{extensions:{KHR_texture_transform:pi("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.maximumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.maximumThickness=n},iridescenceThicknessMinimum:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.minimumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.minimumThickness=n},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:pi("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).sheen.color,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).sheen.color.copyFrom(n)},sheenColorTexture:{extensions:{KHR_texture_transform:pi("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).sheen.intensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).sheen.intensity=n},sheenRoughnessTexture:{extensions:{KHR_texture_transform:pi("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).metallicF0Factor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).metallicF0Factor=n,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).metallicReflectanceColor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).metallicReflectanceColor.copyFrom(n),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:pi("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:pi("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.refractionIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.refractionIntensity=n,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:pi("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.translucencyIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.translucencyIntensity=n},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:pi("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).subSurface.translucencyColor,getTarget:Le,set:(n,e,t,i)=>{var r;return n&&((r=Le(e,t,i).subSurface.translucencyColor)==null?void 0:r.copyFrom(n))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:pi("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).subSurface.tintColor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.tintColor.copyFrom(n)},attenuationDistance:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.tintColorAtDistance,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.tintColorAtDistance=n},thicknessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.maximumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.maximumThickness=n},thicknessTexture:{extensions:{KHR_texture_transform:pi("subSurface","thicknessTexture")}}}}}},uz={KHR_lights_punctual:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.diffuse},set:(n,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(n)},getTarget:n=>n._babylonLight,getPropertyName:[n=>"diffuse"]},intensity:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.intensity},set:(n,e)=>e._babylonLight?e._babylonLight.intensity=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"intensity"]},range:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.range},set:(n,e)=>e._babylonLight?e._babylonLight.range=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"range"]},spot:{innerConeAngle:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.innerAngle},set:(n,e)=>e._babylonLight?e._babylonLight.innerAngle=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"innerConeAngle"]},outerConeAngle:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.angle},set:(n,e)=>e._babylonLight?e._babylonLight.angle=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"outerConeAngle"]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.diffuse},set:(n,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(n)},getTarget:n=>n._babylonLight,getPropertyName:[n=>"diffuse"]},intensity:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.intensity},set:(n,e)=>e._babylonLight?e._babylonLight.intensity=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"intensity"]},size:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.height},set:(n,e)=>e._babylonLight?e._babylonLight.height=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"size"]},rect:{aspect:{type:"number",get:n=>{var e,t;return((e=n._babylonLight)==null?void 0:e.width)/((t=n._babylonLight)==null?void 0:t.height)},set:(n,e)=>e._babylonLight?e._babylonLight.width=n*e._babylonLight.height:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"aspect"]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonTexture),getPropertyName:[n=>"length"]},__array__:{__target__:!0,intensity:{type:"number",get:n=>{var e;return(e=n._babylonTexture)==null?void 0:e.level},set:(n,e)=>{e._babylonTexture&&(e._babylonTexture.level=n)},getTarget:n=>n._babylonTexture},rotation:{type:"Quaternion",get:n=>{var e;return n._babylonTexture&&Ae.FromRotationMatrix((e=n._babylonTexture)==null?void 0:e.getReflectionTextureMatrix())},set:(n,e)=>{var t;e._babylonTexture&&((t=e._babylonTexture.getScene())!=null&&t.useRightHandedSystem||(n=Ae.Inverse(n)),G.FromQuaternionToRef(n,e._babylonTexture.getReflectionTextureMatrix()))},getTarget:n=>n._babylonTexture}}}}};zO={cameras:dz,nodes:lz,materials:hz,extensions:uz,animations:cz,meshes:fz}});function TT(...n){let e=t=>!!t&&typeof t=="object";return n.reduce((t,i)=>{let r=Object.keys(i);for(let s of r){let a=t[s],o=i[s];Array.isArray(a)&&Array.isArray(o)?t[s]=a.concat(...o):e(a)&&e(o)?t[s]=TT(a,o):t[s]=o}return t},{})}var XO=A(()=>{});var Jf,YO=A(()=>{Jf=class{constructor(e){this._factory=e}get value(){return this._factory&&(this._value=this._factory(),this._factory=void 0),this._value}}});var Bm,KO=A(()=>{ve();Is();Bm=class{get currentFrame(){return this._currentFrame}get weight(){return this._weight}get currentValue(){return this._currentValue}get targetPath(){return this._targetPath}get target(){return this._currentActiveTarget}get isAdditive(){return this._host&&this._host.isAdditive}constructor(e,t,i,r){if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._absoluteFrameOffset=0,this._previousElapsedTime=0,this._yoyoDirection=1,this._previousAbsoluteFrame=0,this._targetIsArray=!1,this._coreRuntimeAnimation=null,this._animation=t,this._target=e,this._scene=i,this._host=r,this._activeTargets=[],t._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===Oe.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=G.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minFrame!==0){let a={frame:0,value:this._keys[0].value};this._keys.splice(0,0,a)}if(this._target instanceof Array){let a=0;for(let o of this._target)this._preparePath(o,a),this._getOriginalValues(a),a++;this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];let s=t.getEvents();if(s&&s.length>0)for(let a of s)this._events.push(a._clone());this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}_preparePath(e,t=0){let i=this._animation.targetPropertyPath;if(i.length>1){let r=e;for(let s=0;s-1&&this._animation.runtimeAnimations.splice(e,1)}setValue(e,t){if(this._targetIsArray){for(let i=0;ii[i.length-1].frame&&(e=i[i.length-1].frame);let r=this._events;if(r.length)for(let a=0;athis._maxFrame)&&(t=this._minFrame),(ithis._maxFrame)&&(i=this._maxFrame),h=i-t;let m,p=e*(o.framePerSecond*s)/1e3+this._absoluteFrameOffset,_=0,g=!1,T=r&&this._animationState.loopMode===Oe.ANIMATIONLOOPMODE_YOYO;if(T){let b=(p-t)/h,R=Math.sin(b*Math.PI);p=Math.abs(R)*h+t;let I=R>=0?1:-1;this._yoyoDirection!==I&&(g=!0),this._yoyoDirection=I}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=p,!r&&i>=t&&(p>=h&&s>0||p<=0&&s<0))c=!1,_=o.evaluate(i);else if(!r&&t>=i&&(p<=h&&s<0||p>=0&&s>0))c=!1,_=o.evaluate(t);else if(this._animationState.loopMode!==Oe.ANIMATIONLOOPMODE_CYCLE){let b=i.toString()+t.toString();if(!this._offsetsCache[b]){this._animationState.repeatCount=0,this._animationState.loopMode=Oe.ANIMATIONLOOPMODE_CYCLE;let R=o._interpolate(t,this._animationState),S=o._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),o.dataType){case Oe.ANIMATIONTYPE_FLOAT:this._offsetsCache[b]=S-R;break;case Oe.ANIMATIONTYPE_QUATERNION:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_VECTOR3:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_VECTOR2:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_SIZE:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_COLOR3:this._offsetsCache[b]=S.subtract(R);break;default:break}this._highLimitsCache[b]=S}_=this._highLimitsCache[b],m=this._offsetsCache[b]}if(m===void 0)switch(o.dataType){case Oe.ANIMATIONTYPE_FLOAT:m=0;break;case Oe.ANIMATIONTYPE_QUATERNION:m=dE;break;case Oe.ANIMATIONTYPE_VECTOR3:m=hE;break;case Oe.ANIMATIONTYPE_VECTOR2:m=uE;break;case Oe.ANIMATIONTYPE_SIZE:m=mE;break;case Oe.ANIMATIONTYPE_COLOR3:m=pE;break;case Oe.ANIMATIONTYPE_COLOR4:m=_E;break}if(this._host&&this._host.syncRoot){let b=this._host.syncRoot,R=(b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame);f=t+h*R}else p>0&&t>i||p<0&&t0&&this.currentFrame>f||s<0&&this.currentFrame0?0:o.getKeys().length-1}this._currentFrame=f,this._animationState.repeatCount=h===0?0:p/h>>0,this._animationState.highLimitValue=_,this._animationState.offsetValue=m}let u=o._interpolate(f,this._animationState);if(this.setValue(u,a),d.length){for(let m=0;m=0&&f>=d[m].frame&&d[m].frame>=t||h<0&&f<=d[m].frame&&d[m].frame<=t){let p=d[m];p.isDone||(p.onlyOnce&&(d.splice(m,1),m--),p.isDone=!0,p.action(f))}}return c||(this._stopped=!0),c}}});function mz(n){if(n.totalWeight===0&&n.totalAdditiveWeight===0)return n.originalValue;let e=1,t=k.Vector3[0],i=k.Vector3[1],r=k.Quaternion[0],s=0,a=n.animations[0],o=n.originalValue,l,c=!1;if(n.totalWeight<1)l=1-n.totalWeight,o.decompose(i,r,t);else{if(s=1,e=n.totalWeight,l=a.weight/e,l==1)if(n.totalAdditiveWeight)c=!0;else return a.currentValue;a.currentValue.decompose(i,r,t)}if(!c){i.scaleInPlace(l),t.scaleInPlace(l),r.scaleInPlace(l);for(let d=s;d0?l:-l,r),u.scaleAndAddToRef(l,t)}r.normalize()}for(let d=0;d0)r.copyFrom(i);else if(n.animations.length===1){if(Ae.SlerpToRef(i,t.currentValue,Math.min(1,n.totalWeight),r),n.totalAdditiveWeight===0)return r}else if(n.animations.length>1){let s=1,a,o;if(n.totalWeight<1){let c=1-n.totalWeight;a=[],o=[],a.push(i),o.push(c)}else{if(n.animations.length===2&&(Ae.SlerpToRef(n.animations[0].currentValue,n.animations[1].currentValue,n.animations[1].weight/n.totalWeight,e),n.totalAdditiveWeight===0))return e;a=[],o=[],s=n.totalWeight}for(let c=0;c=l&&T.frame<=c&&(s?(R=T.value.clone(),m?(b=R.getTranslation(),R.setTranslation(b.scaleInPlace(p))):_&&a?(b=R.getTranslation(),R.setTranslation(b.multiplyInPlace(a))):R=T.value):R=T.value,g.push({frame:T.frame+r,value:R}));return this.animations[0].createRange(i,l+r,c+r),!0}),n&&(n.prototype._animate=function(t){if(!this.animationsEnabled)return;let i=kt.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=i}this.deltaTime=t!==void 0?t:this.useConstantAnimationDeltaTime?16:(i-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=i;let r=this._activeAnimatables;if(r.length===0)return;this._animationTime+=this.deltaTime;let s=this._animationTime;for(let a=0;at.playOrder-i.playOrder)},n.prototype.beginWeightedAnimation=function(t,i,r,s=1,a,o=1,l,c,f,d,h=!1){let u=this.beginAnimation(t,i,r,a,o,l,c,!1,f,d,h);return u.weight=s,u},n.prototype.beginAnimation=function(t,i,r,s,a=1,o,l,c=!0,f,d,h=!1){if(a<0){let m=i;i=r,r=m,a=-a}i>r&&(a=-a),c&&this.stopAnimation(t,void 0,f),l||(l=new $f(this,t,i,r,s,a,o,void 0,d,h));let u=f?f(t):!0;if(t.animations&&u&&l.appendAnimations(t,t.animations),t.getAnimatables){let m=t.getAnimatables();for(let p=0;ps&&(o=-o),new $f(this,t,r,s,a,o,l,i,c,f)},n.prototype.beginDirectHierarchyAnimation=function(t,i,r,s,a,o,l,c,f,d=!1){let h=t.getDescendants(i),u=[];u.push(this.beginDirectAnimation(t,r,s,a,o,l,c,f,d));for(let m of h)u.push(this.beginDirectAnimation(m,r,s,a,o,l,c,f,d));return u},n.prototype.getAnimatableByTarget=function(t){for(let i=0;i{ct();KO();Is();rs();ve();$f=class n{get syncRoot(){return this._syncRoot}get masterFrame(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame}get weight(){return this._weight}set weight(e){if(e===-1){this._weight=-1;return}this._weight=Math.min(Math.max(e,0),1)}get speedRatio(){return this._speedRatio}set speedRatio(e){for(let t=0;t-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this}getAnimations(){return this._runtimeAnimations}appendAnimations(e,t){for(let i=0;i{this.onAnimationLoopObservable.notifyObservers(this),this.onAnimationLoop&&this.onAnimationLoop()},this._runtimeAnimations.push(s)}}getAnimationByTargetProperty(e){let t=this._runtimeAnimations;for(let i=0;i-1){let a=this._runtimeAnimations;for(let o=a.length-1;o>=0;o--){let l=a[o];e&&l.animation.name!=e||t&&!t(l.target)||(l.dispose(),a.splice(o,1))}a.length==0&&(i||this._scene._activeAnimatables.splice(s,1),r||this._raiseOnAnimationEnd())}}else{let s=this._scene._activeAnimatables.indexOf(this);if(s>-1){i||this._scene._activeAnimatables.splice(s,1);let a=this._runtimeAnimations;for(let o=0;o{this.onAnimationEndObservable.add(()=>{e(this)},void 0,void 0,this,!0)})}_animate(e){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=e),!0;if(this._localDelayOffset===null?(this._localDelayOffset=e,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),this._manualJumpDelay!==null&&(this._localDelayOffset+=this.speedRatio<0?-this._manualJumpDelay:this._manualJumpDelay,this._manualJumpDelay=null,this._frameToSyncFromJump=null),this._goToFrame=null,!n.ProcessPausedAnimatables&&this._weight===0&&this._previousWeight===0)return!0;this._previousWeight=this._weight;let t=!1,i=this._runtimeAnimations,r;for(r=0;r{Nm();ST();gr();ST();jO(gt,Kr)});var qO={};De(qO,{AnimationGroup:()=>AT,TargetedAnimation:()=>Um});var Um,AT,QO=A(()=>{Is();ct();At();ha();ZO();Uh();Um=class{getClassName(){return"TargetedAnimation"}constructor(e){this.parent=e,this.uniqueId=vs.UniqueId}serialize(){let e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e.targetUniqueId=this.target.uniqueId,e}},AT=class n{get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this.syncWithMask(!0))}syncWithMask(e=!1){if(!this.mask&&!e){this._numActiveAnimatables=this._targetedAnimations.length;return}this._numActiveAnimatables=0;for(let t=0;t0)){for(let t=0;ta&&(a=l.to);let o=new n(e[0].name+"_merged",e[0]._scene,r);for(let l of e){i&&l.normalize(s,a);for(let c of l.targetedAnimations)o.addTargetedAnimation(c.animation,c.target);t&&l.dispose()}return o}getScene(){return this._scene}constructor(e,t=null,i=-1,r=0){this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this._loopAnimation=!1,this._isAdditive=!1,this._weight=-1,this._playOrder=0,this._enableBlending=null,this._blendingSpeed=null,this._numActiveAnimatables=0,this._shouldStart=!0,this._parentContainer=null,this.onAnimationEndObservable=new Y,this.onAnimationLoopObservable=new Y,this.onAnimationGroupLoopObservable=new Y,this.onAnimationGroupEndObservable=new Y,this.onAnimationGroupPauseObservable=new Y,this.onAnimationGroupPlayObservable=new Y,this.metadata=null,this._mask=null,this._animationLoopFlags=[],this._scene=t||ue.LastCreatedScene,this._weight=i,this._playOrder=r,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}addTargetedAnimation(e,t){let i=new Um(this);i.animation=e,i.target=t;let r=e.getKeys();return this._from>r[0].frame&&(this._from=r[0].frame),this._to-1;t--)this._targetedAnimations[t].animation===e&&this._targetedAnimations.splice(t,1)}normalize(e=null,t=null){e==null&&(e=this._from),t==null&&(t=this._to);for(let i=0;ie){let l={frame:e,value:a.value,inTangent:a.inTangent,outTangent:a.outTangent,interpolation:a.interpolation};s.splice(0,0,l)}if(o.frame{this.onAnimationLoopObservable.notifyObservers(t),!this._animationLoopFlags[i]&&(this._animationLoopFlags[i]=!0,this._animationLoopCount++,this._animationLoopCount===this._numActiveAnimatables&&(this.onAnimationGroupLoopObservable.notifyObservers(this),this._animationLoopCount=0,this._animationLoopFlags.length=0))}}start(e=!1,t=1,i,r,s){if(this._isStarted||this._targetedAnimations.length===0)return this;this._loopAnimation=e,this._shouldStart=!1,this._animationLoopCount=0,this._animationLoopFlags.length=0;for(let a=0;a{this.onAnimationEndObservable.notifyObservers(o),this._checkAnimationGroupEnded(l)},this._processLoop(l,o,a),this._animatables.push(l)}return this.syncWithMask(),this._scene.sortActiveAnimatables(),this._speedRatio=t,this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this}pause(){if(!this._isStarted)return this;this._isPaused=!0;for(let e=0;e0?this._scene._activeAnimatables[i++]=s:e&&this._checkAnimationGroupEnded(s,e)}return this._scene._activeAnimatables.length=i,this._isStarted=!1,this}setWeightForAllAnimatables(e){for(let t=0;t-1&&this._parentContainer.animationGroups.splice(e,1),this._parentContainer=null}this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()}_checkAnimationGroupEnded(e,t=!1){let i=this._animatables.indexOf(e);i>-1&&this._animatables.splice(i,1),this._animatables.length===this._targetedAnimations.length-this._numActiveAnimatables&&(this._isStarted=!1,t||this.onAnimationGroupEndObservable.notifyObservers(this),this._animatables.length=0)}clone(e,t,i=!1,r=!1){let s=new n(e||this.name,this._scene,this._weight,this._playOrder);s._from=this.from,s._to=this.to,s._speedRatio=this.speedRatio,s._loopAnimation=this.loopAnimation,s._isAdditive=this.isAdditive,s._enableBlending=this.enableBlending,s._blendingSpeed=this.blendingSpeed,s.metadata=this.metadata,s.mask=this.mask;for(let a of this._targetedAnimations)s.addTargetedAnimation(i?a.animation.clone(r):a.animation,t?t(a.target):a.target);return s}serialize(){let e={};e.name=this.name,e.from=this.from,e.to=this.to,e.speedRatio=this.speedRatio,e.loopAnimation=this.loopAnimation,e.isAdditive=this.isAdditive,e.weight=this.weight,e.playOrder=this.playOrder,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,e.targetedAnimations=[];for(let t=0;tp[0].frame&&(c=p[0].frame),f=t&&p<=i||s&&_.frame>=t&&_.frame<=i){let g={frame:_.frame,value:_.value.clone?_.value.clone():_.value,inTangent:_.inTangent,outTangent:_.outTangent,interpolation:_.interpolation,lockedTangent:_.lockedTangent};m===Number.MAX_VALUE&&(m=g.frame),g.frame-=m,u.push(g)}}if(u.length===0){l.splice(c,1),c--;continue}a>u[0].frame&&(a=u[0].frame),oed,TransformNodeAnimationPropertyInfo:()=>pc,WeightAnimationPropertyInfo:()=>Vm,getQuaternion:()=>JO,getVector3:()=>RT,getWeights:()=>$O});function RT(n,e,t,i){return v.FromArray(e,t).scaleInPlace(i)}function JO(n,e,t,i){return Ae.FromArray(e,t).scaleInPlace(i)}function $O(n,e,t,i){let r=new Array(n._numMorphTargets);for(let s=0;s{Is();ve();vT();ed=class{constructor(e,t,i,r){this.type=e,this.name=t,this.getValue=i,this.getStride=r}_buildAnimation(e,t,i){let r=new Oe(e,this.name,t,this.type);return r.setKeys(i,!0),r}},pc=class extends ed{buildAnimations(e,t,i,r){let s=[];return s.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,i,r)}),s}},Vm=class extends ed{buildAnimations(e,t,i,r){let s=[];if(e._numMorphTargets)for(let a=0;a({frame:l.frame,inTangent:l.inTangent?l.inTangent[a]:void 0,value:l.value[a],outTangent:l.outTangent?l.outTangent[a]:void 0,interpolation:l.interpolation})),!0),e._primitiveBabylonMeshes){for(let l of e._primitiveBabylonMeshes)if(l.morphTargetManager){let c=l.morphTargetManager.getTarget(a),f=o.clone();c.animations.push(f),s.push({babylonAnimatable:c,babylonAnimation:f})}}}return s}};Qf("/nodes/{}/translation",[new pc(Oe.ANIMATIONTYPE_VECTOR3,"position",RT,()=>3)]);Qf("/nodes/{}/rotation",[new pc(Oe.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",JO,()=>4)]);Qf("/nodes/{}/scale",[new pc(Oe.ANIMATIONTYPE_VECTOR3,"scaling",RT,()=>3)]);Qf("/nodes/{}/weights",[new Vm(Oe.ANIMATIONTYPE_FLOAT,"influence",$O,n=>n._numMorphTargets)])});var gz,Ez,vz,Tz,IT,Gm,xT,iN,km=A(()=>{oi();gg();gz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSe"+"EoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==",Ez="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAF9UlEQVR4nGWVy64eVxGF16X27u7/HMcyuZGYAINwmTBigngBXoc34El4B0ZMGDJjFCExQUIKiRKZYBITHdvn/L1rF4P+c+yEUqmH9WmtrrWLkdB4C1/91h/9yn947D8+8CfdlBeGGAMtqwNd6K7VWAJrw9qwLtw2nDaernh6wKuHPD3S1Vs6vaPT97W9r/Wx1seKUWj7Uzz6vX79T//wF/Gbx/7rw/jsFB/39nlrX7q99LKrp5bJZXAtrqW1uJIncbNOXafBU+o0tZW28got0AJ3KACsE4OfYvmzfvDMb/+4//Td9snD9rfr9vHWnyz9361/1fpNLLde0mt5pTZ7a9pCm32SrqQTfZI3aqNXHAwvcAB4BPwnk/oMEcqX8eaz1t9cHjxs7133f5z6p2v/Ylme9eWmLbexjlhnrPBirz3WxWv30rw0L/Yi96PpDrcDcPMEfq+qvQCfsFF1blcv2js3vb2xLNd9O/XT1p8u/Vlfnvd+25bResXC6BFLj2WJpUdv7uEe0exGByPoOAC//BH+cgNqUjfkU4mOEetde+O2vf+y8br71Nva+9q/XpYXvZ97z9ardUXrra3RerQWrUU4myLk4AzYiADwJ+NRQ41i7MSNEBIcM5YR1+f21rnlXcPWtbVYW1/a7dL21mZvbK211lv01lpEtIi0MxTmFGzMAABAN6gF1CTPxI1gkXa5Z5xGPNrbfo6xB/bQubW9nXvkHtXDPfqIJd2bI+1mpZjmNK17QFuxDzhBJued8Fy0KLvcp7fpNzJuM3JE7daIWGKMqAylW0bLiHQ0e1ppTXEK8Qrwkzv8fUIua6oG553wQpRIme7lbfpBxm3GnoEMZ+wZlYGMlu6pNh1pT3nqALCEugCeAB2ohKqYk9hZd4JFS5ThDm/lB9N305nGtKfnNKZiqk23qZhySZOcYhHFewXfI54UMCBDOYlU3TMkSaYWaCtdwXu5yprOKUxrqk9FyUWXNKXiBfCNgucGboGAUBwUJzFYO3G+MCwFtdAn6K6UZZSyXCXBAUVdGCoS5IVxAcQNujAHKCiLLHJqDtWZh1GHV0Et8EYNqOABTUhglKJoyKBBgSwCBC6Ajz7Azz+GiJbwhFTkZCXnEM6EJcuHDmmlztCkBE2IkMGAAhQoSCBBvgYA0G6xN4DgLE5IU5iqZA1hJ8zDqCY2qktJHfEnZSpIk6bE++kEXwHUEBMCmBBBFzE5UzNZuyBRshlSSF0aEg6MaDHIgyFCPAqvA/YdIjTgQ3WBLNZkpWoQPnRIUljdGiIkHd9jumgeO0ESEI97cNTPJj6Z4ISOZh1JUSVLwiAs7pRp02aTypRUhwIzjvhfPCKF1wH/BTqwA5pQlnYyipgs6dDBQVncZatZaZUlsUxZYVq0jyfm8kNeBzz/Gu0ETrjABAURAoTJOVVJpDAoM3ZOc5olfmMK42CYMrRTAr6tIK6QiSA84VtIIEosslSTNYUkUxyS5aEDQ6tMmQ7YDMOmjziYx8E56oPEl8DdDgM2/BLeIJVw9CRSTClZg97ZrDl0BF6m49V0GTIZQL4CvNuxFj47w4ASmqUkAalYU+DBoIbK8hAG506aZTLonWFG0IMa1AAHXlegW9wFGuAJG97hhFkqiuCxUZyqSSWR5GCZHKxB7nSwDcZADHiACQ4eJ/Oot9+BvsaLQD2Hby9RUEEs1cUlcdKpmWKSQ2VyqAY56J0RiEEPOqHxXYv2W4yJuANWxBkBOKEGFcwyjlhMYdLJSjLJpA8FAxqMwXZRQA0wgdQ94Hcf4nqDFnQhBDcY5YJUIqSSpnxpRqone6ol+2Af7Il2MJJxnN/8lgIA8yWQUKItaBMRsGEdDIrQoYNTnGSyBqdZQSY16IEYaANOOKn/A+htXH+OdgLOiB1BBOEGCz5ejmO6JpGEeexVJTmohJNORqIlnVDyO4CvvsT2AGm0BVEHo0IMHeEooeQipzDFY5eSNcigLgwoGYlIKHF/ky9Z+xD/WrCfoQUuRCGAKBhlwIBRQvmSuykkMYHkqx7EAPK+/wdqEbWmfB0bfwAAAABJRU5ErkJggg==",vz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAABGSklEQVR42u3cx4tb6brvcf0DmmpUoxrUoAY1KCgwFAZjME1jjGmMTWNs2tjY2MY2DjjinHPOOeec3dXOOeecU2VlaSksSc/9aq1X0pJKqmD3Dn3upvnCSe197v38nlfS2fscW1x+kbCMloAsFY/skEY5KbVySb7JXfkoT+WtvJGX8ol/67s8lDr+o065KW65Jl7+q/zyF3/nWTpJx+gQ/7H94pPd/Oe38yduEZds4E9dK/Wykj95GX/OYvkq8/kz58h7mcmfP41/hMnyTCbIIxkn9/nv5raMlOsyTK7IELkgg6RKBshp6ScnpI8ckd5yQHrJHvmd/3578I/QjX+E32SNdOEfobMskV9lAf+vmiOdZIZ0lKnSQSZKe/7kSv7kdjKchkoFf2q59Ke+UsafWCY9pZQ/rZQ/rUS6Umcp5k8q5k8p5k8p4k8p4k8o4u928Hc7+Dsd/F1mpWLn7zArVhWpHOlsRvYC/Yf++t8A/j8fQCxrADvTA/j6vwH8/zGAaOzX/w3g/+cBaJEuEkqMMQbg/t8A2jiA8n/+AHzB7qLFx8K2zBhAA5Q16QE8+98A/q8PwOXvLYHYePEllsO666cGcPR/A/jnDaDRN0C80Ynija8QV2K3GsBlywDe5h3AVYAvAv0X4IUH4P7fAP7bB9DgGyau0BRx6yvFGd8j9YlTUp24LF+g/gDKGwbwAqwnwD1o5QD2/VcPYMT/BmD9q94/Thq0GeKMrpbG2B6pi5+S78kBJAoNoDFrAFU/PICP/+UD6PL/xwDqAlOlNjBH6sMQ6XulJnZavsWvyGcG8D7BABJvsgZwxxiAK2sAZ9ID8P/gAF78QwbQ/v/eAGqDc6Tav1BqtA1SE90v1fpp+Rq7Ip/id+UdA3jNAJ4nPsnjRGYAN0C9whe8C+kB+BmAP2sAu/jPNx1AjRrAlzwDeNqKARz/3wD+7r+qtSXy1QdLcJN8Dx+Qb9Ez8kW/Ih9id+Vt/Jm8sgzgfqL5ARwxBuBjAN70ADbznSE5gDWMJzWARekBvGsygLFy738D+Hf+9T20Sj77VsuXwFb5oh2SL5Gz8lG/Ku8ZwJvYM3kZfyPP4h/lUeIbA6iV24lGuZ5IDcALjQ8aP4+zOYCD/Pt70wNwqQE0WAbwLWcAr/MM4FbOAP78Bw+g6L97AN/CG+Sjb6N89O+Qj9oR+Rg+J++jV+Wtfk9eMYAXsTfyhAE8jH+TuwzgVqLBGMDlhFvOJ7zyZyI5AB8D8EHjyxrAtjYN4EnWAEYYA7j8XzCAXwoMoOJvHsB/aARfwtvkvS/ZHnkfOCbvtCp5G74mb6L35KX+TJ4xgMexj/IgOYB4rdyMN8i1hFMuGQPwyDlGcJoRHE+YAzgA/l7jn1VwqwE0WgZQLUuNAXxmAB+MAcyQVxClBvCQAdxtxQD25x1A1x8ewB9tGEAljO3+7wzgU2SPvPPvlje+A/LGf0LeBP+S16Fr8jJyT55Hn8kT/Y080j/K/dhXuROvYQD1cjWeHIBL/lIDOEXH6TAdoD0JcwBbGcAmBrCeL4Br+AWQO4DZ/MQ0B/C8mQGczxnA4YIDaM0LUNmqAfz2LxmA/b9xAB8iB+VN4IC88h2Rl/5T8jJwXl5o1+V56L48jTyTx9HX8kD/IHf1r3IrViPXY/VyJd4oF+IuqYq75SzYJ0E/ZgzAI/tpD6/DDgaylZdiE9efHMBqYwDfGcBXBvBJ5uUMYJIxgAeWAVyzDODcv2gAA35oAEV5BpAZwT9sAO+iR+VV4Ii88B2X576z8tx/QZ4Fb8gT7b48Dj+Vh5HXcj/6Qe7oX+SmXi3XYnVyOdbAAJwMwCVnGMHJuEeOAn/IGICbAbiMAWzhC+NGvjOs49fD6kSNrFADWGgM4L0awEs1gMeWAdxUA7jUxgGs+Le8AP+nBvAmelJeBE/IM99peeqrkif+S/I4cFMeMYAHoadyP/xK7kTey63oF7muf5creq1c4hU4H2uUczGXnGYEJxjBETpE+4DfbQzAqQZQzwBqZVWiWlbwS2JJ4ossTHxUA3ijBvDMGMB4YwB3ZFTeAZz6FwzA+gL0+jcN4L/sl8BL/Yw8004Df04e+87LI98Veei/JQ+CD+Se9lTuhF7JrfB7uRH5JNei3+SyXiMX9Hqp0hvkbMwppxjBcTrCEA7SXtrF67Ad/C1c/wauf60awHJjAJ8ZwAeZm3gnsxJvZHrihUxNpAZwvxUDOKQGsJsBbP+bB/A7df/JAfzD/mcBz3WuXvtTHvmr5IHvotz3XZN7DOBu4IHcCT6VW9oruRF6J9fCn+RK5KtcjFbL+Wid/MkITuuNcpIRHKPDjGA/8HtoJ98RtvFrYTNfGDeAv5bnf2XiOwP4KosTn2SBMYC3DOCVMYApiacyKfFIxifuy5hEcgA3YLrKAC7KYPlLBjKA/nKSARzLM4DNagCr/4UD6PRvGsB/YARPda5eOy8PAhfknu+y3PVdlzu+O3LL/0BuBp7Kde2lXNPeyZXQR7kU/irnI9+lKlojZxnBKV6B44zgCB3iI2E/7aEd4G8Ff1O8Tjbw03FNvFpW8jNyGc//Yp7/BYn3lgE8ZwBPZKIxgHsM4LaMSlyXEYkrMjTBABJVDOCsMYC+lgH0VAPo/hMDqGhxAJ1bOYCyf+4AHuuX+Ky/yMVfAv6q3PLdlJsM4Ib/oVxnANeCL+WK9lYuaR/kQuiLVIW/yblItZyO1spJRnCMl+AwQzhAe2kXXxB38B1hC18WN4K/HvzV8e8M4KssjX+WRfGPMp/nfw7P/8zES5mWHsADGZe4ywBuGQMYbgzggjmAxBnpn2AAiaPSJ5EcwD4GsAuubWoA6/83gB/964F+Re6Grsjt4FW56b8uN3y35LrvrlzzPZQr/qdyOfBSLgbfyHntvVRpn+Rc6KucCX+Xk5EaOR6plSOM4FC0XvYzhD20U6+TbeBvidXKBn42rot9l1Vc/4r4FwbwiQF8kHnxtzI7/lpmxl8wgGcyOfE4awAjE9cYwGXLAE4zgBMM4AgDOCi9E3ulZ4IBJBhAYpN0S6QGsByyxX/bAEqyBtDxJwbwX/xL4J5+TW6Hr8nN4HW57r8B/G254rsnl32P5BIDuOB/IecDb6Qq+F7OaR/ljPZFToW+yXFGcJQRHGYEB3gN9tJufiHsoK18UdzET8YN4K+JfZOVsa+yPPZJlsQ+yML4OwbwhgG8khnx5zI1/lQmxx/JhPh9BnBHRiduqgFcYgDnGcCfWQP4Iz2AndkDSKySLgkGkGAAifnyS2K2GsCUv2UAxQUH8A//HwbdiV2Xm2HwtRtyNXAL/DtyyXdfLjCA876n8hcDqAq8lnOBd3Im+EFO8QqcYATHGMFhRnAwXC37GcIe2sl3g+18SdwC/kZ+Mq7Xv8lq/SsD+CzLYh9lcey9LIi9lbmx1zIr/lKmx58xgCcyKf6QAdyTsfHbMjp+Q0bGrxoDGMIABiXOqQEcVwM4wAD2qAFsVQNYl38ACQaQYAAJBpBgAIm2DKDrDwzg7/gp+G8ewc3YTbkevilXtZs897flov8u+PfBfyRVDOCc74Wc9b+S04G3cpJX4ETwoxzTPssR7ascYgT7+U6whyHs4svhDtoa/S6b+Lm4Afi1+hdZpX+WFfpHWap/kEWxdzI/9kbmxF7JzNgLmR57KlPijxnAAxkfv8sAbjEAvgDGr8iw+EUZEv9LBsX5CZjgJ6AxgMMMgF8AxgB2SA9jABuNAXRt7QASDCDBABIMIMEAEgwgwQAShQbQ+n9VUNP/WcA/4HvA9RhXH7nFl7xbciFwR84zgCrfA/mTAZzzPZEzvudy2v9STvrfyHFegaO8AkcYwSFGsJ+XYC/fCXbTDoawLfJNtvBTcSOtj36RNdFPshL85eAv0d/JQv2tzNNfyWzwZ8aeybTYE5kceyQTY/dlfOyOjInflFHxawzgMgO4wACqGMBZGRDnJ2D8mPSNH8oZwBY1gLUMYCUDWMYAFlkGML1tA0gwgAQDSDCARKEBFP7nA/6RA7jCAC5FbssFDfwg+P57wD8A/pGcZgAnGcAJ30s57n8tR/1v5XDgvRxiBPsZwV4+DvYwhJ38OthOW8JfZBNtiHyWtZFPsir6UVZEP8jS6DtZBP4C/bXM1V/KLP25zNCfylT9MQN4IBNid2Vc7LaMid2QUTGe/xif/3E+/+N/MoDTagD8AkgOIM4A4rulZ5wBxJMD2JBnAPPyDGAs+KPyDKBf4QEkGECCASQYQIIBJP5d/7OAf+MILvH/8Rcid+Sv0B35kwGcC9zn4h/IKQZwkgEc9z2TY3wMHPG9kkO8AgcZwX5GsJcR7GEEO/liuJ0hbAl9ks20IfxR1tHqyAdZGXkvyyPvZEn0rSyMvpZ50ZcyR+f69WcyHfwp+kOZpN+XCfodGcsQR/N9ZGTsCgO4KENjf8ngGJ//DKB//DgD4BdAnC+A8X0MgF8A8e3mAOIb5Lf4GukaTw5gqWUAsywDmNDGAXQrPIAEA0gwgAQDSDCABANIMIBEqZE9UaIqVhVZcqSzJf5LBnCep7cqeoefd3flrHaPz/r7PPcPuPpH4D+RowzgMK/AIV6BA3wX2M8I9vJ9YDcfBzv5TrCdIWzVPshm2hj6IOtpTei9rAy/kxW0NPJWFkVeywLw50ZfyOzoM5kRfSLT9EcyWX8gE/W7Ml6/LWP1GzKaXyQjYjz/sQsMoIoBnJWBsZPSP8bnf+wwA+ALYHwvA+ALYHwbA9icPYA4A4gvlF/jc+WXeGoAk/+GAfzSigGUtXEAagS5/bsHUMUAzkXv8tv+Lt/w78lJBnCcARxlAEd8j4F/KgcZwH5egX2MYA8j2M0IdjCC7bQ1+E4200btnayntbQq9FZW0rLwG1kSfiULIy9lXuSFzIk8k1ngT48+lqnRBzI5es+4/nH6TRmjX5dR+hUZoV+SYfp5GRLj+Y/x/BsD4PM/xvMf2y+9Y3z+x3YwgK0MgF8AcX4CxlczgBUMYEn2AOLTpGOcAcStAxje4gBK/5MDSGfL9K/86xwDOM0ATjGAEwzgePC+HAk8kMP+R+A/lgO8Avt5BfYygj2MYBcj2MEItvOdYEvgjWymjcE3sp7Wam9kNa2k5aFXsoQWhV/K/PBzmRt+JrMjT2RG5LFMizyUKdH7Mol/3PHRWzI2al7/SP2yDNe5fr1KhujnZJDOAHSe/9gRywB2mwOI8fzH+AIY4ydgfBUDWK4GsEANYGb2AOIMIM4A4gwgzgDihb4E9rAMoMvfMIDiHxxAzghy+7v+Os0ATgJxnAEcYwBHGMAhBnDQ/xD4R1z9Y+CfyG5GsJMR7GAE22gLvww2M4SNgVeyntYGX8lqWqm9kuXaS1lKi7UXsiD0XOaFnsmc8BOZGX4s08MPZWrkvkyO3JWJfPkcF+X6o9dkVJTrj15kAOcZwJ8yWD8jA/WT5gB0nn/9gPyh8/zHdjGA7WoAfAGMrZXfYiula4wBxBYbA/glPqd1A4gzgDgDiDOAOAOIM4A4A4gzgDgDiDOAeGoAnZoZQL7vAcXNvgI/PYC21NxfJ+N35Difw0cZwJHQPb7h35cDDGA/HwN7eQX2MIBdDGAHbWcEW2kLQ9jECDb4X8h6Wht4IatpZfCFLKelwefgP5eF2jOZrz2VOaHHMiv0SGaEHsi08H2Zwj/WJPAnRG7KuMh1GRO5ygAuMYALMizK9UfN6x+on5D++lHpqx9iAFy/vkd66Tulp87nf2yzGsAaYwBdYvwCiPEFMMZPwNgc6RSbwQCmMoBJDGA8AxhjGcCQtg0gzgDiDCDOAOK5A/iZL4L/xhEU6hgDOMIADnORB/kiuF+7L/sYwR5GsJtXYCevwA5GsI22MILNfCfYxAg20Hpa638uq2ll4LksDzyTpbQ4+EwWBp+A/0Tmao9ltvZIZoI/PQQ+/xiTwuCHwQ9fl7Hgj45clpGRCzI8wvVHuf7oGRkU5fqjxxkAz79+kOvfxwB2MwCef53Pf32TdNfXSzedz39jAEvVAPgFEJttDKBjjAHEGECMAcSSAxj59wwgzgDiDCBeYfZPHsARBnCIL2IHGcB+cPbyMbCHAeziy+AOXoHtvgdc/SPwH4H/WDbSBoawjtbQKlrpfyLLaWngiSymhYHHMj/4WOYGH4H/QGYyqun8uVO1uzI5dFsmhm7K+BD44WsyOnxFRoUvygjwh0W4/shZGRzh+qMnGMBR6Rfl+qP7jee/t87zr/P861sYAJ//Op//Op//Ol8AdT7/db4A6skB8AUwxi+AGD8BYxNpnDmA2EhpFxtGDCDGAGL9pTzGAGIMINaaAXTMGUBqBAwgXqZiAPF/0AAOxW/LAQawL3JH9jCA3SDtDN7jW/592ea/L1sZwRZGsMn3EPhHXP0jWUtrGMIqWknLaan/sSzmI2MhzQ88lLm8ILMZ0kyaEbwr07Q7MkW7JZO0mzJBuy7jQtdkTAj80CUZGT4vw8NVMjR8jgGclkERrj/C9Ue4/uhBcwBRnv/oDukZ3coAeP51nn+dz3+dz3+dz3+dz3+dL4A6XwB1BqAzAJ0B6AxAZwD6aKnUrQMY2HQAMQYQYwCx/AMoNgaQ7xXIMwCjYktFmbIG4PjPDmA/A9jH7/A9DGBX+I7sAGo7I9gWuMu3/Ht80bvP1d8H/z5X/wD8B7KaVjKIFbSMlvLvL6aFjGU+zeXvmc3fO4s/Y0bwjkwL3pYpwQz+eO2qjNWuyOgkfuiCjAhVybAQ+OEzMjh8UgaGjzOAI9Ivckj6RsCPcP2RXQyA649y/dGN0j3K8x9drQawjAEsYgDzGQBfAHW+AOp8AdT5AqjzBTA9gBHSTmcA+mCp0AeC38wAYgwgxgBi/BSMtXUApc0PIO5IZzOym/0nRrAnfkv26LdkV/S27OCzeXvojmxlBFuA2wTgBv9dvujdBf8eV3+fq78vK733ZQUt499eQotoIc3nv2Yu/7WzaZb/jswI3JZpgVsyJXBTJgevy8TgNRkfTOJfljHaRRmlga/9JcNDf8rQ0BkZEjolg0I8/eGj0j98WPqFuf7wPgawhwFw/ZFt8ntkMwPYwADWMgCe/yjPf5TP/yjPf5TnPzqb+AKo8/mvT1IDGEujmg5AZwA6A9AZgJ4aQPecAfxqDiDGAGIMIMYAYgwg1poBlLRtAAWzFe5nB7ArflN2MoAd/B7fFr4lW/iM3qzd5rf9HdkQuAP+Hb7o3eHq73L1Zsu9d2UpLaFF/PsLaL7vjsyl2b7b4N+SGTTNfxP8GzI5AH4giX9FxgUvyZhgEv+8jNSqZLj2pwzTzsoQ7bQMDnH9oWMyIMT1h7j+8H4GAH6Y6w9vZwBbGABf/iJcf4Rv/xGuP8LzH+H5j/L8R3n+ozz/0enEAKIMIDo+ZwBDCw9AZwA6A9AZgN6KAcQYQIwBxMpVDCBWavT3DqCFEfzMQHYwgO36TdnK7/EtDGBT6JZs4LN6A0/2Oq53DVe8yn8b+Ns8+be5+js8+Xdksfe2LKQFNM93C/xb4N+Smb6bMoOm+a/LFJrsvyYT/VdkQuCyjAuAH7ggo4PgB6tkRPCcgT80ia+dlEEaT792RPqD3y8Efmiv/BHazQC4/jCf/WGuP8z1h9dJtzDPf2QFA1jKAHj+Izz/EZ7/yExjAB2jU2iiOYAoXwCjDCA63DIAfgHo/ahP4QHoDEBnADoD0Ns4gFiJqlhVZCl3AI5/3QBaalv8hmzRb8jm6A3ZyO/yDXxDX89n9VpaHbwpq3i+V3LNy2kZwEtoMS303pT5NI/m0GzvDfCvy3Sa5rsmU2iy74qJ778k4/wXZWwSPwB+APzAORkePCNDg6dlSNDEH5jE18DXDkhfbZ/00bj+0E7pFeL6Q1x/aKP0CK1nAFx/mOsPc/3hJbRQOofnMQCe/wjPf4TP/wif/5EJDIDP/yif/9GR5gCifAGM8gsgah1A79YNQGcAOgPQGYDOAHQGoLd2AHlGoLIZ2bP7dw1gS/y6bNKvy4YoRa7LOn6br9FuyGpaGbwhK3jCl/tv8C3/BvA3ePJv8OTfAP+6zKU5NItmeq/JdJrmuwr+FfAvy0TfJZnguwj+BRnrPy+j/VUyyv+niR8AP3BKhgROyOAg+MEjMiB4iAFk8P/QdklvbYf00rh+jevXuP4Q1x/i+kMMIMSXvxDPf5jnP8zzH55FPP9hnv/IJHMAEZ7/CAOIjGAAw7IHEGUAUQYQZQDRnj8+AL1cxQD0UiO7/pMDyJvN7O8cwMb4NdmgX5P10WuyNnJN1vDbfBW/0VfybX0FX9yW8fm9hBbznC/kqhfQPJpLswGf5b0qM7xXwL8iU2mK95JMoonAj/ddkHG+8zLW95eM9iXxz8kI/1kZ7j8tw/wnTfzAMRkUAD8AfvCg9Avul75B8IMZ/J4a169x/RrXr62RbtpK+U1bzgC4/hDXH+L6Qzz/YZ7/8DTi+Q/z/Id5/iNjaJQxgHYRBhBhABF+Akb6Nx1AlAFEGUCUAUQZQJQBRFszgArLAMoyAzAqtlRklncAjtYPoFA/MoAN8auyLnZV1uhXZXXkqqwMX5UVoauynJ9qS/nGvoQWBa7yE+8qP/Gugn9F5tBsmgn4DO9lmQb4VJrivQj+BZlI473nZZz3L/CrwP9TRvnA952R4T6F7z8ug/3g+4/IwCR+4ID0C4Af2CN9ArsYAPjBbdIzCH4Q/CDXr/HNX1sFPp/9Gp/9Gtevcf2hucTzH+L5D3H9ockMgOsP8/yH+fwP8/yHef7DfP5HBmcGEOlLfP5HGECEAUR6GAMoif6WPYAoA4gygCgDiLZ1ACVNB2DkSGfT/6YBtKXUANbGr8ia2BVZpV+RlZErsiJ8RZaFrshSfqcvpkV8c18QuAL+ZX7iXQb/ksyimTQd9GmgTwV8Mk0CfQKN91aBXyVjvH/KaO85GeU9A/5p8E/KMN8JGeoD33fUxPcfkgF+8P3g+8H3gx/YIb0D26RXYIv0DGyS3wMbGMBa6R5cLd2CyetfxgC4fo3r17h+jevXZhLPf4jrD/H8h8YTz39otGUAQ4jnP8zzH2YAYQYQTg6gV2YAEQYQYQARBhApMIAoA4gygCgDiFaYNRlAaQsDyDMC3d60f+UIkq2OX5KVMdIvyfLoJVkaviRLQpdkkXZJFtJ8frbN49v7XJrNF7lZPO0zeNqn0zTQpwA+mSZy7RNAHw/6ONDH0GjgR3lPywjvKRnuBd97HPxj4B+RQb7DMtAHvu+A9Pftk74+he8H3w++H3y/wg+sk+4B8APgB3n6g1x/kG/+wQUMgOvXuH6N69f48qdx/RrPv8bzr/H8h3j+Q3z+h3j+Qzz/IQYQSg6A5z/M858cQJgBhHn+wwwg3M0ygM5SHGEAEQYQYQARBhApMIAoA4iWqcCP/k0DaJItu58dwMr4RVkRuyjL9IuyNHpRFkcuyqLQRVmgXZD5NDd4Qebw7X02zeSL3Ayaxuf6VD7Xp4A+CfSJNAH48aCP9Z4F/wz4p2Uk8COAH+49YeJ7j8pgL/jeQzLQe1AGePcb+P3A7+sD3we+D3wf+D7w/eD7wfevMfEDK2ipdA0sli4B8INcf5DrD3L9Qa5f4/o1rl/j+dd4/rXRxPVrXL/G86/x/Id4/kNcf4gBhBhAiOc/xC8A6wDCDCDchRhAOM8AIgwgwgAiDCDSzACiJapiS3/zAFpboQEsj1+QZbELskS/IIujF2Rh5IIsCJ+XeaHzMlc7L7P5zT6LZgb+kun+v/h9XwV+Fd/y/5RJNBH0JPw44MeCPoZGeU7JSM9JGeE5IcM9x2WY55gM8RwB/7DCP2Die/dKPy/43l3Sx7tD/vBuk97eLQxgEwPYIL/71ksP3xoGsEq6+cH38/T7efoDPP2B+TRHfg3wzT/A9QenEtcf5PqDPP9Bnn+N69e4fo3r14aYA9AYgMYANJ7/0B9qADz/IQYQ4gtgiAGEcgYQZgBhBhBmAOE8AzBiAJEyVakaQYEBpHOks/07RpCvpfHzsjh2Xhbp52VB9LzMj/wl88J/yZzQXzJbq5KZNCNYJdP57T6Vn3BT+CY/mS90k2iC7yz4Z8A/beCP5tpHAT8S+BHADwd+GPBDPIdlsOeQDPIclIGe/TLAs0/6e/ZIP89u6evZKX08Fnwv+F7wvQrfB76P6/cpfP8iAt/P0++fbeD/EuCbf4DrD0wirj/I9Qd5/oMMIMgAguYAKjSef43nX+tnDkBjABrPv8YAtB6WAfD8hxhAiAGEGEAoZwBhBhBmAGEGEC4wALJHSlTFZs0NIJ29af/KASyOV8nCWJUs0KtkXrRK5kaqZE64SmaF/gT/T5mhnZNpwXMyld/uUwJnZZL/DD/xzoB/mp95SfhTXP1J8E+Afxz84+Cb8EMN/EPgHwT/gMLfq/B3gb8D/O3yh2er9PaA7wHfo/C94HvB9ybxl9MS6eoD38fT75tn4P/q5+n38/T7uX4/1+/n+gPjCPwA+AGe/wDPf5DnP8j1B7n+INcfTA6A51/rrQbwuzkAjQFoXL/GALScAYQ6SVGIAYQYQChnAEYMIFymKjAAoyJLjjwjsLciW3Y/M4CF8T9lfuxPmaefkznRczI7ck5mhc/JjNA5ma6dlWk0JXhGJgdOyySayG/48f5T/L4/yU+8k+CfAP84X/aOAX+Uqz+i8A8p/AMyyL1fBrr3yQD3Hunv3i393Dulrxt8N/hu8N0WfM866eEB32Pid/OC7+Vz3wu+18Tv7OPp9/H0+7h+H9fvM/E7+nn6/Tz9fj77/Ul8rj/A9Qd4/gNcf2CAGgDXH2QAQQYQtA6A67cOQGMAGvga15/GVwMIMYAQAwhVmOUOgOzhElWxWZMBqBGobEb27FozgNZUaADz4udkbuyszNHPyqzoWZkZOSMzwmdkeui0TNVOyxSaHDwlEwOnZELgJPgnZZz/BPjHZYzPhB/Jl7sRfLkbzlM/DHQT/4AMBn4Q8AOBN/F3gb9D4W8Dfwv4m6WXe6P0dIPvBt9t4nf3gO8B3wO+hy99ngUMAHwv+F7wveB7k/g8/T6efh9Pv4/r93H9fq7fD76f6/dz/X6uPzDQGEB5gOsPMIDAH2oAPP9BBhDk+oMMIJgaQBL/18wANAagga+1V+UMIMQAQmWqUqMmAzAqyslhlh5AnhHkzWYW/cnmxk/L7NhpmaWflpnR0zI9clqmhU/J1NAp8E/KJJoYPCkTgidkfOA4+MD7j8lofseP4ufcSOBH8OVuOOjDeOqHAj+Ep34w8IPcexX+bvB3Sj8X+K7t0se1Vf5wge/aJL1cG8BfD/5aA7+HG3w3+G7w3SZ+V89CBsDnvofPfQ9Pv4en38vT7+Xp93L9Xp5+L9fv4/p9XL+P6/cNJ67fz/X7uX4/A/Bz/f4kPtcfAD/A9QcYQKCHZQDgB7n+IAMIMoBgMwPQGIBWoWIAWs4AQiWqYksFBkC2dPbsmhtAS7U0gNnxUzIzdkpm6KdkevSkTIuclCnhkzI5dEIm0UTtuIwPAh88JmMDx8A/KqP9R0x8fseP4Fv9MK8F3pMfvh/wfV3bwN8C/mbwN5r4LvBd4LtW00rp7loB/jLw+cx3g+8G3w2+ey4pfM90At8DvoenP4nvHUtcv5fr944w8X1cv4/r94Hv4/n39zMH4Of6/QzA35N+NwcQYAABrj/AAAI5AwgygCADCDKAYAq/wACMSo3sWolZ1giKcnKks4UKDCBvNrPITzYzflJmxIDXT8jU6AmZEjkuk8PHZSJNCB2T8doxGacdlbHBIzImALz/sIz0Aw/+cN9B8A/w+34/+PvA38uXvT3g7wZ/F/g71NVvM67exN9kwV8H/ppsfBf4riW0SLq6ePZdFnw3+G7w3eC7JzMAnn4PT7+Hp98DvmcUA+D6vVy/F3wv1+8dpAbA9fsYgK8PMQBfL2MApckB+MH3c/1+BuBXAwgwgAADCDCAAAMIWAYQrFQxgGCFWXMDMCpWFWWXOwAje/7yDaClWhrA9PhxmRY7LlN14PVjMil6TCZGjsqE8FEZHzoiYzXgtcMyOnhIRgUOgX9QRvgPgL9fhtFQ7z4Zwu/5wcAP4mfdQOAHAG/ibwN/a/rq/wC+N/C9uPqeXL2Jv0rhL8+DP4/Ad4Hvmkngu5L4Uwh89wQC383T7+Hp94Dv4fo9XL8HfA/X7wXfy/V7wfdy/d4kfm9zAD7wfVy/jwH4UgMA3w++H3w/+H4T3xhAgAEEGEAA/EA7I3MA5aoyVamRPZhvALkjcKSzpbMXHkE6W3bhH2xq/JhMiR0F/6hM0o/IxOgRGR85IuPCh2Vs6BD4h2Q0jQoelJGBA+Dvl+H+JP4+GerbA/4eGezdDf4ufubtUPjbwd8K/hbwN6ur36Dw10lPJ/hOrt650qi7M4m/FPjFOfhzmuK7wHeB7wLfNd7A7+AG3831u8F3D6OhBn47D9fvAd/D9XuS+H3MAXjB9/L8exmAt4eBX+oD38f1+xiAjwH4LAPwg+/voMoZQIABBMpVZWbWAaQrttSKARSquRE0V6EBTIkfkUkx4MGfoB+W8dFDMi5ySMaGwQ8dBP+AjNT2y4gg8IF9Msy/V4b6gQd/sA94r4I38LeDv5Vv+lsU/qb01fd2rpdewPd0rgF/lcJfAf4y6eYE3wm+c6F0dYLvBN8JvhN8Zwb/l1x8F/gunn4X+C7wXcNNfDfX7wbfzfW7+zOAfuYAPOB7uH4PA/AofC/X7+X6vQzAywC8DMCrBuBjAD4G4GMAPvB97c0B+BmAH3wjBuAvN0sNIFBqZA+UWMoZQDpHOluwFQPIyta0UBubFD8kE2OHwD8k42ls9KCMiRyQ0eH9Miq038TX9snw4F4ZFthj4vt3g79TBvl2yEBvEh94zzYD3sTfDP5G8JNXn4RfR2vAXw3+SoW/XOHz5DsXKfz5FvxZJr4TfCf4TvCd4Dsn5sEfaeK7ePpd4Lu4flcSf4AxgHI3+G6u380A3En8nuYAPAzAwwA84HvA9yh8L/he8L2dVJYB+CpV4PsqzFID8JepwDcqMUsNIF2RJUfTERjZm9aaAbQm6wAmxA/K+NhBGacfkLH6fhkT3S+jI+CH98nI0F7w98hwGhbcLUMDu8DfKYP9OxT+dhng3QY+8NSX3/R9+U3fB3gTf526+tW0SuGbV9+dq+/WyNU3gt+4QLo2gt84l8BvBL9xBmXjd0riO8F3gu8E3wm+cyQDMPErXUMVPtfvAt/F9bu4fhf4riR+b3MAbvDd4LvBd3P9bssAPAzAwwA8DMCj8I0YgJcBeCtVDMCrBuArV5WpwPdZBmBUbKnILDUAS7Z0drNgc9my+5ExjI/vl3Gx/Sa+vk9GR/fKqAjwYeBDwGvAa8AHd8qQwA4T379dBvq2gb9F+nuT+En4TdLHvUHhrwd/bfrqewL/u+XquzcuUfgLFf48hT87G78R/EbwG8FvBL9xPPGlr3EMAxht4jt5+p3gO8F3gu9M4g+04PdVAwDfBb6L63cxABcDcCUHAL4bfDf47s5GxW4G4FYD8IDv6aBiAB7wPe0yAzAqV5Wp1AB8Jari7FIDMHJkZUuVGkCz2ZqOoLnyDWBcfJ+Mie2V0Trw+h4ZGd0jIyK7ZXh4twwL7QIfeA34IPAB4P1bZYB/iwzwJfE3Sz/vJunr2Wjg/+FeD/468NfwZS9z9b9z9T0M+KUKf5HCn6/w5yj8mQp/msKfrPAnZOM3gt8IfiP4jeA3JvGHGPjtnOA7uX4n+E7wneA7uX5nHnwX1+9iAC4G4GIALvBdCt/dScUA3OC726vMATiMwPeUq8pUpeYAjEpUxZl8RTk5skoPwG8vnHUALdXSKMbE98jo2B4TX98tI6K7ZHhkpwwL75ChoR3gb5fB2jYZFNwqAwNbDPz+/s3S37cJ/I3gc/Ue4N3rjKvvDXwvftr1VPC/c/U9LFffTV29ic/VN4DfMEs6N4DfMJ3AbwC/AfwG8BvAbwC/gWe/AfwGK/5wE78R/EauvxH8RvAbuf5G8BtT+L3NATgZgJMBOMF38s3facW3DMDFAFzguzoaFbkYgEvhG4HvrlCVqywDILtRicoyAG9RTg6z1ADS2ZuWdxC2pgXa0Oj4bhkV2wX+Lhmh75Th0R0yLAJ+eLsMCW0Df6sM0rbIwCD4AeD9wPuA922Qvt714K+TPzzAu9cY8L34Td/Tlbn6Hs7k1S82rr6b5eq7NiTxZyv8GRb8KQp/Yn78BvAbwG8Av2Eogd8AfgP4DeA3JPG5fmMAfxD4jeA3gt8IfiPX32gOoCQ5ACcDcILvBN8JvvMXMzWANL5RpYoBuCpU5WbJARiVGtndJZmSA0hXlJMjMwKypbNn8jWXLZO/DaUGMDK+U0bEdshwHXgaGgU+Anx4qwwObTHxtc0yILhJ+gc2Sj//BgO/j2+d9PGuBX8N+Fy9e6XC5+pdyw34HnzD7+40r76b5eq7GlefxJ9pwZ+ajV8Pfj349eDXg18Pfj349SMYQC7+oAx+A/gN4Ddw/Q3gN4DfAH6DBb+R628EvxH8RvAbOxsVN6YGAL6zo1GRkwE426vAd7bLPwBXmarUyO6yDMBdbKkou+QALNnS2c28LWXLHkFL5Q5hRBz82Hbwt8lQGhIFPgJ8GPjQZvA3yQBto/QPbpB+AfD9wPuA966h1dLbs8rAT8L3BP531zKFvxj8RQp/PvjzFL559Sa+efW/1oNfD349T359Cn+cBX9UBr8e/Hrw68GvB7+ez/168OvBrwe/Hvx68Ot5+uutAwDfiAE0cP0NDKCBATQwgAaF3/iLigE0gt/YQQV+Y6UZA3AYge8sV5VlDcCeGkC6YktFZukROLKypbNnRtBcyQG0pkKDGB7fJsNiW8HfIkNocBT8CPBh4EPAaxtM/OB66RtYK338wPtWg78KfK6eerqXg78MfOBdSwz47vyu7+Y0r/63JDxf9LpannwDvz6Jn4SfbMEf3zJ+Hfh14Ncl8Qem8Sss+OVJ/Hrw68Gv5/rrwa8Hv57rrwe/Hvx6E98YQAMDaAC/AfyGjkZFDeA3tDczBtDOyNFYoSo3Sw7AqNTIblSSKd8A0jmysqVKDqCljBHYWq65YQyLb5GhsST+ZhlMg6KbZGBkowwIAx8CXlsP/joTPwC8H3jfSuntTeKvMPB/dy8Ffwn4XL0rib8AfPPqM/iz0k++iT/Vgm9evYFfB34d+HWjCfw68OvAr+Pbfl0Ofh34deDXgV8Hfh34deDXgV8Hfh34deDXgV8Hfp0VXw2gHvx68Ot/UTGAevDrO5gZA6hUtTNyNFSo1AAay1SlRnajkkzOYktFORUYgMvefOkh2JqvpXEMjW+WIbFN4G+SQfpGGRjdIAMi4IeBDwGvrZW+wTXgrwIfeOrlWyG9vFy9Z5nCXww+8K6FGXznXPCB5+ediW/Cd1ZP/q/qyU/j14034DvWjcnBH94Uvxb8WvBrwa8Fvxb8WvBrwa8FvzaDX2bFp5I6BlAHfh34dVx/HfhG4NeBX9fRqKguOYD2qkoV+PUVqnJzAA1llkqN7A0lmRqLcyrKLjkAS7Z09kzNjsFWOHcrGhLfKINjG8HfIANpQHS99I+sk35h4EPAa6ulTxD8QBIfeN9yWiY9vcB7uHp3Eh94F/Cu+eDPU/jANwLPb/sMvgn/q3ryDfy6JP64PPhcfS34teDXgl8Lfm0r8WvBrwW/FnwjBlDLAGrBrwW/FvzazkbFteDXgl/bySyFbwR+XaWqnZGjzjIAozJVqZHdqMTMGEFxTkXZNTrS2bKyZ3I2l83M9YMNjm+QQbEk/noZoK+T/tG14K8BH3htFa2UP4LgB8D3A+9bCv4S8IH3LGIAKfx5BLxzDqXwZ4BvXn02/kQyrz4bf5R0qOXqa5viV6bwa/jCVwN+Dfg14NeAXwN+TW8Cv6aniqe/Bvwa8GvArwG/BvyaLioGUAN+zS9mxgA6GhXVgl/bXlWpAr9WDcCoXFWmKjWyG5WYGUMotlTUtAZHOltW9kyNzWUzc7ay3AEMiq+XgbF14K+V/voa6RdZLX3DwIeAT+JrK6R3kKsPgO8H37dYfvcC71kI/gLw51vwgXfOAn9mDr4J/6u6+mz8McTV1xbArwG/Bvyaga3A79UCftcc/NQAOqnAr+mgAr+mUtXOyFFboSpXlVkqNbIblWRGUFdsqahp9Y50tqzsmRqay2bW2MpyBzEwvlYGxNaAv1r6RVdJ38hK6RMGPrQC/OXSW1smvYLAB5YwAPB94HsXMID50t1twndzcfUuhe8EvnE6mVffFN+E76SuvmNtHvyaYWn4yppB2fjV4Ff3JfCrwa/ubVRWDX41+NU8/dXgV4NfDX71b0Yl1eBXg1/d2ai4Gvxq8Ks7qbj+auCN2qsqzZL4RhWqclWZqtTIblRilhxBbXFORU2rc6SzZWXPVN9ctkwNrcw6iAHx1dI/tkr66SulbxT8CPDh5QxgGfhLpZcGfHAxA1gkv/u5eh9X7wXfA77bhP/NlYSfmQcf+IZJ4JtX3zy+Cd++ZmhT/Grwq1vA/w7+d/C/g/8d/O/dVOB/B/87+N87q8D//osK/O8djYq+d1BZ8KvbGTmqK1TllspUpUZ2o5LMCGqKcyrKCfjaTLas7NnVFcqWXX0rS42hfxz8GPgMoE8U/AhXHwY/lMH/PbAQfK7eB7x3HvhzTXy3wnfNAB945zTwgW/k6hX+L03wzSe/o4LvYLn6LPxq8KtN/HZW/O/gfwf/e2+jsu/N4H8D/xv437qowP8G/rdfVJ1UOfhGlSrwjSpU5aoyS6VG9u8lZtWpii0V5clhjkBlS2dvWm2hbE2ra2XJIfSLgx9bIX10rj4KfGQpA1givUJcvcbVB8EPgO8H3we+d4508wDvngX+TBPfZeJ3dqbwufoG4BsUfL159Xnxa3Lwq/Pgfwf/ewH8b+B/A/8b+N/A/9ZNVQj/1yb4xd+AN2qvqlS1M3J8q1CVWypTlRrZjUrMjCEU51SUJ4c5ApUtnT1/+YZRY8tfbSvrG18ufWLL5A8d+OgSBrBYeoUXSc8Q8NoCBjBfegSA989lAOB7wfeA755pwHd1cfVJeOcU8Ln6xjz49T+I/z0P/jfwvyXh8+HTV/C/gv+1qwr8r+B/Bd4I/K+dVB2Nir52UIH/tVLVzsjxtcJSuarMUqmR3agkM4JvxTkV5clhxhBsWdmbL2sYtsLVtKI+cfBj4OvgR8GPgB8GPwS+Bn4Q/MAcBjBbuvmA985kAFy9W+G7FL5T4Tcq/AYFX6/g+YnXUcF3sDz57S3wlQY8fc/B/wb+tzz4X8H/Cv7X7ioTvzSF/wX8L51V4H/5RQX+l45GRV86qNqrKlXtjBxfKlTllspUpUZ2oxJzAOmKcyrKyZGV7Zs1e8ulB2FrueZG8kcc+NhiBrBIekUXSs8I8OH5DGCe9NC4+iD4AfD9VnwTvosLeNdk8E34XxuT8OPz49e1Al/Bp/G/5cH/miwP/hfwv4D/JQnfEr4awGfgjdqrKlXtjByfKyyVq8oslRrZjUrMERgV51SUJ0dWtmRfU9lb3zdb68s3jj/i4MfA18GPgh8BP6zwNfCDs8AH3jeDAXD1HvDdOfhOhd+Yg1//I/hJ+Bz8r+Cn4RX+F/C/dFdZ8D8nA/9zZxX4n4H/lKyTqqNR0SfwP7VXVaraGTmMKlTlqjJLpUZ2o5KcinMqyu5zMkdWNmtf7G3IZva1jaVG0Tu+UHrFFkhPHfjoPAYwV3qEgddmE/gB8P3g+8D3gu8B353En0TAOycQ8I3jwAe+YQz4wNeb8B3rTPgOtcNaid83g/81g1+ewv9i4pel8D+D/xn8JPynZOB/6qwC36gA/sdk7VWVqnZGjo8VqnJLZZZKjexGJZaK81TUtE+OrGzp7K3rcypb0760oV5x8GPzGQD4UfAj4IcUfhD8wHQGME26+oD3TgGfq3crfJcFv7EAfp3CrzXh2xs/8fLgW66+Cf6XJHwO/meF/wn8T3nwPwJvBP7HTqqORia8Bf9DpaqdkeNDhaVyVZmlUiO7UUlOxTkV5cmR6SPoWdnbGIiffrDkWHrGwY+Br4MfBT4yiwHMlG4aVx8EPwC+H3wf+J48+E4LfoPCr28O34QviG/A5+L/bvYZ/CT8p2Q5+B+7qEz8kjS+GsCHjirgjdqrcvDfJ6tQlVsqs1RqZDcqyak4p6I8ObKypfqQzN7GbE372IZ6xufK77E50kMHPwp+GPwQ+Br4QfAD4PvB94LvmcgAgHeNJ+CdY8EHvnE0+MA3jGwVfuonXrP4Xyz4nxX+pxz8j0n4HPwPvxoVf/hFlYP/Pll7VaWldkZp/HfllsoslRrZjUpyKs6pqECOrGxZ2TO9b022lvvQTL/HwY/NZgDgR8EPgx8CXwM/OIUBTOb6uXov+B7w3QrfBb5T4Tem8EcQ8HXDaKiJX6vwa3Lx++XB750f/1MKv5vZxxz8D8ny4L/vpAL/fQ7+u2SVqnZGjncVlhT+2zJLpensRiWWivNUlCdHVrYm2Qv3Ll+2Hys1jh5x8GPg6+BHpzOAaQxgqnTVwA+C7wffB743D77Tgt+Qiw987eBm8NWXva8W/C8WfAM+B/9jBr/0Q1cFb8F/D/77X1QW/Hd87r/roLLgv03WzsjxtsJSuSXg36QqNbIbleRUnFNRgRxZ2bKy/0A2s7c/WI/4TOkemyHddPAj4IfBD4GvgR8A3w++D3wP+G6F77LgN1rw63PxB6XxK1vE75WD3yOD/9GC/yEH/31nAz4L/10nVUcV8G+TtVdl4xe9YQBvKlTllpriO16Db1Riqbhpr4oK5MjKlpW9cK8LZWu5N83UPT6DAYCvgx8BPwx+CHxtEgMA3w++F3wP8O4x4APvGsUARmbwGyz4dQq/NolvwjfF75Mf/3MO/kcL/gcL/vsuKgv+u19UCv9tR5UF/02ySlW7dAb861TlZq/Kcio1shuV5FSc3ctkRXlyZGVrkr2N2bJ79QN1j4MfA1+fygDADyv8IPgB4P3jGAD4HvDdFnwn8I3DwR9m4tfnwa9J4vc3/gkdA/975vO+IufLnoH/KQ/+Bwv++xz8d78apfHfdlJZ8N90UPAK/3WqdkaOVxWWyi0p+JfJSo3sRiU5FWf3IllRgRxZ2bKy/0C2H8s6mm5x8GPg6+BHwA+Dr02QzsHxDAB8H/heC77Lgt8IfMPQDH5dK/C/tYD/sRX473Lw31rw33RUWfBftzfRX6VqZ5SGf5ms3FKZJfBfmNmNSnIqzu55sqI8OZpky8r+A9l+vm5x8GPg65MZAPgh8DXwg+AHxjIA8L2jGYCJ38kFvtOKD3z94Ax+rcKvSeL3y4Pfuxn87k3x31vw31nw3/6q4BX+mxz81x1M+FftLfD0sp2RiW7Bf5GqzJIF/3mykpyKm/asqECOrGxNsv9Atp/vtzj4MfCjE6VLBPwQ+Br4QfD94PvA94DvVvgu8J3gN4LfkMIfZNQEv7pvC/i/N8VPX70FPw3f2YA3U/hvLPivkwH/qoOCV72sVJn4RS8YwIsKlQX/eVlOpUYG/rOSPBVn97SoQKA/yc6Wlf0Hs/18v8XB17n86AQGAH4IfA38IPh+8L3ge8B358FvAL/egl+bB//7D+C/z4P/Ngf/jQU/Cf8qmQX/ZSqF/6JdujT+82TllkB/lqo0nf2ZGsBTa4A/ya0of48dWdmaZG97j5LZfr6u8UkMAPwo+JFxDAB8DfwA+H7wveB7FL4LfCf4jUMYgMKvB77Ogl+Twu+Tg9+rbfjvCuC/seC/7qTgTfzilx0s8PSiUqXwn7dT6Kpn5ZYs+E9L09mfJCvJSYE/tlaUv0eOJtmaZM/fw+aytb0Heeoa5+nXwY+CHwE/NIYBgB8A3w++F3y3wneB7wS/EfyGHPxaC361Bf/bT+C/teC/seAb8Bb8lxb8F6kU/vN26Uz0VBb8p2VmT5KVpjPwH5fkSaE/slaUv4eOrGzJHlizt637qWx/T13iE9QAwA+DHwJfG8UAwPeNYADgu4cxgBz8BuDrga+z4NdY8L9b8L/+BP4bC/7rXxS8wn9pwX9hwX9eqVL4z9pZ4OlpudmTcoVu6XFpOvtjNYBH1izoD1MVmT3IzdEk2/3c7M13r1C27O7+YF3i4OtcfxT8MPgh8IPgB8D3ge8B3w2+C3wn+I0mfvsUfh34tRb86gx+hRX/S/Zv/Dbhv87Bf2nBf5HEVwN4bsF/VmnAmyXR6UmFQrfgP7YG/CMzu5FCf5gK7Ae5WcDv5+bI7h7gWQF5t43dSWX7e+oSB1/n+o0BgK+BHwTfD74PfI/Cd4HvBL8R/IYB6vot+DU5+N9y8D9n45dZ8d8p/LcK/00O/qs8+C8s+M8t+M8s+E+TpeAV/mNrCv5RWRrewH9YaoI/yA3w+7lZwO9Zuutoks3aHYcFs4Vu58tmdusn6xwHXwc/yvUbAwA/CL4ffC/4HhO/gwt8J/iNwBsD6M8AwK818c3rB/+7Bf+riV+ehd8tD34XKW0J/6XCf2HBf67wn7XPwD+tNOGfJFPwj1Mp+EflCl0FuNED4I0U+H1rFvR7qZLQBQI4N1uq26ksoLda2c1kth/vRk6d4+Dr4EfBD3P9xgDA9w9lAOC7W8Cv7aOu34L/LQ/+pzz47wvgv6ZXzeA/z4P/VPWkXboMfIVCt+A/VD0oM+CN7oNvZIG/V2Ji381XEjpfgN+2dAvsJllBW9ENawrv+k90TfVrfDQDAD8Kfhh8jetXA+igBtBeDaDSGAD49eDX5eBXg/89B//LT+K/VPgv8uA/U/hpeAv+Ywv+Iwv+w3ILuup+aToD/55Cv5vKAn7HmsK+rbplzZHpJth5y0Wl663omj2D15quttCvcfD1kQwA/PBwBgB+AHwf+F7w3eC7uH4n+I3gN4BfD35dH2MAFTU5+N/A/6rwP1vwP7YevyQf/nMTv/hZDv4TC/5jhf+oItNDBf+g3IKeSuHfA/5uqQWd7qSyoN9W3Spq2s1UjuxugJ3qeqpCsM10NZUF70obulwgcwDgR8APga/x9AfA9/H0exS+C3yniV+ZD7+6lxpAHvxP/wL8p+0t8JVp+KJHyVLwFRb48hz4MgPdcdcsjX8npzR4blZw1Y0iA9voeiabtWupCuGqrjRXHsRLbehiTr/ER6YH0DEEvgZ+AHwf+B4LfiP4DX0t1w9+TR78rz3Mf+Wugd89g/8h81Ov9F0L+C8U/vOOaXgD/2kO/uNKC7zCT8I/qMjA3y+3oKvuZvAdd0ot4KpbJdngN61Zwem6NQV/LVMa/WqqFoAvW7qUr2YwL7Sh86pf4uDrXH9kmGUAgxgA+J4BDAB8Zz9jAO2MAYBfB34t+DW9jAGUfwf/2++W6+9uefpbif8yH37HbPwn7S3wOfhp+AoLvMpAT2Wip7LfLrWgW/Bv5nSjOA84XUtlgb9qZruSpxaBVRctXbDWDGZz/ZWnKmMA4OvgR8APgR/k+v1cv5cBuLl+NYB2jbn4vbPxv6Wuv7vl6c/+Z/XMp/9n8Ntn8NPw9MCCnwVfboEvy4J3JOFvlWbQb1pLgdP1VLngqqsqcHOzXVZdStVaZEvnrbWAWtWK/sypkzEA8CNDGAD4QfD94HvBd4Pv4vqd4DeAXw9+XW/L9YP/PQf/cw7+hxz8t23Af9rBAq/wHxXAv1+RA2/Bv6O6bcI7blnwrfA3SnLQ6VqqXHBrgF9WXTKzWbuYqjXIlv6yVGVvPeq5FjprqVN8WHoAHYwBgO/n6feC7wbfBX4j+A1/WAYAfg346QGA/7W7un6F/zEXv0vr8J+1At+AV/j3LaXhyzPoBnyZgZ7KfrM0B52ul+RBVzUBp8uqS47sLlrAL1hrBXRVgf5M1QbYZGdyOp2nTnHwda4/An6I61cDqPRYrl8NoKI+P37m+rsZA8jCf9/F8rmf/YWvJI3fqQl+cSvwi9LwFRl4K74Bb8G/aZaGv24pC1x1pbgp+iVrJrjRhUwG+HlrhS66APS5fP0AbqpTOZ20ZA4A/Ahf/DTwg1y/D3yPun4n+I3J6we/rpcxgHJjAOB/72G5/m6W6++qBtCl6Ze+tuI/UvgPKxU83W9n4hvwFvw75TnwZVnwjhvgJ8uCT2VFV13Og35RdaEoC91+3iyN/pelghddAPus6oyl1uCebKYTOR1XdYwPSQ+gfXIAAfB94HvAd4HvBL+ht3n9xgDAr8mDb1x/U/yCn/vN4T9uI/4dVRZ8WRa843oSvjQHna6WZMNfVl0qLoBuwT9v6S8zW1VOzWGfzYN9Ok+tQc6Hm69jOXWMg69z/WHwtQF5B1BhDAD8OoWvrr/sW3fL9Vs+9z90UQNoBf7zVuLfV6XhKzLwufg3y7Lg0/i58FdKsuEvWcqHfj5VNrq9yswEV51L1VZs1UlrbUC24h7N6UiesgcAfgB8H/hu8F1cfyP4DeDX98xcfzXX/727GkDy+n+zXH8e/Dd5vvQ1we/QFP9BK/Bv061yC3xZFryBf63Ucu0p+JKca0/BFxdAp79UVY7sssBVZx0/iK06oTpubz3ykQIdtnQop45x8HXwwwMyA/BmBlCRGkDy+mvBr+lhuX7wv/xmDCD99BsDsPwrePN97reE/7AZ/DsVGfi8+GUZ/GtmTeFLsuEvpuCLm0FPZYIbncuURj+j+mHsnFoL3RxyqoOWDqg6pAfQnwGAH+jLAMB3c/1O8BvN6y+v+90cQPr6u6UHkPzf0W96/Zl/Tj/7S19T/OKW8IEvysW/pcqCL8uCd1wtbQp/qSTn2i2dL86Gr7L0Z1ETdPtZswy6pULgzWKrjqqO2NsOnQ852f4CdYgPZAADjAFUJgfg5/q94LvAd4Lf2DMzgOT1V4OfGoBx/V3VALpYrj/zr+BN47/M81v/ieVzPx/+vVbgp+HLMvAp/CbwqrzwxXmuXcGfS5VBtwNuP52LrmoNeF7snA7b2wZdCHmfpb2W9qgBtI9y/WHwNa7f3yd7AA3g1yevv4cxgLLq1PX/Zrn+LvmffuP6O2U//Xnx27eMf7vCAt8MPvCOK0n80jzwJU3RDfjiZtDpbFEWujUTPKd86C2BH1YdspaD3dJFF0LO125Vh/gAYwCVagDt/OB7wHeB7+T6G35Xz39yAMnr75YeQPL/KldmAJ0LX39z3/gftbd84au04LdrHf61six4A/9yDr4BX1IAvrh5+DNFTeFBt2eBq447mqK3CZwOqg7YC2Pnu+jmkJPtsrTTUodYcgDgh7n+YJ/sAfD8lxsDAL+2u3n9xgCS19/V+L/MVfDpV9ef/fRn8ItbgV+UDz/r6pviO5L4TeBLCsAXq8/23GtX8KeLmqCnykZXNXflrQKn/al+EDsf9I4Cbaf2sf7mAEJqAL7eDAB8F9ffCH59D3MAyeuvBv/7b5br75K+fuN/T/+d+b+2ZV5/HvxnzXzps+LfycG/mcIvz8a/WpYF77hU2hTeip8Fr2py7Sl4OlXUBN7eBF111NE69ILgqn2qtmDvbAF7u6Vtqq2qzADAD/5hDKDCbQ6gPDWA5PXXdDMHkLz+r10tA8jz9L9Ofe7n/LN7hb70tQX/Whvwz6vywhdnw5/OgT9ZlIVuP54pG52OOLLRm7vyguCqPfafu+xcaCv2ljy1j4Ef7WsZAPhurt8JfmOP7AEkr/+bwv+s8Ft7/blP/8NWPPst4St4Az8vfEkB+OIW4IvywtuboKsKoee78rzglnbb8193a7C3toC9WbXJUmYA4Ae5fusAGpLPP/i13SzPf3IAXTLX/yEH/3Whpz/P5376d34ufkUG/3oO/pV8+KUt46fhi5uHP1GUDX9M1QRddcjxc+i7VbtUhcCbe8Zbi71RtcFS+xj4Ua4/OYAAA/AmBwC+s0fOANT1pwfQ2RhA9vV3Utdv+RdzNvnWn/Ol767l6W8rPvCOC6V54EsKwNPp4mbg6XhRBv6o6ohZNrqqNeh7WkKnHal+4Lpbi51qvaXKrAGA7+X6XakBgF8Hfs1vlgF0ST//qf/TbCXvLNf/Kv/T3+LnfnP4V/9m/ILwRRn4I5aaoKvaim4Fz0JXWdHbct2twV5naa1qjU3+HwuefjlXE4+yAAAAAElFTkSuQmCC",Tz=0,IT=(n,e,t,i)=>{if(!n[t]){let r=n.useDelayedTextureLoading;n.useDelayedTextureLoading=!1;let s=n._blockEntityCollection;n._blockEntityCollection=!1;let a=ne.CreateFromBase64String(e,i+Tz++,n,!0,!1,ne.BILINEAR_SAMPLINGMODE);n._blockEntityCollection=s;let o=n.getEngine().getLoadedTexturesCache(),l=o.indexOf(a.getInternalTexture());l!==-1&&o.splice(l,1),a.isRGBD=!0,a.wrapU=ne.CLAMP_ADDRESSMODE,a.wrapV=ne.CLAMP_ADDRESSMODE,n[t]=a,n.useDelayedTextureLoading=r,Sl.ExpandRGBDTexture(a);let c=n.getEngine().onContextRestoredObservable.add(()=>{a.isRGBD=!0;let f=n.onBeforeRenderObservable.add(()=>{a.isReady()&&(n.onBeforeRenderObservable.remove(f),Sl.ExpandRGBDTexture(a))})});n.onDisposeObservable.add(()=>{n.getEngine().onContextRestoredObservable.remove(c)})}return n[t]},Gm=n=>IT(n,gz,"environmentBRDFTexture","EnvironmentBRDFTexture"),xT=n=>IT(n,Ez,"environmentFuzzBRDFTexture","EnvironmentFuzzBRDFTexture"),iN=n=>IT(n,vz,"openPBREnvironmentBRDFTexture","OpenPBREnvironmentBRDFTexture")});function rN(n){return class extends n{constructor(){super(...arguments),this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1}}}var nN=A(()=>{});var CT=A(()=>{_r();ze();Ji();We.prototype.restoreSingleAttachment=function(){let n=this._gl;this.bindAttachments([n.BACK])};We.prototype.restoreSingleAttachmentForRenderTarget=function(){let n=this._gl;this.bindAttachments([n.COLOR_ATTACHMENT0])};We.prototype.buildTextureLayout=function(n,e=!1){let t=this._gl,i=[];if(e)i.push(t.BACK);else for(let r=0;r1&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===16||e.depthTextureFormat===14||e.depthTextureFormat===18)&&(o=e.depthTextureFormat)),o===void 0&&(o=s?13:14);let y=this._gl,B=this._currentFramebuffer,w=y.createFramebuffer();this._bindUnboundFramebuffer(w);let H=(z=n.width)!=null?z:n,O=(K=n.height)!=null?K:n,V=[],X=[],j=this.webGLVersion>1&&(o===13||o===17||o===18);L.label=(J=e==null?void 0:e.label)!=null?J:"MultiRenderTargetWrapper",L._framebuffer=w,L._generateDepthBuffer=a||r,L._generateStencilBuffer=a?j:s,L._depthStencilBuffer=this._setupFramebufferDepthAttachments(L._generateStencilBuffer,L._generateDepthBuffer,H,O,1,o),L._attachments=X;for(let ge=0;ge1||this.isWebGPU);let $e=this.webGLVersion>1,Fe=y[$e?"COLOR_ATTACHMENT"+ge:"COLOR_ATTACHMENT"+ge+"_WEBGL"];if(X.push(Fe),ce===-1||P)continue;let Xe=new bt(this,6);V[ge]=Xe,y.activeTexture(y["TEXTURE"+ge]),y.bindTexture(ce,Xe._hardwareTexture.underlyingResource),y.texParameteri(ce,y.TEXTURE_MAG_FILTER,ke.mag),y.texParameteri(ce,y.TEXTURE_MIN_FILTER,ke.min),y.texParameteri(ce,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(ce,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE);let xt=this._getRGBABufferInternalSizedFormat(se,xe,le),Dt=this._getInternalFormat(xe),Yt=this._getWebGLTextureType(se);if($e&&(ce===35866||ce===32879))ce===35866?Xe.is2DArray=!0:Xe.is3D=!0,Xe.baseDepth=Xe.depth=he,y.texImage3D(ce,0,xt,H,O,he,0,Dt,Yt,null);else if(ce===34067){for(let di=0;di<6;di++)y.texImage2D(y.TEXTURE_CUBE_MAP_POSITIVE_X+di,0,xt,H,O,0,Dt,Yt,null);Xe.isCube=!0}else y.texImage2D(y.TEXTURE_2D,0,xt,H,O,0,Dt,Yt,null);i&&y.generateMipmap(ce),this._bindTextureDirectly(ce,null),Xe.baseWidth=H,Xe.baseHeight=O,Xe.width=H,Xe.height=O,Xe.isReady=!0,Xe.samples=1,Xe.generateMipMaps=i,Xe.samplingMode=me,Xe.type=se,Xe._useSRGBBuffer=le,Xe.format=xe,Xe.label=(Pe=x[ge])!=null?Pe:L.label+"-Texture"+ge,this._internalTexturesCache.push(Xe)}if(a&&this._caps.depthTextureExtension&&!P){let ge=new bt(this,14),me=5,se=y.DEPTH_COMPONENT16,le=y.DEPTH_COMPONENT,xe=y.UNSIGNED_SHORT,ce=y.DEPTH_ATTACHMENT;this.webGLVersion<2?se=y.DEPTH_COMPONENT:o===14?(me=1,xe=y.FLOAT,se=y.DEPTH_COMPONENT32F):o===18?(me=0,xe=y.FLOAT_32_UNSIGNED_INT_24_8_REV,se=y.DEPTH32F_STENCIL8,le=y.DEPTH_STENCIL,ce=y.DEPTH_STENCIL_ATTACHMENT):o===16?(me=0,xe=y.UNSIGNED_INT,se=y.DEPTH_COMPONENT24,ce=y.DEPTH_ATTACHMENT):(o===13||o===17)&&(me=12,xe=y.UNSIGNED_INT_24_8,se=y.DEPTH24_STENCIL8,le=y.DEPTH_STENCIL,ce=y.DEPTH_STENCIL_ATTACHMENT),this._bindTextureDirectly(y.TEXTURE_2D,ge,!0),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texImage2D(y.TEXTURE_2D,0,se,H,O,0,le,xe,null),y.framebufferTexture2D(y.FRAMEBUFFER,ce,y.TEXTURE_2D,ge._hardwareTexture.underlyingResource,0),this._bindTextureDirectly(y.TEXTURE_2D,null),L._depthStencilTexture=ge,L._depthStencilTextureWithStencil=j,ge.baseWidth=H,ge.baseHeight=O,ge.width=H,ge.height=O,ge.isReady=!0,ge.samples=1,ge.generateMipMaps=i,ge.samplingMode=1,ge.format=o,ge.type=me,ge.label=L.label+"-DepthStencil",V[l]=ge,this._internalTexturesCache.push(ge)}if(L.setTextures(V),t&&y.drawBuffers(X),this._bindUnboundFramebuffer(B),L.setLayerAndFaceIndices(S,R),this.resetTextureCache(),!P)this.updateMultipleRenderTargetTextureSampleCount(L,c,t);else if(c>1){let ge=y.createFramebuffer();if(!ge)throw new Error("Unable to create multi sampled framebuffer");L._samples=c,L._MSAAFramebuffer=ge,l>0&&t&&(this._bindUnboundFramebuffer(ge),y.drawBuffers(X),this._bindUnboundFramebuffer(B))}return L};We.prototype.updateMultipleRenderTargetTextureSampleCount=function(n,e,t=!0){if(this.webGLVersion<2||!n)return 1;if(n.samples===e)return e;let i=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),n._depthStencilBuffer&&(i.deleteRenderbuffer(n._depthStencilBuffer),n._depthStencilBuffer=null),n._MSAAFramebuffer&&(i.deleteFramebuffer(n._MSAAFramebuffer),n._MSAAFramebuffer=null);let r=n._attachments.length;for(let a=0;a1&&typeof i.renderbufferStorageMultisample=="function"){let a=i.createFramebuffer();if(!a)throw new Error("Unable to create multi sampled framebuffer");n._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);let o=[];for(let l=0;l1?"COLOR_ATTACHMENT"+l:"COLOR_ATTACHMENT"+l+"_WEBGL"],h=this._createRenderBuffer(c.width,c.height,e,-1,this._getRGBABufferInternalSizedFormat(c.type,c.format,c._useSRGBBuffer),d);if(!h)throw new Error("Unable to create multi sampled framebuffer");f.addMSAARenderBuffer(h),c.samples=e,o.push(d)}t&&i.drawBuffers(o)}else this._bindUnboundFramebuffer(n._framebuffer);let s=n._depthStencilTexture?n._depthStencilTexture.format:void 0;return n._depthStencilBuffer=this._setupFramebufferDepthAttachments(n._generateStencilBuffer,n._generateDepthBuffer,n.width,n.height,e,s),this._bindUnboundFramebuffer(null),n._samples=e,e};We.prototype.generateMipMapsMultiFramebuffer=function(n){let e=n,t=this._gl;if(e.isMulti)for(let i=0;i1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],t.readBuffer(r[a]),t.drawBuffers(r),t.blitFramebuffer(0,0,o.width,o.height,0,0,o.width,o.height,i,t.NEAREST)}for(let a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];t.drawBuffers(r),t.bindFramebuffer(this._gl.FRAMEBUFFER,e._MSAAFramebuffer)}});var Wm,sN=A(()=>{oi();_a();CT();Wm=class extends ri{get isSupported(){var e,t;return(t=(e=this._engine)==null?void 0:e.getCaps().drawBuffersExtension)!=null?t:!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t0&&(this._createInternalTextures(),this._createTextures(a))}_initTypes(e,t,i,r,s,a,o,l,c,f){for(let d=0;d{this.onAfterRenderObservable.notifyObservers(t)})}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){var t,i;let e=(t=this._renderTarget)==null?void 0:t.textures;if(e){for(let r=e.length-1;r>=0;r--)this._textures[r]._texture=null;(i=this._renderTarget)==null||i.dispose(),this._renderTarget=null}}}});var aN,Sz,oN=A(()=>{N();aN="mrtFragmentDeclaration",Sz=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +#define VIEW_DEPTH`:""));r.textureWidth=t,r.textureHeight=i,this.reductionSteps.push(r);let s=1;for(;t>1||i>1;){t=Math.max(Math.round(t/2),1),i=Math.max(Math.round(i/2),1);let a=new za("Reduction phase "+s,e.getEngine(),"#define "+(t==1&&i==1?"LAST":t==1||i==1?"ONEBEFORELAST":"MAIN"));a.textureWidth=t,a.textureHeight=i,this.reductionSteps.push(a),s++}}}});var Cm,EO=A(()=>{ps();vh();gO();rT();tT();Cm=class{get onAfterReductionPerformed(){return this._thinMinMaxReducer.onAfterReductionPerformed}constructor(e){this._onAfterUnbindObserver=null,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new ms(e.getScene()),this._thinMinMaxReducer=new xm(e.getScene()),this._reductionSteps=[],this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{this._postProcessManager._rebuild()})}get sourceTexture(){return this._sourceTexture}setSourceTexture(e,t,i=2,r=!0){if(e!==this._sourceTexture&&(this._thinMinMaxReducer.depthRedux=t,this.deactivate(),this._sourceTexture=e,this._forceFullscreenViewport=r,this._thinMinMaxReducer.setTextureDimensions(e.getRenderWidth(),e.getRenderHeight()))){this._disposePostProcesses();let s=this._thinMinMaxReducer.reductionSteps;for(let a=0;a{c.setTexture("textureSampler",this._sourceTexture)})),a===s.length-1&&this._reductionSteps[a-1].onAfterRenderObservable.add(()=>{this._thinMinMaxReducer.readMinMax(l.inputTexture.texture)})}}}get refreshRate(){return this._sourceTexture?this._sourceTexture.refreshRate:-1}set refreshRate(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)}get activated(){return this._activated}activate(){this._onAfterUnbindObserver||!this._sourceTexture||(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add(()=>{var t,i;let e=this._camera.getScene().getEngine();(t=e._debugPushGroup)==null||t.call(e,"min max reduction"),this._reductionSteps[0].activate(this._camera),this._postProcessManager.directRender(this._reductionSteps,this._reductionSteps[0].inputTexture,this._forceFullscreenViewport,0,0,!0,this._reductionSteps.length-1),e.unBindFramebuffer(this._reductionSteps[this._reductionSteps.length-1].inputTexture,!1),(i=e._debugPopGroup)==null||i.call(e)}),this._activated=!0)}deactivate(){!this._onAfterUnbindObserver||!this._sourceTexture||(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=void 0,this._disposePostProcesses(),this._postProcessManager.dispose(),this._postProcessManager=void 0,this._thinMinMaxReducer.dispose(),this._thinMinMaxReducer=void 0,this._sourceTexture=null)}_disposePostProcesses(){for(let e=0;e{dO();EO();bm=class extends Cm{get depthRenderer(){return this._depthRenderer}constructor(e){super(e)}setDepthRenderer(e=null,t=2,i=!0){let r=this._camera.getScene();this._depthRenderer&&(delete r._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),e===null&&(r._depthRenderer||(r._depthRenderer={}),this._depthRendererId="minmax_"+this._camera.uniqueId,e=this._depthRenderer=new fc(r,t,this._camera,!1,1,!1,`DepthRenderer ${this._depthRendererId}`),e.enabled=!1,r._depthRenderer[this._depthRendererId]=e),super.setSourceTexture(e.getDepthMap(),!0,t,i)}setSourceTexture(e,t,i=2,r=!0){super.setSourceTexture(e,t,i,r)}activate(){this._depthRenderer&&(this._depthRenderer.enabled=!0),super.activate()}deactivate(){super.deactivate(),this._depthRenderer&&(this._depthRenderer.enabled=!1)}dispose(e=!0){super.dispose(e),this._depthRenderer&&e&&(this._depthRenderer.dispose(),this._depthRenderer=null)}}});var TO,dz,qt,dc,Mm,An,SO=A(()=>{ve();_a();Ei();Im();bl();vO();ze();At();cf();TO=v.Up(),dz=v.Zero(),qt=new v,dc=new v,Mm=new U,An=class n extends St{_validateFilter(e){return e===St.FILTER_NONE||e===St.FILTER_PCF||e===St.FILTER_PCSS?e:(W.Error('Unsupported filter "'+e+'"!'),St.FILTER_NONE)}get numCascades(){return this._numCascades}set numCascades(e){e=Math.min(Math.max(e,n.MIN_CASCADES_COUNT),n.MAX_CASCADES_COUNT),e!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap(),this._recreateSceneUBOs())}get freezeShadowCastersBoundingInfo(){return this._freezeShadowCastersBoundingInfo}set freezeShadowCastersBoundingInfo(e){this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),!this._freezeShadowCastersBoundingInfoObservable&&!e&&(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(()=>this._computeShadowCastersBoundingInfo())),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()}_computeShadowCastersBoundingInfo(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){let e=this._shadowMap.renderList;for(let t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)}get minDistance(){return this._minDistance}get maxDistance(){return this._maxDistance}getClassName(){return n.CLASSNAME}getCascadeMinExtents(e){return e>=0&&e=0&&et.maxZ&&t.maxZ!==0||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0)}get debug(){return this._debug}set debug(e){this._debug=e,this._light._markMeshesAsLightDirty()}get depthClamp(){return this._depthClamp}set depthClamp(e){this._depthClamp=e}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()}get lambda(){return this._lambda}set lambda(e){let t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)}getCascadeViewMatrix(e){return e>=0&&e=0&&e=0&&e{let r=i.min,s=i.max;r>=s&&(r=0,s=1),(r!=this._minDistance||s!=this._maxDistance)&&this.setMinMaxDistance(r,s)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}}get autoCalcDepthBoundsRefreshRate(){var e,t,i;return(i=(t=(e=this._depthReducer)==null?void 0:e.depthRenderer)==null?void 0:t.getDepthMap().refreshRate)!=null?i:-1}set autoCalcDepthBoundsRefreshRate(e){var t;(t=this._depthReducer)!=null&&t.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)}splitFrustum(){this._breaksAreDirty=!0}_splitFrustum(){let e=this._getCamera();if(!e)return;let t=e.minZ,i=e.maxZ||this._shadowMaxZ,r=i-t,s=this._minDistance,a=this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance,o=t+s*r,l=t+a*r,c=l-o,f=l/o;for(let d=0;da||(!this._depthClamp||this.filter===St.FILTER_PCSS?(s=Math.min(s,l),this.filter!==St.FILTER_PCSS&&(a=Math.min(a,c))):(a=Math.min(a,c),s=Math.max(s,l),a=Math.max(s+1,a))),U.OrthoOffCenterLHToRef(this._cascadeMinExtents[r].x,this._cascadeMaxExtents[r].x,this._cascadeMinExtents[r].y,this._cascadeMaxExtents[r].y,i?a:s,i?s:a,this._projectionMatrices[r],e.getEngine().isNDCHalfZRange),this._cascadeMinExtents[r].z=s,this._cascadeMaxExtents[r].z=a,this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r],this._transformMatrices[r]),v.TransformCoordinatesToRef(dz,this._transformMatrices[r],qt),qt.scaleInPlace(this._mapSize/2),dc.copyFromFloats(Math.round(qt.x),Math.round(qt.y),Math.round(qt.z)),dc.subtractInPlace(qt).scaleInPlace(2/this._mapSize),U.TranslationToRef(dc.x,dc.y,0,Mm),this._projectionMatrices[r].multiplyToRef(Mm,this._projectionMatrices[r]),this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r],this._transformMatrices[r]),this._transformMatrices[r].copyToArray(this._transformMatricesAsArray,r*16)}}_computeFrustumInWorldSpace(e){let t=this._getCamera();if(!t)return;let i=this._cascades[e].prevBreakDistance,r=this._cascades[e].breakDistance,s=this._scene.getEngine().isNDCHalfZRange;t.getViewMatrix();let a=t.maxZ===0,o=t.maxZ;a&&(t.maxZ=this._shadowMaxZ,t.getProjectionMatrix(!0));let l=U.Invert(t.getTransformationMatrix());a&&(t.maxZ=o,t.getProjectionMatrix(!0));let c=this._scene.getEngine().useReverseDepthBuffer?4:0;for(let f=0;f{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[t]),this._currentLayer=t,this._filter===St.FILTER_PCF&&e.setColorWrite(!1),Vr.eyeAtCamera=!1,this._scene.setTransformMatrix(this.getCascadeViewMatrix(t),this.getCascadeProjectionMatrix(t)),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onBeforeBindObservable.add(()=>{var t;this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._enableGPUDebugMarkers&&((t=e._debugPushGroup)==null||t.call(e,`Cascaded shadow map generation for pass id ${e.currentRenderPassId}`)),this._breaksAreDirty&&this._splitFrustum(),this._computeMatrices()}),this._splitFrustum()}_bindCustomEffectForRenderSubMeshForShadowMap(e,t){t.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))}_isReadyCustomDefines(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==St.FILTER_PCSS?"1":"0"))}prepareDefines(e,t){super.prepareDefines(e,t);let i=this._scene,r=this._light;if(!i.shadowsEnabled||!r.shadowEnabled)return;e["SHADOWCSM"+t]=!0,e["SHADOWCSMDEBUG"+t]=this.debug,e["SHADOWCSMNUM_CASCADES"+t]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+t]=i.useRightHandedSystem;let s=this._getCamera();s&&this._shadowMaxZ<=(s.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+t]=!0),this.cascadeBlendPercentage===0&&(e["SHADOWCSMNOBLEND"+t]=!0)}bindShadowLight(e,t){let i=this._light,r=this._scene;if(!r.shadowsEnabled||!i.shadowEnabled)return;let s=this._getCamera();if(!s)return;let a=this.getShadowMap();if(!a)return;let o=a.getSize().width,l=this._transformMatricesAsArray,c=r.floatingOriginMode?zx(this._scene.floatingOriginOffset,this._viewMatrices,this._projectionMatrices,this._numCascades,this._tempTransformMatricesAsArray):l;if(t.setMatrices("lightMatrix"+e,c),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,this.cascadeBlendPercentage===0?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===St.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o,1/o,this.frustumEdgeFalloff,e);else if(this._filter===St.FILTER_PCSS){for(let f=0;fnew n(r,s,void 0,a));return e.numCascades!==void 0&&(i.numCascades=e.numCascades),e.debug!==void 0&&(i.debug=e.debug),e.stabilizeCascades!==void 0&&(i.stabilizeCascades=e.stabilizeCascades),e.lambda!==void 0&&(i.lambda=e.lambda),e.cascadeBlendPercentage!==void 0&&(i.cascadeBlendPercentage=e.cascadeBlendPercentage),e.depthClamp!==void 0&&(i.depthClamp=e.depthClamp),e.autoCalcDepthBounds!==void 0&&(i.autoCalcDepthBounds=e.autoCalcDepthBounds),e.shadowMaxZ!==void 0&&(i.shadowMaxZ=e.shadowMaxZ),e.penumbraDarkness!==void 0&&(i.penumbraDarkness=e.penumbraDarkness),e.freezeShadowCastersBoundingInfo!==void 0&&(i.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),e.minDistance!==void 0&&e.maxDistance!==void 0&&i.setMinMaxDistance(e.minDistance,e.maxDistance),i}};An._FrustumCornersNdcSpace=[new v(-1,1,-1),new v(1,1,-1),new v(1,-1,-1),new v(-1,-1,-1),new v(-1,1,1),new v(1,1,1),new v(1,-1,1),new v(-1,-1,1)];An.CLASSNAME="CascadedShadowGenerator";An.DEFAULT_CASCADES_COUNT=4;An.MIN_CASCADES_COUNT=2;An.MAX_CASCADES_COUNT=4;An._SceneComponentInitialization=n=>{throw Ie("ShadowGeneratorSceneComponent")}});function ym(n,e){hz[n]=e}var hz,nT=A(()=>{hz={}});var sT,AO=A(()=>{Im();SO();vl();nT();ym(be.NAME_SHADOWGENERATOR,(n,e)=>{if(n.shadowGenerators!==void 0&&n.shadowGenerators!==null)for(let t=0,i=n.shadowGenerators.length;t{let e=n._getComponent(be.NAME_SHADOWGENERATOR);e||(e=new sT(n),n._addComponent(e))}});async function RO(n,e){let t=e.method||"GET";return await new Promise((i,r)=>{let s=new $t;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){let a={};if(e.responseHeaders)for(let o of e.responseHeaders)a[o]=s.getResponseHeader(o)||"";i({response:s.response,headerValues:a})}else r(`Unable to fetch data from ${n}. Error code: ${s.status}`)}),s.open(t,n),s.send()})}var IO=A(()=>{mo()});function uz(n){return!!n.createPlugin}function mz(n){return!!n.name}function Dm(){return Kn[".babylon"]}function pz(n){for(let e in Kn){let t=Kn[e];if(t.mimeType===n)return t}}function oT(n,e){let t=Kn[n];return t||(W.Warn("Unable to find a plugin to load "+n+" 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?Dm():void 0)}function _z(n){return!!Kn[n]}function gz(n){for(let e in Kn){let t=Kn[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(n))return Kn[e]}return Dm()}function Ez(n){let e=n.indexOf("?");e!==-1&&(n=n.substring(0,e));let t=n.lastIndexOf(".");return n.substring(t,n.length).toLowerCase()}function vz(n){return n.substring(0,5)==="data:"?n.substring(5):null}function lT(n,e,t){let r="Unable to load from "+(n.rawData?"binary data":n.url);return e?r+=`: ${e}`:t&&(r+=`: ${t}`),r}async function cT(n,e,t,i,r,s,a,o,l){var u;let c=vz(n.url);if(n.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";let f=!c&&!a?Ez(n.url):"",d=a?oT(a,!0):c?gz(n.url):oT(f,!1);if(!d&&f){if(n.url&&!n.url.startsWith("blob:")){let m=await RO(n.url,{method:"HEAD",responseHeaders:["Content-Type"]}),p=m.headerValues?m.headerValues["Content-Type"]:"";p&&(d=pz(p))}d||(d=Dm())}if(!d)throw new Error(`No plugin or fallback for ${a!=null?a:n.url}`);if(((u=l==null?void 0:l[d.plugin.name])==null?void 0:u.enabled)===!1)throw new Error(`The '${d.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(n.rawData&&!d.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(m=>{if(uz(d.plugin)){let _=d.plugin.createPlugin(l!=null?l:{});return _ instanceof Promise?(_.then(m).catch(g=>{r("Error instantiating plugin.",g)}),null):(m(_),_)}else return m(d.plugin),d.plugin})(m=>{var I;if(!m)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(CO.notifyObservers(m),c&&(m.canDirectLoad&&m.canDirectLoad(n.url)||!fa(n.url))){if(m.directLoad){let x=m.directLoad(e,c);x instanceof Promise?x.then(P=>{t(m,P)}).catch(P=>{r("Error in directLoad of _loadData: "+P,P)}):t(m,x)}else t(m,c);return}let p=d.isBinary,_=(x,P)=>{if(e.isDisposed){r("Scene has been disposed");return}t(m,x,P)},g=null,T=!1;(I=m.onDisposeObservable)==null||I.add(()=>{T=!0,g&&(g.abort(),g=null),s()});let b=()=>{if(T)return;let x=(P,L)=>{r(P==null?void 0:P.statusText,L)};if(!m.loadFile&&n.rawData)throw"Plugin does not support loading ArrayBufferView.";g=m.loadFile?m.loadFile(e,n.rawData||n.file||n.url,n.rootUrl,_,i,p,x,o):e._loadFile(n.file||n.url,_,i,!0,p,x)},R=e.getEngine(),S=R.enableOfflineSupport;if(S){let x=!1;for(let P of e.disableOfflineSupportExceptionRules)if(P.test(n.url)){x=!0;break}S=!x}S&&fe.OfflineProviderFactory?e.offlineProvider=fe.OfflineProviderFactory(n.url,b,R.disableManifestCheck):b()})}function fT(n,e){let t,i,r=null,s=null;if(!e)t=n,i=re.GetFilename(n),n=re.GetFolderPath(n);else if(mz(e))t=`file:${e.name}`,i=e.name,r=e;else if(ArrayBuffer.isView(e))t="",i=la(),s=e;else if(e.startsWith("data:"))t=e,i="";else if(n){let a=e;if(a.substring(0,1)==="/")return re.Error("Wrong sceneFilename parameter"),null;t=n+a,i=a}else t=e,i=re.GetFilename(e),n=re.GetFolderPath(e);return{url:t,rootUrl:n,name:i,file:r,rawData:s}}function Xa(n){if(typeof n.extensions=="string"){let e=n.extensions;Kn[e.toLowerCase()]={plugin:n,isBinary:!1}}else{let e=n.extensions,t=Object.keys(e);for(let i of t)Kn[i.toLowerCase()]={plugin:n,isBinary:e[i].isBinary,mimeType:e[i].mimeType}}}async function Yf(n,e,t){let{meshNames:i,rootUrl:r="",onProgress:s,pluginExtension:a,name:o,pluginOptions:l}=t!=null?t:{};return await MO(i,r,n,e,s,a,o,l)}async function bO(n,e,t="",i=ue.LastCreatedScene,r=null,s=null,a=null,o=null,l="",c={}){if(!i)return W.Error("No scene available to import mesh to"),null;let f=fT(e,t);if(!f)return null;let d={};i.addPendingData(d);let h=()=>{i.removePendingData(d)},u=(_,g)=>{let T=lT(f,_,g);a?a(i,T,new nr(T,Or.SceneLoaderError,g)):W.Error(T),h()},m=s?_=>{try{s(_)}catch(g){u("Error in onProgress callback: "+g,g)}}:void 0,p=(_,g,T,b,R,S,I,x)=>{if(i.importedMeshesFiles.push(f.url),r)try{r(_,g,T,b,R,S,I,x)}catch(P){u("Error in onSuccess callback: "+P,P)}i.removePendingData(d)};return await cT(f,i,(_,g,T)=>{if(_.rewriteRootURL&&(f.rootUrl=_.rewriteRootURL(f.rootUrl,T)),_.importMesh){let b=_,R=[],S=[],I=[];if(!b.importMesh(n,i,g,f.rootUrl,R,S,I,u))return;i.loadingPluginName=_.name,p(R,S,I,[],[],[],[],[])}else _.importMeshAsync(n,i,g,f.rootUrl,m,f.name).then(R=>{i.loadingPluginName=_.name,p(R.meshes,R.particleSystems,R.skeletons,R.animationGroups,R.transformNodes,R.geometries,R.lights,R.spriteManagers)}).catch(R=>{u(R.message,R)})},m,u,h,o,l,c)}async function MO(n,e,t,i,r,s,a,o){return await new Promise((l,c)=>{try{bO(n,e,t,i,(f,d,h,u,m,p,_,g)=>{l({meshes:f,particleSystems:d,skeletons:h,animationGroups:u,transformNodes:m,geometries:p,lights:_,spriteManagers:g})},r,(f,d,h)=>{c(h||new Error(d))},s,a,o).catch(c)}catch(f){c(f)}})}async function yO(n,e="",t=ue.LastCreatedEngine,i=null,r=null,s=null,a=null,o="",l={}){if(!t){re.Error("No engine available");return}await dT(n,e,new st(t),i,r,s,a,o,l)}async function Tz(n,e,t,i,r,s,a){return await new Promise((o,l)=>{yO(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a)})}async function dT(n,e="",t=ue.LastCreatedScene,i=null,r=null,s=null,a=null,o="",l={}){if(!t)return W.Error("No scene available to append to"),null;let c=fT(n,e);if(!c)return null;let f={};t.addPendingData(f);let d=()=>{t.removePendingData(f)};ci.ShowLoadingScreen&&!aT&&(aT=!0,t.getEngine().displayLoadingUI(),t.executeWhenReady(()=>{t.getEngine().hideLoadingUI(),aT=!1}));let h=(p,_)=>{let g=lT(c,p,_);s?s(t,g,new nr(g,Or.SceneLoaderError,_)):W.Error(g),d()},u=r?p=>{try{r(p)}catch(_){h("Error in onProgress callback",_)}}:void 0,m=()=>{if(i)try{i(t)}catch(p){h("Error in onSuccess callback",p)}t.removePendingData(f)};return await cT(c,t,(p,_)=>{if(p.load){if(!p.load(t,_,c.rootUrl,h))return;t.loadingPluginName=p.name,m()}else p.loadAsync(t,_,c.rootUrl,u,c.name).then(()=>{t.loadingPluginName=p.name,m()}).catch(T=>{h(T.message,T)})},u,h,d,a,o,l)}async function Sz(n,e,t,i,r,s,a){return await new Promise((o,l)=>{try{dT(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a).catch(l)}catch(c){l(c)}})}async function hT(n,e="",t=ue.LastCreatedScene,i=null,r=null,s=null,a=null,o="",l={}){if(!t)return W.Error("No scene available to load asset container to"),null;let c=fT(n,e);if(!c)return null;let f={};t.addPendingData(f);let d=()=>{t.removePendingData(f)},h=(p,_)=>{let g=lT(c,p,_);s?s(t,g,new nr(g,Or.SceneLoaderError,_)):W.Error(g),d()},u=r?p=>{try{r(p)}catch(_){h("Error in onProgress callback",_)}}:void 0,m=p=>{if(i)try{i(p)}catch(_){h("Error in onSuccess callback",_)}t.removePendingData(f)};return await cT(c,t,(p,_)=>{if(p.loadAssetContainer){let T=p.loadAssetContainer(t,_,c.rootUrl,h);if(!T)return;T.populateRootNodes(),t.loadingPluginName=p.name,m(T)}else p.loadAssetContainerAsync?p.loadAssetContainerAsync(t,_,c.rootUrl,u,c.name).then(T=>{T.populateRootNodes(),t.loadingPluginName=p.name,m(T)}).catch(T=>{h(T.message,T)}):h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},u,h,d,a,o,l)}async function Az(n,e,t,i,r,s,a){return await new Promise((o,l)=>{try{hT(n,e,t,c=>{o(c)},i,(c,f,d)=>{l(d||new Error(f))},r,s,a).catch(l)}catch(c){l(c)}})}async function DO(n,e="",t=ue.LastCreatedScene,i=!0,r=0,s=null,a=null,o=null,l=null,c=null,f="",d={}){if(!t){W.Error("No scene available to load animations to");return}if(i){for(let _ of t.animatables)_.reset();t.stopAllAnimations();let m=t.animationGroups.slice();for(let _ of m)_.dispose();let p=t.getNodes();for(let _ of p)_.animations&&(_.animations=[])}else switch(r){case 0:let m=t.animationGroups.slice();for(let p of m)p.dispose();break;case 1:for(let p of t.animationGroups)p.stop();break;case 2:for(let p of t.animationGroups)p.reset(),p.restart();break;case 3:break;default:W.Error("Unknown animation group loading mode value '"+r+"'");return}let h=t.animatables.length;await hT(n,e,t,m=>{m.mergeAnimationsTo(t,t.animatables.slice(h),s),m.dispose(),t.onAnimationFileImportedObservable.notifyObservers(t),a&&a(t)},o,l,c,f,d)}async function Rz(n,e,t,i,r,s,a,o,l,c){return await new Promise((f,d)=>{try{DO(n,e,t,i,r,s,h=>{f(h)},a,(h,u,m)=>{d(m||new Error(u))},o,l,c).catch(d)}catch(h){d(h)}})}var xO,CO,Kn,aT,wo,hc=A(()=>{Tt();ft();sr();At();ze();Jh();ds();Kc();Yc();ii();IO();(function(n){n[n.Clean=0]="Clean",n[n.Stop=1]="Stop",n[n.Sync=2]="Sync",n[n.NoSync=3]="NoSync"})(xO||(xO={}));CO=new Y,Kn={},aT=!1;wo=class{static get ForceFullSceneLoadingForIncremental(){return ci.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){ci.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return ci.ShowLoadingScreen}static set ShowLoadingScreen(e){ci.ShowLoadingScreen=e}static get loggingLevel(){return ci.loggingLevel}static set loggingLevel(e){ci.loggingLevel=e}static get CleanBoneMatrixWeights(){return ci.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){ci.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return Dm()}static GetPluginForExtension(e){var t;return(t=oT(e,!0))==null?void 0:t.plugin}static IsPluginForExtensionAvailable(e){return _z(e)}static RegisterPlugin(e){Xa(e)}static ImportMesh(e,t,i,r,s,a,o,l,c,f){bO(e,t,i,r,s,a,o,l,c,f).catch(d=>o==null?void 0:o(ue.LastCreatedScene,d==null?void 0:d.message,d))}static async ImportMeshAsync(e,t,i,r,s,a,o){return await MO(e,t,i,r,s,a,o)}static Load(e,t,i,r,s,a,o,l){yO(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(ue.LastCreatedScene,c==null?void 0:c.message,c))}static async LoadAsync(e,t,i,r,s,a){return await Tz(e,t,i,r,s,a)}static Append(e,t,i,r,s,a,o,l){dT(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(i!=null?i:ue.LastCreatedScene,c==null?void 0:c.message,c))}static async AppendAsync(e,t,i,r,s,a){return await Sz(e,t,i,r,s,a)}static LoadAssetContainer(e,t,i,r,s,a,o,l){hT(e,t,i,r,s,a,o,l).catch(c=>a==null?void 0:a(i!=null?i:ue.LastCreatedScene,c==null?void 0:c.message,c))}static async LoadAssetContainerAsync(e,t,i,r,s,a){return await Az(e,t,i,r,s,a)}static ImportAnimations(e,t,i,r,s,a,o,l,c,f,d){DO(e,t,i,r,s,a,o,l,c,f,d).catch(h=>c==null?void 0:c(i!=null?i:ue.LastCreatedScene,h==null?void 0:h.message,h))}static async ImportAnimationsAsync(e,t,i,r,s,a,o,l,c,f,d){return await Rz(e,t,i,r,s,a,l,f,d)}};wo.NO_LOGGING=0;wo.MINIMAL_LOGGING=1;wo.SUMMARY_LOGGING=2;wo.DETAILED_LOGGING=3;wo.OnPluginActivatedObservable=CO});var Lm,uT,mT,jn,Kf=A(()=>{Rt();yl();Dl();ze();At();BE();Ma();Gn();Tt();ha();Lm=class{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=[],this.spriteManagers=[]}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture=e}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(let t of this.skeletons)e=e.concat(t.bones);return e}},uT=class extends Lm{},mT=class{constructor(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}dispose(){let e=this.rootNodes;for(let r of e)r.dispose();e.length=0;let t=this.skeletons;for(let r of t)r.dispose();t.length=0;let i=this.animationGroups;for(let r of i)r.dispose();i.length=0}},jn=class extends Lm{constructor(e){super(),this._wasAddedToScene=!1,e=e||ue.LastCreatedScene,e&&(this.scene=e,this.proceduralTextures=[],e.onDisposeObservable.add(()=>{this._wasAddedToScene||this.dispose()}),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{for(let t of this.geometries)t._rebuild();for(let t of this.meshes)t._rebuild();for(let t of this.particleSystems)t.rebuild();for(let t of this.textures)t._rebuild();for(let t of this.spriteManagers)t.rebuild()}))}_topologicalSort(e){let t=new Map;for(let o of e)t.set(o.uniqueId,o);let i={dependsOn:new Map,dependedBy:new Map};for(let o of e){let l=o.uniqueId;i.dependsOn.set(l,new Set),i.dependedBy.set(l,new Set)}for(let o of e){let l=o.uniqueId,c=i.dependsOn.get(l);if(o instanceof xs){let d=o.sourceMesh;t.has(d.uniqueId)&&(c.add(d.uniqueId),i.dependedBy.get(d.uniqueId).add(l))}let f=i.dependedBy.get(l);for(let d of o.getDescendants()){let h=d.uniqueId;t.has(h)&&(f.add(h),i.dependsOn.get(h).add(l))}}let r=[],s=[];for(let o of e){let l=o.uniqueId;i.dependsOn.get(l).size===0&&(s.push(o),t.delete(l))}let a=s;for(;a.length>0;){let o=a.shift();r.push(o);let l=i.dependedBy.get(o.uniqueId);for(let c of Array.from(l.values())){let f=i.dependsOn.get(c);f.delete(o.uniqueId),f.size===0&&t.get(c)&&(a.push(t.get(c)),t.delete(c))}}return t.size>0&&(W.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach(o=>{W.Error(o.name)})),r}_addNodeAndDescendantsToList(e,t,i,r){if(!(!i||r&&!r(i)||t.has(i.uniqueId))){e.push(i),t.add(i.uniqueId);for(let s of i.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,s,r)}}_isNodeInContainer(e){return e instanceof zt&&this.meshes.indexOf(e)!==-1||e instanceof at&&this.transformNodes.indexOf(e)!==-1||e instanceof tt&&this.lights.indexOf(e)!==-1||e instanceof Ue&&this.cameras.indexOf(e)!==-1}_isValidHierarchy(){for(let e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.transformNodes)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.lights)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(let e of this.cameras)if(e.parent&&!this._isNodeInContainer(e.parent))return W.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;return!0}instantiateModelsToScene(e,t=!1,i){this._isValidHierarchy()||re.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");let r={},s={},a=new mT,o=[],l=[],c={doNotInstantiate:!0,...i},f=(p,_)=>{if(r[p.uniqueId]=_.uniqueId,s[_.uniqueId]=_,e&&(_.name=e(p.name)),_ instanceof V){let g=_;if(g.morphTargetManager){let T=p.morphTargetManager;g.morphTargetManager=T.clone();for(let b=0;b{if(f(p,_),p.parent){let g=r[p.parent.uniqueId],T=s[g];T?_.parent=T:_.parent=p.parent}if(_.position&&p.position&&_.position.copyFrom(p.position),_.rotationQuaternion&&p.rotationQuaternion&&_.rotationQuaternion.copyFrom(p.rotationQuaternion),_.rotation&&p.rotation&&_.rotation.copyFrom(p.rotation),_.scaling&&p.scaling&&_.scaling.copyFrom(p.scaling),_.material){let g=_;if(g.material)if(t){let T=p.material;if(l.indexOf(T)===-1){let b=T.clone(e?e(T.name):"Clone of "+T.name);if(l.push(T),r[T.uniqueId]=b.uniqueId,s[b.uniqueId]=b,T.getClassName()==="MultiMaterial"){let R=T;for(let S of R.subMaterials)S&&(b=S.clone(e?e(S.name):"Clone of "+S.name),l.push(S),r[S.uniqueId]=b.uniqueId,s[b.uniqueId]=b);R.subMaterials=R.subMaterials.map(S=>S&&s[r[S.uniqueId]])}}g.getClassName()!=="InstancedMesh"&&(g.material=s[r[T.uniqueId]])}else g.material.getClassName()==="MultiMaterial"?this.scene.multiMaterials.indexOf(g.material)===-1&&this.scene.addMultiMaterial(g.material):this.scene.materials.indexOf(g.material)===-1&&this.scene.addMaterial(g.material)}_.parent===null&&a.rootNodes.push(_)};for(let p of u)if(p.getClassName()==="InstancedMesh"){let _=p,g=_.sourceMesh,T=r[g.uniqueId],R=(typeof T=="number"?s[T]:g).createInstance(_.name);m(_,R)}else{let _=!0;p.getClassName()==="TransformNode"||p.getClassName()==="Node"||p.skeleton||!p.getTotalVertices||p.getTotalVertices()===0?_=!1:c.doNotInstantiate&&(typeof c.doNotInstantiate=="function"?_=!c.doNotInstantiate(p):_=!c.doNotInstantiate);let g=_?p.createInstance(`instance of ${p.name}`):p.clone(`Clone of ${p.name}`,null,!0);if(!g)throw new Error(`Could not clone or instantiate node on Asset Container ${p.name}`);m(p,g)}for(let p of this.skeletons){if(c.predicate&&!c.predicate(p))continue;let _=p.clone(e?e(p.name):"Clone of "+p.name);for(let g of this.meshes)if(g.skeleton===p&&!g.isAnInstance){let T=s[r[g.uniqueId]];if(!T||T.isAnInstance||(T.skeleton=_,o.indexOf(_)!==-1))continue;o.push(_);for(let b of _.bones)b._linkedTransformNode&&(b._linkedTransformNode=s[r[b._linkedTransformNode.uniqueId]])}a.skeletons.push(_)}for(let p of this.animationGroups){if(c.predicate&&!c.predicate(p))continue;let _=p.clone(e?e(p.name):"Clone of "+p.name,g=>s[r[g.uniqueId]]||g);a.animationGroups.push(_)}return a}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||re.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(let e of this.scene._serializableComponents)e.addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}}addToScene(e=null){let t=[];for(let i of this.cameras)e&&!e(i)||(this.scene.addCamera(i),t.push(i));for(let i of this.lights)e&&!e(i)||(this.scene.addLight(i),t.push(i));for(let i of this.meshes)e&&!e(i)||(this.scene.addMesh(i),t.push(i));for(let i of this.skeletons)e&&!e(i)||this.scene.addSkeleton(i);for(let i of this.animations)e&&!e(i)||this.scene.addAnimation(i);for(let i of this.animationGroups)e&&!e(i)||this.scene.addAnimationGroup(i);for(let i of this.multiMaterials)e&&!e(i)||this.scene.addMultiMaterial(i);for(let i of this.materials)e&&!e(i)||this.scene.addMaterial(i);for(let i of this.morphTargetManagers)e&&!e(i)||this.scene.addMorphTargetManager(i);for(let i of this.geometries)e&&!e(i)||this.scene.addGeometry(i);for(let i of this.transformNodes)e&&!e(i)||(this.scene.addTransformNode(i),t.push(i));for(let i of this.actionManagers)e&&!e(i)||this.scene.addActionManager(i);for(let i of this.textures)e&&!e(i)||this.scene.addTexture(i);for(let i of this.reflectionProbes)e&&!e(i)||this.scene.addReflectionProbe(i);for(let i of this.spriteManagers)e&&!e(i)||(this.scene.spriteManagers||(this.scene.spriteManagers=[]),this.scene.spriteManagers.push(i));if(t.length){let i=new Set(this.scene.meshes);for(let r of this.scene.lights)i.add(r);for(let r of this.scene.cameras)i.add(r);for(let r of this.scene.transformNodes)i.add(r);for(let r of this.skeletons)for(let s of r.bones)i.add(s);for(let r of t)r.parent&&!i.has(r.parent)&&(r.setParent?r.setParent(null):r.parent=null)}}removeAllFromScene(){this._isValidHierarchy()||re.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(let e of this.scene._serializableComponents)e.removeFromContainer(this)}removeFromScene(e=null){for(let t of this.cameras)e&&!e(t)||this.scene.removeCamera(t);for(let t of this.lights)e&&!e(t)||this.scene.removeLight(t);for(let t of this.meshes)e&&!e(t)||this.scene.removeMesh(t,!0);for(let t of this.skeletons)e&&!e(t)||this.scene.removeSkeleton(t);for(let t of this.animations)e&&!e(t)||this.scene.removeAnimation(t);for(let t of this.animationGroups)e&&!e(t)||this.scene.removeAnimationGroup(t);for(let t of this.multiMaterials)e&&!e(t)||this.scene.removeMultiMaterial(t);for(let t of this.materials)e&&!e(t)||this.scene.removeMaterial(t);for(let t of this.morphTargetManagers)e&&!e(t)||this.scene.removeMorphTargetManager(t);for(let t of this.geometries)e&&!e(t)||this.scene.removeGeometry(t);for(let t of this.transformNodes)e&&!e(t)||this.scene.removeTransformNode(t);for(let t of this.actionManagers)e&&!e(t)||this.scene.removeActionManager(t);for(let t of this.textures)e&&!e(t)||this.scene.removeTexture(t);for(let t of this.reflectionProbes)e&&!e(t)||this.scene.removeReflectionProbe(t);for(let t of this.spriteManagers)if(!(e&&!e(t))&&this.scene.spriteManagers){let i=this.scene.spriteManagers.indexOf(t);i!==-1&&this.scene.spriteManagers.splice(i,1)}}dispose(){let e=this.cameras.slice(0);for(let p of e)p.dispose();this.cameras.length=0;let t=this.lights.slice(0);for(let p of t)p.dispose();this.lights.length=0;let i=this.meshes.slice(0);for(let p of i)p.dispose();this.meshes.length=0;let r=this.skeletons.slice(0);for(let p of r)p.dispose();this.skeletons.length=0;let s=this.animationGroups.slice(0);for(let p of s)p.dispose();this.animationGroups.length=0;let a=this.multiMaterials.slice(0);for(let p of a)p.dispose();this.multiMaterials.length=0;let o=this.materials.slice(0);for(let p of o)p.dispose();this.materials.length=0;let l=this.geometries.slice(0);for(let p of l)p.dispose();this.geometries.length=0;let c=this.transformNodes.slice(0);for(let p of c)p.dispose();this.transformNodes.length=0;let f=this.actionManagers.slice(0);for(let p of f)p.dispose();this.actionManagers.length=0;let d=this.textures.slice(0);for(let p of d)p.dispose();this.textures.length=0;let h=this.reflectionProbes.slice(0);for(let p of h)p.dispose();this.reflectionProbes.length=0;let u=this.morphTargetManagers.slice(0);for(let p of u)p.dispose();this.morphTargetManagers.length=0;let m=this.spriteManagers.slice(0);for(let p of m)p.dispose();this.spriteManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(let p of this.scene._serializableComponents)p.removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}_moveAssets(e,t,i){if(!(!e||!t))for(let r of e){let s=!0;if(i){for(let a of i)if(r===a){s=!1;break}}s&&(t.push(r),r._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,e===void 0&&(e=new uT);for(let 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(){let e=new V("assetContainerRootMesh",this.scene);for(let t of this.meshes)t.parent||e.addChild(t);return this.meshes.unshift(e),e}mergeAnimationsTo(e=ue.LastCreatedScene,t,i=null){if(!e)return W.Error("No scene available to merge animations to"),[];let r=i||(l=>{let c,f=l.animations.length?l.animations[0].targetProperty:"",d=l.name.split(".").join("").split("_primitive")[0];switch(f){case"position":case"rotationQuaternion":c=e.getTransformNodeByName(l.name)||e.getTransformNodeByName(d);break;case"influence":c=e.getMorphTargetByName(l.name)||e.getMorphTargetByName(d);break;default:c=e.getNodeByName(l.name)||e.getNodeByName(d)}return c}),s=this.getNodes();for(let l of s){let c=r(l);if(c!==null){for(let f of l.animations){let d=c.animations.filter(h=>h.targetProperty===f.targetProperty);for(let h of d){let u=c.animations.indexOf(h,0);u>-1&&c.animations.splice(u,1)}}c.animations=c.animations.concat(l.animations)}}let a=[],o=this.animationGroups.slice();for(let l of o){a.push(l.clone(l.name,r));for(let c of l.animatables)c.stop()}for(let l of t){let c=r(l.target);c&&(e.beginAnimation(c,l.fromFrame,l.toFrame,l.loopAnimation,l.speedRatio,l.onAnimationEnd?l.onAnimationEnd:void 0,void 0,!0,void 0,l.onAnimationLoop?l.onAnimationLoop:void 0),e.stopAnimation(l.target))}return a}populateRootNodes(){this.rootNodes.length=0;for(let e of this.meshes)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.transformNodes)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.lights)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e);for(let e of this.cameras)!e.parent&&this.rootNodes.indexOf(e)===-1&&this.rootNodes.push(e)}addAllAssetsToContainer(e){if(!e)return;let t=[],i=new Set;for(t.push(e);t.length>0;){let r=t.pop();if(r instanceof V?(r.geometry&&this.geometries.indexOf(r.geometry)===-1&&this.geometries.push(r.geometry),this.meshes.push(r)):r instanceof xs?this.meshes.push(r):r instanceof at?this.transformNodes.push(r):r instanceof tt?this.lights.push(r):r instanceof Ue&&this.cameras.push(r),r instanceof zt){if(r.material&&this.materials.indexOf(r.material)===-1){this.materials.push(r.material);for(let s of r.material.getActiveTextures())this.textures.indexOf(s)===-1&&this.textures.push(s)}r.skeleton&&this.skeletons.indexOf(r.skeleton)===-1&&this.skeletons.push(r.skeleton),r.morphTargetManager&&this.morphTargetManagers.indexOf(r.morphTargetManager)===-1&&this.morphTargetManagers.push(r.morphTargetManager)}for(let s of r.getChildren())i.has(s)||t.push(s);i.add(r)}this.populateRootNodes()}_getByTags(e,t,i){if(t===void 0)return e;let r=[];for(let s in e){let a=e[s];nt&&nt.MatchesQuery(a,t)&&(!i||i(a))&&r.push(a)}return r}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)}getMaterialsByTags(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)}}});var Bo,LO=A(()=>{jc();Bo=class{constructor(e){this.byteOffset=0,this.buffer=e}async loadAsync(e){let t=await this.buffer.readAsync(this.byteOffset,e);this._dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),this._dataByteOffset=0}readUint32(){let e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e}readUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t}readString(e){return kI(this.readUint8Array(e))}skipBytes(e){this._dataByteOffset+=e,this.byteOffset+=e}}});function pT(n,e,t,i){let r={externalResourceFunction:i};return t&&(r.uri=e==="file:"?t:e+t),ArrayBuffer.isView(n)?GLTFValidator.validateBytes(n,r):GLTFValidator.validateString(n,r)}function Iz(){let n=[];onmessage=e=>{let t=e.data;switch(t.id){case"init":{importScripts(t.url);break}case"validate":{pT(t.data,t.rootUrl,t.fileName,i=>new Promise((r,s)=>{let a=n.length;n.push({resolve:r,reject:s}),postMessage({id:"getExternalResource",index:a,uri:i})})).then(i=>{postMessage({id:"validate.resolve",value:i})},i=>{postMessage({id:"validate.reject",reason:i})});break}case"getExternalResource.resolve":{n[t.index].resolve(t.value);break}case"getExternalResource.reject":{n[t.index].reject(t.reason);break}}}}var uc,PO=A(()=>{Tt();uc=class n{static ValidateAsync(e,t,i,r){return typeof Worker=="function"?new Promise((s,a)=>{let o=`${pT}(${Iz})()`,l=URL.createObjectURL(new Blob([o],{type:"application/javascript"})),c=new Worker(l),f=h=>{c.removeEventListener("error",f),c.removeEventListener("message",d),a(h)},d=h=>{let u=h.data;switch(u.id){case"getExternalResource":{r(u.uri).then(m=>{c.postMessage({id:"getExternalResource.resolve",index:u.index,value:m},[m.buffer])},m=>{c.postMessage({id:"getExternalResource.reject",index:u.index,reason:m})});break}case"validate.resolve":{c.removeEventListener("error",f),c.removeEventListener("message",d),n._LastResults=u.value,s(u.value),c.terminate();break}case"validate.reject":c.removeEventListener("error",f),c.removeEventListener("message",d),a(u.reason),c.terminate()}};if(c.addEventListener("error",f),c.addEventListener("message",d),c.postMessage({id:"init",url:re.GetBabylonScriptURL(this.Configuration.url)}),ArrayBuffer.isView(e)){let h=e.slice();c.postMessage({id:"validate",data:h,rootUrl:t,fileName:i},[h.buffer])}else c.postMessage({id:"validate",data:e,rootUrl:t,fileName:i})}):(this._LoadScriptPromise||(this._LoadScriptPromise=re.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>pT(e,t,i,r)))}};uc.Configuration={url:`${re._DefaultCdnUrl}/gltf_validator.js`};uc._LastResults=null});var Ys,jf,OO=A(()=>{Ys="Z2xURg",jf={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad(n){return n.indexOf("asset")!==-1&&n.indexOf("version")!==-1||n.startsWith("data:base64,"+Ys)||n.startsWith("data:;base64,"+Ys)||n.startsWith("data:application/octet-stream;base64,"+Ys)||n.startsWith("data:model/gltf-binary;base64,"+Ys)}}});function NO(n,e,t){try{return Promise.resolve(new Uint8Array(n,e,t))}catch(i){return Promise.reject(i)}}function xz(n,e,t){try{if(e<0||e>=n.byteLength)throw new RangeError("Offset is out of range.");if(e+t>n.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(n.buffer,n.byteOffset+e,t))}catch(i){return Promise.reject(i)}}var mc,Uo,ji,Pm,Cz,_T,Ya,gT=A(()=>{ft();Tt();hc();Kf();ze();LO();PO();OO();ds();Kc();(function(n){n[n.AUTO=0]="AUTO",n[n.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(mc||(mc={}));(function(n){n[n.NONE=0]="NONE",n[n.FIRST=1]="FIRST",n[n.ALL=2]="ALL"})(Uo||(Uo={}));(function(n){n[n.LOADING=0]="LOADING",n[n.READY=1]="READY",n[n.COMPLETE=2]="COMPLETE"})(ji||(ji={}));Pm=class{constructor(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=Uo.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=mc.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1}},Cz=new Pm,_T=class extends Pm{constructor(){super(...arguments),this.extensionOptions={},this.preprocessUrlAsync=e=>Promise.resolve(e)}copyFrom(e){var t,i,r,s,a,o,l,c,f,d,h,u,m,p,_,g,T,b,R,S,I,x,P,L,y,B;e&&(this.alwaysComputeBoundingBox=(t=e.alwaysComputeBoundingBox)!=null?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=(i=e.alwaysComputeSkeletonRootNode)!=null?i:this.alwaysComputeSkeletonRootNode,this.animationStartMode=(r=e.animationStartMode)!=null?r:this.animationStartMode,this.capturePerformanceCounters=(s=e.capturePerformanceCounters)!=null?s:this.capturePerformanceCounters,this.compileMaterials=(a=e.compileMaterials)!=null?a:this.compileMaterials,this.compileShadowGenerators=(o=e.compileShadowGenerators)!=null?o:this.compileShadowGenerators,this.coordinateSystemMode=(l=e.coordinateSystemMode)!=null?l:this.coordinateSystemMode,this.createInstances=(c=e.createInstances)!=null?c:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=(f=e.extensionOptions)!=null?f:this.extensionOptions,this.loadAllMaterials=(d=e.loadAllMaterials)!=null?d:this.loadAllMaterials,this.loadMorphTargets=(h=e.loadMorphTargets)!=null?h:this.loadMorphTargets,this.loadNodeAnimations=(u=e.loadNodeAnimations)!=null?u:this.loadNodeAnimations,this.loadOnlyMaterials=(m=e.loadOnlyMaterials)!=null?m:this.loadOnlyMaterials,this.loadSkins=(p=e.loadSkins)!=null?p:this.loadSkins,this.loggingEnabled=(_=e.loggingEnabled)!=null?_:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=(g=e.preprocessUrlAsync)!=null?g:this.preprocessUrlAsync,this.skipMaterials=(T=e.skipMaterials)!=null?T:this.skipMaterials,this.targetFps=(b=e.targetFps)!=null?b:this.targetFps,this.transparencyAsCoverage=(R=e.transparencyAsCoverage)!=null?R:this.transparencyAsCoverage,this.useClipPlane=(S=e.useClipPlane)!=null?S:this.useClipPlane,this.useGltfTextureNames=(I=e.useGltfTextureNames)!=null?I:this.useGltfTextureNames,this.useOpenPBR=(x=e.useOpenPBR)!=null?x:this.useOpenPBR,this.useRangeRequests=(P=e.useRangeRequests)!=null?P:this.useRangeRequests,this.useSRGBBuffers=(L=e.useSRGBBuffers)!=null?L:this.useSRGBBuffers,this.validate=(y=e.validate)!=null?y:this.validate,this.dontUseTransmissionHelper=(B=e.dontUseTransmissionHelper)!=null?B:this.dontUseTransmissionHelper)}},Ya=class n extends _T{constructor(e){super(),this.onParsedObservable=new Y,this.onMeshLoadedObservable=new Y,this.onSkinLoadedObservable=new Y,this.onTextureLoadedObservable=new Y,this.onMaterialLoadedObservable=new Y,this.onCameraLoadedObservable=new Y,this.onCompleteObservable=new Y,this.onErrorObservable=new Y,this.onDisposeObservable=new Y,this.onExtensionLoadedObservable=new Y,this.onValidatedObservable=new Y,this._loader=null,this._state=null,this._requests=new Array,this.name=jf.name,this.extensions=jf.extensions,this.onLoaderStateChangedObservable=new Y,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled,this.copyFrom(Object.assign({...Cz},e))}set onParsed(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))}set onMeshLoaded(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))}set onSkinLoaded(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(t=>e(t.node,t.skinnedNode)))}set onTextureLoaded(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))}set onMaterialLoaded(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))}set onCameraLoaded(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))}set onComplete(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)}set onError(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set onExtensionLoaded(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)}get loggingEnabled(){return this._loggingEnabled}set loggingEnabled(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)}get capturePerformanceCounters(){return this._capturePerformanceCounters}set capturePerformanceCounters(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))}set onValidated(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)}dispose(){this._loader&&(this._loader.dispose(),this._loader=null);for(let e of this._requests)e.abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=e=>Promise.resolve(e),this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()}loadFile(e,t,i,r,s,a,o,l){if(ArrayBuffer.isView(t))return this._loadBinary(e,t,i,r,o,l),null;this._progressCallback=s;let c=t.name||re.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&W.Warn("glTF validation is not supported when range requests are enabled");let f={abort:()=>{},onCompleteObservable:new Y},d={readAsync:(h,u)=>new Promise((m,p)=>{this._loadFile(e,t,_=>{m(new Uint8Array(_))},!0,_=>{p(_)},_=>{_.setRequestHeader("Range",`bytes=${h}-${h+u-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new Bo(d)).then(h=>{f.onCompleteObservable.notifyObservers(f),r(h)},o?h=>o(void 0,h):void 0),f}return this._loadFile(e,t,f=>{this._validate(e,new Uint8Array(f,0,f.byteLength),i,c),this._unpackBinaryAsync(new Bo({readAsync:(d,h)=>NO(f,d,h),byteLength:f.byteLength})).then(d=>{r(d)},o?d=>o(void 0,d):void 0)},!0,o)}else return this._loadFile(e,t,f=>{try{this._validate(e,f,i,c),r({json:this._parseJson(f)})}catch(d){o&&o()}},!1,o)}_loadBinary(e,t,i,r,s,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i,a),this._unpackBinaryAsync(new Bo({readAsync:(o,l)=>xz(t,o,l),byteLength:t.byteLength})).then(o=>{r(o)},s?o=>s(void 0,o):void 0)}importMeshAsync(e,t,i,r,s,a){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(i),this.onParsedObservable.clear(),this._log(`Loading ${a||""}`),this._loader=this._getLoader(i),this._loader.importMeshAsync(e,t,null,i,r,s,a)))}loadAsync(e,t,i,r,s){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,i,r,s)))}loadAssetContainerAsync(e,t,i,r,s){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t);let a=new jn(e),o=[];this.onMaterialLoadedObservable.add(d=>{o.push(d)});let l=[];this.onTextureLoadedObservable.add(d=>{l.push(d)});let c=[];this.onCameraLoadedObservable.add(d=>{c.push(d)});let f=[];return this.onMeshLoadedObservable.add(d=>{d.morphTargetManager&&f.push(d.morphTargetManager)}),this._loader.importMeshAsync(null,e,a,t,i,r,s).then(d=>(Array.prototype.push.apply(a.geometries,d.geometries),Array.prototype.push.apply(a.meshes,d.meshes),Array.prototype.push.apply(a.particleSystems,d.particleSystems),Array.prototype.push.apply(a.skeletons,d.skeletons),Array.prototype.push.apply(a.animationGroups,d.animationGroups),Array.prototype.push.apply(a.materials,o),Array.prototype.push.apply(a.textures,l),Array.prototype.push.apply(a.lights,d.lights),Array.prototype.push.apply(a.transformNodes,d.transformNodes),Array.prototype.push.apply(a.cameras,c),Array.prototype.push.apply(a.morphTargetManagers,f),a))})}canDirectLoad(e){return jf.canDirectLoad(e)}directLoad(e,t){if(t.startsWith("base64,"+Ys)||t.startsWith(";base64,"+Ys)||t.startsWith("application/octet-stream;base64,"+Ys)||t.startsWith("model/gltf-binary;base64,"+Ys)){let i=da(t);return this._validate(e,new Uint8Array(i,0,i.byteLength)),this._unpackBinaryAsync(new Bo({readAsync:(r,s)=>NO(i,r,s),byteLength:i.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})}createPlugin(e){return new n(e[jf.name])}get loaderState(){return this._state}whenCompleteAsync(){return new Promise((e,t)=>{this.onCompleteObservable.addOnce(()=>{e()}),this.onErrorObservable.addOnce(i=>{t(i)})})}_setState(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(ji[this._state]))}_loadFile(e,t,i,r,s,a){let o=e._loadFile(t,i,l=>{this._onProgress(l,o)},!0,r,s,a);return o.onCompleteObservable.add(()=>{o._lengthComputable=!0,o._total=o._loaded}),this._requests.push(o),o}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let i=!0,r=0,s=0;for(let a of this._requests){if(a._lengthComputable===void 0||a._loaded===void 0||a._total===void 0)return;i=i&&a._lengthComputable,r+=a._loaded,s+=a._total}this._progressCallback({lengthComputable:i,loaded:r,total:i?s:0})}_validate(e,t,i="",r=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),uc.ValidateAsync(t,i,r,s=>this.preprocessUrlAsync(i+s).then(a=>e._loadFileAsync(a,void 0,!0,!0).then(o=>new Uint8Array(o,0,o.byteLength)))).then(s=>{this._endPerformanceCounter("Validate JSON"),this.onValidatedObservable.notifyObservers(s),this.onValidatedObservable.clear()},s=>{this._endPerformanceCounter("Validate JSON"),re.Warn(`Failed to validate: ${s.message}`),this.onValidatedObservable.clear()}))}_getLoader(e){let t=e.json.asset||{};this._log(`Asset version: ${t.version}`),t.minVersion&&this._log(`Asset minimum version: ${t.minVersion}`),t.generator&&this._log(`Asset generator: ${t.generator}`);let i=n._parseVersion(t.version);if(!i)throw new Error("Invalid version: "+t.version);if(t.minVersion!==void 0){let a=n._parseVersion(t.minVersion);if(!a)throw new Error("Invalid minimum version: "+t.minVersion);if(n._compareVersion(a,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}let s={1:n._CreateGLTF1Loader,2:n._CreateGLTF2Loader}[i.major];if(!s)throw new Error("Unsupported version: "+t.version);return s(this)}_parseJson(e){this._startPerformanceCounter("Parse JSON"),this._log(`JSON length: ${e.length}`);let t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t}_unpackBinaryAsync(e){return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(()=>{let t={Magic:1179937895},i=e.readUint32();if(i!==t.Magic)throw new nr("Unexpected magic: "+i,Or.GLTFLoaderUnexpectedMagicError);let r=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${r}`);let s=e.readUint32();!this.useRangeRequests&&s!==e.buffer.byteLength&&W.Warn(`Length in header does not match actual data length: ${s} != ${e.buffer.byteLength}`);let a;switch(r){case 1:{a=this._unpackBinaryV1Async(e,s);break}case 2:{a=this._unpackBinaryV2Async(e,s);break}default:throw new Error("Unsupported version: "+r)}return this._endPerformanceCounter("Unpack Binary"),a})}_unpackBinaryV1Async(e,t){let i={JSON:0},r=e.readUint32(),s=e.readUint32();if(s!==i.JSON)throw new Error(`Unexpected content format: ${s}`);let a=t-e.byteOffset,o={json:this._parseJson(e.readString(r)),bin:null};if(a!==0){let l=e.byteOffset;o.bin={readAsync:(c,f)=>e.buffer.readAsync(l+c,f),byteLength:a}}return Promise.resolve(o)}_unpackBinaryV2Async(e,t){let i={JSON:1313821514,BIN:5130562},r=e.readUint32();if(e.readUint32()!==i.JSON)throw new Error("First chunk format is not JSON");return e.byteOffset+r===t?e.loadAsync(r).then(()=>({json:this._parseJson(e.readString(r)),bin:null})):e.loadAsync(r+8).then(()=>{let a={json:this._parseJson(e.readString(r)),bin:null},o=()=>{let l=e.readUint32();switch(e.readUint32()){case i.JSON:throw new Error("Unexpected JSON chunk");case i.BIN:{let f=e.byteOffset;a.bin={readAsync:(d,h)=>e.buffer.readAsync(f+d,h),byteLength:l},e.skipBytes(l);break}default:{e.skipBytes(l);break}}return e.byteOffset!==t?e.loadAsync(8).then(o):Promise.resolve(a)};return o()})}static _parseVersion(e){if(e==="1.0"||e==="1.0.1")return{major:1,minor:0};let t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null}static _compareVersion(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor{Om=class{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}}});var Gi,wO=A(()=>{Qe();qe();Xn();Ph();ve();Tt();Gi=class{constructor(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this.keysRotateUp=[],this.keysRotateDown=[],this._keys=new Array}attachControl(e){e=re.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=>{let i=t.event;if(!i.metaKey){if(t.type===hn.KEYDOWN)(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.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1)&&(this._keys.indexOf(i.keyCode)===-1&&this._keys.push(i.keyCode),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.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1){let r=this._keys.indexOf(i.keyCode);r>=0&&this._keys.splice(r,1),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){let e=this.camera;for(let t=0;t{Qe();ft();qe();Xn();dn();Tt();Vo=class{constructor(e=!0){this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this._previousPosition=null,this.onPointerMovedObservable=new Y,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement();this._pointerInput||(this._pointerInput=r=>{let s=r.event,a=s.pointerType==="touch";if(!this.touchEnabled&&a||r.type!==ye.POINTERMOVE&&this.buttons.indexOf(s.button)===-1)return;let o=s.target;if(r.type===ye.POINTERDOWN){if(a&&this._activePointerId!==-1||!a&&this._currentActiveButton!==-1)return;this._activePointerId=s.pointerId;try{o==null||o.setPointerCapture(s.pointerId)}catch(l){}this._currentActiveButton===-1&&(this._currentActiveButton=s.button),this._previousPosition={x:s.clientX,y:s.clientY},e||(s.preventDefault(),i&&i.focus()),t.isPointerLock&&this._onMouseMove&&this._onMouseMove(r.event)}else if(r.type===ye.POINTERUP){if(a&&this._activePointerId!==s.pointerId||!a&&this._currentActiveButton!==s.button)return;try{o==null||o.releasePointerCapture(s.pointerId)}catch(l){}this._currentActiveButton=-1,this._previousPosition=null,e||s.preventDefault(),this._activePointerId=-1}else if(r.type===ye.POINTERMOVE&&(this._activePointerId===s.pointerId||!a)){if(t.isPointerLock&&this._onMouseMove)this._onMouseMove(r.event);else if(this._previousPosition){let l=this.camera._calculateHandednessMultiplier(),c=(s.clientX-this._previousPosition.x)*l,f=(s.clientY-this._previousPosition.y)*l;this._allowCameraRotation&&(this.camera.cameraRotation.y+=c/this.angularSensibility,this.camera.cameraRotation.x+=f/this.angularSensibility),this.onPointerMovedObservable.notifyObservers({offsetX:c,offsetY:f}),this._previousPosition={x:s.clientX,y:s.clientY},e||s.preventDefault()}}}),this._onMouseMove=r=>{if(!t.isPointerLock)return;let s=this.camera._calculateHandednessMultiplier();this.camera.cameraRotation.y+=r.movementX*s/this.angularSensibility,this.camera.cameraRotation.x+=r.movementY*s/this.angularSensibility,this._previousPosition=null,e||r.preventDefault()},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE),i&&(this._contextMenuBind=r=>this.onContextMenu(r),i.addEventListener("contextmenu",this._contextMenuBind,!1))}onContextMenu(e){e.preventDefault()}detachControl(){if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._contextMenuBind){let t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("contextmenu",this._contextMenuBind)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this._previousPosition=null}this._activePointerId=-1,this._currentActiveButton=-1}getClassName(){return"FreeCameraMouseInput"}getSimpleName(){return"mouse"}};C([D()],Vo.prototype,"buttons",void 0);C([D()],Vo.prototype,"angularSensibility",void 0);wi.FreeCameraMouseInput=Vo});var Go,UO=A(()=>{Qe();qe();ft();dn();Oh();Tt();Go=class{constructor(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new Y,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==ye.POINTERWHEEL)return;let i=t.event,r=i.deltaMode===un.DOM_DELTA_LINE?this._ffMultiplier:1;this._wheelDeltaX+=this.wheelPrecisionX*r*i.deltaX/this._normalize,this._wheelDeltaY-=this.wheelPrecisionY*r*i.deltaY/this._normalize,this._wheelDeltaZ+=this.wheelPrecisionZ*r*i.deltaZ/this._normalize,i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,ye.POINTERWHEEL)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()}checkInputs(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0}getClassName(){return"BaseCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}};C([D()],Go.prototype,"wheelPrecisionX",void 0);C([D()],Go.prototype,"wheelPrecisionY",void 0);C([D()],Go.prototype,"wheelPrecisionZ",void 0)});var It,ur,VO=A(()=>{Qe();qe();Xn();UO();ve();(function(n){n[n.MoveRelative=0]="MoveRelative",n[n.RotateRelative=1]="RotateRelative",n[n.MoveScene=2]="MoveScene"})(It||(It={}));ur=class extends Go{constructor(){super(...arguments),this._moveRelative=v.Zero(),this._rotateRelative=v.Zero(),this._moveScene=v.Zero(),this._wheelXAction=It.MoveRelative,this._wheelXActionCoordinate=0,this._wheelYAction=It.MoveRelative,this._wheelYActionCoordinate=2,this._wheelZAction=null,this._wheelZActionCoordinate=null}getClassName(){return"FreeCameraMouseWheelInput"}set wheelXMoveRelative(e){e===null&&this._wheelXAction!==It.MoveRelative||(this._wheelXAction=It.MoveRelative,this._wheelXActionCoordinate=e)}get wheelXMoveRelative(){return this._wheelXAction!==It.MoveRelative?null:this._wheelXActionCoordinate}set wheelYMoveRelative(e){e===null&&this._wheelYAction!==It.MoveRelative||(this._wheelYAction=It.MoveRelative,this._wheelYActionCoordinate=e)}get wheelYMoveRelative(){return this._wheelYAction!==It.MoveRelative?null:this._wheelYActionCoordinate}set wheelZMoveRelative(e){e===null&&this._wheelZAction!==It.MoveRelative||(this._wheelZAction=It.MoveRelative,this._wheelZActionCoordinate=e)}get wheelZMoveRelative(){return this._wheelZAction!==It.MoveRelative?null:this._wheelZActionCoordinate}set wheelXRotateRelative(e){e===null&&this._wheelXAction!==It.RotateRelative||(this._wheelXAction=It.RotateRelative,this._wheelXActionCoordinate=e)}get wheelXRotateRelative(){return this._wheelXAction!==It.RotateRelative?null:this._wheelXActionCoordinate}set wheelYRotateRelative(e){e===null&&this._wheelYAction!==It.RotateRelative||(this._wheelYAction=It.RotateRelative,this._wheelYActionCoordinate=e)}get wheelYRotateRelative(){return this._wheelYAction!==It.RotateRelative?null:this._wheelYActionCoordinate}set wheelZRotateRelative(e){e===null&&this._wheelZAction!==It.RotateRelative||(this._wheelZAction=It.RotateRelative,this._wheelZActionCoordinate=e)}get wheelZRotateRelative(){return this._wheelZAction!==It.RotateRelative?null:this._wheelZActionCoordinate}set wheelXMoveScene(e){e===null&&this._wheelXAction!==It.MoveScene||(this._wheelXAction=It.MoveScene,this._wheelXActionCoordinate=e)}get wheelXMoveScene(){return this._wheelXAction!==It.MoveScene?null:this._wheelXActionCoordinate}set wheelYMoveScene(e){e===null&&this._wheelYAction!==It.MoveScene||(this._wheelYAction=It.MoveScene,this._wheelYActionCoordinate=e)}get wheelYMoveScene(){return this._wheelYAction!==It.MoveScene?null:this._wheelYActionCoordinate}set wheelZMoveScene(e){e===null&&this._wheelZAction!==It.MoveScene||(this._wheelZAction=It.MoveScene,this._wheelZActionCoordinate=e)}get wheelZMoveScene(){return this._wheelZAction!==It.MoveScene?null:this._wheelZActionCoordinate}checkInputs(){if(this._wheelDeltaX===0&&this._wheelDeltaY===0&&this._wheelDeltaZ==0)return;this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);let e=U.Zero();this.camera.getViewMatrix().invertToRef(e);let t=v.Zero();v.TransformNormalToRef(this._moveRelative,e,t),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(t),this.camera.cameraDirection.addInPlace(this._moveScene),super.checkInputs()}_updateCamera(){this._updateCameraProperty(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),this._updateCameraProperty(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),this._updateCameraProperty(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)}_updateCameraProperty(e,t,i){if(e===0||t===null||i===null)return;let r=null;switch(t){case It.MoveRelative:r=this._moveRelative;break;case It.RotateRelative:r=this._rotateRelative;break;case It.MoveScene:r=this._moveScene;break}switch(i){case 0:r.set(e,0,0);break;case 1:r.set(0,e,0);break;case 2:r.set(0,0,e);break}}};C([D()],ur.prototype,"wheelXMoveRelative",null);C([D()],ur.prototype,"wheelYMoveRelative",null);C([D()],ur.prototype,"wheelZMoveRelative",null);C([D()],ur.prototype,"wheelXRotateRelative",null);C([D()],ur.prototype,"wheelYRotateRelative",null);C([D()],ur.prototype,"wheelZRotateRelative",null);C([D()],ur.prototype,"wheelXMoveScene",null);C([D()],ur.prototype,"wheelYMoveScene",null);C([D()],ur.prototype,"wheelZMoveScene",null);wi.FreeCameraMouseWheelInput=ur});var ko,GO=A(()=>{Qe();qe();Xn();dn();ve();Tt();ko=class{constructor(e=!1){this.allowMouse=e,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this.singleFingerRotate=!1,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array,this._isSafari=re.IsSafari()}attachControl(e){e=re.BackCompatCameraNoPreventDefault(arguments);let t=null;if(this._pointerInput===void 0&&(this._onLostFocus=()=>{this._offsetX=null,this._offsetY=null},this._pointerInput=i=>{let r=i.event,s=r.pointerType==="mouse"||this._isSafari&&typeof r.pointerType=="undefined";if(!(!this.allowMouse&&s)){if(i.type===ye.POINTERDOWN){if(e||r.preventDefault(),this._pointerPressed.push(r.pointerId),this._pointerPressed.length!==1)return;t={x:r.clientX,y:r.clientY}}else if(i.type===ye.POINTERUP){e||r.preventDefault();let a=this._pointerPressed.indexOf(r.pointerId);if(a===-1||(this._pointerPressed.splice(a,1),a!=0))return;t=null,this._offsetX=null,this._offsetY=null}else if(i.type===ye.POINTERMOVE){if(e||r.preventDefault(),!t||this._pointerPressed.indexOf(r.pointerId)!=0)return;this._offsetX=r.clientX-t.x,this._offsetY=-(r.clientY-t.y)}}}),this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,ye.POINTERDOWN|ye.POINTERUP|ye.POINTERMOVE),this._onLostFocus){let r=this.camera.getEngine().getInputElement();r&&r.addEventListener("blur",this._onLostFocus)}}detachControl(){if(this._pointerInput){if(this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null),this._onLostFocus){let t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed.length=0,this._offsetX=null,this._offsetY=null}}checkInputs(){if(this._offsetX===null||this._offsetY===null||this._offsetX===0&&this._offsetY===0)return;let e=this.camera,t=e._calculateHandednessMultiplier();if(e.cameraRotation.y=this._offsetX*t/this.touchAngularSensibility,this.singleFingerRotate&&this._pointerPressed.length===1||!this.singleFingerRotate&&this._pointerPressed.length>1)e.cameraRotation.x=-(this._offsetY*t)/this.touchAngularSensibility;else{let r=e._computeLocalCameraSpeed(),s=G.Vector3[0];s.copyFromFloats(0,0,this.touchMoveSensibility!==0?r*this._offsetY/this.touchMoveSensibility:0),U.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),v.TransformCoordinatesToRef(s,e._cameraRotationMatrix,s),e.cameraDirection.addInPlace(s)}}getClassName(){return"FreeCameraTouchInput"}getSimpleName(){return"touch"}};C([D()],ko.prototype,"touchAngularSensibility",void 0);C([D()],ko.prototype,"touchMoveSensibility",void 0);wi.FreeCameraTouchInput=ko});var Nm,kO=A(()=>{Xn();wO();BO();VO();GO();Nm=class extends Jl{constructor(e){super(e),this._mouseInput=null,this._mouseWheelInput=null}addKeyboard(){return this.add(new Gi),this}addMouse(e=!0){return this._mouseInput||(this._mouseInput=new Vo(e),this.add(this._mouseInput)),this}removeMouse(){return this._mouseInput&&this.remove(this._mouseInput),this}addMouseWheel(){return this._mouseWheelInput||(this._mouseWheelInput=new ur,this.add(this._mouseWheelInput)),this}removeMouseWheel(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this}addTouch(){return this.add(new ko),this}clear(){super.clear(),this._mouseInput=null}}});var Ks,WO=A(()=>{Qe();qe();ve();SE();kO();Tt();Lt();ii();Ks=class extends cr{get angularSensibility(){let e=this.inputs.attached.mouse;return e?e.angularSensibility:0}set angularSensibility(e){let t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)}get keysUp(){let e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysUpward(){let e=this.inputs.attached.keyboard;return e?e.keysUpward:[]}set keysUpward(e){let t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)}get keysDown(){let e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysDownward(){let e=this.inputs.attached.keyboard;return e?e.keysDownward:[]}set keysDownward(e){let t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)}get keysLeft(){let e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){let e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get keysRotateLeft(){let e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]}set keysRotateLeft(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)}get keysRotateRight(){let e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]}set keysRotateRight(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)}get keysRotateUp(){let e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]}set keysRotateUp(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateUp=e)}get keysRotateDown(){let e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]}set keysRotateDown(e){let t=this.inputs.attached.keyboard;t&&(t.keysRotateDown=e)}constructor(e,t,i,r=!0){super(e,t,i,r),this.ellipsoid=new v(.5,1,.5),this.ellipsoidOffset=new v(0,0,0),this.checkCollisions=!1,this.applyGravity=!1,this._needMoveForGravity=!1,this._oldPosition=v.Zero(),this._diffPosition=v.Zero(),this._newPosition=v.Zero(),this._collisionMask=-1,this._onCollisionPositionChange=(s,a,o=null)=>{this._newPosition.copyFrom(a),this._newPosition.subtractToRef(this._oldPosition,this._diffPosition),this._diffPosition.length()>fe.CollisionsEpsilon&&(this.position.addToRef(this._diffPosition,this._deferredPositionUpdate),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate),this.onCollide&&o&&this.onCollide(o))},this.inputs=new Nm(this),this.inputs.addKeyboard().addMouse()}attachControl(e,t){t=re.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)}detachControl(){this.inputs.detachElement(),this.cameraDirection=new v(0,0,0),this.cameraRotation=new _e(0,0)}get collisionMask(){return this._collisionMask}set collisionMask(e){this._collisionMask=isNaN(e)?-1:e}_collideWithWorld(e){let t;this.parent?t=v.TransformCoordinates(this.position,this.parent.getWorldMatrix()):t=this.position,t.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);let i=this.getScene().collisionCoordinator;this._collider||(this._collider=i.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;let r=e;this.applyGravity&&(r=e.add(this.getScene().gravity)),i.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}_checkInputs(){this._localDirection||(this._localDirection=v.Zero(),this._transformedDirection=v.Zero()),this.inputs.checkInputs(),super._checkInputs()}set needMoveForGravity(e){this._needMoveForGravity=e}get needMoveForGravity(){return this._needMoveForGravity}_decideIfNeedsToMove(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):super._updatePosition()}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"FreeCamera"}};C([ai()],Ks.prototype,"ellipsoid",void 0);C([ai()],Ks.prototype,"ellipsoidOffset",void 0);C([D()],Ks.prototype,"checkCollisions",void 0);C([D()],Ks.prototype,"applyGravity",void 0);je("BABYLON.FreeCamera",Ks)});var Zr,Fm=A(()=>{ve();Ln();Sr();Zr=class n extends ht{get _matrix(){return this._compose(),this._localMatrix}set _matrix(e){e.updateFlag===this._localMatrix.updateFlag&&!this._needToCompose||(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())}constructor(e,t,i=null,r=null,s=null,a=null,o=null){var l;super(e,t.getScene(),!1),this.name=e,this.children=[],this.animations=[],this._index=null,this._scalingDeterminant=1,this._needToDecompose=!0,this._needToCompose=!1,this._linkedTransformNode=null,this._waitingTransformNodeId=null,this._waitingTransformNodeUniqueId=null,this._skeleton=t,this._localMatrix=(l=r==null?void 0:r.clone())!=null?l:U.Identity(),this._restMatrix=s!=null?s:this._localMatrix.clone(),this._bindMatrix=a!=null?a:this._localMatrix.clone(),this._index=o,this._absoluteMatrix=new U,this._absoluteBindMatrix=new U,this._absoluteInverseBindMatrix=new U,this._finalMatrix=new U,t.bones.push(this),this.setParent(i,!1),this._updateAbsoluteBindMatrices()}getClassName(){return"Bone"}getSkeleton(){return this._skeleton}get parent(){return this._parentNode}getParent(){return this.parent}getChildren(){return this.children}getIndex(){return this._index===null?this.getSkeleton().bones.indexOf(this):this._index}set parent(e){this.setParent(e)}setParent(e,t=!0){if(this.parent!==e){if(this.parent){let i=this.parent.children.indexOf(this);i!==-1&&this.parent.children.splice(i,1)}this._parentNode=e,this.parent&&this.parent.children.push(this),t&&this._updateAbsoluteBindMatrices(),this.markAsDirty()}}getLocalMatrix(){return this._compose(),this._localMatrix}getBindMatrix(){return this._bindMatrix}getBaseMatrix(){return this.getBindMatrix()}getRestMatrix(){return this._restMatrix}getRestPose(){return this.getRestMatrix()}setRestMatrix(e){this._restMatrix.copyFrom(e)}setRestPose(e){this.setRestMatrix(e)}getBindPose(){return this.getBindMatrix()}setBindMatrix(e){this.updateMatrix(e)}setBindPose(e){this.setBindMatrix(e)}getFinalMatrix(){return this._finalMatrix}getWorldMatrix(){return this.getFinalMatrix()}returnToRest(){var e;if(this._linkedTransformNode){let t=G.Vector3[0],i=G.Quaternion[0],r=G.Vector3[1];this.getRestMatrix().decompose(t,i,r),this._linkedTransformNode.position.copyFrom(r),this._linkedTransformNode.rotationQuaternion=(e=this._linkedTransformNode.rotationQuaternion)!=null?e:Ae.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(i),this._linkedTransformNode.scaling.copyFrom(t)}else this._matrix=this._restMatrix}getAbsoluteInverseBindMatrix(){return this._absoluteInverseBindMatrix}getInvertedAbsoluteTransform(){return this.getAbsoluteInverseBindMatrix()}getAbsoluteMatrix(){return this._skeleton.computeAbsoluteMatrices(),this._absoluteMatrix}getAbsoluteTransform(){return this.getAbsoluteMatrix()}linkTransformNode(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++}getTransformNode(){return this._linkedTransformNode}get position(){return this._decompose(),this._localPosition}set position(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()}get rotation(){return this.getRotation()}set rotation(e){this.setRotation(e)}get rotationQuaternion(){return this._decompose(),this._localRotation}set rotationQuaternion(e){this.setRotationQuaternion(e)}get scaling(){return this.getScale()}set scaling(e){this.setScale(e)}get animationPropertiesOverride(){return this._skeleton.animationPropertiesOverride}_decompose(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=v.Zero(),this._localRotation=Ae.Zero(),this._localPosition=v.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))}_compose(){if(this._needToCompose){if(!this._localScaling){this._needToCompose=!1;return}this._needToCompose=!1,U.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)}}updateMatrix(e,t=!0,i=!0){this._bindMatrix.copyFrom(e),t&&this._updateAbsoluteBindMatrices(),i?this._matrix=e:this.markAsDirty()}_updateAbsoluteBindMatrices(e,t=!0){if(e||(e=this._bindMatrix),this.parent?e.multiplyToRef(this.parent._absoluteBindMatrix,this._absoluteBindMatrix):this._absoluteBindMatrix.copyFrom(e),this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix),t)for(let i=0;i{oi();Zf=class n extends ne{constructor(e,t,i,r,s,a=!0,o=!1,l=3,c=0,f,d,h,u){super(null,s,!a,o,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,f),this.format=r,this._engine&&(!this._engine._caps.textureFloatLinearFiltering&&c===1&&(l=1),!this._engine._caps.textureHalfFloatLinearFiltering&&c===2&&(l=1),this._texture=this._engine.createRawTexture(e,t,i,r,a,o,l,null,c,f!=null?f:0,d!=null?d:!1,u),this.wrapU=ne.CLAMP_ADDRESSMODE,this.wrapV=ne.CLAMP_ADDRESSMODE,this._waitingForData=!!h&&!e)}update(e){this.updateMipLevel(e,0)}updateMipLevel(e,t){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer,t),this._waitingForData=!1}clone(){if(!this._texture)return super.clone();let e=new n(null,this.getSize().width,this.getSize().height,this.format,this.getScene(),this._texture.generateMipMaps,this._invertY,this.samplingMode,this._texture.type,this._texture._creationFlags,this._useSRGBBuffer);return e._texture=this._texture,this._texture.incrementReferences(),e}isReady(){return super.isReady()&&!this._waitingForData}static CreateLuminanceTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,1,r,s,a,o)}static CreateLuminanceAlphaTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,2,r,s,a,o)}static CreateAlphaTexture(e,t,i,r,s=!0,a=!1,o=3){return new n(e,t,i,0,r,s,a,o)}static CreateRGBTexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=0,f=!1){return new n(e,t,i,4,r,s,a,o,l,c,f)}static CreateRGBATexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=0,f=!1,d=!1){return new n(e,t,i,5,r,s,a,o,l,c,f,d)}static CreateRGBAStorageTexture(e,t,i,r,s=!0,a=!1,o=3,l=0,c=!1){return new n(e,t,i,5,r,s,a,o,l,1,c)}static CreateRTexture(e,t,i,r,s=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new n(e,t,i,6,r,s,a,o,l)}static CreateRStorageTexture(e,t,i,r,s=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new n(e,t,i,6,r,s,a,o,l,1)}}});var wm,zO=A(()=>{Fm();ft();ve();HO();Is();uE();At();ze();Qc();wm=class n{get useTextureToStoreBoneMatrices(){return this._useTextureToStoreBoneMatrices}set useTextureToStoreBoneMatrices(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}get isUsingTextureForMatrices(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones}get uniqueId(){return this._uniqueId}constructor(e,t,i){this.name=e,this.id=t,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=U.Identity(),this._currentRenderId=-1,this._textureWidth=0,this._textureHeight=1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new Y,this.metadata=null,this.bones=[],this._scene=i||ue.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;let r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}getClassName(){return"Skeleton"}getChildren(){return this.bones.filter(e=>!e.getParent())}getTransformMatrices(e){if(this.needInitialSkinMatrix){if(!e)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return e._bonesTransformMatrices||this.prepare(!0),e._bonesTransformMatrices}return(!this._transformMatrices||this._isDirty)&&this.prepare(!this._transformMatrices),this._transformMatrices}getTransformMatrixTexture(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture}getScene(){return this._scene}toString(e){let t=`Name: ${this.name}, nBones: ${this.bones.length}`;if(t+=`, nAnimationRanges: ${this._ranges?Object.keys(this._ranges).length:"none"}`,e){t+=", Ranges: {";let i=!0;for(let r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t}getBoneIndexByName(e){for(let t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)}_computeTransformMatrices(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(let i=0;i0){for(let r of this.bones)if(r._linkedTransformNode){let s=r._linkedTransformNode;r.position=s.position,s.rotationQuaternion?r.rotationQuaternion=s.rotationQuaternion:r.rotation=s.rotation,r.scaling=s.scaling}}let t=null;if(this.needInitialSkinMatrix)for(let r of this._meshesWithPoseMatrix){let s=r.getPoseMatrix(),a=this._isDirty;if(t===null&&(t=this._computeTextureSize()),(!r._bonesTransformMatrices||r._bonesTransformMatrices.length!==t)&&(r._bonesTransformMatrices=new Float32Array(t),a=!0),!!a){if(this._synchronizedWithMesh!==r){this._synchronizedWithMesh=r;for(let o of this.bones)o.getParent()||(o.getBindMatrix().multiplyToRef(s,G.Matrix[1]),o._updateAbsoluteBindMatrices(G.Matrix[1]));if(this.isUsingTextureForMatrices){let o=(i=r._transformMatrixTexture)==null?void 0:i.getSize(),l=o?o.width*o.height*4:0;(!r._transformMatrixTexture||l!==t)&&(r._transformMatrixTexture&&r._transformMatrixTexture.dispose(),r._transformMatrixTexture=Zf.CreateRGBATexture(r._bonesTransformMatrices,this._textureWidth,this._textureHeight,this._scene,!1,!1,1,1))}}this._computeTransformMatrices(r._bonesTransformMatrices,s),this.isUsingTextureForMatrices&&r._transformMatrixTexture&&r._transformMatrixTexture.update(r._bonesTransformMatrices)}}else{if(!this._isDirty)return;t===null&&(t=this._computeTextureSize()),(!this._transformMatrices||this._transformMatrices.length!==t)&&(this._transformMatrices=new Float32Array(t),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=Zf.CreateRGBATexture(this._transformMatrices,this._textureWidth,this._textureHeight,this._scene,!1,!1,1,1))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices)}this._isDirty=!1}getAnimatables(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(let e=0;e-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)}serialize(){var t,i;let e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix,this.metadata&&(e.metadata=this.metadata);for(let r=0;r0&&(o.animation=s.animations[0].serialize()),e.ranges=[];for(let l in this._ranges){let c=this._ranges[l];if(!c)continue;let f={};f.name=l,f.from=c.from,f.to=c.to,e.ranges.push(f)}}return e}static Parse(e,t){let i=new n(e.name,e.id,t);e.dimensionsAtRest&&(i.dimensionsAtRest=v.FromArray(e.dimensionsAtRest)),i.needInitialSkinMatrix=e.needInitialSkinMatrix,e.metadata&&(i.metadata=e.metadata);let r;for(r=0;r-1&&(o=i.bones[s.parentBoneIndex]);let l=s.rest?U.FromArray(s.rest):null,c=new Zr(s.name,i,o,U.FromArray(s.matrix),l,null,a);s.id!==void 0&&s.id!==null&&(c.id=s.id),s.length&&(c.length=s.length),s.metadata&&(c.metadata=s.metadata),s.animation&&c.animations.push(Oe.Parse(s.animation)),s.linkedTransformNodeId!==void 0&&s.linkedTransformNodeId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeId=s.linkedTransformNodeId),s.linkedTransformNodeUniqueId!==void 0&&s.linkedTransformNodeUniqueId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeUniqueId=s.linkedTransformNodeUniqueId)}if(e.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e}sortBones(){let e=[],t=new Array(this.bones.length);for(let i=0;i{Qe();ft();At();yt();qe();Kt();Lt();Ka=class n{get influence(){return this._influence}set influence(e){if(this._influence===e)return;let t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(t===0||e===0)}get animationPropertiesOverride(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}constructor(e,t=0,i=null,r=null){this.name=e,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uv2s=null,this._colors=null,this._uniqueId=0,this.onInfluenceChanged=new Y,this._onDataLayoutChanged=new Y,this.morphTargetManager=null,this._animationPropertiesOverride=null,this.id=e,this.morphTargetManager=r,this._scene=i||ue.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}get uniqueId(){return this._uniqueId}get hasPositions(){return!!this._positions}get hasNormals(){return!!this._normals}get hasTangents(){return!!this._tangents}get hasUVs(){return!!this._uvs}get hasUV2s(){return!!this._uv2s}get hasColors(){return!!this._colors}get vertexCount(){return this._positions?this._positions.length/3:this._normals?this._normals.length/3:this._tangents?this._tangents.length/3:this._uvs?this._uvs.length/2:this._uv2s?this._uv2s.length/2:this._colors?this._colors.length/4:0}setPositions(e){let t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)}getPositions(){return this._positions}setNormals(e){let t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)}getNormals(){return this._normals}setTangents(e){let t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)}getTangents(){return this._tangents}setUVs(e){let t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)}getUVs(){return this._uvs}setUV2s(e){let t=this.hasUV2s;this._uv2s=e,t!==this.hasUV2s&&this._onDataLayoutChanged.notifyObservers(void 0)}getUV2s(){return this._uv2s}setColors(e){let t=this.hasColors;this._colors=e,t!==this.hasColors&&this._onDataLayoutChanged.notifyObservers(void 0)}getColors(){return this._colors}clone(){let e=Me.Clone(()=>new n(this.name,this.influence,this._scene,this.morphTargetManager),this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e._uv2s=this._uv2s,e._colors=this._colors,e}serialize(){let e={};return e.name=this.name,e.influence=this.influence,this.id!=null&&(e.id=this.id),e.uniqueId=this.uniqueId,e.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),this.hasUV2s&&(e.uv2s=Array.prototype.slice.call(this.getUV2s())),this.hasColors&&(e.colors=Array.prototype.slice.call(this.getColors())),Me.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,t,i=null){let r=new n(e.name,e.influence,t,i);if(r.setPositions(e.positions),e.id!=null&&(r.id=e.id),e.normals&&r.setNormals(e.normals),e.tangents&&r.setTangents(e.tangents),e.uvs&&r.setUVs(e.uvs),e.uv2s&&r.setUV2s(e.uv2s),e.colors&&r.setColors(e.colors),e.animations){for(let s=0;s{oi();Bm=class n extends ne{get depth(){return this._depth}constructor(e,t,i,r,s,a,o=!0,l=!1,c=ne.TRILINEAR_SAMPLINGMODE,f=0,d,h){super(null,a,!o,l),this.format=s,this._texture=a.getEngine().createRawTexture2DArray(e,t,i,r,s,o,l,c,null,f,d!=null?d:0,h),this._depth=r,this.is2DArray=!0}update(e){this.updateMipLevel(e,0)}updateMipLevel(e,t){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,t)}static CreateRGBATexture(e,t,i,r,s,a=!0,o=!1,l=3,c=0){return new n(e,t,i,r,5,s,a,o,l,c)}}});var Wo,YO=A(()=>{cn();ze();At();ET();XO();Wo=class n{set areUpdatesFrozen(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(this._forceUpdateWhenUnfrozen),this._forceUpdateWhenUnfrozen=!1))}get areUpdatesFrozen(){return this._blockCounter>0}constructor(e=null,t){if(this.meshName=t,this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new Ct(16),this._supportsPositions=!1,this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._supportsUV2s=!1,this._supportsColors=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._mustSynchronize=!0,this._forceUpdateWhenUnfrozen=!1,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enablePositionMorphing=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this.enableUV2Morphing=!0,this.enableColorMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,this.metadata=null,this._influencesAreDirty=!1,this._needUpdateInfluences=!1,e||(e=ue.LastCreatedScene),this._scene=e,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();let i=this._scene.getEngine().getCaps();this._canUseTextureForTargets=i.canUseGLVertexID&&i.textureFloat&&i.maxVertexTextureImageUnits>0&&i.texture2DArrayMaxLayerCount>1}}get numMaxInfluencers(){return n.ConstantTargetCountForTextureMode>0&&this.isUsingTextureForTargets?n.ConstantTargetCountForTextureMode:this._numMaxInfluencers}set numMaxInfluencers(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._mustSynchronize=!0,this._syncActiveTargets())}get uniqueId(){return this._uniqueId}get vertexCount(){return this._vertexCount}get supportsPositions(){return this._supportsPositions&&this.enablePositionMorphing}get supportsNormals(){return this._supportsNormals&&this.enableNormalMorphing}get supportsTangents(){return this._supportsTangents&&this.enableTangentMorphing}get supportsUVs(){return this._supportsUVs&&this.enableUVMorphing}get supportsUV2s(){return this._supportsUV2s&&this.enableUV2Morphing}get supportsColors(){return this._supportsColors&&this.enableColorMorphing}get hasPositions(){return this._supportsPositions}get hasNormals(){return this._supportsNormals}get hasTangents(){return this._supportsTangents}get hasUVs(){return this._supportsUVs}get hasUV2s(){return this._supportsUV2s}get hasColors(){return this._supportsColors}get numTargets(){return this._targets.length}get numInfluencers(){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.length}get influences(){return this._influencesAreDirty&&this._syncActiveTargets(),this._influences}get useTextureToStoreTargets(){return this._useTextureToStoreTargets}set useTextureToStoreTargets(e){this._useTextureToStoreTargets!==e&&(this._useTextureToStoreTargets=e,this._mustSynchronize=!0,this._syncActiveTargets())}get isUsingTextureForTargets(){var e;return n.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!((e=this._scene)!=null&&e.getEngine().getCaps().disableMorphTargetTexture)}getActiveTarget(e){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.data[e]}getTarget(e){return this._targets[e]}getTargetByName(e){for(let t of this._targets)if(t.name===e)return t;return null}addTarget(e){this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(t=>{this.areUpdatesFrozen&&t&&(this._forceUpdateWhenUnfrozen=!0),this._influencesAreDirty=!0,this._needUpdateInfluences=this._needUpdateInfluences||t})),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(()=>{this._mustSynchronize=!0,this._syncActiveTargets()})),this._mustSynchronize=!0,this._syncActiveTargets()}removeTarget(e){let t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._mustSynchronize=!0,this._syncActiveTargets()),this._scene&&this._scene.stopAnimation(e)}_bind(e){this._influencesAreDirty&&this._syncActiveTargets(),e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setFloat("morphTargetCount",this.numInfluencers)}clone(){let e=new n(this._scene);e.areUpdatesFrozen=!0;for(let t of this._targets)e.addTarget(t.clone());return e.areUpdatesFrozen=!1,e.enablePositionMorphing=this.enablePositionMorphing,e.enableNormalMorphing=this.enableNormalMorphing,e.enableTangentMorphing=this.enableTangentMorphing,e.enableUVMorphing=this.enableUVMorphing,e.enableUV2Morphing=this.enableUV2Morphing,e.enableColorMorphing=this.enableColorMorphing,e.metadata=this.metadata,e}serialize(){let e={};e.id=this.uniqueId,e.meshName=this.meshName,e.targets=[];for(let t of this._targets)e.targets.push(t.serialize());return this.metadata&&(e.metadata=this.metadata),e}_syncActiveTargets(e=!1){if(this.areUpdatesFrozen)return;e=e||this._needUpdateInfluences,this._needUpdateInfluences=!1,this._influencesAreDirty=!1;let t=!!this._targetStoreTexture,i=this.isUsingTextureForTargets;(this._mustSynchronize||t!==i)&&(this._mustSynchronize=!1,this.synchronize());let r=0;this._activeTargets.reset(),(!this._morphTargetTextureIndices||this._morphTargetTextureIndices.length!==this._targets.length)&&(this._morphTargetTextureIndices=new Float32Array(this._targets.length));let s=-1;for(let a of this._targets)if(s++,!(a.influence===0&&this.optimizeInfluencers)){if(this._activeTargets.length>=n.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(a),this._morphTargetTextureIndices[r]=s,this._tempInfluences[r++]=a.influence}this._morphTargetTextureIndices.length!==r&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,r)),(!this._influences||this._influences.length!==r)&&(this._influences=new Float32Array(r));for(let a=0;ae.getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1);for(let i of this._targets){this._supportsPositions=this._supportsPositions&&i.hasPositions,this._supportsNormals=this._supportsNormals&&i.hasNormals,this._supportsTangents=this._supportsTangents&&i.hasTangents,this._supportsUVs=this._supportsUVs&&i.hasUVs,this._supportsUV2s=this._supportsUV2s&&i.hasUV2s,this._supportsColors=this._supportsColors&&i.hasColors;let r=i.vertexCount;if(this._vertexCount===0)this._vertexCount=r;else if(this._vertexCount!==r){W.Error(`Incompatible target. Targets must all have the same vertices count. Current vertex count: ${this._vertexCount}, vertex count for target "${i.name}": ${r}`);return}}if(this.isUsingTextureForTargets){this._textureVertexStride=0,this._supportsPositions&&this._textureVertexStride++,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._supportsUV2s&&this._textureVertexStride++,this._supportsColors&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;let i=e.getCaps().maxTextureSize;this._textureWidth>i&&(this._textureHeight=Math.ceil(this._textureWidth/i),this._textureWidth=i);let r=this._targets.length,s=new Float32Array(r*this._textureWidth*this._textureHeight*4),a;for(let o=0;o-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(let e of this._targets)this._scene.stopAnimation(e)}}static Parse(e,t){let i=new n(t);for(let r of e.targets)i.addTarget(Ka.Parse(r,t,i));return e.metadata&&(i.metadata=e.metadata),i}};Wo.EnableTextureStorage=!0;Wo.MaxActiveMorphTargetsInVertexAttributeMode=8;Wo.ConstantTargetCountForTextureMode=0});function jO(n,e,t){TT(n)&&W.Warn(`Extension with the name '${n}' already exists`),vT.set(n,{isGLTFExtension:e,factory:t})}function TT(n){return vT.delete(n)}var vT,KO,ZO=A(()=>{ze();vT=new Map,KO=vT});var F,ST=A(()=>{F=class{};F.AUTOSAMPLERSUFFIX="Sampler";F.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS";F.ALPHA_DISABLE=0;F.ALPHA_ADD=1;F.ALPHA_COMBINE=2;F.ALPHA_SUBTRACT=3;F.ALPHA_MULTIPLY=4;F.ALPHA_MAXIMIZED=5;F.ALPHA_ONEONE=6;F.ALPHA_PREMULTIPLIED=7;F.ALPHA_PREMULTIPLIED_PORTERDUFF=8;F.ALPHA_INTERPOLATE=9;F.ALPHA_SCREENMODE=10;F.ALPHA_ONEONE_ONEONE=11;F.ALPHA_ALPHATOCOLOR=12;F.ALPHA_REVERSEONEMINUS=13;F.ALPHA_SRC_DSTONEMINUSSRCALPHA=14;F.ALPHA_ONEONE_ONEZERO=15;F.ALPHA_EXCLUSION=16;F.ALPHA_LAYER_ACCUMULATE=17;F.ALPHA_MIN=18;F.ALPHA_MAX=19;F.ALPHA_DUAL_SRC0_ADD_SRC1xDST=20;F.ALPHA_EQUATION_ADD=0;F.ALPHA_EQUATION_SUBSTRACT=1;F.ALPHA_EQUATION_REVERSE_SUBTRACT=2;F.ALPHA_EQUATION_MAX=3;F.ALPHA_EQUATION_MIN=4;F.ALPHA_EQUATION_DARKEN=5;F.DELAYLOADSTATE_NONE=0;F.DELAYLOADSTATE_LOADED=1;F.DELAYLOADSTATE_LOADING=2;F.DELAYLOADSTATE_NOTLOADED=4;F.NEVER=512;F.ALWAYS=519;F.LESS=513;F.EQUAL=514;F.LEQUAL=515;F.GREATER=516;F.GEQUAL=518;F.NOTEQUAL=517;F.KEEP=7680;F.ZERO=0;F.REPLACE=7681;F.INCR=7682;F.DECR=7683;F.INVERT=5386;F.INCR_WRAP=34055;F.DECR_WRAP=34056;F.TEXTURE_CLAMP_ADDRESSMODE=0;F.TEXTURE_WRAP_ADDRESSMODE=1;F.TEXTURE_MIRROR_ADDRESSMODE=2;F.TEXTURE_CREATIONFLAG_STORAGE=1;F.TEXTUREFORMAT_ALPHA=0;F.TEXTUREFORMAT_LUMINANCE=1;F.TEXTUREFORMAT_LUMINANCE_ALPHA=2;F.TEXTUREFORMAT_RGB=4;F.TEXTUREFORMAT_RGBA=5;F.TEXTUREFORMAT_RED=6;F.TEXTUREFORMAT_R=6;F.TEXTUREFORMAT_R16_UNORM=33322;F.TEXTUREFORMAT_RG16_UNORM=33324;F.TEXTUREFORMAT_RGB16_UNORM=32852;F.TEXTUREFORMAT_RGBA16_UNORM=32859;F.TEXTUREFORMAT_R16_SNORM=36760;F.TEXTUREFORMAT_RG16_SNORM=36761;F.TEXTUREFORMAT_RGB16_SNORM=36762;F.TEXTUREFORMAT_RGBA16_SNORM=36763;F.TEXTUREFORMAT_RG=7;F.TEXTUREFORMAT_RED_INTEGER=8;F.TEXTUREFORMAT_R_INTEGER=8;F.TEXTUREFORMAT_RG_INTEGER=9;F.TEXTUREFORMAT_RGB_INTEGER=10;F.TEXTUREFORMAT_RGBA_INTEGER=11;F.TEXTUREFORMAT_BGRA=12;F.TEXTUREFORMAT_DEPTH24_STENCIL8=13;F.TEXTUREFORMAT_DEPTH32_FLOAT=14;F.TEXTUREFORMAT_DEPTH16=15;F.TEXTUREFORMAT_DEPTH24=16;F.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17;F.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18;F.TEXTUREFORMAT_STENCIL8=19;F.TEXTUREFORMAT_UNDEFINED=4294967295;F.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493;F.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495;F.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918;F.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777;F.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776;F.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917;F.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x4=37809;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x5=37810;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x5=37811;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x6=37812;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x5=37813;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x6=37814;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x8=37815;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x5=37816;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x6=37817;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x8=37818;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x10=37819;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x10=37820;F.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x12=37821;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853;F.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196;F.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493;F.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494;F.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495;F.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496;F.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497;F.TEXTURETYPE_UNSIGNED_BYTE=0;F.TEXTURETYPE_UNSIGNED_INT=0;F.TEXTURETYPE_FLOAT=1;F.TEXTURETYPE_HALF_FLOAT=2;F.TEXTURETYPE_BYTE=3;F.TEXTURETYPE_SHORT=4;F.TEXTURETYPE_UNSIGNED_SHORT=5;F.TEXTURETYPE_INT=6;F.TEXTURETYPE_UNSIGNED_INTEGER=7;F.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;F.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;F.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;F.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;F.TEXTURETYPE_UNSIGNED_INT_24_8=12;F.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;F.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;F.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;F.TEXTURETYPE_UNDEFINED=16;F.TEXTURE_2D=3553;F.TEXTURE_2D_ARRAY=35866;F.TEXTURE_CUBE_MAP=34067;F.TEXTURE_CUBE_MAP_ARRAY=3735928559;F.TEXTURE_3D=32879;F.TEXTURE_NEAREST_SAMPLINGMODE=1;F.TEXTURE_NEAREST_NEAREST=1;F.TEXTURE_BILINEAR_SAMPLINGMODE=2;F.TEXTURE_LINEAR_LINEAR=2;F.TEXTURE_TRILINEAR_SAMPLINGMODE=3;F.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;F.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;F.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;F.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;F.TEXTURE_NEAREST_LINEAR=7;F.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;F.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;F.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;F.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;F.TEXTURE_LINEAR_NEAREST=12;F.TEXTURE_EXPLICIT_MODE=0;F.TEXTURE_SPHERICAL_MODE=1;F.TEXTURE_PLANAR_MODE=2;F.TEXTURE_CUBIC_MODE=3;F.TEXTURE_PROJECTION_MODE=4;F.TEXTURE_SKYBOX_MODE=5;F.TEXTURE_INVCUBIC_MODE=6;F.TEXTURE_EQUIRECTANGULAR_MODE=7;F.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;F.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;F.TEXTURE_FILTERING_QUALITY_OFFLINE=4096;F.TEXTURE_FILTERING_QUALITY_HIGH=64;F.TEXTURE_FILTERING_QUALITY_MEDIUM=16;F.TEXTURE_FILTERING_QUALITY_LOW=8;F.SCALEMODE_FLOOR=1;F.SCALEMODE_NEAREST=2;F.SCALEMODE_CEILING=3;F.MATERIAL_TextureDirtyFlag=1;F.MATERIAL_LightDirtyFlag=2;F.MATERIAL_FresnelDirtyFlag=4;F.MATERIAL_AttributesDirtyFlag=8;F.MATERIAL_MiscDirtyFlag=16;F.MATERIAL_PrePassDirtyFlag=32;F.MATERIAL_ImageProcessingDirtyFlag=64;F.MATERIAL_AllDirtyFlag=127;F.MATERIAL_TriangleFillMode=0;F.MATERIAL_WireFrameFillMode=1;F.MATERIAL_PointFillMode=2;F.MATERIAL_PointListDrawMode=3;F.MATERIAL_LineListDrawMode=4;F.MATERIAL_LineLoopDrawMode=5;F.MATERIAL_LineStripDrawMode=6;F.MATERIAL_TriangleStripDrawMode=7;F.MATERIAL_TriangleFanDrawMode=8;F.MATERIAL_ClockWiseSideOrientation=0;F.MATERIAL_CounterClockWiseSideOrientation=1;F.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR=0;F.MATERIAL_DIFFUSE_MODEL_BURLEY=1;F.MATERIAL_DIFFUSE_MODEL_LAMBERT=2;F.MATERIAL_DIFFUSE_MODEL_LEGACY=3;F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_GLTF=0;F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR=1;F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_GLTF=0;F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR=1;F.ACTION_NothingTrigger=0;F.ACTION_OnPickTrigger=1;F.ACTION_OnLeftPickTrigger=2;F.ACTION_OnRightPickTrigger=3;F.ACTION_OnCenterPickTrigger=4;F.ACTION_OnPickDownTrigger=5;F.ACTION_OnDoublePickTrigger=6;F.ACTION_OnPickUpTrigger=7;F.ACTION_OnPickOutTrigger=16;F.ACTION_OnLongPressTrigger=8;F.ACTION_OnPointerOverTrigger=9;F.ACTION_OnPointerOutTrigger=10;F.ACTION_OnEveryFrameTrigger=11;F.ACTION_OnIntersectionEnterTrigger=12;F.ACTION_OnIntersectionExitTrigger=13;F.ACTION_OnKeyDownTrigger=14;F.ACTION_OnKeyUpTrigger=15;F.PARTICLES_BILLBOARDMODE_Y=2;F.PARTICLES_BILLBOARDMODE_ALL=7;F.PARTICLES_BILLBOARDMODE_STRETCHED=8;F.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9;F.MESHES_CULLINGSTRATEGY_STANDARD=0;F.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;F.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;F.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;F.SCENELOADER_NO_LOGGING=0;F.SCENELOADER_MINIMAL_LOGGING=1;F.SCENELOADER_SUMMARY_LOGGING=2;F.SCENELOADER_DETAILED_LOGGING=3;F.PREPASS_IRRADIANCE_LEGACY_TEXTURE_TYPE=0;F.PREPASS_POSITION_TEXTURE_TYPE=1;F.PREPASS_VELOCITY_TEXTURE_TYPE=2;F.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3;F.PREPASS_COLOR_TEXTURE_TYPE=4;F.PREPASS_DEPTH_TEXTURE_TYPE=5;F.PREPASS_NORMAL_TEXTURE_TYPE=6;F.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7;F.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8;F.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9;F.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10;F.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11;F.PREPASS_ALBEDO_TEXTURE_TYPE=12;F.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE=13;F.PREPASS_IRRADIANCE_TEXTURE_TYPE=14;F.BUFFER_CREATIONFLAG_READ=1;F.BUFFER_CREATIONFLAG_WRITE=2;F.BUFFER_CREATIONFLAG_READWRITE=3;F.BUFFER_CREATIONFLAG_UNIFORM=4;F.BUFFER_CREATIONFLAG_VERTEX=8;F.BUFFER_CREATIONFLAG_INDEX=16;F.BUFFER_CREATIONFLAG_STORAGE=32;F.BUFFER_CREATIONFLAG_INDIRECT=64;F.RENDERPASS_MAIN=0;F.INPUT_ALT_KEY=18;F.INPUT_CTRL_KEY=17;F.INPUT_META_KEY1=91;F.INPUT_META_KEY2=92;F.INPUT_META_KEY3=93;F.INPUT_SHIFT_KEY=16;F.SNAPSHOTRENDERING_STANDARD=0;F.SNAPSHOTRENDERING_FAST=1;F.PERSPECTIVE_CAMERA=0;F.ORTHOGRAPHIC_CAMERA=1;F.FOVMODE_VERTICAL_FIXED=0;F.FOVMODE_HORIZONTAL_FIXED=1;F.RIG_MODE_NONE=0;F.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;F.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;F.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;F.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;F.RIG_MODE_STEREOSCOPIC_INTERLACED=14;F.RIG_MODE_VR=20;F.RIG_MODE_CUSTOM=22;F.MAX_SUPPORTED_UV_SETS=6;F.GL_ALPHA_EQUATION_ADD=32774;F.GL_ALPHA_EQUATION_MIN=32775;F.GL_ALPHA_EQUATION_MAX=32776;F.GL_ALPHA_EQUATION_SUBTRACT=32778;F.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779;F.GL_ALPHA_FUNCTION_SRC=768;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769;F.GL_ALPHA_FUNCTION_SRC_ALPHA=770;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771;F.GL_ALPHA_FUNCTION_DST_ALPHA=772;F.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773;F.GL_ALPHA_FUNCTION_DST_COLOR=774;F.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775;F.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776;F.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769;F.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770;F.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771;F.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772;F.GL_ALPHA_FUNCTION_SRC1_COLOR=35065;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066;F.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185;F.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067;F.SnippetUrl="https://snippet.babylonjs.com";F.FOGMODE_NONE=0;F.FOGMODE_EXP=1;F.FOGMODE_EXP2=2;F.FOGMODE_LINEAR=3;F.BYTE=5120;F.UNSIGNED_BYTE=5121;F.SHORT=5122;F.UNSIGNED_SHORT=5123;F.INT=5124;F.UNSIGNED_INT=5125;F.FLOAT=5126;F.PositionKind="position";F.NormalKind="normal";F.TangentKind="tangent";F.UVKind="uv";F.UV2Kind="uv2";F.UV3Kind="uv3";F.UV4Kind="uv4";F.UV5Kind="uv5";F.UV6Kind="uv6";F.ColorKind="color";F.ColorInstanceKind="instanceColor";F.MatricesIndicesKind="matricesIndices";F.MatricesWeightsKind="matricesWeights";F.MatricesIndicesExtraKind="matricesIndicesExtra";F.MatricesWeightsExtraKind="matricesWeightsExtra";F.ANIMATIONTYPE_FLOAT=0;F.ANIMATIONTYPE_VECTOR3=1;F.ANIMATIONTYPE_QUATERNION=2;F.ANIMATIONTYPE_MATRIX=3;F.ANIMATIONTYPE_COLOR3=4;F.ANIMATIONTYPE_COLOR4=7;F.ANIMATIONTYPE_VECTOR2=5;F.ANIMATIONTYPE_SIZE=6;F.ShadowMinZ=0;F.ShadowMaxZ=1e4;F.OUTLINELAYER_SAMPLING_TRIDIRECTIONAL=0;F.OUTLINELAYER_SAMPLING_OCTADIRECTIONAL=1});var Sbe,qO=A(()=>{Sbe=[{regex:new RegExp("^/nodes/\\d+/extensions/")}]});function ja(n,e,t,i){let r=Le(n,e);return i?r[t][i]:r[t]}function Le(n,e,t){var i,r,s;return(s=(r=n._data)==null?void 0:r[(i=t==null?void 0:t.fillMode)!=null?i:F.MATERIAL_TriangleFillMode])==null?void 0:s.babylonMaterial}function _i(n,e){return{offset:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let s=ja(t,r,n,e);return new _e(s==null?void 0:s.uOffset,s==null?void 0:s.vOffset)},getTarget:Le,set:(t,i,r,s)=>{let a=ja(i,s,n,e);a.uOffset=t.x,a.vOffset=t.y},getPropertyName:[()=>`${n}${e?"."+e:""}.uOffset`,()=>`${n}${e?"."+e:""}.vOffset`]},rotation:{type:"number",get:(t,i,r)=>{var s;return(s=ja(t,r,n,e))==null?void 0:s.wAng},getTarget:Le,set:(t,i,r,s)=>ja(i,s,n,e).wAng=t,getPropertyName:[()=>`${n}${e?"."+e:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let s=ja(t,r,n,e);return new _e(s==null?void 0:s.uScale,s==null?void 0:s.vScale)},getTarget:Le,set:(t,i,r,s)=>{let a=ja(i,s,n,e);a.uScale=t.x,a.vScale=t.y},getPropertyName:[()=>`${n}${e?"."+e:""}.uScale`,()=>`${n}${e?"."+e:""}.vScale`]}}}function qf(n){let e=n.split("/").map(i=>i.replace(/{}/g,"__array__")),t=QO;for(let i of e)i&&(t=t[i]);if(t&&t.type&&t.get)return t}function Qf(n,e){let t=n.split("/").map(r=>r.replace(/{}/g,"__array__")),i=QO;for(let r of t)r&&(i=i[r]);i&&i.type&&i.get&&(i.interpolation=e)}var bz,Mz,yz,Dz,Lz,Pz,QO,AT=A(()=>{ve();ST();et();AE();qO();bz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonTransformNode),getPropertyName:[()=>"length"]},__array__:{__target__:!0,translation:{type:"Vector3",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.position},set:(n,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.position.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"position"]},rotation:{type:"Quaternion",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.rotationQuaternion},set:(n,e)=>{var t,i;return(i=(t=e._babylonTransformNode)==null?void 0:t.rotationQuaternion)==null?void 0:i.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"rotationQuaternion"]},scale:{type:"Vector3",get:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.scaling},set:(n,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.scaling.copyFrom(n)},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"scaling"]},weights:{length:{type:"number",get:n=>n._numMorphTargets,getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},__array__:{__target__:!0,type:"number",get:(n,e)=>{var t,i;return e!==void 0?(i=(t=n._primitiveBabylonMeshes)==null?void 0:t[0].morphTargetManager)==null?void 0:i.getTarget(e).influence:void 0},getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},type:"number[]",get:(n,e)=>[0],getTarget:n=>n._babylonTransformNode,getPropertyName:[()=>"influence"]},matrix:{type:"Matrix",get:n=>{var e,t,i;return U.Compose((e=n._babylonTransformNode)==null?void 0:e.scaling,(t=n._babylonTransformNode)==null?void 0:t.rotationQuaternion,(i=n._babylonTransformNode)==null?void 0:i.position)},getTarget:n=>n._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:n=>{var r,s,a,o,l,c,f;let e=U.Identity(),t=n.parent;for(;t&&t.parent;)t=t.parent;let i=((r=n._babylonTransformNode)==null?void 0:r.position._isDirty)||((a=(s=n._babylonTransformNode)==null?void 0:s.rotationQuaternion)==null?void 0:a._isDirty)||((o=n._babylonTransformNode)==null?void 0:o.scaling._isDirty);if(t){let d=(l=t._babylonTransformNode)==null?void 0:l.computeWorldMatrix(!0).invert();d&&((f=(c=n._babylonTransformNode)==null?void 0:c.computeWorldMatrix(i))==null||f.multiplyToRef(d,e))}else n._babylonTransformNode&&e.copyFrom(n._babylonTransformNode.computeWorldMatrix(i));return e},getTarget:n=>n._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:n=>{var e,t;return(t=(e=n._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.intensity},getTarget:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(n,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.intensity=n)}}},color:{type:"Color3",get:n=>{var e,t;return(t=(e=n._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.diffuse},getTarget:n=>{var e;return(e=n._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(n,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.diffuse=n)}}}},KHR_node_visibility:{visible:{type:"boolean",get:n=>n._primitiveBabylonMeshes?n._primitiveBabylonMeshes[0].isVisible:!1,getTarget:()=>{},set:(n,e)=>{e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes.forEach(t=>t.isVisible=n)}}}}}},Mz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>"length"]},__array__:{}},yz={length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>{var t;return(t=e.primitives[0]._instanceData)==null?void 0:t.babylonSourceMesh}),getPropertyName:[()=>"length"]},__array__:{}},Dz={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:n=>{var e,t,i,r;return new _e((t=(e=n._babylonCamera)==null?void 0:e.orthoLeft)!=null?t:0,(r=(i=n._babylonCamera)==null?void 0:i.orthoRight)!=null?r:0)},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.orthoLeft=n.x,e._babylonCamera.orthoRight=n.y)},getTarget:n=>n,getPropertyName:[()=>"orthoLeft",()=>"orthoRight"]},ymag:{componentsCount:2,type:"Vector2",get:n=>{var e,t,i,r;return new _e((t=(e=n._babylonCamera)==null?void 0:e.orthoBottom)!=null?t:0,(r=(i=n._babylonCamera)==null?void 0:i.orthoTop)!=null?r:0)},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.orthoBottom=n.x,e._babylonCamera.orthoTop=n.y)},getTarget:n=>n,getPropertyName:[()=>"orthoBottom",()=>"orthoTop"]},zfar:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.maxZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=n)},getTarget:n=>n,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.minZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=n)},getTarget:n=>n,getPropertyName:[()=>"minZ"]}},perspective:{aspectRatio:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.getEngine().getAspectRatio(n._babylonCamera)},getTarget:n=>n,getPropertyName:[()=>"aspectRatio"],isReadOnly:!0},yfov:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.fov},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.fov=n)},getTarget:n=>n,getPropertyName:[()=>"fov"]},zfar:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.maxZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=n)},getTarget:n=>n,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:n=>{var e;return(e=n._babylonCamera)==null?void 0:e.minZ},set:(n,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=n)},getTarget:n=>n,getPropertyName:[()=>"minZ"]}}}},Lz={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).emissiveColor,set:(n,e,t,i)=>Le(e,t,i).emissiveColor.copyFrom(n),getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:_i("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(n,e,t)=>{var i;return(i=ja(n,t,"bumpTexture"))==null?void 0:i.level},set:(n,e,t,i)=>{let r=ja(e,i,"bumpTexture");r&&(r.level=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:_i("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(n,e,t)=>Le(n,e,t).ambientTextureStrength,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.ambientTextureStrength=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:_i("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(n,e,t)=>{let i=Le(n,e,t);return Ne.FromColor3(i.albedoColor,i.alpha)},set:(n,e,t,i)=>{let r=Le(e,t,i);r.albedoColor.set(n.r,n.g,n.b),r.alpha=n.a},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:_i("albedoTexture")}},metallicFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).metallic,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.metallic=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).roughness,set:(n,e,t,i)=>{let r=Le(e,t,i);r&&(r.roughness=n)},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:_i("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(n,e,t)=>Le(n,e,t).anisotropy.intensity,set:(n,e,t,i)=>{Le(e,t,i).anisotropy.intensity=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(n,e,t)=>Le(n,e,t).anisotropy.angle,set:(n,e,t,i)=>{Le(e,t,i).anisotropy.angle=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:_i("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).clearCoat.intensity,set:(n,e,t,i)=>{Le(e,t,i).clearCoat.intensity=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).clearCoat.roughness,set:(n,e,t,i)=>{Le(e,t,i).clearCoat.roughness=n},getTarget:(n,e,t)=>Le(n,e,t),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:_i("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(n,e,t)=>{var i;return(i=Le(n,e,t).clearCoat.bumpTexture)==null?void 0:i.level},getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).clearCoat.bumpTexture.level=n},extensions:{KHR_texture_transform:_i("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:_i("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.dispersion,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.dispersion=n}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(n,e,t)=>Le(n,e,t).emissiveIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).emissiveIntensity=n}},KHR_materials_ior:{ior:{type:"number",get:(n,e,t)=>Le(n,e,t).indexOfRefraction,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).indexOfRefraction=n}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.intensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.intensity=n},iridescenceIor:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.indexOfRefraction,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.indexOfRefraction=n},iridescenceTexture:{extensions:{KHR_texture_transform:_i("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.maximumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.maximumThickness=n},iridescenceThicknessMinimum:{type:"number",get:(n,e,t)=>Le(n,e,t).iridescence.minimumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).iridescence.minimumThickness=n},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:_i("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).sheen.color,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).sheen.color.copyFrom(n)},sheenColorTexture:{extensions:{KHR_texture_transform:_i("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).sheen.intensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).sheen.intensity=n},sheenRoughnessTexture:{extensions:{KHR_texture_transform:_i("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).metallicF0Factor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).metallicF0Factor=n,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).metallicReflectanceColor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).metallicReflectanceColor.copyFrom(n),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:_i("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:_i("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.refractionIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.refractionIntensity=n,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:_i("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.translucencyIntensity,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.translucencyIntensity=n},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:_i("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).subSurface.translucencyColor,getTarget:Le,set:(n,e,t,i)=>{var r;return n&&((r=Le(e,t,i).subSurface.translucencyColor)==null?void 0:r.copyFrom(n))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:_i("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(n,e,t)=>Le(n,e,t).subSurface.tintColor,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.tintColor.copyFrom(n)},attenuationDistance:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.tintColorAtDistance,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.tintColorAtDistance=n},thicknessFactor:{type:"number",get:(n,e,t)=>Le(n,e,t).subSurface.maximumThickness,getTarget:Le,set:(n,e,t,i)=>Le(e,t,i).subSurface.maximumThickness=n},thicknessTexture:{extensions:{KHR_texture_transform:_i("subSurface","thicknessTexture")}}}}}},Pz={KHR_lights_punctual:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.diffuse},set:(n,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(n)},getTarget:n=>n._babylonLight,getPropertyName:[n=>"diffuse"]},intensity:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.intensity},set:(n,e)=>e._babylonLight?e._babylonLight.intensity=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"intensity"]},range:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.range},set:(n,e)=>e._babylonLight?e._babylonLight.range=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"range"]},spot:{innerConeAngle:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.innerAngle},set:(n,e)=>e._babylonLight?e._babylonLight.innerAngle=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"innerConeAngle"]},outerConeAngle:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.angle},set:(n,e)=>e._babylonLight?e._babylonLight.angle=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"outerConeAngle"]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.diffuse},set:(n,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(n)},getTarget:n=>n._babylonLight,getPropertyName:[n=>"diffuse"]},intensity:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.intensity},set:(n,e)=>e._babylonLight?e._babylonLight.intensity=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"intensity"]},size:{type:"number",get:n=>{var e;return(e=n._babylonLight)==null?void 0:e.height},set:(n,e)=>e._babylonLight?e._babylonLight.height=n:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"size"]},rect:{aspect:{type:"number",get:n=>{var e,t;return((e=n._babylonLight)==null?void 0:e.width)/((t=n._babylonLight)==null?void 0:t.height)},set:(n,e)=>e._babylonLight?e._babylonLight.width=n*e._babylonLight.height:void 0,getTarget:n=>n._babylonLight,getPropertyName:[n=>"aspect"]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonLight),getPropertyName:[n=>"length"]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:n=>n.length,getTarget:n=>n.map(e=>e._babylonTexture),getPropertyName:[n=>"length"]},__array__:{__target__:!0,intensity:{type:"number",get:n=>{var e;return(e=n._babylonTexture)==null?void 0:e.level},set:(n,e)=>{e._babylonTexture&&(e._babylonTexture.level=n)},getTarget:n=>n._babylonTexture},rotation:{type:"Quaternion",get:n=>{var e;return n._babylonTexture&&Ae.FromRotationMatrix((e=n._babylonTexture)==null?void 0:e.getReflectionTextureMatrix())},set:(n,e)=>{var t;e._babylonTexture&&((t=e._babylonTexture.getScene())!=null&&t.useRightHandedSystem||(n=Ae.Inverse(n)),U.FromQuaternionToRef(n,e._babylonTexture.getReflectionTextureMatrix()))},getTarget:n=>n._babylonTexture}}}}};QO={cameras:Dz,nodes:bz,materials:Lz,extensions:Pz,animations:Mz,meshes:yz}});function RT(...n){let e=t=>!!t&&typeof t=="object";return n.reduce((t,i)=>{let r=Object.keys(i);for(let s of r){let a=t[s],o=i[s];Array.isArray(a)&&Array.isArray(o)?t[s]=a.concat(...o):e(a)&&e(o)?t[s]=RT(a,o):t[s]=o}return t},{})}var JO=A(()=>{});var Jf,$O=A(()=>{Jf=class{constructor(e){this._factory=e}get value(){return this._factory&&(this._value=this._factory(),this._factory=void 0),this._value}}});var Um,eN=A(()=>{ve();Is();Um=class{get currentFrame(){return this._currentFrame}get weight(){return this._weight}get currentValue(){return this._currentValue}get targetPath(){return this._targetPath}get target(){return this._currentActiveTarget}get isAdditive(){return this._host&&this._host.isAdditive}constructor(e,t,i,r){if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._absoluteFrameOffset=0,this._previousElapsedTime=0,this._yoyoDirection=1,this._previousAbsoluteFrame=0,this._targetIsArray=!1,this._coreRuntimeAnimation=null,this._animation=t,this._target=e,this._scene=i,this._host=r,this._activeTargets=[],t._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===Oe.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=U.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minFrame!==0){let a={frame:0,value:this._keys[0].value};this._keys.splice(0,0,a)}if(this._target instanceof Array){let a=0;for(let o of this._target)this._preparePath(o,a),this._getOriginalValues(a),a++;this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];let s=t.getEvents();if(s&&s.length>0)for(let a of s)this._events.push(a._clone());this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}_preparePath(e,t=0){let i=this._animation.targetPropertyPath;if(i.length>1){let r=e;for(let s=0;s-1&&this._animation.runtimeAnimations.splice(e,1)}setValue(e,t){if(this._targetIsArray){for(let i=0;ii[i.length-1].frame&&(e=i[i.length-1].frame);let r=this._events;if(r.length)for(let a=0;athis._maxFrame)&&(t=this._minFrame),(ithis._maxFrame)&&(i=this._maxFrame),h=i-t;let m,p=e*(o.framePerSecond*s)/1e3+this._absoluteFrameOffset,_=0,g=!1,T=r&&this._animationState.loopMode===Oe.ANIMATIONLOOPMODE_YOYO;if(T){let b=(p-t)/h,R=Math.sin(b*Math.PI);p=Math.abs(R)*h+t;let I=R>=0?1:-1;this._yoyoDirection!==I&&(g=!0),this._yoyoDirection=I}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=p,!r&&i>=t&&(p>=h&&s>0||p<=0&&s<0))c=!1,_=o.evaluate(i);else if(!r&&t>=i&&(p<=h&&s<0||p>=0&&s>0))c=!1,_=o.evaluate(t);else if(this._animationState.loopMode!==Oe.ANIMATIONLOOPMODE_CYCLE){let b=i.toString()+t.toString();if(!this._offsetsCache[b]){this._animationState.repeatCount=0,this._animationState.loopMode=Oe.ANIMATIONLOOPMODE_CYCLE;let R=o._interpolate(t,this._animationState),S=o._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),o.dataType){case Oe.ANIMATIONTYPE_FLOAT:this._offsetsCache[b]=S-R;break;case Oe.ANIMATIONTYPE_QUATERNION:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_VECTOR3:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_VECTOR2:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_SIZE:this._offsetsCache[b]=S.subtract(R);break;case Oe.ANIMATIONTYPE_COLOR3:this._offsetsCache[b]=S.subtract(R);break;default:break}this._highLimitsCache[b]=S}_=this._highLimitsCache[b],m=this._offsetsCache[b]}if(m===void 0)switch(o.dataType){case Oe.ANIMATIONTYPE_FLOAT:m=0;break;case Oe.ANIMATIONTYPE_QUATERNION:m=mE;break;case Oe.ANIMATIONTYPE_VECTOR3:m=pE;break;case Oe.ANIMATIONTYPE_VECTOR2:m=_E;break;case Oe.ANIMATIONTYPE_SIZE:m=gE;break;case Oe.ANIMATIONTYPE_COLOR3:m=EE;break;case Oe.ANIMATIONTYPE_COLOR4:m=vE;break}if(this._host&&this._host.syncRoot){let b=this._host.syncRoot,R=(b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame);f=t+h*R}else p>0&&t>i||p<0&&t0&&this.currentFrame>f||s<0&&this.currentFrame0?0:o.getKeys().length-1}this._currentFrame=f,this._animationState.repeatCount=h===0?0:p/h>>0,this._animationState.highLimitValue=_,this._animationState.offsetValue=m}let u=o._interpolate(f,this._animationState);if(this.setValue(u,a),d.length){for(let m=0;m=0&&f>=d[m].frame&&d[m].frame>=t||h<0&&f<=d[m].frame&&d[m].frame<=t){let p=d[m];p.isDone||(p.onlyOnce&&(d.splice(m,1),m--),p.isDone=!0,p.action(f))}}return c||(this._stopped=!0),c}}});function Oz(n){if(n.totalWeight===0&&n.totalAdditiveWeight===0)return n.originalValue;let e=1,t=G.Vector3[0],i=G.Vector3[1],r=G.Quaternion[0],s=0,a=n.animations[0],o=n.originalValue,l,c=!1;if(n.totalWeight<1)l=1-n.totalWeight,o.decompose(i,r,t);else{if(s=1,e=n.totalWeight,l=a.weight/e,l==1)if(n.totalAdditiveWeight)c=!0;else return a.currentValue;a.currentValue.decompose(i,r,t)}if(!c){i.scaleInPlace(l),t.scaleInPlace(l),r.scaleInPlace(l);for(let d=s;d0?l:-l,r),u.scaleAndAddToRef(l,t)}r.normalize()}for(let d=0;d0)r.copyFrom(i);else if(n.animations.length===1){if(Ae.SlerpToRef(i,t.currentValue,Math.min(1,n.totalWeight),r),n.totalAdditiveWeight===0)return r}else if(n.animations.length>1){let s=1,a,o;if(n.totalWeight<1){let c=1-n.totalWeight;a=[],o=[],a.push(i),o.push(c)}else{if(n.animations.length===2&&(Ae.SlerpToRef(n.animations[0].currentValue,n.animations[1].currentValue,n.animations[1].weight/n.totalWeight,e),n.totalAdditiveWeight===0))return e;a=[],o=[],s=n.totalWeight}for(let c=0;c=l&&T.frame<=c&&(s?(R=T.value.clone(),m?(b=R.getTranslation(),R.setTranslation(b.scaleInPlace(p))):_&&a?(b=R.getTranslation(),R.setTranslation(b.multiplyInPlace(a))):R=T.value):R=T.value,g.push({frame:T.frame+r,value:R}));return this.animations[0].createRange(i,l+r,c+r),!0}),n&&(n.prototype._animate=function(t){if(!this.animationsEnabled)return;let i=kt.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=i}this.deltaTime=t!==void 0?t:this.useConstantAnimationDeltaTime?16:(i-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=i;let r=this._activeAnimatables;if(r.length===0)return;this._animationTime+=this.deltaTime;let s=this._animationTime;for(let a=0;at.playOrder-i.playOrder)},n.prototype.beginWeightedAnimation=function(t,i,r,s=1,a,o=1,l,c,f,d,h=!1){let u=this.beginAnimation(t,i,r,a,o,l,c,!1,f,d,h);return u.weight=s,u},n.prototype.beginAnimation=function(t,i,r,s,a=1,o,l,c=!0,f,d,h=!1){if(a<0){let m=i;i=r,r=m,a=-a}i>r&&(a=-a),c&&this.stopAnimation(t,void 0,f),l||(l=new $f(this,t,i,r,s,a,o,void 0,d,h));let u=f?f(t):!0;if(t.animations&&u&&l.appendAnimations(t,t.animations),t.getAnimatables){let m=t.getAnimatables();for(let p=0;ps&&(o=-o),new $f(this,t,r,s,a,o,l,i,c,f)},n.prototype.beginDirectHierarchyAnimation=function(t,i,r,s,a,o,l,c,f,d=!1){let h=t.getDescendants(i),u=[];u.push(this.beginDirectAnimation(t,r,s,a,o,l,c,f,d));for(let m of h)u.push(this.beginDirectAnimation(m,r,s,a,o,l,c,f,d));return u},n.prototype.getAnimatableByTarget=function(t){for(let i=0;i{ft();eN();Is();ns();ve();$f=class n{get syncRoot(){return this._syncRoot}get masterFrame(){return this._runtimeAnimations.length===0?0:this._runtimeAnimations[0].currentFrame}get weight(){return this._weight}set weight(e){if(e===-1){this._weight=-1;return}this._weight=Math.min(Math.max(e,0),1)}get speedRatio(){return this._speedRatio}set speedRatio(e){for(let t=0;t-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this}getAnimations(){return this._runtimeAnimations}appendAnimations(e,t){for(let i=0;i{this.onAnimationLoopObservable.notifyObservers(this),this.onAnimationLoop&&this.onAnimationLoop()},this._runtimeAnimations.push(s)}}getAnimationByTargetProperty(e){let t=this._runtimeAnimations;for(let i=0;i-1){let a=this._runtimeAnimations;for(let o=a.length-1;o>=0;o--){let l=a[o];e&&l.animation.name!=e||t&&!t(l.target)||(l.dispose(),a.splice(o,1))}a.length==0&&(i||this._scene._activeAnimatables.splice(s,1),r||this._raiseOnAnimationEnd())}}else{let s=this._scene._activeAnimatables.indexOf(this);if(s>-1){i||this._scene._activeAnimatables.splice(s,1);let a=this._runtimeAnimations;for(let o=0;o{this.onAnimationEndObservable.add(()=>{e(this)},void 0,void 0,this,!0)})}_animate(e){if(this._paused)return this.animationStarted=!1,this._pausedDelay===null&&(this._pausedDelay=e),!0;if(this._localDelayOffset===null?(this._localDelayOffset=e,this._pausedDelay=null):this._pausedDelay!==null&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),this._manualJumpDelay!==null&&(this._localDelayOffset+=this.speedRatio<0?-this._manualJumpDelay:this._manualJumpDelay,this._manualJumpDelay=null,this._frameToSyncFromJump=null),this._goToFrame=null,!n.ProcessPausedAnimatables&&this._weight===0&&this._previousWeight===0)return!0;this._previousWeight=this._weight;let t=!1,i=this._runtimeAnimations,r;for(r=0;r{Fm();IT();sr();IT();tN(st,Zr)});var rN={};De(rN,{AnimationGroup:()=>xT,TargetedAnimation:()=>Vm});var Vm,xT,nN=A(()=>{Is();ft();At();ha();iN();Vh();Vm=class{getClassName(){return"TargetedAnimation"}constructor(e){this.parent=e,this.uniqueId=Ts.UniqueId}serialize(){let e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e.targetUniqueId=this.target.uniqueId,e}},xT=class n{get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this.syncWithMask(!0))}syncWithMask(e=!1){if(!this.mask&&!e){this._numActiveAnimatables=this._targetedAnimations.length;return}this._numActiveAnimatables=0;for(let t=0;t0)){for(let t=0;ta&&(a=l.to);let o=new n(e[0].name+"_merged",e[0]._scene,r);for(let l of e){i&&l.normalize(s,a);for(let c of l.targetedAnimations)o.addTargetedAnimation(c.animation,c.target);t&&l.dispose()}return o}getScene(){return this._scene}constructor(e,t=null,i=-1,r=0){this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this._loopAnimation=!1,this._isAdditive=!1,this._weight=-1,this._playOrder=0,this._enableBlending=null,this._blendingSpeed=null,this._numActiveAnimatables=0,this._shouldStart=!0,this._parentContainer=null,this.onAnimationEndObservable=new Y,this.onAnimationLoopObservable=new Y,this.onAnimationGroupLoopObservable=new Y,this.onAnimationGroupEndObservable=new Y,this.onAnimationGroupPauseObservable=new Y,this.onAnimationGroupPlayObservable=new Y,this.metadata=null,this._mask=null,this._animationLoopFlags=[],this._scene=t||ue.LastCreatedScene,this._weight=i,this._playOrder=r,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}addTargetedAnimation(e,t){let i=new Vm(this);i.animation=e,i.target=t;let r=e.getKeys();return this._from>r[0].frame&&(this._from=r[0].frame),this._to-1;t--)this._targetedAnimations[t].animation===e&&this._targetedAnimations.splice(t,1)}normalize(e=null,t=null){e==null&&(e=this._from),t==null&&(t=this._to);for(let i=0;ie){let l={frame:e,value:a.value,inTangent:a.inTangent,outTangent:a.outTangent,interpolation:a.interpolation};s.splice(0,0,l)}if(o.frame{this.onAnimationLoopObservable.notifyObservers(t),!this._animationLoopFlags[i]&&(this._animationLoopFlags[i]=!0,this._animationLoopCount++,this._animationLoopCount===this._numActiveAnimatables&&(this.onAnimationGroupLoopObservable.notifyObservers(this),this._animationLoopCount=0,this._animationLoopFlags.length=0))}}start(e=!1,t=1,i,r,s){if(this._isStarted||this._targetedAnimations.length===0)return this;this._loopAnimation=e,this._shouldStart=!1,this._animationLoopCount=0,this._animationLoopFlags.length=0;for(let a=0;a{this.onAnimationEndObservable.notifyObservers(o),this._checkAnimationGroupEnded(l)},this._processLoop(l,o,a),this._animatables.push(l)}return this.syncWithMask(),this._scene.sortActiveAnimatables(),this._speedRatio=t,this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this}pause(){if(!this._isStarted)return this;this._isPaused=!0;for(let e=0;e0?this._scene._activeAnimatables[i++]=s:e&&this._checkAnimationGroupEnded(s,e)}return this._scene._activeAnimatables.length=i,this._isStarted=!1,this}setWeightForAllAnimatables(e){for(let t=0;t-1&&this._parentContainer.animationGroups.splice(e,1),this._parentContainer=null}this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear(),this.onAnimationGroupLoopObservable.clear()}_checkAnimationGroupEnded(e,t=!1){let i=this._animatables.indexOf(e);i>-1&&this._animatables.splice(i,1),this._animatables.length===this._targetedAnimations.length-this._numActiveAnimatables&&(this._isStarted=!1,t||this.onAnimationGroupEndObservable.notifyObservers(this),this._animatables.length=0)}clone(e,t,i=!1,r=!1){let s=new n(e||this.name,this._scene,this._weight,this._playOrder);s._from=this.from,s._to=this.to,s._speedRatio=this.speedRatio,s._loopAnimation=this.loopAnimation,s._isAdditive=this.isAdditive,s._enableBlending=this.enableBlending,s._blendingSpeed=this.blendingSpeed,s.metadata=this.metadata,s.mask=this.mask;for(let a of this._targetedAnimations)s.addTargetedAnimation(i?a.animation.clone(r):a.animation,t?t(a.target):a.target);return s}serialize(){let e={};e.name=this.name,e.from=this.from,e.to=this.to,e.speedRatio=this.speedRatio,e.loopAnimation=this.loopAnimation,e.isAdditive=this.isAdditive,e.weight=this.weight,e.playOrder=this.playOrder,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,e.targetedAnimations=[];for(let t=0;tp[0].frame&&(c=p[0].frame),f=t&&p<=i||s&&_.frame>=t&&_.frame<=i){let g={frame:_.frame,value:_.value.clone?_.value.clone():_.value,inTangent:_.inTangent,outTangent:_.outTangent,interpolation:_.interpolation,lockedTangent:_.lockedTangent};m===Number.MAX_VALUE&&(m=g.frame),g.frame-=m,u.push(g)}}if(u.length===0){l.splice(c,1),c--;continue}a>u[0].frame&&(a=u[0].frame),oed,TransformNodeAnimationPropertyInfo:()=>pc,WeightAnimationPropertyInfo:()=>Gm,getQuaternion:()=>sN,getVector3:()=>CT,getWeights:()=>aN});function CT(n,e,t,i){return v.FromArray(e,t).scaleInPlace(i)}function sN(n,e,t,i){return Ae.FromArray(e,t).scaleInPlace(i)}function aN(n,e,t,i){let r=new Array(n._numMorphTargets);for(let s=0;s{Is();ve();AT();ed=class{constructor(e,t,i,r){this.type=e,this.name=t,this.getValue=i,this.getStride=r}_buildAnimation(e,t,i){let r=new Oe(e,this.name,t,this.type);return r.setKeys(i,!0),r}},pc=class extends ed{buildAnimations(e,t,i,r){let s=[];return s.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,i,r)}),s}},Gm=class extends ed{buildAnimations(e,t,i,r){let s=[];if(e._numMorphTargets)for(let a=0;a({frame:l.frame,inTangent:l.inTangent?l.inTangent[a]:void 0,value:l.value[a],outTangent:l.outTangent?l.outTangent[a]:void 0,interpolation:l.interpolation})),!0),e._primitiveBabylonMeshes){for(let l of e._primitiveBabylonMeshes)if(l.morphTargetManager){let c=l.morphTargetManager.getTarget(a),f=o.clone();c.animations.push(f),s.push({babylonAnimatable:c,babylonAnimation:f})}}}return s}};Qf("/nodes/{}/translation",[new pc(Oe.ANIMATIONTYPE_VECTOR3,"position",CT,()=>3)]);Qf("/nodes/{}/rotation",[new pc(Oe.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",sN,()=>4)]);Qf("/nodes/{}/scale",[new pc(Oe.ANIMATIONTYPE_VECTOR3,"scaling",CT,()=>3)]);Qf("/nodes/{}/weights",[new Gm(Oe.ANIMATIONTYPE_FLOAT,"influence",aN,n=>n._numMorphTargets)])});var wz,Bz,Uz,Vz,bT,km,MT,cN,Wm=A(()=>{oi();Tg();wz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSe"+"EoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==",Bz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAF9UlEQVR4nGWVy64eVxGF16X27u7/HMcyuZGYAINwmTBigngBXoc34El4B0ZMGDJjFCExQUIKiRKZYBITHdvn/L1rF4P+c+yEUqmH9WmtrrWLkdB4C1/91h/9yn947D8+8CfdlBeGGAMtqwNd6K7VWAJrw9qwLtw2nDaernh6wKuHPD3S1Vs6vaPT97W9r/Wx1seKUWj7Uzz6vX79T//wF/Gbx/7rw/jsFB/39nlrX7q99LKrp5bJZXAtrqW1uJIncbNOXafBU+o0tZW28got0AJ3KACsE4OfYvmzfvDMb/+4//Td9snD9rfr9vHWnyz9361/1fpNLLde0mt5pTZ7a9pCm32SrqQTfZI3aqNXHAwvcAB4BPwnk/oMEcqX8eaz1t9cHjxs7133f5z6p2v/Ylme9eWmLbexjlhnrPBirz3WxWv30rw0L/Yi96PpDrcDcPMEfq+qvQCfsFF1blcv2js3vb2xLNd9O/XT1p8u/Vlfnvd+25bResXC6BFLj2WJpUdv7uEe0exGByPoOAC//BH+cgNqUjfkU4mOEetde+O2vf+y8br71Nva+9q/XpYXvZ97z9ardUXrra3RerQWrUU4myLk4AzYiADwJ+NRQ41i7MSNEBIcM5YR1+f21rnlXcPWtbVYW1/a7dL21mZvbK211lv01lpEtIi0MxTmFGzMAABAN6gF1CTPxI1gkXa5Z5xGPNrbfo6xB/bQubW9nXvkHtXDPfqIJd2bI+1mpZjmNK17QFuxDzhBJued8Fy0KLvcp7fpNzJuM3JE7daIWGKMqAylW0bLiHQ0e1ppTXEK8Qrwkzv8fUIua6oG553wQpRIme7lbfpBxm3GnoEMZ+wZlYGMlu6pNh1pT3nqALCEugCeAB2ohKqYk9hZd4JFS5ThDm/lB9N305nGtKfnNKZiqk23qZhySZOcYhHFewXfI54UMCBDOYlU3TMkSaYWaCtdwXu5yprOKUxrqk9FyUWXNKXiBfCNgucGboGAUBwUJzFYO3G+MCwFtdAn6K6UZZSyXCXBAUVdGCoS5IVxAcQNujAHKCiLLHJqDtWZh1GHV0Et8EYNqOABTUhglKJoyKBBgSwCBC6Ajz7Azz+GiJbwhFTkZCXnEM6EJcuHDmmlztCkBE2IkMGAAhQoSCBBvgYA0G6xN4DgLE5IU5iqZA1hJ8zDqCY2qktJHfEnZSpIk6bE++kEXwHUEBMCmBBBFzE5UzNZuyBRshlSSF0aEg6MaDHIgyFCPAqvA/YdIjTgQ3WBLNZkpWoQPnRIUljdGiIkHd9jumgeO0ESEI97cNTPJj6Z4ISOZh1JUSVLwiAs7pRp02aTypRUhwIzjvhfPCKF1wH/BTqwA5pQlnYyipgs6dDBQVncZatZaZUlsUxZYVq0jyfm8kNeBzz/Gu0ETrjABAURAoTJOVVJpDAoM3ZOc5olfmMK42CYMrRTAr6tIK6QiSA84VtIIEosslSTNYUkUxyS5aEDQ6tMmQ7YDMOmjziYx8E56oPEl8DdDgM2/BLeIJVw9CRSTClZg97ZrDl0BF6m49V0GTIZQL4CvNuxFj47w4ASmqUkAalYU+DBoIbK8hAG506aZTLonWFG0IMa1AAHXlegW9wFGuAJG97hhFkqiuCxUZyqSSWR5GCZHKxB7nSwDcZADHiACQ4eJ/Oot9+BvsaLQD2Hby9RUEEs1cUlcdKpmWKSQ2VyqAY56J0RiEEPOqHxXYv2W4yJuANWxBkBOKEGFcwyjlhMYdLJSjLJpA8FAxqMwXZRQA0wgdQ94Hcf4nqDFnQhBDcY5YJUIqSSpnxpRqone6ol+2Af7Il2MJJxnN/8lgIA8yWQUKItaBMRsGEdDIrQoYNTnGSyBqdZQSY16IEYaANOOKn/A+htXH+OdgLOiB1BBOEGCz5ejmO6JpGEeexVJTmohJNORqIlnVDyO4CvvsT2AGm0BVEHo0IMHeEooeQipzDFY5eSNcigLgwoGYlIKHF/ky9Z+xD/WrCfoQUuRCGAKBhlwIBRQvmSuykkMYHkqx7EAPK+/wdqEbWmfB0bfwAAAABJRU5ErkJggg==",Uz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAABGSklEQVR42u3cx4tb6brvcf0DmmpUoxrUoAY1KCgwFAZjME1jjGmMTWNs2tjY2MY2DjjinHPOOeec3dXOOeecU2VlaSksSc/9aq1X0pJKqmD3Dn3upvnCSe197v38nlfS2fscW1x+kbCMloAsFY/skEY5KbVySb7JXfkoT+WtvJGX8ol/67s8lDr+o065KW65Jl7+q/zyF3/nWTpJx+gQ/7H94pPd/Oe38yduEZds4E9dK/Wykj95GX/OYvkq8/kz58h7mcmfP41/hMnyTCbIIxkn9/nv5raMlOsyTK7IELkgg6RKBshp6ScnpI8ckd5yQHrJHvmd/3578I/QjX+E32SNdOEfobMskV9lAf+vmiOdZIZ0lKnSQSZKe/7kSv7kdjKchkoFf2q59Ke+UsafWCY9pZQ/rZQ/rUS6Umcp5k8q5k8p5k8p4k8p4k8o4u928Hc7+Dsd/F1mpWLn7zArVhWpHOlsRvYC/Yf++t8A/j8fQCxrADvTA/j6vwH8/zGAaOzX/w3g/+cBaJEuEkqMMQbg/t8A2jiA8n/+AHzB7qLFx8K2zBhAA5Q16QE8+98A/q8PwOXvLYHYePEllsO666cGcPR/A/jnDaDRN0C80Ynija8QV2K3GsBlywDe5h3AVYAvAv0X4IUH4P7fAP7bB9DgGyau0BRx6yvFGd8j9YlTUp24LF+g/gDKGwbwAqwnwD1o5QD2/VcPYMT/BmD9q94/Thq0GeKMrpbG2B6pi5+S78kBJAoNoDFrAFU/PICP/+UD6PL/xwDqAlOlNjBH6sMQ6XulJnZavsWvyGcG8D7BABJvsgZwxxiAK2sAZ9ID8P/gAF78QwbQ/v/eAGqDc6Tav1BqtA1SE90v1fpp+Rq7Ip/id+UdA3jNAJ4nPsnjRGYAN0C9whe8C+kB+BmAP2sAu/jPNx1AjRrAlzwDeNqKARz/3wD+7r+qtSXy1QdLcJN8Dx+Qb9Ez8kW/Ih9id+Vt/Jm8sgzgfqL5ARwxBuBjAN70ADbznSE5gDWMJzWARekBvGsygLFy738D+Hf+9T20Sj77VsuXwFb5oh2SL5Gz8lG/Ku8ZwJvYM3kZfyPP4h/lUeIbA6iV24lGuZ5IDcALjQ8aP4+zOYCD/Pt70wNwqQE0WAbwLWcAr/MM4FbOAP78Bw+g6L97AN/CG+Sjb6N89O+Qj9oR+Rg+J++jV+Wtfk9eMYAXsTfyhAE8jH+TuwzgVqLBGMDlhFvOJ7zyZyI5AB8D8EHjyxrAtjYN4EnWAEYYA7j8XzCAXwoMoOJvHsB/aARfwtvkvS/ZHnkfOCbvtCp5G74mb6L35KX+TJ4xgMexj/IgOYB4rdyMN8i1hFMuGQPwyDlGcJoRHE+YAzgA/l7jn1VwqwE0WgZQLUuNAXxmAB+MAcyQVxClBvCQAdxtxQD25x1A1x8ewB9tGEAljO3+7wzgU2SPvPPvlje+A/LGf0LeBP+S16Fr8jJyT55Hn8kT/Y080j/K/dhXuROvYQD1cjWeHIBL/lIDOEXH6TAdoD0JcwBbGcAmBrCeL4Br+AWQO4DZ/MQ0B/C8mQGczxnA4YIDaM0LUNmqAfz2LxmA/b9xAB8iB+VN4IC88h2Rl/5T8jJwXl5o1+V56L48jTyTx9HX8kD/IHf1r3IrViPXY/VyJd4oF+IuqYq75SzYJ0E/ZgzAI/tpD6/DDgaylZdiE9efHMBqYwDfGcBXBvBJ5uUMYJIxgAeWAVyzDODcv2gAA35oAEV5BpAZwT9sAO+iR+VV4Ii88B2X576z8tx/QZ4Fb8gT7b48Dj+Vh5HXcj/6Qe7oX+SmXi3XYnVyOdbAAJwMwCVnGMHJuEeOAn/IGICbAbiMAWzhC+NGvjOs49fD6kSNrFADWGgM4L0awEs1gMeWAdxUA7jUxgGs+Le8AP+nBvAmelJeBE/IM99peeqrkif+S/I4cFMeMYAHoadyP/xK7kTey63oF7muf5creq1c4hU4H2uUczGXnGYEJxjBETpE+4DfbQzAqQZQzwBqZVWiWlbwS2JJ4ossTHxUA3ijBvDMGMB4YwB3ZFTeAZz6FwzA+gL0+jcN4L/sl8BL/Yw8004Df04e+87LI98Veei/JQ+CD+Se9lTuhF7JrfB7uRH5JNei3+SyXiMX9Hqp0hvkbMwppxjBcTrCEA7SXtrF67Ad/C1c/wauf60awHJjAJ8ZwAeZm3gnsxJvZHrihUxNpAZwvxUDOKQGsJsBbP+bB/A7df/JAfzD/mcBz3WuXvtTHvmr5IHvotz3XZN7DOBu4IHcCT6VW9oruRF6J9fCn+RK5KtcjFbL+Wid/MkITuuNcpIRHKPDjGA/8HtoJ98RtvFrYTNfGDeAv5bnf2XiOwP4KosTn2SBMYC3DOCVMYApiacyKfFIxifuy5hEcgA3YLrKAC7KYPlLBjKA/nKSARzLM4DNagCr/4UD6PRvGsB/YARPda5eOy8PAhfknu+y3PVdlzu+O3LL/0BuBp7Kde2lXNPeyZXQR7kU/irnI9+lKlojZxnBKV6B44zgCB3iI2E/7aEd4G8Ff1O8Tjbw03FNvFpW8jNyGc//Yp7/BYn3lgE8ZwBPZKIxgHsM4LaMSlyXEYkrMjTBABJVDOCsMYC+lgH0VAPo/hMDqGhxAJ1bOYCyf+4AHuuX+Ky/yMVfAv6q3PLdlJsM4Ib/oVxnANeCL+WK9lYuaR/kQuiLVIW/yblItZyO1spJRnCMl+AwQzhAe2kXXxB38B1hC18WN4K/HvzV8e8M4KssjX+WRfGPMp/nfw7P/8zES5mWHsADGZe4ywBuGQMYbgzggjmAxBnpn2AAiaPSJ5EcwD4GsAuubWoA6/83gB/964F+Re6Grsjt4FW56b8uN3y35LrvrlzzPZQr/qdyOfBSLgbfyHntvVRpn+Rc6KucCX+Xk5EaOR6plSOM4FC0XvYzhD20U6+TbeBvidXKBn42rot9l1Vc/4r4FwbwiQF8kHnxtzI7/lpmxl8wgGcyOfE4awAjE9cYwGXLAE4zgBMM4AgDOCi9E3ulZ4IBJBhAYpN0S6QGsByyxX/bAEqyBtDxJwbwX/xL4J5+TW6Hr8nN4HW57r8B/G254rsnl32P5BIDuOB/IecDb6Qq+F7OaR/ljPZFToW+yXFGcJQRHGYEB3gN9tJufiHsoK18UdzET8YN4K+JfZOVsa+yPPZJlsQ+yML4OwbwhgG8khnx5zI1/lQmxx/JhPh9BnBHRiduqgFcYgDnGcCfWQP4Iz2AndkDSKySLgkGkGAAifnyS2K2GsCUv2UAxQUH8A//HwbdiV2Xm2HwtRtyNXAL/DtyyXdfLjCA876n8hcDqAq8lnOBd3Im+EFO8QqcYATHGMFhRnAwXC37GcIe2sl3g+18SdwC/kZ+Mq7Xv8lq/SsD+CzLYh9lcey9LIi9lbmx1zIr/lKmx58xgCcyKf6QAdyTsfHbMjp+Q0bGrxoDGMIABiXOqQEcVwM4wAD2qAFsVQNYl38ACQaQYAAJBpBgAIm2DKDrDwzg7/gp+G8ewc3YTbkevilXtZs897flov8u+PfBfyRVDOCc74Wc9b+S04G3cpJX4ETwoxzTPssR7ascYgT7+U6whyHs4svhDtoa/S6b+Lm4Afi1+hdZpX+WFfpHWap/kEWxdzI/9kbmxF7JzNgLmR57KlPijxnAAxkfv8sAbjEAvgDGr8iw+EUZEv9LBsX5CZjgJ6AxgMMMgF8AxgB2SA9jABuNAXRt7QASDCDBABIMIMEAEgwgwQAShQbQ+n9VUNP/WcA/4HvA9RhXH7nFl7xbciFwR84zgCrfA/mTAZzzPZEzvudy2v9STvrfyHFegaO8AkcYwSFGsJ+XYC/fCXbTDoawLfJNtvBTcSOtj36RNdFPshL85eAv0d/JQv2tzNNfyWzwZ8aeybTYE5kceyQTY/dlfOyOjInflFHxawzgMgO4wACqGMBZGRDnJ2D8mPSNH8oZwBY1gLUMYCUDWMYAFlkGML1tA0gwgAQDSDCARKEBFP7nA/6RA7jCAC5FbssFDfwg+P57wD8A/pGcZgAnGcAJ30s57n8tR/1v5XDgvRxiBPsZwV4+DvYwhJ38OthOW8JfZBNtiHyWtZFPsir6UVZEP8jS6DtZBP4C/bXM1V/KLP25zNCfylT9MQN4IBNid2Vc7LaMid2QUTGe/xif/3E+/+N/MoDTagD8AkgOIM4A4rulZ5wBxJMD2JBnAPPyDGAs+KPyDKBf4QEkGECCASQYQIIBJP5d/7OAf+MILvH/8Rcid+Sv0B35kwGcC9zn4h/IKQZwkgEc9z2TY3wMHPG9kkO8AgcZwX5GsJcR7GEEO/liuJ0hbAl9ks20IfxR1tHqyAdZGXkvyyPvZEn0rSyMvpZ50ZcyR+f69WcyHfwp+kOZpN+XCfodGcsQR/N9ZGTsCgO4KENjf8ngGJ//DKB//DgD4BdAnC+A8X0MgF8A8e3mAOIb5Lf4GukaTw5gqWUAsywDmNDGAXQrPIAEA0gwgAQDSDCABANIMIBEqZE9UaIqVhVZcqSzJf5LBnCep7cqeoefd3flrHaPz/r7PPcPuPpH4D+RowzgMK/AIV6BA3wX2M8I9vJ9YDcfBzv5TrCdIWzVPshm2hj6IOtpTei9rAy/kxW0NPJWFkVeywLw50ZfyOzoM5kRfSLT9EcyWX8gE/W7Ml6/LWP1GzKaXyQjYjz/sQsMoIoBnJWBsZPSP8bnf+wwA+ALYHwvA+ALYHwbA9icPYA4A4gvlF/jc+WXeGoAk/+GAfzSigGUtXEAagS5/bsHUMUAzkXv8tv+Lt/w78lJBnCcARxlAEd8j4F/KgcZwH5egX2MYA8j2M0IdjCC7bQ1+E4200btnayntbQq9FZW0rLwG1kSfiULIy9lXuSFzIk8k1ngT48+lqnRBzI5es+4/nH6TRmjX5dR+hUZoV+SYfp5GRLj+Y/x/BsD4PM/xvMf2y+9Y3z+x3YwgK0MgF8AcX4CxlczgBUMYEn2AOLTpGOcAcStAxje4gBK/5MDSGfL9K/86xwDOM0ATjGAEwzgePC+HAk8kMP+R+A/lgO8Avt5BfYygj2MYBcj2MEItvOdYEvgjWymjcE3sp7Wam9kNa2k5aFXsoQWhV/K/PBzmRt+JrMjT2RG5LFMizyUKdH7Mol/3PHRWzI2al7/SP2yDNe5fr1KhujnZJDOAHSe/9gRywB2mwOI8fzH+AIY4ydgfBUDWK4GsEANYGb2AOIMIM4A4gwgzgDihb4E9rAMoMvfMIDiHxxAzghy+7v+Os0ATgJxnAEcYwBHGMAhBnDQ/xD4R1z9Y+CfyG5GsJMR7GAE22gLvww2M4SNgVeyntYGX8lqWqm9kuXaS1lKi7UXsiD0XOaFnsmc8BOZGX4s08MPZWrkvkyO3JWJfPkcF+X6o9dkVJTrj15kAOcZwJ8yWD8jA/WT5gB0nn/9gPyh8/zHdjGA7WoAfAGMrZXfYiula4wBxBYbA/glPqd1A4gzgDgDiDOAOAOIM4A4A4gzgDgDiDOAeGoAnZoZQL7vAcXNvgI/PYC21NxfJ+N35Difw0cZwJHQPb7h35cDDGA/HwN7eQX2MIBdDGAHbWcEW2kLQ9jECDb4X8h6Wht4IatpZfCFLKelwefgP5eF2jOZrz2VOaHHMiv0SGaEHsi08H2Zwj/WJPAnRG7KuMh1GRO5ygAuMYALMizK9UfN6x+on5D++lHpqx9iAFy/vkd66Tulp87nf2yzGsAaYwBdYvwCiPEFMMZPwNgc6RSbwQCmMoBJDGA8AxhjGcCQtg0gzgDiDCDOAOK5A/iZL4L/xhEU6hgDOMIADnORB/kiuF+7L/sYwR5GsJtXYCevwA5GsI22MILNfCfYxAg20Hpa638uq2ll4LksDzyTpbQ4+EwWBp+A/0Tmao9ltvZIZoI/PQQ+/xiTwuCHwQ9fl7Hgj45clpGRCzI8wvVHuf7oGRkU5fqjxxkAz79+kOvfxwB2MwCef53Pf32TdNfXSzedz39jAEvVAPgFEJttDKBjjAHEGECMAcSSAxj59wwgzgDiDCBeYfZPHsARBnCIL2IHGcB+cPbyMbCHAeziy+AOXoHtvgdc/SPwH4H/WDbSBoawjtbQKlrpfyLLaWngiSymhYHHMj/4WOYGH4H/QGYyqun8uVO1uzI5dFsmhm7K+BD44WsyOnxFRoUvygjwh0W4/shZGRzh+qMnGMBR6Rfl+qP7jee/t87zr/P861sYAJ//Op//Op//Ol8AdT7/db4A6skB8AUwxi+AGD8BYxNpnDmA2EhpFxtGDCDGAGL9pTzGAGIMINaaAXTMGUBqBAwgXqZiAPF/0AAOxW/LAQawL3JH9jCA3SDtDN7jW/592ea/L1sZwRZGsMn3EPhHXP0jWUtrGMIqWknLaan/sSzmI2MhzQ88lLm8ILMZ0kyaEbwr07Q7MkW7JZO0mzJBuy7jQtdkTAj80CUZGT4vw8NVMjR8jgGclkERrj/C9Ue4/uhBcwBRnv/oDukZ3coAeP51nn+dz3+dz3+dz3+dz3+dL4A6XwB1BqAzAJ0B6AxAZwD6aKnUrQMY2HQAMQYQYwCx/AMoNgaQ7xXIMwCjYktFmbIG4PjPDmA/A9jH7/A9DGBX+I7sAGo7I9gWuMu3/Ht80bvP1d8H/z5X/wD8B7KaVjKIFbSMlvLvL6aFjGU+zeXvmc3fO4s/Y0bwjkwL3pYpwQz+eO2qjNWuyOgkfuiCjAhVybAQ+OEzMjh8UgaGjzOAI9Ivckj6RsCPcP2RXQyA649y/dGN0j3K8x9drQawjAEsYgDzGQBfAHW+AOp8AdT5AqjzBTA9gBHSTmcA+mCp0AeC38wAYgwgxgBi/BSMtXUApc0PIO5IZzOym/0nRrAnfkv26LdkV/S27OCzeXvojmxlBFuA2wTgBv9dvujdBf8eV3+fq78vK733ZQUt499eQotoIc3nv2Yu/7WzaZb/jswI3JZpgVsyJXBTJgevy8TgNRkfTOJfljHaRRmlga/9JcNDf8rQ0BkZEjolg0I8/eGj0j98WPqFuf7wPgawhwFw/ZFt8ntkMwPYwADWMgCe/yjPf5TP/yjPf5TnPzqb+AKo8/mvT1IDGEujmg5AZwA6A9AZgJ4aQPecAfxqDiDGAGIMIMYAYgwg1poBlLRtAAWzFe5nB7ArflN2MoAd/B7fFr4lW/iM3qzd5rf9HdkQuAP+Hb7o3eHq73L1Zsu9d2UpLaFF/PsLaL7vjsyl2b7b4N+SGTTNfxP8GzI5AH4giX9FxgUvyZhgEv+8jNSqZLj2pwzTzsoQ7bQMDnH9oWMyIMT1h7j+8H4GAH6Y6w9vZwBbGABf/iJcf4Rv/xGuP8LzH+H5j/L8R3n+ozz/0enEAKIMIDo+ZwBDCw9AZwA6A9AZgN6KAcQYQIwBxMpVDCBWavT3DqCFEfzMQHYwgO36TdnK7/EtDGBT6JZs4LN6A0/2Oq53DVe8yn8b+Ns8+be5+js8+Xdksfe2LKQFNM93C/xb4N+Smb6bMoOm+a/LFJrsvyYT/VdkQuCyjAuAH7ggo4PgB6tkRPCcgT80ia+dlEEaT792RPqD3y8Efmiv/BHazQC4/jCf/WGuP8z1h9dJtzDPf2QFA1jKAHj+Izz/EZ7/yExjAB2jU2iiOYAoXwCjDCA63DIAfgHo/ahP4QHoDEBnADoD0Ns4gFiJqlhVZCl3AI5/3QBaalv8hmzRb8jm6A3ZyO/yDXxDX89n9VpaHbwpq3i+V3LNy2kZwEtoMS303pT5NI/m0GzvDfCvy3Sa5rsmU2iy74qJ778k4/wXZWwSPwB+APzAORkePCNDg6dlSNDEH5jE18DXDkhfbZ/00bj+0E7pFeL6Q1x/aKP0CK1nAFx/mOsPc/3hJbRQOofnMQCe/wjPf4TP/wif/5EJDIDP/yif/9GR5gCifAGM8gsgah1A79YNQGcAOgPQGYDOAHQGoLd2AHlGoLIZ2bP7dw1gS/y6bNKvy4YoRa7LOn6br9FuyGpaGbwhK3jCl/tv8C3/BvA3ePJv8OTfAP+6zKU5NItmeq/JdJrmuwr+FfAvy0TfJZnguwj+BRnrPy+j/VUyyv+niR8AP3BKhgROyOAg+MEjMiB4iAFk8P/QdklvbYf00rh+jevXuP4Q1x/i+kMMIMSXvxDPf5jnP8zzH55FPP9hnv/IJHMAEZ7/CAOIjGAAw7IHEGUAUQYQZQDRnj8+AL1cxQD0UiO7/pMDyJvN7O8cwMb4NdmgX5P10WuyNnJN1vDbfBW/0VfybX0FX9yW8fm9hBbznC/kqhfQPJpLswGf5b0qM7xXwL8iU2mK95JMoonAj/ddkHG+8zLW95eM9iXxz8kI/1kZ7j8tw/wnTfzAMRkUAD8AfvCg9Avul75B8IMZ/J4a169x/RrXr62RbtpK+U1bzgC4/hDXH+L6Qzz/YZ7/8DTi+Q/z/Id5/iNjaJQxgHYRBhBhABF+Akb6Nx1AlAFEGUCUAUQZQJQBRFszgArLAMoyAzAqtlRklncAjtYPoFA/MoAN8auyLnZV1uhXZXXkqqwMX5UVoauynJ9qS/nGvoQWBa7yE+8qP/Gugn9F5tBsmgn4DO9lmQb4VJrivQj+BZlI473nZZz3L/CrwP9TRvnA952R4T6F7z8ug/3g+4/IwCR+4ID0C4Af2CN9ArsYAPjBbdIzCH4Q/CDXr/HNX1sFPp/9Gp/9Gtevcf2hucTzH+L5D3H9ockMgOsP8/yH+fwP8/yHef7DfP5HBmcGEOlLfP5HGECEAUR6GAMoif6WPYAoA4gygCgDiLZ1ACVNB2DkSGfT/6YBtKXUANbGr8ia2BVZpV+RlZErsiJ8RZaFrshSfqcvpkV8c18QuAL+ZX7iXQb/ksyimTQd9GmgTwV8Mk0CfQKN91aBXyVjvH/KaO85GeU9A/5p8E/KMN8JGeoD33fUxPcfkgF+8P3g+8H3gx/YIb0D26RXYIv0DGyS3wMbGMBa6R5cLd2CyetfxgC4fo3r17h+jevXZhLPf4jrD/H8h8YTz39otGUAQ4jnP8zzH2YAYQYQTg6gV2YAEQYQYQARBhApMIAoA4gygCgDiFaYNRlAaQsDyDMC3d60f+UIkq2OX5KVMdIvyfLoJVkaviRLQpdkkXZJFtJ8frbN49v7XJrNF7lZPO0zeNqn0zTQpwA+mSZy7RNAHw/6ONDH0GjgR3lPywjvKRnuBd97HPxj4B+RQb7DMtAHvu+A9Pftk74+he8H3w++H3y/wg+sk+4B8APgB3n6g1x/kG/+wQUMgOvXuH6N69f48qdx/RrPv8bzr/H8h3j+Q3z+h3j+Qzz/IQYQSg6A5z/M858cQJgBhHn+wwwg3M0ygM5SHGEAEQYQYQARBhApMIAoA4iWqcCP/k0DaJItu58dwMr4RVkRuyjL9IuyNHpRFkcuyqLQRVmgXZD5NDd4Qebw7X02zeSL3Ayaxuf6VD7Xp4A+CfSJNAH48aCP9Z4F/wz4p2Uk8COAH+49YeJ7j8pgL/jeQzLQe1AGePcb+P3A7+sD3we+D3wf+D7w/eD7wfevMfEDK2ipdA0sli4B8INcf5DrD3L9Qa5f4/o1rl/j+dd4/rXRxPVrXL/G86/x/Id4/kNcf4gBhBhAiOc/xC8A6wDCDCDchRhAOM8AIgwgwgAiDCDSzACiJapiS3/zAFpboQEsj1+QZbELskS/IIujF2Rh5IIsCJ+XeaHzMlc7L7P5zT6LZgb+kun+v/h9XwV+Fd/y/5RJNBH0JPw44MeCPoZGeU7JSM9JGeE5IcM9x2WY55gM8RwB/7DCP2Die/dKPy/43l3Sx7tD/vBuk97eLQxgEwPYIL/71ksP3xoGsEq6+cH38/T7efoDPP2B+TRHfg3wzT/A9QenEtcf5PqDPP9Bnn+N69e4fo3r14aYA9AYgMYANJ7/0B9qADz/IQYQ4gtgiAGEcgYQZgBhBhBmAOE8AzBiAJEyVakaQYEBpHOks/07RpCvpfHzsjh2Xhbp52VB9LzMj/wl88J/yZzQXzJbq5KZNCNYJdP57T6Vn3BT+CY/mS90k2iC7yz4Z8A/beCP5tpHAT8S+BHADwd+GPBDPIdlsOeQDPIclIGe/TLAs0/6e/ZIP89u6evZKX08Fnwv+F7wvQrfB76P6/cpfP8iAt/P0++fbeD/EuCbf4DrD0wirj/I9Qd5/oMMIMgAguYAKjSef43nX+tnDkBjABrPv8YAtB6WAfD8hxhAiAGEGEAoZwBhBhBmAGEGEC4wALJHSlTFZs0NIJ29af/KASyOV8nCWJUs0KtkXrRK5kaqZE64SmaF/gT/T5mhnZNpwXMyld/uUwJnZZL/DD/xzoB/mp95SfhTXP1J8E+Afxz84+Cb8EMN/EPgHwT/gMLfq/B3gb8D/O3yh2er9PaA7wHfo/C94HvB9ybxl9MS6eoD38fT75tn4P/q5+n38/T7uX4/1+/n+gPjCPwA+AGe/wDPf5DnP8j1B7n+INcfTA6A51/rrQbwuzkAjQFoXL/GALScAYQ6SVGIAYQYQChnAEYMIFymKjAAoyJLjjwjsLciW3Y/M4CF8T9lfuxPmaefkznRczI7ck5mhc/JjNA5ma6dlWk0JXhGJgdOyySayG/48f5T/L4/yU+8k+CfAP84X/aOAX+Uqz+i8A8p/AMyyL1fBrr3yQD3Hunv3i393Dulrxt8N/hu8N0WfM866eEB32Pid/OC7+Vz3wu+18Tv7OPp9/H0+7h+H9fvM/E7+nn6/Tz9fj77/Ul8rj/A9Qd4/gNcf2CAGgDXH2QAQQYQtA6A67cOQGMAGvga15/GVwMIMYAQAwhVmOUOgOzhElWxWZMBqBGobEb27FozgNZUaADz4udkbuyszNHPyqzoWZkZOSMzwmdkeui0TNVOyxSaHDwlEwOnZELgJPgnZZz/BPjHZYzPhB/Jl7sRfLkbzlM/DHQT/4AMBn4Q8AOBN/F3gb9D4W8Dfwv4m6WXe6P0dIPvBt9t4nf3gO8B3wO+hy99ngUMAHwv+F7wveB7k/g8/T6efh9Pv4/r93H9fq7fD76f6/dz/X6uPzDQGEB5gOsPMIDAH2oAPP9BBhDk+oMMIJgaQBL/18wANAagga+1V+UMIMQAQmWqUqMmAzAqyslhlh5AnhHkzWYW/cnmxk/L7NhpmaWflpnR0zI9clqmhU/J1NAp8E/KJJoYPCkTgidkfOA4+MD7j8lofseP4ufcSOBH8OVuOOjDeOqHAj+Ep34w8IPcexX+bvB3Sj8X+K7t0se1Vf5wge/aJL1cG8BfD/5aA7+HG3w3+G7w3SZ+V89CBsDnvofPfQ9Pv4en38vT7+Xp93L9Xp5+L9fv4/p9XL+P6/cNJ67fz/X7uX4/A/Bz/f4kPtcfAD/A9QcYQKCHZQDgB7n+IAMIMoBgMwPQGIBWoWIAWs4AQiWqYksFBkC2dPbsmhtAS7U0gNnxUzIzdkpm6KdkevSkTIuclCnhkzI5dEIm0UTtuIwPAh88JmMDx8A/KqP9R0x8fseP4Fv9MK8F3pMfvh/wfV3bwN8C/mbwN5r4LvBd4LtW00rp7loB/jLw+cx3g+8G3w2+ey4pfM90At8DvoenP4nvHUtcv5fr944w8X1cv4/r94Hv4/n39zMH4Of6/QzA35N+NwcQYAABrj/AAAI5AwgygCADCDKAYAq/wACMSo3sWolZ1giKcnKks4UKDCBvNrPITzYzflJmxIDXT8jU6AmZEjkuk8PHZSJNCB2T8doxGacdlbHBIzImALz/sIz0Aw/+cN9B8A/w+34/+PvA38uXvT3g7wZ/F/g71NVvM67exN9kwV8H/ppsfBf4riW0SLq6ePZdFnw3+G7w3eC7JzMAnn4PT7+Hp98DvmcUA+D6vVy/F3wv1+8dpAbA9fsYgK8PMQBfL2MApckB+MH3c/1+BuBXAwgwgAADCDCAAAMIWAYQrFQxgGCFWXMDMCpWFWWXOwAje/7yDaClWhrA9PhxmRY7LlN14PVjMil6TCZGjsqE8FEZHzoiYzXgtcMyOnhIRgUOgX9QRvgPgL9fhtFQ7z4Zwu/5wcAP4mfdQOAHAG/ibwN/a/rq/wC+N/C9uPqeXL2Jv0rhL8+DP4/Ad4Hvmkngu5L4Uwh89wQC383T7+Hp94Dv4fo9XL8HfA/X7wXfy/V7wfdy/d4kfm9zAD7wfVy/jwH4UgMA3w++H3w/+H4T3xhAgAEEGEAA/EA7I3MA5aoyVamRPZhvALkjcKSzpbMXHkE6W3bhH2xq/JhMiR0F/6hM0o/IxOgRGR85IuPCh2Vs6BD4h2Q0jQoelJGBA+Dvl+H+JP4+GerbA/4eGezdDf4ufubtUPjbwd8K/hbwN6ur36Dw10lPJ/hOrt650qi7M4m/FPjFOfhzmuK7wHeB7wLfNd7A7+AG3831u8F3D6OhBn47D9fvAd/D9XuS+H3MAXjB9/L8exmAt4eBX+oD38f1+xiAjwH4LAPwg+/voMoZQIABBMpVZWbWAaQrttSKARSquRE0V6EBTIkfkUkx4MGfoB+W8dFDMi5ySMaGwQ8dBP+AjNT2y4gg8IF9Msy/V4b6gQd/sA94r4I38LeDv5Vv+lsU/qb01fd2rpdewPd0rgF/lcJfAf4y6eYE3wm+c6F0dYLvBN8JvhN8Zwb/l1x8F/gunn4X+C7wXcNNfDfX7wbfzfW7+zOAfuYAPOB7uH4PA/AofC/X7+X6vQzAywC8DMCrBuBjAD4G4GMAPvB97c0B+BmAH3wjBuAvN0sNIFBqZA+UWMoZQDpHOluwFQPIyta0UBubFD8kE2OHwD8k42ls9KCMiRyQ0eH9Miq038TX9snw4F4ZFthj4vt3g79TBvl2yEBvEh94zzYD3sTfDP5G8JNXn4RfR2vAXw3+SoW/XOHz5DsXKfz5FvxZJr4TfCf4TvCd4Dsn5sEfaeK7ePpd4Lu4flcSf4AxgHI3+G6u380A3En8nuYAPAzAwwA84HvA9yh8L/he8L2dVJYB+CpV4PsqzFID8JepwDcqMUsNIF2RJUfTERjZm9aaAbQm6wAmxA/K+NhBGacfkLH6fhkT3S+jI+CH98nI0F7w98hwGhbcLUMDu8DfKYP9OxT+dhng3QY+8NSX3/R9+U3fB3gTf526+tW0SuGbV9+dq+/WyNU3gt+4QLo2gt84l8BvBL9xBmXjd0riO8F3gu8E3wm+cyQDMPErXUMVPtfvAt/F9bu4fhf4riR+b3MAbvDd4LvBd3P9bssAPAzAwwA8DMCj8I0YgJcBeCtVDMCrBuArV5WpwPdZBmBUbKnILDUAS7Z0drNgc9my+5ExjI/vl3Gx/Sa+vk9GR/fKqAjwYeBDwGvAa8AHd8qQwA4T379dBvq2gb9F+nuT+En4TdLHvUHhrwd/bfrqewL/u+XquzcuUfgLFf48hT87G78R/EbwG8FvBL9xPPGlr3EMAxht4jt5+p3gO8F3gu9M4g+04PdVAwDfBb6L63cxABcDcCUHAL4bfDf47s5GxW4G4FYD8IDv6aBiAB7wPe0yAzAqV5Wp1AB8Jari7FIDMHJkZUuVGkCz2ZqOoLnyDWBcfJ+Mie2V0Trw+h4ZGd0jIyK7ZXh4twwL7QIfeA34IPAB4P1bZYB/iwzwJfE3Sz/vJunr2Wjg/+FeD/468NfwZS9z9b9z9T0M+KUKf5HCn6/w5yj8mQp/msKfrPAnZOM3gt8IfiP4jeA3JvGHGPjtnOA7uX4n+E7wneA7uX5nHnwX1+9iAC4G4GIALvBdCt/dScUA3OC726vMATiMwPeUq8pUpeYAjEpUxZl8RTk5skoPwG8vnHUALdXSKMbE98jo2B4TX98tI6K7ZHhkpwwL75ChoR3gb5fB2jYZFNwqAwNbDPz+/s3S37cJ/I3gc/Ue4N3rjKvvDXwvftr1VPC/c/U9LFffTV29ic/VN4DfMEs6N4DfMJ3AbwC/AfwG8BvAbwC/gWe/AfwGK/5wE78R/EauvxH8RvAbuf5G8BtT+L3NATgZgJMBOMF38s3facW3DMDFAFzguzoaFbkYgEvhG4HvrlCVqywDILtRicoyAG9RTg6z1ADS2ZuWdxC2pgXa0Oj4bhkV2wX+Lhmh75Th0R0yLAJ+eLsMCW0Df6sM0rbIwCD4AeD9wPuA922Qvt714K+TPzzAu9cY8L34Td/Tlbn6Hs7k1S82rr6b5eq7NiTxZyv8GRb8KQp/Yn78BvAbwG8Av2Eogd8AfgP4DeA3JPG5fmMAfxD4jeA3gt8IfiPX32gOoCQ5ACcDcILvBN8JvvMXMzWANL5RpYoBuCpU5WbJARiVGtndJZmSA0hXlJMjMwKypbNn8jWXLZO/DaUGMDK+U0bEdshwHXgaGgU+Anx4qwwObTHxtc0yILhJ+gc2Sj//BgO/j2+d9PGuBX8N+Fy9e6XC5+pdyw34HnzD7+40r76b5eq7GlefxJ9pwZ+ajV8Pfj349eDXg18Pfj349SMYQC7+oAx+A/gN4Ddw/Q3gN4DfAH6DBb+R628EvxH8RvAbOxsVN6YGAL6zo1GRkwE426vAd7bLPwBXmarUyO6yDMBdbKkou+QALNnS2c28LWXLHkFL5Q5hRBz82Hbwt8lQGhIFPgJ8GPjQZvA3yQBto/QPbpB+AfD9wPuA966h1dLbs8rAT8L3BP531zKFvxj8RQp/PvjzFL559Sa+efW/1oNfD349T359Cn+cBX9UBr8e/Hrw68GvB7+ez/168OvBrwe/Hvx68Ot5+uutAwDfiAE0cP0NDKCBATQwgAaF3/iLigE0gt/YQQV+Y6UZA3AYge8sV5VlDcCeGkC6YktFZukROLKypbNnRtBcyQG0pkKDGB7fJsNiW8HfIkNocBT8CPBh4EPAaxtM/OB66RtYK338wPtWg78KfK6eerqXg78MfOBdSwz47vyu7+Y0r/63JDxf9LpannwDvz6Jn4SfbMEf3zJ+Hfh14Ncl8Qem8Sss+OVJ/Hrw68Gv5/rrwa8Hv57rrwe/Hvx6E98YQAMDaAC/AfyGjkZFDeA3tDczBtDOyNFYoSo3Sw7AqNTIblSSKd8A0jmysqVKDqCljBHYWq65YQyLb5GhsST+ZhlMg6KbZGBkowwIAx8CXlsP/joTPwC8H3jfSuntTeKvMPB/dy8Ffwn4XL0rib8AfPPqM/iz0k++iT/Vgm9evYFfB34d+HWjCfw68OvAr+Pbfl0Ofh34deDXgV8Hfh34deDXgV8Hfh34deDXgV8Hfp0VXw2gHvx68Ot/UTGAevDrO5gZA6hUtTNyNFSo1AAay1SlRnajkkzOYktFORUYgMvefOkh2JqvpXEMjW+WIbFN4G+SQfpGGRjdIAMi4IeBDwGvrZW+wTXgrwIfeOrlWyG9vFy9Z5nCXww+8K6FGXznXPCB5+ediW/Cd1ZP/q/qyU/j14034DvWjcnBH94Uvxb8WvBrwa8Fvxb8WvBrwa8FvzaDX2bFp5I6BlAHfh34dVx/HfhG4NeBX9fRqKguOYD2qkoV+PUVqnJzAA1llkqN7A0lmRqLcyrKLjkAS7Z09kzNjsFWOHcrGhLfKINjG8HfIANpQHS99I+sk35h4EPAa6ulTxD8QBIfeN9yWiY9vcB7uHp3Eh94F/Cu+eDPU/jANwLPb/sMvgn/q3ryDfy6JP64PPhcfS34teDXgl8Lfm0r8WvBrwW/FnwjBlDLAGrBrwW/FvzazkbFteDXgl/bySyFbwR+XaWqnZGjzjIAozJVqZHdqMTMGEFxTkXZNTrS2bKyZ3I2l83M9YMNjm+QQbEk/noZoK+T/tG14K8BH3htFa2UP4LgB8D3A+9bCv4S8IH3LGIAKfx5BLxzDqXwZ4BvXn02/kQyrz4bf5R0qOXqa5viV6bwa/jCVwN+Dfg14NeAXwN+TW8Cv6aniqe/Bvwa8GvArwG/BvyaLioGUAN+zS9mxgA6GhXVgl/bXlWpAr9WDcCoXFWmKjWyG5WYGUMotlTUtAZHOltW9kyNzWUzc7ay3AEMiq+XgbF14K+V/voa6RdZLX3DwIeAT+JrK6R3kKsPgO8H37dYfvcC71kI/gLw51vwgXfOAn9mDr4J/6u6+mz8McTV1xbArwG/Bvyaga3A79UCftcc/NQAOqnAr+mgAr+mUtXOyFFboSpXlVkqNbIblWRGUFdsqahp9Y50tqzsmRqay2bW2MpyBzEwvlYGxNaAv1r6RVdJ38hK6RMGPrQC/OXSW1smvYLAB5YwAPB94HsXMID50t1twndzcfUuhe8EvnE6mVffFN+E76SuvmNtHvyaYWn4yppB2fjV4Ff3JfCrwa/ubVRWDX41+NU8/dXgV4NfDX71b0Yl1eBXg1/d2ai4Gvxq8Ks7qbj+auCN2qsqzZL4RhWqclWZqtTIblRilhxBbXFORU2rc6SzZWXPVN9ctkwNrcw6iAHx1dI/tkr66SulbxT8CPDh5QxgGfhLpZcGfHAxA1gkv/u5eh9X7wXfA77bhP/NlYSfmQcf+IZJ4JtX3zy+Cd++ZmhT/Grwq1vA/w7+d/C/g/8d/O/dVOB/B/87+N87q8D//osK/O8djYq+d1BZ8KvbGTmqK1TllspUpUZ2o5LMCGqKcyrKCfjaTLas7NnVFcqWXX0rS42hfxz8GPgMoE8U/AhXHwY/lMH/PbAQfK7eB7x3HvhzTXy3wnfNAB945zTwgW/k6hX+L03wzSe/o4LvYLn6LPxq8KtN/HZW/O/gfwf/e2+jsu/N4H8D/xv437qowP8G/rdfVJ1UOfhGlSrwjSpU5aoyS6VG9u8lZtWpii0V5clhjkBlS2dvWm2hbE2ra2XJIfSLgx9bIX10rj4KfGQpA1givUJcvcbVB8EPgO8H3we+d4508wDvngX+TBPfZeJ3dqbwufoG4BsUfL159Xnxa3Lwq/Pgfwf/ewH8b+B/A/8b+N/A/9ZNVQj/1yb4xd+AN2qvqlS1M3J8q1CVWypTlRrZjUrMjCEU51SUJ4c5ApUtnT1/+YZRY8tfbSvrG18ufWLL5A8d+OgSBrBYeoUXSc8Q8NoCBjBfegSA989lAOB7wfeA755pwHd1cfVJeOcU8Ln6xjz49T+I/z0P/jfwvyXh8+HTV/C/gv+1qwr8r+B/Bd4I/K+dVB2Nir52UIH/tVLVzsjxtcJSuarMUqmR3agkM4JvxTkV5clhxhBsWdmbL2sYtsLVtKI+cfBj4OvgR8GPgB8GPwS+Bn4Q/MAcBjBbuvmA985kAFy9W+G7FL5T4Tcq/AYFX6/g+YnXUcF3sDz57S3wlQY8fc/B/wb+tzz4X8H/Cv7X7ioTvzSF/wX8L51V4H/5RQX+l45GRV86qNqrKlXtjBxfKlTllspUpUZ2oxJzAOmKcyrKyZGV7Zs1e8ulB2FrueZG8kcc+NhiBrBIekUXSs8I8OH5DGCe9NC4+iD4AfD9VnwTvosLeNdk8E34XxuT8OPz49e1Al/Bp/G/5cH/miwP/hfwv4D/JQnfEr4awGfgjdqrKlXtjByfKyyVq8oslRrZjUrMERgV51SUJ0dWtmRfU9lb3zdb68s3jj/i4MfA18GPgh8BP6zwNfCDs8AH3jeDAXD1HvDdOfhOhd+Yg1//I/hJ+Bz8r+Cn4RX+F/C/dFdZ8D8nA/9zZxX4n4H/lKyTqqNR0SfwP7VXVaraGTmMKlTlqjJLpUZ2o5KcinMqyu5zMkdWNmtf7G3IZva1jaVG0Tu+UHrFFkhPHfjoPAYwV3qEgddmE/gB8P3g+8D3gu8B353En0TAOycQ8I3jwAe+YQz4wNeb8B3rTPgOtcNaid83g/81g1+ewv9i4pel8D+D/xn8JPynZOB/6qwC36gA/sdk7VWVqnZGjo8VqnJLZZZKjexGJZaK81TUtE+OrGzp7K3rcypb0760oV5x8GPzGQD4UfAj4IcUfhD8wHQGME26+oD3TgGfq3crfJcFv7EAfp3CrzXh2xs/8fLgW66+Cf6XJHwO/meF/wn8T3nwPwJvBP7HTqqORia8Bf9DpaqdkeNDhaVyVZmlUiO7UUlOxTkV5cmR6SPoWdnbGIiffrDkWHrGwY+Br4MfBT4yiwHMlG4aVx8EPwC+H3wf+J48+E4LfoPCr28O34QviG/A5+L/bvYZ/CT8p2Q5+B+7qEz8kjS+GsCHjirgjdqrcvDfJ6tQlVsqs1RqZDcqyak4p6I8ObKypfqQzN7GbE372IZ6xufK77E50kMHPwp+GPwQ+Br4QfAD4PvB94LvmcgAgHeNJ+CdY8EHvnE0+MA3jGwVfuonXrP4Xyz4nxX+pxz8j0n4HPwPvxoVf/hFlYP/Pll7VaWldkZp/HfllsoslRrZjUpyKs6pqECOrGxZ2TO9b022lvvQTL/HwY/NZgDgR8EPgx8CXwM/OIUBTOb6uXov+B7w3QrfBb5T4Tem8EcQ8HXDaKiJX6vwa3Lx++XB750f/1MKv5vZxxz8D8ny4L/vpAL/fQ7+u2SVqnZGjncVlhT+2zJLpensRiWWivNUlCdHVrYm2Qv3Ll+2Hys1jh5x8GPg6+BHpzOAaQxgqnTVwA+C7wffB743D77Tgt+Qiw987eBm8NWXva8W/C8WfAM+B/9jBr/0Q1cFb8F/D/77X1QW/Hd87r/roLLgv03WzsjxtsJSuSXg36QqNbIbleRUnFNRgRxZ2bKy/0A2s7c/WI/4TOkemyHddPAj4IfBD4GvgR8A3w++D3wP+G6F77LgN1rw63PxB6XxK1vE75WD3yOD/9GC/yEH/31nAz4L/10nVUcV8G+TtVdl4xe9YQBvKlTllpriO16Db1Riqbhpr4oK5MjKlpW9cK8LZWu5N83UPT6DAYCvgx8BPwx+CHxtEgMA3w++F3wP8O4x4APvGsUARmbwGyz4dQq/NolvwjfF75Mf/3MO/kcL/gcL/vsuKgv+u19UCv9tR5UF/02ySlW7dAb861TlZq/Kcio1shuV5FSc3ctkRXlyZGVrkr2N2bJ79QN1j4MfA1+fygDADyv8IPgB4P3jGAD4HvDdFnwn8I3DwR9m4tfnwa9J4vc3/gkdA/975vO+IufLnoH/KQ/+Bwv++xz8d78apfHfdlJZ8N90UPAK/3WqdkaOVxWWyi0p+JfJSo3sRiU5FWf3IllRgRxZ2bKy/0C2H8s6mm5x8GPg6+BHwA+Dr02QzsHxDAB8H/heC77Lgt8IfMPQDH5dK/C/tYD/sRX473Lw31rw33RUWfBftzfRX6VqZ5SGf5ms3FKZJfBfmNmNSnIqzu55sqI8OZpky8r+A9l+vm5x8GPg65MZAPgh8DXwg+AHxjIA8L2jGYCJ38kFvtOKD3z94Ax+rcKvSeL3y4Pfuxn87k3x31vw31nw3/6q4BX+mxz81x1M+FftLfD0sp2RiW7Bf5GqzJIF/3mykpyKm/asqECOrGxNsv9Atp/vtzj4MfCjE6VLBPwQ+Br4QfD94PvA94DvVvgu8J3gN4LfkMIfZNQEv7pvC/i/N8VPX70FPw3f2YA3U/hvLPivkwH/qoOCV72sVJn4RS8YwIsKlQX/eVlOpUYG/rOSPBVn97SoQKA/yc6Wlf0Hs/18v8XB17n86AQGAH4IfA38IPh+8L3ge8B358FvAL/egl+bB//7D+C/z4P/Ngf/jQU/Cf8qmQX/ZSqF/6JdujT+82TllkB/lqo0nf2ZGsBTa4A/ya0of48dWdmaZG97j5LZfr6u8UkMAPwo+JFxDAB8DfwA+H7wveB7FL4LfCf4jUMYgMKvB77Ogl+Twu+Tg9+rbfjvCuC/seC/7qTgTfzilx0s8PSiUqXwn7dT6Kpn5ZYs+E9L09mfJCvJSYE/tlaUv0eOJtmaZM/fw+aytb0Heeoa5+nXwY+CHwE/NIYBgB8A3w++F3y3wneB7wS/EfyGHPxaC361Bf/bT+C/teC/seAb8Bb8lxb8F6kU/vN26Uz0VBb8p2VmT5KVpjPwH5fkSaE/slaUv4eOrGzJHlizt637qWx/T13iE9QAwA+DHwJfG8UAwPeNYADgu4cxgBz8BuDrga+z4NdY8L9b8L/+BP4bC/7rXxS8wn9pwX9hwX9eqVL4z9pZ4OlpudmTcoVu6XFpOvtjNYBH1izoD1MVmT3IzdEk2/3c7M13r1C27O7+YF3i4OtcfxT8MPgh8IPgB8D3ge8B3w2+C3wn+I0mfvsUfh34tRb86gx+hRX/S/Zv/Dbhv87Bf2nBf5HEVwN4bsF/VmnAmyXR6UmFQrfgP7YG/CMzu5FCf5gK7Ae5WcDv5+bI7h7gWQF5t43dSWX7e+oSB1/n+o0BgK+BHwTfD74PfI/Cd4HvBL8R/IYB6vot+DU5+N9y8D9n45dZ8d8p/LcK/00O/qs8+C8s+M8t+M8s+E+TpeAV/mNrCv5RWRrewH9YaoI/yA3w+7lZwO9Zuutoks3aHYcFs4Vu58tmdusn6xwHXwc/yvUbAwA/CL4ffC/4HhO/gwt8J/iNwBsD6M8AwK818c3rB/+7Bf+riV+ehd8tD34XKW0J/6XCf2HBf67wn7XPwD+tNOGfJFPwj1Mp+EflCl0FuNED4I0U+H1rFvR7qZLQBQI4N1uq26ksoLda2c1kth/vRk6d4+Dr4EfBD3P9xgDA9w9lAOC7W8Cv7aOu34L/LQ/+pzz47wvgv6ZXzeA/z4P/VPWkXboMfIVCt+A/VD0oM+CN7oNvZIG/V2Ji381XEjpfgN+2dAvsJllBW9ENawrv+k90TfVrfDQDAD8Kfhh8jetXA+igBtBeDaDSGAD49eDX5eBXg/89B//LT+K/VPgv8uA/U/hpeAv+Ywv+Iwv+w3ILuup+aToD/55Cv5vKAn7HmsK+rbplzZHpJth5y0Wl663omj2D15quttCvcfD1kQwA/PBwBgB+AHwf+F7w3eC7uH4n+I3gN4BfD35dH2MAFTU5+N/A/6rwP1vwP7YevyQf/nMTv/hZDv4TC/5jhf+oItNDBf+g3IKeSuHfA/5uqQWd7qSyoN9W3Spq2s1UjuxugJ3qeqpCsM10NZUF70obulwgcwDgR8APga/x9AfA9/H0exS+C3yniV+ZD7+6lxpAHvxP/wL8p+0t8JVp+KJHyVLwFRb48hz4MgPdcdcsjX8npzR4blZw1Y0iA9voeiabtWupCuGqrjRXHsRLbehiTr/ER6YH0DEEvgZ+AHwf+B4LfiP4DX0t1w9+TR78rz3Mf+Wugd89g/8h81Ov9F0L+C8U/vOOaXgD/2kO/uNKC7zCT8I/qMjA3y+3oKvuZvAdd0ot4KpbJdngN61Zwem6NQV/LVMa/WqqFoAvW7qUr2YwL7Sh86pf4uDrXH9kmGUAgxgA+J4BDAB8Zz9jAO2MAYBfB34t+DW9jAGUfwf/2++W6+9uefpbif8yH37HbPwn7S3wOfhp+AoLvMpAT2Wip7LfLrWgW/Bv5nSjOA84XUtlgb9qZruSpxaBVRctXbDWDGZz/ZWnKmMA4OvgR8APgR/k+v1cv5cBuLl+NYB2jbn4vbPxv6Wuv7vl6c/+Z/XMp/9n8Ntn8NPw9MCCnwVfboEvy4J3JOFvlWbQb1pLgdP1VLngqqsqcHOzXVZdStVaZEvnrbWAWtWK/sypkzEA8CNDGAD4QfD94HvBd4Pv4vqd4DeAXw9+XW/L9YP/PQf/cw7+hxz8t23Af9rBAq/wHxXAv1+RA2/Bv6O6bcI7blnwrfA3SnLQ6VqqXHBrgF9WXTKzWbuYqjXIlv6yVGVvPeq5FjprqVN8WHoAHYwBgO/n6feC7wbfBX4j+A1/WAYAfg346QGA/7W7un6F/zEXv0vr8J+1At+AV/j3LaXhyzPoBnyZgZ7KfrM0B52ul+RBVzUBp8uqS47sLlrAL1hrBXRVgf5M1QbYZGdyOp2nTnHwda4/An6I61cDqPRYrl8NoKI+P37m+rsZA8jCf9/F8rmf/YWvJI3fqQl+cSvwi9LwFRl4K74Bb8G/aZaGv24pC1x1pbgp+iVrJrjRhUwG+HlrhS66APS5fP0AbqpTOZ20ZA4A/Ahf/DTwg1y/D3yPun4n+I3J6we/rpcxgHJjAOB/72G5/m6W6++qBtCl6Ze+tuI/UvgPKxU83W9n4hvwFvw75TnwZVnwjhvgJ8uCT2VFV13Og35RdaEoC91+3iyN/pelghddAPus6oyl1uCebKYTOR1XdYwPSQ+gfXIAAfB94HvAd4HvBL+ht3n9xgDAr8mDb1x/U/yCn/vN4T9uI/4dVRZ8WRa843oSvjQHna6WZMNfVl0qLoBuwT9v6S8zW1VOzWGfzYN9Ok+tQc6Hm69jOXWMg69z/WHwtQF5B1BhDAD8OoWvrr/sW3fL9Vs+9z90UQNoBf7zVuLfV6XhKzLwufg3y7Lg0/i58FdKsuEvWcqHfj5VNrq9yswEV51L1VZs1UlrbUC24h7N6UiesgcAfgB8H/hu8F1cfyP4DeDX98xcfzXX/727GkDy+n+zXH8e/Dd5vvQ1we/QFP9BK/Bv061yC3xZFryBf63Ucu0p+JKca0/BFxdAp79UVY7sssBVZx0/iK06oTpubz3ykQIdtnQop45x8HXwwwMyA/BmBlCRGkDy+mvBr+lhuX7wv/xmDCD99BsDsPwrePN97reE/7AZ/DsVGfi8+GUZ/GtmTeFLsuEvpuCLm0FPZYIbncuURj+j+mHsnFoL3RxyqoOWDqg6pAfQnwGAH+jLAMB3c/1O8BvN6y+v+90cQPr6u6UHkPzf0W96/Zl/Tj/7S19T/OKW8IEvysW/pcqCL8uCd1wtbQp/qSTn2i2dL86Gr7L0Z1ETdPtZswy6pULgzWKrjqqO2NsOnQ852f4CdYgPZAADjAFUJgfg5/q94LvAd4Lf2DMzgOT1V4OfGoBx/V3VALpYrj/zr+BN47/M81v/ieVzPx/+vVbgp+HLMvAp/CbwqrzwxXmuXcGfS5VBtwNuP52LrmoNeF7snA7b2wZdCHmfpb2W9qgBtI9y/WHwNa7f3yd7AA3g1yevv4cxgLLq1PX/Zrn+LvmffuP6O2U//Xnx27eMf7vCAt8MPvCOK0n80jzwJU3RDfjiZtDpbFEWujUTPKd86C2BH1YdspaD3dJFF0LO125Vh/gAYwCVagDt/OB7wHeB7+T6G35Xz39yAMnr75YeQPL/KldmAJ0LX39z3/gftbd84au04LdrHf61six4A/9yDr4BX1IAvrh5+DNFTeFBt2eBq447mqK3CZwOqg7YC2Pnu+jmkJPtsrTTUodYcgDgh7n+YJ/sAfD8lxsDAL+2u3n9xgCS19/V+L/MVfDpV9ef/fRn8ItbgV+UDz/r6pviO5L4TeBLCsAXq8/23GtX8KeLmqCnykZXNXflrQKn/al+EDsf9I4Cbaf2sf7mAEJqAL7eDAB8F9ffCH59D3MAyeuvBv/7b5br75K+fuN/T/+d+b+2ZV5/HvxnzXzps+LfycG/mcIvz8a/WpYF77hU2hTeip8Fr2py7Sl4OlXUBN7eBF111NE69ILgqn2qtmDvbAF7u6Vtqq2qzADAD/5hDKDCbQ6gPDWA5PXXdDMHkLz+r10tA8jz9L9Ofe7n/LN7hb70tQX/Whvwz6vywhdnw5/OgT9ZlIVuP54pG52OOLLRm7vyguCqPfafu+xcaCv2ljy1j4Ef7WsZAPhurt8JfmOP7AEkr/+bwv+s8Ft7/blP/8NWPPst4St4Az8vfEkB+OIW4IvywtuboKsKoee78rzglnbb8193a7C3toC9WbXJUmYA4Ae5fusAGpLPP/i13SzPf3IAXTLX/yEH/3Whpz/P5376d34ufkUG/3oO/pV8+KUt46fhi5uHP1GUDX9M1QRddcjxc+i7VbtUhcCbe8Zbi71RtcFS+xj4Ua4/OYAAA/AmBwC+s0fOANT1pwfQ2RhA9vV3Utdv+RdzNvnWn/Ol767l6W8rPvCOC6V54EsKwNPp4mbg6XhRBv6o6ohZNrqqNeh7WkKnHal+4Lpbi51qvaXKrAGA7+X6XakBgF8Hfs1vlgF0ST//qf/TbCXvLNf/Kv/T3+LnfnP4V/9m/ILwRRn4I5aaoKvaim4Fz0JXWdHbct2twV5naa1qjU3+HwuefjlXE4+yAAAAAElFTkSuQmCC",Vz=0,bT=(n,e,t,i)=>{if(!n[t]){let r=n.useDelayedTextureLoading;n.useDelayedTextureLoading=!1;let s=n._blockEntityCollection;n._blockEntityCollection=!1;let a=ne.CreateFromBase64String(e,i+Vz++,n,!0,!1,ne.BILINEAR_SAMPLINGMODE);n._blockEntityCollection=s;let o=n.getEngine().getLoadedTexturesCache(),l=o.indexOf(a.getInternalTexture());l!==-1&&o.splice(l,1),a.isRGBD=!0,a.wrapU=ne.CLAMP_ADDRESSMODE,a.wrapV=ne.CLAMP_ADDRESSMODE,n[t]=a,n.useDelayedTextureLoading=r,Sl.ExpandRGBDTexture(a);let c=n.getEngine().onContextRestoredObservable.add(()=>{a.isRGBD=!0;let f=n.onBeforeRenderObservable.add(()=>{a.isReady()&&(n.onBeforeRenderObservable.remove(f),Sl.ExpandRGBDTexture(a))})});n.onDisposeObservable.add(()=>{n.getEngine().onContextRestoredObservable.remove(c)})}return n[t]},km=n=>bT(n,wz,"environmentBRDFTexture","EnvironmentBRDFTexture"),MT=n=>bT(n,Bz,"environmentFuzzBRDFTexture","EnvironmentFuzzBRDFTexture"),cN=n=>bT(n,Uz,"openPBREnvironmentBRDFTexture","OpenPBREnvironmentBRDFTexture")});function fN(n){return class extends n{constructor(){super(...arguments),this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1}}}var dN=A(()=>{});var yT=A(()=>{vr();ze();er();We.prototype.restoreSingleAttachment=function(){let n=this._gl;this.bindAttachments([n.BACK])};We.prototype.restoreSingleAttachmentForRenderTarget=function(){let n=this._gl;this.bindAttachments([n.COLOR_ATTACHMENT0])};We.prototype.buildTextureLayout=function(n,e=!1){let t=this._gl,i=[];if(e)i.push(t.BACK);else for(let r=0;r1&&(e.depthTextureFormat===13||e.depthTextureFormat===17||e.depthTextureFormat===16||e.depthTextureFormat===14||e.depthTextureFormat===18)&&(o=e.depthTextureFormat)),o===void 0&&(o=s?13:14);let y=this._gl,B=this._currentFramebuffer,w=y.createFramebuffer();this._bindUnboundFramebuffer(w);let H=(z=n.width)!=null?z:n,O=(K=n.height)!=null?K:n,k=[],X=[],j=this.webGLVersion>1&&(o===13||o===17||o===18);L.label=(J=e==null?void 0:e.label)!=null?J:"MultiRenderTargetWrapper",L._framebuffer=w,L._generateDepthBuffer=a||r,L._generateStencilBuffer=a?j:s,L._depthStencilBuffer=this._setupFramebufferDepthAttachments(L._generateStencilBuffer,L._generateDepthBuffer,H,O,1,o),L._attachments=X;for(let ge=0;ge1||this.isWebGPU);let $e=this.webGLVersion>1,Fe=y[$e?"COLOR_ATTACHMENT"+ge:"COLOR_ATTACHMENT"+ge+"_WEBGL"];if(X.push(Fe),ce===-1||P)continue;let Xe=new bt(this,6);k[ge]=Xe,y.activeTexture(y["TEXTURE"+ge]),y.bindTexture(ce,Xe._hardwareTexture.underlyingResource),y.texParameteri(ce,y.TEXTURE_MAG_FILTER,ke.mag),y.texParameteri(ce,y.TEXTURE_MIN_FILTER,ke.min),y.texParameteri(ce,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(ce,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE);let xt=this._getRGBABufferInternalSizedFormat(se,xe,le),Dt=this._getInternalFormat(xe),Yt=this._getWebGLTextureType(se);if($e&&(ce===35866||ce===32879))ce===35866?Xe.is2DArray=!0:Xe.is3D=!0,Xe.baseDepth=Xe.depth=he,y.texImage3D(ce,0,xt,H,O,he,0,Dt,Yt,null);else if(ce===34067){for(let hi=0;hi<6;hi++)y.texImage2D(y.TEXTURE_CUBE_MAP_POSITIVE_X+hi,0,xt,H,O,0,Dt,Yt,null);Xe.isCube=!0}else y.texImage2D(y.TEXTURE_2D,0,xt,H,O,0,Dt,Yt,null);i&&y.generateMipmap(ce),this._bindTextureDirectly(ce,null),Xe.baseWidth=H,Xe.baseHeight=O,Xe.width=H,Xe.height=O,Xe.isReady=!0,Xe.samples=1,Xe.generateMipMaps=i,Xe.samplingMode=me,Xe.type=se,Xe._useSRGBBuffer=le,Xe.format=xe,Xe.label=(Pe=x[ge])!=null?Pe:L.label+"-Texture"+ge,this._internalTexturesCache.push(Xe)}if(a&&this._caps.depthTextureExtension&&!P){let ge=new bt(this,14),me=5,se=y.DEPTH_COMPONENT16,le=y.DEPTH_COMPONENT,xe=y.UNSIGNED_SHORT,ce=y.DEPTH_ATTACHMENT;this.webGLVersion<2?se=y.DEPTH_COMPONENT:o===14?(me=1,xe=y.FLOAT,se=y.DEPTH_COMPONENT32F):o===18?(me=0,xe=y.FLOAT_32_UNSIGNED_INT_24_8_REV,se=y.DEPTH32F_STENCIL8,le=y.DEPTH_STENCIL,ce=y.DEPTH_STENCIL_ATTACHMENT):o===16?(me=0,xe=y.UNSIGNED_INT,se=y.DEPTH_COMPONENT24,ce=y.DEPTH_ATTACHMENT):(o===13||o===17)&&(me=12,xe=y.UNSIGNED_INT_24_8,se=y.DEPTH24_STENCIL8,le=y.DEPTH_STENCIL,ce=y.DEPTH_STENCIL_ATTACHMENT),this._bindTextureDirectly(y.TEXTURE_2D,ge,!0),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MAG_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_MIN_FILTER,y.NEAREST),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_S,y.CLAMP_TO_EDGE),y.texParameteri(y.TEXTURE_2D,y.TEXTURE_WRAP_T,y.CLAMP_TO_EDGE),y.texImage2D(y.TEXTURE_2D,0,se,H,O,0,le,xe,null),y.framebufferTexture2D(y.FRAMEBUFFER,ce,y.TEXTURE_2D,ge._hardwareTexture.underlyingResource,0),this._bindTextureDirectly(y.TEXTURE_2D,null),L._depthStencilTexture=ge,L._depthStencilTextureWithStencil=j,ge.baseWidth=H,ge.baseHeight=O,ge.width=H,ge.height=O,ge.isReady=!0,ge.samples=1,ge.generateMipMaps=i,ge.samplingMode=1,ge.format=o,ge.type=me,ge.label=L.label+"-DepthStencil",k[l]=ge,this._internalTexturesCache.push(ge)}if(L.setTextures(k),t&&y.drawBuffers(X),this._bindUnboundFramebuffer(B),L.setLayerAndFaceIndices(S,R),this.resetTextureCache(),!P)this.updateMultipleRenderTargetTextureSampleCount(L,c,t);else if(c>1){let ge=y.createFramebuffer();if(!ge)throw new Error("Unable to create multi sampled framebuffer");L._samples=c,L._MSAAFramebuffer=ge,l>0&&t&&(this._bindUnboundFramebuffer(ge),y.drawBuffers(X),this._bindUnboundFramebuffer(B))}return L};We.prototype.updateMultipleRenderTargetTextureSampleCount=function(n,e,t=!0){if(this.webGLVersion<2||!n)return 1;if(n.samples===e)return e;let i=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),n._depthStencilBuffer&&(i.deleteRenderbuffer(n._depthStencilBuffer),n._depthStencilBuffer=null),n._MSAAFramebuffer&&(i.deleteFramebuffer(n._MSAAFramebuffer),n._MSAAFramebuffer=null);let r=n._attachments.length;for(let a=0;a1&&typeof i.renderbufferStorageMultisample=="function"){let a=i.createFramebuffer();if(!a)throw new Error("Unable to create multi sampled framebuffer");n._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);let o=[];for(let l=0;l1?"COLOR_ATTACHMENT"+l:"COLOR_ATTACHMENT"+l+"_WEBGL"],h=this._createRenderBuffer(c.width,c.height,e,-1,this._getRGBABufferInternalSizedFormat(c.type,c.format,c._useSRGBBuffer),d);if(!h)throw new Error("Unable to create multi sampled framebuffer");f.addMSAARenderBuffer(h),c.samples=e,o.push(d)}t&&i.drawBuffers(o)}else this._bindUnboundFramebuffer(n._framebuffer);let s=n._depthStencilTexture?n._depthStencilTexture.format:void 0;return n._depthStencilBuffer=this._setupFramebufferDepthAttachments(n._generateStencilBuffer,n._generateDepthBuffer,n.width,n.height,e,s),this._bindUnboundFramebuffer(null),n._samples=e,e};We.prototype.generateMipMapsMultiFramebuffer=function(n){let e=n,t=this._gl;if(e.isMulti)for(let i=0;i1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],t.readBuffer(r[a]),t.drawBuffers(r),t.blitFramebuffer(0,0,o.width,o.height,0,0,o.width,o.height,i,t.NEAREST)}for(let a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];t.drawBuffers(r),t.bindFramebuffer(this._gl.FRAMEBUFFER,e._MSAAFramebuffer)}});var Hm,hN=A(()=>{oi();_a();yT();Hm=class extends ri{get isSupported(){var e,t;return(t=(e=this._engine)==null?void 0:e.getCaps().drawBuffersExtension)!=null?t:!1}get textures(){return this._textures}get count(){return this._count}get depthTexture(){return this._textures[this._textures.length-1]}set wrapU(e){if(this._textures)for(let t=0;t0&&(this._createInternalTextures(),this._createTextures(a))}_initTypes(e,t,i,r,s,a,o,l,c,f){for(let d=0;d{this.onAfterRenderObservable.notifyObservers(t)})}dispose(e=!1){this._releaseTextures(),e?this._texture=null:this.releaseInternalTextures(),super.dispose()}releaseInternalTextures(){var t,i;let e=(t=this._renderTarget)==null?void 0:t.textures;if(e){for(let r=e.length-1;r>=0;r--)this._textures[r]._texture=null;(i=this._renderTarget)==null||i.dispose(),this._renderTarget=null}}}});var uN,Gz,mN=A(()=>{N();uN="mrtFragmentDeclaration",Gz=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) layout(location=0) out vec4 glFragData[{X}]; #endif -`;E.IncludesShadersStore[aN]||(E.IncludesShadersStore[aN]=Sz)});var lN,Az,Hm=A(()=>{N();lN="pbrFragmentReflectionDeclaration",Az=`#ifdef REFLECTION +`;E.IncludesShadersStore[uN]||(E.IncludesShadersStore[uN]=Gz)});var pN,kz,zm=A(()=>{N();pN="pbrFragmentReflectionDeclaration",kz=`#ifdef REFLECTION #ifdef REFLECTIONMAP_3D #define sampleReflection(s,c) textureCube(s,c) uniform samplerCube reflectionSampler; @@ -6640,12 +6640,12 @@ varying vec3 vDirectionW; #endif #endif #endif -`;E.IncludesShadersStore[lN]||(E.IncludesShadersStore[lN]=Az)});var cN,Rz,bT=A(()=>{N();cN="sceneFragmentDeclaration",Rz=`uniform mat4 viewProjection; +`;E.IncludesShadersStore[pN]||(E.IncludesShadersStore[pN]=kz)});var _N,Wz,DT=A(()=>{N();_N="sceneFragmentDeclaration",Wz=`uniform mat4 viewProjection; #ifdef MULTIVIEW uniform mat4 viewProjectionR; #endif uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;uniform mat4 inverseProjection; -`;E.IncludesShadersStore[cN]||(E.IncludesShadersStore[cN]=Rz)});var fN,Iz,_c=A(()=>{N();fN="pbrBRDFFunctions",Iz=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 +`;E.IncludesShadersStore[_N]||(E.IncludesShadersStore[_N]=Wz)});var gN,Hz,_c=A(()=>{N();gN="pbrBRDFFunctions",Hz=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 #define BRDF_DIFFUSE_MODEL_EON 0 #define BRDF_DIFFUSE_MODEL_BURLEY 1 #define BRDF_DIFFUSE_MODEL_LAMBERT 2 @@ -6818,7 +6818,7 @@ vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance, float computeWrappedDiffuseNdotL(float NdotL,float w) {float t=1.0+w;float invt2=1.0/square(t);return saturate((NdotL+w)*invt2);} #endif #endif -`;E.IncludesShadersStore[fN]||(E.IncludesShadersStore[fN]=Iz)});var dN,xz,MT=A(()=>{N();dN="openpbrDielectricReflectance",xz=`struct ReflectanceParams +`;E.IncludesShadersStore[gN]||(E.IncludesShadersStore[gN]=Hz)});var EN,zz,LT=A(()=>{N();EN="openpbrDielectricReflectance",zz=`struct ReflectanceParams {float F0;float F90;vec3 coloredF0;vec3 coloredF90;}; #define pbr_inline ReflectanceParams dielectricReflectance( @@ -6836,7 +6836,7 @@ float maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams. outParams.F0=mix(dielectricF0_NoSpec,dielectricF0,specularWeight); #endif outParams.F90=mix(f90Scale_NoSpec,f90Scale,specularWeight);outParams.coloredF0=mix(vec3(dielectricF0_NoSpec),vec3(dielectricF0),specularWeight)*specularColor.rgb;outParams.coloredF90=mix(dielectricColorF90_NoSpec,dielectricColorF90,specularWeight);return outParams;} -`;E.IncludesShadersStore[dN]||(E.IncludesShadersStore[dN]=xz)});var hN,Cz,zm=A(()=>{N();hN="pbrIBLFunctions",Cz=`#if defined(REFLECTION) || defined(SS_REFRACTION) +`;E.IncludesShadersStore[EN]||(E.IncludesShadersStore[EN]=zz)});var vN,Xz,Xm=A(()=>{N();vN="pbrIBLFunctions",Xz=`#if defined(REFLECTION) || defined(SS_REFRACTION) float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;float lod=log2(microsurfaceAverageSlopeTexels);return lod;} float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {float lod=log2(cubeMapDimensionPixels)*roughness;return lod;} #endif @@ -6850,7 +6850,7 @@ float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {v #define UNPACK_LOD(x) (1.0-x)*255.0 float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {float microsurfaceAverageSlope=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);} #endif -`;E.IncludesShadersStore[hN]||(E.IncludesShadersStore[hN]=Cz)});var uN,bz,yT=A(()=>{N();uN="openpbrGeometryInfo",bz=`struct geometryInfoOutParams +`;E.IncludesShadersStore[vN]||(E.IncludesShadersStore[vN]=Xz)});var TN,Yz,PT=A(()=>{N();TN="openpbrGeometryInfo",Yz=`struct geometryInfoOutParams {float NdotV;float NdotVUnclamped;vec3 environmentBrdf;float horizonOcclusion;};struct geometryInfoAnisoOutParams {float NdotV;float NdotVUnclamped;vec3 environmentBrdf;float horizonOcclusion;float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;mat3 TBN;}; #define pbr_inline @@ -6879,7 +6879,7 @@ geometryInfoAnisoOutParams geometryInfoAniso( in vec3 normalW,in vec3 viewDirectionW,in float roughness,in vec3 geometricNormalW ,in vec3 vAnisotropy,in mat3 TBN ) -{geometryInfoOutParams geoInfo=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);geometryInfoAnisoOutParams outParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}`;E.IncludesShadersStore[uN]||(E.IncludesShadersStore[uN]=bz)});var mN,Mz,DT=A(()=>{N();mN="openpbrIblFunctions",Mz=`#ifdef REFLECTION +{geometryInfoOutParams geoInfo=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);geometryInfoAnisoOutParams outParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}`;E.IncludesShadersStore[TN]||(E.IncludesShadersStore[TN]=Yz)});var SN,Kz,OT=A(()=>{N();SN="openpbrIblFunctions",Kz=`#ifdef REFLECTION vec3 sampleIrradiance( in vec3 surfaceNormal #if defined(NORMAL) && defined(USESPHERICALINVERTEX) @@ -7101,7 +7101,7 @@ return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90 #endif } #endif -`;E.IncludesShadersStore[mN]||(E.IncludesShadersStore[mN]=Mz)});var pN,yz,LT=A(()=>{N();pN="openpbrSubsurfaceLayerData",yz=`float subsurface_weight=vSubsurfaceWeight;vec3 subsurface_color=vSubsurfaceColor.rgb;float subsurface_radius=vSubsurfaceRadius;vec3 subsurface_radius_scale=vSubsurfaceRadiusScale;float subsurface_scatter_anisotropy=clamp(vSubsurfaceScatterAnisotropy,-0.9999,0.9999); +`;E.IncludesShadersStore[SN]||(E.IncludesShadersStore[SN]=Kz)});var AN,jz,NT=A(()=>{N();AN="openpbrSubsurfaceLayerData",jz=`float subsurface_weight=vSubsurfaceWeight;vec3 subsurface_color=vSubsurfaceColor.rgb;float subsurface_radius=vSubsurfaceRadius;vec3 subsurface_radius_scale=vSubsurfaceRadiusScale;float subsurface_scatter_anisotropy=clamp(vSubsurfaceScatterAnisotropy,-0.9999,0.9999); #ifdef SUBSURFACE_WEIGHT vec4 subsurfaceWeightFromTexture=texture2D(subsurfaceWeightSampler,vSubsurfaceWeightUV+uvOffset); #endif @@ -7125,7 +7125,7 @@ subsurface_color*=vSubsurfaceColorInfos.y; #ifdef SUBSURFACE_RADIUS_SCALE subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb; #endif -`;E.IncludesShadersStore[pN]||(E.IncludesShadersStore[pN]=yz)});var _N,Dz,PT=A(()=>{N();_N="openpbrTransmissionLayerData",Dz=`float transmission_weight=vTransmissionWeight;vec3 transmission_color=vTransmissionColor.rgb;float transmission_depth=vTransmissionDepth;vec3 transmission_scatter=vTransmissionScatter.rgb;float transmission_scatter_anisotropy=clamp(vTransmissionScatterAnisotropy,-0.9999,0.9999);float transmission_dispersion_scale=vTransmissionDispersionScale;float transmission_dispersion_abbe_number=vTransmissionDispersionAbbeNumber; +`;E.IncludesShadersStore[AN]||(E.IncludesShadersStore[AN]=jz)});var RN,Zz,FT=A(()=>{N();RN="openpbrTransmissionLayerData",Zz=`float transmission_weight=vTransmissionWeight;vec3 transmission_color=vTransmissionColor.rgb;float transmission_depth=vTransmissionDepth;vec3 transmission_scatter=vTransmissionScatter.rgb;float transmission_scatter_anisotropy=clamp(vTransmissionScatterAnisotropy,-0.9999,0.9999);float transmission_dispersion_scale=vTransmissionDispersionScale;float transmission_dispersion_abbe_number=vTransmissionDispersionAbbeNumber; #ifdef TRANSMISSION_WEIGHT vec4 transmissionWeightFromTexture=texture2D(transmissionWeightSampler,vTransmissionWeightUV+uvOffset); #endif @@ -7161,7 +7161,7 @@ transmission_scatter*=transmissionScatterFromTexture.rgb; #ifdef TRANSMISSION_DISPERSION_SCALE transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r; #endif -`;E.IncludesShadersStore[_N]||(E.IncludesShadersStore[_N]=Dz)});var EN={};De(EN,{geometryPixelShader:()=>Lz});var OT,gN,Lz,NT=A(()=>{N();Ws();oN();pm();_m();Gr();Hm();bT();Po();_c();MT();zm();Xf();yT();DT();No();Hs();gm();LT();PT();OT="geometryPixelShader",gN=`#extension GL_EXT_draw_buffers : require +`;E.IncludesShadersStore[RN]||(E.IncludesShadersStore[RN]=Zz)});var xN={};De(xN,{geometryPixelShader:()=>qz});var wT,IN,qz,BT=A(()=>{N();Ws();mN();_m();gm();Wr();zm();DT();Oo();_c();LT();Xm();Xf();PT();OT();Fo();Hs();Em();NT();FT();wT="geometryPixelShader",IN=`#extension GL_EXT_draw_buffers : require #if defined(BUMP) || !defined(NORMAL) #extension GL_OES_standard_derivatives : enable #endif @@ -7399,8 +7399,8 @@ irradiance_alpha=min(subsurface_weight+transmission_weight,1.0); gl_FragData[IRRADIANCE_INDEX]=vec4(irradiance,irradiance_alpha); #endif } -`;E.ShadersStore[OT]||(E.ShadersStore[OT]=gN);Lz={name:OT,shader:gN}});var vN,Pz,TN=A(()=>{N();vN="geometryVertexDeclaration",Pz="uniform mat4 viewProjection;uniform mat4 view;";E.IncludesShadersStore[vN]||(E.IncludesShadersStore[vN]=Pz)});var SN,Oz,AN=A(()=>{N();Po();SN="geometryUboDeclaration",Oz=`#include -`;E.IncludesShadersStore[SN]||(E.IncludesShadersStore[SN]=Oz)});var RN,Nz,gc=A(()=>{N();RN="harmonicsFunctions",Nz=`#ifdef USESPHERICALFROMREFLECTIONMAP +`;E.ShadersStore[wT]||(E.ShadersStore[wT]=IN);qz={name:wT,shader:IN}});var CN,Qz,bN=A(()=>{N();CN="geometryVertexDeclaration",Qz="uniform mat4 viewProjection;uniform mat4 view;";E.IncludesShadersStore[CN]||(E.IncludesShadersStore[CN]=Qz)});var MN,Jz,yN=A(()=>{N();Oo();MN="geometryUboDeclaration",Jz=`#include +`;E.IncludesShadersStore[MN]||(E.IncludesShadersStore[MN]=Jz)});var DN,$z,gc=A(()=>{N();DN="harmonicsFunctions",$z=`#ifdef USESPHERICALFROMREFLECTIONMAP #ifdef SPHERICAL_HARMONICS vec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00 + vSphericalL1_1*(normal.y) @@ -7415,7 +7415,7 @@ vec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00 vec3 computeEnvironmentIrradiance(vec3 normal) {float Nx=normal.x;float Ny=normal.y;float Nz=normal.z;vec3 C1=vSphericalZZ.rgb;vec3 Cx=vSphericalX.rgb;vec3 Cy=vSphericalY.rgb;vec3 Cz=vSphericalZ.rgb;vec3 Cxx_zz=vSphericalXX_ZZ.rgb;vec3 Cyy_zz=vSphericalYY_ZZ.rgb;vec3 Cxy=vSphericalXY.rgb;vec3 Cyz=vSphericalYZ.rgb;vec3 Czx=vSphericalZX.rgb;vec3 a1=Cyy_zz*Ny+Cy;vec3 a2=Cyz*Nz+a1;vec3 b1=Czx*Nz+Cx;vec3 b2=Cxy*Ny+b1;vec3 b3=Cxx_zz*Nx+b2;vec3 t1=Cz *Nz+C1;vec3 t2=a2 *Ny+t1;vec3 t3=b3 *Nx+t2;return t3;} #endif #endif -`;E.IncludesShadersStore[RN]||(E.IncludesShadersStore[RN]=Nz)});var xN={};De(xN,{geometryVertexShader:()=>Fz});var FT,IN,Fz,wT=A(()=>{N();Fs();ws();Ga();ka();Na();TN();AN();Bs();gc();Wa();Ha();Us();Vs();Gs();ks();nm();FT="geometryVertexShader",IN=`precision highp float; +`;E.IncludesShadersStore[DN]||(E.IncludesShadersStore[DN]=$z)});var PN={};De(PN,{geometryVertexShader:()=>eX});var UT,LN,eX,VT=A(()=>{N();Fs();ws();Ga();ka();Na();bN();yN();Bs();gc();Wa();Ha();Us();Vs();Gs();ks();sm();UT="geometryVertexShader",LN=`precision highp float; #include #include #include @@ -7627,7 +7627,7 @@ vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*vReflectio #endif #endif } -`;E.ShadersStore[FT]||(E.ShadersStore[FT]=IN);Fz={name:FT,shader:IN}});var CN,wz,Ec=A(()=>{N();CN="harmonicsFunctions",wz=`#ifdef USESPHERICALFROMREFLECTIONMAP +`;E.ShadersStore[UT]||(E.ShadersStore[UT]=LN);eX={name:UT,shader:LN}});var ON,tX,Ec=A(()=>{N();ON="harmonicsFunctions",tX=`#ifdef USESPHERICALFROMREFLECTIONMAP #ifdef SPHERICAL_HARMONICS fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {return uniforms.vSphericalL00 + uniforms.vSphericalL1_1*(normal.y) @@ -7642,7 +7642,7 @@ fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {return uniforms.vSpherica fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {var Nx: f32=normal.x;var Ny: f32=normal.y;var Nz: f32=normal.z;var C1: vec3f=uniforms.vSphericalZZ.rgb;var Cx: vec3f=uniforms.vSphericalX.rgb;var Cy: vec3f=uniforms.vSphericalY.rgb;var Cz: vec3f=uniforms.vSphericalZ.rgb;var Cxx_zz: vec3f=uniforms.vSphericalXX_ZZ.rgb;var Cyy_zz: vec3f=uniforms.vSphericalYY_ZZ.rgb;var Cxy: vec3f=uniforms.vSphericalXY.rgb;var Cyz: vec3f=uniforms.vSphericalYZ.rgb;var Czx: vec3f=uniforms.vSphericalZX.rgb;var a1: vec3f=Cyy_zz*Ny+Cy;var a2: vec3f=Cyz*Nz+a1;var b1: vec3f=Czx*Nz+Cx;var b2: vec3f=Cxy*Ny+b1;var b3: vec3f=Cxx_zz*Nx+b2;var t1: vec3f=Cz *Nz+C1;var t2: vec3f=a2 *Ny+t1;var t3: vec3f=b3 *Nx+t2;return t3;} #endif #endif -`;E.IncludesShadersStoreWGSL[CN]||(E.IncludesShadersStoreWGSL[CN]=wz)});var MN={};De(MN,{geometryVertexShaderWGSL:()=>Bz});var BT,bN,Bz,yN=A(()=>{N();Cs();bs();wa();Ba();Oa();yo();Ms();Ec();Ua();Va();ys();Ds();Ls();Ps();Nu();BT="geometryVertexShader",bN=`#include +`;E.IncludesShadersStoreWGSL[ON]||(E.IncludesShadersStoreWGSL[ON]=tX)});var FN={};De(FN,{geometryVertexShaderWGSL:()=>iX});var GT,NN,iX,wN=A(()=>{N();Cs();bs();wa();Ba();Oa();Do();Ms();Ec();Ua();Va();ys();Ds();Ls();Ps();Fu();GT="geometryVertexShader",NN=`#include #include #include #include[0..maxSimultaneousMorphTargets] @@ -7853,7 +7853,7 @@ vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVect #endif #endif } -`;E.ShadersStoreWGSL[BT]||(E.ShadersStoreWGSL[BT]=bN);Bz={name:BT,shader:bN}});var DN,Uz,Xm=A(()=>{N();DN="pbrFragmentReflectionDeclaration",Uz=`#ifdef REFLECTION +`;E.ShadersStoreWGSL[GT]||(E.ShadersStoreWGSL[GT]=NN);iX={name:GT,shader:NN}});var BN,rX,Ym=A(()=>{N();BN="pbrFragmentReflectionDeclaration",rX=`#ifdef REFLECTION #ifdef REFLECTIONMAP_3D var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube; #ifdef LODBASEDMICROSFURACE @@ -7881,7 +7881,7 @@ varying vDirectionW: vec3f; #endif #endif #endif -`;E.IncludesShadersStoreWGSL[DN]||(E.IncludesShadersStoreWGSL[DN]=Uz)});var LN,Vz,vc=A(()=>{N();LN="pbrBRDFFunctions",Vz=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 +`;E.IncludesShadersStoreWGSL[BN]||(E.IncludesShadersStoreWGSL[BN]=rX)});var UN,nX,vc=A(()=>{N();UN="pbrBRDFFunctions",nX=`#define FRESNEL_MAXIMUM_ON_ROUGH 0.25 #define BRDF_DIFFUSE_MODEL_EON 0 #define BRDF_DIFFUSE_MODEL_BURLEY 1 #define BRDF_DIFFUSE_MODEL_LAMBERT 2 @@ -8053,7 +8053,7 @@ fn transmittanceBRDF_Burley(tintColor: vec3f,diffusionDistance: vec3f,thickness: fn computeWrappedDiffuseNdotL(NdotL: f32,w: f32)->f32 {var t: f32=1.0+w;var invt2: f32=1.0/(t*t);return saturate((NdotL+w)*invt2);} #endif #endif -`;E.IncludesShadersStoreWGSL[LN]||(E.IncludesShadersStoreWGSL[LN]=Vz)});var PN,Gz,UT=A(()=>{N();PN="openpbrDielectricReflectance",Gz=`struct ReflectanceParams +`;E.IncludesShadersStoreWGSL[UN]||(E.IncludesShadersStoreWGSL[UN]=nX)});var VN,sX,kT=A(()=>{N();VN="openpbrDielectricReflectance",sX=`struct ReflectanceParams {F0: f32, F90: f32, coloredF0: vec3f, @@ -8075,7 +8075,7 @@ let dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight; let dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight; #endif outParams.coloredF90=dielectricColorF90;return outParams;} -`;E.IncludesShadersStoreWGSL[PN]||(E.IncludesShadersStoreWGSL[PN]=Gz)});var ON,kz,Ym=A(()=>{N();ON="pbrIBLFunctions",kz=`#if defined(REFLECTION) || defined(SS_REFRACTION) +`;E.IncludesShadersStoreWGSL[VN]||(E.IncludesShadersStoreWGSL[VN]=sX)});var GN,aX,Km=A(()=>{N();GN="pbrIBLFunctions",aX=`#if defined(REFLECTION) || defined(SS_REFRACTION) fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;} fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;} #endif @@ -8089,7 +8089,7 @@ fn environmentHorizonOcclusion(view: vec3f,normal: vec3f,geometricNormal: vec3f) fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;} fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);} #endif -`;E.IncludesShadersStoreWGSL[ON]||(E.IncludesShadersStoreWGSL[ON]=kz)});var NN,Wz,VT=A(()=>{N();NN="openpbrGeometryInfo",Wz=`struct geometryInfoOutParams +`;E.IncludesShadersStoreWGSL[GN]||(E.IncludesShadersStoreWGSL[GN]=aX)});var kN,oX,WT=A(()=>{N();kN="openpbrGeometryInfo",oX=`struct geometryInfoOutParams {NdotV: f32, NdotVUnclamped: f32, environmentBrdf: vec3f, @@ -8126,7 +8126,7 @@ normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f ,vAnisotropy: vec3f,TBN: mat3x3 )->geometryInfoAnisoOutParams {let geoInfo: geometryInfoOutParams=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);var outParams: geometryInfoAnisoOutParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;let anisotropyDirection: vec3f=vec3f(vAnisotropy.xy,0.);let anisoTBN: mat3x3=mat3x3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;} -`;E.IncludesShadersStoreWGSL[NN]||(E.IncludesShadersStoreWGSL[NN]=Wz)});var FN,Hz,GT=A(()=>{N();FN="openpbrIblFunctions",Hz=`#ifdef REFLECTION +`;E.IncludesShadersStoreWGSL[kN]||(E.IncludesShadersStoreWGSL[kN]=oX)});var WN,lX,HT=A(()=>{N();WN="openpbrIblFunctions",lX=`#ifdef REFLECTION fn sampleIrradiance( surfaceNormal: vec3f #if defined(NORMAL) && defined(USESPHERICALINVERTEX) @@ -8344,7 +8344,7 @@ return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90 #endif } #endif -`;E.IncludesShadersStoreWGSL[FN]||(E.IncludesShadersStoreWGSL[FN]=Hz)});var wN,zz,kT=A(()=>{N();wN="openpbrSubsurfaceLayerData",zz=`var subsurface_weight: f32=uniforms.vSubsurfaceWeight;var subsurface_color: vec3f=uniforms.vSubsurfaceColor.rgb;var subsurface_radius: f32=uniforms.vSubsurfaceRadius;var subsurface_radius_scale: vec3f=uniforms.vSubsurfaceRadiusScale;var subsurface_scatter_anisotropy: f32=clamp(uniforms.vSubsurfaceScatterAnisotropy,-0.9999f,0.9999f); +`;E.IncludesShadersStoreWGSL[WN]||(E.IncludesShadersStoreWGSL[WN]=lX)});var HN,cX,zT=A(()=>{N();HN="openpbrSubsurfaceLayerData",cX=`var subsurface_weight: f32=uniforms.vSubsurfaceWeight;var subsurface_color: vec3f=uniforms.vSubsurfaceColor.rgb;var subsurface_radius: f32=uniforms.vSubsurfaceRadius;var subsurface_radius_scale: vec3f=uniforms.vSubsurfaceRadiusScale;var subsurface_scatter_anisotropy: f32=clamp(uniforms.vSubsurfaceScatterAnisotropy,-0.9999f,0.9999f); #ifdef SUBSURFACE_WEIGHT let subsurfaceWeightFromTexture: vec4f=textureSample(subsurfaceWeightSampler,subsurfaceWeightSamplerSampler,fragmentInputs.vSubsurfaceWeightUV+uvOffset); #endif @@ -8368,7 +8368,7 @@ subsurface_color*=uniforms.vSubsurfaceColorInfos.y; #ifdef SUBSURFACE_RADIUS_SCALE subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb; #endif -`;E.IncludesShadersStoreWGSL[wN]||(E.IncludesShadersStoreWGSL[wN]=zz)});var BN,Xz,WT=A(()=>{N();BN="openpbrTransmissionLayerData",Xz=`var transmission_weight: f32=uniforms.vTransmissionWeight;var transmission_color: vec3f=uniforms.vTransmissionColor.rgb;var transmission_depth: f32=uniforms.vTransmissionDepth;var transmission_scatter: vec3f=uniforms.vTransmissionScatter.rgb;var transmission_scatter_anisotropy: f32=clamp(uniforms.vTransmissionScatterAnisotropy,-0.9999f,0.9999f);var transmission_dispersion_scale: f32=uniforms.vTransmissionDispersionScale;var transmission_dispersion_abbe_number: f32=uniforms.vTransmissionDispersionAbbeNumber; +`;E.IncludesShadersStoreWGSL[HN]||(E.IncludesShadersStoreWGSL[HN]=cX)});var zN,fX,XT=A(()=>{N();zN="openpbrTransmissionLayerData",fX=`var transmission_weight: f32=uniforms.vTransmissionWeight;var transmission_color: vec3f=uniforms.vTransmissionColor.rgb;var transmission_depth: f32=uniforms.vTransmissionDepth;var transmission_scatter: vec3f=uniforms.vTransmissionScatter.rgb;var transmission_scatter_anisotropy: f32=clamp(uniforms.vTransmissionScatterAnisotropy,-0.9999f,0.9999f);var transmission_dispersion_scale: f32=uniforms.vTransmissionDispersionScale;var transmission_dispersion_abbe_number: f32=uniforms.vTransmissionDispersionAbbeNumber; #ifdef TRANSMISSION_WEIGHT let transmissionWeightFromTexture: vec4f=textureSample(transmissionWeightSampler,transmissionWeightSamplerSampler,fragmentInputs.vTransmissionWeightUV+uvOffset); #endif @@ -8404,7 +8404,7 @@ transmission_scatter*=transmissionScatterFromTexture.rgb; #ifdef TRANSMISSION_DISPERSION_SCALE transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r; #endif -`;E.IncludesShadersStoreWGSL[BN]||(E.IncludesShadersStoreWGSL[BN]=Xz)});var VN={};De(VN,{geometryPixelShaderWGSL:()=>Yz});var HT,UN,Yz,GN=A(()=>{N();Os();Hu();zu();Vr();Xm();yo();vc();UT();Ym();Hf();VT();GT();Lo();Ns();Xu();kT();WT();HT="geometryPixelShader",UN=`#ifdef BUMP +`;E.IncludesShadersStoreWGSL[zN]||(E.IncludesShadersStoreWGSL[zN]=fX)});var YN={};De(YN,{geometryPixelShaderWGSL:()=>dX});var YT,XN,dX,KN=A(()=>{N();Os();zu();Xu();kr();Ym();Do();vc();kT();Km();Hf();WT();HT();Po();Ns();Yu();zT();XT();YT="geometryPixelShader",XN=`#ifdef BUMP varying vWorldView0: vec4f;varying vWorldView1: vec4f;varying vWorldView2: vec4f;varying vWorldView3: vec4f;varying vNormalW: vec3f; #else varying vNormalV: vec3f; @@ -8665,22 +8665,22 @@ fragmentOutputs.fragData6=fragData[6]; fragmentOutputs.fragData7=fragData[7]; #endif } -`;E.ShadersStoreWGSL[HT]||(E.ShadersStoreWGSL[HT]=UN);Yz={name:HT,shader:UN}});var kN,zT,Ki,WN=A(()=>{ve();yt();oi();sN();et();gi();Ni();NT();wT();Wr();kn();Oi();CT();kN=["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler","transmissionWeightSampler","subsurfaceWeightSampler","iblShadowSampler"],zT=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","reflectionMatrix","vTransmissionWeight","vSubsurfaceWeight","vEyePosition","vTransmissionScatterAnisotropy","vSubsurfaceScatterAnisotropy","shadowTextureSize","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","boneTextureInfo"];Ia(zT,kN,!0);Di(zT);Ki=class n{get normalsAreUnsigned(){return this._normalsAreUnsigned}_linkPrePassRenderer(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(()=>{}))}_unlinkPrePassRenderer(){this._linkedWithPrePass=!1,this._createRenderTargets()}_resetLayout(){this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableScreenspaceDepth=!1,this._enableIrradiance=!1,this._attachmentsFromPrePass=[]}_forceTextureType(e,t){e===n.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===n.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===n.VELOCITY_LINEAR_TEXTURE_TYPE?(this._velocityLinearIndex=t,this._enableVelocityLinear=!0):e===n.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===n.DEPTH_TEXTURE_TYPE?(this._depthIndex=t,this._enableDepth=!0):e===n.NORMAL_TEXTURE_TYPE?(this._normalIndex=t,this._enableNormal=!0):e===n.SCREENSPACE_DEPTH_TEXTURE_TYPE?(this._screenspaceDepthIndex=t,this._enableScreenspaceDepth=!0):e===n.IRRADIANCE_TEXTURE_TYPE&&(this._irradianceIndex=t,this._enableIrradiance=!0)}_setAttachments(e){this._attachmentsFromPrePass=e}_linkInternalTexture(e){this._multiRenderTarget.setInternalTexture(e,0,!1)}get renderList(){return this._multiRenderTarget.renderList}set renderList(e){this._multiRenderTarget.renderList=e}get isSupported(){return this._multiRenderTarget.isSupported}getTextureIndex(e){switch(e){case n.POSITION_TEXTURE_TYPE:return this._positionIndex;case n.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case n.VELOCITY_LINEAR_TEXTURE_TYPE:return this._velocityLinearIndex;case n.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case n.DEPTH_TEXTURE_TYPE:return this._depthIndex;case n.NORMAL_TEXTURE_TYPE:return this._normalIndex;case n.SCREENSPACE_DEPTH_TEXTURE_TYPE:return this._screenspaceDepthIndex;case n.IRRADIANCE_TEXTURE_TYPE:return this._irradianceIndex;default:return-1}}get enableDepth(){return this._enableDepth}set enableDepth(e){this._enableDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableNormal(){return this._enableNormal}set enableNormal(e){this._enableNormal=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enablePosition(){return this._enablePosition}set enablePosition(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableVelocity(){return this._enableVelocity}set enableVelocity(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e}get enableVelocityLinear(){return this._enableVelocityLinear}set enableVelocityLinear(e){this._enableVelocityLinear=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableReflectivity(){return this._enableReflectivity}set enableReflectivity(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableScreenspaceDepth(){return this._enableScreenspaceDepth}set enableScreenspaceDepth(e){this._enableScreenspaceDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableIrradiance(){return this._enableIrradiance}set enableIrradiance(e){this._enableIrradiance=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get scene(){return this._scene}get ratio(){return typeof this._ratioOrDimensions=="object"?1:this._ratioOrDimensions}get shaderLanguage(){return this._shaderLanguage}constructor(e,t=1,i=15,r){this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._normalsAreUnsigned=!1,this._resizeObserver=null,this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableReflectivity=!1,this._enableScreenspaceDepth=!1,this._enableIrradiance=!1,this._clearColor=new Ne(0,0,0,0),this._clearDepthColor=new Ne(0,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._velocityLinearIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._screenspaceDepthIndex=-1,this._irradianceIndex=-1,this._linkedWithPrePass=!1,this.generateIrradianceWithScatterMask=!1,this.useSpecificClearForDepthTexture=!1,this._shaderLanguage=0,this._shadersLoaded=!1,this._scene=e,this._ratioOrDimensions=t,this._useUbo=e.getEngine().supportsUniformBuffers,this._depthFormat=i,this._textureTypesAndFormats=r||{},this._initShaderSourceAsync(),n._SceneComponentInitialization(this._scene),this._createRenderTargets()}async _initShaderSourceAsync(){this._scene.getEngine().isWebGPU&&!n.ForceGLSL?(this._shaderLanguage=1,await Promise.all([Promise.resolve().then(()=>(yN(),MN)),Promise.resolve().then(()=>(GN(),VN))])):await Promise.all([Promise.resolve().then(()=>(wT(),xN)),Promise.resolve().then(()=>(NT(),EN))]),this._shadersLoaded=!0}isReady(e,t){if(!this._shadersLoaded)return!1;let i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;let r=[],s=[M.PositionKind],a=e.getMesh();a.isVerticesDataPresent(M.NormalKind)&&(r.push("#define HAS_NORMAL_ATTRIBUTE"),s.push(M.NormalKind));let l=!1,c=!1,f=!1;if(i){let _=!1;if(i.needAlphaTestingForMesh(a)&&i.getAlphaTestTexture()&&(r.push("#define ALPHATEST"),r.push(`#define ALPHATEST_UV${i.getAlphaTestTexture().coordinatesIndex+1}`),_=!0),(i.bumpTexture||i.normalTexture||i.geometryNormalTexture)&&ie.BumpTextureEnabled){let g=i.bumpTexture||i.normalTexture||i.geometryNormalTexture;r.push("#define BUMP"),r.push(`#define BUMP_UV${g.coordinatesIndex+1}`),_=!0}if(this._enableReflectivity){let g=!1;if(i.getClassName()==="PBRMetallicRoughnessMaterial")i.metallicRoughnessTexture&&(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.metallicRoughnessTexture.coordinatesIndex+1}`),r.push("#define METALLICWORKFLOW"),_=!0,g=!0),i.metallic!=null&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),g=!0),i.roughness!=null&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),g=!0),g&&(i.baseTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${i.baseTexture.coordinatesIndex+1}`),i.baseTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),i.baseColor&&r.push("#define ALBEDOCOLOR"));else if(i.getClassName()==="PBRSpecularGlossinessMaterial")i.specularGlossinessTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.specularGlossinessTexture.coordinatesIndex+1}`),_=!0,i.specularGlossinessTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE")):i.specularColor&&r.push("#define REFLECTIVITYCOLOR"),i.glossiness!=null&&r.push("#define GLOSSINESS");else if(i.getClassName()==="PBRMaterial")i.metallicTexture&&(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.metallicTexture.coordinatesIndex+1}`),r.push("#define METALLICWORKFLOW"),_=!0,g=!0),i.metallic!=null&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),g=!0),i.roughness!=null&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),g=!0),g?(i.albedoTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${i.albedoTexture.coordinatesIndex+1}`),i.albedoTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),i.albedoColor&&r.push("#define ALBEDOCOLOR")):(i.reflectivityTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.reflectivityTexture.coordinatesIndex+1}`),i.reflectivityTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),_=!0):i.reflectivityColor&&r.push("#define REFLECTIVITYCOLOR"),i.microSurface!=null&&r.push("#define GLOSSINESS"));else if(i.getClassName()==="StandardMaterial")i.specularTexture&&(r.push("#define REFLECTIVITYTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.specularTexture.coordinatesIndex+1}`),i.specularTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),_=!0),i.specularColor&&r.push("#define REFLECTIVITYCOLOR");else if(i.getClassName()==="OpenPBRMaterial"){let T=i;r.push("#define METALLIC"),r.push("#define ROUGHNESS"),T._useRoughnessFromMetallicTextureGreen&&T.baseMetalnessTexture?(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${T.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):T.baseMetalnessTexture?(r.push("#define METALLIC_TEXTURE"),r.push(`#define METALLIC_UV${T.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):T.specularRoughnessTexture&&(r.push("#define ROUGHNESS_TEXTURE"),r.push(`#define ROUGHNESS_UV${T.specularRoughnessTexture.coordinatesIndex+1}`),_=!0),T.baseColorTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${T.baseColorTexture.coordinatesIndex+1}`),T.baseColorTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),T.baseColor&&r.push("#define ALBEDOCOLOR")}}if(this._enableIrradiance&&this.generateIrradianceWithScatterMask&&(r.push("#define IRRADIANCE_SCATTER_MASK"),i.getClassName()==="OpenPBRMaterial")){let g=i;g.subsurfaceWeight>0&&g.subsurfaceWeightTexture&&(r.push("#define SUBSURFACE_WEIGHT"),r.push(`#define SUBSURFACEWEIGHT_UV${g.subsurfaceWeightTexture.coordinatesIndex+1}`),_=!0),g.transmissionWeight>0&&g.transmissionWeightTexture&&(r.push("#define TRANSMISSION_WEIGHT"),r.push(`#define TRANSMISSIONWEIGHT_UV${g.transmissionWeightTexture.coordinatesIndex+1}`),_=!0)}_&&(r.push("#define NEED_UV"),a.isVerticesDataPresent(M.UVKind)&&(s.push(M.UVKind),r.push("#define UV1"),l=!0),a.isVerticesDataPresent(M.UV2Kind)&&(s.push(M.UV2Kind),r.push("#define UV2"),c=!0))}if(this._enableDepth&&(r.push("#define DEPTH"),r.push("#define DEPTH_INDEX "+this._depthIndex)),this._enableNormal&&(r.push("#define NORMAL"),r.push("#define NORMAL_INDEX "+this._normalIndex)),this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(a)===-1&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableVelocityLinear&&(r.push("#define VELOCITY_LINEAR"),r.push("#define VELOCITY_LINEAR_INDEX "+this._velocityLinearIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(a)===-1&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(r.push("#define REFLECTIVITY"),r.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),this._enableScreenspaceDepth&&this._screenspaceDepthIndex!==-1&&(r.push("#define SCREENSPACE_DEPTH_INDEX "+this._screenspaceDepthIndex),r.push("#define SCREENSPACE_DEPTH")),this._enableIrradiance&&this._irradianceIndex!==-1){r.push("#define IRRADIANCE_INDEX "+this._irradianceIndex),r.push("#define IRRADIANCE");let _=this._scene;if(_.environmentTexture){let g={},T=!1,b=0;(i.getClassName()==="OpenPBRMaterial"||i.getClassName()==="StandardMaterial"||i.getClassName()==="PBRMetallicRoughnessMaterial"||i.getClassName()==="PBRSpecularGlossinessMaterial"||i.getClassName()==="PBRMaterial")&&(T=!!i.realtimeFiltering,b=i.realtimeFilteringQuality||0),Ra(_,_.environmentTexture,g,T,b,!0);for(let S in g)g[S]&&r.push("#define "+S);g.USEIRRADIANCEMAP||r.push("#define SPHERICAL_HARMONICS");let R=_.postProcessRenderPipelineManager.supportedPipelines.find(S=>S.getClassName()==="IBLShadowsRenderPipeline");if(R){let S=R;S._getAccumulatedTexture()&&(r.push("#define IBL_SHADOW_TEXTURE"),S.coloredShadows&&r.push("#define COLORED_IBL_SHADOWS"))}}}this.generateNormalsInWorldSpace&&r.push("#define NORMAL_WORLDSPACE"),this._normalsAreUnsigned&&r.push("#define ENCODE_NORMAL"),a.useBones&&a.computeBonesUsingShaders&&a.skeleton?(s.push(M.MatricesIndicesKind),s.push(M.MatricesWeightsKind),a.numBoneInfluencers>4&&(s.push(M.MatricesIndicesExtraKind),s.push(M.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),r.push("#define BONETEXTURE "+a.skeleton.isUsingTextureForMatrices),r.push("#define BonesPerMesh "+(a.skeleton.bones.length+1))):(r.push("#define NUM_BONE_INFLUENCERS 0"),r.push("#define BONETEXTURE false"),r.push("#define BonesPerMesh 0"));let d=a.morphTargetManager?Wn(a.morphTargetManager,r,s,a,!0,!0,!1,l,c,f):0;t&&(r.push("#define INSTANCES"),_n(s,this._enableVelocity||this._enableVelocityLinear),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES")),this._linkedWithPrePass?r.push("#define SCENE_MRT_COUNT "+this._attachmentsFromPrePass.length):r.push("#define SCENE_MRT_COUNT "+this._multiRenderTarget.textures.length),Gn(i,this._scene,r);let h=this._scene.getEngine(),u=e._getDrawWrapper(void 0,!0),m=u.defines,p=r.join(` -`);return m!==p&&u.setEffect(h.createEffect("geometry",{attributes:s,uniformsNames:zT,samplers:kN,defines:p,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:d},shaderLanguage:this.shaderLanguage},h),p),u.effect.isReady()}getGBuffer(){return this._multiRenderTarget}get samples(){return this._multiRenderTarget.samples}set samples(e){this._multiRenderTarget.samples=e}dispose(){var e,t;this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),(e=this._multiRenderTarget)!=null&&e.renderTarget&&this.scene.getEngine()._currentRenderTarget===this._multiRenderTarget.renderTarget&&this.scene.getEngine().unBindFramebuffer((t=this._multiRenderTarget)==null?void 0:t.renderTarget),this.getGBuffer().dispose()}_assignRenderTargetIndices(){let e=[],t=[],i=0;return this._enableDepth&&(this._depthIndex=i,i++,e.push("gBuffer_Depth"),t.push(this._textureTypesAndFormats[n.DEPTH_TEXTURE_TYPE])),this._enableNormal&&(this._normalIndex=i,i++,e.push("gBuffer_Normal"),t.push(this._textureTypesAndFormats[n.NORMAL_TEXTURE_TYPE])),this._enablePosition&&(this._positionIndex=i,i++,e.push("gBuffer_Position"),t.push(this._textureTypesAndFormats[n.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=i,i++,e.push("gBuffer_Velocity"),t.push(this._textureTypesAndFormats[n.VELOCITY_TEXTURE_TYPE])),this._enableVelocityLinear&&(this._velocityLinearIndex=i,i++,e.push("gBuffer_VelocityLinear"),t.push(this._textureTypesAndFormats[n.VELOCITY_LINEAR_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=i,i++,e.push("gBuffer_Reflectivity"),t.push(this._textureTypesAndFormats[n.REFLECTIVITY_TEXTURE_TYPE])),this._enableScreenspaceDepth&&(this._screenspaceDepthIndex=i,i++,e.push("gBuffer_ScreenspaceDepth"),t.push(this._textureTypesAndFormats[n.SCREENSPACE_DEPTH_TEXTURE_TYPE])),this._enableIrradiance&&(this._irradianceIndex=i,i++,e.push("gBuffer_Irradiance"),t.push(this._textureTypesAndFormats[n.IRRADIANCE_TEXTURE_TYPE])),[i,e,t]}_createRenderTargets(){var g;let e=this._scene.getEngine(),[t,i,r]=this._assignRenderTargetIndices(),s=0;e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?s=1:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(s=2);let a=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions},o=[],l=[],c=[];for(let T of r)T?(o.push(T.textureType),l.push(T.textureFormat),c.push((g=T.samplingMode)!=null?g:2)):(o.push(s),l.push(5),c.push(2));if(this._normalsAreUnsigned=o[n.NORMAL_TEXTURE_TYPE]===11||o[n.NORMAL_TEXTURE_TYPE]===13,this._multiRenderTarget=new Wm("gBuffer",a,t,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,types:o,formats:l,samplingModes:c,depthTextureFormat:this._depthFormat},i.concat("gBuffer_DepthBuffer")),!this.isSupported)return;this._multiRenderTarget.wrapU=ne.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=ne.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;let f=[!0],d=[!1],h=[!0];for(let T=1;T{T.bindAttachments(this.useSpecificClearForDepthTexture?m:u),T.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(T.bindAttachments(p),T.clear(this._clearDepthColor,!0,!0,!0)),T.bindAttachments(u)}),this._resizeObserver=e.onResizeObservable.add(()=>{if(this._multiRenderTarget){let T=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions};this._multiRenderTarget.resize(T)}});let _=T=>{let b=T.getRenderingMesh(),R=T.getEffectiveMesh(),S=this._scene,I=S.getEngine(),x=T.getMaterial();if(!x)return;if(R._internalAbstractMeshDataInfo._isActiveIntermediate=!1,(this._enableVelocity||this._enableVelocityLinear)&&!this._previousTransformationMatrices[R.uniqueId]&&(this._previousTransformationMatrices[R.uniqueId]={world:G.Identity(),viewProjection:S.getTransformMatrix()},b.skeleton)){let B=b.skeleton.getTransformMatrices(b);this._previousBonesTransformationMatrices[b.uniqueId]=this._copyBonesTransformationMatrices(B,new Float32Array(B.length))}let P=b._getInstancesRenderList(T._id,!!T.getReplacementMesh());if(P.mustReturn)return;let L=I.getCaps().instancedArrays&&(P.visibleInstances[T._id]!==null||b.hasThinInstances),y=R.getWorldMatrix();if(this.isReady(T,L)){let B=T._getDrawWrapper();if(!B)return;let w=B.effect;I.enableEffect(B),L||b._bind(T,w,x.fillMode),this._useUbo?(Aa(w,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(w.setMatrix("viewProjection",S.getTransformMatrix()),w.setMatrix("view",S.getViewMatrix()),this._scene.bindEyePosition(w,"vEyePosition"));let H;if(!b._instanceDataStorage.isFrozen&&(x.backFaceCulling||x.sideOrientation!==null)){let V=R._getWorldMatrixDeterminant();H=x._getEffectiveOrientation(b),V<0&&(H=H===ae.ClockWiseSideOrientation?ae.CounterClockWiseSideOrientation:ae.ClockWiseSideOrientation)}else H=b._effectiveSideOrientation;if(x._preBind(B,H),x.needAlphaTestingForMesh(R)){let V=x.getAlphaTestTexture();V&&(w.setTexture("diffuseSampler",V),w.setMatrix("diffuseMatrix",V.getTextureMatrix()))}if((x.bumpTexture||x.normalTexture||x.geometryNormalTexture)&&S.getEngine().getCaps().standardDerivatives&&ie.BumpTextureEnabled){let V=x.bumpTexture||x.normalTexture||x.geometryNormalTexture;w.setFloat3("vBumpInfos",V.coordinatesIndex,1/V.level,x.parallaxScaleBias),w.setMatrix("bumpMatrix",V.getTextureMatrix()),w.setTexture("bumpSampler",V),w.setFloat2("vTangentSpaceParams",x.invertNormalMapX?-1:1,x.invertNormalMapY?-1:1)}if(this._enableReflectivity){if(x.getClassName()==="PBRMetallicRoughnessMaterial")x.metallicRoughnessTexture!==null&&(w.setTexture("reflectivitySampler",x.metallicRoughnessTexture),w.setMatrix("reflectivityMatrix",x.metallicRoughnessTexture.getTextureMatrix())),x.metallic!==null&&w.setFloat("metallic",x.metallic),x.roughness!==null&&w.setFloat("glossiness",1-x.roughness),x.baseTexture!==null&&(w.setTexture("albedoSampler",x.baseTexture),w.setMatrix("albedoMatrix",x.baseTexture.getTextureMatrix())),x.baseColor!==null&&w.setColor3("albedoColor",x.baseColor);else if(x.getClassName()==="PBRSpecularGlossinessMaterial")x.specularGlossinessTexture!==null?(w.setTexture("reflectivitySampler",x.specularGlossinessTexture),w.setMatrix("reflectivityMatrix",x.specularGlossinessTexture.getTextureMatrix())):x.specularColor!==null&&w.setColor3("reflectivityColor",x.specularColor),x.glossiness!==null&&w.setFloat("glossiness",x.glossiness);else if(x.getClassName()==="PBRMaterial")x.metallicTexture!==null&&(w.setTexture("reflectivitySampler",x.metallicTexture),w.setMatrix("reflectivityMatrix",x.metallicTexture.getTextureMatrix())),x.metallic!==null&&w.setFloat("metallic",x.metallic),x.roughness!==null&&w.setFloat("glossiness",1-x.roughness),x.roughness!==null||x.metallic!==null||x.metallicTexture!==null?(x.albedoTexture!==null&&(w.setTexture("albedoSampler",x.albedoTexture),w.setMatrix("albedoMatrix",x.albedoTexture.getTextureMatrix())),x.albedoColor!==null&&w.setColor3("albedoColor",x.albedoColor)):(x.reflectivityTexture!==null?(w.setTexture("reflectivitySampler",x.reflectivityTexture),w.setMatrix("reflectivityMatrix",x.reflectivityTexture.getTextureMatrix())):x.reflectivityColor!==null&&w.setColor3("reflectivityColor",x.reflectivityColor),x.microSurface!==null&&w.setFloat("glossiness",x.microSurface));else if(x.getClassName()==="StandardMaterial")x.specularTexture!==null&&(w.setTexture("reflectivitySampler",x.specularTexture),w.setMatrix("reflectivityMatrix",x.specularTexture.getTextureMatrix())),x.specularColor!==null&&w.setColor3("reflectivityColor",x.specularColor);else if(x.getClassName()==="OpenPBRMaterial"){let V=x;V._useRoughnessFromMetallicTextureGreen&&V.baseMetalnessTexture?(w.setTexture("reflectivitySampler",V.baseMetalnessTexture),w.setMatrix("reflectivityMatrix",V.baseMetalnessTexture.getTextureMatrix())):V.baseMetalnessTexture?(w.setTexture("metallicSampler",V.baseMetalnessTexture),w.setMatrix("metallicMatrix",V.baseMetalnessTexture.getTextureMatrix())):V.specularRoughnessTexture&&(w.setTexture("roughnessSampler",V.specularRoughnessTexture),w.setMatrix("roughnessMatrix",V.specularRoughnessTexture.getTextureMatrix())),w.setFloat("metallic",V.baseMetalness),w.setFloat("glossiness",1-V.specularRoughness),V.baseColorTexture!==null&&(w.setTexture("albedoSampler",V.baseColorTexture),w.setMatrix("albedoMatrix",V.baseColorTexture.getTextureMatrix())),V.baseColor!==null&&w.setColor3("albedoColor",V.baseColor)}}if(this._enableIrradiance&&S.environmentTexture){let V=S.environmentTexture,X=S.postProcessRenderPipelineManager.supportedPipelines.find(j=>j.getClassName()==="IBLShadowsRenderPipeline");if(X){let Q=X._getAccumulatedTexture();Q&&(w.setTexture("iblShadowSampler",Q),w.setFloat2("shadowTextureSize",Q.getSize().width,Q.getSize().height))}if(w.setMatrix("reflectionMatrix",V.getReflectionTextureMatrix()),w.setFloat2("vReflectionInfos",V.level*S.iblIntensity,0),w.setTexture("reflectionSampler",V),V.irradianceTexture&&(w.setTexture("irradianceSampler",V.irradianceTexture),V.irradianceTexture._dominantDirection&&w.setVector3("vReflectionDominantDirection",V.irradianceTexture._dominantDirection)),V.sphericalPolynomial){let j=V.sphericalPolynomial;if(j.preScaledHarmonics){let Q=j.preScaledHarmonics;w.setVector3("vSphericalL00",Q.l00),w.setVector3("vSphericalL1_1",Q.l1_1),w.setVector3("vSphericalL10",Q.l10),w.setVector3("vSphericalL11",Q.l11),w.setVector3("vSphericalL2_2",Q.l2_2),w.setVector3("vSphericalL2_1",Q.l2_1),w.setVector3("vSphericalL20",Q.l20),w.setVector3("vSphericalL21",Q.l21),w.setVector3("vSphericalL22",Q.l22)}else w.setFloat3("vSphericalX",j.x.x,j.x.y,j.x.z),w.setFloat3("vSphericalY",j.y.x,j.y.y,j.y.z),w.setFloat3("vSphericalZ",j.z.x,j.z.y,j.z.z),w.setFloat3("vSphericalXX_ZZ",j.xx.x-j.zz.x,j.xx.y-j.zz.y,j.xx.z-j.zz.z),w.setFloat3("vSphericalYY_ZZ",j.yy.x-j.zz.x,j.yy.y-j.zz.y,j.yy.z-j.zz.z),w.setFloat3("vSphericalZZ",j.zz.x,j.zz.y,j.zz.z),w.setFloat3("vSphericalXY",j.xy.x,j.xy.y,j.xy.z),w.setFloat3("vSphericalYZ",j.yz.x,j.yz.y,j.yz.z),w.setFloat3("vSphericalZX",j.zx.x,j.zx.y,j.zx.z)}if(this.generateIrradianceWithScatterMask&&x.getClassName()==="OpenPBRMaterial"){let j=x;w.setFloat("vSubsurfaceWeight",j.subsurfaceWeight),j.subsurfaceWeightTexture&&(w.setTexture("subsurfaceWeightSampler",j.subsurfaceWeightTexture),w.setMatrix("subsurfaceWeightMatrix",j.subsurfaceWeightTexture.getTextureMatrix())),w.setFloat("vTransmissionWeight",j.transmissionWeight),j.transmissionWeightTexture&&(w.setTexture("transmissionWeightSampler",j.transmissionWeightTexture),w.setMatrix("transmissionWeightMatrix",j.transmissionWeightTexture.getTextureMatrix())),w.setFloat("vTransmissionScatterAnisotropy",j.transmissionScatterAnisotropy),w.setFloat("vSubsurfaceScatterAnisotropy",j.subsurfaceScatterAnisotropy)}}if(Li(w,x,this._scene),b.useBones&&b.computeBonesUsingShaders&&b.skeleton){let V=b.skeleton;if(V.isUsingTextureForMatrices&&w.getUniformIndex("boneTextureInfo")>-1){let X=V.getTransformMatrixTexture(b);w.setTexture("boneSampler",X),w.setFloat2("boneTextureInfo",V._textureWidth,V._textureHeight)}else w.setMatrices("mBones",b.skeleton.getTransformMatrices(b));(this._enableVelocity||this._enableVelocityLinear)&&w.setMatrices("mPreviousBones",this._previousBonesTransformationMatrices[b.uniqueId])}Pi(b,w),b.morphTargetManager&&b.morphTargetManager.isUsingTextureForTargets&&b.morphTargetManager._bind(w),(this._enableVelocity||this._enableVelocityLinear)&&(w.setMatrix("previousWorld",this._previousTransformationMatrices[R.uniqueId].world),w.setMatrix("previousViewProjection",this._previousTransformationMatrices[R.uniqueId].viewProjection)),L&&b.hasThinInstances&&w.setMatrix("world",y),b._processRendering(R,T,w,x.fillMode,P,L,(V,X)=>{V||w.setMatrix("world",X)})}(this._enableVelocity||this._enableVelocityLinear)&&(this._previousTransformationMatrices[R.uniqueId].world=y.clone(),this._previousTransformationMatrices[R.uniqueId].viewProjection=this._scene.getTransformMatrix().clone(),b.skeleton&&this._copyBonesTransformationMatrices(b.skeleton.getTransformMatrices(b),this._previousBonesTransformationMatrices[R.uniqueId]))};this._multiRenderTarget.customIsReadyFunction=(T,b,R)=>{if((R||b===0)&&T.subMeshes)for(let S=0;S{let I;if(this._linkedWithPrePass){if(!this._prePassRenderer.enabled)return;this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass)}if(S.length){for(e.setColorWrite(!1),I=0;I{throw Ie("GeometryBufferRendererSceneComponent")}});var HN,Kz,XT=A(()=>{N();yo();Wf();HN="openpbrUboDeclaration",Kz=`uniform vTangentSpaceParams: vec2f;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vDebugMode: vec2f;uniform renderTargetSize: vec2f;uniform cameraInfo: vec4f;uniform backgroundRefractionMatrix: mat4x4f;uniform vBackgroundRefractionInfos: vec3f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionDominantDirection: vec3f;uniform vReflectionColor: vec3f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f;uniform vBaseWeight: f32;uniform vBaseColor: vec4f;uniform vBaseDiffuseRoughness: f32;uniform vReflectanceInfo: vec4f;uniform vSpecularColor: vec4f;uniform vSpecularAnisotropy: vec3f;uniform vTransmissionWeight : f32;uniform vTransmissionColor : vec3f;uniform vTransmissionDepth : f32;uniform vTransmissionScatter : vec3f;uniform vTransmissionScatterAnisotropy : f32;uniform vTransmissionDispersionScale : f32;uniform vTransmissionDispersionAbbeNumber : f32;uniform vSubsurfaceWeight: f32;uniform vSubsurfaceColor: vec3f;uniform vSubsurfaceRadius: f32;uniform vSubsurfaceRadiusScale: vec3f;uniform vSubsurfaceScatterAnisotropy: f32;uniform vCoatWeight: f32;uniform vCoatColor: vec3f;uniform vCoatRoughness: f32;uniform vCoatRoughnessAnisotropy: f32;uniform vCoatIor: f32;uniform vCoatDarkening : f32;uniform vFuzzWeight: f32;uniform vFuzzColor: vec3f;uniform vFuzzRoughness: f32;uniform vGeometryThinWalled: f32;uniform vGeometryCoatTangent: vec2f;uniform vGeometryThickness: f32;uniform vEmissionColor: vec3f;uniform vThinFilmWeight: f32;uniform vThinFilmThickness: vec2f;uniform vThinFilmIor: f32;uniform vBaseWeightInfos: vec2f;uniform baseWeightMatrix: mat4x4f;uniform vBaseColorInfos: vec2f;uniform baseColorMatrix: mat4x4f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform vBaseMetalnessInfos: vec2f;uniform baseMetalnessMatrix: mat4x4f;uniform vSpecularWeightInfos: vec2f;uniform specularWeightMatrix: mat4x4f;uniform vSpecularColorInfos: vec2f;uniform specularColorMatrix: mat4x4f;uniform vSpecularRoughnessInfos: vec2f;uniform specularRoughnessMatrix: mat4x4f;uniform vSpecularRoughnessAnisotropyInfos: vec2f;uniform specularRoughnessAnisotropyMatrix: mat4x4f;uniform vTransmissionWeightInfos : vec2f;uniform transmissionWeightMatrix : mat4x4f;uniform vTransmissionColorInfos : vec2f;uniform transmissionColorMatrix : mat4x4f;uniform vTransmissionDepthInfos : vec2f;uniform transmissionDepthMatrix : mat4x4f;uniform vTransmissionScatterInfos : vec2f;uniform transmissionScatterMatrix : mat4x4f;uniform vTransmissionDispersionScaleInfos : vec2f;uniform transmissionDispersionScaleMatrix : mat4x4f;uniform vSubsurfaceWeightInfos: vec2f;uniform subsurfaceWeightMatrix: mat4x4f;uniform vSubsurfaceColorInfos: vec2f;uniform subsurfaceColorMatrix: mat4x4f;uniform vSubsurfaceRadiusScaleInfos: vec2f;uniform subsurfaceRadiusScaleMatrix: mat4x4f;uniform vCoatWeightInfos: vec2f;uniform coatWeightMatrix: mat4x4f;uniform vCoatColorInfos: vec2f;uniform coatColorMatrix: mat4x4f;uniform vCoatRoughnessInfos: vec2f;uniform coatRoughnessMatrix: mat4x4f;uniform vCoatRoughnessAnisotropyInfos: vec2f;uniform coatRoughnessAnisotropyMatrix: mat4x4f;uniform vCoatDarkeningInfos : vec2f;uniform coatDarkeningMatrix : mat4x4f;uniform vFuzzWeightInfos: vec2f;uniform fuzzWeightMatrix: mat4x4f;uniform vFuzzColorInfos: vec2f;uniform fuzzColorMatrix: mat4x4f;uniform vFuzzRoughnessInfos: vec2f;uniform fuzzRoughnessMatrix: mat4x4f;uniform vGeometryNormalInfos: vec2f;uniform geometryNormalMatrix: mat4x4f;uniform vGeometryTangentInfos: vec2f;uniform geometryTangentMatrix: mat4x4f;uniform vGeometryCoatNormalInfos: vec2f;uniform geometryCoatNormalMatrix: mat4x4f;uniform vGeometryCoatTangentInfos: vec2f;uniform geometryCoatTangentMatrix: mat4x4f;uniform vGeometryOpacityInfos: vec2f;uniform geometryOpacityMatrix: mat4x4f;uniform vGeometryThicknessInfos: vec2f;uniform geometryThicknessMatrix: mat4x4f;uniform vEmissionInfos: vec2f;uniform emissionMatrix: mat4x4f;uniform vThinFilmWeightInfos: vec2f;uniform thinFilmWeightMatrix: mat4x4f;uniform vThinFilmThicknessInfos: vec2f;uniform thinFilmThicknessMatrix: mat4x4f;uniform vAmbientOcclusionInfos: vec2f;uniform ambientOcclusionMatrix: mat4x4f; +`;E.ShadersStoreWGSL[YT]||(E.ShadersStoreWGSL[YT]=XN);dX={name:YT,shader:XN}});var jN,KT,Zi,ZN=A(()=>{ve();yt();oi();hN();et();Ei();Fi();BT();VT();zr();Wn();Ni();yT();jN=["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler","transmissionWeightSampler","subsurfaceWeightSampler","iblShadowSampler"],KT=["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","albedoMatrix","reflectivityColor","albedoColor","reflectionMatrix","vTransmissionWeight","vSubsurfaceWeight","vEyePosition","vTransmissionScatterAnisotropy","vSubsurfaceScatterAnisotropy","shadowTextureSize","metallic","glossiness","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","boneTextureInfo"];Ia(KT,jN,!0);Li(KT);Zi=class n{get normalsAreUnsigned(){return this._normalsAreUnsigned}_linkPrePassRenderer(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add(()=>{}))}_unlinkPrePassRenderer(){this._linkedWithPrePass=!1,this._createRenderTargets()}_resetLayout(){this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableScreenspaceDepth=!1,this._enableIrradiance=!1,this._attachmentsFromPrePass=[]}_forceTextureType(e,t){e===n.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===n.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===n.VELOCITY_LINEAR_TEXTURE_TYPE?(this._velocityLinearIndex=t,this._enableVelocityLinear=!0):e===n.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===n.DEPTH_TEXTURE_TYPE?(this._depthIndex=t,this._enableDepth=!0):e===n.NORMAL_TEXTURE_TYPE?(this._normalIndex=t,this._enableNormal=!0):e===n.SCREENSPACE_DEPTH_TEXTURE_TYPE?(this._screenspaceDepthIndex=t,this._enableScreenspaceDepth=!0):e===n.IRRADIANCE_TEXTURE_TYPE&&(this._irradianceIndex=t,this._enableIrradiance=!0)}_setAttachments(e){this._attachmentsFromPrePass=e}_linkInternalTexture(e){this._multiRenderTarget.setInternalTexture(e,0,!1)}get renderList(){return this._multiRenderTarget.renderList}set renderList(e){this._multiRenderTarget.renderList=e}get isSupported(){return this._multiRenderTarget.isSupported}getTextureIndex(e){switch(e){case n.POSITION_TEXTURE_TYPE:return this._positionIndex;case n.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case n.VELOCITY_LINEAR_TEXTURE_TYPE:return this._velocityLinearIndex;case n.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case n.DEPTH_TEXTURE_TYPE:return this._depthIndex;case n.NORMAL_TEXTURE_TYPE:return this._normalIndex;case n.SCREENSPACE_DEPTH_TEXTURE_TYPE:return this._screenspaceDepthIndex;case n.IRRADIANCE_TEXTURE_TYPE:return this._irradianceIndex;default:return-1}}get enableDepth(){return this._enableDepth}set enableDepth(e){this._enableDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableNormal(){return this._enableNormal}set enableNormal(e){this._enableNormal=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enablePosition(){return this._enablePosition}set enablePosition(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableVelocity(){return this._enableVelocity}set enableVelocity(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets()),this._scene.needsPreviousWorldMatrices=e}get enableVelocityLinear(){return this._enableVelocityLinear}set enableVelocityLinear(e){this._enableVelocityLinear=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableReflectivity(){return this._enableReflectivity}set enableReflectivity(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableScreenspaceDepth(){return this._enableScreenspaceDepth}set enableScreenspaceDepth(e){this._enableScreenspaceDepth=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get enableIrradiance(){return this._enableIrradiance}set enableIrradiance(e){this._enableIrradiance=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())}get scene(){return this._scene}get ratio(){return typeof this._ratioOrDimensions=="object"?1:this._ratioOrDimensions}get shaderLanguage(){return this._shaderLanguage}constructor(e,t=1,i=15,r){this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this.generateNormalsInWorldSpace=!1,this._normalsAreUnsigned=!1,this._resizeObserver=null,this._enableDepth=!0,this._enableNormal=!0,this._enablePosition=!1,this._enableVelocity=!1,this._enableVelocityLinear=!1,this._enableReflectivity=!1,this._enableScreenspaceDepth=!1,this._enableIrradiance=!1,this._clearColor=new Ne(0,0,0,0),this._clearDepthColor=new Ne(0,0,0,1),this._positionIndex=-1,this._velocityIndex=-1,this._velocityLinearIndex=-1,this._reflectivityIndex=-1,this._depthIndex=-1,this._normalIndex=-1,this._screenspaceDepthIndex=-1,this._irradianceIndex=-1,this._linkedWithPrePass=!1,this.generateIrradianceWithScatterMask=!1,this.useSpecificClearForDepthTexture=!1,this._shaderLanguage=0,this._shadersLoaded=!1,this._scene=e,this._ratioOrDimensions=t,this._useUbo=e.getEngine().supportsUniformBuffers,this._depthFormat=i,this._textureTypesAndFormats=r||{},this._initShaderSourceAsync(),n._SceneComponentInitialization(this._scene),this._createRenderTargets()}async _initShaderSourceAsync(){this._scene.getEngine().isWebGPU&&!n.ForceGLSL?(this._shaderLanguage=1,await Promise.all([Promise.resolve().then(()=>(wN(),FN)),Promise.resolve().then(()=>(KN(),YN))])):await Promise.all([Promise.resolve().then(()=>(VT(),PN)),Promise.resolve().then(()=>(BT(),xN))]),this._shadersLoaded=!0}isReady(e,t){if(!this._shadersLoaded)return!1;let i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;let r=[],s=[M.PositionKind],a=e.getMesh();a.isVerticesDataPresent(M.NormalKind)&&(r.push("#define HAS_NORMAL_ATTRIBUTE"),s.push(M.NormalKind));let l=!1,c=!1,f=!1;if(i){let _=!1;if(i.needAlphaTestingForMesh(a)&&i.getAlphaTestTexture()&&(r.push("#define ALPHATEST"),r.push(`#define ALPHATEST_UV${i.getAlphaTestTexture().coordinatesIndex+1}`),_=!0),(i.bumpTexture||i.normalTexture||i.geometryNormalTexture)&&ie.BumpTextureEnabled){let g=i.bumpTexture||i.normalTexture||i.geometryNormalTexture;r.push("#define BUMP"),r.push(`#define BUMP_UV${g.coordinatesIndex+1}`),_=!0}if(this._enableReflectivity){let g=!1;if(i.getClassName()==="PBRMetallicRoughnessMaterial")i.metallicRoughnessTexture&&(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.metallicRoughnessTexture.coordinatesIndex+1}`),r.push("#define METALLICWORKFLOW"),_=!0,g=!0),i.metallic!=null&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),g=!0),i.roughness!=null&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),g=!0),g&&(i.baseTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${i.baseTexture.coordinatesIndex+1}`),i.baseTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),i.baseColor&&r.push("#define ALBEDOCOLOR"));else if(i.getClassName()==="PBRSpecularGlossinessMaterial")i.specularGlossinessTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.specularGlossinessTexture.coordinatesIndex+1}`),_=!0,i.specularGlossinessTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE")):i.specularColor&&r.push("#define REFLECTIVITYCOLOR"),i.glossiness!=null&&r.push("#define GLOSSINESS");else if(i.getClassName()==="PBRMaterial")i.metallicTexture&&(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.metallicTexture.coordinatesIndex+1}`),r.push("#define METALLICWORKFLOW"),_=!0,g=!0),i.metallic!=null&&(r.push("#define METALLIC"),r.push("#define METALLICWORKFLOW"),g=!0),i.roughness!=null&&(r.push("#define ROUGHNESS"),r.push("#define METALLICWORKFLOW"),g=!0),g?(i.albedoTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${i.albedoTexture.coordinatesIndex+1}`),i.albedoTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),i.albedoColor&&r.push("#define ALBEDOCOLOR")):(i.reflectivityTexture?(r.push("#define SPECULARGLOSSINESSTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.reflectivityTexture.coordinatesIndex+1}`),i.reflectivityTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),_=!0):i.reflectivityColor&&r.push("#define REFLECTIVITYCOLOR"),i.microSurface!=null&&r.push("#define GLOSSINESS"));else if(i.getClassName()==="StandardMaterial")i.specularTexture&&(r.push("#define REFLECTIVITYTEXTURE"),r.push(`#define REFLECTIVITY_UV${i.specularTexture.coordinatesIndex+1}`),i.specularTexture.gammaSpace&&r.push("#define GAMMAREFLECTIVITYTEXTURE"),_=!0),i.specularColor&&r.push("#define REFLECTIVITYCOLOR");else if(i.getClassName()==="OpenPBRMaterial"){let T=i;r.push("#define METALLIC"),r.push("#define ROUGHNESS"),T._useRoughnessFromMetallicTextureGreen&&T.baseMetalnessTexture?(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${T.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):T.baseMetalnessTexture?(r.push("#define METALLIC_TEXTURE"),r.push(`#define METALLIC_UV${T.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):T.specularRoughnessTexture&&(r.push("#define ROUGHNESS_TEXTURE"),r.push(`#define ROUGHNESS_UV${T.specularRoughnessTexture.coordinatesIndex+1}`),_=!0),T.baseColorTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${T.baseColorTexture.coordinatesIndex+1}`),T.baseColorTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),T.baseColor&&r.push("#define ALBEDOCOLOR")}}if(this._enableIrradiance&&this.generateIrradianceWithScatterMask&&(r.push("#define IRRADIANCE_SCATTER_MASK"),i.getClassName()==="OpenPBRMaterial")){let g=i;g.subsurfaceWeight>0&&g.subsurfaceWeightTexture&&(r.push("#define SUBSURFACE_WEIGHT"),r.push(`#define SUBSURFACEWEIGHT_UV${g.subsurfaceWeightTexture.coordinatesIndex+1}`),_=!0),g.transmissionWeight>0&&g.transmissionWeightTexture&&(r.push("#define TRANSMISSION_WEIGHT"),r.push(`#define TRANSMISSIONWEIGHT_UV${g.transmissionWeightTexture.coordinatesIndex+1}`),_=!0)}_&&(r.push("#define NEED_UV"),a.isVerticesDataPresent(M.UVKind)&&(s.push(M.UVKind),r.push("#define UV1"),l=!0),a.isVerticesDataPresent(M.UV2Kind)&&(s.push(M.UV2Kind),r.push("#define UV2"),c=!0))}if(this._enableDepth&&(r.push("#define DEPTH"),r.push("#define DEPTH_INDEX "+this._depthIndex)),this._enableNormal&&(r.push("#define NORMAL"),r.push("#define NORMAL_INDEX "+this._normalIndex)),this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(a)===-1&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableVelocityLinear&&(r.push("#define VELOCITY_LINEAR"),r.push("#define VELOCITY_LINEAR_INDEX "+this._velocityLinearIndex),this.excludedSkinnedMeshesFromVelocity.indexOf(a)===-1&&r.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(r.push("#define REFLECTIVITY"),r.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),this._enableScreenspaceDepth&&this._screenspaceDepthIndex!==-1&&(r.push("#define SCREENSPACE_DEPTH_INDEX "+this._screenspaceDepthIndex),r.push("#define SCREENSPACE_DEPTH")),this._enableIrradiance&&this._irradianceIndex!==-1){r.push("#define IRRADIANCE_INDEX "+this._irradianceIndex),r.push("#define IRRADIANCE");let _=this._scene;if(_.environmentTexture){let g={},T=!1,b=0;(i.getClassName()==="OpenPBRMaterial"||i.getClassName()==="StandardMaterial"||i.getClassName()==="PBRMetallicRoughnessMaterial"||i.getClassName()==="PBRSpecularGlossinessMaterial"||i.getClassName()==="PBRMaterial")&&(T=!!i.realtimeFiltering,b=i.realtimeFilteringQuality||0),Ra(_,_.environmentTexture,g,T,b,!0);for(let S in g)g[S]&&r.push("#define "+S);g.USEIRRADIANCEMAP||r.push("#define SPHERICAL_HARMONICS");let R=_.postProcessRenderPipelineManager.supportedPipelines.find(S=>S.getClassName()==="IBLShadowsRenderPipeline");if(R){let S=R;S._getAccumulatedTexture()&&(r.push("#define IBL_SHADOW_TEXTURE"),S.coloredShadows&&r.push("#define COLORED_IBL_SHADOWS"))}}}this.generateNormalsInWorldSpace&&r.push("#define NORMAL_WORLDSPACE"),this._normalsAreUnsigned&&r.push("#define ENCODE_NORMAL"),a.useBones&&a.computeBonesUsingShaders&&a.skeleton?(s.push(M.MatricesIndicesKind),s.push(M.MatricesWeightsKind),a.numBoneInfluencers>4&&(s.push(M.MatricesIndicesExtraKind),s.push(M.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),r.push("#define BONETEXTURE "+a.skeleton.isUsingTextureForMatrices),r.push("#define BonesPerMesh "+(a.skeleton.bones.length+1))):(r.push("#define NUM_BONE_INFLUENCERS 0"),r.push("#define BONETEXTURE false"),r.push("#define BonesPerMesh 0"));let d=a.morphTargetManager?Hn(a.morphTargetManager,r,s,a,!0,!0,!1,l,c,f):0;t&&(r.push("#define INSTANCES"),gn(s,this._enableVelocity||this._enableVelocityLinear),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES")),this._linkedWithPrePass?r.push("#define SCENE_MRT_COUNT "+this._attachmentsFromPrePass.length):r.push("#define SCENE_MRT_COUNT "+this._multiRenderTarget.textures.length),kn(i,this._scene,r);let h=this._scene.getEngine(),u=e._getDrawWrapper(void 0,!0),m=u.defines,p=r.join(` +`);return m!==p&&u.setEffect(h.createEffect("geometry",{attributes:s,uniformsNames:KT,samplers:jN,defines:p,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:d},shaderLanguage:this.shaderLanguage},h),p),u.effect.isReady()}getGBuffer(){return this._multiRenderTarget}get samples(){return this._multiRenderTarget.samples}set samples(e){this._multiRenderTarget.samples=e}dispose(){var e,t;this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),(e=this._multiRenderTarget)!=null&&e.renderTarget&&this.scene.getEngine()._currentRenderTarget===this._multiRenderTarget.renderTarget&&this.scene.getEngine().unBindFramebuffer((t=this._multiRenderTarget)==null?void 0:t.renderTarget),this.getGBuffer().dispose()}_assignRenderTargetIndices(){let e=[],t=[],i=0;return this._enableDepth&&(this._depthIndex=i,i++,e.push("gBuffer_Depth"),t.push(this._textureTypesAndFormats[n.DEPTH_TEXTURE_TYPE])),this._enableNormal&&(this._normalIndex=i,i++,e.push("gBuffer_Normal"),t.push(this._textureTypesAndFormats[n.NORMAL_TEXTURE_TYPE])),this._enablePosition&&(this._positionIndex=i,i++,e.push("gBuffer_Position"),t.push(this._textureTypesAndFormats[n.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=i,i++,e.push("gBuffer_Velocity"),t.push(this._textureTypesAndFormats[n.VELOCITY_TEXTURE_TYPE])),this._enableVelocityLinear&&(this._velocityLinearIndex=i,i++,e.push("gBuffer_VelocityLinear"),t.push(this._textureTypesAndFormats[n.VELOCITY_LINEAR_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=i,i++,e.push("gBuffer_Reflectivity"),t.push(this._textureTypesAndFormats[n.REFLECTIVITY_TEXTURE_TYPE])),this._enableScreenspaceDepth&&(this._screenspaceDepthIndex=i,i++,e.push("gBuffer_ScreenspaceDepth"),t.push(this._textureTypesAndFormats[n.SCREENSPACE_DEPTH_TEXTURE_TYPE])),this._enableIrradiance&&(this._irradianceIndex=i,i++,e.push("gBuffer_Irradiance"),t.push(this._textureTypesAndFormats[n.IRRADIANCE_TEXTURE_TYPE])),[i,e,t]}_createRenderTargets(){var g;let e=this._scene.getEngine(),[t,i,r]=this._assignRenderTargetIndices(),s=0;e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?s=1:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(s=2);let a=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions},o=[],l=[],c=[];for(let T of r)T?(o.push(T.textureType),l.push(T.textureFormat),c.push((g=T.samplingMode)!=null?g:2)):(o.push(s),l.push(5),c.push(2));if(this._normalsAreUnsigned=o[n.NORMAL_TEXTURE_TYPE]===11||o[n.NORMAL_TEXTURE_TYPE]===13,this._multiRenderTarget=new Hm("gBuffer",a,t,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,types:o,formats:l,samplingModes:c,depthTextureFormat:this._depthFormat},i.concat("gBuffer_DepthBuffer")),!this.isSupported)return;this._multiRenderTarget.wrapU=ne.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=ne.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null;let f=[!0],d=[!1],h=[!0];for(let T=1;T{T.bindAttachments(this.useSpecificClearForDepthTexture?m:u),T.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(T.bindAttachments(p),T.clear(this._clearDepthColor,!0,!0,!0)),T.bindAttachments(u)}),this._resizeObserver=e.onResizeObservable.add(()=>{if(this._multiRenderTarget){let T=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions};this._multiRenderTarget.resize(T)}});let _=T=>{let b=T.getRenderingMesh(),R=T.getEffectiveMesh(),S=this._scene,I=S.getEngine(),x=T.getMaterial();if(!x)return;if(R._internalAbstractMeshDataInfo._isActiveIntermediate=!1,(this._enableVelocity||this._enableVelocityLinear)&&!this._previousTransformationMatrices[R.uniqueId]&&(this._previousTransformationMatrices[R.uniqueId]={world:U.Identity(),viewProjection:S.getTransformMatrix()},b.skeleton)){let B=b.skeleton.getTransformMatrices(b);this._previousBonesTransformationMatrices[b.uniqueId]=this._copyBonesTransformationMatrices(B,new Float32Array(B.length))}let P=b._getInstancesRenderList(T._id,!!T.getReplacementMesh());if(P.mustReturn)return;let L=I.getCaps().instancedArrays&&(P.visibleInstances[T._id]!==null||b.hasThinInstances),y=R.getWorldMatrix();if(this.isReady(T,L)){let B=T._getDrawWrapper();if(!B)return;let w=B.effect;I.enableEffect(B),L||b._bind(T,w,x.fillMode),this._useUbo?(Aa(w,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(w.setMatrix("viewProjection",S.getTransformMatrix()),w.setMatrix("view",S.getViewMatrix()),this._scene.bindEyePosition(w,"vEyePosition"));let H;if(!b._instanceDataStorage.isFrozen&&(x.backFaceCulling||x.sideOrientation!==null)){let k=R._getWorldMatrixDeterminant();H=x._getEffectiveOrientation(b),k<0&&(H=H===ae.ClockWiseSideOrientation?ae.CounterClockWiseSideOrientation:ae.ClockWiseSideOrientation)}else H=b._effectiveSideOrientation;if(x._preBind(B,H),x.needAlphaTestingForMesh(R)){let k=x.getAlphaTestTexture();k&&(w.setTexture("diffuseSampler",k),w.setMatrix("diffuseMatrix",k.getTextureMatrix()))}if((x.bumpTexture||x.normalTexture||x.geometryNormalTexture)&&S.getEngine().getCaps().standardDerivatives&&ie.BumpTextureEnabled){let k=x.bumpTexture||x.normalTexture||x.geometryNormalTexture;w.setFloat3("vBumpInfos",k.coordinatesIndex,1/k.level,x.parallaxScaleBias),w.setMatrix("bumpMatrix",k.getTextureMatrix()),w.setTexture("bumpSampler",k),w.setFloat2("vTangentSpaceParams",x.invertNormalMapX?-1:1,x.invertNormalMapY?-1:1)}if(this._enableReflectivity){if(x.getClassName()==="PBRMetallicRoughnessMaterial")x.metallicRoughnessTexture!==null&&(w.setTexture("reflectivitySampler",x.metallicRoughnessTexture),w.setMatrix("reflectivityMatrix",x.metallicRoughnessTexture.getTextureMatrix())),x.metallic!==null&&w.setFloat("metallic",x.metallic),x.roughness!==null&&w.setFloat("glossiness",1-x.roughness),x.baseTexture!==null&&(w.setTexture("albedoSampler",x.baseTexture),w.setMatrix("albedoMatrix",x.baseTexture.getTextureMatrix())),x.baseColor!==null&&w.setColor3("albedoColor",x.baseColor);else if(x.getClassName()==="PBRSpecularGlossinessMaterial")x.specularGlossinessTexture!==null?(w.setTexture("reflectivitySampler",x.specularGlossinessTexture),w.setMatrix("reflectivityMatrix",x.specularGlossinessTexture.getTextureMatrix())):x.specularColor!==null&&w.setColor3("reflectivityColor",x.specularColor),x.glossiness!==null&&w.setFloat("glossiness",x.glossiness);else if(x.getClassName()==="PBRMaterial")x.metallicTexture!==null&&(w.setTexture("reflectivitySampler",x.metallicTexture),w.setMatrix("reflectivityMatrix",x.metallicTexture.getTextureMatrix())),x.metallic!==null&&w.setFloat("metallic",x.metallic),x.roughness!==null&&w.setFloat("glossiness",1-x.roughness),x.roughness!==null||x.metallic!==null||x.metallicTexture!==null?(x.albedoTexture!==null&&(w.setTexture("albedoSampler",x.albedoTexture),w.setMatrix("albedoMatrix",x.albedoTexture.getTextureMatrix())),x.albedoColor!==null&&w.setColor3("albedoColor",x.albedoColor)):(x.reflectivityTexture!==null?(w.setTexture("reflectivitySampler",x.reflectivityTexture),w.setMatrix("reflectivityMatrix",x.reflectivityTexture.getTextureMatrix())):x.reflectivityColor!==null&&w.setColor3("reflectivityColor",x.reflectivityColor),x.microSurface!==null&&w.setFloat("glossiness",x.microSurface));else if(x.getClassName()==="StandardMaterial")x.specularTexture!==null&&(w.setTexture("reflectivitySampler",x.specularTexture),w.setMatrix("reflectivityMatrix",x.specularTexture.getTextureMatrix())),x.specularColor!==null&&w.setColor3("reflectivityColor",x.specularColor);else if(x.getClassName()==="OpenPBRMaterial"){let k=x;k._useRoughnessFromMetallicTextureGreen&&k.baseMetalnessTexture?(w.setTexture("reflectivitySampler",k.baseMetalnessTexture),w.setMatrix("reflectivityMatrix",k.baseMetalnessTexture.getTextureMatrix())):k.baseMetalnessTexture?(w.setTexture("metallicSampler",k.baseMetalnessTexture),w.setMatrix("metallicMatrix",k.baseMetalnessTexture.getTextureMatrix())):k.specularRoughnessTexture&&(w.setTexture("roughnessSampler",k.specularRoughnessTexture),w.setMatrix("roughnessMatrix",k.specularRoughnessTexture.getTextureMatrix())),w.setFloat("metallic",k.baseMetalness),w.setFloat("glossiness",1-k.specularRoughness),k.baseColorTexture!==null&&(w.setTexture("albedoSampler",k.baseColorTexture),w.setMatrix("albedoMatrix",k.baseColorTexture.getTextureMatrix())),k.baseColor!==null&&w.setColor3("albedoColor",k.baseColor)}}if(this._enableIrradiance&&S.environmentTexture){let k=S.environmentTexture,X=S.postProcessRenderPipelineManager.supportedPipelines.find(j=>j.getClassName()==="IBLShadowsRenderPipeline");if(X){let Q=X._getAccumulatedTexture();Q&&(w.setTexture("iblShadowSampler",Q),w.setFloat2("shadowTextureSize",Q.getSize().width,Q.getSize().height))}if(w.setMatrix("reflectionMatrix",k.getReflectionTextureMatrix()),w.setFloat2("vReflectionInfos",k.level*S.iblIntensity,0),w.setTexture("reflectionSampler",k),k.irradianceTexture&&(w.setTexture("irradianceSampler",k.irradianceTexture),k.irradianceTexture._dominantDirection&&w.setVector3("vReflectionDominantDirection",k.irradianceTexture._dominantDirection)),k.sphericalPolynomial){let j=k.sphericalPolynomial;if(j.preScaledHarmonics){let Q=j.preScaledHarmonics;w.setVector3("vSphericalL00",Q.l00),w.setVector3("vSphericalL1_1",Q.l1_1),w.setVector3("vSphericalL10",Q.l10),w.setVector3("vSphericalL11",Q.l11),w.setVector3("vSphericalL2_2",Q.l2_2),w.setVector3("vSphericalL2_1",Q.l2_1),w.setVector3("vSphericalL20",Q.l20),w.setVector3("vSphericalL21",Q.l21),w.setVector3("vSphericalL22",Q.l22)}else w.setFloat3("vSphericalX",j.x.x,j.x.y,j.x.z),w.setFloat3("vSphericalY",j.y.x,j.y.y,j.y.z),w.setFloat3("vSphericalZ",j.z.x,j.z.y,j.z.z),w.setFloat3("vSphericalXX_ZZ",j.xx.x-j.zz.x,j.xx.y-j.zz.y,j.xx.z-j.zz.z),w.setFloat3("vSphericalYY_ZZ",j.yy.x-j.zz.x,j.yy.y-j.zz.y,j.yy.z-j.zz.z),w.setFloat3("vSphericalZZ",j.zz.x,j.zz.y,j.zz.z),w.setFloat3("vSphericalXY",j.xy.x,j.xy.y,j.xy.z),w.setFloat3("vSphericalYZ",j.yz.x,j.yz.y,j.yz.z),w.setFloat3("vSphericalZX",j.zx.x,j.zx.y,j.zx.z)}if(this.generateIrradianceWithScatterMask&&x.getClassName()==="OpenPBRMaterial"){let j=x;w.setFloat("vSubsurfaceWeight",j.subsurfaceWeight),j.subsurfaceWeightTexture&&(w.setTexture("subsurfaceWeightSampler",j.subsurfaceWeightTexture),w.setMatrix("subsurfaceWeightMatrix",j.subsurfaceWeightTexture.getTextureMatrix())),w.setFloat("vTransmissionWeight",j.transmissionWeight),j.transmissionWeightTexture&&(w.setTexture("transmissionWeightSampler",j.transmissionWeightTexture),w.setMatrix("transmissionWeightMatrix",j.transmissionWeightTexture.getTextureMatrix())),w.setFloat("vTransmissionScatterAnisotropy",j.transmissionScatterAnisotropy),w.setFloat("vSubsurfaceScatterAnisotropy",j.subsurfaceScatterAnisotropy)}}if(Pi(w,x,this._scene),b.useBones&&b.computeBonesUsingShaders&&b.skeleton){let k=b.skeleton;if(k.isUsingTextureForMatrices&&w.getUniformIndex("boneTextureInfo")>-1){let X=k.getTransformMatrixTexture(b);w.setTexture("boneSampler",X),w.setFloat2("boneTextureInfo",k._textureWidth,k._textureHeight)}else w.setMatrices("mBones",b.skeleton.getTransformMatrices(b));(this._enableVelocity||this._enableVelocityLinear)&&w.setMatrices("mPreviousBones",this._previousBonesTransformationMatrices[b.uniqueId])}Oi(b,w),b.morphTargetManager&&b.morphTargetManager.isUsingTextureForTargets&&b.morphTargetManager._bind(w),(this._enableVelocity||this._enableVelocityLinear)&&(w.setMatrix("previousWorld",this._previousTransformationMatrices[R.uniqueId].world),w.setMatrix("previousViewProjection",this._previousTransformationMatrices[R.uniqueId].viewProjection)),L&&b.hasThinInstances&&w.setMatrix("world",y),b._processRendering(R,T,w,x.fillMode,P,L,(k,X)=>{k||w.setMatrix("world",X)})}(this._enableVelocity||this._enableVelocityLinear)&&(this._previousTransformationMatrices[R.uniqueId].world=y.clone(),this._previousTransformationMatrices[R.uniqueId].viewProjection=this._scene.getTransformMatrix().clone(),b.skeleton&&this._copyBonesTransformationMatrices(b.skeleton.getTransformMatrices(b),this._previousBonesTransformationMatrices[R.uniqueId]))};this._multiRenderTarget.customIsReadyFunction=(T,b,R)=>{if((R||b===0)&&T.subMeshes)for(let S=0;S{let I;if(this._linkedWithPrePass){if(!this._prePassRenderer.enabled)return;this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass)}if(S.length){for(e.setColorWrite(!1),I=0;I{throw Ie("GeometryBufferRendererSceneComponent")}});var qN,hX,jT=A(()=>{N();Do();Wf();qN="openpbrUboDeclaration",hX=`uniform vTangentSpaceParams: vec2f;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vDebugMode: vec2f;uniform renderTargetSize: vec2f;uniform cameraInfo: vec4f;uniform backgroundRefractionMatrix: mat4x4f;uniform vBackgroundRefractionInfos: vec3f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionDominantDirection: vec3f;uniform vReflectionColor: vec3f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f;uniform vBaseWeight: f32;uniform vBaseColor: vec4f;uniform vBaseDiffuseRoughness: f32;uniform vReflectanceInfo: vec4f;uniform vSpecularColor: vec4f;uniform vSpecularAnisotropy: vec3f;uniform vTransmissionWeight : f32;uniform vTransmissionColor : vec3f;uniform vTransmissionDepth : f32;uniform vTransmissionScatter : vec3f;uniform vTransmissionScatterAnisotropy : f32;uniform vTransmissionDispersionScale : f32;uniform vTransmissionDispersionAbbeNumber : f32;uniform vSubsurfaceWeight: f32;uniform vSubsurfaceColor: vec3f;uniform vSubsurfaceRadius: f32;uniform vSubsurfaceRadiusScale: vec3f;uniform vSubsurfaceScatterAnisotropy: f32;uniform vCoatWeight: f32;uniform vCoatColor: vec3f;uniform vCoatRoughness: f32;uniform vCoatRoughnessAnisotropy: f32;uniform vCoatIor: f32;uniform vCoatDarkening : f32;uniform vFuzzWeight: f32;uniform vFuzzColor: vec3f;uniform vFuzzRoughness: f32;uniform vGeometryThinWalled: f32;uniform vGeometryCoatTangent: vec2f;uniform vGeometryThickness: f32;uniform vEmissionColor: vec3f;uniform vThinFilmWeight: f32;uniform vThinFilmThickness: vec2f;uniform vThinFilmIor: f32;uniform vBaseWeightInfos: vec2f;uniform baseWeightMatrix: mat4x4f;uniform vBaseColorInfos: vec2f;uniform baseColorMatrix: mat4x4f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform vBaseMetalnessInfos: vec2f;uniform baseMetalnessMatrix: mat4x4f;uniform vSpecularWeightInfos: vec2f;uniform specularWeightMatrix: mat4x4f;uniform vSpecularColorInfos: vec2f;uniform specularColorMatrix: mat4x4f;uniform vSpecularRoughnessInfos: vec2f;uniform specularRoughnessMatrix: mat4x4f;uniform vSpecularRoughnessAnisotropyInfos: vec2f;uniform specularRoughnessAnisotropyMatrix: mat4x4f;uniform vTransmissionWeightInfos : vec2f;uniform transmissionWeightMatrix : mat4x4f;uniform vTransmissionColorInfos : vec2f;uniform transmissionColorMatrix : mat4x4f;uniform vTransmissionDepthInfos : vec2f;uniform transmissionDepthMatrix : mat4x4f;uniform vTransmissionScatterInfos : vec2f;uniform transmissionScatterMatrix : mat4x4f;uniform vTransmissionDispersionScaleInfos : vec2f;uniform transmissionDispersionScaleMatrix : mat4x4f;uniform vSubsurfaceWeightInfos: vec2f;uniform subsurfaceWeightMatrix: mat4x4f;uniform vSubsurfaceColorInfos: vec2f;uniform subsurfaceColorMatrix: mat4x4f;uniform vSubsurfaceRadiusScaleInfos: vec2f;uniform subsurfaceRadiusScaleMatrix: mat4x4f;uniform vCoatWeightInfos: vec2f;uniform coatWeightMatrix: mat4x4f;uniform vCoatColorInfos: vec2f;uniform coatColorMatrix: mat4x4f;uniform vCoatRoughnessInfos: vec2f;uniform coatRoughnessMatrix: mat4x4f;uniform vCoatRoughnessAnisotropyInfos: vec2f;uniform coatRoughnessAnisotropyMatrix: mat4x4f;uniform vCoatDarkeningInfos : vec2f;uniform coatDarkeningMatrix : mat4x4f;uniform vFuzzWeightInfos: vec2f;uniform fuzzWeightMatrix: mat4x4f;uniform vFuzzColorInfos: vec2f;uniform fuzzColorMatrix: mat4x4f;uniform vFuzzRoughnessInfos: vec2f;uniform fuzzRoughnessMatrix: mat4x4f;uniform vGeometryNormalInfos: vec2f;uniform geometryNormalMatrix: mat4x4f;uniform vGeometryTangentInfos: vec2f;uniform geometryTangentMatrix: mat4x4f;uniform vGeometryCoatNormalInfos: vec2f;uniform geometryCoatNormalMatrix: mat4x4f;uniform vGeometryCoatTangentInfos: vec2f;uniform geometryCoatTangentMatrix: mat4x4f;uniform vGeometryOpacityInfos: vec2f;uniform geometryOpacityMatrix: mat4x4f;uniform vGeometryThicknessInfos: vec2f;uniform geometryThicknessMatrix: mat4x4f;uniform vEmissionInfos: vec2f;uniform emissionMatrix: mat4x4f;uniform vThinFilmWeightInfos: vec2f;uniform thinFilmWeightMatrix: mat4x4f;uniform vThinFilmThicknessInfos: vec2f;uniform thinFilmThicknessMatrix: mat4x4f;uniform vAmbientOcclusionInfos: vec2f;uniform ambientOcclusionMatrix: mat4x4f; #define ADDITIONAL_UBO_DECLARATION #include #include -`;E.IncludesShadersStoreWGSL[HN]||(E.IncludesShadersStoreWGSL[HN]=Kz)});var zN,jz,XN=A(()=>{N();zN="openpbrNormalMapVertexDeclaration",jz=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(FUZZ) +`;E.IncludesShadersStoreWGSL[qN]||(E.IncludesShadersStoreWGSL[qN]=hX)});var QN,uX,JN=A(()=>{N();QN="openpbrNormalMapVertexDeclaration",uX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(FUZZ) #if defined(TANGENT) && defined(NORMAL) varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f; #endif #endif -`;E.IncludesShadersStoreWGSL[zN]||(E.IncludesShadersStoreWGSL[zN]=jz)});var YN,Zz,KN=A(()=>{N();YN="openpbrNormalMapVertex",Zz=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(FUZZ) +`;E.IncludesShadersStoreWGSL[QN]||(E.IncludesShadersStoreWGSL[QN]=uX)});var $N,mX,eF=A(()=>{N();$N="openpbrNormalMapVertex",mX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(FUZZ) #if defined(TANGENT) && defined(NORMAL) var tbnNormal: vec3f=normalize(normalUpdated);var tbnTangent: vec3f=normalize(tangentUpdated.xyz);var tbnBitangent: vec3f=cross(tbnNormal,tbnTangent)*tangentUpdated.w;var matTemp= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz)* mat3x3f(tbnTangent,tbnBitangent,tbnNormal);vertexOutputs.vTBN0=matTemp[0];vertexOutputs.vTBN1=matTemp[1];vertexOutputs.vTBN2=matTemp[2]; #endif #endif -`;E.IncludesShadersStoreWGSL[YN]||(E.IncludesShadersStoreWGSL[YN]=Zz)});var ZN={};De(ZN,{openpbrVertexShaderWGSL:()=>qz});var YT,jN,qz,qN=A(()=>{N();XT();xu();lc();Vr();vc();Cs();bs();Oa();Cu();bu();Ec();XN();Ms();bf();Mu();wa();Ba();Do();yu();Du();Ua();Va();ys();Ds();Ls();Lu();Pu();Ou();KN();Ps();Mf();Fu();yf();wu();YT="openpbrVertexShader",jN=`#define OPENPBR_VERTEX_SHADER +`;E.IncludesShadersStoreWGSL[$N]||(E.IncludesShadersStoreWGSL[$N]=mX)});var iF={};De(iF,{openpbrVertexShaderWGSL:()=>pX});var ZT,tF,pX,rF=A(()=>{N();jT();Cu();lc();kr();vc();Cs();bs();Oa();bu();Mu();Ec();JN();Ms();bf();yu();wa();Ba();Lo();Du();Lu();Ua();Va();ys();Ds();Ls();Pu();Ou();Nu();eF();Ps();Mf();wu();yf();Bu();ZT="openpbrVertexShader",tF=`#define OPENPBR_VERTEX_SHADER #include #define CUSTOM_VERTEX_BEGIN #ifndef USE_VERTEX_PULLING @@ -8920,7 +8920,7 @@ vertexOutputs.vMainUV2=uv2Updated; #include #include #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStoreWGSL[YT]||(E.ShadersStoreWGSL[YT]=jN);qz={name:YT,shader:jN}});var QN,Qz,KT=A(()=>{N();lc();QN="pbrFragmentExtraDeclaration",Qz=`varying vPositionW: vec3f; +}`;E.ShadersStoreWGSL[ZT]||(E.ShadersStoreWGSL[ZT]=tF);pX={name:ZT,shader:tF}});var nF,_X,qT=A(()=>{N();lc();nF="pbrFragmentExtraDeclaration",_X=`varying vPositionW: vec3f; #if DEBUGMODE>0 varying vClipSpacePosition: vec4f; #endif @@ -8937,7 +8937,7 @@ varying vColor: vec4f; #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 varying vViewDepth: f32; #endif -`;E.IncludesShadersStoreWGSL[QN]||(E.IncludesShadersStoreWGSL[QN]=Qz)});var JN,Jz,$N=A(()=>{N();Lo();Xm();JN="openpbrFragmentSamplersDeclaration",Jz=`#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor) +`;E.IncludesShadersStoreWGSL[nF]||(E.IncludesShadersStoreWGSL[nF]=_X)});var sF,gX,aF=A(()=>{N();Po();Ym();sF="openpbrFragmentSamplersDeclaration",gX=`#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor) #include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight) #include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness) #include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness) @@ -8989,15 +8989,15 @@ var blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d; #ifdef IBL_CDF_FILTERING var icdfSamplerSampler: sampler;var icdfSampler: texture_2d; #endif -`;E.IncludesShadersStoreWGSL[JN]||(E.IncludesShadersStoreWGSL[JN]=Jz)});var eF,$z,jT=A(()=>{N();eF="subSurfaceScatteringFunctions",$z=`fn testLightingForSSS(diffusionProfile: f32)->bool -{return diffusionProfile<1.;}`;E.IncludesShadersStoreWGSL[eF]||(E.IncludesShadersStoreWGSL[eF]=$z)});var tF,eX,ZT=A(()=>{N();tF="importanceSampling",eX=`fn hemisphereCosSample(u: vec2f)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=1.-u.y;var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} +`;E.IncludesShadersStoreWGSL[sF]||(E.IncludesShadersStoreWGSL[sF]=gX)});var oF,EX,QT=A(()=>{N();oF="subSurfaceScatteringFunctions",EX=`fn testLightingForSSS(diffusionProfile: f32)->bool +{return diffusionProfile<1.;}`;E.IncludesShadersStoreWGSL[oF]||(E.IncludesShadersStoreWGSL[oF]=EX)});var lF,vX,JT=A(()=>{N();lF="importanceSampling",vX=`fn hemisphereCosSample(u: vec2f)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=1.-u.y;var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} fn hemisphereImportanceSampleDggx(u: vec2f,a: f32)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} fn hemisphereImportanceSampleDggxAnisotropic(Xi: vec2f,alphaTangent: f32,alphaBitangent: f32)->vec3f {let alphaT: f32=max(alphaTangent,0.0001);let alphaB: f32=max(alphaBitangent,0.0001);var phi: f32=atan(alphaB/alphaT*tan(2.0f*PI*Xi.x));if (Xi.x>0.5) {phi+=PI; } let cosPhi: f32=cos(phi);let sinPhi: f32=sin(phi);let alpha2: f32=(cosPhi*cosPhi)/(alphaT*alphaT) + (sinPhi*sinPhi)/(alphaB*alphaB);let tanTheta2: f32=Xi.y/(1.0f-Xi.y)/alpha2;let cosTheta: f32=1.0f/sqrt(1.0f+tanTheta2);let sinTheta: f32=sqrt(max(0.0f,1.0f-cosTheta*cosTheta));return vec3f(sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);} fn hemisphereImportanceSampleDCharlie(u: vec2f,a: f32)->vec3f { -var phi: f32=2.*PI*u.x;var sinTheta: f32=pow(u.y,a/(2.*a+1.));var cosTheta: f32=sqrt(1.-sinTheta*sinTheta);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;E.IncludesShadersStoreWGSL[tF]||(E.IncludesShadersStoreWGSL[tF]=eX)});var iF,tX,qT=A(()=>{N();iF="pbrHelperFunctions",tX=`#define MINIMUMVARIANCE 0.0005 +var phi: f32=2.*PI*u.x;var sinTheta: f32=pow(u.y,a/(2.*a+1.));var cosTheta: f32=sqrt(1.-sinTheta*sinTheta);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;E.IncludesShadersStoreWGSL[lF]||(E.IncludesShadersStoreWGSL[lF]=vX)});var cF,TX,$T=A(()=>{N();cF="pbrHelperFunctions",TX=`#define MINIMUMVARIANCE 0.0005 fn convertRoughnessToAverageSlope(roughness: f32)->f32 {return roughness*roughness+MINIMUMVARIANCE;} fn fresnelGrazingReflectance(reflectance0: f32)->f32 {var reflectance90: f32=saturate(reflectance0*25.0);return reflectance90;} @@ -9031,7 +9031,7 @@ clearCoatIntensity);return clearCoatAbsorption;} fn computeDefaultMicroSurface(microSurface: f32,reflectivityColor: vec3f)->f32 {const kReflectivityNoAlphaWorkflow_SmoothnessMax: f32=0.95;var reflectivityLuminance: f32=getLuminance(reflectivityColor);var reflectivityLuma: f32=sqrt(reflectivityLuminance);var resultMicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return resultMicroSurface;} #endif -`;E.IncludesShadersStoreWGSL[iF]||(E.IncludesShadersStoreWGSL[iF]=tX)});var rF,iX,QT=A(()=>{N();fv();rF="pbrDirectLightingSetupFunctions",iX=`struct preLightingInfo +`;E.IncludesShadersStoreWGSL[cF]||(E.IncludesShadersStoreWGSL[cF]=TX)});var fF,SX,eS=A(()=>{N();uv();fF="pbrDirectLightingSetupFunctions",SX=`struct preLightingInfo {lightOffset: vec3f, lightDistanceSquared: f32, lightDistance: f32, @@ -9076,7 +9076,7 @@ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular; #endif result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3f(0.);return result;} #endif -`;E.IncludesShadersStoreWGSL[rF]||(E.IncludesShadersStoreWGSL[rF]=iX)});var nF,rX,JT=A(()=>{N();nF="pbrDirectLightingFalloffFunctions",rX=`fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32 +`;E.IncludesShadersStoreWGSL[fF]||(E.IncludesShadersStoreWGSL[fF]=SX)});var dF,AX,tS=A(()=>{N();dF="pbrDirectLightingFalloffFunctions",AX=`fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32 {return max(0.,1.0-length(lightOffset)/range);} fn computeDistanceLightFalloff_Physical(lightDistanceSquared: f32)->f32 {return 1.0/maxEps(lightDistanceSquared);} @@ -9112,7 +9112,7 @@ return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenter #else return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); #endif -}`;E.IncludesShadersStoreWGSL[nF]||(E.IncludesShadersStoreWGSL[nF]=rX)});var sF,nX,$T=A(()=>{N();sF="hdrFilteringFunctions",nX=`#ifdef NUM_SAMPLES +}`;E.IncludesShadersStoreWGSL[dF]||(E.IncludesShadersStoreWGSL[dF]=AX)});var hF,RX,iS=A(()=>{N();hF="hdrFilteringFunctions",RX=`#ifdef NUM_SAMPLES #if NUM_SAMPLES>0 fn radicalInverse_VdC(value: u32)->f32 {var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; } @@ -9229,11 +9229,11 @@ result=result/weight;return result;} #endif #endif #endif -`;E.IncludesShadersStoreWGSL[sF]||(E.IncludesShadersStoreWGSL[sF]=nX)});var aF,sX,eS=A(()=>{N();aF="pbrBlockReflectance0",sX=`var reflectanceF0: f32=reflectivityOut.reflectanceF0;var specularEnvironmentR0: vec3f=reflectivityOut.colorReflectanceF0;var specularEnvironmentR90: vec3f= reflectivityOut.reflectanceF90; +`;E.IncludesShadersStoreWGSL[hF]||(E.IncludesShadersStoreWGSL[hF]=RX)});var uF,IX,rS=A(()=>{N();uF="pbrBlockReflectance0",IX=`var reflectanceF0: f32=reflectivityOut.reflectanceF0;var specularEnvironmentR0: vec3f=reflectivityOut.colorReflectanceF0;var specularEnvironmentR90: vec3f= reflectivityOut.reflectanceF90; #ifdef ALPHAFRESNEL var reflectance90: f32=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90; #endif -`;E.IncludesShadersStoreWGSL[aF]||(E.IncludesShadersStoreWGSL[aF]=sX)});var oF,aX,tS=A(()=>{N();dv();eS();oF="pbrDirectLightingFunctions",aX=`#define CLEARCOATREFLECTANCE90 1.0 +`;E.IncludesShadersStoreWGSL[uF]||(E.IncludesShadersStoreWGSL[uF]=IX)});var mF,xX,nS=A(()=>{N();mv();rS();mF="pbrDirectLightingFunctions",xX=`#define CLEARCOATREFLECTANCE90 1.0 struct lightingInfo {diffuse: vec3f, #ifdef SS_TRANSLUCENCY @@ -9455,7 +9455,7 @@ result.sheen+=info.sheen; batchOffset+=CLUSTLIGHT_BATCH;} return result;} #endif -`;E.IncludesShadersStoreWGSL[oF]||(E.IncludesShadersStoreWGSL[oF]=aX)});var lF,oX,cF=A(()=>{N();lF="openpbrNormalMapFragmentMainFunctions",oX=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL) +`;E.IncludesShadersStoreWGSL[mF]||(E.IncludesShadersStoreWGSL[mF]=xX)});var pF,CX,_F=A(()=>{N();pF="openpbrNormalMapFragmentMainFunctions",CX=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL) #if defined(TANGENT) && defined(NORMAL) varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f; #endif @@ -9495,7 +9495,7 @@ fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f {var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);} #endif -`;E.IncludesShadersStoreWGSL[lF]||(E.IncludesShadersStoreWGSL[lF]=oX)});var fF,lX,dF=A(()=>{N();Lo();fF="openpbrNormalMapFragmentFunctions",lX=`#if defined(GEOMETRY_NORMAL) +`;E.IncludesShadersStoreWGSL[pF]||(E.IncludesShadersStoreWGSL[pF]=CX)});var gF,bX,EF=A(()=>{N();Po();gF="openpbrNormalMapFragmentFunctions",bX=`#if defined(GEOMETRY_NORMAL) #include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal) #endif #if defined(GEOMETRY_COAT_NORMAL) @@ -9528,7 +9528,7 @@ return -texCoordOffset; #endif } #endif -`;E.IncludesShadersStoreWGSL[fF]||(E.IncludesShadersStoreWGSL[fF]=lX)});var hF,cX,uF=A(()=>{N();hF="openpbrConductorReflectance",cX=`#define pbr_inline +`;E.IncludesShadersStoreWGSL[gF]||(E.IncludesShadersStoreWGSL[gF]=bX)});var vF,MX,TF=A(()=>{N();vF="openpbrConductorReflectance",MX=`#define pbr_inline fn conductorReflectance(baseColor: vec3f,specularColor: vec3f,specularWeight: f32)->ReflectanceParams {var outParams: ReflectanceParams; #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) @@ -9536,9 +9536,9 @@ outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor* #else outParams.coloredF0=baseColor;outParams.coloredF90=vec3f(1.0f); #endif -outParams.F0=1.0f;outParams.F90=1.0f;return outParams;}`;E.IncludesShadersStoreWGSL[hF]||(E.IncludesShadersStoreWGSL[hF]=cX)});var mF,fX,pF=A(()=>{N();mF="openpbrAmbientOcclusionFunctions",fX=`fn compute_specular_occlusion(n_dot_v: f32,metallic: f32,ambient_occlusion: f32,roughness: f32)->f32 +outParams.F0=1.0f;outParams.F90=1.0f;return outParams;}`;E.IncludesShadersStoreWGSL[vF]||(E.IncludesShadersStoreWGSL[vF]=MX)});var SF,yX,AF=A(()=>{N();SF="openpbrAmbientOcclusionFunctions",yX=`fn compute_specular_occlusion(n_dot_v: f32,metallic: f32,ambient_occlusion: f32,roughness: f32)->f32 {let specular_occlusion: f32=saturate(pow(n_dot_v+ambient_occlusion,exp2(-16.0*roughness-1.0))-1.0+ambient_occlusion);return mix(specular_occlusion,1.0,metallic*square(1.0-roughness));} -`;E.IncludesShadersStoreWGSL[mF]||(E.IncludesShadersStoreWGSL[mF]=fX)});var _F,dX,gF=A(()=>{N();_F="openpbrVolumeFunctions",dX=`struct OpenPBRHomogeneousVolume {extinction_coeff: vec3f, +`;E.IncludesShadersStoreWGSL[SF]||(E.IncludesShadersStoreWGSL[SF]=yX)});var RF,DX,IF=A(()=>{N();RF="openpbrVolumeFunctions",DX=`struct OpenPBRHomogeneousVolume {extinction_coeff: vec3f, ss_albedo: vec3f, multi_scatter_color: vec3f, absorption_coeff: vec3f, @@ -9595,7 +9595,7 @@ let filter_samples_scale: f32=samples_scale(pixels_to_projective(overscan_size_i return vec3f(select(unconvolved_irradiance.r,irradiance_sum.r/weight_sum.r,weight_sum.r>=1e-5f), select(unconvolved_irradiance.g,irradiance_sum.g/weight_sum.g,weight_sum.g>=1e-5f), select(unconvolved_irradiance.b,irradiance_sum.b/weight_sum.b,weight_sum.b>=1e-5f));} -`;E.IncludesShadersStoreWGSL[_F]||(E.IncludesShadersStoreWGSL[_F]=dX)});var EF,hX,iS=A(()=>{N();EF="pbrBlockNormalGeometric",hX=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW); +`;E.IncludesShadersStoreWGSL[RF]||(E.IncludesShadersStoreWGSL[RF]=DX)});var xF,LX,sS=A(()=>{N();xF="pbrBlockNormalGeometric",LX=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW); #ifdef NORMAL var normalW: vec3f=normalize(input.vNormalW); #else @@ -9605,7 +9605,7 @@ var geometricNormalW: vec3f=normalW; #if defined(TWOSIDEDLIGHTING) && defined(NORMAL) geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing); #endif -`;E.IncludesShadersStoreWGSL[EF]||(E.IncludesShadersStoreWGSL[EF]=hX)});var vF,uX,TF=A(()=>{N();vF="openpbrNormalMapFragment",uX=`var uvOffset: vec2f= vec2f(0.0,0.0); +`;E.IncludesShadersStoreWGSL[xF]||(E.IncludesShadersStoreWGSL[xF]=LX)});var CF,PX,bF=A(()=>{N();CF="openpbrNormalMapFragment",PX=`var uvOffset: vec2f= vec2f(0.0,0.0); #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL) #ifdef NORMALXYSCALE var normalScale: f32=1.0; @@ -9660,7 +9660,7 @@ normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vGeometryNormalInfos.y); #elif defined(DETAIL) detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z); #endif -`;E.IncludesShadersStoreWGSL[vF]||(E.IncludesShadersStoreWGSL[vF]=uX)});var SF,mX,AF=A(()=>{N();SF="openpbrBlockNormalFinal",mX=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +`;E.IncludesShadersStoreWGSL[CF]||(E.IncludesShadersStoreWGSL[CF]=PX)});var MF,OX,yF=A(()=>{N();MF="openpbrBlockNormalFinal",OX=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w; #if defined(TWOSIDEDLIGHTING) faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing); @@ -9674,7 +9674,7 @@ normalW=select(normalW,-normalW,fragmentInputs.frontFacing);coatNormalW=select(c normalW=select(-normalW,normalW,fragmentInputs.frontFacing);coatNormalW=select(-coatNormalW,coatNormalW,fragmentInputs.frontFacing); #endif #endif -`;E.IncludesShadersStoreWGSL[SF]||(E.IncludesShadersStoreWGSL[SF]=mX)});var RF,pX,IF=A(()=>{N();RF="openpbrBaseLayerData",pX=`var base_color=vec3f(0.8);var base_metalness: f32=0.0;var base_diffuse_roughness: f32=0.0;var specular_weight: f32=1.0;var specular_roughness: f32=0.3;var specular_color: vec3f=vec3f(1.0);var specular_roughness_anisotropy: f32=0.0;var specular_ior: f32=1.5;var alpha: f32=1.0;var geometry_tangent: vec2f=vec2f(1.0,0.0);var geometry_thickness: f32=0.0; +`;E.IncludesShadersStoreWGSL[MF]||(E.IncludesShadersStoreWGSL[MF]=OX)});var DF,NX,LF=A(()=>{N();DF="openpbrBaseLayerData",NX=`var base_color=vec3f(0.8);var base_metalness: f32=0.0;var base_diffuse_roughness: f32=0.0;var specular_weight: f32=1.0;var specular_roughness: f32=0.3;var specular_color: vec3f=vec3f(1.0);var specular_roughness_anisotropy: f32=0.0;var specular_ior: f32=1.5;var alpha: f32=1.0;var geometry_tangent: vec2f=vec2f(1.0,0.0);var geometry_thickness: f32=0.0; #ifdef BASE_WEIGHT let baseWeightFromTexture: vec4f=textureSample(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset); #endif @@ -9800,7 +9800,7 @@ let detailRoughness: f32=mix(0.5f,detailColor.b,vDetailInfos.w);let loLerp: f32= #ifdef USE_GLTF_STYLE_ANISOTROPY let baseAlpha: f32=specular_roughness*specular_roughness;let roughnessT: f32=mix(baseAlpha,1.0f,specular_roughness_anisotropy*specular_roughness_anisotropy);let roughnessB: f32=baseAlpha;specular_roughness_anisotropy=1.0f-roughnessB/max(roughnessT,0.00001f);specular_roughness=sqrt(roughnessT/sqrt(2.0f/(1.0f+(1.0f-specular_roughness_anisotropy)*(1.0f-specular_roughness_anisotropy)))); #endif -`;E.IncludesShadersStoreWGSL[RF]||(E.IncludesShadersStoreWGSL[RF]=pX)});var xF,_X,CF=A(()=>{N();xF="openpbrCoatLayerData",_X=`var coat_weight: f32=0.0f;var coat_color: vec3f=vec3f(1.0f);var coat_roughness: f32=0.0f;var coat_roughness_anisotropy: f32=0.0f;var coat_ior: f32=1.6f;var coat_darkening: f32=1.0f;var geometry_coat_tangent: vec2f=vec2f(1.0f,0.0f); +`;E.IncludesShadersStoreWGSL[DF]||(E.IncludesShadersStoreWGSL[DF]=NX)});var PF,FX,OF=A(()=>{N();PF="openpbrCoatLayerData",FX=`var coat_weight: f32=0.0f;var coat_color: vec3f=vec3f(1.0f);var coat_roughness: f32=0.0f;var coat_roughness_anisotropy: f32=0.0f;var coat_ior: f32=1.6f;var coat_darkening: f32=1.0f;var geometry_coat_tangent: vec2f=vec2f(1.0f,0.0f); #ifdef COAT_WEIGHT var coatWeightFromTexture: vec4f=textureSample(coatWeightSampler,coatWeightSamplerSampler,fragmentInputs.vCoatWeightUV+uvOffset); #endif @@ -9852,7 +9852,7 @@ coat_darkening*=coatDarkeningFromTexture.r; #ifdef USE_GLTF_STYLE_ANISOTROPY let coatAlpha: f32=coat_roughness*coat_roughness;let coatRoughnessT: f32=mix(coatAlpha,1.0f,coat_roughness_anisotropy*coat_roughness_anisotropy);let coatRoughnessB: f32=coatAlpha;coat_roughness_anisotropy=1.0f-coatRoughnessB/max(coatRoughnessT,0.00001f);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0f/(1.0f+(1.0f-coat_roughness_anisotropy)*(1.0f-coat_roughness_anisotropy)))); #endif -`;E.IncludesShadersStoreWGSL[xF]||(E.IncludesShadersStoreWGSL[xF]=_X)});var bF,gX,MF=A(()=>{N();bF="openpbrThinFilmLayerData",gX=`#ifdef THIN_FILM +`;E.IncludesShadersStoreWGSL[PF]||(E.IncludesShadersStoreWGSL[PF]=FX)});var NF,wX,FF=A(()=>{N();NF="openpbrThinFilmLayerData",wX=`#ifdef THIN_FILM var thin_film_weight: f32=uniforms.vThinFilmWeight;var thin_film_thickness: f32=uniforms.vThinFilmThickness.r*1000.0f; var thin_film_ior: f32=uniforms.vThinFilmIor; #ifdef THIN_FILM_WEIGHT @@ -9869,7 +9869,7 @@ thin_film_thickness*=thinFilmThicknessFromTexture; #endif let thin_film_ior_scale: f32=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f); #endif -`;E.IncludesShadersStoreWGSL[bF]||(E.IncludesShadersStoreWGSL[bF]=gX)});var yF,EX,DF=A(()=>{N();yF="openpbrFuzzLayerData",EX=`var fuzz_weight: f32=0.0f;var fuzz_color: vec3f=vec3f(1.0f);var fuzz_roughness: f32=0.0f; +`;E.IncludesShadersStoreWGSL[NF]||(E.IncludesShadersStoreWGSL[NF]=wX)});var wF,BX,BF=A(()=>{N();wF="openpbrFuzzLayerData",BX=`var fuzz_weight: f32=0.0f;var fuzz_color: vec3f=vec3f(1.0f);var fuzz_roughness: f32=0.0f; #ifdef FUZZ #ifdef FUZZ_WEIGHT let fuzzWeightFromTexture: vec4f=textureSample(fuzzWeightSampler,fuzzWeightSamplerSampler,fragmentInputs.vFuzzWeightUV+uvOffset); @@ -9898,11 +9898,11 @@ fuzz_roughness*=fuzzRoughnessFromTexture.a; fuzz_roughness*=fuzzRoughnessFromTexture.r; #endif #endif -`;E.IncludesShadersStoreWGSL[yF]||(E.IncludesShadersStoreWGSL[yF]=EX)});var LF,vX,PF=A(()=>{N();LF="openpbrAmbientOcclusionData",vX=`var ambient_occlusion: vec3f=vec3f(1.0f,1.0f,1.0f);var specular_ambient_occlusion: f32=1.0f;var coat_specular_ambient_occlusion: f32=1.0f; +`;E.IncludesShadersStoreWGSL[wF]||(E.IncludesShadersStoreWGSL[wF]=BX)});var UF,UX,VF=A(()=>{N();UF="openpbrAmbientOcclusionData",UX=`var ambient_occlusion: vec3f=vec3f(1.0f,1.0f,1.0f);var specular_ambient_occlusion: f32=1.0f;var coat_specular_ambient_occlusion: f32=1.0f; #ifdef AMBIENT_OCCLUSION var ambientOcclusionFromTexture: vec3f=textureSample(ambientOcclusionSampler,ambientOcclusionSamplerSampler,fragmentInputs.vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3f(ambientOcclusionFromTexture.r*uniforms.vAmbientOcclusionInfos.y+(1.0f-uniforms.vAmbientOcclusionInfos.y)); #endif -`;E.IncludesShadersStoreWGSL[LF]||(E.IncludesShadersStoreWGSL[LF]=vX)});var OF,TX,NF=A(()=>{N();OF="openpbrBackgroundTransmission",TX=`var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.); +`;E.IncludesShadersStoreWGSL[UF]||(E.IncludesShadersStoreWGSL[UF]=UX)});var GF,VX,kF=A(()=>{N();GF="openpbrBackgroundTransmission",VX=`var slab_translucent_background: vec4f=vec4f(0.,0.,0.,1.); #ifdef REFRACTED_BACKGROUND {let refractionLOD: f32=min(transmission_roughness,0.7)*uniforms.vBackgroundRefractionInfos.x;let lodTexelSize: f32=pow(2.0f,refractionLOD-uniforms.vBackgroundRefractionInfos.x); #ifdef DISPERSION @@ -9930,7 +9930,7 @@ let noiseOffset: vec2f=noise.xy*lodTexelSize;slab_translucent_background=texture #endif } #endif -`;E.IncludesShadersStoreWGSL[OF]||(E.IncludesShadersStoreWGSL[OF]=TX)});var FF,SX,wF=A(()=>{N();FF="openpbrEnvironmentLighting",SX=`#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND) +`;E.IncludesShadersStoreWGSL[GF]||(E.IncludesShadersStoreWGSL[GF]=VX)});var WF,GX,HF=A(()=>{N();WF="openpbrEnvironmentLighting",GX=`#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND) var coatAbsorption=vec3f(1.0f);var coatIblFresnel: f32=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);let hemisphere_avg_fresnel: f32=coatReflectance.F0+0.5f*(1.0f-coatReflectance.F0);var averageReflectance: f32=(coatIblFresnel+hemisphere_avg_fresnel)*0.5f;let roughnessFactor=1.0f-coat_roughness*0.5f;averageReflectance*=roughnessFactor;var darkened_transmission: f32=(1.0f-averageReflectance)*(1.0f-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);var sin2: f32=1.0f-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);let cos_t: f32=sqrt(1.0f-sin2);let coatPathLength=1.0f/cos_t;let colored_transmission: vec3f=pow(coat_color,vec3f(coatPathLength));coatAbsorption=mix(vec3f(1.0f),colored_transmission*darkened_transmission,coat_weight);} #endif #ifdef REFLECTION @@ -10224,7 +10224,7 @@ slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*tran #endif let material_dielectric_base_ibl: vec3f=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(baseGeoInfo.NdotV);let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,black,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3f(1.0f));material_surface_ibl=material_coated_base_ibl; #endif -`;E.IncludesShadersStoreWGSL[FF]||(E.IncludesShadersStoreWGSL[FF]=SX)});var BF,AX,UF=A(()=>{N();BF="openpbrDirectLightingInit",AX=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[WF]||(E.IncludesShadersStoreWGSL[WF]=GX)});var zF,kX,XF=A(()=>{N();zF="openpbrDirectLightingInit",kX=`#ifdef LIGHT{X} var preInfo{X}: preLightingInfo;var preInfoCoat{X}: preLightingInfo;let lightColor{X}: vec4f=light{X}.vLightDiffuse;var shadow{X}: f32=1.0f; #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) #else @@ -10295,7 +10295,7 @@ preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb; #endif #endif -`;E.IncludesShadersStoreWGSL[BF]||(E.IncludesShadersStoreWGSL[BF]=AX)});var VF,RX,GF=A(()=>{N();VF="openpbrDirectLighting",RX=`#ifdef LIGHT{X} +`;E.IncludesShadersStoreWGSL[zF]||(E.IncludesShadersStoreWGSL[zF]=kX)});var YF,WX,KF=A(()=>{N();YF="openpbrDirectLighting",WX=`#ifdef LIGHT{X} {var slab_diffuse: vec3f=vec3f(0.f,0.f,0.f);var slab_translucent: vec3f=vec3f(0.f,0.f,0.f);var slab_glossy: vec3f=vec3f(0.f,0.f,0.f);var specularFresnel: f32=0.0f;var specularColoredFresnel: vec3f=vec3f(0.f,0.f,0.f);var slab_metal: vec3f=vec3f(0.f,0.f,0.f);var slab_coat: vec3f=vec3f(0.f,0.f,0.f);var coatFresnel: f32=0.0f;var slab_fuzz: vec3f=vec3f(0.f,0.f,0.f);var fuzzFresnel: f32=0.0f; #ifdef HEMILIGHT{X} slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround); @@ -10450,7 +10450,7 @@ total_direct_diffuse+=slab_diffuse; #endif let material_dielectric_base: vec3f=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);let material_dielectric_gloss: vec3f=material_dielectric_base*(1.0f-specularFresnel)+slab_glossy*specularColoredFresnel;let material_base_substrate: vec3f=mix(material_dielectric_gloss,slab_metal,base_metalness);let material_coated_base: vec3f=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3f(1.0f));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3f(1.0f),fuzz_color);} #endif -`;E.IncludesShadersStoreWGSL[VF]||(E.IncludesShadersStoreWGSL[VF]=RX)});var kF,IX,rS=A(()=>{N();kF="pbrBlockImageProcessing",IX=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) +`;E.IncludesShadersStoreWGSL[YF]||(E.IncludesShadersStoreWGSL[YF]=WX)});var jF,HX,aS=A(()=>{N();jF="pbrBlockImageProcessing",HX=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) #if !defined(SKIPFINALCOLORCLAMP) finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a); #endif @@ -10461,7 +10461,7 @@ finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility); #ifdef PREMULTIPLYALPHA finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);; #endif -`;E.IncludesShadersStoreWGSL[kF]||(E.IncludesShadersStoreWGSL[kF]=IX)});var WF,xX,HF=A(()=>{N();WF="openpbrBlockPrePass",xX=`#if SCENE_MRT_COUNT>0 +`;E.IncludesShadersStoreWGSL[jF]||(E.IncludesShadersStoreWGSL[jF]=HX)});var ZF,zX,qF=A(()=>{N();ZF="openpbrBlockPrePass",zX=`#if SCENE_MRT_COUNT>0 var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array,SCENE_MRT_COUNT>; #ifdef PREPASS_POSITION fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo); @@ -10551,7 +10551,7 @@ fragmentOutputs.fragData6=fragData[6]; fragmentOutputs.fragData7=fragData[7]; #endif #endif -`;E.IncludesShadersStoreWGSL[WF]||(E.IncludesShadersStoreWGSL[WF]=xX)});var zF,CX,nS=A(()=>{N();zF="pbrDebug",CX=`#if DEBUGMODE>0 +`;E.IncludesShadersStoreWGSL[ZF]||(E.IncludesShadersStoreWGSL[ZF]=zX)});var QF,XX,oS=A(()=>{N();QF="pbrDebug",XX=`#if DEBUGMODE>0 if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f; #if DEBUGMODE==1 color=fragmentInputs.vPositionW.rgb; @@ -10735,7 +10735,7 @@ return fragmentOutputs; #endif } #endif -`;E.IncludesShadersStoreWGSL[zF]||(E.IncludesShadersStoreWGSL[zF]=CX)});var YF={};De(YF,{openpbrPixelShaderWGSL:()=>bX});var sS,XF,bX,KF=A(()=>{N();Bu();Uu();XT();KT();Vu();$N();ku();Os();Do();Df();Vr();jT();ZT();qT();Wu();Gu();Ec();QT();JT();vc();$T();tS();Ym();cF();dF();Hf();UT();uF();pF();VT();GT();gF();Ns();iS();TF();AF();IF();WT();kT();CF();MF();DF();PF();Yu();NF();wF();UF();GF();Ku();Lf();rS();HF();ju();nS();sS="openpbrPixelShader",XF=`#define OPENPBR_FRAGMENT_SHADER +`;E.IncludesShadersStoreWGSL[QF]||(E.IncludesShadersStoreWGSL[QF]=XX)});var $F={};De($F,{openpbrPixelShaderWGSL:()=>YX});var lS,JF,YX,ew=A(()=>{N();Uu();Vu();jT();qT();Gu();aF();Wu();Os();Lo();Df();kr();QT();JT();$T();Hu();ku();Ec();eS();tS();vc();iS();nS();Km();_F();EF();Hf();kT();TF();AF();WT();HT();IF();Ns();sS();bF();yF();LF();XT();zT();OF();FF();BF();VF();Ku();kF();HF();XF();KF();ju();Lf();aS();qF();Zu();oS();lS="openpbrPixelShader",JF=`#define OPENPBR_FRAGMENT_SHADER #define CUSTOM_FRAGMENT_BEGIN #include[SCENE_MRT_COUNT] #include @@ -10959,7 +10959,7 @@ if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.f #include #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStoreWGSL[sS]||(E.ShadersStoreWGSL[sS]=XF);bX={name:sS,shader:XF}});var jF,MX,ZF=A(()=>{N();kv();Zu();jF="openpbrVertexDeclaration",MX=`#include +`;E.ShadersStoreWGSL[lS]||(E.ShadersStoreWGSL[lS]=JF);YX={name:lS,shader:JF}});var tw,KX,iw=A(()=>{N();zv();qu();tw="openpbrVertexDeclaration",KX=`#include #ifdef BASE_COLOR uniform vec2 vBaseColorInfos;uniform mat4 baseColorMatrix; #endif @@ -11086,22 +11086,22 @@ uniform vec4 vDetailInfos;uniform mat4 detailMatrix; #endif #include #define ADDITIONAL_VERTEX_DECLARATION -`;E.IncludesShadersStore[jF]||(E.IncludesShadersStore[jF]=MX)});var qF,yX,aS=A(()=>{N();Po();zf();qF="openpbrUboDeclaration",yX=`layout(std140,column_major) uniform;uniform Material {vec2 vTangentSpaceParams;vec4 vLightingIntensity;float pointSize;vec2 vDebugMode;vec2 renderTargetSize;vec4 cameraInfo;mat4 backgroundRefractionMatrix;vec3 vBackgroundRefractionInfos;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionMicrosurfaceInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vReflectionFilteringInfo;vec3 vReflectionDominantDirection;vec3 vReflectionColor;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX;float vBaseWeight;vec4 vBaseColor;float vBaseDiffuseRoughness;vec4 vReflectanceInfo;vec4 vSpecularColor;vec3 vSpecularAnisotropy;float vTransmissionWeight;vec3 vTransmissionColor;float vTransmissionDepth;vec3 vTransmissionScatter;float vTransmissionScatterAnisotropy;float vTransmissionDispersionScale;float vTransmissionDispersionAbbeNumber;float vSubsurfaceWeight;vec3 vSubsurfaceColor;float vSubsurfaceRadius;vec3 vSubsurfaceRadiusScale;float vSubsurfaceScatterAnisotropy;float vCoatWeight;vec3 vCoatColor;float vCoatRoughness;float vCoatRoughnessAnisotropy;float vCoatIor;float vCoatDarkening;float vFuzzWeight;vec3 vFuzzColor;float vFuzzRoughness;float vGeometryThinWalled;vec2 vGeometryCoatTangent;float vGeometryThickness;vec3 vEmissionColor;float vThinFilmWeight;vec2 vThinFilmThickness;float vThinFilmIor;vec2 vBaseWeightInfos;mat4 baseWeightMatrix;vec2 vBaseColorInfos;mat4 baseColorMatrix;vec2 vBaseDiffuseRoughnessInfos;mat4 baseDiffuseRoughnessMatrix;vec2 vBaseMetalnessInfos;mat4 baseMetalnessMatrix;vec2 vSpecularWeightInfos;mat4 specularWeightMatrix;vec2 vSpecularColorInfos;mat4 specularColorMatrix;vec2 vSpecularRoughnessInfos;mat4 specularRoughnessMatrix;vec2 vSpecularRoughnessAnisotropyInfos;mat4 specularRoughnessAnisotropyMatrix;vec2 vTransmissionWeightInfos;mat4 transmissionWeightMatrix;vec2 vTransmissionColorInfos;mat4 transmissionColorMatrix;vec2 vTransmissionDepthInfos;mat4 transmissionDepthMatrix;vec2 vTransmissionScatterInfos;mat4 transmissionScatterMatrix;vec2 vTransmissionDispersionScaleInfos;mat4 transmissionDispersionScaleMatrix;vec2 vSubsurfaceWeightInfos;mat4 subsurfaceWeightMatrix;vec2 vSubsurfaceColorInfos;mat4 subsurfaceColorMatrix;vec2 vSubsurfaceRadiusScaleInfos;mat4 subsurfaceRadiusScaleMatrix;vec2 vCoatWeightInfos;mat4 coatWeightMatrix;vec2 vCoatColorInfos;mat4 coatColorMatrix;vec2 vCoatRoughnessInfos;mat4 coatRoughnessMatrix;vec2 vCoatRoughnessAnisotropyInfos;mat4 coatRoughnessAnisotropyMatrix;vec2 vCoatDarkeningInfos;mat4 coatDarkeningMatrix;vec2 vFuzzWeightInfos;mat4 fuzzWeightMatrix;vec2 vFuzzColorInfos;mat4 fuzzColorMatrix;vec2 vFuzzRoughnessInfos;mat4 fuzzRoughnessMatrix;vec2 vGeometryNormalInfos;mat4 geometryNormalMatrix;vec2 vGeometryTangentInfos;mat4 geometryTangentMatrix;vec2 vGeometryCoatNormalInfos;mat4 geometryCoatNormalMatrix;vec2 vGeometryCoatTangentInfos;mat4 geometryCoatTangentMatrix;vec2 vGeometryOpacityInfos;mat4 geometryOpacityMatrix;vec2 vGeometryThicknessInfos;mat4 geometryThicknessMatrix;vec2 vEmissionColorInfos;mat4 emissionColorMatrix;vec2 vThinFilmWeightInfos;mat4 thinFilmWeightMatrix;vec2 vThinFilmThicknessInfos;mat4 thinFilmThicknessMatrix;vec2 vAmbientOcclusionInfos;mat4 ambientOcclusionMatrix; +`;E.IncludesShadersStore[tw]||(E.IncludesShadersStore[tw]=KX)});var rw,jX,cS=A(()=>{N();Oo();zf();rw="openpbrUboDeclaration",jX=`layout(std140,column_major) uniform;uniform Material {vec2 vTangentSpaceParams;vec4 vLightingIntensity;float pointSize;vec2 vDebugMode;vec2 renderTargetSize;vec4 cameraInfo;mat4 backgroundRefractionMatrix;vec3 vBackgroundRefractionInfos;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionMicrosurfaceInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vReflectionFilteringInfo;vec3 vReflectionDominantDirection;vec3 vReflectionColor;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX;float vBaseWeight;vec4 vBaseColor;float vBaseDiffuseRoughness;vec4 vReflectanceInfo;vec4 vSpecularColor;vec3 vSpecularAnisotropy;float vTransmissionWeight;vec3 vTransmissionColor;float vTransmissionDepth;vec3 vTransmissionScatter;float vTransmissionScatterAnisotropy;float vTransmissionDispersionScale;float vTransmissionDispersionAbbeNumber;float vSubsurfaceWeight;vec3 vSubsurfaceColor;float vSubsurfaceRadius;vec3 vSubsurfaceRadiusScale;float vSubsurfaceScatterAnisotropy;float vCoatWeight;vec3 vCoatColor;float vCoatRoughness;float vCoatRoughnessAnisotropy;float vCoatIor;float vCoatDarkening;float vFuzzWeight;vec3 vFuzzColor;float vFuzzRoughness;float vGeometryThinWalled;vec2 vGeometryCoatTangent;float vGeometryThickness;vec3 vEmissionColor;float vThinFilmWeight;vec2 vThinFilmThickness;float vThinFilmIor;vec2 vBaseWeightInfos;mat4 baseWeightMatrix;vec2 vBaseColorInfos;mat4 baseColorMatrix;vec2 vBaseDiffuseRoughnessInfos;mat4 baseDiffuseRoughnessMatrix;vec2 vBaseMetalnessInfos;mat4 baseMetalnessMatrix;vec2 vSpecularWeightInfos;mat4 specularWeightMatrix;vec2 vSpecularColorInfos;mat4 specularColorMatrix;vec2 vSpecularRoughnessInfos;mat4 specularRoughnessMatrix;vec2 vSpecularRoughnessAnisotropyInfos;mat4 specularRoughnessAnisotropyMatrix;vec2 vTransmissionWeightInfos;mat4 transmissionWeightMatrix;vec2 vTransmissionColorInfos;mat4 transmissionColorMatrix;vec2 vTransmissionDepthInfos;mat4 transmissionDepthMatrix;vec2 vTransmissionScatterInfos;mat4 transmissionScatterMatrix;vec2 vTransmissionDispersionScaleInfos;mat4 transmissionDispersionScaleMatrix;vec2 vSubsurfaceWeightInfos;mat4 subsurfaceWeightMatrix;vec2 vSubsurfaceColorInfos;mat4 subsurfaceColorMatrix;vec2 vSubsurfaceRadiusScaleInfos;mat4 subsurfaceRadiusScaleMatrix;vec2 vCoatWeightInfos;mat4 coatWeightMatrix;vec2 vCoatColorInfos;mat4 coatColorMatrix;vec2 vCoatRoughnessInfos;mat4 coatRoughnessMatrix;vec2 vCoatRoughnessAnisotropyInfos;mat4 coatRoughnessAnisotropyMatrix;vec2 vCoatDarkeningInfos;mat4 coatDarkeningMatrix;vec2 vFuzzWeightInfos;mat4 fuzzWeightMatrix;vec2 vFuzzColorInfos;mat4 fuzzColorMatrix;vec2 vFuzzRoughnessInfos;mat4 fuzzRoughnessMatrix;vec2 vGeometryNormalInfos;mat4 geometryNormalMatrix;vec2 vGeometryTangentInfos;mat4 geometryTangentMatrix;vec2 vGeometryCoatNormalInfos;mat4 geometryCoatNormalMatrix;vec2 vGeometryCoatTangentInfos;mat4 geometryCoatTangentMatrix;vec2 vGeometryOpacityInfos;mat4 geometryOpacityMatrix;vec2 vGeometryThicknessInfos;mat4 geometryThicknessMatrix;vec2 vEmissionColorInfos;mat4 emissionColorMatrix;vec2 vThinFilmWeightInfos;mat4 thinFilmWeightMatrix;vec2 vThinFilmThicknessInfos;mat4 thinFilmThicknessMatrix;vec2 vAmbientOcclusionInfos;mat4 ambientOcclusionMatrix; #define ADDITIONAL_UBO_DECLARATION }; #include #include -`;E.IncludesShadersStore[qF]||(E.IncludesShadersStore[qF]=yX)});var QF,DX,JF=A(()=>{N();QF="openpbrNormalMapVertexDeclaration",DX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) +`;E.IncludesShadersStore[rw]||(E.IncludesShadersStore[rw]=jX)});var nw,ZX,sw=A(()=>{N();nw="openpbrNormalMapVertexDeclaration",ZX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) #if defined(TANGENT) && defined(NORMAL) varying mat3 vTBN; #endif #endif -`;E.IncludesShadersStore[QF]||(E.IncludesShadersStore[QF]=DX)});var $F,LX,ew=A(()=>{N();$F="openpbrNormalMapVertex",LX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) +`;E.IncludesShadersStore[nw]||(E.IncludesShadersStore[nw]=ZX)});var aw,qX,ow=A(()=>{N();aw="openpbrNormalMapVertex",qX=`#if defined(GEOMETRY_NORMAL) || defined(PARALLAX) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) #if defined(TANGENT) && defined(NORMAL) vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal); #endif #endif -`;E.IncludesShadersStore[$F]||(E.IncludesShadersStore[$F]=LX)});var iw={};De(iw,{openpbrVertexShader:()=>PX});var oS,tw,PX,rw=A(()=>{N();ZF();aS();qu();cc();Gr();_c();Fs();ws();Na();Qu();Ju();gc();JF();Bs();Pf();$u();em();Ga();ka();Oo();Wa();Ha();Us();Vs();Gs();tm();im();rm();ew();ks();Of();sm();Nf();am();oS="openpbrVertexShader",tw=`#define OPENPBR_VERTEX_SHADER +`;E.IncludesShadersStore[aw]||(E.IncludesShadersStore[aw]=qX)});var cw={};De(cw,{openpbrVertexShader:()=>QX});var fS,lw,QX,fw=A(()=>{N();iw();cS();Qu();cc();Wr();_c();Fs();ws();Na();Ju();$u();gc();sw();Bs();Pf();em();tm();Ga();ka();No();Wa();Ha();Us();Vs();Gs();im();rm();nm();ow();ks();Of();am();Nf();om();fS="openpbrVertexShader",lw=`#define OPENPBR_VERTEX_SHADER #define CUSTOM_VERTEX_EXTENSION precision highp float; #include<__decl__openpbrVertex> @@ -11322,7 +11322,7 @@ gl_PointSize=pointSize; #include #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStore[oS]||(E.ShadersStore[oS]=tw);PX={name:oS,shader:tw}});var nw,OX,sw=A(()=>{N();bT();om();nw="openpbrFragmentDeclaration",OX=`uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vTransmissionWeight;uniform vec3 vTransmissionColor;uniform float vTransmissionDepth;uniform vec3 vTransmissionScatter;uniform float vTransmissionScatterAnisotropy;uniform float vTransmissionDispersionScale;uniform float vTransmissionDispersionAbbeNumber;uniform float vSubsurfaceWeight;uniform vec3 vSubsurfaceColor;uniform float vSubsurfaceRadius;uniform vec3 vSubsurfaceRadiusScale;uniform float vSubsurfaceScatterAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform float vFuzzWeight;uniform vec3 vFuzzColor;uniform float vFuzzRoughness;uniform vec2 vGeometryCoatTangent;uniform float vGeometryThickness;uniform vec3 vEmissionColor;uniform float vThinFilmWeight;uniform vec2 vThinFilmThickness;uniform float vThinFilmIor;uniform float vGeometryThinWalled;uniform vec4 vLightingIntensity;uniform float visibility;uniform vec2 renderTargetSize; +`;E.ShadersStore[fS]||(E.ShadersStore[fS]=lw);QX={name:fS,shader:lw}});var dw,JX,hw=A(()=>{N();DT();lm();dw="openpbrFragmentDeclaration",JX=`uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vTransmissionWeight;uniform vec3 vTransmissionColor;uniform float vTransmissionDepth;uniform vec3 vTransmissionScatter;uniform float vTransmissionScatterAnisotropy;uniform float vTransmissionDispersionScale;uniform float vTransmissionDispersionAbbeNumber;uniform float vSubsurfaceWeight;uniform vec3 vSubsurfaceColor;uniform float vSubsurfaceRadius;uniform vec3 vSubsurfaceRadiusScale;uniform float vSubsurfaceScatterAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform float vFuzzWeight;uniform vec3 vFuzzColor;uniform float vFuzzRoughness;uniform vec2 vGeometryCoatTangent;uniform float vGeometryThickness;uniform vec3 vEmissionColor;uniform float vThinFilmWeight;uniform vec2 vThinFilmThickness;uniform float vThinFilmIor;uniform float vGeometryThinWalled;uniform vec4 vLightingIntensity;uniform float visibility;uniform vec2 renderTargetSize; #ifdef BASE_COLOR uniform vec2 vBaseColorInfos; #endif @@ -11471,7 +11471,7 @@ uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;unifo uniform mat4 backgroundRefractionMatrix;uniform vec3 vBackgroundRefractionInfos; #endif #define ADDITIONAL_FRAGMENT_DECLARATION -`;E.IncludesShadersStore[nw]||(E.IncludesShadersStore[nw]=OX)});var aw,NX,lS=A(()=>{N();cc();aw="pbrFragmentExtraDeclaration",NX=`varying vec3 vPositionW; +`;E.IncludesShadersStore[dw]||(E.IncludesShadersStore[dw]=JX)});var uw,$X,dS=A(()=>{N();cc();uw="pbrFragmentExtraDeclaration",$X=`varying vec3 vPositionW; #if DEBUGMODE>0 varying vec4 vClipSpacePosition; #endif @@ -11488,7 +11488,7 @@ varying vec4 vColor; #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 varying float vViewDepth; #endif -`;E.IncludesShadersStore[aw]||(E.IncludesShadersStore[aw]=NX)});var ow,FX,lw=A(()=>{N();No();Hm();ow="openpbrFragmentSamplersDeclaration",FX=`#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor) +`;E.IncludesShadersStore[uw]||(E.IncludesShadersStore[uw]=$X)});var mw,e5,pw=A(()=>{N();Fo();zm();mw="openpbrFragmentSamplersDeclaration",e5=`#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor) #include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight) #include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness) #include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness) @@ -11540,15 +11540,15 @@ uniform sampler2D blueNoiseSampler; #ifdef IBL_CDF_FILTERING uniform sampler2D icdfSampler; #endif -`;E.IncludesShadersStore[ow]||(E.IncludesShadersStore[ow]=FX)});var cw,wX,cS=A(()=>{N();cw="subSurfaceScatteringFunctions",wX=`bool testLightingForSSS(float diffusionProfile) -{return diffusionProfile<1.;}`;E.IncludesShadersStore[cw]||(E.IncludesShadersStore[cw]=wX)});var fw,BX,fS=A(()=>{N();fw="importanceSampling",BX=`vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} +`;E.IncludesShadersStore[mw]||(E.IncludesShadersStore[mw]=e5)});var _w,t5,hS=A(()=>{N();_w="subSurfaceScatteringFunctions",t5=`bool testLightingForSSS(float diffusionProfile) +{return diffusionProfile<1.;}`;E.IncludesShadersStore[_w]||(E.IncludesShadersStore[_w]=t5)});var gw,i5,uS=A(()=>{N();gw="importanceSampling",i5=`vec3 hemisphereCosSample(vec2 u) {float phi=2.*PI*u.x;float cosTheta2=1.-u.y;float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {float phi=2.*PI*u.x;float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));float cosTheta=sqrt(cosTheta2);float sinTheta=sqrt(1.-cosTheta2);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);} vec3 hemisphereImportanceSampleDggxAnisotropic(vec2 Xi,float alphaTangent,float alphaBitangent) {alphaTangent=max(alphaTangent,0.0001);alphaBitangent=max(alphaBitangent,0.0001);float phi=atan(alphaBitangent/alphaTangent*tan(2.0*3.14159265*Xi.x));if (Xi.x>0.5) phi+=3.14159265; float cosPhi=cos(phi);float sinPhi=sin(phi);float alpha2=(cosPhi*cosPhi)/(alphaTangent*alphaTangent) + (sinPhi*sinPhi)/(alphaBitangent*alphaBitangent);float tanTheta2=Xi.y/(1.0-Xi.y)/alpha2;float cosTheta=1.0/sqrt(1.0+tanTheta2);float sinTheta=sqrt(max(0.0,1.0-cosTheta*cosTheta));return vec3(sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);} vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) { -float phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;E.IncludesShadersStore[fw]||(E.IncludesShadersStore[fw]=BX)});var dw,UX,dS=A(()=>{N();dw="pbrHelperFunctions",UX=`#define MINIMUMVARIANCE 0.0005 +float phi=2.*PI*u.x;float sinTheta=pow(u.y,a/(2.*a+1.));float cosTheta=sqrt(1.-sinTheta*sinTheta);return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;E.IncludesShadersStore[gw]||(E.IncludesShadersStore[gw]=i5)});var Ew,r5,mS=A(()=>{N();Ew="pbrHelperFunctions",r5=`#define MINIMUMVARIANCE 0.0005 float convertRoughnessToAverageSlope(float roughness) {return square(roughness)+MINIMUMVARIANCE;} float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;} @@ -11583,7 +11583,7 @@ clearCoatIntensity);return clearCoatAbsorption;} float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor) {const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;float reflectivityLuminance=getLuminance(reflectivityColor);float reflectivityLuma=sqrt(reflectivityLuminance);microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return microSurface;} #endif -`;E.IncludesShadersStore[dw]||(E.IncludesShadersStore[dw]=UX)});var hw,VX,hS=A(()=>{N();vv();hw="pbrDirectLightingSetupFunctions",VX=`struct preLightingInfo +`;E.IncludesShadersStore[Ew]||(E.IncludesShadersStore[Ew]=r5)});var vw,n5,pS=A(()=>{N();Av();vw="pbrDirectLightingSetupFunctions",n5=`struct preLightingInfo {vec3 lightOffset;float lightDistanceSquared;float lightDistance;float attenuation;vec3 L;vec3 H;float NdotV;float NdotLUnclamped;float NdotL;float VdotH;float LdotV;float roughness;float diffuseRoughness;vec3 surfaceAlbedo; #ifdef IRIDESCENCE float iridescenceIntensity; @@ -11616,7 +11616,7 @@ result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular; #endif result.areaLightDiffuse=data.Diffuse;result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} #endif -`;E.IncludesShadersStore[hw]||(E.IncludesShadersStore[hw]=VX)});var uw,GX,uS=A(()=>{N();uw="pbrDirectLightingFalloffFunctions",GX=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range) +`;E.IncludesShadersStore[vw]||(E.IncludesShadersStore[vw]=n5)});var Tw,s5,_S=A(()=>{N();Tw="pbrDirectLightingFalloffFunctions",s5=`float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range) {return max(0.,1.0-length(lightOffset)/range);} float computeDistanceLightFalloff_Physical(float lightDistanceSquared) {return 1.0/maxEps(lightDistanceSquared);} @@ -11652,7 +11652,7 @@ return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenter #else return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); #endif -}`;E.IncludesShadersStore[uw]||(E.IncludesShadersStore[uw]=GX)});var mw,kX,mS=A(()=>{N();mw="hdrFilteringFunctions",kX=`#if NUM_SAMPLES +}`;E.IncludesShadersStore[Tw]||(E.IncludesShadersStore[Tw]=s5)});var Sw,a5,gS=A(()=>{N();Sw="hdrFilteringFunctions",a5=`#if NUM_SAMPLES #if NUM_SAMPLES>0 #if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) float radicalInverse_VdC(uint bits) @@ -11797,7 +11797,7 @@ result=result/weight;return result;} #endif #endif #endif -`;E.IncludesShadersStore[mw]||(E.IncludesShadersStore[mw]=kX)});var pw,WX,pS=A(()=>{N();pw="pbrDirectLightingFunctions",WX=`#define CLEARCOATREFLECTANCE90 1.0 +`;E.IncludesShadersStore[Sw]||(E.IncludesShadersStore[Sw]=a5)});var Aw,o5,ES=A(()=>{N();Aw="pbrDirectLightingFunctions",o5=`#define CLEARCOATREFLECTANCE90 1.0 struct lightingInfo {vec3 diffuse; #ifdef SS_TRANSLUCENCY @@ -11903,7 +11903,7 @@ float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG); float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */ float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;} #endif -`;E.IncludesShadersStore[pw]||(E.IncludesShadersStore[pw]=WX)});var _w,HX,gw=A(()=>{N();_w="openpbrNormalMapFragmentMainFunctions",HX=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL) +`;E.IncludesShadersStore[Aw]||(E.IncludesShadersStore[Aw]=o5)});var Rw,l5,Iw=A(()=>{N();Rw="openpbrNormalMapFragmentMainFunctions",l5=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL) #if defined(TANGENT) && defined(NORMAL) varying mat3 vTBN; #endif @@ -11964,7 +11964,7 @@ vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale) mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams) {vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);} #endif -`;E.IncludesShadersStore[_w]||(E.IncludesShadersStore[_w]=HX)});var Ew,zX,vw=A(()=>{N();No();Ew="openpbrNormalMapFragmentFunctions",zX=`#if defined(GEOMETRY_NORMAL) +`;E.IncludesShadersStore[Rw]||(E.IncludesShadersStore[Rw]=l5)});var xw,c5,Cw=A(()=>{N();Fo();xw="openpbrNormalMapFragmentFunctions",c5=`#if defined(GEOMETRY_NORMAL) #include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal) #endif #if defined(GEOMETRY_COAT_NORMAL) @@ -11997,7 +11997,7 @@ return -texCoordOffset; #endif } #endif -`;E.IncludesShadersStore[Ew]||(E.IncludesShadersStore[Ew]=zX)});var Tw,XX,Sw=A(()=>{N();Tw="openpbrConductorReflectance",XX=`#define pbr_inline +`;E.IncludesShadersStore[xw]||(E.IncludesShadersStore[xw]=c5)});var bw,f5,Mw=A(()=>{N();bw="openpbrConductorReflectance",f5=`#define pbr_inline ReflectanceParams conductorReflectance(in vec3 baseColor,in vec3 specularColor,in float specularWeight) {ReflectanceParams outParams; #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) @@ -12005,9 +12005,9 @@ outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor* #else outParams.coloredF0=baseColor;outParams.coloredF90=vec3(1.0); #endif -outParams.F0=1.0;outParams.F90=1.0;return outParams;}`;E.IncludesShadersStore[Tw]||(E.IncludesShadersStore[Tw]=XX)});var Aw,YX,Rw=A(()=>{N();Aw="openpbrAmbientOcclusionFunctions",YX=`float compute_specular_occlusion(const float n_dot_v,const float metallic,const float ambient_occlusion,const float roughness) +outParams.F0=1.0;outParams.F90=1.0;return outParams;}`;E.IncludesShadersStore[bw]||(E.IncludesShadersStore[bw]=f5)});var yw,d5,Dw=A(()=>{N();yw="openpbrAmbientOcclusionFunctions",d5=`float compute_specular_occlusion(const float n_dot_v,const float metallic,const float ambient_occlusion,const float roughness) {float specular_occlusion=saturate(pow(n_dot_v+ambient_occlusion,exp2(-16.0*roughness-1.0))-1.0+ambient_occlusion);return mix(specular_occlusion,1.0,metallic*square(1.0-roughness));} -`;E.IncludesShadersStore[Aw]||(E.IncludesShadersStore[Aw]=YX)});var Iw,KX,xw=A(()=>{N();Iw="openpbrVolumeFunctions",KX=`struct OpenPBRHomogeneousVolume {vec3 extinction_coeff; +`;E.IncludesShadersStore[yw]||(E.IncludesShadersStore[yw]=d5)});var Lw,h5,Pw=A(()=>{N();Lw="openpbrVolumeFunctions",h5=`struct OpenPBRHomogeneousVolume {vec3 extinction_coeff; vec3 ss_albedo; vec3 multi_scatter_color; vec3 absorption_coeff; @@ -12063,7 +12063,7 @@ float filter_samples_scale=samples_scale(pixels_to_projective(overscan_size_in_p {vec3 weights=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d.rgb);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}} return vec3(weight_sum.r<1e-5f ? unconvolved_irradiance.r : irradiance_sum.r/weight_sum.r, weight_sum.g<1e-5f ? unconvolved_irradiance.g : irradiance_sum.g/weight_sum.g, -weight_sum.b<1e-5f ? unconvolved_irradiance.b : irradiance_sum.b/weight_sum.b);}`;E.IncludesShadersStore[Iw]||(E.IncludesShadersStore[Iw]=KX)});var Cw,jX,_S=A(()=>{N();Cw="pbrBlockNormalGeometric",jX=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); +weight_sum.b<1e-5f ? unconvolved_irradiance.b : irradiance_sum.b/weight_sum.b);}`;E.IncludesShadersStore[Lw]||(E.IncludesShadersStore[Lw]=h5)});var Ow,u5,vS=A(()=>{N();Ow="pbrBlockNormalGeometric",u5=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); #ifdef NORMAL vec3 normalW=normalize(vNormalW); #else @@ -12073,7 +12073,7 @@ vec3 geometricNormalW=normalW; #if defined(TWOSIDEDLIGHTING) && defined(NORMAL) geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW; #endif -`;E.IncludesShadersStore[Cw]||(E.IncludesShadersStore[Cw]=jX)});var bw,ZX,Mw=A(()=>{N();bw="openpbrNormalMapFragment",ZX=`vec2 uvOffset=vec2(0.0,0.0); +`;E.IncludesShadersStore[Ow]||(E.IncludesShadersStore[Ow]=u5)});var Nw,m5,Fw=A(()=>{N();Nw="openpbrNormalMapFragment",m5=`vec2 uvOffset=vec2(0.0,0.0); #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL) #ifdef NORMALXYSCALE float normalScale=1.0; @@ -12128,7 +12128,7 @@ normalW=perturbNormalBase(TBN,blendedNormal,vGeometryNormalInfos.y); #elif defined(DETAIL) detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); #endif -`;E.IncludesShadersStore[bw]||(E.IncludesShadersStore[bw]=ZX)});var yw,qX,Dw=A(()=>{N();yw="openpbrBlockNormalFinal",qX=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +`;E.IncludesShadersStore[Nw]||(E.IncludesShadersStore[Nw]=m5)});var ww,p5,Bw=A(()=>{N();ww="openpbrBlockNormalFinal",p5=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; #if defined(TWOSIDEDLIGHTING) faceNormal=gl_FrontFacing ? faceNormal : -faceNormal; @@ -12142,7 +12142,7 @@ normalW=gl_FrontFacing ? -normalW : normalW;coatNormalW=gl_FrontFacing ? -coatNo normalW=gl_FrontFacing ? normalW : -normalW;coatNormalW=gl_FrontFacing ? coatNormalW : -coatNormalW; #endif #endif -`;E.IncludesShadersStore[yw]||(E.IncludesShadersStore[yw]=qX)});var Lw,QX,Pw=A(()=>{N();Lw="openpbrBaseLayerData",QX=`vec3 base_color=vec3(0.8);float base_metalness=0.0;float base_diffuse_roughness=0.0;float specular_weight=1.0;float specular_roughness=0.3;vec3 specular_color=vec3(1.0);float specular_roughness_anisotropy=0.0;float specular_ior=1.5;float alpha=1.0;vec2 geometry_tangent=vec2(1.0,0.0);float geometry_thickness=0.0; +`;E.IncludesShadersStore[ww]||(E.IncludesShadersStore[ww]=p5)});var Uw,_5,Vw=A(()=>{N();Uw="openpbrBaseLayerData",_5=`vec3 base_color=vec3(0.8);float base_metalness=0.0;float base_diffuse_roughness=0.0;float specular_weight=1.0;float specular_roughness=0.3;vec3 specular_color=vec3(1.0);float specular_roughness_anisotropy=0.0;float specular_ior=1.5;float alpha=1.0;vec2 geometry_tangent=vec2(1.0,0.0);float geometry_thickness=0.0; #ifdef BASE_WEIGHT vec4 baseWeightFromTexture=texture2D(baseWeightSampler,vBaseWeightUV+uvOffset); #endif @@ -12268,7 +12268,7 @@ float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0., #ifdef USE_GLTF_STYLE_ANISOTROPY float baseAlpha=specular_roughness*specular_roughness;float roughnessT=mix(baseAlpha,1.0,specular_roughness_anisotropy*specular_roughness_anisotropy);float roughnessB=baseAlpha;specular_roughness_anisotropy=1.0-roughnessB/max(roughnessT,0.00001);specular_roughness=sqrt(roughnessT/sqrt(2.0/(1.0+(1.0-specular_roughness_anisotropy)*(1.0-specular_roughness_anisotropy)))); #endif -`;E.IncludesShadersStore[Lw]||(E.IncludesShadersStore[Lw]=QX)});var Ow,JX,Nw=A(()=>{N();Ow="openpbrCoatLayerData",JX=`float coat_weight=0.0;vec3 coat_color=vec3(1.0);float coat_roughness=0.0;float coat_roughness_anisotropy=0.0;float coat_ior=1.6;float coat_darkening=1.0;vec2 geometry_coat_tangent=vec2(1.0,0.0); +`;E.IncludesShadersStore[Uw]||(E.IncludesShadersStore[Uw]=_5)});var Gw,g5,kw=A(()=>{N();Gw="openpbrCoatLayerData",g5=`float coat_weight=0.0;vec3 coat_color=vec3(1.0);float coat_roughness=0.0;float coat_roughness_anisotropy=0.0;float coat_ior=1.6;float coat_darkening=1.0;vec2 geometry_coat_tangent=vec2(1.0,0.0); #ifdef COAT_WEIGHT vec4 coatWeightFromTexture=texture2D(coatWeightSampler,vCoatWeightUV+uvOffset); #endif @@ -12320,7 +12320,7 @@ coat_darkening*=coatDarkeningFromTexture.r; #ifdef USE_GLTF_STYLE_ANISOTROPY float coatAlpha=coat_roughness*coat_roughness;float coatRoughnessT=mix(coatAlpha,1.0,coat_roughness_anisotropy*coat_roughness_anisotropy);float coatRoughnessB=coatAlpha;coat_roughness_anisotropy=1.0-coatRoughnessB/max(coatRoughnessT,0.00001);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0/(1.0+(1.0-coat_roughness_anisotropy)*(1.0-coat_roughness_anisotropy)))); #endif -`;E.IncludesShadersStore[Ow]||(E.IncludesShadersStore[Ow]=JX)});var Fw,$X,ww=A(()=>{N();Fw="openpbrThinFilmLayerData",$X=`#ifdef THIN_FILM +`;E.IncludesShadersStore[Gw]||(E.IncludesShadersStore[Gw]=g5)});var Ww,E5,Hw=A(()=>{N();Ww="openpbrThinFilmLayerData",E5=`#ifdef THIN_FILM float thin_film_weight=vThinFilmWeight;float thin_film_thickness=vThinFilmThickness.r*1000.0; float thin_film_ior=vThinFilmIor; #ifdef THIN_FILM_WEIGHT @@ -12337,7 +12337,7 @@ thin_film_thickness*=thinFilmThicknessFromTexture; #endif float thin_film_ior_scale=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f); #endif -`;E.IncludesShadersStore[Fw]||(E.IncludesShadersStore[Fw]=$X)});var Bw,e5,Uw=A(()=>{N();Bw="openpbrFuzzLayerData",e5=`float fuzz_weight=0.0;vec3 fuzz_color=vec3(1.0);float fuzz_roughness=0.0; +`;E.IncludesShadersStore[Ww]||(E.IncludesShadersStore[Ww]=E5)});var zw,v5,Xw=A(()=>{N();zw="openpbrFuzzLayerData",v5=`float fuzz_weight=0.0;vec3 fuzz_color=vec3(1.0);float fuzz_roughness=0.0; #ifdef FUZZ #ifdef FUZZ_WEIGHT vec4 fuzzWeightFromTexture=texture2D(fuzzWeightSampler,vFuzzWeightUV+uvOffset); @@ -12366,11 +12366,11 @@ fuzz_roughness*=fuzzRoughnessFromTexture.a; fuzz_roughness*=fuzzRoughnessFromTexture.r; #endif #endif -`;E.IncludesShadersStore[Bw]||(E.IncludesShadersStore[Bw]=e5)});var Vw,t5,Gw=A(()=>{N();Vw="openpbrAmbientOcclusionData",t5=`vec3 ambient_occlusion=vec3(1.0);float specular_ambient_occlusion=1.0;float coat_specular_ambient_occlusion=1.0; +`;E.IncludesShadersStore[zw]||(E.IncludesShadersStore[zw]=v5)});var Yw,T5,Kw=A(()=>{N();Yw="openpbrAmbientOcclusionData",T5=`vec3 ambient_occlusion=vec3(1.0);float specular_ambient_occlusion=1.0;float coat_specular_ambient_occlusion=1.0; #ifdef AMBIENT_OCCLUSION vec3 ambientOcclusionFromTexture=texture2D(ambientOcclusionSampler,vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3(ambientOcclusionFromTexture.r*vAmbientOcclusionInfos.y+(1.0-vAmbientOcclusionInfos.y)); #endif -`;E.IncludesShadersStore[Vw]||(E.IncludesShadersStore[Vw]=t5)});var kw,i5,Ww=A(()=>{N();kw="openpbrBackgroundTransmission",i5=`vec4 slab_translucent_background=vec4(0.,0.,0.,1.); +`;E.IncludesShadersStore[Yw]||(E.IncludesShadersStore[Yw]=T5)});var jw,S5,Zw=A(()=>{N();jw="openpbrBackgroundTransmission",S5=`vec4 slab_translucent_background=vec4(0.,0.,0.,1.); #ifdef REFRACTED_BACKGROUND {float refractionLOD=min(transmission_roughness,0.7)*vBackgroundRefractionInfos.x;float lodTexelSize=pow(2.0,refractionLOD-vBackgroundRefractionInfos.x); #ifdef DISPERSION @@ -12398,7 +12398,7 @@ vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background=texture2DLodE #endif } #endif -`;E.IncludesShadersStore[kw]||(E.IncludesShadersStore[kw]=i5)});var Hw,r5,zw=A(()=>{N();Hw="openpbrEnvironmentLighting",r5=`#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND) +`;E.IncludesShadersStore[jw]||(E.IncludesShadersStore[jw]=S5)});var qw,A5,Qw=A(()=>{N();qw="openpbrEnvironmentLighting",A5=`#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND) vec3 coatAbsorption=vec3(1.0);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior);float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;vec3 colored_transmission=pow(coat_color,vec3(coatPathLength));coatAbsorption=mix(vec3(1.0),colored_transmission*darkened_transmission,coat_weight);} #endif #ifdef REFLECTION @@ -12680,7 +12680,7 @@ slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*tran #endif vec3 material_dielectric_base_ibl=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(baseGeoInfo.NdotV);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,black,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=material_coated_base_ibl; #endif -`;E.IncludesShadersStore[Hw]||(E.IncludesShadersStore[Hw]=r5)});var Xw,n5,Yw=A(()=>{N();Xw="openpbrDirectLightingInit",n5=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[qw]||(E.IncludesShadersStore[qw]=A5)});var Jw,R5,$w=A(()=>{N();Jw="openpbrDirectLightingInit",R5=`#ifdef LIGHT{X} preLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.; #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) #else @@ -12751,7 +12751,7 @@ preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb; #endif #endif -`;E.IncludesShadersStore[Xw]||(E.IncludesShadersStore[Xw]=n5)});var Kw,s5,jw=A(()=>{N();Kw="openpbrDirectLighting",s5=`#ifdef LIGHT{X} +`;E.IncludesShadersStore[Jw]||(E.IncludesShadersStore[Jw]=R5)});var e1,I5,t1=A(()=>{N();e1="openpbrDirectLighting",I5=`#ifdef LIGHT{X} {vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 specularColoredFresnel=vec3(0.,0.,0.);vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);float fuzzFresnel=0.0; #ifdef HEMILIGHT{X} slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround); @@ -12906,7 +12906,7 @@ total_direct_diffuse+=slab_diffuse; #endif vec3 material_dielectric_base=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);vec3 material_dielectric_gloss=material_dielectric_base*(1.0-specularFresnel)+slab_glossy*specularColoredFresnel;vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3(1.0),fuzz_color);} #endif -`;E.IncludesShadersStore[Kw]||(E.IncludesShadersStore[Kw]=s5)});var Zw,a5,gS=A(()=>{N();Zw="pbrBlockImageProcessing",a5=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) +`;E.IncludesShadersStore[e1]||(E.IncludesShadersStore[e1]=I5)});var i1,x5,TS=A(()=>{N();i1="pbrBlockImageProcessing",x5=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) #if !defined(SKIPFINALCOLORCLAMP) finalColor.rgb=clamp(finalColor.rgb,0.,30.0); #endif @@ -12917,7 +12917,7 @@ finalColor.a*=visibility; #ifdef PREMULTIPLYALPHA finalColor.rgb*=finalColor.a; #endif -`;E.IncludesShadersStore[Zw]||(E.IncludesShadersStore[Zw]=a5)});var qw,o5,Qw=A(()=>{N();qw="openpbrBlockPrePass",o5=`#if SCENE_MRT_COUNT>0 +`;E.IncludesShadersStore[i1]||(E.IncludesShadersStore[i1]=x5)});var r1,C5,n1=A(()=>{N();r1="openpbrBlockPrePass",C5=`#if SCENE_MRT_COUNT>0 float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0; #ifdef PREPASS_POSITION gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo); @@ -12983,7 +12983,7 @@ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInf #endif #endif #endif -`;E.IncludesShadersStore[qw]||(E.IncludesShadersStore[qw]=o5)});var Jw,l5,ES=A(()=>{N();Jw="pbrDebug",l5=`#if DEBUGMODE>0 +`;E.IncludesShadersStore[r1]||(E.IncludesShadersStore[r1]=C5)});var s1,b5,SS=A(()=>{N();s1="pbrDebug",b5=`#if DEBUGMODE>0 if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) { #if DEBUGMODE==1 gl_FragColor.rgb=vPositionW.rgb; @@ -13167,7 +13167,7 @@ return; #endif } #endif -`;E.IncludesShadersStore[Jw]||(E.IncludesShadersStore[Jw]=l5)});var e1={};De(e1,{openpbrPixelShader:()=>c5});var vS,$w,c5,t1=A(()=>{N();lm();cm();sw();aS();lS();fm();dm();lw();um();Ws();Oo();Ff();Gr();cS();fS();dS();mm();hm();gc();hS();uS();_c();mS();pS();zm();gw();vw();Xf();MT();Sw();Rw();yT();DT();xw();Hs();_S();Mw();Dw();Pw();PT();LT();Nw();ww();Uw();Gw();Em();Ww();zw();Yw();jw();vm();wf();gS();Qw();Tm();ES();vS="openpbrPixelShader",$w=`#define OPENPBR_FRAGMENT_SHADER +`;E.IncludesShadersStore[s1]||(E.IncludesShadersStore[s1]=b5)});var o1={};De(o1,{openpbrPixelShader:()=>M5});var AS,a1,M5,l1=A(()=>{N();cm();fm();hw();cS();dS();dm();hm();pw();mm();Ws();No();Ff();Wr();hS();uS();mS();pm();um();gc();pS();_S();_c();gS();ES();Xm();Iw();Cw();Xf();LT();Mw();Dw();PT();OT();Pw();Hs();vS();Fw();Bw();Vw();FT();NT();kw();Hw();Xw();Kw();vm();Zw();Qw();$w();t1();Tm();wf();TS();n1();Sm();SS();AS="openpbrPixelShader",a1=`#define OPENPBR_FRAGMENT_SHADER #define CUSTOM_FRAGMENT_EXTENSION #if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) #extension GL_OES_standard_derivatives : enable @@ -13402,11 +13402,11 @@ if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaM #include #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStore[vS]||(E.ShadersStore[vS]=$w);c5={name:vS,shader:$w}});var i1={};De(i1,{OpenPBRMaterial:()=>pe,OpenPBRMaterialDefines:()=>td});var Tc,Km,lt,mt,TS,SS,td,AS,pe,r1=A(()=>{Qe();qe();km();et();sf();oi();Lt();Ni();Kt();zr();Tu();Da();kn();Cf();Oi();yt();Su();vu();Wr();ze();Au();Ru();nN();ve();Iu();xf();on();Tt();WN();Tc={effect:null,subMesh:null},Km=class n{populateVectorFromLinkedProperties(e){let t=e.dimension[0];for(let i in this.linkedProperties){let r=this.linkedProperties[i],s=r.numComponents;if(tt-s){s==1?W.Error(`Float property ${r.name} has an offset that is too large.`):W.Error(`Vector${s} property ${r.name} won't fit in Vector${t} or has an offset that is too large.`);return}typeof r.value=="number"?n._tmpArray[r.targetUniformComponentOffset]=r.value:r.value.toArray(n._tmpArray,r.targetUniformComponentOffset)}e.fromArray(n._tmpArray)}constructor(e,t){this.linkedProperties={},this.firstLinkedKey="",this.name=e,this.numComponents=t}};Km._tmpArray=[0,0,0,0];lt=class{constructor(e,t,i,r,s=0,a){this.targetUniformComponentNum=4,this.targetUniformComponentOffset=0,this.name=e,this.targetUniformName=i,this.defaultValue=t,this.value=t,this.targetUniformComponentNum=r,this.targetUniformComponentOffset=s,this.requiredDefine=a}get numComponents(){return typeof this.defaultValue=="number"?1:this.defaultValue.dimension[0]}},mt=class{get samplerName(){return this.samplerPrefix+"Sampler"}get samplerInfoName(){return"v"+this.samplerPrefix.charAt(0).toUpperCase()+this.samplerPrefix.slice(1)+"Infos"}get samplerMatrixName(){return this.samplerPrefix+"Matrix"}constructor(e,t,i){this.value=null,this.samplerPrefix="",this.textureDefine="",this.name=e,this.samplerPrefix=t,this.textureDefine=i}},TS=class extends ac(sc(Zt)){},SS=class extends rN(TS){},td=class extends rc(SS){constructor(e){super(e),this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.LIGHTCOUNT=0,this.VERTEXCOLOR=!1,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.VERTEXALPHA=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHA_FROM_BASE_COLOR_TEXTURE=!1,this.ALPHATESTVALUE="0.5",this.PREMULTIPLYALPHA=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.LODBASEDMICROSFURACE=!0,this.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN=!1,this.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.SPECULAR_WEIGHT_IN_ALPHA=!1,this.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE=!1,this.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=!1,this.COAT_ROUGHNESS_FROM_GREEN_CHANNEL=!1,this.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=!1,this.USE_GLTF_STYLE_ANISOTROPY=!1,this.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE=!1,this.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA=!1,this.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL=!1,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.FUZZENVIRONMENTBRDF=!1,this.NORMAL=!1,this.TANGENT=!1,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.ANISOTROPIC=!1,this.ANISOTROPIC_OPENPBR=!0,this.ANISOTROPIC_BASE=!1,this.ANISOTROPIC_COAT=!1,this.FUZZ_IBL_SAMPLES=6,this.REFRACTION_HIGH_QUALITY_BLUR=!1,this.FUZZ=!1,this.THIN_FILM=!1,this.IRIDESCENCE=!1,this.DISPERSION=!1,this.SCATTERING=!1,this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING=!1,this.SSS_SAMPLE_COUNT=16,this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER=!1,this.TRANSMISSION_SLAB=!1,this.TRANSMISSION_SLAB_VOLUME=!1,this.SUBSURFACE_SLAB=!1,this.GEOMETRY_THIN_WALLED=!1,this.REFRACTED_BACKGROUND=!1,this.REFRACTED_LIGHTS=!1,this.REFRACTED_ENVIRONMENT=!1,this.REFRACTED_ENVIRONMENT_OPPOSITEZ=!1,this.REFRACTED_ENVIRONMENT_LOCAL_CUBE=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.MIRRORED=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.BRDF_V_HEIGHT_CORRELATED=!0,this.MS_BRDF_ENERGY_CONSERVATION=!0,this.SPHERICAL_HARMONICS=!0,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!0,this.MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0,this.LEGACY_SPECULAR_ENERGY_CONSERVATION=!1,this.BASE_DIFFUSE_MODEL=0,this.DIELECTRIC_SPECULAR_MODEL=1,this.CONDUCTOR_SPECULAR_MODEL=1,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.NORMALXYSCALE=!0}},AS=class extends oc(Xn){},pe=class n extends AS{get geometryTangentAngle(){return Math.atan2(this.geometryTangent.y,this.geometryTangent.x)}set geometryTangentAngle(e){this.geometryTangent=new _e(Math.cos(e),Math.sin(e))}get geometryCoatTangentAngle(){return Math.atan2(this.geometryCoatTangent.y,this.geometryCoatTangent.x)}set geometryCoatTangentAngle(e){this.geometryCoatTangent=new _e(Math.cos(e),Math.sin(e))}get sssQuality(){return this._sssQuality}set sssQuality(e){this._sssQuality!==e&&(this._sssQuality=e,this.markAsDirty(1))}get sssIrradianceTexture(){return this._sssIrradianceTexture}set sssIrradianceTexture(e){this._sssIrradianceTexture!==e&&(this._sssIrradianceTexture=e,this._markAllSubMeshesAsTexturesDirty())}get sssDepthTexture(){return this._sssDepthTexture}set sssDepthTexture(e){this._sssDepthTexture!==e&&(this._sssDepthTexture=e,this._markAllSubMeshesAsTexturesDirty())}get hasTransparency(){return this.subsurfaceWeight>0||this.transmissionWeight>0}get hasScattering(){return this.transmissionWeight>0&&this.transmissionDepth>0&&!this.transmissionScatter.equals(oe.BlackReadOnly)||this.subsurfaceWeight>0}get usePhysicalLightFalloff(){return this._lightFalloff===ae.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ae.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=ae.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===ae.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ae.LIGHTFALLOFF_GLTF:this._lightFalloff=ae.LIGHTFALLOFF_STANDARD)}get backgroundRefractionTexture(){return this._backgroundRefractionTexture}set backgroundRefractionTexture(e){this._backgroundRefractionTexture=e,this._markAllSubMeshesAsTexturesDirty()}get refractionHighQualityBlur(){return this._refractionHighQualityBlur}set refractionHighQualityBlur(e){this._refractionHighQualityBlur!==e&&(this._refractionHighQualityBlur=e,this.markAsDirty(1))}get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(1)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(1)}get fuzzSampleNumber(){return this._fuzzSampleNumber}set fuzzSampleNumber(e){this._fuzzSampleNumber=e,this.markAsDirty(1)}get canRenderToMRT(){return!0}constructor(e,t,i=!1){var s;super(e,t,void 0,i||n.ForceGLSL),this._baseWeight=new lt("base_weight",1,"vBaseWeight",1),this._baseWeightTexture=new mt("base_weight","baseWeight","BASE_WEIGHT"),this._baseColor=new lt("base_color",oe.White(),"vBaseColor",4),this._baseColorTexture=new mt("base_color","baseColor","BASE_COLOR"),this._baseDiffuseRoughness=new lt("base_diffuse_roughness",0,"vBaseDiffuseRoughness",1),this._baseDiffuseRoughnessTexture=new mt("base_diffuse_roughness","baseDiffuseRoughness","BASE_DIFFUSE_ROUGHNESS"),this._baseMetalness=new lt("base_metalness",0,"vReflectanceInfo",4,0),this._baseMetalnessTexture=new mt("base_metalness","baseMetalness","BASE_METALNESS"),this._specularWeight=new lt("specular_weight",1,"vReflectanceInfo",4,3),this._specularWeightTexture=new mt("specular_weight","specularWeight","SPECULAR_WEIGHT"),this._specularColor=new lt("specular_color",oe.White(),"vSpecularColor",4),this._specularColorTexture=new mt("specular_color","specularColor","SPECULAR_COLOR"),this._specularRoughness=new lt("specular_roughness",.3,"vReflectanceInfo",4,1),this._specularRoughnessTexture=new mt("specular_roughness","specularRoughness","SPECULAR_ROUGHNESS"),this._specularRoughnessAnisotropy=new lt("specular_roughness_anisotropy",0,"vSpecularAnisotropy",3,2),this._specularRoughnessAnisotropyTexture=new mt("specular_roughness_anisotropy","specularRoughnessAnisotropy","SPECULAR_ROUGHNESS_ANISOTROPY"),this._specularIor=new lt("specular_ior",1.5,"vReflectanceInfo",4,2),this._transmissionWeight=new lt("transmission_weight",0,"vTransmissionWeight",1),this._transmissionWeightTexture=new mt("transmission_weight","transmissionWeight","TRANSMISSION_WEIGHT"),this._transmissionColor=new lt("transmission_color",oe.White(),"vTransmissionColor",3,0),this._transmissionColorTexture=new mt("transmission_color","transmissionColor","TRANSMISSION_COLOR"),this._transmissionDepth=new lt("transmission_depth",0,"vTransmissionDepth",1,0),this._transmissionDepthTexture=new mt("transmission_depth","transmissionDepth","TRANSMISSION_DEPTH"),this._transmissionScatter=new lt("transmission_scatter",oe.Black(),"vTransmissionScatter",3,0),this._transmissionScatterTexture=new mt("transmission_scatter","transmissionScatter","TRANSMISSION_SCATTER"),this._transmissionScatterAnisotropy=new lt("transmission_scatter_anisotropy",0,"vTransmissionScatterAnisotropy",1,0),this._transmissionDispersionScale=new lt("transmission_dispersion_scale",0,"vTransmissionDispersionScale",1,0),this._transmissionDispersionScaleTexture=new mt("transmission_dispersion_scale","transmissionDispersionScale","TRANSMISSION_DISPERSION_SCALE"),this._transmissionDispersionAbbeNumber=new lt("transmission_dispersion_abbe_number",20,"vTransmissionDispersionAbbeNumber",1,0),this._subsurfaceWeight=new lt("subsurface_weight",0,"vSubsurfaceWeight",1,0,"SUBSURFACE_SLAB"),this._subsurfaceWeightTexture=new mt("subsurface_weight","subsurfaceWeight","SUBSURFACE_WEIGHT"),this._subsurfaceColor=new lt("subsurface_color",new oe(.8,.8,.8),"vSubsurfaceColor",3,0,"SUBSURFACE_SLAB"),this._subsurfaceColorTexture=new mt("subsurface_color","subsurfaceColor","SUBSURFACE_COLOR"),this._subsurfaceRadius=new lt("subsurface_radius",.1,"vSubsurfaceRadius",1,0,"SUBSURFACE_SLAB"),this._subsurfaceRadiusScale=new lt("subsurface_radius_scale",new oe(1,.5,.25),"vSubsurfaceRadiusScale",3,0,"SUBSURFACE_SLAB"),this._subsurfaceRadiusScaleTexture=new mt("subsurface_radius_scale","subsurfaceRadiusScale","SUBSURFACE_RADIUS_SCALE"),this._subsurfaceScatterAnisotropy=new lt("subsurface_scatter_anisotropy",0,"vSubsurfaceScatterAnisotropy",1,0,"SUBSURFACE_SLAB"),this._coatWeight=new lt("coat_weight",0,"vCoatWeight",1,0),this._coatWeightTexture=new mt("coat_weight","coatWeight","COAT_WEIGHT"),this._coatColor=new lt("coat_color",oe.White(),"vCoatColor",3,0),this._coatColorTexture=new mt("coat_color","coatColor","COAT_COLOR"),this._coatRoughness=new lt("coat_roughness",0,"vCoatRoughness",1,0),this._coatRoughnessTexture=new mt("coat_roughness","coatRoughness","COAT_ROUGHNESS"),this._coatRoughnessAnisotropy=new lt("coat_roughness_anisotropy",0,"vCoatRoughnessAnisotropy",1),this._coatRoughnessAnisotropyTexture=new mt("coat_roughness_anisotropy","coatRoughnessAnisotropy","COAT_ROUGHNESS_ANISOTROPY"),this._coatIor=new lt("coat_ior",1.5,"vCoatIor",1,0),this._coatDarkening=new lt("coat_darkening",1,"vCoatDarkening",1,0),this._coatDarkeningTexture=new mt("coat_darkening","coatDarkening","COAT_DARKENING"),this.useCoatRoughnessFromWeightTexture=!1,this._fuzzWeight=new lt("fuzz_weight",0,"vFuzzWeight",1,0),this._fuzzWeightTexture=new mt("fuzz_weight","fuzzWeight","FUZZ_WEIGHT"),this._fuzzColor=new lt("fuzz_color",oe.White(),"vFuzzColor",3,0),this._fuzzColorTexture=new mt("fuzz_color","fuzzColor","FUZZ_COLOR"),this._fuzzRoughness=new lt("fuzz_roughness",.5,"vFuzzRoughness",1,0),this._fuzzRoughnessTexture=new mt("fuzz_roughness","fuzzRoughness","FUZZ_ROUGHNESS"),this._geometryThinWalled=new lt("geometry_thin_walled",0,"vGeometryThinWalled",1,0),this._geometryNormalTexture=new mt("geometry_normal","geometryNormal","GEOMETRY_NORMAL"),this._geometryTangent=new lt("geometry_tangent",new _e(1,0),"vSpecularAnisotropy",3,0),this._geometryTangentTexture=new mt("geometry_tangent","geometryTangent","GEOMETRY_TANGENT"),this._geometryCoatNormalTexture=new mt("geometry_coat_normal","geometryCoatNormal","GEOMETRY_COAT_NORMAL"),this._geometryCoatTangent=new lt("geometry_coat_tangent",new _e(1,0),"vGeometryCoatTangent",2,0),this._geometryCoatTangentTexture=new mt("geometry_coat_tangent","geometryCoatTangent","GEOMETRY_COAT_TANGENT"),this._geometryOpacity=new lt("geometry_opacity",1,"vBaseColor",4,3),this._geometryOpacityTexture=new mt("geometry_opacity","geometryOpacity","GEOMETRY_OPACITY"),this._geometryThickness=new lt("geometry_thickness",0,"vGeometryThickness",1,0),this._geometryThicknessTexture=new mt("geometry_thickness","geometryThickness","GEOMETRY_THICKNESS"),this._emissionLuminance=new lt("emission_luminance",1,"vLightingIntensity",4,1),this._emissionColor=new lt("emission_color",oe.Black(),"vEmissionColor",3),this._emissionColorTexture=new mt("emission_color","emissionColor","EMISSION_COLOR"),this._thinFilmWeight=new lt("thin_film_weight",0,"vThinFilmWeight",1,0),this._thinFilmWeightTexture=new mt("thin_film_weight","thinFilmWeight","THIN_FILM_WEIGHT"),this._thinFilmThickness=new lt("thin_film_thickness",.5,"vThinFilmThickness",2,0),this._thinFilmThicknessMin=new lt("thin_film_thickness_min",0,"vThinFilmThickness",2,1),this._thinFilmThicknessTexture=new mt("thin_film_thickness","thinFilmThickness","THIN_FILM_THICKNESS"),this._thinFilmIor=new lt("thin_film_ior",1.4,"vThinFilmIor",1,0),this._ambientOcclusionTexture=new mt("ambient_occlusion","ambientOcclusion","AMBIENT_OCCLUSION"),this._sssQuality=n.SSS_QUALITY_MEDIUM,this._sssIrradianceTexture=null,this._sssDepthTexture=null,this._uniformsList={},this._uniformsArray=[],this._samplersList={},this._samplerDefines={},this.directIntensity=1,this.environmentIntensity=1,this.useSpecularWeightFromTextureAlpha=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._lightingInfos=new vt(this.directIntensity,1,this.environmentIntensity,1),this._radianceTexture=null,this._useSpecularWeightFromAlpha=!1,this._useSpecularWeightFromSpecularColorTexture=!1,this._useSpecularRoughnessAnisotropyFromTangentTexture=!1,this._useCoatRoughnessAnisotropyFromTangentTexture=!1,this._useCoatRoughnessFromGreenChannel=!1,this._useGltfStyleAnisotropy=!1,this._useFuzzRoughnessFromTextureAlpha=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromBaseColorTexture=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallicFromMetallicTextureBlue=!1,this._useThinFilmThicknessFromTextureGreen=!1,this._useGeometryThicknessFromGreenChannel=!1,this._lightFalloff=ae.LIGHTFALLOFF_PHYSICAL,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._environmentFuzzBRDFTexture=null,this._backgroundRefractionTexture=null,this._refractionHighQualityBlur=!0,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=8,this._fuzzSampleNumber=4,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._renderTargets=new Ct(16),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this._vertexPullingMetadata=null,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this._transparencyMode=ae.MATERIAL_OPAQUE,this.getScene()&&!((s=this.getScene())!=null&&s.getEngine().isWebGPU)&&this.getScene().getEngine().webGLVersion<2&&W.Error("OpenPBRMaterial: WebGL 2.0 or above is required for this material."),n._noiseTextures[this.getScene().uniqueId]||(n._noiseTextures[this.getScene().uniqueId]=new ne(re.GetAssetUrl("https://assets.babylonjs.com/core/blue_noise/blue_noise_rgb.png"),this.getScene(),!1,!0,1),this.getScene().onDisposeObservable.addOnce(()=>{var a;(a=n._noiseTextures[this.getScene().uniqueId])==null||a.dispose(),delete n._noiseTextures[this.getScene().uniqueId]})),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),ie.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget&&this._renderTargets.push(this._radianceTexture),ie.RefractionTextureEnabled&&this._backgroundRefractionTexture&&this._backgroundRefractionTexture.isRenderTarget&&this._renderTargets.push(this._backgroundRefractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=iN(this.getScene()),this._environmentFuzzBRDFTexture=xT(this.getScene()),this.prePassConfiguration=new cr,this._propertyList={};for(let a of Object.getOwnPropertyNames(this)){let o=this[a];o instanceof lt&&(this._propertyList[a]=o)}Object.keys(this._propertyList).forEach(a=>{let o=this._propertyList[a],l=this._uniformsList[o.targetUniformName];l?l.numComponents!==o.targetUniformComponentNum?W.Error(`Uniform ${o.targetUniformName} already exists of size ${l.numComponents}, but trying to set it to ${o.targetUniformComponentNum}.`):l.requiredDefine!==o.requiredDefine&&(l.requiredDefine=void 0):(l=new Km(o.targetUniformName,o.targetUniformComponentNum),l.requiredDefine=o.requiredDefine,this._uniformsList[o.targetUniformName]=l),l.firstLinkedKey===""&&(l.firstLinkedKey=o.name),l.linkedProperties[o.name]=o}),this._uniformsArray=Object.values(this._uniformsList),this._samplersList={};for(let a of Object.getOwnPropertyNames(this)){let o=this[a];o instanceof mt&&(this._samplersList[a]=o)}for(let a in this._samplersList){let l=this._samplersList[a].textureDefine;this._samplerDefines[l]={type:"boolean",default:!1},this._samplerDefines[l+"DIRECTUV"]={type:"number",default:0},this._samplerDefines[l+"_GAMMA"]={type:"boolean",default:!1}}this._baseWeight,this._baseWeightTexture,this._baseColor,this._baseColorTexture,this._baseDiffuseRoughness,this._baseDiffuseRoughnessTexture,this._baseMetalness,this._baseMetalnessTexture,this._specularWeight,this._specularWeightTexture,this._specularColor,this._specularColorTexture,this._specularRoughness,this._specularIor,this._specularRoughnessTexture,this._specularRoughnessAnisotropy,this._specularRoughnessAnisotropyTexture,this._transmissionWeight,this._transmissionWeightTexture,this._transmissionColor,this._transmissionColorTexture,this._transmissionDepth,this._transmissionDepthTexture,this._transmissionScatter,this._transmissionScatterTexture,this._transmissionScatterAnisotropy,this._transmissionDispersionScale,this._transmissionDispersionScaleTexture,this._transmissionDispersionAbbeNumber,this._subsurfaceWeight,this._subsurfaceWeightTexture,this._subsurfaceColor,this._subsurfaceColorTexture,this._subsurfaceRadius,this._subsurfaceRadiusScale,this._subsurfaceRadiusScaleTexture,this._subsurfaceScatterAnisotropy,this._coatWeight,this._coatWeightTexture,this._coatColor,this._coatColorTexture,this._coatRoughness,this._coatRoughnessTexture,this._coatRoughnessAnisotropy,this._coatRoughnessAnisotropyTexture,this._coatIor,this._coatDarkening,this._coatDarkeningTexture,this._fuzzWeight,this._fuzzWeightTexture,this._fuzzColor,this._fuzzColorTexture,this._fuzzRoughness,this._fuzzRoughnessTexture,this._geometryThinWalled,this._geometryNormalTexture,this._geometryTangent,this._geometryTangentTexture,this._geometryCoatNormalTexture,this._geometryCoatTangent,this._geometryCoatTangentTexture,this._geometryOpacity,this._geometryOpacityTexture,this._geometryThickness,this._geometryThicknessTexture,this._thinFilmWeight,this._thinFilmWeightTexture,this._thinFilmThickness,this._thinFilmThicknessMin,this._thinFilmThicknessTexture,this._thinFilmIor,this._emissionLuminance,this._emissionColor,this._emissionColorTexture,this._ambientOcclusionTexture}get hasRenderTargetTextures(){return ie.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget||ie.RefractionTextureEnabled&&this._backgroundRefractionTexture&&this._backgroundRefractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"OpenPBRMaterial"}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}_shouldUseAlphaFromBaseColorTexture(){return this._hasAlphaChannel()&&this._transparencyMode!==ae.MATERIAL_OPAQUE&&!this.geometryOpacityTexture}_hasAlphaChannel(){return this.baseColorTexture!=null&&this.baseColorTexture.hasAlpha&&this._useAlphaFromBaseColorTexture||this.geometryOpacityTexture!=null}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.id=e,r.name=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}serialize(){let e=super.serialize();return e.customType="BABYLON.OpenPBRMaterial",e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),r}forceCompilation(e,t,i){let r={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),(()=>{if(this._breakShaderLoadedCheck)return;let a=new td({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Tc.effect=o,Tc.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Tc)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}isReadyForSubMesh(e,t,i){var h;this._uniformBufferLayoutBuilt||this.buildUniformLayout();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new td({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}));let s=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(s._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){for(let m in this._samplersList){let p=this._samplersList[m];if(p.value&&!p.value.isReadyOrNotBlocking())return!1}let u=this._getRadianceTexture();if(u&&ie.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((h=u.getInternalTexture())!=null&&h._sphericalPolynomialPromise))return!1}if(this._environmentBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady()||this._environmentFuzzBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentFuzzBRDFTexture.isReady()||this._backgroundRefractionTexture&&ie.RefractionTextureEnabled&&!this._backgroundRefractionTexture.isReadyOrNotBlocking()||n._noiseTextures[a.uniqueId]&&!n._noiseTextures[a.uniqueId].isReady()||this._sssIrradianceTexture&&this._sssDepthTexture&&(!this._sssIrradianceTexture.isReady()||!this._sssDepthTexture.isReady()))return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||s._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(s.AREALIGHTUSED){for(let u=0;u{e.addUniform(t.name,t.numComponents)}),Object.values(this._samplersList).forEach(t=>{e.addUniform(t.samplerInfoName,2),e.addUniform(t.samplerMatrixName,16)}),super.buildUniformLayout()}bindPropertiesForSubMesh(e,t,i,r){if(this.geometryThickness===0)e.updateFloat("vGeometryThickness",0);else{r.getRenderingMesh().getWorldMatrix().decompose(k.Vector3[0]);let s=Math.max(Math.abs(k.Vector3[0].x),Math.abs(k.Vector3[0].y),Math.abs(k.Vector3[0].z));e.updateFloat("vGeometryThickness",this.geometryThickness*s)}}bindForSubMesh(e,t,i){var d;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e);let o=r.getEngine();this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Ui.Bind(o.currentRenderPassId,this._activeEffect,t,e,this);let l=r.activeCamera;l?this._uniformBuffer.updateFloat4("cameraInfo",l.minZ,l.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);nr(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&Pa(this._activeEffect,this._vertexPullingMetadata);let f=this._uniformBuffer;if(c){this.bindViewProjection(a);let h=this._getRadianceTexture();if(!f.useUbo||!this.isFrozen||!f.isSync||i._drawWrapper._forceRebindOnNextCall){if(r.texturesEnabled){for(let m in this._samplersList){let p=this._samplersList[m];p.value&&(f.updateFloat2(p.samplerInfoName,p.value.coordinatesIndex,p.value.level),ot(p.value,f,p.samplerPrefix))}(this.geometryNormalTexture||this.geometryCoatNormalTexture)&&(r._mirroredCameraPosition?f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),Pl(r,s,f,oe.White(),h,this.realTimeFiltering,!0,!0,!0,!0,!0)}this.pointsCloud&&f.updateFloat("pointSize",this.pointSize);let u=this._uniformsArray;for(let m=0,p=u.length;m0&&e.push(i.value)}return this._radianceTexture&&this._radianceTexture.animations&&this._radianceTexture.animations.length>0&&e.push(this._radianceTexture),e}getActiveTextures(){let e=super.getActiveTextures();for(let t in this._samplersList){let i=this._samplersList[t];i.value&&e.push(i.value)}return this._radianceTexture&&e.push(this._radianceTexture),e}hasTexture(e){if(super.hasTexture(e))return!0;for(let t in this._samplersList)if(this._samplersList[t].value===e)return!0;return this._radianceTexture===e}setPrePassRenderer(){return!1}dispose(e,t){var i,r;if(this._breakShaderLoadedCheck=!0,t){this._environmentBRDFTexture&&this.getScene().openPBREnvironmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._environmentFuzzBRDFTexture&&this.getScene().environmentFuzzBRDFTexture!==this._environmentFuzzBRDFTexture&&this._environmentFuzzBRDFTexture.dispose(),this._backgroundRefractionTexture=null;for(let s in this._samplersList)(i=this._samplersList[s].value)==null||i.dispose();(r=this._radianceTexture)==null||r.dispose()}this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}_getRadianceTexture(){return this._radianceTexture?this._radianceTexture:this.getScene().environmentTexture}_prepareEffect(e,t,i,r=null,s=null,a=null,o=null){if(this._prepareDefines(e,t,i,a,o),!i.isDirty)return null;i.markAsProcessed();let c=this.getScene().getEngine(),f=new Bi,d=0;i.USESPHERICALINVERTEX&&f.addFallback(d++,"USESPHERICALINVERTEX"),i.FOG&&f.addFallback(d,"FOG"),i.SPECULARAA&&f.addFallback(d,"SPECULARAA"),i.POINTSIZE&&f.addFallback(d,"POINTSIZE"),i.LOGARITHMICDEPTH&&f.addFallback(d,"LOGARITHMICDEPTH"),i.PARALLAX&&f.addFallback(d,"PARALLAX"),i.PARALLAX_RHS&&f.addFallback(d,"PARALLAX_RHS"),i.PARALLAXOCCLUSION&&f.addFallback(d++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&f.addFallback(d++,"ENVIRONMENTBRDF"),i.TANGENT&&f.addFallback(d++,"TANGENT"),d=Bl(i,f,this._maxSimultaneousLights,d),i.SPECULARTERM&&f.addFallback(d++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&f.addFallback(d++,"USESPHERICALFROMREFLECTIONMAP"),i.USEIRRADIANCEMAP&&f.addFallback(d++,"USEIRRADIANCEMAP"),i.NORMAL&&f.addFallback(d++,"NORMAL"),i.VERTEXCOLOR&&f.addFallback(d++,"VERTEXCOLOR"),i.MORPHTARGETS&&f.addFallback(d++,"MORPHTARGETS"),i.MULTIVIEW&&f.addFallback(0,"MULTIVIEW");let h=[M.PositionKind];i.NORMAL&&h.push(M.NormalKind),i.TANGENT&&h.push(M.TangentKind);for(let S=1;S<=6;++S)i["UV"+S]&&h.push(`uv${S===1?"":S}`);i.VERTEXCOLOR&&h.push(M.ColorKind),Fl(h,e,i,f),wl(h,i),Co(h,e,i),Ol(h,e,i);let u="openpbr",m=["world","view","viewProjection","projection","vEyePosition","inverseProjection","renderTargetSize","vLightsType","visibility","vFogInfos","vFogColor","pointSize","mBones","normalMatrix","vLightingIntensity","logarithmicDepthConstant","vTangentSpaceParams","boneTextureInfo","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices","cameraInfo","backgroundRefractionMatrix","vBackgroundRefractionInfos"];for(let S in this._uniformsList)m.push(S);let p=["environmentBrdfSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"];i.FUZZENVIRONMENTBRDF&&p.push("environmentFuzzBrdfSampler"),i.REFRACTED_BACKGROUND&&p.push("backgroundRefractionSampler"),(i.ANISOTROPIC||i.FUZZ||i.REFRACTED_BACKGROUND||i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)&&p.push("blueNoiseSampler"),i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING&&(p.push("sceneIrradianceSampler"),p.push("sceneDepthSampler"));for(let S in this._samplersList){let I=this._samplersList[S];p.push(I.samplerName),m.push(I.samplerInfoName),m.push(I.samplerMatrixName)}Ia(m,p,!0);let _=["Material","Scene","Mesh"],g={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS};if(this._eventInfo.fallbacks=f,this._eventInfo.fallbackRank=d,this._eventInfo.defines=i,this._eventInfo.uniforms=m,this._eventInfo.attributes=h,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=_,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=g,this._callbackPluginEventGeneric(128,this._eventInfo),Ui.AddUniformsAndSamplers(m,p),cr.AddUniforms(m),cr.AddSamplers(p),Di(m),this._useVertexPulling){let S=t==null?void 0:t.geometry;S&&(this._vertexPullingMetadata=La(S),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((I,x)=>{m.push(`vp_${x}_info`)}))}else this._vertexPullingMetadata=null;Je&&(Je.PrepareUniforms(m,i),Je.PrepareSamplers(p,i)),Yl({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,h,T));let b=i.toString(),R=c.createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:f,onCompiled:r,onError:s,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:i.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(qN(),ZN)),Promise.resolve().then(()=>(KF(),YF))]):await Promise.all([Promise.resolve().then(()=>(rw(),iw)),Promise.resolve().then(()=>(t1(),e1))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,R}_prepareDefines(e,t,i,r=null,s=null){var d;let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Gl(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Hl(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(o,i,this.canRenderToMRT&&!c),zl(o,i,c),Ui.PrepareDefines(l.currentRenderPassId,e,i),i._areTexturesDirty){i._needUVs=!1;for(let h=1;h<=6;++h)i["MAINUV"+h]=!1;if(o.texturesEnabled){for(let m in this._samplersList){let p=this._samplersList[m];p.value?(at(p.value,i,p.textureDefine),i[p.textureDefine+"_GAMMA"]=p.value.gammaSpace):i[p.textureDefine]=!1}let h=this._getRadianceTexture(),u=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;if(Ra(o,h,i,this.realTimeFiltering,this.realTimeFilteringQuality,!u),this._baseMetalnessTexture&&(i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed),i.SPECULAR_WEIGHT_IN_ALPHA=this._useSpecularWeightFromAlpha,i.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE=this._useSpecularWeightFromSpecularColorTexture,i.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=this._useSpecularRoughnessAnisotropyFromTangentTexture,i.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=this._useCoatRoughnessAnisotropyFromTangentTexture,i.COAT_ROUGHNESS_FROM_GREEN_CHANNEL=this._useCoatRoughnessFromGreenChannel,i.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN=this._useRoughnessFromMetallicTextureGreen,i.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA=this._useFuzzRoughnessFromTextureAlpha,i.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE=this._useMetallicFromMetallicTextureBlue,i.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE=this._useThinFilmThicknessFromTextureGreen,i.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL=this._useGeometryThicknessFromGreenChannel,this.geometryNormalTexture?(this._useParallax&&this.baseColorTexture&&ie.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=o.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&ie.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._environmentFuzzBRDFTexture?i.FUZZENVIRONMENTBRDF=!0:i.FUZZENVIRONMENTBRDF=!1,this.hasTransparency){i.REFRACTED_BACKGROUND=!!this._backgroundRefractionTexture&&ie.RefractionTextureEnabled,i.REFRACTION_HIGH_QUALITY_BLUR=this._refractionHighQualityBlur,i.REFRACTED_LIGHTS=!0;let m=this._getRadianceTexture();m?(i.REFRACTED_ENVIRONMENT=ie.RefractionTextureEnabled,i.REFRACTED_ENVIRONMENT_OPPOSITEZ=this.getScene().useRightHandedSystem?!m.invertZ:m.invertZ,i.REFRACTED_ENVIRONMENT_LOCAL_CUBE=m.isCube&&m.boundingBoxSize):i.REFRACTED_ENVIRONMENT=!1}else i.REFRACTED_BACKGROUND=!1,i.REFRACTED_LIGHTS=!1,i.REFRACTED_ENVIRONMENT=!1;this._shouldUseAlphaFromBaseColorTexture()?i.ALPHA_FROM_BASE_COLOR_TEXTURE=!0:i.ALPHA_FROM_BASE_COLOR_TEXTURE=!1}this._lightFalloff===ae.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===ae.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.MIRRORED=!!o._mirroredCameraPosition,i.SPECULARAA=l.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,i.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,i.ALPHABLEND=this.needAlphaBlendingForMesh(e)),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,(this.specularRoughnessAnisotropy>0||this.coatRoughnessAnisotropy>0)&&n._noiseTextures[o.uniqueId]&&ie.ReflectionTextureEnabled?(i.ANISOTROPIC=!0,e.isVerticesDataPresent(M.TangentKind)||(i._needUVs=!0,i.MAINUV1=!0),this._useGltfStyleAnisotropy&&(i.USE_GLTF_STYLE_ANISOTROPY=!0),i.ANISOTROPIC_BASE=this.specularRoughnessAnisotropy>0,i.ANISOTROPIC_COAT=this.coatRoughnessAnisotropy>0):(i.ANISOTROPIC=!1,i.USE_GLTF_STYLE_ANISOTROPY=!1,i.ANISOTROPIC_BASE=!1,i.ANISOTROPIC_COAT=!1),i.THIN_FILM=this.thinFilmWeight>0,i.IRIDESCENCE=this.thinFilmWeight>0,i.DISPERSION=this.transmissionDispersionScale>0,i.SCATTERING=this.hasScattering;let f=[8,16,32];if(i.SSS_SAMPLE_COUNT=(d=f[this._sssQuality])!=null?d:16,i.TRANSMISSION_SLAB=this.transmissionWeight>0,i.TRANSMISSION_SLAB_VOLUME=this.transmissionWeight>0&&this.transmissionDepth>0,i.SUBSURFACE_SLAB=this.subsurfaceWeight>0,!i.PREPASS&&(i.SUBSURFACE_SLAB||i.TRANSMISSION_SLAB_VOLUME)){let h=!1;if(!this.sssIrradianceTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(Ki.IRRADIANCE_TEXTURE_TYPE);this.sssIrradianceTexture=o.geometryBufferRenderer.getGBuffer().textures[u],h=!0}if(!this.sssDepthTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(Ki.SCREENSPACE_DEPTH_TEXTURE_TYPE);this.sssDepthTexture=o.geometryBufferRenderer.getGBuffer().textures[u],h=!0}this.sssIrradianceTexture&&this.sssDepthTexture&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING=!0,h&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER=!0))}i.FUZZ=this.fuzzWeight>0&&ie.ReflectionTextureEnabled,i.GEOMETRY_THIN_WALLED=this.geometryThinWalled!=0,i.FUZZ?(e.isVerticesDataPresent(M.TangentKind)||(i._needUVs=!0,i.MAINUV1=!0),this._environmentFuzzBRDFTexture=xT(this.getScene()),i.FUZZ_IBL_SAMPLES=this.fuzzSampleNumber):(this._environmentFuzzBRDFTexture=null,i.FUZZENVIRONMENTBRDF=!1,i.FUZZ_IBL_SAMPLES=0),i._areMiscDirty&&(Ul(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),i,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t,this._isVertexOutputInvariant),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(M.NormalKind),i.DEBUGMODE=this._debugMode),kl(o,l,this,i,!!r,s,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Wl(e,i,!0,!0,!0,this._transparencyMode!==ae.MATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}};pe.SSS_QUALITY_LOW=0;pe.SSS_QUALITY_MEDIUM=1;pe.SSS_QUALITY_HIGH=2;pe._noiseTextures={};pe.ForceGLSL=!1;C([Be("_markAllSubMeshesAsTexturesDirty","baseWeight")],pe.prototype,"_baseWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseWeightTexture")],pe.prototype,"_baseWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseColor")],pe.prototype,"_baseColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseColorTexture")],pe.prototype,"_baseColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughness")],pe.prototype,"_baseDiffuseRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughnessTexture")],pe.prototype,"_baseDiffuseRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseMetalness")],pe.prototype,"_baseMetalness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseMetalnessTexture")],pe.prototype,"_baseMetalnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularWeight")],pe.prototype,"_specularWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularWeightTexture")],pe.prototype,"_specularWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularColor")],pe.prototype,"_specularColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularColorTexture")],pe.prototype,"_specularColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughness")],pe.prototype,"_specularRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessTexture")],pe.prototype,"_specularRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropy")],pe.prototype,"_specularRoughnessAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropyTexture")],pe.prototype,"_specularRoughnessAnisotropyTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularIor")],pe.prototype,"_specularIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionWeight")],pe.prototype,"_transmissionWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionWeightTexture")],pe.prototype,"_transmissionWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionColor")],pe.prototype,"_transmissionColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionColorTexture")],pe.prototype,"_transmissionColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDepth")],pe.prototype,"_transmissionDepth",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDepthTexture")],pe.prototype,"_transmissionDepthTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatter")],pe.prototype,"_transmissionScatter",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatterTexture")],pe.prototype,"_transmissionScatterTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatterAnisotropy")],pe.prototype,"_transmissionScatterAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScale")],pe.prototype,"_transmissionDispersionScale",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScaleTexture")],pe.prototype,"_transmissionDispersionScaleTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionAbbeNumber")],pe.prototype,"_transmissionDispersionAbbeNumber",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceWeight")],pe.prototype,"_subsurfaceWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceWeightTexture")],pe.prototype,"_subsurfaceWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceColor")],pe.prototype,"_subsurfaceColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceColorTexture")],pe.prototype,"_subsurfaceColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadius")],pe.prototype,"_subsurfaceRadius",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScale")],pe.prototype,"_subsurfaceRadiusScale",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScaleTexture")],pe.prototype,"_subsurfaceRadiusScaleTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceScatterAnisotropy")],pe.prototype,"_subsurfaceScatterAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatWeight")],pe.prototype,"_coatWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatWeightTexture")],pe.prototype,"_coatWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatColor")],pe.prototype,"_coatColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatColorTexture")],pe.prototype,"_coatColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughness")],pe.prototype,"_coatRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessTexture")],pe.prototype,"_coatRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropy")],pe.prototype,"_coatRoughnessAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropyTexture")],pe.prototype,"_coatRoughnessAnisotropyTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatIor")],pe.prototype,"_coatIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatDarkening")],pe.prototype,"_coatDarkening",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatDarkeningTexture")],pe.prototype,"_coatDarkeningTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzWeight")],pe.prototype,"_fuzzWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzWeightTexture")],pe.prototype,"_fuzzWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzColor")],pe.prototype,"_fuzzColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzColorTexture")],pe.prototype,"_fuzzColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzRoughness")],pe.prototype,"_fuzzRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzRoughnessTexture")],pe.prototype,"_fuzzRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThinWalled")],pe.prototype,"_geometryThinWalled",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryNormalTexture")],pe.prototype,"_geometryNormalTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryTangent")],pe.prototype,"_geometryTangent",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryTangentTexture")],pe.prototype,"_geometryTangentTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatNormalTexture")],pe.prototype,"_geometryCoatNormalTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatTangent")],pe.prototype,"_geometryCoatTangent",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatTangentTexture")],pe.prototype,"_geometryCoatTangentTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryOpacity")],pe.prototype,"_geometryOpacity",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryOpacityTexture")],pe.prototype,"_geometryOpacityTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThickness")],pe.prototype,"_geometryThickness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThicknessTexture")],pe.prototype,"_geometryThicknessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionLuminance")],pe.prototype,"_emissionLuminance",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionColor")],pe.prototype,"_emissionColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionColorTexture")],pe.prototype,"_emissionColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmWeight")],pe.prototype,"_thinFilmWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmWeightTexture")],pe.prototype,"_thinFilmWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThickness")],pe.prototype,"_thinFilmThickness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessMin")],pe.prototype,"_thinFilmThicknessMin",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessTexture")],pe.prototype,"_thinFilmThicknessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmIor")],pe.prototype,"_thinFilmIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","ambientOcclusionTexture")],pe.prototype,"_ambientOcclusionTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"directIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"environmentIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useSpecularWeightFromTextureAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],pe.prototype,"forceAlphaTest",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],pe.prototype,"alphaCutOff",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAmbientInGrayScale",void 0);C([D()],pe.prototype,"usePhysicalLightFalloff",null);C([D()],pe.prototype,"useGLTFLightFalloff",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useObjectSpaceNormalMap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useParallax",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useParallaxOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"parallaxScaleBias",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],pe.prototype,"disableLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"forceIrradianceInFragment",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],pe.prototype,"maxSimultaneousLights",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"invertNormalMapX",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"invertNormalMapY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"twoSidedLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAlphaFresnel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useLinearAlphaFresnel",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"environmentBRDFTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"forceNormalForward",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"enableSpecularAntiAliasing",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useHorizonOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useRadianceOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"unlit",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"applyDecalMapAfterDetailMap",void 0);C([ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"debugMode",void 0);C([D()],pe.prototype,"transparencyMode",null);je("BABYLON.OpenPBRMaterial",pe)});var n1={};De(n1,{OpenPBRMaterialLoadingAdapter:()=>RS});var RS,s1=A(()=>{et();RS=class{constructor(e){this._diffuseTransmissionTint=oe.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){}get alphaCutOff(){return .5}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return!1}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){let t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){var t;let e=this._material.ambientOcclusionTexture;return(t=e==null?void 0:e.level)!=null?t:1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}set coatDarkening(e){this._material.coatDarkening=e}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||this._material.transmissionDepth!==0?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(oe.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=e?1:0}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}finalize(){(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(oe.White())||this._diffuseTransmissionTintTexture)&&(this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture):this._material.coatWeight==0&&(!this.baseColor.equals(oe.White())||this.baseColorTexture)&&(this._material.coatWeight=this.subsurfaceWeight,this._material.coatWeightTexture=this.subsurfaceWeightTexture,this._material.coatColor=this._diffuseTransmissionTint,this._material.coatColorTexture=this._diffuseTransmissionTintTexture,this._material.coatIor=this._material.specularIor,this._material.coatDarkening=0,this._material.coatRoughness=this._material.specularRoughness,this._material.coatRoughnessTexture=this._material.specularRoughnessTexture,this._material.specularRoughness=1,this._material.specularRoughnessTexture=null)),this.transmissionWeight>0&&(this._material.geometryThinWalled||this._material.transmissionDepth===0?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture):this._material.coatWeight==0&&(!this.baseColor.equals(oe.White())||this.baseColorTexture!==null)&&(this._material.coatWeight=this.transmissionWeight,this._material.coatWeightTexture=this.transmissionWeightTexture,this._material.coatColor=this.baseColor,this._material.coatColorTexture=this.baseColorTexture,this._material.coatIor=this._material.specularIor,this._material.coatDarkening=0,this._material.coatRoughness=this._material.specularRoughness,this._material.coatRoughnessTexture=this._material.specularRoughnessTexture))}}});var IS,ei,a1=A(()=>{Qe();qe();zr();Fa();IS=class extends Zt{constructor(){super(...arguments),this.BRDF_V_HEIGHT_CORRELATED=!1,this.MS_BRDF_ENERGY_CONSERVATION=!1,this.SPHERICAL_HARMONICS=!1,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,this.MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0,this.LEGACY_SPECULAR_ENERGY_CONSERVATION=!1,this.BASE_DIFFUSE_MODEL=0,this.DIELECTRIC_SPECULAR_MODEL=0,this.CONDUCTOR_SPECULAR_MODEL=0}},ei=class n extends si{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new IS,t),this._useEnergyConservation=n.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=n.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=n.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=n.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=n.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=n.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=n.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=n.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._mixIblRadianceWithIrradiance=n.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this.mixIblRadianceWithIrradiance=n.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this._useLegacySpecularEnergyConservation=n.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this.useLegacySpecularEnergyConservation=n.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this._baseDiffuseModel=n.DEFAULT_DIFFUSE_MODEL,this.baseDiffuseModel=n.DEFAULT_DIFFUSE_MODEL,this._dielectricSpecularModel=n.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this.dielectricSpecularModel=n.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this._conductorSpecularModel=n.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this.conductorSpecularModel=n.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16],this._enable(!0)}prepareDefines(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation,e.MIX_IBL_RADIANCE_WITH_IRRADIANCE=this._mixIblRadianceWithIrradiance&&!this._material._disableLighting,e.LEGACY_SPECULAR_ENERGY_CONSERVATION=this._useLegacySpecularEnergyConservation,e.BASE_DIFFUSE_MODEL=this._baseDiffuseModel,e.DIELECTRIC_SPECULAR_MODEL=this._dielectricSpecularModel,e.CONDUCTOR_SPECULAR_MODEL=this._conductorSpecularModel}getClassName(){return"PBRBRDFConfiguration"}};ei.DEFAULT_USE_ENERGY_CONSERVATION=!0;ei.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0;ei.DEFAULT_USE_SPHERICAL_HARMONICS=!0;ei.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0;ei.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0;ei.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION=!0;ei.DEFAULT_DIFFUSE_MODEL=0;ei.DEFAULT_DIELECTRIC_SPECULAR_MODEL=0;ei.DEFAULT_CONDUCTOR_SPECULAR_MODEL=0;C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useEnergyConservation",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSmithVisibilityHeightCorrelated",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSphericalHarmonics",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"mixIblRadianceWithIrradiance",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useLegacySpecularEnergyConservation",void 0);C([D("baseDiffuseModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"baseDiffuseModel",void 0);C([D("dielectricSpecularModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"dielectricSpecularModel",void 0);C([D("conductorSpecularModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"conductorSpecularModel",void 0)});var xS,_i,o1=A(()=>{Qe();qe();et();Wr();Fa();zr();Oi();xS=class extends Zt{constructor(){super(...arguments),this.CLEARCOAT=!1,this.CLEARCOAT_DEFAULTIOR=!1,this.CLEARCOAT_TEXTURE=!1,this.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this.CLEARCOAT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,this.CLEARCOAT_BUMP=!1,this.CLEARCOAT_BUMPDIRECTUV=0,this.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,this.CLEARCOAT_REMAP_F0=!1,this.CLEARCOAT_TINT=!1,this.CLEARCOAT_TINT_TEXTURE=!1,this.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TINT_GAMMATEXTURE=!1}},_i=class n extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new xS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=n._DefaultIndexOfRefraction,this.indexOfRefraction=n._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=oe.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,i){if(!this._isEnabled)return!0;let r=this._material._disableBumpMap;return!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ie.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&ie.ClearCoatBumpTextureEnabled&&!r&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&ie.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking()))}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.CLEARCOAT=!0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled?at(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&ie.ClearCoatTextureEnabled?at(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&ie.ClearCoatBumpTextureEnabled?at(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===n._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&ie.ClearCoatTintTextureEnabled?(at(this._tintTexture,e,"CLEARCOAT_TINT_TEXTURE"),e.CLEARCOAT_TINT_GAMMATEXTURE=this._tintTexture.gammaSpace):e.CLEARCOAT_TINT_TEXTURE=!1):(e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1))):(e.CLEARCOAT=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1)}bindForSubMesh(e,t,i,r){var f,d,h,u,m,p,_,g;if(!this._isEnabled)return;let s=r.materialDefines,a=this._material.isFrozen,o=this._material._disableBumpMap,l=this._material._invertNormalMapX,c=this._material._invertNormalMapY;if(!e.useUbo||!a||!e.isSync){(this._texture||this._textureRoughness)&&ie.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",(d=(f=this._texture)==null?void 0:f.coordinatesIndex)!=null?d:0,(u=(h=this._texture)==null?void 0:h.level)!=null?u:0,(p=(m=this._textureRoughness)==null?void 0:m.coordinatesIndex)!=null?p:0,(g=(_=this._textureRoughness)==null?void 0:_.level)!=null?g:0),this._texture&&ot(this._texture,e,"clearCoat"),this._textureRoughness&&!s.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&ot(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&ie.ClearCoatTextureEnabled&&!o&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),ot(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",l?1:-1,c?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",l?-1:1,c?-1:1)),this._tintTexture&&ie.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),ot(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);let T=1-this._indexOfRefraction,b=1+this._indexOfRefraction,R=Math.pow(-T/b,2),S=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",R,S,T,b),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!s.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&ie.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&ie.ClearCoatBumpTextureEnabled&&!o&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&ie.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))}hasTexture(e){return this._texture===e||this._textureRoughness===e||this._bumpTexture===e||this._tintTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)}dispose(e){var t,i,r,s;e&&((t=this._texture)==null||t.dispose(),(i=this._textureRoughness)==null||i.dispose(),(r=this._bumpTexture)==null||r.dispose(),(s=this._tintTexture)==null||s.dispose())}getClassName(){return"PBRClearCoatConfiguration"}addFallbacks(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i}getSamplers(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")}getUniforms(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}}};_i._DefaultIndexOfRefraction=1.5;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"isEnabled",void 0);C([D()],_i.prototype,"intensity",void 0);C([D()],_i.prototype,"roughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"indexOfRefraction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"useRoughnessFromMainTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"textureRoughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"remapF0OnInterfaceChange",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"bumpTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"isTintEnabled",void 0);C([Ht()],_i.prototype,"tintColor",void 0);C([D()],_i.prototype,"tintColorAtDistance",void 0);C([D()],_i.prototype,"tintThickness",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_i.prototype,"tintTexture",void 0)});var CS,dr,l1=A(()=>{Qe();qe();Wr();Fa();zr();Oi();CS=class extends Zt{constructor(){super(...arguments),this.IRIDESCENCE=!1,this.IRIDESCENCE_TEXTURE=!1,this.IRIDESCENCE_TEXTUREDIRECTUV=0,this.IRIDESCENCE_THICKNESS_TEXTURE=!1,this.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0}},dr=class n extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new CS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=n._DefaultMinimumThickness,this.maximumThickness=n._DefaultMaximumThickness,this.indexOfRefraction=n._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._thicknessTexture=null,this.thicknessTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&ie.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled?at(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&ie.IridescenceTextureEnabled?at(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)}bindForSubMesh(e,t){var r,s,a,o,l,c,f,d;if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&((this._texture||this._thicknessTexture)&&ie.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",(s=(r=this._texture)==null?void 0:r.coordinatesIndex)!=null?s:0,(o=(a=this._texture)==null?void 0:a.level)!=null?o:0,(c=(l=this._thicknessTexture)==null?void 0:l.coordinatesIndex)!=null?c:0,(d=(f=this._thicknessTexture)==null?void 0:f.level)!=null?d:0),this._texture&&ot(this._texture,e,"iridescence"),this._thicknessTexture&&ot(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&ie.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}hasTexture(e){return this._texture===e||this._thicknessTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)}dispose(e){var t,i;e&&((t=this._texture)==null||t.dispose(),(i=this._thicknessTexture)==null||i.dispose())}getClassName(){return"PBRIridescenceConfiguration"}addFallbacks(e,t,i){return e.IRIDESCENCE&&t.addFallback(i++,"IRIDESCENCE"),i}getSamplers(e){e.push("iridescenceSampler","iridescenceThicknessSampler")}getUniforms(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}}};dr._DefaultMinimumThickness=100;dr._DefaultMaximumThickness=400;dr._DefaultIndexOfRefraction=1.3;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],dr.prototype,"isEnabled",void 0);C([D()],dr.prototype,"intensity",void 0);C([D()],dr.prototype,"minimumThickness",void 0);C([D()],dr.prototype,"maximumThickness",void 0);C([D()],dr.prototype,"indexOfRefraction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],dr.prototype,"texture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],dr.prototype,"thicknessTexture",void 0)});var bS,js,c1=A(()=>{Qe();qe();yt();ve();Wr();Fa();zr();Oi();bS=class extends Zt{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}},js=class extends si{set angle(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)}get angle(){return Math.atan2(this.direction.y,this.direction.x)}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markAllSubMeshesAsMiscDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRAnisotropic",110,new bS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new _e(1,0),this._texture=null,this.texture=null,this._legacy=!1,this.legacy=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&ie.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking()):!0}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(M.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.AnisotropicTextureEnabled?at(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)}bindForSubMesh(e,t){if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&(this._texture&&ie.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),ot(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&ie.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture&&this._texture.dispose()}getClassName(){return"PBRAnisotropicConfiguration"}addFallbacks(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i}getSamplers(e){e.push("anisotropySampler")}getUniforms(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}}parse(e,t,i){super.parse(e,t,i),e.legacy===void 0&&(this.legacy=!0)}};C([D(),ee("_markAllSubMeshesAsTexturesDirty")],js.prototype,"isEnabled",void 0);C([D()],js.prototype,"intensity",void 0);C([hl()],js.prototype,"direction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],js.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],js.prototype,"legacy",void 0)});var MS,Ar,f1=A(()=>{Qe();qe();et();Wr();Fa();zr();Oi();MS=class extends Zt{constructor(){super(...arguments),this.SHEEN=!1,this.SHEEN_TEXTURE=!1,this.SHEEN_GAMMATEXTURE=!1,this.SHEEN_TEXTURE_ROUGHNESS=!1,this.SHEEN_TEXTUREDIRECTUV=0,this.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,this.SHEEN_LINKWITHALBEDO=!1,this.SHEEN_ROUGHNESS=!1,this.SHEEN_ALBEDOSCALING=!1,this.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1}},Ar=class extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new MS,t),this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=oe.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ie.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=this._roughness!==null,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled?(at(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&ie.SheenTextureEnabled?at(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)}bindForSubMesh(e,t,i,r){var o,l,c,f,d,h,u,m;if(!this._isEnabled)return;let s=r.materialDefines,a=this._material.isFrozen;(!e.useUbo||!a||!e.isSync)&&((this._texture||this._textureRoughness)&&ie.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",(l=(o=this._texture)==null?void 0:o.coordinatesIndex)!=null?l:0,(f=(c=this._texture)==null?void 0:c.level)!=null?f:0,(h=(d=this._textureRoughness)==null?void 0:d.coordinatesIndex)!=null?h:0,(m=(u=this._textureRoughness)==null?void 0:u.level)!=null?m:0),this._texture&&ot(this._texture,e,"sheen"),this._textureRoughness&&!s.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ot(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),this._roughness!==null&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!s.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ie.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}hasTexture(e){return this._texture===e||this._textureRoughness===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)}dispose(e){var t,i;e&&((t=this._texture)==null||t.dispose(),(i=this._textureRoughness)==null||i.dispose())}getClassName(){return"PBRSheenConfiguration"}addFallbacks(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i}getSamplers(e){e.push("sheenSampler","sheenRoughnessSampler")}getUniforms(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}}};C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"isEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"linkSheenWithAlbedo",void 0);C([D()],Ar.prototype,"intensity",void 0);C([Ht()],Ar.prototype,"color",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"useRoughnessFromMainTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"roughness",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"textureRoughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ar.prototype,"albedoScaling",void 0)});var yS,pt,d1=A(()=>{Qe();qe();et();Wr();ve();Fa();zr();Oi();yS=class extends Zt{constructor(){super(...arguments),this.SUBSURFACE=!1,this.SS_REFRACTION=!1,this.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_TRANSLUCENCY=!1,this.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_SCATTERING=!1,this.SS_DISPERSION=!1,this.SS_THICKNESSANDMASK_TEXTURE=!1,this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,this.SS_HAS_THICKNESS=!1,this.SS_REFRACTIONINTENSITY_TEXTURE=!1,this.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,this.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,this.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,this.SS_REFRACTIONMAP_3D=!1,this.SS_REFRACTIONMAP_OPPOSITEZ=!1,this.SS_LODINREFRACTIONALPHA=!1,this.SS_GAMMAREFRACTION=!1,this.SS_RGBDREFRACTION=!1,this.SS_LINEARSPECULARREFRACTION=!1,this.SS_LINKREFRACTIONTOTRANSPARENCY=!1,this.SS_ALBEDOFORREFRACTIONTINT=!1,this.SS_ALBEDOFORTRANSLUCENCYTINT=!1,this.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,this.SS_USE_THICKNESS_AS_DEPTH=!1,this.SS_USE_GLTF_TEXTURES=!1,this.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1,this.SS_TRANSLUCENCY_LEGACY=!1}},pt=class n extends si{get scatteringDiffusionProfile(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null}set scatteringDiffusionProfile(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))}get volumeIndexOfRefraction(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction}set volumeIndexOfRefraction(e){e>=1?this._volumeIndexOfRefraction=e:this._volumeIndexOfRefraction=-1}get legacyTransluceny(){return this.legacyTranslucency}set legacyTransluceny(e){this.legacyTranslucency=e}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markScenePrePassDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRSubSurface",130,new yS,t),this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isDispersionEnabled=!1,this.isDispersionEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this._useAlbedoToTintRefraction=!1,this.useAlbedoToTintRefraction=!1,this._useAlbedoToTintTranslucency=!1,this.useAlbedoToTintTranslucency=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.useThicknessAsDepth=!1,this.tintColor=oe.White(),this.tintColorAtDistance=1,this.dispersion=0,this.diffusionDistance=oe.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._refractionIntensityTexture=null,this.refractionIntensityTexture=null,this._translucencyIntensityTexture=null,this.translucencyIntensityTexture=null,this.translucencyColor=null,this._translucencyColorTexture=null,this.translucencyColorTexture=null,this._useGltfStyleTextures=!0,this.useGltfStyleTextures=!0,this.applyAlbedoAfterSubSurface=n.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE,this.legacyTranslucency=n.DEFAULT_LEGACY_TRANSLUCENCY,this._scene=e.getScene(),this.registerForExtraEvents=!0,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkScenePrePassDirty=e._dirtyCallbacks[32]}isReadyForSubMesh(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&ie.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&!this._refractionIntensityTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;let i=this._getRefractionTexture(t);if(i&&ie.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled){e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1;return}if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_LEGACY=this.legacyTranslucency,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=this.applyAlbedoAfterSubSurface,e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&ie.ThicknessTextureEnabled&&at(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&at(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&at(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&(at(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE"),e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=this._translucencyColorTexture.gammaSpace)),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!==0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&t.texturesEnabled){let i=this._getRefractionTexture(t);i&&ie.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this._useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this._useAlbedoToTintTranslucency)}}hardBindForSubMesh(e,t,i,r){if(!(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled))if(this.maximumThickness===0&&this.minimumThickness===0)e.updateFloat2("vThicknessParam",0,0);else{r.getRenderingMesh().getWorldMatrix().decompose(k.Vector3[0]);let s=Math.max(Math.abs(k.Vector3[0].x),Math.abs(k.Vector3[0].y),Math.abs(k.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*s,(this.maximumThickness-this.minimumThickness)*s)}}bindForSubMesh(e,t,i,r){var f;if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return;let s=r.materialDefines,a=this._material.isFrozen,o=this._material.realTimeFiltering,l=s.LODBASEDMICROSFURACE,c=this._getRefractionTexture(t);if(!e.useUbo||!a||!e.isSync){if(this._thicknessTexture&&ie.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),ot(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),ot(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),ot(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),ot(this._translucencyIntensityTexture,e,"translucencyIntensity")),c&&ie.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",c.getRefractionTextureMatrix());let d=1;c.isCube||c.depth&&(d=c.depth);let h=c.getSize().width,u=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",c.level,1/u,d,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",h,c.lodGenerationScale,c.lodGenerationOffset,1/this.indexOfRefraction),o&&e.updateFloat2("vRefractionFilteringInfo",h,Math.log2(h)),c.boundingBoxSize){let m=c;e.updateVector3("vRefractionPosition",m.boundingBoxPosition),e.updateVector3("vRefractionSize",m.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",(f=this.translucencyColor)!=null?f:this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}t.texturesEnabled&&(this._thicknessTexture&&ie.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),c&&ie.RefractionTextureEnabled&&(l?e.setTexture("refractionSampler",c):(e.setTexture("refractionSampler",c._lodTextureMid||c),e.setTexture("refractionSamplerLow",c._lodTextureLow||c),e.setTexture("refractionSamplerHigh",c._lodTextureHigh||c))))}_getRefractionTexture(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null}get disableAlphaBlending(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency}fillRenderTargetTextures(e){ie.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)}hasTexture(e){return this._thicknessTexture===e||this._refractionTexture===e||this._refractionIntensityTexture===e||this._translucencyIntensityTexture===e||this._translucencyColorTexture===e}hasRenderTargetTextures(){return!!(ie.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)}getActiveTextures(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._refractionIntensityTexture&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&e.push(this._translucencyIntensityTexture)}getAnimatables(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._refractionIntensityTexture&&this._refractionIntensityTexture.animations&&this._refractionIntensityTexture.animations.length>0&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.animations&&this._translucencyIntensityTexture.animations.length>0&&e.push(this._translucencyIntensityTexture)}dispose(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._refractionIntensityTexture&&this._refractionIntensityTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose(),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.dispose())}getClassName(){return"PBRSubSurfaceConfiguration"}addFallbacks(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i}getSamplers(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")}getUniforms(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}}};pt.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE=!1;pt.DEFAULT_LEGACY_TRANSLUCENCY=!1;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"isRefractionEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"isTranslucencyEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"isDispersionEnabled",void 0);C([D(),ee("_markScenePrePassDirty")],pt.prototype,"isScatteringEnabled",void 0);C([D()],pt.prototype,"_scatteringDiffusionProfileIndex",void 0);C([D()],pt.prototype,"refractionIntensity",void 0);C([D()],pt.prototype,"translucencyIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"useAlbedoToTintRefraction",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"useAlbedoToTintTranslucency",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"thicknessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"refractionTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"indexOfRefraction",void 0);C([D()],pt.prototype,"_volumeIndexOfRefraction",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"volumeIndexOfRefraction",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"invertRefractionY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"linkRefractionWithTransparency",void 0);C([D()],pt.prototype,"minimumThickness",void 0);C([D()],pt.prototype,"maximumThickness",void 0);C([D()],pt.prototype,"useThicknessAsDepth",void 0);C([Ht()],pt.prototype,"tintColor",void 0);C([D()],pt.prototype,"tintColorAtDistance",void 0);C([D()],pt.prototype,"dispersion",void 0);C([Ht()],pt.prototype,"diffusionDistance",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"useMaskFromThicknessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"refractionIntensityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"translucencyIntensityTexture",void 0);C([Ht()],pt.prototype,"translucencyColor",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"translucencyColorTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pt.prototype,"useGltfStyleTextures",void 0);C([D()],pt.prototype,"applyAlbedoAfterSubSurface",void 0);C([D()],pt.prototype,"legacyTranslucency",void 0)});var h1,f5,DS=A(()=>{N();yo();Wf();h1="pbrUboDeclaration",f5=`uniform vAlbedoInfos: vec2f;uniform vBaseWeightInfos: vec2f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform vAmbientInfos: vec4f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vReflectivityInfos: vec3f;uniform vMicroSurfaceSamplerInfos: vec2f;uniform vBumpInfos: vec3f;uniform albedoMatrix: mat4x4f;uniform baseWeightMatrix: mat4x4f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform reflectivityMatrix: mat4x4f;uniform microSurfaceSamplerMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform vAlbedoColor: vec4f;uniform baseWeight: f32;uniform baseDiffuseRoughness: f32;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vReflectivityColor: vec4f;uniform vEmissiveColor: vec3f;uniform vAmbientColor: vec3f;uniform vDebugMode: vec2f;uniform vMetallicReflectanceFactors: vec4f;uniform vMetallicReflectanceInfos: vec2f;uniform metallicReflectanceMatrix: mat4x4f;uniform vReflectanceInfos: vec2f;uniform reflectanceMatrix: mat4x4f;uniform cameraInfo: vec4f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionDominantDirection: vec3f;uniform vReflectionColor: vec3f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f; +`;E.ShadersStore[AS]||(E.ShadersStore[AS]=a1);M5={name:AS,shader:a1}});var c1={};De(c1,{OpenPBRMaterial:()=>pe,OpenPBRMaterialDefines:()=>td});var Tc,jm,ct,pt,RS,IS,td,xS,pe,f1=A(()=>{Qe();qe();Wm();et();sf();oi();Lt();Fi();Kt();Yr();Su();Da();Wn();Cf();Ni();yt();Au();Tu();zr();ze();Ru();Iu();dN();ve();xu();xf();cn();Tt();ZN();Tc={effect:null,subMesh:null},jm=class n{populateVectorFromLinkedProperties(e){let t=e.dimension[0];for(let i in this.linkedProperties){let r=this.linkedProperties[i],s=r.numComponents;if(tt-s){s==1?W.Error(`Float property ${r.name} has an offset that is too large.`):W.Error(`Vector${s} property ${r.name} won't fit in Vector${t} or has an offset that is too large.`);return}typeof r.value=="number"?n._tmpArray[r.targetUniformComponentOffset]=r.value:r.value.toArray(n._tmpArray,r.targetUniformComponentOffset)}e.fromArray(n._tmpArray)}constructor(e,t){this.linkedProperties={},this.firstLinkedKey="",this.name=e,this.numComponents=t}};jm._tmpArray=[0,0,0,0];ct=class{constructor(e,t,i,r,s=0,a){this.targetUniformComponentNum=4,this.targetUniformComponentOffset=0,this.name=e,this.targetUniformName=i,this.defaultValue=t,this.value=t,this.targetUniformComponentNum=r,this.targetUniformComponentOffset=s,this.requiredDefine=a}get numComponents(){return typeof this.defaultValue=="number"?1:this.defaultValue.dimension[0]}},pt=class{get samplerName(){return this.samplerPrefix+"Sampler"}get samplerInfoName(){return"v"+this.samplerPrefix.charAt(0).toUpperCase()+this.samplerPrefix.slice(1)+"Infos"}get samplerMatrixName(){return this.samplerPrefix+"Matrix"}constructor(e,t,i){this.value=null,this.samplerPrefix="",this.textureDefine="",this.name=e,this.samplerPrefix=t,this.textureDefine=i}},RS=class extends ac(sc(Zt)){},IS=class extends fN(RS){},td=class extends rc(IS){constructor(e){super(e),this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.LIGHTCOUNT=0,this.VERTEXCOLOR=!1,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.VERTEXALPHA=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHA_FROM_BASE_COLOR_TEXTURE=!1,this.ALPHATESTVALUE="0.5",this.PREMULTIPLYALPHA=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.LODBASEDMICROSFURACE=!0,this.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN=!1,this.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.SPECULAR_WEIGHT_IN_ALPHA=!1,this.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE=!1,this.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=!1,this.COAT_ROUGHNESS_FROM_GREEN_CHANNEL=!1,this.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=!1,this.USE_GLTF_STYLE_ANISOTROPY=!1,this.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE=!1,this.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA=!1,this.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL=!1,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.FUZZENVIRONMENTBRDF=!1,this.NORMAL=!1,this.TANGENT=!1,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.ANISOTROPIC=!1,this.ANISOTROPIC_OPENPBR=!0,this.ANISOTROPIC_BASE=!1,this.ANISOTROPIC_COAT=!1,this.FUZZ_IBL_SAMPLES=6,this.REFRACTION_HIGH_QUALITY_BLUR=!1,this.FUZZ=!1,this.THIN_FILM=!1,this.IRIDESCENCE=!1,this.DISPERSION=!1,this.SCATTERING=!1,this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING=!1,this.SSS_SAMPLE_COUNT=16,this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER=!1,this.TRANSMISSION_SLAB=!1,this.TRANSMISSION_SLAB_VOLUME=!1,this.SUBSURFACE_SLAB=!1,this.GEOMETRY_THIN_WALLED=!1,this.REFRACTED_BACKGROUND=!1,this.REFRACTED_LIGHTS=!1,this.REFRACTED_ENVIRONMENT=!1,this.REFRACTED_ENVIRONMENT_OPPOSITEZ=!1,this.REFRACTED_ENVIRONMENT_LOCAL_CUBE=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.MIRRORED=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.BRDF_V_HEIGHT_CORRELATED=!0,this.MS_BRDF_ENERGY_CONSERVATION=!0,this.SPHERICAL_HARMONICS=!0,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!0,this.MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0,this.LEGACY_SPECULAR_ENERGY_CONSERVATION=!1,this.BASE_DIFFUSE_MODEL=0,this.DIELECTRIC_SPECULAR_MODEL=1,this.CONDUCTOR_SPECULAR_MODEL=1,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.NORMALXYSCALE=!0}},xS=class extends oc(Yn){},pe=class n extends xS{get geometryTangentAngle(){return Math.atan2(this.geometryTangent.y,this.geometryTangent.x)}set geometryTangentAngle(e){this.geometryTangent=new _e(Math.cos(e),Math.sin(e))}get geometryCoatTangentAngle(){return Math.atan2(this.geometryCoatTangent.y,this.geometryCoatTangent.x)}set geometryCoatTangentAngle(e){this.geometryCoatTangent=new _e(Math.cos(e),Math.sin(e))}get sssQuality(){return this._sssQuality}set sssQuality(e){this._sssQuality!==e&&(this._sssQuality=e,this.markAsDirty(1))}get sssIrradianceTexture(){return this._sssIrradianceTexture}set sssIrradianceTexture(e){this._sssIrradianceTexture!==e&&(this._sssIrradianceTexture=e,this._markAllSubMeshesAsTexturesDirty())}get sssDepthTexture(){return this._sssDepthTexture}set sssDepthTexture(e){this._sssDepthTexture!==e&&(this._sssDepthTexture=e,this._markAllSubMeshesAsTexturesDirty())}get hasTransparency(){return this.subsurfaceWeight>0||this.transmissionWeight>0}get hasScattering(){return this.transmissionWeight>0&&this.transmissionDepth>0&&!this.transmissionScatter.equals(oe.BlackReadOnly)||this.subsurfaceWeight>0}get usePhysicalLightFalloff(){return this._lightFalloff===ae.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ae.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=ae.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===ae.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=ae.LIGHTFALLOFF_GLTF:this._lightFalloff=ae.LIGHTFALLOFF_STANDARD)}get backgroundRefractionTexture(){return this._backgroundRefractionTexture}set backgroundRefractionTexture(e){this._backgroundRefractionTexture=e,this._markAllSubMeshesAsTexturesDirty()}get refractionHighQualityBlur(){return this._refractionHighQualityBlur}set refractionHighQualityBlur(e){this._refractionHighQualityBlur!==e&&(this._refractionHighQualityBlur=e,this.markAsDirty(1))}get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(1)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(1)}get fuzzSampleNumber(){return this._fuzzSampleNumber}set fuzzSampleNumber(e){this._fuzzSampleNumber=e,this.markAsDirty(1)}get canRenderToMRT(){return!0}constructor(e,t,i=!1){var s;super(e,t,void 0,i||n.ForceGLSL),this._baseWeight=new ct("base_weight",1,"vBaseWeight",1),this._baseWeightTexture=new pt("base_weight","baseWeight","BASE_WEIGHT"),this._baseColor=new ct("base_color",oe.White(),"vBaseColor",4),this._baseColorTexture=new pt("base_color","baseColor","BASE_COLOR"),this._baseDiffuseRoughness=new ct("base_diffuse_roughness",0,"vBaseDiffuseRoughness",1),this._baseDiffuseRoughnessTexture=new pt("base_diffuse_roughness","baseDiffuseRoughness","BASE_DIFFUSE_ROUGHNESS"),this._baseMetalness=new ct("base_metalness",0,"vReflectanceInfo",4,0),this._baseMetalnessTexture=new pt("base_metalness","baseMetalness","BASE_METALNESS"),this._specularWeight=new ct("specular_weight",1,"vReflectanceInfo",4,3),this._specularWeightTexture=new pt("specular_weight","specularWeight","SPECULAR_WEIGHT"),this._specularColor=new ct("specular_color",oe.White(),"vSpecularColor",4),this._specularColorTexture=new pt("specular_color","specularColor","SPECULAR_COLOR"),this._specularRoughness=new ct("specular_roughness",.3,"vReflectanceInfo",4,1),this._specularRoughnessTexture=new pt("specular_roughness","specularRoughness","SPECULAR_ROUGHNESS"),this._specularRoughnessAnisotropy=new ct("specular_roughness_anisotropy",0,"vSpecularAnisotropy",3,2),this._specularRoughnessAnisotropyTexture=new pt("specular_roughness_anisotropy","specularRoughnessAnisotropy","SPECULAR_ROUGHNESS_ANISOTROPY"),this._specularIor=new ct("specular_ior",1.5,"vReflectanceInfo",4,2),this._transmissionWeight=new ct("transmission_weight",0,"vTransmissionWeight",1),this._transmissionWeightTexture=new pt("transmission_weight","transmissionWeight","TRANSMISSION_WEIGHT"),this._transmissionColor=new ct("transmission_color",oe.White(),"vTransmissionColor",3,0),this._transmissionColorTexture=new pt("transmission_color","transmissionColor","TRANSMISSION_COLOR"),this._transmissionDepth=new ct("transmission_depth",0,"vTransmissionDepth",1,0),this._transmissionDepthTexture=new pt("transmission_depth","transmissionDepth","TRANSMISSION_DEPTH"),this._transmissionScatter=new ct("transmission_scatter",oe.Black(),"vTransmissionScatter",3,0),this._transmissionScatterTexture=new pt("transmission_scatter","transmissionScatter","TRANSMISSION_SCATTER"),this._transmissionScatterAnisotropy=new ct("transmission_scatter_anisotropy",0,"vTransmissionScatterAnisotropy",1,0),this._transmissionDispersionScale=new ct("transmission_dispersion_scale",0,"vTransmissionDispersionScale",1,0),this._transmissionDispersionScaleTexture=new pt("transmission_dispersion_scale","transmissionDispersionScale","TRANSMISSION_DISPERSION_SCALE"),this._transmissionDispersionAbbeNumber=new ct("transmission_dispersion_abbe_number",20,"vTransmissionDispersionAbbeNumber",1,0),this._subsurfaceWeight=new ct("subsurface_weight",0,"vSubsurfaceWeight",1,0,"SUBSURFACE_SLAB"),this._subsurfaceWeightTexture=new pt("subsurface_weight","subsurfaceWeight","SUBSURFACE_WEIGHT"),this._subsurfaceColor=new ct("subsurface_color",new oe(.8,.8,.8),"vSubsurfaceColor",3,0,"SUBSURFACE_SLAB"),this._subsurfaceColorTexture=new pt("subsurface_color","subsurfaceColor","SUBSURFACE_COLOR"),this._subsurfaceRadius=new ct("subsurface_radius",.1,"vSubsurfaceRadius",1,0,"SUBSURFACE_SLAB"),this._subsurfaceRadiusScale=new ct("subsurface_radius_scale",new oe(1,.5,.25),"vSubsurfaceRadiusScale",3,0,"SUBSURFACE_SLAB"),this._subsurfaceRadiusScaleTexture=new pt("subsurface_radius_scale","subsurfaceRadiusScale","SUBSURFACE_RADIUS_SCALE"),this._subsurfaceScatterAnisotropy=new ct("subsurface_scatter_anisotropy",0,"vSubsurfaceScatterAnisotropy",1,0,"SUBSURFACE_SLAB"),this._coatWeight=new ct("coat_weight",0,"vCoatWeight",1,0),this._coatWeightTexture=new pt("coat_weight","coatWeight","COAT_WEIGHT"),this._coatColor=new ct("coat_color",oe.White(),"vCoatColor",3,0),this._coatColorTexture=new pt("coat_color","coatColor","COAT_COLOR"),this._coatRoughness=new ct("coat_roughness",0,"vCoatRoughness",1,0),this._coatRoughnessTexture=new pt("coat_roughness","coatRoughness","COAT_ROUGHNESS"),this._coatRoughnessAnisotropy=new ct("coat_roughness_anisotropy",0,"vCoatRoughnessAnisotropy",1),this._coatRoughnessAnisotropyTexture=new pt("coat_roughness_anisotropy","coatRoughnessAnisotropy","COAT_ROUGHNESS_ANISOTROPY"),this._coatIor=new ct("coat_ior",1.5,"vCoatIor",1,0),this._coatDarkening=new ct("coat_darkening",1,"vCoatDarkening",1,0),this._coatDarkeningTexture=new pt("coat_darkening","coatDarkening","COAT_DARKENING"),this.useCoatRoughnessFromWeightTexture=!1,this._fuzzWeight=new ct("fuzz_weight",0,"vFuzzWeight",1,0),this._fuzzWeightTexture=new pt("fuzz_weight","fuzzWeight","FUZZ_WEIGHT"),this._fuzzColor=new ct("fuzz_color",oe.White(),"vFuzzColor",3,0),this._fuzzColorTexture=new pt("fuzz_color","fuzzColor","FUZZ_COLOR"),this._fuzzRoughness=new ct("fuzz_roughness",.5,"vFuzzRoughness",1,0),this._fuzzRoughnessTexture=new pt("fuzz_roughness","fuzzRoughness","FUZZ_ROUGHNESS"),this._geometryThinWalled=new ct("geometry_thin_walled",0,"vGeometryThinWalled",1,0),this._geometryNormalTexture=new pt("geometry_normal","geometryNormal","GEOMETRY_NORMAL"),this._geometryTangent=new ct("geometry_tangent",new _e(1,0),"vSpecularAnisotropy",3,0),this._geometryTangentTexture=new pt("geometry_tangent","geometryTangent","GEOMETRY_TANGENT"),this._geometryCoatNormalTexture=new pt("geometry_coat_normal","geometryCoatNormal","GEOMETRY_COAT_NORMAL"),this._geometryCoatTangent=new ct("geometry_coat_tangent",new _e(1,0),"vGeometryCoatTangent",2,0),this._geometryCoatTangentTexture=new pt("geometry_coat_tangent","geometryCoatTangent","GEOMETRY_COAT_TANGENT"),this._geometryOpacity=new ct("geometry_opacity",1,"vBaseColor",4,3),this._geometryOpacityTexture=new pt("geometry_opacity","geometryOpacity","GEOMETRY_OPACITY"),this._geometryThickness=new ct("geometry_thickness",0,"vGeometryThickness",1,0),this._geometryThicknessTexture=new pt("geometry_thickness","geometryThickness","GEOMETRY_THICKNESS"),this._emissionLuminance=new ct("emission_luminance",1,"vLightingIntensity",4,1),this._emissionColor=new ct("emission_color",oe.Black(),"vEmissionColor",3),this._emissionColorTexture=new pt("emission_color","emissionColor","EMISSION_COLOR"),this._thinFilmWeight=new ct("thin_film_weight",0,"vThinFilmWeight",1,0),this._thinFilmWeightTexture=new pt("thin_film_weight","thinFilmWeight","THIN_FILM_WEIGHT"),this._thinFilmThickness=new ct("thin_film_thickness",.5,"vThinFilmThickness",2,0),this._thinFilmThicknessMin=new ct("thin_film_thickness_min",0,"vThinFilmThickness",2,1),this._thinFilmThicknessTexture=new pt("thin_film_thickness","thinFilmThickness","THIN_FILM_THICKNESS"),this._thinFilmIor=new ct("thin_film_ior",1.4,"vThinFilmIor",1,0),this._ambientOcclusionTexture=new pt("ambient_occlusion","ambientOcclusion","AMBIENT_OCCLUSION"),this._sssQuality=n.SSS_QUALITY_MEDIUM,this._sssIrradianceTexture=null,this._sssDepthTexture=null,this._uniformsList={},this._uniformsArray=[],this._samplersList={},this._samplerDefines={},this.directIntensity=1,this.environmentIntensity=1,this.useSpecularWeightFromTextureAlpha=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._lightingInfos=new vt(this.directIntensity,1,this.environmentIntensity,1),this._radianceTexture=null,this._useSpecularWeightFromAlpha=!1,this._useSpecularWeightFromSpecularColorTexture=!1,this._useSpecularRoughnessAnisotropyFromTangentTexture=!1,this._useCoatRoughnessAnisotropyFromTangentTexture=!1,this._useCoatRoughnessFromGreenChannel=!1,this._useGltfStyleAnisotropy=!1,this._useFuzzRoughnessFromTextureAlpha=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromBaseColorTexture=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallicFromMetallicTextureBlue=!1,this._useThinFilmThicknessFromTextureGreen=!1,this._useGeometryThicknessFromGreenChannel=!1,this._lightFalloff=ae.LIGHTFALLOFF_PHYSICAL,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._environmentFuzzBRDFTexture=null,this._backgroundRefractionTexture=null,this._refractionHighQualityBlur=!0,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=8,this._fuzzSampleNumber=4,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._renderTargets=new Ct(16),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this._vertexPullingMetadata=null,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this._transparencyMode=ae.MATERIAL_OPAQUE,this.getScene()&&!((s=this.getScene())!=null&&s.getEngine().isWebGPU)&&this.getScene().getEngine().webGLVersion<2&&W.Error("OpenPBRMaterial: WebGL 2.0 or above is required for this material."),n._noiseTextures[this.getScene().uniqueId]||(n._noiseTextures[this.getScene().uniqueId]=new ne(re.GetAssetUrl("https://assets.babylonjs.com/core/blue_noise/blue_noise_rgb.png"),this.getScene(),!1,!0,1),this.getScene().onDisposeObservable.addOnce(()=>{var a;(a=n._noiseTextures[this.getScene().uniqueId])==null||a.dispose(),delete n._noiseTextures[this.getScene().uniqueId]})),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),ie.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget&&this._renderTargets.push(this._radianceTexture),ie.RefractionTextureEnabled&&this._backgroundRefractionTexture&&this._backgroundRefractionTexture.isRenderTarget&&this._renderTargets.push(this._backgroundRefractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=cN(this.getScene()),this._environmentFuzzBRDFTexture=MT(this.getScene()),this.prePassConfiguration=new hr,this._propertyList={};for(let a of Object.getOwnPropertyNames(this)){let o=this[a];o instanceof ct&&(this._propertyList[a]=o)}Object.keys(this._propertyList).forEach(a=>{let o=this._propertyList[a],l=this._uniformsList[o.targetUniformName];l?l.numComponents!==o.targetUniformComponentNum?W.Error(`Uniform ${o.targetUniformName} already exists of size ${l.numComponents}, but trying to set it to ${o.targetUniformComponentNum}.`):l.requiredDefine!==o.requiredDefine&&(l.requiredDefine=void 0):(l=new jm(o.targetUniformName,o.targetUniformComponentNum),l.requiredDefine=o.requiredDefine,this._uniformsList[o.targetUniformName]=l),l.firstLinkedKey===""&&(l.firstLinkedKey=o.name),l.linkedProperties[o.name]=o}),this._uniformsArray=Object.values(this._uniformsList),this._samplersList={};for(let a of Object.getOwnPropertyNames(this)){let o=this[a];o instanceof pt&&(this._samplersList[a]=o)}for(let a in this._samplersList){let l=this._samplersList[a].textureDefine;this._samplerDefines[l]={type:"boolean",default:!1},this._samplerDefines[l+"DIRECTUV"]={type:"number",default:0},this._samplerDefines[l+"_GAMMA"]={type:"boolean",default:!1}}this._baseWeight,this._baseWeightTexture,this._baseColor,this._baseColorTexture,this._baseDiffuseRoughness,this._baseDiffuseRoughnessTexture,this._baseMetalness,this._baseMetalnessTexture,this._specularWeight,this._specularWeightTexture,this._specularColor,this._specularColorTexture,this._specularRoughness,this._specularIor,this._specularRoughnessTexture,this._specularRoughnessAnisotropy,this._specularRoughnessAnisotropyTexture,this._transmissionWeight,this._transmissionWeightTexture,this._transmissionColor,this._transmissionColorTexture,this._transmissionDepth,this._transmissionDepthTexture,this._transmissionScatter,this._transmissionScatterTexture,this._transmissionScatterAnisotropy,this._transmissionDispersionScale,this._transmissionDispersionScaleTexture,this._transmissionDispersionAbbeNumber,this._subsurfaceWeight,this._subsurfaceWeightTexture,this._subsurfaceColor,this._subsurfaceColorTexture,this._subsurfaceRadius,this._subsurfaceRadiusScale,this._subsurfaceRadiusScaleTexture,this._subsurfaceScatterAnisotropy,this._coatWeight,this._coatWeightTexture,this._coatColor,this._coatColorTexture,this._coatRoughness,this._coatRoughnessTexture,this._coatRoughnessAnisotropy,this._coatRoughnessAnisotropyTexture,this._coatIor,this._coatDarkening,this._coatDarkeningTexture,this._fuzzWeight,this._fuzzWeightTexture,this._fuzzColor,this._fuzzColorTexture,this._fuzzRoughness,this._fuzzRoughnessTexture,this._geometryThinWalled,this._geometryNormalTexture,this._geometryTangent,this._geometryTangentTexture,this._geometryCoatNormalTexture,this._geometryCoatTangent,this._geometryCoatTangentTexture,this._geometryOpacity,this._geometryOpacityTexture,this._geometryThickness,this._geometryThicknessTexture,this._thinFilmWeight,this._thinFilmWeightTexture,this._thinFilmThickness,this._thinFilmThicknessMin,this._thinFilmThicknessTexture,this._thinFilmIor,this._emissionLuminance,this._emissionColor,this._emissionColorTexture,this._ambientOcclusionTexture}get hasRenderTargetTextures(){return ie.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget||ie.RefractionTextureEnabled&&this._backgroundRefractionTexture&&this._backgroundRefractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"OpenPBRMaterial"}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}_shouldUseAlphaFromBaseColorTexture(){return this._hasAlphaChannel()&&this._transparencyMode!==ae.MATERIAL_OPAQUE&&!this.geometryOpacityTexture}_hasAlphaChannel(){return this.baseColorTexture!=null&&this.baseColorTexture.hasAlpha&&this._useAlphaFromBaseColorTexture||this.geometryOpacityTexture!=null}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.id=e,r.name=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}serialize(){let e=super.serialize();return e.customType="BABYLON.OpenPBRMaterial",e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),r}forceCompilation(e,t,i){let r={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),(()=>{if(this._breakShaderLoadedCheck)return;let a=new td({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Tc.effect=o,Tc.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Tc)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}isReadyForSubMesh(e,t,i){var h;this._uniformBufferLayoutBuilt||this.buildUniformLayout();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new td({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}));let s=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(s._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){for(let m in this._samplersList){let p=this._samplersList[m];if(p.value&&!p.value.isReadyOrNotBlocking())return!1}let u=this._getRadianceTexture();if(u&&ie.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((h=u.getInternalTexture())!=null&&h._sphericalPolynomialPromise))return!1}if(this._environmentBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady()||this._environmentFuzzBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentFuzzBRDFTexture.isReady()||this._backgroundRefractionTexture&&ie.RefractionTextureEnabled&&!this._backgroundRefractionTexture.isReadyOrNotBlocking()||n._noiseTextures[a.uniqueId]&&!n._noiseTextures[a.uniqueId].isReady()||this._sssIrradianceTexture&&this._sssDepthTexture&&(!this._sssIrradianceTexture.isReady()||!this._sssDepthTexture.isReady()))return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||s._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(s.AREALIGHTUSED){for(let u=0;u{e.addUniform(t.name,t.numComponents)}),Object.values(this._samplersList).forEach(t=>{e.addUniform(t.samplerInfoName,2),e.addUniform(t.samplerMatrixName,16)}),super.buildUniformLayout()}bindPropertiesForSubMesh(e,t,i,r){if(this.geometryThickness===0)e.updateFloat("vGeometryThickness",0);else{r.getRenderingMesh().getWorldMatrix().decompose(G.Vector3[0]);let s=Math.max(Math.abs(G.Vector3[0].x),Math.abs(G.Vector3[0].y),Math.abs(G.Vector3[0].z));e.updateFloat("vGeometryThickness",this.geometryThickness*s)}}bindForSubMesh(e,t,i){var d;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e);let o=r.getEngine();this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Vi.Bind(o.currentRenderPassId,this._activeEffect,t,e,this);let l=r.activeCamera;l?this._uniformBuffer.updateFloat4("cameraInfo",l.minZ,l.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);or(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&Pa(this._activeEffect,this._vertexPullingMetadata);let f=this._uniformBuffer;if(c){this.bindViewProjection(a);let h=this._getRadianceTexture();if(!f.useUbo||!this.isFrozen||!f.isSync||i._drawWrapper._forceRebindOnNextCall){if(r.texturesEnabled){for(let m in this._samplersList){let p=this._samplersList[m];p.value&&(f.updateFloat2(p.samplerInfoName,p.value.coordinatesIndex,p.value.level),lt(p.value,f,p.samplerPrefix))}(this.geometryNormalTexture||this.geometryCoatNormalTexture)&&(r._mirroredCameraPosition?f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),Pl(r,s,f,oe.White(),h,this.realTimeFiltering,!0,!0,!0,!0,!0)}this.pointsCloud&&f.updateFloat("pointSize",this.pointSize);let u=this._uniformsArray;for(let m=0,p=u.length;m0&&e.push(i.value)}return this._radianceTexture&&this._radianceTexture.animations&&this._radianceTexture.animations.length>0&&e.push(this._radianceTexture),e}getActiveTextures(){let e=super.getActiveTextures();for(let t in this._samplersList){let i=this._samplersList[t];i.value&&e.push(i.value)}return this._radianceTexture&&e.push(this._radianceTexture),e}hasTexture(e){if(super.hasTexture(e))return!0;for(let t in this._samplersList)if(this._samplersList[t].value===e)return!0;return this._radianceTexture===e}setPrePassRenderer(){return!1}dispose(e,t){var i,r;if(this._breakShaderLoadedCheck=!0,t){this._environmentBRDFTexture&&this.getScene().openPBREnvironmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._environmentFuzzBRDFTexture&&this.getScene().environmentFuzzBRDFTexture!==this._environmentFuzzBRDFTexture&&this._environmentFuzzBRDFTexture.dispose(),this._backgroundRefractionTexture=null;for(let s in this._samplersList)(i=this._samplersList[s].value)==null||i.dispose();(r=this._radianceTexture)==null||r.dispose()}this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}_getRadianceTexture(){return this._radianceTexture?this._radianceTexture:this.getScene().environmentTexture}_prepareEffect(e,t,i,r=null,s=null,a=null,o=null){if(this._prepareDefines(e,t,i,a,o),!i.isDirty)return null;i.markAsProcessed();let c=this.getScene().getEngine(),f=new Ui,d=0;i.USESPHERICALINVERTEX&&f.addFallback(d++,"USESPHERICALINVERTEX"),i.FOG&&f.addFallback(d,"FOG"),i.SPECULARAA&&f.addFallback(d,"SPECULARAA"),i.POINTSIZE&&f.addFallback(d,"POINTSIZE"),i.LOGARITHMICDEPTH&&f.addFallback(d,"LOGARITHMICDEPTH"),i.PARALLAX&&f.addFallback(d,"PARALLAX"),i.PARALLAX_RHS&&f.addFallback(d,"PARALLAX_RHS"),i.PARALLAXOCCLUSION&&f.addFallback(d++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&f.addFallback(d++,"ENVIRONMENTBRDF"),i.TANGENT&&f.addFallback(d++,"TANGENT"),d=Bl(i,f,this._maxSimultaneousLights,d),i.SPECULARTERM&&f.addFallback(d++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&f.addFallback(d++,"USESPHERICALFROMREFLECTIONMAP"),i.USEIRRADIANCEMAP&&f.addFallback(d++,"USEIRRADIANCEMAP"),i.NORMAL&&f.addFallback(d++,"NORMAL"),i.VERTEXCOLOR&&f.addFallback(d++,"VERTEXCOLOR"),i.MORPHTARGETS&&f.addFallback(d++,"MORPHTARGETS"),i.MULTIVIEW&&f.addFallback(0,"MULTIVIEW");let h=[M.PositionKind];i.NORMAL&&h.push(M.NormalKind),i.TANGENT&&h.push(M.TangentKind);for(let S=1;S<=6;++S)i["UV"+S]&&h.push(`uv${S===1?"":S}`);i.VERTEXCOLOR&&h.push(M.ColorKind),Fl(h,e,i,f),wl(h,i),bo(h,e,i),Ol(h,e,i);let u="openpbr",m=["world","view","viewProjection","projection","vEyePosition","inverseProjection","renderTargetSize","vLightsType","visibility","vFogInfos","vFogColor","pointSize","mBones","normalMatrix","vLightingIntensity","logarithmicDepthConstant","vTangentSpaceParams","boneTextureInfo","vDebugMode","morphTargetTextureInfo","morphTargetTextureIndices","cameraInfo","backgroundRefractionMatrix","vBackgroundRefractionInfos"];for(let S in this._uniformsList)m.push(S);let p=["environmentBrdfSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"];i.FUZZENVIRONMENTBRDF&&p.push("environmentFuzzBrdfSampler"),i.REFRACTED_BACKGROUND&&p.push("backgroundRefractionSampler"),(i.ANISOTROPIC||i.FUZZ||i.REFRACTED_BACKGROUND||i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)&&p.push("blueNoiseSampler"),i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING&&(p.push("sceneIrradianceSampler"),p.push("sceneDepthSampler"));for(let S in this._samplersList){let I=this._samplersList[S];p.push(I.samplerName),m.push(I.samplerInfoName),m.push(I.samplerMatrixName)}Ia(m,p,!0);let _=["Material","Scene","Mesh"],g={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS};if(this._eventInfo.fallbacks=f,this._eventInfo.fallbackRank=d,this._eventInfo.defines=i,this._eventInfo.uniforms=m,this._eventInfo.attributes=h,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=_,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=g,this._callbackPluginEventGeneric(128,this._eventInfo),Vi.AddUniformsAndSamplers(m,p),hr.AddUniforms(m),hr.AddSamplers(p),Li(m),this._useVertexPulling){let S=t==null?void 0:t.geometry;S&&(this._vertexPullingMetadata=La(S),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((I,x)=>{m.push(`vp_${x}_info`)}))}else this._vertexPullingMetadata=null;Je&&(Je.PrepareUniforms(m,i),Je.PrepareSamplers(p,i)),Yl({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,h,T));let b=i.toString(),R=c.createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:f,onCompiled:r,onError:s,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:i.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(rF(),iF)),Promise.resolve().then(()=>(ew(),$F))]):await Promise.all([Promise.resolve().then(()=>(fw(),cw)),Promise.resolve().then(()=>(l1(),o1))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,R}_prepareDefines(e,t,i,r=null,s=null){var d;let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Gl(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Hl(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(o,i,this.canRenderToMRT&&!c),zl(o,i,c),Vi.PrepareDefines(l.currentRenderPassId,e,i),i._areTexturesDirty){i._needUVs=!1;for(let h=1;h<=6;++h)i["MAINUV"+h]=!1;if(o.texturesEnabled){for(let m in this._samplersList){let p=this._samplersList[m];p.value?(ot(p.value,i,p.textureDefine),i[p.textureDefine+"_GAMMA"]=p.value.gammaSpace):i[p.textureDefine]=!1}let h=this._getRadianceTexture(),u=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;if(Ra(o,h,i,this.realTimeFiltering,this.realTimeFilteringQuality,!u),this._baseMetalnessTexture&&(i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed),i.SPECULAR_WEIGHT_IN_ALPHA=this._useSpecularWeightFromAlpha,i.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE=this._useSpecularWeightFromSpecularColorTexture,i.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=this._useSpecularRoughnessAnisotropyFromTangentTexture,i.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE=this._useCoatRoughnessAnisotropyFromTangentTexture,i.COAT_ROUGHNESS_FROM_GREEN_CHANNEL=this._useCoatRoughnessFromGreenChannel,i.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN=this._useRoughnessFromMetallicTextureGreen,i.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA=this._useFuzzRoughnessFromTextureAlpha,i.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE=this._useMetallicFromMetallicTextureBlue,i.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE=this._useThinFilmThicknessFromTextureGreen,i.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL=this._useGeometryThicknessFromGreenChannel,this.geometryNormalTexture?(this._useParallax&&this.baseColorTexture&&ie.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=o.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&ie.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._environmentFuzzBRDFTexture?i.FUZZENVIRONMENTBRDF=!0:i.FUZZENVIRONMENTBRDF=!1,this.hasTransparency){i.REFRACTED_BACKGROUND=!!this._backgroundRefractionTexture&&ie.RefractionTextureEnabled,i.REFRACTION_HIGH_QUALITY_BLUR=this._refractionHighQualityBlur,i.REFRACTED_LIGHTS=!0;let m=this._getRadianceTexture();m?(i.REFRACTED_ENVIRONMENT=ie.RefractionTextureEnabled,i.REFRACTED_ENVIRONMENT_OPPOSITEZ=this.getScene().useRightHandedSystem?!m.invertZ:m.invertZ,i.REFRACTED_ENVIRONMENT_LOCAL_CUBE=m.isCube&&m.boundingBoxSize):i.REFRACTED_ENVIRONMENT=!1}else i.REFRACTED_BACKGROUND=!1,i.REFRACTED_LIGHTS=!1,i.REFRACTED_ENVIRONMENT=!1;this._shouldUseAlphaFromBaseColorTexture()?i.ALPHA_FROM_BASE_COLOR_TEXTURE=!0:i.ALPHA_FROM_BASE_COLOR_TEXTURE=!1}this._lightFalloff===ae.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===ae.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.MIRRORED=!!o._mirroredCameraPosition,i.SPECULARAA=l.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,i.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,i.ALPHABLEND=this.needAlphaBlendingForMesh(e)),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,(this.specularRoughnessAnisotropy>0||this.coatRoughnessAnisotropy>0)&&n._noiseTextures[o.uniqueId]&&ie.ReflectionTextureEnabled?(i.ANISOTROPIC=!0,e.isVerticesDataPresent(M.TangentKind)||(i._needUVs=!0,i.MAINUV1=!0),this._useGltfStyleAnisotropy&&(i.USE_GLTF_STYLE_ANISOTROPY=!0),i.ANISOTROPIC_BASE=this.specularRoughnessAnisotropy>0,i.ANISOTROPIC_COAT=this.coatRoughnessAnisotropy>0):(i.ANISOTROPIC=!1,i.USE_GLTF_STYLE_ANISOTROPY=!1,i.ANISOTROPIC_BASE=!1,i.ANISOTROPIC_COAT=!1),i.THIN_FILM=this.thinFilmWeight>0,i.IRIDESCENCE=this.thinFilmWeight>0,i.DISPERSION=this.transmissionDispersionScale>0,i.SCATTERING=this.hasScattering;let f=[8,16,32];if(i.SSS_SAMPLE_COUNT=(d=f[this._sssQuality])!=null?d:16,i.TRANSMISSION_SLAB=this.transmissionWeight>0,i.TRANSMISSION_SLAB_VOLUME=this.transmissionWeight>0&&this.transmissionDepth>0,i.SUBSURFACE_SLAB=this.subsurfaceWeight>0,!i.PREPASS&&(i.SUBSURFACE_SLAB||i.TRANSMISSION_SLAB_VOLUME)){let h=!1;if(!this.sssIrradianceTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(Zi.IRRADIANCE_TEXTURE_TYPE);this.sssIrradianceTexture=o.geometryBufferRenderer.getGBuffer().textures[u],h=!0}if(!this.sssDepthTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(Zi.SCREENSPACE_DEPTH_TEXTURE_TYPE);this.sssDepthTexture=o.geometryBufferRenderer.getGBuffer().textures[u],h=!0}this.sssIrradianceTexture&&this.sssDepthTexture&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING=!0,h&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER=!0))}i.FUZZ=this.fuzzWeight>0&&ie.ReflectionTextureEnabled,i.GEOMETRY_THIN_WALLED=this.geometryThinWalled!=0,i.FUZZ?(e.isVerticesDataPresent(M.TangentKind)||(i._needUVs=!0,i.MAINUV1=!0),this._environmentFuzzBRDFTexture=MT(this.getScene()),i.FUZZ_IBL_SAMPLES=this.fuzzSampleNumber):(this._environmentFuzzBRDFTexture=null,i.FUZZENVIRONMENTBRDF=!1,i.FUZZ_IBL_SAMPLES=0),i._areMiscDirty&&(Ul(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),i,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t,this._isVertexOutputInvariant),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(M.NormalKind),i.DEBUGMODE=this._debugMode),kl(o,l,this,i,!!r,s,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Wl(e,i,!0,!0,!0,this._transparencyMode!==ae.MATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}};pe.SSS_QUALITY_LOW=0;pe.SSS_QUALITY_MEDIUM=1;pe.SSS_QUALITY_HIGH=2;pe._noiseTextures={};pe.ForceGLSL=!1;C([Be("_markAllSubMeshesAsTexturesDirty","baseWeight")],pe.prototype,"_baseWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseWeightTexture")],pe.prototype,"_baseWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseColor")],pe.prototype,"_baseColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseColorTexture")],pe.prototype,"_baseColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughness")],pe.prototype,"_baseDiffuseRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughnessTexture")],pe.prototype,"_baseDiffuseRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseMetalness")],pe.prototype,"_baseMetalness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","baseMetalnessTexture")],pe.prototype,"_baseMetalnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularWeight")],pe.prototype,"_specularWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularWeightTexture")],pe.prototype,"_specularWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularColor")],pe.prototype,"_specularColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularColorTexture")],pe.prototype,"_specularColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughness")],pe.prototype,"_specularRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessTexture")],pe.prototype,"_specularRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropy")],pe.prototype,"_specularRoughnessAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropyTexture")],pe.prototype,"_specularRoughnessAnisotropyTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","specularIor")],pe.prototype,"_specularIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionWeight")],pe.prototype,"_transmissionWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionWeightTexture")],pe.prototype,"_transmissionWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionColor")],pe.prototype,"_transmissionColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionColorTexture")],pe.prototype,"_transmissionColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDepth")],pe.prototype,"_transmissionDepth",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDepthTexture")],pe.prototype,"_transmissionDepthTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatter")],pe.prototype,"_transmissionScatter",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatterTexture")],pe.prototype,"_transmissionScatterTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionScatterAnisotropy")],pe.prototype,"_transmissionScatterAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScale")],pe.prototype,"_transmissionDispersionScale",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScaleTexture")],pe.prototype,"_transmissionDispersionScaleTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","transmissionDispersionAbbeNumber")],pe.prototype,"_transmissionDispersionAbbeNumber",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceWeight")],pe.prototype,"_subsurfaceWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceWeightTexture")],pe.prototype,"_subsurfaceWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceColor")],pe.prototype,"_subsurfaceColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceColorTexture")],pe.prototype,"_subsurfaceColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadius")],pe.prototype,"_subsurfaceRadius",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScale")],pe.prototype,"_subsurfaceRadiusScale",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScaleTexture")],pe.prototype,"_subsurfaceRadiusScaleTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","subsurfaceScatterAnisotropy")],pe.prototype,"_subsurfaceScatterAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatWeight")],pe.prototype,"_coatWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatWeightTexture")],pe.prototype,"_coatWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatColor")],pe.prototype,"_coatColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatColorTexture")],pe.prototype,"_coatColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughness")],pe.prototype,"_coatRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessTexture")],pe.prototype,"_coatRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropy")],pe.prototype,"_coatRoughnessAnisotropy",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropyTexture")],pe.prototype,"_coatRoughnessAnisotropyTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatIor")],pe.prototype,"_coatIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatDarkening")],pe.prototype,"_coatDarkening",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","coatDarkeningTexture")],pe.prototype,"_coatDarkeningTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzWeight")],pe.prototype,"_fuzzWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzWeightTexture")],pe.prototype,"_fuzzWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzColor")],pe.prototype,"_fuzzColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzColorTexture")],pe.prototype,"_fuzzColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzRoughness")],pe.prototype,"_fuzzRoughness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","fuzzRoughnessTexture")],pe.prototype,"_fuzzRoughnessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThinWalled")],pe.prototype,"_geometryThinWalled",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryNormalTexture")],pe.prototype,"_geometryNormalTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryTangent")],pe.prototype,"_geometryTangent",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryTangentTexture")],pe.prototype,"_geometryTangentTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatNormalTexture")],pe.prototype,"_geometryCoatNormalTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatTangent")],pe.prototype,"_geometryCoatTangent",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryCoatTangentTexture")],pe.prototype,"_geometryCoatTangentTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryOpacity")],pe.prototype,"_geometryOpacity",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryOpacityTexture")],pe.prototype,"_geometryOpacityTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThickness")],pe.prototype,"_geometryThickness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","geometryThicknessTexture")],pe.prototype,"_geometryThicknessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionLuminance")],pe.prototype,"_emissionLuminance",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionColor")],pe.prototype,"_emissionColor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","emissionColorTexture")],pe.prototype,"_emissionColorTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmWeight")],pe.prototype,"_thinFilmWeight",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmWeightTexture")],pe.prototype,"_thinFilmWeightTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThickness")],pe.prototype,"_thinFilmThickness",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessMin")],pe.prototype,"_thinFilmThicknessMin",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessTexture")],pe.prototype,"_thinFilmThicknessTexture",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","thinFilmIor")],pe.prototype,"_thinFilmIor",void 0);C([Be("_markAllSubMeshesAsTexturesDirty","ambientOcclusionTexture")],pe.prototype,"_ambientOcclusionTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"directIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"environmentIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useSpecularWeightFromTextureAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],pe.prototype,"forceAlphaTest",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],pe.prototype,"alphaCutOff",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAmbientInGrayScale",void 0);C([D()],pe.prototype,"usePhysicalLightFalloff",null);C([D()],pe.prototype,"useGLTFLightFalloff",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useObjectSpaceNormalMap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useParallax",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useParallaxOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"parallaxScaleBias",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],pe.prototype,"disableLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"forceIrradianceInFragment",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],pe.prototype,"maxSimultaneousLights",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"invertNormalMapX",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"invertNormalMapY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"twoSidedLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useAlphaFresnel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useLinearAlphaFresnel",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"environmentBRDFTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"forceNormalForward",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"enableSpecularAntiAliasing",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useHorizonOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],pe.prototype,"useRadianceOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"unlit",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"applyDecalMapAfterDetailMap",void 0);C([ee("_markAllSubMeshesAsMiscDirty")],pe.prototype,"debugMode",void 0);C([D()],pe.prototype,"transparencyMode",null);je("BABYLON.OpenPBRMaterial",pe)});var d1={};De(d1,{OpenPBRMaterialLoadingAdapter:()=>CS});var CS,h1=A(()=>{et();CS=class{constructor(e){this._diffuseTransmissionTint=oe.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){}get alphaCutOff(){return .5}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return!1}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){let t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){var t;let e=this._material.ambientOcclusionTexture;return(t=e==null?void 0:e.level)!=null?t:1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}set coatDarkening(e){this._material.coatDarkening=e}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||this._material.transmissionDepth!==0?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(oe.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=e?1:0}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}finalize(){(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(oe.White())||this._diffuseTransmissionTintTexture)&&(this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture):this._material.coatWeight==0&&(!this.baseColor.equals(oe.White())||this.baseColorTexture)&&(this._material.coatWeight=this.subsurfaceWeight,this._material.coatWeightTexture=this.subsurfaceWeightTexture,this._material.coatColor=this._diffuseTransmissionTint,this._material.coatColorTexture=this._diffuseTransmissionTintTexture,this._material.coatIor=this._material.specularIor,this._material.coatDarkening=0,this._material.coatRoughness=this._material.specularRoughness,this._material.coatRoughnessTexture=this._material.specularRoughnessTexture,this._material.specularRoughness=1,this._material.specularRoughnessTexture=null)),this.transmissionWeight>0&&(this._material.geometryThinWalled||this._material.transmissionDepth===0?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture):this._material.coatWeight==0&&(!this.baseColor.equals(oe.White())||this.baseColorTexture!==null)&&(this._material.coatWeight=this.transmissionWeight,this._material.coatWeightTexture=this.transmissionWeightTexture,this._material.coatColor=this.baseColor,this._material.coatColorTexture=this.baseColorTexture,this._material.coatIor=this._material.specularIor,this._material.coatDarkening=0,this._material.coatRoughness=this._material.specularRoughness,this._material.coatRoughnessTexture=this._material.specularRoughnessTexture))}}});var bS,ei,u1=A(()=>{Qe();qe();Yr();Fa();bS=class extends Zt{constructor(){super(...arguments),this.BRDF_V_HEIGHT_CORRELATED=!1,this.MS_BRDF_ENERGY_CONSERVATION=!1,this.SPHERICAL_HARMONICS=!1,this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,this.MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0,this.LEGACY_SPECULAR_ENERGY_CONSERVATION=!1,this.BASE_DIFFUSE_MODEL=0,this.DIELECTRIC_SPECULAR_MODEL=0,this.CONDUCTOR_SPECULAR_MODEL=0}},ei=class n extends si{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new bS,t),this._useEnergyConservation=n.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=n.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=n.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=n.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=n.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=n.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=n.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=n.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._mixIblRadianceWithIrradiance=n.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this.mixIblRadianceWithIrradiance=n.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this._useLegacySpecularEnergyConservation=n.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this.useLegacySpecularEnergyConservation=n.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this._baseDiffuseModel=n.DEFAULT_DIFFUSE_MODEL,this.baseDiffuseModel=n.DEFAULT_DIFFUSE_MODEL,this._dielectricSpecularModel=n.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this.dielectricSpecularModel=n.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this._conductorSpecularModel=n.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this.conductorSpecularModel=n.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16],this._enable(!0)}prepareDefines(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation,e.MIX_IBL_RADIANCE_WITH_IRRADIANCE=this._mixIblRadianceWithIrradiance&&!this._material._disableLighting,e.LEGACY_SPECULAR_ENERGY_CONSERVATION=this._useLegacySpecularEnergyConservation,e.BASE_DIFFUSE_MODEL=this._baseDiffuseModel,e.DIELECTRIC_SPECULAR_MODEL=this._dielectricSpecularModel,e.CONDUCTOR_SPECULAR_MODEL=this._conductorSpecularModel}getClassName(){return"PBRBRDFConfiguration"}};ei.DEFAULT_USE_ENERGY_CONSERVATION=!0;ei.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0;ei.DEFAULT_USE_SPHERICAL_HARMONICS=!0;ei.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0;ei.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0;ei.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION=!0;ei.DEFAULT_DIFFUSE_MODEL=0;ei.DEFAULT_DIELECTRIC_SPECULAR_MODEL=0;ei.DEFAULT_CONDUCTOR_SPECULAR_MODEL=0;C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useEnergyConservation",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSmithVisibilityHeightCorrelated",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSphericalHarmonics",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"mixIblRadianceWithIrradiance",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"useLegacySpecularEnergyConservation",void 0);C([D("baseDiffuseModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"baseDiffuseModel",void 0);C([D("dielectricSpecularModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"dielectricSpecularModel",void 0);C([D("conductorSpecularModel"),ee("_markAllSubMeshesAsMiscDirty")],ei.prototype,"conductorSpecularModel",void 0)});var MS,gi,m1=A(()=>{Qe();qe();et();zr();Fa();Yr();Ni();MS=class extends Zt{constructor(){super(...arguments),this.CLEARCOAT=!1,this.CLEARCOAT_DEFAULTIOR=!1,this.CLEARCOAT_TEXTURE=!1,this.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this.CLEARCOAT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,this.CLEARCOAT_BUMP=!1,this.CLEARCOAT_BUMPDIRECTUV=0,this.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,this.CLEARCOAT_REMAP_F0=!1,this.CLEARCOAT_TINT=!1,this.CLEARCOAT_TINT_TEXTURE=!1,this.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,this.CLEARCOAT_TINT_GAMMATEXTURE=!1}},gi=class n extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new MS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=n._DefaultIndexOfRefraction,this.indexOfRefraction=n._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=oe.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,i){if(!this._isEnabled)return!0;let r=this._material._disableBumpMap;return!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ie.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&ie.ClearCoatBumpTextureEnabled&&!r&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&ie.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking()))}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.CLEARCOAT=!0,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled?ot(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&ie.ClearCoatTextureEnabled?ot(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&ie.ClearCoatBumpTextureEnabled?ot(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===n._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&ie.ClearCoatTintTextureEnabled?(ot(this._tintTexture,e,"CLEARCOAT_TINT_TEXTURE"),e.CLEARCOAT_TINT_GAMMATEXTURE=this._tintTexture.gammaSpace):e.CLEARCOAT_TINT_TEXTURE=!1):(e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1))):(e.CLEARCOAT=!1,e.CLEARCOAT_TEXTURE=!1,e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_TINT=!1,e.CLEARCOAT_TINT_TEXTURE=!1,e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.CLEARCOAT_DEFAULTIOR=!1,e.CLEARCOAT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,e.CLEARCOAT_BUMPDIRECTUV=0,e.CLEARCOAT_REMAP_F0=!1,e.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,e.CLEARCOAT_TINT_GAMMATEXTURE=!1)}bindForSubMesh(e,t,i,r){var f,d,h,u,m,p,_,g;if(!this._isEnabled)return;let s=r.materialDefines,a=this._material.isFrozen,o=this._material._disableBumpMap,l=this._material._invertNormalMapX,c=this._material._invertNormalMapY;if(!e.useUbo||!a||!e.isSync){(this._texture||this._textureRoughness)&&ie.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",(d=(f=this._texture)==null?void 0:f.coordinatesIndex)!=null?d:0,(u=(h=this._texture)==null?void 0:h.level)!=null?u:0,(p=(m=this._textureRoughness)==null?void 0:m.coordinatesIndex)!=null?p:0,(g=(_=this._textureRoughness)==null?void 0:_.level)!=null?g:0),this._texture&<(this._texture,e,"clearCoat"),this._textureRoughness&&!s.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&<(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&ie.ClearCoatTextureEnabled&&!o&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),lt(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",l?1:-1,c?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",l?-1:1,c?-1:1)),this._tintTexture&&ie.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),lt(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);let T=1-this._indexOfRefraction,b=1+this._indexOfRefraction,R=Math.pow(-T/b,2),S=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",R,S,T,b),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&ie.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!s.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&ie.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&ie.ClearCoatBumpTextureEnabled&&!o&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&ie.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))}hasTexture(e){return this._texture===e||this._textureRoughness===e||this._bumpTexture===e||this._tintTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)}dispose(e){var t,i,r,s;e&&((t=this._texture)==null||t.dispose(),(i=this._textureRoughness)==null||i.dispose(),(r=this._bumpTexture)==null||r.dispose(),(s=this._tintTexture)==null||s.dispose())}getClassName(){return"PBRClearCoatConfiguration"}addFallbacks(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i}getSamplers(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")}getUniforms(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}}};gi._DefaultIndexOfRefraction=1.5;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"isEnabled",void 0);C([D()],gi.prototype,"intensity",void 0);C([D()],gi.prototype,"roughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"indexOfRefraction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"useRoughnessFromMainTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"textureRoughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"remapF0OnInterfaceChange",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"bumpTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"isTintEnabled",void 0);C([Ht()],gi.prototype,"tintColor",void 0);C([D()],gi.prototype,"tintColorAtDistance",void 0);C([D()],gi.prototype,"tintThickness",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],gi.prototype,"tintTexture",void 0)});var yS,mr,p1=A(()=>{Qe();qe();zr();Fa();Yr();Ni();yS=class extends Zt{constructor(){super(...arguments),this.IRIDESCENCE=!1,this.IRIDESCENCE_TEXTURE=!1,this.IRIDESCENCE_TEXTUREDIRECTUV=0,this.IRIDESCENCE_THICKNESS_TEXTURE=!1,this.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0}},mr=class n extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new yS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=n._DefaultMinimumThickness,this.maximumThickness=n._DefaultMaximumThickness,this.indexOfRefraction=n._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._thicknessTexture=null,this.thicknessTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&ie.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled?ot(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&ie.IridescenceTextureEnabled?ot(this._thicknessTexture,e,"IRIDESCENCE_THICKNESS_TEXTURE"):e.IRIDESCENCE_THICKNESS_TEXTURE=!1)):(e.IRIDESCENCE=!1,e.IRIDESCENCE_TEXTURE=!1,e.IRIDESCENCE_THICKNESS_TEXTURE=!1,e.IRIDESCENCE_TEXTUREDIRECTUV=0,e.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0)}bindForSubMesh(e,t){var r,s,a,o,l,c,f,d;if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&((this._texture||this._thicknessTexture)&&ie.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",(s=(r=this._texture)==null?void 0:r.coordinatesIndex)!=null?s:0,(o=(a=this._texture)==null?void 0:a.level)!=null?o:0,(c=(l=this._thicknessTexture)==null?void 0:l.coordinatesIndex)!=null?c:0,(d=(f=this._thicknessTexture)==null?void 0:f.level)!=null?d:0),this._texture&<(this._texture,e,"iridescence"),this._thicknessTexture&<(this._thicknessTexture,e,"iridescenceThickness")),e.updateFloat4("vIridescenceParams",this.intensity,this.indexOfRefraction,this.minimumThickness,this.maximumThickness)),t.texturesEnabled&&(this._texture&&ie.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&ie.IridescenceTextureEnabled&&e.setTexture("iridescenceThicknessSampler",this._thicknessTexture))}hasTexture(e){return this._texture===e||this._thicknessTexture===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._thicknessTexture&&e.push(this._thicknessTexture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture)}dispose(e){var t,i;e&&((t=this._texture)==null||t.dispose(),(i=this._thicknessTexture)==null||i.dispose())}getClassName(){return"PBRIridescenceConfiguration"}addFallbacks(e,t,i){return e.IRIDESCENCE&&t.addFallback(i++,"IRIDESCENCE"),i}getSamplers(e){e.push("iridescenceSampler","iridescenceThicknessSampler")}getUniforms(){return{ubo:[{name:"vIridescenceParams",size:4,type:"vec4"},{name:"vIridescenceInfos",size:4,type:"vec4"},{name:"iridescenceMatrix",size:16,type:"mat4"},{name:"iridescenceThicknessMatrix",size:16,type:"mat4"}]}}};mr._DefaultMinimumThickness=100;mr._DefaultMaximumThickness=400;mr._DefaultIndexOfRefraction=1.3;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],mr.prototype,"isEnabled",void 0);C([D()],mr.prototype,"intensity",void 0);C([D()],mr.prototype,"minimumThickness",void 0);C([D()],mr.prototype,"maximumThickness",void 0);C([D()],mr.prototype,"indexOfRefraction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],mr.prototype,"texture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],mr.prototype,"thicknessTexture",void 0)});var DS,js,_1=A(()=>{Qe();qe();yt();ve();zr();Fa();Yr();Ni();DS=class extends Zt{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}},js=class extends si{set angle(e){this.direction.x=Math.cos(e),this.direction.y=Math.sin(e)}get angle(){return Math.atan2(this.direction.y,this.direction.x)}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markAllSubMeshesAsMiscDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRAnisotropic",110,new DS,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new _e(1,0),this._texture=null,this.texture=null,this._legacy=!1,this.legacy=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkAllSubMeshesAsMiscDirty=e._dirtyCallbacks[16]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&ie.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking()):!0}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(M.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.AnisotropicTextureEnabled?ot(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1),e._areMiscDirty&&(e.ANISOTROPIC_LEGACY=this._legacy)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1,e.ANISOTROPIC_TEXTUREDIRECTUV=0,e.ANISOTROPIC_LEGACY=!1)}bindForSubMesh(e,t){if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&(this._texture&&ie.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),lt(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&ie.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture&&this._texture.dispose()}getClassName(){return"PBRAnisotropicConfiguration"}addFallbacks(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i}getSamplers(e){e.push("anisotropySampler")}getUniforms(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}}parse(e,t,i){super.parse(e,t,i),e.legacy===void 0&&(this.legacy=!0)}};C([D(),ee("_markAllSubMeshesAsTexturesDirty")],js.prototype,"isEnabled",void 0);C([D()],js.prototype,"intensity",void 0);C([ul()],js.prototype,"direction",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],js.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],js.prototype,"legacy",void 0)});var LS,Ir,g1=A(()=>{Qe();qe();et();zr();Fa();Yr();Ni();LS=class extends Zt{constructor(){super(...arguments),this.SHEEN=!1,this.SHEEN_TEXTURE=!1,this.SHEEN_GAMMATEXTURE=!1,this.SHEEN_TEXTURE_ROUGHNESS=!1,this.SHEEN_TEXTUREDIRECTUV=0,this.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,this.SHEEN_LINKWITHALBEDO=!1,this.SHEEN_ROUGHNESS=!1,this.SHEEN_ALBEDOSCALING=!1,this.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1}},Ir=class extends si{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new LS,t),this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=oe.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&ie.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.SHEEN=!0,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=this._roughness!==null,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled?(ot(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&ie.SheenTextureEnabled?ot(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_GAMMATEXTURE=!1,e.SHEEN_TEXTUREDIRECTUV=0,e.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0)}bindForSubMesh(e,t,i,r){var o,l,c,f,d,h,u,m;if(!this._isEnabled)return;let s=r.materialDefines,a=this._material.isFrozen;(!e.useUbo||!a||!e.isSync)&&((this._texture||this._textureRoughness)&&ie.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",(l=(o=this._texture)==null?void 0:o.coordinatesIndex)!=null?l:0,(f=(c=this._texture)==null?void 0:c.level)!=null?f:0,(h=(d=this._textureRoughness)==null?void 0:d.coordinatesIndex)!=null?h:0,(m=(u=this._textureRoughness)==null?void 0:u.level)!=null?m:0),this._texture&<(this._texture,e,"sheen"),this._textureRoughness&&!s.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&<(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),this._roughness!==null&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&ie.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!s.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&ie.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}hasTexture(e){return this._texture===e||this._textureRoughness===e}getActiveTextures(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)}dispose(e){var t,i;e&&((t=this._texture)==null||t.dispose(),(i=this._textureRoughness)==null||i.dispose())}getClassName(){return"PBRSheenConfiguration"}addFallbacks(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i}getSamplers(e){e.push("sheenSampler","sheenRoughnessSampler")}getUniforms(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}}};C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"isEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"linkSheenWithAlbedo",void 0);C([D()],Ir.prototype,"intensity",void 0);C([Ht()],Ir.prototype,"color",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"texture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"useRoughnessFromMainTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"roughness",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"textureRoughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],Ir.prototype,"albedoScaling",void 0)});var PS,_t,E1=A(()=>{Qe();qe();et();zr();ve();Fa();Yr();Ni();PS=class extends Zt{constructor(){super(...arguments),this.SUBSURFACE=!1,this.SS_REFRACTION=!1,this.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_TRANSLUCENCY=!1,this.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,this.SS_SCATTERING=!1,this.SS_DISPERSION=!1,this.SS_THICKNESSANDMASK_TEXTURE=!1,this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,this.SS_HAS_THICKNESS=!1,this.SS_REFRACTIONINTENSITY_TEXTURE=!1,this.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,this.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,this.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,this.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,this.SS_REFRACTIONMAP_3D=!1,this.SS_REFRACTIONMAP_OPPOSITEZ=!1,this.SS_LODINREFRACTIONALPHA=!1,this.SS_GAMMAREFRACTION=!1,this.SS_RGBDREFRACTION=!1,this.SS_LINEARSPECULARREFRACTION=!1,this.SS_LINKREFRACTIONTOTRANSPARENCY=!1,this.SS_ALBEDOFORREFRACTIONTINT=!1,this.SS_ALBEDOFORTRANSLUCENCYTINT=!1,this.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,this.SS_USE_THICKNESS_AS_DEPTH=!1,this.SS_USE_GLTF_TEXTURES=!1,this.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1,this.SS_TRANSLUCENCY_LEGACY=!1}},_t=class n extends si{get scatteringDiffusionProfile(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null}set scatteringDiffusionProfile(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))}get volumeIndexOfRefraction(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction}set volumeIndexOfRefraction(e){e>=1?this._volumeIndexOfRefraction=e:this._volumeIndexOfRefraction=-1}get legacyTransluceny(){return this.legacyTranslucency}set legacyTransluceny(e){this.legacyTranslucency=e}_markAllSubMeshesAsTexturesDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}_markScenePrePassDirty(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRSubSurface",130,new PS,t),this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isDispersionEnabled=!1,this.isDispersionEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this._useAlbedoToTintRefraction=!1,this.useAlbedoToTintRefraction=!1,this._useAlbedoToTintTranslucency=!1,this.useAlbedoToTintTranslucency=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.useThicknessAsDepth=!1,this.tintColor=oe.White(),this.tintColorAtDistance=1,this.dispersion=0,this.diffusionDistance=oe.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._refractionIntensityTexture=null,this.refractionIntensityTexture=null,this._translucencyIntensityTexture=null,this.translucencyIntensityTexture=null,this.translucencyColor=null,this._translucencyColorTexture=null,this.translucencyColorTexture=null,this._useGltfStyleTextures=!0,this.useGltfStyleTextures=!0,this.applyAlbedoAfterSubSurface=n.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE,this.legacyTranslucency=n.DEFAULT_LEGACY_TRANSLUCENCY,this._scene=e.getScene(),this.registerForExtraEvents=!0,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1],this._internalMarkScenePrePassDirty=e._dirtyCallbacks[32]}isReadyForSubMesh(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&ie.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&!this._refractionIntensityTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;let i=this._getRefractionTexture(t);if(i&&ie.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0}prepareDefinesBeforeAttributes(e,t){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled){e.SUBSURFACE=!1,e.SS_DISPERSION=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,e.SS_HAS_THICKNESS=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV=0,e.SS_REFRACTIONMAP_3D=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_TRANSLUCENCYCOLOR_TEXTUREDIRECTUV=0,e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=!1;return}if(e._areTexturesDirty){if(e.SUBSURFACE=!0,e.SS_DISPERSION=this._isDispersionEnabled,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_TRANSLUCENCY_LEGACY=this.legacyTranslucency,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1,e.SS_TRANSLUCENCYCOLOR_TEXTURE=!1,e.SS_APPLY_ALBEDO_AFTER_SUBSURFACE=this.applyAlbedoAfterSubSurface,e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&ie.ThicknessTextureEnabled&&ot(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&ot(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&ot(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&(ot(this._translucencyColorTexture,e,"SS_TRANSLUCENCYCOLOR_TEXTURE"),e.SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA=this._translucencyColorTexture.gammaSpace)),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!==0,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._refractionIntensityTexture,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS=this._useMaskFromThicknessTexture&&!this._translucencyIntensityTexture,this._isRefractionEnabled&&t.texturesEnabled){let i=this._getRefractionTexture(t);i&&ie.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=this._scene.useRightHandedSystem&&i.isCube?!i.invertZ:i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this._useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=i.isCube&&i.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this._useAlbedoToTintTranslucency)}}hardBindForSubMesh(e,t,i,r){if(!(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled))if(this.maximumThickness===0&&this.minimumThickness===0)e.updateFloat2("vThicknessParam",0,0);else{r.getRenderingMesh().getWorldMatrix().decompose(G.Vector3[0]);let s=Math.max(Math.abs(G.Vector3[0].x),Math.abs(G.Vector3[0].y),Math.abs(G.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*s,(this.maximumThickness-this.minimumThickness)*s)}}bindForSubMesh(e,t,i,r){var f;if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return;let s=r.materialDefines,a=this._material.isFrozen,o=this._material.realTimeFiltering,l=s.LODBASEDMICROSFURACE,c=this._getRefractionTexture(t);if(!e.useUbo||!a||!e.isSync){if(this._thicknessTexture&&ie.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),lt(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),lt(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),lt(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),lt(this._translucencyIntensityTexture,e,"translucencyIntensity")),c&&ie.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",c.getRefractionTextureMatrix());let d=1;c.isCube||c.depth&&(d=c.depth);let h=c.getSize().width,u=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",c.level,1/u,d,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",h,c.lodGenerationScale,c.lodGenerationOffset,1/this.indexOfRefraction),o&&e.updateFloat2("vRefractionFilteringInfo",h,Math.log2(h)),c.boundingBoxSize){let m=c;e.updateVector3("vRefractionPosition",m.boundingBoxPosition),e.updateVector3("vRefractionSize",m.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateColor4("vTranslucencyColor",(f=this.translucencyColor)!=null?f:this.tintColor,0),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0),e.updateFloat("dispersion",this.dispersion)}t.texturesEnabled&&(this._thicknessTexture&&ie.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&ie.RefractionIntensityTextureEnabled&&s.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&ie.TranslucencyIntensityTextureEnabled&&s.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&ie.TranslucencyColorTextureEnabled&&s.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),c&&ie.RefractionTextureEnabled&&(l?e.setTexture("refractionSampler",c):(e.setTexture("refractionSampler",c._lodTextureMid||c),e.setTexture("refractionSamplerLow",c._lodTextureLow||c),e.setTexture("refractionSamplerHigh",c._lodTextureHigh||c))))}_getRefractionTexture(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null}get disableAlphaBlending(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency}fillRenderTargetTextures(e){ie.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)}hasTexture(e){return this._thicknessTexture===e||this._refractionTexture===e||this._refractionIntensityTexture===e||this._translucencyIntensityTexture===e||this._translucencyColorTexture===e}hasRenderTargetTextures(){return!!(ie.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)}getActiveTextures(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture),this._refractionIntensityTexture&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&e.push(this._translucencyIntensityTexture)}getAnimatables(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._refractionIntensityTexture&&this._refractionIntensityTexture.animations&&this._refractionIntensityTexture.animations.length>0&&e.push(this._refractionIntensityTexture),this._translucencyColorTexture&&this._translucencyColorTexture.animations&&this._translucencyColorTexture.animations.length>0&&e.push(this._translucencyColorTexture),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.animations&&this._translucencyIntensityTexture.animations.length>0&&e.push(this._translucencyIntensityTexture)}dispose(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._refractionIntensityTexture&&this._refractionIntensityTexture.dispose(),this._translucencyColorTexture&&this._translucencyColorTexture.dispose(),this._translucencyIntensityTexture&&this._translucencyIntensityTexture.dispose())}getClassName(){return"PBRSubSurfaceConfiguration"}addFallbacks(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i}getSamplers(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","translucencyColorSampler")}getUniforms(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"},{name:"dispersion",size:1,type:"float"},{name:"vTranslucencyColor",size:4,type:"vec4"},{name:"vTranslucencyColorInfos",size:2,type:"vec2"},{name:"translucencyColorMatrix",size:16,type:"mat4"}]}}};_t.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE=!1;_t.DEFAULT_LEGACY_TRANSLUCENCY=!1;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"isRefractionEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"isTranslucencyEnabled",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"isDispersionEnabled",void 0);C([D(),ee("_markScenePrePassDirty")],_t.prototype,"isScatteringEnabled",void 0);C([D()],_t.prototype,"_scatteringDiffusionProfileIndex",void 0);C([D()],_t.prototype,"refractionIntensity",void 0);C([D()],_t.prototype,"translucencyIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"useAlbedoToTintRefraction",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"useAlbedoToTintTranslucency",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"thicknessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"refractionTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"indexOfRefraction",void 0);C([D()],_t.prototype,"_volumeIndexOfRefraction",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"volumeIndexOfRefraction",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"invertRefractionY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"linkRefractionWithTransparency",void 0);C([D()],_t.prototype,"minimumThickness",void 0);C([D()],_t.prototype,"maximumThickness",void 0);C([D()],_t.prototype,"useThicknessAsDepth",void 0);C([Ht()],_t.prototype,"tintColor",void 0);C([D()],_t.prototype,"tintColorAtDistance",void 0);C([D()],_t.prototype,"dispersion",void 0);C([Ht()],_t.prototype,"diffusionDistance",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"useMaskFromThicknessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"refractionIntensityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"translucencyIntensityTexture",void 0);C([Ht()],_t.prototype,"translucencyColor",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"translucencyColorTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],_t.prototype,"useGltfStyleTextures",void 0);C([D()],_t.prototype,"applyAlbedoAfterSubSurface",void 0);C([D()],_t.prototype,"legacyTranslucency",void 0)});var v1,y5,OS=A(()=>{N();Do();Wf();v1="pbrUboDeclaration",y5=`uniform vAlbedoInfos: vec2f;uniform vBaseWeightInfos: vec2f;uniform vBaseDiffuseRoughnessInfos: vec2f;uniform vAmbientInfos: vec4f;uniform vOpacityInfos: vec2f;uniform vEmissiveInfos: vec2f;uniform vLightmapInfos: vec2f;uniform vReflectivityInfos: vec3f;uniform vMicroSurfaceSamplerInfos: vec2f;uniform vBumpInfos: vec3f;uniform albedoMatrix: mat4x4f;uniform baseWeightMatrix: mat4x4f;uniform baseDiffuseRoughnessMatrix: mat4x4f;uniform ambientMatrix: mat4x4f;uniform opacityMatrix: mat4x4f;uniform emissiveMatrix: mat4x4f;uniform lightmapMatrix: mat4x4f;uniform reflectivityMatrix: mat4x4f;uniform microSurfaceSamplerMatrix: mat4x4f;uniform bumpMatrix: mat4x4f;uniform vTangentSpaceParams: vec2f;uniform vAlbedoColor: vec4f;uniform baseWeight: f32;uniform baseDiffuseRoughness: f32;uniform vLightingIntensity: vec4f;uniform pointSize: f32;uniform vReflectivityColor: vec4f;uniform vEmissiveColor: vec3f;uniform vAmbientColor: vec3f;uniform vDebugMode: vec2f;uniform vMetallicReflectanceFactors: vec4f;uniform vMetallicReflectanceInfos: vec2f;uniform metallicReflectanceMatrix: mat4x4f;uniform vReflectanceInfos: vec2f;uniform reflectanceMatrix: mat4x4f;uniform cameraInfo: vec4f;uniform vReflectionInfos: vec2f;uniform reflectionMatrix: mat4x4f;uniform vReflectionMicrosurfaceInfos: vec3f;uniform vReflectionPosition: vec3f;uniform vReflectionSize: vec3f;uniform vReflectionFilteringInfo: vec2f;uniform vReflectionDominantDirection: vec3f;uniform vReflectionColor: vec3f;uniform vSphericalL00: vec3f;uniform vSphericalL1_1: vec3f;uniform vSphericalL10: vec3f;uniform vSphericalL11: vec3f;uniform vSphericalL2_2: vec3f;uniform vSphericalL2_1: vec3f;uniform vSphericalL20: vec3f;uniform vSphericalL21: vec3f;uniform vSphericalL22: vec3f;uniform vSphericalX: vec3f;uniform vSphericalY: vec3f;uniform vSphericalZ: vec3f;uniform vSphericalXX_ZZ: vec3f;uniform vSphericalYY_ZZ: vec3f;uniform vSphericalZZ: vec3f;uniform vSphericalXY: vec3f;uniform vSphericalYZ: vec3f;uniform vSphericalZX: vec3f; #define ADDITIONAL_UBO_DECLARATION #include #include -`;E.IncludesShadersStoreWGSL[h1]||(E.IncludesShadersStoreWGSL[h1]=f5)});var m1={};De(m1,{pbrVertexShaderWGSL:()=>d5});var LS,u1,d5,p1=A(()=>{N();DS();xu();lc();Vr();vc();Cs();bs();Oa();Cu();bu();Ec();lv();Ms();bf();Mu();wa();Ba();Do();yu();Du();Ua();Va();ys();Ds();Ls();Lu();Pu();Ou();Nu();Ps();Mf();Fu();yf();wu();LS="pbrVertexShader",u1=`#define PBR_VERTEX_SHADER +`;E.IncludesShadersStoreWGSL[v1]||(E.IncludesShadersStoreWGSL[v1]=y5)});var S1={};De(S1,{pbrVertexShaderWGSL:()=>D5});var NS,T1,D5,A1=A(()=>{N();OS();Cu();lc();kr();vc();Cs();bs();Oa();bu();Mu();Ec();dv();Ms();bf();yu();wa();Ba();Lo();Du();Lu();Ua();Va();ys();Ds();Ls();Pu();Ou();Nu();Fu();Ps();Mf();wu();yf();Bu();NS="pbrVertexShader",T1=`#define PBR_VERTEX_SHADER #include #define CUSTOM_VERTEX_BEGIN #ifndef USE_VERTEX_PULLING @@ -13660,7 +13660,7 @@ vertexOutputs.vMainUV2=uv2Updated; #include #include #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStoreWGSL[LS]||(E.ShadersStoreWGSL[LS]=u1);d5={name:LS,shader:u1}});var _1,h5,g1=A(()=>{N();_1="samplerFragmentAlternateDeclaration",h5=`#ifdef _DEFINENAME_ +}`;E.ShadersStoreWGSL[NS]||(E.ShadersStoreWGSL[NS]=T1);D5={name:NS,shader:T1}});var R1,L5,I1=A(()=>{N();R1="samplerFragmentAlternateDeclaration",L5=`#ifdef _DEFINENAME_ #if _DEFINENAME_DIRECTUV==1 #define v_VARYINGNAME_UV vMainUV1 #elif _DEFINENAME_DIRECTUV==2 @@ -13677,7 +13677,7 @@ vertexOutputs.vMainUV2=uv2Updated; varying v_VARYINGNAME_UV: vec2f; #endif #endif -`;E.IncludesShadersStoreWGSL[_1]||(E.IncludesShadersStoreWGSL[_1]=h5)});var E1,u5,v1=A(()=>{N();Lo();g1();Xm();E1="pbrFragmentSamplersDeclaration",u5=`#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) +`;E.IncludesShadersStoreWGSL[R1]||(E.IncludesShadersStoreWGSL[R1]=L5)});var x1,P5,C1=A(()=>{N();Po();I1();Ym();x1="pbrFragmentSamplersDeclaration",P5=`#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) #include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight) #include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) @@ -13740,7 +13740,7 @@ var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d; #endif -`;E.IncludesShadersStoreWGSL[E1]||(E.IncludesShadersStoreWGSL[E1]=u5)});var T1,m5,S1=A(()=>{N();hv();T1="pbrBlockAlbedoOpacity",m5=`struct albedoOpacityOutParams +`;E.IncludesShadersStoreWGSL[x1]||(E.IncludesShadersStoreWGSL[x1]=P5)});var b1,O5,M1=A(()=>{N();pv();b1="pbrBlockAlbedoOpacity",O5=`struct albedoOpacityOutParams {surfaceAlbedo: vec3f, alpha: f32}; #define pbr_inline @@ -13819,7 +13819,7 @@ alpha=1.0; #endif #endif outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;} -`;E.IncludesShadersStoreWGSL[T1]||(E.IncludesShadersStoreWGSL[T1]=m5)});var A1,p5,R1=A(()=>{N();A1="pbrBlockReflectivity",p5=`struct reflectivityOutParams +`;E.IncludesShadersStoreWGSL[b1]||(E.IncludesShadersStoreWGSL[b1]=O5)});var y1,N5,D1=A(()=>{N();y1="pbrBlockReflectivity",N5=`struct reflectivityOutParams {microSurface: f32, roughness: f32, diffuseRoughness: f32, @@ -13979,7 +13979,7 @@ microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;var diffu diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y; #endif outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;} -`;E.IncludesShadersStoreWGSL[A1]||(E.IncludesShadersStoreWGSL[A1]=p5)});var I1,_5,x1=A(()=>{N();I1="pbrBlockAmbientOcclusion",_5=`struct ambientOcclusionOutParams +`;E.IncludesShadersStoreWGSL[y1]||(E.IncludesShadersStoreWGSL[y1]=N5)});var L1,F5,P1=A(()=>{N();L1="pbrBlockAmbientOcclusion",F5=`struct ambientOcclusionOutParams {ambientOcclusionColor: vec3f, #if DEBUGMODE>0 && defined(AMBIENT) ambientOcclusionColorMap: vec3f @@ -14005,7 +14005,7 @@ outParams.ambientOcclusionColorMap=ambientOcclusionColorMap; #endif #endif outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;} -`;E.IncludesShadersStoreWGSL[I1]||(E.IncludesShadersStoreWGSL[I1]=_5)});var C1,g5,b1=A(()=>{N();C1="pbrBlockAlphaFresnel",g5=`#ifdef ALPHAFRESNEL +`;E.IncludesShadersStoreWGSL[L1]||(E.IncludesShadersStoreWGSL[L1]=F5)});var O1,w5,N1=A(()=>{N();O1="pbrBlockAlphaFresnel",w5=`#ifdef ALPHAFRESNEL #if defined(ALPHATEST) || defined(ALPHABLEND) struct alphaFresnelOutParams {alpha: f32};fn faceforward(N: vec3,I: vec3,Nref: vec3)->vec3 {return select(N,-N,dot(Nref,I)>0.0);} @@ -14032,7 +14032,7 @@ outParams.alpha=1.0; return outParams;} #endif #endif -`;E.IncludesShadersStoreWGSL[C1]||(E.IncludesShadersStoreWGSL[C1]=g5)});var M1,E5,y1=A(()=>{N();M1="pbrBlockAnisotropic",E5=`#ifdef ANISOTROPIC +`;E.IncludesShadersStoreWGSL[O1]||(E.IncludesShadersStoreWGSL[O1]=w5)});var F1,B5,w1=A(()=>{N();F1="pbrBlockAnisotropic",B5=`#ifdef ANISOTROPIC struct anisotropicOutParams {anisotropy: f32, anisotropicTangent: vec3f, @@ -14069,7 +14069,7 @@ anisotropyDirection=vec3f(mat2x2f(anisotropyDirection.x,anisotropyDirection.y,-a #endif var anisoTBN: mat3x3f= mat3x3f(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));var anisotropicTangent: vec3f=normalize(anisoTBN*anisotropyDirection);var anisotropicBitangent: vec3f=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;} #endif -`;E.IncludesShadersStoreWGSL[M1]||(E.IncludesShadersStoreWGSL[M1]=E5)});var D1,v5,L1=A(()=>{N();D1="pbrBlockReflection",v5=`#ifdef REFLECTION +`;E.IncludesShadersStoreWGSL[F1]||(E.IncludesShadersStoreWGSL[F1]=B5)});var B1,U5,U1=A(()=>{N();B1="pbrBlockReflection",U5=`#ifdef REFLECTION struct reflectionOutParams {environmentRadiance: vec4f ,environmentIrradiance: vec3f @@ -14379,7 +14379,7 @@ outParams.environmentRadiance=environmentRadiance; #endif outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;} #endif -`;E.IncludesShadersStoreWGSL[D1]||(E.IncludesShadersStoreWGSL[D1]=v5)});var P1,T5,O1=A(()=>{N();P1="pbrBlockSheen",T5=`#ifdef SHEEN +`;E.IncludesShadersStoreWGSL[B1]||(E.IncludesShadersStoreWGSL[B1]=U5)});var V1,V5,G1=A(()=>{N();V1="pbrBlockSheen",V5=`#ifdef SHEEN struct sheenOutParams {sheenIntensity: f32 ,sheenColor: vec3f @@ -14565,7 +14565,7 @@ outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor. #endif outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;} #endif -`;E.IncludesShadersStoreWGSL[P1]||(E.IncludesShadersStoreWGSL[P1]=T5)});var N1,S5,F1=A(()=>{N();N1="pbrBlockClearcoat",S5=`struct clearcoatOutParams +`;E.IncludesShadersStoreWGSL[V1]||(E.IncludesShadersStoreWGSL[V1]=V5)});var k1,G5,W1=A(()=>{N();k1="pbrBlockClearcoat",G5=`struct clearcoatOutParams {specularEnvironmentR0: vec3f, conservationFactor: f32, clearCoatNormalW: vec3f, @@ -14818,7 +14818,7 @@ outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParam #endif return outParams;} #endif -`;E.IncludesShadersStoreWGSL[N1]||(E.IncludesShadersStoreWGSL[N1]=S5)});var w1,A5,B1=A(()=>{N();w1="pbrBlockIridescence",A5=`struct iridescenceOutParams +`;E.IncludesShadersStoreWGSL[k1]||(E.IncludesShadersStoreWGSL[k1]=G5)});var H1,k5,z1=A(()=>{N();H1="pbrBlockIridescence",k5=`struct iridescenceOutParams {iridescenceIntensity: f32, iridescenceIOR: f32, iridescenceThickness: f32, @@ -14859,7 +14859,7 @@ topIor=mix(1.0,uniforms.vClearCoatRefractionParams.w-1.,clearCoatIntensity);view #endif var iridescenceFresnel: vec3f=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;} #endif -`;E.IncludesShadersStoreWGSL[w1]||(E.IncludesShadersStoreWGSL[w1]=A5)});var U1,R5,V1=A(()=>{N();U1="pbrBlockSubSurface",R5=`struct subSurfaceOutParams +`;E.IncludesShadersStoreWGSL[H1]||(E.IncludesShadersStoreWGSL[H1]=k5)});var X1,W5,Y1=A(()=>{N();X1="pbrBlockSubSurface",W5=`struct subSurfaceOutParams {specularEnvironmentReflectance: vec3f, #ifdef SS_REFRACTION finalRefraction: vec3f, @@ -15281,7 +15281,7 @@ outParams.refractionIrradiance=refractionIrradiance; #endif return outParams;} #endif -`;E.IncludesShadersStoreWGSL[U1]||(E.IncludesShadersStoreWGSL[U1]=R5)});var G1,I5,k1=A(()=>{N();G1="pbrBlockNormalFinal",I5=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +`;E.IncludesShadersStoreWGSL[X1]||(E.IncludesShadersStoreWGSL[X1]=W5)});var K1,H5,j1=A(()=>{N();K1="pbrBlockNormalFinal",H5=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w; #if defined(TWOSIDEDLIGHTING) faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing); @@ -15295,7 +15295,7 @@ normalW=select(normalW,-normalW,fragmentInputs.frontFacing); normalW=select(-normalW,normalW,fragmentInputs.frontFacing); #endif #endif -`;E.IncludesShadersStoreWGSL[G1]||(E.IncludesShadersStoreWGSL[G1]=I5)});var W1,x5,H1=A(()=>{N();W1="pbrBlockLightmapInit",x5=`#ifdef LIGHTMAP +`;E.IncludesShadersStoreWGSL[K1]||(E.IncludesShadersStoreWGSL[K1]=H5)});var Z1,z5,q1=A(()=>{N();Z1="pbrBlockLightmapInit",z5=`#ifdef LIGHTMAP var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset); #ifdef RGBDLIGHTMAP lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a); @@ -15305,7 +15305,7 @@ lightmapColor=vec4f(toLinearSpaceVec3(lightmapColor.rgb),lightmapColor.a); #endif lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a); #endif -`;E.IncludesShadersStoreWGSL[W1]||(E.IncludesShadersStoreWGSL[W1]=x5)});var z1,C5,X1=A(()=>{N();z1="pbrBlockGeometryInfo",C5=`var NdotVUnclamped: f32=dot(normalW,viewDirectionW);var NdotV: f32=absEps(NdotVUnclamped);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var AARoughnessFactors: vec2f=getAARoughnessFactors(normalW.xyz); +`;E.IncludesShadersStoreWGSL[Z1]||(E.IncludesShadersStoreWGSL[Z1]=z5)});var Q1,X5,J1=A(()=>{N();Q1="pbrBlockGeometryInfo",X5=`var NdotVUnclamped: f32=dot(normalW,viewDirectionW);var NdotV: f32=absEps(NdotVUnclamped);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var AARoughnessFactors: vec2f=getAARoughnessFactors(normalW.xyz); #ifdef SPECULARAA alphaG+=AARoughnessFactors.y; #endif @@ -15329,7 +15329,7 @@ var eho: f32=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormal #endif #endif #endif -`;E.IncludesShadersStoreWGSL[z1]||(E.IncludesShadersStoreWGSL[z1]=C5)});var Y1,b5,K1=A(()=>{N();Y1="pbrBlockReflectance",b5=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +`;E.IncludesShadersStoreWGSL[Q1]||(E.IncludesShadersStoreWGSL[Q1]=X5)});var $1,Y5,e3=A(()=>{N();$1="pbrBlockReflectance",Y5=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) var baseSpecularEnvironmentReflectance: vec3f=getReflectanceFromBRDFWithEnvLookup(vec3f(reflectanceF0),vec3f(reflectivityOut.reflectanceF90),environmentBrdf); #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) let metalEnvironmentReflectance: vec3f=vec3f(reflectivityOut.specularWeight)*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricEnvironmentReflectance=getReflectanceFromBRDFWithEnvLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);var colorSpecularEnvironmentReflectance: vec3f=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic); @@ -15355,7 +15355,7 @@ colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor; colorSpecularEnvironmentReflectance*=clearcoatOut.absorption; #endif #endif -`;E.IncludesShadersStoreWGSL[Y1]||(E.IncludesShadersStoreWGSL[Y1]=b5)});var j1,M5,Z1=A(()=>{N();j1="pbrBlockDirectLighting",M5=`var diffuseBase: vec3f=vec3f(0.,0.,0.); +`;E.IncludesShadersStoreWGSL[$1]||(E.IncludesShadersStoreWGSL[$1]=Y5)});var t3,K5,i3=A(()=>{N();t3="pbrBlockDirectLighting",K5=`var diffuseBase: vec3f=vec3f(0.,0.,0.); #ifdef SS_TRANSLUCENCY var diffuseTransmissionBase: vec3f=vec3f(0.,0.,0.); #endif @@ -15376,7 +15376,7 @@ var aggShadow: f32=0.;var numLights: f32=0.; #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT) var absorption: vec3f=vec3f(0.); #endif -`;E.IncludesShadersStoreWGSL[j1]||(E.IncludesShadersStoreWGSL[j1]=M5)});var q1,y5,Q1=A(()=>{N();q1="pbrBlockFinalLitComponents",y5=`aggShadow=aggShadow/numLights; +`;E.IncludesShadersStoreWGSL[t3]||(E.IncludesShadersStoreWGSL[t3]=K5)});var r3,j5,n3=A(()=>{N();r3="pbrBlockFinalLitComponents",j5=`aggShadow=aggShadow/numLights; #if defined(ENVIRONMENTBRDF) #ifdef MS_BRDF_ENERGY_CONSERVATION var baseSpecularEnergyConservationFactor: vec3f=getEnergyConservationFactor(vec3f(reflectanceF0),environmentBrdf);var coloredEnergyConservationFactor: vec3f=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf); @@ -15482,7 +15482,7 @@ luminanceOverAlpha+=getLuminance(finalClearCoatScaled); alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha); #endif #endif -`;E.IncludesShadersStoreWGSL[q1]||(E.IncludesShadersStoreWGSL[q1]=y5)});var J1,D5,$1=A(()=>{N();J1="pbrBlockFinalUnlitComponents",D5=`var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo; +`;E.IncludesShadersStoreWGSL[r3]||(E.IncludesShadersStoreWGSL[r3]=j5)});var s3,Z5,a3=A(()=>{N();s3="pbrBlockFinalUnlitComponents",Z5=`var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo; #if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION) finalDiffuse*=subSurfaceOut.refractionOpacity; #endif @@ -15506,7 +15506,7 @@ var ambientOcclusionForDirectDiffuse: vec3f=mix( vec3f(1.),aoOut.ambientOcclusio var ambientOcclusionForDirectDiffuse: vec3f=aoOut.ambientOcclusionColor; #endif finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse; -`;E.IncludesShadersStoreWGSL[J1]||(E.IncludesShadersStoreWGSL[J1]=D5)});var e3,L5,t3=A(()=>{N();e3="pbrBlockFinalColorComposition",L5=`var finalColor: vec4f= vec4f( +`;E.IncludesShadersStoreWGSL[s3]||(E.IncludesShadersStoreWGSL[s3]=Z5)});var o3,q5,l3=A(()=>{N();o3="pbrBlockFinalColorComposition",q5=`var finalColor: vec4f= vec4f( #ifndef UNLIT #ifdef REFLECTION finalIrradiance + @@ -15548,7 +15548,7 @@ finalColor=vec4f(finalColor.rgb+lightmapColor.rgb,finalColor.a); finalColor=vec4f(finalColor.rgb+finalEmissive,finalColor.a); #define CUSTOM_FRAGMENT_BEFORE_FOG finalColor=max(finalColor,vec4f(0.0)); -`;E.IncludesShadersStoreWGSL[e3]||(E.IncludesShadersStoreWGSL[e3]=L5)});var i3,P5,r3=A(()=>{N();i3="pbrBlockPrePass",P5=`#if SCENE_MRT_COUNT>0 +`;E.IncludesShadersStoreWGSL[o3]||(E.IncludesShadersStoreWGSL[o3]=q5)});var c3,Q5,f3=A(()=>{N();c3="pbrBlockPrePass",Q5=`#if SCENE_MRT_COUNT>0 var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>ALPHATESTVALUE);var fragData: array,SCENE_MRT_COUNT>; #ifdef PREPASS_POSITION fragData[PREPASS_POSITION_INDEX]= vec4f(fragmentInputs.vPositionW,writeGeometryInfo); @@ -15654,7 +15654,7 @@ fragmentOutputs.fragData6=fragData[6]; fragmentOutputs.fragData7=fragData[7]; #endif #endif -`;E.IncludesShadersStoreWGSL[i3]||(E.IncludesShadersStoreWGSL[i3]=P5)});var s3={};De(s3,{pbrPixelShaderWGSL:()=>O5});var PS,n3,O5,a3=A(()=>{N();Bu();Uu();DS();KT();Vu();v1();ku();Os();Do();Df();Vr();jT();ZT();qT();Wu();Gu();Ec();QT();JT();vc();$T();tS();Ym();Hu();zu();Hf();S1();R1();x1();b1();y1();L1();O1();F1();B1();V1();Ns();iS();Xu();k1();Yu();H1();X1();eS();K1();Z1();uv();Q1();$1();t3();Ku();Lf();rS();r3();ju();nS();PS="pbrPixelShader",n3=`#define PBR_FRAGMENT_SHADER +`;E.IncludesShadersStoreWGSL[c3]||(E.IncludesShadersStoreWGSL[c3]=Q5)});var h3={};De(h3,{pbrPixelShaderWGSL:()=>J5});var FS,d3,J5,u3=A(()=>{N();Uu();Vu();OS();qT();Gu();C1();Wu();Os();Lo();Df();kr();QT();JT();$T();Hu();ku();Ec();eS();tS();vc();iS();nS();Km();zu();Xu();Hf();M1();D1();P1();N1();w1();U1();G1();W1();z1();Y1();Ns();sS();Yu();j1();Ku();q1();J1();rS();e3();i3();_v();n3();a3();l3();ju();Lf();aS();f3();Zu();oS();FS="pbrPixelShader",d3=`#define PBR_FRAGMENT_SHADER #define CUSTOM_FRAGMENT_BEGIN #include[SCENE_MRT_COUNT] #include @@ -16218,7 +16218,7 @@ if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.f #include #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStoreWGSL[PS]||(E.ShadersStoreWGSL[PS]=n3);O5={name:PS,shader:n3}});var o3,N5,l3=A(()=>{N();Zu();o3="pbrVertexDeclaration",N5=`uniform mat4 view;uniform mat4 viewProjection;uniform vec4 vEyePosition; +`;E.ShadersStoreWGSL[FS]||(E.ShadersStoreWGSL[FS]=d3);J5={name:FS,shader:d3}});var m3,$5,p3=A(()=>{N();qu();m3="pbrVertexDeclaration",$5=`uniform mat4 view;uniform mat4 viewProjection;uniform vec4 vEyePosition; #ifdef MULTIVIEW mat4 viewProjectionR; #endif @@ -16343,12 +16343,12 @@ uniform vec4 vDetailInfos;uniform mat4 detailMatrix; #endif #include #define ADDITIONAL_VERTEX_DECLARATION -`;E.IncludesShadersStore[o3]||(E.IncludesShadersStore[o3]=N5)});var c3,F5,OS=A(()=>{N();Po();zf();c3="pbrUboDeclaration",F5=`layout(std140,column_major) uniform;uniform Material {vec2 vAlbedoInfos;vec2 vBaseWeightInfos;vec2 vBaseDiffuseRoughnessInfos;vec4 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec3 vReflectivityInfos;vec2 vMicroSurfaceSamplerInfos;vec3 vBumpInfos;mat4 albedoMatrix;mat4 baseWeightMatrix;mat4 baseDiffuseRoughnessMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 reflectivityMatrix;mat4 microSurfaceSamplerMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;vec4 vAlbedoColor;float baseWeight;float baseDiffuseRoughness;vec4 vLightingIntensity;float pointSize;vec4 vReflectivityColor;vec3 vEmissiveColor;vec3 vAmbientColor;vec2 vDebugMode;vec4 vMetallicReflectanceFactors;vec2 vMetallicReflectanceInfos;mat4 metallicReflectanceMatrix;vec2 vReflectanceInfos;mat4 reflectanceMatrix;vec4 cameraInfo;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionMicrosurfaceInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vReflectionFilteringInfo;vec3 vReflectionDominantDirection;vec3 vReflectionColor;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX; +`;E.IncludesShadersStore[m3]||(E.IncludesShadersStore[m3]=$5)});var _3,eY,wS=A(()=>{N();Oo();zf();_3="pbrUboDeclaration",eY=`layout(std140,column_major) uniform;uniform Material {vec2 vAlbedoInfos;vec2 vBaseWeightInfos;vec2 vBaseDiffuseRoughnessInfos;vec4 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec3 vReflectivityInfos;vec2 vMicroSurfaceSamplerInfos;vec3 vBumpInfos;mat4 albedoMatrix;mat4 baseWeightMatrix;mat4 baseDiffuseRoughnessMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 reflectivityMatrix;mat4 microSurfaceSamplerMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;vec4 vAlbedoColor;float baseWeight;float baseDiffuseRoughness;vec4 vLightingIntensity;float pointSize;vec4 vReflectivityColor;vec3 vEmissiveColor;vec3 vAmbientColor;vec2 vDebugMode;vec4 vMetallicReflectanceFactors;vec2 vMetallicReflectanceInfos;mat4 metallicReflectanceMatrix;vec2 vReflectanceInfos;mat4 reflectanceMatrix;vec4 cameraInfo;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionMicrosurfaceInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vReflectionFilteringInfo;vec3 vReflectionDominantDirection;vec3 vReflectionColor;vec3 vSphericalL00;vec3 vSphericalL1_1;vec3 vSphericalL10;vec3 vSphericalL11;vec3 vSphericalL2_2;vec3 vSphericalL2_1;vec3 vSphericalL20;vec3 vSphericalL21;vec3 vSphericalL22;vec3 vSphericalX;vec3 vSphericalY;vec3 vSphericalZ;vec3 vSphericalXX_ZZ;vec3 vSphericalYY_ZZ;vec3 vSphericalZZ;vec3 vSphericalXY;vec3 vSphericalYZ;vec3 vSphericalZX; #define ADDITIONAL_UBO_DECLARATION }; #include #include -`;E.IncludesShadersStore[c3]||(E.IncludesShadersStore[c3]=F5)});var d3={};De(d3,{pbrVertexShader:()=>w5});var NS,f3,w5,h3=A(()=>{N();l3();OS();qu();cc();Gr();_c();Fs();ws();Na();Qu();Ju();gc();_v();Bs();Pf();$u();em();Ga();ka();Oo();Wa();Ha();Us();Vs();Gs();tm();im();rm();nm();ks();Of();sm();Nf();am();NS="pbrVertexShader",f3=`#define PBR_VERTEX_SHADER +`;E.IncludesShadersStore[_3]||(E.IncludesShadersStore[_3]=eY)});var E3={};De(E3,{pbrVertexShader:()=>tY});var BS,g3,tY,v3=A(()=>{N();p3();wS();Qu();cc();Wr();_c();Fs();ws();Na();Ju();$u();gc();vv();Bs();Pf();em();tm();Ga();ka();No();Wa();Ha();Us();Vs();Gs();im();rm();nm();sm();ks();Of();am();Nf();om();BS="pbrVertexShader",g3=`#define PBR_VERTEX_SHADER #define CUSTOM_VERTEX_EXTENSION precision highp float; #include<__decl__pbrVertex> @@ -16579,7 +16579,7 @@ gl_PointSize=pointSize; #include #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStore[NS]||(E.ShadersStore[NS]=f3);w5={name:NS,shader:f3}});var u3,B5,m3=A(()=>{N();om();u3="pbrFragmentDeclaration",B5=`uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform float baseWeight;uniform float baseDiffuseRoughness;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor; +`;E.ShadersStore[BS]||(E.ShadersStore[BS]=g3);tY={name:BS,shader:g3}});var T3,iY,S3=A(()=>{N();lm();T3="pbrFragmentDeclaration",iY=`uniform vec4 vEyePosition;uniform vec3 vReflectionColor;uniform vec4 vAlbedoColor;uniform float baseWeight;uniform float baseDiffuseRoughness;uniform vec4 vLightingIntensity;uniform vec4 vReflectivityColor;uniform vec4 vMetallicReflectanceFactors;uniform vec3 vEmissiveColor;uniform float visibility;uniform vec3 vAmbientColor; #ifdef ALBEDO uniform vec2 vAlbedoInfos; #endif @@ -16727,7 +16727,7 @@ uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;unifo #endif #endif #define ADDITIONAL_FRAGMENT_DECLARATION -`;E.IncludesShadersStore[u3]||(E.IncludesShadersStore[u3]=B5)});var p3,U5,_3=A(()=>{N();p3="samplerFragmentAlternateDeclaration",U5=`#ifdef _DEFINENAME_ +`;E.IncludesShadersStore[T3]||(E.IncludesShadersStore[T3]=iY)});var A3,rY,R3=A(()=>{N();A3="samplerFragmentAlternateDeclaration",rY=`#ifdef _DEFINENAME_ #if _DEFINENAME_DIRECTUV==1 #define v_VARYINGNAME_UV vMainUV1 #elif _DEFINENAME_DIRECTUV==2 @@ -16744,7 +16744,7 @@ uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;unifo varying vec2 v_VARYINGNAME_UV; #endif #endif -`;E.IncludesShadersStore[p3]||(E.IncludesShadersStore[p3]=U5)});var g3,V5,E3=A(()=>{N();No();_3();Hm();g3="pbrFragmentSamplersDeclaration",V5=`#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) +`;E.IncludesShadersStore[A3]||(E.IncludesShadersStore[A3]=rY)});var I3,nY,x3=A(()=>{N();Fo();R3();zm();I3="pbrFragmentSamplersDeclaration",nY=`#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo) #include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight) #include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness) #include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) @@ -16811,7 +16811,7 @@ uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh; #ifdef IBL_CDF_FILTERING uniform sampler2D icdfSampler; #endif -`;E.IncludesShadersStore[g3]||(E.IncludesShadersStore[g3]=V5)});var v3,G5,T3=A(()=>{N();Sv();v3="pbrBlockAlbedoOpacity",G5=`struct albedoOpacityOutParams +`;E.IncludesShadersStore[I3]||(E.IncludesShadersStore[I3]=nY)});var C3,sY,b3=A(()=>{N();Iv();C3="pbrBlockAlbedoOpacity",sY=`struct albedoOpacityOutParams {vec3 surfaceAlbedo;float alpha;}; #define pbr_inline albedoOpacityOutParams albedoOpacityBlock( @@ -16890,7 +16890,7 @@ alpha=1.0; #endif #endif outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;} -`;E.IncludesShadersStore[v3]||(E.IncludesShadersStore[v3]=G5)});var S3,k5,A3=A(()=>{N();S3="pbrBlockReflectivity",k5=`struct reflectivityOutParams +`;E.IncludesShadersStore[C3]||(E.IncludesShadersStore[C3]=sY)});var M3,aY,y3=A(()=>{N();M3="pbrBlockReflectivity",aY=`struct reflectivityOutParams {float microSurface;float roughness;float diffuseRoughness;float reflectanceF0;vec3 reflectanceF90;vec3 colorReflectanceF0;vec3 colorReflectanceF90; #ifdef METALLICWORKFLOW vec3 surfaceAlbedo;float metallic;float specularWeight;vec3 dielectricColorF0; @@ -17037,7 +17037,7 @@ microSurface=saturate(microSurface);float roughness=1.-microSurface;float diffus diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y; #endif outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;} -`;E.IncludesShadersStore[S3]||(E.IncludesShadersStore[S3]=k5)});var R3,W5,I3=A(()=>{N();R3="pbrBlockAmbientOcclusion",W5=`struct ambientOcclusionOutParams +`;E.IncludesShadersStore[M3]||(E.IncludesShadersStore[M3]=aY)});var D3,oY,L3=A(()=>{N();D3="pbrBlockAmbientOcclusion",oY=`struct ambientOcclusionOutParams {vec3 ambientOcclusionColor; #if DEBUGMODE>0 && defined(AMBIENT) vec3 ambientOcclusionColorMap; @@ -17060,7 +17060,7 @@ outParams.ambientOcclusionColorMap=ambientOcclusionColorMap; #endif #endif outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;} -`;E.IncludesShadersStore[R3]||(E.IncludesShadersStore[R3]=W5)});var x3,H5,C3=A(()=>{N();x3="pbrBlockAlphaFresnel",H5=`#ifdef ALPHAFRESNEL +`;E.IncludesShadersStore[D3]||(E.IncludesShadersStore[D3]=oY)});var P3,lY,O3=A(()=>{N();P3="pbrBlockAlphaFresnel",lY=`#ifdef ALPHAFRESNEL #if defined(ALPHATEST) || defined(ALPHABLEND) struct alphaFresnelOutParams {float alpha;}; @@ -17088,7 +17088,7 @@ outParams.alpha=1.0; return outParams;} #endif #endif -`;E.IncludesShadersStore[x3]||(E.IncludesShadersStore[x3]=H5)});var b3,z5,M3=A(()=>{N();b3="pbrBlockAnisotropic",z5=`#ifdef ANISOTROPIC +`;E.IncludesShadersStore[P3]||(E.IncludesShadersStore[P3]=lY)});var N3,cY,F3=A(()=>{N();N3="pbrBlockAnisotropic",cY=`#ifdef ANISOTROPIC struct anisotropicOutParams {float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal; #if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE) @@ -17121,7 +17121,7 @@ anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotr #endif mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;} #endif -`;E.IncludesShadersStore[b3]||(E.IncludesShadersStore[b3]=z5)});var y3,X5,D3=A(()=>{N();y3="pbrBlockReflection",X5=`#ifdef REFLECTION +`;E.IncludesShadersStore[N3]||(E.IncludesShadersStore[N3]=cY)});var w3,fY,B3=A(()=>{N();w3="pbrBlockReflection",fY=`#ifdef REFLECTION struct reflectionOutParams {vec4 environmentRadiance;vec3 environmentIrradiance; #ifdef REFLECTIONMAP_3D @@ -17406,7 +17406,7 @@ outParams.environmentRadiance=environmentRadiance; #endif outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;} #endif -`;E.IncludesShadersStore[y3]||(E.IncludesShadersStore[y3]=X5)});var L3,Y5,P3=A(()=>{N();L3="pbrBlockSheen",Y5=`#ifdef SHEEN +`;E.IncludesShadersStore[w3]||(E.IncludesShadersStore[w3]=fY)});var U3,dY,V3=A(()=>{N();U3="pbrBlockSheen",dY=`#ifdef SHEEN struct sheenOutParams {float sheenIntensity;vec3 sheenColor;float sheenRoughness; #ifdef SHEEN_LINKWITHALBEDO @@ -17583,7 +17583,7 @@ outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor. #endif outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;} #endif -`;E.IncludesShadersStore[L3]||(E.IncludesShadersStore[L3]=Y5)});var O3,K5,N3=A(()=>{N();O3="pbrBlockClearcoat",K5=`struct clearcoatOutParams +`;E.IncludesShadersStore[U3]||(E.IncludesShadersStore[U3]=dY)});var G3,hY,k3=A(()=>{N();G3="pbrBlockClearcoat",hY=`struct clearcoatOutParams {vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness; #ifdef REFLECTION vec3 finalClearCoatRadianceScaled; @@ -17820,7 +17820,7 @@ outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParam #endif return outParams;} #endif -`;E.IncludesShadersStore[O3]||(E.IncludesShadersStore[O3]=K5)});var F3,j5,w3=A(()=>{N();F3="pbrBlockIridescence",j5=`struct iridescenceOutParams +`;E.IncludesShadersStore[G3]||(E.IncludesShadersStore[G3]=hY)});var W3,uY,H3=A(()=>{N();W3="pbrBlockIridescence",uY=`struct iridescenceOutParams {float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;}; #ifdef IRIDESCENCE #define pbr_inline @@ -17860,7 +17860,7 @@ topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqr #endif vec3 iridescenceFresnel=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;} #endif -`;E.IncludesShadersStore[F3]||(E.IncludesShadersStore[F3]=j5)});var B3,Z5,U3=A(()=>{N();B3="pbrBlockSubSurface",Z5=`struct subSurfaceOutParams +`;E.IncludesShadersStore[W3]||(E.IncludesShadersStore[W3]=uY)});var z3,mY,X3=A(()=>{N();z3="pbrBlockSubSurface",mY=`struct subSurfaceOutParams {vec3 specularEnvironmentReflectance; #ifdef SS_REFRACTION vec3 finalRefraction;vec3 surfaceAlbedo; @@ -18257,11 +18257,11 @@ outParams.refractionIrradiance=refractionIrradiance.rgb; #endif return outParams;} #endif -`;E.IncludesShadersStore[B3]||(E.IncludesShadersStore[B3]=Z5)});var V3,q5,FS=A(()=>{N();V3="pbrBlockReflectance0",q5=`float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90; +`;E.IncludesShadersStore[z3]||(E.IncludesShadersStore[z3]=mY)});var Y3,pY,US=A(()=>{N();Y3="pbrBlockReflectance0",pY=`float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90; #ifdef ALPHAFRESNEL float reflectance90=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90; #endif -`;E.IncludesShadersStore[V3]||(E.IncludesShadersStore[V3]=q5)});var G3,Q5,k3=A(()=>{N();Tv();FS();G3="pbrClusteredLightingFunctions",Q5=`#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +`;E.IncludesShadersStore[Y3]||(E.IncludesShadersStore[Y3]=pY)});var K3,_Y,j3=A(()=>{N();Rv();US();K3="pbrClusteredLightingFunctions",_Y=`#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 #include #define inline lightingInfo computeClusteredLighting( @@ -18374,7 +18374,7 @@ result.sheen+=info.sheen; batchOffset+=CLUSTLIGHT_BATCH;} return result;} #endif -`;E.IncludesShadersStore[G3]||(E.IncludesShadersStore[G3]=Q5)});var W3,J5,H3=A(()=>{N();W3="pbrBlockNormalFinal",J5=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +`;E.IncludesShadersStore[K3]||(E.IncludesShadersStore[K3]=_Y)});var Z3,gY,q3=A(()=>{N();Z3="pbrBlockNormalFinal",gY=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; #if defined(TWOSIDEDLIGHTING) faceNormal=gl_FrontFacing ? faceNormal : -faceNormal; @@ -18388,7 +18388,7 @@ normalW=gl_FrontFacing ? -normalW : normalW; normalW=gl_FrontFacing ? normalW : -normalW; #endif #endif -`;E.IncludesShadersStore[W3]||(E.IncludesShadersStore[W3]=J5)});var z3,$5,X3=A(()=>{N();z3="pbrBlockLightmapInit",$5=`#ifdef LIGHTMAP +`;E.IncludesShadersStore[Z3]||(E.IncludesShadersStore[Z3]=gY)});var Q3,EY,J3=A(()=>{N();Q3="pbrBlockLightmapInit",EY=`#ifdef LIGHTMAP vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); #ifdef RGBDLIGHTMAP lightmapColor.rgb=fromRGBD(lightmapColor); @@ -18398,7 +18398,7 @@ lightmapColor.rgb=toLinearSpace(lightmapColor.rgb); #endif lightmapColor.rgb*=vLightmapInfos.y; #endif -`;E.IncludesShadersStore[z3]||(E.IncludesShadersStore[z3]=$5)});var Y3,eY,K3=A(()=>{N();Y3="pbrBlockGeometryInfo",eY=`float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz); +`;E.IncludesShadersStore[Q3]||(E.IncludesShadersStore[Q3]=EY)});var $3,vY,eB=A(()=>{N();$3="pbrBlockGeometryInfo",vY=`float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz); #ifdef SPECULARAA alphaG+=AARoughnessFactors.y; #endif @@ -18422,7 +18422,7 @@ float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); #endif #endif #endif -`;E.IncludesShadersStore[Y3]||(E.IncludesShadersStore[Y3]=eY)});var j3,tY,Z3=A(()=>{N();j3="pbrBlockReflectance",tY=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +`;E.IncludesShadersStore[$3]||(E.IncludesShadersStore[$3]=vY)});var tB,TY,iB=A(()=>{N();tB="pbrBlockReflectance",TY=`#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) vec3 baseSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(reflectanceF0),reflectivityOut.reflectanceF90,environmentBrdf); #if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) vec3 metalEnvironmentReflectance=reflectivityOut.specularWeight*getF82Specular(NdotV,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricEnvironmentReflectance=getReflectanceFromBRDFLookup(reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90,environmentBrdf);vec3 colorSpecularEnvironmentReflectance=mix(dielectricEnvironmentReflectance,metalEnvironmentReflectance,reflectivityOut.metallic); @@ -18448,7 +18448,7 @@ colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor; colorSpecularEnvironmentReflectance*=clearcoatOut.absorption; #endif #endif -`;E.IncludesShadersStore[j3]||(E.IncludesShadersStore[j3]=tY)});var q3,iY,Q3=A(()=>{N();q3="pbrBlockDirectLighting",iY=`vec3 diffuseBase=vec3(0.,0.,0.); +`;E.IncludesShadersStore[tB]||(E.IncludesShadersStore[tB]=TY)});var rB,SY,nB=A(()=>{N();rB="pbrBlockDirectLighting",SY=`vec3 diffuseBase=vec3(0.,0.,0.); #ifdef SS_TRANSLUCENCY vec3 diffuseTransmissionBase=vec3(0.,0.,0.); #endif @@ -18469,7 +18469,7 @@ float aggShadow=0.;float numLights=0.; #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT) vec3 absorption=vec3(0.); #endif -`;E.IncludesShadersStore[q3]||(E.IncludesShadersStore[q3]=iY)});var J3,rY,$3=A(()=>{N();J3="pbrBlockFinalLitComponents",rY=`aggShadow=aggShadow/numLights; +`;E.IncludesShadersStore[rB]||(E.IncludesShadersStore[rB]=SY)});var sB,AY,aB=A(()=>{N();sB="pbrBlockFinalLitComponents",AY=`aggShadow=aggShadow/numLights; #if defined(ENVIRONMENTBRDF) #ifdef MS_BRDF_ENERGY_CONSERVATION vec3 baseSpecularEnergyConservationFactor=getEnergyConservationFactor(vec3(reflectanceF0),environmentBrdf);vec3 coloredEnergyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf); @@ -18575,7 +18575,7 @@ luminanceOverAlpha+=getLuminance(finalClearCoatScaled); alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha); #endif #endif -`;E.IncludesShadersStore[J3]||(E.IncludesShadersStore[J3]=rY)});var eB,nY,tB=A(()=>{N();eB="pbrBlockFinalUnlitComponents",nY=`vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo; +`;E.IncludesShadersStore[sB]||(E.IncludesShadersStore[sB]=AY)});var oB,RY,lB=A(()=>{N();oB="pbrBlockFinalUnlitComponents",RY=`vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo; #if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION) finalDiffuse*=subSurfaceOut.refractionOpacity; #endif @@ -18599,7 +18599,7 @@ vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,v vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor; #endif finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse; -`;E.IncludesShadersStore[eB]||(E.IncludesShadersStore[eB]=nY)});var iB,sY,rB=A(()=>{N();iB="pbrBlockFinalColorComposition",sY=`vec4 finalColor=vec4( +`;E.IncludesShadersStore[oB]||(E.IncludesShadersStore[oB]=RY)});var cB,IY,fB=A(()=>{N();cB="pbrBlockFinalColorComposition",IY=`vec4 finalColor=vec4( #ifndef UNLIT #ifdef REFLECTION finalIrradiance + @@ -18641,7 +18641,7 @@ finalColor.rgb+=lightmapColor.rgb; finalColor.rgb+=finalEmissive; #define CUSTOM_FRAGMENT_BEFORE_FOG finalColor=max(finalColor,0.0); -`;E.IncludesShadersStore[iB]||(E.IncludesShadersStore[iB]=sY)});var nB,aY,sB=A(()=>{N();nB="pbrBlockPrePass",aY=`#if SCENE_MRT_COUNT>0 +`;E.IncludesShadersStore[cB]||(E.IncludesShadersStore[cB]=IY)});var dB,xY,hB=A(()=>{N();dB="pbrBlockPrePass",xY=`#if SCENE_MRT_COUNT>0 float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0; #ifdef PREPASS_POSITION gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo); @@ -18723,7 +18723,7 @@ gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInf #endif #endif #endif -`;E.IncludesShadersStore[nB]||(E.IncludesShadersStore[nB]=aY)});var oB={};De(oB,{pbrPixelShader:()=>oY});var wS,aB,oY,lB=A(()=>{N();lm();cm();m3();OS();lS();fm();dm();E3();um();Ws();Oo();Ff();Gr();cS();fS();dS();mm();hm();gc();hS();uS();_c();mS();pS();zm();pm();_m();Xf();T3();A3();I3();C3();M3();D3();P3();N3();w3();U3();k3();Hs();_S();gm();H3();Em();X3();K3();FS();Z3();Q3();Av();$3();tB();rB();vm();wf();gS();sB();Tm();ES();wS="pbrPixelShader",aB=`#define PBR_FRAGMENT_SHADER +`;E.IncludesShadersStore[dB]||(E.IncludesShadersStore[dB]=xY)});var mB={};De(mB,{pbrPixelShader:()=>CY});var VS,uB,CY,pB=A(()=>{N();cm();fm();S3();wS();dS();dm();hm();x3();mm();Ws();No();Ff();Wr();hS();uS();mS();pm();um();gc();pS();_S();_c();gS();ES();Xm();_m();gm();Xf();b3();y3();L3();O3();F3();B3();V3();k3();H3();X3();j3();Hs();vS();Em();q3();vm();J3();eB();US();iB();nB();xv();aB();lB();fB();Tm();wf();TS();hB();Sm();SS();VS="pbrPixelShader",uB=`#define PBR_FRAGMENT_SHADER #define CUSTOM_FRAGMENT_EXTENSION #if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) #extension GL_OES_standard_derivatives : enable @@ -19286,23 +19286,23 @@ if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaM #include #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStore[wS]||(E.ShadersStore[wS]=aB);oY={name:wS,shader:aB}});var Sc,BS,jm,US,Xt,cB=A(()=>{Qe();qe();ze();on();km();gr();ve();yt();a1();vu();et();Tu();sf();Ni();zr();xf();Wr();Eg();Da();o1();l1();c1();f1();d1();av();kn();Cf();Oi();Su();Au();Ru();Iu();Sc={effect:null,subMesh:null},BS=class extends ac(sc(Zt)){},jm=class extends rc(BS){constructor(e){super(e),this.PBR=!0,this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.ALBEDO=!1,this.GAMMAALBEDO=!1,this.ALBEDODIRECTUV=0,this.VERTEXCOLOR=!1,this.BASE_WEIGHT=!1,this.BASE_WEIGHTDIRECTUV=0,this.BASE_DIFFUSE_ROUGHNESS=!1,this.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.AMBIENTINGRAYSCALE=!1,this.OPACITY=!1,this.VERTEXALPHA=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHAFROMALBEDO=!1,this.ALPHATESTVALUE="0.5",this.SPECULAROVERALPHA=!1,this.RADIANCEOVERALPHA=!1,this.ALPHAFRESNEL=!1,this.LINEARALPHAFRESNEL=!1,this.PREMULTIPLYALPHA=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.GAMMAEMISSIVE=!1,this.REFLECTIVITY=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.MICROSURFACEFROMREFLECTIVITYMAP=!1,this.MICROSURFACEAUTOMATIC=!1,this.LODBASEDMICROSFURACE=!1,this.MICROSURFACEMAP=!1,this.MICROSURFACEMAPDIRECTUV=0,this.METALLICWORKFLOW=!1,this.ROUGHNESSSTOREINMETALMAPALPHA=!1,this.ROUGHNESSSTOREINMETALMAPGREEN=!1,this.METALLNESSSTOREINMETALMAPBLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.METALLIC_REFLECTANCE=!1,this.METALLIC_REFLECTANCE_GAMMA=!1,this.METALLIC_REFLECTANCEDIRECTUV=0,this.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,this.REFLECTANCE=!1,this.REFLECTANCE_GAMMA=!1,this.REFLECTANCEDIRECTUV=0,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.NORMAL=!1,this.TANGENT=!1,this.BUMP=!1,this.BUMPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.USELIGHTMAPASSHADOWMAP=!1,this.GAMMALIGHTMAP=!1,this.RGBDLIGHTMAP=!1,this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1,this.LINEARSPECULARREFLECTION=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.MIRRORED=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0}},US=class extends oc(Xn){},Xt=class n extends US{get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(1)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(1)}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||n.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new vt(this._directIntensity,this._emissiveIntensity,this._environmentIntensity,this._specularIntensity),this._disableBumpMap=!1,this._albedoTexture=null,this._baseWeightTexture=null,this._baseDiffuseRoughnessTexture=null,this._ambientTexture=null,this._ambientTextureStrength=1,this._ambientTextureImpactOnAnalyticalLights=n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._reflectivityTexture=null,this._metallicTexture=null,this._metallic=null,this._roughness=null,this._metallicF0Factor=1,this._metallicReflectanceColor=oe.White(),this._useOnlyMetallicFromMetallicReflectanceTexture=!1,this._metallicReflectanceTexture=null,this._reflectanceTexture=null,this._microSurfaceTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._ambientColor=new oe(0,0,0),this._albedoColor=new oe(1,1,1),this._baseWeight=1,this._baseDiffuseRoughness=null,this._reflectivityColor=new oe(1,1,1),this._reflectionColor=new oe(1,1,1),this._emissiveColor=new oe(0,0,0),this._microSurface=.9,this._useLightmapAsShadowmap=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromAlbedoTexture=!1,this._useSpecularOverAlpha=!0,this._useMicroSurfaceFromReflectivityMapAlpha=!1,this._useRoughnessFromMetallicTextureAlpha=!0,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallnessFromMetallicTextureBlue=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useAmbientInGrayScale=!1,this._useAutoMicroSurfaceFromReflectivityMap=!1,this._lightFalloff=n.LIGHTFALLOFF_PHYSICAL,this._useRadianceOverAlpha=!0,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=8,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._renderTargets=new Ct(16),this._globalAmbientColor=new oe(0,0,0),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this._vertexPullingMetadata=null,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this.brdf=new ei(this),this.clearCoat=new _i(this),this.iridescence=new dr(this),this.anisotropy=new js(this),this.sheen=new Ar(this),this.subSurface=new pt(this),this.detailMap=new Xr(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),ie.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=Gm(this.getScene()),this.prePassConfiguration=new cr}get hasRenderTargetTextures(){return ie.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){var e;return this._transparencyMode===n.PBRMATERIAL_OPAQUE||this._transparencyMode===n.PBRMATERIAL_ALPHATEST||((e=this.subSurface)==null?void 0:e.disableAlphaBlending)}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromAlbedoTexture()}needAlphaTesting(){var e;return this._hasTransparencyMode?this._transparencyModeIsTest:(e=this.subSurface)!=null&&e.disableAlphaBlending?!1:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===n.PBRMATERIAL_ALPHATEST)}_shouldUseAlphaFromAlbedoTexture(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==n.PBRMATERIAL_OPAQUE}_hasAlphaChannel(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._albedoTexture}isReadyForSubMesh(e,t,i){var h;this._uniformBufferLayoutBuilt||this.buildUniformLayout();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new jm(this._eventInfo.defineNames));let s=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(s._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){if(this._albedoTexture&&ie.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&!this._baseWeightTexture.isReadyOrNotBlocking()||this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()||this._ambientTexture&&ie.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&ie.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;let u=this._getReflectionTexture();if(u&&ie.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((h=u.getInternalTexture())!=null&&h._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&ie.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&ie.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(ie.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking()||this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking()||this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&ie.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||s._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(s.AREALIGHTUSED||s.CLUSTLIGHT_BATCH){for(let u=0;u{m.push(`vp_${x}_info`)}))}else this._vertexPullingMetadata=null;Je&&(Je.PrepareUniforms(m,i),Je.PrepareSamplers(p,i)),Yl({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,h,T));let b=i.toString(),R=c.createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:f,onCompiled:r,onError:s,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:i.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(p1(),m1)),Promise.resolve().then(()=>(a3(),s3))]):await Promise.all([Promise.resolve().then(()=>(h3(),d3)),Promise.resolve().then(()=>(lB(),oB))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,R}_prepareDefines(e,t,i,r=null,s=null){let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Gl(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Hl(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(o,i,this.canRenderToMRT&&!c),zl(o,i,c),Ui.PrepareDefines(l.currentRenderPassId,e,i),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){i._needUVs=!1;for(let f=1;f<=6;++f)i["MAINUV"+f]=!1;if(o.texturesEnabled){i.ALBEDODIRECTUV=0,i.BASE_WEIGHTDIRECTUV=0,i.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,i.AMBIENTDIRECTUV=0,i.OPACITYDIRECTUV=0,i.EMISSIVEDIRECTUV=0,i.REFLECTIVITYDIRECTUV=0,i.MICROSURFACEMAPDIRECTUV=0,i.METALLIC_REFLECTANCEDIRECTUV=0,i.REFLECTANCEDIRECTUV=0,i.BUMPDIRECTUV=0,i.LIGHTMAPDIRECTUV=0,l.getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&ie.DiffuseTextureEnabled?(at(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._baseWeightTexture&&ie.BaseWeightTextureEnabled?at(this._baseWeightTexture,i,"BASE_WEIGHT"):i.BASE_WEIGHT=!1,this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled?at(this._baseDiffuseRoughnessTexture,i,"BASE_DIFFUSE_ROUGHNESS"):i.BASE_DIFFUSE_ROUGHNESS=!1,this._ambientTexture&&ie.AmbientTextureEnabled?(at(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&ie.OpacityTextureEnabled?(at(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;let f=this._getReflectionTexture(),d=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;Ra(o,f,i,this.realTimeFiltering,this.realTimeFilteringQuality,!d),this._lightmapTexture&&ie.LightmapTextureEnabled?(at(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&ie.EmissiveTextureEnabled?(at(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,ie.SpecularTextureEnabled?(this._metallicTexture?(at(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,i.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(at(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,i.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):i.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(at(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"),i.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):i.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(at(this._reflectanceTexture,i,"REFLECTANCE"),i.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):i.REFLECTANCE=!1):(i.METALLIC_REFLECTANCE=!1,i.REFLECTANCE=!1),this._microSurfaceTexture?at(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),l.getCaps().standardDerivatives&&this._bumpTexture&&ie.BumpTextureEnabled&&!this._disableBumpMap?(at(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&ie.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=o.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.BUMP=!1,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&ie.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===n.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===n.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.MIRRORED=!!o._mirroredCameraPosition,i.SPECULARAA=l.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,i.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(Ul(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),i,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t,this._isVertexOutputInvariant),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(M.NormalKind),i.DEBUGMODE=this._debugMode),kl(o,l,this,i,!!r,s,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Wl(e,i,!0,!0,!0,this._transparencyMode!==n.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}forceCompilation(e,t,i){let r={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),(()=>{if(this._breakShaderLoadedCheck)return;let a=new jm(this._eventInfo.defineNames),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Sc.effect=o,Sc.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Sc)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}buildUniformLayout(){let e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vBaseWeightInfos",2),e.addUniform("vBaseDiffuseRoughnessInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("baseWeightMatrix",16),e.addUniform("baseDiffuseRoughnessMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("vAlbedoColor",4),e.addUniform("baseWeight",1),e.addUniform("baseDiffuseRoughness",1),e.addUniform("vLightingIntensity",4),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vAmbientColor",3),e.addUniform("vDebugMode",2),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),e.addUniform("vReflectanceInfos",2),e.addUniform("reflectanceMatrix",16),e.addUniform("cameraInfo",4),Kl(e,!0,!0,!0,!0,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var h,u,m,p;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e);let o=r.getEngine();this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Ui.Bind(o.currentRenderPassId,this._activeEffect,t,e,this);let l=r.activeCamera;l?this._uniformBuffer.updateFloat4("cameraInfo",l.minZ,l.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);nr(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&Pa(this._activeEffect,this._vertexPullingMetadata);let f=null,d=this._uniformBuffer;if(c){if(this.bindViewProjection(a),f=this._getReflectionTexture(),!d.useUbo||!this.isFrozen||!d.isSync||i._drawWrapper._forceRebindOnNextCall){if(r.texturesEnabled&&(this._albedoTexture&&ie.DiffuseTextureEnabled&&(d.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ot(this._albedoTexture,d,"albedo")),this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&(d.updateFloat2("vBaseWeightInfos",this._baseWeightTexture.coordinatesIndex,this._baseWeightTexture.level),ot(this._baseWeightTexture,d,"baseWeight")),this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&(d.updateFloat2("vBaseDiffuseRoughnessInfos",this._baseDiffuseRoughnessTexture.coordinatesIndex,this._baseDiffuseRoughnessTexture.level),ot(this._baseDiffuseRoughnessTexture,d,"baseDiffuseRoughness")),this._ambientTexture&&ie.AmbientTextureEnabled&&(d.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ot(this._ambientTexture,d,"ambient")),this._opacityTexture&&ie.OpacityTextureEnabled&&(d.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ot(this._opacityTexture,d,"opacity")),this._emissiveTexture&&ie.EmissiveTextureEnabled&&(d.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ot(this._emissiveTexture,d,"emissive")),this._lightmapTexture&&ie.LightmapTextureEnabled&&(d.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ot(this._lightmapTexture,d,"lightmap")),ie.SpecularTextureEnabled&&(this._metallicTexture?(d.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ot(this._metallicTexture,d,"reflectivity")):this._reflectivityTexture&&(d.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ot(this._reflectivityTexture,d,"reflectivity")),this._metallicReflectanceTexture&&(d.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),ot(this._metallicReflectanceTexture,d,"metallicReflectance")),this._reflectanceTexture&&s.REFLECTANCE&&(d.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),ot(this._reflectanceTexture,d,"reflectance")),this._microSurfaceTexture&&(d.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ot(this._microSurfaceTexture,d,"microSurfaceSampler"))),this._bumpTexture&&o.getCaps().standardDerivatives&&ie.BumpTextureEnabled&&!this._disableBumpMap&&(d.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ot(this._bumpTexture,d,"bump"),r._mirroredCameraPosition?d.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):d.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),Pl(r,s,d,this._reflectionColor,f,this.realTimeFiltering,!0,!0,!0,!0,!0)),this.pointsCloud&&d.updateFloat("pointSize",this.pointSize),s.METALLICWORKFLOW){Ri.Color4[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,Ri.Color4[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness;let _=(u=(h=this.subSurface)==null?void 0:h._indexOfRefraction)!=null?u:1.5,g=1;Ri.Color4[0].b=_;let T=Math.pow((_-g)/(_+g),2);Ri.Color4[0].a=T,d.updateDirectColor4("vReflectivityColor",Ri.Color4[0]),d.updateColor4("vMetallicReflectanceFactors",this._metallicReflectanceColor,this._metallicF0Factor)}else d.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);d.updateColor3("vEmissiveColor",ie.EmissiveTextureEnabled?this._emissiveColor:oe.BlackReadOnly),!s.SS_REFRACTION&&((m=this.subSurface)!=null&&m._linkRefractionWithTransparency)?d.updateColor4("vAlbedoColor",this._albedoColor,1):d.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),d.updateFloat("baseWeight",this._baseWeight),d.updateFloat("baseDiffuseRoughness",this._baseDiffuseRoughness||0),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*r.environmentIntensity,this._lightingInfos.w=this._specularIntensity,d.updateVector4("vLightingIntensity",this._lightingInfos),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),d.updateColor3("vAmbientColor",this._globalAmbientColor),d.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}r.texturesEnabled&&(this._albedoTexture&&ie.DiffuseTextureEnabled&&d.setTexture("albedoSampler",this._albedoTexture),this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&d.setTexture("baseWeightSampler",this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&d.setTexture("baseDiffuseRoughnessSampler",this._baseDiffuseRoughnessTexture),this._ambientTexture&&ie.AmbientTextureEnabled&&d.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ie.OpacityTextureEnabled&&d.setTexture("opacitySampler",this._opacityTexture),tu(r,s,d,f,this.realTimeFiltering),s.ENVIRONMENTBRDF&&d.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&ie.EmissiveTextureEnabled&&d.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ie.LightmapTextureEnabled&&d.setTexture("lightmapSampler",this._lightmapTexture),ie.SpecularTextureEnabled&&(this._metallicTexture?d.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&d.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&d.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&s.REFLECTANCE&&d.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&d.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&o.getCaps().standardDerivatives&&ie.BumpTextureEnabled&&!this._disableBumpMap&&d.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(a),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Li(this._activeEffect,this,r),this.bindEyePosition(a)}else r.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(c||!this.isFrozen)&&(r.lightsEnabled&&!this._disableLighting&&Nl(r,t,this._activeEffect,s,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==gt.FOGMODE_NONE||f||this.subSurface.refractionTexture||t.receiveShadows||s.PREPASS||s.CLUSTLIGHT_BATCH)&&this.bindView(a),Sa(r,t,this._activeEffect,!0),s.NUM_MORPH_INFLUENCERS&&Pi(t,this._activeEffect),s.BAKED_VERTEX_ANIMATION_TEXTURE&&((p=t.bakedVertexAnimationManager)==null||p.bind(a,s.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),Ta(s,this._activeEffect,r)),this._afterBind(t,this._activeEffect,i),d.update()}getAnimatables(){let e=super.getAnimatables();return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._baseWeightTexture&&this._baseWeightTexture.animations&&this._baseWeightTexture.animations.length>0&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&this._baseDiffuseRoughnessTexture.animations&&this._baseDiffuseRoughnessTexture.animations.length>0&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&e.push(this._microSurfaceTexture),e}_getReflectionTexture(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture}getActiveTextures(){let e=super.getActiveTextures();return this._albedoTexture&&e.push(this._albedoTexture),this._baseWeightTexture&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._metallicReflectanceTexture&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),e}hasTexture(e){return!!(super.hasTexture(e)||this._albedoTexture===e||this._baseWeightTexture===e||this._baseDiffuseRoughnessTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._reflectivityTexture===e||this._metallicTexture===e||this._metallicReflectanceTexture===e||this._reflectanceTexture===e||this._microSurfaceTexture===e||this._bumpTexture===e||this._lightmapTexture===e)}setPrePassRenderer(){var t;if(!((t=this.subSurface)!=null&&t.isScatteringEnabled))return!1;let e=this.getScene().enableSubSurfaceForPrePass();return e&&(e.enabled=!0),!0}dispose(e,t){var i,r,s,a,o,l,c,f,d,h,u,m,p,_;this._breakShaderLoadedCheck=!0,t&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),(i=this._albedoTexture)==null||i.dispose(),(r=this._baseWeightTexture)==null||r.dispose(),(s=this._baseDiffuseRoughnessTexture)==null||s.dispose(),(a=this._ambientTexture)==null||a.dispose(),(o=this._opacityTexture)==null||o.dispose(),(l=this._reflectionTexture)==null||l.dispose(),(c=this._emissiveTexture)==null||c.dispose(),(f=this._metallicTexture)==null||f.dispose(),(d=this._reflectivityTexture)==null||d.dispose(),(h=this._bumpTexture)==null||h.dispose(),(u=this._lightmapTexture)==null||u.dispose(),(m=this._metallicReflectanceTexture)==null||m.dispose(),(p=this._reflectanceTexture)==null||p.dispose(),(_=this._microSurfaceTexture)==null||_.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}};Xt.PBRMATERIAL_OPAQUE=ae.MATERIAL_OPAQUE;Xt.PBRMATERIAL_ALPHATEST=ae.MATERIAL_ALPHATEST;Xt.PBRMATERIAL_ALPHABLEND=ae.MATERIAL_ALPHABLEND;Xt.PBRMATERIAL_ALPHATESTANDBLEND=ae.MATERIAL_ALPHATESTANDBLEND;Xt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0;Xt.LIGHTFALLOFF_PHYSICAL=0;Xt.LIGHTFALLOFF_GLTF=1;Xt.LIGHTFALLOFF_STANDARD=2;Xt.ForceGLSL=!1;C([ee("_markAllSubMeshesAsMiscDirty")],Xt.prototype,"debugMode",void 0)});var fB={};De(fB,{PBRMaterial:()=>we});var we,dB=A(()=>{Qe();qe();km();et();cB();Lt();Ni();Kt();we=class n extends Xt{get refractionTexture(){return this.subSurface.refractionTexture}set refractionTexture(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)}get indexOfRefraction(){return this.subSurface.indexOfRefraction}set indexOfRefraction(e){this.subSurface.indexOfRefraction=e}get invertRefractionY(){return this.subSurface.invertRefractionY}set invertRefractionY(e){this.subSurface.invertRefractionY=e}get linkRefractionWithTransparency(){return this.subSurface.linkRefractionWithTransparency}set linkRefractionWithTransparency(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)}get usePhysicalLightFalloff(){return this._lightFalloff===Xt.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Xt.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=Xt.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===Xt.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Xt.LIGHTFALLOFF_GLTF:this._lightFalloff=Xt.LIGHTFALLOFF_STANDARD)}constructor(e,t,i=!1){super(e,t,i),this.directIntensity=1,this.emissiveIntensity=1,this.environmentIntensity=1,this.specularIntensity=1,this.disableBumpMap=!1,this.ambientTextureStrength=1,this.ambientTextureImpactOnAnalyticalLights=n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this.metallicF0Factor=1,this.metallicReflectanceColor=oe.White(),this.useOnlyMetallicFromMetallicReflectanceTexture=!1,this.ambientColor=new oe(0,0,0),this.albedoColor=new oe(1,1,1),this.baseWeight=1,this.reflectivityColor=new oe(1,1,1),this.reflectionColor=new oe(1,1,1),this.emissiveColor=new oe(0,0,0),this.microSurface=1,this.useLightmapAsShadowmap=!1,this.useAlphaFromAlbedoTexture=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useSpecularOverAlpha=!0,this.useMicroSurfaceFromReflectivityMapAlpha=!1,this.useRoughnessFromMetallicTextureAlpha=!0,this.useRoughnessFromMetallicTextureGreen=!1,this.useMetallnessFromMetallicTextureBlue=!1,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useAutoMicroSurfaceFromReflectivityMap=!1,this.useRadianceOverAlpha=!0,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._environmentBRDFTexture=Gm(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.id=e,r.name=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}serialize(){let e=super.serialize();return e.customType="BABYLON.PBRMaterial",e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),e.clearCoat&&r.clearCoat.parse(e.clearCoat,t,i),e.anisotropy&&r.anisotropy.parse(e.anisotropy,t,i),e.brdf&&r.brdf.parse(e.brdf,t,i),e.sheen&&r.sheen.parse(e.sheen,t,i),e.subSurface&&r.subSurface.parse(e.subSurface,t,i),e.iridescence&&r.iridescence.parse(e.iridescence,t,i),r}};we.PBRMATERIAL_OPAQUE=Xt.PBRMATERIAL_OPAQUE;we.PBRMATERIAL_ALPHATEST=Xt.PBRMATERIAL_ALPHATEST;we.PBRMATERIAL_ALPHABLEND=Xt.PBRMATERIAL_ALPHABLEND;we.PBRMATERIAL_ALPHATESTANDBLEND=Xt.PBRMATERIAL_ALPHATESTANDBLEND;we.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=Xt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"directIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"environmentIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"specularIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"disableBumpMap",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"albedoTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseWeightTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseDiffuseRoughnessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTextureStrength",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTextureImpactOnAnalyticalLights",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"opacityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectionTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectivityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallic",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"roughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicF0Factor",void 0);C([Ht(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicReflectanceColor",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicReflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"microSurfaceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"bumpTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty",null)],we.prototype,"lightmapTexture",void 0);C([Ht("ambient"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientColor",void 0);C([Ht("albedo"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"albedoColor",void 0);C([D("baseWeight"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseWeight",void 0);C([D("baseDiffuseRoughness"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseDiffuseRoughness",void 0);C([Ht("reflectivity"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectivityColor",void 0);C([Ht("reflection"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectionColor",void 0);C([Ht("emissive"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveColor",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"microSurface",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useLightmapAsShadowmap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"useAlphaFromAlbedoTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"forceAlphaTest",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"alphaCutOff",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useSpecularOverAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRoughnessFromMetallicTextureAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRoughnessFromMetallicTextureGreen",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useMetallnessFromMetallicTextureBlue",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAmbientInGrayScale",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0);C([D()],we.prototype,"usePhysicalLightFalloff",null);C([D()],we.prototype,"useGLTFLightFalloff",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRadianceOverAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useObjectSpaceNormalMap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useParallax",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useParallaxOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"parallaxScaleBias",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],we.prototype,"disableLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"forceIrradianceInFragment",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],we.prototype,"maxSimultaneousLights",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"invertNormalMapX",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"invertNormalMapY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"twoSidedLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAlphaFresnel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useLinearAlphaFresnel",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"environmentBRDFTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"forceNormalForward",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"enableSpecularAntiAliasing",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useHorizonOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRadianceOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],we.prototype,"unlit",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],we.prototype,"applyDecalMapAfterDetailMap",void 0);je("BABYLON.PBRMaterial",we)});var hB={};De(hB,{PBRMaterialLoadingAdapter:()=>VS});var VS,uB=A(()=>{et();ET();ve();VS=class{constructor(e){this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material.useAlphaFromAlbedoTexture=e}get useAlphaFromBaseColorTexture(){return this._material.useAlphaFromAlbedoTexture}get transparencyAsAlphaCoverage(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha}set transparencyAsAlphaCoverage(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e}set baseColor(e){this._material.albedoColor=e}get baseColor(){return this._material.albedoColor}set baseColorTexture(e){this._material.albedoTexture=e}get baseColorTexture(){return this._material.albedoTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=F.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)}get baseDiffuseRoughness(){var e;return(e=this._material.baseDiffuseRoughness)!=null?e:0}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.metallic=e}get baseMetalness(){var e;return(e=this._material.metallic)!=null?e:1}set baseMetalnessTexture(e){this._material.metallicTexture=e}get baseMetalnessTexture(){return this._material.metallicTexture}set useRoughnessFromMetallicTextureGreen(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e}set useMetallicFromMetallicTextureBlue(e){this._material.useMetallnessFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){e&&(this._material.brdf.dielectricSpecularModel=F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)}set specularWeight(e){this._material.metallicF0Factor=e}get specularWeight(){var e;return(e=this._material.metallicF0Factor)!=null?e:1}set specularWeightTexture(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)}get specularWeightTexture(){return this._material.metallicReflectanceTexture}set specularColor(e){this._material.metallicReflectanceColor=e}get specularColor(){return this._material.metallicReflectanceColor}set specularColorTexture(e){this._material.reflectanceTexture=e}get specularColorTexture(){return this._material.reflectanceTexture}set specularRoughness(e){this._material.roughness=e}get specularRoughness(){var e;return(e=this._material.roughness)!=null?e:1}set specularRoughnessTexture(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)}get specularRoughnessTexture(){return this._material.metallicTexture}set specularIor(e){this._material.indexOfRefraction=e}get specularIor(){return this._material.indexOfRefraction}set emissionColor(e){this._material.emissiveColor=e}get emissionColor(){return this._material.emissiveColor}set emissionLuminance(e){this._material.emissiveIntensity=e}get emissionLuminance(){return this._material.emissiveIntensity}set emissionColorTexture(e){this._material.emissiveTexture=e}get emissionColorTexture(){return this._material.emissiveTexture}set ambientOcclusionTexture(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)}get ambientOcclusionTexture(){return this._material.ambientTexture}set ambientOcclusionTextureStrength(e){this._material.ambientTextureStrength=e}get ambientOcclusionTextureStrength(){var e;return(e=this._material.ambientTextureStrength)!=null?e:1}configureCoat(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1}set coatWeight(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e}get coatWeight(){return this._material.clearCoat.intensity}set coatWeightTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e}get coatWeightTexture(){return this._material.clearCoat.texture}set coatColor(e){this._material.clearCoat.isTintEnabled=e!=oe.White(),this._material.clearCoat.tintColor=e}set coatColorTexture(e){this._material.clearCoat.tintTexture=e}set coatRoughness(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e}get coatRoughness(){var e;return(e=this._material.clearCoat.roughness)!=null?e:0}set coatRoughnessTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e}get coatRoughnessTexture(){return this._material.clearCoat.textureRoughness}set coatIor(e){this._material.clearCoat.indexOfRefraction=e}set coatDarkening(e){}set coatDarkeningTexture(e){}set coatRoughnessAnisotropy(e){}get coatRoughnessAnisotropy(){return 0}set geometryCoatTangentAngle(e){}set geometryCoatTangentTexture(e){}get geometryCoatTangentTexture(){return null}set transmissionWeight(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e}get transmissionWeight(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0}set transmissionWeightTexture(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set transmissionDepth(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new oe(e,e,e))}get transmissionDepth(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0}set transmissionColor(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)}get transmissionColor(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new oe(0,0,0)}set transmissionScatter(e){this._material.subSurface.diffusionDistance=e}get transmissionScatter(){return this._material.subSurface.diffusionDistance}set transmissionScatterTexture(e){}set transmissionScatterAnisotropy(e){}set transmissionDispersionAbbeNumber(e){}set transmissionDispersionScale(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)}get refractionBackgroundTexture(){return this._material.subSurface.refractionTexture}set refractionBackgroundTexture(e){this._material.subSurface.refractionTexture=e}configureTransmission(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0}configureVolume(){}set geometryThinWalled(e){}get geometryThinWalled(){return!0}set volumeThicknessTexture(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set volumeThickness(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)}configureSubsurface(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1}set subsurfaceWeight(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e}get subsurfaceWeight(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0}set subsurfaceWeightTexture(e){this._material.subSurface.translucencyIntensityTexture=e}set subsurfaceColor(e){let t=new v(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));t.scaleInPlace(1/Math.max(this.transmissionDepth,.001));let i=t,r=Math.max(i.x,Math.max(i.y,i.z)),s=r>0?1/r:1;this._material.subSurface.diffusionDistance=new oe(Math.exp(-i.x*s),Math.exp(-i.y*s),Math.exp(-i.z*s))}set subsurfaceColorTexture(e){}set diffuseTransmissionTint(e){this._material.subSurface.tintColor=e}get diffuseTransmissionTint(){return this._material.subSurface.tintColor}set diffuseTransmissionTintTexture(e){this._material.subSurface.translucencyColorTexture=e}get subsurfaceRadius(){return 1}set subsurfaceRadius(e){}get subsurfaceRadiusScale(){var e;return(e=this._material.subSurface.scatteringDiffusionProfile)!=null?e:oe.White()}set subsurfaceRadiusScale(e){this._material.subSurface.scatteringDiffusionProfile=e}set subsurfaceScatterAnisotropy(e){}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0}set fuzzWeight(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e}set fuzzWeightTexture(e){this._material.sheen.texture||(this._material.sheen.texture=e)}set fuzzColor(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e}set fuzzColorTexture(e){this._material.sheen.texture=e}set fuzzRoughness(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e}set fuzzRoughnessTexture(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e}set specularRoughnessAnisotropy(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e}get specularRoughnessAnisotropy(){return this._material.anisotropy.intensity}set geometryTangentAngle(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e}set geometryTangentTexture(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e}get geometryTangentTexture(){return this._material.anisotropy.texture}configureGltfStyleAnisotropy(e=!0){}set thinFilmWeight(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e}set thinFilmIor(e){this._material.iridescence.indexOfRefraction=e}set thinFilmThicknessMinimum(e){this._material.iridescence.minimumThickness=e}set thinFilmThicknessMaximum(e){this._material.iridescence.maximumThickness=e}set thinFilmWeightTexture(e){this._material.iridescence.texture=e}set thinFilmThicknessTexture(e){this._material.iridescence.thicknessTexture=e}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.alpha=e}get geometryOpacity(){return this._material.alpha}set geometryNormalTexture(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0}get geometryNormalTexture(){return this._material.bumpTexture}setNormalMapInversions(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t}set geometryCoatNormalTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e}get geometryCoatNormalTexture(){return this._material.clearCoat.bumpTexture}set geometryCoatNormalTextureScale(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)}}});function fY(n){if(n.min&&n.max){let e=n.min,t=n.max,i=k.Vector3[0].copyFromFloats(e[0],e[1],e[2]),r=k.Vector3[1].copyFromFloats(t[0],t[1],t[2]);if(n.normalized&&n.componentType!==5126){let s=1;switch(n.componentType){case 5120:s=127;break;case 5121:s=255;break;case 5122:s=32767;break;case 5123:s=65535;break}let a=1/s;i.scaleInPlace(a),r.scaleInPlace(a)}return new vi(i,r)}return null}var lY,cY,rt,Zm,mB=A(()=>{MO();ve();et();Tt();Rs();FO();Nm();BO();Ni();oi();yl();yt();Jh();Dl();Rt();pT();VO();mT();fs();ze();bl();WO();vT();XO();pl();YO();lY=new Jf(()=>Promise.resolve().then(()=>(QO(),qO))),cY=new Jf(()=>Promise.resolve().then(()=>(tN(),eN))),rt=class{static Get(e,t,i){if(!t||i==null||!t[i])throw new Error(`${e}: Failed to find index (${i})`);return t[i]}static TryGet(e,t){return!e||t==null||!e[t]?null:e[t]}static Assign(e){if(e)for(let t=0;tt.dispose&&t.dispose()),this._extensions.length=0;for(let t of Array.from(this._materialAdapters))(e=t.finalize)==null||e.call(t);this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose()}}async importMeshAsync(e,t,i,r,s,a,o=""){return await Promise.resolve().then(async()=>{this._babylonScene=t,this._assetContainer=i,this._loadData(r);let l=null;if(e){let c={};if(this._gltf.nodes)for(let d of this._gltf.nodes)d.name&&(c[d.name]=d.index);l=(e instanceof Array?e:[e]).map(d=>{let h=c[d];if(h===void 0)throw new Error(`Failed to find node '${d}'`);return h})}return await this._loadAsync(s,o,l,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))})}async loadAsync(e,t,i,r,s=""){return this._babylonScene=e,this._loadData(t),await this._loadAsync(i,s,null,()=>{})}async _loadAsync(e,t,i,r){return await Promise.resolve().then(async()=>{this._rootUrl=e,this._uniqueRootUrl=!e.startsWith("file:")&&t?e:`${e}${Date.now()}/`,this._fileName=t,this._allMaterialsDirtyRequired=!1,await this._loadExtensionsAsync(),!this.parent.skipMaterials&&this._pbrMaterialImpl==null&&(this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr")?this._pbrMaterialImpl={materialClass:(await Promise.resolve().then(()=>(r1(),i1))).OpenPBRMaterial,adapterClass:(await Promise.resolve().then(()=>(s1(),n1))).OpenPBRMaterialLoadingAdapter}:this._pbrMaterialImpl={materialClass:(await Promise.resolve().then(()=>(dB(),fB))).PBRMaterial,adapterClass:(await Promise.resolve().then(()=>(uB(),hB))).PBRMaterialLoadingAdapter});let s=`${Yi[Yi.LOADING]} => ${Yi[Yi.READY]}`,a=`${Yi[Yi.LOADING]} => ${Yi[Yi.COMPLETE]}`;this._parent._startPerformanceCounter(s),this._parent._startPerformanceCounter(a),this._parent._setState(Yi.LOADING),this._extensionsOnLoading();let o=new Array,l=this._babylonScene.blockMaterialDirtyMechanism;if(this._babylonScene.blockMaterialDirtyMechanism=!0,!this.parent.loadOnlyMaterials){if(i)o.push(this.loadSceneAsync("/nodes",{nodes:i,index:-1}));else if(this._gltf.scene!=null||this._gltf.scenes&&this._gltf.scenes[0]){let f=rt.Get("/scene",this._gltf.scenes,this._gltf.scene||0);o.push(this.loadSceneAsync(`/scenes/${f.index}`,f))}}if(!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(let f=0;f{}))}return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=l:this._babylonScene._forceBlockMaterialDirtyMechanism(l),this._parent.compileMaterials&&o.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&o.push(this._compileShadowGeneratorsAsync()),await Promise.all(o).then(()=>{this._rootBabylonMesh&&this._rootBabylonMesh!==this._parent.customRootNode&&this._rootBabylonMesh.setEnabled(!0);for(let f of this._babylonScene.materials){let d=f;d.maxSimultaneousLights!==void 0&&(d.maxSimultaneousLights=Math.max(d.maxSimultaneousLights,this._babylonScene.lights.length))}return this._extensionsOnReady(),this._parent._setState(Yi.READY),this._skipStartAnimationStep||this._startAnimations(),r()}).then(f=>(this._parent._endPerformanceCounter(s),re.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(a),this._parent._setState(Yi.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},d=>{this._parent.onErrorObservable.notifyObservers(d),this._parent.onErrorObservable.clear(),this.dispose()})}),f))}).catch(s=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(s),this._parent.onErrorObservable.clear(),this.dispose()),s})}_loadData(e){if(this._gltf=e.json,this._setupData(),e.bin){let t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){let i=t[0];(i.byteLengthe.bin.byteLength)&&W.Warn(`Binary buffer length (${i.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else W.Warn("Unexpected BIN chunk")}}_setupData(){if(rt.Assign(this._gltf.accessors),rt.Assign(this._gltf.animations),rt.Assign(this._gltf.buffers),rt.Assign(this._gltf.bufferViews),rt.Assign(this._gltf.cameras),rt.Assign(this._gltf.images),rt.Assign(this._gltf.materials),rt.Assign(this._gltf.meshes),rt.Assign(this._gltf.nodes),rt.Assign(this._gltf.samplers),rt.Assign(this._gltf.scenes),rt.Assign(this._gltf.skins),rt.Assign(this._gltf.textures),this._gltf.nodes){let e={};for(let i of this._gltf.nodes)if(i.children)for(let r of i.children)e[r]=i.index;let t=this._createRootNode();for(let i of this._gltf.nodes){let r=e[i.index];i.parent=r===void 0?t:this._gltf.nodes[r]}}}async _loadExtensionsAsync(){var t;let e=[];if(GO.forEach((i,r)=>{var s;((s=this.parent.extensionOptions[r])==null?void 0:s.enabled)===!1?i.isGLTFExtension&&this.isExtensionUsed(r)&&W.Warn(`Extension ${r} is used but has been explicitly disabled.`):(!i.isGLTFExtension||this.isExtensionUsed(r))&&e.push((async()=>{let a=await i.factory(this);return a.name!==r&&W.Warn(`The name of the glTF loader extension instance does not match the registered name: ${a.name} !== ${r}`),this._parent.onExtensionLoadedObservable.notifyObservers(a),a})())}),this._extensions.push(...await Promise.all(e)),this._extensions.sort((i,r)=>(i.order||Number.MAX_VALUE)-(r.order||Number.MAX_VALUE)),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired){for(let i of this._gltf.extensionsRequired)if(!this._extensions.some(s=>s.name===i&&s.enabled))throw((t=this.parent.extensionOptions[i])==null?void 0:t.enabled)===!1?new Error(`Required extension ${i} is disabled`):new Error(`Required extension ${i} is not available`)}}_createRootNode(){if(this._parent.customRootNode!==void 0)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:this._rootBabylonMesh===null?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;let e=new U("__root__",this._babylonScene);this._rootBabylonMesh=e,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);let t={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case mc.AUTO:{this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],n._LoadTransform(t,this._rootBabylonMesh));break}case mc.FORCE_RIGHT_HANDED:{this._babylonScene.useRightHandedSystem=!0;break}default:throw new Error(`Invalid coordinate system mode (${this._parent.coordinateSystemMode})`)}return this._parent.onMeshLoadedObservable.notifyObservers(e),t}loadSceneAsync(e,t){let i=this._extensionsLoadSceneAsync(e,t);if(i)return i;let r=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(let s of t.nodes){let a=rt.Get(`${e}/nodes/${s}`,this._gltf.nodes,s);r.push(this.loadNodeAsync(`/nodes/${a.index}`,a,o=>{o.parent=this._rootBabylonMesh}))}for(let s of this._postSceneLoadActions)s();return r.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(r).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(let i of e._primitiveBabylonMeshes)t(i)}_getGeometries(){let e=[],t=this._gltf.nodes;if(t)for(let i of t)this._forEachPrimitive(i,r=>{let s=r.geometry;s&&e.indexOf(s)===-1&&e.push(s)});return e}_getMeshes(){let e=[];this._rootBabylonMesh instanceof zt&&e.push(this._rootBabylonMesh);let t=this._gltf.nodes;if(t)for(let i of t)this._forEachPrimitive(i,r=>{e.push(r)});return e}_getTransformNodes(){let e=[],t=this._gltf.nodes;if(t)for(let i of t)i._babylonTransformNode&&i._babylonTransformNode.getClassName()==="TransformNode"&&e.push(i._babylonTransformNode),i._babylonTransformNodeForSkin&&e.push(i._babylonTransformNodeForSkin);return e}_getSkeletons(){let e=[],t=this._gltf.skins;if(t)for(let i of t)i._data&&e.push(i._data.babylonSkeleton);return e}_getAnimationGroups(){let e=[],t=this._gltf.animations;if(t)for(let i of t)i._babylonAnimationGroup&&e.push(i._babylonAnimationGroup);return e}_startAnimations(){switch(this._parent.animationStartMode){case Bo.NONE:break;case Bo.FIRST:{let e=this._getAnimationGroups();e.length!==0&&e[0].start(!0);break}case Bo.ALL:{let e=this._getAnimationGroups();for(let t of e)t.start(!0);break}default:{W.Error(`Invalid animation start mode (${this._parent.animationStartMode})`);return}}}loadNodeAsync(e,t,i=()=>{}){let r=this._extensionsLoadNodeAsync(e,t,i);if(r)return r;if(t._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);let s=new Array;this.logOpen(`${e} ${t.name||""}`);let a=c=>{if(n.AddPointerMetadata(c,e),n._LoadTransform(t,c),t.camera!=null){let f=rt.Get(`${e}/camera`,this._gltf.cameras,t.camera);s.push(this.loadCameraAsync(`/cameras/${f.index}`,f,d=>{d.parent=c,this._babylonScene.useRightHandedSystem||(c.scaling.x=-1)}))}if(t.children)for(let f of t.children){let d=rt.Get(`${e}/children/${f}`,this._gltf.nodes,f);s.push(this.loadNodeAsync(`/nodes/${d.index}`,d,h=>{h.parent=c}))}i(c)},o=t.mesh!=null,l=this._parent.loadSkins&&t.skin!=null;if(!o||l){let c=t.name||`node${t.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let f=new st(c,this._babylonScene);f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t.mesh==null?t._babylonTransformNode=f:t._babylonTransformNodeForSkin=f,a(f)}if(o)if(l){let c=rt.Get(`${e}/mesh`,this._gltf.meshes,t.mesh);s.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,f=>{let d=t._babylonTransformNodeForSkin;f.metadata=TT(d.metadata,f.metadata||{});let h=rt.Get(`${e}/skin`,this._gltf.skins,t.skin);s.push(this._loadSkinAsync(`/skins/${h.index}`,t,h,u=>{this._forEachPrimitive(t,m=>{m.skeleton=u}),this._postSceneLoadActions.push(()=>{if(h.skeleton!=null){let m=rt.Get(`/skins/${h.index}/skeleton`,this._gltf.nodes,h.skeleton).parent;t.index===m.index?f.parent=d.parent:f.parent=m._babylonTransformNode}else f.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:d,skinnedNode:f})})}))}))}else{let c=rt.Get(`${e}/mesh`,this._gltf.meshes,t.mesh);s.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,a))}return this.logClose(),Promise.all(s).then(()=>(this._forEachPrimitive(t,c=>{let f=c;!f.isAnInstance&&f.geometry&&f.geometry.useBoundingInfoFromGeometry?c._updateBoundingInfo():c.refreshBoundingInfo(!0,!0)}),t._babylonTransformNode))}_loadMeshAsync(e,t,i,r){let s=i.primitives;if(!s||!s.length)throw new Error(`${e}: Primitives are missing`);s[0].index==null&&rt.Assign(s);let a=new Array;this.logOpen(`${e} ${i.name||""}`);let o=t.name||`node${t.index}`;if(s.length===1){let l=i.primitives[0];a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${l.index}`,o,t,i,l,c=>{t._babylonTransformNode=c,t._primitiveBabylonMeshes=[c]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new st(o,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(let l of s)a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${l.index}`,`${o}_primitive${l.index}`,t,i,l,c=>{c.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(c)}))}return r(t._babylonTransformNode),this.logClose(),Promise.all(a).then(()=>t._babylonTransformNode)}_loadMeshPrimitiveAsync(e,t,i,r,s,a){let o=this._extensionsLoadMeshPrimitiveAsync(e,t,i,r,s,a);if(o)return o;this.logOpen(`${e}`);let l=this._disableInstancedMesh===0&&this._parent.createInstances&&i.skin==null&&!r.primitives[0].targets,c,f;if(l&&s._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,c=s._instanceData.babylonSourceMesh.createInstance(t),c._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=s._instanceData.promise;else{let d=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;let h=new U(t,this._babylonScene);if(h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,h.sideOrientation=this._babylonScene.useRightHandedSystem?ae.CounterClockWiseSideOrientation:ae.ClockWiseSideOrientation,this._createMorphTargets(e,i,r,s,h),d.push(this._loadVertexDataAsync(e,s,h).then(async u=>await this._loadMorphTargetsAsync(e,s,h,u).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,u.applyToMesh(h),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)}))),!this.parent.skipMaterials){let u=n._GetDrawMode(e,s.mode);if(s.material==null){let m=this._defaultBabylonMaterialData[u];m||(m=this._createDefaultMaterial("__GLTFLoader._default",u),this._parent.onMaterialLoadedObservable.notifyObservers(m),this._defaultBabylonMaterialData[u]=m),h.material=m}else{let m=rt.Get(`${e}/material`,this._gltf.materials,s.material);d.push(this._loadMaterialAsync(`/materials/${m.index}`,m,h,u,p=>{h.material=p}))}}f=Promise.all(d),l&&(s._instanceData={babylonSourceMesh:h,promise:f}),c=h}return n.AddPointerMetadata(c,e),this._parent.onMeshLoadedObservable.notifyObservers(c),a(c),this.logClose(),f.then(()=>c)}_loadVertexDataAsync(e,t,i){let r=this._extensionsLoadVertexDataAsync(e,t,i);if(r)return r;let s=t.attributes;if(!s)throw new Error(`${e}: Attributes are missing`);let a=new Array,o=new Ti(i.name,this._babylonScene);if(t.indices==null)i.isUnIndexed=!0;else{let c=rt.Get(`${e}/indices`,this._gltf.accessors,t.indices);a.push(this._loadIndicesAccessorAsync(`/accessors/${c.index}`,c).then(f=>{o.setIndices(f)}))}let l=(c,f,d)=>{if(s[c]==null)return;i._delayInfo=i._delayInfo||[],i._delayInfo.indexOf(f)===-1&&i._delayInfo.push(f);let h=rt.Get(`${e}/attributes/${c}`,this._gltf.accessors,s[c]);a.push(this._loadVertexAccessorAsync(`/accessors/${h.index}`,h,f).then(u=>{if(u.getKind()===M.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!i.skeleton){let m=fY(h);m&&(o._boundingInfo=m,o.useBoundingInfoFromGeometry=!0)}o.setVerticesBuffer(u,h.count)})),f==M.MatricesIndicesExtraKind&&(i.numBoneInfluencers=8),d&&d(h)};return l("POSITION",M.PositionKind),l("NORMAL",M.NormalKind),l("TANGENT",M.TangentKind),l("TEXCOORD_0",M.UVKind),l("TEXCOORD_1",M.UV2Kind),l("TEXCOORD_2",M.UV3Kind),l("TEXCOORD_3",M.UV4Kind),l("TEXCOORD_4",M.UV5Kind),l("TEXCOORD_5",M.UV6Kind),l("JOINTS_0",M.MatricesIndicesKind),l("WEIGHTS_0",M.MatricesWeightsKind),l("JOINTS_1",M.MatricesIndicesExtraKind),l("WEIGHTS_1",M.MatricesWeightsExtraKind),l("COLOR_0",M.ColorKind,c=>{c.type==="VEC4"&&(i.hasVertexAlpha=!0)}),Promise.all(a).then(()=>o)}_createMorphTargets(e,t,i,r,s){if(!r.targets||!this._parent.loadMorphTargets)return;if(t._numMorphTargets==null)t._numMorphTargets=r.targets.length;else if(r.targets.length!==t._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);let a=i.extras?i.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,s.morphTargetManager=new ko(this._babylonScene),s.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.morphTargetManager.areUpdatesFrozen=!0;for(let o=0;o{a.areUpdatesFrozen=!1})}async _loadMorphTargetVertexDataAsync(e,t,i,r){let s=new Array,a=(o,l,c)=>{if(i[o]==null)return;let f=t.getVertexBuffer(l);if(!f)return;let d=rt.Get(`${e}/${o}`,this._gltf.accessors,i[o]);s.push(this._loadFloatAccessorAsync(`/accessors/${d.index}`,d).then(h=>{c(f,h)}))};return a("POSITION",M.PositionKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setPositions(c)}),a("NORMAL",M.NormalKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(c.length,(f,d)=>{c[d]=l[d]+f}),r.setNormals(c)}),a("TANGENT",M.TangentKind,(o,l)=>{let c=new Float32Array(l.length/3*4),f=0;o.forEach(l.length/3*4,(d,h)=>{(h+1)%4!==0&&(c[f]=l[f]+d,f++)}),r.setTangents(c)}),a("TEXCOORD_0",M.UVKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setUVs(c)}),a("TEXCOORD_1",M.UV2Kind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setUV2s(c)}),a("COLOR_0",M.ColorKind,(o,l)=>{let c=null,f=o.getSize();if(f===3){c=new Float32Array(l.length/3*4),o.forEach(l.length,(d,h)=>{let u=Math.floor(h/3),m=h%3;c[4*u+m]=l[3*u+m]+d});for(let d=0;d{c[h]=l[h]+d});else throw new Error(`${e}: Invalid number of components (${f}) for COLOR_0 attribute`);r.setColors(c)}),await Promise.all(s).then(()=>{})}static _LoadTransform(e,t){if(e.skin!=null)return;let i=v.Zero(),r=Ae.Identity(),s=v.One();e.matrix?G.FromArray(e.matrix).decompose(s,r,i):(e.translation&&(i=v.FromArray(e.translation)),e.rotation&&(r=Ae.FromArray(e.rotation)),e.scale&&(s=v.FromArray(e.scale))),t.position=i,t.rotationQuaternion=r,t.scaling=s}_loadSkinAsync(e,t,i,r){if(!this._parent.loadSkins)return Promise.resolve();let s=this._extensionsLoadSkinAsync(e,t,i);if(s)return s;if(i._data)return r(i._data.babylonSkeleton),i._data.promise;let a=`skeleton${i.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let o=new Fm(i.name||a,a,this._babylonScene);o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,i,o);let l=this._loadSkinInverseBindMatricesDataAsync(e,i).then(c=>{this._updateBoneMatrices(o,c)});return i._data={babylonSkeleton:o,promise:l},r(o),l}_loadBones(e,t,i){if(t.skeleton==null||this._parent.alwaysComputeSkeletonRootNode){let s=this._findSkeletonRootNode(`${e}/joints`,t.joints);if(s)if(t.skeleton===void 0)t.skeleton=s.index;else{let a=(l,c)=>{for(;c.parent;c=c.parent)if(c.parent===l)return!0;return!1},o=rt.Get(`${e}/skeleton`,this._gltf.nodes,t.skeleton);o!==s&&!a(o,s)&&(W.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),t.skeleton=s.index)}else W.Warn(`${e}: Failed to find common root`)}let r={};for(let s of t.joints){let a=rt.Get(`${e}/joints/${s}`,this._gltf.nodes,s);this._loadBone(a,t,i,r)}}_findSkeletonRootNode(e,t){if(t.length===0)return null;let i={};for(let s of t){let a=[],o=rt.Get(`${e}/${s}`,this._gltf.nodes,s);for(;o.index!==-1;)a.unshift(o),o=o.parent;i[s]=a}let r=null;for(let s=0;;++s){let a=i[t[0]];if(s>=a.length)return r;let o=a[s];for(let l=1;l=a.length||o!==a[s])return r;r=o}}_loadBone(e,t,i,r){e._isJoint=!0;let s=r[e.index];if(s)return s;let a=null;e.index!==t.skeleton&&(e.parent&&e.parent.index!==-1?a=this._loadBone(e.parent,t,i,r):t.skeleton!==void 0&&W.Warn(`/skins/${t.index}/skeleton: Skeleton node is not a common root`));let o=t.joints.indexOf(e.index);return s=new Kr(e.name||`joint${e.index}`,i,a,this._getNodeMatrix(e),null,null,o),r[e.index]=s,this._postSceneLoadActions.push(()=>{s.linkTransformNode(e._babylonTransformNode)}),s}_loadSkinInverseBindMatricesDataAsync(e,t){if(t.inverseBindMatrices==null)return Promise.resolve(null);let i=rt.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${i.index}`,i)}_updateBoneMatrices(e,t){for(let i of e.bones){let r=G.Identity(),s=i._index;t&&s!==-1&&(G.FromArrayToRef(t,s*16,r),r.invertToRef(r));let a=i.getParent();a&&r.multiplyToRef(a.getAbsoluteInverseBindMatrix(),r),i.updateMatrix(r,!1,!1),i._updateAbsoluteBindMatrices(void 0,!1)}}_getNodeMatrix(e){return e.matrix?G.FromArray(e.matrix):G.Compose(e.scale?v.FromArray(e.scale):v.One(),e.rotation?Ae.FromArray(e.rotation):Ae.Identity(),e.translation?v.FromArray(e.translation):v.Zero())}loadCameraAsync(e,t,i=()=>{}){let r=this._extensionsLoadCameraAsync(e,t,i);if(r)return r;let s=new Array;this.logOpen(`${e} ${t.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;let a=new Ks(t.name||`camera${t.index}`,v.Zero(),this._babylonScene,!1);switch(a._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonCamera=a,a.setTarget(new v(0,0,-1)),t.type){case"perspective":{let o=t.perspective;if(!o)throw new Error(`${e}: Camera perspective properties are missing`);a.fov=o.yfov,a.minZ=o.znear,a.maxZ=o.zfar||0;break}case"orthographic":{if(!t.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);a.mode=Ge.ORTHOGRAPHIC_CAMERA,a.orthoLeft=-t.orthographic.xmag,a.orthoRight=t.orthographic.xmag,a.orthoBottom=-t.orthographic.ymag,a.orthoTop=t.orthographic.ymag,a.minZ=t.orthographic.znear,a.maxZ=t.orthographic.zfar;break}default:throw new Error(`${e}: Invalid camera type (${t.type})`)}return n.AddPointerMetadata(a,e),this._parent.onCameraLoadedObservable.notifyObservers(a),i(a),this.logClose(),Promise.all(s).then(()=>a)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");let e=this._gltf.animations;if(!e)return Promise.resolve();let t=new Array;for(let i=0;i{s.targetedAnimations.length===0&&s.dispose()}))}return Promise.all(t).then(()=>{this._parent._endPerformanceCounter("Load animations")})}loadAnimationAsync(e,t){this._parent._startPerformanceCounter("Load animation");let i=this._extensionsLoadAnimationAsync(e,t);return i||lY.value.then(({AnimationGroup:r})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;let s=new r(t.name||`animation${t.index}`,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=s;let a=new Array;rt.Assign(t.channels),rt.Assign(t.samplers);for(let o of t.channels)a.push(this._loadAnimationChannelAsync(`${e}/channels/${o.index}`,e,t,o,(l,c)=>{l.animations=l.animations||[],l.animations.push(c),s.addTargetedAnimation(c,l)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(a).then(()=>(s.normalize(0),s))})}_loadAnimationChannelAsync(e,t,i,r,s){let a=this._extensionsLoadAnimationChannelAsync(e,t,i,r,s);if(a)return a;if(r.target.node==null)return Promise.resolve();let o=rt.Get(`${e}/target/node`,this._gltf.nodes,r.target.node),l=r.target.path,c=l==="weights";return c&&!o._numMorphTargets||!c&&!o._babylonTransformNode||!this._parent.loadNodeAnimations&&!c&&!o._isJoint?Promise.resolve():cY.value.then(()=>{var h,u,m,p;let f;switch(l){case"translation":{f=(h=qf("/nodes/{}/translation"))==null?void 0:h.interpolation;break}case"rotation":{f=(u=qf("/nodes/{}/rotation"))==null?void 0:u.interpolation;break}case"scale":{f=(m=qf("/nodes/{}/scale"))==null?void 0:m.interpolation;break}case"weights":{f=(p=qf("/nodes/{}/weights"))==null?void 0:p.interpolation;break}default:throw new Error(`${e}/target/path: Invalid value (${r.target.path})`)}if(!f)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${r.target.path})`);let d={object:o,info:f};return this._loadAnimationChannelFromTargetInfoAsync(e,t,i,r,d,s)})}_loadAnimationChannelFromTargetInfoAsync(e,t,i,r,s,a){let o=this.parent.targetFps,l=1/o,c=rt.Get(`${e}/sampler`,i.samplers,r.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${r.sampler}`,c).then(f=>{let d=0,h=s.object,u=s.info;for(let m of u){let p=m.getStride(h),_=f.input,g=f.output,T=new Array(_.length),b=0;switch(f.interpolation){case"STEP":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,1);b+=p,T[R]={frame:_[R]*o,value:S,interpolation:1}}break}case"CUBICSPLINE":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,l);b+=p;let I=m.getValue(h,g,b,1);b+=p;let x=m.getValue(h,g,b,l);b+=p,T[R]={frame:_[R]*o,inTangent:S,value:I,outTangent:x}}break}case"LINEAR":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,1);b+=p,T[R]={frame:_[R]*o,value:S}}break}}if(b>0){let R=`${i.name||`animation${i.index}`}_channel${r.index}_${d}`,S=m.buildAnimations(h,R,o,T);for(let I of S)d++,a(I.babylonAnimatable,I.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;let i=t.interpolation||"LINEAR";switch(i){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}let r=rt.Get(`${e}/input`,this._gltf.accessors,t.input),s=rt.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${s.index}`,s)]).then(([a,o])=>({input:a,interpolation:i,output:o})),t._data}loadBufferAsync(e,t,i,r){let s=this._extensionsLoadBufferAsync(e,t,i,r);if(s)return s;if(!t._data)if(t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{if(!this._bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(a=>{try{return new Uint8Array(a.buffer,a.byteOffset+i,r)}catch(o){throw new Error(`${e}: ${o.message}`,{cause:o})}})}loadBufferViewAsync(e,t){let i=this._extensionsLoadBufferViewAsync(e,t);if(i)return i;if(t._data)return t._data;let r=rt.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${r.index}`,r,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,t,i){if(t._data)return t._data;let r=n._GetNumComponents(e,t.type),s=r*M.GetTypeByteLength(t.componentType),a=r*t.count;if(t.bufferView==null)t._data=Promise.resolve(new i(a));else{let o=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${o.index}`,o).then(l=>{if(t.componentType===5126&&!t.normalized&&(!o.byteStride||o.byteStride===s))return n._GetTypedArray(e,t.componentType,l,t.byteOffset,a);{let c=new i(a);return M.ForEach(l,t.byteOffset||0,o.byteStride||s,r,t.componentType,c.length,t.normalized||!1,(f,d)=>{c[d]=f}),c}})}if(t.sparse){let o=t.sparse;t._data=t._data.then(l=>{let c=l,f=rt.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,o.indices.bufferView),d=rt.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${f.index}`,f),this.loadBufferViewAsync(`/bufferViews/${d.index}`,d)]).then(([h,u])=>{let m=n._GetTypedArray(`${e}/sparse/indices`,o.indices.componentType,h,o.indices.byteOffset,o.count),p=r*o.count,_;if(t.componentType===5126&&!t.normalized)_=n._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);else{let T=n._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);_=new i(p),M.ForEach(T,0,s,r,t.componentType,_.length,t.normalized||!1,(b,R)=>{_[R]=b})}let g=0;for(let T=0;Tn._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;let t=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(i=>new sn(t,i,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,t,i){var s;if((s=t._babylonVertexBuffer)!=null&&s[i])return t._babylonVertexBuffer[i];t._babylonVertexBuffer||(t._babylonVertexBuffer={});let r=this._babylonScene.getEngine();if(t.sparse||t.bufferView==null)t._babylonVertexBuffer[i]=this._loadFloatAccessorAsync(e,t).then(a=>new M(r,a,i,!1));else{let a=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._babylonVertexBuffer[i]=this._loadVertexBufferViewAsync(a).then(o=>{let l=n._GetNumComponents(e,t.type);return new M(r,o,i,!1,void 0,a.byteStride,void 0,t.byteOffset,l,t.componentType,t.normalized,!0,void 0,!0)})}return t._babylonVertexBuffer[i]}_loadMaterialMetallicRoughnessPropertiesAsync(e,t,i){let r=new Array,s=this._getOrCreateMaterialAdapter(i);return t&&(t.baseColorFactor?(s.baseColor=oe.FromArray(t.baseColorFactor),s.geometryOpacity=t.baseColorFactor[3]):s.baseColor=oe.White(),s.baseMetalness=t.metallicFactor==null?1:t.metallicFactor,s.specularRoughness=t.roughnessFactor==null?1:t.roughnessFactor,t.baseColorTexture&&r.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,t.baseColorTexture,a=>{a.name=`${i.name} (Base Color)`,s.baseColorTexture=a})),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,t.metallicRoughnessTexture,a=>{a.name=`${i.name} (Metallic Roughness)`,s.baseMetalnessTexture=a,s.specularRoughnessTexture=a})),s.useRoughnessFromMetallicTextureGreen=!0,s.useMetallicFromMetallicTextureBlue=!0)),Promise.all(r).then(()=>{})}_loadMaterialAsync(e,t,i,r,s=()=>{}){let a=this._extensionsLoadMaterialAsync(e,t,i,r,s);if(a)return a;t._data=t._data||{};let o=t._data[r];if(!o){this.logOpen(`${e} ${t.name||""}`);let l=this.createMaterial(e,t,r);o={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[r]=o,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return i&&(o.babylonMeshes.push(i),i.onDisposeObservable.addOnce(()=>{let l=o.babylonMeshes.indexOf(i);l!==-1&&o.babylonMeshes.splice(l,1)})),s(o.babylonMaterial),o.promise.then(()=>o.babylonMaterial)}_createDefaultMaterial(e,t){if(!this._pbrMaterialImpl)throw new Error("PBR Material class not loaded");this._babylonScene._blockEntityCollection=!!this._assetContainer;let i=new this._pbrMaterialImpl.materialClass(e,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i.fillMode=t,i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE;let r=this._getOrCreateMaterialAdapter(i);return r.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,r.baseMetalness=1,r.specularRoughness=1,i}createMaterial(e,t,i){let r=this._extensionsCreateMaterial(e,t,i);if(r)return r;let s=t.name||`material${t.index}`;return this._createDefaultMaterial(s,i)}loadMaterialPropertiesAsync(e,t,i){let r=this._extensionsLoadMaterialPropertiesAsync(e,t,i);if(r)return r;let s=new Array;return s.push(this.loadMaterialBasePropertiesAsync(e,t,i)),t.pbrMetallicRoughness&&s.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,i)),this.loadMaterialAlphaProperties(e,t,i),Promise.all(s).then(()=>{})}loadMaterialBasePropertiesAsync(e,t,i){let r=new Array,s=this._getOrCreateMaterialAdapter(i);s.emissionColor=t.emissiveFactor?oe.FromArray(t.emissiveFactor):new oe(0,0,0),t.doubleSided&&(s.backFaceCulling=!1,s.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/normalTexture`,t.normalTexture,c=>{var f;c.name=`${i.name} (Normal)`,s.geometryNormalTexture=c,((f=t.normalTexture)==null?void 0:f.scale)!=null&&(c.level=t.normalTexture.scale)})),s.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let a,o=1,l;return t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,t.occlusionTexture,c=>{c.name=`${i.name} (Occlusion)`,a=c})),t.occlusionTexture.strength!=null&&(o=t.occlusionTexture.strength)),t.emissiveTexture&&r.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,t.emissiveTexture,c=>{c.name=`${i.name} (Emissive)`,l=c})),Promise.all(r).then(()=>{a&&(s.ambientOcclusionTexture=a,s.ambientOcclusionTextureStrength=o),l&&(s.emissionColorTexture=l)})}loadMaterialAlphaProperties(e,t,i){if(!this._pbrMaterialImpl)throw new Error(`${e}: Material type not supported`);let r=this._getOrCreateMaterialAdapter(i),s=r.baseColorTexture;switch(t.alphaMode||"OPAQUE"){case"OPAQUE":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE,i.alpha=1;break}case"MASK":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHATEST,r.alphaCutOff=t.alphaCutoff==null?.5:t.alphaCutoff,s&&(s.hasAlpha=!0);break}case"BLEND":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHABLEND,s&&(s.hasAlpha=!0,r.useAlphaFromBaseColorTexture=!0);break}default:throw new Error(`${e}/alphaMode: Invalid value (${t.alphaMode})`)}}loadTextureInfoAsync(e,t,i=()=>{}){let r=this._extensionsLoadTextureInfoAsync(e,t,i);if(r)return r;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);let s=rt.Get(`${e}/index`,this._gltf.textures,t.index);s._textureInfo=t;let a=this._loadTextureAsync(`/textures/${t.index}`,s,o=>{o.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(o,e),this._parent.onTextureLoadedObservable.notifyObservers(o),i(o)});return this.logClose(),a}_loadTextureAsync(e,t,i=()=>{}){let r=this._extensionsLoadTextureAsync(e,t,i);if(r)return r;this.logOpen(`${e} ${t.name||""}`);let s=t.sampler==null?n.DefaultSampler:rt.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),a=rt.Get(`${e}/source`,this._gltf.images,t.source),o=this._createTextureAsync(e,s,a,i,void 0,!t._textureInfo.nonColorData);return this.logClose(),o}_createTextureAsync(e,t,i,r=()=>{},s,a){var m,p;let o=this._loadSampler(`/samplers/${t.index}`,t),l=new Array,c=new Pm;this._babylonScene._blockEntityCollection=!!this._assetContainer;let f={noMipmap:o.noMipMaps,invertY:!1,samplingMode:o.samplingMode,onLoad:()=>{this._disposed||c.resolve()},onError:(_,g)=>{this._disposed||c.reject(new Error(`${e}: ${g&&g.message?g.message:_||"Failed to load texture"}`))},mimeType:(p=i.mimeType)!=null?p:GI((m=i.uri)!=null?m:""),loaderOptions:s,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},d=new ne(null,this._babylonScene,f);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(c.promise);let h=i.uri&&!fa(i.uri)?i.uri:void 0,u=h!=null?h:`${this._fileName}#image${i.index}`;if(l.push(this.loadImageAsync(`/images/${i.index}`,i).then(_=>{let g=`data:${this._uniqueRootUrl}${u}`;d.updateURL(g,_);let T=d.getInternalTexture();T&&(T.label=i.name)})),d.wrapU=o.wrapU,d.wrapV=o.wrapV,r(d),this._parent.useGltfTextureNames){let _=i.name||h||`image${i.index}`;d.name=_}return Promise.all(l).then(()=>d)}_loadSampler(e,t){return t._data||(t._data={noMipMaps:t.minFilter===9728||t.minFilter===9729,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:n._GetTextureWrapMode(`${e}/wrapT`,t.wrapT)}),t._data}loadImageAsync(e,t){if(!t._data){if(this.logOpen(`${e} ${t.name||""}`),t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{let i=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i)}this.logClose()}return t._data}loadUriAsync(e,t,i){let r=this._extensionsLoadUriAsync(e,t,i);if(r)return r;if(!n._ValidateUri(i))throw new Error(`${e}: '${i}' is invalid`);if(fa(i)){let s=new Uint8Array(da(i));return this.log(`${e}: Decoded ${i.substring(0,64)}... (${s.length} bytes)`),Promise.resolve(s)}return this.log(`${e}: Loading ${i}`),this._parent.preprocessUrlAsync(this._rootUrl+i).then(s=>new Promise((a,o)=>{this._parent._loadFile(this._babylonScene,s,l=>{this._disposed||(this.log(`${e}: Loaded ${i} (${l.byteLength} bytes)`),a(new Uint8Array(l)))},!0,l=>{o(new _l(`${e}: Failed to load '${i}'${l?": "+l.status+" "+l.statusText:""}`,l))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};let i=e._internalMetadata=e._internalMetadata||{},r=i.gltf=i.gltf||{};(r.pointers=r.pointers||[]).push(t)}static _GetTextureWrapMode(e,t){switch(t=t==null?10497:t,t){case 33071:return ne.CLAMP_ADDRESSMODE;case 33648:return ne.MIRROR_ADDRESSMODE;case 10497:return ne.WRAP_ADDRESSMODE;default:return W.Warn(`${e}: Invalid value (${t})`),ne.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,t){let i=t.magFilter==null?9729:t.magFilter,r=t.minFilter==null?9987:t.minFilter;if(i===9729)switch(r){case 9728:return ne.LINEAR_NEAREST;case 9729:return ne.LINEAR_LINEAR;case 9984:return ne.LINEAR_NEAREST_MIPNEAREST;case 9985:return ne.LINEAR_LINEAR_MIPNEAREST;case 9986:return ne.LINEAR_NEAREST_MIPLINEAR;case 9987:return ne.LINEAR_LINEAR_MIPLINEAR;default:return W.Warn(`${e}/minFilter: Invalid value (${r})`),ne.LINEAR_LINEAR_MIPLINEAR}else switch(i!==9728&&W.Warn(`${e}/magFilter: Invalid value (${i})`),r){case 9728:return ne.NEAREST_NEAREST;case 9729:return ne.NEAREST_LINEAR;case 9984:return ne.NEAREST_NEAREST_MIPNEAREST;case 9985:return ne.NEAREST_LINEAR_MIPNEAREST;case 9986:return ne.NEAREST_NEAREST_MIPLINEAR;case 9987:return ne.NEAREST_LINEAR_MIPLINEAR;default:return W.Warn(`${e}/minFilter: Invalid value (${r})`),ne.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,t){try{return A_(t)}catch(i){throw new Error(`${e}: ${i.message}`,{cause:i})}}static _GetTypedArray(e,t,i,r,s){let a=i.buffer;r=i.byteOffset+(r||0);let o=n._GetTypedArrayConstructor(`${e}/componentType`,t),l=M.GetTypeByteLength(t);return r%l!==0?(W.Warn(`${e}: Copying buffer as byte offset (${r}) is not a multiple of component type byte length (${l})`),new o(a.slice(r,r+s*l),0)):new o(a,r,s)}static _GetNumComponents(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(`${e}: Invalid type (${t})`)}static _ValidateUri(e){return re.IsBase64(e)||e.indexOf("..")===-1}static _GetDrawMode(e,t){switch(t==null&&(t=4),t){case 0:return ae.PointListDrawMode;case 1:return ae.LineListDrawMode;case 2:return ae.LineLoopDrawMode;case 3:return ae.LineStripDrawMode;case 4:return ae.TriangleFillMode;case 5:return ae.TriangleStripDrawMode;case 6:return ae.TriangleFanDrawMode}throw new Error(`${e}: Invalid mesh primitive mode (${t})`)}_compileMaterialsAsync(){this._parent._startPerformanceCounter("Compile materials");let e=new Array;if(this._gltf.materials){for(let t of this._gltf.materials)if(t._data)for(let i in t._data){let r=t._data[i];for(let s of r.babylonMeshes){s.computeWorldMatrix(!0);let a=r.babylonMaterial;e.push(a.forceCompilationAsync(s)),e.push(a.forceCompilationAsync(s,{useInstances:!0})),this._parent.useClipPlane&&(e.push(a.forceCompilationAsync(s,{clipPlane:!0})),e.push(a.forceCompilationAsync(s,{clipPlane:!0,useInstances:!0})))}}}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile materials")})}_compileShadowGeneratorsAsync(){this._parent._startPerformanceCounter("Compile shadow generators");let e=new Array,t=this._babylonScene.lights;for(let i of t){let r=i.getShadowGenerator();r&&e.push(r.forceCompilationAsync())}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile shadow generators")})}_forEachExtensions(e){for(let t of this._extensions)t.enabled&&e(t)}_applyExtensions(e,t,i){for(let r of this._extensions)if(r.enabled){let s=`${r.name}.${t}`,a=e;a._activeLoaderExtensionFunctions=a._activeLoaderExtensionFunctions||{};let o=a._activeLoaderExtensionFunctions;if(!o[s]){o[s]=!0;try{let l=i(r);if(l)return l}finally{delete o[s]}}}return null}_extensionsOnLoading(){this._forEachExtensions(e=>e.onLoading&&e.onLoading())}_extensionsOnReady(){this._forEachExtensions(e=>e.onReady&&e.onReady())}_extensionsLoadSceneAsync(e,t){return this._applyExtensions(t,"loadScene",i=>i.loadSceneAsync&&i.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,i){return this._applyExtensions(t,"loadNode",r=>r.loadNodeAsync&&r.loadNodeAsync(e,t,i))}_extensionsLoadCameraAsync(e,t,i){return this._applyExtensions(t,"loadCamera",r=>r.loadCameraAsync&&r.loadCameraAsync(e,t,i))}_extensionsLoadVertexDataAsync(e,t,i){return this._applyExtensions(t,"loadVertexData",r=>r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,i))}_extensionsLoadMeshPrimitiveAsync(e,t,i,r,s,a){return this._applyExtensions(s,"loadMeshPrimitive",o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,i,r,s,a))}_extensionsLoadMaterialAsync(e,t,i,r,s){return this._applyExtensions(t,"loadMaterial",a=>a._loadMaterialAsync&&a._loadMaterialAsync(e,t,i,r,s))}_extensionsCreateMaterial(e,t,i){return this._applyExtensions(t,"createMaterial",r=>r.createMaterial&&r.createMaterial(e,t,i))}_extensionsLoadMaterialPropertiesAsync(e,t,i){return this._applyExtensions(t,"loadMaterialProperties",r=>r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,i))}_extensionsLoadTextureInfoAsync(e,t,i){return this._applyExtensions(t,"loadTextureInfo",r=>r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,i))}_extensionsLoadTextureAsync(e,t,i){return this._applyExtensions(t,"loadTexture",r=>r._loadTextureAsync&&r._loadTextureAsync(e,t,i))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",i=>i.loadAnimationAsync&&i.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,i,r,s){return this._applyExtensions(i,"loadAnimationChannel",a=>a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,i,r,s))}_extensionsLoadSkinAsync(e,t,i){return this._applyExtensions(i,"loadSkin",r=>r._loadSkinAsync&&r._loadSkinAsync(e,t,i))}_extensionsLoadUriAsync(e,t,i){return this._applyExtensions(t,"loadUri",r=>r._loadUriAsync&&r._loadUriAsync(e,t,i))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",i=>i.loadBufferViewAsync&&i.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,i,r){return this._applyExtensions(t,"loadBuffer",s=>s.loadBufferAsync&&s.loadBufferAsync(e,t,i,r))}static LoadExtensionAsync(e,t,i,r){if(!t.extensions)return null;let a=t.extensions[i];return a?r(`${e}/extensions/${i}`,a):null}static LoadExtraAsync(e,t,i,r){if(!t.extras)return null;let a=t.extras[i];return a?r(`${e}/extras/${i}`,a):null}isExtensionUsed(e){return!!this._gltf.extensionsUsed&&this._gltf.extensionsUsed.indexOf(e)!==-1}logOpen(e){this._parent._logOpen(e)}logClose(){this._parent._logClose()}log(e){this._parent._log(e)}startPerformanceCounter(e){this._parent._startPerformanceCounter(e)}endPerformanceCounter(e){this._parent._endPerformanceCounter(e)}};Zm.DefaultSampler={index:-1};Ya._CreateGLTF2Loader=n=>new Zm(n)});var qm,pB=A(()=>{qm={name:"obj",extensions:".obj"}});var Wo,_B=A(()=>{et();oi();Xs();Wo=class n{constructor(){this.materials=[]}parseMTL(e,t,i,r){if(t instanceof ArrayBuffer)return;let s=t.split(` -`),a=/\s+/,o,l=null;for(let c=0;c=0?f.substring(0,d):f;h=h.toLowerCase();let u=d>=0?f.substring(d+1).trim():"";if(h==="newmtl")l&&this.materials.push(l),e._blockEntityCollection=!!r,l=new Re(u,e),l._parentContainer=r,e._blockEntityCollection=!1;else if(h==="kd"&&l)o=u.split(a,3).map(parseFloat),l.diffuseColor=oe.FromArray(o);else if(h==="ka"&&l)o=u.split(a,3).map(parseFloat),l.ambientColor=oe.FromArray(o);else if(h==="ks"&&l)o=u.split(a,3).map(parseFloat),l.specularColor=oe.FromArray(o);else if(h==="ke"&&l)o=u.split(a,3).map(parseFloat),l.emissiveColor=oe.FromArray(o);else if(h==="ns"&&l)l.specularPower=parseFloat(u);else if(h==="d"&&l)l.alpha=parseFloat(u);else if(h==="map_ka"&&l)l.ambientTexture=n._GetTexture(i,u,e);else if(h==="map_kd"&&l)l.diffuseTexture=n._GetTexture(i,u,e);else if(h==="map_ks"&&l)l.specularTexture=n._GetTexture(i,u,e);else if(h!=="map_ns")if(h==="map_bump"&&l){let m=u.split(a),p=m.indexOf("-bm"),_=null;p>=0&&(_=m[p+1],m.splice(p,2)),l.bumpTexture=n._GetTexture(i,m.join(" "),e),l.bumpTexture&&_!==null&&(l.bumpTexture.level=parseFloat(_))}else h==="map_d"&&l&&(l.opacityTexture=n._GetTexture(i,u,e))}l&&this.materials.push(l)}static _GetTexture(e,t,i){if(!t)return null;let r=e;if(e==="file:"){let s=t.lastIndexOf("\\");s===-1&&(s=t.lastIndexOf("/")),s>-1?r+=t.substring(s+1):r+=t}else r+=t;return new ne(r,i,!1,n.INVERT_TEXTURE_Y)}};Wo.INVERT_TEXTURE_Y=!0});var fi,gB=A(()=>{yt();Xs();et();ve();Jh();Rt();Vt();ze();fi=class n{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 Ne(.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:[]});let 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:[]});let 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){var i,r;(i=e.indiceUvsFromObj)!=null||(e.indiceUvsFromObj=-1),(r=e.indiceNormalFromObj)!=null||(e.indiceNormalFromObj=-1);let t;this._loadingOptions.optimizeWithUV?t=this._isInArrayUV(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj,e.indiceUvsFromObj]):t=this._isInArray(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj]),t===-1?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(e.positionVectorFromOBJ),e.textureVectorFromOBJ!==void 0&&this._wrappedUvsForBabylon.push(e.textureVectorFromOBJ),e.normalsVectorFromOBJ!==void 0&&this._wrappedNormalsForBabylon.push(e.normalsVectorFromOBJ),e.positionColorsFromOBJ!==void 0&&this._wrappedColorsForBabylon.push(e.positionColorsFromOBJ),this._tuplePosNorm[e.indicePositionFromObj].normals.push(e.indiceNormalFromObj),this._tuplePosNorm[e.indicePositionFromObj].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e.indicePositionFromObj].uv.push(e.indiceUvsFromObj)):this._indicesForBabylon.push(t)}_unwrapData(){try{for(let e=0;e0&&(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._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice()),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon.slice()),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._handledMesh.hasLines=this._hasLineData,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){let t=e.getVerticesData(M.PositionKind),i=e.getVerticesData(M.NormalKind),r={};if(!t||!i)return;for(let a=0;athis._triangles.push(h[0],h[u],h[u+1]),this._handednessSign=1):i.useRightHandedSystem?(this._pushTriangle=(h,u)=>this._triangles.push(h[0],h[u+1],h[u]),this._handednessSign=1):(this._pushTriangle=(h,u)=>this._triangles.push(h[0],h[u],h[u+1]),this._handednessSign=-1);let a=t.split(` -`),o=[],l=[];o.push(l);for(let h=0;h=7){let p=parseFloat(m[4]),_=parseFloat(m[5]),g=parseFloat(m[6]);this._colors.push(new Ne(p>1?p/255:p,_>1?_/255:_,g>1?g/255:g,m.length===7||m[7]===void 0?1:parseFloat(m[7])))}else this._colors.push(this._grayColor)}else if((m=n.NormalPattern.exec(u))!==null)this._normals.push(new v(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])));else if((m=n.UVPattern.exec(u))!==null)this._uvs.push(new _e(parseFloat(m[1])*this._loadingOptions.UVScaling.x,parseFloat(m[2])*this._loadingOptions.UVScaling.y));else if((m=n.FacePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),1);else if((m=n.FacePattern4.exec(u))!==null)this._setDataForCurrentFaceWithPattern4(m[1].trim().split(" "),1);else if((m=n.FacePattern5.exec(u))!==null)this._setDataForCurrentFaceWithPattern5(m[1].trim().split(" "),1);else if((m=n.FacePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),1);else if((m=n.FacePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),1);else if((m=n.LinePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),0),this._hasLineData=!0;else if((m=n.LinePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),0),this._hasLineData=!0;else if(m=n._GetZbrushMRGB(u,!this._loadingOptions.importVertexColors))for(let p of m)this._extColors.push(p);else if((m=n.LinePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),0),this._hasLineData=!0;else if(n.GroupDescriptor.test(u)||n.ObjectDescriptor.test(u)){let p={name:u.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:n.ObjectDescriptor.test(u)};this._addPreviousObjMesh(),this._meshesFromObj.push(p),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(n.UseMtlDescriptor.test(u)){if(this._materialNameFromObj=u.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();let 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 n.MtlLibGroupDescriptor.test(u)?s(u.substring(7).trim()):n.SmoothDescriptor.test(u)||W.Log("Unhandled expression at line : "+u)}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._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){let h=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(let u of this._positions)this._unwrappedPositionsForBabylon.push(u.x,u.y,u.z);if(this._normals.length)for(let u of this._normals)this._unwrappedNormalsForBabylon.push(u.x,u.y,u.z);if(this._uvs.length)for(let u of this._uvs)this._unwrappedUVForBabylon.push(u.x,u.y);if(this._extColors.length)for(let u of this._extColors)this._unwrappedColorsForBabylon.push(u.r,u.g,u.b,u.a);else if(this._colors.length)for(let u of this._colors)this._unwrappedColorsForBabylon.push(u.r,u.g,u.b,u.a);this._materialNameFromObj||(h=new Re(Ti.RandomId(),i),h.pointsCloud=!0,this._materialNameFromObj=h.name,this._normals.length||(h.disableLighting=!0,h.emissiveColor=oe.White()))}this._meshesFromObj.push({name:Ti.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:h,isObject:!0,hasLines:this._hasLineData})}for(let h=0;h=0;--p)if(this._meshesFromObj[p].isObject&&this._meshesFromObj[p]._babylonMesh){u.parent=this._meshesFromObj[p]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[h].materialName),this._handledMesh.hasLines&&((f=u._internalMetadata)!=null||(u._internalMetadata={}),u._internalMetadata._isLine=!0),((d=this._handledMesh.positions)==null?void 0:d.length)===0){this._babylonMeshesArray.push(u);continue}let m=new de;if(m.indices=this._handledMesh.indices,m.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals){let p=new Array;de.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,p),m.normals=p}else m.normals=this._handledMesh.normals;this._handledMesh.uvs&&(m.uvs=this._handledMesh.uvs),this._handledMesh.colors&&(m.colors=this._handledMesh.colors),m.applyToMesh(u),this._loadingOptions.invertY&&(u.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(u),this._babylonMeshesArray.push(u),this._handledMesh.directMaterial&&(u.material=this._handledMesh.directMaterial)}}};fi.ObjectDescriptor=/^o/;fi.GroupDescriptor=/^g/;fi.MtlLibGroupDescriptor=/^mtllib /;fi.UseMtlDescriptor=/^usemtl /;fi.SmoothDescriptor=/^s /;fi.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/;fi.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;fi.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;fi.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/;fi.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;fi.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/;fi.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;fi.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/});var EB={};De(EB,{OBJFileLoader:()=>Rr});var Rr,GS=A(()=>{ve();Tt();hc();Kf();pB();_B();gB();Xs();Rr=class n{static get INVERT_TEXTURE_Y(){return Wo.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){Wo.INVERT_TEXTURE_Y=e}constructor(e){this.name=qm.name,this.extensions=qm.extensions,this._assetContainer=null,this._loadingOptions={...n._DefaultLoadingOptions,...e!=null?e:{}}}static get _DefaultLoadingOptions(){return{computeNormals:n.COMPUTE_NORMALS,optimizeNormals:n.OPTIMIZE_NORMALS,importVertexColors:n.IMPORT_VERTEX_COLORS,invertY:n.INVERT_Y,invertTextureY:n.INVERT_TEXTURE_Y,UVScaling:n.UV_SCALING,materialLoadingFailsSilently:n.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:n.OPTIMIZE_WITH_UV,skipMaterials:n.SKIP_MATERIALS,useLegacyBehavior:n.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,i,r){let s=t+e;re.LoadFile(s,i,void 0,void 0,!1,(a,o)=>{r(s,o)})}createPlugin(e){return new n(e[qm.name])}canDirectLoad(){return!1}importMeshAsync(e,t,i,r){return this._parseSolidAsync(e,t,i,r).then(s=>({meshes:s,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,i){return this.importMeshAsync(null,e,t,i).then(()=>{})}loadAssetContainerAsync(e,t,i){let r=new Kn(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,i).then(s=>(s.meshes.forEach(a=>r.meshes.push(a)),s.meshes.forEach(a=>{let o=a.material;o&&r.materials.indexOf(o)==-1&&(r.materials.push(o),o.getActiveTextures().forEach(c=>{r.textures.indexOf(c)==-1&&r.textures.push(c)}))}),this._assetContainer=null,r)).catch(s=>{throw this._assetContainer=null,s})}_parseSolidAsync(e,t,i,r){let s="",a=new Wo,o=[],l=[];i=i.replace(/#.*$/gm,"").trim(),new fi(o,l,this._loadingOptions).parse(e,i,t,this._assetContainer,d=>{s=d});let f=[];return s!==""&&!this._loadingOptions.skipMaterials&&f.push(new Promise((d,h)=>{this._loadMTL(s,r,u=>{try{a.parseMTL(t,u,r,this._assetContainer);for(let m=0;m-1;)_.push(g),p=g+1;if(g===-1&&_.length===0)a.materials[m].dispose();else for(let T=0;T<_.length;T++){let b=l[_[T]],R=a.materials[m];b.material=R,b.getTotalIndices()||(R.pointsCloud=!0)}}d()}catch(m){re.Warn(`Error processing MTL file: '${s}'`),this._loadingOptions.materialLoadingFailsSilently?d():h(m)}},(u,m)=>{re.Warn(`Error downloading MTL file: '${s}'`),this._loadingOptions.materialLoadingFailsSilently?d():h(m)})})),Promise.all(f).then(()=>{let d=h=>{var u,m;return!!((m=(u=h._internalMetadata)==null?void 0:u._isLine)!=null&&m)};return l.forEach(h=>{var u,m;if(d(h)){let p=(u=h.material)!=null?u:new Re(h.name+"_line",t);p.getBindedMeshes().filter(g=>!d(g)).length>0&&(p=(m=p.clone(p.name+"_line"))!=null?m:p),p.wireframe=!0,h.material=p,h._internalMetadata&&(h._internalMetadata._isLine=void 0)}}),l})}};Rr.OPTIMIZE_WITH_UV=!0;Rr.INVERT_Y=!1;Rr.IMPORT_VERTEX_COLORS=!1;Rr.COMPUTE_NORMALS=!1;Rr.OPTIMIZE_NORMALS=!1;Rr.UV_SCALING=new _e(1,1);Rr.SKIP_MATERIALS=!1;Rr.MATERIAL_LOADING_FAILS_SILENTLY=!0;Rr.USE_LEGACY_BEHAVIOR=!1;Xa(new Rr)});function dY(n){let e=n.trim();return/^https?:\/\//i.test(e)||/^wss?:\/\//i.test(e)||/^\/\//.test(e)}function kS(n,e){if(dY(n))throw new Error(`[AI3D] Babylon ${e} is limited to local vault resources. Refused remote URL: ${n}`);return n}function Qm(n){throw new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${n}`)}function TB(){if(vB)return;let n=i=>kS(i,"asset loading"),e=i=>kS(i,"script loading"),t=()=>-1;re.PreprocessUrl=n,re.ScriptPreprocessUrl=e,re.DefaultRetryStrategy=t,re.LoadScript=(i,r,s)=>{try{e(i),Qm(i)}catch(a){s==null||s(a instanceof Error?a.message:String(a),a);return}r==null||r()},re.LoadScriptAsync=async i=>{e(i),Qm(i)},re.LoadBabylonScript=(i,r,s)=>{try{Qm(i)}catch(a){s==null||s(a instanceof Error?a.message:String(a),a);return}r()},re.LoadBabylonScriptAsync=async i=>{Qm(i)},Mt.PreprocessUrl=n,Mt.ScriptPreprocessUrl=e,Mt.DefaultRetryStrategy=t,$t.CustomRequestModifiers.push((i,r)=>kS(r,"request")),vB=!0}var vB,SB=A(()=>{"use strict";fs();Tt();mo();vB=!1});function Jm(n,e){if(e.byteLength<84)throw new Error(`STL buffer too small: ${e.byteLength} bytes (need 84+)`);if(e.byteLength>=6){let _=new TextDecoder().decode(new Uint8Array(e,0,6));if(_==="solid "||_===`solid -`){let g=new TextDecoder().decode(new Uint8Array(e,0,Math.min(e.byteLength,800)));if(g.includes("facet")||g.includes("endsolid"))throw new Error("ASCII STL detected \u2014 only binary STL is supported. Convert to binary STL first.")}}let t=new DataView(e),i=t.getUint32(80,!0);if(console.debug(`[AI3D STL] Parsing ${e.byteLength} bytes, ${i} triangles`),i===0)throw new Error("STL file contains 0 triangles");let r=84+i*50;if(e.byteLength>0&31)/31,V=(b>>5&31)/31,X=(b>>10&31)/31,j=_*12;l[j+0]=O,l[j+1]=V,l[j+2]=X,l[j+3]=1,l[j+4]=O,l[j+5]=V,l[j+6]=X,l[j+7]=1,l[j+8]=O,l[j+9]=V,l[j+10]=X,l[j+11]=1,d++}let R=a[g+3]-a[g+0],S=a[g+4]-a[g+1],I=a[g+5]-a[g+2],x=a[g+6]-a[g+0],P=a[g+7]-a[g+1],L=a[g+8]-a[g+2],y=S*L-I*P,B=I*x-R*L,w=R*P-S*x,H=Math.sqrt(y*y+B*B+w*w);H>1e-8?(y/=H,B/=H,w/=H):(y=0,B=0,w=1,f++),o[g+0]=y,o[g+1]=B,o[g+2]=w,o[g+3]=y,o[g+4]=B,o[g+5]=w,o[g+6]=y,o[g+7]=B,o[g+8]=w,c[T+0]=g/3+0,c[T+1]=g/3+1,c[T+2]=g/3+2}f>0&&console.warn(`[AI3D STL] ${f} degenerate triangles with zero-area normals`),s&&console.debug(`[AI3D STL] Detected per-face colors: ${d}/${i} faces colored`);let u=new de;u.positions=a,u.normals=o,u.indices=c,l&&(u.colors=l);let m=new U("stl-model",n);u.applyToMesh(m);let p=new Re("stl-mat",n);return p.backFaceCulling=!1,p.specularColor=new oe(.3,.3,.3),p.specularPower=32,l?(p.diffuseColor=new oe(1,1,1),p.emissiveColor=new oe(.05,.05,.05),p.vertexColorEnabled=!0):(p.diffuseColor=new oe(.85,.85,.85),p.emissiveColor=new oe(.1,.1,.1)),m.material=p,m}function AB(n,e){return Jm(n,e)}function RB(n){n(hY)}var hY,WS=A(()=>{"use strict";Rt();Kf();Vt();Xs();et();hY={name:"stl",extensions:".stl",importMeshAsync(n,e,t){return Promise.resolve().then(()=>({meshes:[Jm(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(n,e){return Promise.resolve().then(()=>{Jm(n,e)})},loadAssetContainerAsync(n,e){return Promise.resolve().then(()=>{let t=Jm(n,e),i=new Kn(n);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(n){return n}}});function uY(n){let e=n.split(` -`),t=[],i="binary_little_endian",r=null;for(let s of e){let a=s.trim();if(a==="end_header")break;if(a==="ply"||a===""||a.startsWith("comment"))continue;let o=a.split(/\s+/),l=o[0];l==="format"?i=o[1]:l==="element"?(r={name:o[1],count:parseInt(o[2],10),properties:[]},t.push(r)):l==="property"&&r&&(o[1]==="list"?r.properties.push({name:o[4],type:"list",isList:!0,countType:o[2],itemType:o[3]}):r.properties.push({name:o[2],type:o[1],isList:!1}))}return{format:i,elements:t}}function Ac(n){switch(n){case"uchar":case"uint8":return 1;case"char":case"int8":return 1;case"ushort":case"uint16":return 2;case"short":case"int16":return 2;case"uint":case"uint32":return 4;case"int":case"int32":return 4;case"float":case"float32":return 4;case"double":case"float64":return 8;default:return 4}}function $m(n,e,t,i){switch(t){case"uchar":case"uint8":return n.getUint8(e);case"char":case"int8":return n.getInt8(e);case"ushort":case"uint16":return n.getUint16(e,i);case"short":case"int16":return n.getInt16(e,i);case"uint":case"uint32":return n.getUint32(e,i);case"int":case"int32":return n.getInt32(e,i);case"float":case"float32":return n.getFloat32(e,i);case"double":case"float64":return n.getFloat64(e,i);default:return 0}}function mY(n,e,t,i){let r=i,s=new DataView(n),a=[],o=[],l=[],c=e.elements.find(d=>d.name==="vertex"),f=e.elements.find(d=>d.name==="face");if(c){let d=c.properties.some(u=>u.name==="x"),h=c.properties.some(u=>u.name==="red"||u.name==="r");for(let u=0;uh.name==="vertex"),c=e.elements.find(h=>h.name==="face"),f=0;if(l){let h=l.properties.some(p=>p.name==="x"),u=l.properties.some(p=>p.name==="red"||p.name==="r"),m=l.properties.filter(p=>!p.isList);for(let p=0;p0){c.indices=o.indices;let h=new Array(l.length).fill(0),u=o.indices,m=l.length-3;for(let p=0;pm||g>m||T>m)continue;let b=l[_],R=l[_+1],S=l[_+2],I=l[g]-b,x=l[g+1]-R,P=l[g+2]-S,L=l[T]-b,y=l[T+1]-R,B=l[T+2]-S,w=x*B-P*y,H=P*L-I*B,O=I*y-x*L;h[_]+=w,h[_+1]+=H,h[_+2]+=O,h[g]+=w,h[g+1]+=H,h[g+2]+=O,h[T]+=w,h[T+1]+=H,h[T+2]+=O}for(let p=0;p0&&(h[p]/=_,h[p+1]/=_,h[p+2]/=_)}c.normals=h}else{let h=o.positions.length/3,u=[];for(let m=0;m=3&&u.push(0,1,2),c.indices=u}let f=new U("ply-model",n);c.applyToMesh(f);let d=new Re("ply-mat",n);return d.backFaceCulling=!1,o.colors.length>0?(c.colors=o.colors,c.applyToMesh(f),d.diffuseColor=new oe(1,1,1),d.vertexColorEnabled=!0):d.diffuseColor=new oe(.7,.7,.7),f.material=d,f}function IB(n,e){return ep(n,e)}function xB(n){n(_Y)}var _Y,HS=A(()=>{"use strict";Rt();Kf();Vt();Xs();et();_Y={name:"ply",extensions:".ply",importMeshAsync(n,e,t){return Promise.resolve().then(()=>({meshes:[ep(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(n,e){return Promise.resolve().then(()=>{ep(n,e)})},loadAssetContainerAsync(n,e){return Promise.resolve().then(()=>{let t=ep(n,e),i=new Kn(n);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(n){return n}}});async function id(){CB||(TB(),RB(Xa),xB(Xa),CB=!0)}var CB,rd=A(()=>{"use strict";mT();mB();GS();hc();SB();WS();HS();CB=!1});function bB(n,e,t){let i=n.getChildMeshes(),r=n.getBoundingInfo().boundingBox.centerWorld;for(let s of i){s.metadata||(s.metadata={});let a=s.metadata;if(!a._originalPos){let c=s.position;a._originalPos={x:c.x,y:c.y,z:c.z}}if(!a._originalCenter){let c=s.getBoundingInfo().boundingBox.centerWorld;a._originalCenter={x:c.x,y:c.y,z:c.z}}let o=(a._originalCenter[t]-r[t])*e,l=a._originalPos;s.position=new v(t==="x"?l.x+o:l.x,t==="y"?l.y+o:l.y,t==="z"?l.z+o:l.z)}}function zS(n){let e=n.getChildMeshes();for(let t of e){let i=t.metadata;i!=null&&i._originalPos&&(t.position=new v(i._originalPos.x,i._originalPos.y,i._originalPos.z))}}var MB=A(()=>{"use strict";ve()});var tp={};De(tp,{glowBlurPostProcessPixelShaderWGSL:()=>gY});var XS,yB,gY,ip=A(()=>{N();XS="glowBlurPostProcessPixelShader",yB=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform screenSize: vec2f;uniform direction: vec2f;uniform blurWidth: f32;fn getLuminance(color: vec3f)->f32 +`;E.ShadersStore[VS]||(E.ShadersStore[VS]=uB);CY={name:VS,shader:uB}});var Sc,GS,Zm,kS,Xt,_B=A(()=>{Qe();qe();ze();cn();Wm();sr();ve();yt();u1();Tu();et();Su();sf();Fi();Yr();xf();zr();Sg();Da();m1();p1();_1();g1();E1();cv();Wn();Cf();Ni();Au();Ru();Iu();xu();Sc={effect:null,subMesh:null},GS=class extends ac(sc(Zt)){},Zm=class extends rc(GS){constructor(e){super(e),this.PBR=!0,this.NUM_SAMPLES="0",this.REALTIME_FILTERING=!1,this.IBL_CDF_FILTERING=!1,this.ALBEDO=!1,this.GAMMAALBEDO=!1,this.ALBEDODIRECTUV=0,this.VERTEXCOLOR=!1,this.BASE_WEIGHT=!1,this.BASE_WEIGHTDIRECTUV=0,this.BASE_DIFFUSE_ROUGHNESS=!1,this.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.AMBIENTINGRAYSCALE=!1,this.OPACITY=!1,this.VERTEXALPHA=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHABLEND=!1,this.ALPHAFROMALBEDO=!1,this.ALPHATESTVALUE="0.5",this.SPECULAROVERALPHA=!1,this.RADIANCEOVERALPHA=!1,this.ALPHAFRESNEL=!1,this.LINEARALPHAFRESNEL=!1,this.PREMULTIPLYALPHA=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.GAMMAEMISSIVE=!1,this.REFLECTIVITY=!1,this.REFLECTIVITY_GAMMA=!1,this.REFLECTIVITYDIRECTUV=0,this.SPECULARTERM=!1,this.MICROSURFACEFROMREFLECTIVITYMAP=!1,this.MICROSURFACEAUTOMATIC=!1,this.LODBASEDMICROSFURACE=!1,this.MICROSURFACEMAP=!1,this.MICROSURFACEMAPDIRECTUV=0,this.METALLICWORKFLOW=!1,this.ROUGHNESSSTOREINMETALMAPALPHA=!1,this.ROUGHNESSSTOREINMETALMAPGREEN=!1,this.METALLNESSSTOREINMETALMAPBLUE=!1,this.AOSTOREINMETALMAPRED=!1,this.METALLIC_REFLECTANCE=!1,this.METALLIC_REFLECTANCE_GAMMA=!1,this.METALLIC_REFLECTANCEDIRECTUV=0,this.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,this.REFLECTANCE=!1,this.REFLECTANCE_GAMMA=!1,this.REFLECTANCEDIRECTUV=0,this.ENVIRONMENTBRDF=!1,this.ENVIRONMENTBRDF_RGBD=!1,this.NORMAL=!1,this.TANGENT=!1,this.BUMP=!1,this.BUMPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.NORMALXYSCALE=!0,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.USELIGHTMAPASSHADOWMAP=!1,this.GAMMALIGHTMAP=!1,this.RGBDLIGHTMAP=!1,this.REFLECTION=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.USEIRRADIANCEMAP=!1,this.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,this.USESPHERICALINVERTEX=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.LODINREFLECTIONALPHA=!1,this.GAMMAREFLECTION=!1,this.RGBDREFLECTION=!1,this.LINEARSPECULARREFLECTION=!1,this.RADIANCEOCCLUSION=!1,this.HORIZONOCCLUSION=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.NONUNIFORMSCALING=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.USEGLTFLIGHTFALLOFF=!1,this.TWOSIDEDLIGHTING=!1,this.MIRRORED=!1,this.SHADOWFLOAT=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.POINTSIZE=!1,this.FOG=!1,this.LOGARITHMICDEPTH=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.FORCENORMALFORWARD=!1,this.SPECULARAA=!1,this.UNLIT=!1,this.DECAL_AFTER_DETAIL=!1,this.DEBUGMODE=0,this.USE_VERTEX_PULLING=!1,this.VERTEX_PULLING_USE_INDEX_BUFFER=!1,this.VERTEX_PULLING_INDEX_BUFFER_32BITS=!1,this.RIGHT_HANDED=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.rebuild()}reset(){super.reset(),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0}},kS=class extends oc(Yn){},Xt=class n extends kS{get realTimeFiltering(){return this._realTimeFiltering}set realTimeFiltering(e){this._realTimeFiltering=e,this.markAsDirty(1)}get realTimeFilteringQuality(){return this._realTimeFilteringQuality}set realTimeFilteringQuality(e){this._realTimeFilteringQuality=e,this.markAsDirty(1)}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||n.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new vt(this._directIntensity,this._emissiveIntensity,this._environmentIntensity,this._specularIntensity),this._disableBumpMap=!1,this._albedoTexture=null,this._baseWeightTexture=null,this._baseDiffuseRoughnessTexture=null,this._ambientTexture=null,this._ambientTextureStrength=1,this._ambientTextureImpactOnAnalyticalLights=n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._reflectivityTexture=null,this._metallicTexture=null,this._metallic=null,this._roughness=null,this._metallicF0Factor=1,this._metallicReflectanceColor=oe.White(),this._useOnlyMetallicFromMetallicReflectanceTexture=!1,this._metallicReflectanceTexture=null,this._reflectanceTexture=null,this._microSurfaceTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._ambientColor=new oe(0,0,0),this._albedoColor=new oe(1,1,1),this._baseWeight=1,this._baseDiffuseRoughness=null,this._reflectivityColor=new oe(1,1,1),this._reflectionColor=new oe(1,1,1),this._emissiveColor=new oe(0,0,0),this._microSurface=.9,this._useLightmapAsShadowmap=!1,this._useHorizonOcclusion=!0,this._useRadianceOcclusion=!0,this._useAlphaFromAlbedoTexture=!1,this._useSpecularOverAlpha=!0,this._useMicroSurfaceFromReflectivityMapAlpha=!1,this._useRoughnessFromMetallicTextureAlpha=!0,this._useRoughnessFromMetallicTextureGreen=!1,this._useMetallnessFromMetallicTextureBlue=!1,this._useAmbientOcclusionFromMetallicTextureRed=!1,this._useAmbientInGrayScale=!1,this._useAutoMicroSurfaceFromReflectivityMap=!1,this._lightFalloff=n.LIGHTFALLOFF_PHYSICAL,this._useRadianceOverAlpha=!0,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this._parallaxScaleBias=.05,this._disableLighting=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._alphaCutOff=.4,this._useAlphaFresnel=!1,this._useLinearAlphaFresnel=!1,this._environmentBRDFTexture=null,this._forceIrradianceInFragment=!1,this._realTimeFiltering=!1,this._realTimeFilteringQuality=8,this._forceNormalForward=!1,this._enableSpecularAntiAliasing=!1,this._renderTargets=new Ct(16),this._globalAmbientColor=new oe(0,0,0),this._unlit=!1,this._applyDecalMapAfterDetailMap=!1,this._debugMode=0,this._shadersLoaded=!1,this._breakShaderLoadedCheck=!1,this._vertexPullingMetadata=null,this.debugMode=0,this.debugLimit=-1,this.debugFactor=1,this._cacheHasRenderTargetTextures=!1,this.brdf=new ei(this),this.clearCoat=new gi(this),this.iridescence=new mr(this),this.anisotropy=new js(this),this.sheen=new Ir(this),this.subSurface=new _t(this),this.detailMap=new Kr(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),ie.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=km(this.getScene()),this.prePassConfiguration=new hr}get hasRenderTargetTextures(){return ie.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){var e;return this._transparencyMode===n.PBRMATERIAL_OPAQUE||this._transparencyMode===n.PBRMATERIAL_ALPHATEST||((e=this.subSurface)==null?void 0:e.disableAlphaBlending)}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromAlbedoTexture()}needAlphaTesting(){var e;return this._hasTransparencyMode?this._transparencyModeIsTest:(e=this.subSurface)!=null&&e.disableAlphaBlending?!1:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===n.PBRMATERIAL_ALPHATEST)}_shouldUseAlphaFromAlbedoTexture(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==n.PBRMATERIAL_OPAQUE}_hasAlphaChannel(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._albedoTexture}isReadyForSubMesh(e,t,i){var h;this._uniformBufferLayoutBuilt||this.buildUniformLayout();let r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new Zm(this._eventInfo.defineNames));let s=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(s._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){if(this._albedoTexture&&ie.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&!this._baseWeightTexture.isReadyOrNotBlocking()||this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()||this._ambientTexture&&ie.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&ie.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;let u=this._getReflectionTexture();if(u&&ie.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((h=u.getInternalTexture())!=null&&h._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&ie.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&ie.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(ie.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking()||this._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking()||this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&ie.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&ie.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||s._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(s.AREALIGHTUSED||s.CLUSTLIGHT_BATCH){for(let u=0;u{m.push(`vp_${x}_info`)}))}else this._vertexPullingMetadata=null;Je&&(Je.PrepareUniforms(m,i),Je.PrepareSamplers(p,i)),Yl({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let T={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,h,T));let b=i.toString(),R=c.createEffect(u,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:b,fallbacks:f,onCompiled:r,onError:s,indexParameters:g,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:i.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this.shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(A1(),S1)),Promise.resolve().then(()=>(u3(),h3))]):await Promise.all([Promise.resolve().then(()=>(v3(),E3)),Promise.resolve().then(()=>(pB(),mB))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,R}_prepareDefines(e,t,i,r=null,s=null){let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Gl(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Hl(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Xl(o,i,this.canRenderToMRT&&!c),zl(o,i,c),Vi.PrepareDefines(l.currentRenderPassId,e,i),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){i._needUVs=!1;for(let f=1;f<=6;++f)i["MAINUV"+f]=!1;if(o.texturesEnabled){i.ALBEDODIRECTUV=0,i.BASE_WEIGHTDIRECTUV=0,i.BASE_DIFFUSE_ROUGHNESSDIRECTUV=0,i.AMBIENTDIRECTUV=0,i.OPACITYDIRECTUV=0,i.EMISSIVEDIRECTUV=0,i.REFLECTIVITYDIRECTUV=0,i.MICROSURFACEMAPDIRECTUV=0,i.METALLIC_REFLECTANCEDIRECTUV=0,i.REFLECTANCEDIRECTUV=0,i.BUMPDIRECTUV=0,i.LIGHTMAPDIRECTUV=0,l.getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&ie.DiffuseTextureEnabled?(ot(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._baseWeightTexture&&ie.BaseWeightTextureEnabled?ot(this._baseWeightTexture,i,"BASE_WEIGHT"):i.BASE_WEIGHT=!1,this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled?ot(this._baseDiffuseRoughnessTexture,i,"BASE_DIFFUSE_ROUGHNESS"):i.BASE_DIFFUSE_ROUGHNESS=!1,this._ambientTexture&&ie.AmbientTextureEnabled?(ot(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&ie.OpacityTextureEnabled?(ot(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;let f=this._getReflectionTexture(),d=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;Ra(o,f,i,this.realTimeFiltering,this.realTimeFilteringQuality,!d),this._lightmapTexture&&ie.LightmapTextureEnabled?(ot(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&ie.EmissiveTextureEnabled?(ot(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,ie.SpecularTextureEnabled?(this._metallicTexture?(ot(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,i.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(ot(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,i.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):i.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture?(i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture,this._metallicReflectanceTexture?(ot(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"),i.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):i.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(ot(this._reflectanceTexture,i,"REFLECTANCE"),i.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):i.REFLECTANCE=!1):(i.METALLIC_REFLECTANCE=!1,i.REFLECTANCE=!1),this._microSurfaceTexture?ot(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),l.getCaps().standardDerivatives&&this._bumpTexture&&ie.BumpTextureEnabled&&!this._disableBumpMap?(ot(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&ie.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAX_RHS=o.useRightHandedSystem,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):(i.BUMP=!1,i.PARALLAX=!1,i.PARALLAX_RHS=!1,i.PARALLAXOCCLUSION=!1,i.OBJECTSPACE_NORMALMAP=!1),this._environmentBRDFTexture&&ie.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===n.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===n.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.MIRRORED=!!o._mirroredCameraPosition,i.SPECULARAA=l.getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=`${this._alphaCutOff}${this._alphaCutOff%1===0?".":""}`,i.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(Ul(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),i,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t,this._isVertexOutputInvariant),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(M.NormalKind),i.DEBUGMODE=this._debugMode),kl(o,l,this,i,!!r,s,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),Wl(e,i,!0,!0,!0,this._transparencyMode!==n.PBRMATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}forceCompilation(e,t,i){let r={clipPlane:!1,useInstances:!1,...i};this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(4,this._eventInfo),(()=>{if(this._breakShaderLoadedCheck)return;let a=new Zm(this._eventInfo.defineNames),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Sc.effect=o,Sc.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Sc)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}buildUniformLayout(){let e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vBaseWeightInfos",2),e.addUniform("vBaseDiffuseRoughnessInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("baseWeightMatrix",16),e.addUniform("baseDiffuseRoughnessMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("vAlbedoColor",4),e.addUniform("baseWeight",1),e.addUniform("baseDiffuseRoughness",1),e.addUniform("vLightingIntensity",4),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vAmbientColor",3),e.addUniform("vDebugMode",2),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),e.addUniform("vReflectanceInfos",2),e.addUniform("reflectanceMatrix",16),e.addUniform("cameraInfo",4),Kl(e,!0,!0,!0,!0,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var h,u,m,p;let r=this.getScene(),s=i.materialDefines;if(!s)return;let a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e);let o=r.getEngine();this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,t,e,this.isFrozen),Vi.Bind(o.currentRenderPassId,this._activeEffect,t,e,this);let l=r.activeCamera;l?this._uniformBuffer.updateFloat4("cameraInfo",l.minZ,l.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);or(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&Pa(this._activeEffect,this._vertexPullingMetadata);let f=null,d=this._uniformBuffer;if(c){if(this.bindViewProjection(a),f=this._getReflectionTexture(),!d.useUbo||!this.isFrozen||!d.isSync||i._drawWrapper._forceRebindOnNextCall){if(r.texturesEnabled&&(this._albedoTexture&&ie.DiffuseTextureEnabled&&(d.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),lt(this._albedoTexture,d,"albedo")),this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&(d.updateFloat2("vBaseWeightInfos",this._baseWeightTexture.coordinatesIndex,this._baseWeightTexture.level),lt(this._baseWeightTexture,d,"baseWeight")),this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&(d.updateFloat2("vBaseDiffuseRoughnessInfos",this._baseDiffuseRoughnessTexture.coordinatesIndex,this._baseDiffuseRoughnessTexture.level),lt(this._baseDiffuseRoughnessTexture,d,"baseDiffuseRoughness")),this._ambientTexture&&ie.AmbientTextureEnabled&&(d.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),lt(this._ambientTexture,d,"ambient")),this._opacityTexture&&ie.OpacityTextureEnabled&&(d.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),lt(this._opacityTexture,d,"opacity")),this._emissiveTexture&&ie.EmissiveTextureEnabled&&(d.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),lt(this._emissiveTexture,d,"emissive")),this._lightmapTexture&&ie.LightmapTextureEnabled&&(d.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),lt(this._lightmapTexture,d,"lightmap")),ie.SpecularTextureEnabled&&(this._metallicTexture?(d.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),lt(this._metallicTexture,d,"reflectivity")):this._reflectivityTexture&&(d.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),lt(this._reflectivityTexture,d,"reflectivity")),this._metallicReflectanceTexture&&(d.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),lt(this._metallicReflectanceTexture,d,"metallicReflectance")),this._reflectanceTexture&&s.REFLECTANCE&&(d.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),lt(this._reflectanceTexture,d,"reflectance")),this._microSurfaceTexture&&(d.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),lt(this._microSurfaceTexture,d,"microSurfaceSampler"))),this._bumpTexture&&o.getCaps().standardDerivatives&&ie.BumpTextureEnabled&&!this._disableBumpMap&&(d.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),lt(this._bumpTexture,d,"bump"),r._mirroredCameraPosition?d.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):d.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),Pl(r,s,d,this._reflectionColor,f,this.realTimeFiltering,!0,!0,!0,!0,!0)),this.pointsCloud&&d.updateFloat("pointSize",this.pointSize),s.METALLICWORKFLOW){Ii.Color4[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,Ii.Color4[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness;let _=(u=(h=this.subSurface)==null?void 0:h._indexOfRefraction)!=null?u:1.5,g=1;Ii.Color4[0].b=_;let T=Math.pow((_-g)/(_+g),2);Ii.Color4[0].a=T,d.updateDirectColor4("vReflectivityColor",Ii.Color4[0]),d.updateColor4("vMetallicReflectanceFactors",this._metallicReflectanceColor,this._metallicF0Factor)}else d.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);d.updateColor3("vEmissiveColor",ie.EmissiveTextureEnabled?this._emissiveColor:oe.BlackReadOnly),!s.SS_REFRACTION&&((m=this.subSurface)!=null&&m._linkRefractionWithTransparency)?d.updateColor4("vAlbedoColor",this._albedoColor,1):d.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),d.updateFloat("baseWeight",this._baseWeight),d.updateFloat("baseDiffuseRoughness",this._baseDiffuseRoughness||0),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*r.environmentIntensity,this._lightingInfos.w=this._specularIntensity,d.updateVector4("vLightingIntensity",this._lightingInfos),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),d.updateColor3("vAmbientColor",this._globalAmbientColor),d.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}r.texturesEnabled&&(this._albedoTexture&&ie.DiffuseTextureEnabled&&d.setTexture("albedoSampler",this._albedoTexture),this._baseWeightTexture&&ie.BaseWeightTextureEnabled&&d.setTexture("baseWeightSampler",this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&ie.BaseDiffuseRoughnessTextureEnabled&&d.setTexture("baseDiffuseRoughnessSampler",this._baseDiffuseRoughnessTexture),this._ambientTexture&&ie.AmbientTextureEnabled&&d.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ie.OpacityTextureEnabled&&d.setTexture("opacitySampler",this._opacityTexture),iu(r,s,d,f,this.realTimeFiltering),s.ENVIRONMENTBRDF&&d.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&ie.EmissiveTextureEnabled&&d.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ie.LightmapTextureEnabled&&d.setTexture("lightmapSampler",this._lightmapTexture),ie.SpecularTextureEnabled&&(this._metallicTexture?d.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&d.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&d.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&s.REFLECTANCE&&d.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&d.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&o.getCaps().standardDerivatives&&ie.BumpTextureEnabled&&!this._disableBumpMap&&d.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(a),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Pi(this._activeEffect,this,r),this.bindEyePosition(a)}else r.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(c||!this.isFrozen)&&(r.lightsEnabled&&!this._disableLighting&&Nl(r,t,this._activeEffect,s,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==st.FOGMODE_NONE||f||this.subSurface.refractionTexture||t.receiveShadows||s.PREPASS||s.CLUSTLIGHT_BATCH)&&this.bindView(a),Sa(r,t,this._activeEffect,!0),s.NUM_MORPH_INFLUENCERS&&Oi(t,this._activeEffect),s.BAKED_VERTEX_ANIMATION_TEXTURE&&((p=t.bakedVertexAnimationManager)==null||p.bind(a,s.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),Ta(s,this._activeEffect,r)),this._afterBind(t,this._activeEffect,i),d.update()}getAnimatables(){let e=super.getAnimatables();return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._baseWeightTexture&&this._baseWeightTexture.animations&&this._baseWeightTexture.animations.length>0&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&this._baseDiffuseRoughnessTexture.animations&&this._baseDiffuseRoughnessTexture.animations.length>0&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._metallicReflectanceTexture&&this._metallicReflectanceTexture.animations&&this._metallicReflectanceTexture.animations.length>0&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&this._reflectanceTexture.animations&&this._reflectanceTexture.animations.length>0&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&this._microSurfaceTexture.animations&&this._microSurfaceTexture.animations.length>0&&e.push(this._microSurfaceTexture),e}_getReflectionTexture(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture}getActiveTextures(){let e=super.getActiveTextures();return this._albedoTexture&&e.push(this._albedoTexture),this._baseWeightTexture&&e.push(this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&e.push(this._baseDiffuseRoughnessTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._metallicReflectanceTexture&&e.push(this._metallicReflectanceTexture),this._reflectanceTexture&&e.push(this._reflectanceTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),e}hasTexture(e){return!!(super.hasTexture(e)||this._albedoTexture===e||this._baseWeightTexture===e||this._baseDiffuseRoughnessTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._reflectivityTexture===e||this._metallicTexture===e||this._metallicReflectanceTexture===e||this._reflectanceTexture===e||this._microSurfaceTexture===e||this._bumpTexture===e||this._lightmapTexture===e)}setPrePassRenderer(){var t;if(!((t=this.subSurface)!=null&&t.isScatteringEnabled))return!1;let e=this.getScene().enableSubSurfaceForPrePass();return e&&(e.enabled=!0),!0}dispose(e,t){var i,r,s,a,o,l,c,f,d,h,u,m,p,_;this._breakShaderLoadedCheck=!0,t&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),(i=this._albedoTexture)==null||i.dispose(),(r=this._baseWeightTexture)==null||r.dispose(),(s=this._baseDiffuseRoughnessTexture)==null||s.dispose(),(a=this._ambientTexture)==null||a.dispose(),(o=this._opacityTexture)==null||o.dispose(),(l=this._reflectionTexture)==null||l.dispose(),(c=this._emissiveTexture)==null||c.dispose(),(f=this._metallicTexture)==null||f.dispose(),(d=this._reflectivityTexture)==null||d.dispose(),(h=this._bumpTexture)==null||h.dispose(),(u=this._lightmapTexture)==null||u.dispose(),(m=this._metallicReflectanceTexture)==null||m.dispose(),(p=this._reflectanceTexture)==null||p.dispose(),(_=this._microSurfaceTexture)==null||_.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}};Xt.PBRMATERIAL_OPAQUE=ae.MATERIAL_OPAQUE;Xt.PBRMATERIAL_ALPHATEST=ae.MATERIAL_ALPHATEST;Xt.PBRMATERIAL_ALPHABLEND=ae.MATERIAL_ALPHABLEND;Xt.PBRMATERIAL_ALPHATESTANDBLEND=ae.MATERIAL_ALPHATESTANDBLEND;Xt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0;Xt.LIGHTFALLOFF_PHYSICAL=0;Xt.LIGHTFALLOFF_GLTF=1;Xt.LIGHTFALLOFF_STANDARD=2;Xt.ForceGLSL=!1;C([ee("_markAllSubMeshesAsMiscDirty")],Xt.prototype,"debugMode",void 0)});var gB={};De(gB,{PBRMaterial:()=>we});var we,EB=A(()=>{Qe();qe();Wm();et();_B();Lt();Fi();Kt();we=class n extends Xt{get refractionTexture(){return this.subSurface.refractionTexture}set refractionTexture(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)}get indexOfRefraction(){return this.subSurface.indexOfRefraction}set indexOfRefraction(e){this.subSurface.indexOfRefraction=e}get invertRefractionY(){return this.subSurface.invertRefractionY}set invertRefractionY(e){this.subSurface.invertRefractionY=e}get linkRefractionWithTransparency(){return this.subSurface.linkRefractionWithTransparency}set linkRefractionWithTransparency(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)}get usePhysicalLightFalloff(){return this._lightFalloff===Xt.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Xt.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=Xt.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===Xt.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Xt.LIGHTFALLOFF_GLTF:this._lightFalloff=Xt.LIGHTFALLOFF_STANDARD)}constructor(e,t,i=!1){super(e,t,i),this.directIntensity=1,this.emissiveIntensity=1,this.environmentIntensity=1,this.specularIntensity=1,this.disableBumpMap=!1,this.ambientTextureStrength=1,this.ambientTextureImpactOnAnalyticalLights=n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this.metallicF0Factor=1,this.metallicReflectanceColor=oe.White(),this.useOnlyMetallicFromMetallicReflectanceTexture=!1,this.ambientColor=new oe(0,0,0),this.albedoColor=new oe(1,1,1),this.baseWeight=1,this.reflectivityColor=new oe(1,1,1),this.reflectionColor=new oe(1,1,1),this.emissiveColor=new oe(0,0,0),this.microSurface=1,this.useLightmapAsShadowmap=!1,this.useAlphaFromAlbedoTexture=!1,this.forceAlphaTest=!1,this.alphaCutOff=.4,this.useSpecularOverAlpha=!0,this.useMicroSurfaceFromReflectivityMapAlpha=!1,this.useRoughnessFromMetallicTextureAlpha=!0,this.useRoughnessFromMetallicTextureGreen=!1,this.useMetallnessFromMetallicTextureBlue=!1,this.useAmbientOcclusionFromMetallicTextureRed=!1,this.useAmbientInGrayScale=!1,this.useAutoMicroSurfaceFromReflectivityMap=!1,this.useRadianceOverAlpha=!0,this.useObjectSpaceNormalMap=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.forceIrradianceInFragment=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this.twoSidedLighting=!1,this.useAlphaFresnel=!1,this.useLinearAlphaFresnel=!1,this.environmentBRDFTexture=null,this.forceNormalForward=!1,this.enableSpecularAntiAliasing=!1,this.useHorizonOcclusion=!0,this.useRadianceOcclusion=!0,this.unlit=!1,this.applyDecalMapAfterDetailMap=!1,this._environmentBRDFTexture=km(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){let r=Me.Clone(()=>new n(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return r.id=e,r.name=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,i),r}serialize(){let e=super.serialize();return e.customType="BABYLON.PBRMaterial",e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),ae._ParsePlugins(e,r,t,i),e.clearCoat&&r.clearCoat.parse(e.clearCoat,t,i),e.anisotropy&&r.anisotropy.parse(e.anisotropy,t,i),e.brdf&&r.brdf.parse(e.brdf,t,i),e.sheen&&r.sheen.parse(e.sheen,t,i),e.subSurface&&r.subSurface.parse(e.subSurface,t,i),e.iridescence&&r.iridescence.parse(e.iridescence,t,i),r}};we.PBRMATERIAL_OPAQUE=Xt.PBRMATERIAL_OPAQUE;we.PBRMATERIAL_ALPHATEST=Xt.PBRMATERIAL_ALPHATEST;we.PBRMATERIAL_ALPHABLEND=Xt.PBRMATERIAL_ALPHABLEND;we.PBRMATERIAL_ALPHATESTANDBLEND=Xt.PBRMATERIAL_ALPHATESTANDBLEND;we.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=Xt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"directIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"environmentIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"specularIntensity",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"disableBumpMap",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"albedoTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseWeightTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseDiffuseRoughnessTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTextureStrength",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientTextureImpactOnAnalyticalLights",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"opacityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectionTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectivityTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallic",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"roughness",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicF0Factor",void 0);C([Ht(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicReflectanceColor",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"metallicReflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectanceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"microSurfaceTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"bumpTexture",void 0);C([Ze(),ee("_markAllSubMeshesAsTexturesDirty",null)],we.prototype,"lightmapTexture",void 0);C([Ht("ambient"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"ambientColor",void 0);C([Ht("albedo"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"albedoColor",void 0);C([D("baseWeight"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseWeight",void 0);C([D("baseDiffuseRoughness"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"baseDiffuseRoughness",void 0);C([Ht("reflectivity"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectivityColor",void 0);C([Ht("reflection"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"reflectionColor",void 0);C([Ht("emissive"),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"emissiveColor",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"microSurface",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useLightmapAsShadowmap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"useAlphaFromAlbedoTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"forceAlphaTest",void 0);C([D(),ee("_markAllSubMeshesAsTexturesAndMiscDirty")],we.prototype,"alphaCutOff",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useSpecularOverAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRoughnessFromMetallicTextureAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRoughnessFromMetallicTextureGreen",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useMetallnessFromMetallicTextureBlue",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAmbientInGrayScale",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0);C([D()],we.prototype,"usePhysicalLightFalloff",null);C([D()],we.prototype,"useGLTFLightFalloff",null);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRadianceOverAlpha",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useObjectSpaceNormalMap",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useParallax",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useParallaxOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"parallaxScaleBias",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],we.prototype,"disableLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"forceIrradianceInFragment",void 0);C([D(),ee("_markAllSubMeshesAsLightsDirty")],we.prototype,"maxSimultaneousLights",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"invertNormalMapX",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"invertNormalMapY",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"twoSidedLighting",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useAlphaFresnel",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useLinearAlphaFresnel",void 0);C([ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"environmentBRDFTexture",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"forceNormalForward",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"enableSpecularAntiAliasing",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useHorizonOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsTexturesDirty")],we.prototype,"useRadianceOcclusion",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],we.prototype,"unlit",void 0);C([D(),ee("_markAllSubMeshesAsMiscDirty")],we.prototype,"applyDecalMapAfterDetailMap",void 0);je("BABYLON.PBRMaterial",we)});var vB={};De(vB,{PBRMaterialLoadingAdapter:()=>WS});var WS,TB=A(()=>{et();ST();ve();WS=class{constructor(e){this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material.useAlphaFromAlbedoTexture=e}get useAlphaFromBaseColorTexture(){return this._material.useAlphaFromAlbedoTexture}get transparencyAsAlphaCoverage(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha}set transparencyAsAlphaCoverage(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e}set baseColor(e){this._material.albedoColor=e}get baseColor(){return this._material.albedoColor}set baseColorTexture(e){this._material.albedoTexture=e}get baseColorTexture(){return this._material.albedoTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=F.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)}get baseDiffuseRoughness(){var e;return(e=this._material.baseDiffuseRoughness)!=null?e:0}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.metallic=e}get baseMetalness(){var e;return(e=this._material.metallic)!=null?e:1}set baseMetalnessTexture(e){this._material.metallicTexture=e}get baseMetalnessTexture(){return this._material.metallicTexture}set useRoughnessFromMetallicTextureGreen(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e}set useMetallicFromMetallicTextureBlue(e){this._material.useMetallnessFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){e&&(this._material.brdf.dielectricSpecularModel=F.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=F.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)}set specularWeight(e){this._material.metallicF0Factor=e}get specularWeight(){var e;return(e=this._material.metallicF0Factor)!=null?e:1}set specularWeightTexture(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)}get specularWeightTexture(){return this._material.metallicReflectanceTexture}set specularColor(e){this._material.metallicReflectanceColor=e}get specularColor(){return this._material.metallicReflectanceColor}set specularColorTexture(e){this._material.reflectanceTexture=e}get specularColorTexture(){return this._material.reflectanceTexture}set specularRoughness(e){this._material.roughness=e}get specularRoughness(){var e;return(e=this._material.roughness)!=null?e:1}set specularRoughnessTexture(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)}get specularRoughnessTexture(){return this._material.metallicTexture}set specularIor(e){this._material.indexOfRefraction=e}get specularIor(){return this._material.indexOfRefraction}set emissionColor(e){this._material.emissiveColor=e}get emissionColor(){return this._material.emissiveColor}set emissionLuminance(e){this._material.emissiveIntensity=e}get emissionLuminance(){return this._material.emissiveIntensity}set emissionColorTexture(e){this._material.emissiveTexture=e}get emissionColorTexture(){return this._material.emissiveTexture}set ambientOcclusionTexture(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)}get ambientOcclusionTexture(){return this._material.ambientTexture}set ambientOcclusionTextureStrength(e){this._material.ambientTextureStrength=e}get ambientOcclusionTextureStrength(){var e;return(e=this._material.ambientTextureStrength)!=null?e:1}configureCoat(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1}set coatWeight(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e}get coatWeight(){return this._material.clearCoat.intensity}set coatWeightTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e}get coatWeightTexture(){return this._material.clearCoat.texture}set coatColor(e){this._material.clearCoat.isTintEnabled=e!=oe.White(),this._material.clearCoat.tintColor=e}set coatColorTexture(e){this._material.clearCoat.tintTexture=e}set coatRoughness(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e}get coatRoughness(){var e;return(e=this._material.clearCoat.roughness)!=null?e:0}set coatRoughnessTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e}get coatRoughnessTexture(){return this._material.clearCoat.textureRoughness}set coatIor(e){this._material.clearCoat.indexOfRefraction=e}set coatDarkening(e){}set coatDarkeningTexture(e){}set coatRoughnessAnisotropy(e){}get coatRoughnessAnisotropy(){return 0}set geometryCoatTangentAngle(e){}set geometryCoatTangentTexture(e){}get geometryCoatTangentTexture(){return null}set transmissionWeight(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e}get transmissionWeight(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0}set transmissionWeightTexture(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set transmissionDepth(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new oe(e,e,e))}get transmissionDepth(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0}set transmissionColor(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)}get transmissionColor(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new oe(0,0,0)}set transmissionScatter(e){this._material.subSurface.diffusionDistance=e}get transmissionScatter(){return this._material.subSurface.diffusionDistance}set transmissionScatterTexture(e){}set transmissionScatterAnisotropy(e){}set transmissionDispersionAbbeNumber(e){}set transmissionDispersionScale(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)}get refractionBackgroundTexture(){return this._material.subSurface.refractionTexture}set refractionBackgroundTexture(e){this._material.subSurface.refractionTexture=e}configureTransmission(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0}configureVolume(){}set geometryThinWalled(e){}get geometryThinWalled(){return!0}set volumeThicknessTexture(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set volumeThickness(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)}configureSubsurface(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1}set subsurfaceWeight(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e}get subsurfaceWeight(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0}set subsurfaceWeightTexture(e){this._material.subSurface.translucencyIntensityTexture=e}set subsurfaceColor(e){let t=new v(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));t.scaleInPlace(1/Math.max(this.transmissionDepth,.001));let i=t,r=Math.max(i.x,Math.max(i.y,i.z)),s=r>0?1/r:1;this._material.subSurface.diffusionDistance=new oe(Math.exp(-i.x*s),Math.exp(-i.y*s),Math.exp(-i.z*s))}set subsurfaceColorTexture(e){}set diffuseTransmissionTint(e){this._material.subSurface.tintColor=e}get diffuseTransmissionTint(){return this._material.subSurface.tintColor}set diffuseTransmissionTintTexture(e){this._material.subSurface.translucencyColorTexture=e}get subsurfaceRadius(){return 1}set subsurfaceRadius(e){}get subsurfaceRadiusScale(){var e;return(e=this._material.subSurface.scatteringDiffusionProfile)!=null?e:oe.White()}set subsurfaceRadiusScale(e){this._material.subSurface.scatteringDiffusionProfile=e}set subsurfaceScatterAnisotropy(e){}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0}set fuzzWeight(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e}set fuzzWeightTexture(e){this._material.sheen.texture||(this._material.sheen.texture=e)}set fuzzColor(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e}set fuzzColorTexture(e){this._material.sheen.texture=e}set fuzzRoughness(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e}set fuzzRoughnessTexture(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e}set specularRoughnessAnisotropy(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e}get specularRoughnessAnisotropy(){return this._material.anisotropy.intensity}set geometryTangentAngle(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e}set geometryTangentTexture(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e}get geometryTangentTexture(){return this._material.anisotropy.texture}configureGltfStyleAnisotropy(e=!0){}set thinFilmWeight(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e}set thinFilmIor(e){this._material.iridescence.indexOfRefraction=e}set thinFilmThicknessMinimum(e){this._material.iridescence.minimumThickness=e}set thinFilmThicknessMaximum(e){this._material.iridescence.maximumThickness=e}set thinFilmWeightTexture(e){this._material.iridescence.texture=e}set thinFilmThicknessTexture(e){this._material.iridescence.thicknessTexture=e}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.alpha=e}get geometryOpacity(){return this._material.alpha}set geometryNormalTexture(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0}get geometryNormalTexture(){return this._material.bumpTexture}setNormalMapInversions(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t}set geometryCoatNormalTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e}get geometryCoatNormalTexture(){return this._material.clearCoat.bumpTexture}set geometryCoatNormalTextureScale(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)}}});function yY(n){if(n.min&&n.max){let e=n.min,t=n.max,i=G.Vector3[0].copyFromFloats(e[0],e[1],e[2]),r=G.Vector3[1].copyFromFloats(t[0],t[1],t[2]);if(n.normalized&&n.componentType!==5126){let s=1;switch(n.componentType){case 5120:s=127;break;case 5121:s=255;break;case 5122:s=32767;break;case 5123:s=65535;break}let a=1/s;i.scaleInPlace(a),r.scaleInPlace(a)}return new Ti(i,r)}return null}var bY,MY,rt,qm,SB=A(()=>{FO();ve();et();Tt();Gn();WO();Fm();zO();Fi();oi();yl();yt();$h();Dl();Rt();ET();YO();gT();ds();ze();bl();ZO();AT();JO();_l();$O();bY=new Jf(()=>Promise.resolve().then(()=>(nN(),rN))),MY=new Jf(()=>Promise.resolve().then(()=>(lN(),oN))),rt=class{static Get(e,t,i){if(!t||i==null||!t[i])throw new Error(`${e}: Failed to find index (${i})`);return t[i]}static TryGet(e,t){return!e||t==null||!e[t]?null:e[t]}static Assign(e){if(e)for(let t=0;tt.dispose&&t.dispose()),this._extensions.length=0;for(let t of Array.from(this._materialAdapters))(e=t.finalize)==null||e.call(t);this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose()}}async importMeshAsync(e,t,i,r,s,a,o=""){return await Promise.resolve().then(async()=>{this._babylonScene=t,this._assetContainer=i,this._loadData(r);let l=null;if(e){let c={};if(this._gltf.nodes)for(let d of this._gltf.nodes)d.name&&(c[d.name]=d.index);l=(e instanceof Array?e:[e]).map(d=>{let h=c[d];if(h===void 0)throw new Error(`Failed to find node '${d}'`);return h})}return await this._loadAsync(s,o,l,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))})}async loadAsync(e,t,i,r,s=""){return this._babylonScene=e,this._loadData(t),await this._loadAsync(i,s,null,()=>{})}async _loadAsync(e,t,i,r){return await Promise.resolve().then(async()=>{this._rootUrl=e,this._uniqueRootUrl=!e.startsWith("file:")&&t?e:`${e}${Date.now()}/`,this._fileName=t,this._allMaterialsDirtyRequired=!1,await this._loadExtensionsAsync(),!this.parent.skipMaterials&&this._pbrMaterialImpl==null&&(this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr")?this._pbrMaterialImpl={materialClass:(await Promise.resolve().then(()=>(f1(),c1))).OpenPBRMaterial,adapterClass:(await Promise.resolve().then(()=>(h1(),d1))).OpenPBRMaterialLoadingAdapter}:this._pbrMaterialImpl={materialClass:(await Promise.resolve().then(()=>(EB(),gB))).PBRMaterial,adapterClass:(await Promise.resolve().then(()=>(TB(),vB))).PBRMaterialLoadingAdapter});let s=`${ji[ji.LOADING]} => ${ji[ji.READY]}`,a=`${ji[ji.LOADING]} => ${ji[ji.COMPLETE]}`;this._parent._startPerformanceCounter(s),this._parent._startPerformanceCounter(a),this._parent._setState(ji.LOADING),this._extensionsOnLoading();let o=new Array,l=this._babylonScene.blockMaterialDirtyMechanism;if(this._babylonScene.blockMaterialDirtyMechanism=!0,!this.parent.loadOnlyMaterials){if(i)o.push(this.loadSceneAsync("/nodes",{nodes:i,index:-1}));else if(this._gltf.scene!=null||this._gltf.scenes&&this._gltf.scenes[0]){let f=rt.Get("/scene",this._gltf.scenes,this._gltf.scene||0);o.push(this.loadSceneAsync(`/scenes/${f.index}`,f))}}if(!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(let f=0;f{}))}return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=l:this._babylonScene._forceBlockMaterialDirtyMechanism(l),this._parent.compileMaterials&&o.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&o.push(this._compileShadowGeneratorsAsync()),await Promise.all(o).then(()=>{this._rootBabylonMesh&&this._rootBabylonMesh!==this._parent.customRootNode&&this._rootBabylonMesh.setEnabled(!0);for(let f of this._babylonScene.materials){let d=f;d.maxSimultaneousLights!==void 0&&(d.maxSimultaneousLights=Math.max(d.maxSimultaneousLights,this._babylonScene.lights.length))}return this._extensionsOnReady(),this._parent._setState(ji.READY),this._skipStartAnimationStep||this._startAnimations(),r()}).then(f=>(this._parent._endPerformanceCounter(s),re.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(a),this._parent._setState(ji.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},d=>{this._parent.onErrorObservable.notifyObservers(d),this._parent.onErrorObservable.clear(),this.dispose()})}),f))}).catch(s=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(s),this._parent.onErrorObservable.clear(),this.dispose()),s})}_loadData(e){if(this._gltf=e.json,this._setupData(),e.bin){let t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){let i=t[0];(i.byteLengthe.bin.byteLength)&&W.Warn(`Binary buffer length (${i.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else W.Warn("Unexpected BIN chunk")}}_setupData(){if(rt.Assign(this._gltf.accessors),rt.Assign(this._gltf.animations),rt.Assign(this._gltf.buffers),rt.Assign(this._gltf.bufferViews),rt.Assign(this._gltf.cameras),rt.Assign(this._gltf.images),rt.Assign(this._gltf.materials),rt.Assign(this._gltf.meshes),rt.Assign(this._gltf.nodes),rt.Assign(this._gltf.samplers),rt.Assign(this._gltf.scenes),rt.Assign(this._gltf.skins),rt.Assign(this._gltf.textures),this._gltf.nodes){let e={};for(let i of this._gltf.nodes)if(i.children)for(let r of i.children)e[r]=i.index;let t=this._createRootNode();for(let i of this._gltf.nodes){let r=e[i.index];i.parent=r===void 0?t:this._gltf.nodes[r]}}}async _loadExtensionsAsync(){var t;let e=[];if(KO.forEach((i,r)=>{var s;((s=this.parent.extensionOptions[r])==null?void 0:s.enabled)===!1?i.isGLTFExtension&&this.isExtensionUsed(r)&&W.Warn(`Extension ${r} is used but has been explicitly disabled.`):(!i.isGLTFExtension||this.isExtensionUsed(r))&&e.push((async()=>{let a=await i.factory(this);return a.name!==r&&W.Warn(`The name of the glTF loader extension instance does not match the registered name: ${a.name} !== ${r}`),this._parent.onExtensionLoadedObservable.notifyObservers(a),a})())}),this._extensions.push(...await Promise.all(e)),this._extensions.sort((i,r)=>(i.order||Number.MAX_VALUE)-(r.order||Number.MAX_VALUE)),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired){for(let i of this._gltf.extensionsRequired)if(!this._extensions.some(s=>s.name===i&&s.enabled))throw((t=this.parent.extensionOptions[i])==null?void 0:t.enabled)===!1?new Error(`Required extension ${i} is disabled`):new Error(`Required extension ${i} is not available`)}}_createRootNode(){if(this._parent.customRootNode!==void 0)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:this._rootBabylonMesh===null?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;let e=new V("__root__",this._babylonScene);this._rootBabylonMesh=e,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);let t={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case mc.AUTO:{this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],n._LoadTransform(t,this._rootBabylonMesh));break}case mc.FORCE_RIGHT_HANDED:{this._babylonScene.useRightHandedSystem=!0;break}default:throw new Error(`Invalid coordinate system mode (${this._parent.coordinateSystemMode})`)}return this._parent.onMeshLoadedObservable.notifyObservers(e),t}loadSceneAsync(e,t){let i=this._extensionsLoadSceneAsync(e,t);if(i)return i;let r=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(let s of t.nodes){let a=rt.Get(`${e}/nodes/${s}`,this._gltf.nodes,s);r.push(this.loadNodeAsync(`/nodes/${a.index}`,a,o=>{o.parent=this._rootBabylonMesh}))}for(let s of this._postSceneLoadActions)s();return r.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(r).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(let i of e._primitiveBabylonMeshes)t(i)}_getGeometries(){let e=[],t=this._gltf.nodes;if(t)for(let i of t)this._forEachPrimitive(i,r=>{let s=r.geometry;s&&e.indexOf(s)===-1&&e.push(s)});return e}_getMeshes(){let e=[];this._rootBabylonMesh instanceof zt&&e.push(this._rootBabylonMesh);let t=this._gltf.nodes;if(t)for(let i of t)this._forEachPrimitive(i,r=>{e.push(r)});return e}_getTransformNodes(){let e=[],t=this._gltf.nodes;if(t)for(let i of t)i._babylonTransformNode&&i._babylonTransformNode.getClassName()==="TransformNode"&&e.push(i._babylonTransformNode),i._babylonTransformNodeForSkin&&e.push(i._babylonTransformNodeForSkin);return e}_getSkeletons(){let e=[],t=this._gltf.skins;if(t)for(let i of t)i._data&&e.push(i._data.babylonSkeleton);return e}_getAnimationGroups(){let e=[],t=this._gltf.animations;if(t)for(let i of t)i._babylonAnimationGroup&&e.push(i._babylonAnimationGroup);return e}_startAnimations(){switch(this._parent.animationStartMode){case Uo.NONE:break;case Uo.FIRST:{let e=this._getAnimationGroups();e.length!==0&&e[0].start(!0);break}case Uo.ALL:{let e=this._getAnimationGroups();for(let t of e)t.start(!0);break}default:{W.Error(`Invalid animation start mode (${this._parent.animationStartMode})`);return}}}loadNodeAsync(e,t,i=()=>{}){let r=this._extensionsLoadNodeAsync(e,t,i);if(r)return r;if(t._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);let s=new Array;this.logOpen(`${e} ${t.name||""}`);let a=c=>{if(n.AddPointerMetadata(c,e),n._LoadTransform(t,c),t.camera!=null){let f=rt.Get(`${e}/camera`,this._gltf.cameras,t.camera);s.push(this.loadCameraAsync(`/cameras/${f.index}`,f,d=>{d.parent=c,this._babylonScene.useRightHandedSystem||(c.scaling.x=-1)}))}if(t.children)for(let f of t.children){let d=rt.Get(`${e}/children/${f}`,this._gltf.nodes,f);s.push(this.loadNodeAsync(`/nodes/${d.index}`,d,h=>{h.parent=c}))}i(c)},o=t.mesh!=null,l=this._parent.loadSkins&&t.skin!=null;if(!o||l){let c=t.name||`node${t.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let f=new at(c,this._babylonScene);f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t.mesh==null?t._babylonTransformNode=f:t._babylonTransformNodeForSkin=f,a(f)}if(o)if(l){let c=rt.Get(`${e}/mesh`,this._gltf.meshes,t.mesh);s.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,f=>{let d=t._babylonTransformNodeForSkin;f.metadata=RT(d.metadata,f.metadata||{});let h=rt.Get(`${e}/skin`,this._gltf.skins,t.skin);s.push(this._loadSkinAsync(`/skins/${h.index}`,t,h,u=>{this._forEachPrimitive(t,m=>{m.skeleton=u}),this._postSceneLoadActions.push(()=>{if(h.skeleton!=null){let m=rt.Get(`/skins/${h.index}/skeleton`,this._gltf.nodes,h.skeleton).parent;t.index===m.index?f.parent=d.parent:f.parent=m._babylonTransformNode}else f.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:d,skinnedNode:f})})}))}))}else{let c=rt.Get(`${e}/mesh`,this._gltf.meshes,t.mesh);s.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,a))}return this.logClose(),Promise.all(s).then(()=>(this._forEachPrimitive(t,c=>{let f=c;!f.isAnInstance&&f.geometry&&f.geometry.useBoundingInfoFromGeometry?c._updateBoundingInfo():c.refreshBoundingInfo(!0,!0)}),t._babylonTransformNode))}_loadMeshAsync(e,t,i,r){let s=i.primitives;if(!s||!s.length)throw new Error(`${e}: Primitives are missing`);s[0].index==null&&rt.Assign(s);let a=new Array;this.logOpen(`${e} ${i.name||""}`);let o=t.name||`node${t.index}`;if(s.length===1){let l=i.primitives[0];a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${l.index}`,o,t,i,l,c=>{t._babylonTransformNode=c,t._primitiveBabylonMeshes=[c]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new at(o,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(let l of s)a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${l.index}`,`${o}_primitive${l.index}`,t,i,l,c=>{c.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(c)}))}return r(t._babylonTransformNode),this.logClose(),Promise.all(a).then(()=>t._babylonTransformNode)}_loadMeshPrimitiveAsync(e,t,i,r,s,a){let o=this._extensionsLoadMeshPrimitiveAsync(e,t,i,r,s,a);if(o)return o;this.logOpen(`${e}`);let l=this._disableInstancedMesh===0&&this._parent.createInstances&&i.skin==null&&!r.primitives[0].targets,c,f;if(l&&s._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,c=s._instanceData.babylonSourceMesh.createInstance(t),c._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=s._instanceData.promise;else{let d=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;let h=new V(t,this._babylonScene);if(h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,h.sideOrientation=this._babylonScene.useRightHandedSystem?ae.CounterClockWiseSideOrientation:ae.ClockWiseSideOrientation,this._createMorphTargets(e,i,r,s,h),d.push(this._loadVertexDataAsync(e,s,h).then(async u=>await this._loadMorphTargetsAsync(e,s,h,u).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,u.applyToMesh(h),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)}))),!this.parent.skipMaterials){let u=n._GetDrawMode(e,s.mode);if(s.material==null){let m=this._defaultBabylonMaterialData[u];m||(m=this._createDefaultMaterial("__GLTFLoader._default",u),this._parent.onMaterialLoadedObservable.notifyObservers(m),this._defaultBabylonMaterialData[u]=m),h.material=m}else{let m=rt.Get(`${e}/material`,this._gltf.materials,s.material);d.push(this._loadMaterialAsync(`/materials/${m.index}`,m,h,u,p=>{h.material=p}))}}f=Promise.all(d),l&&(s._instanceData={babylonSourceMesh:h,promise:f}),c=h}return n.AddPointerMetadata(c,e),this._parent.onMeshLoadedObservable.notifyObservers(c),a(c),this.logClose(),f.then(()=>c)}_loadVertexDataAsync(e,t,i){let r=this._extensionsLoadVertexDataAsync(e,t,i);if(r)return r;let s=t.attributes;if(!s)throw new Error(`${e}: Attributes are missing`);let a=new Array,o=new Si(i.name,this._babylonScene);if(t.indices==null)i.isUnIndexed=!0;else{let c=rt.Get(`${e}/indices`,this._gltf.accessors,t.indices);a.push(this._loadIndicesAccessorAsync(`/accessors/${c.index}`,c).then(f=>{o.setIndices(f)}))}let l=(c,f,d)=>{if(s[c]==null)return;i._delayInfo=i._delayInfo||[],i._delayInfo.indexOf(f)===-1&&i._delayInfo.push(f);let h=rt.Get(`${e}/attributes/${c}`,this._gltf.accessors,s[c]);a.push(this._loadVertexAccessorAsync(`/accessors/${h.index}`,h,f).then(u=>{if(u.getKind()===M.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!i.skeleton){let m=yY(h);m&&(o._boundingInfo=m,o.useBoundingInfoFromGeometry=!0)}o.setVerticesBuffer(u,h.count)})),f==M.MatricesIndicesExtraKind&&(i.numBoneInfluencers=8),d&&d(h)};return l("POSITION",M.PositionKind),l("NORMAL",M.NormalKind),l("TANGENT",M.TangentKind),l("TEXCOORD_0",M.UVKind),l("TEXCOORD_1",M.UV2Kind),l("TEXCOORD_2",M.UV3Kind),l("TEXCOORD_3",M.UV4Kind),l("TEXCOORD_4",M.UV5Kind),l("TEXCOORD_5",M.UV6Kind),l("JOINTS_0",M.MatricesIndicesKind),l("WEIGHTS_0",M.MatricesWeightsKind),l("JOINTS_1",M.MatricesIndicesExtraKind),l("WEIGHTS_1",M.MatricesWeightsExtraKind),l("COLOR_0",M.ColorKind,c=>{c.type==="VEC4"&&(i.hasVertexAlpha=!0)}),Promise.all(a).then(()=>o)}_createMorphTargets(e,t,i,r,s){if(!r.targets||!this._parent.loadMorphTargets)return;if(t._numMorphTargets==null)t._numMorphTargets=r.targets.length;else if(r.targets.length!==t._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);let a=i.extras?i.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,s.morphTargetManager=new Wo(this._babylonScene),s.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.morphTargetManager.areUpdatesFrozen=!0;for(let o=0;o{a.areUpdatesFrozen=!1})}async _loadMorphTargetVertexDataAsync(e,t,i,r){let s=new Array,a=(o,l,c)=>{if(i[o]==null)return;let f=t.getVertexBuffer(l);if(!f)return;let d=rt.Get(`${e}/${o}`,this._gltf.accessors,i[o]);s.push(this._loadFloatAccessorAsync(`/accessors/${d.index}`,d).then(h=>{c(f,h)}))};return a("POSITION",M.PositionKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setPositions(c)}),a("NORMAL",M.NormalKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(c.length,(f,d)=>{c[d]=l[d]+f}),r.setNormals(c)}),a("TANGENT",M.TangentKind,(o,l)=>{let c=new Float32Array(l.length/3*4),f=0;o.forEach(l.length/3*4,(d,h)=>{(h+1)%4!==0&&(c[f]=l[f]+d,f++)}),r.setTangents(c)}),a("TEXCOORD_0",M.UVKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setUVs(c)}),a("TEXCOORD_1",M.UV2Kind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,d)=>{c[d]=l[d]+f}),r.setUV2s(c)}),a("COLOR_0",M.ColorKind,(o,l)=>{let c=null,f=o.getSize();if(f===3){c=new Float32Array(l.length/3*4),o.forEach(l.length,(d,h)=>{let u=Math.floor(h/3),m=h%3;c[4*u+m]=l[3*u+m]+d});for(let d=0;d{c[h]=l[h]+d});else throw new Error(`${e}: Invalid number of components (${f}) for COLOR_0 attribute`);r.setColors(c)}),await Promise.all(s).then(()=>{})}static _LoadTransform(e,t){if(e.skin!=null)return;let i=v.Zero(),r=Ae.Identity(),s=v.One();e.matrix?U.FromArray(e.matrix).decompose(s,r,i):(e.translation&&(i=v.FromArray(e.translation)),e.rotation&&(r=Ae.FromArray(e.rotation)),e.scale&&(s=v.FromArray(e.scale))),t.position=i,t.rotationQuaternion=r,t.scaling=s}_loadSkinAsync(e,t,i,r){if(!this._parent.loadSkins)return Promise.resolve();let s=this._extensionsLoadSkinAsync(e,t,i);if(s)return s;if(i._data)return r(i._data.babylonSkeleton),i._data.promise;let a=`skeleton${i.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let o=new wm(i.name||a,a,this._babylonScene);o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,i,o);let l=this._loadSkinInverseBindMatricesDataAsync(e,i).then(c=>{this._updateBoneMatrices(o,c)});return i._data={babylonSkeleton:o,promise:l},r(o),l}_loadBones(e,t,i){if(t.skeleton==null||this._parent.alwaysComputeSkeletonRootNode){let s=this._findSkeletonRootNode(`${e}/joints`,t.joints);if(s)if(t.skeleton===void 0)t.skeleton=s.index;else{let a=(l,c)=>{for(;c.parent;c=c.parent)if(c.parent===l)return!0;return!1},o=rt.Get(`${e}/skeleton`,this._gltf.nodes,t.skeleton);o!==s&&!a(o,s)&&(W.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),t.skeleton=s.index)}else W.Warn(`${e}: Failed to find common root`)}let r={};for(let s of t.joints){let a=rt.Get(`${e}/joints/${s}`,this._gltf.nodes,s);this._loadBone(a,t,i,r)}}_findSkeletonRootNode(e,t){if(t.length===0)return null;let i={};for(let s of t){let a=[],o=rt.Get(`${e}/${s}`,this._gltf.nodes,s);for(;o.index!==-1;)a.unshift(o),o=o.parent;i[s]=a}let r=null;for(let s=0;;++s){let a=i[t[0]];if(s>=a.length)return r;let o=a[s];for(let l=1;l=a.length||o!==a[s])return r;r=o}}_loadBone(e,t,i,r){e._isJoint=!0;let s=r[e.index];if(s)return s;let a=null;e.index!==t.skeleton&&(e.parent&&e.parent.index!==-1?a=this._loadBone(e.parent,t,i,r):t.skeleton!==void 0&&W.Warn(`/skins/${t.index}/skeleton: Skeleton node is not a common root`));let o=t.joints.indexOf(e.index);return s=new Zr(e.name||`joint${e.index}`,i,a,this._getNodeMatrix(e),null,null,o),r[e.index]=s,this._postSceneLoadActions.push(()=>{s.linkTransformNode(e._babylonTransformNode)}),s}_loadSkinInverseBindMatricesDataAsync(e,t){if(t.inverseBindMatrices==null)return Promise.resolve(null);let i=rt.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${i.index}`,i)}_updateBoneMatrices(e,t){for(let i of e.bones){let r=U.Identity(),s=i._index;t&&s!==-1&&(U.FromArrayToRef(t,s*16,r),r.invertToRef(r));let a=i.getParent();a&&r.multiplyToRef(a.getAbsoluteInverseBindMatrix(),r),i.updateMatrix(r,!1,!1),i._updateAbsoluteBindMatrices(void 0,!1)}}_getNodeMatrix(e){return e.matrix?U.FromArray(e.matrix):U.Compose(e.scale?v.FromArray(e.scale):v.One(),e.rotation?Ae.FromArray(e.rotation):Ae.Identity(),e.translation?v.FromArray(e.translation):v.Zero())}loadCameraAsync(e,t,i=()=>{}){let r=this._extensionsLoadCameraAsync(e,t,i);if(r)return r;let s=new Array;this.logOpen(`${e} ${t.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;let a=new Ks(t.name||`camera${t.index}`,v.Zero(),this._babylonScene,!1);switch(a._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonCamera=a,a.setTarget(new v(0,0,-1)),t.type){case"perspective":{let o=t.perspective;if(!o)throw new Error(`${e}: Camera perspective properties are missing`);a.fov=o.yfov,a.minZ=o.znear,a.maxZ=o.zfar||0;break}case"orthographic":{if(!t.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);a.mode=Ue.ORTHOGRAPHIC_CAMERA,a.orthoLeft=-t.orthographic.xmag,a.orthoRight=t.orthographic.xmag,a.orthoBottom=-t.orthographic.ymag,a.orthoTop=t.orthographic.ymag,a.minZ=t.orthographic.znear,a.maxZ=t.orthographic.zfar;break}default:throw new Error(`${e}: Invalid camera type (${t.type})`)}return n.AddPointerMetadata(a,e),this._parent.onCameraLoadedObservable.notifyObservers(a),i(a),this.logClose(),Promise.all(s).then(()=>a)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");let e=this._gltf.animations;if(!e)return Promise.resolve();let t=new Array;for(let i=0;i{s.targetedAnimations.length===0&&s.dispose()}))}return Promise.all(t).then(()=>{this._parent._endPerformanceCounter("Load animations")})}loadAnimationAsync(e,t){this._parent._startPerformanceCounter("Load animation");let i=this._extensionsLoadAnimationAsync(e,t);return i||bY.value.then(({AnimationGroup:r})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;let s=new r(t.name||`animation${t.index}`,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=s;let a=new Array;rt.Assign(t.channels),rt.Assign(t.samplers);for(let o of t.channels)a.push(this._loadAnimationChannelAsync(`${e}/channels/${o.index}`,e,t,o,(l,c)=>{l.animations=l.animations||[],l.animations.push(c),s.addTargetedAnimation(c,l)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(a).then(()=>(s.normalize(0),s))})}_loadAnimationChannelAsync(e,t,i,r,s){let a=this._extensionsLoadAnimationChannelAsync(e,t,i,r,s);if(a)return a;if(r.target.node==null)return Promise.resolve();let o=rt.Get(`${e}/target/node`,this._gltf.nodes,r.target.node),l=r.target.path,c=l==="weights";return c&&!o._numMorphTargets||!c&&!o._babylonTransformNode||!this._parent.loadNodeAnimations&&!c&&!o._isJoint?Promise.resolve():MY.value.then(()=>{var h,u,m,p;let f;switch(l){case"translation":{f=(h=qf("/nodes/{}/translation"))==null?void 0:h.interpolation;break}case"rotation":{f=(u=qf("/nodes/{}/rotation"))==null?void 0:u.interpolation;break}case"scale":{f=(m=qf("/nodes/{}/scale"))==null?void 0:m.interpolation;break}case"weights":{f=(p=qf("/nodes/{}/weights"))==null?void 0:p.interpolation;break}default:throw new Error(`${e}/target/path: Invalid value (${r.target.path})`)}if(!f)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${r.target.path})`);let d={object:o,info:f};return this._loadAnimationChannelFromTargetInfoAsync(e,t,i,r,d,s)})}_loadAnimationChannelFromTargetInfoAsync(e,t,i,r,s,a){let o=this.parent.targetFps,l=1/o,c=rt.Get(`${e}/sampler`,i.samplers,r.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${r.sampler}`,c).then(f=>{let d=0,h=s.object,u=s.info;for(let m of u){let p=m.getStride(h),_=f.input,g=f.output,T=new Array(_.length),b=0;switch(f.interpolation){case"STEP":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,1);b+=p,T[R]={frame:_[R]*o,value:S,interpolation:1}}break}case"CUBICSPLINE":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,l);b+=p;let I=m.getValue(h,g,b,1);b+=p;let x=m.getValue(h,g,b,l);b+=p,T[R]={frame:_[R]*o,inTangent:S,value:I,outTangent:x}}break}case"LINEAR":{for(let R=0;R<_.length;R++){let S=m.getValue(h,g,b,1);b+=p,T[R]={frame:_[R]*o,value:S}}break}}if(b>0){let R=`${i.name||`animation${i.index}`}_channel${r.index}_${d}`,S=m.buildAnimations(h,R,o,T);for(let I of S)d++,a(I.babylonAnimatable,I.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;let i=t.interpolation||"LINEAR";switch(i){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}let r=rt.Get(`${e}/input`,this._gltf.accessors,t.input),s=rt.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${s.index}`,s)]).then(([a,o])=>({input:a,interpolation:i,output:o})),t._data}loadBufferAsync(e,t,i,r){let s=this._extensionsLoadBufferAsync(e,t,i,r);if(s)return s;if(!t._data)if(t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{if(!this._bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(a=>{try{return new Uint8Array(a.buffer,a.byteOffset+i,r)}catch(o){throw new Error(`${e}: ${o.message}`,{cause:o})}})}loadBufferViewAsync(e,t){let i=this._extensionsLoadBufferViewAsync(e,t);if(i)return i;if(t._data)return t._data;let r=rt.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${r.index}`,r,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,t,i){if(t._data)return t._data;let r=n._GetNumComponents(e,t.type),s=r*M.GetTypeByteLength(t.componentType),a=r*t.count;if(t.bufferView==null)t._data=Promise.resolve(new i(a));else{let o=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${o.index}`,o).then(l=>{if(t.componentType===5126&&!t.normalized&&(!o.byteStride||o.byteStride===s))return n._GetTypedArray(e,t.componentType,l,t.byteOffset,a);{let c=new i(a);return M.ForEach(l,t.byteOffset||0,o.byteStride||s,r,t.componentType,c.length,t.normalized||!1,(f,d)=>{c[d]=f}),c}})}if(t.sparse){let o=t.sparse;t._data=t._data.then(l=>{let c=l,f=rt.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,o.indices.bufferView),d=rt.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${f.index}`,f),this.loadBufferViewAsync(`/bufferViews/${d.index}`,d)]).then(([h,u])=>{let m=n._GetTypedArray(`${e}/sparse/indices`,o.indices.componentType,h,o.indices.byteOffset,o.count),p=r*o.count,_;if(t.componentType===5126&&!t.normalized)_=n._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);else{let T=n._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);_=new i(p),M.ForEach(T,0,s,r,t.componentType,_.length,t.normalized||!1,(b,R)=>{_[R]=b})}let g=0;for(let T=0;Tn._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;let t=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(i=>new on(t,i,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,t,i){var s;if((s=t._babylonVertexBuffer)!=null&&s[i])return t._babylonVertexBuffer[i];t._babylonVertexBuffer||(t._babylonVertexBuffer={});let r=this._babylonScene.getEngine();if(t.sparse||t.bufferView==null)t._babylonVertexBuffer[i]=this._loadFloatAccessorAsync(e,t).then(a=>new M(r,a,i,!1));else{let a=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._babylonVertexBuffer[i]=this._loadVertexBufferViewAsync(a).then(o=>{let l=n._GetNumComponents(e,t.type);return new M(r,o,i,!1,void 0,a.byteStride,void 0,t.byteOffset,l,t.componentType,t.normalized,!0,void 0,!0)})}return t._babylonVertexBuffer[i]}_loadMaterialMetallicRoughnessPropertiesAsync(e,t,i){let r=new Array,s=this._getOrCreateMaterialAdapter(i);return t&&(t.baseColorFactor?(s.baseColor=oe.FromArray(t.baseColorFactor),s.geometryOpacity=t.baseColorFactor[3]):s.baseColor=oe.White(),s.baseMetalness=t.metallicFactor==null?1:t.metallicFactor,s.specularRoughness=t.roughnessFactor==null?1:t.roughnessFactor,t.baseColorTexture&&r.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,t.baseColorTexture,a=>{a.name=`${i.name} (Base Color)`,s.baseColorTexture=a})),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,t.metallicRoughnessTexture,a=>{a.name=`${i.name} (Metallic Roughness)`,s.baseMetalnessTexture=a,s.specularRoughnessTexture=a})),s.useRoughnessFromMetallicTextureGreen=!0,s.useMetallicFromMetallicTextureBlue=!0)),Promise.all(r).then(()=>{})}_loadMaterialAsync(e,t,i,r,s=()=>{}){let a=this._extensionsLoadMaterialAsync(e,t,i,r,s);if(a)return a;t._data=t._data||{};let o=t._data[r];if(!o){this.logOpen(`${e} ${t.name||""}`);let l=this.createMaterial(e,t,r);o={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[r]=o,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return i&&(o.babylonMeshes.push(i),i.onDisposeObservable.addOnce(()=>{let l=o.babylonMeshes.indexOf(i);l!==-1&&o.babylonMeshes.splice(l,1)})),s(o.babylonMaterial),o.promise.then(()=>o.babylonMaterial)}_createDefaultMaterial(e,t){if(!this._pbrMaterialImpl)throw new Error("PBR Material class not loaded");this._babylonScene._blockEntityCollection=!!this._assetContainer;let i=new this._pbrMaterialImpl.materialClass(e,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i.fillMode=t,i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE;let r=this._getOrCreateMaterialAdapter(i);return r.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,r.baseMetalness=1,r.specularRoughness=1,i}createMaterial(e,t,i){let r=this._extensionsCreateMaterial(e,t,i);if(r)return r;let s=t.name||`material${t.index}`;return this._createDefaultMaterial(s,i)}loadMaterialPropertiesAsync(e,t,i){let r=this._extensionsLoadMaterialPropertiesAsync(e,t,i);if(r)return r;let s=new Array;return s.push(this.loadMaterialBasePropertiesAsync(e,t,i)),t.pbrMetallicRoughness&&s.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,i)),this.loadMaterialAlphaProperties(e,t,i),Promise.all(s).then(()=>{})}loadMaterialBasePropertiesAsync(e,t,i){let r=new Array,s=this._getOrCreateMaterialAdapter(i);s.emissionColor=t.emissiveFactor?oe.FromArray(t.emissiveFactor):new oe(0,0,0),t.doubleSided&&(s.backFaceCulling=!1,s.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/normalTexture`,t.normalTexture,c=>{var f;c.name=`${i.name} (Normal)`,s.geometryNormalTexture=c,((f=t.normalTexture)==null?void 0:f.scale)!=null&&(c.level=t.normalTexture.scale)})),s.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let a,o=1,l;return t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,t.occlusionTexture,c=>{c.name=`${i.name} (Occlusion)`,a=c})),t.occlusionTexture.strength!=null&&(o=t.occlusionTexture.strength)),t.emissiveTexture&&r.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,t.emissiveTexture,c=>{c.name=`${i.name} (Emissive)`,l=c})),Promise.all(r).then(()=>{a&&(s.ambientOcclusionTexture=a,s.ambientOcclusionTextureStrength=o),l&&(s.emissionColorTexture=l)})}loadMaterialAlphaProperties(e,t,i){if(!this._pbrMaterialImpl)throw new Error(`${e}: Material type not supported`);let r=this._getOrCreateMaterialAdapter(i),s=r.baseColorTexture;switch(t.alphaMode||"OPAQUE"){case"OPAQUE":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE,i.alpha=1;break}case"MASK":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHATEST,r.alphaCutOff=t.alphaCutoff==null?.5:t.alphaCutoff,s&&(s.hasAlpha=!0);break}case"BLEND":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHABLEND,s&&(s.hasAlpha=!0,r.useAlphaFromBaseColorTexture=!0);break}default:throw new Error(`${e}/alphaMode: Invalid value (${t.alphaMode})`)}}loadTextureInfoAsync(e,t,i=()=>{}){let r=this._extensionsLoadTextureInfoAsync(e,t,i);if(r)return r;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);let s=rt.Get(`${e}/index`,this._gltf.textures,t.index);s._textureInfo=t;let a=this._loadTextureAsync(`/textures/${t.index}`,s,o=>{o.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(o,e),this._parent.onTextureLoadedObservable.notifyObservers(o),i(o)});return this.logClose(),a}_loadTextureAsync(e,t,i=()=>{}){let r=this._extensionsLoadTextureAsync(e,t,i);if(r)return r;this.logOpen(`${e} ${t.name||""}`);let s=t.sampler==null?n.DefaultSampler:rt.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),a=rt.Get(`${e}/source`,this._gltf.images,t.source),o=this._createTextureAsync(e,s,a,i,void 0,!t._textureInfo.nonColorData);return this.logClose(),o}_createTextureAsync(e,t,i,r=()=>{},s,a){var m,p;let o=this._loadSampler(`/samplers/${t.index}`,t),l=new Array,c=new Om;this._babylonScene._blockEntityCollection=!!this._assetContainer;let f={noMipmap:o.noMipMaps,invertY:!1,samplingMode:o.samplingMode,onLoad:()=>{this._disposed||c.resolve()},onError:(_,g)=>{this._disposed||c.reject(new Error(`${e}: ${g&&g.message?g.message:_||"Failed to load texture"}`))},mimeType:(p=i.mimeType)!=null?p:KI((m=i.uri)!=null?m:""),loaderOptions:s,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},d=new ne(null,this._babylonScene,f);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(c.promise);let h=i.uri&&!fa(i.uri)?i.uri:void 0,u=h!=null?h:`${this._fileName}#image${i.index}`;if(l.push(this.loadImageAsync(`/images/${i.index}`,i).then(_=>{let g=`data:${this._uniqueRootUrl}${u}`;d.updateURL(g,_);let T=d.getInternalTexture();T&&(T.label=i.name)})),d.wrapU=o.wrapU,d.wrapV=o.wrapV,r(d),this._parent.useGltfTextureNames){let _=i.name||h||`image${i.index}`;d.name=_}return Promise.all(l).then(()=>d)}_loadSampler(e,t){return t._data||(t._data={noMipMaps:t.minFilter===9728||t.minFilter===9729,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:n._GetTextureWrapMode(`${e}/wrapT`,t.wrapT)}),t._data}loadImageAsync(e,t){if(!t._data){if(this.logOpen(`${e} ${t.name||""}`),t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{let i=rt.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i)}this.logClose()}return t._data}loadUriAsync(e,t,i){let r=this._extensionsLoadUriAsync(e,t,i);if(r)return r;if(!n._ValidateUri(i))throw new Error(`${e}: '${i}' is invalid`);if(fa(i)){let s=new Uint8Array(da(i));return this.log(`${e}: Decoded ${i.substring(0,64)}... (${s.length} bytes)`),Promise.resolve(s)}return this.log(`${e}: Loading ${i}`),this._parent.preprocessUrlAsync(this._rootUrl+i).then(s=>new Promise((a,o)=>{this._parent._loadFile(this._babylonScene,s,l=>{this._disposed||(this.log(`${e}: Loaded ${i} (${l.byteLength} bytes)`),a(new Uint8Array(l)))},!0,l=>{o(new gl(`${e}: Failed to load '${i}'${l?": "+l.status+" "+l.statusText:""}`,l))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};let i=e._internalMetadata=e._internalMetadata||{},r=i.gltf=i.gltf||{};(r.pointers=r.pointers||[]).push(t)}static _GetTextureWrapMode(e,t){switch(t=t==null?10497:t,t){case 33071:return ne.CLAMP_ADDRESSMODE;case 33648:return ne.MIRROR_ADDRESSMODE;case 10497:return ne.WRAP_ADDRESSMODE;default:return W.Warn(`${e}: Invalid value (${t})`),ne.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,t){let i=t.magFilter==null?9729:t.magFilter,r=t.minFilter==null?9987:t.minFilter;if(i===9729)switch(r){case 9728:return ne.LINEAR_NEAREST;case 9729:return ne.LINEAR_LINEAR;case 9984:return ne.LINEAR_NEAREST_MIPNEAREST;case 9985:return ne.LINEAR_LINEAR_MIPNEAREST;case 9986:return ne.LINEAR_NEAREST_MIPLINEAR;case 9987:return ne.LINEAR_LINEAR_MIPLINEAR;default:return W.Warn(`${e}/minFilter: Invalid value (${r})`),ne.LINEAR_LINEAR_MIPLINEAR}else switch(i!==9728&&W.Warn(`${e}/magFilter: Invalid value (${i})`),r){case 9728:return ne.NEAREST_NEAREST;case 9729:return ne.NEAREST_LINEAR;case 9984:return ne.NEAREST_NEAREST_MIPNEAREST;case 9985:return ne.NEAREST_LINEAR_MIPNEAREST;case 9986:return ne.NEAREST_NEAREST_MIPLINEAR;case 9987:return ne.NEAREST_LINEAR_MIPLINEAR;default:return W.Warn(`${e}/minFilter: Invalid value (${r})`),ne.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,t){try{return x_(t)}catch(i){throw new Error(`${e}: ${i.message}`,{cause:i})}}static _GetTypedArray(e,t,i,r,s){let a=i.buffer;r=i.byteOffset+(r||0);let o=n._GetTypedArrayConstructor(`${e}/componentType`,t),l=M.GetTypeByteLength(t);return r%l!==0?(W.Warn(`${e}: Copying buffer as byte offset (${r}) is not a multiple of component type byte length (${l})`),new o(a.slice(r,r+s*l),0)):new o(a,r,s)}static _GetNumComponents(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(`${e}: Invalid type (${t})`)}static _ValidateUri(e){return re.IsBase64(e)||e.indexOf("..")===-1}static _GetDrawMode(e,t){switch(t==null&&(t=4),t){case 0:return ae.PointListDrawMode;case 1:return ae.LineListDrawMode;case 2:return ae.LineLoopDrawMode;case 3:return ae.LineStripDrawMode;case 4:return ae.TriangleFillMode;case 5:return ae.TriangleStripDrawMode;case 6:return ae.TriangleFanDrawMode}throw new Error(`${e}: Invalid mesh primitive mode (${t})`)}_compileMaterialsAsync(){this._parent._startPerformanceCounter("Compile materials");let e=new Array;if(this._gltf.materials){for(let t of this._gltf.materials)if(t._data)for(let i in t._data){let r=t._data[i];for(let s of r.babylonMeshes){s.computeWorldMatrix(!0);let a=r.babylonMaterial;e.push(a.forceCompilationAsync(s)),e.push(a.forceCompilationAsync(s,{useInstances:!0})),this._parent.useClipPlane&&(e.push(a.forceCompilationAsync(s,{clipPlane:!0})),e.push(a.forceCompilationAsync(s,{clipPlane:!0,useInstances:!0})))}}}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile materials")})}_compileShadowGeneratorsAsync(){this._parent._startPerformanceCounter("Compile shadow generators");let e=new Array,t=this._babylonScene.lights;for(let i of t){let r=i.getShadowGenerator();r&&e.push(r.forceCompilationAsync())}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile shadow generators")})}_forEachExtensions(e){for(let t of this._extensions)t.enabled&&e(t)}_applyExtensions(e,t,i){for(let r of this._extensions)if(r.enabled){let s=`${r.name}.${t}`,a=e;a._activeLoaderExtensionFunctions=a._activeLoaderExtensionFunctions||{};let o=a._activeLoaderExtensionFunctions;if(!o[s]){o[s]=!0;try{let l=i(r);if(l)return l}finally{delete o[s]}}}return null}_extensionsOnLoading(){this._forEachExtensions(e=>e.onLoading&&e.onLoading())}_extensionsOnReady(){this._forEachExtensions(e=>e.onReady&&e.onReady())}_extensionsLoadSceneAsync(e,t){return this._applyExtensions(t,"loadScene",i=>i.loadSceneAsync&&i.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,i){return this._applyExtensions(t,"loadNode",r=>r.loadNodeAsync&&r.loadNodeAsync(e,t,i))}_extensionsLoadCameraAsync(e,t,i){return this._applyExtensions(t,"loadCamera",r=>r.loadCameraAsync&&r.loadCameraAsync(e,t,i))}_extensionsLoadVertexDataAsync(e,t,i){return this._applyExtensions(t,"loadVertexData",r=>r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,i))}_extensionsLoadMeshPrimitiveAsync(e,t,i,r,s,a){return this._applyExtensions(s,"loadMeshPrimitive",o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,i,r,s,a))}_extensionsLoadMaterialAsync(e,t,i,r,s){return this._applyExtensions(t,"loadMaterial",a=>a._loadMaterialAsync&&a._loadMaterialAsync(e,t,i,r,s))}_extensionsCreateMaterial(e,t,i){return this._applyExtensions(t,"createMaterial",r=>r.createMaterial&&r.createMaterial(e,t,i))}_extensionsLoadMaterialPropertiesAsync(e,t,i){return this._applyExtensions(t,"loadMaterialProperties",r=>r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,i))}_extensionsLoadTextureInfoAsync(e,t,i){return this._applyExtensions(t,"loadTextureInfo",r=>r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,i))}_extensionsLoadTextureAsync(e,t,i){return this._applyExtensions(t,"loadTexture",r=>r._loadTextureAsync&&r._loadTextureAsync(e,t,i))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",i=>i.loadAnimationAsync&&i.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,i,r,s){return this._applyExtensions(i,"loadAnimationChannel",a=>a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,i,r,s))}_extensionsLoadSkinAsync(e,t,i){return this._applyExtensions(i,"loadSkin",r=>r._loadSkinAsync&&r._loadSkinAsync(e,t,i))}_extensionsLoadUriAsync(e,t,i){return this._applyExtensions(t,"loadUri",r=>r._loadUriAsync&&r._loadUriAsync(e,t,i))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",i=>i.loadBufferViewAsync&&i.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,i,r){return this._applyExtensions(t,"loadBuffer",s=>s.loadBufferAsync&&s.loadBufferAsync(e,t,i,r))}static LoadExtensionAsync(e,t,i,r){if(!t.extensions)return null;let a=t.extensions[i];return a?r(`${e}/extensions/${i}`,a):null}static LoadExtraAsync(e,t,i,r){if(!t.extras)return null;let a=t.extras[i];return a?r(`${e}/extras/${i}`,a):null}isExtensionUsed(e){return!!this._gltf.extensionsUsed&&this._gltf.extensionsUsed.indexOf(e)!==-1}logOpen(e){this._parent._logOpen(e)}logClose(){this._parent._logClose()}log(e){this._parent._log(e)}startPerformanceCounter(e){this._parent._startPerformanceCounter(e)}endPerformanceCounter(e){this._parent._endPerformanceCounter(e)}};qm.DefaultSampler={index:-1};Ya._CreateGLTF2Loader=n=>new qm(n)});var Qm,AB=A(()=>{Qm={name:"obj",extensions:".obj"}});var Ho,RB=A(()=>{et();oi();Xs();Ho=class n{constructor(){this.materials=[]}parseMTL(e,t,i,r){if(t instanceof ArrayBuffer)return;let s=t.split(` +`),a=/\s+/,o,l=null;for(let c=0;c=0?f.substring(0,d):f;h=h.toLowerCase();let u=d>=0?f.substring(d+1).trim():"";if(h==="newmtl")l&&this.materials.push(l),e._blockEntityCollection=!!r,l=new Re(u,e),l._parentContainer=r,e._blockEntityCollection=!1;else if(h==="kd"&&l)o=u.split(a,3).map(parseFloat),l.diffuseColor=oe.FromArray(o);else if(h==="ka"&&l)o=u.split(a,3).map(parseFloat),l.ambientColor=oe.FromArray(o);else if(h==="ks"&&l)o=u.split(a,3).map(parseFloat),l.specularColor=oe.FromArray(o);else if(h==="ke"&&l)o=u.split(a,3).map(parseFloat),l.emissiveColor=oe.FromArray(o);else if(h==="ns"&&l)l.specularPower=parseFloat(u);else if(h==="d"&&l)l.alpha=parseFloat(u);else if(h==="map_ka"&&l)l.ambientTexture=n._GetTexture(i,u,e);else if(h==="map_kd"&&l)l.diffuseTexture=n._GetTexture(i,u,e);else if(h==="map_ks"&&l)l.specularTexture=n._GetTexture(i,u,e);else if(h!=="map_ns")if(h==="map_bump"&&l){let m=u.split(a),p=m.indexOf("-bm"),_=null;p>=0&&(_=m[p+1],m.splice(p,2)),l.bumpTexture=n._GetTexture(i,m.join(" "),e),l.bumpTexture&&_!==null&&(l.bumpTexture.level=parseFloat(_))}else h==="map_d"&&l&&(l.opacityTexture=n._GetTexture(i,u,e))}l&&this.materials.push(l)}static _GetTexture(e,t,i){if(!t)return null;let r=e;if(e==="file:"){let s=t.lastIndexOf("\\");s===-1&&(s=t.lastIndexOf("/")),s>-1?r+=t.substring(s+1):r+=t}else r+=t;return new ne(r,i,!1,n.INVERT_TEXTURE_Y)}};Ho.INVERT_TEXTURE_Y=!0});var fi,IB=A(()=>{yt();Xs();et();ve();$h();Rt();Vt();ze();fi=class n{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 Ne(.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:[]});let 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:[]});let 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){var i,r;(i=e.indiceUvsFromObj)!=null||(e.indiceUvsFromObj=-1),(r=e.indiceNormalFromObj)!=null||(e.indiceNormalFromObj=-1);let t;this._loadingOptions.optimizeWithUV?t=this._isInArrayUV(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj,e.indiceUvsFromObj]):t=this._isInArray(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj]),t===-1?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(e.positionVectorFromOBJ),e.textureVectorFromOBJ!==void 0&&this._wrappedUvsForBabylon.push(e.textureVectorFromOBJ),e.normalsVectorFromOBJ!==void 0&&this._wrappedNormalsForBabylon.push(e.normalsVectorFromOBJ),e.positionColorsFromOBJ!==void 0&&this._wrappedColorsForBabylon.push(e.positionColorsFromOBJ),this._tuplePosNorm[e.indicePositionFromObj].normals.push(e.indiceNormalFromObj),this._tuplePosNorm[e.indicePositionFromObj].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e.indicePositionFromObj].uv.push(e.indiceUvsFromObj)):this._indicesForBabylon.push(t)}_unwrapData(){try{for(let e=0;e0&&(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._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice()),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon.slice()),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._handledMesh.hasLines=this._hasLineData,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){let t=e.getVerticesData(M.PositionKind),i=e.getVerticesData(M.NormalKind),r={};if(!t||!i)return;for(let a=0;athis._triangles.push(h[0],h[u],h[u+1]),this._handednessSign=1):i.useRightHandedSystem?(this._pushTriangle=(h,u)=>this._triangles.push(h[0],h[u+1],h[u]),this._handednessSign=1):(this._pushTriangle=(h,u)=>this._triangles.push(h[0],h[u],h[u+1]),this._handednessSign=-1);let a=t.split(` +`),o=[],l=[];o.push(l);for(let h=0;h=7){let p=parseFloat(m[4]),_=parseFloat(m[5]),g=parseFloat(m[6]);this._colors.push(new Ne(p>1?p/255:p,_>1?_/255:_,g>1?g/255:g,m.length===7||m[7]===void 0?1:parseFloat(m[7])))}else this._colors.push(this._grayColor)}else if((m=n.NormalPattern.exec(u))!==null)this._normals.push(new v(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])));else if((m=n.UVPattern.exec(u))!==null)this._uvs.push(new _e(parseFloat(m[1])*this._loadingOptions.UVScaling.x,parseFloat(m[2])*this._loadingOptions.UVScaling.y));else if((m=n.FacePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),1);else if((m=n.FacePattern4.exec(u))!==null)this._setDataForCurrentFaceWithPattern4(m[1].trim().split(" "),1);else if((m=n.FacePattern5.exec(u))!==null)this._setDataForCurrentFaceWithPattern5(m[1].trim().split(" "),1);else if((m=n.FacePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),1);else if((m=n.FacePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),1);else if((m=n.LinePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),0),this._hasLineData=!0;else if((m=n.LinePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),0),this._hasLineData=!0;else if(m=n._GetZbrushMRGB(u,!this._loadingOptions.importVertexColors))for(let p of m)this._extColors.push(p);else if((m=n.LinePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),0),this._hasLineData=!0;else if(n.GroupDescriptor.test(u)||n.ObjectDescriptor.test(u)){let p={name:u.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:n.ObjectDescriptor.test(u)};this._addPreviousObjMesh(),this._meshesFromObj.push(p),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(n.UseMtlDescriptor.test(u)){if(this._materialNameFromObj=u.substring(7).trim(),!this._isFirstMaterial||!this._hasMeshes){this._addPreviousObjMesh();let 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 n.MtlLibGroupDescriptor.test(u)?s(u.substring(7).trim()):n.SmoothDescriptor.test(u)||W.Log("Unhandled expression at line : "+u)}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._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){let h=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(let u of this._positions)this._unwrappedPositionsForBabylon.push(u.x,u.y,u.z);if(this._normals.length)for(let u of this._normals)this._unwrappedNormalsForBabylon.push(u.x,u.y,u.z);if(this._uvs.length)for(let u of this._uvs)this._unwrappedUVForBabylon.push(u.x,u.y);if(this._extColors.length)for(let u of this._extColors)this._unwrappedColorsForBabylon.push(u.r,u.g,u.b,u.a);else if(this._colors.length)for(let u of this._colors)this._unwrappedColorsForBabylon.push(u.r,u.g,u.b,u.a);this._materialNameFromObj||(h=new Re(Si.RandomId(),i),h.pointsCloud=!0,this._materialNameFromObj=h.name,this._normals.length||(h.disableLighting=!0,h.emissiveColor=oe.White()))}this._meshesFromObj.push({name:Si.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:h,isObject:!0,hasLines:this._hasLineData})}for(let h=0;h=0;--p)if(this._meshesFromObj[p].isObject&&this._meshesFromObj[p]._babylonMesh){u.parent=this._meshesFromObj[p]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[h].materialName),this._handledMesh.hasLines&&((f=u._internalMetadata)!=null||(u._internalMetadata={}),u._internalMetadata._isLine=!0),((d=this._handledMesh.positions)==null?void 0:d.length)===0){this._babylonMeshesArray.push(u);continue}let m=new de;if(m.indices=this._handledMesh.indices,m.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals){let p=new Array;de.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,p),m.normals=p}else m.normals=this._handledMesh.normals;this._handledMesh.uvs&&(m.uvs=this._handledMesh.uvs),this._handledMesh.colors&&(m.colors=this._handledMesh.colors),m.applyToMesh(u),this._loadingOptions.invertY&&(u.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(u),this._babylonMeshesArray.push(u),this._handledMesh.directMaterial&&(u.material=this._handledMesh.directMaterial)}}};fi.ObjectDescriptor=/^o/;fi.GroupDescriptor=/^g/;fi.MtlLibGroupDescriptor=/^mtllib /;fi.UseMtlDescriptor=/^usemtl /;fi.SmoothDescriptor=/^s /;fi.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/;fi.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;fi.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;fi.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/;fi.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;fi.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;fi.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/;fi.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;fi.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/});var xB={};De(xB,{OBJFileLoader:()=>xr});var xr,HS=A(()=>{ve();Tt();hc();Kf();AB();RB();IB();Xs();xr=class n{static get INVERT_TEXTURE_Y(){return Ho.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){Ho.INVERT_TEXTURE_Y=e}constructor(e){this.name=Qm.name,this.extensions=Qm.extensions,this._assetContainer=null,this._loadingOptions={...n._DefaultLoadingOptions,...e!=null?e:{}}}static get _DefaultLoadingOptions(){return{computeNormals:n.COMPUTE_NORMALS,optimizeNormals:n.OPTIMIZE_NORMALS,importVertexColors:n.IMPORT_VERTEX_COLORS,invertY:n.INVERT_Y,invertTextureY:n.INVERT_TEXTURE_Y,UVScaling:n.UV_SCALING,materialLoadingFailsSilently:n.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:n.OPTIMIZE_WITH_UV,skipMaterials:n.SKIP_MATERIALS,useLegacyBehavior:n.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,i,r){let s=t+e;re.LoadFile(s,i,void 0,void 0,!1,(a,o)=>{r(s,o)})}createPlugin(e){return new n(e[Qm.name])}canDirectLoad(){return!1}importMeshAsync(e,t,i,r){return this._parseSolidAsync(e,t,i,r).then(s=>({meshes:s,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,i){return this.importMeshAsync(null,e,t,i).then(()=>{})}loadAssetContainerAsync(e,t,i){let r=new jn(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,i).then(s=>(s.meshes.forEach(a=>r.meshes.push(a)),s.meshes.forEach(a=>{let o=a.material;o&&r.materials.indexOf(o)==-1&&(r.materials.push(o),o.getActiveTextures().forEach(c=>{r.textures.indexOf(c)==-1&&r.textures.push(c)}))}),this._assetContainer=null,r)).catch(s=>{throw this._assetContainer=null,s})}_parseSolidAsync(e,t,i,r){let s="",a=new Ho,o=[],l=[];i=i.replace(/#.*$/gm,"").trim(),new fi(o,l,this._loadingOptions).parse(e,i,t,this._assetContainer,d=>{s=d});let f=[];return s!==""&&!this._loadingOptions.skipMaterials&&f.push(new Promise((d,h)=>{this._loadMTL(s,r,u=>{try{a.parseMTL(t,u,r,this._assetContainer);for(let m=0;m-1;)_.push(g),p=g+1;if(g===-1&&_.length===0)a.materials[m].dispose();else for(let T=0;T<_.length;T++){let b=l[_[T]],R=a.materials[m];b.material=R,b.getTotalIndices()||(R.pointsCloud=!0)}}d()}catch(m){re.Warn(`Error processing MTL file: '${s}'`),this._loadingOptions.materialLoadingFailsSilently?d():h(m)}},(u,m)=>{re.Warn(`Error downloading MTL file: '${s}'`),this._loadingOptions.materialLoadingFailsSilently?d():h(m)})})),Promise.all(f).then(()=>{let d=h=>{var u,m;return!!((m=(u=h._internalMetadata)==null?void 0:u._isLine)!=null&&m)};return l.forEach(h=>{var u,m;if(d(h)){let p=(u=h.material)!=null?u:new Re(h.name+"_line",t);p.getBindedMeshes().filter(g=>!d(g)).length>0&&(p=(m=p.clone(p.name+"_line"))!=null?m:p),p.wireframe=!0,h.material=p,h._internalMetadata&&(h._internalMetadata._isLine=void 0)}}),l})}};xr.OPTIMIZE_WITH_UV=!0;xr.INVERT_Y=!1;xr.IMPORT_VERTEX_COLORS=!1;xr.COMPUTE_NORMALS=!1;xr.OPTIMIZE_NORMALS=!1;xr.UV_SCALING=new _e(1,1);xr.SKIP_MATERIALS=!1;xr.MATERIAL_LOADING_FAILS_SILENTLY=!0;xr.USE_LEGACY_BEHAVIOR=!1;Xa(new xr)});function DY(n){let e=n.trim();return/^https?:\/\//i.test(e)||/^wss?:\/\//i.test(e)||/^\/\//.test(e)}function zS(n,e){if(DY(n))throw new Error(`[AI3D] Babylon ${e} is limited to local vault resources. Refused remote URL: ${n}`);return n}function Jm(n){throw new Error(`[AI3D] Babylon script loading is disabled in this plugin build. Refused script URL: ${n}`)}function bB(){if(CB)return;let n=i=>zS(i,"asset loading"),e=i=>zS(i,"script loading"),t=()=>-1;re.PreprocessUrl=n,re.ScriptPreprocessUrl=e,re.DefaultRetryStrategy=t,re.LoadScript=(i,r,s)=>{try{e(i),Jm(i)}catch(a){s==null||s(a instanceof Error?a.message:String(a),a);return}r==null||r()},re.LoadScriptAsync=async i=>{e(i),Jm(i)},re.LoadBabylonScript=(i,r,s)=>{try{Jm(i)}catch(a){s==null||s(a instanceof Error?a.message:String(a),a);return}r()},re.LoadBabylonScriptAsync=async i=>{Jm(i)},Mt.PreprocessUrl=n,Mt.ScriptPreprocessUrl=e,Mt.DefaultRetryStrategy=t,$t.CustomRequestModifiers.push((i,r)=>zS(r,"request")),CB=!0}var CB,MB=A(()=>{"use strict";ds();Tt();mo();CB=!1});function $m(n,e){if(e.byteLength<84)throw new Error(`STL buffer too small: ${e.byteLength} bytes (need 84+)`);if(e.byteLength>=6){let _=new TextDecoder().decode(new Uint8Array(e,0,6));if(_==="solid "||_===`solid +`){let g=new TextDecoder().decode(new Uint8Array(e,0,Math.min(e.byteLength,800)));if(g.includes("facet")||g.includes("endsolid"))throw new Error("ASCII STL detected \u2014 only binary STL is supported. Convert to binary STL first.")}}let t=new DataView(e),i=t.getUint32(80,!0);if(console.debug(`[AI3D STL] Parsing ${e.byteLength} bytes, ${i} triangles`),i===0)throw new Error("STL file contains 0 triangles");let r=84+i*50;if(e.byteLength>0&31)/31,k=(b>>5&31)/31,X=(b>>10&31)/31,j=_*12;l[j+0]=O,l[j+1]=k,l[j+2]=X,l[j+3]=1,l[j+4]=O,l[j+5]=k,l[j+6]=X,l[j+7]=1,l[j+8]=O,l[j+9]=k,l[j+10]=X,l[j+11]=1,d++}let R=a[g+3]-a[g+0],S=a[g+4]-a[g+1],I=a[g+5]-a[g+2],x=a[g+6]-a[g+0],P=a[g+7]-a[g+1],L=a[g+8]-a[g+2],y=S*L-I*P,B=I*x-R*L,w=R*P-S*x,H=Math.sqrt(y*y+B*B+w*w);H>1e-8?(y/=H,B/=H,w/=H):(y=0,B=0,w=1,f++),o[g+0]=y,o[g+1]=B,o[g+2]=w,o[g+3]=y,o[g+4]=B,o[g+5]=w,o[g+6]=y,o[g+7]=B,o[g+8]=w,c[T+0]=g/3+0,c[T+1]=g/3+1,c[T+2]=g/3+2}f>0&&console.warn(`[AI3D STL] ${f} degenerate triangles with zero-area normals`),s&&console.debug(`[AI3D STL] Detected per-face colors: ${d}/${i} faces colored`);let u=new de;u.positions=a,u.normals=o,u.indices=c,l&&(u.colors=l);let m=new V("stl-model",n);u.applyToMesh(m);let p=new Re("stl-mat",n);return p.backFaceCulling=!1,p.specularColor=new oe(.3,.3,.3),p.specularPower=32,l?(p.diffuseColor=new oe(1,1,1),p.emissiveColor=new oe(.05,.05,.05),p.vertexColorEnabled=!0):(p.diffuseColor=new oe(.85,.85,.85),p.emissiveColor=new oe(.1,.1,.1)),m.material=p,m}function yB(n,e){return $m(n,e)}function DB(n){n(LY)}var LY,XS=A(()=>{"use strict";Rt();Kf();Vt();Xs();et();LY={name:"stl",extensions:".stl",importMeshAsync(n,e,t){return Promise.resolve().then(()=>({meshes:[$m(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(n,e){return Promise.resolve().then(()=>{$m(n,e)})},loadAssetContainerAsync(n,e){return Promise.resolve().then(()=>{let t=$m(n,e),i=new jn(n);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(n){return n}}});function PY(n){let e=n.split(` +`),t=[],i="binary_little_endian",r=null;for(let s of e){let a=s.trim();if(a==="end_header")break;if(a==="ply"||a===""||a.startsWith("comment"))continue;let o=a.split(/\s+/),l=o[0];l==="format"?i=o[1]:l==="element"?(r={name:o[1],count:parseInt(o[2],10),properties:[]},t.push(r)):l==="property"&&r&&(o[1]==="list"?r.properties.push({name:o[4],type:"list",isList:!0,countType:o[2],itemType:o[3]}):r.properties.push({name:o[2],type:o[1],isList:!1}))}return{format:i,elements:t}}function Ac(n){switch(n){case"uchar":case"uint8":return 1;case"char":case"int8":return 1;case"ushort":case"uint16":return 2;case"short":case"int16":return 2;case"uint":case"uint32":return 4;case"int":case"int32":return 4;case"float":case"float32":return 4;case"double":case"float64":return 8;default:return 4}}function ep(n,e,t,i){switch(t){case"uchar":case"uint8":return n.getUint8(e);case"char":case"int8":return n.getInt8(e);case"ushort":case"uint16":return n.getUint16(e,i);case"short":case"int16":return n.getInt16(e,i);case"uint":case"uint32":return n.getUint32(e,i);case"int":case"int32":return n.getInt32(e,i);case"float":case"float32":return n.getFloat32(e,i);case"double":case"float64":return n.getFloat64(e,i);default:return 0}}function OY(n,e,t,i){let r=i,s=new DataView(n),a=[],o=[],l=[],c=e.elements.find(d=>d.name==="vertex"),f=e.elements.find(d=>d.name==="face");if(c){let d=c.properties.some(u=>u.name==="x"),h=c.properties.some(u=>u.name==="red"||u.name==="r");for(let u=0;uh.name==="vertex"),c=e.elements.find(h=>h.name==="face"),f=0;if(l){let h=l.properties.some(p=>p.name==="x"),u=l.properties.some(p=>p.name==="red"||p.name==="r"),m=l.properties.filter(p=>!p.isList);for(let p=0;p0){c.indices=o.indices;let h=new Array(l.length).fill(0),u=o.indices,m=l.length-3;for(let p=0;pm||g>m||T>m)continue;let b=l[_],R=l[_+1],S=l[_+2],I=l[g]-b,x=l[g+1]-R,P=l[g+2]-S,L=l[T]-b,y=l[T+1]-R,B=l[T+2]-S,w=x*B-P*y,H=P*L-I*B,O=I*y-x*L;h[_]+=w,h[_+1]+=H,h[_+2]+=O,h[g]+=w,h[g+1]+=H,h[g+2]+=O,h[T]+=w,h[T+1]+=H,h[T+2]+=O}for(let p=0;p0&&(h[p]/=_,h[p+1]/=_,h[p+2]/=_)}c.normals=h}else{let h=o.positions.length/3,u=[];for(let m=0;m=3&&u.push(0,1,2),c.indices=u}let f=new V("ply-model",n);c.applyToMesh(f);let d=new Re("ply-mat",n);return d.backFaceCulling=!1,o.colors.length>0?(c.colors=o.colors,c.applyToMesh(f),d.diffuseColor=new oe(1,1,1),d.vertexColorEnabled=!0):d.diffuseColor=new oe(.7,.7,.7),f.material=d,f}function LB(n,e){return tp(n,e)}function PB(n){n(FY)}var FY,YS=A(()=>{"use strict";Rt();Kf();Vt();Xs();et();FY={name:"ply",extensions:".ply",importMeshAsync(n,e,t){return Promise.resolve().then(()=>({meshes:[tp(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(n,e){return Promise.resolve().then(()=>{tp(n,e)})},loadAssetContainerAsync(n,e){return Promise.resolve().then(()=>{let t=tp(n,e),i=new jn(n);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(n){return n}}});async function id(){OB||(bB(),DB(Xa),PB(Xa),OB=!0)}var OB,rd=A(()=>{"use strict";gT();SB();HS();hc();MB();XS();YS();OB=!1});function NB(n,e,t){let i=n.getChildMeshes(),r=n.getBoundingInfo().boundingBox.centerWorld;for(let s of i){s.metadata||(s.metadata={});let a=s.metadata;if(!a._originalPos){let c=s.position;a._originalPos={x:c.x,y:c.y,z:c.z}}if(!a._originalCenter){let c=s.getBoundingInfo().boundingBox.centerWorld;a._originalCenter={x:c.x,y:c.y,z:c.z}}let o=(a._originalCenter[t]-r[t])*e,l=a._originalPos;s.position=new v(t==="x"?l.x+o:l.x,t==="y"?l.y+o:l.y,t==="z"?l.z+o:l.z)}}function KS(n){let e=n.getChildMeshes();for(let t of e){let i=t.metadata;i!=null&&i._originalPos&&(t.position=new v(i._originalPos.x,i._originalPos.y,i._originalPos.z))}}var FB=A(()=>{"use strict";ve()});var ip={};De(ip,{glowBlurPostProcessPixelShaderWGSL:()=>wY});var jS,wB,wY,rp=A(()=>{N();jS="glowBlurPostProcessPixelShader",wB=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d;uniform screenSize: vec2f;uniform direction: vec2f;uniform blurWidth: f32;fn getLuminance(color: vec3f)->f32 {return dot(color, vec3f(0.2126,0.7152,0.0722));} #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs {var weights: array;weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;var texelSize: vec2f= vec2f(1.0/uniforms.screenSize.x,1.0/uniforms.screenSize.y);var texelStep: vec2f=texelSize*uniforms.direction*uniforms.blurWidth;var start: vec2f=input.vUV-3.0*texelStep;var baseColor: vec4f= vec4f(0.,0.,0.,0.);var texelOffset: vec2f= vec2f(0.,0.);for (var i: i32=0; i<7; i++) {var texel: vec4f=textureSample(textureSampler,textureSamplerSampler,start+texelOffset);baseColor=vec4f(baseColor.rgb,baseColor.a+texel.a*weights[i]);var luminance: f32=getLuminance(baseColor.rgb);var luminanceTexel: f32=getLuminance(texel.rgb);var choice: f32=step(luminanceTexel,luminance);baseColor=vec4f(choice*baseColor.rgb+(1.0-choice)*texel.rgb,baseColor.a);texelOffset+=texelStep;} -fragmentOutputs.color=baseColor;}`;E.ShadersStoreWGSL[XS]||(E.ShadersStoreWGSL[XS]=yB);gY={name:XS,shader:yB}});var rp={};De(rp,{glowBlurPostProcessPixelShader:()=>EY});var YS,DB,EY,np=A(()=>{N();YS="glowBlurPostProcessPixelShader",DB=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color) +fragmentOutputs.color=baseColor;}`;E.ShadersStoreWGSL[jS]||(E.ShadersStoreWGSL[jS]=wB);wY={name:jS,shader:wB}});var np={};De(np,{glowBlurPostProcessPixelShader:()=>BY});var ZS,BB,BY,sp=A(()=>{N();ZS="glowBlurPostProcessPixelShader",BB=`varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color) {return dot(color,vec3(0.2126,0.7152,0.0722));} #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) {float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++) {vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;} -gl_FragColor=baseColor;}`;E.ShadersStore[YS]||(E.ShadersStore[YS]=DB);EY={name:YS,shader:DB}});var PB={};De(PB,{glowMapGenerationVertexShaderWGSL:()=>vY});var KS,LB,vY,OB=A(()=>{N();Cs();bs();wa();Ba();Ms();Oa();Ua();Va();ys();Ds();Ls();Ps();KS="glowMapGenerationVertexShader",LB=`attribute position: vec3f; +gl_FragColor=baseColor;}`;E.ShadersStore[ZS]||(E.ShadersStore[ZS]=BB);BY={name:ZS,shader:BB}});var VB={};De(VB,{glowMapGenerationVertexShaderWGSL:()=>UY});var qS,UB,UY,GB=A(()=>{N();Cs();bs();wa();Ba();Ms();Oa();Ua();Va();ys();Ds();Ls();Ps();qS="glowMapGenerationVertexShader",UB=`attribute position: vec3f; #include #include #include @@ -19376,7 +19376,7 @@ vertexOutputs.vUVEmissive= (uniforms.emissiveMatrix* vec4f(uv2Updated,1.0,0.0)). vertexOutputs.vColor=vertexInputs.color; #endif #include -}`;E.ShadersStoreWGSL[KS]||(E.ShadersStoreWGSL[KS]=LB);vY={name:KS,shader:LB}});var FB={};De(FB,{glowMapGenerationPixelShaderWGSL:()=>TY});var jS,NB,TY,wB=A(()=>{N();Vr();Os();Ns();jS="glowMapGenerationPixelShader",NB=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) +}`;E.ShadersStoreWGSL[qS]||(E.ShadersStoreWGSL[qS]=UB);UY={name:qS,shader:UB}});var WB={};De(WB,{glowMapGenerationPixelShaderWGSL:()=>VY});var QS,kB,VY,HB=A(()=>{N();kr();Os();Ns();QS="glowMapGenerationPixelShader",kB=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) #include #endif #ifdef DIFFUSE @@ -19438,7 +19438,7 @@ fragmentOutputs.color=finalColor*uniforms.glowIntensity; fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,uniforms.glowColor.a); #endif } -`;E.ShadersStoreWGSL[jS]||(E.ShadersStoreWGSL[jS]=NB);TY={name:jS,shader:NB}});var UB={};De(UB,{glowMapGenerationVertexShader:()=>SY});var ZS,BB,SY,VB=A(()=>{N();Fs();ws();Ga();ka();Bs();Na();Wa();Ha();Us();Vs();Gs();ks();ZS="glowMapGenerationVertexShader",BB=`attribute vec3 position; +`;E.ShadersStoreWGSL[QS]||(E.ShadersStoreWGSL[QS]=kB);VY={name:QS,shader:kB}});var XB={};De(XB,{glowMapGenerationVertexShader:()=>GY});var JS,zB,GY,YB=A(()=>{N();Fs();ws();Ga();ka();Bs();Na();Wa();Ha();Us();Vs();Gs();ks();JS="glowMapGenerationVertexShader",zB=`attribute vec3 position; #include #include #include @@ -19512,7 +19512,7 @@ vUVEmissive=vec2(emissiveMatrix*vec4(uv2Updated,1.0,0.0)); vColor=color; #endif #include -}`;E.ShadersStore[ZS]||(E.ShadersStore[ZS]=BB);SY={name:ZS,shader:BB}});var kB={};De(kB,{glowMapGenerationPixelShader:()=>AY});var qS,GB,AY,WB=A(()=>{N();Gr();Ws();Hs();qS="glowMapGenerationPixelShader",GB=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) +}`;E.ShadersStore[JS]||(E.ShadersStore[JS]=zB);GY={name:JS,shader:zB}});var jB={};De(jB,{glowMapGenerationPixelShader:()=>kY});var $S,KB,kY,ZB=A(()=>{N();Wr();Ws();Hs();$S="glowMapGenerationPixelShader",KB=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) #include #endif #ifdef DIFFUSE @@ -19574,8 +19574,8 @@ gl_FragColor=finalColor*glowIntensity; #ifdef HIGHLIGHT gl_FragColor.a=glowColor.a; #endif -}`;E.ShadersStore[qS]||(E.ShadersStore[qS]=GB);AY={name:qS,shader:GB}});var An,Zs,sp=A(()=>{ct();et();At();yt();Eo();Ni();Da();go();kn();Oi();M_();An=class n extends li{constructor(e,t=null,i,r,s){super({...s,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms}),this.direction=i,this.kernel=r,this.textureWidth=0,this.textureHeight=0}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(ip(),tp)))):t.push(Promise.resolve().then(()=>(np(),rp))),super._gatherImports(e,t)}bind(){super.bind(),this._drawWrapper.effect.setFloat2("screenSize",this.textureWidth,this.textureHeight),this._drawWrapper.effect.setVector2("direction",this.direction),this._drawWrapper.effect.setFloat("blurWidth",this.kernel)}};An.FragmentUrl="glowBlurPostProcess";An.Uniforms=["screenSize","direction","blurWidth"];Zs=class n{get camera(){return this._options.camera}set camera(e){this._options.camera=e}get renderingGroupId(){return this._options.renderingGroupId}set renderingGroupId(e){this._options.renderingGroupId=e}get objectRenderer(){return this._objectRenderer}get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){if(this._objectRenderer.setMaterialForRendering(e,t),Array.isArray(e))for(let i=0;i{t=this._scene.getBoundingBoxRenderer().enabled,this._scene.getBoundingBoxRenderer().enabled=!this.disableBoundingBoxesFromEffectLayer&&t}),this._objectRenderer.onAfterRenderObservable.add(()=>{this._scene.getBoundingBoxRenderer().enabled=t})),this._objectRenderer.customIsReadyFunction=(i,r,s)=>{if((s||r===0)&&i.subMeshes)for(let a=0;a{this.onBeforeRenderLayerObservable.notifyObservers(this);let o,l=this._scene.getEngine();if(a.length){for(l.setColorWrite(!1),o=0;o4&&(c.push(M.MatricesIndicesExtraKind),c.push(M.MatricesWeightsExtraKind)),l.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers);let S=s.skeleton;S&&S.isUsingTextureForMatrices?l.push("#define BONETEXTURE"):l.push("#define BonesPerMesh "+(S?S.bones.length+1:0)),s.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,s)}else l.push("#define NUM_BONE_INFLUENCERS 0");let m=s.morphTargetManager?Wn(s.morphTargetManager,l,c,s,!0,!1,!1,f,d,h):0;t&&(l.push("#define INSTANCES"),_n(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES"));let p=s.bakedVertexAnimationManager;p&&p.isEnabled&&(l.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&c.push("bakedVertexAnimationSettingsInstanced")),Gn(o,this._scene,l),this._addCustomEffectDefines(l);let _=e._getDrawWrapper(void 0,!0),g=_.defines,T=l.join(` -`);if(g!==T){let S=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureInfo","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture","glowIntensity"];Di(S),_.setEffect(this._engine.createEffect("glowMapGeneration",c,S,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],T,u,void 0,void 0,{maxSimultaneousMorphTargets:m},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),T)}return _.effect.isReady()&&(this._dontCheckIfReady||!this._dontCheckIfReady&&this.isLayerReady())}_isSubMeshReady(e,t,i){return this._internalIsSubMeshReady(e,t,i)}async _importShadersAsync(){var e;this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(OB(),PB)),Promise.resolve().then(()=>(wB(),FB))]):await Promise.all([Promise.resolve().then(()=>(VB(),UB)),Promise.resolve().then(()=>(WB(),kB))]),(e=this._additionalImportShadersAsync)==null||e.call(this)}_internalIsLayerReady(){let e=!0;for(let i=0;iT.setMatrix("world",x)),(i.disableDepthWrite||i.forceDepthWrite)&&c.setDepthWrite(b),i.disableColorWrite&&c.setColorWrite(R),i.depthFunction!==0&&c.setDepthFunction(S)}else this._objectRenderer.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(r)}_useMeshMaterial(e){return!1}_rebuild(){let e=this._vertexBuffers[M.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}dispose(){let e=this._vertexBuffers[M.PositionKind];e&&(e.dispose(),this._vertexBuffers[M.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);for(let t of this._mergeDrawWrapper)t.dispose();this._mergeDrawWrapper=[],this._objectRenderer.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderLayerObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear()}};Zs.ForceGLSL=!1});var hr,QS=A(()=>{Qe();qe();Tt();ct();At();oi();_a();gi();Dn();sp();Uh();hr=class n{get _shouldRender(){return this._thinEffectLayer._shouldRender}set _shouldRender(e){this._thinEffectLayer._shouldRender=e}get _emissiveTextureAndColor(){return this._thinEffectLayer._emissiveTextureAndColor}set _emissiveTextureAndColor(e){this._thinEffectLayer._emissiveTextureAndColor=e}get _effectIntensity(){return this._thinEffectLayer._effectIntensity}set _effectIntensity(e){this._thinEffectLayer._effectIntensity=e}static get ForceGLSL(){return Zs.ForceGLSL}static set ForceGLSL(e){Zs.ForceGLSL=e}get name(){return this._thinEffectLayer.name}set name(e){this._thinEffectLayer.name=e}get neutralColor(){return this._thinEffectLayer.neutralColor}set neutralColor(e){this._thinEffectLayer.neutralColor=e}get isEnabled(){return this._thinEffectLayer.isEnabled}set isEnabled(e){this._thinEffectLayer.isEnabled=e}get camera(){return this._thinEffectLayer.camera}get renderingGroupId(){return this._thinEffectLayer.renderingGroupId}set renderingGroupId(e){this._thinEffectLayer.renderingGroupId=e}get disableBoundingBoxesFromEffectLayer(){return this._thinEffectLayer.disableBoundingBoxesFromEffectLayer}set disableBoundingBoxesFromEffectLayer(e){this._thinEffectLayer.disableBoundingBoxesFromEffectLayer=e}get mainTexture(){return this._mainTexture}get _shaderLanguage(){return this._thinEffectLayer.shaderLanguage}get shaderLanguage(){return this._thinEffectLayer.shaderLanguage}setMaterialForRendering(e,t){this._thinEffectLayer.setMaterialForRendering(e,t)}getEffectIntensity(e){return this._thinEffectLayer.getEffectIntensity(e)}setEffectIntensity(e,t){this._thinEffectLayer.setEffectIntensity(e,t)}constructor(e,t,i=!1,r){this._mainTextureCreatedSize={width:0,height:0},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._postProcesses=[],this._textures=[],this.uniqueId=vs.UniqueId,this.onDisposeObservable=new Y,this.onBeforeRenderMainTextureObservable=new Y,this.onBeforeComposeObservable=new Y,this.onBeforeRenderMeshToEffect=new Y,this.onAfterRenderMeshToEffect=new Y,this.onAfterComposeObservable=new Y,this.onSizeChangedObservable=new Y,this._internalThinEffectLayer=!r,r||(r=new Zs(e,t,i,!1,this._importShadersAsync.bind(this)),r.getEffectName=this.getEffectName.bind(this),r.isReady=this.isReady.bind(this),r._createMergeEffect=this._createMergeEffect.bind(this),r._createTextureAndPostProcesses=this._createTextureAndPostProcesses.bind(this),r._internalCompose=this._internalRender.bind(this),r._setEmissiveTextureAndColor=this._setEmissiveTextureAndColor.bind(this),r._numInternalDraws=this._numInternalDraws.bind(this),r._addCustomEffectDefines=this._addCustomEffectDefines.bind(this),r.hasMesh=this.hasMesh.bind(this),r.shouldRender=this.shouldRender.bind(this),r._shouldRenderMesh=this._shouldRenderMesh.bind(this),r._canRenderMesh=this._canRenderMesh.bind(this),r._useMeshMaterial=this._useMeshMaterial.bind(this)),this._thinEffectLayer=r,this.name=e,this._scene=t||ue.LastCreatedScene,n._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.addEffectLayer(this),this._thinEffectLayer.onDisposeObservable.add(()=>{this.onDisposeObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeRenderLayerObservable.add(()=>{this.onBeforeRenderMainTextureObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeComposeObservable.add(()=>{this.onBeforeComposeObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeRenderMeshToEffect.add(s=>{this.onBeforeRenderMeshToEffect.notifyObservers(s)}),this._thinEffectLayer.onAfterRenderMeshToEffect.add(s=>{this.onAfterRenderMeshToEffect.notifyObservers(s)}),this._thinEffectLayer.onAfterComposeObservable.add(()=>{this.onAfterComposeObservable.notifyObservers(this)})}get _shadersLoaded(){return this._thinEffectLayer._shadersLoaded}set _shadersLoaded(e){this._thinEffectLayer._shadersLoaded=e}_numInternalDraws(){return this._internalThinEffectLayer?1:this._thinEffectLayer._numInternalDraws()}_init(e){this._effectLayerOptions={mainTextureRatio:.5,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,mainTextureFormat:5,generateStencilBuffer:!1,...e},this._setMainTextureSize(),this._thinEffectLayer._init(e),this._createMainTexture(),this._createTextureAndPostProcesses()}_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?Qi(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?Qi(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 ri("EffectLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,{type:this._effectLayerOptions.mainTextureType,format:this._effectLayerOptions.mainTextureFormat,samplingMode:ne.TRILINEAR_SAMPLINGMODE,generateStencilBuffer:this._effectLayerOptions.generateStencilBuffer,existingObjectRenderer:this._thinEffectLayer.objectRenderer}),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=ne.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=ne.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.onClearObservable.add(e=>{e.clear(this.neutralColor,!0,!0,!0)})}_addCustomEffectDefines(e){}_isReady(e,t,i){return this._internalThinEffectLayer?this._thinEffectLayer._internalIsSubMeshReady(e,t,i):this._thinEffectLayer._isSubMeshReady(e,t,i)}async _importShadersAsync(){}_arePostProcessAndMergeReady(){return this._internalThinEffectLayer?this._thinEffectLayer._internalIsLayerReady():this._thinEffectLayer.isLayerReady()}isLayerReady(){return this._arePostProcessAndMergeReady()&&this._mainTexture.isReady()}render(){this._thinEffectLayer.compose()&&(this._setMainTextureSize(),(this._mainTextureCreatedSize.width!==this._mainTextureDesiredSize.width||this._mainTextureCreatedSize.height!==this._mainTextureDesiredSize.height)&&this._mainTextureDesiredSize.width!==0&&this._mainTextureDesiredSize.height!==0&&(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mainTextureCreatedSize.width=this._mainTextureDesiredSize.width,this._mainTextureCreatedSize.height=this._mainTextureDesiredSize.height))}hasMesh(e){return this._internalThinEffectLayer?this._thinEffectLayer._internalHasMesh(e):this._thinEffectLayer.hasMesh(e)}shouldRender(){return this._internalThinEffectLayer?this._thinEffectLayer._internalShouldRender():this._thinEffectLayer.shouldRender()}_shouldRenderMesh(e){return this._internalThinEffectLayer?!0:this._thinEffectLayer._shouldRenderMesh(e)}_canRenderMesh(e,t){return this._internalThinEffectLayer?this._thinEffectLayer._internalCanRenderMesh(e,t):this._thinEffectLayer._canRenderMesh(e,t)}_shouldRenderEmissiveTextureForMesh(){return!0}_useMeshMaterial(e){return this._internalThinEffectLayer?!1:this._thinEffectLayer._useMeshMaterial(e)}_rebuild(){this._thinEffectLayer._rebuild()}_disposeTextureAndPostProcesses(){this._mainTexture.dispose();for(let e=0;e{throw Ie("EffectLayerSceneComponent")};C([D()],hr.prototype,"name",null);C([ul()],hr.prototype,"neutralColor",null);C([D()],hr.prototype,"isEnabled",null);C([LI()],hr.prototype,"camera",null);C([D()],hr.prototype,"renderingGroupId",null);C([D()],hr.prototype,"disableBoundingBoxesFromEffectLayer",null)});var zB={};De(zB,{glowMapMergePixelShaderWGSL:()=>RY});var JS,HB,RY,XB=A(()=>{N();JS="glowMapMergePixelShader",HB=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; +}`;E.ShadersStore[$S]||(E.ShadersStore[$S]=KB);kY={name:$S,shader:KB}});var Rn,Zs,ap=A(()=>{ft();et();At();yt();Eo();Fi();Da();go();Wn();Ni();L_();Rn=class n extends li{constructor(e,t=null,i,r,s){super({...s,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms}),this.direction=i,this.kernel=r,this.textureWidth=0,this.textureHeight=0}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(rp(),ip)))):t.push(Promise.resolve().then(()=>(sp(),np))),super._gatherImports(e,t)}bind(){super.bind(),this._drawWrapper.effect.setFloat2("screenSize",this.textureWidth,this.textureHeight),this._drawWrapper.effect.setVector2("direction",this.direction),this._drawWrapper.effect.setFloat("blurWidth",this.kernel)}};Rn.FragmentUrl="glowBlurPostProcess";Rn.Uniforms=["screenSize","direction","blurWidth"];Zs=class n{get camera(){return this._options.camera}set camera(e){this._options.camera=e}get renderingGroupId(){return this._options.renderingGroupId}set renderingGroupId(e){this._options.renderingGroupId=e}get objectRenderer(){return this._objectRenderer}get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){if(this._objectRenderer.setMaterialForRendering(e,t),Array.isArray(e))for(let i=0;i{t=this._scene.getBoundingBoxRenderer().enabled,this._scene.getBoundingBoxRenderer().enabled=!this.disableBoundingBoxesFromEffectLayer&&t}),this._objectRenderer.onAfterRenderObservable.add(()=>{this._scene.getBoundingBoxRenderer().enabled=t})),this._objectRenderer.customIsReadyFunction=(i,r,s)=>{if((s||r===0)&&i.subMeshes)for(let a=0;a{this.onBeforeRenderLayerObservable.notifyObservers(this);let o,l=this._scene.getEngine();if(a.length){for(l.setColorWrite(!1),o=0;o4&&(c.push(M.MatricesIndicesExtraKind),c.push(M.MatricesWeightsExtraKind)),l.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers);let S=s.skeleton;S&&S.isUsingTextureForMatrices?l.push("#define BONETEXTURE"):l.push("#define BonesPerMesh "+(S?S.bones.length+1:0)),s.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,s)}else l.push("#define NUM_BONE_INFLUENCERS 0");let m=s.morphTargetManager?Hn(s.morphTargetManager,l,c,s,!0,!1,!1,f,d,h):0;t&&(l.push("#define INSTANCES"),gn(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES"));let p=s.bakedVertexAnimationManager;p&&p.isEnabled&&(l.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&c.push("bakedVertexAnimationSettingsInstanced")),kn(o,this._scene,l),this._addCustomEffectDefines(l);let _=e._getDrawWrapper(void 0,!0),g=_.defines,T=l.join(` +`);if(g!==T){let S=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureInfo","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture","glowIntensity"];Li(S),_.setEffect(this._engine.createEffect("glowMapGeneration",c,S,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],T,u,void 0,void 0,{maxSimultaneousMorphTargets:m},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),T)}return _.effect.isReady()&&(this._dontCheckIfReady||!this._dontCheckIfReady&&this.isLayerReady())}_isSubMeshReady(e,t,i){return this._internalIsSubMeshReady(e,t,i)}async _importShadersAsync(){var e;this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(GB(),VB)),Promise.resolve().then(()=>(HB(),WB))]):await Promise.all([Promise.resolve().then(()=>(YB(),XB)),Promise.resolve().then(()=>(ZB(),jB))]),(e=this._additionalImportShadersAsync)==null||e.call(this)}_internalIsLayerReady(){let e=!0;for(let i=0;iT.setMatrix("world",x)),(i.disableDepthWrite||i.forceDepthWrite)&&c.setDepthWrite(b),i.disableColorWrite&&c.setColorWrite(R),i.depthFunction!==0&&c.setDepthFunction(S)}else this._objectRenderer.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(r)}_useMeshMaterial(e){return!1}_rebuild(){let e=this._vertexBuffers[M.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}dispose(){let e=this._vertexBuffers[M.PositionKind];e&&(e.dispose(),this._vertexBuffers[M.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);for(let t of this._mergeDrawWrapper)t.dispose();this._mergeDrawWrapper=[],this._objectRenderer.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderLayerObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear()}};Zs.ForceGLSL=!1});var pr,eA=A(()=>{Qe();qe();Tt();ft();At();oi();_a();Ei();Dn();ap();Vh();pr=class n{get _shouldRender(){return this._thinEffectLayer._shouldRender}set _shouldRender(e){this._thinEffectLayer._shouldRender=e}get _emissiveTextureAndColor(){return this._thinEffectLayer._emissiveTextureAndColor}set _emissiveTextureAndColor(e){this._thinEffectLayer._emissiveTextureAndColor=e}get _effectIntensity(){return this._thinEffectLayer._effectIntensity}set _effectIntensity(e){this._thinEffectLayer._effectIntensity=e}static get ForceGLSL(){return Zs.ForceGLSL}static set ForceGLSL(e){Zs.ForceGLSL=e}get name(){return this._thinEffectLayer.name}set name(e){this._thinEffectLayer.name=e}get neutralColor(){return this._thinEffectLayer.neutralColor}set neutralColor(e){this._thinEffectLayer.neutralColor=e}get isEnabled(){return this._thinEffectLayer.isEnabled}set isEnabled(e){this._thinEffectLayer.isEnabled=e}get camera(){return this._thinEffectLayer.camera}get renderingGroupId(){return this._thinEffectLayer.renderingGroupId}set renderingGroupId(e){this._thinEffectLayer.renderingGroupId=e}get disableBoundingBoxesFromEffectLayer(){return this._thinEffectLayer.disableBoundingBoxesFromEffectLayer}set disableBoundingBoxesFromEffectLayer(e){this._thinEffectLayer.disableBoundingBoxesFromEffectLayer=e}get mainTexture(){return this._mainTexture}get _shaderLanguage(){return this._thinEffectLayer.shaderLanguage}get shaderLanguage(){return this._thinEffectLayer.shaderLanguage}setMaterialForRendering(e,t){this._thinEffectLayer.setMaterialForRendering(e,t)}getEffectIntensity(e){return this._thinEffectLayer.getEffectIntensity(e)}setEffectIntensity(e,t){this._thinEffectLayer.setEffectIntensity(e,t)}constructor(e,t,i=!1,r){this._mainTextureCreatedSize={width:0,height:0},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._postProcesses=[],this._textures=[],this.uniqueId=Ts.UniqueId,this.onDisposeObservable=new Y,this.onBeforeRenderMainTextureObservable=new Y,this.onBeforeComposeObservable=new Y,this.onBeforeRenderMeshToEffect=new Y,this.onAfterRenderMeshToEffect=new Y,this.onAfterComposeObservable=new Y,this.onSizeChangedObservable=new Y,this._internalThinEffectLayer=!r,r||(r=new Zs(e,t,i,!1,this._importShadersAsync.bind(this)),r.getEffectName=this.getEffectName.bind(this),r.isReady=this.isReady.bind(this),r._createMergeEffect=this._createMergeEffect.bind(this),r._createTextureAndPostProcesses=this._createTextureAndPostProcesses.bind(this),r._internalCompose=this._internalRender.bind(this),r._setEmissiveTextureAndColor=this._setEmissiveTextureAndColor.bind(this),r._numInternalDraws=this._numInternalDraws.bind(this),r._addCustomEffectDefines=this._addCustomEffectDefines.bind(this),r.hasMesh=this.hasMesh.bind(this),r.shouldRender=this.shouldRender.bind(this),r._shouldRenderMesh=this._shouldRenderMesh.bind(this),r._canRenderMesh=this._canRenderMesh.bind(this),r._useMeshMaterial=this._useMeshMaterial.bind(this)),this._thinEffectLayer=r,this.name=e,this._scene=t||ue.LastCreatedScene,n._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.addEffectLayer(this),this._thinEffectLayer.onDisposeObservable.add(()=>{this.onDisposeObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeRenderLayerObservable.add(()=>{this.onBeforeRenderMainTextureObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeComposeObservable.add(()=>{this.onBeforeComposeObservable.notifyObservers(this)}),this._thinEffectLayer.onBeforeRenderMeshToEffect.add(s=>{this.onBeforeRenderMeshToEffect.notifyObservers(s)}),this._thinEffectLayer.onAfterRenderMeshToEffect.add(s=>{this.onAfterRenderMeshToEffect.notifyObservers(s)}),this._thinEffectLayer.onAfterComposeObservable.add(()=>{this.onAfterComposeObservable.notifyObservers(this)})}get _shadersLoaded(){return this._thinEffectLayer._shadersLoaded}set _shadersLoaded(e){this._thinEffectLayer._shadersLoaded=e}_numInternalDraws(){return this._internalThinEffectLayer?1:this._thinEffectLayer._numInternalDraws()}_init(e){this._effectLayerOptions={mainTextureRatio:.5,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,mainTextureFormat:5,generateStencilBuffer:!1,...e},this._setMainTextureSize(),this._thinEffectLayer._init(e),this._createMainTexture(),this._createTextureAndPostProcesses()}_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?$i(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?$i(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 ri("EffectLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,{type:this._effectLayerOptions.mainTextureType,format:this._effectLayerOptions.mainTextureFormat,samplingMode:ne.TRILINEAR_SAMPLINGMODE,generateStencilBuffer:this._effectLayerOptions.generateStencilBuffer,existingObjectRenderer:this._thinEffectLayer.objectRenderer}),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=ne.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=ne.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(ne.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.onClearObservable.add(e=>{e.clear(this.neutralColor,!0,!0,!0)})}_addCustomEffectDefines(e){}_isReady(e,t,i){return this._internalThinEffectLayer?this._thinEffectLayer._internalIsSubMeshReady(e,t,i):this._thinEffectLayer._isSubMeshReady(e,t,i)}async _importShadersAsync(){}_arePostProcessAndMergeReady(){return this._internalThinEffectLayer?this._thinEffectLayer._internalIsLayerReady():this._thinEffectLayer.isLayerReady()}isLayerReady(){return this._arePostProcessAndMergeReady()&&this._mainTexture.isReady()}render(){this._thinEffectLayer.compose()&&(this._setMainTextureSize(),(this._mainTextureCreatedSize.width!==this._mainTextureDesiredSize.width||this._mainTextureCreatedSize.height!==this._mainTextureDesiredSize.height)&&this._mainTextureDesiredSize.width!==0&&this._mainTextureDesiredSize.height!==0&&(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mainTextureCreatedSize.width=this._mainTextureDesiredSize.width,this._mainTextureCreatedSize.height=this._mainTextureDesiredSize.height))}hasMesh(e){return this._internalThinEffectLayer?this._thinEffectLayer._internalHasMesh(e):this._thinEffectLayer.hasMesh(e)}shouldRender(){return this._internalThinEffectLayer?this._thinEffectLayer._internalShouldRender():this._thinEffectLayer.shouldRender()}_shouldRenderMesh(e){return this._internalThinEffectLayer?!0:this._thinEffectLayer._shouldRenderMesh(e)}_canRenderMesh(e,t){return this._internalThinEffectLayer?this._thinEffectLayer._internalCanRenderMesh(e,t):this._thinEffectLayer._canRenderMesh(e,t)}_shouldRenderEmissiveTextureForMesh(){return!0}_useMeshMaterial(e){return this._internalThinEffectLayer?!1:this._thinEffectLayer._useMeshMaterial(e)}_rebuild(){this._thinEffectLayer._rebuild()}_disposeTextureAndPostProcesses(){this._mainTexture.dispose();for(let e=0;e{throw Ie("EffectLayerSceneComponent")};C([D()],pr.prototype,"name",null);C([ml()],pr.prototype,"neutralColor",null);C([D()],pr.prototype,"isEnabled",null);C([UI()],pr.prototype,"camera",null);C([D()],pr.prototype,"renderingGroupId",null);C([D()],pr.prototype,"disableBoundingBoxesFromEffectLayer",null)});var QB={};De(QB,{glowMapMergePixelShaderWGSL:()=>WY});var tA,qB,WY,JB=A(()=>{N();tA="glowMapMergePixelShader",qB=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; #ifdef EMISSIVE var textureSampler2Sampler: sampler;var textureSampler2: texture_2d; #endif @@ -19599,14 +19599,14 @@ baseColor=clamp(baseColor,vec4f(0.),vec4f(1.0)); fragmentOutputs.color=baseColor; #define CUSTOM_FRAGMENT_MAIN_END } -`;E.ShadersStoreWGSL[JS]||(E.ShadersStoreWGSL[JS]=HB);RY={name:JS,shader:HB}});var KB={};De(KB,{glowMapMergeVertexShaderWGSL:()=>IY});var $S,YB,IY,jB=A(()=>{N();$S="glowMapMergeVertexShader",YB=`attribute position: vec2f;varying vUV: vec2f; +`;E.ShadersStoreWGSL[tA]||(E.ShadersStoreWGSL[tA]=qB);WY={name:tA,shader:qB}});var eU={};De(eU,{glowMapMergeVertexShaderWGSL:()=>HY});var iA,$B,HY,tU=A(()=>{N();iA="glowMapMergeVertexShader",$B=`attribute position: vec2f;varying vUV: vec2f; #define CUSTOM_VERTEX_DEFINITIONS @vertex fn main(input : VertexInputs)->FragmentInputs {const madd: vec2f= vec2f(0.5,0.5); #define CUSTOM_VERTEX_MAIN_BEGIN vertexOutputs.vUV=vertexInputs.position*madd+madd;vertexOutputs.position= vec4f(vertexInputs.position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStoreWGSL[$S]||(E.ShadersStoreWGSL[$S]=YB);IY={name:$S,shader:YB}});var qB={};De(qB,{glowMapMergePixelShader:()=>xY});var eA,ZB,xY,QB=A(()=>{N();eA="glowMapMergePixelShader",ZB=`varying vec2 vUV;uniform sampler2D textureSampler; +}`;E.ShadersStoreWGSL[iA]||(E.ShadersStoreWGSL[iA]=$B);HY={name:iA,shader:$B}});var rU={};De(rU,{glowMapMergePixelShader:()=>zY});var rA,iU,zY,nU=A(()=>{N();rA="glowMapMergePixelShader",iU=`varying vec2 vUV;uniform sampler2D textureSampler; #ifdef EMISSIVE uniform sampler2D textureSampler2; #endif @@ -19628,14 +19628,14 @@ baseColor=clamp(baseColor,0.,1.0); #endif gl_FragColor=baseColor; #define CUSTOM_FRAGMENT_MAIN_END -}`;E.ShadersStore[eA]||(E.ShadersStore[eA]=ZB);xY={name:eA,shader:ZB}});var $B={};De($B,{glowMapMergeVertexShader:()=>CY});var tA,JB,CY,eU=A(()=>{N();tA="glowMapMergeVertexShader",JB=`attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5); +}`;E.ShadersStore[rA]||(E.ShadersStore[rA]=iU);zY={name:rA,shader:iU}});var aU={};De(aU,{glowMapMergeVertexShader:()=>XY});var nA,sU,XY,oU=A(()=>{N();nA="glowMapMergeVertexShader",sU=`attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5); #define CUSTOM_VERTEX_DEFINITIONS void main(void) { #define CUSTOM_VERTEX_MAIN_BEGIN vUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0); #define CUSTOM_VERTEX_MAIN_END -}`;E.ShadersStore[tA]||(E.ShadersStore[tA]=JB);CY={name:tA,shader:JB}});var jn,tU=A(()=>{ve();yt();Ni();H_();sp();et();Nv();jn=class n extends Zs{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}get stencilReference(){return this._instanceGlowingMeshStencilReference<<8-this.numStencilBits}constructor(e,t,i,r=!1){super(e,t,i!==void 0?!!i.forceGLSL:!1),this.innerGlow=!0,this.outerGlow=!0,this._instanceGlowingMeshStencilReference=n.GlowingMeshStencilReference++,this._meshes={},this._excludedMeshes={},this._mainObjectRendererRenderPassId=-1,this.numStencilBits=8,this.neutralColor=n.NeutralColor,this._options={mainTextureRatio:.5,blurTextureSizeRatio:.5,mainTextureFixedSize:0,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:2,camera:null,renderingGroupId:-1,forceGLSL:!1,mainTextureType:0,mainTextureFormat:5,isStroke:!1,...i},this._init(this._options),this._shouldRender=!1,r&&this._createTextureAndPostProcesses()}getClassName(){return"HighlightLayer"}async _importShadersAsync(){this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(XB(),zB)),Promise.resolve().then(()=>(jB(),KB)),Promise.resolve().then(()=>(ip(),tp))]):await Promise.all([Promise.resolve().then(()=>(QB(),qB)),Promise.resolve().then(()=>(eU(),$B)),Promise.resolve().then(()=>(np(),rp))]),await super._importShadersAsync()}getEffectName(){return n.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._engine.createEffect("glowMapMerge",[M.PositionKind],["offset"],["textureSampler"],this._options.isStroke?`#define STROKE -`:void 0,void 0,void 0,void 0,void 0,this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0})}_createTextureAndPostProcesses(){this._options.alphaBlendingMode===2?(this._downSamplePostprocess=new ps("HighlightLayerPPP",this._scene.getEngine()),this._horizontalBlurPostprocess=new An("HighlightLayerHBP",this._scene.getEngine(),new _e(1,0),this._options.blurHorizontalSize),this._verticalBlurPostprocess=new An("HighlightLayerVBP",this._scene.getEngine(),new _e(0,1),this._options.blurVerticalSize),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new Xi("HighlightLayerHBP",this._scene.getEngine(),new _e(1,0),this._options.blurHorizontalSize/2),this._verticalBlurPostprocess=new Xi("HighlightLayerVBP",this._scene.getEngine(),new _e(0,1),this._options.blurVerticalSize/2),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess])}needStencil(){return!0}isReady(e,t){let i=e.getMaterial(),r=e.getRenderingMesh();if(!i||!r||!this._meshes)return!1;let s=null,a=this._meshes[r.uniqueId];return a&&a.glowEmissiveOnly&&i&&(s=i.emissiveTexture),super._isSubMeshReady(e,t,s)}_canRenderMesh(e,t){return!0}_internalCompose(e,t){this.bindTexturesForCompose(e);let i=this._engine;i.cacheStencilState(),i.setStencilOperationPass(7681),i.setStencilOperationFail(7680),i.setStencilOperationDepthFail(7680),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference<<8-this.numStencilBits),i.setStencilFunctionMask(255-((1<<8-this.numStencilBits)-1)),this.outerGlow&&t===0&&(e.setFloat("offset",0),i.setStencilFunction(517),i.drawElementsType(ae.TriangleFillMode,0,6)),this.innerGlow&&t===1&&(e.setFloat("offset",1),i.setStencilFunction(514),i.drawElementsType(ae.TriangleFillMode,0,6)),i.restoreStencilState()}_setEmissiveTextureAndColor(e,t,i){let r=this._meshes[e.uniqueId];r?this._emissiveTextureAndColor.color.set(r.color.r,r.color.g,r.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),r&&r.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null}shouldRender(){return!!(this._meshes&&super.shouldRender())}_shouldRenderMesh(e){return this._excludedMeshes&&this._excludedMeshes[e.uniqueId]?!1:super.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define HIGHLIGHT")}addExcludedMesh(e){if(!this._excludedMeshes)return;if(!this._excludedMeshes[e.uniqueId]){let i={mesh:e,beforeBind:null,afterRender:null,stencilState:!1};i.beforeBind=e.onBeforeBindObservable.add(r=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||(i.stencilState=r.getEngine().getStencilBuffer(),r.getEngine().setStencilBuffer(!1))}),i.afterRender=e.onAfterRenderObservable.add(r=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||r.getEngine().setStencilBuffer(i.stencilState)}),this._excludedMeshes[e.uniqueId]=i}}removeExcludedMesh(e){if(!this._excludedMeshes)return;let 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]}addMesh(e,t,i=!1){if(!this._meshes)return;let r=this._meshes[e.uniqueId];r?r.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeBindObservable.add(s=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&(this._excludedMeshes&&this._excludedMeshes[s.uniqueId]?this._defaultStencilReference(s):s.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference<<8-this.numStencilBits))}),observerDefault:e.onAfterRenderObservable.add(s=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&this._defaultStencilReference(s)}),glowEmissiveOnly:i},e.onDisposeObservable.add(()=>{this._disposeMesh(e)})),this._shouldRender=!0}removeMesh(e){if(!this._meshes)return;let 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(let i in this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}removeAllMeshes(){if(this._meshes){for(let e in this._meshes)if(Object.prototype.hasOwnProperty.call(this._meshes,e)){let t=this._meshes[e];t&&this.removeMesh(t.mesh)}}}_defaultStencilReference(e){e.getScene().getEngine().setStencilFunctionReference(n.NormalMeshStencilReference<<8-this.numStencilBits)}_disposeMesh(e){this.removeMesh(e),this.removeExcludedMesh(e)}dispose(){if(this._meshes){for(let e in this._meshes){let 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(let e in this._excludedMeshes){let 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()}};jn.EffectName="HighlightLayer";jn.NeutralColor=new Ne(0,0,0,0);jn.GlowingMeshStencilReference=2;jn.NormalMeshStencilReference=1});var ap,Ir,iU=A(()=>{Qe();qe();ct();gr();ve();oi();_a();ms();X_();Fv();QS();ze();Lt();et();tU();Kt();Dn();sp();gt.prototype.getHighlightLayerByName=function(n){var e;for(let t=0;t<((e=this.effectLayers)==null?void 0:e.length);t++)if(this.effectLayers[t].name===n&&this.effectLayers[t].getEffectName()===Ir.EffectName)return this.effectLayers[t];return null};ap=class extends _t{constructor(e,t,i,r,s=null,a=ne.BILINEAR_SAMPLINGMODE,o,l){let c={uniforms:An.Uniforms,size:typeof r=="number"?r:void 0,camera:s,samplingMode:a,engine:o,reusable:l,...r};super(e,An.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new An(e,o,t,i,c):void 0,...c}),this.direction=t,this.kernel=i,this.onApplyObservable.add(()=>{this._effectWrapper.textureWidth=this.width,this._effectWrapper.textureHeight=this.height})}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(ip(),tp)))):t.push(Promise.resolve().then(()=>(np(),rp))),super._gatherImports(e,t)}},Ir=class n extends hr{static get NeutralColor(){return jn.NeutralColor}static set NeutralColor(e){jn.NeutralColor=e}get innerGlow(){return this._thinEffectLayer.innerGlow}set innerGlow(e){this._thinEffectLayer.innerGlow=e}get outerGlow(){return this._thinEffectLayer.outerGlow}set outerGlow(e){this._thinEffectLayer.outerGlow=e}set blurHorizontalSize(e){this._thinEffectLayer.blurHorizontalSize=e}set blurVerticalSize(e){this._thinEffectLayer.blurVerticalSize=e}get blurHorizontalSize(){return this._thinEffectLayer.blurHorizontalSize}get blurVerticalSize(){return this._thinEffectLayer.blurVerticalSize}get numStencilBits(){return this._thinEffectLayer.numStencilBits}set numStencilBits(e){this._thinEffectLayer.numStencilBits=e}get stencilReference(){return this._thinEffectLayer.stencilReference}constructor(e,t,i){super(e,t,i!==void 0?!!i.forceGLSL:!1,new jn(e,t,i)),this.onBeforeBlurObservable=new Y,this.onAfterBlurObservable=new Y,this._engine.isStencilEnable||W.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,mainTextureFixedSize:0,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,mainTextureFormat:5,forceGLSL:!1,isStroke:!1,generateStencilBuffer:!1,...i},this._init(this._options),this._shouldRender=!1}getEffectName(){return n.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._thinEffectLayer._createMergeEffect()}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,t=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;e=this._engine.needPOTTextures?Qi(e,this._maxSize):e,t=this._engine.needPOTTextures?Qi(t,this._maxSize):t;let i;this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture=new ri("HighlightLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,i),this._blurTexture.wrapU=ne.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=ne.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(ne.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._thinEffectLayer.bindTexturesForCompose=r=>{r.setTexture("textureSampler",this._blurTexture)},this._thinEffectLayer._createTextureAndPostProcesses(),this._options.alphaBlendingMode===2?(this._downSamplePostprocess=new vo("HighlightLayerPPP",{size:this._options.blurTextureSizeRatio,samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[0]}),this._downSamplePostprocess.externalTextureSamplerBinding=!0,this._downSamplePostprocess.onApplyObservable.add(r=>{r.setTexture("textureSampler",this._mainTexture)}),this._horizontalBlurPostprocess=new ap("HighlightLayerHBP",new _e(1,0),this._options.blurHorizontalSize,{samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[1]}),this._horizontalBlurPostprocess.onApplyObservable.add(r=>{r.setFloat2("screenSize",e,t)}),this._verticalBlurPostprocess=new ap("HighlightLayerVBP",new _e(0,1),this._options.blurVerticalSize,{samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[2]}),this._verticalBlurPostprocess.onApplyObservable.add(r=>{r.setFloat2("screenSize",e,t)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new Yr("HighlightLayerHBP",new _e(1,0),this._options.blurHorizontalSize/2,{size:{width:e,height:t},samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),textureType:i,effectWrapper:this._thinEffectLayer._postProcesses[0]}),this._horizontalBlurPostprocess.width=e,this._horizontalBlurPostprocess.height=t,this._horizontalBlurPostprocess.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess.onApplyObservable.add(r=>{r.setTexture("textureSampler",this._mainTexture)}),this._verticalBlurPostprocess=new Yr("HighlightLayerVBP",new _e(0,1),this._options.blurVerticalSize/2,{size:{width:e,height:t},samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),textureType:i}),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add(()=>{this.onBeforeBlurObservable.notifyObservers(this);let r=this._blurTexture.renderTarget;r&&(this._scene.postProcessManager.directRender(this._postProcesses,r,!0),this._engine.unBindFramebuffer(r,!0)),this.onAfterBlurObservable.notifyObservers(this)}),this._postProcesses.map(r=>{r.autoClear=!1}),this._mainTextureCreatedSize.width=this._mainTextureDesiredSize.width,this._mainTextureCreatedSize.height=this._mainTextureDesiredSize.height}needStencil(){return this._thinEffectLayer.needStencil()}isReady(e,t){return this._thinEffectLayer.isReady(e,t)}_internalRender(e,t){this._thinEffectLayer._internalCompose(e,t)}shouldRender(){return this._thinEffectLayer.shouldRender()}_shouldRenderMesh(e){return this._thinEffectLayer._shouldRenderMesh(e)}_canRenderMesh(e,t){return this._thinEffectLayer._canRenderMesh(e,t)}_addCustomEffectDefines(e){this._thinEffectLayer._addCustomEffectDefines(e)}_setEmissiveTextureAndColor(e,t,i){this._thinEffectLayer._setEmissiveTextureAndColor(e,t,i)}addExcludedMesh(e){this._thinEffectLayer.addExcludedMesh(e)}removeExcludedMesh(e){this._thinEffectLayer.removeExcludedMesh(e)}hasMesh(e){return this._thinEffectLayer.hasMesh(e)}addMesh(e,t,i=!1){this._thinEffectLayer.addMesh(e,t,i)}removeMesh(e){this._thinEffectLayer.removeMesh(e)}removeAllMeshes(){this._thinEffectLayer.removeAllMeshes()}_disposeMesh(e){this._thinEffectLayer._disposeMesh(e)}getClassName(){return"HighlightLayer"}serialize(){let e=Me.Serialize(this);e.customType="BABYLON.HighlightLayer",e.meshes=[];let t=this._thinEffectLayer._meshes;if(t)for(let r in t){let s=t[r];s&&e.meshes.push({glowEmissiveOnly:s.glowEmissiveOnly,color:s.color.asArray(),meshId:s.mesh.id})}e.excludedMeshes=[];let i=this._thinEffectLayer._excludedMeshes;if(i)for(let r in i){let s=i[r];s&&e.excludedMeshes.push(s.mesh.id)}return e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t,e.options),e,t,i),s;for(s=0;s{Rs();El();QS();At();tT();Mm(be.NAME_EFFECTLAYER,(n,e,t,i)=>{if(n.effectLayers){t.effectLayers||(t.effectLayers=[]);for(let r=0;r0){this._previousStencilState=this._engine.getStencilBuffer();for(let r of i)if(r.shouldRender()&&(!r.camera||r.camera.cameraRigMode===Ge.RIG_MODE_NONE&&e===r.camera||r.camera.cameraRigMode!==Ge.RIG_MODE_NONE&&r.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||r.needStencil();let s=r._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1),t=!0)}this.scene.incrementRenderId()}return t}_setStencil(){this._needStencil&&this._engine.setStencilBuffer(!0)}_setStencilBack(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)}_draw(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);let t=this.scene.effectLayers;for(let i=0;i{let e=n._getComponent(be.NAME_EFFECTLAYER);e||(e=new iA(n),n._addComponent(e))}});function nU(n,e){let t=new Ir("ai3d-pick-highlight",n),i=new oe(.15,.45,1);function r(){t.removeAllMeshes()}function s(o){o.isDisposed()||t.addMesh(o,i)}let a=n.onPointerObservable.add(o=>{var h;if(o.type!==ye.POINTERDOWN)return;let l=o.event,c=l.clientX,f=l.clientY;r();let d=o.pickInfo;d!=null&&d.hit&&d.pickedMesh?(s(d.pickedMesh),e({mesh:d.pickedMesh,pickedPoint:(h=d.pickedPoint)!=null?h:null,screenX:c,screenY:f})):e({mesh:null,pickedPoint:null,screenX:c,screenY:f})});return()=>{r(),t.dispose(),n.onPointerObservable.remove(a)}}var sU=A(()=>{"use strict";fn();et();iU();rU()});function nd(n){let e=new Uint8Array(n),t=32768,i=[];for(let r=0;r{"use strict"});function Qt(){return aU.Platform.isMobile}var aU,jr=A(()=>{"use strict";aU=require("obsidian")});function bY(){if("require"in activeWindow)return activeWindow.require}function op(){if("process"in activeWindow)return activeWindow.process}function sd(n){let e=bY();if(!e)return null;try{return e(n)}catch(t){return null}}function xr(n,e){if(n===null)throw new Error(`${e} is not available in this environment (mobile or web).`);return n}function ur(n,e){return xr(ad,"node:fs/promises").access(n,e)}function Zr(n){return xr(ad,"node:fs/promises").readFile(n)}function Ic(n,e,t){return xr(ad,"node:fs/promises").writeFile(n,e,{encoding:t})}function xc(n,e){return xr(ad,"node:fs/promises").mkdir(n,e)}function Cc(n,e){return xr(ad,"node:fs/promises").rm(n,e)}function Pt(...n){return xr(qs,"node:path").join(...n)}function Zn(n){return xr(qs,"node:path").dirname(n)}function qn(n,e){return xr(qs,"node:path").basename(n,e)}function qr(n){return xr(qs,"node:path").extname(n)}function nA(n){return xr(qs,"node:path").normalize(n)}function ji(n){return xr(qs,"node:path").isAbsolute(n)}function Qr(n,e,t,i){xr(MY,"node:child_process").execFile(n,e,t,i)}function bc(){return xr(yY,"node:os").tmpdir()}var ad,Rc,qs,MY,yY,oU,mr,lU,fU,cU,dU,Gt=A(()=>{"use strict";ad=sd("node:fs/promises"),Rc=sd("node:fs"),qs=sd("node:path"),MY=sd("node:child_process"),yY=sd("node:os");mr=(oU=Rc==null?void 0:Rc.constants.F_OK)!=null?oU:0,fU=(lU=Rc==null?void 0:Rc.constants.X_OK)!=null?lU:0;dU=(cU=qs==null?void 0:qs.delimiter)!=null?cU:":"});function uU(n){return n.replace(/\\/g,"/")}function mU(n){let e=uU(n).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function lp(n){let e=uU(n).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Cr(n){return lp(n).replace(/\.[^.]+$/,"")}function DY(n){return Uint8Array.from(n).buffer}function LY(n){let e=n.vault.adapter;return typeof e.getBasePath=="function"?e.getBasePath():typeof e.basePath=="string"&&e.basePath.length>0?e.basePath:null}function Mc(n,e){var r,s;let t=n.vault.getAbstractFileByPath(e);if(t)return t.path;let i=(s=(r=n.metadataCache)==null?void 0:r.getFirstLinkpathDest)==null?void 0:s.call(r,e,"");return i?i.path:null}function Qs(n,e){if(ji(e))return nA(e);let t=LY(n);return t?nA(Pt(t,e)):null}async function br(n,e){if(ji(e)){let i=await Zr(e);return DY(i)}let t=n.vault.getAbstractFileByPath(e);if(!(t instanceof hU.TFile))throw new Error(`File not found: ${e}`);return n.vault.readBinary(t)}var hU,Js=A(()=>{"use strict";hU=require("obsidian");Gt();Gt()});function UY(n,e,t){let i=oe.FromHexString(e),r=new Re(n,t);return r.emissiveColor=i,r.diffuseColor=oe.Black(),r.specularColor=oe.Black(),r.backFaceCulling=!1,r}function VY(n){let e=new Re("gizmo-origin-mat",n);return e.emissiveColor=new oe(.72,.78,.86),e.diffuseColor=oe.Black(),e.specularColor=oe.Black(),e}var PY,cp,OY,aA,NY,FY,sA,wY,BY,fp,pU=A(()=>{"use strict";gr();du();hu();ve();et();fl();nv();Xs();PY=.32,cp=1.05,OY=.075,aA=.28,NY=.22,FY=.16,sA=(cp+aA)*.42,wY=new v(sA,sA,sA),BY=[{name:"x",color:"#e74c3c",rot:new v(0,0,-Math.PI/2),dir:new v(1,0,0)},{name:"y",color:"#2ecc71",rot:new v(0,0,0),dir:new v(0,1,0)},{name:"z",color:"#3498db",rot:new v(Math.PI/2,0,0),dir:new v(0,0,1)}];fp=class{constructor(e,t){this.engine=e,this.scene=new gt(e),this.scene.clearColor=new Ne(0,0,0,0),this.scene.autoClear=!1,this.camera=new ht("gizmo-cam",0,0,4.1,wY,this.scene),this.camera.minZ=.01,this.camera.fov=.56,this.camera.detachControl(),new Sr("gizmo-light",new v(0,1,.5),this.scene);let i=zs.CreateSphere("gizmo-origin",{diameter:FY,segments:16},this.scene);i.material=VY(this.scene);for(let{name:s,color:a,rot:o,dir:l}of BY){let c=UY(`gizmo-${s}-mat`,a,this.scene),f=zs.CreateCylinder(`gizmo-${s}-shaft`,{height:cp,diameter:OY,tessellation:8},this.scene);f.material=c,f.position=l.scale(cp/2),f.rotation=o;let d=zs.CreateCylinder(`gizmo-${s}-head`,{height:aA,diameterTop:0,diameterBottom:NY,tessellation:8},this.scene);d.material=c;let h=cp+aA/2;d.position=l.scale(h),d.rotation=o}let r=PY;this.viewport=new nn(.02,.03,r,r),this.camera.viewport=this.viewport,this.syncWith(t)}syncWith(e){this.camera.alpha=e.alpha,this.camera.beta=e.beta}render(){let e=this.engine.getRenderWidth(),t=this.engine.getRenderHeight(),i=this.viewport.x*e,r=this.viewport.y*t,s=this.viewport.width*e,a=this.viewport.height*t;this.engine.enableScissor(i,r,s,a),this.engine.clear(null,!1,!0,!0),this.scene.render(),this.engine.disableScissor()}dispose(){this.scene.dispose()}}});var Rn,oA=A(()=>{Ci();ve();Ln();eE();af();At();og();Rn=class n{constructor(e,t,i=Number.MAX_VALUE,r=Ye){this.origin=e,this.direction=t,this.length=i,this.epsilon=r}clone(){return new n(this.origin.clone(),this.direction.clone(),this.length)}intersectsBoxMinMax(e,t,i=0){let r=n._TmpVector3[0].copyFromFloats(e.x-i,e.y-i,e.z-i),s=n._TmpVector3[1].copyFromFloats(t.x+i,t.y+i,t.z+i),a=0,o=Number.MAX_VALUE,l,c,f,d;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xs.x)return!1}else if(l=1/this.direction.x,c=(r.x-this.origin.x)*l,f=(s.x-this.origin.x)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.ys.y)return!1}else if(l=1/this.direction.y,c=(r.y-this.origin.y)*l,f=(s.y-this.origin.y)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zs.z)return!1}else if(l=1/this.direction.z,c=(r.z-this.origin.z)*l,f=(s.z-this.origin.z)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;return!0}intersectsBox(e,t=0){return this.intersectsBoxMinMax(e.minimum,e.maximum,t)}intersectsSphere(e,t=0){let i=e.center.x-this.origin.x,r=e.center.y-this.origin.y,s=e.center.z-this.origin.z,a=i*i+r*r+s*s,o=e.radius+t,l=o*o;if(a<=l)return!0;let c=i*this.direction.x+r*this.direction.y+s*this.direction.z;return c<0?!1:a-c*c<=l}intersectsTriangle(e,t,i){let r=n._TmpVector3[0],s=n._TmpVector3[1],a=n._TmpVector3[2],o=n._TmpVector3[3],l=n._TmpVector3[4];t.subtractToRef(e,r),i.subtractToRef(e,s),v.CrossToRef(this.direction,s,a);let c=v.Dot(r,a);if(c===0)return null;let f=1/c;this.origin.subtractToRef(e,o);let d=v.Dot(o,a)*f;if(d<-this.epsilon||d>1+this.epsilon)return null;v.CrossToRef(o,r,l);let h=v.Dot(this.direction,l)*f;if(h<-this.epsilon||d+h>1+this.epsilon)return null;let u=v.Dot(s,l)*f;return u>this.length||u<0?null:new Io(1-d-h,d,u)}intersectsPlane(e){let t,i=v.Dot(e.normal,this.direction);if(Math.abs(i)<999999997475243e-21)return null;{let r=v.Dot(e.normal,this.origin);return t=(-e.d-r)/i,t<0?t<-999999997475243e-21?null:0:t}}intersectsAxis(e,t=0){switch(e){case"y":{let 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":{let 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":{let 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,r=!1,s,a=!1){let o=k.Matrix[0];return e.getWorldMatrix().invertToRef(o),this._tmpRay?n.TransformToRef(this,o,this._tmpRay):this._tmpRay=n.Transform(this,o),e.intersects(this._tmpRay,t,i,r,s,a)}intersectsMeshes(e,t,i){i?i.length=0:i=[];for(let r=0;rt.distance?1:0}intersectionSegment(e,t,i){let r=this.origin,s=k.Vector3[0],a=k.Vector3[1],o=k.Vector3[2],l=k.Vector3[3];t.subtractToRef(e,s),this.direction.scaleToRef(n._Rayl,o),r.addToRef(o,a),e.subtractToRef(r,l);let c=v.Dot(s,s),f=v.Dot(s,o),d=v.Dot(o,o),h=v.Dot(s,l),u=v.Dot(o,l),m=c*d-f*f,p,_=m,g,T=m;m_&&(p=_,g=u+f,T=d)),g<0?(g=0,-h<0?p=0:-h>c?p=_:(p=-h,_=c)):g>T&&(g=T,-h+f<0?p=0:-h+f>c?p=_:(p=-h+f,_=c));let b=Math.abs(p)0&&R<=this.length&&x.lengthSquared()GY});var lA,_U,GY,fA=A(()=>{N();lA="boundingBoxRendererVertexShader",_U=`attribute position: vec3f;uniform world: mat4x4f;uniform viewProjection: mat4x4f; +}`;E.ShadersStore[nA]||(E.ShadersStore[nA]=sU);XY={name:nA,shader:sU}});var Zn,lU=A(()=>{ve();yt();Fi();Y_();ap();et();Bv();Zn=class n extends Zs{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}get stencilReference(){return this._instanceGlowingMeshStencilReference<<8-this.numStencilBits}constructor(e,t,i,r=!1){super(e,t,i!==void 0?!!i.forceGLSL:!1),this.innerGlow=!0,this.outerGlow=!0,this._instanceGlowingMeshStencilReference=n.GlowingMeshStencilReference++,this._meshes={},this._excludedMeshes={},this._mainObjectRendererRenderPassId=-1,this.numStencilBits=8,this.neutralColor=n.NeutralColor,this._options={mainTextureRatio:.5,blurTextureSizeRatio:.5,mainTextureFixedSize:0,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:2,camera:null,renderingGroupId:-1,forceGLSL:!1,mainTextureType:0,mainTextureFormat:5,isStroke:!1,...i},this._init(this._options),this._shouldRender=!1,r&&this._createTextureAndPostProcesses()}getClassName(){return"HighlightLayer"}async _importShadersAsync(){this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(JB(),QB)),Promise.resolve().then(()=>(tU(),eU)),Promise.resolve().then(()=>(rp(),ip))]):await Promise.all([Promise.resolve().then(()=>(nU(),rU)),Promise.resolve().then(()=>(oU(),aU)),Promise.resolve().then(()=>(sp(),np))]),await super._importShadersAsync()}getEffectName(){return n.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._engine.createEffect("glowMapMerge",[M.PositionKind],["offset"],["textureSampler"],this._options.isStroke?`#define STROKE +`:void 0,void 0,void 0,void 0,void 0,this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0})}_createTextureAndPostProcesses(){this._options.alphaBlendingMode===2?(this._downSamplePostprocess=new _s("HighlightLayerPPP",this._scene.getEngine()),this._horizontalBlurPostprocess=new Rn("HighlightLayerHBP",this._scene.getEngine(),new _e(1,0),this._options.blurHorizontalSize),this._verticalBlurPostprocess=new Rn("HighlightLayerVBP",this._scene.getEngine(),new _e(0,1),this._options.blurVerticalSize),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new Ki("HighlightLayerHBP",this._scene.getEngine(),new _e(1,0),this._options.blurHorizontalSize/2),this._verticalBlurPostprocess=new Ki("HighlightLayerVBP",this._scene.getEngine(),new _e(0,1),this._options.blurVerticalSize/2),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess])}needStencil(){return!0}isReady(e,t){let i=e.getMaterial(),r=e.getRenderingMesh();if(!i||!r||!this._meshes)return!1;let s=null,a=this._meshes[r.uniqueId];return a&&a.glowEmissiveOnly&&i&&(s=i.emissiveTexture),super._isSubMeshReady(e,t,s)}_canRenderMesh(e,t){return!0}_internalCompose(e,t){this.bindTexturesForCompose(e);let i=this._engine;i.cacheStencilState(),i.setStencilOperationPass(7681),i.setStencilOperationFail(7680),i.setStencilOperationDepthFail(7680),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference<<8-this.numStencilBits),i.setStencilFunctionMask(255-((1<<8-this.numStencilBits)-1)),this.outerGlow&&t===0&&(e.setFloat("offset",0),i.setStencilFunction(517),i.drawElementsType(ae.TriangleFillMode,0,6)),this.innerGlow&&t===1&&(e.setFloat("offset",1),i.setStencilFunction(514),i.drawElementsType(ae.TriangleFillMode,0,6)),i.restoreStencilState()}_setEmissiveTextureAndColor(e,t,i){let r=this._meshes[e.uniqueId];r?this._emissiveTextureAndColor.color.set(r.color.r,r.color.g,r.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),r&&r.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null}shouldRender(){return!!(this._meshes&&super.shouldRender())}_shouldRenderMesh(e){return this._excludedMeshes&&this._excludedMeshes[e.uniqueId]?!1:super.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define HIGHLIGHT")}addExcludedMesh(e){if(!this._excludedMeshes)return;if(!this._excludedMeshes[e.uniqueId]){let i={mesh:e,beforeBind:null,afterRender:null,stencilState:!1};i.beforeBind=e.onBeforeBindObservable.add(r=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||(i.stencilState=r.getEngine().getStencilBuffer(),r.getEngine().setStencilBuffer(!1))}),i.afterRender=e.onAfterRenderObservable.add(r=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||r.getEngine().setStencilBuffer(i.stencilState)}),this._excludedMeshes[e.uniqueId]=i}}removeExcludedMesh(e){if(!this._excludedMeshes)return;let 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]}addMesh(e,t,i=!1){if(!this._meshes)return;let r=this._meshes[e.uniqueId];r?r.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeBindObservable.add(s=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&(this._excludedMeshes&&this._excludedMeshes[s.uniqueId]?this._defaultStencilReference(s):s.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference<<8-this.numStencilBits))}),observerDefault:e.onAfterRenderObservable.add(s=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&this._defaultStencilReference(s)}),glowEmissiveOnly:i},e.onDisposeObservable.add(()=>{this._disposeMesh(e)})),this._shouldRender=!0}removeMesh(e){if(!this._meshes)return;let 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(let i in this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}removeAllMeshes(){if(this._meshes){for(let e in this._meshes)if(Object.prototype.hasOwnProperty.call(this._meshes,e)){let t=this._meshes[e];t&&this.removeMesh(t.mesh)}}}_defaultStencilReference(e){e.getScene().getEngine().setStencilFunctionReference(n.NormalMeshStencilReference<<8-this.numStencilBits)}_disposeMesh(e){this.removeMesh(e),this.removeExcludedMesh(e)}dispose(){if(this._meshes){for(let e in this._meshes){let 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(let e in this._excludedMeshes){let 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()}};Zn.EffectName="HighlightLayer";Zn.NeutralColor=new Ne(0,0,0,0);Zn.GlowingMeshStencilReference=2;Zn.NormalMeshStencilReference=1});var op,Cr,cU=A(()=>{Qe();qe();ft();sr();ve();oi();_a();ps();j_();Uv();eA();ze();Lt();et();lU();Kt();Dn();ap();st.prototype.getHighlightLayerByName=function(n){var e;for(let t=0;t<((e=this.effectLayers)==null?void 0:e.length);t++)if(this.effectLayers[t].name===n&&this.effectLayers[t].getEffectName()===Cr.EffectName)return this.effectLayers[t];return null};op=class extends gt{constructor(e,t,i,r,s=null,a=ne.BILINEAR_SAMPLINGMODE,o,l){let c={uniforms:Rn.Uniforms,size:typeof r=="number"?r:void 0,camera:s,samplingMode:a,engine:o,reusable:l,...r};super(e,Rn.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new Rn(e,o,t,i,c):void 0,...c}),this.direction=t,this.kernel=i,this.onApplyObservable.add(()=>{this._effectWrapper.textureWidth=this.width,this._effectWrapper.textureHeight=this.height})}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(rp(),ip)))):t.push(Promise.resolve().then(()=>(sp(),np))),super._gatherImports(e,t)}},Cr=class n extends pr{static get NeutralColor(){return Zn.NeutralColor}static set NeutralColor(e){Zn.NeutralColor=e}get innerGlow(){return this._thinEffectLayer.innerGlow}set innerGlow(e){this._thinEffectLayer.innerGlow=e}get outerGlow(){return this._thinEffectLayer.outerGlow}set outerGlow(e){this._thinEffectLayer.outerGlow=e}set blurHorizontalSize(e){this._thinEffectLayer.blurHorizontalSize=e}set blurVerticalSize(e){this._thinEffectLayer.blurVerticalSize=e}get blurHorizontalSize(){return this._thinEffectLayer.blurHorizontalSize}get blurVerticalSize(){return this._thinEffectLayer.blurVerticalSize}get numStencilBits(){return this._thinEffectLayer.numStencilBits}set numStencilBits(e){this._thinEffectLayer.numStencilBits=e}get stencilReference(){return this._thinEffectLayer.stencilReference}constructor(e,t,i){super(e,t,i!==void 0?!!i.forceGLSL:!1,new Zn(e,t,i)),this.onBeforeBlurObservable=new Y,this.onAfterBlurObservable=new Y,this._engine.isStencilEnable||W.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,mainTextureFixedSize:0,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:2,camera:null,renderingGroupId:-1,mainTextureType:0,mainTextureFormat:5,forceGLSL:!1,isStroke:!1,generateStencilBuffer:!1,...i},this._init(this._options),this._shouldRender=!1}getEffectName(){return n.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._thinEffectLayer._createMergeEffect()}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,t=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;e=this._engine.needPOTTextures?$i(e,this._maxSize):e,t=this._engine.needPOTTextures?$i(t,this._maxSize):t;let i;this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture=new ri("HighlightLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,i),this._blurTexture.wrapU=ne.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=ne.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(ne.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._thinEffectLayer.bindTexturesForCompose=r=>{r.setTexture("textureSampler",this._blurTexture)},this._thinEffectLayer._createTextureAndPostProcesses(),this._options.alphaBlendingMode===2?(this._downSamplePostprocess=new vo("HighlightLayerPPP",{size:this._options.blurTextureSizeRatio,samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[0]}),this._downSamplePostprocess.externalTextureSamplerBinding=!0,this._downSamplePostprocess.onApplyObservable.add(r=>{r.setTexture("textureSampler",this._mainTexture)}),this._horizontalBlurPostprocess=new op("HighlightLayerHBP",new _e(1,0),this._options.blurHorizontalSize,{samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[1]}),this._horizontalBlurPostprocess.onApplyObservable.add(r=>{r.setFloat2("screenSize",e,t)}),this._verticalBlurPostprocess=new op("HighlightLayerVBP",new _e(0,1),this._options.blurVerticalSize,{samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),effectWrapper:this._thinEffectLayer._postProcesses[2]}),this._verticalBlurPostprocess.onApplyObservable.add(r=>{r.setFloat2("screenSize",e,t)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new jr("HighlightLayerHBP",new _e(1,0),this._options.blurHorizontalSize/2,{size:{width:e,height:t},samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),textureType:i,effectWrapper:this._thinEffectLayer._postProcesses[0]}),this._horizontalBlurPostprocess.width=e,this._horizontalBlurPostprocess.height=t,this._horizontalBlurPostprocess.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess.onApplyObservable.add(r=>{r.setTexture("textureSampler",this._mainTexture)}),this._verticalBlurPostprocess=new jr("HighlightLayerVBP",new _e(0,1),this._options.blurVerticalSize/2,{size:{width:e,height:t},samplingMode:ne.BILINEAR_SAMPLINGMODE,engine:this._scene.getEngine(),textureType:i}),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add(()=>{this.onBeforeBlurObservable.notifyObservers(this);let r=this._blurTexture.renderTarget;r&&(this._scene.postProcessManager.directRender(this._postProcesses,r,!0),this._engine.unBindFramebuffer(r,!0)),this.onAfterBlurObservable.notifyObservers(this)}),this._postProcesses.map(r=>{r.autoClear=!1}),this._mainTextureCreatedSize.width=this._mainTextureDesiredSize.width,this._mainTextureCreatedSize.height=this._mainTextureDesiredSize.height}needStencil(){return this._thinEffectLayer.needStencil()}isReady(e,t){return this._thinEffectLayer.isReady(e,t)}_internalRender(e,t){this._thinEffectLayer._internalCompose(e,t)}shouldRender(){return this._thinEffectLayer.shouldRender()}_shouldRenderMesh(e){return this._thinEffectLayer._shouldRenderMesh(e)}_canRenderMesh(e,t){return this._thinEffectLayer._canRenderMesh(e,t)}_addCustomEffectDefines(e){this._thinEffectLayer._addCustomEffectDefines(e)}_setEmissiveTextureAndColor(e,t,i){this._thinEffectLayer._setEmissiveTextureAndColor(e,t,i)}addExcludedMesh(e){this._thinEffectLayer.addExcludedMesh(e)}removeExcludedMesh(e){this._thinEffectLayer.removeExcludedMesh(e)}hasMesh(e){return this._thinEffectLayer.hasMesh(e)}addMesh(e,t,i=!1){this._thinEffectLayer.addMesh(e,t,i)}removeMesh(e){this._thinEffectLayer.removeMesh(e)}removeAllMeshes(){this._thinEffectLayer.removeAllMeshes()}_disposeMesh(e){this._thinEffectLayer._disposeMesh(e)}getClassName(){return"HighlightLayer"}serialize(){let e=Me.Serialize(this);e.customType="BABYLON.HighlightLayer",e.meshes=[];let t=this._thinEffectLayer._meshes;if(t)for(let r in t){let s=t[r];s&&e.meshes.push({glowEmissiveOnly:s.glowEmissiveOnly,color:s.color.asArray(),meshId:s.mesh.id})}e.excludedMeshes=[];let i=this._thinEffectLayer._excludedMeshes;if(i)for(let r in i){let s=i[r];s&&e.excludedMeshes.push(s.mesh.id)}return e}static Parse(e,t,i){let r=Me.Parse(()=>new n(e.name,t,e.options),e,t,i),s;for(s=0;s{Gn();vl();eA();At();nT();ym(be.NAME_EFFECTLAYER,(n,e,t,i)=>{if(n.effectLayers){t.effectLayers||(t.effectLayers=[]);for(let r=0;r0){this._previousStencilState=this._engine.getStencilBuffer();for(let r of i)if(r.shouldRender()&&(!r.camera||r.camera.cameraRigMode===Ue.RIG_MODE_NONE&&e===r.camera||r.camera.cameraRigMode!==Ue.RIG_MODE_NONE&&r.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||r.needStencil();let s=r._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1),t=!0)}this.scene.incrementRenderId()}return t}_setStencil(){this._needStencil&&this._engine.setStencilBuffer(!0)}_setStencilBack(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)}_draw(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);let t=this.scene.effectLayers;for(let i=0;i{let e=n._getComponent(be.NAME_EFFECTLAYER);e||(e=new sA(n),n._addComponent(e))}});function dU(n,e){let t=new Cr("ai3d-pick-highlight",n),i=new oe(.15,.45,1);function r(){t.removeAllMeshes()}function s(o){o.isDisposed()||t.addMesh(o,i)}let a=n.onPointerObservable.add(o=>{var h;if(o.type!==ye.POINTERDOWN)return;let l=o.event,c=l.clientX,f=l.clientY;r();let d=o.pickInfo;d!=null&&d.hit&&d.pickedMesh?(s(d.pickedMesh),e({mesh:d.pickedMesh,pickedPoint:(h=d.pickedPoint)!=null?h:null,screenX:c,screenY:f})):e({mesh:null,pickedPoint:null,screenX:c,screenY:f})});return()=>{r(),t.dispose(),n.onPointerObservable.remove(a)}}var hU=A(()=>{"use strict";dn();et();cU();fU()});function nd(n){let e=new Uint8Array(n),t=32768,i=[];for(let r=0;r{"use strict"});function Qt(){return uU.Platform.isMobile}var uU,qr=A(()=>{"use strict";uU=require("obsidian")});function YY(){if("require"in activeWindow)return activeWindow.require}function lp(){if("process"in activeWindow)return activeWindow.process}function sd(n){let e=YY();if(!e)return null;try{return e(n)}catch(t){return null}}function br(n,e){if(n===null)throw new Error(`${e} is not available in this environment (mobile or web).`);return n}function _r(n,e){return br(ad,"node:fs/promises").access(n,e)}function Qr(n){return br(ad,"node:fs/promises").readFile(n)}function Ic(n,e,t){return br(ad,"node:fs/promises").writeFile(n,e,{encoding:t})}function xc(n,e){return br(ad,"node:fs/promises").mkdir(n,e)}function Cc(n,e){return br(ad,"node:fs/promises").rm(n,e)}function Pt(...n){return br(qs,"node:path").join(...n)}function qn(n){return br(qs,"node:path").dirname(n)}function Qn(n,e){return br(qs,"node:path").basename(n,e)}function Jr(n){return br(qs,"node:path").extname(n)}function oA(n){return br(qs,"node:path").normalize(n)}function qi(n){return br(qs,"node:path").isAbsolute(n)}function $r(n,e,t,i){br(KY,"node:child_process").execFile(n,e,t,i)}function bc(){return br(jY,"node:os").tmpdir()}var ad,Rc,qs,KY,jY,mU,gr,pU,gU,_U,EU,Gt=A(()=>{"use strict";ad=sd("node:fs/promises"),Rc=sd("node:fs"),qs=sd("node:path"),KY=sd("node:child_process"),jY=sd("node:os");gr=(mU=Rc==null?void 0:Rc.constants.F_OK)!=null?mU:0,gU=(pU=Rc==null?void 0:Rc.constants.X_OK)!=null?pU:0;EU=(_U=qs==null?void 0:qs.delimiter)!=null?_U:":"});function TU(n){return n.replace(/\\/g,"/")}function SU(n){let e=TU(n).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function cp(n){let e=TU(n).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Mr(n){return cp(n).replace(/\.[^.]+$/,"")}function ZY(n){return Uint8Array.from(n).buffer}function qY(n){let e=n.vault.adapter;return typeof e.getBasePath=="function"?e.getBasePath():typeof e.basePath=="string"&&e.basePath.length>0?e.basePath:null}function Mc(n,e){var r,s;let t=n.vault.getAbstractFileByPath(e);if(t)return t.path;let i=(s=(r=n.metadataCache)==null?void 0:r.getFirstLinkpathDest)==null?void 0:s.call(r,e,"");return i?i.path:null}function Qs(n,e){if(qi(e))return oA(e);let t=qY(n);return t?oA(Pt(t,e)):null}async function yr(n,e){if(qi(e)){let i=await Qr(e);return ZY(i)}let t=n.vault.getAbstractFileByPath(e);if(!(t instanceof vU.TFile))throw new Error(`File not found: ${e}`);return n.vault.readBinary(t)}var vU,Js=A(()=>{"use strict";vU=require("obsidian");Gt();Gt()});function r8(n,e,t){let i=oe.FromHexString(e),r=new Re(n,t);return r.emissiveColor=i,r.diffuseColor=oe.Black(),r.specularColor=oe.Black(),r.backFaceCulling=!1,r}function n8(n){let e=new Re("gizmo-origin-mat",n);return e.emissiveColor=new oe(.72,.78,.86),e.diffuseColor=oe.Black(),e.specularColor=oe.Black(),e}var QY,fp,JY,cA,$Y,e8,lA,t8,i8,dp,AU=A(()=>{"use strict";sr();hu();uu();ve();et();dl();ov();Xs();QY=.32,fp=1.05,JY=.075,cA=.28,$Y=.22,e8=.16,lA=(fp+cA)*.42,t8=new v(lA,lA,lA),i8=[{name:"x",color:"#e74c3c",rot:new v(0,0,-Math.PI/2),dir:new v(1,0,0)},{name:"y",color:"#2ecc71",rot:new v(0,0,0),dir:new v(0,1,0)},{name:"z",color:"#3498db",rot:new v(Math.PI/2,0,0),dir:new v(0,0,1)}];dp=class{constructor(e,t){this.engine=e,this.scene=new st(e),this.scene.clearColor=new Ne(0,0,0,0),this.scene.autoClear=!1,this.camera=new ut("gizmo-cam",0,0,4.1,t8,this.scene),this.camera.minZ=.01,this.camera.fov=.56,this.camera.detachControl(),new Rr("gizmo-light",new v(0,1,.5),this.scene);let i=zs.CreateSphere("gizmo-origin",{diameter:e8,segments:16},this.scene);i.material=n8(this.scene);for(let{name:s,color:a,rot:o,dir:l}of i8){let c=r8(`gizmo-${s}-mat`,a,this.scene),f=zs.CreateCylinder(`gizmo-${s}-shaft`,{height:fp,diameter:JY,tessellation:8},this.scene);f.material=c,f.position=l.scale(fp/2),f.rotation=o;let d=zs.CreateCylinder(`gizmo-${s}-head`,{height:cA,diameterTop:0,diameterBottom:$Y,tessellation:8},this.scene);d.material=c;let h=fp+cA/2;d.position=l.scale(h),d.rotation=o}let r=QY;this.viewport=new an(.02,.03,r,r),this.camera.viewport=this.viewport,this.syncWith(t)}syncWith(e){this.camera.alpha=e.alpha,this.camera.beta=e.beta}render(){let e=this.engine.getRenderWidth(),t=this.engine.getRenderHeight(),i=this.viewport.x*e,r=this.viewport.y*t,s=this.viewport.width*e,a=this.viewport.height*t;this.engine.enableScissor(i,r,s,a),this.engine.clear(null,!1,!0,!0),this.scene.render(),this.engine.disableScissor()}dispose(){this.scene.dispose()}}});function up(n,e,t,i,r,s=!1){let a=di.Zero();return od(n,e,t,i,a,r,s),a}function od(n,e,t,i,r,s,a=!1,o=!1){let l=n.getEngine();if(!s&&!(s=n.activeCamera)&&!(s=n.cameraToUseForPointers))return n;let c=s.viewport,f=l.getRenderHeight(),{x:d,y:h,width:u,height:m}=c.toGlobal(l.getRenderWidth(),f),p=1/l.getHardwareScalingLevel();return e=e*p-d,t=t*p-(f-h-m),r.update(e,t,u,m,i||U.IdentityReadOnly,a?U.IdentityReadOnly:s.getViewMatrix(),s.getProjectionMatrix(),o),n}function xU(n,e,t,i){let r=di.Zero();return fA(n,e,t,r,i),r}function fA(n,e,t,i,r){if(!Xi)return n;let s=n.getEngine();if(!r&&!(r=n.activeCamera)&&!(r=n.cameraToUseForPointers))throw new Error("Active camera not set");let a=r.viewport,o=s.getRenderHeight(),{x:l,y:c,width:f,height:d}=a.toGlobal(s.getRenderWidth(),o),h=U.Identity(),u=1/s.getHardwareScalingLevel();return e=e*u-l,t=t*u-(o-c-d),i.update(e,t,f,d,h,h,r.getProjectionMatrix()),n}function hp(n,e,t,i,r,s,a,o){let l=e(i,t.enableDistantPicking);return dA(n,t,i,l,r,s,a,o)}function dA(n,e,t,i,r,s,a,o){let l=e.intersects(i,r,a,s,t,o);return!l||!l.hit||!r&&n!=null&&l.distance>=n.distance?null:l}function s8(n,e){return n==="InstancedLinesMesh"||n==="LinesMesh"?e.intersectionThreshold:0}function CU(n){let e=n.getClassName();if(e==="GreasedLineMesh")return{rawBoundingInfo:null,intersectionThreshold:0};let t=n.rawBoundingInfo;return{rawBoundingInfo:t,intersectionThreshold:t?s8(e,n):0}}function bU(n,e,t,i,r){let s=n(t,e.enableDistantPicking);return!s.intersectsSphere(i.boundingSphere,r)||!s.intersectsBox(i.boundingBox,r)?null:s}function hA(n,e,t,i,r,s){let a=null,o=!!(n.activeCameras&&n.activeCameras.length>1&&n.cameraToUseForPointers!==n.activeCamera),l=n.cameraToUseForPointers||n.activeCamera,c=IU.internalPickerForMesh||hp,f=c===hp;for(let d=0;d>4);for(let I=0;I1&&n.cameraToUseForPointers!==n.activeCamera),a=n.cameraToUseForPointers||n.activeCamera,o=IU.internalPickerForMesh||hp,l=o===hp;for(let c=0;c>4);for(let R=0;R(n._tempPickingRay||(n._tempPickingRay=di.Zero()),od(n,e,t,o,n._tempPickingRay,s||null),n._tempPickingRay),i,r,!0);return a&&(a.ray=up(n,e,t,U.Identity(),s||null)),a}function DU(n,e,t,i,r,s,a,o=!1){let l=hA(n,(c,f)=>(n._tempPickingRay||(n._tempPickingRay=di.Zero()),od(n,e,t,c,n._tempPickingRay,s||null,!1,f),n._tempPickingRay),i,r,!1,a);return l&&(l.ray=up(n,e,t,U.Identity(),s||null)),l}function LU(n,e,t,i,r){let s=hA(n,a=>(n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=U.Identity()),a.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=di.Zero()),di.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform),t,i,!1,r);return s&&(s.ray=e),s}function PU(n,e,t,i,r,s){return MU(n,a=>up(n,e,t,a,r||null),i,s)}function OU(n,e,t,i){return MU(n,r=>(n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=U.Identity()),r.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=di.Zero()),di.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform),t,i)}function RU(n,e,t=100,i,r){i||(i=n.getWorldMatrix()),e.length=t,r?e.origin.copyFrom(r):e.origin.copyFrom(n.position);let s=G.Vector3[2];s.set(0,0,n._scene.useRightHandedSystem?-1:1);let a=G.Vector3[3];return v.TransformNormalToRef(s,i,a),v.NormalizeToRef(a,e.direction),e}function NU(n,e){e&&(e.prototype.getForwardRay=function(t=100,i,r){return RU(this,new di(v.Zero(),v.Zero(),t),t,i,r)},e.prototype.getForwardRayToRef=function(t,i=100,r,s){return RU(this,t,i,r,s)}),n&&(Ro._IsPickingAvailable=!0,n.prototype.createPickingRay=function(t,i,r,s,a=!1){return up(this,t,i,r,s,a)})}var IU,di,uA=A(()=>{bi();ve();Ln();rE();af();At();fg();IU={internalPickerForMesh:void 0},di=class n{constructor(e,t,i=Number.MAX_VALUE,r=Ye){this.origin=e,this.direction=t,this.length=i,this.epsilon=r}clone(){return new n(this.origin.clone(),this.direction.clone(),this.length)}intersectsBoxMinMax(e,t,i=0){let r=n._TmpVector3[0].copyFromFloats(e.x-i,e.y-i,e.z-i),s=n._TmpVector3[1].copyFromFloats(t.x+i,t.y+i,t.z+i),a=0,o=Number.MAX_VALUE,l,c,f,d;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xs.x)return!1}else if(l=1/this.direction.x,c=(r.x-this.origin.x)*l,f=(s.x-this.origin.x)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.ys.y)return!1}else if(l=1/this.direction.y,c=(r.y-this.origin.y)*l,f=(s.y-this.origin.y)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zs.z)return!1}else if(l=1/this.direction.z,c=(r.z-this.origin.z)*l,f=(s.z-this.origin.z)*l,f===-1/0&&(f=1/0),c>f&&(d=c,c=f,f=d),a=Math.max(c,a),o=Math.min(f,o),a>o)return!1;return!0}intersectsBox(e,t=0){return this.intersectsBoxMinMax(e.minimum,e.maximum,t)}intersectsSphere(e,t=0){let i=e.center.x-this.origin.x,r=e.center.y-this.origin.y,s=e.center.z-this.origin.z,a=i*i+r*r+s*s,o=e.radius+t,l=o*o;if(a<=l)return!0;let c=i*this.direction.x+r*this.direction.y+s*this.direction.z;return c<0?!1:a-c*c<=l}intersectsTriangle(e,t,i){let r=n._TmpVector3[0],s=n._TmpVector3[1],a=n._TmpVector3[2],o=n._TmpVector3[3],l=n._TmpVector3[4];t.subtractToRef(e,r),i.subtractToRef(e,s),v.CrossToRef(this.direction,s,a);let c=v.Dot(r,a);if(c===0)return null;let f=1/c;this.origin.subtractToRef(e,o);let d=v.Dot(o,a)*f;if(d<-this.epsilon||d>1+this.epsilon)return null;v.CrossToRef(o,r,l);let h=v.Dot(this.direction,l)*f;if(h<-this.epsilon||d+h>1+this.epsilon)return null;let u=v.Dot(s,l)*f;return u>this.length||u<0?null:new xo(1-d-h,d,u)}intersectsPlane(e){let t,i=v.Dot(e.normal,this.direction);if(Math.abs(i)<999999997475243e-21)return null;{let r=v.Dot(e.normal,this.origin);return t=(-e.d-r)/i,t<0?t<-999999997475243e-21?null:0:t}}intersectsAxis(e,t=0){switch(e){case"y":{let 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":{let 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":{let 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,r=!1,s,a=!1){let o=G.Matrix[0];return e.getWorldMatrix().invertToRef(o),this._tmpRay?n.TransformToRef(this,o,this._tmpRay):this._tmpRay=n.Transform(this,o),e.intersects(this._tmpRay,t,i,r,s,a)}intersectsMeshes(e,t,i){i?i.length=0:i=[];for(let r=0;rt.distance?1:0}intersectionSegment(e,t,i){let r=this.origin,s=G.Vector3[0],a=G.Vector3[1],o=G.Vector3[2],l=G.Vector3[3];t.subtractToRef(e,s),this.direction.scaleToRef(n._Rayl,o),r.addToRef(o,a),e.subtractToRef(r,l);let c=v.Dot(s,s),f=v.Dot(s,o),d=v.Dot(o,o),h=v.Dot(s,l),u=v.Dot(o,l),m=c*d-f*f,p,_=m,g,T=m;m_&&(p=_,g=u+f,T=d)),g<0?(g=0,-h<0?p=0:-h>c?p=_:(p=-h,_=c)):g>T&&(g=T,-h+f<0?p=0:-h+f>c?p=_:(p=-h+f,_=c));let b=Math.abs(p)0&&R<=this.length&&x.lengthSquared(){sr();Gn();uA();uA();NU(st,Ue);st.prototype.createPickingRayToRef=function(n,e,t,i,r,s=!1,a=!1){return od(this,n,e,t,i,r,s,a)};st.prototype.createPickingRayInCameraSpace=function(n,e,t){return xU(this,n,e,t)};st.prototype.createPickingRayInCameraSpaceToRef=function(n,e,t,i){return fA(this,n,e,t,i)};st.prototype.pickWithBoundingInfo=function(n,e,t,i,r){return yU(this,n,e,t,i,r)};st.prototype.pick=function(n,e,t,i,r,s,a=!1){return DU(this,n,e,t,i,r,s,a)};st.prototype.pickWithRay=function(n,e,t,i){return LU(this,n,e,t,i)};st.prototype.multiPick=function(n,e,t,i,r){return PU(this,n,e,t,i,r)};st.prototype.multiPickWithRay=function(n,e,t){return OU(this,n,e,t)}});var _A={};De(_A,{boundingBoxRendererVertexShaderWGSL:()=>a8});var pA,FU,a8,gA=A(()=>{N();pA="boundingBoxRendererVertexShader",FU=`attribute position: vec3f;uniform world: mat4x4f;uniform viewProjection: mat4x4f; #ifdef INSTANCES attribute world0 : vec4;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4; #endif @@ -19651,18 +19651,18 @@ var worldPos: vec4f=uniforms.world* vec4f(vertexInputs.position,1.0); vertexOutputs.position=uniforms.viewProjection*worldPos; #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStoreWGSL[lA]||(E.ShadersStoreWGSL[lA]=_U);GY={name:lA,shader:_U}});var hA={};De(hA,{boundingBoxRendererPixelShaderWGSL:()=>kY});var dA,gU,kY,uA=A(()=>{N();dA="boundingBoxRendererPixelShader",gU=`uniform color: vec4f; +`;E.ShadersStoreWGSL[pA]||(E.ShadersStoreWGSL[pA]=FU);a8={name:pA,shader:FU}});var vA={};De(vA,{boundingBoxRendererPixelShaderWGSL:()=>o8});var EA,wU,o8,TA=A(()=>{N();EA="boundingBoxRendererPixelShader",wU=`uniform color: vec4f; #define CUSTOM_FRAGMENT_DEFINITIONS @fragment fn main(input: FragmentInputs)->FragmentOutputs { #define CUSTOM_FRAGMENT_MAIN_BEGIN fragmentOutputs.color=uniforms.color; #define CUSTOM_FRAGMENT_MAIN_END -}`;E.ShadersStoreWGSL[dA]||(E.ShadersStoreWGSL[dA]=gU);kY={name:dA,shader:gU}});var EU,WY,vU=A(()=>{N();EU="boundingBoxRendererVertexDeclaration",WY=`uniform mat4 world;uniform mat4 viewProjection; +}`;E.ShadersStoreWGSL[EA]||(E.ShadersStoreWGSL[EA]=wU);o8={name:EA,shader:wU}});var BU,l8,UU=A(()=>{N();BU="boundingBoxRendererVertexDeclaration",l8=`uniform mat4 world;uniform mat4 viewProjection; #ifdef MULTIVIEW uniform mat4 viewProjectionR; #endif -`;E.IncludesShadersStore[EU]||(E.IncludesShadersStore[EU]=WY)});var TU,HY,mA=A(()=>{N();TU="boundingBoxRendererUboDeclaration",HY=`#ifdef WEBGL2 +`;E.IncludesShadersStore[BU]||(E.IncludesShadersStore[BU]=l8)});var VU,c8,SA=A(()=>{N();VU="boundingBoxRendererUboDeclaration",c8=`#ifdef WEBGL2 uniform vec4 color;uniform mat4 world;uniform mat4 viewProjection; #ifdef MULTIVIEW uniform mat4 viewProjectionR; @@ -19670,7 +19670,7 @@ uniform mat4 viewProjectionR; #else layout(std140,column_major) uniform;uniform BoundingBoxRenderer {vec4 color;mat4 world;mat4 viewProjection;mat4 viewProjectionR;}; #endif -`;E.IncludesShadersStore[TU]||(E.IncludesShadersStore[TU]=HY)});var _A={};De(_A,{boundingBoxRendererVertexShader:()=>zY});var pA,SU,zY,gA=A(()=>{N();vU();mA();pA="boundingBoxRendererVertexShader",SU=`attribute vec3 position; +`;E.IncludesShadersStore[VU]||(E.IncludesShadersStore[VU]=c8)});var RA={};De(RA,{boundingBoxRendererVertexShader:()=>f8});var AA,GU,f8,IA=A(()=>{N();UU();SA();AA="boundingBoxRendererVertexShader",GU=`attribute vec3 position; #include<__decl__boundingBoxRendererVertex> #ifdef INSTANCES attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; @@ -19690,29 +19690,29 @@ gl_Position=viewProjection*worldPos; #endif #define CUSTOM_VERTEX_MAIN_END } -`;E.ShadersStore[pA]||(E.ShadersStore[pA]=SU);zY={name:pA,shader:SU}});var AU,XY,RU=A(()=>{N();AU="boundingBoxRendererFragmentDeclaration",XY=`uniform vec4 color; -`;E.IncludesShadersStore[AU]||(E.IncludesShadersStore[AU]=XY)});var vA={};De(vA,{boundingBoxRendererPixelShader:()=>YY});var EA,IU,YY,TA=A(()=>{N();RU();mA();EA="boundingBoxRendererPixelShader",IU=`#include<__decl__boundingBoxRendererFragment> +`;E.ShadersStore[AA]||(E.ShadersStore[AA]=GU);f8={name:AA,shader:GU}});var kU,d8,WU=A(()=>{N();kU="boundingBoxRendererFragmentDeclaration",d8=`uniform vec4 color; +`;E.IncludesShadersStore[kU]||(E.IncludesShadersStore[kU]=d8)});var CA={};De(CA,{boundingBoxRendererPixelShader:()=>h8});var xA,HU,h8,bA=A(()=>{N();WU();SA();xA="boundingBoxRendererPixelShader",HU=`#include<__decl__boundingBoxRendererFragment> #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN gl_FragColor=color; #define CUSTOM_FRAGMENT_MAIN_END -}`;E.ShadersStore[EA]||(E.ShadersStore[EA]=IU);YY={name:EA,shader:IU}});var bU,xU,dp,KY,jY,CU,SA,MU=A(()=>{gr();yt();Dl();ve();on();El();tE();Ni();wE();et();ct();go();ma();bE();Mn();ze();Object.defineProperty(gt.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(n){this._forceShowBoundingBoxes=n,n&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0});gt.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new SA(this)),this._boundingBoxRenderer};Object.defineProperty(zt.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(n){this._showBoundingBox=n,n&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});bU=G.Identity(),xU=new G,dp=new v,KY=new v,jY=bU.asArray(),CU=new va(dp,dp),SA=class{get shaderLanguage(){return this._shaderLanguage}constructor(e){this.name=be.NAME_BOUNDINGBOXRENDERER,this.frontColor=new oe(1,1,1),this.backColor=new oe(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new Y,this.onAfterBoxRenderingObservable=new Y,this.onResourcesReadyObservable=new Y,this.enabled=!0,this._shaderLanguage=0,this.renderList=new Ct(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this._matrixBuffer=null,this._matrices=null,this._useInstances=!1,this._drawWrapperFront=null,this._drawWrapperBack=null,this.scene=e,this.scene.getEngine().isWebGPU&&(this._shaderLanguage=1),e._addComponent(this),this._uniformBufferFront=new Ut(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!0),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new Ut(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack",!0),this._buildUniformLayout(this._uniformBufferBack)}_buildUniformLayout(e){e.addUniform("color",4),e.addUniform("world",16),e.addUniform("viewProjection",16),e.addUniform("viewProjectionR",16),e.create()}register(){this.scene._beforeEvaluateActiveMeshStage.registerStep(be.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(be.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(be.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(be.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)}async whenReadyAsync(e=16,t=3e4){return this._prepareResources(),await new Promise(i=>{bn(()=>this._colorShader.isReady(),()=>{i()},(r,s)=>{s?(W.Error("BoundingBoxRenderer: Timeout while waiting for the renderer to be ready."),r&&W.Error(r)):(W.Error("BoundingBoxRenderer: An unexpected error occurred while waiting for the renderer to be ready."),r&&(W.Error(r),r.stack&&W.Error(r.stack)))},e,t)})}_evaluateSubMesh(e,t){if(e.showSubMeshesBoundingBox){let i=t.getBoundingInfo();i!=null&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}}_preActiveMesh(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){let t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}}_prepareResources(){if(this._colorShader)return;this._colorShader=new vn("colorShader",this.scene,"boundingBoxRenderer",{attributes:[M.PositionKind,"world0","world1","world2","world3"],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(fA(),cA)),Promise.resolve().then(()=>(uA(),hA))]):await Promise.all([Promise.resolve().then(()=>(gA(),_A)),Promise.resolve().then(()=>(TA(),vA))])}},!1),this._colorShader.setDefine("INSTANCES",this._useInstances),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new vn("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[M.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(fA(),cA)),Promise.resolve().then(()=>(uA(),hA))]):await Promise.all([Promise.resolve().then(()=>(gA(),_A)),Promise.resolve().then(()=>(TA(),vA))])}},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};let e=this.scene.getEngine(),t=mu({size:1});this._vertexBuffers[M.PositionKind]=new M(e,t.positions,M.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}_createIndexBuffer(){let e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}rebuild(){let e=this._vertexBuffers[M.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this._matrixBuffer&&this._matrixBuffer._rebuild()}reset(){this.renderList.reset()}render(e){var r,s;if(this.renderList.length===0||!this.enabled)return;if(this._useInstances){this._renderInstanced(e);return}if(this._prepareResources(),!this._colorShader.isReady())return;let t=this.scene.getEngine();t.setDepthWrite(!1);let i=this.scene.getTransformMatrix();for(let a=0;ar*2)&&(i=new Float32Array(r),this._matrices=i),this.onBeforeBoxRenderingObservable.notifyObservers(CU);let s=0,a=this.scene.floatingOriginOffset;for(let g=0;g{"use strict";ve();oA();et();fo();fn();MU();yc=class yc{constructor(e,t,i){this.originals=new Map;this.observer=null;this.renderObserver=null;this.frameCount=0;this.lastOccluded=!1;this.active=!1;this.drag=null;this.selected=null;var s;this.scene=e,this.camera=t,this.meshes=i;let r=(s=e.getBoundingBoxRenderer)==null?void 0:s.call(e);r&&(r.frontColor=new oe(.25,.7,1),r.backColor=new oe(.25,.7,1));for(let a of i)this.originals.set(a.uniqueId,this.captureTransform(a))}setEnabled(e){return this.active===e?this.active:(this.active=e,this.drag=null,this.setSelected(null),e?(this.observer=this.scene.onPointerObservable.add(t=>{var r,s;let i=t.event;t.type===ye.POINTERDOWN?this.startDrag((s=(r=t.pickInfo)==null?void 0:r.pickedMesh)!=null?s:null,i):t.type===ye.POINTERMOVE?this.updateDrag(i):t.type===ye.POINTERUP&&this.stopDrag()}),this.renderObserver=this.scene.onAfterRenderCameraObservable.add(t=>{t===this.camera&&this.updateBboxOcclusion()})):(this.observer&&(this.scene.onPointerObservable.remove(this.observer),this.observer=null),this.renderObserver&&(this.scene.onAfterRenderCameraObservable.remove(this.renderObserver),this.renderObserver=null),this.camera.attachControl(this.scene.getEngine().getRenderingCanvas(),!0)),this.active)}toggle(){return this.setEnabled(!this.active)}reset(){var e,t;this.stopDrag(),this.setSelected(null);for(let i of this.meshes){if(i.isDisposed())continue;let r=this.originals.get(i.uniqueId);r&&(i.setParent(r.parent),i.position.copyFrom(r.position),i.rotation.copyFrom(r.rotation),i.rotationQuaternion=(t=(e=r.rotationQuaternion)==null?void 0:e.clone())!=null?t:null,i.scaling.copyFrom(r.scaling),i.computeWorldMatrix(!0))}}dispose(){this.setEnabled(!1),this.originals.clear()}updateBboxOcclusion(){var c,f;if(!this.selected||this.selected.isDisposed()||(this.frameCount++,this.frameCount%3!==0))return;let e=this.selected.getBoundingInfo().boundingBox.centerWorld,t=this.camera.position,i=v.Distance(t,e),r=e.subtract(t).normalize(),s=new Rn(t,r,i),a=this.scene.pickWithRay(s),o=Math.max(i*.01,.01),l=!!(a!=null&&a.hit)&&a.distance$s});function ZY(n){let e=n.getClassName();return e==="DirectionalLight"||e==="PointLight"||e==="SpotLight"}function AA(n){return n.getClassName()==="GaussianSplattingMesh"}function DU(n){return n.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}var hp,$s,ld=A(()=>{"use strict";qg();gr();du();hu();PM();OM();vE();ve();et();nv();Xs();Rm();pO();cE();hc();rd();rd();WS();HS();MB();sU();rA();jr();Js();pU();yU();hp=null;$s=class{constructor(e){this.rootMesh=null;this.loadedMeshes=[];this.loadedExt="";this.rendering=!1;this.cleanupPicking=null;this.configLights=[];this.shadowGenerator=null;this.groundMesh=null;this.gridMesh=null;this.axisMeshes=[];this.autoRotateBehavior=null;this.wireframeEnabled=!1;this.gizmo=null;this.gizmoEnabled=!1;this.disassembly=null;this.disassemblyEnabled=!1;this.bboxMesh=null;this.bboxEnabled=!1;this.currentQuality="high";this.animPlaying=!1;this.initialCamera={alpha:Math.PI/4,beta:Math.PI/3,radius:5,target:v.Zero()};this._lastPickResult={mesh:null,pickedPoint:null,screenX:0,screenY:0};this._onPickCallbacks=[];this.preventCanvasWheelScroll=e=>{e.preventDefault(),e.stopPropagation()};this.engine=new Ee(e,!0,{preserveDrawingBuffer:!0}),this.scene=new gt(this.engine),this.scene.clearColor=new Ne(.12,.12,.14,1),this.camera=new ht("cam",Math.PI/4,Math.PI/3,5,v.Zero(),this.scene),this.camera.attachControl(e,!0),this.camera.lowerRadiusLimit=.1,this.camera.wheelPrecision=30,e.addEventListener("wheel",this.preventCanvasWheelScroll,{passive:!1}),this.scene.ambientColor=new oe(.3,.3,.3);let t=new Sr("default-light",new v(0,1,.5),this.scene);t.intensity=1.2,this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),window.requestAnimationFrame(()=>this.engine.resize())}canRender(){let e=this.engine.getRenderingCanvas();return!!(e!=null&&e.isConnected)&&e.clientWidth>0&&e.clientHeight>0}async loadModel(e,t,i,r){var m,p,_,g,T;await id(),this.rootMesh&&(this.rootMesh.dispose(!0,!0),this.rootMesh=null),this.loadedMeshes=[],(m=this.disassembly)==null||m.dispose(),this.disassembly=null,this.disassemblyEnabled=!1;let s=t.toLowerCase().replace(".","");this.loadedExt=s;let a=this.scene,l=(p={glb:".glb",gltf:".gltf",stl:".stl",obj:".obj",splat:".splat",ply:".ply"}[s])!=null?p:`.${s}`,c=`data:application/octet-stream;base64,${nd(e)}`;if(s==="obj"&&i&&r){hp&&await hp;let b;hp=new Promise(R=>{b=R});try{let{OBJFileLoader:R}=await Promise.resolve().then(()=>(GS(),EB)),S=R.prototype;typeof S._loadMTL!="function"&&console.warn("[AI3D] OBJFileLoader._loadMTL not found \u2014 MTL vault resolution disabled");let I=S._loadMTL,P=new TextDecoder().decode(new Uint8Array(e)).match(/mtllib\s+(.+)/),L=null,y=0,B=0;if(P&&i&&r){let H=P[1].trim().split(/\s+/)[0],O=mU(r),V=O?`${O}/${H}`:H;try{let X=await i(V),Q=new TextDecoder().decode(new Uint8Array(X)).split(` -`),$=/^\s*(map_Kd|map_Ka|map_Ks|map_Ns|map_d|map_bump|bump|disp|decal)\s+(.+)/i,q=Cr(r),z=["jpg","jpeg","png","bmp","tga","webp","tif","tiff"];for(let te=0;tete!=="");if(!K.some(te=>/^\s*Kd\s+/i.test(te))){let te=K.findIndex(Pe=>/^\s*newmtl\s+/i.test(Pe));K.splice(te>=0?te+1:0,0,"Kd 0.80 0.80 0.80")}L=K.join(` -`),console.debug(`[AI3D] MTL: ${V} | textures: ${y} loaded, ${B} missing`)}catch(X){console.debug(`[AI3D] No MTL in vault: ${V}`)}}S._loadMTL=function(H,O,V){let X=L!=null?L:"";console.debug(`[AI3D] _loadMTL called: url=${H}, content_len=${X.length}, has_Kd=${X.includes("Kd")}, has_map=${X.includes("map_")}`),V(X)};let w=await Yf(c,a,{meshNames:"",pluginExtension:l});this.loadedMeshes=w.meshes,w.meshes.length>0&&(this.rootMesh=w.meshes[0]);for(let H of w.meshes){let O=H.material;console.debug(`[AI3D] OBJ mesh "${H.name}" material:`,O?`${O.name} diffuse=${String(O==null?void 0:O.diffuseColor)}`:"NONE")}S._loadMTL=I}catch(R){throw console.error("[AI3D] OBJ load error:",R),R}finally{b(),hp=null}}else if(s==="stl")this.rootMesh=AB(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else if(s==="ply")this.rootMesh=IB(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else{let b=await Yf(c,a,{meshNames:"",pluginExtension:l});this.loadedMeshes=b.meshes,b.meshes.length>0&&(this.rootMesh=b.meshes[0])}if(!this.rootMesh)throw new Error("No mesh found in model file");for(let b of this.getRenderableMeshes(this.rootMesh))b.material&&(b.material.backFaceCulling=!1);this.rootMesh.computeWorldMatrix(!0);let f=this.rootMesh.getHierarchyBoundingVectors(),d=f.max.subtract(f.min),h=d.length()/2,u=f.min.add(d.scale(.5));return this.camera.target=u,this.camera.radius=h*2.5,this.camera.lowerRadiusLimit=h*.05,this.camera.upperRadiusLimit=h*10,this.camera.minZ=h*.001,this.camera.maxZ=h*20,this.initialCamera={alpha:this.camera.alpha,beta:this.camera.beta,radius:this.camera.radius,target:u.clone()},this.startRenderLoop(),this.engine.resize(),(T=this.cleanupPicking)==null||T.call(this),this.cleanupPicking=nU(this.scene,b=>{this.disassemblyEnabled||(this._lastPickResult=b,this._onPickCallbacks.forEach(R=>R(b)))}),this.disassembly=new od(this.scene,this.camera,this.getRenderableMeshes(this.rootMesh)),this.computeSummary(this.rootMesh)}applyConfig(e){e.camera&&this.applyCameraConfig(e.camera),e.lights&&this.applyLightConfig(e.lights),e.scene&&this.applySceneConfig(e.scene),e.stl&&this.loadedExt==="stl"&&(e.stl.color&&this.setSTLColor(e.stl.color),e.stl.wireframe!==void 0&&this.setWireframe(e.stl.wireframe))}applyCameraConfig(e){var i;let t=this.engine.getRenderingCanvas();if(t){if(e.mode==="orthographic"){let r=this.camera.radius,s=t.clientWidth/t.clientHeight,a=(i=e.zoom)!=null?i:1,o=r/a;this.camera.mode=1,this.camera.orthoLeft=-o*s,this.camera.orthoRight=o*s,this.camera.orthoTop=o,this.camera.orthoBottom=-o}else this.camera.mode=0,e.fov&&(this.camera.fov=e.fov*Math.PI/180);if(e.position){let[r,s,a]=e.position;this.camera.setPosition(new v(r,s,a))}if(e.lookAt){let[r,s,a]=e.lookAt;this.camera.setTarget(new v(r,s,a))}e.near!==void 0&&(this.camera.minZ=e.near),e.far!==void 0&&(this.camera.maxZ=e.far)}}applyLightConfig(e){var i;for(let r of this.configLights)r.dispose();this.configLights=[],(i=this.shadowGenerator)==null||i.dispose(),this.shadowGenerator=null;let t=this.scene.getLightByName("default-light");t&&t.dispose();for(let r of e){let s=this.createLight(r);s&&this.configLights.push(s)}}createLight(e){var r,s;let t=e.color?oe.FromHexString(e.color):oe.White(),i=(r=e.intensity)!=null?r:1;switch(e.type){case"hemisphere":{let a=e.groundColor?oe.FromHexString(e.groundColor):new oe(.2,.2,.2),o=new Sr("hemi",new v(0,1,0),this.scene);return o.diffuse=t,o.groundColor=a,o.intensity=i,o}case"directional":{let a=e.position?new v(...e.position).normalize():new v(-1,-2,-1).normalize(),o=new lr("dir",a,this.scene);return o.diffuse=t,o.intensity=i,e.castShadow&&this.rootMesh&&this.setupShadow(o),o}case"point":{let a=e.position?new v(...e.position):new v(0,5,0),o=new ya("point",a,this.scene);return o.diffuse=t,o.intensity=i,e.decay!==void 0&&(o.decay=e.decay),o}case"spot":{let a=e.position?new v(...e.position):new v(0,5,0),l=(e.target?new v(...e.target):v.Zero()).subtract(a).normalize(),c=e.angle?e.angle*Math.PI/180:Math.PI/4,f=(s=e.penumbra)!=null?s:.5,d=new ni("spot",a,l,c,f,this.scene);return d.diffuse=t,d.intensity=i,e.decay!==void 0&&(d.decay=e.decay),e.castShadow&&this.rootMesh&&this.setupShadow(d),d}case"attachToCam":{let a=new ya("cam-light",v.Zero(),this.scene);return a.diffuse=t,a.intensity=i,a.parent=this.camera,a}default:return null}}setupShadow(e){if(!this.rootMesh)return;if(!ZY(e)){console.warn("[AI3D] Light type does not support shadows:",e.name);return}let t=new St(1024,e);t.useBlurExponentialShadowMap=!0,t.blurKernel=32;let i=this.rootMesh.getChildMeshes(!0);for(let r of i)t.addShadowCaster(r),r.receiveShadows=!0;this.shadowGenerator=t}applySceneConfig(e){var t,i;if(e.background!==void 0){let r=Ne.FromColor3(oe.FromHexString(e.background),e.transparent?0:1);this.scene.clearColor=r}e.autoRotate&&(this.autoRotateBehavior?this.autoRotateBehavior.idleRotationSpeed=(i=e.autoRotateSpeed)!=null?i:.5:(this.autoRotateBehavior=new ql,this.autoRotateBehavior.idleRotationSpeed=(t=e.autoRotateSpeed)!=null?t:.5,this.autoRotateBehavior.idleRotationWaitTime=1e3,this.autoRotateBehavior.idleRotationSpinupTime=500,this.camera.addBehavior(this.autoRotateBehavior))),e.groundShadow&&this.rootMesh&&this.createGround(),e.grid&&this.createGrid(),e.axis&&this.createAxis()}createGround(){if(!this.rootMesh||this.groundMesh)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.z)*3,r=e.min.y;this.groundMesh=zs.CreateGround("ground",{width:i,height:i},this.scene),this.groundMesh.position.y=r;let s=new Re("ground-mat",this.scene);s.diffuseColor=new oe(.15,.15,.15),s.specularColor=oe.Black(),s.alpha=.5,this.groundMesh.material=s,this.groundMesh.receiveShadows=!0}createGrid(){if(!this.rootMesh||this.gridMesh)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.z)*2,r=e.min.y-.01;this.gridMesh=zs.CreateGround("grid",{width:i,height:i,subdivisions:20},this.scene),this.gridMesh.position.y=r;let s=new Re("grid-mat",this.scene);s.wireframe=!0,s.diffuseColor=new oe(.3,.3,.3),s.emissiveColor=new oe(.1,.1,.1),this.gridMesh.material=s}createAxis(){if(!this.rootMesh||this.axisMeshes.length>0)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.y,t.z)*1.5,r=e.min,s=[["x",oe.Red(),new v(i,0,0)],["y",oe.Green(),new v(0,i,0)],["z",oe.Blue(),new v(0,0,i)]];for(let[a,o,l]of s){let c=zs.CreateTube(`axis-${a}`,{path:[r,r.add(l)],radius:t.length()*.005,tessellation:8},this.scene),f=new Re(`axis-${a}-mat`,this.scene);f.emissiveColor=o,f.diffuseColor=oe.Black(),c.material=f,this.axisMeshes.push(c)}}setSTLColor(e){if(!this.rootMesh)return;let t=oe.FromHexString(e),i=this.rootMesh.getChildMeshes(!0);for(let r of i)if(r.material&&r.material.name==="stl-mat"){let s=r.material;s.diffuseColor=t,s.emissiveColor=t.scale(.1)}}setWireframe(e){this.rootMesh&&(AA(this.rootMesh)||(this.wireframeEnabled=e,this.scene.forceWireframe=e))}toggleWireframe(){return this.setWireframe(!this.wireframeEnabled),this.wireframeEnabled}hasAnimations(){return this.scene.animationGroups.length>0}toggleAnimation(){let e=this.scene.animationGroups;if(e.length===0)return!1;this.animPlaying=!this.animPlaying;for(let t of e)this.animPlaying?t.play(!0):t.pause();return this.animPlaying}setAnimationSpeed(e){for(let t of this.scene.animationGroups)t.speedRatio=e}captureSnapshot(){let e=this.engine.getRenderingCanvas();return e?(this.scene.render(),e.toDataURL("image/png")):null}toggleOrientationGizmo(){return this.gizmoEnabled=!this.gizmoEnabled,this.gizmoEnabled&&!this.gizmo&&(this.gizmo=new fp(this.engine,this.camera)),this.gizmoEnabled}setRenderScale(e){let t=Math.max(.25,Math.min(e,2)),i={low:2,medium:1.33,high:1}[this.currentQuality],r=Qt()?1.5:1;return this.engine.setHardwareScalingLevel(i*r/t),t}toggleBoundingBox(){var e;if(this.bboxEnabled=!this.bboxEnabled,this.bboxEnabled){if(!this.rootMesh)return this.bboxEnabled;this.bboxMesh&&this.bboxMesh.dispose(),this.rootMesh.computeWorldMatrix(!0);let t=this.rootMesh.getHierarchyBoundingVectors(),i=t.min.add(t.max.subtract(t.min).scale(.5)),r=t.max.subtract(t.min);this.bboxMesh=zs.CreateBox("bbox",{width:r.x,height:r.y,depth:r.z},this.scene),this.bboxMesh.position=i;let s=new Re("bbox-mat",this.scene);s.wireframe=!0,s.emissiveColor=new oe(1,1,0),s.disableLighting=!0,s.alpha=.6,this.bboxMesh.material=s}else(e=this.bboxMesh)==null||e.dispose(),this.bboxMesh=null;return this.bboxEnabled}toggleDisassembly(){return this.rootMesh?(this.disassembly||(this.disassembly=new od(this.scene,this.camera,this.getRenderableMeshes(this.rootMesh))),this.disassemblyEnabled=this.disassembly.toggle(),this.disassemblyEnabled):!1}resetDisassembly(){var e;(e=this.disassembly)==null||e.reset()}setExplode(e,t){this.rootMesh&&bB(this.rootMesh,e,t)}resetExplode(){this.rootMesh&&zS(this.rootMesh)}resetView(){this.rootMesh&&zS(this.rootMesh),this.resetDisassembly(),this.camera.mode=0,this.camera.alpha=this.initialCamera.alpha,this.camera.beta=this.initialCamera.beta,this.camera.radius=this.initialCamera.radius,this.camera.target=this.initialCamera.target.clone()}exportModelInfo(e){var f,d,h;if(!this.rootMesh)return"";let t=this.computeSummary(this.rootMesh),i=this.getRenderableMeshes(this.rootMesh),r=AA(this.rootMesh),s=this.loadedExt.toUpperCase(),a=e&&lp(e)||t.rootName,o=r?"Splats":"Triangles",l=[];if(l.push(`## ${a} \u2014 Model Info`),l.push(""),l.push("| Property | Value |"),l.push("|----------|-------|"),l.push(`| Format | ${s} |`),l.push(`| Meshes | ${t.meshCount} |`),l.push(`| ${o} | ${((f=t.splatCount)!=null?f:t.triangleCount).toLocaleString()} |`),l.push(`| Vertices | ${t.vertexCount.toLocaleString()} |`),l.push(`| Materials | ${t.materialCount} |`),l.push(`| Bounding Size | ${t.boundingSize.x.toFixed(3)} x ${t.boundingSize.y.toFixed(3)} x ${t.boundingSize.z.toFixed(3)} |`),l.push(""),i.length>1&&i.length<=50){l.push("### Mesh Breakdown"),l.push(""),l.push("| # | Name | Triangles | Vertices | Material |"),l.push("|---|------|-----------|----------|----------|");for(let u=0;u0){l.push("### Materials"),l.push("");for(let u of c)l.push(`- ${u}`);l.push("")}return l.join(` -`)}getRootMesh(){return this.rootMesh}getScene(){return this.scene}getEngine(){return this.engine}getCamera(){return this.camera}getCanvas(){return this.engine.getRenderingCanvas()}getLastPickResult(){return this._lastPickResult}onPick(e){return this._onPickCallbacks.push(e),()=>{this._onPickCallbacks=this._onPickCallbacks.filter(t=>t!==e)}}setRenderQuality(e,t=1){this.currentQuality=e;let i={low:2,medium:1.33,high:1},r=Qt()?1.5:1,s=i[e]*r/Math.max(t,.25);if(this.engine.setHardwareScalingLevel(s),this.shadowGenerator){let a={low:0,medium:16,high:32};this.shadowGenerator.blurKernel=a[e],e==="low"?(this.shadowGenerator.useBlurExponentialShadowMap=!1,this.shadowGenerator.useExponentialShadowMap=!0):(this.shadowGenerator.useBlurExponentialShadowMap=!0,this.shadowGenerator.useExponentialShadowMap=!1)}}destroy(){var t,i,r,s,a,o,l;this.engine.stopRenderLoop(),this._onPickCallbacks=[],(t=this.cleanupPicking)==null||t.call(this),this.cleanupPicking=null,(i=this.gizmo)==null||i.dispose(),this.gizmo=null,(r=this.disassembly)==null||r.dispose(),this.disassembly=null,(s=this.bboxMesh)==null||s.dispose(),this.bboxMesh=null,this.camera.detachControl();let e=this.engine.getRenderingCanvas();e==null||e.removeEventListener("wheel",this.preventCanvasWheelScroll),this.resizeObs.disconnect(),this.autoRotateBehavior&&(this.camera.removeBehavior(this.autoRotateBehavior),this.autoRotateBehavior=null);for(let c of this.configLights)c.dispose();this.configLights=[],(a=this.shadowGenerator)==null||a.dispose(),this.shadowGenerator=null,(o=this.groundMesh)==null||o.dispose(),this.groundMesh=null,(l=this.gridMesh)==null||l.dispose(),this.gridMesh=null;for(let c of this.axisMeshes)c.dispose();this.axisMeshes=[],this.scene.dispose(),this.engine.dispose()}startRenderLoop(){this.rendering||(this.rendering=!0,this.engine.runRenderLoop(()=>{this.canRender()&&(this.scene.render(),this.gizmo&&this.gizmoEnabled&&(this.gizmo.syncWith(this.camera),this.gizmo.render()))}))}getRenderableMeshes(e){let t=[e,...this.loadedMeshes,...e.getChildMeshes(!0)],i=new Set;return t.filter(r=>!r||i.has(r)||r.isDisposed()?!1:(i.add(r),r.getTotalVertices()>0||r.getTotalIndices()>0))}computeSummary(e){let t=this.getRenderableMeshes(e),i=0,r=0,s=new Set,a=AA(e);for(let f of t){let d=f.getTotalIndices(),h=f.getTotalVertices();i+=Math.floor(d/3),r+=h,f.material&&s.add(f.material.name)}let o=a?r:void 0,l=e.getHierarchyBoundingVectors(),c=l.max.subtract(l.min);return{meshCount:t.length,triangleCount:i,splatCount:o,vertexCount:r,materialCount:s.size,boundingSize:{x:c.x,y:c.y,z:c.z},rootName:e.name}}}});var RA,PU=A(()=>{"use strict";RA={"settings.title":"AI 3d model workbench","settings.folders":"Folders","settings.behavior":"Behavior","settings.converters":"Converters","settings.converterMenu":"Model converters","settings.converterMenu.desc":"Closed by default. Open this section only when you want to manually enable an optional local conversion route.","settings.environmentInspector":"Environment inspector","settings.environmentInspector.desc":"Closed by default. Open this section when you need to configure command paths or run environment checks.","settings.paths":"Converter paths","settings.diagnostics":"Converter command diagnostics","settings.performance":"Performance & display","settings.mobileSupport":"Mobile support","settings.sourceModelFolder":"Source model folder","settings.sourceModelFolder.desc":"Vault folder where source model files are stored.","settings.reportFolder":"Report folder","settings.reportFolder.desc":"Vault folder where generated knowledge notes are saved.","settings.snapshotFolder":"Snapshot folder","settings.snapshotFolder.desc":"Vault folder where exported snapshots are saved.","settings.autoGenerateKnowledgeNotes":"Auto-generate knowledge notes","settings.autoGenerateKnowledgeNotes.desc":"Reserved for a future automation flow. For now, generate notes manually from the command or the workbench button.","settings.annotationPreviewMode":"Annotation preview mode","settings.annotationPreviewMode.desc":"Choose how bound note previews render in annotation popovers and the editor.","settings.annotationPreviewMode.plainText":"Plain text","settings.annotationPreviewMode.markdown":"Markdown","settings.autoRotateDefault":"Auto-rotate by default","settings.autoRotateDefault.desc":"Start model previews with auto-rotation enabled.","settings.snapshotNaming":"Snapshot naming","settings.snapshotNaming.desc":"How exported snapshot files are named.","settings.snapshotNaming.modelName":"Model name + timestamp","settings.snapshotNaming.timestamp":"Timestamp only","settings.logLevel":"Log level","settings.logLevel.desc":"Controls plugin runtime log verbosity in the developer console.","settings.language":"Language","settings.language.desc":"Display language for plugin settings. Takes effect immediately.","settings.enableCad":"Enable cad conversion for step, iges, and brep files","settings.enableCad.desc":"Enable cad conversion for step, iges, and brep formats. Requires cadquery and trimesh in your python environment.","settings.enableObj2gltf":"Enable obj2gltf converter (experimental)","settings.enableObj2gltf.desc":"Keep obj direct loading as the default. Enable this only if you want an optional local normalization route through obj2gltf.","settings.preferObj2gltf":"Prefer obj2gltf for obj","settings.preferObj2gltf.desc":"Recommended default is off. Turn this on only when you want normalized output files or direct obj loading is not good enough.","settings.enableFbx2gltf":"Enable FBX2glTF converter","settings.enableFbx2gltf.desc":"Enable conversion for fbx files via FBX2glTF. Requires the FBX2glTF binary installed locally.","settings.enableMesh":"Enable mesh conversion for 3mf and dae files","settings.enableMesh.desc":"Enable conversion for 3mf and dae formats via python trimesh. Requires trimesh, numpy, networkx, and pycollada in your python environment.","settings.enableSldprt":"Enable sldprt conversion for SolidWorks files","settings.enableSldprt.desc":"Enable conversion for SolidWorks sldprt files via FreeCAD. Requires FreeCAD installed locally.","settings.mobileSupport.desc":"On iOS, iPadOS, and Android, direct formats like GLB, GLTF, STL, OBJ, and PLY are supported. Local converter settings and diagnostics remain desktop-only.","settings.pythonCmd":"Path to the python command for cad conversion","settings.pythonCmd.desc":"Optional path to the python command used for cad conversion. Windows usually uses py. macOS and Linux usually use python3. Overrides auto-discovery when set.","settings.freecadCmd":"Path to the FreeCAD command for sldprt conversion","settings.freecadCmd.desc":"Optional path to the FreeCAD command used for SolidWorks file conversion. Windows usually uses FreeCADCmd.exe, macOS usually uses FreeCADCmd, and Linux usually uses freecadcmd. Overrides auto-discovery when set.","settings.obj2gltfCmd":"Path to the obj2gltf command","settings.obj2gltfCmd.desc":"Optional path to the obj2gltf command. Windows usually uses obj2gltf.cmd, and macOS and Linux usually use obj2gltf. Overrides auto-discovery when set.","settings.fbx2gltfCmd":"FBX2glTF command path","settings.fbx2gltfCmd.desc":"Optional path to the FBX2glTF command. Windows usually uses FBX2glTF.exe, and macOS and Linux usually use FBX2glTF. Overrides auto-discovery when set.","settings.assimpCmd":"Path to the python command for 3mf and dae conversion","settings.assimpCmd.desc":"Optional path to the python command used for 3mf and dae conversion. Windows usually uses py. macOS and Linux usually use python3. Overrides auto-discovery when set.","settings.diagnostics.desc":"Shows the exact executable path the plugin would use right now and runs lightweight self-checks for Python environments and converter CLIs.","settings.diagnostics.idle":"Diagnostics are off by default. Click Check now to run them manually.","settings.diagnostics.checkNow":"Check now","settings.diagnostics.checking":"Checking...","settings.diagnostics.refreshed":"Converter command diagnostics refreshed.","settings.diagnostics.checkingAvailability":"Checking converter command availability...","settings.diagnostics.available":"available","settings.diagnostics.notFound":"not found","settings.diagnostics.sourceLabel":"Source","settings.diagnostics.commandLabel":"Command","settings.diagnostics.resolvedPathLabel":"Resolved path","settings.diagnostics.selfCheckLabel":"Self-check","settings.diagnostics.selfCheckOk":"passed","settings.diagnostics.selfCheckFailed":"failed","settings.diagnostics.cadPythonCheck":"Python packages (cadquery, trimesh)","settings.diagnostics.meshPythonCheck":"Python packages (trimesh, numpy, networkx, collada)","settings.diagnostics.freecadCmdCheck":"FreeCADCmd launch probe","settings.diagnostics.obj2gltfCheck":"obj2gltf launch probe","settings.diagnostics.fbx2gltfCheck":"FBX2glTF launch probe","settings.canvasHeight":"Default canvas height","settings.canvasHeight.desc":"Default height (px) for inline model previews. Range: 200\u2013800.","settings.autoRotateSpeed":"Auto-rotate speed","settings.autoRotateSpeed.desc":"Rotation speed when auto-rotate is enabled. Range: 0.1\u20132.0.","settings.renderQuality":"Render quality","settings.renderQuality.desc":"Higher quality uses more GPU resources. Affects anti-aliasing and resolution.","settings.renderScale":"Resolution scale","settings.renderScale.desc":"Render resolution multiplier. 1.0 = native, 0.5 = half, 2.0 = double (supersampling). Range: 0.25\u20132.0.","modelLoad.warningTitle":"Model preview unavailable","modelLoad.warningMessage":"{ext} files need the {converterName} converter enabled in plugin settings before they can load.","modelLoad.warningHint":"Enable the matching converter in plugin settings, then reload this file.","modelLoad.mobileWarningMessage":"{ext} files need local conversion tools that are unavailable on iOS, iPadOS, and Android.","modelLoad.mobileWarningHint":"Open this file on desktop, or convert it to GLB, GLTF, OBJ, STL, or PLY first.","modelLoad.errorTitle":"Couldn't display this model","modelLoad.errorMessage":"Failed to load: {reason}","modelLoad.errorHint":"Check the file format or open the developer console for details.","headingPin.showSingle":"Show linked pin","headingPin.showMultiple":"Show linked pins","headingPin.linkedTo":"Pin linked to: {models}","helper.resetViewLabel":"Reset view","helper.resetViewDone":"Reset","helper.copyModelInfoLabel":"Copy model info as Markdown","helper.copied":"Copied!","helper.failed":"Failed","helper.toggleWireframeLabel":"Toggle wireframe","helper.wireframeOn":"Wireframe","helper.wireframeOff":"Solid","helper.toggleAxesLabel":"Toggle orientation axes","helper.axesOn":"Axes on","helper.axesOff":"Axes off","helper.toggleBoundingBoxLabel":"Toggle bounding box","helper.boundingBoxOn":"Bounding box on","helper.boundingBoxOff":"Bounding box off","helper.toggleDisassemblyLabel":"Toggle disassembly mode","helper.disassemblyOn":"Disassembly on","helper.disassemblyOff":"Disassembly off","helper.resetPartsLabel":"Reset disassembled parts","helper.partsReset":"Parts reset","helper.changeResolutionLabel":"Change resolution","helper.resolutionValue":"Resolution: {value}","helper.toggleAnimationLabel":"Play or pause animation","helper.playing":"Playing","helper.paused":"Paused","helper.removePreviewLabel":"Remove preview","helper.copySnapshotLabel":"Copy snapshot","helper.saveSnapshotLabel":"Save snapshot to vault","helper.saved":"Saved!","helper.downloadSnapshotLabel":"Download snapshot","helper.downloaded":"Downloaded!","helper.toggleAnnotationLabel":"Toggle annotation mode","helper.toggleAnnotationsVisibilityLabel":"Show or hide annotations","helper.annotateOn":"Annotation mode on","helper.annotateOff":"Annotation mode off","helper.annotationsVisible":"Annotations shown","helper.annotationsHidden":"Annotations hidden","helper.enableInteractionLabel":"Enable touch interaction","helper.disableInteractionLabel":"Return to scroll mode","helper.interactionOn":"Model interaction on","helper.interactionOff":"Scroll mode on","helper.showMoreActionsLabel":"Show more actions","helper.hideMoreActionsLabel":"Hide extra actions","helper.moreActionsShown":"More actions shown","helper.moreActionsHidden":"Extra actions hidden","helper.interactAction":"Interact","helper.scrollAction":"Scroll","workbench.emptyTitle":"No model","workbench.emptyText":'Use the "import 3D model" command to load a GLB, GLTF, or STL file.',"workbench.modelTitle":"Model","workbench.noModelLoaded":"No model loaded","workbench.disassemblyTitle":"Disassembly","workbench.explodeLabel":"Explode","workbench.summaryTitle":"Summary","workbench.meshesLabel":"Meshes","workbench.splatsLabel":"Splats","workbench.trianglesLabel":"Triangles","workbench.materialsLabel":"Materials","workbench.tagsTitle":"Tags","workbench.noTagsYet":"No tags yet","workbench.addTagPlaceholder":"Add tag...","workbench.addTagAction":"Add","workbench.annotationsTitle":"Annotations","workbench.exitAnnotate":"Exit annotate","workbench.annotate":"Annotate","workbench.annotateHintActive":"Click the model to add a label \xB7 press Esc to exit","workbench.annotateHintActiveMobile":"Tap the model to add a label. Switch back to Scroll when you want to move through the note again.","workbench.pinCount":"{count} pin(s)","workbench.editAction":"Edit","workbench.deleteAction":"Delete","workbench.resetViewAction":"Reset view","workbench.insertInfoAction":"Insert info","workbench.playAction":"Play","workbench.pauseAction":"Pause","workbench.saveProfileAction":"Save profile","workbench.generateNoteAction":"Generate note","workbench.mobileHint":"Mobile tip: tap Interact to move the model, then switch back to Scroll to keep reading the note.","workbench.mobileHintInteractive":"Interaction mode is on. Switch back to Scroll when you want to move through the note again.","directView.mobileHint":"Mobile tip: use the toolbar Interact button to switch between model interaction and note scrolling.","workbench.fileNotFound":"File not found: {path}","annotation.selectColor":"Select color {color}","annotation.sectionEmpty":"Section is empty.","modal.selectModel":"Select a 3D model...","main.ribbonOpenWorkbench":"Open the 3D workbench","main.commandImportModel":"Import a 3D model","main.commandOpenWorkbench":"Open the 3D workbench","main.commandGenerateNote":"Generate knowledge note","main.commandClearConversionCache":"Clear conversion cache","main.commandCheckConverters":"Check converters","main.converterDiagnosticsMobileUnavailable":"Converter diagnostics are only available on desktop. On iOS, iPadOS, and Android, direct formats can still load.","codeBlock.noModelPathOrConfig":"No model path or config specified.","codeBlock.jsonParseError":"JSON parse error: {error}","codeBlock.jsonParseLine":" (line {line})","codeBlock.noModelsInConfig":"No models specified in config.","codeBlock.unsupportedFormat":"Unsupported format: {ext}. Supported: {formats}","codeBlock.noConfigSpecified":"No config specified.","codeBlock.noModelsSpecified":"No models specified.","codeBlock.mobileHint":"Mobile tip: use Interact to manipulate the model, then switch back to Scroll to keep moving through the note.","codeBlock.renderingGrid":"Rendering grid...","codeBlock.composeRequiresSections":'"compose" preset requires a "sections" array.',"codeBlock.composeNoValidSections":"Compose: no valid sections.","codeBlock.unknownPreset":'Unknown preset: "{preset}". Available: compare, showcase, explode, timeline, compose',"codeBlock.presetRequiresModels":'Preset "{preset}" requires {min}-{max} models, got {count}.',"codeBlock.gridFailed":"Grid failed: {reason}","livePreview.mobileHint":"Mobile tip: switch between Interact and Scroll depending on whether you want to move the model or keep reading.","loading.default":"Loading...","loading.preparingModel":"Preparing model...","loading.loadingModel":"Loading model..."}});var OU,NU=A(()=>{"use strict";OU={"settings.title":"AI 3D \u6A21\u578B\u5DE5\u4F5C\u53F0","settings.folders":"\u6587\u4EF6\u5939","settings.behavior":"\u884C\u4E3A","settings.converters":"\u8F6C\u6362\u5668","settings.converterMenu":"\u6A21\u578B\u8F6C\u6362\u5668","settings.converterMenu.desc":"\u9ED8\u8BA4\u6536\u8D77\u3002\u4EC5\u5728\u4F60\u9700\u8981\u624B\u52A8\u542F\u7528\u67D0\u6761\u672C\u5730\u8F6C\u6362\u8DEF\u7EBF\u65F6\u518D\u5C55\u5F00\u3002","settings.environmentInspector":"\u73AF\u5883\u68C0\u67E5\u5668","settings.environmentInspector.desc":"\u9ED8\u8BA4\u6536\u8D77\u3002\u4EC5\u5728\u9700\u8981\u914D\u7F6E\u547D\u4EE4\u8DEF\u5F84\u6216\u624B\u52A8\u6267\u884C\u73AF\u5883\u68C0\u67E5\u65F6\u518D\u5C55\u5F00\u3002","settings.paths":"\u8F6C\u6362\u5668\u8DEF\u5F84","settings.diagnostics":"\u8F6C\u6362\u5668\u547D\u4EE4\u8BCA\u65AD","settings.performance":"\u6027\u80FD\u4E0E\u663E\u793A","settings.mobileSupport":"\u79FB\u52A8\u7AEF\u652F\u6301","settings.sourceModelFolder":"\u6E90\u6A21\u578B\u6587\u4EF6\u5939","settings.sourceModelFolder.desc":"\u5B58\u653E\u6E90 3D \u6A21\u578B\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.reportFolder":"\u62A5\u544A\u6587\u4EF6\u5939","settings.reportFolder.desc":"\u4FDD\u5B58\u751F\u6210\u7684\u77E5\u8BC6\u7B14\u8BB0\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.snapshotFolder":"\u5FEB\u7167\u6587\u4EF6\u5939","settings.snapshotFolder.desc":"\u4FDD\u5B58\u5BFC\u51FA\u5FEB\u7167\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.autoGenerateKnowledgeNotes":"\u81EA\u52A8\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0","settings.autoGenerateKnowledgeNotes.desc":"\u9884\u7559\u7ED9\u540E\u7EED\u81EA\u52A8\u5316\u6D41\u7A0B\u3002\u5F53\u524D\u8BF7\u901A\u8FC7\u547D\u4EE4\u6216\u5DE5\u4F5C\u53F0\u6309\u94AE\u624B\u52A8\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0\u3002","settings.annotationPreviewMode":"\u6807\u6CE8\u9884\u89C8\u6A21\u5F0F","settings.annotationPreviewMode.desc":"\u9009\u62E9\u6807\u6CE8\u7ED1\u5B9A\u7B14\u8BB0\u5728\u60AC\u6D6E\u9884\u89C8\u548C\u7F16\u8F91\u5668\u4E2D\u7684\u663E\u793A\u65B9\u5F0F\u3002","settings.annotationPreviewMode.plainText":"\u7EAF\u6587\u672C","settings.annotationPreviewMode.markdown":"Markdown","settings.autoRotateDefault":"\u9ED8\u8BA4\u81EA\u52A8\u65CB\u8F6C","settings.autoRotateDefault.desc":"\u542F\u52A8 3D \u9884\u89C8\u65F6\u9ED8\u8BA4\u5F00\u542F\u81EA\u52A8\u65CB\u8F6C\u3002","settings.snapshotNaming":"\u5FEB\u7167\u547D\u540D","settings.snapshotNaming.desc":"\u5BFC\u51FA\u5FEB\u7167\u6587\u4EF6\u7684\u547D\u540D\u65B9\u5F0F\u3002","settings.snapshotNaming.modelName":"\u6A21\u578B\u540D + \u65F6\u95F4\u6233","settings.snapshotNaming.timestamp":"\u4EC5\u65F6\u95F4\u6233","settings.logLevel":"\u65E5\u5FD7\u7EA7\u522B","settings.logLevel.desc":"\u63A7\u5236\u63D2\u4EF6\u5728\u5F00\u53D1\u8005\u63A7\u5236\u53F0\u4E2D\u7684\u65E5\u5FD7\u8BE6\u7EC6\u7A0B\u5EA6\u3002","settings.language":"\u8BED\u8A00","settings.language.desc":"\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u7684\u663E\u793A\u8BED\u8A00\u3002\u7ACB\u5373\u751F\u6548\u3002","settings.enableCad":"\u542F\u7528 CAD \u8F6C\u6362\u5668 (STEP/IGES/BREP)","settings.enableCad.desc":"\u542F\u7528 STEP/IGES/BREP \u683C\u5F0F\u7684 CAD \u8F6C\u6362\u8DEF\u7EBF\uFF0C\u901A\u8FC7 Python CadQuery (OpenCASCADE)\u3002\u9700\u8981\uFF1Apip install cadquery trimesh","settings.enableObj2gltf":"\u542F\u7528 obj2gltf \u8F6C\u6362\u5668\uFF08\u5B9E\u9A8C\u6027\uFF09","settings.enableObj2gltf.desc":"\u9ED8\u8BA4\u4F7F\u7528 OBJ \u76F4\u63A5\u52A0\u8F7D\u3002\u4EC5\u5728\u9700\u8981\u672C\u5730\u6807\u51C6\u5316 GLB \u8F93\u51FA\u65F6\u542F\u7528\u3002","settings.preferObj2gltf":"OBJ \u4F18\u5148\u4F7F\u7528 obj2gltf","settings.preferObj2gltf.desc":"\u9ED8\u8BA4\u5173\u95ED\u3002\u4EC5\u5728\u9700\u8981\u6807\u51C6\u5316 GLB \u8F93\u51FA\u6216\u76F4\u63A5 OBJ \u52A0\u8F7D\u6548\u679C\u4E0D\u4F73\u65F6\u5F00\u542F\u3002","settings.enableFbx2gltf":"\u542F\u7528 FBX2glTF \u8F6C\u6362\u5668","settings.enableFbx2gltf.desc":"\u542F\u7528 FBX \u6587\u4EF6\u901A\u8FC7 FBX2glTF \u8F6C\u6362\u3002\u9700\u8981\u672C\u5730\u5B89\u88C5 FBX2glTF \u4E8C\u8FDB\u5236\u6587\u4EF6\u3002","settings.enableMesh":"\u542F\u7528\u7F51\u683C\u8F6C\u6362\u5668 (3MF/DAE)","settings.enableMesh.desc":"\u542F\u7528 3MF \u548C DAE (Collada) \u683C\u5F0F\u7684\u8F6C\u6362\u8DEF\u7EBF\uFF0C\u901A\u8FC7 Python trimesh\u3002\u9700\u8981\u5B89\u88C5 Python \u548C trimesh (pip install trimesh numpy networkx pycollada)\u3002","settings.enableSldprt":"\u542F\u7528 SLDPRT \u8F6C\u6362\u5668 (SolidWorks)","settings.enableSldprt.desc":"\u542F\u7528 SolidWorks .sldprt \u6587\u4EF6\u901A\u8FC7 FreeCAD \u8F6C\u6362\u3002\u9700\u8981\u5B89\u88C5 FreeCAD (https://www.freecad.org/downloads.php)\u3002","settings.mobileSupport.desc":"\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\uFF0CGLB\u3001GLTF\u3001STL\u3001OBJ\u3001PLY \u8FD9\u7C7B\u76F4\u8BFB\u683C\u5F0F\u53EF\u7528\u3002\u672C\u5730\u8F6C\u6362\u5668\u8BBE\u7F6E\u548C\u547D\u4EE4\u8BCA\u65AD\u4ECD\u4EC5\u652F\u6301\u684C\u9762\u7AEF\u3002","settings.pythonCmd":"Python \u547D\u4EE4\u8DEF\u5F84\uFF08CAD \u7528\uFF09","settings.pythonCmd.desc":"\u53EF\u9009\u7684 Python \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E CAD \u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 py\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 python3\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FREECAD_CMD\u3002","settings.freecadCmd":"FreeCAD \u547D\u4EE4\u8DEF\u5F84\uFF08SLDPRT \u7528\uFF09","settings.freecadCmd.desc":"\u53EF\u9009\u7684 FreeCAD \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E SolidWorks \u6587\u4EF6\u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 FreeCADCmd.exe\uFF0CmacOS \u901A\u5E38\u7528 FreeCADCmd\uFF0CLinux \u901A\u5E38\u7528 freecadcmd\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FREECADCMD\u3002","settings.obj2gltfCmd":"obj2gltf \u547D\u4EE4\u8DEF\u5F84","settings.obj2gltfCmd.desc":"\u53EF\u9009\u7684 obj2gltf \u547D\u4EE4\u8DEF\u5F84\u3002Windows \u901A\u5E38\u7528 obj2gltf.cmd\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 obj2gltf\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_OBJ2GLTF_CMD\u3002","settings.fbx2gltfCmd":"FBX2glTF \u547D\u4EE4\u8DEF\u5F84","settings.fbx2gltfCmd.desc":"\u53EF\u9009\u7684 FBX2glTF \u547D\u4EE4\u8DEF\u5F84\u3002Windows \u901A\u5E38\u7528 FBX2glTF.exe\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 FBX2glTF\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FBX2GLTF_CMD\u3002","settings.assimpCmd":"Python \u547D\u4EE4\u8DEF\u5F84\uFF083MF/DAE \u7528\uFF09","settings.assimpCmd.desc":"\u53EF\u9009\u7684 Python \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E 3MF \u548C DAE \u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 py\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 python3\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_ASSIMP_CMD\u3002","settings.diagnostics.desc":"\u663E\u793A\u63D2\u4EF6\u5F53\u524D\u5B9E\u9645\u4F7F\u7528\u7684\u53EF\u6267\u884C\u6587\u4EF6\u8DEF\u5F84\uFF0C\u5E76\u4E3A Python \u73AF\u5883\u548C\u8F6C\u6362\u5668\u547D\u4EE4\u6267\u884C\u8F7B\u91CF\u81EA\u68C0\u3002","settings.diagnostics.idle":"\u73AF\u5883\u68C0\u67E5\u9ED8\u8BA4\u5173\u95ED\u3002\u70B9\u51FB\u201C\u7ACB\u5373\u68C0\u67E5\u201D\u540E\u624D\u4F1A\u6267\u884C\u3002","settings.diagnostics.checkNow":"\u7ACB\u5373\u68C0\u67E5","settings.diagnostics.checking":"\u68C0\u67E5\u4E2D...","settings.diagnostics.refreshed":"AI 3D \u8F6C\u6362\u5668\u547D\u4EE4\u8BCA\u65AD\u5DF2\u5237\u65B0\u3002","settings.diagnostics.checkingAvailability":"\u6B63\u5728\u68C0\u67E5\u8F6C\u6362\u5668\u547D\u4EE4\u53EF\u7528\u6027...","settings.diagnostics.available":"\u53EF\u7528","settings.diagnostics.notFound":"\u672A\u627E\u5230","settings.diagnostics.sourceLabel":"\u6765\u6E90","settings.diagnostics.commandLabel":"\u547D\u4EE4","settings.diagnostics.resolvedPathLabel":"\u89E3\u6790\u8DEF\u5F84","settings.diagnostics.selfCheckLabel":"\u81EA\u68C0","settings.diagnostics.selfCheckOk":"\u901A\u8FC7","settings.diagnostics.selfCheckFailed":"\u5931\u8D25","settings.diagnostics.cadPythonCheck":"Python \u5305\uFF08cadquery\u3001trimesh\uFF09","settings.diagnostics.meshPythonCheck":"Python \u5305\uFF08trimesh\u3001numpy\u3001networkx\u3001collada\uFF09","settings.diagnostics.freecadCmdCheck":"FreeCADCmd \u542F\u52A8\u63A2\u6D4B","settings.diagnostics.obj2gltfCheck":"obj2gltf \u542F\u52A8\u63A2\u6D4B","settings.diagnostics.fbx2gltfCheck":"FBX2glTF \u542F\u52A8\u63A2\u6D4B","settings.canvasHeight":"\u9ED8\u8BA4\u753B\u5E03\u9AD8\u5EA6","settings.canvasHeight.desc":"\u5185\u8054 3D \u9884\u89C8\u7684\u9ED8\u8BA4\u9AD8\u5EA6\uFF08\u50CF\u7D20\uFF09\u3002\u8303\u56F4\uFF1A200\u2013800\u3002","settings.autoRotateSpeed":"\u81EA\u52A8\u65CB\u8F6C\u901F\u5EA6","settings.autoRotateSpeed.desc":"\u542F\u7528\u81EA\u52A8\u65CB\u8F6C\u65F6\u7684\u65CB\u8F6C\u901F\u5EA6\u3002\u8303\u56F4\uFF1A0.1\u20132.0\u3002","settings.renderQuality":"\u6E32\u67D3\u8D28\u91CF","settings.renderQuality.desc":"\u66F4\u9AD8\u8D28\u91CF\u4F7F\u7528\u66F4\u591A GPU \u8D44\u6E90\u3002\u5F71\u54CD\u6297\u952F\u9F7F\u548C\u5206\u8FA8\u7387\u3002","settings.renderScale":"\u6E32\u67D3\u7F29\u653E","settings.renderScale.desc":"\u6E32\u67D3\u5206\u8FA8\u7387\u500D\u6570\u30021.0 = \u539F\u59CB\uFF0C0.5 = \u4E00\u534A\uFF0C2.0 = \u53CC\u500D\uFF08\u8D85\u91C7\u6837\uFF09\u3002\u8303\u56F4\uFF1A0.25\u20132.0\u3002","modelLoad.warningTitle":"\u6682\u65F6\u65E0\u6CD5\u9884\u89C8\u6A21\u578B","modelLoad.warningMessage":"{ext} \u6587\u4EF6\u9700\u8981\u5148\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u542F\u7528 {converterName} \u8F6C\u6362\u5668\uFF0C\u624D\u80FD\u52A0\u8F7D\u3002","modelLoad.warningHint":"\u8BF7\u5148\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u542F\u7528\u5BF9\u5E94\u8F6C\u6362\u5668\uFF0C\u7136\u540E\u91CD\u65B0\u52A0\u8F7D\u5F53\u524D\u6587\u4EF6\u3002","modelLoad.mobileWarningMessage":"{ext} \u6587\u4EF6\u9700\u8981\u672C\u5730\u8F6C\u6362\u5DE5\u5177\uFF0C\u4F46\u8FD9\u4E9B\u5DE5\u5177\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\u4E0D\u53EF\u7528\u3002","modelLoad.mobileWarningHint":"\u8BF7\u5728\u684C\u9762\u7AEF\u6253\u5F00\u6B64\u6587\u4EF6\uFF0C\u6216\u5148\u5C06\u5B83\u8F6C\u6362\u4E3A GLB\u3001GLTF\u3001OBJ\u3001STL \u6216 PLY\u3002","modelLoad.errorTitle":"\u65E0\u6CD5\u663E\u793A\u8FD9\u4E2A\u6A21\u578B","modelLoad.errorMessage":"\u52A0\u8F7D\u5931\u8D25\uFF1A{reason}","modelLoad.errorHint":"\u8BF7\u68C0\u67E5\u6587\u4EF6\u683C\u5F0F\uFF0C\u6216\u6253\u5F00\u5F00\u53D1\u8005\u63A7\u5236\u53F0\u67E5\u770B\u8BE6\u7EC6\u4FE1\u606F\u3002","headingPin.showSingle":"\u663E\u793A\u5173\u8054\u6807\u6CE8","headingPin.showMultiple":"\u663E\u793A\u5173\u8054\u6807\u6CE8","headingPin.linkedTo":"\u5173\u8054\u5230\uFF1A{models}","helper.resetViewLabel":"\u91CD\u7F6E\u89C6\u56FE","helper.resetViewDone":"\u5DF2\u91CD\u7F6E","helper.copyModelInfoLabel":"\u590D\u5236\u6A21\u578B\u4FE1\u606F\u4E3A Markdown","helper.copied":"\u5DF2\u590D\u5236","helper.failed":"\u5931\u8D25","helper.toggleWireframeLabel":"\u5207\u6362\u7EBF\u6846\u663E\u793A","helper.wireframeOn":"\u7EBF\u6846","helper.wireframeOff":"\u5B9E\u4F53","helper.toggleAxesLabel":"\u5207\u6362\u65B9\u5411\u5750\u6807\u8F74","helper.axesOn":"\u5750\u6807\u8F74\u5DF2\u5F00\u542F","helper.axesOff":"\u5750\u6807\u8F74\u5DF2\u5173\u95ED","helper.toggleBoundingBoxLabel":"\u5207\u6362\u5305\u56F4\u76D2","helper.boundingBoxOn":"\u5305\u56F4\u76D2\u5DF2\u5F00\u542F","helper.boundingBoxOff":"\u5305\u56F4\u76D2\u5DF2\u5173\u95ED","helper.toggleDisassemblyLabel":"\u5207\u6362\u5206\u89E3\u6A21\u5F0F","helper.disassemblyOn":"\u5206\u89E3\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.disassemblyOff":"\u5206\u89E3\u6A21\u5F0F\u5DF2\u5173\u95ED","helper.resetPartsLabel":"\u91CD\u7F6E\u5206\u89E3\u90E8\u4EF6","helper.partsReset":"\u90E8\u4EF6\u5DF2\u91CD\u7F6E","helper.changeResolutionLabel":"\u5207\u6362\u5206\u8FA8\u7387","helper.resolutionValue":"\u5206\u8FA8\u7387\uFF1A{value}","helper.toggleAnimationLabel":"\u64AD\u653E\u6216\u6682\u505C\u52A8\u753B","helper.playing":"\u64AD\u653E\u4E2D","helper.paused":"\u5DF2\u6682\u505C","helper.removePreviewLabel":"\u79FB\u9664\u9884\u89C8","helper.copySnapshotLabel":"\u590D\u5236\u5FEB\u7167","helper.saveSnapshotLabel":"\u4FDD\u5B58\u5FEB\u7167\u5230\u4ED3\u5E93","helper.saved":"\u5DF2\u4FDD\u5B58","helper.downloadSnapshotLabel":"\u4E0B\u8F7D\u5FEB\u7167","helper.downloaded":"\u5DF2\u4E0B\u8F7D","helper.toggleAnnotationLabel":"\u5207\u6362\u6807\u6CE8\u6A21\u5F0F","helper.toggleAnnotationsVisibilityLabel":"\u663E\u793A\u6216\u9690\u85CF\u6807\u6CE8","helper.annotateOn":"\u6807\u6CE8\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.annotateOff":"\u6807\u6CE8\u6A21\u5F0F\u5DF2\u5173\u95ED","helper.annotationsVisible":"\u6807\u6CE8\u5DF2\u663E\u793A","helper.annotationsHidden":"\u6807\u6CE8\u5DF2\u9690\u85CF","helper.enableInteractionLabel":"\u542F\u7528\u89E6\u63A7\u4EA4\u4E92","helper.disableInteractionLabel":"\u5207\u56DE\u6EDA\u52A8\u6A21\u5F0F","helper.interactionOn":"\u6A21\u578B\u4EA4\u4E92\u5DF2\u5F00\u542F","helper.interactionOff":"\u6EDA\u52A8\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.showMoreActionsLabel":"\u663E\u793A\u66F4\u591A\u64CD\u4F5C","helper.hideMoreActionsLabel":"\u6536\u8D77\u989D\u5916\u64CD\u4F5C","helper.moreActionsShown":"\u5DF2\u5C55\u5F00\u66F4\u591A\u64CD\u4F5C","helper.moreActionsHidden":"\u5DF2\u6536\u8D77\u989D\u5916\u64CD\u4F5C","helper.interactAction":"\u4EA4\u4E92","helper.scrollAction":"\u6EDA\u52A8","workbench.emptyTitle":"\u6682\u65E0\u6A21\u578B","workbench.emptyText":"\u4F7F\u7528\u201C\u5BFC\u5165 3D \u6A21\u578B\u201D\u547D\u4EE4\u52A0\u8F7D GLB\u3001GLTF \u6216 STL \u6587\u4EF6\u3002","workbench.modelTitle":"3D \u6A21\u578B","workbench.noModelLoaded":"\u5C1A\u672A\u52A0\u8F7D\u6A21\u578B","workbench.disassemblyTitle":"\u5206\u89E3","workbench.explodeLabel":"\u7206\u70B8","workbench.summaryTitle":"\u6458\u8981","workbench.meshesLabel":"\u7F51\u683C","workbench.splatsLabel":"\u70B9\u4E91","workbench.trianglesLabel":"\u4E09\u89D2\u5F62","workbench.materialsLabel":"\u6750\u8D28","workbench.tagsTitle":"\u6807\u7B7E","workbench.noTagsYet":"\u8FD8\u6CA1\u6709\u6807\u7B7E","workbench.addTagPlaceholder":"\u6DFB\u52A0\u6807\u7B7E...","workbench.addTagAction":"\u6DFB\u52A0","workbench.annotationsTitle":"\u6807\u6CE8","workbench.exitAnnotate":"\u9000\u51FA\u6807\u6CE8","workbench.annotate":"\u6807\u6CE8","workbench.annotateHintActive":"\u70B9\u51FB\u6A21\u578B\u6DFB\u52A0\u6807\u7B7E \xB7 \u6309 Esc \u9000\u51FA","workbench.annotateHintActiveMobile":"\u70B9\u6309\u6A21\u578B\u6DFB\u52A0\u6807\u7B7E\u3002\u9700\u8981\u7EE7\u7EED\u9605\u8BFB\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","workbench.pinCount":"{count} \u4E2A\u6807\u6CE8","workbench.editAction":"\u7F16\u8F91","workbench.deleteAction":"\u5220\u9664","workbench.resetViewAction":"\u91CD\u7F6E\u89C6\u56FE","workbench.insertInfoAction":"\u63D2\u5165\u4FE1\u606F","workbench.playAction":"\u64AD\u653E","workbench.pauseAction":"\u6682\u505C","workbench.saveProfileAction":"\u4FDD\u5B58\u914D\u7F6E","workbench.generateNoteAction":"\u751F\u6210\u7B14\u8BB0","workbench.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u64CD\u4F5C\u6A21\u578B\u65F6\u70B9\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u7B14\u8BB0\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","workbench.mobileHintInteractive":"\u5F53\u524D\u4E3A\u4EA4\u4E92\u6A21\u5F0F\u3002\u9700\u8981\u7EE7\u7EED\u6EDA\u52A8\u7B14\u8BB0\u65F6\uFF0C\u8BF7\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","directView.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u4F7F\u7528\u4E0B\u65B9\u5DE5\u5177\u680F\u91CC\u7684\u201C\u4EA4\u4E92\u201D\u6309\u94AE\uFF0C\u5728\u6A21\u578B\u64CD\u4F5C\u548C\u7B14\u8BB0\u6EDA\u52A8\u4E4B\u95F4\u5207\u6362\u3002","workbench.fileNotFound":"\u672A\u627E\u5230\u6587\u4EF6\uFF1A{path}","annotation.selectColor":"\u9009\u62E9\u989C\u8272 {color}","annotation.sectionEmpty":"\u8BE5\u6BB5\u5185\u5BB9\u4E3A\u7A7A\u3002","modal.selectModel":"\u9009\u62E9\u4E00\u4E2A 3D \u6A21\u578B...","main.ribbonOpenWorkbench":"\u6253\u5F00 3D \u5DE5\u4F5C\u53F0","main.commandImportModel":"\u5BFC\u5165 3D \u6A21\u578B","main.commandOpenWorkbench":"\u6253\u5F00 3D \u5DE5\u4F5C\u53F0","main.commandGenerateNote":"\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0","main.commandClearConversionCache":"\u6E05\u9664\u8F6C\u6362\u7F13\u5B58","main.commandCheckConverters":"\u68C0\u67E5\u8F6C\u6362\u5668","main.converterDiagnosticsMobileUnavailable":"\u8F6C\u6362\u5668\u8BCA\u65AD\u4EC5\u652F\u6301\u684C\u9762\u7AEF\u3002\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\uFF0C\u76F4\u8BFB\u683C\u5F0F\u4ECD\u53EF\u52A0\u8F7D\u3002","codeBlock.noModelPathOrConfig":"\u672A\u6307\u5B9A\u6A21\u578B\u8DEF\u5F84\u6216\u914D\u7F6E\u3002","codeBlock.jsonParseError":"JSON \u89E3\u6790\u9519\u8BEF\uFF1A{error}","codeBlock.jsonParseLine":"\uFF08\u7B2C {line} \u884C\uFF09","codeBlock.noModelsInConfig":"\u914D\u7F6E\u4E2D\u672A\u6307\u5B9A\u6A21\u578B\u3002","codeBlock.unsupportedFormat":"\u4E0D\u652F\u6301\u7684\u683C\u5F0F\uFF1A{ext}\u3002\u652F\u6301\uFF1A{formats}","codeBlock.noConfigSpecified":"\u672A\u6307\u5B9A\u914D\u7F6E\u3002","codeBlock.noModelsSpecified":"\u672A\u6307\u5B9A\u6A21\u578B\u3002","codeBlock.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u64CD\u4F5C\u6A21\u578B\u65F6\u70B9\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u7B14\u8BB0\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","codeBlock.renderingGrid":"\u6B63\u5728\u6E32\u67D3\u7F51\u683C...","codeBlock.composeRequiresSections":"\u201Ccompose\u201D \u9884\u8BBE\u9700\u8981\u63D0\u4F9B \u201Csections\u201D \u6570\u7EC4\u3002","codeBlock.composeNoValidSections":"Compose\uFF1A\u6CA1\u6709\u6709\u6548\u7684\u5206\u6BB5\u3002","codeBlock.unknownPreset":"\u672A\u77E5\u9884\u8BBE\uFF1A\u201C{preset}\u201D\u3002\u53EF\u7528\uFF1Acompare\u3001showcase\u3001explode\u3001timeline\u3001compose","codeBlock.presetRequiresModels":"\u9884\u8BBE \u201C{preset}\u201D \u9700\u8981 {min}-{max} \u4E2A\u6A21\u578B\uFF0C\u5F53\u524D\u4E3A {count} \u4E2A\u3002","codeBlock.gridFailed":"\u7F51\u683C\u6E32\u67D3\u5931\u8D25\uFF1A{reason}","livePreview.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u62D6\u52A8\u6A21\u578B\u65F6\u5207\u5230\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","loading.default":"\u52A0\u8F7D\u4E2D...","loading.preparingModel":"\u6B63\u5728\u51C6\u5907\u6A21\u578B...","loading.loadingModel":"\u6B63\u5728\u52A0\u8F7D\u6A21\u578B..."}});function cd(n){FU=n;for(let e of IA)e()}function Z(n){var e,t,i;return(i=(t=(e=qY[FU])==null?void 0:e[n])!=null?t:RA[n])!=null?i:n}function wU(n){return IA.add(n),()=>{IA.delete(n)}}function QY(n,e){return n.replace(/\{(\w+)\}/g,(t,i)=>{var r;return(r=e[i])!=null?r:""})}function Jt(n,e){return QY(Z(n),e)}var qY,FU,IA,Jr=A(()=>{"use strict";PU();NU();qY={en:RA,"zh-CN":OU},FU="en",IA=new Set});function $Y(){return`pin-${Date.now()}-${JY++}`}var fd,Dc,JY,Qn,Jn,dd=A(()=>{"use strict";fd=require("obsidian");ve();oA();Jr();Js();Dc=["#4a9eff","#ff6b6b","#51cf66","#ffd43b","#845ef7","#ff922b","#22b8cf","#f06595","#94d82d","#ffa8a8"],JY=1;Qn=class Qn{constructor(e,t,i,r,s,a,o,l={}){this.provider=e;this.hostEl=t;this.mode=i;this.onChange=s;this.noteReader=a;this.headingSearch=o;this.pinEls=new Map;this.observer=null;this.resizeObs=null;this.annotations=[];this.editorEl=null;this.disposeCallbacks=[];this.frameCount=0;this.lastCamState="";this.idleFrames=0;this.cameraIdle=!1;this.hoverPopover=null;this.hoverTimeout=null;this.hoverRequestId=0;this._highlightHandler=null;this._pulseTimeout=null;this._headingDropdown=null;this._headingDebounce=null;this._selectedHeading=null;this.previewRenderRoot=new fd.Component;this.previewRenderChildren=new WeakMap;var c;this.previewApp=l.app,this.previewMode=(c=l.previewMode)!=null?c:"plain-text",this.previewRenderRoot.load(),this.overlay=this.hostEl.createDiv({cls:"ai3d-annotation-overlay"}),this.setAnnotations(r),this._highlightHandler=f=>{let d=f.detail,h=d==null?void 0:d.pinId;h&&this.pulsePin(h)},activeDocument.addEventListener("ai3d-pin-highlight",this._highlightHandler),this.disposeCallbacks.push(()=>activeDocument.removeEventListener("ai3d-pin-highlight",this._highlightHandler)),this.disposeCallbacks.push(()=>this.previewRenderRoot.unload()),this.startProjectionLoop()}setAnnotations(e){for(let[,t]of this.pinEls)t.el.remove();this.pinEls.clear(),this.annotations=[...e];for(let t of e)this.createPinElement(t);this.updateProjections()}addPin(e,t,i){var s;let r={id:$Y(),position:[e.x,e.y,e.z],label:t,color:i!=null?i:Dc[this.annotations.length%Dc.length],createdAt:new Date().toISOString()};return this.annotations.push(r),this.createPinElement(r),this.updateProjections(),(s=this.onChange)==null||s.call(this,this.annotations),r}removePin(e){var i;let t=this.pinEls.get(e);t&&(t.el.remove(),this.pinEls.delete(e)),this.annotations=this.annotations.filter(r=>r.id!==e),(i=this.onChange)==null||i.call(this,this.annotations)}updatePin(e,t){var s;let i=this.annotations.find(a=>a.id===e);if(!i)return;Object.assign(i,t);let r=this.pinEls.get(e);if(r){t.position&&(r.worldPos=new v(...t.position));let a=r.el.querySelector(".ai3d-pin-label");a&&t.label!==void 0&&(a.textContent=t.label);let o=r.el.querySelector(".ai3d-pin-dot");o&&t.color!==void 0&&o.style.setProperty("--pin-color",t.color)}this.updateProjections(),(s=this.onChange)==null||s.call(this,this.annotations)}showEditor(e,t,i){this.showEditorInternal(e,t,i)}editPin(e){let t=this.annotations.find(o=>o.id===e);if(!t)return;let i=this.pinEls.get(e);if(!i)return;let r=i.el.getBoundingClientRect(),s=r.left+r.width/2,a=r.top;this.showEditorInternal(s,a,i.worldPos,t)}getPinPosition(e){let t=this.pinEls.get(e);return t?t.worldPos.clone():null}getAnnotations(){return this.annotations}showEditorInternal(e,t,i,r){var w,H;this.hideEditor(),this._selectedHeading=null;let s=this.overlay.createDiv({cls:"ai3d-annotation-editor"}),a=s.createDiv({cls:"ai3d-editor-input-wrap"}),o=a.createEl("input",{cls:"ai3d-annotation-editor-input"});o.type="text",o.placeholder=this.headingSearch?"Label or search heading...":"Label...",r&&(o.value=r.label);let l=a.createSpan({cls:"ai3d-editor-binding-tag is-hidden"}),c=l.createEl("button",{cls:"ai3d-editor-binding-clear"});c.textContent="\xD7",c.addEventListener("click",O=>{O.stopPropagation(),this._selectedHeading=null,l.classList.add("is-hidden"),f.classList.add("is-hidden"),f.textContent="",o.value="",o.focus()});let f=s.createDiv({cls:"ai3d-editor-content-preview is-hidden"}),d=s.createDiv({cls:"ai3d-heading-dropdown is-hidden"});this._headingDropdown=d;let h=-1,u=[],m=O=>{let V=d.querySelectorAll(".ai3d-heading-dropdown-item");V.forEach(X=>X.classList.remove("active")),h=O,O>=0&&O{var j;this._selectedHeading=O,o.value=O.heading;let V=Cr(O.notePath);(j=l.querySelector(".ai3d-editor-binding-text"))==null||j.remove();let X=l.createSpan({cls:"ai3d-editor-binding-text"});X.textContent=`\u{1F4C4} ${V}`,l.classList.remove("is-hidden"),_(),o.focus(),this.loadContentPreview(f,O.notePath,O.heading)},_=()=>{d.classList.add("is-hidden"),d.replaceChildren(),h=-1},g=O=>{if(d.replaceChildren(),h=-1,u=O,O.length===0){d.classList.add("is-hidden");return}for(let V=0;V{q.preventDefault(),q.stopPropagation(),p(X)}),j.addEventListener("mouseenter",()=>m(V))}d.classList.remove("is-hidden")};o.addEventListener("input",()=>{if(!this.headingSearch)return;this._headingDebounce&&window.clearTimeout(this._headingDebounce);let O=o.value.trim();if(O.length<1){_();return}this._headingDebounce=window.setTimeout(()=>{let V=this.headingSearch(O);g(V)},150)}),o.addEventListener("keydown",O=>{if(d.classList.contains("is-hidden")){O.key==="Enter"?(O.preventDefault(),x.click()):O.key==="Escape"&&(O.preventDefault(),this.hideEditor());return}let V=d.querySelectorAll(".ai3d-heading-dropdown-item");O.key==="ArrowDown"?(O.preventDefault(),m(Math.min(h+1,V.length-1))):O.key==="ArrowUp"?(O.preventDefault(),m(Math.max(h-1,0))):O.key==="Enter"?(O.preventDefault(),h>=0&&h{window.setTimeout(_,150)});let T=s.createDiv({cls:"ai3d-annotation-editor-colors"}),b=(w=r==null?void 0:r.color)==null?void 0:w.trim(),R=b||Dc[0],S=b&&!Dc.includes(b)?[b,...Dc]:Dc;for(let O of S){let V=T.createEl("button",{cls:"ai3d-pin-color-swatch"});V.type="button",V.title=O,V.setAttribute("aria-label",Jt("annotation.selectColor",{color:O})),V.style.setProperty("--swatch-color",O),V.style.backgroundColor=O,O===R&&V.classList.add("is-selected"),V.addEventListener("click",X=>{X.stopPropagation(),R=O,T.querySelectorAll(".ai3d-pin-color-swatch").forEach(j=>j.classList.remove("is-selected")),V.classList.add("is-selected")})}let I=s.createDiv({cls:"ai3d-annotation-editor-actions"});if(r){let O=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-delete"});O.textContent="Delete",O.addEventListener("click",V=>{V.stopPropagation(),this.removePin(r.id),this.hideEditor()})}let x=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-confirm"});x.textContent=r?"Save":"OK",x.addEventListener("click",O=>{O.stopPropagation();let V=o.value.trim()||"Pin",X=this._selectedHeading;if(r){let j={label:V,color:R};X&&(j.notePath=X.notePath,j.headingRef=X.heading,j.headingLevel=X.level),this.updatePin(r.id,j)}else{let j=this.addPin(i,V,R);X&&this.updatePin(j.id,{notePath:X.notePath,headingRef:X.heading,headingLevel:X.level})}this.hideEditor()});let P=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-cancel"});P.textContent="Cancel",P.addEventListener("click",O=>{O.stopPropagation(),this.hideEditor()});let L=this.overlay.getBoundingClientRect(),y=e-L.left,B=t-L.top;if(s.style.setProperty("--editor-left",`${Math.max(0,Math.min(y,L.width-220))}px`),s.style.setProperty("--editor-top",`${Math.max(0,Math.min(B-10,L.height-160))}px`),this.editorEl=s,r!=null&&r.notePath&&(r!=null&&r.headingRef)){let O=Cr(r.notePath),V=l.createSpan({cls:"ai3d-editor-binding-text"});V.textContent=`\u{1F4C4} ${O}`,l.classList.remove("is-hidden"),this._selectedHeading={notePath:r.notePath,heading:r.headingRef,level:(H=r.headingLevel)!=null?H:2},this.loadContentPreview(f,r.notePath,r.headingRef)}window.requestAnimationFrame(()=>o.focus()),s.addEventListener("pointerdown",O=>O.stopPropagation()),s.addEventListener("mousedown",O=>O.stopPropagation())}hideEditor(){if(this._headingDebounce&&(window.clearTimeout(this._headingDebounce),this._headingDebounce=null),this._headingDropdown=null,this._selectedHeading=null,this.editorEl){let e=this.editorEl.querySelector(".ai3d-editor-content-preview");e&&this.clearRenderedPreview(e),this.editorEl.remove(),this.editorEl=null}}async loadContentPreview(e,t,i){if(!this.noteReader)return;this.clearRenderedPreview(e),e.classList.add("is-hidden");let r=await this.noteReader(t,i);if(!r){e.textContent=Z("annotation.sectionEmpty"),e.className="ai3d-editor-content-preview ai3d-editor-content-preview--empty",e.classList.remove("is-hidden");return}await this.renderPreviewContent(e,r,t,"editor")}async showHoverPopover(e,t,i){if(!this.noteReader||!i.notePath||!i.headingRef)return;this.hideHoverPopover();let r=await this.noteReader(i.notePath,i.headingRef);if(!r||e!==this.hoverRequestId||!t.isConnected||!this.hostEl.isConnected)return;let s=createDiv({cls:"ai3d-pin-popover"}),a=s.createDiv({cls:"ai3d-pin-popover-title"});a.textContent=i.headingRef;let o=s.createDiv({cls:"ai3d-pin-popover-body"});if(await this.renderPreviewContent(o,r,i.notePath,"popover"),e!==this.hoverRequestId||!t.isConnected||!this.hostEl.isConnected){this.clearRenderedPreview(o);return}let l=t.getBoundingClientRect();s.style.setProperty("--popover-left",`${l.left+l.width/2}px`),s.style.setProperty("--popover-top",`${l.bottom+4}px`),activeDocument.body.appendChild(s),this.hoverPopover=s}hideHoverPopover(){if(this.hoverTimeout&&(window.clearTimeout(this.hoverTimeout),this.hoverTimeout=null),this.hoverPopover){let e=this.hoverPopover.querySelector(".ai3d-pin-popover-body");e&&this.clearRenderedPreview(e),this.hoverPopover.remove(),this.hoverPopover=null}}clearRenderedPreview(e){let t=this.previewRenderChildren.get(e);t&&(this.previewRenderRoot.removeChild(t),this.previewRenderChildren.delete(e)),e.replaceChildren()}async renderPreviewContent(e,t,i,r){let s=this.previewMode==="markdown"&&!!this.previewApp,a=r==="editor";if(!s){let l=a&&t.length>300?t.slice(0,300)+"...":t;e.textContent=l,e.className=a?"ai3d-editor-content-preview":"ai3d-pin-popover-body",a&&e.classList.remove("is-hidden");return}e.className=a?"ai3d-editor-content-preview ai3d-editor-content-preview--markdown markdown-rendered":"ai3d-pin-popover-body ai3d-pin-popover-body--markdown markdown-rendered",a&&e.classList.remove("is-hidden");let o=this.previewRenderRoot.addChild(new fd.Component);this.previewRenderChildren.set(e,o);try{await fd.MarkdownRenderer.render(this.previewApp,t,e,i,o)}catch(l){this.previewRenderRoot.removeChild(o),this.previewRenderChildren.delete(e),e.textContent=a&&t.length>300?t.slice(0,300)+"...":t,e.className=a?"ai3d-editor-content-preview":"ai3d-pin-popover-body",a&&e.classList.remove("is-hidden"),console.warn("[AI3D] Annotation markdown preview fallback:",l)}}pulsePin(e){let t=this.pinEls.get(e);t&&(this._pulseTimeout&&(window.clearTimeout(this._pulseTimeout),this._pulseTimeout=null),t.el.classList.remove("ai3d-pin-pulse"),t.el.offsetWidth,t.el.classList.add("ai3d-pin-pulse"),this._pulseTimeout=window.setTimeout(()=>{t.el.classList.remove("ai3d-pin-pulse"),this._pulseTimeout=null},1200))}destroy(){var e,t,i;this.hoverRequestId++,this.hideHoverPopover(),this._pulseTimeout&&(window.clearTimeout(this._pulseTimeout),this._pulseTimeout=null),this._headingDebounce&&(window.clearTimeout(this._headingDebounce),this._headingDebounce=null),this._headingDropdown=null,this._selectedHeading=null,(e=this.observer)==null||e.remove(),this.observer=null,(t=this.resizeObs)==null||t.disconnect(),this.resizeObs=null;for(let r of this.disposeCallbacks)r();this.disposeCallbacks=[],this.overlay.remove(),this.pinEls.clear(),(i=this.editorEl)==null||i.remove(),this.editorEl=null}createPinElement(e){let t=this.overlay.createDiv({cls:"ai3d-annotation-pin"});t.dataset.pinId=e.id,t.createDiv({cls:"ai3d-pin-dot"}).style.setProperty("--pin-color",e.color);let r=t.createSpan({cls:"ai3d-pin-label"});if(r.textContent=e.label,this.mode==="edit"){let s=t.createEl("button",{cls:"ai3d-pin-delete"});s.textContent="\xD7",s.addEventListener("click",a=>{a.stopPropagation(),this.removePin(e.id)}),t.addEventListener("click",a=>{a.target.closest(".ai3d-pin-delete")||(a.stopPropagation(),this.editPin(e.id))})}t.addEventListener("pointerdown",s=>s.stopPropagation()),e.notePath&&e.headingRef&&this.noteReader&&(t.addEventListener("mouseenter",()=>{this.hoverTimeout&&window.clearTimeout(this.hoverTimeout);let s=++this.hoverRequestId;this.hoverTimeout=window.setTimeout(()=>{this.hoverTimeout=null,s===this.hoverRequestId&&this.showHoverPopover(s,t,e)},300)}),t.addEventListener("mouseleave",()=>{this.hoverTimeout&&(window.clearTimeout(this.hoverTimeout),this.hoverTimeout=null),this.hoverRequestId++,this.hideHoverPopover()})),this.pinEls.set(e.id,{el:t,worldPos:new v(...e.position)})}startProjectionLoop(){let e=this.provider.scene,t=e.onAfterRenderCameraObservable.add(i=>{i===this.provider.camera&&this.updateProjections()});this.observer={remove:()=>e.onAfterRenderCameraObservable.remove(t)},this.resizeObs=new ResizeObserver(()=>this.updateProjections()),this.provider.canvas&&this.resizeObs.observe(this.provider.canvas)}updateProjections(){if(this.pinEls.size===0)return;let{scene:e,camera:t,engine:i,canvas:r}=this.provider;if(!this.hostEl.isConnected||!r.isConnected||r.clientWidth===0||r.clientHeight===0||e.isDisposed)return;let s=i.getRenderWidth(),a=i.getRenderHeight();if(s===0||a===0)return;let o=r.clientWidth,l=r.clientHeight,c=o/s,f=l/a,d=e.getTransformMatrix(),h=t.viewport.toGlobal(s,a),u=`${t.alpha.toFixed(3)}_${t.beta.toFixed(3)}_${t.radius.toFixed(3)}_${t.target.x.toFixed(2)}_${t.target.y.toFixed(2)}_${t.target.z.toFixed(2)}`;u===this.lastCamState?this.idleFrames++:(this.idleFrames=0,this.cameraIdle=!1),this.lastCamState=u,this.idleFrames>=Qn.IDLE_THRESHOLD&&!this.cameraIdle&&(this.cameraIdle=!0),this.frameCount++;let m=this.cameraIdle?1:this.pinEls.size>=12?3:2;if(!this.cameraIdle&&this.frameCount%m!==0)return;let p=this.cameraIdle&&this.frameCount%6===0,_=p?t.position:null,g=Qn._identity,T=Qn._scratchDir,b=Qn._scratchRay;for(let[,R]of this.pinEls){let S=v.Project(R.worldPos,g,d,h);if(S.z>1||S.z<0)this.hidePin(R.el);else if(R.el.style.setProperty("--pin-left",`${S.x*c}px`),R.el.style.setProperty("--pin-top",`${S.y*f}px`),p&&_){let I=v.Distance(_,R.worldPos);R.worldPos.subtractToRef(_,T),T.normalize(),b.origin=_,b.direction=T,b.length=I;let x=e.pickWithRay(b),P=Math.max(I*.01,.01),L=!!(x!=null&&x.hit)&&x.distance=5&&((a||!h&&s===5)&&(l.push(s,0,a,r),s=6),h&&(l.push(s,h,0,r),s=6)),a=""},f=0;f"?(s=1,a=""):a=i+a[0]:o?i===o?o="":a+=i:i==='"'||i==="'"?o=i:i===">"?(c(),s=1):s&&(i==="="?(s=5,r=a,a=""):i==="/"&&(s<5||t[f][d+1]===">")?(c(),s===3&&(l=l[0]),s=l,(l=l[0]).push(2,0,s),s=0):i===" "||i===" "||i===` -`||i==="\r"?(c(),s=2):a+=i),s===3&&a==="!--"&&(s=4,l=l[0])}return c(),l})(n)),e),arguments,[])).length>1?e:e[0]}var UU,BU,GU=A(()=>{UU=function(n,e,t,i){var r;e[0]=0;for(var s=1;s{"use strict"});var Zi,zU=A(()=>{"use strict";GU();HU();Zi=VU.bind(kU)});function xA(n){YU=n}function up(n){return XU[n]>=XU[YU]}function mp(){return new Date().toISOString()}function pp(n){return n&&Object.keys(n).length>0?n:void 0}function ti(n){let e=`[AI3D][${n}]`;return{debug(t,i){up("debug")&&console.debug(e,mp(),t,pp(i))},info(t,i){up("info")&&console.debug(e,mp(),t,pp(i))},warn(t,i){up("warn")&&console.warn(e,mp(),t,pp(i))},error(t,i){up("error")&&console.error(e,mp(),t,pp(i))}}}var XU,YU,Mr=A(()=>{"use strict";XU={debug:10,info:20,warn:30,error:40},YU="warn"});function KU(n){let e=xn(n.sourceExt),t=[];return e!==n.sourceExt&&t.push(`Normalized extension '${n.sourceExt}' -> '${e}'.`),e8.debug("prepare direct load",{path:n.path,sourceExt:n.sourceExt,normalizedExt:e,warningCount:t.length}),{effectivePath:n.path,effectiveExt:e,warnings:t}}var e8,jU=A(()=>{"use strict";ts();Mr();e8=ti("direct-load-service")});function _p(n){return`.${n.trim().toLowerCase()}`}function Za(n){return n instanceof Ho}function CA(n){var e;if(n instanceof Ho){let t=(e=t8[n.converterId])!=null?e:n.converterId;return Jt("modelLoad.warningMessage",{ext:_p(n.sourceExt),converterName:t})}return n instanceof Lc?Jt("modelLoad.mobileWarningMessage",{ext:_p(n.sourceExt)}):Jt("modelLoad.errorMessage",{reason:n instanceof Error?n.message:String(n)})}function qa(n){return n instanceof Ho?{level:"warning",title:Z("modelLoad.warningTitle"),message:CA(n),hint:Z("modelLoad.warningHint")}:n instanceof Lc?{level:"warning",title:Z("modelLoad.warningTitle"),message:CA(n),hint:Z("modelLoad.mobileWarningHint")}:{level:"error",title:Z("modelLoad.errorTitle"),message:CA(n),hint:Z("modelLoad.errorHint")}}var t8,Ho,Lc,zo=A(()=>{"use strict";Jr();t8={freecad:"FreeCAD",obj2gltf:"obj2gltf",fbx2gltf:"FBX2glTF",assimp:"mesh",sldprt:"SolidWorks"};Ho=class extends Error{constructor(t,i){super(`Converter '${t}' is not registered for ${_p(i)}. Enable the matching converter in plugin settings before loading this format.`);this.converterId=t;this.sourceExt=i;this.name="MissingConverterError"}},Lc=class extends Error{constructor(t){super(`Format ${_p(t)} requires local conversion tools that are unavailable on iOS, iPadOS, and Android.`);this.sourceExt=t;this.name="MobileConversionUnavailableError"}}});function r8(n,e,t){return n.converterId!==e?!1:t?n.converterId===t.converterId&&n.converterCacheKey===t.cacheKey:!0}async function n8(n){if(!n)return!1;try{return await ur(n,mr),!0}catch(e){return!1}}async function ZU(n){var a,o,l,c,f,d,h;if(n.capability.strategy!=="convert")throw new Error(`Expected convert strategy, got '${n.capability.strategy}'.`);let e=n.capability.converterId,t=(a=n.capability.outputFormat)!=null?a:"glb";if(!e)throw new Error(`Format .${n.sourceExt} does not define a converter id.`);hd.info("prepare conversion route",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,converterId:e});let i=n.conversionManager.canConvert(n.sourceExt)?await n.conversionManager.getConverterCacheIdentity(n.sourceExt):void 0,r=(o=n.convertedAssetCache)==null?void 0:o.get(n.sourcePath,n.sourceExt,t);if(r)if(!await n8(r.outputPath))hd.warn("conversion cache stale",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:r.outputPath}),(l=n.convertedAssetCache)==null||l.delete(n.sourcePath,n.sourceExt,t);else if(!r8(r,e,i))hd.warn("conversion cache identity mismatch",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,cachedConverterId:r.converterId,cachedConverterCacheKey:r.converterCacheKey,currentConverterId:(c=i==null?void 0:i.converterId)!=null?c:e,currentConverterCacheKey:i==null?void 0:i.cacheKey}),(f=n.convertedAssetCache)==null||f.delete(n.sourcePath,n.sourceExt,t);else return hd.info("conversion cache hit",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:r.outputPath}),{effectivePath:r.outputPath,effectiveExt:r.outputExt,warnings:[...r.warnings,"Using cached conversion output."]};if(!n.conversionManager.canConvert(n.sourceExt))throw new Ho(e,n.sourceExt);let s=await n.conversionManager.convert({sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t});return(h=n.convertedAssetCache)==null||h.set({cacheVersion:2,converterId:e,converterCacheKey:(d=i==null?void 0:i.cacheKey)!=null?d:e,sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:s.outputPath,outputExt:s.outputExt,warnings:s.warnings,createdAt:Date.now()}),hd.info("conversion route done",{sourcePath:n.sourcePath,outputPath:s.outputPath,warningCount:s.warnings.length}),{effectivePath:s.outputPath,effectiveExt:s.outputExt,warnings:s.warnings}}var hd,qU=A(()=>{"use strict";zp();Mr();Gt();zo();hd=ti("conversion-service")});function s8(n,e){var t;return!!((t=n.preferConversionExts)!=null&&t.includes(e))}async function ta(n){var a,o;let e=xn((a=n.path.split(".").pop())!=null?a:""),t=Xp(e);if(ea.info("prepare model input",{path:n.path,sourceExt:e}),!t||!t.enabled)throw ea.warn("unsupported format",{sourceExt:e,path:n.path}),new Error(`Unsupported format: .${e}`);let i=s8(n,e);if(t.strategy==="convert"||i&&!!t.converterId){if(Qt())throw ea.warn("conversion unavailable on mobile",{sourceExt:e,path:n.path}),new Lc(e);if(!n.absolutePath)throw ea.error("filesystem path missing for conversion",{sourceExt:e,path:n.path}),new Error(`Format .${e} requires a local filesystem path for conversion, but none was resolved for '${n.path}'.`);if(!n.conversionManager)throw ea.error("conversion manager missing",{sourceExt:e,path:n.path}),new Error(`Format .${e} requires conversion support, but no conversion manager is available.`);let l=t.strategy==="convert"?t:{...t,strategy:"convert",outputFormat:(o=t.outputFormat)!=null?o:"glb"};if(!l.converterId)throw ea.error("preferred conversion route missing converter id",{sourceExt:e,path:n.path}),new Error(`Format .${e} is configured to prefer conversion, but no converter id is defined.`);i&&t.strategy==="direct"&&ea.info("preferred conversion route",{sourceExt:e,path:n.path,converterId:l.converterId});let c=await ZU({sourcePath:n.absolutePath,sourceExt:e,capability:l,conversionManager:n.conversionManager,convertedAssetCache:n.convertedAssetCache});return ea.info("conversion completed",{sourceExt:e,outputExt:c.effectiveExt,outputPath:c.effectivePath,warningCount:c.warnings.length}),{sourcePath:n.path,sourceExt:e,strategy:"convert",effectivePath:c.effectivePath,effectiveExt:c.effectiveExt,warnings:c.warnings}}let s=KU({path:n.path,sourceExt:e});return ea.debug("direct route",{sourceExt:e,path:n.path,warningCount:s.warnings.length}),{sourcePath:n.path,sourceExt:e,strategy:t.strategy,effectivePath:s.effectivePath,effectiveExt:s.effectiveExt,warnings:s.warnings}}var ea,ud=A(()=>{"use strict";ts();jU();qU();zo();Mr();jr();ea=ti("model-pipeline")});var md,gp,QU=A(()=>{"use strict";ts();Mr();md=ti("conversion-manager"),gp=class{constructor(){this.converters=new Map;this.pending=new Map}getConverter(e){return this.converters.get(xn(e))}registerConverter(e){md.info("register converter",{converterId:e.id,sourceExts:[...e.sourceExts]});for(let t of e.sourceExts)this.converters.set(xn(t),e)}canConvert(e){let t=xn(e),i=this.converters.has(t);return md.debug("can convert",{ext:t,ok:i}),i}async getConverterCacheIdentity(e){let t=this.getConverter(e);if(t)return{converterId:t.id,cacheKey:await t.getCacheKey()}}async convert(e){let t=xn(e.sourceExt),i=this.getConverter(t);if(!i)throw md.error("converter missing",{ext:t,targetExt:e.targetExt}),new Error(`No converter registered for .${t}`);let r=`${e.sourcePath}::${t}::${e.targetExt}`,s=this.pending.get(r);if(s)return md.info("joining in-flight conversion",{key:r}),s;md.info("dispatch conversion",{converterId:i.id,ext:t,targetExt:e.targetExt});let a=i.convert({...e,sourceExt:t});this.pending.set(r,a);try{return await a}finally{this.pending.delete(r)}}}});function yA(...n){let e=(Te==null?void 0:Te.platform)==="darwin"?["/opt/homebrew/bin","/usr/local/bin","/opt/local/bin","/usr/bin"]:["/usr/local/bin","/opt/homebrew/bin","/opt/local/bin","/usr/bin"];return Array.from(new Set(e.flatMap(t=>n.map(i=>`${t}/${i}`))))}function o8(){var r,s,a;if((Te==null?void 0:Te.platform)==="darwin")return["/Applications/FreeCAD.app/Contents/MacOS/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/freecadcmd",...yA("FreeCADCmd","freecadcmd")];if((Te==null?void 0:Te.platform)!=="win32")return["/usr/local/bin/freecadcmd","/opt/homebrew/bin/freecadcmd","/opt/local/bin/freecadcmd","/snap/freecad/current/usr/bin/freecadcmd","/usr/bin/freecadcmd"];let n=[],e=(r=Te==null?void 0:Te.env)==null?void 0:r.LOCALAPPDATA,t=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles,i=(a=Te==null?void 0:Te.env)==null?void 0:a["ProgramFiles(x86)"];if(e&&n.push(Pt(e,"Programs","FreeCAD","bin","FreeCADCmd.exe")),t&&n.push(Pt(t,"FreeCAD","bin","FreeCADCmd.exe")),e)for(let o of["1.2","1.1","1.0","0.22","0.21","0.20"])n.push(`${e}/Programs/FreeCAD ${o}/bin/FreeCADCmd.exe`);if(t)for(let o of["1.2","1.1","1.0","0.22","0.21","0.20"])n.push(`${t}/FreeCAD ${o}/bin/FreeCADCmd.exe`);return i&&n.push(`${i}/FreeCAD/bin/FreeCADCmd.exe`),n}function l8(n){var a,o,l,c;if((Te==null?void 0:Te.platform)!=="win32")return[];let e=(a=Te==null?void 0:Te.env)==null?void 0:a.APPDATA,t=(o=Te==null?void 0:Te.env)==null?void 0:o.LOCALAPPDATA,i=(l=Te==null?void 0:Te.env)==null?void 0:l.npm_config_prefix,r=(c=Te==null?void 0:Te.env)==null?void 0:c.USERPROFILE,s=[i,e?Pt(e,"npm"):void 0,t?Pt(t,"npm"):void 0,r?Pt(r,"AppData","Roaming","npm"):void 0].filter(f=>!!f);return Array.from(new Set(s.map(f=>Pt(f,n))))}function c8(...n){var s,a,o;if((Te==null?void 0:Te.platform)!=="win32")return[];let e=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles,t=(a=Te==null?void 0:Te.env)==null?void 0:a["ProgramFiles(x86)"],i=(o=Te==null?void 0:Te.env)==null?void 0:o.LOCALAPPDATA,r=[e,t,i?Pt(i,"Programs"):void 0].filter(l=>!!l);return Array.from(new Set(r.flatMap(l=>n.map(c=>Pt(l,c)))))}async function PA(n){try{return await ur(n,(Te==null?void 0:Te.platform)==="win32"?mr:fU),!0}catch(e){return!1}}function bA(n){let e=n==null?void 0:n.trim();if(e)return e}function f8(n){let e=[],t="",i=null;for(let r=0;rr.trim().toLowerCase()).filter(Boolean);return e!=null&&e.length?e:a8}async function m8(n){var r;let e=(r=Te==null?void 0:Te.env)==null?void 0:r.PATH;if(!e)return;let t=e.split(dU).map(s=>s.trim()).filter(Boolean),i=(Te==null?void 0:Te.platform)==="win32"?u8(n):[""];for(let s of t)for(let a of i){let o=Pt(s,a?`${n}${a}`:n);if(await PA(o))return o}}function DA(n,e,t=15e3){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:4*1024*1024},(s,a,o)=>{if(s){r(new Error((o||a||s.message).toString().trim()||s.message));return}i({stdout:a!=null?a:"",stderr:o!=null?o:""})})})}function LA(n){let t=(n instanceof Error?n.message:String(n)).replace(/\s+/g," ").trim();return t.length>180?`${t.slice(0,177)}...`:t}async function MA(n,e,t,i){let r="";for(let s of t)try{return await DA(n,[...e,...s]),{ok:!0,detail:""}}catch(a){let o=LA(a);if(i.test(o))return{ok:!0,detail:""};r=o}return{ok:!1,detail:r||"Command probe failed."}}async function p8(n){var i;if(!n.available)return[];let e=(i=n.resolvedPath)!=null?i:n.executable,t=[...n.args];if(n.id==="freecad")try{return await DA(e,[...t,"-c","import cadquery, trimesh; print('ok')"]),[{kind:"cad-python",ok:!0,detail:""}]}catch(r){return[{kind:"cad-python",ok:!1,detail:LA(r)}]}if(n.id==="assimp")try{return await DA(e,[...t,"-c","import trimesh, numpy, networkx, collada; print('ok')"]),[{kind:"mesh-python",ok:!0,detail:""}]}catch(r){return[{kind:"mesh-python",ok:!1,detail:LA(r)}]}if(n.id==="freecadcmd"){let r=await MA(e,t,[["--version"],["--help"]],/freecad|usage|help|version/i);return[{kind:"freecadcmd-cli",ok:r.ok,detail:r.detail}]}if(n.id==="obj2gltf"){let r=await MA(e,t,[["--version"],["--help"]],/obj2gltf|usage|help|version/i);return[{kind:"obj2gltf-cli",ok:r.ok,detail:r.detail}]}if(n.id==="fbx2gltf"){let r=await MA(e,t,[["--version"],["--help"]],/fbx2gltf|usage|help|version/i);return[{kind:"fbx2gltf-cli",ok:r.ok,detail:r.detail}]}return[]}function _8(n){let e=$U.find(t=>t.id===n);if(!e)throw new Error(`Unknown converter command id: ${n}`);return e}function g8(n){var s,a,o,l;let e=(a=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles)==null?void 0:a.toLowerCase(),t=(l=(o=Te==null?void 0:Te.env)==null?void 0:o["ProgramFiles(x86)"])==null?void 0:l.toLowerCase(),i=[],r=[];for(let c of n.knownCandidates){let f=c.toLowerCase(),d=(Te==null?void 0:Te.platform)==="win32"&&((e?f.startsWith(e):!1)||(t?f.startsWith(t):!1)),h=(Te==null?void 0:Te.platform)!=="win32"&&(c.startsWith("/usr/bin/")||c.startsWith("/snap/freecad/current/usr/bin/"));d||h?r.push(c):i.push(c)}return{userCandidates:i,systemCandidates:r}}async function JU(n,e,t){for(let i of e)if(await PA(i))return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,command:i,executable:i,args:[],resolvedPath:i,available:!0,source:"candidate",detail:t,checkedCandidates:[i]}}function E8(n,e){let t=[];return n.length&&t.push(`Checked common user locations: ${n.join("; ")}`),e.length&&t.push(`Checked system fallback locations: ${e.join("; ")}`),t.join(". ")}async function Ep(n,e,t,i){let r=d8(e);if(h8(r.executable)){let a=await PA(r.executable);return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:a?r.executable:void 0,available:a,source:t,detail:a?`Using ${vp(t)} path.`:"Configured path was not found or is not executable.",checkedCandidates:[r.executable]}}let s=await m8(r.executable);return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:s,available:!!s,source:t,detail:s?`Resolved from ${vp(t)} via PATH lookup.`:"Command name was not found on PATH.",checkedCandidates:[r.executable]}}function vp(n){switch(n){case"settings":return"plugin settings";case"env":return"environment variable";case"candidate":return"known install location";case"path":return"PATH fallback"}}async function e2(n,e){var h,u,m;let t=_8(n),{userCandidates:i,systemCandidates:r}=g8(t),s=bA(e);if(s)return Ep(t,s,"settings",s);let a=bA((h=Te==null?void 0:Te.env)==null?void 0:h[t.envVar]);if(a)return Ep(t,a,"env");for(let p of(u=t.envVarAliases)!=null?u:[]){let _=bA((m=Te==null?void 0:Te.env)==null?void 0:m[p]);if(_)return Ep(t,_,"env")}let o=await JU(t,i,"Detected at a common user-managed install location.");if(o)return o;let l=[];for(let p of t.fallbackCommands){let _=await Ep(t,p,"path");if(l.push(_),_.available)return _}let c=await JU(t,r,"Detected at a system fallback install location.");if(c)return c;let f=l.flatMap(p=>p.checkedCandidates),d=E8(i,r);return{...l[0],detail:d?`Command name was not found on PATH. ${d}`:"Command name was not found on PATH.",checkedCandidates:[...i,...f,...r]}}async function Tp(n){let e=await Promise.all($U.map(t=>e2(t.id,n[t.settingsKey])));return Promise.all(e.map(async t=>({...t,dependencyChecks:await p8(t)})))}async function qi(n,e){var i;let t=await e2(n,e);return{command:(i=t.resolvedPath)!=null?i:t.executable,args:[...t.args]}}var Te,a8,$U,Qa=A(()=>{"use strict";Gt();Gt();Gt();Te=op(),a8=[".exe",".cmd",".bat",".com"];$U=[{id:"freecad",label:"Python (CadQuery/OCCT)",settingsKey:"freecadCommand",envVar:"AI3D_FREECAD_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?[]:["/usr/local/bin/python3","/opt/homebrew/bin/python3","/opt/local/bin/python3","/usr/bin/python3"]},{id:"obj2gltf",label:"obj2gltf",settingsKey:"obj2gltfCommand",envVar:"AI3D_OBJ2GLTF_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["obj2gltf.cmd"]:["obj2gltf"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?l8("obj2gltf.cmd"):yA("obj2gltf")},{id:"fbx2gltf",label:"FBX2glTF",settingsKey:"fbx2gltfCommand",envVar:"AI3D_FBX2GLTF_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["FBX2glTF.exe"]:["FBX2glTF","fbx2gltf"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?c8(Pt("FBX2glTF","FBX2glTF-windows-x64.exe"),Pt("FBX2glTF","FBX2glTF.exe")):yA("FBX2glTF","fbx2gltf")},{id:"assimp",label:"Python (trimesh)",settingsKey:"assimpCommand",envVar:"AI3D_ASSIMP_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?[]:["/usr/local/bin/python3","/opt/homebrew/bin/python3","/opt/local/bin/python3","/usr/bin/python3"]},{id:"freecadcmd",label:"FreeCAD (SLDPRT)",settingsKey:"freecadcmdCommand",envVar:"AI3D_FREECADCMD",envVarAliases:["AI3D_FREECMDCMD"],fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["FreeCADCmd.exe"]:["freecadcmd","FreeCADCmd"],knownCandidates:o8()}]});function ia(n){if(n.includes('"'))throw new Error(`File path contains double-quote character, not supported for Python conversion: ${n}`);return n.replace(/\\/g,"/")}var Sp=A(()=>{"use strict"});async function S8(n){try{return await ur(n,mr),!0}catch(e){return!1}}function A8(n,e,t){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`CAD conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function R8(n,e,t){let i=ia(n),r=ia(e),s=t.toLowerCase().replace(/^\./,""),a=s==="step"||s==="stp",o=s==="iges"||s==="igs",l=["import cadquery as cq","import trimesh","import trimesh.visual","import numpy as np","import sys","import os","",`src = r"${i}"`,`out = r"${r}"`,""];return a?l.push("from OCP.STEPCAFControl import STEPCAFControl_Reader","from OCP.STEPControl import STEPControl_Reader","from OCP.XCAFDoc import XCAFDoc_DocumentTool, XCAFDoc_ColorType, XCAFDoc_ShapeTool","from OCP.TDocStd import TDocStd_Document","from OCP.TCollection import TCollection_ExtendedString","from OCP.Quantity import Quantity_Color","from OCP.TDF import TDF_ChildIterator"):o&&l.push("from OCP.IGESControl import IGESControl_Reader"),l.push("from OCP.TopoDS import TopoDS","from OCP.TopAbs import TopAbs_FACE","from OCP.TopExp import TopExp_Explorer","from OCP.BRep import BRep_Tool","from OCP.BRepMesh import BRepMesh_IncrementalMesh","from OCP.TopLoc import TopLoc_Location","from OCP.IFSelect import IFSelect_RetDone"),a||l.push("from OCP.BRepTools import BRepTools"),l.push("","DEFAULT_COLOR = [180, 180, 180, 255]","","def triangulate_face(face, linear=0.1, angular=0.5):"," BRepMesh_IncrementalMesh(face, linear, False, angular, True)"," loc = TopLoc_Location()"," tri = BRep_Tool.Triangulation_s(face, loc)"," if tri is None:"," return None, None"," n = tri.NbNodes()"," verts = []"," for i in range(1, n + 1):"," p = tri.Node(i)"," if not loc.IsIdentity():"," p = p.Transformed(loc.Transformation())"," verts.append([p.X(), p.Y(), p.Z()])"," ntri = tri.NbTriangles()"," faces = []"," for i in range(1, ntri + 1):"," t = tri.Triangle(i)"," n1, n2, n3 = t.Get()"," faces.append([n1 - 1, n2 - 1, n3 - 1])"," return verts, faces"),a&&l.push("","def build_xde_color_lookup(step_path):",' """Load XDE with STEPCAFControl, extract per-face colors via surface signature."""'," from OCP.BRepAdaptor import BRepAdaptor_Surface"," lookup = {}"," try:"," reader = STEPCAFControl_Reader()"," reader.SetColorMode(True)"," reader.SetNameMode(True)"," status = reader.ReadFile(step_path)"," if status != IFSelect_RetDone:"," return lookup"," doc = TDocStd_Document(TCollection_ExtendedString('XmlOcaf'))"," reader.Transfer(doc)"," shape_tool = XCAFDoc_DocumentTool.ShapeTool_s(doc.Main())"," color_tool = XCAFDoc_DocumentTool.ColorTool_s(doc.Main())",""," def walk(label):"," if XCAFDoc_ShapeTool.IsShape_s(label):"," s = XCAFDoc_ShapeTool.GetShape_s(label)"," if s is not None and s.ShapeType() == TopAbs_FACE:"," c = Quantity_Color()"," if color_tool.GetColor(s, XCAFDoc_ColorType.XCAFDoc_ColorSurf, c):"," face = TopoDS.Face_s(s)"," try:"," adaptor = BRepAdaptor_Surface(face)"," u_r = (adaptor.FirstUParameter(), adaptor.LastUParameter())"," v_r = (adaptor.FirstVParameter(), adaptor.LastVParameter())"," key = (adaptor.GetType(), tuple(round(x, 4) for x in u_r), tuple(round(x, 4) for x in v_r))"," color = (c.Red(), c.Green(), c.Blue())"," if key not in lookup:"," lookup[key] = color"," except Exception:"," pass"," children = TDF_ChildIterator(label)"," while children.More():"," walk(children.Value())"," children.Next()",""," walk(doc.Main())"," except Exception as e:",' print(f"XDE color extraction failed: {e}", file=sys.stderr)'," return lookup","","def get_face_color(face, color_lookup):",' """Match a geometry face to an XDE face via surface signature, return color."""'," from OCP.BRepAdaptor import BRepAdaptor_Surface"," try:"," adaptor = BRepAdaptor_Surface(face)"," u_r = (adaptor.FirstUParameter(), adaptor.LastUParameter())"," v_r = (adaptor.FirstVParameter(), adaptor.LastVParameter())"," key = (adaptor.GetType(), tuple(round(x, 4) for x in u_r), tuple(round(x, 4) for x in v_r))"," return color_lookup.get(key)"," except Exception:"," return None"),l.push(""),a?l.push("# STEP: build XDE color lookup + load geometry","color_lookup = build_xde_color_lookup(src)",'print(f"XDE color lookup: {len(color_lookup)} surface signatures")',"","sr = STEPControl_Reader()","status = sr.ReadFile(src)","if status != IFSelect_RetDone:",' print(f"Failed to read STEP file: {src}", file=sys.stderr)'," sys.exit(1)","sr.TransferRoots()","shape = sr.OneShape()"):o?l.push("# IGES: load geometry (no XDE color support for IGES)","ir = IGESControl_Reader()","status = ir.ReadFile(src)","if status != IFSelect_RetDone:",' print(f"Failed to read IGES file: {src}", file=sys.stderr)'," sys.exit(1)","ir.TransferRoots()","shape = ir.OneShape()"):l.push("# BREP: load geometry from native OpenCascade format","from OCP.TopoDS import TopoDS_Shape","from OCP.BRep import BRep_Builder","shape = TopoDS_Shape()","builder = BRep_Builder()","success = BRepTools.Read_s(shape, src, builder)","if not success:",' print(f"Failed to read BREP file: {src}", file=sys.stderr)'," sys.exit(1)"),l.push("","all_verts = []","all_faces = []","all_colors = []","matched_count = 0","total_faces = 0","","exp = TopExp_Explorer(shape, TopAbs_FACE)","while exp.More():"," face = TopoDS.Face_s(exp.Current())"," total_faces += 1"," verts, faces = triangulate_face(face)"," if verts and faces:"," offset = len(all_verts)"," all_verts.extend(verts)"," for tri in faces:"," all_faces.append([tri[0] + offset, tri[1] + offset, tri[2] + offset])"),a?l.push(" color = get_face_color(face, color_lookup)"," if color:"," matched_count += 1"," r, g, b = color"," rgba = [int(r * 255), int(g * 255), int(b * 255), 255]"," else:"," rgba = DEFAULT_COLOR"):l.push(" rgba = DEFAULT_COLOR"),l.push(" n = len(verts)"," all_colors.extend([rgba] * n)"," exp.Next()","",'print(f"Triangulated: {total_faces} faces, {len(all_verts)} verts, {matched_count} colored ({matched_count*100//max(total_faces,1)}%)")',"","if not all_verts or not all_faces:"," # Fallback: use CadQuery import (works for STEP/IGES, not BREP)"),a?l.push(" cq_shape = cq.importers.importStep(src)"):o?l.push(" cq_shape = cq.importers.importStep(src) # CadQuery reads IGES via importStep"):l.push(" cq_shape = cq.importers.importStep(src) # CadQuery BREP import"),l.push(" cq.exporters.export(cq_shape, out, exportType='STL')"," mesh = trimesh.load(out)"," data = mesh.export(file_type='glb')"," if isinstance(data, str):"," with open(data, 'rb') as f:"," data = f.read()"," with open(out, 'wb') as f:"," f.write(data)",' print(f"Fallback CadQuery STL->GLB: {out} ({len(data)} bytes)")'," sys.exit(0)","","verts_arr = np.array(all_verts, dtype=float)","faces_arr = np.array(all_faces, dtype=int)","colors_arr = np.array(all_colors, dtype=np.uint8)","","mesh = trimesh.Trimesh("," vertices=verts_arr,"," faces=faces_arr,"," visual=trimesh.visual.ColorVisuals(vertex_colors=colors_arr),"," process=True,",")","mesh.fix_normals()","scene = trimesh.Scene([mesh])","","result = scene.export(file_type='glb')","if isinstance(result, bytes):"," data = result","elif isinstance(result, str):"," with open(result, 'rb') as f:"," data = f.read()","else:"," data = bytes(result)","","with open(out, 'wb') as f:"," f.write(data)","","print(f'Converted {src} -> {out} ({len(data)} bytes, {matched_count}/{total_faces} colored faces)')"),l.join(` -`)}var v8,T8,Ap,t2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Mr();Qa();Sp();v8=ti("freecad-converter"),T8=300*1e3;Ap=class{constructor(e){this.configuredCommand=e;this.id="freecad";this.sourceExts=["step","stp","iges","igs","brep"];this.targetExt="glb"}async getCacheKey(){let e=await qi(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!ji(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking CAD conversion.`);let t=await qi(this.id,this.configuredCommand),i=Zn(e.sourcePath),r=qn(e.sourcePath,qr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-freecad"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,R8(e.sourcePath,s,e.sourceExt),"utf8"),v8.info("run CAD conversion (CadQuery/OCCT)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await A8(t.command,[...t.args,o],T8)}catch(c){throw new Error(`CAD conversion failed for '${e.sourcePath}'. Ensure Python with cadquery is installed: pip install cadquery trimesh. Set Python command path in plugin settings or AI3D_FREECAD_CMD if Python is not discoverable. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await S8(s))throw new Error(`CAD conversion finished but output was not found: '${s}'. Check that CadQuery supports this CAD format.`);if((await Zr(s)).byteLength===0)throw new Error(`CAD conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/CadQuery(OCCT) bridge."]}}}});async function C8(n){try{return await ur(n,mr),!0}catch(e){return!1}}function b8(n,e,t){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`obj2gltf command failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var I8,x8,Rp,i2=A(()=>{"use strict";Gt();Gt();Gt();Mr();Qa();I8=ti("obj2gltf-converter"),x8=180*1e3;Rp=class{constructor(e){this.configuredCommand=e;this.id="obj2gltf";this.sourceExts=["obj"];this.targetExt="glb"}async getCacheKey(){let e=await qi(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!ji(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking obj2gltf.`);let t=await qi(this.id,this.configuredCommand),i=Zn(e.sourcePath),r=qn(e.sourcePath,qr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`);I8.info("run obj2gltf conversion",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await b8(t.command,[...t.args,"-i",e.sourcePath,"-o",s,"-b"],x8)}catch(o){throw new Error(`obj2gltf conversion failed for '${e.sourcePath}'. Set obj2gltf command path in plugin settings or AI3D_OBJ2GLTF_CMD if obj2gltf is not discoverable. ${o instanceof Error?o.message:String(o)}`)}if(!await C8(s))throw new Error(`obj2gltf conversion finished but output was not found: '${s}'.`);if((await Zr(s)).byteLength===0)throw new Error(`obj2gltf output file is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local obj2gltf CLI bridge."]}}}});async function D8(n){try{return await ur(n,mr),!0}catch(e){return!1}}function L8(n,e,t){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`FBX2glTF command failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var M8,y8,Ip,r2=A(()=>{"use strict";Gt();Gt();Gt();Mr();Qa();M8=ti("fbx2gltf-converter"),y8=180*1e3;Ip=class{constructor(e){this.configuredCommand=e;this.id="fbx2gltf";this.sourceExts=["fbx"];this.targetExt="glb"}async getCacheKey(){let e=await qi(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!ji(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking FBX2glTF.`);let t=await qi(this.id,this.configuredCommand),i=Zn(e.sourcePath),r=qn(e.sourcePath,qr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`);M8.info("run FBX2glTF conversion",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await L8(t.command,[...t.args,"-i",e.sourcePath,"-o",s,"-b"],y8)}catch(o){throw new Error(`FBX2glTF conversion failed for '${e.sourcePath}'. Set FBX2glTF command path in plugin settings or AI3D_FBX2GLTF_CMD if FBX2glTF is not discoverable. ${o instanceof Error?o.message:String(o)}`)}if(!await D8(s))throw new Error(`FBX2glTF conversion finished but output was not found: '${s}'.`);if((await Zr(s)).byteLength===0)throw new Error(`FBX2glTF output file is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local FBX2glTF CLI bridge."]}}}});async function N8(n){try{return await ur(n,mr),!0}catch(e){return!1}}function F8(n,e,t){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`mesh conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function w8(n,e){let t=ia(n),i=ia(e);return["import trimesh","import sys","",`src = r"${t}"`,`out = r"${i}"`,"","try:"," loaded = trimesh.load(src, force=None)","except Exception as e:",' print(f"Failed to load {src}: {e}", file=sys.stderr)'," sys.exit(1)","","if isinstance(loaded, trimesh.Scene):"," scene = loaded","elif isinstance(loaded, trimesh.Trimesh):"," scene = trimesh.Scene([loaded])","else:",' print(f"Unsupported type: {type(loaded)}", file=sys.stderr)'," sys.exit(1)","","try:"," data = scene.export(file_type='glb')","except Exception as e:",' print(f"Failed to export GLB: {e}", file=sys.stderr)'," sys.exit(1)","","with open(out, 'wb') as f:"," f.write(data)","","print(f'Converted {src} -> {out} ({len(data)} bytes)')"].join(` -`)}var P8,O8,xp,n2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Mr();Qa();Sp();P8=ti("assimp-converter"),O8=300*1e3;xp=class{constructor(e){this.configuredCommand=e;this.id="assimp";this.sourceExts=["3mf","dae"];this.targetExt="glb"}async getCacheKey(){let e=await qi(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!ji(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking mesh conversion.`);let t=await qi(this.id,this.configuredCommand),i=Zn(e.sourcePath),r=qn(e.sourcePath,qr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-mesh-convert"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,w8(e.sourcePath,s),"utf8"),P8.info("run mesh conversion (trimesh)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await F8(t.command,[...t.args,o],O8)}catch(c){throw new Error(`Mesh conversion failed for '${e.sourcePath}'. Ensure Python with trimesh is installed: pip install trimesh numpy networkx pycollada. Set Python command path in plugin settings or AI3D_ASSIMP_CMD if Python is not discoverable. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await N8(s))throw new Error(`Mesh conversion finished but output was not found: '${s}'. Check that trimesh supports this format.`);if((await Zr(s)).byteLength===0)throw new Error(`Mesh conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/trimesh bridge."]}}}});async function U8(n){try{return await ur(n,mr),!0}catch(e){return!1}}function V8(n,e,t){return new Promise((i,r)=>{Qr(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i({stdout:a!=null?a:"",stderr:o!=null?o:""});return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`SLDPRT conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function G8(n,e){let t=ia(n),i=ia(e),r=i.replace(/\.glb$/i,".intermediate.step");return["import sys","import os","",`src = r"${t}"`,`out = r"${i}"`,`step_out = r"${r}"`,"","# Step 1: Import SLDPRT via FreeCAD","try:"," import FreeCAD"," import ImportGui"," import Mesh","except ImportError as e:",' print(f"FreeCAD modules not available: {e}", file=sys.stderr)',' print("Ensure this script runs under FreeCADCmd (not system Python).", file=sys.stderr)'," sys.exit(1)","","print(f'Opening SLDPRT: {src}')","try:"," doc = FreeCAD.newDocument('Convert')"," ImportGui.open(src, doc.Name)","except Exception as e:",' print(f"Failed to open SLDPRT file: {e}", file=sys.stderr)'," sys.exit(1)","","if not doc.Objects:",' print("SLDPRT file imported but contains no objects", file=sys.stderr)'," sys.exit(1)","",'print(f"Imported {len(doc.Objects)} object(s) from SLDPRT")',"","# Step 2: Export to STEP (intermediate)","try:"," import Import"," objs = [o for o in doc.Objects if hasattr(o, 'Shape')]"," if not objs:",' print("No shape objects found after import", file=sys.stderr)'," sys.exit(1)"," Import.export(objs, step_out)",' print(f"Exported intermediate STEP: {step_out}")',"except Exception as e:",' print(f"Failed to export STEP: {e}", file=sys.stderr)'," sys.exit(1)","","FreeCAD.closeDocument(doc.Name)","","# Step 3: Convert STEP to GLB using OCP (same pipeline as FreecadConverter)","import trimesh","import trimesh.visual","import numpy as np","","from OCP.STEPControl import STEPControl_Reader","from OCP.TopoDS import TopoDS","from OCP.TopAbs import TopAbs_FACE","from OCP.TopExp import TopExp_Explorer","from OCP.BRep import BRep_Tool","from OCP.BRepMesh import BRepMesh_IncrementalMesh","from OCP.TopLoc import TopLoc_Location","from OCP.IFSelect import IFSelect_RetDone","","DEFAULT_COLOR = [180, 180, 180, 255]","","def triangulate_face(face, linear=0.1, angular=0.5):"," BRepMesh_IncrementalMesh(face, linear, False, angular, True)"," loc = TopLoc_Location()"," tri = BRep_Tool.Triangulation_s(face, loc)"," if tri is None:"," return None, None"," n = tri.NbNodes()"," verts = []"," for i in range(1, n + 1):"," p = tri.Node(i)"," if not loc.IsIdentity():"," p = p.Transformed(loc.Transformation())"," verts.append([p.X(), p.Y(), p.Z()])"," ntri = tri.NbTriangles()"," faces = []"," for i in range(1, ntri + 1):"," t = tri.Triangle(i)"," n1, n2, n3 = t.Get()"," faces.append([n1 - 1, n2 - 1, n3 - 1])"," return verts, faces","","sr = STEPControl_Reader()","status = sr.ReadFile(step_out)","if status != IFSelect_RetDone:",' print(f"Failed to read intermediate STEP: {step_out}", file=sys.stderr)'," sys.exit(1)","sr.TransferRoots()","shape = sr.OneShape()","","all_verts = []","all_faces = []","all_colors = []","total_faces = 0","","exp = TopExp_Explorer(shape, TopAbs_FACE)","while exp.More():"," face = TopoDS.Face_s(exp.Current())"," total_faces += 1"," verts, faces = triangulate_face(face)"," if verts and faces:"," offset = len(all_verts)"," all_verts.extend(verts)"," for tri in faces:"," all_faces.append([tri[0] + offset, tri[1] + offset, tri[2] + offset])"," all_colors.extend([DEFAULT_COLOR] * len(verts))"," exp.Next()","","if not all_verts or not all_faces:",' print(f"No geometry extracted from STEP ({total_faces} faces scanned)", file=sys.stderr)'," sys.exit(1)","",'print(f"Triangulated: {total_faces} faces, {len(all_verts)} verts")',"","verts_arr = np.array(all_verts, dtype=float)","faces_arr = np.array(all_faces, dtype=int)","colors_arr = np.array(all_colors, dtype=np.uint8)","","mesh = trimesh.Trimesh("," vertices=verts_arr,"," faces=faces_arr,"," visual=trimesh.visual.ColorVisuals(vertex_colors=colors_arr),"," process=True,",")","mesh.fix_normals()","scene = trimesh.Scene([mesh])","","result = scene.export(file_type='glb')","if isinstance(result, bytes):"," data = result","elif isinstance(result, str):"," with open(result, 'rb') as f:"," data = f.read()","else:"," data = bytes(result)","","with open(out, 'wb') as f:"," f.write(data)","","# Cleanup intermediate STEP","try:"," os.remove(step_out)","except OSError:"," pass","","print(f'Converted {src} -> {out} ({len(data)} bytes, {total_faces} faces)')"].join(` -`)}var OA,B8,Cp,s2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Mr();Qa();Sp();OA=ti("sldprt-converter"),B8=600*1e3;Cp=class{constructor(e){this.configuredCommand=e;this.id="sldprt";this.sourceExts=["sldprt"];this.targetExt="glb"}async getCacheKey(){let e=await qi("freecadcmd",this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!ji(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking SLDPRT conversion.`);let t=await qi("freecadcmd",this.configuredCommand),i=Zn(e.sourcePath),r=qn(e.sourcePath,qr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-sldprt"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,G8(e.sourcePath,s),"utf8"),OA.info("run SLDPRT conversion (FreeCAD + OCP)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{let{stdout:c,stderr:f}=await V8(t.command,[...t.args,o],B8);c&&OA.info("FreeCAD stdout",{stdout:c.trim().slice(0,500)}),f&&OA.warn("FreeCAD stderr",{stderr:f.trim().slice(0,500)})}catch(c){throw new Error(`SLDPRT conversion failed for '${e.sourcePath}'. Ensure FreeCAD is installed (https://www.freecad.org/downloads.php). Set FreeCADCmd path in plugin settings or AI3D_FREECADCMD env var. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await U8(s))throw new Error(`SLDPRT conversion finished but output was not found: '${s}'. Check that FreeCAD can import this SolidWorks file version.`);if((await Zr(s)).byteLength===0)throw new Error(`SLDPRT conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local FreeCAD + OpenCASCADE bridge."]}}}});function ra(n){var r;let e=new gp,t=new Set((r=n==null?void 0:n.enabledConverterIds)!=null?r:[]);NA.debug("create conversion manager",{enabledConverterIds:[...t]});let i=[new Ap(n==null?void 0:n.freecadCommand),new Rp(n==null?void 0:n.obj2gltfCommand),new Ip(n==null?void 0:n.fbx2gltfCommand),new xp(n==null?void 0:n.assimpCommand),new Cp(n==null?void 0:n.freecadcmdCommand)];for(let s of i)t.has(s.id)?(e.registerConverter(s),NA.info("enabled converter",{converterId:s.id})):NA.debug("converter disabled",{converterId:s.id});return e}var NA,pd=A(()=>{"use strict";QU();t2();i2();r2();n2();s2();Mr();NA=ti("conversion-factory")});function Xo(n){return{path:n.effectivePath,ext:n.effectiveExt,strategy:n.strategy,sourcePath:n.sourcePath,sourceExt:n.sourceExt,warnings:n.warnings}}var bp=A(()=>{"use strict"});function na(n){let e=[];return n.preferObj2gltfForObj&&e.push("obj"),n.preferFbx2gltfForFbx&&e.push("fbx"),e}var _d=A(()=>{"use strict"});function gd(n){return n.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g,"$2").replace(/\[\[([^\]]+)\]\]/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[*_~`]+/g,"").replace(/==([^=]+)==/g,"$1").replace(/\s+/g," ").trim()}function k8(n,e){let t=e.toLowerCase().trim();if(!t)return[];let i=[],r=n.vault.getMarkdownFiles();for(let s of r){let a=n.metadataCache.getFileCache(s);if(a!=null&&a.headings)for(let o of a.headings)o.heading.toLowerCase().includes(t)&&i.push({notePath:s.path,heading:o.heading,level:o.level})}return i.slice(0,15)}function Mp(n){return e=>k8(n,e)}async function W8(n,e,t){try{let i=n.vault.getAbstractFileByPath(e);if(!(i instanceof a2.TFile))return null;let s=(await n.vault.cachedRead(i)).split(` -`),a=-1,o=0,l=gd(t);for(let f=0;fW8(n,e,t)}var a2,Pc=A(()=>{"use strict";a2=require("obsidian")});function $a(n,e){let t=n.createDiv({cls:"ai3d-inline-empty ai3d-load-feedback-shell"});Qt()&&t.classList.add("is-mobile");let i=t.createDiv({cls:`ai3d-load-feedback is-${e.level}`});return i.createDiv({cls:"ai3d-load-feedback-title",text:e.title}),i.createDiv({cls:"ai3d-load-feedback-message",text:e.message}),i.createDiv({cls:"ai3d-load-feedback-hint",text:e.hint}),t}var Ed=A(()=>{"use strict";jr()});var c2={};De(c2,{generateKnowledgeNote:()=>l2,mountWorkbench:()=>FA});function FA(n,e,t,i){var X,j;let r=Qt();n.classList.add("ai3d-workbench"),n.classList.toggle("is-mobile",r);let s=null,a=null,o=!1,l=!1,c=t.store.getState(),f=c.currentModelPath,d=c.currentModelPath,h=c.modelPreview;function u(Q){if(!a||!s)return;let $=a.getPinPosition(Q);if(!$)return;let q=s.getCamera(),z=new Oe("focusPin","target",30,Oe.ANIMATIONTYPE_VECTOR3,Oe.ANIMATIONLOOPMODE_CONSTANT);z.setKeys([{frame:0,value:q.target.clone()},{frame:20,value:$}]);let K=new au;K.setEasingMode(sr.EASINGMODE_EASEOUT),z.setEasingFunction(K),q.animations=[z],s.getScene().beginAnimation(q,0,20,!1)}let m=Q=>{Q.key==="Escape"&&o&&y(!1)};activeDocument.addEventListener("keydown",m);let p=n.createDiv({cls:"ai3d-preview-host"});r&&p.classList.add("is-mobile-scroll-mode");let _=Zi` +}`;E.ShadersStore[xA]||(E.ShadersStore[xA]=HU);h8={name:xA,shader:HU}});var YU,zU,mp,u8,m8,XU,MA,KU=A(()=>{sr();yt();Dl();ve();cn();vl();nE();Fi();VE();et();ft();go();ma();DE();Mn();ze();Object.defineProperty(st.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(n){this._forceShowBoundingBoxes=n,n&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0});st.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new MA(this)),this._boundingBoxRenderer};Object.defineProperty(zt.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(n){this._showBoundingBox=n,n&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});YU=U.Identity(),zU=new U,mp=new v,u8=new v,m8=YU.asArray(),XU=new va(mp,mp),MA=class{get shaderLanguage(){return this._shaderLanguage}constructor(e){this.name=be.NAME_BOUNDINGBOXRENDERER,this.frontColor=new oe(1,1,1),this.backColor=new oe(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new Y,this.onAfterBoxRenderingObservable=new Y,this.onResourcesReadyObservable=new Y,this.enabled=!0,this._shaderLanguage=0,this.renderList=new Ct(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this._matrixBuffer=null,this._matrices=null,this._useInstances=!1,this._drawWrapperFront=null,this._drawWrapperBack=null,this.scene=e,this.scene.getEngine().isWebGPU&&(this._shaderLanguage=1),e._addComponent(this),this._uniformBufferFront=new Ut(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!0),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new Ut(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack",!0),this._buildUniformLayout(this._uniformBufferBack)}_buildUniformLayout(e){e.addUniform("color",4),e.addUniform("world",16),e.addUniform("viewProjection",16),e.addUniform("viewProjectionR",16),e.create()}register(){this.scene._beforeEvaluateActiveMeshStage.registerStep(be.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(be.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(be.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(be.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)}async whenReadyAsync(e=16,t=3e4){return this._prepareResources(),await new Promise(i=>{bn(()=>this._colorShader.isReady(),()=>{i()},(r,s)=>{s?(W.Error("BoundingBoxRenderer: Timeout while waiting for the renderer to be ready."),r&&W.Error(r)):(W.Error("BoundingBoxRenderer: An unexpected error occurred while waiting for the renderer to be ready."),r&&(W.Error(r),r.stack&&W.Error(r.stack)))},e,t)})}_evaluateSubMesh(e,t){if(e.showSubMeshesBoundingBox){let i=t.getBoundingInfo();i!=null&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}}_preActiveMesh(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){let t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}}_prepareResources(){if(this._colorShader)return;this._colorShader=new Tn("colorShader",this.scene,"boundingBoxRenderer",{attributes:[M.PositionKind,"world0","world1","world2","world3"],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(gA(),_A)),Promise.resolve().then(()=>(TA(),vA))]):await Promise.all([Promise.resolve().then(()=>(IA(),RA)),Promise.resolve().then(()=>(bA(),CA))])}},!1),this._colorShader.setDefine("INSTANCES",this._useInstances),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new Tn("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[M.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(gA(),_A)),Promise.resolve().then(()=>(TA(),vA))]):await Promise.all([Promise.resolve().then(()=>(IA(),RA)),Promise.resolve().then(()=>(bA(),CA))])}},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};let e=this.scene.getEngine(),t=pu({size:1});this._vertexBuffers[M.PositionKind]=new M(e,t.positions,M.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}_createIndexBuffer(){let e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}rebuild(){let e=this._vertexBuffers[M.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this._matrixBuffer&&this._matrixBuffer._rebuild()}reset(){this.renderList.reset()}render(e){var r,s;if(this.renderList.length===0||!this.enabled)return;if(this._useInstances){this._renderInstanced(e);return}if(this._prepareResources(),!this._colorShader.isReady())return;let t=this.scene.getEngine();t.setDepthWrite(!1);let i=this.scene.getTransformMatrix();for(let a=0;ar*2)&&(i=new Float32Array(r),this._matrices=i),this.onBeforeBoxRenderingObservable.notifyObservers(XU);let s=0,a=this.scene.floatingOriginOffset;for(let g=0;g{"use strict";ve();mA();et();fo();dn();KU();yc=class yc{constructor(e,t,i){this.originals=new Map;this.observer=null;this.renderObserver=null;this.frameCount=0;this.lastOccluded=!1;this.active=!1;this.drag=null;this.selected=null;var s;this.scene=e,this.camera=t,this.meshes=i;let r=(s=e.getBoundingBoxRenderer)==null?void 0:s.call(e);r&&(r.frontColor=new oe(.25,.7,1),r.backColor=new oe(.25,.7,1));for(let a of i)this.originals.set(a.uniqueId,this.captureTransform(a))}setEnabled(e){return this.active===e?this.active:(this.active=e,this.drag=null,this.setSelected(null),e?(this.observer=this.scene.onPointerObservable.add(t=>{var r,s;let i=t.event;t.type===ye.POINTERDOWN?this.startDrag((s=(r=t.pickInfo)==null?void 0:r.pickedMesh)!=null?s:null,i):t.type===ye.POINTERMOVE?this.updateDrag(i):t.type===ye.POINTERUP&&this.stopDrag()}),this.renderObserver=this.scene.onAfterRenderCameraObservable.add(t=>{t===this.camera&&this.updateBboxOcclusion()})):(this.observer&&(this.scene.onPointerObservable.remove(this.observer),this.observer=null),this.renderObserver&&(this.scene.onAfterRenderCameraObservable.remove(this.renderObserver),this.renderObserver=null),this.camera.attachControl(this.scene.getEngine().getRenderingCanvas(),!0)),this.active)}toggle(){return this.setEnabled(!this.active)}reset(){var e,t;this.stopDrag(),this.setSelected(null);for(let i of this.meshes){if(i.isDisposed())continue;let r=this.originals.get(i.uniqueId);r&&(i.setParent(r.parent),i.position.copyFrom(r.position),i.rotation.copyFrom(r.rotation),i.rotationQuaternion=(t=(e=r.rotationQuaternion)==null?void 0:e.clone())!=null?t:null,i.scaling.copyFrom(r.scaling),i.computeWorldMatrix(!0))}}dispose(){this.setEnabled(!1),this.originals.clear()}updateBboxOcclusion(){var c,f;if(!this.selected||this.selected.isDisposed()||(this.frameCount++,this.frameCount%3!==0))return;let e=this.selected.getBoundingInfo().boundingBox.centerWorld,t=this.camera.position,i=v.Distance(t,e),r=e.subtract(t).normalize(),s=new di(t,r,i),a=this.scene.pickWithRay(s),o=Math.max(i*.01,.01),l=!!(a!=null&&a.hit)&&a.distance$s});function p8(n){let e=n.getClassName();return e==="DirectionalLight"||e==="PointLight"||e==="SpotLight"}function yA(n){return n.getClassName()==="GaussianSplattingMesh"}function ZU(n){return n.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}var pp,$s,cd=A(()=>{"use strict";$g();sr();hu();uu();VM();GM();AE();ve();et();ov();Xs();Im();AO();hE();hc();rd();rd();XS();YS();FB();hU();aA();qr();Js();AU();jU();pp=null;$s=class{constructor(e){this.rootMesh=null;this.loadedMeshes=[];this.loadedExt="";this.rendering=!1;this.cleanupPicking=null;this.configLights=[];this.shadowGenerator=null;this.groundMesh=null;this.gridMesh=null;this.axisMeshes=[];this.autoRotateBehavior=null;this.wireframeEnabled=!1;this.gizmo=null;this.gizmoEnabled=!1;this.disassembly=null;this.disassemblyEnabled=!1;this.bboxMesh=null;this.bboxEnabled=!1;this.currentQuality="high";this.animPlaying=!1;this.initialCamera={alpha:Math.PI/4,beta:Math.PI/3,radius:5,target:v.Zero()};this._lastPickResult={mesh:null,pickedPoint:null,screenX:0,screenY:0};this._onPickCallbacks=[];this.preventCanvasWheelScroll=e=>{e.preventDefault(),e.stopPropagation()};this.engine=new Ee(e,!0,{preserveDrawingBuffer:!0}),this.scene=new st(this.engine),this.scene.clearColor=new Ne(.12,.12,.14,1),this.camera=new ut("cam",Math.PI/4,Math.PI/3,5,v.Zero(),this.scene),this.camera.attachControl(e,!0),this.camera.lowerRadiusLimit=.1,this.camera.wheelPrecision=30,e.addEventListener("wheel",this.preventCanvasWheelScroll,{passive:!1}),this.scene.ambientColor=new oe(.3,.3,.3);let t=new Rr("default-light",new v(0,1,.5),this.scene);t.intensity=1.2,this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),window.requestAnimationFrame(()=>this.engine.resize())}canRender(){let e=this.engine.getRenderingCanvas();return!!(e!=null&&e.isConnected)&&e.clientWidth>0&&e.clientHeight>0}async loadModel(e,t,i,r){var m,p,_,g,T;await id(),this.rootMesh&&(this.rootMesh.dispose(!0,!0),this.rootMesh=null),this.loadedMeshes=[],(m=this.disassembly)==null||m.dispose(),this.disassembly=null,this.disassemblyEnabled=!1;let s=t.toLowerCase().replace(".","");this.loadedExt=s;let a=this.scene,l=(p={glb:".glb",gltf:".gltf",stl:".stl",obj:".obj",splat:".splat",ply:".ply"}[s])!=null?p:`.${s}`,c=`data:application/octet-stream;base64,${nd(e)}`;if(s==="obj"&&i&&r){pp&&await pp;let b;pp=new Promise(R=>{b=R});try{let{OBJFileLoader:R}=await Promise.resolve().then(()=>(HS(),xB)),S=R.prototype;typeof S._loadMTL!="function"&&console.warn("[AI3D] OBJFileLoader._loadMTL not found \u2014 MTL vault resolution disabled");let I=S._loadMTL,P=new TextDecoder().decode(new Uint8Array(e)).match(/mtllib\s+(.+)/),L=null,y=0,B=0;if(P&&i&&r){let H=P[1].trim().split(/\s+/)[0],O=SU(r),k=O?`${O}/${H}`:H;try{let X=await i(k),Q=new TextDecoder().decode(new Uint8Array(X)).split(` +`),$=/^\s*(map_Kd|map_Ka|map_Ks|map_Ns|map_d|map_bump|bump|disp|decal)\s+(.+)/i,q=Mr(r),z=["jpg","jpeg","png","bmp","tga","webp","tif","tiff"];for(let te=0;tete!=="");if(!K.some(te=>/^\s*Kd\s+/i.test(te))){let te=K.findIndex(Pe=>/^\s*newmtl\s+/i.test(Pe));K.splice(te>=0?te+1:0,0,"Kd 0.80 0.80 0.80")}L=K.join(` +`),console.debug(`[AI3D] MTL: ${k} | textures: ${y} loaded, ${B} missing`)}catch(X){console.debug(`[AI3D] No MTL in vault: ${k}`)}}S._loadMTL=function(H,O,k){let X=L!=null?L:"";console.debug(`[AI3D] _loadMTL called: url=${H}, content_len=${X.length}, has_Kd=${X.includes("Kd")}, has_map=${X.includes("map_")}`),k(X)};let w=await Yf(c,a,{meshNames:"",pluginExtension:l});this.loadedMeshes=w.meshes,w.meshes.length>0&&(this.rootMesh=w.meshes[0]);for(let H of w.meshes){let O=H.material;console.debug(`[AI3D] OBJ mesh "${H.name}" material:`,O?`${O.name} diffuse=${String(O==null?void 0:O.diffuseColor)}`:"NONE")}S._loadMTL=I}catch(R){throw console.error("[AI3D] OBJ load error:",R),R}finally{b(),pp=null}}else if(s==="stl")this.rootMesh=yB(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else if(s==="ply")this.rootMesh=LB(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else{let b=await Yf(c,a,{meshNames:"",pluginExtension:l});this.loadedMeshes=b.meshes,b.meshes.length>0&&(this.rootMesh=b.meshes[0])}if(!this.rootMesh)throw new Error("No mesh found in model file");for(let b of this.getRenderableMeshes(this.rootMesh))b.material&&(b.material.backFaceCulling=!1);this.rootMesh.computeWorldMatrix(!0);let f=this.rootMesh.getHierarchyBoundingVectors(),d=f.max.subtract(f.min),h=d.length()/2,u=f.min.add(d.scale(.5));return this.camera.target=u,this.camera.radius=h*2.5,this.camera.lowerRadiusLimit=h*.05,this.camera.upperRadiusLimit=h*10,this.camera.minZ=h*.001,this.camera.maxZ=h*20,this.initialCamera={alpha:this.camera.alpha,beta:this.camera.beta,radius:this.camera.radius,target:u.clone()},this.startRenderLoop(),this.engine.resize(),(T=this.cleanupPicking)==null||T.call(this),this.cleanupPicking=dU(this.scene,b=>{this.disassemblyEnabled||(this._lastPickResult=b,this._onPickCallbacks.forEach(R=>R(b)))}),this.disassembly=new ld(this.scene,this.camera,this.getRenderableMeshes(this.rootMesh)),this.computeSummary(this.rootMesh)}applyConfig(e){e.camera&&this.applyCameraConfig(e.camera),e.lights&&this.applyLightConfig(e.lights),e.scene&&this.applySceneConfig(e.scene),e.stl&&this.loadedExt==="stl"&&(e.stl.color&&this.setSTLColor(e.stl.color),e.stl.wireframe!==void 0&&this.setWireframe(e.stl.wireframe))}applyCameraConfig(e){var i;let t=this.engine.getRenderingCanvas();if(t){if(e.mode==="orthographic"){let r=this.camera.radius,s=t.clientWidth/t.clientHeight,a=(i=e.zoom)!=null?i:1,o=r/a;this.camera.mode=1,this.camera.orthoLeft=-o*s,this.camera.orthoRight=o*s,this.camera.orthoTop=o,this.camera.orthoBottom=-o}else this.camera.mode=0,e.fov&&(this.camera.fov=e.fov*Math.PI/180);if(e.position){let[r,s,a]=e.position;this.camera.setPosition(new v(r,s,a))}if(e.lookAt){let[r,s,a]=e.lookAt;this.camera.setTarget(new v(r,s,a))}e.near!==void 0&&(this.camera.minZ=e.near),e.far!==void 0&&(this.camera.maxZ=e.far)}}applyLightConfig(e){var i;for(let r of this.configLights)r.dispose();this.configLights=[],(i=this.shadowGenerator)==null||i.dispose(),this.shadowGenerator=null;let t=this.scene.getLightByName("default-light");t&&t.dispose();for(let r of e){let s=this.createLight(r);s&&this.configLights.push(s)}}createLight(e){var r,s;let t=e.color?oe.FromHexString(e.color):oe.White(),i=(r=e.intensity)!=null?r:1;switch(e.type){case"hemisphere":{let a=e.groundColor?oe.FromHexString(e.groundColor):new oe(.2,.2,.2),o=new Rr("hemi",new v(0,1,0),this.scene);return o.diffuse=t,o.groundColor=a,o.intensity=i,o}case"directional":{let a=e.position?new v(...e.position).normalize():new v(-1,-2,-1).normalize(),o=new dr("dir",a,this.scene);return o.diffuse=t,o.intensity=i,e.castShadow&&this.rootMesh&&this.setupShadow(o),o}case"point":{let a=e.position?new v(...e.position):new v(0,5,0),o=new ya("point",a,this.scene);return o.diffuse=t,o.intensity=i,e.decay!==void 0&&(o.decay=e.decay),o}case"spot":{let a=e.position?new v(...e.position):new v(0,5,0),l=(e.target?new v(...e.target):v.Zero()).subtract(a).normalize(),c=e.angle?e.angle*Math.PI/180:Math.PI/4,f=(s=e.penumbra)!=null?s:.5,d=new ni("spot",a,l,c,f,this.scene);return d.diffuse=t,d.intensity=i,e.decay!==void 0&&(d.decay=e.decay),e.castShadow&&this.rootMesh&&this.setupShadow(d),d}case"attachToCam":{let a=new ya("cam-light",v.Zero(),this.scene);return a.diffuse=t,a.intensity=i,a.parent=this.camera,a}default:return null}}setupShadow(e){if(!this.rootMesh)return;if(!p8(e)){console.warn("[AI3D] Light type does not support shadows:",e.name);return}let t=new St(1024,e);t.useBlurExponentialShadowMap=!0,t.blurKernel=32;let i=this.rootMesh.getChildMeshes(!0);for(let r of i)t.addShadowCaster(r),r.receiveShadows=!0;this.shadowGenerator=t}applySceneConfig(e){var t,i;if(e.background!==void 0){let r=Ne.FromColor3(oe.FromHexString(e.background),e.transparent?0:1);this.scene.clearColor=r}e.autoRotate&&(this.autoRotateBehavior?this.autoRotateBehavior.idleRotationSpeed=(i=e.autoRotateSpeed)!=null?i:.5:(this.autoRotateBehavior=new ql,this.autoRotateBehavior.idleRotationSpeed=(t=e.autoRotateSpeed)!=null?t:.5,this.autoRotateBehavior.idleRotationWaitTime=1e3,this.autoRotateBehavior.idleRotationSpinupTime=500,this.camera.addBehavior(this.autoRotateBehavior))),e.groundShadow&&this.rootMesh&&this.createGround(),e.grid&&this.createGrid(),e.axis&&this.createAxis()}createGround(){if(!this.rootMesh||this.groundMesh)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.z)*3,r=e.min.y;this.groundMesh=zs.CreateGround("ground",{width:i,height:i},this.scene),this.groundMesh.position.y=r;let s=new Re("ground-mat",this.scene);s.diffuseColor=new oe(.15,.15,.15),s.specularColor=oe.Black(),s.alpha=.5,this.groundMesh.material=s,this.groundMesh.receiveShadows=!0}createGrid(){if(!this.rootMesh||this.gridMesh)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.z)*2,r=e.min.y-.01;this.gridMesh=zs.CreateGround("grid",{width:i,height:i,subdivisions:20},this.scene),this.gridMesh.position.y=r;let s=new Re("grid-mat",this.scene);s.wireframe=!0,s.diffuseColor=new oe(.3,.3,.3),s.emissiveColor=new oe(.1,.1,.1),this.gridMesh.material=s}createAxis(){if(!this.rootMesh||this.axisMeshes.length>0)return;let e=this.rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.y,t.z)*1.5,r=e.min,s=[["x",oe.Red(),new v(i,0,0)],["y",oe.Green(),new v(0,i,0)],["z",oe.Blue(),new v(0,0,i)]];for(let[a,o,l]of s){let c=zs.CreateTube(`axis-${a}`,{path:[r,r.add(l)],radius:t.length()*.005,tessellation:8},this.scene),f=new Re(`axis-${a}-mat`,this.scene);f.emissiveColor=o,f.diffuseColor=oe.Black(),c.material=f,this.axisMeshes.push(c)}}setSTLColor(e){if(!this.rootMesh)return;let t=oe.FromHexString(e),i=this.rootMesh.getChildMeshes(!0);for(let r of i)if(r.material&&r.material.name==="stl-mat"){let s=r.material;s.diffuseColor=t,s.emissiveColor=t.scale(.1)}}setWireframe(e){this.rootMesh&&(yA(this.rootMesh)||(this.wireframeEnabled=e,this.scene.forceWireframe=e))}toggleWireframe(){return this.setWireframe(!this.wireframeEnabled),this.wireframeEnabled}hasAnimations(){return this.scene.animationGroups.length>0}toggleAnimation(){let e=this.scene.animationGroups;if(e.length===0)return!1;this.animPlaying=!this.animPlaying;for(let t of e)this.animPlaying?t.play(!0):t.pause();return this.animPlaying}setAnimationSpeed(e){for(let t of this.scene.animationGroups)t.speedRatio=e}captureSnapshot(){let e=this.engine.getRenderingCanvas();return e?(this.scene.render(),e.toDataURL("image/png")):null}toggleOrientationGizmo(){return this.gizmoEnabled=!this.gizmoEnabled,this.gizmoEnabled&&!this.gizmo&&(this.gizmo=new dp(this.engine,this.camera)),this.gizmoEnabled}setRenderScale(e){let t=Math.max(.25,Math.min(e,2)),i={low:2,medium:1.33,high:1}[this.currentQuality],r=Qt()?1.5:1;return this.engine.setHardwareScalingLevel(i*r/t),t}toggleBoundingBox(){var e;if(this.bboxEnabled=!this.bboxEnabled,this.bboxEnabled){if(!this.rootMesh)return this.bboxEnabled;this.bboxMesh&&this.bboxMesh.dispose(),this.rootMesh.computeWorldMatrix(!0);let t=this.rootMesh.getHierarchyBoundingVectors(),i=t.min.add(t.max.subtract(t.min).scale(.5)),r=t.max.subtract(t.min);this.bboxMesh=zs.CreateBox("bbox",{width:r.x,height:r.y,depth:r.z},this.scene),this.bboxMesh.position=i;let s=new Re("bbox-mat",this.scene);s.wireframe=!0,s.emissiveColor=new oe(1,1,0),s.disableLighting=!0,s.alpha=.6,this.bboxMesh.material=s}else(e=this.bboxMesh)==null||e.dispose(),this.bboxMesh=null;return this.bboxEnabled}toggleDisassembly(){return this.rootMesh?(this.disassembly||(this.disassembly=new ld(this.scene,this.camera,this.getRenderableMeshes(this.rootMesh))),this.disassemblyEnabled=this.disassembly.toggle(),this.disassemblyEnabled):!1}resetDisassembly(){var e;(e=this.disassembly)==null||e.reset()}setExplode(e,t){this.rootMesh&&NB(this.rootMesh,e,t)}resetExplode(){this.rootMesh&&KS(this.rootMesh)}resetView(){this.rootMesh&&KS(this.rootMesh),this.resetDisassembly(),this.camera.mode=0,this.camera.alpha=this.initialCamera.alpha,this.camera.beta=this.initialCamera.beta,this.camera.radius=this.initialCamera.radius,this.camera.target=this.initialCamera.target.clone()}exportModelInfo(e){var f,d,h;if(!this.rootMesh)return"";let t=this.computeSummary(this.rootMesh),i=this.getRenderableMeshes(this.rootMesh),r=yA(this.rootMesh),s=this.loadedExt.toUpperCase(),a=e&&cp(e)||t.rootName,o=r?"Splats":"Triangles",l=[];if(l.push(`## ${a} \u2014 Model Info`),l.push(""),l.push("| Property | Value |"),l.push("|----------|-------|"),l.push(`| Format | ${s} |`),l.push(`| Meshes | ${t.meshCount} |`),l.push(`| ${o} | ${((f=t.splatCount)!=null?f:t.triangleCount).toLocaleString()} |`),l.push(`| Vertices | ${t.vertexCount.toLocaleString()} |`),l.push(`| Materials | ${t.materialCount} |`),l.push(`| Bounding Size | ${t.boundingSize.x.toFixed(3)} x ${t.boundingSize.y.toFixed(3)} x ${t.boundingSize.z.toFixed(3)} |`),l.push(""),i.length>1&&i.length<=50){l.push("### Mesh Breakdown"),l.push(""),l.push("| # | Name | Triangles | Vertices | Material |"),l.push("|---|------|-----------|----------|----------|");for(let u=0;u0){l.push("### Materials"),l.push("");for(let u of c)l.push(`- ${u}`);l.push("")}return l.join(` +`)}getRootMesh(){return this.rootMesh}getScene(){return this.scene}getEngine(){return this.engine}getCamera(){return this.camera}getCanvas(){return this.engine.getRenderingCanvas()}getLastPickResult(){return this._lastPickResult}onPick(e){return this._onPickCallbacks.push(e),()=>{this._onPickCallbacks=this._onPickCallbacks.filter(t=>t!==e)}}setRenderQuality(e,t=1){this.currentQuality=e;let i={low:2,medium:1.33,high:1},r=Qt()?1.5:1,s=i[e]*r/Math.max(t,.25);if(this.engine.setHardwareScalingLevel(s),this.shadowGenerator){let a={low:0,medium:16,high:32};this.shadowGenerator.blurKernel=a[e],e==="low"?(this.shadowGenerator.useBlurExponentialShadowMap=!1,this.shadowGenerator.useExponentialShadowMap=!0):(this.shadowGenerator.useBlurExponentialShadowMap=!0,this.shadowGenerator.useExponentialShadowMap=!1)}}destroy(){var t,i,r,s,a,o,l;this.engine.stopRenderLoop(),this._onPickCallbacks=[],(t=this.cleanupPicking)==null||t.call(this),this.cleanupPicking=null,(i=this.gizmo)==null||i.dispose(),this.gizmo=null,(r=this.disassembly)==null||r.dispose(),this.disassembly=null,(s=this.bboxMesh)==null||s.dispose(),this.bboxMesh=null,this.camera.detachControl();let e=this.engine.getRenderingCanvas();e==null||e.removeEventListener("wheel",this.preventCanvasWheelScroll),this.resizeObs.disconnect(),this.autoRotateBehavior&&(this.camera.removeBehavior(this.autoRotateBehavior),this.autoRotateBehavior=null);for(let c of this.configLights)c.dispose();this.configLights=[],(a=this.shadowGenerator)==null||a.dispose(),this.shadowGenerator=null,(o=this.groundMesh)==null||o.dispose(),this.groundMesh=null,(l=this.gridMesh)==null||l.dispose(),this.gridMesh=null;for(let c of this.axisMeshes)c.dispose();this.axisMeshes=[],this.scene.dispose(),this.engine.dispose()}startRenderLoop(){this.rendering||(this.rendering=!0,this.engine.runRenderLoop(()=>{this.canRender()&&(this.scene.render(),this.gizmo&&this.gizmoEnabled&&(this.gizmo.syncWith(this.camera),this.gizmo.render()))}))}getRenderableMeshes(e){let t=[e,...this.loadedMeshes,...e.getChildMeshes(!0)],i=new Set;return t.filter(r=>!r||i.has(r)||r.isDisposed()?!1:(i.add(r),r.getTotalVertices()>0||r.getTotalIndices()>0))}computeSummary(e){let t=this.getRenderableMeshes(e),i=0,r=0,s=new Set,a=yA(e);for(let f of t){let d=f.getTotalIndices(),h=f.getTotalVertices();i+=Math.floor(d/3),r+=h,f.material&&s.add(f.material.name)}let o=a?r:void 0,l=e.getHierarchyBoundingVectors(),c=l.max.subtract(l.min);return{meshCount:t.length,triangleCount:i,splatCount:o,vertexCount:r,materialCount:s.size,boundingSize:{x:c.x,y:c.y,z:c.z},rootName:e.name}}}});var DA,QU=A(()=>{"use strict";DA={"settings.title":"AI 3d model workbench","settings.folders":"Folders","settings.behavior":"Behavior","settings.converters":"Converters","settings.converterMenu":"Model converters","settings.converterMenu.desc":"Closed by default. Open this section only when you want to manually enable an optional local conversion route.","settings.environmentInspector":"Environment inspector","settings.environmentInspector.desc":"Closed by default. Open this section when you need to configure command paths or run environment checks.","settings.paths":"Converter paths","settings.diagnostics":"Converter command diagnostics","settings.performance":"Performance & display","settings.mobileSupport":"Mobile support","settings.sourceModelFolder":"Source model folder","settings.sourceModelFolder.desc":"Vault folder where source model files are stored.","settings.reportFolder":"Report folder","settings.reportFolder.desc":"Vault folder where generated knowledge notes are saved.","settings.snapshotFolder":"Snapshot folder","settings.snapshotFolder.desc":"Vault folder where exported snapshots are saved.","settings.autoGenerateKnowledgeNotes":"Auto-generate knowledge notes","settings.autoGenerateKnowledgeNotes.desc":"Reserved for a future automation flow. For now, generate notes manually from the command or the workbench button.","settings.annotationPreviewMode":"Annotation preview mode","settings.annotationPreviewMode.desc":"Choose how bound note previews render in annotation popovers and the editor.","settings.annotationPreviewMode.plainText":"Plain text","settings.annotationPreviewMode.markdown":"Markdown","settings.autoRotateDefault":"Auto-rotate by default","settings.autoRotateDefault.desc":"Start model previews with auto-rotation enabled.","settings.snapshotNaming":"Snapshot naming","settings.snapshotNaming.desc":"How exported snapshot files are named.","settings.snapshotNaming.modelName":"Model name + timestamp","settings.snapshotNaming.timestamp":"Timestamp only","settings.logLevel":"Log level","settings.logLevel.desc":"Controls plugin runtime log verbosity in the developer console.","settings.language":"Language","settings.language.desc":"Display language for plugin settings. Takes effect immediately.","settings.enableCad":"Enable cad conversion for step, iges, and brep files","settings.enableCad.desc":"Enable cad conversion for step, iges, and brep formats. Requires cadquery and trimesh in your python environment.","settings.enableObj2gltf":"Enable obj2gltf converter (experimental)","settings.enableObj2gltf.desc":"Keep obj direct loading as the default. Enable this only if you want an optional local normalization route through obj2gltf.","settings.preferObj2gltf":"Prefer obj2gltf for obj","settings.preferObj2gltf.desc":"Recommended default is off. Turn this on only when you want normalized output files or direct obj loading is not good enough.","settings.enableFbx2gltf":"Enable FBX2glTF converter","settings.enableFbx2gltf.desc":"Enable conversion for fbx files via FBX2glTF. Requires the FBX2glTF binary installed locally.","settings.enableMesh":"Enable mesh conversion for 3mf and dae files","settings.enableMesh.desc":"Enable conversion for 3mf and dae formats via python trimesh. Requires trimesh, numpy, networkx, and pycollada in your python environment.","settings.enableSldprt":"Enable sldprt conversion for SolidWorks files","settings.enableSldprt.desc":"Enable conversion for SolidWorks sldprt files via FreeCAD. Requires FreeCAD installed locally.","settings.mobileSupport.desc":"On iOS, iPadOS, and Android, direct formats like GLB, GLTF, STL, OBJ, and PLY are supported. Local converter settings and diagnostics remain desktop-only.","settings.pythonCmd":"Path to the python command for cad conversion","settings.pythonCmd.desc":"Optional path to the python command used for cad conversion. Windows usually uses py. macOS and Linux usually use python3. Overrides auto-discovery when set.","settings.freecadCmd":"Path to the FreeCAD command for sldprt conversion","settings.freecadCmd.desc":"Optional path to the FreeCAD command used for SolidWorks file conversion. Windows usually uses FreeCADCmd.exe, macOS usually uses FreeCADCmd, and Linux usually uses freecadcmd. Overrides auto-discovery when set.","settings.obj2gltfCmd":"Path to the obj2gltf command","settings.obj2gltfCmd.desc":"Optional path to the obj2gltf command. Windows usually uses obj2gltf.cmd, and macOS and Linux usually use obj2gltf. Overrides auto-discovery when set.","settings.fbx2gltfCmd":"FBX2glTF command path","settings.fbx2gltfCmd.desc":"Optional path to the FBX2glTF command. Windows usually uses FBX2glTF.exe, and macOS and Linux usually use FBX2glTF. Overrides auto-discovery when set.","settings.assimpCmd":"Path to the python command for 3mf and dae conversion","settings.assimpCmd.desc":"Optional path to the python command used for 3mf and dae conversion. Windows usually uses py. macOS and Linux usually use python3. Overrides auto-discovery when set.","settings.diagnostics.desc":"Shows the exact executable path the plugin would use right now and runs lightweight self-checks for Python environments and converter CLIs.","settings.diagnostics.idle":"Diagnostics are off by default. Click Check now to run them manually.","settings.diagnostics.checkNow":"Check now","settings.diagnostics.checking":"Checking...","settings.diagnostics.refreshed":"Converter command diagnostics refreshed.","settings.diagnostics.checkingAvailability":"Checking converter command availability...","settings.diagnostics.available":"available","settings.diagnostics.notFound":"not found","settings.diagnostics.sourceLabel":"Source","settings.diagnostics.commandLabel":"Command","settings.diagnostics.resolvedPathLabel":"Resolved path","settings.diagnostics.selfCheckLabel":"Self-check","settings.diagnostics.selfCheckOk":"passed","settings.diagnostics.selfCheckFailed":"failed","settings.diagnostics.cadPythonCheck":"Python packages (cadquery, trimesh)","settings.diagnostics.meshPythonCheck":"Python packages (trimesh, numpy, networkx, collada)","settings.diagnostics.freecadCmdCheck":"FreeCADCmd launch probe","settings.diagnostics.obj2gltfCheck":"obj2gltf launch probe","settings.diagnostics.fbx2gltfCheck":"FBX2glTF launch probe","settings.canvasHeight":"Default canvas height","settings.canvasHeight.desc":"Default height (px) for inline model previews. Range: 200\u2013800.","settings.autoRotateSpeed":"Auto-rotate speed","settings.autoRotateSpeed.desc":"Rotation speed when auto-rotate is enabled. Range: 0.1\u20132.0.","settings.renderQuality":"Render quality","settings.renderQuality.desc":"Higher quality uses more GPU resources. Affects anti-aliasing and resolution.","settings.renderScale":"Resolution scale","settings.renderScale.desc":"Render resolution multiplier. 1.0 = native, 0.5 = half, 2.0 = double (supersampling). Range: 0.25\u20132.0.","modelLoad.warningTitle":"Model preview unavailable","modelLoad.warningMessage":"{ext} files need the {converterName} converter enabled in plugin settings before they can load.","modelLoad.warningHint":"Enable the matching converter in plugin settings, then reload this file.","modelLoad.mobileWarningMessage":"{ext} files need local conversion tools that are unavailable on iOS, iPadOS, and Android.","modelLoad.mobileWarningHint":"Open this file on desktop, or convert it to GLB, GLTF, OBJ, STL, or PLY first.","modelLoad.errorTitle":"Couldn't display this model","modelLoad.errorMessage":"Failed to load: {reason}","modelLoad.errorHint":"Check the file format or open the developer console for details.","headingPin.showSingle":"Show linked pin","headingPin.showMultiple":"Show linked pins","headingPin.linkedTo":"Pin linked to: {models}","helper.resetViewLabel":"Reset view","helper.resetViewDone":"Reset","helper.copyModelInfoLabel":"Copy model info as Markdown","helper.copied":"Copied!","helper.failed":"Failed","helper.toggleWireframeLabel":"Toggle wireframe","helper.wireframeOn":"Wireframe","helper.wireframeOff":"Solid","helper.toggleAxesLabel":"Toggle orientation axes","helper.axesOn":"Axes on","helper.axesOff":"Axes off","helper.toggleBoundingBoxLabel":"Toggle bounding box","helper.boundingBoxOn":"Bounding box on","helper.boundingBoxOff":"Bounding box off","helper.toggleDisassemblyLabel":"Toggle disassembly mode","helper.disassemblyOn":"Disassembly on","helper.disassemblyOff":"Disassembly off","helper.resetPartsLabel":"Reset disassembled parts","helper.partsReset":"Parts reset","helper.changeResolutionLabel":"Change resolution","helper.resolutionValue":"Resolution: {value}","helper.toggleAnimationLabel":"Play or pause animation","helper.playing":"Playing","helper.paused":"Paused","helper.removePreviewLabel":"Remove preview","helper.copySnapshotLabel":"Copy snapshot","helper.saveSnapshotLabel":"Save snapshot to vault","helper.saved":"Saved!","helper.downloadSnapshotLabel":"Download snapshot","helper.downloaded":"Downloaded!","helper.toggleAnnotationLabel":"Toggle annotation mode","helper.toggleAnnotationsVisibilityLabel":"Show or hide annotations","helper.annotateOn":"Annotation mode on","helper.annotateOff":"Annotation mode off","helper.annotationsVisible":"Annotations shown","helper.annotationsHidden":"Annotations hidden","helper.enableInteractionLabel":"Enable touch interaction","helper.disableInteractionLabel":"Return to scroll mode","helper.interactionOn":"Model interaction on","helper.interactionOff":"Scroll mode on","helper.showMoreActionsLabel":"Show more actions","helper.hideMoreActionsLabel":"Hide extra actions","helper.moreActionsShown":"More actions shown","helper.moreActionsHidden":"Extra actions hidden","helper.interactAction":"Interact","helper.scrollAction":"Scroll","workbench.emptyTitle":"No model","workbench.emptyText":'Use the "import 3D model" command to load a GLB, GLTF, or STL file.',"workbench.modelTitle":"Model","workbench.noModelLoaded":"No model loaded","workbench.disassemblyTitle":"Disassembly","workbench.explodeLabel":"Explode","workbench.summaryTitle":"Summary","workbench.meshesLabel":"Meshes","workbench.splatsLabel":"Splats","workbench.trianglesLabel":"Triangles","workbench.materialsLabel":"Materials","workbench.tagsTitle":"Tags","workbench.noTagsYet":"No tags yet","workbench.addTagPlaceholder":"Add tag...","workbench.addTagAction":"Add","workbench.annotationsTitle":"Annotations","workbench.exitAnnotate":"Exit annotate","workbench.annotate":"Annotate","workbench.annotateHintActive":"Click the model to add a label \xB7 press Esc to exit","workbench.annotateHintActiveMobile":"Tap the model to add a label. Switch back to Scroll when you want to move through the note again.","workbench.pinCount":"{count} pin(s)","workbench.editAction":"Edit","workbench.deleteAction":"Delete","workbench.resetViewAction":"Reset view","workbench.insertInfoAction":"Insert info","workbench.playAction":"Play","workbench.pauseAction":"Pause","workbench.saveProfileAction":"Save profile","workbench.generateNoteAction":"Generate note","workbench.mobileHint":"Mobile tip: tap Interact to move the model, then switch back to Scroll to keep reading the note.","workbench.mobileHintInteractive":"Interaction mode is on. Switch back to Scroll when you want to move through the note again.","directView.mobileHint":"Mobile tip: use the toolbar Interact button to switch between model interaction and note scrolling.","workbench.fileNotFound":"File not found: {path}","annotation.selectColor":"Select color {color}","annotation.sectionEmpty":"Section is empty.","modal.selectModel":"Select a 3D model...","main.ribbonOpenWorkbench":"Open the 3D workbench","main.commandImportModel":"Import a 3D model","main.commandOpenWorkbench":"Open the 3D workbench","main.commandGenerateNote":"Generate knowledge note","main.commandClearConversionCache":"Clear conversion cache","main.commandCheckConverters":"Check converters","main.converterDiagnosticsMobileUnavailable":"Converter diagnostics are only available on desktop. On iOS, iPadOS, and Android, direct formats can still load.","codeBlock.noModelPathOrConfig":"No model path or config specified.","codeBlock.jsonParseError":"JSON parse error: {error}","codeBlock.jsonParseLine":" (line {line})","codeBlock.noModelsInConfig":"No models specified in config.","codeBlock.unsupportedFormat":"Unsupported format: {ext}. Supported: {formats}","codeBlock.noConfigSpecified":"No config specified.","codeBlock.noModelsSpecified":"No models specified.","codeBlock.mobileHint":"Mobile tip: use Interact to manipulate the model, then switch back to Scroll to keep moving through the note.","codeBlock.renderingGrid":"Rendering grid...","codeBlock.composeRequiresSections":'"compose" preset requires a "sections" array.',"codeBlock.composeNoValidSections":"Compose: no valid sections.","codeBlock.unknownPreset":'Unknown preset: "{preset}". Available: compare, showcase, explode, timeline, compose',"codeBlock.presetRequiresModels":'Preset "{preset}" requires {min}-{max} models, got {count}.',"codeBlock.gridFailed":"Grid failed: {reason}","livePreview.mobileHint":"Mobile tip: switch between Interact and Scroll depending on whether you want to move the model or keep reading.","loading.default":"Loading...","loading.preparingModel":"Preparing model...","loading.loadingModel":"Loading model..."}});var JU,$U=A(()=>{"use strict";JU={"settings.title":"AI 3D \u6A21\u578B\u5DE5\u4F5C\u53F0","settings.folders":"\u6587\u4EF6\u5939","settings.behavior":"\u884C\u4E3A","settings.converters":"\u8F6C\u6362\u5668","settings.converterMenu":"\u6A21\u578B\u8F6C\u6362\u5668","settings.converterMenu.desc":"\u9ED8\u8BA4\u6536\u8D77\u3002\u4EC5\u5728\u4F60\u9700\u8981\u624B\u52A8\u542F\u7528\u67D0\u6761\u672C\u5730\u8F6C\u6362\u8DEF\u7EBF\u65F6\u518D\u5C55\u5F00\u3002","settings.environmentInspector":"\u73AF\u5883\u68C0\u67E5\u5668","settings.environmentInspector.desc":"\u9ED8\u8BA4\u6536\u8D77\u3002\u4EC5\u5728\u9700\u8981\u914D\u7F6E\u547D\u4EE4\u8DEF\u5F84\u6216\u624B\u52A8\u6267\u884C\u73AF\u5883\u68C0\u67E5\u65F6\u518D\u5C55\u5F00\u3002","settings.paths":"\u8F6C\u6362\u5668\u8DEF\u5F84","settings.diagnostics":"\u8F6C\u6362\u5668\u547D\u4EE4\u8BCA\u65AD","settings.performance":"\u6027\u80FD\u4E0E\u663E\u793A","settings.mobileSupport":"\u79FB\u52A8\u7AEF\u652F\u6301","settings.sourceModelFolder":"\u6E90\u6A21\u578B\u6587\u4EF6\u5939","settings.sourceModelFolder.desc":"\u5B58\u653E\u6E90 3D \u6A21\u578B\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.reportFolder":"\u62A5\u544A\u6587\u4EF6\u5939","settings.reportFolder.desc":"\u4FDD\u5B58\u751F\u6210\u7684\u77E5\u8BC6\u7B14\u8BB0\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.snapshotFolder":"\u5FEB\u7167\u6587\u4EF6\u5939","settings.snapshotFolder.desc":"\u4FDD\u5B58\u5BFC\u51FA\u5FEB\u7167\u7684\u5E93\u6587\u4EF6\u5939\u3002","settings.autoGenerateKnowledgeNotes":"\u81EA\u52A8\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0","settings.autoGenerateKnowledgeNotes.desc":"\u9884\u7559\u7ED9\u540E\u7EED\u81EA\u52A8\u5316\u6D41\u7A0B\u3002\u5F53\u524D\u8BF7\u901A\u8FC7\u547D\u4EE4\u6216\u5DE5\u4F5C\u53F0\u6309\u94AE\u624B\u52A8\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0\u3002","settings.annotationPreviewMode":"\u6807\u6CE8\u9884\u89C8\u6A21\u5F0F","settings.annotationPreviewMode.desc":"\u9009\u62E9\u6807\u6CE8\u7ED1\u5B9A\u7B14\u8BB0\u5728\u60AC\u6D6E\u9884\u89C8\u548C\u7F16\u8F91\u5668\u4E2D\u7684\u663E\u793A\u65B9\u5F0F\u3002","settings.annotationPreviewMode.plainText":"\u7EAF\u6587\u672C","settings.annotationPreviewMode.markdown":"Markdown","settings.autoRotateDefault":"\u9ED8\u8BA4\u81EA\u52A8\u65CB\u8F6C","settings.autoRotateDefault.desc":"\u542F\u52A8 3D \u9884\u89C8\u65F6\u9ED8\u8BA4\u5F00\u542F\u81EA\u52A8\u65CB\u8F6C\u3002","settings.snapshotNaming":"\u5FEB\u7167\u547D\u540D","settings.snapshotNaming.desc":"\u5BFC\u51FA\u5FEB\u7167\u6587\u4EF6\u7684\u547D\u540D\u65B9\u5F0F\u3002","settings.snapshotNaming.modelName":"\u6A21\u578B\u540D + \u65F6\u95F4\u6233","settings.snapshotNaming.timestamp":"\u4EC5\u65F6\u95F4\u6233","settings.logLevel":"\u65E5\u5FD7\u7EA7\u522B","settings.logLevel.desc":"\u63A7\u5236\u63D2\u4EF6\u5728\u5F00\u53D1\u8005\u63A7\u5236\u53F0\u4E2D\u7684\u65E5\u5FD7\u8BE6\u7EC6\u7A0B\u5EA6\u3002","settings.language":"\u8BED\u8A00","settings.language.desc":"\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u7684\u663E\u793A\u8BED\u8A00\u3002\u7ACB\u5373\u751F\u6548\u3002","settings.enableCad":"\u542F\u7528 CAD \u8F6C\u6362\u5668 (STEP/IGES/BREP)","settings.enableCad.desc":"\u542F\u7528 STEP/IGES/BREP \u683C\u5F0F\u7684 CAD \u8F6C\u6362\u8DEF\u7EBF\uFF0C\u901A\u8FC7 Python CadQuery (OpenCASCADE)\u3002\u9700\u8981\uFF1Apip install cadquery trimesh","settings.enableObj2gltf":"\u542F\u7528 obj2gltf \u8F6C\u6362\u5668\uFF08\u5B9E\u9A8C\u6027\uFF09","settings.enableObj2gltf.desc":"\u9ED8\u8BA4\u4F7F\u7528 OBJ \u76F4\u63A5\u52A0\u8F7D\u3002\u4EC5\u5728\u9700\u8981\u672C\u5730\u6807\u51C6\u5316 GLB \u8F93\u51FA\u65F6\u542F\u7528\u3002","settings.preferObj2gltf":"OBJ \u4F18\u5148\u4F7F\u7528 obj2gltf","settings.preferObj2gltf.desc":"\u9ED8\u8BA4\u5173\u95ED\u3002\u4EC5\u5728\u9700\u8981\u6807\u51C6\u5316 GLB \u8F93\u51FA\u6216\u76F4\u63A5 OBJ \u52A0\u8F7D\u6548\u679C\u4E0D\u4F73\u65F6\u5F00\u542F\u3002","settings.enableFbx2gltf":"\u542F\u7528 FBX2glTF \u8F6C\u6362\u5668","settings.enableFbx2gltf.desc":"\u542F\u7528 FBX \u6587\u4EF6\u901A\u8FC7 FBX2glTF \u8F6C\u6362\u3002\u9700\u8981\u672C\u5730\u5B89\u88C5 FBX2glTF \u4E8C\u8FDB\u5236\u6587\u4EF6\u3002","settings.enableMesh":"\u542F\u7528\u7F51\u683C\u8F6C\u6362\u5668 (3MF/DAE)","settings.enableMesh.desc":"\u542F\u7528 3MF \u548C DAE (Collada) \u683C\u5F0F\u7684\u8F6C\u6362\u8DEF\u7EBF\uFF0C\u901A\u8FC7 Python trimesh\u3002\u9700\u8981\u5B89\u88C5 Python \u548C trimesh (pip install trimesh numpy networkx pycollada)\u3002","settings.enableSldprt":"\u542F\u7528 SLDPRT \u8F6C\u6362\u5668 (SolidWorks)","settings.enableSldprt.desc":"\u542F\u7528 SolidWorks .sldprt \u6587\u4EF6\u901A\u8FC7 FreeCAD \u8F6C\u6362\u3002\u9700\u8981\u5B89\u88C5 FreeCAD (https://www.freecad.org/downloads.php)\u3002","settings.mobileSupport.desc":"\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\uFF0CGLB\u3001GLTF\u3001STL\u3001OBJ\u3001PLY \u8FD9\u7C7B\u76F4\u8BFB\u683C\u5F0F\u53EF\u7528\u3002\u672C\u5730\u8F6C\u6362\u5668\u8BBE\u7F6E\u548C\u547D\u4EE4\u8BCA\u65AD\u4ECD\u4EC5\u652F\u6301\u684C\u9762\u7AEF\u3002","settings.pythonCmd":"Python \u547D\u4EE4\u8DEF\u5F84\uFF08CAD \u7528\uFF09","settings.pythonCmd.desc":"\u53EF\u9009\u7684 Python \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E CAD \u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 py\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 python3\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FREECAD_CMD\u3002","settings.freecadCmd":"FreeCAD \u547D\u4EE4\u8DEF\u5F84\uFF08SLDPRT \u7528\uFF09","settings.freecadCmd.desc":"\u53EF\u9009\u7684 FreeCAD \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E SolidWorks \u6587\u4EF6\u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 FreeCADCmd.exe\uFF0CmacOS \u901A\u5E38\u7528 FreeCADCmd\uFF0CLinux \u901A\u5E38\u7528 freecadcmd\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FREECADCMD\u3002","settings.obj2gltfCmd":"obj2gltf \u547D\u4EE4\u8DEF\u5F84","settings.obj2gltfCmd.desc":"\u53EF\u9009\u7684 obj2gltf \u547D\u4EE4\u8DEF\u5F84\u3002Windows \u901A\u5E38\u7528 obj2gltf.cmd\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 obj2gltf\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_OBJ2GLTF_CMD\u3002","settings.fbx2gltfCmd":"FBX2glTF \u547D\u4EE4\u8DEF\u5F84","settings.fbx2gltfCmd.desc":"\u53EF\u9009\u7684 FBX2glTF \u547D\u4EE4\u8DEF\u5F84\u3002Windows \u901A\u5E38\u7528 FBX2glTF.exe\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 FBX2glTF\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_FBX2GLTF_CMD\u3002","settings.assimpCmd":"Python \u547D\u4EE4\u8DEF\u5F84\uFF083MF/DAE \u7528\uFF09","settings.assimpCmd.desc":"\u53EF\u9009\u7684 Python \u547D\u4EE4\u8DEF\u5F84\uFF0C\u7528\u4E8E 3MF \u548C DAE \u8F6C\u6362\u3002Windows \u901A\u5E38\u7528 py\uFF0CmacOS \u548C Linux \u901A\u5E38\u7528 python3\u3002\u8BBE\u7F6E\u540E\u8986\u76D6\u81EA\u52A8\u53D1\u73B0\u548C AI3D_ASSIMP_CMD\u3002","settings.diagnostics.desc":"\u663E\u793A\u63D2\u4EF6\u5F53\u524D\u5B9E\u9645\u4F7F\u7528\u7684\u53EF\u6267\u884C\u6587\u4EF6\u8DEF\u5F84\uFF0C\u5E76\u4E3A Python \u73AF\u5883\u548C\u8F6C\u6362\u5668\u547D\u4EE4\u6267\u884C\u8F7B\u91CF\u81EA\u68C0\u3002","settings.diagnostics.idle":"\u73AF\u5883\u68C0\u67E5\u9ED8\u8BA4\u5173\u95ED\u3002\u70B9\u51FB\u201C\u7ACB\u5373\u68C0\u67E5\u201D\u540E\u624D\u4F1A\u6267\u884C\u3002","settings.diagnostics.checkNow":"\u7ACB\u5373\u68C0\u67E5","settings.diagnostics.checking":"\u68C0\u67E5\u4E2D...","settings.diagnostics.refreshed":"AI 3D \u8F6C\u6362\u5668\u547D\u4EE4\u8BCA\u65AD\u5DF2\u5237\u65B0\u3002","settings.diagnostics.checkingAvailability":"\u6B63\u5728\u68C0\u67E5\u8F6C\u6362\u5668\u547D\u4EE4\u53EF\u7528\u6027...","settings.diagnostics.available":"\u53EF\u7528","settings.diagnostics.notFound":"\u672A\u627E\u5230","settings.diagnostics.sourceLabel":"\u6765\u6E90","settings.diagnostics.commandLabel":"\u547D\u4EE4","settings.diagnostics.resolvedPathLabel":"\u89E3\u6790\u8DEF\u5F84","settings.diagnostics.selfCheckLabel":"\u81EA\u68C0","settings.diagnostics.selfCheckOk":"\u901A\u8FC7","settings.diagnostics.selfCheckFailed":"\u5931\u8D25","settings.diagnostics.cadPythonCheck":"Python \u5305\uFF08cadquery\u3001trimesh\uFF09","settings.diagnostics.meshPythonCheck":"Python \u5305\uFF08trimesh\u3001numpy\u3001networkx\u3001collada\uFF09","settings.diagnostics.freecadCmdCheck":"FreeCADCmd \u542F\u52A8\u63A2\u6D4B","settings.diagnostics.obj2gltfCheck":"obj2gltf \u542F\u52A8\u63A2\u6D4B","settings.diagnostics.fbx2gltfCheck":"FBX2glTF \u542F\u52A8\u63A2\u6D4B","settings.canvasHeight":"\u9ED8\u8BA4\u753B\u5E03\u9AD8\u5EA6","settings.canvasHeight.desc":"\u5185\u8054 3D \u9884\u89C8\u7684\u9ED8\u8BA4\u9AD8\u5EA6\uFF08\u50CF\u7D20\uFF09\u3002\u8303\u56F4\uFF1A200\u2013800\u3002","settings.autoRotateSpeed":"\u81EA\u52A8\u65CB\u8F6C\u901F\u5EA6","settings.autoRotateSpeed.desc":"\u542F\u7528\u81EA\u52A8\u65CB\u8F6C\u65F6\u7684\u65CB\u8F6C\u901F\u5EA6\u3002\u8303\u56F4\uFF1A0.1\u20132.0\u3002","settings.renderQuality":"\u6E32\u67D3\u8D28\u91CF","settings.renderQuality.desc":"\u66F4\u9AD8\u8D28\u91CF\u4F7F\u7528\u66F4\u591A GPU \u8D44\u6E90\u3002\u5F71\u54CD\u6297\u952F\u9F7F\u548C\u5206\u8FA8\u7387\u3002","settings.renderScale":"\u6E32\u67D3\u7F29\u653E","settings.renderScale.desc":"\u6E32\u67D3\u5206\u8FA8\u7387\u500D\u6570\u30021.0 = \u539F\u59CB\uFF0C0.5 = \u4E00\u534A\uFF0C2.0 = \u53CC\u500D\uFF08\u8D85\u91C7\u6837\uFF09\u3002\u8303\u56F4\uFF1A0.25\u20132.0\u3002","modelLoad.warningTitle":"\u6682\u65F6\u65E0\u6CD5\u9884\u89C8\u6A21\u578B","modelLoad.warningMessage":"{ext} \u6587\u4EF6\u9700\u8981\u5148\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u542F\u7528 {converterName} \u8F6C\u6362\u5668\uFF0C\u624D\u80FD\u52A0\u8F7D\u3002","modelLoad.warningHint":"\u8BF7\u5148\u5728\u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u542F\u7528\u5BF9\u5E94\u8F6C\u6362\u5668\uFF0C\u7136\u540E\u91CD\u65B0\u52A0\u8F7D\u5F53\u524D\u6587\u4EF6\u3002","modelLoad.mobileWarningMessage":"{ext} \u6587\u4EF6\u9700\u8981\u672C\u5730\u8F6C\u6362\u5DE5\u5177\uFF0C\u4F46\u8FD9\u4E9B\u5DE5\u5177\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\u4E0D\u53EF\u7528\u3002","modelLoad.mobileWarningHint":"\u8BF7\u5728\u684C\u9762\u7AEF\u6253\u5F00\u6B64\u6587\u4EF6\uFF0C\u6216\u5148\u5C06\u5B83\u8F6C\u6362\u4E3A GLB\u3001GLTF\u3001OBJ\u3001STL \u6216 PLY\u3002","modelLoad.errorTitle":"\u65E0\u6CD5\u663E\u793A\u8FD9\u4E2A\u6A21\u578B","modelLoad.errorMessage":"\u52A0\u8F7D\u5931\u8D25\uFF1A{reason}","modelLoad.errorHint":"\u8BF7\u68C0\u67E5\u6587\u4EF6\u683C\u5F0F\uFF0C\u6216\u6253\u5F00\u5F00\u53D1\u8005\u63A7\u5236\u53F0\u67E5\u770B\u8BE6\u7EC6\u4FE1\u606F\u3002","headingPin.showSingle":"\u663E\u793A\u5173\u8054\u6807\u6CE8","headingPin.showMultiple":"\u663E\u793A\u5173\u8054\u6807\u6CE8","headingPin.linkedTo":"\u5173\u8054\u5230\uFF1A{models}","helper.resetViewLabel":"\u91CD\u7F6E\u89C6\u56FE","helper.resetViewDone":"\u5DF2\u91CD\u7F6E","helper.copyModelInfoLabel":"\u590D\u5236\u6A21\u578B\u4FE1\u606F\u4E3A Markdown","helper.copied":"\u5DF2\u590D\u5236","helper.failed":"\u5931\u8D25","helper.toggleWireframeLabel":"\u5207\u6362\u7EBF\u6846\u663E\u793A","helper.wireframeOn":"\u7EBF\u6846","helper.wireframeOff":"\u5B9E\u4F53","helper.toggleAxesLabel":"\u5207\u6362\u65B9\u5411\u5750\u6807\u8F74","helper.axesOn":"\u5750\u6807\u8F74\u5DF2\u5F00\u542F","helper.axesOff":"\u5750\u6807\u8F74\u5DF2\u5173\u95ED","helper.toggleBoundingBoxLabel":"\u5207\u6362\u5305\u56F4\u76D2","helper.boundingBoxOn":"\u5305\u56F4\u76D2\u5DF2\u5F00\u542F","helper.boundingBoxOff":"\u5305\u56F4\u76D2\u5DF2\u5173\u95ED","helper.toggleDisassemblyLabel":"\u5207\u6362\u5206\u89E3\u6A21\u5F0F","helper.disassemblyOn":"\u5206\u89E3\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.disassemblyOff":"\u5206\u89E3\u6A21\u5F0F\u5DF2\u5173\u95ED","helper.resetPartsLabel":"\u91CD\u7F6E\u5206\u89E3\u90E8\u4EF6","helper.partsReset":"\u90E8\u4EF6\u5DF2\u91CD\u7F6E","helper.changeResolutionLabel":"\u5207\u6362\u5206\u8FA8\u7387","helper.resolutionValue":"\u5206\u8FA8\u7387\uFF1A{value}","helper.toggleAnimationLabel":"\u64AD\u653E\u6216\u6682\u505C\u52A8\u753B","helper.playing":"\u64AD\u653E\u4E2D","helper.paused":"\u5DF2\u6682\u505C","helper.removePreviewLabel":"\u79FB\u9664\u9884\u89C8","helper.copySnapshotLabel":"\u590D\u5236\u5FEB\u7167","helper.saveSnapshotLabel":"\u4FDD\u5B58\u5FEB\u7167\u5230\u4ED3\u5E93","helper.saved":"\u5DF2\u4FDD\u5B58","helper.downloadSnapshotLabel":"\u4E0B\u8F7D\u5FEB\u7167","helper.downloaded":"\u5DF2\u4E0B\u8F7D","helper.toggleAnnotationLabel":"\u5207\u6362\u6807\u6CE8\u6A21\u5F0F","helper.toggleAnnotationsVisibilityLabel":"\u663E\u793A\u6216\u9690\u85CF\u6807\u6CE8","helper.annotateOn":"\u6807\u6CE8\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.annotateOff":"\u6807\u6CE8\u6A21\u5F0F\u5DF2\u5173\u95ED","helper.annotationsVisible":"\u6807\u6CE8\u5DF2\u663E\u793A","helper.annotationsHidden":"\u6807\u6CE8\u5DF2\u9690\u85CF","helper.enableInteractionLabel":"\u542F\u7528\u89E6\u63A7\u4EA4\u4E92","helper.disableInteractionLabel":"\u5207\u56DE\u6EDA\u52A8\u6A21\u5F0F","helper.interactionOn":"\u6A21\u578B\u4EA4\u4E92\u5DF2\u5F00\u542F","helper.interactionOff":"\u6EDA\u52A8\u6A21\u5F0F\u5DF2\u5F00\u542F","helper.showMoreActionsLabel":"\u663E\u793A\u66F4\u591A\u64CD\u4F5C","helper.hideMoreActionsLabel":"\u6536\u8D77\u989D\u5916\u64CD\u4F5C","helper.moreActionsShown":"\u5DF2\u5C55\u5F00\u66F4\u591A\u64CD\u4F5C","helper.moreActionsHidden":"\u5DF2\u6536\u8D77\u989D\u5916\u64CD\u4F5C","helper.interactAction":"\u4EA4\u4E92","helper.scrollAction":"\u6EDA\u52A8","workbench.emptyTitle":"\u6682\u65E0\u6A21\u578B","workbench.emptyText":"\u4F7F\u7528\u201C\u5BFC\u5165 3D \u6A21\u578B\u201D\u547D\u4EE4\u52A0\u8F7D GLB\u3001GLTF \u6216 STL \u6587\u4EF6\u3002","workbench.modelTitle":"3D \u6A21\u578B","workbench.noModelLoaded":"\u5C1A\u672A\u52A0\u8F7D\u6A21\u578B","workbench.disassemblyTitle":"\u5206\u89E3","workbench.explodeLabel":"\u7206\u70B8","workbench.summaryTitle":"\u6458\u8981","workbench.meshesLabel":"\u7F51\u683C","workbench.splatsLabel":"\u70B9\u4E91","workbench.trianglesLabel":"\u4E09\u89D2\u5F62","workbench.materialsLabel":"\u6750\u8D28","workbench.tagsTitle":"\u6807\u7B7E","workbench.noTagsYet":"\u8FD8\u6CA1\u6709\u6807\u7B7E","workbench.addTagPlaceholder":"\u6DFB\u52A0\u6807\u7B7E...","workbench.addTagAction":"\u6DFB\u52A0","workbench.annotationsTitle":"\u6807\u6CE8","workbench.exitAnnotate":"\u9000\u51FA\u6807\u6CE8","workbench.annotate":"\u6807\u6CE8","workbench.annotateHintActive":"\u70B9\u51FB\u6A21\u578B\u6DFB\u52A0\u6807\u7B7E \xB7 \u6309 Esc \u9000\u51FA","workbench.annotateHintActiveMobile":"\u70B9\u6309\u6A21\u578B\u6DFB\u52A0\u6807\u7B7E\u3002\u9700\u8981\u7EE7\u7EED\u9605\u8BFB\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","workbench.pinCount":"{count} \u4E2A\u6807\u6CE8","workbench.editAction":"\u7F16\u8F91","workbench.deleteAction":"\u5220\u9664","workbench.resetViewAction":"\u91CD\u7F6E\u89C6\u56FE","workbench.insertInfoAction":"\u63D2\u5165\u4FE1\u606F","workbench.playAction":"\u64AD\u653E","workbench.pauseAction":"\u6682\u505C","workbench.saveProfileAction":"\u4FDD\u5B58\u914D\u7F6E","workbench.generateNoteAction":"\u751F\u6210\u7B14\u8BB0","workbench.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u64CD\u4F5C\u6A21\u578B\u65F6\u70B9\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u7B14\u8BB0\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","workbench.mobileHintInteractive":"\u5F53\u524D\u4E3A\u4EA4\u4E92\u6A21\u5F0F\u3002\u9700\u8981\u7EE7\u7EED\u6EDA\u52A8\u7B14\u8BB0\u65F6\uFF0C\u8BF7\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","directView.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u4F7F\u7528\u4E0B\u65B9\u5DE5\u5177\u680F\u91CC\u7684\u201C\u4EA4\u4E92\u201D\u6309\u94AE\uFF0C\u5728\u6A21\u578B\u64CD\u4F5C\u548C\u7B14\u8BB0\u6EDA\u52A8\u4E4B\u95F4\u5207\u6362\u3002","workbench.fileNotFound":"\u672A\u627E\u5230\u6587\u4EF6\uFF1A{path}","annotation.selectColor":"\u9009\u62E9\u989C\u8272 {color}","annotation.sectionEmpty":"\u8BE5\u6BB5\u5185\u5BB9\u4E3A\u7A7A\u3002","modal.selectModel":"\u9009\u62E9\u4E00\u4E2A 3D \u6A21\u578B...","main.ribbonOpenWorkbench":"\u6253\u5F00 3D \u5DE5\u4F5C\u53F0","main.commandImportModel":"\u5BFC\u5165 3D \u6A21\u578B","main.commandOpenWorkbench":"\u6253\u5F00 3D \u5DE5\u4F5C\u53F0","main.commandGenerateNote":"\u751F\u6210\u77E5\u8BC6\u7B14\u8BB0","main.commandClearConversionCache":"\u6E05\u9664\u8F6C\u6362\u7F13\u5B58","main.commandCheckConverters":"\u68C0\u67E5\u8F6C\u6362\u5668","main.converterDiagnosticsMobileUnavailable":"\u8F6C\u6362\u5668\u8BCA\u65AD\u4EC5\u652F\u6301\u684C\u9762\u7AEF\u3002\u5728 iOS\u3001iPadOS \u548C Android \u4E0A\uFF0C\u76F4\u8BFB\u683C\u5F0F\u4ECD\u53EF\u52A0\u8F7D\u3002","codeBlock.noModelPathOrConfig":"\u672A\u6307\u5B9A\u6A21\u578B\u8DEF\u5F84\u6216\u914D\u7F6E\u3002","codeBlock.jsonParseError":"JSON \u89E3\u6790\u9519\u8BEF\uFF1A{error}","codeBlock.jsonParseLine":"\uFF08\u7B2C {line} \u884C\uFF09","codeBlock.noModelsInConfig":"\u914D\u7F6E\u4E2D\u672A\u6307\u5B9A\u6A21\u578B\u3002","codeBlock.unsupportedFormat":"\u4E0D\u652F\u6301\u7684\u683C\u5F0F\uFF1A{ext}\u3002\u652F\u6301\uFF1A{formats}","codeBlock.noConfigSpecified":"\u672A\u6307\u5B9A\u914D\u7F6E\u3002","codeBlock.noModelsSpecified":"\u672A\u6307\u5B9A\u6A21\u578B\u3002","codeBlock.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u64CD\u4F5C\u6A21\u578B\u65F6\u70B9\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u7B14\u8BB0\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","codeBlock.renderingGrid":"\u6B63\u5728\u6E32\u67D3\u7F51\u683C...","codeBlock.composeRequiresSections":"\u201Ccompose\u201D \u9884\u8BBE\u9700\u8981\u63D0\u4F9B \u201Csections\u201D \u6570\u7EC4\u3002","codeBlock.composeNoValidSections":"Compose\uFF1A\u6CA1\u6709\u6709\u6548\u7684\u5206\u6BB5\u3002","codeBlock.unknownPreset":"\u672A\u77E5\u9884\u8BBE\uFF1A\u201C{preset}\u201D\u3002\u53EF\u7528\uFF1Acompare\u3001showcase\u3001explode\u3001timeline\u3001compose","codeBlock.presetRequiresModels":"\u9884\u8BBE \u201C{preset}\u201D \u9700\u8981 {min}-{max} \u4E2A\u6A21\u578B\uFF0C\u5F53\u524D\u4E3A {count} \u4E2A\u3002","codeBlock.gridFailed":"\u7F51\u683C\u6E32\u67D3\u5931\u8D25\uFF1A{reason}","livePreview.mobileHint":"\u79FB\u52A8\u7AEF\u63D0\u793A\uFF1A\u9700\u8981\u62D6\u52A8\u6A21\u578B\u65F6\u5207\u5230\u201C\u4EA4\u4E92\u201D\uFF0C\u7EE7\u7EED\u9605\u8BFB\u65F6\u5207\u56DE\u201C\u6EDA\u52A8\u201D\u3002","loading.default":"\u52A0\u8F7D\u4E2D...","loading.preparingModel":"\u6B63\u5728\u51C6\u5907\u6A21\u578B...","loading.loadingModel":"\u6B63\u5728\u52A0\u8F7D\u6A21\u578B..."}});function fd(n){e2=n;for(let e of LA)e()}function Z(n){var e,t,i;return(i=(t=(e=_8[e2])==null?void 0:e[n])!=null?t:DA[n])!=null?i:n}function t2(n){return LA.add(n),()=>{LA.delete(n)}}function g8(n,e){return n.replace(/\{(\w+)\}/g,(t,i)=>{var r;return(r=e[i])!=null?r:""})}function Jt(n,e){return g8(Z(n),e)}var _8,e2,LA,en=A(()=>{"use strict";QU();$U();_8={en:DA,"zh-CN":JU},e2="en",LA=new Set});function v8(){return`pin-${Date.now()}-${E8++}`}var dd,Dc,E8,Jn,$n,hd=A(()=>{"use strict";dd=require("obsidian");ve();mA();en();Js();Dc=["#4a9eff","#ff6b6b","#51cf66","#ffd43b","#845ef7","#ff922b","#22b8cf","#f06595","#94d82d","#ffa8a8"],E8=1;Jn=class Jn{constructor(e,t,i,r,s,a,o,l={}){this.provider=e;this.hostEl=t;this.mode=i;this.onChange=s;this.noteReader=a;this.headingSearch=o;this.pinEls=new Map;this.observer=null;this.resizeObs=null;this.annotations=[];this.editorEl=null;this.disposeCallbacks=[];this.frameCount=0;this.lastCamState="";this.idleFrames=0;this.cameraIdle=!1;this.hoverPopover=null;this.hoverTimeout=null;this.hoverRequestId=0;this._highlightHandler=null;this._pulseTimeout=null;this._headingDropdown=null;this._headingDebounce=null;this._selectedHeading=null;this.previewRenderRoot=new dd.Component;this.previewRenderChildren=new WeakMap;var c;this.previewApp=l.app,this.previewMode=(c=l.previewMode)!=null?c:"plain-text",this.previewRenderRoot.load(),this.overlay=this.hostEl.createDiv({cls:"ai3d-annotation-overlay"}),this.setAnnotations(r),this._highlightHandler=f=>{let d=f.detail,h=d==null?void 0:d.pinId;h&&this.pulsePin(h)},activeDocument.addEventListener("ai3d-pin-highlight",this._highlightHandler),this.disposeCallbacks.push(()=>activeDocument.removeEventListener("ai3d-pin-highlight",this._highlightHandler)),this.disposeCallbacks.push(()=>this.previewRenderRoot.unload()),this.startProjectionLoop()}setAnnotations(e){for(let[,t]of this.pinEls)t.el.remove();this.pinEls.clear(),this.annotations=[...e];for(let t of e)this.createPinElement(t);this.updateProjections()}addPin(e,t,i){var s;let r={id:v8(),position:[e.x,e.y,e.z],label:t,color:i!=null?i:Dc[this.annotations.length%Dc.length],createdAt:new Date().toISOString()};return this.annotations.push(r),this.createPinElement(r),this.updateProjections(),(s=this.onChange)==null||s.call(this,this.annotations),r}removePin(e){var i;let t=this.pinEls.get(e);t&&(t.el.remove(),this.pinEls.delete(e)),this.annotations=this.annotations.filter(r=>r.id!==e),(i=this.onChange)==null||i.call(this,this.annotations)}updatePin(e,t){var s;let i=this.annotations.find(a=>a.id===e);if(!i)return;Object.assign(i,t);let r=this.pinEls.get(e);if(r){t.position&&(r.worldPos=new v(...t.position));let a=r.el.querySelector(".ai3d-pin-label");a&&t.label!==void 0&&(a.textContent=t.label);let o=r.el.querySelector(".ai3d-pin-dot");o&&t.color!==void 0&&o.style.setProperty("--pin-color",t.color)}this.updateProjections(),(s=this.onChange)==null||s.call(this,this.annotations)}showEditor(e,t,i){this.showEditorInternal(e,t,i)}editPin(e){let t=this.annotations.find(o=>o.id===e);if(!t)return;let i=this.pinEls.get(e);if(!i)return;let r=i.el.getBoundingClientRect(),s=r.left+r.width/2,a=r.top;this.showEditorInternal(s,a,i.worldPos,t)}getPinPosition(e){let t=this.pinEls.get(e);return t?t.worldPos.clone():null}getAnnotations(){return this.annotations}showEditorInternal(e,t,i,r){var w,H;this.hideEditor(),this._selectedHeading=null;let s=this.overlay.createDiv({cls:"ai3d-annotation-editor"}),a=s.createDiv({cls:"ai3d-editor-input-wrap"}),o=a.createEl("input",{cls:"ai3d-annotation-editor-input"});o.type="text",o.placeholder=this.headingSearch?"Label or search heading...":"Label...",r&&(o.value=r.label);let l=a.createSpan({cls:"ai3d-editor-binding-tag is-hidden"}),c=l.createEl("button",{cls:"ai3d-editor-binding-clear"});c.textContent="\xD7",c.addEventListener("click",O=>{O.stopPropagation(),this._selectedHeading=null,l.classList.add("is-hidden"),f.classList.add("is-hidden"),f.textContent="",o.value="",o.focus()});let f=s.createDiv({cls:"ai3d-editor-content-preview is-hidden"}),d=s.createDiv({cls:"ai3d-heading-dropdown is-hidden"});this._headingDropdown=d;let h=-1,u=[],m=O=>{let k=d.querySelectorAll(".ai3d-heading-dropdown-item");k.forEach(X=>X.classList.remove("active")),h=O,O>=0&&O{var j;this._selectedHeading=O,o.value=O.heading;let k=Mr(O.notePath);(j=l.querySelector(".ai3d-editor-binding-text"))==null||j.remove();let X=l.createSpan({cls:"ai3d-editor-binding-text"});X.textContent=`\u{1F4C4} ${k}`,l.classList.remove("is-hidden"),_(),o.focus(),this.loadContentPreview(f,O.notePath,O.heading)},_=()=>{d.classList.add("is-hidden"),d.replaceChildren(),h=-1},g=O=>{if(d.replaceChildren(),h=-1,u=O,O.length===0){d.classList.add("is-hidden");return}for(let k=0;k{q.preventDefault(),q.stopPropagation(),p(X)}),j.addEventListener("mouseenter",()=>m(k))}d.classList.remove("is-hidden")};o.addEventListener("input",()=>{if(!this.headingSearch)return;this._headingDebounce&&window.clearTimeout(this._headingDebounce);let O=o.value.trim();if(O.length<1){_();return}this._headingDebounce=window.setTimeout(()=>{let k=this.headingSearch(O);g(k)},150)}),o.addEventListener("keydown",O=>{if(d.classList.contains("is-hidden")){O.key==="Enter"?(O.preventDefault(),x.click()):O.key==="Escape"&&(O.preventDefault(),this.hideEditor());return}let k=d.querySelectorAll(".ai3d-heading-dropdown-item");O.key==="ArrowDown"?(O.preventDefault(),m(Math.min(h+1,k.length-1))):O.key==="ArrowUp"?(O.preventDefault(),m(Math.max(h-1,0))):O.key==="Enter"?(O.preventDefault(),h>=0&&h{window.setTimeout(_,150)});let T=s.createDiv({cls:"ai3d-annotation-editor-colors"}),b=(w=r==null?void 0:r.color)==null?void 0:w.trim(),R=b||Dc[0],S=b&&!Dc.includes(b)?[b,...Dc]:Dc;for(let O of S){let k=T.createEl("button",{cls:"ai3d-pin-color-swatch"});k.type="button",k.title=O,k.setAttribute("aria-label",Jt("annotation.selectColor",{color:O})),k.style.setProperty("--swatch-color",O),k.style.backgroundColor=O,O===R&&k.classList.add("is-selected"),k.addEventListener("click",X=>{X.stopPropagation(),R=O,T.querySelectorAll(".ai3d-pin-color-swatch").forEach(j=>j.classList.remove("is-selected")),k.classList.add("is-selected")})}let I=s.createDiv({cls:"ai3d-annotation-editor-actions"});if(r){let O=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-delete"});O.textContent="Delete",O.addEventListener("click",k=>{k.stopPropagation(),this.removePin(r.id),this.hideEditor()})}let x=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-confirm"});x.textContent=r?"Save":"OK",x.addEventListener("click",O=>{O.stopPropagation();let k=o.value.trim()||"Pin",X=this._selectedHeading;if(r){let j={label:k,color:R};X&&(j.notePath=X.notePath,j.headingRef=X.heading,j.headingLevel=X.level),this.updatePin(r.id,j)}else{let j=this.addPin(i,k,R);X&&this.updatePin(j.id,{notePath:X.notePath,headingRef:X.heading,headingLevel:X.level})}this.hideEditor()});let P=I.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-cancel"});P.textContent="Cancel",P.addEventListener("click",O=>{O.stopPropagation(),this.hideEditor()});let L=this.overlay.getBoundingClientRect(),y=e-L.left,B=t-L.top;if(s.style.setProperty("--editor-left",`${Math.max(0,Math.min(y,L.width-220))}px`),s.style.setProperty("--editor-top",`${Math.max(0,Math.min(B-10,L.height-160))}px`),this.editorEl=s,r!=null&&r.notePath&&(r!=null&&r.headingRef)){let O=Mr(r.notePath),k=l.createSpan({cls:"ai3d-editor-binding-text"});k.textContent=`\u{1F4C4} ${O}`,l.classList.remove("is-hidden"),this._selectedHeading={notePath:r.notePath,heading:r.headingRef,level:(H=r.headingLevel)!=null?H:2},this.loadContentPreview(f,r.notePath,r.headingRef)}window.requestAnimationFrame(()=>o.focus()),s.addEventListener("pointerdown",O=>O.stopPropagation()),s.addEventListener("mousedown",O=>O.stopPropagation())}hideEditor(){if(this._headingDebounce&&(window.clearTimeout(this._headingDebounce),this._headingDebounce=null),this._headingDropdown=null,this._selectedHeading=null,this.editorEl){let e=this.editorEl.querySelector(".ai3d-editor-content-preview");e&&this.clearRenderedPreview(e),this.editorEl.remove(),this.editorEl=null}}async loadContentPreview(e,t,i){if(!this.noteReader)return;this.clearRenderedPreview(e),e.classList.add("is-hidden");let r=await this.noteReader(t,i);if(!r){e.textContent=Z("annotation.sectionEmpty"),e.className="ai3d-editor-content-preview ai3d-editor-content-preview--empty",e.classList.remove("is-hidden");return}await this.renderPreviewContent(e,r,t,"editor")}async showHoverPopover(e,t,i){if(!this.noteReader||!i.notePath||!i.headingRef)return;this.hideHoverPopover();let r=await this.noteReader(i.notePath,i.headingRef);if(!r||e!==this.hoverRequestId||!t.isConnected||!this.hostEl.isConnected)return;let s=createDiv({cls:"ai3d-pin-popover"}),a=s.createDiv({cls:"ai3d-pin-popover-title"});a.textContent=i.headingRef;let o=s.createDiv({cls:"ai3d-pin-popover-body"});if(await this.renderPreviewContent(o,r,i.notePath,"popover"),e!==this.hoverRequestId||!t.isConnected||!this.hostEl.isConnected){this.clearRenderedPreview(o);return}let l=t.getBoundingClientRect();s.style.setProperty("--popover-left",`${l.left+l.width/2}px`),s.style.setProperty("--popover-top",`${l.bottom+4}px`),activeDocument.body.appendChild(s),this.hoverPopover=s}hideHoverPopover(){if(this.hoverTimeout&&(window.clearTimeout(this.hoverTimeout),this.hoverTimeout=null),this.hoverPopover){let e=this.hoverPopover.querySelector(".ai3d-pin-popover-body");e&&this.clearRenderedPreview(e),this.hoverPopover.remove(),this.hoverPopover=null}}clearRenderedPreview(e){let t=this.previewRenderChildren.get(e);t&&(this.previewRenderRoot.removeChild(t),this.previewRenderChildren.delete(e)),e.replaceChildren()}async renderPreviewContent(e,t,i,r){let s=this.previewMode==="markdown"&&!!this.previewApp,a=r==="editor";if(!s){let l=a&&t.length>300?t.slice(0,300)+"...":t;e.textContent=l,e.className=a?"ai3d-editor-content-preview":"ai3d-pin-popover-body",a&&e.classList.remove("is-hidden");return}e.className=a?"ai3d-editor-content-preview ai3d-editor-content-preview--markdown markdown-rendered":"ai3d-pin-popover-body ai3d-pin-popover-body--markdown markdown-rendered",a&&e.classList.remove("is-hidden");let o=this.previewRenderRoot.addChild(new dd.Component);this.previewRenderChildren.set(e,o);try{await dd.MarkdownRenderer.render(this.previewApp,t,e,i,o)}catch(l){this.previewRenderRoot.removeChild(o),this.previewRenderChildren.delete(e),e.textContent=a&&t.length>300?t.slice(0,300)+"...":t,e.className=a?"ai3d-editor-content-preview":"ai3d-pin-popover-body",a&&e.classList.remove("is-hidden"),console.warn("[AI3D] Annotation markdown preview fallback:",l)}}pulsePin(e){let t=this.pinEls.get(e);t&&(this._pulseTimeout&&(window.clearTimeout(this._pulseTimeout),this._pulseTimeout=null),t.el.classList.remove("ai3d-pin-pulse"),t.el.offsetWidth,t.el.classList.add("ai3d-pin-pulse"),this._pulseTimeout=window.setTimeout(()=>{t.el.classList.remove("ai3d-pin-pulse"),this._pulseTimeout=null},1200))}destroy(){var e,t,i;this.hoverRequestId++,this.hideHoverPopover(),this._pulseTimeout&&(window.clearTimeout(this._pulseTimeout),this._pulseTimeout=null),this._headingDebounce&&(window.clearTimeout(this._headingDebounce),this._headingDebounce=null),this._headingDropdown=null,this._selectedHeading=null,(e=this.observer)==null||e.remove(),this.observer=null,(t=this.resizeObs)==null||t.disconnect(),this.resizeObs=null;for(let r of this.disposeCallbacks)r();this.disposeCallbacks=[],this.overlay.remove(),this.pinEls.clear(),(i=this.editorEl)==null||i.remove(),this.editorEl=null}createPinElement(e){let t=this.overlay.createDiv({cls:"ai3d-annotation-pin"});t.dataset.pinId=e.id,t.createDiv({cls:"ai3d-pin-dot"}).style.setProperty("--pin-color",e.color);let r=t.createSpan({cls:"ai3d-pin-label"});if(r.textContent=e.label,this.mode==="edit"){let s=t.createEl("button",{cls:"ai3d-pin-delete"});s.textContent="\xD7",s.addEventListener("click",a=>{a.stopPropagation(),this.removePin(e.id)}),t.addEventListener("click",a=>{a.target.closest(".ai3d-pin-delete")||(a.stopPropagation(),this.editPin(e.id))})}t.addEventListener("pointerdown",s=>s.stopPropagation()),e.notePath&&e.headingRef&&this.noteReader&&(t.addEventListener("mouseenter",()=>{this.hoverTimeout&&window.clearTimeout(this.hoverTimeout);let s=++this.hoverRequestId;this.hoverTimeout=window.setTimeout(()=>{this.hoverTimeout=null,s===this.hoverRequestId&&this.showHoverPopover(s,t,e)},300)}),t.addEventListener("mouseleave",()=>{this.hoverTimeout&&(window.clearTimeout(this.hoverTimeout),this.hoverTimeout=null),this.hoverRequestId++,this.hideHoverPopover()})),this.pinEls.set(e.id,{el:t,worldPos:new v(...e.position)})}startProjectionLoop(){let e=this.provider.scene,t=e.onAfterRenderCameraObservable.add(i=>{i===this.provider.camera&&this.updateProjections()});this.observer={remove:()=>e.onAfterRenderCameraObservable.remove(t)},this.resizeObs=new ResizeObserver(()=>this.updateProjections()),this.provider.canvas&&this.resizeObs.observe(this.provider.canvas)}updateProjections(){if(this.pinEls.size===0)return;let{scene:e,camera:t,engine:i,canvas:r}=this.provider;if(!this.hostEl.isConnected||!r.isConnected||r.clientWidth===0||r.clientHeight===0||e.isDisposed)return;let s=i.getRenderWidth(),a=i.getRenderHeight();if(s===0||a===0)return;let o=r.clientWidth,l=r.clientHeight,c=o/s,f=l/a,d=e.getTransformMatrix(),h=t.viewport.toGlobal(s,a),u=`${t.alpha.toFixed(3)}_${t.beta.toFixed(3)}_${t.radius.toFixed(3)}_${t.target.x.toFixed(2)}_${t.target.y.toFixed(2)}_${t.target.z.toFixed(2)}`;u===this.lastCamState?this.idleFrames++:(this.idleFrames=0,this.cameraIdle=!1),this.lastCamState=u,this.idleFrames>=Jn.IDLE_THRESHOLD&&!this.cameraIdle&&(this.cameraIdle=!0),this.frameCount++;let m=this.cameraIdle?1:this.pinEls.size>=12?3:2;if(!this.cameraIdle&&this.frameCount%m!==0)return;let p=this.cameraIdle&&this.frameCount%6===0,_=p?t.position:null,g=Jn._identity,T=Jn._scratchDir,b=Jn._scratchRay;for(let[,R]of this.pinEls){let S=v.Project(R.worldPos,g,d,h);if(S.z>1||S.z<0)this.hidePin(R.el);else if(R.el.style.setProperty("--pin-left",`${S.x*c}px`),R.el.style.setProperty("--pin-top",`${S.y*f}px`),p&&_){let I=v.Distance(_,R.worldPos);R.worldPos.subtractToRef(_,T),T.normalize(),b.origin=_,b.direction=T,b.length=I;let x=e.pickWithRay(b),P=Math.max(I*.01,.01),L=!!(x!=null&&x.hit)&&x.distance=5&&((a||!h&&s===5)&&(l.push(s,0,a,r),s=6),h&&(l.push(s,h,0,r),s=6)),a=""},f=0;f"?(s=1,a=""):a=i+a[0]:o?i===o?o="":a+=i:i==='"'||i==="'"?o=i:i===">"?(c(),s=1):s&&(i==="="?(s=5,r=a,a=""):i==="/"&&(s<5||t[f][d+1]===">")?(c(),s===3&&(l=l[0]),s=l,(l=l[0]).push(2,0,s),s=0):i===" "||i===" "||i===` +`||i==="\r"?(c(),s=2):a+=i),s===3&&a==="!--"&&(s=4,l=l[0])}return c(),l})(n)),e),arguments,[])).length>1?e:e[0]}var r2,i2,s2=A(()=>{r2=function(n,e,t,i){var r;e[0]=0;for(var s=1;s{"use strict"});var Qi,c2=A(()=>{"use strict";s2();l2();Qi=n2.bind(a2)});function PA(n){d2=n}function _p(n){return f2[n]>=f2[d2]}function gp(){return new Date().toISOString()}function Ep(n){return n&&Object.keys(n).length>0?n:void 0}function ti(n){let e=`[AI3D][${n}]`;return{debug(t,i){_p("debug")&&console.debug(e,gp(),t,Ep(i))},info(t,i){_p("info")&&console.debug(e,gp(),t,Ep(i))},warn(t,i){_p("warn")&&console.warn(e,gp(),t,Ep(i))},error(t,i){_p("error")&&console.error(e,gp(),t,Ep(i))}}}var f2,d2,Dr=A(()=>{"use strict";f2={debug:10,info:20,warn:30,error:40},d2="warn"});function h2(n){let e=xn(n.sourceExt),t=[];return e!==n.sourceExt&&t.push(`Normalized extension '${n.sourceExt}' -> '${e}'.`),T8.debug("prepare direct load",{path:n.path,sourceExt:n.sourceExt,normalizedExt:e,warningCount:t.length}),{effectivePath:n.path,effectiveExt:e,warnings:t}}var T8,u2=A(()=>{"use strict";is();Dr();T8=ti("direct-load-service")});function vp(n){return`.${n.trim().toLowerCase()}`}function Za(n){return n instanceof zo}function OA(n){var e;if(n instanceof zo){let t=(e=S8[n.converterId])!=null?e:n.converterId;return Jt("modelLoad.warningMessage",{ext:vp(n.sourceExt),converterName:t})}return n instanceof Lc?Jt("modelLoad.mobileWarningMessage",{ext:vp(n.sourceExt)}):Jt("modelLoad.errorMessage",{reason:n instanceof Error?n.message:String(n)})}function qa(n){return n instanceof zo?{level:"warning",title:Z("modelLoad.warningTitle"),message:OA(n),hint:Z("modelLoad.warningHint")}:n instanceof Lc?{level:"warning",title:Z("modelLoad.warningTitle"),message:OA(n),hint:Z("modelLoad.mobileWarningHint")}:{level:"error",title:Z("modelLoad.errorTitle"),message:OA(n),hint:Z("modelLoad.errorHint")}}var S8,zo,Lc,Xo=A(()=>{"use strict";en();S8={freecad:"FreeCAD",obj2gltf:"obj2gltf",fbx2gltf:"FBX2glTF",assimp:"mesh",sldprt:"SolidWorks"};zo=class extends Error{constructor(t,i){super(`Converter '${t}' is not registered for ${vp(i)}. Enable the matching converter in plugin settings before loading this format.`);this.converterId=t;this.sourceExt=i;this.name="MissingConverterError"}},Lc=class extends Error{constructor(t){super(`Format ${vp(t)} requires local conversion tools that are unavailable on iOS, iPadOS, and Android.`);this.sourceExt=t;this.name="MobileConversionUnavailableError"}}});function R8(n,e,t){return n.converterId!==e?!1:t?n.converterId===t.converterId&&n.converterCacheKey===t.cacheKey:!0}async function I8(n){if(!n)return!1;try{return await _r(n,gr),!0}catch(e){return!1}}async function m2(n){var a,o,l,c,f,d,h;if(n.capability.strategy!=="convert")throw new Error(`Expected convert strategy, got '${n.capability.strategy}'.`);let e=n.capability.converterId,t=(a=n.capability.outputFormat)!=null?a:"glb";if(!e)throw new Error(`Format .${n.sourceExt} does not define a converter id.`);ud.info("prepare conversion route",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,converterId:e});let i=n.conversionManager.canConvert(n.sourceExt)?await n.conversionManager.getConverterCacheIdentity(n.sourceExt):void 0,r=(o=n.convertedAssetCache)==null?void 0:o.get(n.sourcePath,n.sourceExt,t);if(r)if(!await I8(r.outputPath))ud.warn("conversion cache stale",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:r.outputPath}),(l=n.convertedAssetCache)==null||l.delete(n.sourcePath,n.sourceExt,t);else if(!R8(r,e,i))ud.warn("conversion cache identity mismatch",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,cachedConverterId:r.converterId,cachedConverterCacheKey:r.converterCacheKey,currentConverterId:(c=i==null?void 0:i.converterId)!=null?c:e,currentConverterCacheKey:i==null?void 0:i.cacheKey}),(f=n.convertedAssetCache)==null||f.delete(n.sourcePath,n.sourceExt,t);else return ud.info("conversion cache hit",{sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:r.outputPath}),{effectivePath:r.outputPath,effectiveExt:r.outputExt,warnings:[...r.warnings,"Using cached conversion output."]};if(!n.conversionManager.canConvert(n.sourceExt))throw new zo(e,n.sourceExt);let s=await n.conversionManager.convert({sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t});return(h=n.convertedAssetCache)==null||h.set({cacheVersion:2,converterId:e,converterCacheKey:(d=i==null?void 0:i.cacheKey)!=null?d:e,sourcePath:n.sourcePath,sourceExt:n.sourceExt,targetExt:t,outputPath:s.outputPath,outputExt:s.outputExt,warnings:s.warnings,createdAt:Date.now()}),ud.info("conversion route done",{sourcePath:n.sourcePath,outputPath:s.outputPath,warningCount:s.warnings.length}),{effectivePath:s.outputPath,effectiveExt:s.outputExt,warnings:s.warnings}}var ud,p2=A(()=>{"use strict";Kp();Dr();Gt();Xo();ud=ti("conversion-service")});function x8(n,e){var t;return!!((t=n.preferConversionExts)!=null&&t.includes(e))}async function ta(n){var a,o;let e=xn((a=n.path.split(".").pop())!=null?a:""),t=jp(e);if(ea.info("prepare model input",{path:n.path,sourceExt:e}),!t||!t.enabled)throw ea.warn("unsupported format",{sourceExt:e,path:n.path}),new Error(`Unsupported format: .${e}`);let i=x8(n,e);if(t.strategy==="convert"||i&&!!t.converterId){if(Qt())throw ea.warn("conversion unavailable on mobile",{sourceExt:e,path:n.path}),new Lc(e);if(!n.absolutePath)throw ea.error("filesystem path missing for conversion",{sourceExt:e,path:n.path}),new Error(`Format .${e} requires a local filesystem path for conversion, but none was resolved for '${n.path}'.`);if(!n.conversionManager)throw ea.error("conversion manager missing",{sourceExt:e,path:n.path}),new Error(`Format .${e} requires conversion support, but no conversion manager is available.`);let l=t.strategy==="convert"?t:{...t,strategy:"convert",outputFormat:(o=t.outputFormat)!=null?o:"glb"};if(!l.converterId)throw ea.error("preferred conversion route missing converter id",{sourceExt:e,path:n.path}),new Error(`Format .${e} is configured to prefer conversion, but no converter id is defined.`);i&&t.strategy==="direct"&&ea.info("preferred conversion route",{sourceExt:e,path:n.path,converterId:l.converterId});let c=await m2({sourcePath:n.absolutePath,sourceExt:e,capability:l,conversionManager:n.conversionManager,convertedAssetCache:n.convertedAssetCache});return ea.info("conversion completed",{sourceExt:e,outputExt:c.effectiveExt,outputPath:c.effectivePath,warningCount:c.warnings.length}),{sourcePath:n.path,sourceExt:e,strategy:"convert",effectivePath:c.effectivePath,effectiveExt:c.effectiveExt,warnings:c.warnings}}let s=h2({path:n.path,sourceExt:e});return ea.debug("direct route",{sourceExt:e,path:n.path,warningCount:s.warnings.length}),{sourcePath:n.path,sourceExt:e,strategy:t.strategy,effectivePath:s.effectivePath,effectiveExt:s.effectiveExt,warnings:s.warnings}}var ea,md=A(()=>{"use strict";is();u2();p2();Xo();Dr();qr();ea=ti("model-pipeline")});var pd,Tp,_2=A(()=>{"use strict";is();Dr();pd=ti("conversion-manager"),Tp=class{constructor(){this.converters=new Map;this.pending=new Map}getConverter(e){return this.converters.get(xn(e))}registerConverter(e){pd.info("register converter",{converterId:e.id,sourceExts:[...e.sourceExts]});for(let t of e.sourceExts)this.converters.set(xn(t),e)}canConvert(e){let t=xn(e),i=this.converters.has(t);return pd.debug("can convert",{ext:t,ok:i}),i}async getConverterCacheIdentity(e){let t=this.getConverter(e);if(t)return{converterId:t.id,cacheKey:await t.getCacheKey()}}async convert(e){let t=xn(e.sourceExt),i=this.getConverter(t);if(!i)throw pd.error("converter missing",{ext:t,targetExt:e.targetExt}),new Error(`No converter registered for .${t}`);let r=`${e.sourcePath}::${t}::${e.targetExt}`,s=this.pending.get(r);if(s)return pd.info("joining in-flight conversion",{key:r}),s;pd.info("dispatch conversion",{converterId:i.id,ext:t,targetExt:e.targetExt});let a=i.convert({...e,sourceExt:t});this.pending.set(r,a);try{return await a}finally{this.pending.delete(r)}}}});function wA(...n){let e=(Te==null?void 0:Te.platform)==="darwin"?["/opt/homebrew/bin","/usr/local/bin","/opt/local/bin","/usr/bin"]:["/usr/local/bin","/opt/homebrew/bin","/opt/local/bin","/usr/bin"];return Array.from(new Set(e.flatMap(t=>n.map(i=>`${t}/${i}`))))}function b8(){var r,s,a;if((Te==null?void 0:Te.platform)==="darwin")return["/Applications/FreeCAD.app/Contents/MacOS/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/freecadcmd",...wA("FreeCADCmd","freecadcmd")];if((Te==null?void 0:Te.platform)!=="win32")return["/usr/local/bin/freecadcmd","/opt/homebrew/bin/freecadcmd","/opt/local/bin/freecadcmd","/snap/freecad/current/usr/bin/freecadcmd","/usr/bin/freecadcmd"];let n=[],e=(r=Te==null?void 0:Te.env)==null?void 0:r.LOCALAPPDATA,t=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles,i=(a=Te==null?void 0:Te.env)==null?void 0:a["ProgramFiles(x86)"];if(e&&n.push(Pt(e,"Programs","FreeCAD","bin","FreeCADCmd.exe")),t&&n.push(Pt(t,"FreeCAD","bin","FreeCADCmd.exe")),e)for(let o of["1.2","1.1","1.0","0.22","0.21","0.20"])n.push(`${e}/Programs/FreeCAD ${o}/bin/FreeCADCmd.exe`);if(t)for(let o of["1.2","1.1","1.0","0.22","0.21","0.20"])n.push(`${t}/FreeCAD ${o}/bin/FreeCADCmd.exe`);return i&&n.push(`${i}/FreeCAD/bin/FreeCADCmd.exe`),n}function M8(n){var a,o,l,c;if((Te==null?void 0:Te.platform)!=="win32")return[];let e=(a=Te==null?void 0:Te.env)==null?void 0:a.APPDATA,t=(o=Te==null?void 0:Te.env)==null?void 0:o.LOCALAPPDATA,i=(l=Te==null?void 0:Te.env)==null?void 0:l.npm_config_prefix,r=(c=Te==null?void 0:Te.env)==null?void 0:c.USERPROFILE,s=[i,e?Pt(e,"npm"):void 0,t?Pt(t,"npm"):void 0,r?Pt(r,"AppData","Roaming","npm"):void 0].filter(f=>!!f);return Array.from(new Set(s.map(f=>Pt(f,n))))}function y8(...n){var s,a,o;if((Te==null?void 0:Te.platform)!=="win32")return[];let e=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles,t=(a=Te==null?void 0:Te.env)==null?void 0:a["ProgramFiles(x86)"],i=(o=Te==null?void 0:Te.env)==null?void 0:o.LOCALAPPDATA,r=[e,t,i?Pt(i,"Programs"):void 0].filter(l=>!!l);return Array.from(new Set(r.flatMap(l=>n.map(c=>Pt(l,c)))))}async function VA(n){try{return await _r(n,(Te==null?void 0:Te.platform)==="win32"?gr:gU),!0}catch(e){return!1}}function NA(n){let e=n==null?void 0:n.trim();if(e)return e}function D8(n){let e=[],t="",i=null;for(let r=0;rr.trim().toLowerCase()).filter(Boolean);return e!=null&&e.length?e:C8}async function N8(n){var r;let e=(r=Te==null?void 0:Te.env)==null?void 0:r.PATH;if(!e)return;let t=e.split(EU).map(s=>s.trim()).filter(Boolean),i=(Te==null?void 0:Te.platform)==="win32"?O8(n):[""];for(let s of t)for(let a of i){let o=Pt(s,a?`${n}${a}`:n);if(await VA(o))return o}}function BA(n,e,t=15e3){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:4*1024*1024},(s,a,o)=>{if(s){r(new Error((o||a||s.message).toString().trim()||s.message));return}i({stdout:a!=null?a:"",stderr:o!=null?o:""})})})}function UA(n){let t=(n instanceof Error?n.message:String(n)).replace(/\s+/g," ").trim();return t.length>180?`${t.slice(0,177)}...`:t}async function FA(n,e,t,i){let r="";for(let s of t)try{return await BA(n,[...e,...s]),{ok:!0,detail:""}}catch(a){let o=UA(a);if(i.test(o))return{ok:!0,detail:""};r=o}return{ok:!1,detail:r||"Command probe failed."}}async function F8(n){var i;if(!n.available)return[];let e=(i=n.resolvedPath)!=null?i:n.executable,t=[...n.args];if(n.id==="freecad")try{return await BA(e,[...t,"-c","import cadquery, trimesh; print('ok')"]),[{kind:"cad-python",ok:!0,detail:""}]}catch(r){return[{kind:"cad-python",ok:!1,detail:UA(r)}]}if(n.id==="assimp")try{return await BA(e,[...t,"-c","import trimesh, numpy, networkx, collada; print('ok')"]),[{kind:"mesh-python",ok:!0,detail:""}]}catch(r){return[{kind:"mesh-python",ok:!1,detail:UA(r)}]}if(n.id==="freecadcmd"){let r=await FA(e,t,[["--version"],["--help"]],/freecad|usage|help|version/i);return[{kind:"freecadcmd-cli",ok:r.ok,detail:r.detail}]}if(n.id==="obj2gltf"){let r=await FA(e,t,[["--version"],["--help"]],/obj2gltf|usage|help|version/i);return[{kind:"obj2gltf-cli",ok:r.ok,detail:r.detail}]}if(n.id==="fbx2gltf"){let r=await FA(e,t,[["--version"],["--help"]],/fbx2gltf|usage|help|version/i);return[{kind:"fbx2gltf-cli",ok:r.ok,detail:r.detail}]}return[]}function w8(n){let e=E2.find(t=>t.id===n);if(!e)throw new Error(`Unknown converter command id: ${n}`);return e}function B8(n){var s,a,o,l;let e=(a=(s=Te==null?void 0:Te.env)==null?void 0:s.ProgramFiles)==null?void 0:a.toLowerCase(),t=(l=(o=Te==null?void 0:Te.env)==null?void 0:o["ProgramFiles(x86)"])==null?void 0:l.toLowerCase(),i=[],r=[];for(let c of n.knownCandidates){let f=c.toLowerCase(),d=(Te==null?void 0:Te.platform)==="win32"&&((e?f.startsWith(e):!1)||(t?f.startsWith(t):!1)),h=(Te==null?void 0:Te.platform)!=="win32"&&(c.startsWith("/usr/bin/")||c.startsWith("/snap/freecad/current/usr/bin/"));d||h?r.push(c):i.push(c)}return{userCandidates:i,systemCandidates:r}}async function g2(n,e,t){for(let i of e)if(await VA(i))return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,command:i,executable:i,args:[],resolvedPath:i,available:!0,source:"candidate",detail:t,checkedCandidates:[i]}}function U8(n,e){let t=[];return n.length&&t.push(`Checked common user locations: ${n.join("; ")}`),e.length&&t.push(`Checked system fallback locations: ${e.join("; ")}`),t.join(". ")}async function Sp(n,e,t,i){let r=L8(e);if(P8(r.executable)){let a=await VA(r.executable);return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:a?r.executable:void 0,available:a,source:t,detail:a?`Using ${Ap(t)} path.`:"Configured path was not found or is not executable.",checkedCandidates:[r.executable]}}let s=await N8(r.executable);return{id:n.id,label:n.label,envVar:n.envVar,settingsKey:n.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:s,available:!!s,source:t,detail:s?`Resolved from ${Ap(t)} via PATH lookup.`:"Command name was not found on PATH.",checkedCandidates:[r.executable]}}function Ap(n){switch(n){case"settings":return"plugin settings";case"env":return"environment variable";case"candidate":return"known install location";case"path":return"PATH fallback"}}async function v2(n,e){var h,u,m;let t=w8(n),{userCandidates:i,systemCandidates:r}=B8(t),s=NA(e);if(s)return Sp(t,s,"settings",s);let a=NA((h=Te==null?void 0:Te.env)==null?void 0:h[t.envVar]);if(a)return Sp(t,a,"env");for(let p of(u=t.envVarAliases)!=null?u:[]){let _=NA((m=Te==null?void 0:Te.env)==null?void 0:m[p]);if(_)return Sp(t,_,"env")}let o=await g2(t,i,"Detected at a common user-managed install location.");if(o)return o;let l=[];for(let p of t.fallbackCommands){let _=await Sp(t,p,"path");if(l.push(_),_.available)return _}let c=await g2(t,r,"Detected at a system fallback install location.");if(c)return c;let f=l.flatMap(p=>p.checkedCandidates),d=U8(i,r);return{...l[0],detail:d?`Command name was not found on PATH. ${d}`:"Command name was not found on PATH.",checkedCandidates:[...i,...f,...r]}}async function Rp(n){let e=await Promise.all(E2.map(t=>v2(t.id,n[t.settingsKey])));return Promise.all(e.map(async t=>({...t,dependencyChecks:await F8(t)})))}async function Ji(n,e){var i;let t=await v2(n,e);return{command:(i=t.resolvedPath)!=null?i:t.executable,args:[...t.args]}}var Te,C8,E2,Qa=A(()=>{"use strict";Gt();Gt();Gt();Te=lp(),C8=[".exe",".cmd",".bat",".com"];E2=[{id:"freecad",label:"Python (CadQuery/OCCT)",settingsKey:"freecadCommand",envVar:"AI3D_FREECAD_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?[]:["/usr/local/bin/python3","/opt/homebrew/bin/python3","/opt/local/bin/python3","/usr/bin/python3"]},{id:"obj2gltf",label:"obj2gltf",settingsKey:"obj2gltfCommand",envVar:"AI3D_OBJ2GLTF_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["obj2gltf.cmd"]:["obj2gltf"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?M8("obj2gltf.cmd"):wA("obj2gltf")},{id:"fbx2gltf",label:"FBX2glTF",settingsKey:"fbx2gltfCommand",envVar:"AI3D_FBX2GLTF_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["FBX2glTF.exe"]:["FBX2glTF","fbx2gltf"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?y8(Pt("FBX2glTF","FBX2glTF-windows-x64.exe"),Pt("FBX2glTF","FBX2glTF.exe")):wA("FBX2glTF","fbx2gltf")},{id:"assimp",label:"Python (trimesh)",settingsKey:"assimpCommand",envVar:"AI3D_ASSIMP_CMD",fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Te==null?void 0:Te.platform)==="win32"?[]:["/usr/local/bin/python3","/opt/homebrew/bin/python3","/opt/local/bin/python3","/usr/bin/python3"]},{id:"freecadcmd",label:"FreeCAD (SLDPRT)",settingsKey:"freecadcmdCommand",envVar:"AI3D_FREECADCMD",envVarAliases:["AI3D_FREECMDCMD"],fallbackCommands:(Te==null?void 0:Te.platform)==="win32"?["FreeCADCmd.exe"]:["freecadcmd","FreeCADCmd"],knownCandidates:b8()}]});function ia(n){if(n.includes('"'))throw new Error(`File path contains double-quote character, not supported for Python conversion: ${n}`);return n.replace(/\\/g,"/")}var Ip=A(()=>{"use strict"});async function k8(n){try{return await _r(n,gr),!0}catch(e){return!1}}function W8(n,e,t){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`CAD conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function H8(n,e,t){let i=ia(n),r=ia(e),s=t.toLowerCase().replace(/^\./,""),a=s==="step"||s==="stp",o=s==="iges"||s==="igs",l=["import cadquery as cq","import trimesh","import trimesh.visual","import numpy as np","import sys","import os","",`src = r"${i}"`,`out = r"${r}"`,""];return a?l.push("from OCP.STEPCAFControl import STEPCAFControl_Reader","from OCP.STEPControl import STEPControl_Reader","from OCP.XCAFDoc import XCAFDoc_DocumentTool, XCAFDoc_ColorType, XCAFDoc_ShapeTool","from OCP.TDocStd import TDocStd_Document","from OCP.TCollection import TCollection_ExtendedString","from OCP.Quantity import Quantity_Color","from OCP.TDF import TDF_ChildIterator"):o&&l.push("from OCP.IGESControl import IGESControl_Reader"),l.push("from OCP.TopoDS import TopoDS","from OCP.TopAbs import TopAbs_FACE","from OCP.TopExp import TopExp_Explorer","from OCP.BRep import BRep_Tool","from OCP.BRepMesh import BRepMesh_IncrementalMesh","from OCP.TopLoc import TopLoc_Location","from OCP.IFSelect import IFSelect_RetDone"),a||l.push("from OCP.BRepTools import BRepTools"),l.push("","DEFAULT_COLOR = [180, 180, 180, 255]","","def triangulate_face(face, linear=0.1, angular=0.5):"," BRepMesh_IncrementalMesh(face, linear, False, angular, True)"," loc = TopLoc_Location()"," tri = BRep_Tool.Triangulation_s(face, loc)"," if tri is None:"," return None, None"," n = tri.NbNodes()"," verts = []"," for i in range(1, n + 1):"," p = tri.Node(i)"," if not loc.IsIdentity():"," p = p.Transformed(loc.Transformation())"," verts.append([p.X(), p.Y(), p.Z()])"," ntri = tri.NbTriangles()"," faces = []"," for i in range(1, ntri + 1):"," t = tri.Triangle(i)"," n1, n2, n3 = t.Get()"," faces.append([n1 - 1, n2 - 1, n3 - 1])"," return verts, faces"),a&&l.push("","def build_xde_color_lookup(step_path):",' """Load XDE with STEPCAFControl, extract per-face colors via surface signature."""'," from OCP.BRepAdaptor import BRepAdaptor_Surface"," lookup = {}"," try:"," reader = STEPCAFControl_Reader()"," reader.SetColorMode(True)"," reader.SetNameMode(True)"," status = reader.ReadFile(step_path)"," if status != IFSelect_RetDone:"," return lookup"," doc = TDocStd_Document(TCollection_ExtendedString('XmlOcaf'))"," reader.Transfer(doc)"," shape_tool = XCAFDoc_DocumentTool.ShapeTool_s(doc.Main())"," color_tool = XCAFDoc_DocumentTool.ColorTool_s(doc.Main())",""," def walk(label):"," if XCAFDoc_ShapeTool.IsShape_s(label):"," s = XCAFDoc_ShapeTool.GetShape_s(label)"," if s is not None and s.ShapeType() == TopAbs_FACE:"," c = Quantity_Color()"," if color_tool.GetColor(s, XCAFDoc_ColorType.XCAFDoc_ColorSurf, c):"," face = TopoDS.Face_s(s)"," try:"," adaptor = BRepAdaptor_Surface(face)"," u_r = (adaptor.FirstUParameter(), adaptor.LastUParameter())"," v_r = (adaptor.FirstVParameter(), adaptor.LastVParameter())"," key = (adaptor.GetType(), tuple(round(x, 4) for x in u_r), tuple(round(x, 4) for x in v_r))"," color = (c.Red(), c.Green(), c.Blue())"," if key not in lookup:"," lookup[key] = color"," except Exception:"," pass"," children = TDF_ChildIterator(label)"," while children.More():"," walk(children.Value())"," children.Next()",""," walk(doc.Main())"," except Exception as e:",' print(f"XDE color extraction failed: {e}", file=sys.stderr)'," return lookup","","def get_face_color(face, color_lookup):",' """Match a geometry face to an XDE face via surface signature, return color."""'," from OCP.BRepAdaptor import BRepAdaptor_Surface"," try:"," adaptor = BRepAdaptor_Surface(face)"," u_r = (adaptor.FirstUParameter(), adaptor.LastUParameter())"," v_r = (adaptor.FirstVParameter(), adaptor.LastVParameter())"," key = (adaptor.GetType(), tuple(round(x, 4) for x in u_r), tuple(round(x, 4) for x in v_r))"," return color_lookup.get(key)"," except Exception:"," return None"),l.push(""),a?l.push("# STEP: build XDE color lookup + load geometry","color_lookup = build_xde_color_lookup(src)",'print(f"XDE color lookup: {len(color_lookup)} surface signatures")',"","sr = STEPControl_Reader()","status = sr.ReadFile(src)","if status != IFSelect_RetDone:",' print(f"Failed to read STEP file: {src}", file=sys.stderr)'," sys.exit(1)","sr.TransferRoots()","shape = sr.OneShape()"):o?l.push("# IGES: load geometry (no XDE color support for IGES)","ir = IGESControl_Reader()","status = ir.ReadFile(src)","if status != IFSelect_RetDone:",' print(f"Failed to read IGES file: {src}", file=sys.stderr)'," sys.exit(1)","ir.TransferRoots()","shape = ir.OneShape()"):l.push("# BREP: load geometry from native OpenCascade format","from OCP.TopoDS import TopoDS_Shape","from OCP.BRep import BRep_Builder","shape = TopoDS_Shape()","builder = BRep_Builder()","success = BRepTools.Read_s(shape, src, builder)","if not success:",' print(f"Failed to read BREP file: {src}", file=sys.stderr)'," sys.exit(1)"),l.push("","all_verts = []","all_faces = []","all_colors = []","matched_count = 0","total_faces = 0","","exp = TopExp_Explorer(shape, TopAbs_FACE)","while exp.More():"," face = TopoDS.Face_s(exp.Current())"," total_faces += 1"," verts, faces = triangulate_face(face)"," if verts and faces:"," offset = len(all_verts)"," all_verts.extend(verts)"," for tri in faces:"," all_faces.append([tri[0] + offset, tri[1] + offset, tri[2] + offset])"),a?l.push(" color = get_face_color(face, color_lookup)"," if color:"," matched_count += 1"," r, g, b = color"," rgba = [int(r * 255), int(g * 255), int(b * 255), 255]"," else:"," rgba = DEFAULT_COLOR"):l.push(" rgba = DEFAULT_COLOR"),l.push(" n = len(verts)"," all_colors.extend([rgba] * n)"," exp.Next()","",'print(f"Triangulated: {total_faces} faces, {len(all_verts)} verts, {matched_count} colored ({matched_count*100//max(total_faces,1)}%)")',"","if not all_verts or not all_faces:"," # Fallback: use CadQuery import (works for STEP/IGES, not BREP)"),a?l.push(" cq_shape = cq.importers.importStep(src)"):o?l.push(" cq_shape = cq.importers.importStep(src) # CadQuery reads IGES via importStep"):l.push(" cq_shape = cq.importers.importStep(src) # CadQuery BREP import"),l.push(" cq.exporters.export(cq_shape, out, exportType='STL')"," mesh = trimesh.load(out)"," data = mesh.export(file_type='glb')"," if isinstance(data, str):"," with open(data, 'rb') as f:"," data = f.read()"," with open(out, 'wb') as f:"," f.write(data)",' print(f"Fallback CadQuery STL->GLB: {out} ({len(data)} bytes)")'," sys.exit(0)","","verts_arr = np.array(all_verts, dtype=float)","faces_arr = np.array(all_faces, dtype=int)","colors_arr = np.array(all_colors, dtype=np.uint8)","","mesh = trimesh.Trimesh("," vertices=verts_arr,"," faces=faces_arr,"," visual=trimesh.visual.ColorVisuals(vertex_colors=colors_arr),"," process=True,",")","mesh.fix_normals()","scene = trimesh.Scene([mesh])","","result = scene.export(file_type='glb')","if isinstance(result, bytes):"," data = result","elif isinstance(result, str):"," with open(result, 'rb') as f:"," data = f.read()","else:"," data = bytes(result)","","with open(out, 'wb') as f:"," f.write(data)","","print(f'Converted {src} -> {out} ({len(data)} bytes, {matched_count}/{total_faces} colored faces)')"),l.join(` +`)}var V8,G8,xp,T2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Dr();Qa();Ip();V8=ti("freecad-converter"),G8=300*1e3;xp=class{constructor(e){this.configuredCommand=e;this.id="freecad";this.sourceExts=["step","stp","iges","igs","brep"];this.targetExt="glb"}async getCacheKey(){let e=await Ji(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!qi(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking CAD conversion.`);let t=await Ji(this.id,this.configuredCommand),i=qn(e.sourcePath),r=Qn(e.sourcePath,Jr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-freecad"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,H8(e.sourcePath,s,e.sourceExt),"utf8"),V8.info("run CAD conversion (CadQuery/OCCT)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await W8(t.command,[...t.args,o],G8)}catch(c){throw new Error(`CAD conversion failed for '${e.sourcePath}'. Ensure Python with cadquery is installed: pip install cadquery trimesh. Set Python command path in plugin settings or AI3D_FREECAD_CMD if Python is not discoverable. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await k8(s))throw new Error(`CAD conversion finished but output was not found: '${s}'. Check that CadQuery supports this CAD format.`);if((await Qr(s)).byteLength===0)throw new Error(`CAD conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/CadQuery(OCCT) bridge."]}}}});async function Y8(n){try{return await _r(n,gr),!0}catch(e){return!1}}function K8(n,e,t){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`obj2gltf command failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var z8,X8,Cp,S2=A(()=>{"use strict";Gt();Gt();Gt();Dr();Qa();z8=ti("obj2gltf-converter"),X8=180*1e3;Cp=class{constructor(e){this.configuredCommand=e;this.id="obj2gltf";this.sourceExts=["obj"];this.targetExt="glb"}async getCacheKey(){let e=await Ji(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!qi(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking obj2gltf.`);let t=await Ji(this.id,this.configuredCommand),i=qn(e.sourcePath),r=Qn(e.sourcePath,Jr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`);z8.info("run obj2gltf conversion",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await K8(t.command,[...t.args,"-i",e.sourcePath,"-o",s,"-b"],X8)}catch(o){throw new Error(`obj2gltf conversion failed for '${e.sourcePath}'. Set obj2gltf command path in plugin settings or AI3D_OBJ2GLTF_CMD if obj2gltf is not discoverable. ${o instanceof Error?o.message:String(o)}`)}if(!await Y8(s))throw new Error(`obj2gltf conversion finished but output was not found: '${s}'.`);if((await Qr(s)).byteLength===0)throw new Error(`obj2gltf output file is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local obj2gltf CLI bridge."]}}}});async function q8(n){try{return await _r(n,gr),!0}catch(e){return!1}}function Q8(n,e,t){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`FBX2glTF command failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var j8,Z8,bp,A2=A(()=>{"use strict";Gt();Gt();Gt();Dr();Qa();j8=ti("fbx2gltf-converter"),Z8=180*1e3;bp=class{constructor(e){this.configuredCommand=e;this.id="fbx2gltf";this.sourceExts=["fbx"];this.targetExt="glb"}async getCacheKey(){let e=await Ji(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!qi(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking FBX2glTF.`);let t=await Ji(this.id,this.configuredCommand),i=qn(e.sourcePath),r=Qn(e.sourcePath,Jr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`);j8.info("run FBX2glTF conversion",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await Q8(t.command,[...t.args,"-i",e.sourcePath,"-o",s,"-b"],Z8)}catch(o){throw new Error(`FBX2glTF conversion failed for '${e.sourcePath}'. Set FBX2glTF command path in plugin settings or AI3D_FBX2GLTF_CMD if FBX2glTF is not discoverable. ${o instanceof Error?o.message:String(o)}`)}if(!await q8(s))throw new Error(`FBX2glTF conversion finished but output was not found: '${s}'.`);if((await Qr(s)).byteLength===0)throw new Error(`FBX2glTF output file is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local FBX2glTF CLI bridge."]}}}});async function e6(n){try{return await _r(n,gr),!0}catch(e){return!1}}function t6(n,e,t){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`mesh conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function i6(n,e){let t=ia(n),i=ia(e);return["import trimesh","import sys","",`src = r"${t}"`,`out = r"${i}"`,"","try:"," loaded = trimesh.load(src, force=None)","except Exception as e:",' print(f"Failed to load {src}: {e}", file=sys.stderr)'," sys.exit(1)","","if isinstance(loaded, trimesh.Scene):"," scene = loaded","elif isinstance(loaded, trimesh.Trimesh):"," scene = trimesh.Scene([loaded])","else:",' print(f"Unsupported type: {type(loaded)}", file=sys.stderr)'," sys.exit(1)","","try:"," data = scene.export(file_type='glb')","except Exception as e:",' print(f"Failed to export GLB: {e}", file=sys.stderr)'," sys.exit(1)","","with open(out, 'wb') as f:"," f.write(data)","","print(f'Converted {src} -> {out} ({len(data)} bytes)')"].join(` +`)}var J8,$8,Mp,R2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Dr();Qa();Ip();J8=ti("assimp-converter"),$8=300*1e3;Mp=class{constructor(e){this.configuredCommand=e;this.id="assimp";this.sourceExts=["3mf","dae"];this.targetExt="glb"}async getCacheKey(){let e=await Ji(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!qi(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking mesh conversion.`);let t=await Ji(this.id,this.configuredCommand),i=qn(e.sourcePath),r=Qn(e.sourcePath,Jr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-mesh-convert"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,i6(e.sourcePath,s),"utf8"),J8.info("run mesh conversion (trimesh)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{await t6(t.command,[...t.args,o],$8)}catch(c){throw new Error(`Mesh conversion failed for '${e.sourcePath}'. Ensure Python with trimesh is installed: pip install trimesh numpy networkx pycollada. Set Python command path in plugin settings or AI3D_ASSIMP_CMD if Python is not discoverable. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await e6(s))throw new Error(`Mesh conversion finished but output was not found: '${s}'. Check that trimesh supports this format.`);if((await Qr(s)).byteLength===0)throw new Error(`Mesh conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/trimesh bridge."]}}}});async function n6(n){try{return await _r(n,gr),!0}catch(e){return!1}}function s6(n,e,t){return new Promise((i,r)=>{$r(n,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(s,a,o)=>{if(!s){i({stdout:a!=null?a:"",stderr:o!=null?o:""});return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`SLDPRT conversion failed: ${s.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function a6(n,e){let t=ia(n),i=ia(e),r=i.replace(/\.glb$/i,".intermediate.step");return["import sys","import os","",`src = r"${t}"`,`out = r"${i}"`,`step_out = r"${r}"`,"","# Step 1: Import SLDPRT via FreeCAD","try:"," import FreeCAD"," import ImportGui"," import Mesh","except ImportError as e:",' print(f"FreeCAD modules not available: {e}", file=sys.stderr)',' print("Ensure this script runs under FreeCADCmd (not system Python).", file=sys.stderr)'," sys.exit(1)","","print(f'Opening SLDPRT: {src}')","try:"," doc = FreeCAD.newDocument('Convert')"," ImportGui.open(src, doc.Name)","except Exception as e:",' print(f"Failed to open SLDPRT file: {e}", file=sys.stderr)'," sys.exit(1)","","if not doc.Objects:",' print("SLDPRT file imported but contains no objects", file=sys.stderr)'," sys.exit(1)","",'print(f"Imported {len(doc.Objects)} object(s) from SLDPRT")',"","# Step 2: Export to STEP (intermediate)","try:"," import Import"," objs = [o for o in doc.Objects if hasattr(o, 'Shape')]"," if not objs:",' print("No shape objects found after import", file=sys.stderr)'," sys.exit(1)"," Import.export(objs, step_out)",' print(f"Exported intermediate STEP: {step_out}")',"except Exception as e:",' print(f"Failed to export STEP: {e}", file=sys.stderr)'," sys.exit(1)","","FreeCAD.closeDocument(doc.Name)","","# Step 3: Convert STEP to GLB using OCP (same pipeline as FreecadConverter)","import trimesh","import trimesh.visual","import numpy as np","","from OCP.STEPControl import STEPControl_Reader","from OCP.TopoDS import TopoDS","from OCP.TopAbs import TopAbs_FACE","from OCP.TopExp import TopExp_Explorer","from OCP.BRep import BRep_Tool","from OCP.BRepMesh import BRepMesh_IncrementalMesh","from OCP.TopLoc import TopLoc_Location","from OCP.IFSelect import IFSelect_RetDone","","DEFAULT_COLOR = [180, 180, 180, 255]","","def triangulate_face(face, linear=0.1, angular=0.5):"," BRepMesh_IncrementalMesh(face, linear, False, angular, True)"," loc = TopLoc_Location()"," tri = BRep_Tool.Triangulation_s(face, loc)"," if tri is None:"," return None, None"," n = tri.NbNodes()"," verts = []"," for i in range(1, n + 1):"," p = tri.Node(i)"," if not loc.IsIdentity():"," p = p.Transformed(loc.Transformation())"," verts.append([p.X(), p.Y(), p.Z()])"," ntri = tri.NbTriangles()"," faces = []"," for i in range(1, ntri + 1):"," t = tri.Triangle(i)"," n1, n2, n3 = t.Get()"," faces.append([n1 - 1, n2 - 1, n3 - 1])"," return verts, faces","","sr = STEPControl_Reader()","status = sr.ReadFile(step_out)","if status != IFSelect_RetDone:",' print(f"Failed to read intermediate STEP: {step_out}", file=sys.stderr)'," sys.exit(1)","sr.TransferRoots()","shape = sr.OneShape()","","all_verts = []","all_faces = []","all_colors = []","total_faces = 0","","exp = TopExp_Explorer(shape, TopAbs_FACE)","while exp.More():"," face = TopoDS.Face_s(exp.Current())"," total_faces += 1"," verts, faces = triangulate_face(face)"," if verts and faces:"," offset = len(all_verts)"," all_verts.extend(verts)"," for tri in faces:"," all_faces.append([tri[0] + offset, tri[1] + offset, tri[2] + offset])"," all_colors.extend([DEFAULT_COLOR] * len(verts))"," exp.Next()","","if not all_verts or not all_faces:",' print(f"No geometry extracted from STEP ({total_faces} faces scanned)", file=sys.stderr)'," sys.exit(1)","",'print(f"Triangulated: {total_faces} faces, {len(all_verts)} verts")',"","verts_arr = np.array(all_verts, dtype=float)","faces_arr = np.array(all_faces, dtype=int)","colors_arr = np.array(all_colors, dtype=np.uint8)","","mesh = trimesh.Trimesh("," vertices=verts_arr,"," faces=faces_arr,"," visual=trimesh.visual.ColorVisuals(vertex_colors=colors_arr),"," process=True,",")","mesh.fix_normals()","scene = trimesh.Scene([mesh])","","result = scene.export(file_type='glb')","if isinstance(result, bytes):"," data = result","elif isinstance(result, str):"," with open(result, 'rb') as f:"," data = f.read()","else:"," data = bytes(result)","","with open(out, 'wb') as f:"," f.write(data)","","# Cleanup intermediate STEP","try:"," os.remove(step_out)","except OSError:"," pass","","print(f'Converted {src} -> {out} ({len(data)} bytes, {total_faces} faces)')"].join(` +`)}var GA,r6,yp,I2=A(()=>{"use strict";Gt();Gt();Gt();Gt();Dr();Qa();Ip();GA=ti("sldprt-converter"),r6=600*1e3;yp=class{constructor(e){this.configuredCommand=e;this.id="sldprt";this.sourceExts=["sldprt"];this.targetExt="glb"}async getCacheKey(){let e=await Ji("freecadcmd",this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!qi(e.sourcePath))throw new Error(`Converter '${this.id}' requires an absolute source path, got '${e.sourcePath}'. Pass a file-system path to the conversion pipeline when invoking SLDPRT conversion.`);let t=await Ji("freecadcmd",this.configuredCommand),i=qn(e.sourcePath),r=Qn(e.sourcePath,Jr(e.sourcePath)),s=Pt(i,`${r}.ai3d-converted.glb`),a=Pt(bc(),"ai3d-sldprt"),o=Pt(a,`${r}-${Date.now()}.py`);await xc(a,{recursive:!0}),await Ic(o,a6(e.sourcePath,s),"utf8"),GA.info("run SLDPRT conversion (FreeCAD + OCP)",{sourcePath:e.sourcePath,outputPath:s,command:t.command,args:t.args});try{let{stdout:c,stderr:f}=await s6(t.command,[...t.args,o],r6);c&&GA.info("FreeCAD stdout",{stdout:c.trim().slice(0,500)}),f&&GA.warn("FreeCAD stderr",{stderr:f.trim().slice(0,500)})}catch(c){throw new Error(`SLDPRT conversion failed for '${e.sourcePath}'. Ensure FreeCAD is installed (https://www.freecad.org/downloads.php). Set FreeCADCmd path in plugin settings or AI3D_FREECADCMD env var. ${c instanceof Error?c.message:String(c)}`)}finally{Cc(o,{force:!0})}if(!await n6(s))throw new Error(`SLDPRT conversion finished but output was not found: '${s}'. Check that FreeCAD can import this SolidWorks file version.`);if((await Qr(s)).byteLength===0)throw new Error(`SLDPRT conversion output is empty: '${s}'.`);return{outputPath:s,outputExt:"glb",fromCache:!1,warnings:["Converted by local FreeCAD + OpenCASCADE bridge."]}}}});function ra(n){var r;let e=new Tp,t=new Set((r=n==null?void 0:n.enabledConverterIds)!=null?r:[]);kA.debug("create conversion manager",{enabledConverterIds:[...t]});let i=[new xp(n==null?void 0:n.freecadCommand),new Cp(n==null?void 0:n.obj2gltfCommand),new bp(n==null?void 0:n.fbx2gltfCommand),new Mp(n==null?void 0:n.assimpCommand),new yp(n==null?void 0:n.freecadcmdCommand)];for(let s of i)t.has(s.id)?(e.registerConverter(s),kA.info("enabled converter",{converterId:s.id})):kA.debug("converter disabled",{converterId:s.id});return e}var kA,_d=A(()=>{"use strict";_2();T2();S2();A2();R2();I2();Dr();kA=ti("conversion-factory")});function Yo(n){return{path:n.effectivePath,ext:n.effectiveExt,strategy:n.strategy,sourcePath:n.sourcePath,sourceExt:n.sourceExt,warnings:n.warnings}}var Dp=A(()=>{"use strict"});function na(n){let e=[];return n.preferObj2gltfForObj&&e.push("obj"),n.preferFbx2gltfForFbx&&e.push("fbx"),e}var gd=A(()=>{"use strict"});function Ed(n){return n.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g,"$2").replace(/\[\[([^\]]+)\]\]/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[*_~`]+/g,"").replace(/==([^=]+)==/g,"$1").replace(/\s+/g," ").trim()}function o6(n,e){let t=e.toLowerCase().trim();if(!t)return[];let i=[],r=n.vault.getMarkdownFiles();for(let s of r){let a=n.metadataCache.getFileCache(s);if(a!=null&&a.headings)for(let o of a.headings)o.heading.toLowerCase().includes(t)&&i.push({notePath:s.path,heading:o.heading,level:o.level})}return i.slice(0,15)}function Lp(n){return e=>o6(n,e)}async function l6(n,e,t){try{let i=n.vault.getAbstractFileByPath(e);if(!(i instanceof x2.TFile))return null;let s=(await n.vault.cachedRead(i)).split(` +`),a=-1,o=0,l=Ed(t);for(let f=0;fl6(n,e,t)}var x2,Pc=A(()=>{"use strict";x2=require("obsidian")});function $a(n,e){let t=n.createDiv({cls:"ai3d-inline-empty ai3d-load-feedback-shell"});Qt()&&t.classList.add("is-mobile");let i=t.createDiv({cls:`ai3d-load-feedback is-${e.level}`});return i.createDiv({cls:"ai3d-load-feedback-title",text:e.title}),i.createDiv({cls:"ai3d-load-feedback-message",text:e.message}),i.createDiv({cls:"ai3d-load-feedback-hint",text:e.hint}),t}var vd=A(()=>{"use strict";qr()});var M2={};De(M2,{generateKnowledgeNote:()=>b2,mountWorkbench:()=>WA});function WA(n,e,t,i){var X,j;let r=Qt();n.classList.add("ai3d-workbench"),n.classList.toggle("is-mobile",r);let s=null,a=null,o=!1,l=!1,c=t.store.getState(),f=c.currentModelPath,d=c.currentModelPath,h=c.modelPreview;function u(Q){if(!a||!s)return;let $=a.getPinPosition(Q);if(!$)return;let q=s.getCamera(),z=new Oe("focusPin","target",30,Oe.ANIMATIONTYPE_VECTOR3,Oe.ANIMATIONLOOPMODE_CONSTANT);z.setKeys([{frame:0,value:q.target.clone()},{frame:20,value:$}]);let K=new ou;K.setEasingMode(lr.EASINGMODE_EASEOUT),z.setEasingFunction(K),q.animations=[z],s.getScene().beginAnimation(q,0,20,!1)}let m=Q=>{Q.key==="Escape"&&o&&y(!1)};activeDocument.addEventListener("keydown",m);let p=n.createDiv({cls:"ai3d-preview-host"});r&&p.classList.add("is-mobile-scroll-mode");let _=Qi`
3D
${Z("workbench.emptyTitle")}
${Z("workbench.emptyText")}
- `;p.appendChild(_);let g=p.createDiv({cls:"ai3d-annot-mode-overlay is-hidden"}),T=!1,b=r?n.createDiv({cls:"ai3d-mobile-mode-bar is-detached is-hidden"}):null,R=(X=b==null?void 0:b.createDiv({cls:"ai3d-mobile-mode-hint",text:Z("workbench.mobileHint")}))!=null?X:null,S=(j=b==null?void 0:b.createEl("button",{cls:"ai3d-mobile-mode-btn",text:Z("helper.interactAction"),attr:{"aria-label":Z("helper.enableInteractionLabel")}}))!=null?j:null;function I(Q){r&&(T=Q,p.classList.toggle("is-mobile-interactive",Q),p.classList.toggle("is-mobile-scroll-mode",!Q),S&&(S.textContent=Q?Z("helper.scrollAction"):Z("helper.interactAction"),S.classList.toggle("ai3d-btn-active",Q),S.setAttribute("aria-label",Q?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel"))),R&&(R.textContent=Q?Z("workbench.mobileHintInteractive"):Z("workbench.mobileHint")))}S==null||S.addEventListener("click",()=>{let Q=!T;!Q&&o&&y(!1),I(Q)});function x(){p.querySelectorAll(".ai3d-inline-empty:not(.ai3d-empty-state)").forEach(Q=>Q.remove())}function P(){a==null||a.hideEditor(),a==null||a.destroy(),a=null,o=!1,g.classList.add("is-hidden"),b==null||b.classList.add("is-hidden"),I(!1),s==null||s.destroy(),s=null,p.querySelectorAll(".ai3d-canvas-full").forEach(Q=>Q.remove()),x()}function L(Q){if(P(),_.classList.remove("is-hidden"),Q)if(typeof Q=="string"){let $=p.createDiv({cls:"ai3d-inline-empty"});$.textContent=Q}else $a(p,Q)}function y(Q){o=Q,r&&Q&&I(!0),a==null||a.hideEditor(),g.classList.toggle("is-hidden",!Q),w()}let B=n.createDiv({cls:"ai3d-panels"});function w(){var q,z,K,J;let Q=t.store.getState();if(B.replaceChildren(),B.appendChild(Zi` + `;p.appendChild(_);let g=p.createDiv({cls:"ai3d-annot-mode-overlay is-hidden"}),T=!1,b=r?n.createDiv({cls:"ai3d-mobile-mode-bar is-detached is-hidden"}):null,R=(X=b==null?void 0:b.createDiv({cls:"ai3d-mobile-mode-hint",text:Z("workbench.mobileHint")}))!=null?X:null,S=(j=b==null?void 0:b.createEl("button",{cls:"ai3d-mobile-mode-btn",text:Z("helper.interactAction"),attr:{"aria-label":Z("helper.enableInteractionLabel")}}))!=null?j:null;function I(Q){r&&(T=Q,p.classList.toggle("is-mobile-interactive",Q),p.classList.toggle("is-mobile-scroll-mode",!Q),S&&(S.textContent=Q?Z("helper.scrollAction"):Z("helper.interactAction"),S.classList.toggle("ai3d-btn-active",Q),S.setAttribute("aria-label",Q?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel"))),R&&(R.textContent=Q?Z("workbench.mobileHintInteractive"):Z("workbench.mobileHint")))}S==null||S.addEventListener("click",()=>{let Q=!T;!Q&&o&&y(!1),I(Q)});function x(){p.querySelectorAll(".ai3d-inline-empty:not(.ai3d-empty-state)").forEach(Q=>Q.remove())}function P(){a==null||a.hideEditor(),a==null||a.destroy(),a=null,o=!1,g.classList.add("is-hidden"),b==null||b.classList.add("is-hidden"),I(!1),s==null||s.destroy(),s=null,p.querySelectorAll(".ai3d-canvas-full").forEach(Q=>Q.remove()),x()}function L(Q){if(P(),_.classList.remove("is-hidden"),Q)if(typeof Q=="string"){let $=p.createDiv({cls:"ai3d-inline-empty"});$.textContent=Q}else $a(p,Q)}function y(Q){o=Q,r&&Q&&I(!0),a==null||a.hideEditor(),g.classList.toggle("is-hidden",!Q),w()}let B=n.createDiv({cls:"ai3d-panels"});function w(){var q,z,K,J;let Q=t.store.getState();if(B.replaceChildren(),B.appendChild(Qi`
@@ -19727,7 +19727,7 @@ gl_FragColor=color;
- `),s){let te=Zi` + `),s){let te=Qi`
${Z("workbench.disassemblyTitle")}
@@ -19747,7 +19747,7 @@ gl_FragColor=color;
- `;B.appendChild(te);let Pe=te.querySelector(".ai3d-slider"),ge=te.querySelector(".ai3d-slider-value"),me=te.querySelectorAll(".ai3d-axis-btn"),se="x";Pe.addEventListener("input",()=>{let le=parseInt(Pe.value,10);ge.textContent=`${le}%`,s==null||s.setExplode(le/100,se)}),me.forEach(le=>{le.addEventListener("click",()=>{me.forEach(ce=>ce.classList.remove("is-active")),le.classList.add("is-active"),se=le.dataset.axis;let xe=parseInt(Pe.value,10);s==null||s.resetExplode(),xe>0&&(s==null||s.setExplode(xe/100,se))})})}if(Q.modelPreview){let te=Q.modelPreview;B.appendChild(Zi` + `;B.appendChild(te);let Pe=te.querySelector(".ai3d-slider"),ge=te.querySelector(".ai3d-slider-value"),me=te.querySelectorAll(".ai3d-axis-btn"),se="x";Pe.addEventListener("input",()=>{let le=parseInt(Pe.value,10);ge.textContent=`${le}%`,s==null||s.setExplode(le/100,se)}),me.forEach(le=>{le.addEventListener("click",()=>{me.forEach(ce=>ce.classList.remove("is-active")),le.classList.add("is-active"),se=le.dataset.axis;let xe=parseInt(Pe.value,10);s==null||s.resetExplode(),xe>0&&(s==null||s.setExplode(xe/100,se))})})}if(Q.modelPreview){let te=Q.modelPreview;B.appendChild(Qi`
${Z("workbench.summaryTitle")}
@@ -19769,7 +19769,7 @@ gl_FragColor=color;
- `)}if(Q.currentModelPath){let le=function(){var Fe;let xe=me.value.trim();if(!xe)return;let ce=t.store.getState().modelAssetProfiles,he=t.store.getState().currentModelPath,ke=(Fe=ce[he])!=null?Fe:o2(),$e=ER([...ke.tags,xe]);t.store.setState({modelAssetProfiles:{...ce,[he]:{...ke,tags:$e}}}),me.value="",w()};var $=le;let te=Q.modelAssetProfiles[Q.currentModelPath],Pe=(K=te==null?void 0:te.tags)!=null?K:[],ge=Zi` + `)}if(Q.currentModelPath){let le=function(){var Fe;let xe=me.value.trim();if(!xe)return;let ce=t.store.getState().modelAssetProfiles,he=t.store.getState().currentModelPath,ke=(Fe=ce[he])!=null?Fe:C2(),$e=xR([...ke.tags,xe]);t.store.setState({modelAssetProfiles:{...ce,[he]:{...ke,tags:$e}}}),me.value="",w()};var $=le;let te=Q.modelAssetProfiles[Q.currentModelPath],Pe=(K=te==null?void 0:te.tags)!=null?K:[],ge=Qi`
${Z("workbench.tagsTitle")}
@@ -19777,7 +19777,7 @@ gl_FragColor=color;
- ${Pe.length>0?Pe.map(xe=>Zi`${xe}`):Zi`${Z("workbench.noTagsYet")}`} + ${Pe.length>0?Pe.map(xe=>Qi`${xe}`):Qi`${Z("workbench.noTagsYet")}`}
@@ -19786,7 +19786,7 @@ gl_FragColor=color;
- `;B.appendChild(ge);let me=ge.querySelector(".ai3d-input");ge.querySelector(".ai3d-axis-btn").addEventListener("click",le),me.addEventListener("keydown",xe=>{xe.key==="Enter"&&le()})}if(Q.currentModelPath&&s){let te=Q.modelAssetProfiles[Q.currentModelPath],Pe=(J=te==null?void 0:te.annotations)!=null?J:[],ge=Zi` + `;B.appendChild(ge);let me=ge.querySelector(".ai3d-input");ge.querySelector(".ai3d-axis-btn").addEventListener("click",le),me.addEventListener("keydown",xe=>{xe.key==="Enter"&&le()})}if(Q.currentModelPath&&s){let te=Q.modelAssetProfiles[Q.currentModelPath],Pe=(J=te==null?void 0:te.annotations)!=null?J:[],ge=Qi`
${Z("workbench.annotationsTitle")}
@@ -19799,9 +19799,9 @@ gl_FragColor=color; ${o?Z(r?"workbench.annotateHintActiveMobile":"workbench.annotateHintActive"):Jt("workbench.pinCount",{count:String(Pe.length)})}
- ${Pe.length>0?Zi` + ${Pe.length>0?Qi`
- ${Pe.map(se=>Zi` + ${Pe.map(se=>Qi`
${se.label} @@ -19820,20 +19820,20 @@ gl_FragColor=color;
- `;B.appendChild(ge);let me=ge.querySelector("[data-action='toggle-annot']");me&&me.addEventListener("click",()=>{y(!o)}),ge.querySelectorAll("[data-action='focus-pin']").forEach(se=>{se.addEventListener("click",()=>{let le=se.dataset.pinId;u(le)})}),ge.querySelectorAll("[data-action='edit-pin']").forEach(se=>{se.addEventListener("click",le=>{le.stopPropagation();let xe=se.dataset.pinId;a==null||a.editPin(xe)})}),ge.querySelectorAll("[data-action='delete-pin']").forEach(se=>{se.addEventListener("click",le=>{le.stopPropagation();let xe=se.dataset.pinId;a==null||a.removePin(xe)})})}if(Q.currentModelPath){let te=Zi` + `;B.appendChild(ge);let me=ge.querySelector("[data-action='toggle-annot']");me&&me.addEventListener("click",()=>{y(!o)}),ge.querySelectorAll("[data-action='focus-pin']").forEach(se=>{se.addEventListener("click",()=>{let le=se.dataset.pinId;u(le)})}),ge.querySelectorAll("[data-action='edit-pin']").forEach(se=>{se.addEventListener("click",le=>{le.stopPropagation();let xe=se.dataset.pinId;a==null||a.editPin(xe)})}),ge.querySelectorAll("[data-action='delete-pin']").forEach(se=>{se.addEventListener("click",le=>{le.stopPropagation();let xe=se.dataset.pinId;a==null||a.removePin(xe)})})}if(Q.currentModelPath){let te=Qi`
- ${s?Zi``:""} - ${s?Zi``:""} - ${s!=null&&s.hasAnimations()?Zi``:""} + ${s?Qi``:""} + ${s?Qi``:""} + ${s!=null&&s.hasAnimations()?Qi``:""}
- `;B.appendChild(te),te.querySelector("[data-action='save']").addEventListener("click",()=>{t.save()});let Pe=te.querySelector("[data-action='reset']");Pe&&Pe.addEventListener("click",()=>{s==null||s.resetView()});let ge=te.querySelector("[data-action='info']");ge&&ge.addEventListener("click",()=>{var ce;if(!s)return;let se=(ce=t.store.getState().currentModelPath)!=null?ce:void 0,le=s.exportModelInfo(se);if(!le)return;let xe=e.workspace.getActiveViewOfType(Nc.MarkdownView);xe&&"editor"in xe?xe.editor.replaceSelection(le):navigator.clipboard.writeText(le).catch(()=>{})});let me=te.querySelector("[data-action='anim']");me&&me.addEventListener("click",()=>{if(!(s!=null&&s.toggleAnimation))return;let se=s.toggleAnimation();me.textContent=se?Z("workbench.pauseAction"):Z("workbench.playAction")}),te.querySelector("[data-action='note']").addEventListener("click",()=>{l2(e,t.store.getState())})}}w();async function H(){var Q,$;if(!l){l=!0;try{for(;f!==void 0;){let q=f;f=void 0;let z=t.store.getState();if(!q){L(),z.modelPreview!==null&&t.store.setState({modelPreview:null});continue}if(!(e.vault.getAbstractFileByPath(q)instanceof Nc.TFile)){L(Jt("workbench.fileNotFound",{path:q})),z.modelPreview!==null&&t.store.setState({modelPreview:null});continue}P(),_.classList.add("is-hidden");let J=p.createEl("canvas",{cls:"ai3d-canvas-full"});p.insertBefore(J,g),p.appendChild(J);try{Oc.info("begin model load",{path:q});let te=(Q=Qs(e,q))!=null?Q:void 0,Pe=ra(z.settings),ge=await ta({path:q,absolutePath:te,preferConversionExts:na(z.settings),conversionManager:Pe,convertedAssetCache:i}),me=Xo(ge);for(let $e of me.warnings)Oc.warn("model prepare warning",{path:q,warning:$e});let se=await br(e,me.path),le=async $e=>br(e,$e);s=new $s(J),b==null||b.classList.remove("is-hidden");let xe=await s.loadModel(se,me.ext,le,me.path),ce=t.store.getState().currentModelPath;if(ce!==q){Oc.info("discard stale model load",{path:q,nextPath:ce}),s.destroy(),s=null,J.remove();continue}let he=t.store.getState().settings;s.setRenderQuality(he.renderQuality,he.renderScale);let ke=s.getCanvas();if(ke){let $e=t.store.getState().modelAssetProfiles[q],Fe=Ja(e),Xe=Mp(e);a=new Jn({scene:s.getScene(),camera:s.getCamera(),engine:s.getEngine(),canvas:ke},p,"edit",($=$e==null?void 0:$e.annotations)!=null?$:[],xt=>{var pr;let Dt=t.store.getState().modelAssetProfiles,Yt=t.store.getState().currentModelPath;if(!Yt)return;let di=(pr=Dt[Yt])!=null?pr:o2();t.store.setState({modelAssetProfiles:{...Dt,[Yt]:{...di,annotations:xt,updatedAt:new Date().toISOString()}}})},Fe,Xe,{app:e,previewMode:he.annotationPreviewMode}),s.onPick(xt=>{if(!o||!a)return;let Dt=xt.screenX,Yt=xt.screenY,di=null;xt.pickedPoint?di=xt.pickedPoint:xt.mesh&&(di=xt.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),di&&(console.debug("[AI3D] Annotation: creating pin at",di.toString(),"screen:",Dt,Yt),a.showEditor(Dt,Yt,di))})}t.store.setState({modelPreview:xe}),Oc.info("model load completed",{path:q,effectivePath:me.path,effectiveExt:me.ext,strategy:me.strategy,meshCount:xe.meshCount,triangleCount:xe.triangleCount})}catch(te){let Pe=qa(te);Za(te)?Oc.warn("model load blocked by converter settings",{path:q,error:te.message}):Oc.error("model load failed",{path:q,error:te instanceof Error?te.message:String(te)}),L(Pe)}}}finally{l=!1}}}let O=t.store.subscribe(()=>{let Q=t.store.getState(),$=Q.currentModelPath!==d,q=Q.modelPreview===null&&h!==null;d=Q.currentModelPath,h=Q.modelPreview,!(!$&&!q)&&(f=Q.currentModelPath,H())});H();let V=t.store.subscribe(()=>w());return()=>{O(),V(),activeDocument.removeEventListener("keydown",m),P(),n.replaceChildren(),n.classList.remove("ai3d-workbench")}}function o2(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}async function l2(n,e){vd!==null&&await vd;let t;vd=new Promise(i=>{t=i});try{let i=e.currentModelPath;if(!i)return;let r=e.modelAssetProfiles[i],s=e.modelPreview,a=Cr(i)||"model",o=e.settings.reportFolder,l=`${o}/${a} Report.md`,c=H8(a,i,r,s),f=n.vault.getAbstractFileByPath(l);if(f instanceof Nc.TFile){await n.vault.modify(f,c);return}n.vault.getAbstractFileByPath(o)||await n.vault.createFolder(o).catch(()=>{});try{await n.vault.create(l,c)}catch(h){let u=n.vault.getAbstractFileByPath(l);u instanceof Nc.TFile&&await n.vault.modify(u,c)}}finally{t(),vd!==null&&(vd=null)}}function H8(n,e,t,i){var s,a,o,l;return[["---",`source_model: "${e}"`,`format: ${(a=(s=e.split(".").pop())==null?void 0:s.toLowerCase())!=null?a:"unknown"}`,"status: ready",`updated_at: ${new Date().toISOString()}`,...t!=null&&t.tags.length?["knowledge_tags:",...t.tags.map(c=>` - ${c}`)]:[],"---"].join(` + `;B.appendChild(te),te.querySelector("[data-action='save']").addEventListener("click",()=>{t.save()});let Pe=te.querySelector("[data-action='reset']");Pe&&Pe.addEventListener("click",()=>{s==null||s.resetView()});let ge=te.querySelector("[data-action='info']");ge&&ge.addEventListener("click",()=>{var ce;if(!s)return;let se=(ce=t.store.getState().currentModelPath)!=null?ce:void 0,le=s.exportModelInfo(se);if(!le)return;let xe=e.workspace.getActiveViewOfType(Nc.MarkdownView);xe&&"editor"in xe?xe.editor.replaceSelection(le):navigator.clipboard.writeText(le).catch(()=>{})});let me=te.querySelector("[data-action='anim']");me&&me.addEventListener("click",()=>{if(!(s!=null&&s.toggleAnimation))return;let se=s.toggleAnimation();me.textContent=se?Z("workbench.pauseAction"):Z("workbench.playAction")}),te.querySelector("[data-action='note']").addEventListener("click",()=>{b2(e,t.store.getState())})}}w();async function H(){var Q,$;if(!l){l=!0;try{for(;f!==void 0;){let q=f;f=void 0;let z=t.store.getState();if(!q){L(),z.modelPreview!==null&&t.store.setState({modelPreview:null});continue}if(!(e.vault.getAbstractFileByPath(q)instanceof Nc.TFile)){L(Jt("workbench.fileNotFound",{path:q})),z.modelPreview!==null&&t.store.setState({modelPreview:null});continue}P(),_.classList.add("is-hidden");let J=p.createEl("canvas",{cls:"ai3d-canvas-full"});p.insertBefore(J,g),p.appendChild(J);try{Oc.info("begin model load",{path:q});let te=(Q=Qs(e,q))!=null?Q:void 0,Pe=ra(z.settings),ge=await ta({path:q,absolutePath:te,preferConversionExts:na(z.settings),conversionManager:Pe,convertedAssetCache:i}),me=Yo(ge);for(let $e of me.warnings)Oc.warn("model prepare warning",{path:q,warning:$e});let se=await yr(e,me.path),le=async $e=>yr(e,$e);s=new $s(J),b==null||b.classList.remove("is-hidden");let xe=await s.loadModel(se,me.ext,le,me.path),ce=t.store.getState().currentModelPath;if(ce!==q){Oc.info("discard stale model load",{path:q,nextPath:ce}),s.destroy(),s=null,J.remove();continue}let he=t.store.getState().settings;s.setRenderQuality(he.renderQuality,he.renderScale);let ke=s.getCanvas();if(ke){let $e=t.store.getState().modelAssetProfiles[q],Fe=Ja(e),Xe=Lp(e);a=new $n({scene:s.getScene(),camera:s.getCamera(),engine:s.getEngine(),canvas:ke},p,"edit",($=$e==null?void 0:$e.annotations)!=null?$:[],xt=>{var Er;let Dt=t.store.getState().modelAssetProfiles,Yt=t.store.getState().currentModelPath;if(!Yt)return;let hi=(Er=Dt[Yt])!=null?Er:C2();t.store.setState({modelAssetProfiles:{...Dt,[Yt]:{...hi,annotations:xt,updatedAt:new Date().toISOString()}}})},Fe,Xe,{app:e,previewMode:he.annotationPreviewMode}),s.onPick(xt=>{if(!o||!a)return;let Dt=xt.screenX,Yt=xt.screenY,hi=null;xt.pickedPoint?hi=xt.pickedPoint:xt.mesh&&(hi=xt.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),hi&&(console.debug("[AI3D] Annotation: creating pin at",hi.toString(),"screen:",Dt,Yt),a.showEditor(Dt,Yt,hi))})}t.store.setState({modelPreview:xe}),Oc.info("model load completed",{path:q,effectivePath:me.path,effectiveExt:me.ext,strategy:me.strategy,meshCount:xe.meshCount,triangleCount:xe.triangleCount})}catch(te){let Pe=qa(te);Za(te)?Oc.warn("model load blocked by converter settings",{path:q,error:te.message}):Oc.error("model load failed",{path:q,error:te instanceof Error?te.message:String(te)}),L(Pe)}}}finally{l=!1}}}let O=t.store.subscribe(()=>{let Q=t.store.getState(),$=Q.currentModelPath!==d,q=Q.modelPreview===null&&h!==null;d=Q.currentModelPath,h=Q.modelPreview,!(!$&&!q)&&(f=Q.currentModelPath,H())});H();let k=t.store.subscribe(()=>w());return()=>{O(),k(),activeDocument.removeEventListener("keydown",m),P(),n.replaceChildren(),n.classList.remove("ai3d-workbench")}}function C2(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}async function b2(n,e){Td!==null&&await Td;let t;Td=new Promise(i=>{t=i});try{let i=e.currentModelPath;if(!i)return;let r=e.modelAssetProfiles[i],s=e.modelPreview,a=Mr(i)||"model",o=e.settings.reportFolder,l=`${o}/${a} Report.md`,c=c6(a,i,r,s),f=n.vault.getAbstractFileByPath(l);if(f instanceof Nc.TFile){await n.vault.modify(f,c);return}n.vault.getAbstractFileByPath(o)||await n.vault.createFolder(o).catch(()=>{});try{await n.vault.create(l,c)}catch(h){let u=n.vault.getAbstractFileByPath(l);u instanceof Nc.TFile&&await n.vault.modify(u,c)}}finally{t(),Td!==null&&(Td=null)}}function c6(n,e,t,i){var s,a,o,l;return[["---",`source_model: "${e}"`,`format: ${(a=(s=e.split(".").pop())==null?void 0:s.toLowerCase())!=null?a:"unknown"}`,"status: ready",`updated_at: ${new Date().toISOString()}`,...t!=null&&t.tags.length?["knowledge_tags:",...t.tags.map(c=>` - ${c}`)]:[],"---"].join(` `),"",`# ${n}`,"","## Summary","",...i?["| Metric | Value |","|--------|-------|",`| Meshes | ${i.meshCount} |`,`| ${i.splatCount?"Splats":"Triangles"} | ${((o=i.splatCount)!=null?o:i.triangleCount).toLocaleString()} |`,`| Vertices | ${i.vertexCount.toLocaleString()} |`,`| Materials | ${i.materialCount} |`,`| Bounding Size | ${i.boundingSize.x.toFixed(2)} x ${i.boundingSize.y.toFixed(2)} x ${i.boundingSize.z.toFixed(2)} |`,""]:["(No preview data available)",""],"## Key Parts","","(Parts will be populated after analysis)","","## Suggested Knowledge Points","","(Knowledge points will be generated after AI analysis)","","## Review Notes","",(l=t==null?void 0:t.notes)!=null?l:"",""].join(` -`)}var Nc,Oc,vd,wA=A(()=>{"use strict";Nc=require("obsidian");vR();ld();dd();Is();lu();zU();ud();pd();bp();Mr();Js();_d();Pc();zo();Jr();Ed();jr();Oc=ti("workbench");vd=null});function Gi(n){let e=createSvg("svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","16"),e.setAttribute("height","16");let t=new DOMParser().parseFromString(`${n}`,"image/svg+xml");for(let i of Array.from(t.documentElement.childNodes))e.appendChild(activeDocument.importNode(i,!0));return e}function d2(n){var a,o;let[e,t]=n.split(","),i=(o=(a=e.match(/:(.*?);/))==null?void 0:a[1])!=null?o:"image/png",r=atob(t),s=new Uint8Array(r.length);for(let l=0;l(f&&J.classList.add("is-secondary"),J),m=!1,p=!1,_=f?h.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-mode-btn",attr:{"aria-label":Z("helper.enableInteractionLabel")}}):null;_==null||_.appendChild(Gi(''));let g=(K=_==null?void 0:_.createSpan({cls:"ai3d-mobile-mode-btn-label"}))!=null?K:null,T=()=>{!f||!_||(h2(e,m),_.classList.toggle("ai3d-btn-active",m),g==null||g.setText(m?Z("helper.scrollAction"):Z("helper.interactAction")),_.setAttribute("aria-label",m?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel")),z==null||z.classList.toggle("ai3d-btn-active",p),h.classList.toggle("show-secondary",p))},b=J=>{m=J,T()};_==null||_.addEventListener("click",()=>{let J=!m;l==null||l(J),b(J),jt(_,J?Z("helper.interactionOn"):Z("helper.interactionOff"))});let R=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.resetViewLabel")}});R.appendChild(Gi('')),R.addEventListener("click",()=>{let J=i();J!=null&&J.resetView&&(J.resetView(),jt(R,Z("helper.resetViewDone")))});let S=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.copyModelInfoLabel")}}));S.appendChild(Gi('')),S.addEventListener("click",()=>{let J=i();if(J!=null&&J.exportModelInfo)try{let te=J.exportModelInfo(r());if(!te)return;navigator.clipboard.writeText(te).then(()=>{jt(S,Z("helper.copied"))}).catch(()=>{jt(S,Z("helper.failed"))})}catch(te){console.error("[AI3D] Export model info failed:",te),jt(S,Z("helper.failed"))}});let I=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleWireframeLabel")}});I.appendChild(Gi('')),I.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleWireframe))return;let te=J.toggleWireframe();I.classList.toggle("ai3d-btn-active",te),jt(I,te?Z("helper.wireframeOn"):Z("helper.wireframeOff"))});let x=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleAxesLabel")}}));x.appendChild(Gi('')),x.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleOrientationGizmo))return;let te=J.toggleOrientationGizmo();x.classList.toggle("ai3d-btn-active",te),jt(x,te?Z("helper.axesOn"):Z("helper.axesOff"))});let P=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleBoundingBoxLabel")}}));P.appendChild(Gi('')),P.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleBoundingBox))return;let te=J.toggleBoundingBox();P.classList.toggle("ai3d-btn-active",te),jt(P,te?Z("helper.boundingBoxOn"):Z("helper.boundingBoxOff"))});let L=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleDisassemblyLabel")}}));L.appendChild(Gi('')),L.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleDisassembly))return;let te=J.toggleDisassembly();L.classList.toggle("ai3d-btn-active",te),jt(L,te?Z("helper.disassemblyOn"):Z("helper.disassemblyOff"))});let y=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.resetPartsLabel")}}));y.appendChild(Gi('')),y.addEventListener("click",()=>{let J=i();J!=null&&J.resetDisassembly&&(J.resetDisassembly(),jt(y,Z("helper.partsReset")))});let B=[.5,.75,1,1.5,2],w=2,H=u(h.createEl("button",{cls:"ai3d-inline-btn ai3d-res-btn",attr:{"aria-label":Z("helper.changeResolutionLabel")}}));H.textContent="1.0x",H.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.setRenderScale))return;w=(w+1)%B.length;let te=J.setRenderScale(B[w]);H.textContent=`${te}x`,jt(H,Jt("helper.resolutionValue",{value:`${te}x`}))});let O=u(h.createEl("button",{cls:"ai3d-inline-btn is-hidden",attr:{"aria-label":Z("helper.toggleAnimationLabel")}}));O.appendChild(Gi('')),O.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleAnimation))return;let te=J.toggleAnimation();O.replaceChildren(Gi(te?'':'')),jt(O,te?Z("helper.playing"):Z("helper.paused"))});let V=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.removePreviewLabel")}});V.appendChild(Gi('')),V.addEventListener("click",s);let X=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.copySnapshotLabel")}});X.appendChild(Gi('')),X.addEventListener("click",()=>{let J=i();if(J)try{let te=J.captureSnapshot();if(!te)return;let Pe=d2(te);navigator.clipboard.write([new ClipboardItem({"image/png":Pe})]).then(()=>{jt(X,Z("helper.copied"))}).catch(()=>{jt(X,Z("helper.failed"))})}catch(te){console.error("[AI3D] Copy snapshot failed:",te),jt(X,Z("helper.failed"))}});let j=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.saveSnapshotLabel")}}));j.appendChild(Gi('')),j.addEventListener("click",()=>{var te,Pe;let J=i();if(J)try{let ge=J.captureSnapshot();if(!ge)return;let me=r(),se=Cr(me)||"model",le=a==null?void 0:a(),xe=(te=le==null?void 0:le.snapshotFolder)!=null?te:"Media/3D Previews",ce=(Pe=le==null?void 0:le.snapshotNaming)!=null?Pe:"model-name",he=Date.now(),ke=ce==="timestamp"?`snapshot_${he}.png`:`${se}_snapshot_${he}.png`,$e=d2(ge),Fe=new FileReader;Fe.onload=()=>{let Xe=Fe.result;t.vault.adapter.exists(xe).then(xt=>xt?Promise.resolve():t.vault.createFolder(xe).catch(()=>{})).then(()=>t.vault.createBinary(`${xe}/${ke}`,Xe)).then(()=>{jt(j,Z("helper.saved"))}).catch(xt=>{console.error("[AI3D] Save snapshot failed:",xt),jt(j,Z("helper.failed"))})},Fe.onerror=()=>{console.error("[AI3D] FileReader error"),jt(j,Z("helper.failed"))},Fe.onabort=()=>{console.error("[AI3D] FileReader aborted"),jt(j,Z("helper.failed"))},Fe.readAsArrayBuffer($e)}catch(ge){console.error("[AI3D] Save snapshot failed:",ge),jt(j,Z("helper.failed"))}});let Q=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.downloadSnapshotLabel")}}));Q.appendChild(Gi('')),Q.addEventListener("click",()=>{let J=i();if(J)try{let te=J.captureSnapshot();if(!te)return;let Pe=r(),me=`${Cr(Pe)||"model"}_snapshot_${Date.now()}.png`,se=createEl("a");se.href=te,se.download=me,activeDocument.body.appendChild(se),se.click(),se.remove(),jt(Q,Z("helper.downloaded"))}catch(te){console.error("[AI3D] Download snapshot failed:",te),jt(Q,Z("helper.failed"))}});let $=u(h.createEl("button",{cls:"ai3d-inline-btn is-hidden ai3d-annot-btn",attr:{"aria-label":Z(d.labelKey)}}));$.appendChild(Gi(''));let q=$.createSpan({cls:"ai3d-pin-badge is-hidden"});$.addEventListener("click",()=>{if(!o)return;let J=o();$.classList.toggle("ai3d-btn-active",J),jt($,J?Z(d.activeTooltipKey):Z(d.inactiveTooltipKey))});let z=f?h.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-more-toggle",attr:{"aria-label":Z("helper.showMoreActionsLabel")}}):null;return z==null||z.appendChild(Gi('')),z==null||z.addEventListener("click",()=>{p=!p,z.setAttribute("aria-label",p?Z("helper.hideMoreActionsLabel"):Z("helper.showMoreActionsLabel")),T(),jt(z,p?Z("helper.moreActionsShown"):Z("helper.moreActionsHidden"))}),n.insertBefore(h,e.nextSibling),T(),{showAnimButton(){O.classList.remove("is-hidden")},showAnnotateButton(){$.classList.remove("is-hidden")},updateAnnotationBadge(J){J>0?(q.textContent=String(J),q.classList.remove("is-hidden")):q.classList.add("is-hidden")},setMobileInteractionMode(J){f&&b(J)}}}function jt(n,e){var r;(r=BA.get(n))==null||r.remove();let t=n.parentElement;if(!t)return;let i=t.createDiv({cls:"ai3d-tooltip"});i.textContent=e,BA.set(n,i),window.setTimeout(()=>{i.remove(),BA.delete(n)},1500)}var BA,UA=A(()=>{"use strict";Jr();jr();Js();BA=new WeakMap});function Yo(n){let e=n.createDiv({cls:"ai3d-loading-overlay"}),t=e.createDiv({cls:"ai3d-loading-skeleton"});t.createDiv({cls:"ai3d-loading-skeleton-canvas"});let i=t.createDiv({cls:"ai3d-loading-skeleton-meta"});i.createDiv({cls:"ai3d-loading-skeleton-line"}),i.createDiv({cls:"ai3d-loading-skeleton-line is-short"}),e.createDiv({cls:"ai3d-loading-spinner"});let r=e.createDiv({cls:"ai3d-loading-text"}),s="loading.default",a="",o=()=>{r.textContent=s?Z(s):a};o();let c=e.createDiv({cls:"ai3d-loading-bar-track"}).createDiv({cls:"ai3d-loading-bar-fill is-indeterminate"}),f=!1,d=wU(()=>{!f&&s&&o()});return{el:e,setPhase(h){s=null,a=h,f||o()},setPhaseKey(h){s=h,f||o()},setProgress(h){f||(h<0?(c.className="ai3d-loading-bar-fill is-indeterminate",c.style.removeProperty("--bar-width")):(c.className="ai3d-loading-bar-fill",c.style.setProperty("--bar-width",`${Math.min(100,Math.max(0,h))}%`)))},hide(){f||(f=!0,d(),e.classList.add("is-hiding"),window.setTimeout(()=>e.remove(),300))}}}var Dp=A(()=>{"use strict";Jr()});function Y8(n){return n.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}function p2(n,e=[]){let t=[n,...e,...n.getChildMeshes(!0)],i=new Set;return t.filter(r=>!r||i.has(r)||r.isDisposed()?!1:(i.add(r),r.getTotalVertices()>0||r.getTotalIndices()>0))}var Fc,Fp,_2=A(()=>{"use strict";qg();gr();du();hu();ve();et();fl();hc();Xs();rd();rd();rA();jr();Fc=32;Fp=class{constructor(e){this.cells=[];this.initialCameras=[];this.wireframeEnabled=!1;this.rendering=!1;this.preventCanvasWheelScroll=e=>{e.preventDefault(),e.stopPropagation()};e.className="ai3d-canvas-full",e.addEventListener("wheel",this.preventCanvasWheelScroll,{passive:!1}),this.engine=new Ee(e,!0,{preserveDrawingBuffer:!0}),this.scene=new gt(this.engine),this.scene.clearColor=new Ne(.12,.12,.14,1),this.scene.autoClear=!1,new Sr("default-light",new v(0,1,.5),this.scene),this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),window.requestAnimationFrame(()=>this.engine.resize())}canRender(){let e=this.engine.getRenderingCanvas();return!!(e!=null&&e.isConnected)&&e.clientWidth>0&&e.clientHeight>0}async loadModels(e,t,i){var d,h,u;await id();let r=e.length>Fc?(console.warn(`[AI3D Grid] Capping ${e.length} models to ${Fc} (layerMask limit)`),e.slice(0,Fc)):e,s=(d=t.columns)!=null?d:Math.min(r.length,3),a=(h=t.gapX)!=null?h:.02,o=(u=t.gapY)!=null?u:.02,l=Math.ceil(r.length/s),c=(1-a*(s+1))/s,f=(1-o*(l+1))/l;for(let m=0;mFc?(console.warn(`[AI3D Preset] Capping ${e.placements.length} placements to ${Fc} (layerMask limit)`),e.placements.slice(0,Fc)):e.placements,r=[];for(let c=0;cc.length>0).map(c=>c[0]),a=v.Zero(),o=1;if(s.length>0){let c=new v(1/0,1/0,1/0),f=new v(-1/0,-1/0,-1/0);for(let h of s){h.computeWorldMatrix(!0);let u=h.getHierarchyBoundingVectors();c=v.Minimize(c,u.min),f=v.Maximize(f,u.max)}let d=f.subtract(c);a=c.add(d.scale(.5)),o=d.length()/2}let l=e.cells.length===1;for(let c of e.cells){let f=r[c.modelIndex];if(!f||f.length===0)continue;let d,h;if(l){d=[],h=0;for(let m=0;m0&&(d.push(...r[m]),h|=1<_!==c),h=1<this.renderFrame()))}captureSnapshot(){let e=this.engine.getRenderingCanvas();return e?(this.renderFrame(),e.toDataURL("image/png")):null}getEngine(){return this.engine}getScene(){return this.scene}getCellCount(){return this.cells.length}getCanvas(){return this.engine.getRenderingCanvas()}getPrimaryCamera(){var e,t;return(t=(e=this.cells[0])==null?void 0:e.camera)!=null?t:null}setRenderScale(e){let t=Math.max(.25,Math.min(e,2)),i=Qt()?1.5:1;return this.engine.setHardwareScalingLevel(i/t),t}resetView(){for(let e=0;e({path:i.path,position:[-t/2+r*e,0,0],color:i.color,wireframe:i.wireframe}))}function WA(n,e){return n.map((t,i)=>{let r=2*Math.PI*i/n.length;return{path:t.path,position:[Math.cos(r)*e,0,Math.sin(r)*e],color:t.color,wireframe:t.wireframe}})}var GA,Ko=A(()=>{"use strict";GA={iso:{alpha:Math.PI/4,beta:Math.PI/3},front:{alpha:0,beta:Math.PI/2},side:{alpha:Math.PI/2,beta:Math.PI/2},top:{alpha:0,beta:.01},back:{alpha:Math.PI,beta:Math.PI/2},"3/4":{alpha:Math.PI/6,beta:Math.PI/3.5}}});var g2,E2=A(()=>{"use strict";Ko();g2={name:"compare",description:"Side-by-side model comparison (2-4 models)",minModels:2,maxModels:4,compute(n,e){if(n.length<2||n.length>4)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=Ad(n,t),s=n.length<=3?n.length:2,a=Math.ceil(n.length/s),o=$n(s,a),l=n.map((c,f)=>({modelIndex:f,camera:In(i),viewport:o[f]}));return{placements:r,cells:l}}}});var v2,T2=A(()=>{"use strict";Ko();v2={name:"showcase",description:"Single model viewed from multiple angles",minModels:1,maxModels:1,compute(n,e){if(n.length<1)return null;let t=Number(e.angles)||4,i=Number(e.radius)||2.5,r=[{path:n[0].path,position:[0,0,0],color:n[0].color,wireframe:n[0].wireframe}],s=t>=6?["front","side","top","back","iso","3/4"]:["iso","front","side","top"],a=s.length<=4?2:3,o=Math.ceil(s.length/a),l=$n(a,o),c=s.map((f,d)=>({modelIndex:0,camera:In(f,void 0,i),viewport:l[d]}));return{placements:r,cells:c}}}});var S2,A2=A(()=>{"use strict";Ko();S2={name:"explode",description:"Spatial arrangement of parts (3-8 models in a ring)",minModels:3,maxModels:8,compute(n,e){if(n.length<3||n.length>8)return null;let t=Number(e.radius)||8,i=e.angle||"iso",r=WA(n,t),s=Math.min(n.length,4),a=Math.ceil(n.length/s),o=$n(s,a),l=n.map((c,f)=>({modelIndex:f,camera:In(i),viewport:o[f]}));return{placements:r,cells:l}}}});var R2,I2=A(()=>{"use strict";Ko();R2={name:"timeline",description:"Horizontal progression of models (2-6 models in a strip)",minModels:2,maxModels:6,compute(n,e){if(n.length<2||n.length>6)return null;let t=Number(e.spacing)||6,i=e.angle||"3/4",r=Ad(n,t),s=kA(n.length),a=n.map((o,l)=>({modelIndex:l,camera:In(i),viewport:s[l]}));return{placements:r,cells:a}}}});function HA(n,e,t,i,r){var f,d;if(!n||n.length===0)return null;let s=n.reduce((h,u)=>{var m;return h+((m=u.weight)!=null?m:1)},0);if(s<=0)return null;let a=[],o=0;for(let h of n){let m=((f=h.weight)!=null?f:1)/s*(1-t*(n.length+1));e==="horizontal"?a.push({x:t+o,y:t,w:m,h:1-2*t}):a.push({x:t,y:t+o,w:1-2*t,h:m}),o+=m+t}let l=[],c=[];for(let h=0;h{"use strict";x2={name:"compose",description:"Combine multiple presets into one layout",minModels:1,maxModels:32,compute(n,e,t){return null}}});var C2,b2=A(()=>{"use strict";Ko();C2={name:"gallery",description:"All models in one scene, single camera (no cell limit)",minModels:1,maxModels:32,compute(n,e){if(n.length===0)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=Number(e.cols)||0,s=r>0?r:Math.ceil(Math.sqrt(n.length)),a=Math.ceil(n.length/s),o=n.map((f,d)=>{let h=d%s,u=Math.floor(d/s),m=(h-(s-1)/2)*t,p=(u-(a-1)/2)*t;return{path:f.path,position:[m,0,p],color:f.color,wireframe:f.wireframe}}),l=$n(1,1,0),c=[{modelIndex:0,camera:In(i,void 0,3+Math.max(s,a)*.5),viewport:l[0]}];return{placements:o,cells:c}}}});function wc(n){M2.set(n.name,n)}function XA(n){return M2.get(n)}var M2,y2=A(()=>{"use strict";E2();T2();A2();I2();zA();b2();Ko();zA();M2=new Map;wc(g2);wc(v2);wc(S2);wc(R2);wc(x2);wc(C2)});var P2={};De(P2,{registerCodeBlockProcessor:()=>Z8,registerGridCodeBlockProcessor:()=>Q8});async function D2(n,e,t,i){var d,h,u;let r=typeof e=="string"?{path:e}:e,s=Mc(n,r.path);if(!s)throw new Error(Jt("workbench.fileNotFound",{path:r.path}));let a=(h=(d=s.split(".").pop())==null?void 0:d.toLowerCase())!=null?h:"";if(!es(a))throw new Error(Jt("codeBlock.unsupportedFormat",{ext:`.${a}`,formats:to().join(", ")}));let o=(u=Qs(n,s))!=null?u:void 0,l=ra(t),c=await ta({path:s,absolutePath:o,preferConversionExts:na(t),conversionManager:l,convertedAssetCache:i}),f=Xo(c);return{sourcePath:s,effectivePath:f.path,effectiveExt:f.ext,warnings:f.warnings,model:{...r,path:f.path}}}async function j8(n,e,t,i){let r=[];for(let s of e.models){let a=await D2(n,s,t,i);r.push(a.model)}return{...e,models:r}}function L2(n){Qt()&&n.createDiv({cls:"ai3d-mobile-mode-hint ai3d-mobile-mode-hint--inline",text:Z("codeBlock.mobileHint")})}function Z8(n,e,t,i){return{id:"3d",handler:(r,s,a)=>{var L,y;let o=r.trim();if(!o){s.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelPathOrConfig")});return}let l;if(o.startsWith("{")||o.startsWith("["))try{let B=JSON.parse(o);l=q8(B)}catch(B){let w=s.createDiv({cls:"ai3d-json-error"}),H=String(B).match(/position\s+(\d+)/),O=Jt("codeBlock.jsonParseError",{error:String(B)});if(H){let V=parseInt(H[1],10),X=o.substring(0,V).split(` -`);O+=Jt("codeBlock.jsonParseLine",{line:String(X.length)})}w.createEl("pre",{text:O});return}else l={models:[{path:o}]};if(!l.models||l.models.length===0){s.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelsInConfig")});return}l.models.length>1&&console.warn(`[AI3D] \`\`\`3d only supports one model; ${l.models.length-1} additional models ignored. Use \`\`\`3dgrid for multi-model.`);let f=l.models[0],d=Mc(n,f.path);if(!d){s.createDiv({cls:"ai3d-inline-empty",text:Jt("workbench.fileNotFound",{path:f.path})});return}let h=(y=(L=d.split(".").pop())==null?void 0:L.toLowerCase())!=null?y:"";if(!es(h)){s.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.unsupportedFormat",{ext:`.${h}`,formats:to().join(", ")})});return}let u=e(),m=s.createDiv({cls:"ai3d-preview-host"});l.height&&m.style.setProperty("--min-height",typeof l.height=="number"?`${l.height}px`:l.height),l.width&&m.style.setProperty("--max-width",typeof l.width=="number"?`${l.width}px`:l.width);let p=m.createEl("canvas",{cls:"ai3d-canvas-full"});p.tabIndex=0,p.addEventListener("keydown",B=>{var H,O,V,X,j;if(b||!_)return;let w=B.key.toLowerCase();w==="r"?((H=_.resetView)==null||H.call(_),B.preventDefault()):w==="w"?((O=_.toggleWireframe)==null||O.call(_),B.preventDefault()):w==="g"?((V=_.toggleOrientationGizmo)==null||V.call(_),B.preventDefault()):w==="b"?((X=_.toggleBoundingBox)==null||X.call(_),B.preventDefault()):w===" "&&((j=_.toggleAnimation)==null||j.call(_),B.preventDefault())}),m.appendChild(p);let _=null,g=null,T=!0,b=!1,R=!1,S=Sd(s,m,n,()=>_,()=>d,()=>{b||(b=!0,I.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null,m.remove())},e,()=>{if(T=!T,g){let B=m.querySelector(".ai3d-annotation-overlay");B&&B.classList.toggle("is-hidden",!T)}return T},void 0,{labelKey:"helper.toggleAnnotationsVisibilityLabel",activeTooltipKey:"helper.annotationsVisible",inactiveTooltipKey:"helper.annotationsHidden"});L2(s);let I=new MutationObserver(()=>{b||s.contains(m)||(b=!0,I.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null)});I.observe(s,{childList:!0});async function x(){var w,H;if(R||b||!d)return;R=!0;let B=Yo(m);try{let O=(w=Qs(n,d))!=null?w:void 0,V=ra(u);B.setPhaseKey("loading.preparingModel");let X=await ta({path:d,absolutePath:O,preferConversionExts:na(u),conversionManager:V,convertedAssetCache:t}),j=Xo(X);_=new $s(p),B.setPhaseKey("loading.loadingModel");let Q=await br(n,j.path),$=async q=>br(n,q);if(b){B.hide();return}if(await _.loadModel(Q,j.ext,$,j.path),B.setProgress(100),b){B.hide();return}if(((H=l.scene)==null?void 0:H.autoRotate)===void 0&&u.autoRotateDefault&&(l.scene={...l.scene,autoRotate:!0,autoRotateSpeed:u.autoRotateSpeed}),_.applyConfig(l),_.setRenderQuality(u.renderQuality,u.renderScale),i&&d){let q=i(d);if(q.length>0){let z=_.getCanvas();z&&(g=new Jn({scene:_.getScene(),camera:_.getCamera(),engine:_.getEngine(),canvas:z},m,"readonly",q,void 0,Ja(n),void 0,{app:n,previewMode:u.annotationPreviewMode}),S.showAnnotateButton(),S.updateAnnotationBadge(q.length))}}h==="stl"&&f.color&&_.setSTLColor(f.color),h==="stl"&&f.wireframe!==void 0&&_.setWireframe(f.wireframe),_.hasAnimations()&&S.showAnimButton(),B.hide()}catch(O){b=!0,I.disconnect(),P.disconnect(),B.hide(),_==null||_.destroy(),_=null,m.replaceChildren();let V=qa(O);Za(O)?console.warn("[AI3D] Inline preview blocked by converter settings:",V.message):console.error("[AI3D] Inline preview failed:",O),$a(m,V)}}let P=new IntersectionObserver(B=>{for(let w of B)w.isIntersecting&&(P.disconnect(),x())},{rootMargin:"200px"});P.observe(m)}}}function q8(n){if(typeof n=="string")return{models:[{path:n}]};if(typeof n!="object"||n===null)return{models:[]};let e=n;return typeof e.path=="string"?{models:[{path:e.path,color:e.color,wireframe:e.wireframe}],camera:e.camera,lights:e.lights,scene:e.scene,stl:e.stl,width:e.width,height:e.height}:{models:Array.isArray(e.models)?e.models.filter(i=>{let r=typeof i=="string"?i:i&&typeof i=="object"&&"path"in i?i.path:void 0;return typeof r=="string"&&r.length>0}).map(i=>{if(typeof i=="string")return{path:i};let r=i;return{path:r.path,color:r.color,wireframe:r.wireframe}}):[],camera:e.camera,lights:e.lights,scene:e.scene,stl:e.stl,width:e.width,height:e.height}}function Q8(n,e,t){return{id:"3dgrid",handler:(i,r,s)=>{let a=i.trim();if(!a){r.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noConfigSpecified")});return}let o;try{o=JSON.parse(a)}catch(f){r.createDiv({cls:"ai3d-json-error"}).createEl("pre",{text:`JSON parse error: ${String(f)}`});return}if(o.preset!=="compose"&&(!o.models||o.models.length===0)){r.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelsSpecified")});return}let l=e(),c=Yo(r);(async()=>{var S,I,x,P;let f=[];for(let L of(S=o.models)!=null?S:[])try{let y=await D2(n,L,l,t);f.push(y)}catch(y){c.hide(),r.createDiv({cls:"ai3d-inline-empty",text:y instanceof Error?y.message:String(y)});return}let d=f.map(L=>L.model),h=(x=(I=f[0])==null?void 0:I.sourcePath)!=null?x:"",u=r.createDiv({cls:"ai3d-grid-host"}),m=u.createEl("canvas");if(m.tabIndex=0,m.addEventListener("keydown",L=>{var B,w;if(_||!p)return;let y=L.key.toLowerCase();y==="r"?((B=p.resetView)==null||B.call(p),L.preventDefault()):y==="w"&&((w=p.toggleWireframe)==null||w.call(p),L.preventDefault())}),u.appendChild(m),typeof o.rowHeight=="number"){let L=o.preset==="compose"?1:Math.ceil(d.length/((P=o.columns)!=null?P:Math.min(d.length,3)));u.style.setProperty("--grid-height",`${o.rowHeight*L}px`)}let p=null,_=!1,g=!1;Sd(r,u,n,()=>p,()=>h,()=>{_||(_=!0,T.disconnect(),R.disconnect(),p==null||p.destroy(),p=null,u.remove())},e),L2(r);let T=new MutationObserver(()=>{_||r.contains(u)||(_=!0,T.disconnect(),R.disconnect(),p==null||p.destroy(),p=null)});T.observe(r,{childList:!0});async function b(){var L,y,B,w;if(!(g||_)){g=!0,c.setPhaseKey("codeBlock.renderingGrid"),c.setProgress(-1);try{p=new Fp(m);let H=p,O=async V=>br(n,V);if(o.preset==="compose"){if(!o.sections||o.sections.length===0){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.composeRequiresSections")}),p.destroy(),p=null;return}let V=[];for(let j of o.sections)try{if(!h){let $=j.models[0];if($){let q=typeof $=="string"?$:$.path;h=(L=Mc(n,q))!=null?L:q}}let Q=await j8(n,j,l,t);V.push(Q)}catch(Q){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Q instanceof Error?Q.message:String(Q)}),H.destroy(),p=null;return}let X=HA(V,(y=o.direction)!=null?y:"horizontal",Number((B=o.params)==null?void 0:B.gap)||.02,j=>typeof j=="string"?null:j,XA);if(!X){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.composeNoValidSections")}),H.destroy(),p=null;return}await H.loadWithPreset(X,O)}else if(o.preset){let V=XA(o.preset);if(!V){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.unknownPreset",{preset:o.preset})}),H.destroy(),p=null;return}let X=V.compute(d,(w=o.params)!=null?w:{});if(!X){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.presetRequiresModels",{preset:o.preset,min:String(V.minModels),max:String(V.maxModels),count:String(d.length)})}),H.destroy(),p=null;return}await H.loadWithPreset(X,O)}else await H.loadModels(d,o,O);if(_){c.hide();return}c.hide()}catch(H){_=!0,T.disconnect(),R.disconnect(),c.hide(),p==null||p.destroy(),p=null,console.error("[AI3D Grid] Failed:",H),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.gridFailed",{reason:String(H)})})}}}let R=new IntersectionObserver(L=>{for(let y of L)y.isIntersecting&&(R.disconnect(),b())},{rootMargin:"200px"});R.observe(u)})()}}}var O2=A(()=>{"use strict";ts();ld();_2();dd();Js();y2();UA();pd();ud();bp();_d();Dp();Pc();zo();Jr();Ed();jr()});function Rd(n){return createDiv().createDiv(n?{cls:n}:void 0)}function YA(n,e){return createDiv().createEl(n,e?{cls:e}:void 0)}var N2=A(()=>{"use strict"});var B2={};De(B2,{registerLivePreviewExtension:()=>J8});function F2(n,e,t,i,r,s,a,o,l,c,f,d,h){var p,_;let u="state"in n?n.state.doc:n.doc,m=[];for(let g=1;g<=u.lines;g++){let T=u.line(g),b=T.text;if(!b.includes("!["))continue;let R=0;for(;R0&&b[S-1]==="\\"){R=S+3;continue}let I=b.indexOf("]]",S+3);if(I===-1)break;let P=b.slice(S+3,I).split("|"),L=P[0].trim(),y=(_=(p=L.split(".").pop())==null?void 0:p.toLowerCase())!=null?_:"";if(!es(y)){R=I+2;continue}let B=400,w=300;if(P.length>1){let V=P[1].trim().match(/^(\d+)\s*x\s*(\d+)$/);V&&(B=parseInt(V[1],10),w=parseInt(V[2],10))}let H=Mc(e,L);if(!H){R=I+2;continue}let O=T.from+S;m.push(Bc.Decoration.widget({widget:new KA(e,H,B,w,t,i,r,s,a,o,l,c,f,d,h),block:!0,side:1}).range(O)),R=I+2}}return m}function w2(n){return n.length===0?Id.RangeSet.empty:Id.RangeSet.of(n,!0)}function J8(n,e,t,i){return[Id.StateField.define({create(s){let a=e(),o=F2(s,n,a.autoRotateDefault,a.enabledConverterIds,a.freecadCommand,a.obj2gltfCommand,a.fbx2gltfCommand,a.freecadcmdCommand,a.preferObj2gltfForObj,a.preferFbx2gltfForFbx,a.annotationPreviewMode,t,i);return w2(o)},update(s,a){if(a.docChanged){let o=e(),l=F2(a.state,n,o.autoRotateDefault,o.enabledConverterIds,o.freecadCommand,o.obj2gltfCommand,o.fbx2gltfCommand,o.freecadcmdCommand,o.preferObj2gltfForObj,o.preferFbx2gltfForFbx,o.annotationPreviewMode,t,i);return w2(l)}return s.map(a.changes)},provide:s=>Bc.EditorView.decorations.from(s)})]}var Bc,Id,KA,U2=A(()=>{"use strict";Bc=require("@codemirror/view"),Id=require("@codemirror/state");ts();dd();Js();pd();ud();_d();Dp();Pc();N2();zo();jr();Ed();Jr();KA=class extends Bc.WidgetType{constructor(t,i,r,s,a,o,l,c,f,d,h,u,m,p,_){super();this.app=t;this.modelPath=i;this.width=r;this.height=s;this.autoRotate=a;this.enabledConverterIds=o;this.freecadCommand=l;this.obj2gltfCommand=c;this.fbx2gltfCommand=f;this.freecadcmdCommand=d;this.preferObj2gltfForObj=h;this.preferFbx2gltfForFbx=u;this.annotationPreviewMode=m;this.convertedAssetCache=p;this.getAnnotations=_;this.preview=null;this.annotationMgr=null;this.mounted=!1;this.pollId=0}eq(t){return this.modelPath===t.modelPath&&this.width===t.width&&this.height===t.height&&this.autoRotate===t.autoRotate&&this.enabledConverterIds.join("|")===t.enabledConverterIds.join("|")&&this.freecadCommand===t.freecadCommand&&this.obj2gltfCommand===t.obj2gltfCommand&&this.fbx2gltfCommand===t.fbx2gltfCommand&&this.freecadcmdCommand===t.freecadcmdCommand&&this.preferObj2gltfForObj===t.preferObj2gltfForObj&&this.preferFbx2gltfForFbx===t.preferFbx2gltfForFbx&&this.annotationPreviewMode===t.annotationPreviewMode&&this.convertedAssetCache===t.convertedAssetCache}toDOM(){let t=Qt(),i=Rd("ai3d-embed-preview");t&&i.classList.add("is-mobile","is-mobile-scroll-mode");let r=YA("canvas","ai3d-embed-canvas"),s=t?Math.min(this.height,220):this.height;r.style.setProperty("--ai3d-embed-height",`${s}px`),i.appendChild(r);let a=Yo(i),o=Rd("ai3d-embed-error is-hidden");if(i.appendChild(o),t){let f=!1,d=Rd("ai3d-mobile-mode-bar"),h=Rd("ai3d-mobile-mode-hint");h.textContent=Z("livePreview.mobileHint");let u=YA("button","ai3d-mobile-mode-btn");u.type="button";let m=()=>{i.classList.toggle("is-mobile-interactive",f),i.classList.toggle("is-mobile-scroll-mode",!f),u.textContent=f?Z("helper.scrollAction"):Z("helper.interactAction"),u.classList.toggle("ai3d-btn-active",f),u.setAttribute("aria-label",f?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel"))};u.addEventListener("click",()=>{f=!f,m()}),m(),d.append(h,u),i.appendChild(d)}let l=0,c=()=>{if(!this.mounted){if(i.isConnected){this.mounted=!0,this.initPreview(i,r,a,o);return}++l>120||(this.pollId=window.requestAnimationFrame(c))}};return this.pollId=window.requestAnimationFrame(c),i}async initPreview(t,i,r,s){var a,o;try{let{BabylonModelPreview:l}=await Promise.resolve().then(()=>(ld(),LU));this.preview=new l(i);let c=(a=Qs(this.app,this.modelPath))!=null?a:void 0,f=ra({enabledConverterIds:this.enabledConverterIds,freecadCommand:this.freecadCommand,obj2gltfCommand:this.obj2gltfCommand,fbx2gltfCommand:this.fbx2gltfCommand,freecadcmdCommand:this.freecadcmdCommand});r.setPhaseKey("loading.preparingModel");let d=await ta({path:this.modelPath,absolutePath:c,preferConversionExts:na({preferObj2gltfForObj:this.preferObj2gltfForObj,preferFbx2gltfForFbx:this.preferFbx2gltfForFbx}),conversionManager:f,convertedAssetCache:this.convertedAssetCache});r.setPhaseKey("loading.loadingModel");let h=await br(this.app,d.effectivePath);if(await this.preview.loadModel(h,d.effectiveExt,u=>br(this.app,u),d.effectivePath),this.autoRotate&&this.preview.applyConfig({models:[],scene:{autoRotate:!0,autoRotateSpeed:.5}}),this.getAnnotations){let u=this.getAnnotations(this.modelPath);if(u.length>0){let m=this.preview.getCanvas();m&&(this.annotationMgr=new Jn({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:m},t,"readonly",u,void 0,Ja(this.app),void 0,{app:this.app,previewMode:this.annotationPreviewMode}))}}r.setProgress(100),r.hide()}catch(l){(o=this.preview)==null||o.destroy(),this.preview=null,r.hide(),s.remove(),t.replaceChildren();let c=qa(l);Za(l)?console.warn("[AI3D] Live Preview blocked by converter settings:",c.message):console.error("[AI3D] Live Preview failed:",l),$a(t,c)}}destroy(){var t;window.cancelAnimationFrame(this.pollId),this.pollId=0,(t=this.annotationMgr)==null||t.destroy(),this.annotationMgr=null,this.preview&&(this.preview.destroy(),this.preview=null),this.mounted=!1}ignoreEvent(){return!1}}});var $8={};De($8,{default:()=>wp});module.exports=X2($8);var jo=require("obsidian");zp();ts();ts();var n6=new Set(to());var io={analysisMode:"local",serviceBaseUrl:"",copySourceModelToVault:!1,sourceModelFolder:"Assets/3D",reportFolder:"Analysis/3D Reports",partFolder:"Parts/3D Components",previewFolder:"Media/3D Previews",maxFileSizeMb:50,autoGenerateKnowledgeNotes:!0,annotationPreviewMode:"plain-text",sendRawModelToRemote:!1,sendPreviewImagesToRemote:!1,sendGeometrySummaryToRemote:!1,defaultKnowledgeTaxonomy:"default-v1",defaultCanvasHeight:400,autoRotateDefault:!1,autoRotateSpeed:.5,renderQuality:"high",renderScale:1,snapshotFolder:"Media/3D Previews",snapshotNaming:"model-name",enabledConverterIds:[],freecadCommand:"",obj2gltfCommand:"",fbx2gltfCommand:"",assimpCommand:"",freecadcmdCommand:"",preferObj2gltfForObj:!1,preferFbx2gltfForFbx:!1,logLevel:"warn",locale:"en"};function _R(n){let e={...n},t=new Set;return{getState:()=>e,setState(i){e={...e,...i};let r=[...t];for(let s of r)s()},subscribe(i){return t.add(i),()=>{t.delete(i)}}}}var Z2={settings:{...io},currentModelPath:null,convertedAssetRecords:[],modelAssetProfiles:{},agentDraft:"",agentPlan:null,modelPreview:null};function gR(n){let e=_R(Z2),t=null;function i(){t&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,r().catch(a=>console.error("[AI3D] Auto-save failed:",a))},500)}async function r(){let a=e.getState(),o={settings:a.settings,convertedAssetRecords:a.convertedAssetRecords,modelAssetProfiles:a.modelAssetProfiles,agentDraft:a.agentDraft,agentPlan:a.agentPlan};await n.saveData(o)}e.subscribe(()=>i());let s=!1;return{store:e,get localeLoadedFromSaved(){return s},async load(){var o,l,c,f,d,h;let a=await n.loadData();a&&(s=!!((o=a.settings)!=null&&o.locale),e.setState({settings:{...io,...(l=a.settings)!=null?l:{}},convertedAssetRecords:(c=a.convertedAssetRecords)!=null?c:[],modelAssetProfiles:(f=a.modelAssetProfiles)!=null?f:{},agentDraft:(d=a.agentDraft)!=null?d:"",agentPlan:(h=a.agentPlan)!=null?h:null}))},async save(){t&&(window.clearTimeout(t),t=null),await r()},dispose(){t&&(window.clearTimeout(t),t=null)}}}var f2=require("obsidian");wA();var Td="ai-3d-workbench",yp=class extends f2.FileView{constructor(t,i,r){super(t);this.unmount=null;this.store=i,this.convertedAssetCache=r}getViewType(){return Td}getDisplayText(){return"AI 3d workbench"}getIcon(){return"box"}onOpen(){return this.unmount=FA(this.contentEl,this.app,this.store,this.convertedAssetCache),Promise.resolve()}onClose(){var t;return(t=this.unmount)==null||t.call(this),this.unmount=null,Promise.resolve()}};var u2=require("obsidian");ld();dd();UA();pd();ud();bp();Js();_d();Pc();Dp();zo();Jr();Ed();jr();var Pp="ai3d-direct-view";function z8(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}var Lp=class extends u2.FileView{constructor(t,i,r,s){super(t);this.preview=null;this.annotationMgr=null;this.annotationMode=!1;this.loadGeneration=0;this.escHandler=null;this.getSettings=i,this.convertedAssetCache=r,this.ps=s}getViewType(){return Pp}getDisplayText(){var t,i;return(i=(t=this.file)==null?void 0:t.name)!=null?i:Z("workbench.modelTitle")}getIcon(){return"box"}async onOpen(){this.contentEl.empty(),this.contentEl.addClass("ai3d-direct-view"),this.file&&await this.loadModel(this.file)}async onLoadFile(t){this.contentEl.empty(),await this.loadModel(t)}onClose(){var t,i;return this.escHandler&&(activeDocument.removeEventListener("keydown",this.escHandler),this.escHandler=null),(t=this.annotationMgr)==null||t.destroy(),this.annotationMgr=null,(i=this.preview)==null||i.destroy(),this.preview=null,Promise.resolve()}async loadModel(t){var h,u,m,p,_;let i=++this.loadGeneration,r=Qt();(h=this.annotationMgr)==null||h.destroy(),this.annotationMgr=null,this.annotationMode=!1,(u=this.preview)==null||u.destroy(),this.preview=null;let s=createDiv(),a=s.createDiv({cls:"ai3d-preview-host"}),o=s.createEl("canvas");o.className="ai3d-canvas-full",a.appendChild(o);let l=s.createDiv();l.className="ai3d-annot-mode-overlay is-hidden",a.appendChild(l),this.contentEl.appendChild(a);let c=null,f=g=>{var T;this.annotationMode=g,r&&g&&(c==null||c.setMobileInteractionMode(!0)),(T=this.annotationMgr)==null||T.hideEditor(),l.classList.toggle("is-hidden",!g),console.debug("[AI3D] DirectView annotation mode:",g)};this.escHandler&&activeDocument.removeEventListener("keydown",this.escHandler),this.escHandler=g=>{g.key==="Escape"&&this.annotationMode&&f(!1)},activeDocument.addEventListener("keydown",this.escHandler),c=Sd(this.contentEl,a,this.app,()=>this.preview,()=>t.path,()=>{this.leaf.detach()},this.getSettings,()=>(f(!this.annotationMode),this.annotationMode),g=>{!g&&this.annotationMode&&f(!1)}),r&&this.contentEl.createDiv({cls:"ai3d-mobile-mode-hint ai3d-mobile-mode-hint--inline",text:Z("directView.mobileHint")});let d=Yo(a);try{let g=this.getSettings(),T=ra(g),b=(m=Qs(this.app,t.path))!=null?m:void 0;d.setPhaseKey("loading.preparingModel");let R=await ta({path:t.path,absolutePath:b,preferConversionExts:na(g),conversionManager:T,convertedAssetCache:this.convertedAssetCache});if(i!==this.loadGeneration)return;let S=Xo(R);this.preview=new $s(o),d.setPhaseKey("loading.loadingModel");let I=await br(this.app,S.path);if(i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loading: ${t.path} via ${S.path} (${S.ext}, ${I.byteLength} bytes)`);let x=async L=>br(this.app,L);if(await this.preview.loadModel(I,S.ext,x,S.path),i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loaded successfully: ${t.path}`),d.setProgress(100);let P=this.preview.getCanvas();if(P){let L=this.ps.store.getState().modelAssetProfiles[t.path],y=(p=L==null?void 0:L.annotations)!=null?p:[],B=Ja(this.app),w=Mp(this.app);this.annotationMgr=new Jn({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:P},a,"edit",y,H=>{var X;let O=this.ps.store.getState().modelAssetProfiles,V=(X=O[t.path])!=null?X:z8();this.ps.store.setState({modelAssetProfiles:{...O,[t.path]:{...V,annotations:H,updatedAt:new Date().toISOString()}}}),c.updateAnnotationBadge(H.length)},B,w,{app:this.app,previewMode:this.getSettings().annotationPreviewMode}),c.showAnnotateButton(),c.updateAnnotationBadge(y.length),this.preview.onPick(H=>{if(!this.annotationMode||!this.annotationMgr)return;let O=H.screenX,V=H.screenY,X=null;H.pickedPoint?X=H.pickedPoint:H.mesh&&(X=H.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),X&&(console.debug("[AI3D] Annotation: creating pin at",X.toString(),"screen:",O,V),this.annotationMgr.showEditor(O,V,X))})}d.hide()}catch(g){if(i!==this.loadGeneration)return;d.hide(),(_=this.preview)==null||_.destroy(),this.preview=null,a.replaceChildren();let T=qa(g);Za(g)?console.warn("[AI3D] Direct view blocked by converter settings:",T.message):console.error("[AI3D] Direct view failed:",g),$a(a,T)}}};var m2=require("obsidian");ts();Jr();var Op=class extends m2.FuzzySuggestModal{constructor(e,t){super(e),this.onChoose=t,this.setPlaceholder(Z("modal.selectModel"))}getItems(){return this.app.vault.getFiles().filter(e=>{let t=e.extension.toLowerCase();return es(t)})}getItemText(e){return e.path}onChooseItem(e){this.onChoose(e)}};var Et=require("obsidian");Qa();Jr();jr();Gt();var VA=op();function X8(){switch(VA==null?void 0:VA.platform){case"win32":return{python:"Path to python executable",freecad:"Path to FreeCADCmd.exe",obj2gltf:"Path to obj2gltf.cmd",fbx2gltf:"Path to FBX2glTF.exe"};case"darwin":return{python:"Path to python3",freecad:"Path to FreeCADCmd",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"};case"linux":return{python:"Path to python3",freecad:"Path to freecadcmd",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"};default:return{python:"Path to python executable",freecad:"Path to FreeCAD command",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"}}}var Np=class extends Et.PluginSettingTab{constructor(t,i){super(t,i);this.diagnosticsRunId=0;this.plugin=i}display(){let{containerEl:t}=this;t.empty(),cd(this.plugin.getSettings().locale);let i=X8(),r=Qt(),s=null,a=(l,c,f)=>{let d=l.createEl("details",{cls:"ai3d-settings-secondary-menu"});d.createEl("summary",{cls:"ai3d-settings-secondary-menu-summary",text:c});let h=d.createDiv({cls:"ai3d-settings-secondary-menu-body"});return h.createEl("p",{cls:"setting-item-description",text:f}),h},o=()=>{s&&(this.diagnosticsRunId++,s.empty(),s.createEl("p",{text:Z("settings.diagnostics.idle")}))};if(new Et.Setting(t).setName(Z("settings.title")).setHeading(),new Et.Setting(t).setName(Z("settings.language")).setDesc(Z("settings.language.desc")).addDropdown(l=>l.addOption("en","English").addOption("zh-CN","\u7B80\u4F53\u4E2D\u6587").setValue(this.plugin.getSettings().locale).onChange(c=>{this.plugin.updateSettings({locale:c}),this.display()})),new Et.Setting(t).setName(Z("settings.folders")).setHeading(),new Et.Setting(t).setName(Z("settings.sourceModelFolder")).setDesc(Z("settings.sourceModelFolder.desc")).addText(l=>l.setPlaceholder(io.sourceModelFolder).setValue(this.plugin.getSettings().sourceModelFolder).onChange(c=>{this.plugin.updateSettings({sourceModelFolder:c})})),new Et.Setting(t).setName(Z("settings.reportFolder")).setDesc(Z("settings.reportFolder.desc")).addText(l=>l.setPlaceholder(io.reportFolder).setValue(this.plugin.getSettings().reportFolder).onChange(c=>{this.plugin.updateSettings({reportFolder:c})})),new Et.Setting(t).setName(Z("settings.snapshotFolder")).setDesc(Z("settings.snapshotFolder.desc")).addText(l=>l.setPlaceholder(io.snapshotFolder).setValue(this.plugin.getSettings().snapshotFolder).onChange(c=>{this.plugin.updateSettings({snapshotFolder:c})})),new Et.Setting(t).setName(Z("settings.behavior")).setHeading(),new Et.Setting(t).setName(Z("settings.autoGenerateKnowledgeNotes")).setDesc(Z("settings.autoGenerateKnowledgeNotes.desc")).addToggle(l=>l.setValue(this.plugin.getSettings().autoGenerateKnowledgeNotes).onChange(c=>{this.plugin.updateSettings({autoGenerateKnowledgeNotes:c})})),new Et.Setting(t).setName(Z("settings.annotationPreviewMode")).setDesc(Z("settings.annotationPreviewMode.desc")).addDropdown(l=>l.addOption("plain-text",Z("settings.annotationPreviewMode.plainText")).addOption("markdown",Z("settings.annotationPreviewMode.markdown")).setValue(this.plugin.getSettings().annotationPreviewMode).onChange(c=>{this.plugin.updateSettings({annotationPreviewMode:c})})),new Et.Setting(t).setName(Z("settings.autoRotateDefault")).setDesc(Z("settings.autoRotateDefault.desc")).addToggle(l=>l.setValue(this.plugin.getSettings().autoRotateDefault).onChange(c=>{this.plugin.updateSettings({autoRotateDefault:c})})),new Et.Setting(t).setName(Z("settings.snapshotNaming")).setDesc(Z("settings.snapshotNaming.desc")).addDropdown(l=>l.addOption("model-name",Z("settings.snapshotNaming.modelName")).addOption("timestamp",Z("settings.snapshotNaming.timestamp")).setValue(this.plugin.getSettings().snapshotNaming).onChange(c=>{this.plugin.updateSettings({snapshotNaming:c})})),new Et.Setting(t).setName(Z("settings.logLevel")).setDesc(Z("settings.logLevel.desc")).addDropdown(l=>l.addOption("debug","Debug").addOption("info","Info").addOption("warn","Warn").addOption("error","Error").setValue(this.plugin.getSettings().logLevel).onChange(c=>{this.plugin.updateSettings({logLevel:c})})),new Et.Setting(t).setName(Z("settings.converters")).setHeading(),r)t.createEl("p",{cls:"setting-item-description",text:Z("settings.mobileSupport.desc")});else{let l=a(t,Z("settings.converterMenu"),Z("settings.converterMenu.desc"));new Et.Setting(l).setName(Z("settings.enableCad")).setDesc(Z("settings.enableCad.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("freecad");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"freecad"])):m.filter(_=>_!=="freecad");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableObj2gltf")).setDesc(Z("settings.enableObj2gltf.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("obj2gltf");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"obj2gltf"])):m.filter(_=>_!=="obj2gltf");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.preferObj2gltf")).setDesc(Z("settings.preferObj2gltf.desc")).addToggle(d=>d.setValue(this.plugin.getSettings().preferObj2gltfForObj).onChange(h=>{this.plugin.updateSettings({preferObj2gltfForObj:h})})),new Et.Setting(l).setName(Z("settings.enableFbx2gltf")).setDesc(Z("settings.enableFbx2gltf.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("fbx2gltf");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"fbx2gltf"])):m.filter(_=>_!=="fbx2gltf");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableMesh")).setDesc(Z("settings.enableMesh.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("assimp");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"assimp"])):m.filter(_=>_!=="assimp");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableSldprt")).setDesc(Z("settings.enableSldprt.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("sldprt");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"sldprt"])):m.filter(_=>_!=="sldprt");this.plugin.updateSettings({enabledConverterIds:p})})});let c=a(t,Z("settings.environmentInspector"),Z("settings.environmentInspector.desc"));new Et.Setting(c).setName(Z("settings.paths")).setHeading(),new Et.Setting(c).setName(Z("settings.pythonCmd")).setDesc(Z("settings.pythonCmd.desc")).addText(d=>d.setPlaceholder(i.python).setValue(this.plugin.getSettings().freecadCommand).onChange(h=>{this.plugin.updateSettings({freecadCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.freecadCmd")).setDesc(Z("settings.freecadCmd.desc")).addText(d=>d.setPlaceholder(i.freecad).setValue(this.plugin.getSettings().freecadcmdCommand).onChange(h=>{this.plugin.updateSettings({freecadcmdCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.obj2gltfCmd")).setDesc(Z("settings.obj2gltfCmd.desc")).addText(d=>d.setPlaceholder(i.obj2gltf).setValue(this.plugin.getSettings().obj2gltfCommand).onChange(h=>{this.plugin.updateSettings({obj2gltfCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.fbx2gltfCmd")).setDesc(Z("settings.fbx2gltfCmd.desc")).addText(d=>d.setPlaceholder(i.fbx2gltf).setValue(this.plugin.getSettings().fbx2gltfCommand).onChange(h=>{this.plugin.updateSettings({fbx2gltfCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.assimpCmd")).setDesc(Z("settings.assimpCmd.desc")).addText(d=>d.setPlaceholder(i.python).setValue(this.plugin.getSettings().assimpCommand).onChange(h=>{this.plugin.updateSettings({assimpCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.diagnostics")).setDesc(Z("settings.diagnostics.desc")).addButton(d=>d.setButtonText(Z("settings.diagnostics.checkNow")).onClick(async()=>{d.setDisabled(!0),d.setButtonText(Z("settings.diagnostics.checking")),s&&await this.renderCommandDiagnostics(s),d.setButtonText(Z("settings.diagnostics.checkNow")),d.setDisabled(!1),new Et.Notice(Z("settings.diagnostics.refreshed"))})),s=c.createDiv({cls:"ai3d-settings-diagnostics"}),o()}new Et.Setting(t).setName(Z("settings.performance")).setHeading(),new Et.Setting(t).setName(Z("settings.canvasHeight")).setDesc(Z("settings.canvasHeight.desc")).addSlider(l=>l.setLimits(200,800,25).setValue(this.plugin.getSettings().defaultCanvasHeight).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({defaultCanvasHeight:c})})),new Et.Setting(t).setName(Z("settings.autoRotateSpeed")).setDesc(Z("settings.autoRotateSpeed.desc")).addSlider(l=>l.setLimits(.1,2,.1).setValue(this.plugin.getSettings().autoRotateSpeed).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({autoRotateSpeed:c})})),new Et.Setting(t).setName(Z("settings.renderQuality")).setDesc(Z("settings.renderQuality.desc")).addDropdown(l=>l.addOption("low","Low").addOption("medium","Medium").addOption("high","High").setValue(this.plugin.getSettings().renderQuality).onChange(c=>{this.plugin.updateSettings({renderQuality:c})})),new Et.Setting(t).setName(Z("settings.renderScale")).setDesc(Z("settings.renderScale.desc")).addSlider(l=>l.setLimits(.25,2,.25).setValue(this.plugin.getSettings().renderScale).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({renderScale:c})}))}async renderCommandDiagnostics(t){let i=++this.diagnosticsRunId;t.empty(),t.createEl("p",{text:Z("settings.diagnostics.checkingAvailability")});let r=await Tp(this.plugin.getSettings());if(i===this.diagnosticsRunId){t.empty();for(let s of r)this.renderCommandStatus(t,s)}}renderCommandStatus(t,i){var a;let r=t.createDiv({cls:"ai3d-settings-status-block"});r.createEl("strong",{text:`${i.label}: ${i.available?Z("settings.diagnostics.available"):Z("settings.diagnostics.notFound")}`});let s=[`${Z("settings.diagnostics.sourceLabel")}: ${vp(i.source)}`,`${Z("settings.diagnostics.commandLabel")}: ${i.command}`,i.resolvedPath&&i.resolvedPath!==i.command?`${Z("settings.diagnostics.resolvedPathLabel")}: ${i.resolvedPath}`:"",i.detail].filter(Boolean);for(let o of s)r.createDiv({text:o});for(let o of(a=i.dependencyChecks)!=null?a:[])this.renderDependencyCheck(r,o)}renderDependencyCheck(t,i){let r=(()=>{switch(i.kind){case"cad-python":return Z("settings.diagnostics.cadPythonCheck");case"mesh-python":return Z("settings.diagnostics.meshPythonCheck");case"freecadcmd-cli":return Z("settings.diagnostics.freecadCmdCheck");case"obj2gltf-cli":return Z("settings.diagnostics.obj2gltfCheck");case"fbx2gltf-cli":return Z("settings.diagnostics.fbx2gltfCheck")}})(),s=i.ok?Z("settings.diagnostics.selfCheckOk"):Z("settings.diagnostics.selfCheckFailed");t.createDiv({text:`${Z("settings.diagnostics.selfCheckLabel")}: ${r} - ${s}`}),i.detail&&t.createDiv({text:i.detail})}};Qa();Mr();Jr();Pc();jr();Js();var wp=class extends jo.Plugin{getSettings(){return this.ps.store.getState().settings}updateSettings(e){let i={...this.ps.store.getState().settings,...e};this.ps.store.setState({settings:i}),xA(i.logLevel),cd(i.locale)}async onload(){var l;if(this.ps=gR(this),await this.ps.load(),this.convertedAssetCache=mR(this.ps.store.getState().convertedAssetRecords,c=>this.ps.store.setState({convertedAssetRecords:c})),xA(this.getSettings().logLevel),!this.ps.localeLoadedFromSaved){let f=((l=navigator.language)!=null?l:"en").startsWith("zh")?"zh-CN":"en";this.updateSettings({locale:f})}cd(this.getSettings().locale),this.registerView(Td,c=>new yp(c,this.ps,this.convertedAssetCache)),this.addRibbonIcon("box",Z("main.ribbonOpenWorkbench"),()=>this.activateView()),this.addCommand({id:"import-model",name:Z("main.commandImportModel"),callback:()=>this.importModel()}),this.addCommand({id:"open-workbench",name:Z("main.commandOpenWorkbench"),callback:()=>this.activateView()}),this.addCommand({id:"generate-note",name:Z("main.commandGenerateNote"),callback:()=>this.generateNote()}),this.addCommand({id:"clear-conversion-cache",name:Z("main.commandClearConversionCache"),callback:()=>this.clearConversionCache()}),this.addCommand({id:"check-converters",name:Z("main.commandCheckConverters"),callback:()=>void this.checkConverterCommands()}),this.addSettingTab(new Np(this.app,this)),this.registerView(Pp,c=>new Lp(c,()=>this.getSettings(),this.convertedAssetCache,this.ps)),this.registerExtensions(to(),Pp);let{registerCodeBlockProcessor:e,registerGridCodeBlockProcessor:t}=await Promise.resolve().then(()=>(O2(),P2)),i=c=>{var f,d;return(d=(f=this.ps.store.getState().modelAssetProfiles[c])==null?void 0:f.annotations)!=null?d:[]},r=e(this.app,()=>this.getSettings(),this.convertedAssetCache,i);this.registerMarkdownCodeBlockProcessor(r.id,r.handler);let s=t(this.app,()=>this.getSettings(),this.convertedAssetCache);this.registerMarkdownCodeBlockProcessor(s.id,s.handler);let{registerLivePreviewExtension:a}=await Promise.resolve().then(()=>(U2(),B2)),o=a(this.app,()=>this.getSettings(),this.convertedAssetCache,i);for(let c of o)this.registerEditorExtension(c);this.setupHeadingPinObserver()}onunload(){this.ps.dispose()}setupHeadingPinObserver(){let e=".markdown-preview-view, .markdown-source-view",t=[".markdown-preview-view h1",".markdown-preview-view h2",".markdown-preview-view h3",".markdown-preview-view h4",".markdown-preview-view h5",".markdown-preview-view h6",".cm-heading-1",".cm-heading-2",".cm-heading-3",".cm-heading-4",".cm-heading-5",".cm-heading-6",".cm-header-1",".cm-header-2",".cm-header-3",".cm-header-4",".cm-header-5",".cm-header-6"].join(", "),i=new Map,r=y=>{if(y.length===0)return"var(--interactive-accent)";if(y.length===1)return y[0];let B=100/y.length;return`linear-gradient(135deg, ${y.map((w,H)=>{let O=Math.round(H*B),V=Math.round((H+1)*B);return`${w} ${O}% ${V}%`}).join(", ")})`},s=()=>{let y=new Map,B=this.ps.store.getState().modelAssetProfiles;for(let[w,H]of Object.entries(B))for(let O of H.annotations)if(O.headingRef&&O.id){let V=gd(O.headingRef);if(!V)continue;let X=y.get(V);X||(X=[],y.set(V,X)),X.push({pinId:O.id,modelPath:w,color:O.color})}return y},a=y=>y.map(B=>`${B.pinId}:${B.modelPath}:${B.color}`).sort().join("|"),o=y=>Array.from(y.entries()).map(([B,w])=>`${B}=>${a(w)}`).sort().join("||"),l=y=>gd(Array.from(y.childNodes).map(B=>{var w;return B.instanceOf(Element)&&B.classList.contains("ai3d-heading-pin-badge")?"":(w=B.textContent)!=null?w:""}).join(" ")),c=y=>{let B=i.get(y);B&&(y.removeEventListener("mouseover",B.handler),B.badge.remove(),delete y.dataset.pinBound,i.delete(y))},f=(y,B)=>{if(B.length===0){c(y);return}let w=a(B),H=i.get(y);if((H==null?void 0:H.signature)===w)return;H&&c(y),y.dataset.pinBound=w;let O=y.createSpan({cls:"ai3d-heading-pin-badge"}),V=[...new Set(B.map(q=>q.color).filter(Boolean))],X=O.createSpan({cls:"ai3d-heading-pin-badge-swatch"});if(X.style.background=r(V),X.title=B.length>1?Z("headingPin.showMultiple"):Z("headingPin.showSingle"),X.setAttribute("role","button"),X.setAttribute("tabindex","0"),B.length>1){let q=O.createSpan({cls:"ai3d-heading-pin-badge-count"});q.textContent=`\xD7${B.length}`}let j=[...new Set(B.map(q=>Cr(q.modelPath)))];O.title=Jt("headingPin.linkedTo",{models:j.join(", ")});let Q=q=>{q==null||q.stopPropagation(),q==null||q.preventDefault();for(let z of B)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:z.pinId}}))};X.addEventListener("click",q=>{Q(q)}),X.addEventListener("keydown",q=>{q.instanceOf(KeyboardEvent)&&(q.key!=="Enter"&&q.key!==" "||Q(q))}),O.addEventListener("click",q=>{q.stopPropagation()}),y.appendChild(O);let $=()=>{for(let q of B)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:q.pinId}}))};y.addEventListener("mouseover",$),i.set(y,{badge:O,handler:$,signature:w})},d=(y,B)=>{var H;let w=l(y);f(y,(H=B.get(w))!=null?H:[])},h=y=>{var B;for(let[w,H]of Array.from(i.entries())){if(!w.isConnected){c(w);continue}let O=(B=y.get(l(w)))!=null?B:[],V=a(O);(O.length===0||H.signature!==V)&&f(w,O)}},u=(y,B)=>{y.querySelectorAll(t).forEach(w=>d(w,B))},m=()=>{let y=s();h(y),activeDocument.querySelectorAll(e).forEach(w=>u(w,y))},p=o(s()),_=0,g=(y=0)=>{_&&window.clearTimeout(_),_=window.setTimeout(()=>{_=0,m()},y)},T=this.ps.store.subscribe(()=>{let y=s(),B=o(y);B!==p&&(p=B,g())});this.registerEvent(this.app.workspace.on("layout-change",()=>{g(200)}));let b=y=>y.matches(e)||y.matches(t)?!0:!!y.querySelector(e)||!!y.querySelector(t),R=y=>y.isConnected&&b(y),S=y=>b(y),I=new Set,x=0,P=()=>{var w,H,O,V,X,j;let y=Array.from(I);I.clear(),x=0;let B=s();h(B);for(let Q of y)Q.isConnected&&((w=Q.matches)!=null&&w.call(Q,t)&&d(Q,B),(O=(H=Q.querySelectorAll)==null?void 0:H.call(Q,t))==null||O.forEach($=>d($,B)),(V=Q.matches)!=null&&V.call(Q,e)&&u(Q,B),(j=(X=Q.querySelectorAll)==null?void 0:X.call(Q,e))==null||j.forEach($=>u($,B)));p=o(B)},L=new MutationObserver(y=>{let B=!1;for(let w of y){for(let H of Array.from(w.addedNodes))H.instanceOf(HTMLElement)&&R(H)&&(I.add(H),B=!0);for(let H of Array.from(w.removedNodes))H.instanceOf(HTMLElement)&&S(H)&&(B=!0)}B&&!x&&(x=window.setTimeout(P,100))});L.observe(activeDocument.body,{childList:!0,subtree:!0}),this.register(()=>{T(),L.disconnect(),x&&(window.clearTimeout(x),x=0),_&&(window.clearTimeout(_),_=0);for(let y of Array.from(i.keys()))c(y)}),g(500)}async activateView(){let{workspace:e}=this.app,t=null;if(e.iterateAllLeaves(i=>{i.getViewState().type===Td&&(t=i)}),!t){if(t=e.getRightLeaf(!1),!t)return;await t.setViewState({type:Td,active:!0})}e.setActiveLeaf(t,{focus:!0})}importModel(){new Op(this.app,e=>{let t=e.extension.toLowerCase();es(t)&&(this.ps.store.getState().currentModelPath===e.path&&this.ps.store.setState({currentModelPath:null,modelPreview:null}),this.ps.store.setState({currentModelPath:e.path,modelPreview:null}),this.activateView())}).open()}async generateNote(){let{generateKnowledgeNote:e}=await Promise.resolve().then(()=>(wA(),c2));await e(this.app,this.ps.store.getState())}clearConversionCache(){this.convertedAssetCache.clear(),new jo.Notice("AI 3d conversion cache cleared.")}async checkConverterCommands(){if(Qt()){new jo.Notice(Z("main.converterDiagnosticsMobileUnavailable"),8e3);return}let e=await Tp(this.getSettings()),t=e.filter(r=>r.available).map(r=>r.label),i=e.filter(r=>!r.available).map(r=>r.label);if(i.length===0){new jo.Notice(`AI 3D converter diagnostics: all commands available (${t.join(", ")}).`,8e3);return}new jo.Notice(`AI 3D converter diagnostics: available ${t.join(", ")||"none"}; missing ${i.join(", ")}.`,1e4)}}; +`)}var Nc,Oc,Td,HA=A(()=>{"use strict";Nc=require("obsidian");CR();cd();hd();Is();cu();c2();md();_d();Dp();Dr();Js();gd();Pc();Xo();en();vd();qr();Oc=ti("workbench");Td=null});function ki(n){let e=createSvg("svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","16"),e.setAttribute("height","16");let t=new DOMParser().parseFromString(`${n}`,"image/svg+xml");for(let i of Array.from(t.documentElement.childNodes))e.appendChild(activeDocument.importNode(i,!0));return e}function D2(n){var a,o;let[e,t]=n.split(","),i=(o=(a=e.match(/:(.*?);/))==null?void 0:a[1])!=null?o:"image/png",r=atob(t),s=new Uint8Array(r.length);for(let l=0;l(f&&J.classList.add("is-secondary"),J),m=!1,p=!1,_=f?h.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-mode-btn",attr:{"aria-label":Z("helper.enableInteractionLabel")}}):null;_==null||_.appendChild(ki(''));let g=(K=_==null?void 0:_.createSpan({cls:"ai3d-mobile-mode-btn-label"}))!=null?K:null,T=()=>{!f||!_||(L2(e,m),_.classList.toggle("ai3d-btn-active",m),g==null||g.setText(m?Z("helper.scrollAction"):Z("helper.interactAction")),_.setAttribute("aria-label",m?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel")),z==null||z.classList.toggle("ai3d-btn-active",p),h.classList.toggle("show-secondary",p))},b=J=>{m=J,T()};_==null||_.addEventListener("click",()=>{let J=!m;l==null||l(J),b(J),jt(_,J?Z("helper.interactionOn"):Z("helper.interactionOff"))});let R=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.resetViewLabel")}});R.appendChild(ki('')),R.addEventListener("click",()=>{let J=i();J!=null&&J.resetView&&(J.resetView(),jt(R,Z("helper.resetViewDone")))});let S=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.copyModelInfoLabel")}}));S.appendChild(ki('')),S.addEventListener("click",()=>{let J=i();if(J!=null&&J.exportModelInfo)try{let te=J.exportModelInfo(r());if(!te)return;navigator.clipboard.writeText(te).then(()=>{jt(S,Z("helper.copied"))}).catch(()=>{jt(S,Z("helper.failed"))})}catch(te){console.error("[AI3D] Export model info failed:",te),jt(S,Z("helper.failed"))}});let I=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleWireframeLabel")}});I.appendChild(ki('')),I.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleWireframe))return;let te=J.toggleWireframe();I.classList.toggle("ai3d-btn-active",te),jt(I,te?Z("helper.wireframeOn"):Z("helper.wireframeOff"))});let x=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleAxesLabel")}}));x.appendChild(ki('')),x.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleOrientationGizmo))return;let te=J.toggleOrientationGizmo();x.classList.toggle("ai3d-btn-active",te),jt(x,te?Z("helper.axesOn"):Z("helper.axesOff"))});let P=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleBoundingBoxLabel")}}));P.appendChild(ki('')),P.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleBoundingBox))return;let te=J.toggleBoundingBox();P.classList.toggle("ai3d-btn-active",te),jt(P,te?Z("helper.boundingBoxOn"):Z("helper.boundingBoxOff"))});let L=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.toggleDisassemblyLabel")}}));L.appendChild(ki('')),L.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleDisassembly))return;let te=J.toggleDisassembly();L.classList.toggle("ai3d-btn-active",te),jt(L,te?Z("helper.disassemblyOn"):Z("helper.disassemblyOff"))});let y=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.resetPartsLabel")}}));y.appendChild(ki('')),y.addEventListener("click",()=>{let J=i();J!=null&&J.resetDisassembly&&(J.resetDisassembly(),jt(y,Z("helper.partsReset")))});let B=[.5,.75,1,1.5,2],w=2,H=u(h.createEl("button",{cls:"ai3d-inline-btn ai3d-res-btn",attr:{"aria-label":Z("helper.changeResolutionLabel")}}));H.textContent="1.0x",H.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.setRenderScale))return;w=(w+1)%B.length;let te=J.setRenderScale(B[w]);H.textContent=`${te}x`,jt(H,Jt("helper.resolutionValue",{value:`${te}x`}))});let O=u(h.createEl("button",{cls:"ai3d-inline-btn is-hidden",attr:{"aria-label":Z("helper.toggleAnimationLabel")}}));O.appendChild(ki('')),O.addEventListener("click",()=>{let J=i();if(!(J!=null&&J.toggleAnimation))return;let te=J.toggleAnimation();O.replaceChildren(ki(te?'':'')),jt(O,te?Z("helper.playing"):Z("helper.paused"))});let k=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.removePreviewLabel")}});k.appendChild(ki('')),k.addEventListener("click",s);let X=h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.copySnapshotLabel")}});X.appendChild(ki('')),X.addEventListener("click",()=>{let J=i();if(J)try{let te=J.captureSnapshot();if(!te)return;let Pe=D2(te);navigator.clipboard.write([new ClipboardItem({"image/png":Pe})]).then(()=>{jt(X,Z("helper.copied"))}).catch(()=>{jt(X,Z("helper.failed"))})}catch(te){console.error("[AI3D] Copy snapshot failed:",te),jt(X,Z("helper.failed"))}});let j=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.saveSnapshotLabel")}}));j.appendChild(ki('')),j.addEventListener("click",()=>{var te,Pe;let J=i();if(J)try{let ge=J.captureSnapshot();if(!ge)return;let me=r(),se=Mr(me)||"model",le=a==null?void 0:a(),xe=(te=le==null?void 0:le.snapshotFolder)!=null?te:"Media/3D Previews",ce=(Pe=le==null?void 0:le.snapshotNaming)!=null?Pe:"model-name",he=Date.now(),ke=ce==="timestamp"?`snapshot_${he}.png`:`${se}_snapshot_${he}.png`,$e=D2(ge),Fe=new FileReader;Fe.onload=()=>{let Xe=Fe.result;t.vault.adapter.exists(xe).then(xt=>xt?Promise.resolve():t.vault.createFolder(xe).catch(()=>{})).then(()=>t.vault.createBinary(`${xe}/${ke}`,Xe)).then(()=>{jt(j,Z("helper.saved"))}).catch(xt=>{console.error("[AI3D] Save snapshot failed:",xt),jt(j,Z("helper.failed"))})},Fe.onerror=()=>{console.error("[AI3D] FileReader error"),jt(j,Z("helper.failed"))},Fe.onabort=()=>{console.error("[AI3D] FileReader aborted"),jt(j,Z("helper.failed"))},Fe.readAsArrayBuffer($e)}catch(ge){console.error("[AI3D] Save snapshot failed:",ge),jt(j,Z("helper.failed"))}});let Q=u(h.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":Z("helper.downloadSnapshotLabel")}}));Q.appendChild(ki('')),Q.addEventListener("click",()=>{let J=i();if(J)try{let te=J.captureSnapshot();if(!te)return;let Pe=r(),me=`${Mr(Pe)||"model"}_snapshot_${Date.now()}.png`,se=createEl("a");se.href=te,se.download=me,activeDocument.body.appendChild(se),se.click(),se.remove(),jt(Q,Z("helper.downloaded"))}catch(te){console.error("[AI3D] Download snapshot failed:",te),jt(Q,Z("helper.failed"))}});let $=u(h.createEl("button",{cls:"ai3d-inline-btn is-hidden ai3d-annot-btn",attr:{"aria-label":Z(d.labelKey)}}));$.appendChild(ki(''));let q=$.createSpan({cls:"ai3d-pin-badge is-hidden"});$.addEventListener("click",()=>{if(!o)return;let J=o();$.classList.toggle("ai3d-btn-active",J),jt($,J?Z(d.activeTooltipKey):Z(d.inactiveTooltipKey))});let z=f?h.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-more-toggle",attr:{"aria-label":Z("helper.showMoreActionsLabel")}}):null;return z==null||z.appendChild(ki('')),z==null||z.addEventListener("click",()=>{p=!p,z.setAttribute("aria-label",p?Z("helper.hideMoreActionsLabel"):Z("helper.showMoreActionsLabel")),T(),jt(z,p?Z("helper.moreActionsShown"):Z("helper.moreActionsHidden"))}),n.insertBefore(h,e.nextSibling),T(),{showAnimButton(){O.classList.remove("is-hidden")},showAnnotateButton(){$.classList.remove("is-hidden")},updateAnnotationBadge(J){J>0?(q.textContent=String(J),q.classList.remove("is-hidden")):q.classList.add("is-hidden")},setMobileInteractionMode(J){f&&b(J)}}}function jt(n,e){var r;(r=zA.get(n))==null||r.remove();let t=n.parentElement;if(!t)return;let i=t.createDiv({cls:"ai3d-tooltip"});i.textContent=e,zA.set(n,i),window.setTimeout(()=>{i.remove(),zA.delete(n)},1500)}var zA,XA=A(()=>{"use strict";en();qr();Js();zA=new WeakMap});function Ko(n){let e=n.createDiv({cls:"ai3d-loading-overlay"}),t=e.createDiv({cls:"ai3d-loading-skeleton"});t.createDiv({cls:"ai3d-loading-skeleton-canvas"});let i=t.createDiv({cls:"ai3d-loading-skeleton-meta"});i.createDiv({cls:"ai3d-loading-skeleton-line"}),i.createDiv({cls:"ai3d-loading-skeleton-line is-short"}),e.createDiv({cls:"ai3d-loading-spinner"});let r=e.createDiv({cls:"ai3d-loading-text"}),s="loading.default",a="",o=()=>{r.textContent=s?Z(s):a};o();let c=e.createDiv({cls:"ai3d-loading-bar-track"}).createDiv({cls:"ai3d-loading-bar-fill is-indeterminate"}),f=!1,d=t2(()=>{!f&&s&&o()});return{el:e,setPhase(h){s=null,a=h,f||o()},setPhaseKey(h){s=h,f||o()},setProgress(h){f||(h<0?(c.className="ai3d-loading-bar-fill is-indeterminate",c.style.removeProperty("--bar-width")):(c.className="ai3d-loading-bar-fill",c.style.setProperty("--bar-width",`${Math.min(100,Math.max(0,h))}%`)))},hide(){f||(f=!0,d(),e.classList.add("is-hiding"),window.setTimeout(()=>e.remove(),300))}}}var Op=A(()=>{"use strict";en()});function h6(n){return n.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}function N2(n,e=[]){let t=[n,...e,...n.getChildMeshes(!0)],i=new Set;return t.filter(r=>!r||i.has(r)||r.isDisposed()?!1:(i.add(r),r.getTotalVertices()>0||r.getTotalIndices()>0))}var Fc,Up,F2=A(()=>{"use strict";$g();sr();hu();uu();ve();et();dl();hc();Xs();rd();rd();aA();qr();Fc=32;Up=class{constructor(e){this.cells=[];this.initialCameras=[];this.wireframeEnabled=!1;this.rendering=!1;this.preventCanvasWheelScroll=e=>{e.preventDefault(),e.stopPropagation()};e.className="ai3d-canvas-full",e.addEventListener("wheel",this.preventCanvasWheelScroll,{passive:!1}),this.engine=new Ee(e,!0,{preserveDrawingBuffer:!0}),this.scene=new st(this.engine),this.scene.clearColor=new Ne(.12,.12,.14,1),this.scene.autoClear=!1,new Rr("default-light",new v(0,1,.5),this.scene),this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),window.requestAnimationFrame(()=>this.engine.resize())}canRender(){let e=this.engine.getRenderingCanvas();return!!(e!=null&&e.isConnected)&&e.clientWidth>0&&e.clientHeight>0}async loadModels(e,t,i){var d,h,u;await id();let r=e.length>Fc?(console.warn(`[AI3D Grid] Capping ${e.length} models to ${Fc} (layerMask limit)`),e.slice(0,Fc)):e,s=(d=t.columns)!=null?d:Math.min(r.length,3),a=(h=t.gapX)!=null?h:.02,o=(u=t.gapY)!=null?u:.02,l=Math.ceil(r.length/s),c=(1-a*(s+1))/s,f=(1-o*(l+1))/l;for(let m=0;mFc?(console.warn(`[AI3D Preset] Capping ${e.placements.length} placements to ${Fc} (layerMask limit)`),e.placements.slice(0,Fc)):e.placements,r=[];for(let c=0;cc.length>0).map(c=>c[0]),a=v.Zero(),o=1;if(s.length>0){let c=new v(1/0,1/0,1/0),f=new v(-1/0,-1/0,-1/0);for(let h of s){h.computeWorldMatrix(!0);let u=h.getHierarchyBoundingVectors();c=v.Minimize(c,u.min),f=v.Maximize(f,u.max)}let d=f.subtract(c);a=c.add(d.scale(.5)),o=d.length()/2}let l=e.cells.length===1;for(let c of e.cells){let f=r[c.modelIndex];if(!f||f.length===0)continue;let d,h;if(l){d=[],h=0;for(let m=0;m0&&(d.push(...r[m]),h|=1<_!==c),h=1<this.renderFrame()))}captureSnapshot(){let e=this.engine.getRenderingCanvas();return e?(this.renderFrame(),e.toDataURL("image/png")):null}getEngine(){return this.engine}getScene(){return this.scene}getCellCount(){return this.cells.length}getCanvas(){return this.engine.getRenderingCanvas()}getPrimaryCamera(){var e,t;return(t=(e=this.cells[0])==null?void 0:e.camera)!=null?t:null}setRenderScale(e){let t=Math.max(.25,Math.min(e,2)),i=Qt()?1.5:1;return this.engine.setHardwareScalingLevel(i/t),t}resetView(){for(let e=0;e({path:i.path,position:[-t/2+r*e,0,0],color:i.color,wireframe:i.wireframe}))}function ZA(n,e){return n.map((t,i)=>{let r=2*Math.PI*i/n.length;return{path:t.path,position:[Math.cos(r)*e,0,Math.sin(r)*e],color:t.color,wireframe:t.wireframe}})}var KA,jo=A(()=>{"use strict";KA={iso:{alpha:Math.PI/4,beta:Math.PI/3},front:{alpha:0,beta:Math.PI/2},side:{alpha:Math.PI/2,beta:Math.PI/2},top:{alpha:0,beta:.01},back:{alpha:Math.PI,beta:Math.PI/2},"3/4":{alpha:Math.PI/6,beta:Math.PI/3.5}}});var w2,B2=A(()=>{"use strict";jo();w2={name:"compare",description:"Side-by-side model comparison (2-4 models)",minModels:2,maxModels:4,compute(n,e){if(n.length<2||n.length>4)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=Rd(n,t),s=n.length<=3?n.length:2,a=Math.ceil(n.length/s),o=es(s,a),l=n.map((c,f)=>({modelIndex:f,camera:In(i),viewport:o[f]}));return{placements:r,cells:l}}}});var U2,V2=A(()=>{"use strict";jo();U2={name:"showcase",description:"Single model viewed from multiple angles",minModels:1,maxModels:1,compute(n,e){if(n.length<1)return null;let t=Number(e.angles)||4,i=Number(e.radius)||2.5,r=[{path:n[0].path,position:[0,0,0],color:n[0].color,wireframe:n[0].wireframe}],s=t>=6?["front","side","top","back","iso","3/4"]:["iso","front","side","top"],a=s.length<=4?2:3,o=Math.ceil(s.length/a),l=es(a,o),c=s.map((f,d)=>({modelIndex:0,camera:In(f,void 0,i),viewport:l[d]}));return{placements:r,cells:c}}}});var G2,k2=A(()=>{"use strict";jo();G2={name:"explode",description:"Spatial arrangement of parts (3-8 models in a ring)",minModels:3,maxModels:8,compute(n,e){if(n.length<3||n.length>8)return null;let t=Number(e.radius)||8,i=e.angle||"iso",r=ZA(n,t),s=Math.min(n.length,4),a=Math.ceil(n.length/s),o=es(s,a),l=n.map((c,f)=>({modelIndex:f,camera:In(i),viewport:o[f]}));return{placements:r,cells:l}}}});var W2,H2=A(()=>{"use strict";jo();W2={name:"timeline",description:"Horizontal progression of models (2-6 models in a strip)",minModels:2,maxModels:6,compute(n,e){if(n.length<2||n.length>6)return null;let t=Number(e.spacing)||6,i=e.angle||"3/4",r=Rd(n,t),s=jA(n.length),a=n.map((o,l)=>({modelIndex:l,camera:In(i),viewport:s[l]}));return{placements:r,cells:a}}}});function qA(n,e,t,i,r){var f,d;if(!n||n.length===0)return null;let s=n.reduce((h,u)=>{var m;return h+((m=u.weight)!=null?m:1)},0);if(s<=0)return null;let a=[],o=0;for(let h of n){let m=((f=h.weight)!=null?f:1)/s*(1-t*(n.length+1));e==="horizontal"?a.push({x:t+o,y:t,w:m,h:1-2*t}):a.push({x:t,y:t+o,w:1-2*t,h:m}),o+=m+t}let l=[],c=[];for(let h=0;h{"use strict";z2={name:"compose",description:"Combine multiple presets into one layout",minModels:1,maxModels:32,compute(n,e,t){return null}}});var X2,Y2=A(()=>{"use strict";jo();X2={name:"gallery",description:"All models in one scene, single camera (no cell limit)",minModels:1,maxModels:32,compute(n,e){if(n.length===0)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=Number(e.cols)||0,s=r>0?r:Math.ceil(Math.sqrt(n.length)),a=Math.ceil(n.length/s),o=n.map((f,d)=>{let h=d%s,u=Math.floor(d/s),m=(h-(s-1)/2)*t,p=(u-(a-1)/2)*t;return{path:f.path,position:[m,0,p],color:f.color,wireframe:f.wireframe}}),l=es(1,1,0),c=[{modelIndex:0,camera:In(i,void 0,3+Math.max(s,a)*.5),viewport:l[0]}];return{placements:o,cells:c}}}});function wc(n){K2.set(n.name,n)}function JA(n){return K2.get(n)}var K2,j2=A(()=>{"use strict";B2();V2();k2();H2();QA();Y2();jo();QA();K2=new Map;wc(w2);wc(U2);wc(G2);wc(W2);wc(z2);wc(X2)});var Q2={};De(Q2,{registerCodeBlockProcessor:()=>p6,registerGridCodeBlockProcessor:()=>g6});async function Z2(n,e,t,i){var d,h,u;let r=typeof e=="string"?{path:e}:e,s=Mc(n,r.path);if(!s)throw new Error(Jt("workbench.fileNotFound",{path:r.path}));let a=(h=(d=s.split(".").pop())==null?void 0:d.toLowerCase())!=null?h:"";if(!ts(a))throw new Error(Jt("codeBlock.unsupportedFormat",{ext:`.${a}`,formats:to().join(", ")}));let o=(u=Qs(n,s))!=null?u:void 0,l=ra(t),c=await ta({path:s,absolutePath:o,preferConversionExts:na(t),conversionManager:l,convertedAssetCache:i}),f=Yo(c);return{sourcePath:s,effectivePath:f.path,effectiveExt:f.ext,warnings:f.warnings,model:{...r,path:f.path}}}async function m6(n,e,t,i){let r=[];for(let s of e.models){let a=await Z2(n,s,t,i);r.push(a.model)}return{...e,models:r}}function q2(n){Qt()&&n.createDiv({cls:"ai3d-mobile-mode-hint ai3d-mobile-mode-hint--inline",text:Z("codeBlock.mobileHint")})}function p6(n,e,t,i){return{id:"3d",handler:(r,s,a)=>{var L,y;let o=r.trim();if(!o){s.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelPathOrConfig")});return}let l;if(o.startsWith("{")||o.startsWith("["))try{let B=JSON.parse(o);l=_6(B)}catch(B){let w=s.createDiv({cls:"ai3d-json-error"}),H=String(B).match(/position\s+(\d+)/),O=Jt("codeBlock.jsonParseError",{error:String(B)});if(H){let k=parseInt(H[1],10),X=o.substring(0,k).split(` +`);O+=Jt("codeBlock.jsonParseLine",{line:String(X.length)})}w.createEl("pre",{text:O});return}else l={models:[{path:o}]};if(!l.models||l.models.length===0){s.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelsInConfig")});return}l.models.length>1&&console.warn(`[AI3D] \`\`\`3d only supports one model; ${l.models.length-1} additional models ignored. Use \`\`\`3dgrid for multi-model.`);let f=l.models[0],d=Mc(n,f.path);if(!d){s.createDiv({cls:"ai3d-inline-empty",text:Jt("workbench.fileNotFound",{path:f.path})});return}let h=(y=(L=d.split(".").pop())==null?void 0:L.toLowerCase())!=null?y:"";if(!ts(h)){s.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.unsupportedFormat",{ext:`.${h}`,formats:to().join(", ")})});return}let u=e(),m=s.createDiv({cls:"ai3d-preview-host"});l.height&&m.style.setProperty("--min-height",typeof l.height=="number"?`${l.height}px`:l.height),l.width&&m.style.setProperty("--max-width",typeof l.width=="number"?`${l.width}px`:l.width);let p=m.createEl("canvas",{cls:"ai3d-canvas-full"});p.tabIndex=0,p.addEventListener("keydown",B=>{var H,O,k,X,j;if(b||!_)return;let w=B.key.toLowerCase();w==="r"?((H=_.resetView)==null||H.call(_),B.preventDefault()):w==="w"?((O=_.toggleWireframe)==null||O.call(_),B.preventDefault()):w==="g"?((k=_.toggleOrientationGizmo)==null||k.call(_),B.preventDefault()):w==="b"?((X=_.toggleBoundingBox)==null||X.call(_),B.preventDefault()):w===" "&&((j=_.toggleAnimation)==null||j.call(_),B.preventDefault())}),m.appendChild(p);let _=null,g=null,T=!0,b=!1,R=!1,S=Ad(s,m,n,()=>_,()=>d,()=>{b||(b=!0,I.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null,m.remove())},e,()=>{if(T=!T,g){let B=m.querySelector(".ai3d-annotation-overlay");B&&B.classList.toggle("is-hidden",!T)}return T},void 0,{labelKey:"helper.toggleAnnotationsVisibilityLabel",activeTooltipKey:"helper.annotationsVisible",inactiveTooltipKey:"helper.annotationsHidden"});q2(s);let I=new MutationObserver(()=>{b||s.contains(m)||(b=!0,I.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null)});I.observe(s,{childList:!0});async function x(){var w,H;if(R||b||!d)return;R=!0;let B=Ko(m);try{let O=(w=Qs(n,d))!=null?w:void 0,k=ra(u);B.setPhaseKey("loading.preparingModel");let X=await ta({path:d,absolutePath:O,preferConversionExts:na(u),conversionManager:k,convertedAssetCache:t}),j=Yo(X);_=new $s(p),B.setPhaseKey("loading.loadingModel");let Q=await yr(n,j.path),$=async q=>yr(n,q);if(b){B.hide();return}if(await _.loadModel(Q,j.ext,$,j.path),B.setProgress(100),b){B.hide();return}if(((H=l.scene)==null?void 0:H.autoRotate)===void 0&&u.autoRotateDefault&&(l.scene={...l.scene,autoRotate:!0,autoRotateSpeed:u.autoRotateSpeed}),_.applyConfig(l),_.setRenderQuality(u.renderQuality,u.renderScale),i&&d){let q=i(d);if(q.length>0){let z=_.getCanvas();z&&(g=new $n({scene:_.getScene(),camera:_.getCamera(),engine:_.getEngine(),canvas:z},m,"readonly",q,void 0,Ja(n),void 0,{app:n,previewMode:u.annotationPreviewMode}),S.showAnnotateButton(),S.updateAnnotationBadge(q.length))}}h==="stl"&&f.color&&_.setSTLColor(f.color),h==="stl"&&f.wireframe!==void 0&&_.setWireframe(f.wireframe),_.hasAnimations()&&S.showAnimButton(),B.hide()}catch(O){b=!0,I.disconnect(),P.disconnect(),B.hide(),_==null||_.destroy(),_=null,m.replaceChildren();let k=qa(O);Za(O)?console.warn("[AI3D] Inline preview blocked by converter settings:",k.message):console.error("[AI3D] Inline preview failed:",O),$a(m,k)}}let P=new IntersectionObserver(B=>{for(let w of B)w.isIntersecting&&(P.disconnect(),x())},{rootMargin:"200px"});P.observe(m)}}}function _6(n){if(typeof n=="string")return{models:[{path:n}]};if(typeof n!="object"||n===null)return{models:[]};let e=n;return typeof e.path=="string"?{models:[{path:e.path,color:e.color,wireframe:e.wireframe}],camera:e.camera,lights:e.lights,scene:e.scene,stl:e.stl,width:e.width,height:e.height}:{models:Array.isArray(e.models)?e.models.filter(i=>{let r=typeof i=="string"?i:i&&typeof i=="object"&&"path"in i?i.path:void 0;return typeof r=="string"&&r.length>0}).map(i=>{if(typeof i=="string")return{path:i};let r=i;return{path:r.path,color:r.color,wireframe:r.wireframe}}):[],camera:e.camera,lights:e.lights,scene:e.scene,stl:e.stl,width:e.width,height:e.height}}function g6(n,e,t){return{id:"3dgrid",handler:(i,r,s)=>{let a=i.trim();if(!a){r.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noConfigSpecified")});return}let o;try{o=JSON.parse(a)}catch(f){r.createDiv({cls:"ai3d-json-error"}).createEl("pre",{text:`JSON parse error: ${String(f)}`});return}if(o.preset!=="compose"&&(!o.models||o.models.length===0)){r.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.noModelsSpecified")});return}let l=e(),c=Ko(r);(async()=>{var S,I,x,P;let f=[];for(let L of(S=o.models)!=null?S:[])try{let y=await Z2(n,L,l,t);f.push(y)}catch(y){c.hide(),r.createDiv({cls:"ai3d-inline-empty",text:y instanceof Error?y.message:String(y)});return}let d=f.map(L=>L.model),h=(x=(I=f[0])==null?void 0:I.sourcePath)!=null?x:"",u=r.createDiv({cls:"ai3d-grid-host"}),m=u.createEl("canvas");if(m.tabIndex=0,m.addEventListener("keydown",L=>{var B,w;if(_||!p)return;let y=L.key.toLowerCase();y==="r"?((B=p.resetView)==null||B.call(p),L.preventDefault()):y==="w"&&((w=p.toggleWireframe)==null||w.call(p),L.preventDefault())}),u.appendChild(m),typeof o.rowHeight=="number"){let L=o.preset==="compose"?1:Math.ceil(d.length/((P=o.columns)!=null?P:Math.min(d.length,3)));u.style.setProperty("--grid-height",`${o.rowHeight*L}px`)}let p=null,_=!1,g=!1;Ad(r,u,n,()=>p,()=>h,()=>{_||(_=!0,T.disconnect(),R.disconnect(),p==null||p.destroy(),p=null,u.remove())},e),q2(r);let T=new MutationObserver(()=>{_||r.contains(u)||(_=!0,T.disconnect(),R.disconnect(),p==null||p.destroy(),p=null)});T.observe(r,{childList:!0});async function b(){var L,y,B,w;if(!(g||_)){g=!0,c.setPhaseKey("codeBlock.renderingGrid"),c.setProgress(-1);try{p=new Up(m);let H=p,O=async k=>yr(n,k);if(o.preset==="compose"){if(!o.sections||o.sections.length===0){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.composeRequiresSections")}),p.destroy(),p=null;return}let k=[];for(let j of o.sections)try{if(!h){let $=j.models[0];if($){let q=typeof $=="string"?$:$.path;h=(L=Mc(n,q))!=null?L:q}}let Q=await m6(n,j,l,t);k.push(Q)}catch(Q){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Q instanceof Error?Q.message:String(Q)}),H.destroy(),p=null;return}let X=qA(k,(y=o.direction)!=null?y:"horizontal",Number((B=o.params)==null?void 0:B.gap)||.02,j=>typeof j=="string"?null:j,JA);if(!X){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Z("codeBlock.composeNoValidSections")}),H.destroy(),p=null;return}await H.loadWithPreset(X,O)}else if(o.preset){let k=JA(o.preset);if(!k){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.unknownPreset",{preset:o.preset})}),H.destroy(),p=null;return}let X=k.compute(d,(w=o.params)!=null?w:{});if(!X){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.presetRequiresModels",{preset:o.preset,min:String(k.minModels),max:String(k.maxModels),count:String(d.length)})}),H.destroy(),p=null;return}await H.loadWithPreset(X,O)}else await H.loadModels(d,o,O);if(_){c.hide();return}c.hide()}catch(H){_=!0,T.disconnect(),R.disconnect(),c.hide(),p==null||p.destroy(),p=null,console.error("[AI3D Grid] Failed:",H),u.createDiv({cls:"ai3d-inline-empty",text:Jt("codeBlock.gridFailed",{reason:String(H)})})}}}let R=new IntersectionObserver(L=>{for(let y of L)y.isIntersecting&&(R.disconnect(),b())},{rootMargin:"200px"});R.observe(u)})()}}}var J2=A(()=>{"use strict";is();cd();F2();hd();Js();j2();XA();_d();md();Dp();gd();Op();Pc();Xo();en();vd();qr()});function Id(n){return createDiv().createDiv(n?{cls:n}:void 0)}function $A(n,e){return createDiv().createEl(n,e?{cls:e}:void 0)}var $2=A(()=>{"use strict"});var iV={};De(iV,{registerLivePreviewExtension:()=>E6});function eV(n,e,t,i,r,s,a,o,l,c,f,d,h){var p,_;let u="state"in n?n.state.doc:n.doc,m=[];for(let g=1;g<=u.lines;g++){let T=u.line(g),b=T.text;if(!b.includes("!["))continue;let R=0;for(;R0&&b[S-1]==="\\"){R=S+3;continue}let I=b.indexOf("]]",S+3);if(I===-1)break;let P=b.slice(S+3,I).split("|"),L=P[0].trim(),y=(_=(p=L.split(".").pop())==null?void 0:p.toLowerCase())!=null?_:"";if(!ts(y)){R=I+2;continue}let B=400,w=300;if(P.length>1){let k=P[1].trim().match(/^(\d+)\s*x\s*(\d+)$/);k&&(B=parseInt(k[1],10),w=parseInt(k[2],10))}let H=Mc(e,L);if(!H){R=I+2;continue}let O=T.from+S;m.push(Bc.Decoration.widget({widget:new eR(e,H,B,w,t,i,r,s,a,o,l,c,f,d,h),block:!0,side:1}).range(O)),R=I+2}}return m}function tV(n){return n.length===0?xd.RangeSet.empty:xd.RangeSet.of(n,!0)}function E6(n,e,t,i){return[xd.StateField.define({create(s){let a=e(),o=eV(s,n,a.autoRotateDefault,a.enabledConverterIds,a.freecadCommand,a.obj2gltfCommand,a.fbx2gltfCommand,a.freecadcmdCommand,a.preferObj2gltfForObj,a.preferFbx2gltfForFbx,a.annotationPreviewMode,t,i);return tV(o)},update(s,a){if(a.docChanged){let o=e(),l=eV(a.state,n,o.autoRotateDefault,o.enabledConverterIds,o.freecadCommand,o.obj2gltfCommand,o.fbx2gltfCommand,o.freecadcmdCommand,o.preferObj2gltfForObj,o.preferFbx2gltfForFbx,o.annotationPreviewMode,t,i);return tV(l)}return s.map(a.changes)},provide:s=>Bc.EditorView.decorations.from(s)})]}var Bc,xd,eR,rV=A(()=>{"use strict";Bc=require("@codemirror/view"),xd=require("@codemirror/state");is();hd();Js();_d();md();gd();Op();Pc();$2();Xo();qr();vd();en();eR=class extends Bc.WidgetType{constructor(t,i,r,s,a,o,l,c,f,d,h,u,m,p,_){super();this.app=t;this.modelPath=i;this.width=r;this.height=s;this.autoRotate=a;this.enabledConverterIds=o;this.freecadCommand=l;this.obj2gltfCommand=c;this.fbx2gltfCommand=f;this.freecadcmdCommand=d;this.preferObj2gltfForObj=h;this.preferFbx2gltfForFbx=u;this.annotationPreviewMode=m;this.convertedAssetCache=p;this.getAnnotations=_;this.preview=null;this.annotationMgr=null;this.mounted=!1;this.pollId=0}eq(t){return this.modelPath===t.modelPath&&this.width===t.width&&this.height===t.height&&this.autoRotate===t.autoRotate&&this.enabledConverterIds.join("|")===t.enabledConverterIds.join("|")&&this.freecadCommand===t.freecadCommand&&this.obj2gltfCommand===t.obj2gltfCommand&&this.fbx2gltfCommand===t.fbx2gltfCommand&&this.freecadcmdCommand===t.freecadcmdCommand&&this.preferObj2gltfForObj===t.preferObj2gltfForObj&&this.preferFbx2gltfForFbx===t.preferFbx2gltfForFbx&&this.annotationPreviewMode===t.annotationPreviewMode&&this.convertedAssetCache===t.convertedAssetCache}toDOM(){let t=Qt(),i=Id("ai3d-embed-preview");t&&i.classList.add("is-mobile","is-mobile-scroll-mode");let r=$A("canvas","ai3d-embed-canvas"),s=t?Math.min(this.height,220):this.height;r.style.setProperty("--ai3d-embed-height",`${s}px`),i.appendChild(r);let a=Ko(i),o=Id("ai3d-embed-error is-hidden");if(i.appendChild(o),t){let f=!1,d=Id("ai3d-mobile-mode-bar"),h=Id("ai3d-mobile-mode-hint");h.textContent=Z("livePreview.mobileHint");let u=$A("button","ai3d-mobile-mode-btn");u.type="button";let m=()=>{i.classList.toggle("is-mobile-interactive",f),i.classList.toggle("is-mobile-scroll-mode",!f),u.textContent=f?Z("helper.scrollAction"):Z("helper.interactAction"),u.classList.toggle("ai3d-btn-active",f),u.setAttribute("aria-label",f?Z("helper.disableInteractionLabel"):Z("helper.enableInteractionLabel"))};u.addEventListener("click",()=>{f=!f,m()}),m(),d.append(h,u),i.appendChild(d)}let l=0,c=()=>{if(!this.mounted){if(i.isConnected){this.mounted=!0,this.initPreview(i,r,a,o);return}++l>120||(this.pollId=window.requestAnimationFrame(c))}};return this.pollId=window.requestAnimationFrame(c),i}async initPreview(t,i,r,s){var a,o;try{let{BabylonModelPreview:l}=await Promise.resolve().then(()=>(cd(),qU));this.preview=new l(i);let c=(a=Qs(this.app,this.modelPath))!=null?a:void 0,f=ra({enabledConverterIds:this.enabledConverterIds,freecadCommand:this.freecadCommand,obj2gltfCommand:this.obj2gltfCommand,fbx2gltfCommand:this.fbx2gltfCommand,freecadcmdCommand:this.freecadcmdCommand});r.setPhaseKey("loading.preparingModel");let d=await ta({path:this.modelPath,absolutePath:c,preferConversionExts:na({preferObj2gltfForObj:this.preferObj2gltfForObj,preferFbx2gltfForFbx:this.preferFbx2gltfForFbx}),conversionManager:f,convertedAssetCache:this.convertedAssetCache});r.setPhaseKey("loading.loadingModel");let h=await yr(this.app,d.effectivePath);if(await this.preview.loadModel(h,d.effectiveExt,u=>yr(this.app,u),d.effectivePath),this.autoRotate&&this.preview.applyConfig({models:[],scene:{autoRotate:!0,autoRotateSpeed:.5}}),this.getAnnotations){let u=this.getAnnotations(this.modelPath);if(u.length>0){let m=this.preview.getCanvas();m&&(this.annotationMgr=new $n({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:m},t,"readonly",u,void 0,Ja(this.app),void 0,{app:this.app,previewMode:this.annotationPreviewMode}))}}r.setProgress(100),r.hide()}catch(l){(o=this.preview)==null||o.destroy(),this.preview=null,r.hide(),s.remove(),t.replaceChildren();let c=qa(l);Za(l)?console.warn("[AI3D] Live Preview blocked by converter settings:",c.message):console.error("[AI3D] Live Preview failed:",l),$a(t,c)}}destroy(){var t;window.cancelAnimationFrame(this.pollId),this.pollId=0,(t=this.annotationMgr)==null||t.destroy(),this.annotationMgr=null,this.preview&&(this.preview.destroy(),this.preview=null),this.mounted=!1}ignoreEvent(){return!1}}});var v6={};De(v6,{default:()=>Vp});module.exports=fV(v6);var Zo=require("obsidian");Kp();is();is();var I6=new Set(to());var io={analysisMode:"local",serviceBaseUrl:"",copySourceModelToVault:!1,sourceModelFolder:"Assets/3D",reportFolder:"Analysis/3D Reports",partFolder:"Parts/3D Components",previewFolder:"Media/3D Previews",maxFileSizeMb:50,autoGenerateKnowledgeNotes:!0,annotationPreviewMode:"plain-text",sendRawModelToRemote:!1,sendPreviewImagesToRemote:!1,sendGeometrySummaryToRemote:!1,defaultKnowledgeTaxonomy:"default-v1",defaultCanvasHeight:400,autoRotateDefault:!1,autoRotateSpeed:.5,renderQuality:"high",renderScale:1,snapshotFolder:"Media/3D Previews",snapshotNaming:"model-name",enabledConverterIds:[],freecadCommand:"",obj2gltfCommand:"",fbx2gltfCommand:"",assimpCommand:"",freecadcmdCommand:"",preferObj2gltfForObj:!1,preferFbx2gltfForFbx:!1,logLevel:"warn",locale:"en"};function RR(n){let e={...n},t=new Set;return{getState:()=>e,setState(i){e={...e,...i};let r=[...t];for(let s of r)s()},subscribe(i){return t.add(i),()=>{t.delete(i)}}}}var mV={settings:{...io},currentModelPath:null,convertedAssetRecords:[],modelAssetProfiles:{},agentDraft:"",agentPlan:null,modelPreview:null};function IR(n){let e=RR(mV),t=null;function i(){t&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,r().catch(a=>console.error("[AI3D] Auto-save failed:",a))},500)}async function r(){let a=e.getState(),o={settings:a.settings,convertedAssetRecords:a.convertedAssetRecords,modelAssetProfiles:a.modelAssetProfiles,agentDraft:a.agentDraft,agentPlan:a.agentPlan};await n.saveData(o)}e.subscribe(()=>i());let s=!1;return{store:e,get localeLoadedFromSaved(){return s},async load(){var o,l,c,f,d,h;let a=await n.loadData();a&&(s=!!((o=a.settings)!=null&&o.locale),e.setState({settings:{...io,...(l=a.settings)!=null?l:{}},convertedAssetRecords:(c=a.convertedAssetRecords)!=null?c:[],modelAssetProfiles:(f=a.modelAssetProfiles)!=null?f:{},agentDraft:(d=a.agentDraft)!=null?d:"",agentPlan:(h=a.agentPlan)!=null?h:null}))},async save(){t&&(window.clearTimeout(t),t=null),await r()},dispose(){t&&(window.clearTimeout(t),t=null)}}}var y2=require("obsidian");HA();var Sd="ai-3d-workbench",Pp=class extends y2.FileView{constructor(t,i,r){super(t);this.unmount=null;this.store=i,this.convertedAssetCache=r}getViewType(){return Sd}getDisplayText(){return"AI 3d workbench"}getIcon(){return"box"}onOpen(){return this.unmount=WA(this.contentEl,this.app,this.store,this.convertedAssetCache),Promise.resolve()}onClose(){var t;return(t=this.unmount)==null||t.call(this),this.unmount=null,Promise.resolve()}};var P2=require("obsidian");cd();hd();XA();_d();md();Dp();Js();gd();Pc();Op();Xo();en();vd();qr();var Fp="ai3d-direct-view";function f6(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}var Np=class extends P2.FileView{constructor(t,i,r,s){super(t);this.preview=null;this.annotationMgr=null;this.annotationMode=!1;this.loadGeneration=0;this.escHandler=null;this.getSettings=i,this.convertedAssetCache=r,this.ps=s}getViewType(){return Fp}getDisplayText(){var t,i;return(i=(t=this.file)==null?void 0:t.name)!=null?i:Z("workbench.modelTitle")}getIcon(){return"box"}async onOpen(){this.contentEl.empty(),this.contentEl.addClass("ai3d-direct-view"),this.file&&await this.loadModel(this.file)}async onLoadFile(t){this.contentEl.empty(),await this.loadModel(t)}onClose(){var t,i;return this.escHandler&&(activeDocument.removeEventListener("keydown",this.escHandler),this.escHandler=null),(t=this.annotationMgr)==null||t.destroy(),this.annotationMgr=null,(i=this.preview)==null||i.destroy(),this.preview=null,Promise.resolve()}async loadModel(t){var h,u,m,p,_;let i=++this.loadGeneration,r=Qt();(h=this.annotationMgr)==null||h.destroy(),this.annotationMgr=null,this.annotationMode=!1,(u=this.preview)==null||u.destroy(),this.preview=null;let s=createDiv(),a=s.createDiv({cls:"ai3d-preview-host"}),o=s.createEl("canvas");o.className="ai3d-canvas-full",a.appendChild(o);let l=s.createDiv();l.className="ai3d-annot-mode-overlay is-hidden",a.appendChild(l),this.contentEl.appendChild(a);let c=null,f=g=>{var T;this.annotationMode=g,r&&g&&(c==null||c.setMobileInteractionMode(!0)),(T=this.annotationMgr)==null||T.hideEditor(),l.classList.toggle("is-hidden",!g),console.debug("[AI3D] DirectView annotation mode:",g)};this.escHandler&&activeDocument.removeEventListener("keydown",this.escHandler),this.escHandler=g=>{g.key==="Escape"&&this.annotationMode&&f(!1)},activeDocument.addEventListener("keydown",this.escHandler),c=Ad(this.contentEl,a,this.app,()=>this.preview,()=>t.path,()=>{this.leaf.detach()},this.getSettings,()=>(f(!this.annotationMode),this.annotationMode),g=>{!g&&this.annotationMode&&f(!1)}),r&&this.contentEl.createDiv({cls:"ai3d-mobile-mode-hint ai3d-mobile-mode-hint--inline",text:Z("directView.mobileHint")});let d=Ko(a);try{let g=this.getSettings(),T=ra(g),b=(m=Qs(this.app,t.path))!=null?m:void 0;d.setPhaseKey("loading.preparingModel");let R=await ta({path:t.path,absolutePath:b,preferConversionExts:na(g),conversionManager:T,convertedAssetCache:this.convertedAssetCache});if(i!==this.loadGeneration)return;let S=Yo(R);this.preview=new $s(o),d.setPhaseKey("loading.loadingModel");let I=await yr(this.app,S.path);if(i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loading: ${t.path} via ${S.path} (${S.ext}, ${I.byteLength} bytes)`);let x=async L=>yr(this.app,L);if(await this.preview.loadModel(I,S.ext,x,S.path),i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loaded successfully: ${t.path}`),d.setProgress(100);let P=this.preview.getCanvas();if(P){let L=this.ps.store.getState().modelAssetProfiles[t.path],y=(p=L==null?void 0:L.annotations)!=null?p:[],B=Ja(this.app),w=Lp(this.app);this.annotationMgr=new $n({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:P},a,"edit",y,H=>{var X;let O=this.ps.store.getState().modelAssetProfiles,k=(X=O[t.path])!=null?X:f6();this.ps.store.setState({modelAssetProfiles:{...O,[t.path]:{...k,annotations:H,updatedAt:new Date().toISOString()}}}),c.updateAnnotationBadge(H.length)},B,w,{app:this.app,previewMode:this.getSettings().annotationPreviewMode}),c.showAnnotateButton(),c.updateAnnotationBadge(y.length),this.preview.onPick(H=>{if(!this.annotationMode||!this.annotationMgr)return;let O=H.screenX,k=H.screenY,X=null;H.pickedPoint?X=H.pickedPoint:H.mesh&&(X=H.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),X&&(console.debug("[AI3D] Annotation: creating pin at",X.toString(),"screen:",O,k),this.annotationMgr.showEditor(O,k,X))})}d.hide()}catch(g){if(i!==this.loadGeneration)return;d.hide(),(_=this.preview)==null||_.destroy(),this.preview=null,a.replaceChildren();let T=qa(g);Za(g)?console.warn("[AI3D] Direct view blocked by converter settings:",T.message):console.error("[AI3D] Direct view failed:",g),$a(a,T)}}};var O2=require("obsidian");is();en();var wp=class extends O2.FuzzySuggestModal{constructor(e,t){super(e),this.onChoose=t,this.setPlaceholder(Z("modal.selectModel"))}getItems(){return this.app.vault.getFiles().filter(e=>{let t=e.extension.toLowerCase();return ts(t)})}getItemText(e){return e.path}onChooseItem(e){this.onChoose(e)}};var Et=require("obsidian");Qa();en();qr();Gt();var YA=lp();function d6(){switch(YA==null?void 0:YA.platform){case"win32":return{python:"Path to python executable",freecad:"Path to FreeCADCmd.exe",obj2gltf:"Path to obj2gltf.cmd",fbx2gltf:"Path to FBX2glTF.exe"};case"darwin":return{python:"Path to python3",freecad:"Path to FreeCADCmd",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"};case"linux":return{python:"Path to python3",freecad:"Path to freecadcmd",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"};default:return{python:"Path to python executable",freecad:"Path to FreeCAD command",obj2gltf:"Path to obj2gltf",fbx2gltf:"Path to FBX2glTF"}}}var Bp=class extends Et.PluginSettingTab{constructor(t,i){super(t,i);this.diagnosticsRunId=0;this.plugin=i}display(){let{containerEl:t}=this;t.empty(),fd(this.plugin.getSettings().locale);let i=d6(),r=Qt(),s=null,a=(l,c,f)=>{let d=l.createEl("details",{cls:"ai3d-settings-secondary-menu"});d.createEl("summary",{cls:"ai3d-settings-secondary-menu-summary",text:c});let h=d.createDiv({cls:"ai3d-settings-secondary-menu-body"});return h.createEl("p",{cls:"setting-item-description",text:f}),h},o=()=>{s&&(this.diagnosticsRunId++,s.empty(),s.createEl("p",{text:Z("settings.diagnostics.idle")}))};if(new Et.Setting(t).setName(Z("settings.title")).setHeading(),new Et.Setting(t).setName(Z("settings.language")).setDesc(Z("settings.language.desc")).addDropdown(l=>l.addOption("en","English").addOption("zh-CN","\u7B80\u4F53\u4E2D\u6587").setValue(this.plugin.getSettings().locale).onChange(c=>{this.plugin.updateSettings({locale:c}),this.display()})),new Et.Setting(t).setName(Z("settings.folders")).setHeading(),new Et.Setting(t).setName(Z("settings.sourceModelFolder")).setDesc(Z("settings.sourceModelFolder.desc")).addText(l=>l.setPlaceholder(io.sourceModelFolder).setValue(this.plugin.getSettings().sourceModelFolder).onChange(c=>{this.plugin.updateSettings({sourceModelFolder:c})})),new Et.Setting(t).setName(Z("settings.reportFolder")).setDesc(Z("settings.reportFolder.desc")).addText(l=>l.setPlaceholder(io.reportFolder).setValue(this.plugin.getSettings().reportFolder).onChange(c=>{this.plugin.updateSettings({reportFolder:c})})),new Et.Setting(t).setName(Z("settings.snapshotFolder")).setDesc(Z("settings.snapshotFolder.desc")).addText(l=>l.setPlaceholder(io.snapshotFolder).setValue(this.plugin.getSettings().snapshotFolder).onChange(c=>{this.plugin.updateSettings({snapshotFolder:c})})),new Et.Setting(t).setName(Z("settings.behavior")).setHeading(),new Et.Setting(t).setName(Z("settings.autoGenerateKnowledgeNotes")).setDesc(Z("settings.autoGenerateKnowledgeNotes.desc")).addToggle(l=>l.setValue(this.plugin.getSettings().autoGenerateKnowledgeNotes).onChange(c=>{this.plugin.updateSettings({autoGenerateKnowledgeNotes:c})})),new Et.Setting(t).setName(Z("settings.annotationPreviewMode")).setDesc(Z("settings.annotationPreviewMode.desc")).addDropdown(l=>l.addOption("plain-text",Z("settings.annotationPreviewMode.plainText")).addOption("markdown",Z("settings.annotationPreviewMode.markdown")).setValue(this.plugin.getSettings().annotationPreviewMode).onChange(c=>{this.plugin.updateSettings({annotationPreviewMode:c})})),new Et.Setting(t).setName(Z("settings.autoRotateDefault")).setDesc(Z("settings.autoRotateDefault.desc")).addToggle(l=>l.setValue(this.plugin.getSettings().autoRotateDefault).onChange(c=>{this.plugin.updateSettings({autoRotateDefault:c})})),new Et.Setting(t).setName(Z("settings.snapshotNaming")).setDesc(Z("settings.snapshotNaming.desc")).addDropdown(l=>l.addOption("model-name",Z("settings.snapshotNaming.modelName")).addOption("timestamp",Z("settings.snapshotNaming.timestamp")).setValue(this.plugin.getSettings().snapshotNaming).onChange(c=>{this.plugin.updateSettings({snapshotNaming:c})})),new Et.Setting(t).setName(Z("settings.logLevel")).setDesc(Z("settings.logLevel.desc")).addDropdown(l=>l.addOption("debug","Debug").addOption("info","Info").addOption("warn","Warn").addOption("error","Error").setValue(this.plugin.getSettings().logLevel).onChange(c=>{this.plugin.updateSettings({logLevel:c})})),new Et.Setting(t).setName(Z("settings.converters")).setHeading(),r)t.createEl("p",{cls:"setting-item-description",text:Z("settings.mobileSupport.desc")});else{let l=a(t,Z("settings.converterMenu"),Z("settings.converterMenu.desc"));new Et.Setting(l).setName(Z("settings.enableCad")).setDesc(Z("settings.enableCad.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("freecad");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"freecad"])):m.filter(_=>_!=="freecad");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableObj2gltf")).setDesc(Z("settings.enableObj2gltf.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("obj2gltf");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"obj2gltf"])):m.filter(_=>_!=="obj2gltf");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.preferObj2gltf")).setDesc(Z("settings.preferObj2gltf.desc")).addToggle(d=>d.setValue(this.plugin.getSettings().preferObj2gltfForObj).onChange(h=>{this.plugin.updateSettings({preferObj2gltfForObj:h})})),new Et.Setting(l).setName(Z("settings.enableFbx2gltf")).setDesc(Z("settings.enableFbx2gltf.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("fbx2gltf");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"fbx2gltf"])):m.filter(_=>_!=="fbx2gltf");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableMesh")).setDesc(Z("settings.enableMesh.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("assimp");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"assimp"])):m.filter(_=>_!=="assimp");this.plugin.updateSettings({enabledConverterIds:p})})}),new Et.Setting(l).setName(Z("settings.enableSldprt")).setDesc(Z("settings.enableSldprt.desc")).addToggle(d=>{let h=this.plugin.getSettings().enabledConverterIds.includes("sldprt");return d.setValue(h).onChange(u=>{let m=this.plugin.getSettings().enabledConverterIds,p=u?Array.from(new Set([...m,"sldprt"])):m.filter(_=>_!=="sldprt");this.plugin.updateSettings({enabledConverterIds:p})})});let c=a(t,Z("settings.environmentInspector"),Z("settings.environmentInspector.desc"));new Et.Setting(c).setName(Z("settings.paths")).setHeading(),new Et.Setting(c).setName(Z("settings.pythonCmd")).setDesc(Z("settings.pythonCmd.desc")).addText(d=>d.setPlaceholder(i.python).setValue(this.plugin.getSettings().freecadCommand).onChange(h=>{this.plugin.updateSettings({freecadCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.freecadCmd")).setDesc(Z("settings.freecadCmd.desc")).addText(d=>d.setPlaceholder(i.freecad).setValue(this.plugin.getSettings().freecadcmdCommand).onChange(h=>{this.plugin.updateSettings({freecadcmdCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.obj2gltfCmd")).setDesc(Z("settings.obj2gltfCmd.desc")).addText(d=>d.setPlaceholder(i.obj2gltf).setValue(this.plugin.getSettings().obj2gltfCommand).onChange(h=>{this.plugin.updateSettings({obj2gltfCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.fbx2gltfCmd")).setDesc(Z("settings.fbx2gltfCmd.desc")).addText(d=>d.setPlaceholder(i.fbx2gltf).setValue(this.plugin.getSettings().fbx2gltfCommand).onChange(h=>{this.plugin.updateSettings({fbx2gltfCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.assimpCmd")).setDesc(Z("settings.assimpCmd.desc")).addText(d=>d.setPlaceholder(i.python).setValue(this.plugin.getSettings().assimpCommand).onChange(h=>{this.plugin.updateSettings({assimpCommand:h.trim()}),o()})),new Et.Setting(c).setName(Z("settings.diagnostics")).setDesc(Z("settings.diagnostics.desc")).addButton(d=>d.setButtonText(Z("settings.diagnostics.checkNow")).onClick(async()=>{d.setDisabled(!0),d.setButtonText(Z("settings.diagnostics.checking")),s&&await this.renderCommandDiagnostics(s),d.setButtonText(Z("settings.diagnostics.checkNow")),d.setDisabled(!1),new Et.Notice(Z("settings.diagnostics.refreshed"))})),s=c.createDiv({cls:"ai3d-settings-diagnostics"}),o()}new Et.Setting(t).setName(Z("settings.performance")).setHeading(),new Et.Setting(t).setName(Z("settings.canvasHeight")).setDesc(Z("settings.canvasHeight.desc")).addSlider(l=>l.setLimits(200,800,25).setValue(this.plugin.getSettings().defaultCanvasHeight).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({defaultCanvasHeight:c})})),new Et.Setting(t).setName(Z("settings.autoRotateSpeed")).setDesc(Z("settings.autoRotateSpeed.desc")).addSlider(l=>l.setLimits(.1,2,.1).setValue(this.plugin.getSettings().autoRotateSpeed).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({autoRotateSpeed:c})})),new Et.Setting(t).setName(Z("settings.renderQuality")).setDesc(Z("settings.renderQuality.desc")).addDropdown(l=>l.addOption("low","Low").addOption("medium","Medium").addOption("high","High").setValue(this.plugin.getSettings().renderQuality).onChange(c=>{this.plugin.updateSettings({renderQuality:c})})),new Et.Setting(t).setName(Z("settings.renderScale")).setDesc(Z("settings.renderScale.desc")).addSlider(l=>l.setLimits(.25,2,.25).setValue(this.plugin.getSettings().renderScale).setDynamicTooltip().onChange(c=>{this.plugin.updateSettings({renderScale:c})}))}async renderCommandDiagnostics(t){let i=++this.diagnosticsRunId;t.empty(),t.createEl("p",{text:Z("settings.diagnostics.checkingAvailability")});let r=await Rp(this.plugin.getSettings());if(i===this.diagnosticsRunId){t.empty();for(let s of r)this.renderCommandStatus(t,s)}}renderCommandStatus(t,i){var a;let r=t.createDiv({cls:"ai3d-settings-status-block"});r.createEl("strong",{text:`${i.label}: ${i.available?Z("settings.diagnostics.available"):Z("settings.diagnostics.notFound")}`});let s=[`${Z("settings.diagnostics.sourceLabel")}: ${Ap(i.source)}`,`${Z("settings.diagnostics.commandLabel")}: ${i.command}`,i.resolvedPath&&i.resolvedPath!==i.command?`${Z("settings.diagnostics.resolvedPathLabel")}: ${i.resolvedPath}`:"",i.detail].filter(Boolean);for(let o of s)r.createDiv({text:o});for(let o of(a=i.dependencyChecks)!=null?a:[])this.renderDependencyCheck(r,o)}renderDependencyCheck(t,i){let r=(()=>{switch(i.kind){case"cad-python":return Z("settings.diagnostics.cadPythonCheck");case"mesh-python":return Z("settings.diagnostics.meshPythonCheck");case"freecadcmd-cli":return Z("settings.diagnostics.freecadCmdCheck");case"obj2gltf-cli":return Z("settings.diagnostics.obj2gltfCheck");case"fbx2gltf-cli":return Z("settings.diagnostics.fbx2gltfCheck")}})(),s=i.ok?Z("settings.diagnostics.selfCheckOk"):Z("settings.diagnostics.selfCheckFailed");t.createDiv({text:`${Z("settings.diagnostics.selfCheckLabel")}: ${r} - ${s}`}),i.detail&&t.createDiv({text:i.detail})}};Qa();Dr();en();Pc();qr();Js();var Vp=class extends Zo.Plugin{getSettings(){return this.ps.store.getState().settings}updateSettings(e){let i={...this.ps.store.getState().settings,...e};this.ps.store.setState({settings:i}),PA(i.logLevel),fd(i.locale)}async onload(){var l;if(this.ps=IR(this),await this.ps.load(),this.convertedAssetCache=SR(this.ps.store.getState().convertedAssetRecords,c=>this.ps.store.setState({convertedAssetRecords:c})),PA(this.getSettings().logLevel),!this.ps.localeLoadedFromSaved){let f=((l=navigator.language)!=null?l:"en").startsWith("zh")?"zh-CN":"en";this.updateSettings({locale:f})}fd(this.getSettings().locale),this.registerView(Sd,c=>new Pp(c,this.ps,this.convertedAssetCache)),this.addRibbonIcon("box",Z("main.ribbonOpenWorkbench"),()=>this.activateView()),this.addCommand({id:"import-model",name:Z("main.commandImportModel"),callback:()=>this.importModel()}),this.addCommand({id:"open-workbench",name:Z("main.commandOpenWorkbench"),callback:()=>this.activateView()}),this.addCommand({id:"generate-note",name:Z("main.commandGenerateNote"),callback:()=>this.generateNote()}),this.addCommand({id:"clear-conversion-cache",name:Z("main.commandClearConversionCache"),callback:()=>this.clearConversionCache()}),this.addCommand({id:"check-converters",name:Z("main.commandCheckConverters"),callback:()=>void this.checkConverterCommands()}),this.addSettingTab(new Bp(this.app,this)),this.registerView(Fp,c=>new Np(c,()=>this.getSettings(),this.convertedAssetCache,this.ps)),this.registerExtensions(to(),Fp);let{registerCodeBlockProcessor:e,registerGridCodeBlockProcessor:t}=await Promise.resolve().then(()=>(J2(),Q2)),i=c=>{var f,d;return(d=(f=this.ps.store.getState().modelAssetProfiles[c])==null?void 0:f.annotations)!=null?d:[]},r=e(this.app,()=>this.getSettings(),this.convertedAssetCache,i);this.registerMarkdownCodeBlockProcessor(r.id,r.handler);let s=t(this.app,()=>this.getSettings(),this.convertedAssetCache);this.registerMarkdownCodeBlockProcessor(s.id,s.handler);let{registerLivePreviewExtension:a}=await Promise.resolve().then(()=>(rV(),iV)),o=a(this.app,()=>this.getSettings(),this.convertedAssetCache,i);for(let c of o)this.registerEditorExtension(c);this.setupHeadingPinObserver()}onunload(){this.ps.dispose()}setupHeadingPinObserver(){let e=".markdown-preview-view, .markdown-source-view",t=[".markdown-preview-view h1",".markdown-preview-view h2",".markdown-preview-view h3",".markdown-preview-view h4",".markdown-preview-view h5",".markdown-preview-view h6",".cm-heading-1",".cm-heading-2",".cm-heading-3",".cm-heading-4",".cm-heading-5",".cm-heading-6",".cm-header-1",".cm-header-2",".cm-header-3",".cm-header-4",".cm-header-5",".cm-header-6"].join(", "),i=new Map,r=y=>{if(y.length===0)return"var(--interactive-accent)";if(y.length===1)return y[0];let B=100/y.length;return`linear-gradient(135deg, ${y.map((w,H)=>{let O=Math.round(H*B),k=Math.round((H+1)*B);return`${w} ${O}% ${k}%`}).join(", ")})`},s=()=>{let y=new Map,B=this.ps.store.getState().modelAssetProfiles;for(let[w,H]of Object.entries(B))for(let O of H.annotations)if(O.headingRef&&O.id){let k=Ed(O.headingRef);if(!k)continue;let X=y.get(k);X||(X=[],y.set(k,X)),X.push({pinId:O.id,modelPath:w,color:O.color})}return y},a=y=>y.map(B=>`${B.pinId}:${B.modelPath}:${B.color}`).sort().join("|"),o=y=>Array.from(y.entries()).map(([B,w])=>`${B}=>${a(w)}`).sort().join("||"),l=y=>Ed(Array.from(y.childNodes).map(B=>{var w;return B.instanceOf(Element)&&B.classList.contains("ai3d-heading-pin-badge")?"":(w=B.textContent)!=null?w:""}).join(" ")),c=y=>{let B=i.get(y);B&&(y.removeEventListener("mouseover",B.handler),B.badge.remove(),delete y.dataset.pinBound,i.delete(y))},f=(y,B)=>{if(B.length===0){c(y);return}let w=a(B),H=i.get(y);if((H==null?void 0:H.signature)===w)return;H&&c(y),y.dataset.pinBound=w;let O=y.createSpan({cls:"ai3d-heading-pin-badge"}),k=[...new Set(B.map(q=>q.color).filter(Boolean))],X=O.createSpan({cls:"ai3d-heading-pin-badge-swatch"});if(X.style.background=r(k),X.title=B.length>1?Z("headingPin.showMultiple"):Z("headingPin.showSingle"),X.setAttribute("role","button"),X.setAttribute("tabindex","0"),B.length>1){let q=O.createSpan({cls:"ai3d-heading-pin-badge-count"});q.textContent=`\xD7${B.length}`}let j=[...new Set(B.map(q=>Mr(q.modelPath)))];O.title=Jt("headingPin.linkedTo",{models:j.join(", ")});let Q=q=>{q==null||q.stopPropagation(),q==null||q.preventDefault();for(let z of B)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:z.pinId}}))};X.addEventListener("click",q=>{Q(q)}),X.addEventListener("keydown",q=>{q.instanceOf(KeyboardEvent)&&(q.key!=="Enter"&&q.key!==" "||Q(q))}),O.addEventListener("click",q=>{q.stopPropagation()}),y.appendChild(O);let $=()=>{for(let q of B)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:q.pinId}}))};y.addEventListener("mouseover",$),i.set(y,{badge:O,handler:$,signature:w})},d=(y,B)=>{var H;let w=l(y);f(y,(H=B.get(w))!=null?H:[])},h=y=>{var B;for(let[w,H]of Array.from(i.entries())){if(!w.isConnected){c(w);continue}let O=(B=y.get(l(w)))!=null?B:[],k=a(O);(O.length===0||H.signature!==k)&&f(w,O)}},u=(y,B)=>{y.querySelectorAll(t).forEach(w=>d(w,B))},m=()=>{let y=s();h(y),activeDocument.querySelectorAll(e).forEach(w=>u(w,y))},p=o(s()),_=0,g=(y=0)=>{_&&window.clearTimeout(_),_=window.setTimeout(()=>{_=0,m()},y)},T=this.ps.store.subscribe(()=>{let y=s(),B=o(y);B!==p&&(p=B,g())});this.registerEvent(this.app.workspace.on("layout-change",()=>{g(200)}));let b=y=>y.matches(e)||y.matches(t)?!0:!!y.querySelector(e)||!!y.querySelector(t),R=y=>y.isConnected&&b(y),S=y=>b(y),I=new Set,x=0,P=()=>{var w,H,O,k,X,j;let y=Array.from(I);I.clear(),x=0;let B=s();h(B);for(let Q of y)Q.isConnected&&((w=Q.matches)!=null&&w.call(Q,t)&&d(Q,B),(O=(H=Q.querySelectorAll)==null?void 0:H.call(Q,t))==null||O.forEach($=>d($,B)),(k=Q.matches)!=null&&k.call(Q,e)&&u(Q,B),(j=(X=Q.querySelectorAll)==null?void 0:X.call(Q,e))==null||j.forEach($=>u($,B)));p=o(B)},L=new MutationObserver(y=>{let B=!1;for(let w of y){for(let H of Array.from(w.addedNodes))H.instanceOf(HTMLElement)&&R(H)&&(I.add(H),B=!0);for(let H of Array.from(w.removedNodes))H.instanceOf(HTMLElement)&&S(H)&&(B=!0)}B&&!x&&(x=window.setTimeout(P,100))});L.observe(activeDocument.body,{childList:!0,subtree:!0}),this.register(()=>{T(),L.disconnect(),x&&(window.clearTimeout(x),x=0),_&&(window.clearTimeout(_),_=0);for(let y of Array.from(i.keys()))c(y)}),g(500)}async activateView(){let{workspace:e}=this.app,t=null;if(e.iterateAllLeaves(i=>{i.getViewState().type===Sd&&(t=i)}),!t){if(t=e.getRightLeaf(!1),!t)return;await t.setViewState({type:Sd,active:!0})}e.setActiveLeaf(t,{focus:!0})}importModel(){new wp(this.app,e=>{let t=e.extension.toLowerCase();ts(t)&&(this.ps.store.getState().currentModelPath===e.path&&this.ps.store.setState({currentModelPath:null,modelPreview:null}),this.ps.store.setState({currentModelPath:e.path,modelPreview:null}),this.activateView())}).open()}async generateNote(){let{generateKnowledgeNote:e}=await Promise.resolve().then(()=>(HA(),M2));await e(this.app,this.ps.store.getState())}clearConversionCache(){this.convertedAssetCache.clear(),new Zo.Notice("AI 3d conversion cache cleared.")}async checkConverterCommands(){if(Qt()){new Zo.Notice(Z("main.converterDiagnosticsMobileUnavailable"),8e3);return}let e=await Rp(this.getSettings()),t=e.filter(r=>r.available).map(r=>r.label),i=e.filter(r=>!r.available).map(r=>r.label);if(i.length===0){new Zo.Notice(`AI 3D converter diagnostics: all commands available (${t.join(", ")}).`,8e3);return}new Zo.Notice(`AI 3D converter diagnostics: available ${t.join(", ")||"none"}; missing ${i.join(", ")}.`,1e4)}}; diff --git a/manifest.json b/manifest.json index 0025b32..ddf8ab6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "ai-model-workbench", "name": "AI Model Workbench", - "version": "0.1.9", + "version": "0.2.0", "minAppVersion": "1.5.0", "description": "Turn 3D models into linked knowledge assets.", "author": "flash", diff --git a/package.json b/package.json index 5e1d60c..a6bded2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-ai-model-workbench", - "version": "0.1.9", + "version": "0.2.0", "private": true, "description": "Obsidian plugin for turning 3D models into linked knowledge assets.", "scripts": { diff --git a/src/render/babylon/annotations.ts b/src/render/babylon/annotations.ts index 048f392..a08bce5 100644 --- a/src/render/babylon/annotations.ts +++ b/src/render/babylon/annotations.ts @@ -3,7 +3,7 @@ import type { Scene } from "@babylonjs/core/scene.js"; import type { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js"; import type { Engine } from "@babylonjs/core/Engines/engine.js"; import { Vector3, Matrix } from "@babylonjs/core/Maths/math.vector.js"; -import { Ray } from "@babylonjs/core/Culling/ray.core.js"; +import { Ray } from "@babylonjs/core/Culling/ray.js"; import type { AnnotationPin, PluginSettings } from "../../domain/models"; import type { HeadingSearchResult } from "../../utils/note-reader"; import { formatT, t } from "../../i18n"; diff --git a/src/render/babylon/disassembly.ts b/src/render/babylon/disassembly.ts index dd87b7b..25352ec 100644 --- a/src/render/babylon/disassembly.ts +++ b/src/render/babylon/disassembly.ts @@ -4,7 +4,7 @@ import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js"; import type { Nullable } from "@babylonjs/core/types.js"; import type { Node } from "@babylonjs/core/node.js"; import { Matrix, Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js"; -import { Ray } from "@babylonjs/core/Culling/ray.core.js"; +import { Ray } from "@babylonjs/core/Culling/ray.js"; import { Color3 } from "@babylonjs/core/Maths/math.color.js"; import { Plane } from "@babylonjs/core/Maths/math.plane.js"; import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js"; diff --git a/versions.json b/versions.json index b2e7b1e..ffadf10 100644 --- a/versions.json +++ b/versions.json @@ -1 +1 @@ -{"0.0.1":"1.5.0","0.0.2":"1.5.0","0.0.3":"1.5.0","0.0.4":"1.5.0","0.0.5-beta.0":"1.5.0","0.1.1":"1.5.0","0.1.2":"1.5.0","0.1.4":"1.5.0","0.1.5":"1.5.0","0.1.6":"1.5.0","0.1.7":"1.5.0","0.1.8":"1.5.0","0.1.9":"1.5.0"} +{"0.0.1":"1.5.0","0.0.2":"1.5.0","0.0.3":"1.5.0","0.0.4":"1.5.0","0.0.5-beta.0":"1.5.0","0.1.1":"1.5.0","0.1.2":"1.5.0","0.1.4":"1.5.0","0.1.5":"1.5.0","0.1.6":"1.5.0","0.1.7":"1.5.0","0.1.8":"1.5.0","0.1.9":"1.5.0","0.2.0":"1.5.0"}