From c0629c7d1712313e2ec293b92e8510a38e70be2e Mon Sep 17 00:00:00 2001 From: flash555588 Date: Wed, 13 May 2026 02:03:30 +0800 Subject: [PATCH] fix: prepare 0.1.5 release --- .gitignore | 2 - CLAUDE.md | 2 +- README.md | 16 +- README.zh-CN.md | 16 +- main.js | 20578 ++++++++++++++++++++++++++++ manifest.json | 6 +- package-lock.json | 5258 +++++++ package.json | 4 +- src/main.ts | 162 +- src/render/babylon/annotations.ts | 30 +- versions.json | 2 +- 11 files changed, 26005 insertions(+), 71 deletions(-) create mode 100644 main.js create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index 819cf57..9d9298b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ node_modules/ -main.js main.js.map data.json -package-lock.json _pr_work/ test-annotation.md diff --git a/CLAUDE.md b/CLAUDE.md index 9f0a2e5..a5be76e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,7 +19,7 @@ No test runner is configured. The only verification gate is `typecheck`. ## Architecture -Entry point: `src/main.ts` → esbuild bundles to `main.js` (CJS, ES2018). `main.js` + `manifest.json` + `styles.css` are deployed to the Obsidian vault's `.obsidian/plugins/ai-3d-model-workbench/`. +Entry point: `src/main.ts` → esbuild bundles to `main.js` (CJS, ES2018). `main.js` + `manifest.json` + `styles.css` are deployed to the Obsidian vault's `.obsidian/plugins/ai-three-d-model-workbench/`. ### Layer Layout diff --git a/README.md b/README.md index b12f353..a6ab73e 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ npm run build 3. Create this folder inside the vault: ```text -/.obsidian/plugins/ai-3d-model-workbench/ +/.obsidian/plugins/ai-three-d-model-workbench/ ``` 4. Copy `main.js`, `manifest.json`, and `styles.css` into that folder. @@ -99,7 +99,7 @@ Use [Quick Start](#quick-start) if you only want the fastest setup. - This plugin folder inside the vault: ```text -/.obsidian/plugins/ai-3d-model-workbench/ +/.obsidian/plugins/ai-three-d-model-workbench/ ``` All install methods place the same three files in that folder: @@ -123,27 +123,27 @@ npm install npm run build ``` -2. Create `/.obsidian/plugins/ai-3d-model-workbench/` if it does not exist. +2. Create `/.obsidian/plugins/ai-three-d-model-workbench/` if it does not exist. 3. Copy `main.js`, `manifest.json`, and `styles.css` into that folder. 4. In Obsidian, enable `AI 3D Model Workbench` in `Settings > Community Plugins`. ### Option B: Download a Release 1. Download `main.js`, `manifest.json`, and `styles.css` from [Releases](https://github.com/flash555588/ai-3d-model-workbench/releases). -2. Create `/.obsidian/plugins/ai-3d-model-workbench/` if it does not exist. +2. Create `/.obsidian/plugins/ai-three-d-model-workbench/` if it does not exist. 3. Put the three files in that folder. 4. In Obsidian, enable `AI 3D Model Workbench` in `Settings > Community Plugins`. ### Option C: Symlink for Development 1. Make sure `/.obsidian/plugins/` already exists. -2. Create a symlink named `ai-3d-model-workbench` that points to this repository. +2. Create a symlink named `ai-three-d-model-workbench` that points to this repository. Windows (PowerShell): ```powershell New-Item -ItemType SymbolicLink ` - -Path "C:\path\to\your-vault\.obsidian\plugins\ai-3d-model-workbench" ` + -Path "C:\path\to\your-vault\.obsidian\plugins\ai-three-d-model-workbench" ` -Target "C:\path\to\ai-3d-model-workbench" ``` @@ -151,7 +151,7 @@ macOS / Linux: ```bash ln -s /path/to/ai-3d-model-workbench \ - /path/to/your-vault/.obsidian/plugins/ai-3d-model-workbench + /path/to/your-vault/.obsidian/plugins/ai-three-d-model-workbench ``` 3. In this repository, run `npm install` once if needed. @@ -569,7 +569,7 @@ npm run typecheck # TypeScript type check ### Build Output ``` -ai-3d-model-workbench/ +ai-three-d-model-workbench/ ├── main.js # 1.7 MB (minified, Babylon.js core) ├── manifest.json # Plugin manifest ├── styles.css # Plugin styles diff --git a/README.zh-CN.md b/README.zh-CN.md index 0ec76ab..cd964d1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -69,7 +69,7 @@ npm run build 3. 在该 vault 里创建这个文件夹: ```text -/.obsidian/plugins/ai-3d-model-workbench/ +/.obsidian/plugins/ai-three-d-model-workbench/ ``` 4. 把 `main.js`、`manifest.json`、`styles.css` 复制到这个文件夹里。 @@ -99,7 +99,7 @@ npm run build - vault 里的插件目录: ```text -/.obsidian/plugins/ai-3d-model-workbench/ +/.obsidian/plugins/ai-three-d-model-workbench/ ``` 无论用哪种方式安装,最终都要把下面这三个文件放进这个目录: @@ -123,27 +123,27 @@ npm install npm run build ``` -2. 如果 `/.obsidian/plugins/ai-3d-model-workbench/` 还不存在,先创建它。 +2. 如果 `/.obsidian/plugins/ai-three-d-model-workbench/` 还不存在,先创建它。 3. 把 `main.js`、`manifest.json`、`styles.css` 复制到这个文件夹里。 4. 在 Obsidian 的“设置 > 社区插件”中启用 `AI 3D Model Workbench`。 ### 方式 B:下载发布版 1. 从 [Releases](https://github.com/flash555588/ai-3d-model-workbench/releases) 下载 `main.js`、`manifest.json` 和 `styles.css`。 -2. 如果 `/.obsidian/plugins/ai-3d-model-workbench/` 还不存在,先创建它。 +2. 如果 `/.obsidian/plugins/ai-three-d-model-workbench/` 还不存在,先创建它。 3. 把这三个文件放进这个文件夹里。 4. 在 Obsidian 的“设置 > 社区插件”中启用 `AI 3D Model Workbench`。 ### 方式 C:开发用符号链接 1. 先确认 `/.obsidian/plugins/` 已经存在。 -2. 创建一个名为 `ai-3d-model-workbench` 的符号链接,指向当前仓库。 +2. 创建一个名为 `ai-three-d-model-workbench` 的符号链接,指向当前仓库。 Windows(PowerShell): ```powershell New-Item -ItemType SymbolicLink ` - -Path "C:\path\to\your-vault\.obsidian\plugins\ai-3d-model-workbench" ` + -Path "C:\path\to\your-vault\.obsidian\plugins\ai-three-d-model-workbench" ` -Target "C:\path\to\ai-3d-model-workbench" ``` @@ -151,7 +151,7 @@ macOS / Linux: ```bash ln -s /path/to/ai-3d-model-workbench \ - /path/to/your-vault/.obsidian/plugins/ai-3d-model-workbench + /path/to/your-vault/.obsidian/plugins/ai-three-d-model-workbench ``` 3. 如果还没装依赖,先在当前仓库运行一次 `npm install`。 @@ -228,7 +228,7 @@ ln -s /path/to/ai-3d-model-workbench \ ```3d model.glb ``` ```` - +ai-three-d-model-workbench/ **完整配置** — 相机、灯光、场景、多模型: ````markdown diff --git a/main.js b/main.js new file mode 100644 index 0000000..584fe8e --- /dev/null +++ b/main.js @@ -0,0 +1,20578 @@ +"use strict";var Y_=Object.defineProperty;var ak=Object.getOwnPropertyDescriptor;var ok=Object.getOwnPropertyNames;var lk=Object.prototype.hasOwnProperty;var C=(s,e)=>()=>(s&&(e=s(s=0)),e);var Ie=(s,e)=>{for(var t in e)Y_(s,t,{get:e[t],enumerable:!0})},ck=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ok(e))!lk.call(s,r)&&r!==t&&Y_(s,r,{get:()=>e[r],enumerable:!(i=ak(e,r))||i.enumerable});return s};var fk=s=>ck(Y_({},"__esModule",{value:!0}),s);function Ul(s,e,t){return`${s}::${e}::${t}`}function hk(s,e){return!!(s.cacheVersion===2&&s.converterId&&s.converterCacheKey&&s.sourcePath&&s.sourceExt&&s.targetExt==="glb"&&s.outputPath&&s.outputExt==="glb"&&Number.isFinite(s.createdAt)&&e-s.createdAt<=2592e6)}function Rx(s,e=Date.now()){let t=new Map;for(let i of s){if(!hk(i,e))continue;let r=Ul(i.sourcePath,i.sourceExt,i.targetExt),n=t.get(r);(!n||i.createdAt>n.createdAt)&&t.set(r,i)}return[...t.values()].sort((i,r)=>r.createdAt-i.createdAt).slice(0,200)}function dk(s,e){return!!s&&!!e&&s.cacheVersion===e.cacheVersion&&s.converterId===e.converterId&&s.converterCacheKey===e.converterCacheKey&&s.sourcePath===e.sourcePath&&s.sourceExt===e.sourceExt&&s.targetExt===e.targetExt&&s.outputPath===e.outputPath&&s.outputExt===e.outputExt&&s.createdAt===e.createdAt&&s.warnings.join(` +`)===e.warnings.join(` +`)}function xx(s=[],e){function t(){return Rx([...n.values()])}function i(l){n.clear();for(let c of l)n.set(Ul(c.sourcePath,c.sourceExt,c.targetExt),c)}let r=Rx(s),n=new Map(r.map(l=>[Ul(l.sourcePath,l.sourceExt,l.targetExt),l]));function a(){let l=t();i(l),e==null||e(l)}return(s.length!==r.length||r.some((l,c)=>!dk(l,s[c])))&&(e==null||e(r)),{get(l,c,f){return n.get(Ul(l,c,f))},set(l){n.set(Ul(l.sourcePath,l.sourceExt,l.targetExt),l),a()},delete(l,c,f){let h=n.delete(Ul(l,c,f));return h&&a(),h},clear(){n.size!==0&&(n.clear(),a())},entries(){return t()}}}var K_=C(()=>{"use strict"});function Hs(s){return s.trim().toLowerCase().replace(/^\./,"")}function j_(s){return uk.get(Hs(s))}function Nn(s){let e=j_(s);return!!(e!=null&&e.enabled)}function Ho(){return Ix.filter(s=>s.enabled).map(s=>s.ext)}var Ix,uk,Fn=C(()=>{"use strict";Ix=[{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:"splat",family:"point-cloud",strategy:"direct",directLoader:"babylon",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}],uk=new Map(Ix.map(s=>[s.ext,s]))});function Mx(s,e=12){let t=new Set,i=[];for(let r of s){let n=r.trim().toLowerCase();if(n&&!t.has(n)&&(t.add(n),i.push(n),i.length>=e))break}return i}var yx=C(()=>{"use strict"});var pk,Z_,q_,Q,dt=C(()=>{pk=typeof WeakRef!="undefined",Z_=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}},q_=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)}},Q=class s{static FromPromise(e,t){let i=new s;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 Z_(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,r=null,n=!1){if(!e)return null;let a=new q_(e,t,r);a.unregisterOnNextCall=n,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=pk?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,n){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=n;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 s;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 Td,Dx=C(()=>{Td=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,n=2,a=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=r,this.samplingMode=n,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 Px,Dt,Dr=C(()=>{dt();Dx();(function(s){s[s.Unknown=0]="Unknown",s[s.Url=1]="Url",s[s.Temp=2]="Temp",s[s.Raw=3]="Raw",s[s.Dynamic=4]="Dynamic",s[s.RenderTarget=5]="RenderTarget",s[s.MultiRenderTarget=6]="MultiRenderTarget",s[s.Cube=7]="Cube",s[s.CubeRaw=8]="CubeRaw",s[s.CubePrefiltered=9]="CubePrefiltered",s[s.Raw3D=10]="Raw3D",s[s.Raw2DArray=11]="Raw2DArray",s[s.DepthStencil=12]="DepthStencil",s[s.CubeRawRGBD=13]="CubeRawRGBD",s[s.Depth=14]="Depth"})(Px||(Px={}));Dt=class s extends Td{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 Q,this.onErrorObservable=new Q,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=s._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),n=a=>{a._swapAndDie(this,!1),this.isReady=r.isReady};r.isAsync?r.proxy.then(n):n(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 n;(n=this._hardwareTexture)==null||n.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);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)}};Dt._Counter=0});var ue,gt=C(()=>{dt();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 Q;ue._LastCreatedScene=null;ue.UseFallbackTexture=!0;ue.FallbackTexture=""});var X,We=C(()=>{X=class s{static _CheckLimit(e,t){let i=s._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},s._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){var n;let i=s._LogLimitOutputs[e];if(!i||!s.MessageLimitReached)return;let r=this._Levels[t];i.current===i.limit&&s[r.name](s.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,(n=r.name)!=null?n:""))}static _AddLogEntry(e){s._LogCache=e+s._LogCache,s.OnNewCacheEntry&&s.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&&!s._CheckLimit(r,i))return;let n=s._FormatMessage(r),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+n,...o);let l=`
${n}

`;s._AddLogEntry(l),s._GenerateLimitMessage(r,e)}static get LogCache(){return s._LogCache}static ClearLogCache(){s._LogCache="",s._LogLimitOutputs={},s.errorsCount=0}static set LogLevels(e){s.Log=s._LogDisabled,s.Warn=s._LogDisabled,s.Error=s._LogDisabled;let t=[s.MessageLogLevel,s.WarningLogLevel,s.ErrorLogLevel];for(let i of t)if((e&i)===i){let r=this._Levels[i];s[r.name]=s._LogEnabled.bind(s,i)}}};X.NoneLogLevel=0;X.MessageLogLevel=1;X.WarningLogLevel=2;X.ErrorLogLevel=4;X.AllLogLevel=7;X.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";X._LogCache="";X._LogLimitOutputs={};X._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];X.errorsCount=0;X.Log=X._LogEnabled.bind(X,X.MessageLogLevel);X.Warn=X._LogEnabled.bind(X,X.WarningLogLevel);X.Error=X._LogEnabled.bind(X,X.ErrorLogLevel)});var E,w=C(()=>{E=class s{static GetShadersRepository(e=0){return e===0?s.ShadersRepository:s.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?s.ShadersStore:s.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?s.IncludesShadersStore:s.IncludesShadersStoreWGSL}};E.ShadersRepository="src/Shaders/";E.ShadersStore={};E.IncludesShadersStore={};E.ShadersRepositoryWGSL="src/ShadersWGSL/";E.ShadersStoreWGSL={};E.IncludesShadersStoreWGSL={}});function Ft(){return typeof window!="undefined"}function wn(){return typeof navigator!="undefined"}function Fa(){return typeof document!="undefined"}function Ad(s){let e="",t=s.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}var Pr=C(()=>{});var Rd,Lx=C(()=>{Rd=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,n,a,o,l){let c=this.engine;if(c.supportsUniformBuffers)for(let d in t)e.bindUniformBlock(d,t[d]);this.engine.getUniforms(this,i).forEach((d,u)=>{r[i[u]]=d}),this._uniforms=r;let h;for(h=0;h{a[d]=u});for(let d of c.getAttributes(this,o))l.push(d)}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 n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),n}_cacheFloat3(e,t,i,r){let n=this._valueCache[e];if(!n||n.length!==3)return n=[t,i,r],this._valueCache[e]=n,!0;let a=!1;return n[0]!==t&&(n[0]=t,a=!0),n[1]!==i&&(n[1]=i,a=!0),n[2]!==r&&(n[2]=r,a=!0),a}_cacheFloat4(e,t,i,r,n){let a=this._valueCache[e];if(!a||a.length!==4)return a=[t,i,r,n],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]!==n&&(a[3]=n,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,n){this._cacheFloat4(e,t,i,r,n)&&(this.engine.setInt4(this._uniforms[e],t,i,r,n)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){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,n){this._cacheFloat4(e,t,i,r,n)&&(this.engine.setUInt4(this._uniforms[e],t,i,r,n)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){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,n){this._cacheFloat4(e,t,i,r,n)&&(this.engine.setFloat4(this._uniforms[e],t,i,r,n)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,i){this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}});function Ce(s,e=!1){if(!(e&&Ox[s]))return Ox[s]=!0,`${s} needs to be imported before as it contains a side-effect required by your code.`}var Ox,Ci=C(()=>{Ox={}});function xd(s,e,t=""){return t+(e?e+` +`:"")+s}function Id(s,e,t,i,r,n,a){let o=a||Vl.loadFile;if(o)return o(s,e,t,i,r,n);throw Ce("FileTools")}function Cd(s,e,t,i){if(s){e?s.IS_NDC_HALF_ZRANGE="":delete s.IS_NDC_HALF_ZRANGE,t?s.USE_REVERSE_DEPTHBUFFER="":delete s.USE_REVERSE_DEPTHBUFFER,i?s.USE_EXACT_SRGB_CONVERSIONS="":delete s.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 Nx(s,e,t=!1,i){switch(s){case 3:{let n=new Int8Array(e);return i&&n.set(new Int8Array(i)),n}case 0:{let n=new Uint8Array(e);return i&&n.set(new Uint8Array(i)),n}case 4:{let n=typeof e!="number"?new Int16Array(e):new Int16Array(t?e/2:e);return i&&n.set(new Int16Array(i)),n}case 5:case 8:case 9:case 10:case 2:{let n=typeof e!="number"?new Uint16Array(e):new Uint16Array(t?e/2:e);return i&&n.set(new Uint16Array(i)),n}case 6:{let n=typeof e!="number"?new Int32Array(e):new Int32Array(t?e/4:e);return i&&n.set(new Int32Array(i)),n}case 7:case 11:case 12:case 13:case 14:case 15:{let n=typeof e!="number"?new Uint32Array(e):new Uint32Array(t?e/4:e);return i&&n.set(new Uint32Array(i)),n}case 1:{let n=typeof e!="number"?new Float32Array(e):new Float32Array(t?e/4:e);return i&&n.set(new Float32Array(i)),n}}let r=new Uint8Array(e);return i&&r.set(new Uint8Array(i)),r}var Vl,wa=C(()=>{Ci();Pr();Vl={}});function ki(s){let e=Q_.get(s);if(!e){if(!s)return _k;e={_webGLVersion:s.TEXTURE_BINDING_3D?2:1,_context:s,parallelShaderCompile:s.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},Q_.set(s,e)}return e}function bd(s){Q_.delete(s)}function $_(s,e,t,i,r,n){var c;let a=ki(i);n||(n=(c=a._createShaderProgramInjection)!=null?c:Md);let o=J_(e,"vertex",i,a._contextWasLost),l=J_(t,"fragment",i,a._contextWasLost);return n(s,o,l,i,r,a.validateShaderPrograms)}function eg(s,e,t,i,r,n=null,a){var h;let o=ki(r);a||(a=(h=o._createShaderProgramInjection)!=null?h:Md);let l=o._webGLVersion>1?`#version 300 es +#define WEBGL2 +`:"",c=Fx(e,"vertex",i,l,r,o._contextWasLost),f=Fx(t,"fragment",i,l,r,o._contextWasLost);return a(s,c,f,r,n,o.validateShaderPrograms)}function wx(s,e){let t=new Rd,i=ki(s);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function Md(s,e,t,i,r=null,n){let a=i.createProgram();if(s.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,e),i.attachShader(a,t),i.linkProgram(a),s.context=i,s.vertexShader=e,s.fragmentShader=t,s.isParallelCompiled||yd(s,i,n),a}function Bx(s,e,t){let i=s;if(i._isDisposed)return!1;let r=ki(e);return r&&r.parallelShaderCompile&&r.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,r.parallelShaderCompile.COMPLETION_STATUS_KHR)?(yd(i,e,t),!0):!1}function yd(s,e,t){let i=s.context,r=s.vertexShader,n=s.fragmentShader,a=s.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!e.getShaderParameter(r,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(r);if(c)throw s.vertexCompilationError=c,new Error("VERTEX SHADER "+c)}if(!e.getShaderParameter(n,e.COMPILE_STATUS)){let c=e.getShaderInfoLog(n);if(c)throw s.fragmentCompilationError=c,new Error("FRAGMENT SHADER "+c)}let l=i.getProgramInfoLog(a);if(l)throw s.programLinkError=l,new Error(l)}if(t&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){let c=i.getProgramInfoLog(a);if(c)throw s.programValidationError=c,new Error(c)}i.deleteShader(r),i.deleteShader(n),s.vertexShader=void 0,s.fragmentShader=void 0,s.onCompiled&&(s.onCompiled(),s.onCompiled=void 0)}function Ux(s,e,t,i,r,n,a,o,l,c="",f,h,d){var p,_;let u=ki(s.context);h||(h=(p=u.createRawShaderProgramInjection)!=null?p:$_),d||(d=(_=u.createShaderProgramInjection)!=null?_:eg);let m=s;i?m.program=h(m,e,t,m.context,l):m.program=d(m,e,t,o,m.context,l),m.program.__SPECTOR_rebuildProgram=a,f()}function Fx(s,e,t,i,r,n){return J_(xd(s,t,i),e,r,n)}function J_(s,e,t,i){let r=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!r){let n=t.NO_ERROR,a;for(;(a=t.getError())!==t.NO_ERROR;)n=a;throw new Error(`Something went wrong while creating a gl ${e} shader object. gl error=${n}, gl isContextLost=${t.isContextLost()}, _contextWasLost=${i}`)}return t.shaderSource(r,s),t.compileShader(r),r}function Vx(s,e){e.useProgram(s)}function Gx(s,e){let t=s;if(!t.isParallelCompiled){e(s);return}let i=t.onCompiled;t.onCompiled=()=>{i==null||i(),e(s)}}var Q_,_k,tg=C(()=>{Lx();wa();Q_=new WeakMap,_k={_webGLVersion:2,cachedPipelines:{}}});var gk,Ek,zs,Dd=C(()=>{gk="attribute",Ek="varying",zs=class{constructor(){this.children=[]}isValid(e){return!0}process(e,t,i){var n,a,o,l,c,f,h;let r="";if(this.line){let d=this.line,u=t.processor;if(u){u.lineProcessor&&(d=u.lineProcessor(d,t.isFragment,t.processingContext));let m=(a=(n=t.processor)==null?void 0:n.attributeKeywordName)!=null?a:gk,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:Ek;!t.isFragment&&u.attributeProcessor&&this.line.startsWith(m)?d=u.attributeProcessor(this.line,e,t.processingContext):u.varyingProcessor&&((h=u.varyingCheck)!=null&&h.call(u,this.line,t.isFragment)||!u.varyingCheck&&this.line.startsWith(p))?d=u.varyingProcessor(this.line,t.isFragment,e,t.processingContext):u.uniformProcessor&&u.uniformRegexp&&u.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(d=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&u.uniformBufferRegexp&&u.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(d=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):u.textureProcessor&&u.textureRegexp&&u.textureRegexp.test(this.line)?d=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&&(d=u.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):u.uniformBufferProcessor&&(d=u.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,u.endOfUniformBufferProcessor&&(d=u.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}r+=d+` +`}for(let d of this.children)r+=d.process(e,t,i);return this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true",i[this.additionalDefineKey]=e[this.additionalDefineKey]),r}}});var Pd,kx=C(()=>{Pd=class{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex1&&this._lines.push(i);else{let n=t.split(";");for(let a=0;a{Dd();Gl=class extends zs{process(e,t,i){for(let r=0;r{Dd();Ld=class extends zs{isValid(e){return this.testExpression.isTrue(e)}}});var Oi,kl=C(()=>{Oi=class s{isTrue(e){return!0}static postfixToInfix(e){let t=[];for(let i of e)if(s._OperatorPriority[i]===void 0)t.push(i);else{let r=t[t.length-1],n=t[t.length-2];t.length-=2,t.push(`(${n}${i}${r})`)}return t[t.length-1]}static infixToPostfix(e){let t=s._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,n=()=>{f=f.trim(),f!==""&&(i.push(f),f="")},a=h=>{rs._Stack[r],l=()=>r===-1?"!!INVALID EXPRESSION!!":s._Stack[r--],c=0,f="";for(;c1){for(n();r!==-1&&s._OperatorPriority[o()]>=s._OperatorPriority[d];)i.push(l());a(d),c++}else f+=h;c++}for(n();r!==-1;)o()==="("?l():i.push(l());return s._InfixToPostfixCache.size>=s.InfixToPostfixCacheLimitSize&&s.ClearCache(),s._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){let e=Array.from(s._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t{kl();Xo=class extends Oi{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 Od,Xx=C(()=>{kl();Od=class extends Oi{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}});var Nd,Yx=C(()=>{kl();Nd=class extends Oi{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}});var Fd,Kx=C(()=>{kl();Fd=class extends Oi{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 qx(s){s.processor&&s.processor.initializeShaders&&s.processor.initializeShaders(s.processingContext)}function ag(s,e,t,i){var r;(r=e.processor)!=null&&r.preProcessShaderCode&&(s=e.processor.preProcessShaderCode(s,e.isFragment)),Yf(s,e,n=>{e.processCodeAfterIncludes&&(n=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",n,e.defines));let a=bk(n,e,i);t(a,n)})}function Qx(s,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:s,fragmentCode:e}:t.processor.finalizeShaders(s,e,t.processingContext)}function Rk(s,e){var i;if((i=e.processor)!=null&&i.noPrecision)return s;let t=e.shouldUseHighPrecisionShader;return s.indexOf("precision highp float")===-1?t?s=`precision highp float; +`+s:s=`precision mediump float; +`+s:t||(s=s.replace("precision highp float","precision mediump float")),s}function rg(s){let t=/defined\((.+)\)/.exec(s);if(t&&t.length)return new Xo(t[1].trim(),s[0]==="!");let i=["==","!=",">=","<=","<",">"],r="",n=0;for(r of i)if(n=s.indexOf(r),n>-1)break;if(n===-1)return new Xo(s);let a=s.substring(0,n).trim(),o=s.substring(n+r.length).trim();return new Fd(a,r,o)}function xk(s){s=s.replace(vk,"defined[$1]");let e=Oi.infixToPostfix(s),t=[];for(let r of e)if(r!=="||"&&r!=="&&")t.push(r);else if(t.length>=2){let n=t[t.length-1],a=t[t.length-2];t.length-=2;let o=r=="&&"?new Nd:new Od;typeof n=="string"&&(n=n.replace(ig,"defined($1)")),typeof a=="string"&&(a=a.replace(ig,"defined($1)")),o.leftOperand=typeof a=="string"?rg(a):a,o.rightOperand=typeof n=="string"?rg(n):n,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(ig,"defined($1)")),typeof i=="string"?rg(i):i}function Bd(s,e){let t=new Ld,i=s.substring(0,e),r=s.substring(e);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i==="#ifdef"?t.testExpression=new Xo(r):i==="#ifndef"?t.testExpression=new Xo(r,!0):t.testExpression=xk(r),t}function sg(s,e,t,i){let r;for(;ng(s,t,i);){r=s.currentLine;let n=r.substring(0,5).toLowerCase();if(n==="#else"){let a=new zs;e.children.push(a),ng(s,a,i);return}else if(n==="#elif"){let a=Bd(r,5);e.children.push(a),t=a}}}function ng(s,e,t){for(;s.canRead;){s.lineIndex++;let i=s.currentLine;if(i.indexOf("#")>=0){let n=Ak.exec(i);if(n&&n.length){switch(n[0]){case"#ifdef":{let o=new Gl;e.children.push(o);let l=Bd(i,6);o.children.push(l),sg(s,o,l,t);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{let o=new Gl;e.children.push(o);let l=Bd(i,7);o.children.push(l),sg(s,o,l,t);break}case"#if":{let o=new Gl,l=Bd(i,3);e.children.push(o),o.children.push(l),sg(s,o,l,t);break}}continue}}let r=new zs;if(r.line=i,e.children.push(r),i[0]==="#"&&i[1]==="d"){let n=i.replace(";","").split(" ");r.additionalDefineKey=n[1],n.length===3&&(r.additionalDefineValue=n[2])}}return!1}function Ik(s,e,t,i){let r=new zs,n=new Pd;return n.lineIndex=-1,n.lines=s.split(` +`),ng(n,r,i),r.process(e,t,i)}function Ck(s,e){var r;let t=s.defines,i={};for(let n of t){let o=n.replace("#define","").replace(";","").trim().split(" ");i[o[0]]=o.length>1?o[1]:""}return((r=s.processor)==null?void 0:r.shaderLanguage)===0&&(i.GL_ES="true"),i.__VERSION__=s.version,i[s.platformName]="true",Cd(i,e==null?void 0:e.isNDCHalfZRange,e==null?void 0:e.useReverseDepthBuffer,e==null?void 0:e.useExactSrgbConversions),i}function bk(s,e,t){let i=Rk(s,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,n=Ck(e,t);e.processor.preProcessor&&(i=e.processor.preProcessor(i,r,n,e.isFragment,e.processingContext));let a={};return i=Ik(i,n,e,a),e.processor.postProcessor&&(i=e.processor.postProcessor(i,r,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{},n,a)),t!=null&&t._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function Yf(s,e,t){wd.length=0;let i;for(;(i=Sk.exec(s))!==null;)wd.push(i);let r=[s],n=!1;for(let o of wd){let l=o[1];if(l.indexOf("__decl__")!==-1&&(l=l.replace(Tk,""),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 h=o[3].split(",");for(let d=0;dv+"{X}")),c+=p.replace(Zx,_.toString())+` +`}else e.supportsUniformBuffers||(c=c.replace(jx,(d,u)=>u+"{X}")),c=c.replace(Zx,h)}let f=[];for(let h of r){let d=h.split(o[0]);for(let u=0;u=0||c.indexOf("#include <")>=0}else{let c=e.shadersRepository+"ShadersInclude/"+l+".fx";og.loadFile(c,f=>{e.includesShadersStore[l]=f,Yf(r.join(""),e,t)});return}}wd.length=0;let a=r.join("");n?Yf(a.toString(),e,t):t(a)}var vk,ig,Sk,Tk,jx,Zx,wd,Ak,og,Ud=C(()=>{Dd();kx();Wx();Hx();zx();Xx();Yx();kl();Kx();Ci();wa();vk=/defined\s*?\((.+?)\)/g,ig=/defined\s*?\[(.+?)\]/g,Sk=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,Tk=/__decl__/,jx=/light\{X\}.(\w*)/g,Zx=/\{X\}/g,wd=[],Ak=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;og={loadFile:(s,e,t,i,r,n)=>{throw Ce("FileTools")}}});function $x(s,e){return ki(e).cachedPipelines[s]}function Vd(s){let e=s._name,t=s.context;if(e&&t){let i=ki(t),r=i.cachedPipelines[e];r==null||r.dispose(),delete i.cachedPipelines[e]}}function eI(s,e,t,i,r,n,a){let o,l,c=Ft()?n==null?void 0:n.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],h=()=>{if(f[0]&&f[1]){let[d,u]=f;qx(s),ag(d,s,(m,p)=>{a&&(a._vertexSourceCodeBeforeMigration=p),t&&(m=t("vertex",m)),s.isFragment=!0,ag(u,s,(_,g)=>{a&&(a._fragmentSourceCodeBeforeMigration=g),t&&(_=t("fragment",_));let v=Qx(m,_,s);s=null;let I=Mk(v.vertexCode,v.fragmentCode,e,r);i==null||i(I.vertexSourceCode,I.fragmentSourceCode)},n)},n)}};Jx(o,"Vertex","",d=>{a&&(a._rawVertexSourceCode=d),f[0]=d,h()},r),Jx(l,"Fragment","Pixel",d=>{a&&(a._rawFragmentSourceCode=d),f[1]=d,h()},r)}function Jx(s,e,t,i,r,n){if(typeof HTMLElement!="undefined"&&s instanceof HTMLElement){let l=Ad(s);i(l);return}if(s.substring(0,7)==="source:"){i(s.substring(7));return}if(s.substring(0,7)==="base64:"){let l=window.atob(s.substring(7));i(l);return}let a=E.GetShadersStore(r);if(a[s+e+"Shader"]){i(a[s+e+"Shader"]);return}if(t&&a[s+t+"Shader"]){i(a[s+t+"Shader"]);return}let o;if(s[0]==="."||s[0]==="/"||s.indexOf("http")>-1?o=s:o=E.GetShadersRepository(r)+s,n=n||Id,!n)throw new Error("loadFileInjection is not defined");n(o+"."+e.toLowerCase()+".fx",i)}function Mk(s,e,t,i){if(t){let r=t.vertexElement||t.vertex||t.spectorName||t,n=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+r+` +`+s,fragmentSourceCode:(i===1?"//":"")+"#define SHADER_NAME fragment:"+n+` +`+e}}else return{vertexSourceCode:s,fragmentSourceCode:e}}var tI,lg=C(()=>{Pr();tg();w();We();Ud();wa();tI=(s,e,t,i)=>{try{let r=s.context?ki(s.context):null;r&&(r.disableParallelShaderCompile=s.disableParallelCompilation);let n=s.existingPipelineContext||e(s.shaderProcessingContext);return n._name=s.name,s.name&&r&&(r.cachedPipelines[s.name]=n),t(n,s.vertex,s.fragment,!!s.createAsRaw,"","",s.rebuildRebind,s.defines,s.transformFeedbackVaryings,"",()=>{i(n,()=>{var a;(a=s.onRenderingStateCompiled)==null||a.call(s,n)})}),n}catch(r){throw X.Error("Error compiling effect"),r}}});function iI(s,e,t){try{if(s())return e(),!0}catch(i){return t==null||t(i),!0}return!1}var Gd,vs,Xs,Ys=C(()=>{Gd=[],vs=class{static SetImmediate(e){Gd.length===0&&setTimeout(()=>{let t=Gd;Gd=[];for(let i of t)i()},1),Gd.push(e)}};Xs=(s,e,t,i=16,r=3e4,n=!0,a)=>{if(n&&iI(s,e,t))return null;let o=setInterval(()=>{iI(s,e,t)?clearInterval(o):(r-=i,r<0&&(clearInterval(o),t==null||t(new Error("Operation timed out after maximum retries. "+(a||"")),!0)))},i);return()=>clearInterval(o)}});var wt,Ba=C(()=>{dt();We();w();lg();Ys();wt=class s{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 Q),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,r=null,n,a=null,o=null,l=null,c=null,f,h="",d=0,u){var _,g,v,I;this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new Q,this.onErrorObservable=new Q,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=h;let m=this._key.replace(/\r/g,"").replace(/\n/g,"|"),p;if(t.attributes){let x=t;if(this._engine=i,this._attributesNames=x.attributes,this._uniformsNames=x.uniformsNames.concat(x.samplers),this._samplerList=x.samplers.slice(),this.defines=x.defines,this.onError=x.onError,this.onCompiled=x.onCompiled,this._fallbacks=x.fallbacks,this._indexParameters=x.indexParameters,this._transformFeedbackVaryings=x.transformFeedbackVaryings||null,this._multiTarget=!!x.multiTarget,this._shaderLanguage=(_=x.shaderLanguage)!=null?_:0,this._disableParallelShaderCompilation=!!x.disableParallelShaderCompilation,x.uniformBuffersNames){this._uniformBuffersNamesList=x.uniformBuffersNames.slice();for(let T=0;T{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 n={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};eI(n,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){Xs(()=>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=(n,a)=>{r&&r(a)},this.onCompiled=()=>{var a,o;let n=this.getEngine().scenes;if(n)for(let l=0;lthis._rebuildProgram(l,c,f,h),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+?):/,n=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&&(n=`Offending line [${o}] in ${i?"fragment":"vertex"} code: ${l[o-1]}`)}}return[e,n]}_processCompilationErrors(e,t=null){var a,o,l;this._compilationError=e.message;let i=this._attributesNames,r=this._fallbacks;if(X.Error("Unable to compile effect:"),X.Error(`Uniforms: ${this._uniformsNames.join(" ")}`),X.Error(`Attributes: ${i.join(" ")}`),X.Error(`Defines: +`+this.defines),s.LogShaderCodeOnCompilationError){let c=null,f=null,h;(a=this._pipelineContext)!=null&&a._getVertexShaderCode()&&([h,c]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),h&&(X.Error("Vertex code:"),X.Error(h))),(o=this._pipelineContext)!=null&&o._getFragmentShaderCode()&&([h,f]=this._getShaderCodeAndErrorLine((l=this._pipelineContext)==null?void 0:l._getFragmentShaderCode(),this._compilationError,!0),h&&(X.Error("Fragment code:"),X.Error(h))),c&&X.Error(c),f&&X.Error(f)}X.Error("Error: "+this._compilationError);let n=()=>{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,n()),r?(this._pipelineContext=null,r.hasMoreFallbacks?(this._allFallbacksProcessed=!1,X.Error("Trying next fallback."),this.defines=r.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,n(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||n())}get isSupported(){return this._compilationError===""}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){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&&Vd(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(){s._BaseCache={}}};wt.LogShaderCodeOnCompilationError=!0;wt.PersistentMode=!1;wt.AutomaticallyClearCodeCache=!1;wt._UniqueIdSeed=0;wt._BaseCache={};wt.ShadersStore=E.ShadersStore;wt.IncludesShadersStore=E.IncludesShadersStore});var er,cg=C(()=>{er=class s{static SetMatrixPrecision(e){if(s.MatrixTrackPrecisionChange=!1,e&&!s.MatrixUse64Bits&&s.MatrixTrackedMatrices)for(let t=0;t{Pr();Xt=class{static get Now(){return Ft()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}});var kd,rI=C(()=>{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 Wd,sI=C(()=>{Wd=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 Yo,nI=C(()=>{Yo=class s{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=s.ALWAYS,this.opStencilFail=s.KEEP,this.opDepthFail=s.KEEP,this.opStencilDepthPass=s.REPLACE,this.backFunc=s.ALWAYS,this.backOpStencilFail=s.KEEP,this.backOpDepthFail=s.KEEP,this.backOpStencilDepthPass=s.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}};Yo.ALWAYS=519;Yo.KEEP=7680;Yo.REPLACE=7681});var Wl,fg=C(()=>{Wl=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,n=0){let a=n*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{dt();Ba();gt();We();cg();Bn();rI();sI();nI();fg();Ci();Dr();Pr();wa();he=class s{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()}wt.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(){X.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,n=this._stencilState.stencilTest;e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=r,this._stencilState.stencilTest=n,this._flagContextRestored()},0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return 0}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){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,Ft()){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(A).toLowerCase():"");R.indexOf("?")>-1&&(R=R.split("?")[0]);let D=s.GetCompatibleTextureLoader(R,m);r&&r.addPendingData(x),x.url=e,x.generateMipMaps=!t,x.samplingMode=n,x.invertY=i,x._useSRGBBuffer=this._getUseSRGBBuffer(!!_,t),this._doNotHandleContextLost||(x._buffer=f);let M=null;a&&!h&&(M=x.onLoadedObservable.add(a)),h||this._internalTexturesCache.push(x);let F=(N,V)=>{r&&r.removePendingData(x),e===T?(M&&x.onLoadedObservable.remove(M),ue.UseFallbackTexture&&e!==ue.FallbackTexture&&this._createTextureBase(ue.FallbackTexture,t,x.invertY,r,n,null,o,l,c,f,x),N=(N||"Unknown error")+(ue.UseFallbackTexture?" - Fallback texture was used":""),x.onErrorObservable.notifyObservers({message:N,exception:V}),o&&o(N,V)):(X.Warn(`Failed to load ${e}, falling back to ${T}`),this._createTextureBase(T,t,x.invertY,r,n,a,o,l,c,f,x,d,u,m,p,_))};if(D){let N=async V=>{(await D).loadData(V,x,(U,k,z,Z,J,q)=>{q?F("TextureLoader failed to load data"):l(x,R,r,{width:U,height:k},x.invertY,!z,Z,()=>(J(),!1),n)},p)};if(!f)this._loadFile(e,async V=>{try{await N(new Uint8Array(V))}catch(O){F("Failed to parse texture data",O)}},void 0,r?r.offlineProvider:void 0,!0,(V,O)=>{F("Unable to load "+(V&&V.responseURL,O))});else{let V=async O=>{try{await N(O)}catch(U){F("Failed to parse texture data",U)}};f instanceof ArrayBuffer?V(new Uint8Array(f)):ArrayBuffer.isView(f)?V(f):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null)}}else{let N=V=>{v&&!this._doNotHandleContextLost&&(x._buffer=V),l(x,R,r,V,x.invertY,t,!1,c,n)};!g||I?f&&(typeof f.decoding=="string"||f.close)?N(f):s._FileToolsLoadImage(e||"",N,F,r?r.offlineProvider:null,m,x.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof f=="string"||f instanceof ArrayBuffer||ArrayBuffer.isView(f)||f instanceof Blob?s._FileToolsLoadImage(f,N,F,r?r.offlineProvider:null,m,x.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):f&&N(f)}return x}_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:Fa()?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,h,d,u,m,p;this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new kd,this._stencilStateComposer=new Wd,this._stencilState=new Yo,this._alphaState=new Wl(!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 Q,this.onCanvasFocusObservable=new Q,this.onNewSceneAddedObservable=new Q,this.onResizeObservable=new Q,this.onCanvasPointerOutObservable=new Q,this.onEffectErrorObservable=new Q,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 Q,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 Q,this.onAfterShaderCompilationObservable=new Q,this.onBeginFrameObservable=new Q,this.onEndFrameObservable=new Q,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new Q,this.onContextRestoredObservable=new Q,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 Q,this.onReleaseEffectsObservable=new Q,ue.Instances.push(this),this.startTime=Xt.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,er.SetMatrixPrecision(!!t.useLargeWorldRendering||!!t.useHighPrecisionMatrix),wn()&&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=(h=(f=t.audioEngineOptions)==null?void 0:f.audioContext)!=null?h:null,this._audioDestination=(u=(d=t.audioEngineOptions)==null?void 0:d.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=Ft()&&window.devicePixelRatio||1,n=t.limitDeviceRatio||r;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(n,r):1,this._lastDevicePixelRatio=r,this._creationOptions=t}resize(e=!1){var r,n;let t,i;if(this.adaptToDeviceRatio){let a=Ft()&&window.devicePixelRatio||1,o=this._lastDevicePixelRatio/a;this._lastDevicePixelRatio=a,this._hardwareScalingLevel*=o}if(Ft()&&Fa())if(this._renderingCanvas){let a=(n=(r=this._renderingCanvas).getBoundingClientRect)==null?void 0:n.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&&Fa()&&"ontouchend"in document},this._checkForMobile(),Ft()&&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 s._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,r,n,a,o){throw Ce("FileTools")}_loadFile(e,t,i,r,n,a){let o=Id(e,t,i,r,n,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,n,a){if(Vl.loadFile)return Vl.loadFile(e,t,i,r,n,a);throw Ce("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),wt.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(),Ft()&&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 Ce("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i{});var zd,oI=C(()=>{zd=class{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,r,n){if(n.drawBuffersExtensionDisabled){let a=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(a,"")}return e}}});var yk,Xd,lI=C(()=>{yk=/(flat\s)?\s*varying\s*.*/,Xd=class{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return yk.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,n=/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;if(e=e.replace(n,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){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 Ko,dg=C(()=>{Ko=class s{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=s._Counter++}};Ko._Counter=0});var Ks,Yd=C(()=>{dg();Ks=class extends Ko{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}});function jo(s){let e=1;do e*=2;while(es-t?t:e}function cI(s){return s--,s|=s>>1,s|=s>>2,s|=s>>4,s|=s>>8,s|=s>>16,s++,s}function Kd(s){return s=s|s>>1,s=s|s>>2,s=s|s>>4,s=s|s>>8,s=s|s>>16,s-(s>>1)}function dr(s,e,t=2){let i;switch(t){case 1:i=Kd(s);break;case 2:i=ug(s);break;case 3:default:i=cI(s);break}return Math.min(i,e)}var js=C(()=>{});var Hl,mg=C(()=>{Hl=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 pg(s){return s===13||s===14||s===15||s===16||s===17||s===18||s===19}function Un(s){return s===13||s===17||s===18||s===19}var jf=C(()=>{});var fI={};Ie(fI,{ThinEngine:()=>He});var _g,He,ur=C(()=>{Ba();tg();ci();hg();We();Pr();oI();lI();Yd();js();mg();Dr();wa();lg();jf();fg();_g=class{},He=class s extends he{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return wt.ShadersRepository}static set ShadersRepository(e){wt.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 n;if(e.getContext){if(n=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 s.ExceptionList){let f=c.key,h=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 h)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=()=>{bd(this._gl)}:(this._onContextLost=l=>{l.preventDefault(),this._contextWasLost=!0,bd(this._gl),X.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},n.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),n.addEventListener("webglcontextlost",this._onContextLost,!1),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=n.getContext("webgl2",i)||n.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch(l){}if(!this._gl){if(!n)throw new Error("The provided canvas is null or undefined.");try{this._gl=n.getContext("webgl",i)||n.getContext("experimental-webgl",i)}catch(l){throw new Error("WebGL not supported",{cause:l})}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,n=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(n),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 Xd:new zd;let a=`Babylon.js v${s.Version}`;X.Log(a+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",a);let o=ki(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 Wl(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 n=0;n<16;n++)this._gl["COLOR_ATTACHMENT"+n+"_WEBGL"]=r["COLOR_ATTACHMENT"+n+"_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),n=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);if(r&&n&&(this._caps.highPrecisionShaderSupported=r.precision!==0&&n.precision!==0,this._caps.shaderFloatPrecision=Math.min(r.precision,n.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,n=this._gl.getUniformBlockIndex(r,t);this._gl.uniformBlockBinding(r,n,i)}bindIndexBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)}_bindBuffer(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)}updateArrayBuffer(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)}_vertexAttribPointer(e,t,i,r,n,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!==n&&(l.normalized=n,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=n,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,n,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 n=0;n=0){let o=r[n],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 n=this._gl.createVertexArray();if(!n)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,r),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n}bindVertexArrayObject(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=t!=null&&t.is32Bits,this._mustWipeVertexAttributes=!0)}bindBuffersDirectly(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;let a=n.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,X.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));let _=pg(c),g=Un(c),v=this._gl,I=new Dt(this,r),x=e.width||e,T=e.height||e,A=e.depth||0,R=e.layers||0,P=this._getSamplingParameters(l,(n||a)&&!_),D=R!==0?v.TEXTURE_2D_ARRAY:A!==0?v.TEXTURE_3D:p?v.TEXTURE_CUBE_MAP:v.TEXTURE_2D,M=_?this._getInternalFormatFromDepthTextureFormat(c,!0,g):this._getRGBABufferInternalSizedFormat(o,c,f),F=_?g?v.DEPTH_STENCIL:v.DEPTH_COMPONENT:this._getInternalFormat(c),N=_?this._getWebGLTextureTypeFromDepthTextureFormat(c):this._getWebGLTextureType(o);if(this._bindTextureDirectly(D,I),R!==0)I.is2DArray=!0,v.texImage3D(D,0,M,x,T,R,0,F,N,null);else if(A!==0)I.is3D=!0,v.texImage3D(D,0,M,x,T,A,0,F,N,null);else if(p){I.isCube=!0;for(let O=0;O<6;O++)v.texImage2D(v.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,M,x,T,0,F,N,null)}else v.texImage2D(D,0,M,x,T,0,F,N,null);if(v.texParameteri(D,v.TEXTURE_MAG_FILTER,P.mag),v.texParameteri(D,v.TEXTURE_MIN_FILTER,P.min),v.texParameteri(D,v.TEXTURE_WRAP_S,v.CLAMP_TO_EDGE),v.texParameteri(D,v.TEXTURE_WRAP_T,v.CLAMP_TO_EDGE),_&&this.webGLVersion>1&&(m===0?(v.texParameteri(D,v.TEXTURE_COMPARE_FUNC,515),v.texParameteri(D,v.TEXTURE_COMPARE_MODE,v.NONE)):(v.texParameteri(D,v.TEXTURE_COMPARE_FUNC,m),v.texParameteri(D,v.TEXTURE_COMPARE_MODE,v.COMPARE_REF_TO_TEXTURE))),(n||a)&&this._gl.generateMipmap(D),this._bindTextureDirectly(D,null),I._useSRGBBuffer=f,I.baseWidth=x,I.baseHeight=T,I.width=x,I.height=T,I.depth=R||A,I.isReady=!0,I.samples=h,I.generateMipMaps=n,I.samplingMode=l,I.type=o,I.format=c,I.label=d,I.comparisonFunction=m,this._internalTexturesCache.push(I),u){let O;if(pg(I.format)?O=this._setupFramebufferDepthAttachments(Un(I.format),I.format!==19,I.width,I.height,h,I.format,!0):O=this._createRenderBuffer(I.width,I.height,h,-1,this._getRGBABufferInternalSizedFormat(I.type,I.format,I._useSRGBBuffer),-1),!O)throw new Error("Unable to create render buffer");I._autoMSAAManagement=!0;let U=I._hardwareTexture;U||(U=I._hardwareTexture=this._createHardwareTexture()),U.addMSAARenderBuffer(O)}return I}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,r,n=3,a=null,o=null,l=null,c=null,f=null,h=null,d,u,m,p){return this._createTextureBase(e,t,i,r,n,a,o,(..._)=>this._prepareWebGLTexture(..._,f),(_,g,v,I,x,T)=>{let A=this._gl,R=v.width===_&&v.height===g;x._creationFlags=m!=null?m:0;let P=this._getTexImageParametersForCreateTexture(x.format,x._useSRGBBuffer);if(R)return A.texImage2D(A.TEXTURE_2D,0,P.internalFormat,P.format,P.type,v),!1;let D=this._caps.maxTextureSize;if(v.width>D||v.height>D||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=_,this._workingCanvas.height=g,this._workingContext.drawImage(v,0,0,v.width,v.height,0,0,_,g),A.texImage2D(A.TEXTURE_2D,0,P.internalFormat,P.format,P.type,this._workingCanvas),x.width=_,x.height=g),!1;{let M=new Dt(this,2);this._bindTextureDirectly(A.TEXTURE_2D,M,!0),A.texImage2D(A.TEXTURE_2D,0,P.internalFormat,P.format,P.type,v),this._rescaleTexture(M,x,r,P.format,()=>{this._releaseTexture(M),this._bindTextureDirectly(A.TEXTURE_2D,x,!0),T()})}return!0},l,c,f,h,d,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,n){}_unpackFlipY(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))}_getUnpackAlignement(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)}_getTextureTarget(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D}updateTextureSamplingMode(e,t,i=!1){let r=this._getTextureTarget(t),n=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(r,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(r,this._gl.TEXTURE_MIN_FILTER,n.min),i&&n.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 n=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&r!==null&&(this._setTextureParameterInteger(n,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(r),e),e._cachedWrapR=r),this._bindTextureDirectly(n,null)}_uploadCompressedDataToTextureDirectly(e,t,i,r,n,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,n)}else this._gl.compressedTexImage2D(c,o,t,i,r,0,n)}_uploadDataToTextureDirectly(e,t,i=0,r=0,n,a=!1){let o=this._gl,l=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),f=n===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(n,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let h=o.TEXTURE_2D;e.isCube&&(h=o.TEXTURE_CUBE_MAP_POSITIVE_X+i);let d=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(d-r,0)),p=a?e.height:Math.pow(2,Math.max(u-r,0));o.texImage2D(h,r,f,m,p,0,c,l,t)}updateTextureData(e,t,i,r,n,a,o=0,l=0,c=!1){let f=this._gl,h=this._getWebGLTextureType(e.type),d=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,n,a,d,h,t),c&&this._gl.generateMipmap(m),this._bindTextureDirectly(u,null)}_uploadArrayBufferViewToTexture(e,t,i=0,r=0){let n=this._gl,a=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(a,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(a,null,!0)}_prepareWebGLTextureContinuation(e,t,i,r,n){let a=this._gl;if(!a)return;let o=this._getSamplingParameters(n,!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,n,a,o,l,c,f){let h=this.getCaps().maxTextureSize,d=Math.min(h,this.needPOTTextures?dr(r.width,h):r.width),u=Math.min(h,this.needPOTTextures?dr(r.height,h):r.height),m=this._gl;if(m){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(m.TEXTURE_2D,e,!0),this._unpackFlipY(n===void 0?!0:!!n),e.baseWidth=r.width,e.baseHeight=r.height,e.width=d,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(d,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,n=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,n,l.DEPTH_STENCIL,c,o?-1:l.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,r,n,c,c,o?-1:l.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,r,n,c,c,o?-1:l.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,r,n,a,o=!0){let c=this._gl.createRenderbuffer();return this._updateRenderBuffer(c,e,t,i,r,n,a,o)}_updateRenderBuffer(e,t,i,r,n,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,n,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&&(Vx(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 X.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&&(n=!0,this._activateCurrentTexture());return a&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),n}_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,n=""){if(!t)return this._boundTexturesCache[e]!=null&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;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 n=0;n=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){this._compiledEffects={},this.onReleaseEffectsObservable.notifyObservers(this)}dispose(){var e;Ft()&&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()),bd(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 n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),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(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i}_getWebGLTextureType(e){if(this._webGLVersion===1){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE}_getInternalFormat(e,t=!1){let i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case 0:i=this._gl.ALPHA;break;case 1:i=this._gl.LUMINANCE;break;case 2:i=this._gl.LUMINANCE_ALPHA;break;case 6:case 33322:case 36760:i=this._gl.RED;break;case 7:case 33324:case 36761:i=this._gl.RG;break;case 4:case 32852:case 36762:i=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case 5:case 32859:case 36763:i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;break}if(this._webGLVersion>1)switch(e){case 8:i=this._gl.RED_INTEGER;break;case 9:i=this._gl.RG_INTEGER;break;case 10:i=this._gl.RGB_INTEGER;break;case 11:i=this._gl.RGBA_INTEGER;break}return i}_getRGBABufferInternalSizedFormat(e,t,i=!1){if(this._webGLVersion===1){if(t!==void 0)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return i?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return i?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case 5:return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case 4:switch(t){case 8:return this._gl.R16I;case 36760:return this._gl.R16_SNORM_EXT;case 36761:return this._gl.RG16_SNORM_EXT;case 36762:return this._gl.RGB16_SNORM_EXT;case 36763:return this._gl.RGBA16_SNORM_EXT;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;case 11:return this._gl.RGBA16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 33322:return this._gl.R16_EXT;case 33324:return this._gl.RG16_EXT;case 32852:return this._gl.RGB16_EXT;case 32859:return this._gl.RGBA16_EXT;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;case 11:return this._gl.RGBA16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;case 11:return this._gl.RGBA32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;case 11:return this._gl.RGBA32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;case 5:return this._gl.RGBA32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;case 5:return this._gl.RGBA16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8}readPixels(e,t,i,r,n=!0,a=!0,o=null){let l=n?4:3,c=n?this._gl.RGBA:this._gl.RGB,f=i*r*l;if(!o)o=new Uint8Array(f);else if(o.length{Bn();jd=class{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new gg(e)}sampleFrame(e=Xt.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()}},gg=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 dI=C(()=>{ur();He.prototype.setAlphaMode=function(s,e=!1,t=0){if(this._alphaMode[t]===s){if(!e){let r=s===0;this.depthCullingState.depthMask!==r&&(this.depthCullingState.depthMask=r)}return}let i=s===0;this._alphaState.setAlphaBlend(!i,t),this._alphaState.setAlphaMode(s,t),e||(this.depthCullingState.depthMask=i),this._alphaMode[t]=s}});function uI(s,e,t,i){let r,n=1;i===1?r=new Float32Array(e*t*4):i===2?(r=new Uint16Array(e*t*4),n=15360):i===7?r=new Uint32Array(e*t*4):r=new Uint8Array(e*t*4);for(let a=0;a{Dr();We();ur();js();He.prototype.updateRawTexture=function(s,e,t,i,r=null,n=0,a=!1){if(!s)return;let o=this._getRGBABufferInternalSizedFormat(n,t,a),l=this._getInternalFormat(t),c=this._getWebGLTextureType(n);this._bindTextureDirectly(this._gl.TEXTURE_2D,s,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(s._bufferView=e,s.format=t,s.type=n,s.invertY=i,s._compression=r),s.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],s.width,s.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,s.width,s.height,0,l,c,e),s.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),s.isReady=!0};He.prototype.createRawTexture=function(s,e,t,i,r,n,a,o=null,l=0,c=0,f=!1){let h=new Dt(this,3);h.baseWidth=e,h.baseHeight=t,h.width=e,h.height=t,h.format=i,h.generateMipMaps=r,h.samplingMode=a,h.invertY=n,h._compression=o,h.type=l,h._useSRGBBuffer=this._getUseSRGBBuffer(f,!r),this._doNotHandleContextLost||(h._bufferView=s),this.updateRawTexture(h,s,i,n,o,l,h._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,h,!0);let d=this._getSamplingParameters(a,r);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,d.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,d.min),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(h),h};He.prototype.createRawCubeTexture=function(s,e,t,i,r,n,a,o=null){let l=this._gl,c=new Dt(this,8);c.isCube=!0,c.format=t,c.type=i,this._doNotHandleContextLost||(c._bufferViewArray=s);let f=this._getWebGLTextureType(i),h=this._getInternalFormat(t);h===l.RGB&&(h=l.RGBA),f===l.FLOAT&&!this._caps.textureFloatLinearFiltering?(r=!1,a=1,X.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,X.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,X.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):f===l.HALF_FLOAT&&!this._caps.colorBufferFloat&&(r=!1,X.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));let d=e,u=d;if(c.width=d,c.height=u,c.invertY=n,c._compression=o,!this.needPOTTextures||jo(c.width)&&jo(c.height)||(r=!1),s)this.updateRawCubeTexture(c,s,t,i,n,o);else{let _=this._getRGBABufferInternalSizedFormat(i),g=0;this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c,!0);for(let v=0;v<6;v++)o?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+v,g,this.getCaps().s3tc[o],c.width,c.height,0,void 0):l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+v,g,_,c.width,c.height,0,h,f,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c,!0),s&&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};He.prototype.updateRawCubeTexture=function(s,e,t,i,r,n=null,a=0){s._bufferViewArray=e,s.format=t,s.type=i,s.invertY=r,s._compression=n;let o=this._gl,l=this._getWebGLTextureType(i),c=this._getInternalFormat(t),f=this._getRGBABufferInternalSizedFormat(i),h=!1;c===o.RGB&&(c=o.RGBA,h=!0),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,s,!0),this._unpackFlipY(r===void 0?!0:!!r),s.width%4!==0&&o.pixelStorei(o.UNPACK_ALIGNMENT,1);for(let u=0;u<6;u++){let m=e[u];n?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,this.getCaps().s3tc[n],s.width,s.height,0,m):(h&&(m=uI(m,s.width,s.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+u,a,f,s.width,s.height,0,c,l,m))}(!this.needPOTTextures||jo(s.width)&&jo(s.height))&&s.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),s.isReady=!0};He.prototype.createRawCubeTextureFromUrl=function(s,e,t,i,r,n,a,o,l=null,c=null,f=3,h=!1){let d=this._gl,u=this.createRawCubeTexture(null,t,i,r,!n,h,f,null);e==null||e.addPendingData(u),u.url=s,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 v=g instanceof Promise?await g:g,I=u.width;if(o){let x=this._getWebGLTextureType(r),T=this._getInternalFormat(i),A=this._getRGBABufferInternalSizedFormat(r),R=!1;T===d.RGB&&(T=d.RGBA,R=!0),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,u,!0),this._unpackFlipY(!1);let P=o(v);for(let D=0;D>D;for(let F=0;F<6;F++){let N=P[D][F];R&&(N=uI(N,M,M,r)),d.texImage2D(F,D,A,M,M,0,T,x,N)}}this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(u,v,i,r,h);u.isReady=!0,e==null||e.removePendingData(u),u.onLoadedObservable.notifyObservers(u),u.onLoadedObservable.clear(),l&&l()};return this._loadFile(s,_=>{p(_).catch(g=>{m(void 0,g)})},void 0,e==null?void 0:e.offlineProvider,!0,m),u};He.prototype.createRawTexture2DArray=mI(!1);He.prototype.createRawTexture3D=mI(!0);He.prototype.updateRawTexture2DArray=pI(!1);He.prototype.updateRawTexture3D=pI(!0)});var gI=C(()=>{ur();wa();He.prototype._readTexturePixelsSync=function(s,e,t,i=-1,r=0,n=null,a=!0,o=!1,l=0,c=0){var d,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&&(s.is2DArray||s.is3D)?f.framebufferTextureLayer(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,(d=s._hardwareTexture)==null?void 0:d.underlyingResource,r,i):i>-1?f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+i,(u=s._hardwareTexture)==null?void 0:u.underlyingResource,r):f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,(m=s._hardwareTexture)==null?void 0:m.underlyingResource,r);let h=s.type!==void 0?this._getWebGLTextureType(s.type):f.UNSIGNED_BYTE;if(o)n||(n=Nx(s.type,4*e*t));else switch(h){case f.UNSIGNED_BYTE:n||(n=new Uint8Array(4*e*t)),h=f.UNSIGNED_BYTE;break;default:n||(n=new Float32Array(4*e*t)),h=f.FLOAT;break}return a&&this.flushFramebuffer(),f.readPixels(l,c,e,t,f.RGBA,h,n),f.bindFramebuffer(f.FRAMEBUFFER,this._currentFramebuffer),n};He.prototype._readTexturePixels=function(s,e,t,i=-1,r=0,n=null,a=!0,o=!1,l=0,c=0){return Promise.resolve(this._readTexturePixelsSync(s,e,t,i,r,n,a,o,l,c))}});var EI=C(()=>{ur();He.prototype.updateDynamicIndexBuffer=function(s,e,t=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(s);let i;s.is32Bits?i=e instanceof Uint32Array?e:new Uint32Array(e):i=e instanceof Uint16Array?e:new Uint16Array(e),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()};He.prototype.updateDynamicVertexBuffer=function(s,e,t,i){this.bindArrayBuffer(s),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 vI=C(()=>{ur();Dr();We();js();He.prototype._createDepthStencilCubeTexture=function(s,e){let t=new Dt(this,12);if(t.isCube=!0,this.webGLVersion===1)return X.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,s,i.bilinearFiltering,i.comparisonFunction);for(let n=0;n<6;n++)i.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r.DEPTH24_STENCIL8,s,s,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r.DEPTH_COMPONENT24,s,s,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(t),t};He.prototype._setCubeMapTextureParams=function(s,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),s.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&t!==void 0&&t>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,t),s._maxLodLevel=t),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};He.prototype.createCubeTexture=function(s,e,t,i,r=null,n=null,a,o=null,l=!1,c=0,f=0,h=null,d,u=!1,m=null){let p=this._gl;return this.createCubeTextureBase(s,e,t,!!i,r,n,a,o,l,c,f,h,_=>this._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),(_,g)=>{let v=this.needPOTTextures?dr(g[0].width,this._caps.maxCubemapTextureSize):g[0].width,I=v,x=[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 T=a?this._getInternalFormat(a,_._useSRGBBuffer):_._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:p.RGBA,A=a?this._getInternalFormat(a):p.RGBA;_._useSRGBBuffer&&this.webGLVersion===1&&(A=T);for(let R=0;R{jf();Zd=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=Un(e.format))}get depthStencilTextureWithStencil(){return this._depthStencilTextureWithStencil}get isCube(){return this._isCube}get isMulti(){return this._isMulti}get is2DArray(){return this.layers>0}get is3D(){return this.depth>0}get size(){return this.width}get width(){var e;return(e=this._size.width)!=null?e:this._size}get height(){var e;return(e=this._size.height)!=null?e:this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){var e,t;return(t=(e=this._textures)==null?void 0:e[0])!=null?t:null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){var n,a,o,l;if(!this._textures)return-1;let t=this._textures[e],i=(a=(n=this._layerIndices)==null?void 0:n[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,n){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=i,this._engine=r,this._depthStencilTexture=null,this.label=n}setTextures(e){Array.isArray(e)?this._textures=e:e?this._textures=[e]:this._textures=null}setTexture(e,t=0,i=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&i&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,i){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),t!==void 0&&t>=0&&(this._layerIndices[e]=t),i!==void 0&&i>=0&&(this._faceIndices[e]=i)}createDepthStencilTexture(e=0,t=!0,i=!1,r=1,n=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:n,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,n,a,o,l,c;let e=null;if(this._isMulti){let f=this.textures;if(f&&f.length>0){let h=!1,d=f.length,u=-1,m=f[f.length-1]._source;(m===14||m===12)&&(h=!0,u=f[f.length-1].format,d--);let p=[],_=[],g=[],v=[],I=[],x=[],T=[],A={};for(let D=0;D1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e{SI();jf();qd=class extends Zd{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;let i=this._engine,r=this._context,n=e._hardwareTexture;if(n&&e._autoMSAAManagement&&this._MSAAFramebuffer){let a=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,Un(e.format)?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,r.RENDERBUFFER,n.getMSAARenderBuffer()),i._bindUnboundFramebuffer(a)}}constructor(e,t,i,r,n){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=n}_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,n=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,n,a)}shareDepth(e){super.shareDepth(e);let t=this._context,i=this._depthStencilBuffer,r=e._MSAAFramebuffer||e._framebuffer,n=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;n._bindUnboundFramebuffer(r),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),n._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,r=0){var f,h,d,u;let n=e._hardwareTexture;if(!n)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=(h=i!=null?i:(f=this.layerIndices)==null?void 0:f[t])!=null?h:0,m.framebufferTextureLayer(m.FRAMEBUFFER,c,n.underlyingResource,r,i)):e.isCube?(i=(u=i!=null?i:(d=this.faceIndices)==null?void 0:d[t])!=null?u:0,m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_CUBE_MAP_POSITIVE_X+i,n.underlyingResource,r)):m.framebufferTexture2D(m.FRAMEBUFFER,c,m.TEXTURE_2D,n.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,n.underlyingResource,r)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){let m=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),m.framebufferRenderbuffer(m.FRAMEBUFFER,c,m.RENDERBUFFER,n.getMSAARenderBuffer())}o._bindUnboundFramebuffer(l)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){var r,n;if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;let i=(n=(r=this._attachments)==null?void 0:r.length)!=null?n:this.textures.length;for(let a=0;a{ci();he.prototype.createDepthStencilTexture=function(s,e,t){if(e.isCube){let i=s.width||s;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(s,e,t)}});var AI=C(()=>{Dr();We();ur();TI();jf();Eg();He.prototype._createHardwareRenderTargetWrapper=function(s,e,t){let i=new qd(s,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};He.prototype.createRenderTargetTexture=function(s,e){var p,_;let t=this._createHardwareRenderTargetWrapper(!1,!1,s),i=!0,r=!1,n=!1,a,o=1,l;e!==void 0&&typeof e=="object"&&(i=(p=e.generateDepthBuffer)!=null?p:!0,r=!!e.generateStencilBuffer,n=!!e.noColorAttachment,a=e.colorAttachment,o=(_=e.samples)!=null?_:1,l=e.label);let c=a||(n?null:this._createInternalTexture(s,e,!0,5)),f=s.width||s,h=s.height||s,d=this._currentFramebuffer,u=this._gl,m=u.createFramebuffer();if(this._bindUnboundFramebuffer(m),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(r,i,f,h),c&&!c.is2DArray&&!c.is3D&&u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,c._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(d),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};He.prototype._createDepthStencilTexture=function(s,e,t){var u;let i=this._gl,r=s.layers||0,n=s.depth||0,a=i.TEXTURE_2D;r!==0?a=i.TEXTURE_2D_ARRAY:n!==0&&(a=i.TEXTURE_3D);let o=new Dt(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return X.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,s,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 X.Error(`Depth texture ${l.depthTextureFormat} format is not supported.`),o;o.format=l.depthTextureFormat}else o.format=l.generateStencil?13:16;let c=Un(o.format),f=this._getWebGLTextureTypeFromDepthTextureFormat(o.format),h=c?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,d=this._getInternalFormatFromDepthTextureFormat(o.format,!0,c);return o.is2DArray?i.texImage3D(a,0,d,o.width,o.height,r,0,h,f,null):o.is3D?i.texImage3D(a,0,d,o.width,o.height,n,0,h,f,null):i.texImage2D(a,0,d,o.width,o.height,0,h,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};He.prototype.updateRenderTargetTextureSampleCount=function(s,e){var n,a;if(this.webGLVersion<2||!s)return 1;if(s.samples===e)return e;let t=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),s._depthStencilBuffer&&(t.deleteRenderbuffer(s._depthStencilBuffer),s._depthStencilBuffer=null),s._MSAAFramebuffer&&(t.deleteFramebuffer(s._MSAAFramebuffer),s._MSAAFramebuffer=null);let i=(n=s.texture)==null?void 0:n._hardwareTexture;if(i==null||i.releaseMSAARenderBuffers(),s.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){let o=t.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");s._MSAAFramebuffer=o,this._bindUnboundFramebuffer(s._MSAAFramebuffer);let l=this._createRenderBuffer(s.texture.width,s.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(s.texture.type,s.texture.format,s.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=s._MSAAFramebuffer)!=null?a:s._framebuffer),s.texture&&(s.texture.samples=e),s._samples=e;let r=s._depthStencilTexture?s._depthStencilTexture.format:void 0;return s._depthStencilBuffer=this._setupFramebufferDepthAttachments(s._generateStencilBuffer,s._generateDepthBuffer,s.width,s.height,e,r),this._bindUnboundFramebuffer(null),e};He.prototype._setupDepthStencilTexture=function(s,e,t,i,r=1){var d,u;let n=(d=e.width)!=null?d:e,a=(u=e.height)!=null?u:e,o=e.layers||0,l=e.depth||0;s.baseWidth=n,s.baseHeight=a,s.width=n,s.height=a,s.is2DArray=o>0,s.depth=o||l,s.isReady=!0,s.samples=r,s.generateMipMaps=!1,s.samplingMode=t?2:1,s.type=0,s._comparisonFunction=i;let c=this._gl,f=this._getTextureTarget(s),h=this._getSamplingParameters(s.samplingMode,!1);c.texParameteri(f,c.TEXTURE_MAG_FILTER,h.mag),c.texParameteri(f,c.TEXTURE_MIN_FILTER,h.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 RI=C(()=>{ur();He.prototype.setDepthStencilTexture=function(s,e,t,i){s!==void 0&&(e&&(this._boundUniforms[s]=e),!t||!t.depthStencilTexture?this._setTexture(s,null,void 0,void 0,i):this._setTexture(s,t,!1,!0,i))}});var xI=C(()=>{Dr();We();ur();He.prototype.createRenderTargetCubeTexture=function(s,e){let t=this._createHardwareRenderTargetWrapper(!1,!0,s),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,n=new Dt(this,5);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,n,!0);let a=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,X.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),s,s,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,s,s),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,n.width=s,n.height=s,n.isReady=!0,n.isCube=!0,n.samples=1,n.generateMipMaps=i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,this._internalTexturesCache.push(n),t.setTextures(n),t}});var II,zl,Yt,je,Wi=C(()=>{II=.45454545454545453,zl=2.2,Yt=(1+Math.sqrt(5))/2,je=.001});function bi(s,e){let t=[];for(let i=0;i{let n=r.previous;if(!n)return;let a=r.next;a?(n.next=a,a.previous=n):(n.next=void 0,s[e]=n),r.next=void 0,r.previous=void 0}}function Qd(s,e){let t=Pk.map(i=>Dk(s,i,e));return()=>{for(let i of t)i==null||i()}}var Pk,Zs=C(()=>{Pk=["push","splice","pop","shift","unshift"]});function Ke(s,e){CI[s]=e}function Ni(s){return CI[s]}var CI,Pt=C(()=>{CI={}});var Ag={};Ie(Ag,{Clamp:()=>Ye,DeltaAngle:()=>bI,Denormalize:()=>Uk,ExtractAsInt:()=>Lk,Hermite:()=>vg,Hermite1stDerivative:()=>wk,HighestCommonFactor:()=>Zo,ILog2:()=>Tg,InverseLerp:()=>Fk,Lerp:()=>Kr,LerpAngle:()=>Nk,MoveTowards:()=>MI,MoveTowardsAngle:()=>kk,Normalize:()=>Bk,NormalizeRadians:()=>Sg,OutsideRange:()=>Ok,PercentToRange:()=>Hk,PingPong:()=>Vk,RandomRange:()=>Tt,RangeToPercent:()=>Wk,Repeat:()=>Jd,SmoothStep:()=>Gk,ToHex:()=>jr,WithinEpsilon:()=>mt});function Lk(s){return parseInt(s.toString().replace(/\W/g,""))}function mt(s,e,t=1401298e-51){return Math.abs(s-e)<=t}function Ok(s,e,t,i=1401298e-51){return st+i}function Tt(s,e){return s===e?s:Math.random()*(e-s)+s}function Kr(s,e,t){return s+(e-s)*t}function Nk(s,e,t){let i=Jd(e-s,360);return i>180&&(i-=360),s+i*Ye(t)}function Fk(s,e,t){let i;return s!=e?i=Ye((t-s)/(e-s)):i=0,i}function vg(s,e,t,i,r){let n=r*r,a=r*n,o=2*a-3*n+1,l=-2*a+3*n,c=a-2*n+r,f=a-n;return s*o+t*l+e*c+i*f}function wk(s,e,t,i,r){let n=r*r;return(n-r)*6*s+(3*n-4*r+1)*e+(-n+r)*6*t+(3*n-2*r)*i}function Ye(s,e=0,t=1){return Math.min(t,Math.max(e,s))}function Sg(s){return s-=Math.PI*2*Math.floor((s+Math.PI)/(Math.PI*2)),s}function jr(s){let e=s.toString(16);return s<=15?("0"+e).toUpperCase():e.toUpperCase()}function Tg(s){if(Math.log2)return Math.floor(Math.log2(s));if(s<0)return NaN;if(s===0)return-1/0;let e=0;if(s<1){for(;s<1;)e++,s=s*2;e=-e}else if(s>1)for(;s>1;)e++,s=Math.floor(s/2);return e}function Jd(s,e){return s-Math.floor(s/e)*e}function Bk(s,e,t){return(s-e)/(t-e)}function Uk(s,e,t){return s*(t-e)+e}function bI(s,e){let t=Jd(e-s,360);return t>180&&(t-=360),t}function Vk(s,e){let t=Jd(s,e*2);return e-Math.abs(t-e)}function Gk(s,e,t){let i=Ye(t);return i=-2*i*i*i+3*i*i,e*i+s*(1-i)}function MI(s,e,t){let i;return Math.abs(e-s)<=t?i=e:i=s+Math.sign(e-s)*t,i}function kk(s,e,t){let i=bI(s,e),r;return-t{});function yI(s){s.updateFlag=Xl._UpdateFlagSeed++}function Rg(s,e,t,i=0){let r=s.asArray(),n=e.asArray(),a=r[0],o=r[1],l=r[2],c=r[3],f=r[4],h=r[5],d=r[6],u=r[7],m=r[8],p=r[9],_=r[10],g=r[11],v=r[12],I=r[13],x=r[14],T=r[15],A=n[0],R=n[1],P=n[2],D=n[3],M=n[4],F=n[5],N=n[6],V=n[7],O=n[8],U=n[9],k=n[10],z=n[11],Z=n[12],J=n[13],q=n[14],Y=n[15];t[i]=a*A+o*M+l*O+c*Z,t[i+1]=a*R+o*F+l*U+c*J,t[i+2]=a*P+o*N+l*k+c*q,t[i+3]=a*D+o*V+l*z+c*Y,t[i+4]=f*A+h*M+d*O+u*Z,t[i+5]=f*R+h*F+d*U+u*J,t[i+6]=f*P+h*N+d*k+u*q,t[i+7]=f*D+h*V+d*z+u*Y,t[i+8]=m*A+p*M+_*O+g*Z,t[i+9]=m*R+p*F+_*U+g*J,t[i+10]=m*P+p*N+_*k+g*q,t[i+11]=m*D+p*V+_*z+g*Y,t[i+12]=v*A+I*M+x*O+T*Z,t[i+13]=v*R+I*F+x*U+T*J,t[i+14]=v*P+I*N+x*k+T*q,t[i+15]=v*D+I*V+x*z+T*Y}function qo(s,e,t,i=0){Rg(s,e,t.asArray(),i),yI(t)}function DI(s,e,t=0){let i=s.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 Zf(s,e){let t=xg(s,e.asArray());return t&&yI(e),t}function xg(s,e){let t=s.asArray(),i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],c=t[6],f=t[7],h=t[8],d=t[9],u=t[10],m=t[11],p=t[12],_=t[13],g=t[14],v=t[15],I=u*v-g*m,x=d*v-_*m,T=d*g-_*u,A=h*v-p*m,R=h*g-u*p,P=h*_-p*d,D=+(l*I-c*x+f*T),M=-(o*I-c*A+f*R),F=+(o*x-l*A+f*P),N=-(o*T-l*R+c*P),V=i*D+r*M+n*F+a*N;if(V===0)return!1;let O=1/V,U=c*v-g*f,k=l*v-_*f,z=l*g-_*c,Z=o*v-p*f,J=o*g-p*c,q=o*_-p*l,Y=c*m-u*f,K=l*m-d*f,j=l*u-d*c,ee=o*m-h*f,be=o*u-h*c,_e=o*d-h*l,pe=-(r*I-n*x+a*T),te=+(i*I-n*A+a*R),le=-(i*x-r*A+a*P),xe=+(i*T-r*R+n*P),ce=+(r*U-n*k+a*z),de=-(i*U-n*Z+a*J),ke=+(i*k-r*Z+a*q),Ze=-(i*z-r*J+n*q),Fe=-(r*Y-n*K+a*j),Xe=+(i*Y-n*ee+a*be),St=-(i*K-r*ee+a*_e),bt=+(i*j-r*be+n*_e);return e[0]=D*O,e[1]=pe*O,e[2]=ce*O,e[3]=Fe*O,e[4]=M*O,e[5]=te*O,e[6]=de*O,e[7]=Xe*O,e[8]=F*O,e[9]=le*O,e[10]=ke*O,e[11]=St*O,e[12]=N*O,e[13]=xe*O,e[14]=Ze*O,e[15]=bt*O,!0}var Xl,Ig=C(()=>{Xl=class{};Xl._UpdateFlagSeed=0});var tr,me,S,ft,Se,H,Re,W,Qo,Ee=C(()=>{Wi();Zs();Pt();cg();gt();Mi();Ig();tr=s=>parseInt(s.toString().replace(/\W/g,"")),me=class s{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=tr(this.x),t=tr(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 s.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 s(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 s(this.x+e.x,this.y+e.y)}subtract(e){return new s(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 s(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 s(this.x*e,this.y*t)}divide(e){return new s(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 s(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 s(-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 s(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=je){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 s(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 s(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 s)}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 s;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 s(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new s(0,0)}static One(){return new s(1,1)}static Random(e=0,t=1){return new s(Tt(e,t),Tt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Tt(e,t),Tt(e,t))}static get ZeroReadOnly(){return s._ZeroReadOnly}static FromArray(e,t=0){return new s(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,n){let a=n*n,o=n*a,l=.5*(2*t.x+(-e.x+i.x)*n+(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)*n+(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 s(l,c)}static ClampToRef(e,t,i,r){return r.x=Ye(e.x,t.x,i.x),r.y=Ye(e.y,t.y,i.y),r}static Clamp(e,t,i){let r=Ye(e.x,t.x,i.x),n=Ye(e.y,t.y,i.y);return new s(r,n)}static Hermite(e,t,i,r,n){let a=n*n,o=n*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+n,h=o-a,d=e.x*l+i.x*c+t.x*f+r.x*h,u=e.y*l+i.y*c+t.y*f+r.y*h;return new s(d,u)}static Hermite1stDerivative(e,t,i,r,n){return this.Hermite1stDerivativeToRef(e,t,i,r,n,new s)}static Hermite1stDerivativeToRef(e,t,i,r,n,a){let o=n*n;return a.x=(o-n)*6*e.x+(3*o-4*n+1)*t.x+(-o+n)*6*i.x+(3*o-2*n)*r.x,a.y=(o-n)*6*e.y+(3*o-4*n+1)*t.y+(-o+n)*6*i.y+(3*o-2*n)*r.y,a}static Lerp(e,t,i){return s.LerpToRef(e,t,i,new s)}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 s.NormalizeToRef(e,new s)}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 s(i,r)}static Transform(e,t){return s.TransformToRef(e,t,new s)}static TransformToRef(e,t,i){let r=t.m,n=e.x*r[0]+e.y*r[4]+r[12],a=e.x*r[1]+e.y*r[5]+r[13];return i.x=n,i.y=a,i}static PointInTriangle(e,t,i,r){let n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),a=n<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*n*a}static Distance(e,t){return Math.sqrt(s.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 s.CenterToRef(e,t,new s)}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=s.DistanceSquared(t,i);if(r===0)return s.Distance(e,t);let n=i.subtract(t),a=Math.max(0,Math.min(1,s.Dot(e.subtract(t),n)/r)),o=t.add(n.multiplyByFloats(a,a));return s.Distance(e,o)}};me._V8PerformanceHack=new me(.5,.5);me._ZeroReadOnly=me.Zero();Object.defineProperties(me.prototype,{dimension:{value:[2]},rank:{value:1}});S=class s{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=tr(this._x),t=tr(this._y),i=tr(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 s.FromArrayToRef(e,t,this),this}toQuaternion(){return Se.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 s(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 s(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 s(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 s(-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 s(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 n=t*Math.sin(i)*Math.cos(r),a=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(r);return e.set(n,a,o),e}applyRotationQuaternionToRef(e,t){let i=this._x,r=this._y,n=this._z,a=e._x,o=e._y,l=e._z,c=e._w,f=2*(o*n-l*r),h=2*(l*i-a*n),d=2*(a*r-o*i);return t._x=i+c*f+o*d-l*h,t._y=r+c*h+l*f-a*d,t._z=n+c*d+a*h-o*f,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new s)}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 s)}projectOnPlaneToRef(e,t,i){let r=e.normal,n=e.d,a=Re.Vector3[0];this.subtractToRef(t,a),a.normalize();let o=s.Dot(a,r);if(Math.abs(o)<1e-10)i.setAll(1/0);else{let l=-(s.Dot(t,r)+n)/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=je){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 s(this._x*e,this._y*t,this._z*i)}divide(e){return new s(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 s(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 s(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=Re.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(Re.Matrix[0]),s.TransformCoordinatesToRef(this,Re.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,Re.Vector3[0]),Re.Vector3[0].rotateByQuaternionToRef(e,Re.Vector3[0]),t.addToRef(Re.Vector3[0],i),i}cross(e){return s.CrossToRef(this,e,new s)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new s)}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 s(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 n=s.Dot(e,i),a=s.Dot(t,i);return(n-r)/(n-a)}static GetAngleBetweenVectors(e,t,i){let r=e.normalizeToRef(Re.Vector3[1]),n=t.normalizeToRef(Re.Vector3[2]),a=s.Dot(r,n);a=Ye(a,-1,1);let o=Math.acos(a),l=Re.Vector3[3];return s.CrossToRef(r,n,l),s.Dot(l,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,t,i){Re.Vector3[0].copyFrom(e);let r=Re.Vector3[0];Re.Vector3[1].copyFrom(t);let n=Re.Vector3[1];Re.Vector3[2].copyFrom(i);let a=Re.Vector3[2],o=Re.Vector3[3],l=Re.Vector3[4];r.normalize(),n.normalize(),a.normalize(),s.CrossToRef(a,r,o),s.CrossToRef(o,a,l);let c=Math.atan2(s.Dot(n,o),s.Dot(n,l));return Sg(c)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){let r=W.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=s.Zero();return s.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,r){i=Ye(i,0,1);let n=Re.Vector3[0],a=Re.Vector3[1];n.copyFrom(e);let o=n.length();n.normalizeFromLength(o),a.copyFrom(t);let l=a.length();a.normalizeFromLength(l);let c=s.Dot(n,a),f,h;if(c<1-je){let d=Math.acos(c),u=1/Math.sin(d);f=Math.sin((1-i)*d)*u,h=Math.sin(i*d)*u}else f=1-i,h=i;return n.scaleInPlace(f),a.scaleInPlace(h),r.copyFrom(n).addInPlace(a),r.scaleInPlace(Kr(o,l,i)),r}static SmoothToRef(e,t,i,r,n){return s.SlerpToRef(e,t,r===0?1:i/r,n),n}static FromArray(e,t=0){return new s(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return s.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 s.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,r){return r.copyFromFloats(e,t,i),r}static Zero(){return new s(0,0,0)}static One(){return new s(1,1,1)}static Up(){return new s(0,1,0)}static get UpReadOnly(){return s._UpReadOnly}static get DownReadOnly(){return s._DownReadOnly}static get RightReadOnly(){return s._RightReadOnly}static get LeftReadOnly(){return s._LeftReadOnly}static get LeftHandedForwardReadOnly(){return s._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return s._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return s._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return s._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return s._ZeroReadOnly}static get OneReadOnly(){return s._OneReadOnly}static Down(){return new s(0,-1,0)}static Forward(e=!1){return new s(0,0,e?-1:1)}static Backward(e=!1){return new s(0,0,e?1:-1)}static Right(){return new s(1,0,0)}static Left(){return new s(-1,0,0)}static Random(e=0,t=1){return new s(Tt(e,t),Tt(e,t),Tt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Tt(e,t),Tt(e,t),Tt(e,t))}static TransformCoordinates(e,t){let i=s.Zero();return s.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return s.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,n){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 n._x=o*f,n._y=l*f,n._z=c*f,n._isDirty=!0,n}static TransformNormal(e,t){let i=s.Zero();return s.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,n){let a=r.m;return n._x=e*a[0]+t*a[4]+i*a[8],n._y=e*a[1]+t*a[5]+i*a[9],n._z=e*a[2]+t*a[6]+i*a[10],n._isDirty=!0,n}static CatmullRom(e,t,i,r,n){let a=n*n,o=n*a,l=.5*(2*t._x+(-e._x+i._x)*n+(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)*n+(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)*n+(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 s(l,c,f)}static Clamp(e,t,i){let r=new s;return s.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){let n=e._x;n=n>i._x?i._x:n,n=ni._y?i._y:a,a=ai._z?i._z:o,o=o0&&M<0?(N.copyFrom(a),V=t,O=i):M>0&&F<0?(N.copyFrom(l),V=i,O=r):(N.copyFrom(o).scaleInPlace(-1),V=r,O=t);let U=Re.Vector3[9],k=Re.Vector3[4];if(V.subtractToRef(v,A),O.subtractToRef(v,U),s.CrossToRef(A,U,k),!(s.Dot(k,c)<0))return n.copyFrom(v),Math.abs(p*_);let Z=Re.Vector3[5];s.CrossToRef(N,k,Z),Z.normalize();let J=Re.Vector3[9];J.copyFrom(V).subtractInPlace(v);let q=J.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 s(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 s(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 s)}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 S(this._x,this._y,this._z)}clone(){return new s(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 s(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 s.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,r,n){return n.x=e,n.y=t,n.z=i,n.w=r,n}static Zero(){return new s(0,0,0,0)}static One(){return new s(1,1,1,1)}static Random(e=0,t=1){return new s(Tt(e,t),Tt(e,t),Tt(e,t),Tt(e,t))}static RandomToRef(e=0,t=1,i){return i.x=Tt(e,t),i.y=Tt(e,t),i.z=Tt(e,t),i.w=Tt(e,t),i}static Clamp(e,t,i){return s.ClampToRef(e,t,i,new s)}static ClampToRef(e,t,i,r){return r.x=Ye(e.x,t.x,i.x),r.y=Ye(e.y,t.y,i.y),r.z=Ye(e.z,t.z,i.z),r.w=Ye(e.w,t.w,i.w),r}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return s._ZeroReadOnly}static Normalize(e){return s.NormalizeToRef(e,new s)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){let i=new s;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){let i=new s;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(s.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,a=e.w-t.w;return i*i+r*r+n*n+a*a}static Center(e,t){return s.CenterToRef(e,t,new s)}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 s.TransformCoordinatesToRef(e,t,new s)}static TransformCoordinatesToRef(e,t,i){return s.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,r,n){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 n.x=o,n.y=l,n.z=c,n.w=f,n}static TransformNormal(e,t){return s.TransformNormalToRef(e,t,new s)}static TransformNormalToRef(e,t,i){let r=t.m,n=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=n,i.y=a,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,r,n,a){let o=n.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 s(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}};ft._V8PerformanceHack=new ft(.5,.5,.5,.5);ft._ZeroReadOnly=ft.Zero();Object.defineProperties(ft.prototype,{dimension:{value:[4]},rank:{value:1}});Se=class s{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=tr(this._x),t=tr(this._y),i=tr(this._z),r=tr(this._w),n=e;return n=n*397^t,n=n*397^i,n=n*397^r,n}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return s.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=je){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=je){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 s(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 s(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 s)}subtractFromFloatsToRef(e,t,i,r,n){return n._x=this._x-e,n._y=this._y-t,n._z=this._z-i,n._w=this._w-r,n._isDirty=!0,n}subtract(e){return new s(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 s(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 s(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,n=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,n,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 s)}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 s(-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 s(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=S.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){let t=this._z,i=this._x,r=this._y,n=this._w,a=r*t-i*n,o=.4999999;if(a<-o)e._y=2*Math.atan2(r,n),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>o)e._y=2*Math.atan2(r,n),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{let l=n*n,c=t*t,f=i*i,h=r*r;e._z=Math.atan2(2*(i*r+t*n),-c-f+h+l),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(t*i+r*n),c-f-h+l),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){let t=this._z,i=this._x,r=this._y,n=this._w,a=Math.sqrt(i*i+r*r),o=Math.sqrt(t*t+n*n),l=2*Math.atan2(a,o),c=2*Math.atan2(t,n),f=2*Math.atan2(r,i),h=(c+f)/2,d=(c-f)/2;return e.set(d,l,h),e}toRotationMatrix(e){return H.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return s.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=S.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 s;return s.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){let i=e.m,r=i[0],n=i[4],a=i[8],o=i[1],l=i[5],c=i[9],f=i[2],h=i[6],d=i[10],u=r+l+d,m;return u>0?(m=.5/Math.sqrt(u+1),t._w=.25/m,t._x=(h-c)*m,t._y=(a-f)*m,t._z=(o-n)*m,t._isDirty=!0):r>l&&r>d?(m=2*Math.sqrt(1+r-l-d),t._w=(h-c)/m,t._x=.25*m,t._y=(n+o)/m,t._z=(a+f)/m,t._isDirty=!0):l>d?(m=2*Math.sqrt(1+l-r-d),t._w=(a-f)/m,t._x=(n+o)/m,t._y=.25*m,t._z=(c+h)/m,t._isDirty=!0):(m=2*Math.sqrt(1+d-r-l),t._w=(o-n)/m,t._x=(a+f)/m,t._y=(c+h)/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=s.Dot(e,t);return 1-r*r<=i}static SmoothToRef(e,t,i,r,n){let a=r===0?1:i/r;return a=Ye(a,0,1),s.SlerpToRef(e,t,a,n),n}static Zero(){return new s(0,0,0,0)}static Inverse(e){return new s(-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 s(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 s.RotationAxisToRef(e,t,new s)}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 s(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,n){return n.copyFromFloats(e,t,i,r),n}static FromEulerAngles(e,t,i){let r=new s;return s.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerAnglesToRef(e,t,i,r){return s.RotationYawPitchRollToRef(t,e,i,r),r}static FromEulerVector(e){let t=new s;return s.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return s.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,r=je){let n=S.Dot(e,t)+1;return nMath.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(S.CrossToRef(e,t,W.Vector3[0]),i.set(W.Vector3[0].x,W.Vector3[0].y,W.Vector3[0].z,n)),i.normalize()}static RotationYawPitchRoll(e,t,i){let r=new s;return s.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){let n=i*.5,a=t*.5,o=e*.5,l=Math.sin(n),c=Math.cos(n),f=Math.sin(a),h=Math.cos(a),d=Math.sin(o),u=Math.cos(o);return r._x=u*f*c+d*h*l,r._y=d*h*c-u*f*l,r._z=u*h*l-d*f*c,r._w=u*h*c+d*f*l,r._isDirty=!0,r}static RotationAlphaBetaGamma(e,t,i){let r=new s;return s.RotationAlphaBetaGammaToRef(e,t,i,r),r}static RotationAlphaBetaGammaToRef(e,t,i,r){let n=(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(n)*Math.cos(o),r._w=Math.cos(n)*Math.cos(o),r._isDirty=!0,r}static RotationQuaternionFromAxis(e,t,i){let r=new s(0,0,0,0);return s.RotationQuaternionFromAxisToRef(e,t,i,r),r}static RotationQuaternionFromAxisToRef(e,t,i,r){let n=Re.Matrix[0];return e=e.normalizeToRef(Re.Vector3[0]),t=t.normalizeToRef(Re.Vector3[1]),i=i.normalizeToRef(Re.Vector3[2]),H.FromXYZAxesToRef(e,t,i,n),s.FromRotationMatrixToRef(n,r),r}static FromLookDirectionLH(e,t){let i=new s;return s.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){let r=Re.Matrix[0];return H.LookDirectionLHToRef(e,t,r),s.FromRotationMatrixToRef(r,i),i}static FromLookDirectionRH(e,t){let i=new s;return s.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){let r=Re.Matrix[0];return H.LookDirectionRHToRef(e,t,r),s.FromRotationMatrixToRef(r,i)}static Slerp(e,t,i){let r=s.Identity();return s.SlerpToRef(e,t,i,r),r}static SlerpToRef(e,t,i,r){let n,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,n=l?-i:i;else{let c=Math.acos(o),f=1/Math.sin(c);a=Math.sin((1-i)*c)*f,n=l?-Math.sin(i*c)*f:Math.sin(i*c)*f}return r._x=a*e._x+n*t._x,r._y=a*e._y+n*t._y,r._z=a*e._z+n*t._z,r._w=a*e._w+n*t._w,r._isDirty=!0,r}static Hermite(e,t,i,r,n){let a=n*n,o=n*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+n,h=o-a,d=e._x*l+i._x*c+t._x*f+r._x*h,u=e._y*l+i._y*c+t._y*f+r._y*h,m=e._z*l+i._z*c+t._z*f+r._z*h,p=e._w*l+i._w*c+t._w*f+r._w*h;return new s(d,u,m,p)}static Hermite1stDerivative(e,t,i,r,n){let a=new s;return this.Hermite1stDerivativeToRef(e,t,i,r,n,a),a}static Hermite1stDerivativeToRef(e,t,i,r,n,a){let o=n*n;return a._x=(o-n)*6*e._x+(3*o-4*n+1)*t._x+(-o+n)*6*i._x+(3*o-2*n)*r._x,a._y=(o-n)*6*e._y+(3*o-4*n+1)*t._y+(-o+n)*6*i._y+(3*o-2*n)*r._y,a._z=(o-n)*6*e._z+(3*o-4*n+1)*t._z+(-o+n)*6*i._z+(3*o-2*n)*r._z,a._w=(o-n)*6*e._w+(3*o-4*n+1)*t._w+(-o+n)*6*i._w+(3*o-2*n)*r._w,a._isDirty=!0,a}static Normalize(e){let t=s.Zero();return s.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){let r=new s;return s.ClampToRef(e,t,i,r),r}static ClampToRef(e,t,i,r){return r.copyFromFloats(Ye(e.x,t.x,i.x),Ye(e.y,t.y,i.y),Ye(e.z,t.z,i.z),Ye(e.w,t.w,i.w))}static Random(e=0,t=1){return new s(Tt(e,t),Tt(e,t),Tt(e,t),Tt(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(Tt(e,t),Tt(e,t),Tt(e,t),Tt(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(s.DistanceSquared(e,t))}static DistanceSquared(e,t){let i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,a=e.w-t.w;return i*i+r*r+n*n+a*a}static Center(e,t){return s.CenterToRef(e,t,s.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)}};Se._V8PerformanceHack=new Se(.5,.5,.5,.5);Object.defineProperties(Se.prototype,{dimension:{value:[4]},rank:{value:1}});H=class s{static get Use64Bits(){return er.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=Xl._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,er.MatrixTrackPrecisionChange&&er.MatrixTrackedMatrices.push(this),this._m=new er.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],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],h=e[9],d=e[10],u=e[11],m=e[12],p=e[13],_=e[14],g=e[15],v=d*g-_*u,I=h*g-p*u,x=h*_-p*d,T=f*g-m*u,A=f*_-d*m,R=f*p-m*h,P=+(o*v-l*I+c*x),D=-(a*v-l*T+c*A),M=+(a*I-o*T+c*R),F=-(a*x-o*A+l*R);return t*P+i*D+r*M+n*F}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 s.FromArrayToRef(e,t,this)}copyFromFloats(...e){return s.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 s.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 s;return this.addToRef(e,t),t}addToRef(e,t){let i=this._m,r=t._m,n=e.m;for(let a=0;a<16;a++)r[a]=i[a]+n[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,n=t._m;for(let a=0;a<16;a++)n[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 s)}subtractFromFloatsToRef(...e){let t=e.pop(),i=this._m,r=t._m,n=e;for(let a=0;a<16;a++)r[a]=i[a]-n[a];return t.markAsUpdated(),t}invertToRef(e){return this._isIdentity===!0?(s.IdentityToRef(e),e):(xg(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 S(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 s.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 DI(this,e,t),this}multiply(e){let t=new s;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,n=e;for(let a=0;a<16;a++)r[a]=i[a]*n[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 Rg(this,e,t,i),this}divide(e){return this.divideToRef(e,new s)}divideToRef(e,t){let i=this._m,r=e.m,n=t._m;for(let a=0;a<16;a++)n[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 s)}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 n=0;n<16;n++)if(!mt(i[n],r[n],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 s)}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 s)}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 s;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=tr(this._m[0]);for(let t=1;t<16;t++)e=e*397^tr(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new Se,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,r,n=!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||Re.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=(n?r.absoluteScaling.x:r.scaling.x)<0?-1:1,l=(n?r.absoluteScaling.y:r.scaling.y)<0?-1:1,c=(n?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;s.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,Re.Matrix[0]),Se.FromRotationMatrixToRef(Re.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;let t=e*4;return new ft(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 s;return s.TransposeToRef(this,e),e}transposeToRef(e){return s.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,r,n){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]=n,this.markAsUpdated(),this}scale(e){let t=new s;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=Re.Matrix[0];this.invertToRef(t),t.transposeToRef(e);let i=e._m;return s.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 s;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){let t=Re.Vector3[0];if(!this.decompose(t))return s.IdentityToRef(e),e;let i=this._m,r=1/t._x,n=1/t._y,a=1/t._z;return s.FromValuesToRef(i[0]*r,i[1]*r,i[2]*r,0,i[4]*n,i[5]*n,i[6]*n,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 s;return s.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 s._IdentityReadOnly}static FromValuesToRef(e,t,i,r,n,a,o,l,c,f,h,d,u,m,p,_,g){let v=g._m;v[0]=e,v[1]=t,v[2]=i,v[3]=r,v[4]=n,v[5]=a,v[6]=o,v[7]=l,v[8]=c,v[9]=f,v[10]=h,v[11]=d,v[12]=u,v[13]=m,v[14]=p,v[15]=_,g.markAsUpdated()}static FromValues(e,t,i,r,n,a,o,l,c,f,h,d,u,m,p,_){let g=new s,v=g._m;return v[0]=e,v[1]=t,v[2]=i,v[3]=r,v[4]=n,v[5]=a,v[6]=o,v[7]=l,v[8]=c,v[9]=f,v[10]=h,v[11]=d,v[12]=u,v[13]=m,v[14]=p,v[15]=_,g.markAsUpdated(),g}static Compose(e,t,i){let r=new s;return s.ComposeToRef(e,t,i,r),r}static ComposeToRef(e,t,i,r){let n=r._m,a=t._x,o=t._y,l=t._z,c=t._w,f=a+a,h=o+o,d=l+l,u=a*f,m=a*h,p=a*d,_=o*h,g=o*d,v=l*d,I=c*f,x=c*h,T=c*d,A=e._x,R=e._y,P=e._z;return n[0]=(1-(_+v))*A,n[1]=(m+T)*A,n[2]=(p-x)*A,n[3]=0,n[4]=(m-T)*R,n[5]=(1-(u+v))*R,n[6]=(g+I)*R,n[7]=0,n[8]=(p+x)*P,n[9]=(g-I)*P,n[10]=(1-(u+_))*P,n[11]=0,n[12]=i._x,n[13]=i._y,n[14]=i._z,n[15]=1,r.markAsUpdated(),r}static Identity(){let e=s.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 s.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=s.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 s;return s.RotationXToRef(e,t),t}static Invert(e){let t=new s;return e.invertToRef(t),t}static RotationXToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return s.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 s;return s.RotationYToRef(e,t),t}static RotationYToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return s.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 s;return s.RotationZToRef(e,t),t}static RotationZToRef(e,t){let i=Math.sin(e),r=Math.cos(e);return s.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 s;return s.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){let r=Math.sin(-t),n=Math.cos(-t),a=1-n;e=e.normalizeToRef(Re.Vector3[0]);let o=i._m;return o[0]=e._x*e._x*a+n,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+n,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+n,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 n=S.Dot(t,e),a=i._m;if(n<-1+je)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=S.Cross(t,e),l=1/(1+n);a[0]=o._x*o._x*l+n,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+n,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+n,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 s;return s.RotationYawPitchRollToRef(e,t,i,r),r}static RotationYawPitchRollToRef(e,t,i,r){return Se.RotationYawPitchRollToRef(e,t,i,Re.Quaternion[0]),Re.Quaternion[0].toRotationMatrix(r),r}static Scaling(e,t,i){let r=new s;return s.ScalingToRef(e,t,i,r),r}static ScalingToRef(e,t,i,r){return s.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 s;return s.TranslationToRef(e,t,i,r),r}static TranslationToRef(e,t,i,r){return s.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 s;return s.LerpToRef(e,t,i,r),r}static LerpToRef(e,t,i,r){let n=r._m,a=e.m,o=t.m;for(let l=0;l<16;l++)n[l]=a[l]*(1-i)+o[l]*i;return r.markAsUpdated(),r}static DecomposeLerp(e,t,i){let r=new s;return s.DecomposeLerpToRef(e,t,i,r),r}static DecomposeLerpToRef(e,t,i,r){let n=Re.Vector3[0],a=Re.Quaternion[0],o=Re.Vector3[1];e.decompose(n,a,o);let l=Re.Vector3[2],c=Re.Quaternion[1],f=Re.Vector3[3];t.decompose(l,c,f);let h=Re.Vector3[4];S.LerpToRef(n,l,i,h);let d=Re.Quaternion[2];Se.SlerpToRef(a,c,i,d);let u=Re.Vector3[5];return S.LerpToRef(o,f,i,u),s.ComposeToRef(h,d,u,r),r}static LookAtLH(e,t,i){let r=new s;return s.LookAtLHToRef(e,t,i,r),r}static LookAtLHToRef(e,t,i,r){let n=Re.Vector3[0],a=Re.Vector3[1],o=Re.Vector3[2];t.subtractToRef(e,o),o.normalize(),S.CrossToRef(i,o,n);let l=n.lengthSquared();l===0?n.x=1:n.normalizeFromLength(Math.sqrt(l)),S.CrossToRef(o,n,a),a.normalize();let c=-S.Dot(n,e),f=-S.Dot(a,e),h=-S.Dot(o,e);return s.FromValuesToRef(n._x,a._x,o._x,0,n._y,a._y,o._y,0,n._z,a._z,o._z,0,c,f,h,1,r),r}static LookAtRH(e,t,i){let r=new s;return s.LookAtRHToRef(e,t,i,r),r}static LookAtRHToRef(e,t,i,r){let n=Re.Vector3[0],a=Re.Vector3[1],o=Re.Vector3[2];e.subtractToRef(t,o),o.normalize(),S.CrossToRef(i,o,n);let l=n.lengthSquared();l===0?n.x=1:n.normalizeFromLength(Math.sqrt(l)),S.CrossToRef(o,n,a),a.normalize();let c=-S.Dot(n,e),f=-S.Dot(a,e),h=-S.Dot(o,e);return s.FromValuesToRef(n._x,a._x,o._x,0,n._y,a._y,o._y,0,n._z,a._z,o._z,0,c,f,h,1,r),r}static LookDirectionLH(e,t){let i=new s;return s.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){let r=Re.Vector3[0];r.copyFrom(e),r.scaleInPlace(-1);let n=Re.Vector3[1];return S.CrossToRef(t,r,n),s.FromValuesToRef(n._x,n._y,n._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 s;return s.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){let r=Re.Vector3[2];return S.CrossToRef(t,e,r),s.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,n){let a=new s;return s.OrthoLHToRef(e,t,i,r,a,n),a}static OrthoLHToRef(e,t,i,r,n,a){let o=i,l=r,c=2/e,f=2/t,h=2/(l-o),d=-(l+o)/(l-o);return s.FromValuesToRef(c,0,0,0,0,f,0,0,0,0,h,0,0,0,d,1,n),a&&n.multiplyToRef(Qo,n),n._updateIdentityStatus(c===1&&f===1&&h===1&&d===0),n}static OrthoOffCenterLH(e,t,i,r,n,a,o){let l=new s;return s.OrthoOffCenterLHToRef(e,t,i,r,n,a,l,o),l}static OrthoOffCenterLHToRef(e,t,i,r,n,a,o,l){let c=n,f=a,h=2/(t-e),d=2/(r-i),u=2/(f-c),m=-(f+c)/(f-c),p=(e+t)/(e-t),_=(r+i)/(i-r);return s.FromValuesToRef(h,0,0,0,0,d,0,0,0,0,u,0,p,_,m,1,o),l&&o.multiplyToRef(Qo,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,r,n,a,o,l,c,f,h){let d=-o*Math.cos(l),u=-o*Math.sin(l);return s.TranslationToRef(0,0,-c,Re.Matrix[1]),s.FromValuesToRef(1,0,0,0,0,1,0,0,d,u,1,0,0,0,0,1,Re.Matrix[0]),Re.Matrix[1].multiplyToRef(Re.Matrix[0],Re.Matrix[0]),s.TranslationToRef(0,0,c,Re.Matrix[1]),Re.Matrix[0].multiplyToRef(Re.Matrix[1],Re.Matrix[0]),s.OrthoOffCenterLHToRef(e,t,i,r,n,a,f,h),Re.Matrix[0].multiplyToRef(f,f),f}static OrthoOffCenterRH(e,t,i,r,n,a,o){let l=new s;return s.OrthoOffCenterRHToRef(e,t,i,r,n,a,l,o),l}static OrthoOffCenterRHToRef(e,t,i,r,n,a,o,l){return s.OrthoOffCenterLHToRef(e,t,i,r,n,a,o,l),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,r,n,a,o,l,c,f,h){let d=o*Math.cos(l),u=o*Math.sin(l);return s.TranslationToRef(0,0,c,Re.Matrix[1]),s.FromValuesToRef(1,0,0,0,0,1,0,0,d,u,1,0,0,0,0,1,Re.Matrix[0]),Re.Matrix[1].multiplyToRef(Re.Matrix[0],Re.Matrix[0]),s.TranslationToRef(0,0,-c,Re.Matrix[1]),Re.Matrix[0].multiplyToRef(Re.Matrix[1],Re.Matrix[0]),s.OrthoOffCenterRHToRef(e,t,i,r,n,a,f,h),Re.Matrix[0].multiplyToRef(f,f),f}static PerspectiveLH(e,t,i,r,n,a=0){let o=new s,l=i,c=r,f=2*l/e,h=2*l/t,d=(c+l)/(c-l),u=-2*c*l/(c-l),m=Math.tan(a);return s.FromValuesToRef(f,0,0,0,0,h,0,m,0,0,d,1,0,0,u,0,o),n&&o.multiplyToRef(Qo,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,r,n,a=0,o=!1){let l=new s;return s.PerspectiveFovLHToRef(e,t,i,r,l,!0,n,a,o),l}static PerspectiveFovLHToRef(e,t,i,r,n,a=!0,o,l=0,c=!1){let f=i,h=r,d=1/Math.tan(e*.5),u=a?d/t:d,m=a?d:d*t,p=c&&f===0?-1:h!==0?(h+f)/(h-f):1,_=c&&f===0?2*h:h!==0?-2*h*f/(h-f):-2*f,g=Math.tan(l);return s.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,1,0,0,_,0,n),o&&n.multiplyToRef(Qo,n),n._updateIdentityStatus(!1),n}static PerspectiveFovReverseLHToRef(e,t,i,r,n,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,h=a?c:c*t,d=Math.tan(l);return s.FromValuesToRef(f,0,0,0,0,h,0,d,0,0,-i,1,0,0,1,0,n),o&&n.multiplyToRef(Qo,n),n._updateIdentityStatus(!1),n}static PerspectiveFovRH(e,t,i,r,n,a=0,o=!1){let l=new s;return s.PerspectiveFovRHToRef(e,t,i,r,l,!0,n,a,o),l}static PerspectiveFovRHToRef(e,t,i,r,n,a=!0,o,l=0,c=!1){let f=i,h=r,d=1/Math.tan(e*.5),u=a?d/t:d,m=a?d:d*t,p=c&&f===0?1:h!==0?-(h+f)/(h-f):-1,_=c&&f===0?2*h:h!==0?-2*h*f/(h-f):-2*f,g=Math.tan(l);return s.FromValuesToRef(u,0,0,0,0,m,0,g,0,0,p,-1,0,0,_,0,n),o&&n.multiplyToRef(Qo,n),n._updateIdentityStatus(!1),n}static PerspectiveFovReverseRHToRef(e,t,i,r,n,a=!0,o,l=0){let c=1/Math.tan(e*.5),f=a?c/t:c,h=a?c:c*t,d=Math.tan(l);return s.FromValuesToRef(f,0,0,0,0,h,0,d,0,0,-i,-1,0,0,-1,0,n),o&&n.multiplyToRef(Qo,n),n._updateIdentityStatus(!1),n}static GetFinalMatrix(e,t,i,r,n,a){let o=e.width,l=e.height,c=e.x,f=e.y,h=s.FromValues(o/2,0,0,0,0,-l/2,0,0,0,0,a-n,0,c+o/2,l/2+f,n,1),d=new s;return t.multiplyToRef(i,d),d.multiplyToRef(r,d),d.multiplyToRef(h,d)}static GetAsMatrix2x2(e){let t=e.m,i=[t[0],t[1],t[4],t[5]];return er.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 er.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){let t=new s;return s.TransposeToRef(e,t),t}static TransposeToRef(e,t){let i=e.m,r=i[0],n=i[4],a=i[8],o=i[12],l=i[1],c=i[5],f=i[9],h=i[13],d=i[2],u=i[6],m=i[10],p=i[14],_=i[3],g=i[7],v=i[11],I=i[15],x=t._m;return x[0]=r,x[1]=n,x[2]=a,x[3]=o,x[4]=l,x[5]=c,x[6]=f,x[7]=h,x[8]=d,x[9]=u,x[10]=m,x[11]=p,x[12]=_,x[13]=g,x[14]=v,x[15]=I,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){let t=new s;return s.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();let i=e.normal.x,r=e.normal.y,n=e.normal.z,a=-2*i,o=-2*r,l=-2*n;return s.FromValuesToRef(a*i+1,o*i,l*i,0,a*r,o*r+1,l*r,0,a*n,o*n,l*n+1,0,a*e.d,o*e.d,l*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,r){return s.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,n=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,h=e._x*e._w;return t._m[0]=1-2*(r+n),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*(n+i),t._m[6]=2*(f+h),t._m[7]=0,t._m[8]=2*(l+c),t._m[9]=2*(f-h),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}};H._IdentityReadOnly=H.Identity();Object.defineProperties(H.prototype,{dimension:{value:[4,4]},rank:{value:2}});Re=class{};Re.Vector3=Vn(11,S.Zero);Re.Matrix=Vn(2,H.Identity);Re.Quaternion=Vn(3,Se.Zero);W=class{};W.Vector2=Vn(3,me.Zero);W.Vector3=Vn(13,S.Zero);W.Vector4=Vn(3,ft.Zero);W.Quaternion=Vn(3,Se.Zero);W.Matrix=Vn(8,H.Identity);Ke("BABYLON.Vector2",me);Ke("BABYLON.Vector3",S);Ke("BABYLON.Vector4",ft);Ke("BABYLON.Matrix",H);Qo=H.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)});var PI,mr,LI,Yl=C(()=>{Ee();(function(s){s[s.LOCAL=0]="LOCAL",s[s.WORLD=1]="WORLD",s[s.BONE=2]="BONE"})(PI||(PI={}));mr=class{};mr.X=new S(1,0,0);mr.Y=new S(0,1,0);mr.Z=new S(0,0,1);(function(s){s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z"})(LI||(LI={}))});function Kl(s){return Math.pow(s,zl)}function jl(s){return s<=.04045?.0773993808*s:Math.pow(.947867299*(s+.055),2.4)}function Zl(s){return Math.pow(s,II)}function ql(s){return s<=.0031308?12.92*s:1.055*Math.pow(s,.41666)-.055}var ae,Me,Fi,Je=C(()=>{Zs();Pt();Wi();Mi();ae=class s{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 s.FromArrayToRef(e,t,this),this}toColor4(e=1){return new Me(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 s(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 s(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=je){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 s(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=Ye(this.r,e,t),i.g=Ye(this.g,e,t),i.b=Ye(this.b,e,t),i}add(e){return new s(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 s(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 s(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 s(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"#"+jr(e)+jr(t)+jr(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 s)}toHSVToRef(e){let t=this.r,i=this.g,r=this.b,n=Math.max(t,i,r),a=Math.min(t,i,r),o=0,l=0,c=n,f=n-a;return n!==0&&(l=f/n),n!=a&&(n==t?(o=(i-r)/f,i=0&&a<=1?(l=n,c=o):a>=1&&a<=2?(l=o,c=n):a>=2&&a<=3?(c=n,f=o):a>=3&&a<=4?(c=o,f=n):a>=4&&a<=5?(l=o,f=n):a>=5&&a<=6&&(l=n,f=o);let h=i-n;return r.r=l+h,r.g=c+h,r.b=f+h,r}static FromHSV(e,t,i){let r=new s(0,0,0);return s.HSVtoRGBToRef(e,t,i,r),r}static FromHexString(e){return new s(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new s(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 s(e/255,t/255,i/255)}static Lerp(e,t,i){let r=new s(0,0,0);return s.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,n){let a=n*n,o=n*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+n,h=o-a,d=e.r*l+i.r*c+t.r*f+r.r*h,u=e.g*l+i.g*c+t.g*f+r.g*h,m=e.b*l+i.b*c+t.b*f+r.b*h;return new s(d,u,m)}static Hermite1stDerivative(e,t,i,r,n){let a=s.Black();return this.Hermite1stDerivativeToRef(e,t,i,r,n,a),a}static Hermite1stDerivativeToRef(e,t,i,r,n,a){let o=n*n;a.r=(o-n)*6*e.r+(3*o-4*n+1)*t.r+(-o+n)*6*i.r+(3*o-2*n)*r.r,a.g=(o-n)*6*e.g+(3*o-4*n+1)*t.g+(-o+n)*6*i.g+(3*o-2*n)*r.g,a.b=(o-n)*6*e.b+(3*o-4*n+1)*t.b+(-o+n)*6*i.b+(3*o-2*n)*r.b}static Red(){return new s(1,0,0)}static Green(){return new s(0,1,0)}static Blue(){return new s(0,0,1)}static Black(){return new s(0,0,0)}static get BlackReadOnly(){return s._BlackReadOnly}static White(){return new s(1,1,1)}static Purple(){return new s(.5,0,.5)}static Magenta(){return new s(1,0,1)}static Yellow(){return new s(1,1,0)}static Gray(){return new s(.5,.5,.5)}static Teal(){return new s(0,1,1)}static Random(){return new s(Math.random(),Math.random(),Math.random())}};ae._V8PerformanceHack=new ae(.5,.5,.5);ae._BlackReadOnly=ae.Black();Object.defineProperties(ae.prototype,{dimension:{value:[3]},rank:{value:1}});Me=class s{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 s(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 s(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 s(this.r-e,this.g-t,this.b-i,this.a-r)}subtractFromFloatsToRef(e,t,i,r,n){return n.r=this.r-e,n.g=this.g-t,n.b=this.b-i,n.a=this.a-r,n}scale(e){return new s(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=Ye(this.r,e,t),i.g=Ye(this.g,e,t),i.b=Ye(this.b,e,t),i.a=Ye(this.a,e,t),i}multiply(e){return new s(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 s(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=je){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 s().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"#"+jr(t)+jr(i)+jr(r);let n=Math.round(this.a*255);return"#"+jr(t)+jr(i)+jr(r)+jr(n)}fromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?this:(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,e.length===9&&(this.a=parseInt(e.substring(7,9),16)/255),this)}toLinearSpace(e=!1){let t=new s;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=jl(this.r),e.g=jl(this.g),e.b=jl(this.b)):(e.r=Kl(this.r),e.g=Kl(this.g),e.b=Kl(this.b)),e.a=this.a,this}toGammaSpace(e=!1){let t=new s;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=ql(this.r),e.g=ql(this.g),e.b=ql(this.b)):(e.r=Zl(this.r),e.g=Zl(this.g),e.b=Zl(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new s(0,0,0,0):new s(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return s.LerpToRef(e,t,i,new s)}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,n){let a=n*n,o=n*a,l=2*o-3*a+1,c=-2*o+3*a,f=o-2*a+n,h=o-a,d=e.r*l+i.r*c+t.r*f+r.r*h,u=e.g*l+i.g*c+t.g*f+r.g*h,m=e.b*l+i.b*c+t.b*f+r.b*h,p=e.a*l+i.a*c+t.a*f+r.a*h;return new s(d,u,m,p)}static Hermite1stDerivative(e,t,i,r,n){let a=new s;return this.Hermite1stDerivativeToRef(e,t,i,r,n,a),a}static Hermite1stDerivativeToRef(e,t,i,r,n,a){let o=n*n;a.r=(o-n)*6*e.r+(3*o-4*n+1)*t.r+(-o+n)*6*i.r+(3*o-2*n)*r.r,a.g=(o-n)*6*e.g+(3*o-4*n+1)*t.g+(-o+n)*6*i.g+(3*o-2*n)*r.g,a.b=(o-n)*6*e.b+(3*o-4*n+1)*t.b+(-o+n)*6*i.b+(3*o-2*n)*r.b,a.a=(o-n)*6*e.a+(3*o-4*n+1)*t.a+(-o+n)*6*i.a+(3*o-2*n)*r.a}static FromColor3(e,t=1){return new s(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new s(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 s(e/255,t/255,i/255,r/255)}static CheckColors4(e,t){if(e.length===t*3){let i=[];for(let r=0;rnew Me(0,0,0,0));Ke("BABYLON.Color3",ae);Ke("BABYLON.Color4",Me)});var pr,Jo=C(()=>{Ee();pr=class s{constructor(e,t,i,r){this.normal=new S(e,t,i),this.d=r}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new s(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=s._TmpMatrix;e.invertToRef(t);let i=t.m,r=this.normal.x,n=this.normal.y,a=this.normal.z,o=this.d,l=r*i[0]+n*i[1]+a*i[2]+o*i[3],c=r*i[4]+n*i[5]+a*i[6]+o*i[7],f=r*i[8]+n*i[9]+a*i[10]+o*i[11],h=r*i[12]+n*i[13]+a*i[14]+o*i[15];return new s(l,c,f,h)}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,n=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=n*c-a*l,h=a*o-r*c,d=r*l-n*o,u=Math.sqrt(f*f+h*h+d*d),m;return u!==0?m=1/u:m=0,this.normal.x=f*m,this.normal.y=h*m,this.normal.z=d*m,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return S.Dot(this.normal,e)<=t}signedDistanceTo(e){return S.Dot(e,this.normal)+this.d}static FromArray(e){return new s(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){let r=new s(0,0,0,0);return r.copyFromPoints(e,t,i),r}static FromPositionAndNormal(e,t){let i=new s(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 S.Dot(i,t)+r}};pr._TmpMatrix=H.Identity()});var Ua,$d=C(()=>{Jo();Ua=class s{static GetPlanes(e){let t=[];for(let i=0;i<6;i++)t.push(new pr(0,0,0,0));return s.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){s.GetNearPlaneToRef(e,t[0]),s.GetFarPlaneToRef(e,t[1]),s.GetLeftPlaneToRef(e,t[2]),s.GetRightPlaneToRef(e,t[3]),s.GetTopPlaneToRef(e,t[4]),s.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 OI,Ql,Cg,Jl,$o,el=C(()=>{Mi();Ee();Wi();(function(s){s[s.CW=0]="CW",s[s.CCW=1]="CCW"})(OI||(OI={}));Ql=class s{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 s(r)}static BetweenTwoVectors(e,t){let i=e.lengthSquared()*t.lengthSquared();if(i===0)return new s(Math.PI/2);i=Math.sqrt(i);let r=e.dot(t)/i;r=Ye(r,-1,1);let n=Math.acos(r);return new s(n)}static FromRadians(e){return new s(e)}static FromDegrees(e){return new s(e*Math.PI/180)}},Cg=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),n=(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 me((n*(t.y-i.y)-a*(e.y-t.y))/o,((e.x-t.x)*a-(t.x-i.x)*n)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=Ql.BetweenTwoPoints(this.centerPoint,this.startPoint);let l=this.startAngle.degrees(),c=Ql.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),f=Ql.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=Ql.FromDegrees(this.orientation===0?l-f:f-l)}},Jl=class s{constructor(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new me(e,t))}addLineTo(e,t){if(this.closed)return this;let i=new me(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,n=36){if(this.closed)return this;let a=this._points[this._points.length-1],o=new me(e,t),l=new me(i,r),c=new Cg(a,o,l),f=c.angle.radians()/n;c.orientation===0&&(f*=-1);let h=c.startAngle.radians()+f;for(let d=0;d(1-l)*(1-l)*c+2*l*(1-l)*f+l*l*h,o=this._points[this._points.length-1];for(let l=0;l<=n;l++){let c=l/n,f=a(c,o.x,e,i),h=a(c,o.y,t,r);this.addLineTo(f,h)}return this}addBezierCurveTo(e,t,i,r,n,a,o=36){if(this.closed)return this;let l=(f,h,d,u,m)=>(1-f)*(1-f)*(1-f)*h+3*f*(1-f)*(1-f)*d+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 h=f/o,d=l(h,c.x,e,i,n),u=l(h,c.y,t,r,a);this.addLineTo(d,u)}return this}isPointInside(e){let t=!1,i=this._points.length;for(let r=i-1,n=0;nNumber.EPSILON){if(c<0&&(a=this._points[n],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 me.Zero();let t=e*this.length(),i=0;for(let r=0;r=i&&t<=c){let f=l.normalize(),h=t-i;return new me(a.x+f.x*h,a.y+f.y*h)}i=c}return me.Zero()}static StartingAt(e,t){return new s(e,t)}},$o=class s{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:S.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:H.Identity()};for(let n=0;nt){let c=e;e=t,t=c}let i=this.getCurve(),r=this.getPointAt(e),n=this.getPreviousPointIndexAt(e),a=this.getPointAt(t),o=this.getPreviousPointIndexAt(t)+1,l=[];return e!==0&&(n++,l.push(r)),l.push(...i.slice(n,o)),(t!==1||e===1)&&l.push(a),new s(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 n;mt(Math.abs(e.y)/r,1,je)?mt(Math.abs(e.x)/r,1,je)?mt(Math.abs(e.z)/r,1,je)?n=S.Zero():n=new S(0,0,1):n=new S(1,0,0):n=new S(0,-1,0),i=S.Cross(e,n)}else i=S.Cross(e,t),S.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],n,a=0,o=e*this.length();for(let l=1;lo){let h=(a-o)/c,d=r.subtract(n),u=n.add(d.scaleInPlace(h));return this._setPointAtData(e,1-h,u,l-1,t)}r=n}return this._pointAtData}_setPointAtData(e,t,i,r,n){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=r,this._pointAtData.interpolateReady=n,n&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=H.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(),n=this._binormals[e].clone(),a=this._tangents[t].clone(),o=this._normals[t].clone(),l=this._binormals[t].clone(),c=Se.RotationQuaternionFromAxis(r,n,i),f=Se.RotationQuaternionFromAxis(o,l,a);Se.Slerp(c,f,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}});var Gn,eu=C(()=>{Gn=class s{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 s(this.width*e,this.height*t)}clone(){return new s(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 s(0,0)}add(e){return new s(this.width+e.width,this.height+e.height)}subtract(e){return new s(this.width-e.width,this.height-e.height)}scale(e){return new s(this.width*e,this.height*e)}static Lerp(e,t,i){let r=e.width+(t.width-e.width)*i,n=e.height+(t.height-e.height)*i;return new s(r,n)}}});var NI=C(()=>{Ee()});var Ss,$l=C(()=>{Ss=class s{constructor(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}toGlobal(e,t){return new s(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 s(this.x,this.y,this.width,this.height)}}});var tu=C(()=>{Yl();Je();Wi();$d();el();Jo();eu();Ee();NI();$l()});var qs,zk,kn,Wn,qf,Qs,Qf=C(()=>{Ee();tu();qs=[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))],zk=[()=>1,s=>s.y,s=>s.z,s=>s.x,s=>s.x*s.y,s=>s.y*s.z,s=>3*s.z*s.z-1,s=>s.x*s.z,s=>s.x*s.x-s.y*s.y],kn=(s,e)=>qs[s]*zk[s](e),Wn=[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],qf=class s{constructor(){this.preScaled=!1,this.l00=S.Zero(),this.l1_1=S.Zero(),this.l10=S.Zero(),this.l11=S.Zero(),this.l2_2=S.Zero(),this.l2_1=S.Zero(),this.l20=S.Zero(),this.l21=S.Zero(),this.l22=S.Zero()}addLight(e,t,i){W.Vector3[0].set(t.r,t.g,t.b);let r=W.Vector3[0],n=W.Vector3[1];r.scaleToRef(i,n),n.scaleToRef(kn(0,e),W.Vector3[2]),this.l00.addInPlace(W.Vector3[2]),n.scaleToRef(kn(1,e),W.Vector3[2]),this.l1_1.addInPlace(W.Vector3[2]),n.scaleToRef(kn(2,e),W.Vector3[2]),this.l10.addInPlace(W.Vector3[2]),n.scaleToRef(kn(3,e),W.Vector3[2]),this.l11.addInPlace(W.Vector3[2]),n.scaleToRef(kn(4,e),W.Vector3[2]),this.l2_2.addInPlace(W.Vector3[2]),n.scaleToRef(kn(5,e),W.Vector3[2]),this.l2_1.addInPlace(W.Vector3[2]),n.scaleToRef(kn(6,e),W.Vector3[2]),this.l20.addInPlace(W.Vector3[2]),n.scaleToRef(kn(7,e),W.Vector3[2]),this.l21.addInPlace(W.Vector3[2]),n.scaleToRef(kn(8,e),W.Vector3[2]),this.l22.addInPlace(W.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(Wn[0]),this.l1_1.scaleInPlace(Wn[1]),this.l10.scaleInPlace(Wn[2]),this.l11.scaleInPlace(Wn[3]),this.l2_2.scaleInPlace(Wn[4]),this.l2_1.scaleInPlace(Wn[5]),this.l20.scaleInPlace(Wn[6]),this.l21.scaleInPlace(Wn[7]),this.l22.scaleInPlace(Wn[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(qs[0]),this.l1_1.scaleInPlace(qs[1]),this.l10.scaleInPlace(qs[2]),this.l11.scaleInPlace(qs[3]),this.l2_2.scaleInPlace(qs[4]),this.l2_1.scaleInPlace(qs[5]),this.l20.scaleInPlace(qs[6]),this.l21.scaleInPlace(qs[7]),this.l22.scaleInPlace(qs[8])}updateFromArray(e){return S.FromArrayToRef(e[0],0,this.l00),S.FromArrayToRef(e[1],0,this.l1_1),S.FromArrayToRef(e[2],0,this.l10),S.FromArrayToRef(e[3],0,this.l11),S.FromArrayToRef(e[4],0,this.l2_2),S.FromArrayToRef(e[5],0,this.l2_1),S.FromArrayToRef(e[6],0,this.l20),S.FromArrayToRef(e[7],0,this.l21),S.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return S.FromFloatsToRef(e[0],e[1],e[2],this.l00),S.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),S.FromFloatsToRef(e[6],e[7],e[8],this.l10),S.FromFloatsToRef(e[9],e[10],e[11],this.l11),S.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),S.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),S.FromFloatsToRef(e[18],e[19],e[20],this.l20),S.FromFloatsToRef(e[21],e[22],e[23],this.l21),S.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return new s().updateFromArray(e)}static FromPolynomial(e){let t=new s;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}},Qs=class s{constructor(){this.x=S.Zero(),this.y=S.Zero(),this.z=S.Zero(),this.xx=S.Zero(),this.yy=S.Zero(),this.zz=S.Zero(),this.xy=S.Zero(),this.yz=S.Zero(),this.zx=S.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=qf.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){W.Vector3[0].copyFromFloats(e.r,e.g,e.b);let t=W.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),W.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),W.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(W.Vector3[0]).addInPlace(W.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(W.Vector3[0]).subtractInPlace(W.Vector3[1]),this.zz.copyFrom(e.l00),W.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(W.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 s().updateFromHarmonics(e)}static FromArray(e){let t=new s;return S.FromArrayToRef(e[0],0,t.x),S.FromArrayToRef(e[1],0,t.y),S.FromArrayToRef(e[2],0,t.z),S.FromArrayToRef(e[3],0,t.xx),S.FromArrayToRef(e[4],0,t.yy),S.FromArrayToRef(e[5],0,t.zz),S.FromArrayToRef(e[6],0,t.yz),S.FromArrayToRef(e[7],0,t.zx),S.FromArrayToRef(e[8],0,t.xy),t}}});function b(s,e,t,i){var r=arguments.length,n=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var o=s.length-1;o>=0;o--)(a=s[o])&&(n=(r<3?a(n):r>3?a(e,t,n):a(e,t))||n);return r>3&&n&&Object.defineProperty(e,t,n),n}var $e=C(()=>{});function FI(s){let e=s.getClassName();return ru[e]||(ru[e]={}),ru[e]}function su(s){let e=s.getClassName();if(iu[e])return iu[e];iu[e]={};let t=iu[e],i=s,r=e;for(;r;){let n=ru[r];for(let l in n)t[l]=n[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 iu,ru,bg=C(()=>{iu={},ru={}});function Zr(s,e){return(t,i)=>{let r=FI(t);r[i]||(r[i]={type:s,sourceName:e})}}function Xk(s,e=null){return(t,i)=>{let r=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[r]},set:function(n){var a;typeof((a=this[r])==null?void 0:a.equals)=="function"&&this[r].equals(n)||this[r]!==n&&(this[r]=n,t[s].apply(this))},enumerable:!0,configurable:!0})}}function ie(s,e=null){return Xk(s,e)}function L(s){return Zr(0,s)}function qe(s){return Zr(1,s)}function Kt(s){return Zr(2,s)}function ec(s){return Zr(3,s)}function tc(s){return Zr(4,s)}function ui(s){return Zr(5,s)}function nu(s){return Zr(6,s)}function wI(s){return Zr(7,s)}function ic(s){return Zr(8,s)}function BI(s){return Zr(9,s)}function UI(s){return Zr(10,s)}function VI(s){return Zr(11,s)}function _r(s,e,t,i){let r=t.value;t.value=(...n)=>{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 s[e]=a,a(...n)}}function Ue(s,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[s].apply(this))},enumerable:!0,configurable:!0})}}var Qe=C(()=>{bg();_r.filter=function(s){return(e,t,i)=>_r(e,t,i,s)}});function Js(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}var rc=C(()=>{});function Yk(){return typeof _native!="undefined"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}var mi,sc=C(()=>{mi=class s{constructor(){this._xhr=Yk(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(s.CustomRequestHeaders).length>0||s.CustomRequestModifiers.length>0}static _CleanUrl(e){return e=e.replace("file:http:","http:"),e=e.replace("file:https:","https:"),e}static _ShouldSkipRequestModifications(e){return s.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}static _CollectCustomizations(e,t={}){let i={...t};if(s._ShouldSkipRequestModifications(e))return{url:e,headers:i};for(let n in s.CustomRequestHeaders){let a=s.CustomRequestHeaders[n];a&&(i[n]=a)}let r={setRequestHeader:(n,a)=>{i[n]=a}};for(let n of s.CustomRequestModifiers){if(s._ShouldSkipRequestModifications(e))break;let a=n(r,e);typeof a=="string"&&(e=a)}return{url:e,headers:i}}static async FetchAsync(e,t={}){var r,n,a;let i=(r=t.method)!=null?r:"GET";if(typeof fetch!="undefined"){let{url:o,headers:l}=s._CollectCustomizations(s._CleanUrl(e),(n=t.headers)!=null?n:{});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 s;c.responseType="arraybuffer",c.addEventListener("readystatechange",()=>{if(c.readyState===4)if(c.status>=200&&c.status<300){let h=typeof Headers!="undefined"?new Headers:void 0,d=c.getResponseHeader("Content-Type");d&&h&&h.set("Content-Type",d),o(typeof Response!="undefined"?new Response(c.response,{status:c.status,statusText:c.statusText,headers:h}):{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:n}=s._CollectCustomizations(t,i);this._requestURL=s._CleanUrl(r),this._xhr.open(e,this._requestURL,!0);for(let a in n)this._xhr.setRequestHeader(a,n[a])}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}};mi.CustomRequestHeaders={};mi.CustomRequestModifiers=new Array;mi.SkipRequestModificationForBabylonCDN=!0});var Va,GI=C(()=>{Va=class{};Va.FilesToLoad={}});var au,kI=C(()=>{au=class{static ExponentialBackoff(e=3,t=500){return(i,r,n)=>r.status!==0||n>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,n)*t}}});var Hn,qr,gr,Jf=C(()=>{Hn=class extends Error{};Hn._setPrototypeOf=Object.setPrototypeOf||((s,e)=>(s.__proto__=e,s));qr={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},gr=class s extends Hn{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",Hn._setPrototypeOf(this,s.prototype)}}});function Kk(s){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",i,r,n,a,o,l,c,f=0;for(;f>2,o=(i&3)<<4|r>>4,l=(r&15)<<2|n>>6,c=n&63,isNaN(r)?l=c=64:isNaN(n)&&(c=64),t+=e.charAt(a)+e.charAt(o)+e.charAt(l)+e.charAt(c);return t}function jk(s){let e=Mg(s),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let r=0;r{WI=s=>{if(typeof TextDecoder!="undefined")return new TextDecoder().decode(s);let e="";for(let t=0;t{let e=ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s);return typeof e.toBase64=="function"?e.toBase64():Kk(e)},Mg=s=>atob(s),nc=s=>typeof Uint8Array.fromBase64=="function"?Uint8Array.fromBase64(s).buffer:jk(s)});function Zk(s,e,t,i){switch(e){case 5120:{let r=s.getInt8(t);return i&&(r=Math.max(r/127,-1)),r}case 5121:{let r=s.getUint8(t);return i&&(r=r/255),r}case 5122:{let r=s.getInt16(t,!0);return i&&(r=Math.max(r/32767,-1)),r}case 5123:{let r=s.getUint16(t,!0);return i&&(r=r/65535),r}case 5124:return s.getInt32(t,!0);case 5125:return s.getUint32(t,!0);case 5126:return s.getFloat32(t,!0);default:throw new Error(`Invalid component type ${e}`)}}function qk(s,e,t,i,r){switch(e){case 5120:{i&&(r=Math.round(r*127)),s.setInt8(t,r);break}case 5121:{i&&(r=Math.round(r*255)),s.setUint8(t,r);break}case 5122:{i&&(r=Math.round(r*32767)),s.setInt16(t,r,!0);break}case 5123:{i&&(r=Math.round(r*65535)),s.setUint16(t,r,!0);break}case 5124:{s.setInt32(t,r,!0);break}case 5125:{s.setUint32(t,r,!0);break}case 5126:{s.setFloat32(t,r,!0);break}default:throw new Error(`Invalid component type ${e}`)}}function en(s){switch(s){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 '${s}'`)}}function yg(s){switch(s){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 '${s}'`)}}function tl(s,e,t,i,r,n,a,o){let l=new Array(i),c=new Array(i);if(s instanceof Array){let f=e/4,h=t/4;for(let d=0;d{for(let u=0;us.length)throw new Error("Last accessed index is out of bounds.");if(p{for(let x=0;xf.byteLength)throw new Error("Last accessed byte is out of bounds.");let u=e*o;if(r{for(let g=0;g{for(let d=0;d{We()});function ka(s){return nc(s.split(",")[1])}var YI,lc,lu,Pg,Qk,Vt,cu,XI,cc,il,tn,fu,KI,jI,Ga,ZI,qI,Jk,$f,$k,Wa=C(()=>{sc();Pr();dt();GI();kI();Jf();ac();Ud();gt();We();Ys();wa();ci();oc();YI=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i),lc=class s extends gr{constructor(e,t){super(e,qr.LoadFileError),this.name="LoadFileError",Hn._setPrototypeOf(this,s.prototype),t instanceof mi?this.request=t:this.file=t}},lu=class s extends gr{constructor(e,t){super(e,qr.RequestFileError),this.request=t,this.name="RequestFileError",Hn._setPrototypeOf(this,s.prototype)}},Pg=class s extends gr{constructor(e,t){super(e,qr.ReadFileError),this.file=t,this.name="ReadFileError",Hn._setPrototypeOf(this,s.prototype)}},Qk=s=>(s=s.replace(/#/gm,"%23"),s),Vt={DefaultRetryStrategy:au.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:s=>s,ScriptBaseUrl:"",ScriptPreprocessUrl:s=>s,CleanUrl:Qk},cu=(s,e)=>{if(!(s&&s.indexOf("data:")===0)&&Vt.CorsBehavior)if(typeof Vt.CorsBehavior=="string"||Vt.CorsBehavior instanceof String)e.crossOrigin=Vt.CorsBehavior;else{let t=Vt.CorsBehavior(s);t&&(e.crossOrigin=t)}},XI={getRequiredSize:null},cc=(s,e,t,i,r="",n,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(s instanceof ArrayBuffer||ArrayBuffer.isView(s))if(typeof Blob!="undefined"&&typeof URL!="undefined"){let T;s instanceof ArrayBuffer?T=s:T=ou(s),o=URL.createObjectURL(new Blob([T],{type:r})),l=!0}else o=`data:${r};base64,`+$s(s);else s instanceof Blob?(o=URL.createObjectURL(s),l=!0):(o=Vt.CleanUrl(s),o=Vt.PreprocessUrl(o));let c=T=>{if(t){let A=o||s.toString();t(`Error while trying to load image: ${A.indexOf("http")===0||A.length<=128?A:A.slice(0,128)+"..."}`,T)}};if(a!=null&&a._features.forceBitmapOverHTMLImageElement)return tn(o,T=>{a.createImageBitmap(new Blob([T],{type:r}),{premultiplyAlpha:"none",colorSpaceConversion:"none",...n}).then(A=>{e(A),l&&URL.revokeObjectURL(o)}).catch(A=>{t&&t("Error while trying to load image: "+s,A)})},void 0,i||void 0,!0,(T,A)=>{c(A)}),null;let f=new Image;if(XI.getRequiredSize){let T=XI.getRequiredSize(s);T.width&&(f.width=T.width),T.height&&(f.height=T.height)}cu(o,f);let h=[],d=()=>{for(let T of h)T.target.addEventListener(T.name,T.handler)},u=()=>{for(let T of h)T.target.removeEventListener(T.name,T.handler);h.length=0},m=()=>{u(),e(f),l&&f.src&&URL.revokeObjectURL(f.src)},p=T=>{u(),c(T),l&&f.src&&URL.revokeObjectURL(f.src)},_=T=>{if(T.blockedURI!==f.src||T.disposition==="report")return;u();let A=new Error(`CSP violation of policy ${T.effectiveDirective} ${T.blockedURI}. Current policy is ${T.originalPolicy}`);ue.UseFallbackTexture=!1,c(A),l&&f.src&&URL.revokeObjectURL(f.src),f.src=""};h.push({target:f,name:"load",handler:m}),h.push({target:f,name:"error",handler:p}),h.push({target:document,name:"securitypolicyviolation",handler:_}),d();let g=o.substring(0,5)==="blob:",v=o.substring(0,5)==="data:",I=()=>{g||v||!mi.IsCustomRequestAvailable?f.src=o:tn(o,(T,A,R)=>{let P=!r&&R?R:r,D=new Blob([T],{type:P}),M=URL.createObjectURL(D);l=!0,f.src=M},void 0,i||void 0,!0,(T,A)=>{c(A)})},x=()=>{i&&i.loadImage(o,f)};if(!g&&!v&&i&&i.enableTexturesOffline)i.open(x,I);else{if(o.indexOf("file:")!==-1){let T=decodeURIComponent(o.substring(5).toLowerCase());if(Va.FilesToLoad[T]&&typeof URL!="undefined"){try{let A;try{A=URL.createObjectURL(Va.FilesToLoad[T])}catch(R){A=URL.createObjectURL(Va.FilesToLoad[T])}f.src=A,l=!0}catch(A){f.src=""}return f}}I()}return f},il=(s,e,t,i,r)=>{let n=new FileReader,a={onCompleteObservable:new Q,abort:()=>n.abort()};return n.onloadend=()=>a.onCompleteObservable.notifyObservers(a),r&&(n.onerror=()=>{r(new Pg(`Unable to read ${s.name}`,s))}),n.onload=o=>{e(o.target.result)},t&&(n.onprogress=t),i?n.readAsArrayBuffer(s):n.readAsText(s),a},tn=(s,e,t,i,r,n,a)=>{if(s.name)return il(s,e,t,r,n?f=>{n(void 0,f)}:void 0);let o=s;if(o.indexOf("file:")!==-1){let f=decodeURIComponent(o.substring(5).toLowerCase());f.indexOf("./")===0&&(f=f.substring(2));let h=Va.FilesToLoad[f];if(h)return il(h,e,t,r,n?d=>n(void 0,new lc(d.message,d.file)):void 0)}let{match:l,type:c}=ZI(o);if(l){let f={onCompleteObservable:new Q,abort:()=>()=>{}};try{let h=r?ka(o):qI(o);e(h,void 0,c)}catch(h){n?n(void 0,h):X.Error(h.message||"Failed to parse the Data URL")}return vs.SetImmediate(()=>{f.onCompleteObservable.notifyObservers(f)}),f}return fu(o,(f,h)=>{e(f,h==null?void 0:h.responseURL,h==null?void 0:h.getResponseHeader("content-type"))},t,i,r,n?f=>{n(f.request,new lc(f.message,f.request))}:void 0,a)},fu=(s,e,t,i,r,n,a)=>{var h;i!==null&&(i!=null||(i=(h=ue.LastCreatedScene)==null?void 0:h.offlineProvider)),s=Vt.CleanUrl(s),s=Vt.PreprocessUrl(s);let o=Vt.BaseUrl+s,l=!1,c={onCompleteObservable:new Q,abort:()=>l=!0},f=()=>{let d=new mi,u=null,m,p=()=>{d&&(t&&d.removeEventListener("progress",t),m&&d.removeEventListener("readystatechange",m),d.removeEventListener("loadend",_))},_=()=>{p(),c.onCompleteObservable.notifyObservers(c),c.onCompleteObservable.clear(),t=void 0,m=null,_=null,n=void 0,a=void 0,e=void 0};c.abort=()=>{l=!0,_&&_(),d&&d.readyState!==(XMLHttpRequest.DONE||4)&&d.abort(),u!==null&&(clearTimeout(u),u=null),d=null};let g=I=>{let x=I.message||"Unknown error";n&&d?n(new lu(x,d)):X.Error(x)},v=I=>{if(d){if(d.open("GET",o),a)try{a(d)}catch(x){g(x);return}r&&(d.responseType="arraybuffer"),t&&d.addEventListener("progress",t),_&&d.addEventListener("loadend",_),m=()=>{if(!(l||!d)&&d.readyState===(XMLHttpRequest.DONE||4)){if(m&&d.removeEventListener("readystatechange",m),d.status>=200&&d.status<300||d.status===0&&(!Ft()||jI())){let A=r?d.response:d.responseText;if(A!==null){try{e&&e(A,d)}catch(R){g(R)}return}}let x=Vt.DefaultRetryStrategy;if(x){let A=x(o,d,I);if(A!==-1){p(),d=new mi,u=setTimeout(()=>v(I+1),A);return}}let T=new lu("Error status: "+d.status+" "+d.statusText+" - Unable to load "+o,d);n&&n(T)}},d.addEventListener("readystatechange",m),d.send()}};v(0)};if(i&&i.enableSceneOffline&&!s.startsWith("blob:")){let d=m=>{m&&m.status>400?n&&n(m):f()},u=()=>{i&&i.loadFile(Vt.BaseUrl+s,m=>{!l&&e&&e(m),c.onCompleteObservable.notifyObservers(c)},t?m=>{!l&&t&&t(m)}:void 0,d,r)};i.open(u,d)}else f();return c},KI=s=>{let{match:e,type:t}=ZI(s);if(e)return t||void 0;let i=s.lastIndexOf(".");switch(s.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:",Ga=s=>YI.test(s),ZI=s=>{let e=YI.exec(s);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace(";base64,","")}};qI=s=>Mg(s.split(",")[1]),Jk=()=>{he._FileToolsLoadImage=cc,Vl.loadFile=tn,og.loadFile=tn};Jk();$k=(s,e,t,i,r,n,a,o,l,c)=>{$f={DecodeBase64UrlToBinary:s,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:r,LoadFile:n,LoadImage:a,ReadFile:o,RequestFile:l,SetCorsBehavior:c},Object.defineProperty($f,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(f){t.DefaultRetryStrategy=f}}),Object.defineProperty($f,"BaseUrl",{get:function(){return t.BaseUrl},set:function(f){t.BaseUrl=f}}),Object.defineProperty($f,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(f){t.PreprocessUrl=f}}),Object.defineProperty($f,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(f){t.CorsBehavior=f}})};$k(ka,qI,Vt,Ga,jI,tn,cc,il,fu,cu)});var hu,QI=C(()=>{eu();hu=class s{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=Gn.Zero(),this._cachedBaseSize=Gn.Zero(),this._initialSamplingMode=2,this._texture=s._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 du,JI=C(()=>{du=class s{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),s._HandleParenthesisContent(i,t))):e=s._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:s.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(n=>n==="true");let i,r=e.split("||");for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n)){let a=s._SimplifyNegation(r[n].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 st,Ha=C(()=>{JI();st=class s{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>s.HasTags(e),e.addTags=t=>s.AddTagsTo(e,t),e.removeTags=t=>s.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>s.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)s._AddTagTo(e,r)}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(s.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!s.HasTags(e))return;let i=t.split(" ");for(let r in i)s._RemoveTagFrom(e,i[r])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?s.HasTags(e):du.Eval(t,i=>s.HasTags(e)&&e._tags[i])}}});var $I,De,jt=C(()=>{Ci();Ha();Je();Ee();bg();$I=function(s,e,t,i={}){let r=s();st&&st.HasTags(e)&&st.AddTagsTo(r,st.GetTags(e,!0));let n=su(r),a={};for(let o in n){let l=n[o],c=e[o],f=l.type;if(c!=null&&(o!=="uniqueId"||De.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},De=class s{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i{throw Ce("ImageProcessingConfiguration")};De._FresnelParametersParser=s=>{throw Ce("FresnelParameters")};De._ColorCurvesParser=s=>{throw Ce("ColorCurves")};De._TextureParser=(s,e,t)=>{throw Ce("Texture")}});var ht,fc=C(()=>{$e();Qe();dt();Ee();gt();rc();Wa();QI();jt();ht=class s extends hu{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=Js()),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=s.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 Q,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?s._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 H.IdentityReadOnly}getReflectionTextureMatrix(){return H.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,r,n,a){let o=this._getEngine();if(!o)return null;let l=o._getUseSRGBBuffer(!!n,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=De.Serialize(this);return De.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"}};ht.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;b([L()],ht.prototype,"uniqueId",void 0);b([L()],ht.prototype,"name",void 0);b([L()],ht.prototype,"displayName",void 0);b([L()],ht.prototype,"metadata",void 0);b([L("hasAlpha")],ht.prototype,"_hasAlpha",void 0);b([L("getAlphaFromRGB")],ht.prototype,"_getAlphaFromRGB",void 0);b([L()],ht.prototype,"level",void 0);b([L("coordinatesIndex")],ht.prototype,"_coordinatesIndex",void 0);b([L()],ht.prototype,"optimizeUVAllocation",void 0);b([L("coordinatesMode")],ht.prototype,"_coordinatesMode",void 0);b([L()],ht.prototype,"wrapU",null);b([L()],ht.prototype,"wrapV",null);b([L()],ht.prototype,"wrapR",void 0);b([L()],ht.prototype,"anisotropicFilteringLevel",void 0);b([L()],ht.prototype,"isCube",null);b([L()],ht.prototype,"is3D",null);b([L()],ht.prototype,"is2DArray",null);b([L()],ht.prototype,"gammaSpace",null);b([L()],ht.prototype,"invertZ",void 0);b([L()],ht.prototype,"lodLevelInAlpha",void 0);b([L()],ht.prototype,"lodGenerationOffset",null);b([L()],ht.prototype,"lodGenerationScale",null);b([L()],ht.prototype,"linearSpecularLOD",null);b([qe()],ht.prototype,"irradianceTexture",null);b([L()],ht.prototype,"isRenderTarget",void 0)});var za,zn,Lg=C(()=>{Ee();Mi();Qf();Wi();Je();za=class{constructor(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}},zn=class{static _NearestPow2Floor(e){return e<=1?1:1<0?this._NearestPow2Floor(i):0,n=!e.noMipmap&&((I=e._texture)==null?void 0:I.generateMipMaps)===!0,a=r>0&&r0&&r{Promise.all([f,c,h,d,u,m]).then(([T,A,R,P,D,M])=>{let F=l;g&&(T=this._DownsampleFace(T,t,r,4),A=this._DownsampleFace(A,t,r,4),R=this._DownsampleFace(R,t,r,4),P=this._DownsampleFace(P,t,r,4),D=this._DownsampleFace(D,t,r,4),M=this._DownsampleFace(M,t,r,4),F=r);let N={size:F,right:A,left:T,up:R,down:P,front:D,back:M,format:_,type:T instanceof Float32Array?1:0,gammaSpace:p};x(this.ConvertCubeMapToSphericalPolynomial(N))})})}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static _DownsampleFace(e,t,i,r){let n=e instanceof Float32Array?e:Float32Array.from(e),a=i*i*r,o=new Float32Array(a),l=t/i,c=1/(l*l);for(let d=0;d0?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 qf,n=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,v=e.format===5?4:3;for(let I=0;IF){let O=F/V;P*=O,D*=O,M*=O}}else P=Ye(P,0,F),D=Ye(D,0,F),M=Ye(M,0,F);let N=new ae(P,D,M);r.addLight(A,N,R),n+=R,x+=a}g+=o}}let u=4*Math.PI*6/6/n;return r.scaleInPlace(u),r.convertIncidentRadianceToIrradiance(),r.convertIrradianceToLambertianRadiance(),Qs.FromHarmonics(r)}};zn._FileFaces=[new za("right",new S(1,0,0),new S(0,0,-1),new S(0,-1,0)),new za("left",new S(-1,0,0),new S(0,0,1),new S(0,-1,0)),new za("up",new S(0,1,0),new S(1,0,0),new S(0,0,1)),new za("down",new S(0,-1,0),new S(1,0,0),new S(0,0,-1)),new za("front",new S(0,0,1),new S(1,0,0),new S(0,-1,0)),new za("back",new S(0,0,-1),new S(-1,0,0),new S(0,-1,0))];zn.MAX_HDRI_VALUE=4096;zn.PRESERVE_CLAMPED_COLORS=!1});var Xn,Og=C(()=>{We();Pt();Xn=class{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];let t=Ni(e);if(t)return t;X.Warn(e+" not found, you may have missed an import.");let i=e.split("."),r=window||this;for(let n=0,a=i.length;n=0;){let h=s[c];h<0?h=0:h>1&&(h=1),f[c]=h*255}s=f}let n=document.createElement("canvas");n.width=i,n.height=r;let a=n.getContext("2d");if(!a)return null;let o=a.createImageData(i,r);if(o.data.set(s),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(n,0,0),c.toDataURL("image/png")):null}return n.toDataURL("image/png")}function tC(s,e=0,t=0){let i=s.getInternalTexture();if(!i)return null;let r=s._readPixelsSync(e,t);return r?eC(r,s.getSize(),i.invertY):null}async function iC(s,e=0,t=0){let i=s.getInternalTexture();if(!i)return null;let r=await s.readPixels(e,t);return r?eC(r,s.getSize(),i.invertY):null}var rC=C(()=>{});var ze,vi=C(()=>{ze=!1});var ne,pi=C(()=>{$e();Qe();dt();Ee();fc();Pt();Ci();Ys();Og();Jo();ac();rC();vi();jt();ne=class s extends ht{static _CreateVideoTexture(e,t,i,r=!1,n=!1,a=s.TRILINEAR_SAMPLINGMODE,o={},l,c=5){throw Ce("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,n=s.TRILINEAR_SAMPLINGMODE,a=null,o=null,l=null,c=!1,f,h,d,u,m){var R,P,D,M,F,N,V,O,U,k,z;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 Q,this._isBlocking=!0,this.name=e||"",this.url=e;let p,_=!1,g=null,v=!0;typeof i=="object"&&i!==null?(p=(R=i.noMipmap)!=null?R:!1,r=(P=i.invertY)!=null?P:!ze,n=(D=i.samplingMode)!=null?D:s.TRILINEAR_SAMPLINGMODE,a=(M=i.onLoad)!=null?M:null,o=(F=i.onError)!=null?F:null,l=(N=i.buffer)!=null?N:null,c=(V=i.deleteBuffer)!=null?V:!1,f=i.format,h=i.mimeType,d=i.loaderOptions,u=i.creationFlags,_=(O=i.useSRGBBuffer)!=null?O:!1,g=(U=i.internalTexture)!=null?U:null,v=(k=i.gammaSpace)!=null?k:v,m=(z=i.forcedExtension)!=null?z:m):p=!!i,this._gammaSpace=v,this._noMipmap=p,this._invertY=r===void 0?!ze:r,this._initialSamplingMode=n,this._buffer=l,this._deleteBuffer=c,this._mimeType=h,this._loaderOptions=d,this._creationFlags=u,this._useSRGBBuffer=_,this._forcedExtension=m,f!==void 0&&(this._format=f);let I=this.getScene(),x=this._getEngine();if(!x)return;x.onBeforeTextureInitObservable.notifyObservers(this);let T=()=>{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&&I&&I.resetCachedMaterial()},A=(Z,J)=>{this._loadingError=!0,this._errorObject={message:Z,exception:J},o&&o(Z,J),s.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!g){this._delayedOnLoad=T,this._delayedOnError=A;return}if(this._texture=g!=null?g:this._getFromCache(this.url,p,n,this._invertY,_,this.isCube),this._texture)if(this._texture.isReady)vs.SetImmediate(()=>T());else{let Z=this._texture.onLoadedObservable.add(T);this._texture.onErrorObservable.add(J=>{var q;A(J.message,J.exception),(q=this._texture)==null||q.onLoadedObservable.remove(Z)})}else if(!I||!I.useDelayedTextureLoading){try{this._texture=x.createTexture(this.url,p,this._invertY,I,n,T,A,this._buffer,void 0,this._format,this._forcedExtension,h,d,u,_)}catch(Z){throw A("error loading",Z),Z}c&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=T,this._delayedOnError=A}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 n=this._delayedOnLoad,a=()=>{n?n():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?vs.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,S.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=H.Zero(),this._rowGenerationMatrix=new H,this._t0=S.Zero(),this._t1=S.Zero(),this._t2=S.Zero()),H.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(H.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,W.Matrix[0]),H.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,W.Matrix[1]),H.ScalingToRef(this._cachedUScale,this._cachedVScale,0,W.Matrix[2]),H.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,W.Matrix[3]),W.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(W.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(W.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(W.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),H.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===s.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=H.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=H.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 s.PLANAR_MODE:{H.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 s.PROJECTION_MODE:{H.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:H.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 De.Clone(()=>new s(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){var i,r;let e=this.name;s.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");let t=super.serialize(s._SerializeInternalTextureUniqueId);if(!t)return null;if(s.SerializeBuffers||s.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 n=this.mimeType||"image/png";t.base64String=`data:${n};base64,${$s(this._buffer)}`}else(s.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?tC(this):iC(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,s._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=Xn.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 s._CubeTextureParser(e,t,i);let r=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!r)return null;let n;if(r){let l=t.getEngine().getLoadedTexturesCache();for(let c of l)if(c.uniqueId===e.internalTextureUniqueId){n=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,h,d,u;let l=!0;if(e.noMipmap&&(l=!1),e.mirrorPlane){let m=s._CreateMirror(e.name,e.renderTargetSize,t,l);return m._waitingRenderList=e.renderList,m.mirrorPlane=pr.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=s.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:")||s.UseSerializedUrlIfAny)&&(p=e.url);let _={noMipmap:!l,invertY:e.invertY,samplingMode:e.samplingMode,useSRGBBuffer:(d=e._useSRGBBuffer)!=null?d:!1,creationFlags:(u=e._creationFlags)!=null?u:0,onLoad:()=>{a(m)},internalTexture:n};m=new s(p,t,_)}return m}},e,t)}static CreateFromBase64String(e,t,i,r,n,a=s.TRILINEAR_SAMPLINGMODE,o=null,l=null,c=5,f,h){return new s("data:"+t,i,r,n,a,o,l,e,!1,c,void 0,void 0,f,h)}static LoadFromDataString(e,t,i,r=!1,n,a=!0,o=s.TRILINEAR_SAMPLINGMODE,l=null,c=null,f=5,h,d){return e.substring(0,5)!=="data:"&&(e="data:"+e),new s(e,i,n,a,o,l,c,t,r,f,void 0,void 0,h,d)}};ne.SerializeBuffers=!0;ne.ForceSerializeBuffers=!1;ne.OnTextureLoadErrorObservable=new Q;ne._SerializeInternalTextureUniqueId=!1;ne._CubeTextureParser=(s,e,t)=>{throw Ce("CubeTexture")};ne._CreateMirror=(s,e,t,i)=>{throw Ce("MirrorTexture")};ne._CreateRenderTargetTexture=(s,e,t,i,r)=>{throw Ce("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;b([L()],ne.prototype,"url",void 0);b([L()],ne.prototype,"uOffset",void 0);b([L()],ne.prototype,"vOffset",void 0);b([L()],ne.prototype,"uScale",void 0);b([L()],ne.prototype,"vScale",void 0);b([L()],ne.prototype,"uAng",void 0);b([L()],ne.prototype,"vAng",void 0);b([L()],ne.prototype,"wAng",void 0);b([L()],ne.prototype,"uRotationCenter",void 0);b([L()],ne.prototype,"vRotationCenter",void 0);b([L()],ne.prototype,"wRotationCenter",void 0);b([L()],ne.prototype,"homogeneousRotationInUVTransform",void 0);b([L()],ne.prototype,"isBlocking",null);Ke("BABYLON.Texture",ne);De._TextureParser=ne.Parse});var Er,y,It=C(()=>{dg();We();oc();Er=class{get isDisposed(){return this._isDisposed}constructor(e,t,i,r=0,n=!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 Ko?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}createVertexBuffer(e,t,i,r,n,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 y(this._engine,this,e,this._updatable,!0,c,n===void 0?this._instanced:n,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}X.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)}},y=class s{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,n,a,o,l,c,f,h=!1,d=!1,u=1,m=!1){var g,v,I,x,T;this._isDisposed=!1;let p;if(this.engine=e,typeof r=="object"&&r!==null?(p=(g=r.updatable)!=null?g:!1,n=r.postponeInternalCreation,a=r.stride,o=r.instanced,l=r.offset,c=r.size,f=r.type,h=(v=r.normalized)!=null?v:!1,d=(I=r.useBytes)!=null?I:!1,u=(x=r.divisor)!=null?x:1,m=(T=r.takeBufferOwnership)!=null?T:!1,this._label=r.label):p=!!r,t instanceof Er?(this._buffer=t,this._ownsBuffer=m):(this._buffer=new Er(e,t,p,a,n,o,d,u,this._label),this._ownsBuffer=!0),this.uniqueId=s._Counter++,this._kind=i,f===void 0){let A=this.getData();this.type=A?s.GetDataType(A):s.FLOAT}else this.type=f;let _=en(this.type);d?(this._size=c||(a?a/_:s.DeduceStride(i)),this.byteStride=a||this._buffer.byteStride||this._size*_,this.byteOffset=l||0):(this._size=c||a||s.DeduceStride(i),this.byteStride=a?a*_:this._buffer.byteStride||this._size*_,this.byteOffset=(l||0)*_),this.normalized=h,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?Dg(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/en(this.type)}getOffset(){return this.byteOffset/en(this.type)}getSize(e=!1){return e?this._size*en(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){tl(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,(i,r)=>{for(let n=0;n{for(let h=0;h{It();dt();Yn=class{constructor(e){this._vertexBuffers={},this._activePostProcesses=[],this.onBeforeRenderObservable=new Q,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[y.PositionKind])return;let e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[y.PositionKind]=new y(this._scene.getEngine(),e,y.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{We();sC=(s,e,t)=>!s||s.getClassName&&s.getClassName()==="Mesh"?null:s.getClassName&&(s.getClassName()==="SubMesh"||s.getClassName()==="PhysicsBody")?s.clone(e):s.clone?s.clone():Array.isArray(s)?s.slice():t&&typeof s=="object"?{...s}:null;rn=class{static DeepCopy(e,t,i,r,n=!1){let a=eW(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{dt();Pr();We();eh();Bn();Ci();sc();gt();Wa();Ys();Og();rc();js();se=class{static get BaseUrl(){return Vt.BaseUrl}static set BaseUrl(e){Vt.BaseUrl=e}static get CleanUrl(){return Vt.CleanUrl}static set CleanUrl(e){Vt.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("://"){tn(e,n=>{i(n)},void 0,void 0,t,(n,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){_native&&Ve.LoadFile(e,r=>{Function(r).apply(null),t&&t()},void 0,void 0,!1,(r,n)=>{i&&i("LoadScript Error",n)})}static _LoadScriptWeb(e,t,i,r,n=!1){if(typeof importScripts=="function"){try{importScripts(e),t&&t()}catch(l){i==null||i(`Unable to load script '${e}' in worker`,l)}return}else if(!Ft()){i==null||i(`Cannot load script '${e}' outside of a window or a worker`);return}let a=document.getElementsByTagName("head")[0],o=document.createElement("script");n?(o.setAttribute("type","module"),o.innerText=e):(o.setAttribute("type","text/javascript"),o.setAttribute("src",e)),r&&(o.id=r),o.onload=()=>{t&&t()},o.onerror=l=>{i&&i(`Unable to load script '${e}'`,l)},a.appendChild(o)}static async LoadScriptAsync(e,t){return await new Promise((i,r)=>{this.LoadScript(e,()=>{i()},(n,a)=>{r(a||new Error(n))},t)})}static ReadFileAsDataURL(e,t,i){let r=new FileReader,n={onCompleteObservable:new Q,abort:()=>r.abort()};return r.onloadend=()=>{n.onCompleteObservable.notifyObservers(n)},r.onload=a=>{t(a.target.result)},r.onprogress=i,r.readAsDataURL(e),n}static ReadFile(e,t,i,r,n){return il(e,t,i,r,n)}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){rn.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 h=0;ht(n)):e.toBlob(function(n){t(n)},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 n=r.document.createElement("img");n.onload=function(){URL.revokeObjectURL(i)},n.src=i,r.document.body.appendChild(n)}}static EncodeScreenshotCanvasData(e,t,i="image/png",r,n){if(typeof r=="string"||!t)this.ToBlob(e,function(a){a&&Ve.DownloadBlob(a,r),t&&t("")},i,n);else if(t){if(Ve._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:n}).then(o=>{let l=new FileReader;l.readAsDataURL(o),l.onloadend=()=>{let c=l.result;t(c)}});return}let a=e.toDataURL(i,n);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,n="image/png",a=!1,o){throw Ce("ScreenshotTools")}static async CreateScreenshotAsync(e,t,i,r="image/png",n){throw Ce("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,r,n="image/png",a=1,o=!1,l,c=!1,f=!1,h=!0,d,u){throw Ce("ScreenshotTools")}static async CreateScreenshotUsingRenderTargetAsync(e,t,i,r="image/png",n=1,a=!1,o,l=!1,c=!1,f=!0,h,d){throw Ce("ScreenshotTools")}static RandomId(){return Js()}static IsBase64(e){return Ga(e)}static DecodeBase64(e){return ka(e)}static get errorsCount(){return X.errorsCount}static Log(e){X.Log(e)}static Warn(e){X.Warn(e)}static Error(e){X.Error(e)}static get LogCache(){return X.LogCache}static ClearLogCache(){X.ClearLogCache()}static set LogLevels(e){X.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(!Ft())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 Xt.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 n=t?e:Object.getPrototypeOf(e);i=n.constructor.__bjsclassName__,r=n.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 wn()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}};Ve=se;se.AssetBaseUrl="";se.UseCustomRequestHeaders=!1;se.CustomRequestHeaders=mi.CustomRequestHeaders;se.GetDOMTextContent=Ad;se._DefaultCdnUrl="https://cdn.babylonjs.com";se._CdnVersion="9.6.0";se._DefaultAssetsUrl="https://assets.babylonjs.com/core";se.LoadScript=typeof _native=="undefined"?Ve._LoadScriptWeb:Ve._LoadScriptNative;se.GetAbsoluteUrl=typeof document=="object"?s=>{let e=document.createElement("a");return e.href=s,e.href}:typeof URL=="function"&&typeof location=="object"?s=>new URL(s,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")};se.NoneLogLevel=X.NoneLogLevel;se.MessageLogLevel=X.MessageLogLevel;se.WarningLogLevel=X.WarningLogLevel;se.ErrorLogLevel=X.ErrorLogLevel;se.AllLogLevel=X.AllLogLevel;se.IsWindowObjectExist=Ft;se.PerformanceNoneLogLevel=0;se.PerformanceUserMarkLogLevel=1;se.PerformanceConsoleLogLevel=2;se._NativePerformanceCounterHandles=new Map;se.StartPerformanceCounter=Ve._StartPerformanceCounterDisabled;se.EndPerformanceCounter=Ve._EndPerformanceCounterDisabled;mu=class s{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{n&&n()?o.breakLoop():setTimeout(()=>{for(let l=0;l=e)break;if(i(c),n&&n()){o.breakLoop();break}}o.executeNext()},a)},r)}};se.Mix=Kf;se.IsExponentOfTwo=jo;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 Wt,Xa=C(()=>{We();At();Wt=class s{constructor(e,t,i=!1,r,n=!1,a){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||n,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 n=0;n0&&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 n=0;n1&&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){X.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 n=0;n1&&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{yt=class s{constructor(e){this.length=0,this.data=new Array(e),this._id=s._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}};yt._GlobalId=0;Ts=class extends yt{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{As();Ee();th=class s{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=s.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=s.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=s.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,r=null,n=null){this.index=e,this._opaqueSubMeshes=new yt(256),this._transparentSubMeshes=new yt(256),this._alphaTestSubMeshes=new yt(256),this._depthOnlySubMeshes=new yt(256),this._particleSystems=new yt(256),this._spriteManagers=new yt(256),this._empty=!0,this._edgesRenderers=new Ts(16),this.disableDepthPrePass=!1,this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=n}render(e,t,i,r,n=!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();n&&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 h=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(h),c)c(this._transparentSubMeshes,this);else if(this._scene.useOrderIndependentTransparency){let d=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);d.length&&this._renderTransparent(d)}else this._renderTransparent(this._transparentSubMeshes);f.setAlphaMode(0)}if(f.setStencilBuffer(!1),a&&this._edgesRenderers.length){for(let d=0;dt._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{nC();Ng=class{},Qr=class s{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 Ng,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=s.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 Jr,Fg=C(()=>{Xa();dt();pu();Zs();Ys();We();As();ih();Jr=class s{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=Qd(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?(X.Error("ObjectRenderer: Timeout while waiting for the renderer to be ready."),t&&X.Error(t)):(X.Error("ObjectRenderer: An unexpected error occurred while waiting for the renderer to be ready."),t&&(X.Error(t),t.stack&&X.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(n===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 Q,this.onAfterRenderObservable=new Q,this.onBeforeRenderingManagerRenderObservable=new Q,this.onAfterRenderingManagerRenderObservable=new Q,this.onInitRenderingObservable=new Q,this.onFinishRenderingObservable=new Q,this.onFastPathRenderObservable=new Q,this._currentRefreshId=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._activeMeshes=new yt(256),this._activeBoundingBoxes=new yt(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 Qr(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 n=this._sceneUBOs.length;this._sceneUBOs.push(this._createSceneUBO(`Scene ubo #${n} 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 n=this.particleSystemList||e.particleSystems;for(let a of n)a.isReady()||(i=!1);return this._engine.currentRenderPassId=t,i}_prepareRenderingManager(e=0,t=!1){var d,u;let i=this._scene,r=null,n,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)n=r.length,a=this.forceLayerMaskCheck;else{if(this._defaultRenderListPrepared&&!t&&!this._engine.isWebGPU)return o;this._defaultRenderListPrepared=!0,r=o,n=l,a=!this.renderList||this.forceLayerMaskCheck}let c=i.activeCamera,f=(d=this.cameraForLOD)!=null?d:c,h=(u=i.getBoundingBoxRenderer)==null?void 0:u.call(i);if(i._activeMeshesFrozen&&this._isFrozen){if(this._renderingManager.resetSprites(),this.enableBoundingBoxRendering&&h){h.reset();for(let m=0;m{Ys();yi=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():vs.SetImmediate(()=>{i.getEngine().onEndFrameObservable.addOnce(()=>{i.dispose()})}),this.effect=null}(t=this.drawContext)==null||t.dispose()}}});var oC={};Ie(oC,{postprocessVertexShader:()=>tW});var wg,aC,tW,Bg=C(()=>{w();wg="postprocessVertexShader",aC=`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[wg]||(E.ShadersStore[wg]=aC);tW={name:wg,shader:aC}});var cC={};Ie(cC,{postprocessVertexShaderWGSL:()=>iW});var Ug,lC,iW,Vg=C(()=>{w();Ug="postprocessVertexShader",lC=`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 { +#define CUSTOM_VERTEX_MAIN_BEGIN +vertexOutputs.vUV=(vertexInputs.position*madd+madd)*uniforms.scale;vertexOutputs.position=vec4(vertexInputs.position,0.0,1.0); +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStoreWGSL[Ug]||(E.ShadersStoreWGSL[Ug]=lC);iW={name:Ug,shader:lC}});var Gg,_u,_i,rl=C(()=>{It();$l();dt();Ba();Ya();Bg();Vg();Gg={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]},_u=class{constructor(e,t=Gg){var n,a;this._fullscreenViewport=new Ss(0,0,1,1);let i=(n=t.positions)!=null?n:Gg.positions,r=(a=t.indices)!=null?a:Gg.indices;this.engine=e,this._vertexBuffers={[y.PositionKind]:new y(e,i,y.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[y.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[y.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}},_i=class s{static RegisterShaderCodeProcessing(e,t){if(!t){delete s._CustomShaderCodeProcessing[e!=null?e:""];return}s._CustomShaderCodeProcessing[e!=null?e:""]=t}static _GetShaderCodeProcessing(e){var t;return(t=s._CustomShaderCodeProcessing[e])!=null?t:s._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 Q(void 0,!0),this.onApplyObservable=new Q,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 yi(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 n=this.options.engine.isWebGPU&&!s.ForceGLSL;this._gatherImports(n,this._importPromises),i!==void 0&&i(n,this._importPromises),n&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,r,n,a,o,l){var d,u;let c=s._GetShaderCodeProcessing(this.name);if(c!=null&&c.defineCustomBindings){let m=(d=t==null?void 0:t.slice())!=null?d:[];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},h;this.options.extraInitializationsAsync?h=async()=>{f==null||f(),await this.options.extraInitializationsAsync()}:h=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:n!=null?n: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:h},this.options.engine):this._drawWrapper.effect=new wt(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,n||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,h),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=s._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)}};_i.ForceGLSL=!1;_i._CustomShaderCodeProcessing={}});var Wg={};Ie(Wg,{passPixelShader:()=>rW});var kg,fC,rW,Hg=C(()=>{w();kg="passPixelShader",fC=`varying vec2 vUV;uniform sampler2D textureSampler; +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{gl_FragColor=texture2D(textureSampler,vUV);}`;E.ShadersStore[kg]||(E.ShadersStore[kg]=fC);rW={name:kg,shader:fC}});var hC={};Ie(hC,{Dispose:()=>Xg,DumpData:()=>gu,DumpDataAsync:()=>sh,DumpFramebuffer:()=>zg,DumpTools:()=>oW,EncodeImageAsync:()=>aW});async function sW(){var o,l;let s=(l=(o=ue.LastCreatedEngine)==null?void 0:o.createCanvas(100,100))!=null?l:new OffscreenCanvas(100,100);s instanceof OffscreenCanvas&&X.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");let{ThinEngine:e}=await Promise.resolve().then(()=>(ur(),fI));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(s,!1,t);ue.Instances.pop(),ue.OnEnginesDisposedObservable.add(c=>{i&&c!==i&&!i.isDisposed&&ue.Instances.length===0&&Xg()}),i.getCaps().parallelShaderCompile=void 0;let r=new _u(i),{passPixelShader:n}=await Promise.resolve().then(()=>(Hg(),Wg)),a=new _i({engine:i,name:n.name,fragmentShader:n.shader,samplerNames:["textureSampler"]});return{canvas:s,dumpEngine:{engine:i,renderer:r,wrapper:a}}}async function nW(){return Ka||(Ka=sW()),await Ka}async function zg(s,e,t,i,r="image/png",n,a){let o=await t.readPixels(0,0,s,e),l=new Uint8Array(o.buffer);gu(s,e,l,i,r,n,!0,void 0,a)}async function sh(s,e,t,i="image/png",r,n=!1,a=!1,o){if(t instanceof Float32Array){let f=new Uint8Array(t.length),h=t.length;for(;h--;){let d=t[h];f[h]=Math.round(Ye(d)*255)}t=f}let l=await rh.EncodeImageAsync(t,s,e,i,n,o);r!==void 0&&se.DownloadBlob(l,r),l.type!==i&&X.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,${$s(c)}`}function gu(s,e,t,i,r="image/png",n,a=!1,o=!1,l){n===void 0&&!i&&(n=""),sh(s,e,t,r,n,a,o,l).then(c=>{i&&i(c)})}function Xg(){Ka&&(Ka==null||Ka.then(s=>{s.canvas instanceof HTMLCanvasElement&&s.canvas.remove(),s.dumpEngine&&(s.dumpEngine.engine.dispose(),s.dumpEngine.renderer.dispose(),s.dumpEngine.wrapper.dispose())}),Ka=null)}var Ka,rh,aW,oW,lW,Yg=C(()=>{$e();rl();At();Mi();gt();We();ac();Qe();Ka=null;rh=class{static async EncodeImageAsync(e,t,i,r,n,a){let o=await nW(),l=o.dumpEngine;l.engine.setSize(t,i,!0);let c=l.engine.createRawTexture(e,t,i,5,!1,!n,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,h)=>{se.ToBlob(o.canvas,d=>{d?f(d):h(new Error("EncodeImageAsync: Failed to convert canvas to blob."))},r,a)})}};b([_r],rh,"EncodeImageAsync",null);aW=rh.EncodeImageAsync;oW={DumpData:gu,DumpDataAsync:sh,DumpFramebuffer:zg,Dispose:Xg},lW=()=>{se.DumpData=gu,se.DumpDataAsync=sh,se.DumpFramebuffer=zg};lW()});var fi,ja=C(()=>{dt();Ee();pi();uu();js();Ba();We();Fg();wt.prototype.setDepthStencilTexture=function(s,e){this._engine.setDepthStencilTexture(this._samplers[s],this._uniforms[s],e,s)};fi=class s 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,n=!0,a=0,o=!1,l=ne.TRILINEAR_SAMPLINGMODE,c=!0,f=!1,h=!1,d=5,u=!1,m,p,_=!1,g=!1){var R,P,D,M,F,N,V;let v,I=!0,x,T=!1;if(typeof r=="object"){let O=r;r=!!O.generateMipMaps,n=(R=O.doNotChangeAspectRatio)!=null?R:!0,a=(P=O.type)!=null?P:0,o=!!O.isCube,l=(D=O.samplingMode)!=null?D:ne.TRILINEAR_SAMPLINGMODE,c=(M=O.generateDepthBuffer)!=null?M:!0,f=!!O.generateStencilBuffer,h=!!O.isMulti,d=(F=O.format)!=null?F:5,u=!!O.delayAllocation,m=O.samples,p=O.creationFlags,_=!!O.noColorAttachment,g=!!O.useSRGBBuffer,v=O.colorAttachment,I=(N=O.gammaSpace)!=null?N:I,x=O.existingObjectRenderer,T=!!O.enableClusteredLights}if(super(null,i,!r,void 0,l,void 0,void 0,void 0,void 0,d),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new Q,this.onAfterUnbindObservable=new Q,this.onClearObservable=new Q,this.onResizeObservable=new Q,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this._dontDisposeObjectRenderer=!1,this.boundingBoxPosition=S.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,i=this.getScene(),!i)return;let A=this.getScene().getEngine();this._gammaSpace=I,this._coordinatesMode=ne.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!x,this._processSizeParameter(t),this._objectRenderer=x!=null?x:new Jr(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:n,enableClusteredLights:T}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{var U;let O=this._scene;if(!this._disableEngineStages)for(let k of O._beforeRenderTargetClearStage)k.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(A):this.skipInitialClear||A.clear((U=this.clearColor)!=null?U:O.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||O.updateTransformMatrix(!0),!this._disableEngineStages)for(let k of O._beforeRenderTargetDrawStage)k.action(this,this._currentFaceIndex,this._currentLayer);A._debugPushGroup&&A._debugPushGroup(`Render to ${this.name} (face #${this._currentFaceIndex} layer #${this._currentLayer})`)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{var U,k,z,Z;if(A._debugPopGroup&&A._debugPopGroup(),!this._disableEngineStages)for(let J of this._scene._afterRenderTargetDrawStage)J.action(this,this._currentFaceIndex,this._currentLayer);let O=(k=(U=this._texture)==null?void 0:U.generateMipMaps)!=null?k:!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,(z=this._renderTarget)!=null?z:void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,(Z=this._renderTarget)!=null?Z:void 0,this._currentFaceIndex),!this._disableEngineStages)for(let J of this._scene._afterRenderTargetPostProcessStage)J.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(),A):X.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(A):this.skipInitialClear||A.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=A.onResizeObservable.add(()=>{}),this._generateMipMaps=!!r,this._doNotChangeAspectRatio=n,!h&&(this._renderTargetOptions={generateMipMaps:r,type:a,format:(V=this._format)!=null?V:void 0,samplingMode:this.samplingMode,generateDepthBuffer:c,generateStencilBuffer:f,samples:m,creationFlags:p,noColorAttachment:_,useSRGBBuffer:g,colorAttachment:v,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=H.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,n=14,a){var o;(o=this._renderTarget)==null||o.createDepthStencilTexture(e,t,i,r,n,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 Yn(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(()=>(Yg(),hC)).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 n=0;n{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 n=this.getScene();if(!n)return;let a=n.getEngine();this._currentFaceIndex=e,this._currentLayer=r,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(n,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 s(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}};fi.REFRESHRATE_RENDER_ONCE=Jr.REFRESHRATE_RENDER_ONCE;fi.REFRESHRATE_RENDER_ONEVERYFRAME=Jr.REFRESHRATE_RENDER_ONEVERYFRAME;fi.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Jr.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;ne._CreateRenderTargetTexture=(s,e,t,i,r)=>new fi(s,e,t,i)});var Rt,Kn=C(()=>{$e();As();dt();Ee();Ba();Qe();jt();Pt();ci();js();rl();he.prototype.setTextureFromPostProcess=function(s,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(s,(r=i==null?void 0:i.texture)!=null?r:null,t)};he.prototype.setTextureFromPostProcessOutput=function(s,e,t){var i,r;this._bindTexture(s,(r=(i=e==null?void 0:e._outputTexture)==null?void 0:i.texture)!=null?r:null,t)};wt.prototype.setTextureFromPostProcess=function(s,e){this._engine.setTextureFromPostProcess(this._samplers[s],e,s)};wt.prototype.setTextureFromPostProcessOutput=function(s,e){this._engine.setTextureFromPostProcessOutput(this._samplers[s],e,s)};Rt=class s{static get ForceGLSL(){return _i.ForceGLSL}static set ForceGLSL(e){_i.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){_i.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,n,a,o=1,l,c,f=null,h=0,d="postprocess",u,m=!1,p=5,_,g){var T,A,R,P,D,M,F,N,V,O,U,k;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 yt(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new me(1,1),this._texelSize=me.Zero(),this.onActivateObservable=new Q,this.onSizeChangedObservable=new Q,this.onApplyObservable=new Q,this.onBeforeRenderObservable=new Q,this.onAfterRenderObservable=new Q,this.onDisposeObservable=new Q;let v=1,I=null,x;if(i&&!Array.isArray(i)){let z=i;i=(T=z.uniforms)!=null?T:null,r=(A=z.samplers)!=null?A:null,v=(R=z.size)!=null?R:1,a=(P=z.camera)!=null?P:null,o=(D=z.samplingMode)!=null?D:1,l=z.engine,c=z.reusable,f=Array.isArray(z.defines)?z.defines.join(` +`):(M=z.defines)!=null?M:null,h=(F=z.textureType)!=null?F:0,d=(N=z.vertexUrl)!=null?N:"postprocess",u=z.indexParameters,m=(V=z.blockCompilation)!=null?V:!1,p=(O=z.textureFormat)!=null?O:5,_=(U=z.shaderLanguage)!=null?U:0,I=(k=z.uniformBuffers)!=null?k:null,g=z.extraInitializations,x=z.effectWrapper}else n&&(typeof n=="number"?v=n:v={width:n.width,height:n.height});if(this._useExistingThinPostProcess=!!x,this._effectWrapper=x!=null?x:new _i({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:l||(a==null?void 0:a.getScene().getEngine()),uniforms:i,samplers:r,uniformBuffers:I,defines:f,vertexUrl:d,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=v,this.renderTargetSamplingMode=o||1,this._reusable=c||!1,this._textureType=h,this._textureFormat=p,this._shaderLanguage=_||0,this._samplers=r||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=d,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=I||[],this._indexParameters=u,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;let z=[];this._gatherImports(this._engine.isWebGPU&&!s.ForceGLSL,z),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(m,f,g,z)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([Promise.resolve().then(()=>(Vg(),cC))])):t.push(Promise.all([Promise.resolve().then(()=>(Bg(),oC))]))}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 yt(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,r,n,a,o,l){this._effectWrapper.updateEffect(e,t,i,r,n,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 n=0;n=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/h),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:n.clearColor,n._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=De.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=s.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=Ni(e.customType);if(!r||!r._Parse)return null;let n=t?t.getCameraById(e.cameraId):null;return r._Parse(e,n,t,i)}static _Parse(e,t,i,r){return De.Parse(()=>new s(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)}};b([L()],Rt.prototype,"uniqueId",void 0);b([L()],Rt.prototype,"name",null);b([L()],Rt.prototype,"width",void 0);b([L()],Rt.prototype,"height",void 0);b([L()],Rt.prototype,"renderTargetSamplingMode",void 0);b([ic()],Rt.prototype,"clearColor",void 0);b([L()],Rt.prototype,"autoClear",void 0);b([L()],Rt.prototype,"forceAutoClearInAlphaMode",void 0);b([L()],Rt.prototype,"alphaMode",null);b([L()],Rt.prototype,"alphaConstants",void 0);b([L()],Rt.prototype,"enablePixelPerfectMode",void 0);b([L()],Rt.prototype,"forceFullscreenViewport",void 0);b([L()],Rt.prototype,"scaleMode",void 0);b([L()],Rt.prototype,"alwaysForcePOT",void 0);b([L("samples")],Rt.prototype,"_samples",void 0);b([L()],Rt.prototype,"adaptScaleToCurrentViewport",void 0);Ke("BABYLON.PostProcess",Rt)});var uC={};Ie(uC,{passPixelShaderWGSL:()=>cW});var Kg,dC,cW,mC=C(()=>{w();Kg="passPixelShader",dC=`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[Kg]||(E.ShadersStoreWGSL[Kg]=dC);cW={name:Kg,shader:dC}});var _C={};Ie(_C,{passCubePixelShaderWGSL:()=>fW});var jg,pC,fW,gC=C(()=>{w();jg="passCubePixelShader",pC=`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; +#ifdef POSITIVEX +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(1.001,uv.y,uv.x)); +#endif +#ifdef NEGATIVEX +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(-1.001,uv.y,uv.x)); +#endif +#ifdef POSITIVEY +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv.y,1.001,uv.x)); +#endif +#ifdef NEGATIVEY +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv.y,-1.001,uv.x)); +#endif +#ifdef POSITIVEZ +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv,1.001)); +#endif +#ifdef NEGATIVEZ +fragmentOutputs.color=textureSample(textureSampler,textureSamplerSampler,vec3f(uv,-1.001)); +#endif +}`;E.ShadersStoreWGSL[jg]||(E.ShadersStoreWGSL[jg]=pC);fW={name:jg,shader:pC}});var vC={};Ie(vC,{passCubePixelShader:()=>hW});var Zg,EC,hW,SC=C(()=>{w();Zg="passCubePixelShader",EC=`varying vec2 vUV;uniform samplerCube textureSampler; +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{vec2 uv=vUV*2.0-1.0; +#ifdef POSITIVEX +gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x)); +#endif +#ifdef NEGATIVEX +gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x)); +#endif +#ifdef POSITIVEY +gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x)); +#endif +#ifdef NEGATIVEY +gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x)); +#endif +#ifdef POSITIVEZ +gl_FragColor=textureCube(textureSampler,vec3(uv,1.001)); +#endif +#ifdef NEGATIVEZ +gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001)); +#endif +}`;E.ShadersStore[Zg]||(E.ShadersStore[Zg]=EC);hW={name:Zg,shader:EC}});var jn,nh,qg=C(()=>{rl();gt();jn=class s extends _i{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(mC(),uC))]))):t.push(Promise.all([Promise.resolve().then(()=>(Hg(),Wg))])),super._gatherImports(e,t)}constructor(e,t=null,i){let r={name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:s.FragmentUrl,...i};r.engine||(r.engine=ue.LastCreatedEngine),super(r)}};jn.FragmentUrl="pass";nh=class s extends _i{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(gC(),_C))]))):t.push(Promise.all([Promise.resolve().then(()=>(SC(),vC))])),super._gatherImports(e,t)}constructor(e,t=null,i){super({...i,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:s.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}}};nh.FragmentUrl="passCube"});var sl,Qg,Jg=C(()=>{$e();Kn();ci();Pt();jt();qg();Qe();sl=class s extends Rt{getClassName(){return"PassPostProcess"}constructor(e,t,i=null,r,n,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:n,reusable:a,textureType:o,blockCompilation:l,...t};super(e,jn.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new jn(e,n,c):void 0,...c})}static _Parse(e,t,i,r){return De.Parse(()=>new s(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};Ke("BABYLON.PassPostProcess",sl);Qg=class s extends Rt{get face(){return this._effectWrapper.face}set face(e){this._effectWrapper.face=e}getClassName(){return"PassCubePostProcess"}constructor(e,t,i=null,r,n,a,o=0,l=!1){let c={size:typeof t=="number"?t:void 0,camera:i,samplingMode:r,engine:n,reusable:a,textureType:o,blockCompilation:l,...t};super(e,jn.FragmentUrl,{effectWrapper:typeof t=="number"||!t.effectWrapper?new nh(e,n,c):void 0,...c})}static _Parse(e,t,i,r){return De.Parse(()=>new s(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable),e,i,r)}};b([L()],Qg.prototype,"face",null);he._RescalePostProcessFactory=s=>new sl("rescale",1,null,2,s,!1,0)});function AC(s,e,t,i,r,n,a,o){let l=e.getEngine();return e.isReady=!1,r=r!=null?r:e.samplingMode,i=i!=null?i:e.type,n=n!=null?n:e.format,a=a!=null?a:e.width,o=o!=null?o:e.height,i===-1&&(i=0),new Promise(c=>{let f=new Rt("postprocess",s,null,null,1,null,r,l,!1,void 0,i,void 0,null,!1,n);f.externalTextureSamplerBinding=!0;let h=l.createRenderTargetTexture({width:a,height:o},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:r,type:i,format:n});f.onEffectCreatedObservable.addOnce(d=>{d.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",e),u.setFloat2("scale",1,1)},t.postProcessManager.directRender([f],h,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(e),f&&f.dispose(),h._swapAndDie(e),e.type=i,e.format=5,e.isReady=!0,c(e)})})})}function Lt(s){Eu||(Eu=new Float32Array(1),TC=new Int32Array(Eu.buffer)),Eu[0]=s;let e=TC[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 Zn(s){let e=(s&32768)>>15,t=(s&31744)>>10,i=s&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 Eu,TC,vu=C(()=>{pi();ja();Jg();Kn();Mi()});function eE(s){return s.split(" ").filter(e=>e!=="").map(e=>parseFloat(e))}function $g(s,e,t){for(;t.length!==e;){let i=eE(s.lines[s.index++]);t.push(...i)}}function dW(s,e,t){let i=0,r=0,n=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 n=eE(i.lines[i.index++]);r.numberOfLights=n[0],r.lumensPerLamp=n[1],r.candelaMultiplier=n[2],r.numberOfVerticalAngles=n[3],r.numberOfHorizontalAngles=n[4],r.photometricType=n[5],r.unitsType=n[6],r.width=n[7],r.length=n[8],r.height=n[9];let a=eE(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)),h[_+p*l]=dW(r,_,p)}return{width:c/2,height:1,data:h}}var xC=C(()=>{Mi()});var IC={};Ie(IC,{_IESTextureLoader:()=>tE});var tE,CC=C(()=>{xC();tE=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),n=RC(r);i(n.width,n.height,!!t.useMipMaps,!1,()=>{let a=t.getEngine();t.type=1,t.format=6,t._gammaSpace=!1,a._uploadDataToTextureDirectly(t,n.data)})}}});var bC={};Ie(bC,{_DDSTextureLoader:()=>iE});var iE,MC=C(()=>{Qf();rE();iE=class{constructor(){this.supportCascades=!0}loadCubeData(e,t,i,r){let n=t.getEngine(),a,o=!1,l=1e3;if(Array.isArray(e))for(let c=0;c1)&&t.generateMipMaps,n._unpackFlipY(a.isCompressed),Rs.UploadDDSLevels(n,t,f,a,o,6,-1,c),!a.isFourCC&&a.mipmapCount===1?n.generateMipMapsForCubemap(t):l=a.mipmapCount-1}else{let c=e;a=Rs.GetDDSInfo(c),t.width=a.width,t.height=a.height,i&&(a.sphericalPolynomial=new Qs),o=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&t.generateMipMaps,n._unpackFlipY(a.isCompressed),Rs.UploadDDSLevels(n,t,c,a,o,6),!a.isFourCC&&a.mipmapCount===1?n.generateMipMapsForCubemap(t,!1):l=a.mipmapCount-1}n._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=Rs.GetDDSInfo(e),n=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&Math.max(r.width,r.height)>>r.mipmapCount-1===1;i(r.width,r.height,n,r.isFourCC,()=>{Rs.UploadDDSLevels(t.getEngine(),t,e,r,n,1)})}}});function yC(){let s={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),h=a.data.ignoreSupportedFormats?null:t(a.data.config,f),d=!1;h===null&&(d=!0,h=f.hasAlpha?s.cTFBC3:s.cTFBC1);let u=!0;c.startTranscoding()||(u=!1);let m=[];for(let p=0;p>2&3],h[I++]=f[v>>4&3],h[I]=f[v>>6&3]}}return h}}async function DC(s,e,t){return await new Promise((i,r)=>{let n=a=>{a.data.action==="init"?(s.removeEventListener("message",n),i(s)):a.data.action==="error"&&r(a.data.error||"error initializing worker")};s.addEventListener("message",n),s.postMessage({action:"init",url:t?se.GetBabylonScriptURL(t):void 0,wasmBinary:e},[e])})}var PC=C(()=>{At()});var qn,Za,uW,sE,nl,mW,pW,_W,Tu,Su,Au,nE,LC=C(()=>{At();pi();Dr();PC();(function(s){s[s.cTFETC1=0]="cTFETC1",s[s.cTFETC2=1]="cTFETC2",s[s.cTFBC1=2]="cTFBC1",s[s.cTFBC3=3]="cTFBC3",s[s.cTFBC4=4]="cTFBC4",s[s.cTFBC5=5]="cTFBC5",s[s.cTFBC7=6]="cTFBC7",s[s.cTFPVRTC1_4_RGB=8]="cTFPVRTC1_4_RGB",s[s.cTFPVRTC1_4_RGBA=9]="cTFPVRTC1_4_RGBA",s[s.cTFASTC_4x4=10]="cTFASTC_4x4",s[s.cTFATC_RGB=11]="cTFATC_RGB",s[s.cTFATC_RGBA_INTERPOLATED_ALPHA=12]="cTFATC_RGBA_INTERPOLATED_ALPHA",s[s.cTFRGBA32=13]="cTFRGBA32",s[s.cTFRGB565=14]="cTFRGB565",s[s.cTFBGR565=15]="cTFBGR565",s[s.cTFRGBA4444=16]="cTFRGBA4444",s[s.cTFFXT1_RGB=17]="cTFFXT1_RGB",s[s.cTFPVRTC2_4_RGB=18]="cTFPVRTC2_4_RGB",s[s.cTFPVRTC2_4_RGBA=19]="cTFPVRTC2_4_RGBA",s[s.cTFETC2_EAC_R11=20]="cTFETC2_EAC_R11",s[s.cTFETC2_EAC_RG11=21]="cTFETC2_EAC_RG11"})(qn||(qn={}));Za={JSModuleURL:`${se._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.js`,WasmModuleURL:`${se._DefaultCdnUrl}/basisTranscoder/1/basis_transcoder.wasm`},uW=(s,e)=>{let t;switch(s){case qn.cTFETC1:t=36196;break;case qn.cTFBC1:t=33776;break;case qn.cTFBC4:t=33779;break;case qn.cTFASTC_4x4:t=37808;break;case qn.cTFETC2:t=37496;break;case qn.cTFBC7:t=36492;break}if(t===void 0)throw"The chosen Basis transcoder format is not currently supported";return t},sE=null,nl=null,mW=0,pW=!1,_W=async()=>(sE||(sE=new Promise((s,e)=>{nl?s(nl):se.LoadFileAsync(se.GetBabylonScriptURL(Za.WasmModuleURL)).then(t=>{if(typeof URL!="function")return e("Basis transcoder requires an environment with a URL constructor");let i=URL.createObjectURL(new Blob([`(${yC})()`],{type:"application/javascript"}));nl=new Worker(i),DC(nl,t,Za.JSModuleURL).then(s,e)}).catch(e)})),await sE),Tu=async(s,e)=>{let t=s instanceof ArrayBuffer?new Uint8Array(s):s;return await new Promise((i,r)=>{_W().then(()=>{let n=mW++,a=l=>{l.data.action==="transcode"&&l.data.id===n&&(nl.removeEventListener("message",a),l.data.success?i(l.data):r("Transcode is not supported on this device"))};nl.addEventListener("message",a);let o=new Uint8Array(t.byteLength);o.set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)),nl.postMessage({action:"transcode",id:n,imageData:o,config:e,ignoreSupportedFormats:pW},[o.buffer])},n=>{r(n)})})},Su=(s,e)=>{var i,r;let t=(i=e._gl)==null?void 0:i.TEXTURE_2D;s.isCube&&(t=(r=e._gl)==null?void 0:r.TEXTURE_CUBE_MAP),e._bindTextureDirectly(t,s,!0)},Au=(s,e)=>{let t=s.getEngine();for(let i=0;i{t._releaseTexture(n),Su(s,t)})}else s._invertVScale=!s.invertY,s.width=r.width+3&-4,s.height=r.height+3&-4,s.samplingMode=2,Su(s,t),t._uploadDataToTextureDirectly(s,new Uint16Array(r.transcodedPixels.buffer),i,0,4,!0);else{s.width=r.width,s.height=r.height,s.generateMipMaps=e.fileInfo.images[i].levels.length>1;let n=nE.GetInternalFormatFromBasisFormat(e.format,t);s.format=n,Su(s,t);let a=e.fileInfo.images[i].levels;for(let o=0;oaE});var aE,NC=C(()=>{LC();At();aE=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,n){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}};Tu(e,o).then(l=>{let c=l.fileInfo.images[0].levels.length>1&&t.generateMipMaps;Au(t,l),t.getEngine()._setCubeMapTextureParams(t,c),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}).catch(l=>{se.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0,n&&n(l)})}loadData(e,t,i){let r=t.getEngine().getCaps(),n={supportedCompressionFormats:{etc1:!!r.etc1,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,astc:!!r.astc,bc7:!!r.bptc}};Tu(e,n).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,()=>{Au(t,a)})}).catch(a=>{se.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),se.Warn(`Failed to transcode Basis file: ${a}`),i(0,0,!1,!1,()=>{},!0)})}}});var ah,FC=C(()=>{ah=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 Ru(s){s.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}var oE=C(()=>{});var Si,wC=C(()=>{$e();Qe();Je();jt();oE();Si=class s{constructor(){this._dirty=!0,this._tempColor=new Me(0,0,0,0),this._globalCurve=new Me(0,0,0,0),this._highlightsCurve=new Me(0,0,0,0),this._midtonesCurve=new Me(0,0,0,0),this._shadowsCurve=new Me(0,0,0,0),this._positiveCurve=new Me(0,0,0,0),this._negativeCurve=new Me(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",n="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,r,n){e!=null&&(e=s._Clamp(e,0,360),t=s._Clamp(t,-100,100),i=s._Clamp(i,-100,100),r=s._Clamp(r,-100,100),t=s._ApplyColorGradingSliderNonlinear(t),t*=.5,r=s._ApplyColorGradingSliderNonlinear(r),t<0&&(t*=-1,e=(e+180)%360),s._FromHSBToRef(e,t,50+.25*r,n),n.scaleToRef(2,n),n.a=1+.01*i)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,i,r){let n=s._Clamp(e,0,360),a=s._Clamp(t/100,0,1),o=s._Clamp(i/100,0,1);if(a===0)r.r=o,r.g=o,r.b=o;else{n/=60;let l=Math.floor(n),c=n-l,f=o*(1-a),h=o*(1-a*c),d=o*(1-a*(1-c));switch(l){case 0:r.r=o,r.g=d,r.b=f;break;case 1:r.r=h,r.g=o,r.b=f;break;case 2:r.r=f,r.g=o,r.b=d;break;case 3:r.r=f,r.g=h,r.b=o;break;case 4:r.r=d,r.g=f,r.b=o;break;default:r.r=o,r.g=f,r.b=h;break}}r.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return De.Clone(()=>new s,this)}serialize(){return De.Serialize(this)}static Parse(e){return De.Parse(()=>new s,e,null,null)}};Si.PrepareUniforms=Ru;b([L()],Si.prototype,"_globalHue",void 0);b([L()],Si.prototype,"_globalDensity",void 0);b([L()],Si.prototype,"_globalSaturation",void 0);b([L()],Si.prototype,"_globalExposure",void 0);b([L()],Si.prototype,"_highlightsHue",void 0);b([L()],Si.prototype,"_highlightsDensity",void 0);b([L()],Si.prototype,"_highlightsSaturation",void 0);b([L()],Si.prototype,"_highlightsExposure",void 0);b([L()],Si.prototype,"_midtonesHue",void 0);b([L()],Si.prototype,"_midtonesDensity",void 0);b([L()],Si.prototype,"_midtonesSaturation",void 0);b([L()],Si.prototype,"_midtonesExposure",void 0);De._ColorCurvesParser=Si.Parse});function BC(s,e){e.EXPOSURE&&s.push("exposureLinear"),e.CONTRAST&&s.push("contrast"),e.COLORGRADING&&s.push("colorTransformSettings"),(e.VIGNETTE||e.DITHER)&&s.push("vInverseScreenSize"),e.VIGNETTE&&(s.push("vignetteSettings1"),s.push("vignetteSettings2")),e.COLORCURVES&&Ru(s),e.DITHER&&s.push("ditherIntensity")}function UC(s,e){e.COLORGRADING&&s.push("txColorTransform")}var VC=C(()=>{oE()});var et,oh=C(()=>{$e();Qe();dt();Je();wC();js();jt();VC();Pt();et=class s{constructor(){this.colorCurves=new Si,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=s.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new Me(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=s.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 Q}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===s._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case s.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case s.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&&Si.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 n=t!=null?t:r/i,a=Math.tan(this.vignetteCameraFov*.5),o=a*n,l=Math.sqrt(o*a);o=Kf(o,l,this.vignetteStretch),a=Kf(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 De.Clone(()=>new s,this)}serialize(){return De.Serialize(this)}static Parse(e){let t=De.Parse(()=>new s,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}};et.TONEMAPPING_STANDARD=0;et.TONEMAPPING_ACES=1;et.TONEMAPPING_KHR_PBR_NEUTRAL=2;et.PrepareUniforms=BC;et.PrepareSamplers=UC;et._VIGNETTEMODE_MULTIPLY=0;et._VIGNETTEMODE_OPAQUE=1;b([wI()],et.prototype,"colorCurves",void 0);b([L()],et.prototype,"_colorCurvesEnabled",void 0);b([qe("colorGradingTexture")],et.prototype,"_colorGradingTexture",void 0);b([L()],et.prototype,"_colorGradingEnabled",void 0);b([L()],et.prototype,"_colorGradingWithGreenDepth",void 0);b([L()],et.prototype,"_colorGradingBGR",void 0);b([L()],et.prototype,"_exposure",void 0);b([L()],et.prototype,"_toneMappingEnabled",void 0);b([L()],et.prototype,"_toneMappingType",void 0);b([L()],et.prototype,"_contrast",void 0);b([L()],et.prototype,"vignetteStretch",void 0);b([L()],et.prototype,"vignetteCenterX",void 0);b([L()],et.prototype,"vignetteCenterY",void 0);b([L()],et.prototype,"vignetteWeight",void 0);b([ic()],et.prototype,"vignetteColor",void 0);b([L()],et.prototype,"vignetteCameraFov",void 0);b([L()],et.prototype,"_vignetteBlendMode",void 0);b([L()],et.prototype,"_vignetteEnabled",void 0);b([L()],et.prototype,"_ditheringEnabled",void 0);b([L()],et.prototype,"_ditheringIntensity",void 0);b([L()],et.prototype,"_skipFinalColorClamp",void 0);b([L()],et.prototype,"_applyByPostProcess",void 0);b([L()],et.prototype,"_isEnabled",void 0);b([L()],et.prototype,"outputTextureWidth",void 0);b([L()],et.prototype,"outputTextureHeight",void 0);De._ImageProcessingConfigurationParser=et.Parse;Ke("BABYLON.ImageProcessingConfiguration",et)});var wi,hc=C(()=>{Ee();It();wi=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(y.NormalKind))return null;let i=this.pickedMesh.getIndices();(i==null?void 0:i.length)===0&&(i=null);let r,n=W.Vector3[0],a=W.Vector3[1],o=W.Vector3[2];if(t){let c=this.pickedMesh.getVerticesData(y.NormalKind),f=i?S.FromArrayToRef(c,i[this.faceId*3]*3,n):n.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),h=i?S.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]),d=i?S.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),h=h.scale(this.bv),d=d.scale(1-this.bu-this.bv),r=new S(f.x+h.x+d.x,f.y+h.y+d.y,f.z+h.z+d.z)}else{let c=this.pickedMesh.getVerticesData(y.PositionKind),f=i?S.FromArrayToRef(c,i[this.faceId*3]*3,n):n.copyFromFloats(c[this.faceId*3*3],c[this.faceId*3*3+1],c[this.faceId*3*3+2]),h=i?S.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]),d=i?S.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(h),m=d.subtract(h);r=S.Cross(u,m)}let l=(c,f)=>{if(this.thinInstanceIndex!==-1){let d=c._thinInstanceDataStorage.matrixData,u=this.thinInstanceIndex<<4;if(d&&d.length>u){let m=W.Matrix[0];H.FromArrayToRef(d,u,m),S.TransformNormalToRef(f,m,f)}}let h=c.getWorldMatrix();c.nonUniformScaling&&(W.Matrix[0].copyFrom(h),h=W.Matrix[0],h.setTranslationFromFloats(0,0,0),h.invert(),h.transposeToRef(W.Matrix[1]),h=W.Matrix[1]),S.TransformNormalToRef(f,h,f)};if(e&&l(this.pickedMesh,r),this.ray){let c=W.Vector3[0].copyFrom(r);e||l(this.pickedMesh,c),S.Dot(c,this.ray.direction)>0&&r.negateInPlace()}return r.normalize(),r}getTextureCoordinates(e=y.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=me.FromArray(i,t[this.faceId*3]*2),n=me.FromArray(i,t[this.faceId*3+1]*2),a=me.FromArray(i,t[this.faceId*3+2]*2);return r=r.scale(this.bu),n=n.scale(this.bv),a=a.scale(1-this.bu-this.bv),new me(r.x+n.x+a.x,r.y+n.y+a.y)}}});var Ti,lE=C(()=>{Ti=class s{constructor(e,t,i,r,n,a){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=a}static CreateNew(e,t,i){let r=e.getScene();return new s(e,r.pointerX,r.pointerY,r.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,r){return new s(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,r)}static CreateNewFromScene(e,t){return new s(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,r){return new s(e,t.x,t.y,null,i,r)}}});function lh(s,e,t){let i=t.asArray(),r=e.asArray();for(let n=0;n<16;n++)i[n]=r[n];return i[12]-=s.x,i[13]-=s.y,i[14]-=s.z,t.markAsUpdated(),t}function HC(s,e,t){return Zf(e,es),lh(s,es,ts),Zf(ts,t),t}function xu(s,e,t){if(!is.eyeAtCamera)return HC(s,e,t);let i=t.asArray(),r=e.asArray();for(let n=0;n<16;n++)i[n]=r[n];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function cE(s,e,t,i){return qo(xu(s,e,i),t,i),i}function zC(s,e,t,i,r){for(let n=0;n{Ba();Ee();Ig();Xa();$r=new H,es=new H,ts=new H,is={getScene:()=>{},eyeAtCamera:!0};ch=Wt,fE=wt,XC=ch.prototype._updateMatrixForUniform,YC=wt.prototype.setMatrix});var Pe,kt,dc=C(()=>{Pe=class{};Pe.NAME_EFFECTLAYER="EffectLayer";Pe.NAME_LAYER="Layer";Pe.NAME_LENSFLARESYSTEM="LensFlareSystem";Pe.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";Pe.NAME_PARTICLESYSTEM="ParticleSystem";Pe.NAME_GAMEPAD="Gamepad";Pe.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";Pe.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";Pe.NAME_PREPASSRENDERER="PrePassRenderer";Pe.NAME_DEPTHRENDERER="DepthRenderer";Pe.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";Pe.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";Pe.NAME_SPRITE="Sprite";Pe.NAME_SUBSURFACE="SubSurface";Pe.NAME_OUTLINERENDERER="Outline";Pe.NAME_PROCEDURALTEXTURE="ProceduralTexture";Pe.NAME_SHADOWGENERATOR="ShadowGenerator";Pe.NAME_OCTREE="Octree";Pe.NAME_PHYSICSENGINE="PhysicsEngine";Pe.NAME_AUDIO="Audio";Pe.NAME_FLUIDRENDERER="FluidRenderer";Pe.NAME_IBLCDFGENERATOR="iblCDFGenerator";Pe.NAME_CLUSTEREDLIGHTING="ClusteredLighting";Pe.STEP_ISREADYFORMESH_EFFECTLAYER=0;Pe.STEP_ISREADYFORMESH_DEPTHRENDERER=1;Pe.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;Pe.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;Pe.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;Pe.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;Pe.STEP_BEFORECAMERADRAW_PREPASS=0;Pe.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;Pe.STEP_BEFORECAMERADRAW_LAYER=2;Pe.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;Pe.STEP_BEFORERENDERTARGETDRAW_LAYER=1;Pe.STEP_BEFORERENDERINGMESH_PREPASS=0;Pe.STEP_BEFORERENDERINGMESH_OUTLINE=1;Pe.STEP_AFTERRENDERINGMESH_PREPASS=0;Pe.STEP_AFTERRENDERINGMESH_OUTLINE=1;Pe.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;Pe.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;Pe.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;Pe.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;Pe.STEP_BEFORECLEAR_PREPASS=1;Pe.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;Pe.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;Pe.STEP_AFTERRENDERTARGETDRAW_LAYER=1;Pe.STEP_AFTERCAMERADRAW_PREPASS=0;Pe.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;Pe.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;Pe.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;Pe.STEP_AFTERCAMERADRAW_LAYER=4;Pe.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;Pe.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;Pe.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;Pe.STEP_AFTERRENDER_AUDIO=0;Pe.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;Pe.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;Pe.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;Pe.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;Pe.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;Pe.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;Pe.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;Pe.STEP_POINTERMOVE_SPRITE=0;Pe.STEP_POINTERDOWN_SPRITE=0;Pe.STEP_POINTERUP_SPRITE=0;kt=class s extends Array{constructor(e){super(...e)}static Create(){return Object.create(s.prototype)}registerStep(e,t,i){let r=0,n;for(;r{Ee();Le=class{};Le.POINTERDOWN=1;Le.POINTERUP=2;Le.POINTERMOVE=4;Le.POINTERWHEEL=8;Le.POINTERPICK=16;Le.POINTERTAP=32;Le.POINTERDOUBLETAP=64;Iu=class{constructor(e,t){this.type=e,this.event=t}},Cu=class extends Iu{constructor(e,t,i,r){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new me(i,r)}},rs=class extends Iu{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 Qn,ZC=C(()=>{Qn=class s{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(let e in s.Triggers)if(Object.prototype.hasOwnProperty.call(s.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(let e in s.Triggers)if(Object.prototype.hasOwnProperty.call(s.Triggers,e)){let t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(let t in s.Triggers)if(Object.prototype.hasOwnProperty.call(s.Triggers,t)&&parseInt(t)===e)return!0;return!1}};Qn.Triggers={}});var Is,uc,hh,bu=C(()=>{Is=class{};Is.KEYDOWN=1;Is.KEYUP=2;uc=class{constructor(e,t){this.type=e,this.event=t}},hh=class extends uc{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 ye,Ge,qC,QC,JC,$C,eb,al=C(()=>{(function(s){s[s.Generic=0]="Generic",s[s.Keyboard=1]="Keyboard",s[s.Mouse=2]="Mouse",s[s.Touch=3]="Touch",s[s.DualShock=4]="DualShock",s[s.Xbox=5]="Xbox",s[s.Switch=6]="Switch",s[s.DualSense=7]="DualSense"})(ye||(ye={}));(function(s){s[s.Horizontal=0]="Horizontal",s[s.Vertical=1]="Vertical",s[s.LeftClick=2]="LeftClick",s[s.MiddleClick=3]="MiddleClick",s[s.RightClick=4]="RightClick",s[s.BrowserBack=5]="BrowserBack",s[s.BrowserForward=6]="BrowserForward",s[s.MouseWheelX=7]="MouseWheelX",s[s.MouseWheelY=8]="MouseWheelY",s[s.MouseWheelZ=9]="MouseWheelZ",s[s.Move=12]="Move"})(Ge||(Ge={}));(function(s){s[s.Horizontal=0]="Horizontal",s[s.Vertical=1]="Vertical",s[s.LeftClick=2]="LeftClick",s[s.MiddleClick=3]="MiddleClick",s[s.RightClick=4]="RightClick",s[s.BrowserBack=5]="BrowserBack",s[s.BrowserForward=6]="BrowserForward",s[s.MouseWheelX=7]="MouseWheelX",s[s.MouseWheelY=8]="MouseWheelY",s[s.MouseWheelZ=9]="MouseWheelZ",s[s.DeltaHorizontal=10]="DeltaHorizontal",s[s.DeltaVertical=11]="DeltaVertical"})(qC||(qC={}));(function(s){s[s.Cross=0]="Cross",s[s.Circle=1]="Circle",s[s.Square=2]="Square",s[s.Triangle=3]="Triangle",s[s.L1=4]="L1",s[s.R1=5]="R1",s[s.L2=6]="L2",s[s.R2=7]="R2",s[s.Share=8]="Share",s[s.Options=9]="Options",s[s.L3=10]="L3",s[s.R3=11]="R3",s[s.DPadUp=12]="DPadUp",s[s.DPadDown=13]="DPadDown",s[s.DPadLeft=14]="DPadLeft",s[s.DPadRight=15]="DPadRight",s[s.Home=16]="Home",s[s.TouchPad=17]="TouchPad",s[s.LStickXAxis=18]="LStickXAxis",s[s.LStickYAxis=19]="LStickYAxis",s[s.RStickXAxis=20]="RStickXAxis",s[s.RStickYAxis=21]="RStickYAxis"})(QC||(QC={}));(function(s){s[s.Cross=0]="Cross",s[s.Circle=1]="Circle",s[s.Square=2]="Square",s[s.Triangle=3]="Triangle",s[s.L1=4]="L1",s[s.R1=5]="R1",s[s.L2=6]="L2",s[s.R2=7]="R2",s[s.Create=8]="Create",s[s.Options=9]="Options",s[s.L3=10]="L3",s[s.R3=11]="R3",s[s.DPadUp=12]="DPadUp",s[s.DPadDown=13]="DPadDown",s[s.DPadLeft=14]="DPadLeft",s[s.DPadRight=15]="DPadRight",s[s.Home=16]="Home",s[s.TouchPad=17]="TouchPad",s[s.LStickXAxis=18]="LStickXAxis",s[s.LStickYAxis=19]="LStickYAxis",s[s.RStickXAxis=20]="RStickXAxis",s[s.RStickYAxis=21]="RStickYAxis"})(JC||(JC={}));(function(s){s[s.A=0]="A",s[s.B=1]="B",s[s.X=2]="X",s[s.Y=3]="Y",s[s.LB=4]="LB",s[s.RB=5]="RB",s[s.LT=6]="LT",s[s.RT=7]="RT",s[s.Back=8]="Back",s[s.Start=9]="Start",s[s.LS=10]="LS",s[s.RS=11]="RS",s[s.DPadUp=12]="DPadUp",s[s.DPadDown=13]="DPadDown",s[s.DPadLeft=14]="DPadLeft",s[s.DPadRight=15]="DPadRight",s[s.Home=16]="Home",s[s.LStickXAxis=17]="LStickXAxis",s[s.LStickYAxis=18]="LStickYAxis",s[s.RStickXAxis=19]="RStickXAxis",s[s.RStickYAxis=20]="RStickYAxis"})($C||($C={}));(function(s){s[s.B=0]="B",s[s.A=1]="A",s[s.Y=2]="Y",s[s.X=3]="X",s[s.L=4]="L",s[s.R=5]="R",s[s.ZL=6]="ZL",s[s.ZR=7]="ZR",s[s.Minus=8]="Minus",s[s.Plus=9]="Plus",s[s.LS=10]="LS",s[s.RS=11]="RS",s[s.DPadUp=12]="DPadUp",s[s.DPadDown=13]="DPadDown",s[s.DPadLeft=14]="DPadLeft",s[s.DPadRight=15]="DPadRight",s[s.Home=16]="Home",s[s.Capture=17]="Capture",s[s.LStickXAxis=18]="LStickXAxis",s[s.LStickYAxis=19]="LStickYAxis",s[s.RStickXAxis=20]="RStickXAxis",s[s.RStickYAxis=21]="RStickYAxis"})(eb||(eb={}))});var tb,Cs,Mu=C(()=>{(function(s){s[s.PointerMove=0]="PointerMove",s[s.PointerDown=1]="PointerDown",s[s.PointerUp=2]="PointerUp"})(tb||(tb={}));Cs=class{};Cs.DOM_DELTA_PIXEL=0;Cs.DOM_DELTA_LINE=1;Cs.DOM_DELTA_PAGE=2});var bs,dE=C(()=>{Mu();al();bs=class{static CreateDeviceEvent(e,t,i,r,n,a,o){switch(e){case ye.Keyboard:return this._CreateKeyboardEvent(i,r,n,a);case ye.Mouse:if(i===Ge.MouseWheelX||i===Ge.MouseWheelY||i===Ge.MouseWheelZ)return this._CreateWheelEvent(e,t,i,r,n,a);case ye.Touch:return this._CreatePointerEvent(e,t,i,r,n,a,o);default:throw`Unable to generate event for device ${ye[e]}`}}static _CreatePointerEvent(e,t,i,r,n,a,o){let l=this._CreateMouseEvent(e,t,i,r,n,a);e===ye.Mouse?(l.deviceType=ye.Mouse,l.pointerId=1,l.pointerType="mouse"):(l.deviceType=ye.Touch,l.pointerId=o!=null?o:t,l.pointerType="touch");let c=0;return c+=n.pollInput(e,t,Ge.LeftClick),c+=n.pollInput(e,t,Ge.RightClick)*2,c+=n.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,n,a){let o=this._CreateMouseEvent(e,t,i,r,n,a);switch(o.pointerId=1,o.type="wheel",o.deltaMode=Cs.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,n,a){let o=this._CreateEvent(a),l=n.pollInput(e,t,Ge.Horizontal),c=n.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=n.pollInput(e,t,10),o.movementY=n.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,n),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 n=this._CreateEvent(r);return this._CheckNonCharacterKeys(n,i),n.deviceType=ye.Keyboard,n.deviceSlot=0,n.inputIndex=e,n.type=t===1?"keydown":"keyup",n.key=String.fromCharCode(e),n.keyCode=e,n}static _CheckNonCharacterKeys(e,t){let i=t.isDeviceAvailable(ye.Keyboard),r=i&&t.pollInput(ye.Keyboard,0,18)===1,n=i&&t.pollInput(ye.Keyboard,0,17)===1,a=i&&(t.pollInput(ye.Keyboard,0,91)===1||t.pollInput(ye.Keyboard,0,92)===1||t.pollInput(ye.Keyboard,0,93)===1),o=i&&t.pollInput(ye.Keyboard,0,16)===1;e.altKey=r,e.ctrlKey=n,e.metaKey=a,e.shiftKey=o}static _CreateEvent(e){let t={};return t.preventDefault=()=>{},t.target=e,t}}});var yu,ib=C(()=>{dE();al();yu=class{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(r,n,a,o)=>{let l=bs.CreateDeviceEvent(r,n,a,o,this);i(r,n,l)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===ye.Mouse||e===ye.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}});var rb,sb,Du,nb=C(()=>{Pr();At();dE();al();rb=255,sb=Object.keys(Ge).length/2,Du=class{constructor(e,t,i,r){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=se.IsSafari(),this._usingMacOs=wn()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=n=>{},this._keyboardUpEvent=n=>{},this._keyboardBlurEvent=n=>{},this._pointerMoveEvent=n=>{},this._pointerDownEvent=n=>{},this._pointerUpEvent=n=>{},this._pointerCancelEvent=n=>{},this._pointerCancelTouch=n=>{},this._pointerLeaveEvent=n=>{},this._pointerWheelEvent=n=>{},this._pointerBlurEvent=n=>{},this._pointerMacOsChromeOutEvent=n=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=wn()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=wn()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=n=>{},this._gamepadDisconnectedEvent=n=>{},this._eventPrefix=se.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 ${ye[e]}`;e>=ye.DualShock&&e<=ye.DualSense&&this._updateDevice(e,t,i);let n=r[i];if(n===void 0)throw`Unable to find input ${i} for device ${ye[e]} in slot ${t}`;return i===Ge.Move&&se.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),n}isDeviceAvailable(e){return this._inputs[e]!==void 0}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){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,n=t[r];if(n)for(let a=0;a{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(ye.Keyboard,0,rb));let t=this._inputs[ye.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(ye.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(ye.Keyboard,0,rb));let t=this._inputs[ye.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 n=bs.CreateDeviceEvent(ye.Keyboard,0,r,0,this,this._elementToAttachTo);t[r]=0,this._onInputChanged(ye.Keyboard,0,n)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(ye.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){let e=this._inputs[ye.Keyboard][0];for(let t=0;t{let r=this._getPointerType(i),n=r===ye.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===ye.Touch&&n===-1){let o=this._activeTouchIds.indexOf(-1);if(o>=0)n=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(r,n);else{se.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][n]||this._addPointerDevice(r,n,i.clientX,i.clientY);let a=this._inputs[r][n];if(a){let o=i;o.inputIndex=Ge.Move,a[Ge.Horizontal]=i.clientX,a[Ge.Vertical]=i.clientY,r===ye.Touch&&a[Ge.LeftClick]===0&&(a[Ge.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(r,n,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,a[i.button+2]=a[i.button+2]?0:1,this._onInputChanged(r,n,o))}},this._pointerDownEvent=i=>{let r=this._getPointerType(i),n=r===ye.Mouse?0:i.pointerId;if(r===ye.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)n=o,this._activeTouchIds[o]=i.pointerId;else{se.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[r]||(this._inputs[r]={}),this._inputs[r][n]?r===ye.Touch&&this._onDeviceConnected(r,n):this._addPointerDevice(r,n,i.clientX,i.clientY);let a=this._inputs[r][n];if(a){let o=a[Ge.Horizontal],l=a[Ge.Vertical];if(r===ye.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,n,c),(o!==i.clientX||l!==i.clientY)&&(c.inputIndex=Ge.Move,this._onInputChanged(r,n,c))}},this._pointerUpEvent=i=>{var c,f,h,d,u;let r=this._getPointerType(i),n=r===ye.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(r===ye.Touch){if(n===-1)return;this._activeTouchIds[n]=-1}let a=(c=this._inputs[r])==null?void 0:c[n],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,n,_)),_.inputIndex=o+2,r===ye.Mouse&&this._mouseId>=0&&((h=(f=this._elementToAttachTo).hasPointerCapture)!=null&&h.call(f,this._mouseId))?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&((u=(d=this._elementToAttachTo).hasPointerCapture)!=null&&u.call(d,i.pointerId))&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(r,n,_),r===ye.Touch&&this._onDeviceDisconnected(r,n)}},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[ye.Touch][r][Ge.LeftClick]=0;let n=bs.CreateDeviceEvent(ye.Touch,r,Ge.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(ye.Touch,r,n),this._activeTouchIds[r]=-1,this._onDeviceDisconnected(ye.Touch,r)},this._pointerCancelEvent=i=>{var r,n;if(i.pointerType==="mouse"){let a=this._inputs[ye.Mouse][0];this._mouseId>=0&&((n=(r=this._elementToAttachTo).hasPointerCapture)!=null&&n.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=bs.CreateDeviceEvent(ye.Mouse,0,o,0,this,this._elementToAttachTo);this._onInputChanged(ye.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,n,a,o;if(this.isDeviceAvailable(ye.Mouse)){let l=this._inputs[ye.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=bs.CreateDeviceEvent(ye.Mouse,0,c,0,this,this._elementToAttachTo);this._onInputChanged(ye.Mouse,0,f)}}if(this.isDeviceAvailable(ye.Touch)){let l=this._inputs[ye.Touch];for(let c=0;c{let r=ye.Mouse,n=0;this._inputs[r]||(this._inputs[r]=[]),this._inputs[r][n]||(this._pointerActive=!0,this._registerDevice(r,n,sb));let a=this._inputs[r][n];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,n,o)),a[Ge.MouseWheelY]!==0&&(o.inputIndex=Ge.MouseWheelY,this._onInputChanged(r,n,o)),a[Ge.MouseWheelZ]!==0&&(o.inputIndex=Ge.MouseWheelZ,this._onInputChanged(r,n,o))}},this._usingMacOs&&this._isUsingChromium&&(this._pointerMacOsChromeOutEvent=i=>{i.buttons>1&&this._pointerCancelEvent(i)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener(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(ye.Mouse)){let i=this._inputs[ye.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 n=this._inputs[e][t];i>=r.buttons.length?n[i]=r.axes[i-r.buttons.length].valueOf():n[i]=r.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?ye.DualSense:ye.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?ye.Xbox:e.indexOf("057e")!==-1?ye.Switch:ye.Generic}_getPointerType(e){let t=ye.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=ye.Touch),t}}});var dh,ab=C(()=>{dt();dh=class{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new Q,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}});var Pu,ob=C(()=>{al();ib();nb();ab();Pu=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(ye).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 dh(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)},n=(a,o,l)=>{if(l)for(let c of this._registeredManagers)c._onInputChanged(a,o,l)};typeof _native!="undefined"?this._deviceInputSystem=new yu(i,r,n):this._deviceInputSystem=new Du(e,i,r,n)}dispose(){this._deviceInputSystem.dispose()}}});var Lu,lb=C(()=>{al();dt();ob();Lu=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(ye).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new Pu(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new Q(i=>{for(let r of this._devices)if(r)for(let n of r)n&&this.onDeviceConnectedObservable.notifyObserver(i,n)}),this.onDeviceDisconnectedObservable=new Q,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,n;let i=(r=this._devices[e])==null?void 0:r[t];this.onDeviceDisconnectedObservable.notifyObservers(i),(n=this._devices[e])!=null&&n[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){var r,n;(n=(r=this._devices[e])==null?void 0:r[t])==null||n.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case ye.Keyboard:case ye.Mouse:this._firstDevice[e]=0;break;case ye.Touch:case ye.DualSense:case ye.DualShock:case ye.Xbox:case ye.Switch:case ye.Generic:{delete this._firstDevice[e];let t=this._devices[e];if(t){for(let i=0;i{ol=class{};ol._IsPickingAvailable=!1});var Ou,Hi,cb=C(()=>{xs();ZC();hc();Ee();lE();bu();al();lb();gt();uE();Ou=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}},Hi=class s{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 me(0,0),this._previousStartingPointerPosition=new me(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 me(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(),n=r.getInputElement();n&&(n.tabIndex=r.canvasTabIndex,i.doNotHandleCursors||(n.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,n)}let a=t.inputIndex>=Ge.MouseWheelX&&t.inputIndex<=Ge.MouseWheelZ?Le.POINTERWHEEL:Le.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,a));let o;e?(o=new rs(a,t,e),this._setRayOnPointerInfo(e,t)):(o=new rs(a,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,a)}_setRayOnPointerInfo(e,t){let i=this._scene;e&&ol._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,H.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,n=new Cu(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(n.originalPickingInfo=e,n.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(n.nearInteractionPickingInfo=e)),r.onPrePointerObservable.notifyObservers(n,i),!!n.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 n=i.getEngine().getInputElement();if(e!=null&&e.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&n&&this._pointerOverMesh){let a=this._pointerOverMesh._getActionManagerForTrigger();a&&a.hasPointerTriggers&&(n.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,Le.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){let i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,Le.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 Ti(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:a.processTrigger(2,new Ti(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:a.processTrigger(4,new Ti(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:a.processTrigger(3,new Ti(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>s.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,a.processTrigger(8,Ti.CreateNew(o.pickedMesh,t)))},s.LongPressDelay)}}else for(let a of i._pointerDownStage)e=a.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let r,n=Le.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,n),r=new rs(n,t,e),this._setRayOnPointerInfo(e,t)):r=new rs(n,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(r,n)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){let r=new PointerEvent("pointerup",t);r.inputIndex=Ge.Move;let n=new Ou;i?n.doubleClick=!0:n.singleClick=!0,!this._checkPrePointerObservable(e,r,Le.POINTERUP)&&this._processPointerUp(e,r,n)}_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=Le.POINTERPICK,o=new rs(a,t,e);this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(o,a)}let n=e.pickedMesh._getActionManagerForTrigger();if(n&&!i.ignore){n.processTrigger(7,Ti.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&n.processTrigger(1,Ti.CreateNew(e.pickedMesh,t,e));let a=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&a&&a.processTrigger(6,Ti.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(let n of r._pointerUpStage)e=n.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){let n=this._pickedDownMesh._getActionManagerForTrigger(16);n&&n.processTrigger(16,Ti.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){let n=new rs(Le.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),r.onPointerObservable.notifyObservers(n,Le.POINTERUP),r.onPointerUp&&r.onPointerUp(t,e,Le.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let a=0;if(i.singleClick?a=Le.POINTERTAP:i.doubleClick&&(a=Le.POINTERDOUBLETAP),a){let o=new rs(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 n=this._scene,a=n.getEngine();r||(r=a.getInputElement()),this._alreadyAttached&&this.detachControl(),r&&(this._alreadyAttachedTo=r),this._deviceSourceManager=new Lu(a),this._initActionManager=o=>{if(!this._meshPickProceed){let l=n.skipPointerUpPicking||n._registeredActions===0&&!this._checkForPicking()&&!n.onPointerUp?null:n.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,n.pointerUpPredicate,n.pointerUpFastCheck,n.cameraToUseForPointers,n.pointerUpTrianglePredicate);this._currentPickResult=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>s.DoubleClickDelay&&!this._doubleClickOccured||o!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,l.singleClick=!0,l.ignore=!1,this._delayedClicks[o])){let f=this._delayedClicks[o].evt,h=Le.POINTERTAP,d=new rs(h,f,this._currentPickResult);n.onPointerObservable.hasObservers()&&n.onPointerObservable.hasSpecificMask(h)&&n.onPointerObservable.notifyObservers(d,h),this._delayedClicks[o]=null}},this._initClickEvent=(o,l,c,f)=>{var p,_;let h=new Ou;this._currentPickResult=null;let d=null,u=o.hasSpecificMask(Le.POINTERPICK)||l.hasSpecificMask(Le.POINTERPICK)||o.hasSpecificMask(Le.POINTERTAP)||l.hasSpecificMask(Le.POINTERTAP)||o.hasSpecificMask(Le.POINTERDOUBLETAP)||l.hasSpecificMask(Le.POINTERDOUBLETAP);!u&&Qn&&(d=this._initActionManager(d,h),d&&(u=d.hasPickTriggers));let m=!1;if(u=u&&!this._isMultiTouchGesture,u){let g=c.button;if(h.hasSwiped=this._isPointerSwiping(),!h.hasSwiped){let v=!s.ExclusiveDoubleClickMode;if(v||(v=!o.hasSpecificMask(Le.POINTERDOUBLETAP)&&!l.hasSpecificMask(Le.POINTERDOUBLETAP),v&&!Qn.HasSpecificTrigger(6)&&(d=this._initActionManager(d,h),d&&(v=!d.hasSpecificTrigger(6)))),v)(Date.now()-this._previousStartingPointerTime>s.DoubleClickDelay||g!==this._previousButtonPressed)&&(h.singleClick=!0,f(h,this._currentPickResult),m=!0);else{let x={evt:c,clickInfo:h,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,g,h,f),s.DoubleClickDelay)};this._delayedClicks[g]=x}let I=o.hasSpecificMask(Le.POINTERDOUBLETAP)||l.hasSpecificMask(Le.POINTERDOUBLETAP);!I&&Qn.HasSpecificTrigger(6)&&(d=this._initActionManager(d,h),d&&(I=d.hasSpecificTrigger(6))),I&&(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)>s.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>s.DragMovementThreshold),a.isPointerLock&&a._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=Ge.MouseWheelX&&o.inputIndex<=Ge.MouseWheelZ?Le.POINTERWHEEL:Le.POINTERMOVE)||!n.cameraToUseForPointers&&!n.activeCamera)return;if(n.skipPointerMovePicking){this._processPointerMove(new wi,o);return}n.pointerMovePredicate||(n.pointerMovePredicate=c=>c.isPickable&&c.isVisible&&c.isReady()&&c.isEnabled()&&(c.enablePointerMoveEvents||n.constantlyUpdateMeshUnderPointer||c._getActionManagerForTrigger()!==null)&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&c.layerMask)!==0));let l=n._registeredActions>0||n.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,s.ExclusiveDoubleClickMode){for(let h=0;hh.isPickable&&h.isVisible&&h.isReady()&&h.isEnabled()&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&h.layerMask)!==0)),this._pickedDownMesh=null;let c;n.skipPointerDownPicking||n._registeredActions===0&&!this._checkForPicking()&&!n.onPointerDown?c=new wi:c=n.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,n.pointerDownPredicate,n.pointerDownFastCheck,n.cameraToUseForPointers,n.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),n.preventDefaultOnPointerUp&&r&&(o.preventDefault(),r.focus()),this._initClickEvent(n.onPrePointerObservable,n.onPointerObservable,o,(c,f)=>{if(n.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!c.ignore)){if(this._checkPrePointerObservable(null,o,Le.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}c.hasSwiped||(c.singleClick&&n.onPrePointerObservable.hasSpecificMask(Le.POINTERTAP)&&this._checkPrePointerObservable(null,o,Le.POINTERTAP)&&(this._skipPointerTap=!0),c.doubleClick&&n.onPrePointerObservable.hasSpecificMask(Le.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,Le.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}if(!this._pointerCaptures[o.pointerId]){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1);return}o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1),!(!n.cameraToUseForPointers&&!n.activeCamera)&&(n.pointerUpPredicate||(n.pointerUpPredicate=h=>h.isPickable&&h.isVisible&&h.isReady()&&h.isEnabled()&&(!n.cameraToUseForPointers||(n.cameraToUseForPointers.layerMask&h.layerMask)!==0)),!this._meshPickProceed&&(Qn&&Qn.HasTriggers||this._checkForPicking()||n.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=Is.KEYDOWN;if(n.onPreKeyboardObservable.hasObservers()){let c=new hh(l,o);if(n.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(n.onKeyboardObservable.hasObservers()){let c=new uc(l,o);n.onKeyboardObservable.notifyObservers(c,l)}n.actionManager&&n.actionManager.processTrigger(14,Ti.CreateNewFromScene(n,o))},this._onKeyUp=o=>{let l=Is.KEYUP;if(n.onPreKeyboardObservable.hasObservers()){let c=new hh(l,o);if(n.onPreKeyboardObservable.notifyObservers(c,l),c.skipOnKeyboardObservable)return}if(n.onKeyboardObservable.hasObservers()){let c=new uc(l,o);n.onKeyboardObservable.notifyObservers(c,l)}n.actionManager&&n.actionManager.processTrigger(15,Ti.CreateNewFromScene(n,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===ye.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===ye.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===ye.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 n=this._meshUnderPointerId[t],a;n&&(a=n._getActionManagerForTrigger(10),a&&a.processTrigger(10,new Ti(n,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 Ti(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]}};Hi.DragMovementThreshold=10;Hi.LongPressDelay=500;Hi.DoubleClickDelay=300;Hi.ExclusiveDoubleClickMode=!1});var sn,mE=C(()=>{Bn();sn=class s{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){s.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){s.Enabled&&(this._startMonitoringTime=Xt.Now)}endMonitoring(e=!0){if(!s.Enabled)return;e&&this.fetchNewFrame();let t=Xt.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=Xt.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}};sn.Enabled=!0});var Jn,Nu=C(()=>{Jn=class{static get UniqueId(){let e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}};Jn._UniqueIdCounter=1});var Fu,fb=C(()=>{Fu=class{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}});var gW,EW,hb,nt,vr=C(()=>{At();Bn();dt();As();FC();Ha();Ee();oh();Xa();hc();lE();uu();fh();pu();dc();Pr();gt();Ci();cb();mE();Je();$d();Nu();Wa();ih();Zs();fb();We();Pt();Ys();gW=new ft,EW=new ft;(function(s){s[s.BackwardCompatible=0]="BackwardCompatible",s[s.Intermediate=1]="Intermediate",s[s.Aggressive=2]="Aggressive"})(hb||(hb={}));nt=class s{static DefaultMaterialFactory(e){throw Ce("StandardMaterial")}static CollisionCoordinatorFactory(){throw Ce("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 Hi.DragMovementThreshold}static set DragMovementThreshold(e){Hi.DragMovementThreshold=e}static get LongPressDelay(){return Hi.LongPressDelay}static set LongPressDelay(e){Hi.LongPressDelay=e}static get DoubleClickDelay(){return Hi.DoubleClickDelay}static set DoubleClickDelay(e){Hi.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return Hi.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){Hi.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:S.ZeroReadOnly}bindEyePosition(e,t="vEyePosition",i=!1){let r=this._eyePosition,n=this.useRightHandedSystem===(this._mirroredCameraPosition!=null),a=this.floatingOriginOffset,o=gW.set(r.x,r.y,r.z,n?-1:1),l=o.subtractFromFloatsToRef(a.x,a.y,a.z,0,EW);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=Qd(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 s.DefaultMaterialFactory!==s._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=s.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=s.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 Hi(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new Me(.2,.2,.3,1),this.onClearColorChangedObservable=new Q,this.ambientColor=new ae(0,0,0),this.environmentIntensity=1,this.iblIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new Q,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 Q,this._onDisposeObserver=null,this.onBeforeRenderObservable=new Q,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new Q,this.onAfterRenderCameraObservable=new Q,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new Q,this.onAfterAnimationsObservable=new Q,this.onBeforeDrawPhaseObservable=new Q,this.onAfterDrawPhaseObservable=new Q,this.onReadyObservable=new Q,this.onBeforeCameraRenderObservable=new Q,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new Q,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new Q,this.onAfterActiveMeshesEvaluationObservable=new Q,this.onBeforeParticlesRenderingObservable=new Q,this.onAfterParticlesRenderingObservable=new Q,this.onDataLoadedObservable=new Q,this.onNewCameraAddedObservable=new Q,this.onCameraRemovedObservable=new Q,this.onNewLightAddedObservable=new Q,this.onLightRemovedObservable=new Q,this.onNewGeometryAddedObservable=new Q,this.onGeometryRemovedObservable=new Q,this.onNewTransformNodeAddedObservable=new Q,this.onTransformNodeRemovedObservable=new Q,this.onNewMeshAddedObservable=new Q,this.onMeshRemovedObservable=new Q,this.onNewSkeletonAddedObservable=new Q,this.onSkeletonRemovedObservable=new Q,this.onNewParticleSystemAddedObservable=new Q,this.onParticleSystemRemovedObservable=new Q,this.onNewAnimationGroupAddedObservable=new Q,this.onAnimationGroupRemovedObservable=new Q,this.onNewMaterialAddedObservable=new Q,this.onNewMultiMaterialAddedObservable=new Q,this.onMaterialRemovedObservable=new Q,this.onMultiMaterialRemovedObservable=new Q,this.onNewTextureAddedObservable=new Q,this.onTextureRemovedObservable=new Q,this.onNewFrameGraphAddedObservable=new Q,this.onFrameGraphRemovedObservable=new Q,this.onNewObjectRendererAddedObservable=new Q,this.onObjectRendererRemovedObservable=new Q,this.onNewPostProcessAddedObservable=new Q,this.onPostProcessRemovedObservable=new Q,this.onNewEffectLayerAddedObservable=new Q,this.onEffectLayerRemovedObservable=new Q,this.onBeforeRenderTargetsRenderObservable=new Q,this.onAfterRenderTargetsRenderObservable=new Q,this.onBeforeStepObservable=new Q,this.onAfterStepObservable=new Q,this.onActiveCameraChanged=new Q,this.onActiveCamerasChanged=new Q,this.onBeforeRenderingGroupObservable=new Q,this.onAfterRenderingGroupObservable=new Q,this.onMeshImportedObservable=new Q,this.onAnimationFileImportedObservable=new Q,this.onEnvironmentTextureChangedObservable=new Q,this.onMeshUnderPointerUpdatedObservable=new Q,this._registeredForLateAnimationBindings=new Ts(256),this._pointerPickingConfiguration=new Fu,this.onPrePointerObservable=new Q,this.onPointerObservable=new Q,this.onPreKeyboardObservable=new Q,this.onKeyboardObservable=new Q,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=s.FOGMODE_NONE,this.fogColor=new ae(.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 S(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new Ts(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new sn,this._activeIndices=new sn,this._activeParticles=new sn,this._activeBones=new sn,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 yt(256),this._processedMaterials=new yt(256),this._renderTargets=new Ts(256),this._materialsRenderTargets=new Ts(256),this._activeParticleSystems=new yt(256),this._activeSkeletons=new Ts(32),this._softwareSkinnedMeshes=new Ts(32),this._activeAnimatables=new Array,this._transformMatrix=H.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=kt.Create(),this._beforeClearStage=kt.Create(),this._beforeRenderTargetClearStage=kt.Create(),this._gatherRenderTargetsStage=kt.Create(),this._gatherActiveCameraRenderTargetsStage=kt.Create(),this._isReadyForMeshStage=kt.Create(),this._beforeEvaluateActiveMeshStage=kt.Create(),this._evaluateSubMeshStage=kt.Create(),this._preActiveMeshStage=kt.Create(),this._cameraDrawRenderTargetStage=kt.Create(),this._beforeCameraDrawStage=kt.Create(),this._beforeRenderTargetDrawStage=kt.Create(),this._beforeRenderingGroupDrawStage=kt.Create(),this._beforeRenderingMeshStage=kt.Create(),this._afterRenderingMeshStage=kt.Create(),this._afterRenderingGroupDrawStage=kt.Create(),this._afterCameraDrawStage=kt.Create(),this._afterCameraPostProcessStage=kt.Create(),this._afterRenderTargetDrawStage=kt.Create(),this._afterRenderTargetPostProcessStage=kt.Create(),this._afterRenderStage=kt.Create(),this._pointerMoveStage=kt.Create(),this._pointerDownStage=kt.Create(),this._pointerUpStage=kt.Create(),this._geometriesByUniqueId=null,this._uniqueId=0,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this.onReadyTimeoutObservable=new Q,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)&&(jC(),this._floatingOriginScene=this,is.getScene=this._getFloatingOriginScene),this._uid=null,this._renderingManager=new Qr(this),Yn&&(this.postProcessManager=new Yn(this)),Ft()&&this.attachControl(),this._createUbo(),et&&(this._imageProcessingConfiguration=new et),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 n=!0;for(this._pendingData.length>0&&(n=!1),(l=this.prePassRenderer)==null||l.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&n&&(n=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t0;for(let d of this._isReadyForMeshStage)d.action(c,f)||(n=!1);if(!e)continue;let h=c.material||this.defaultMaterial;if(h)if(h._storeEffectOnSubMeshes)for(let d of c.subMeshes){let u=d.getMaterial();u&&u.hasRenderTargetTextures&&u.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(u)===-1&&(this._processedMaterials.push(u),this._materialsRenderTargets.concatWithNoDuplicate(u.getRenderTargetTextures()))}else h.hasRenderTargetTextures&&h.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(h)===-1&&(this._processedMaterials.push(h),this._materialsRenderTargets.concatWithNoDuplicate(h.getRenderTargetTextures()))}if(e){for(t=0;t0)for(let c of this.activeCameras)c.isReady(!0)||(n=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(n=!1));for(let c of this.particleSystems)c.isReady()||(n=!1);if(this.proceduralTexturesEnabled)for(let c of this.proceduralTextures)c.isReady()||(n=!1);if(this.layers)for(let c of this.layers)c.isReady()||(n=!1);if(this.effectLayers)for(let c of this.effectLayers)c.isLayerReady()||(n=!1);for(let c of this._isReadyChecks)c.isReady()||(n=!1);return i.areAllEffectsReady()||(n=!1),i.currentRenderPassId=r,n}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){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=Xt.Now;else if(this.onReadyTimeoutDuration>0&&Xt.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=Xt.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 H),this._projectionMatrix.invertToRef(this._inverseProjectionMatrix),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Ua.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ua.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 Wt(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:S.ZeroReadOnly}getUniqueId(){return Jn.UniqueId}addMesh(e,t=!1){if(!this._blockEntityCollection&&(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),se.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 n of r)this.removeMesh(n)}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),se.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),se.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||(this.particleSystems.push(e),se.SetImmediate(()=>{this.onNewParticleSystemAddedObservable.notifyObservers(e)}))}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||(this.animationGroups.push(e),se.SetImmediate(()=>{this.onNewAnimationGroupAddedObservable.notifyObservers(e)}))}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),se.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),se.SetImmediate(()=>{this.onNewMaterialAddedObservable.notifyObservers(e)}))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}addFrameGraph(e){this.frameGraphs.push(e),se.SetImmediate(()=>{this.onNewFrameGraphAddedObservable.notifyObservers(e)})}addObjectRenderer(e){this.objectRenderers.push(e),se.SetImmediate(()=>{this.onNewObjectRendererAddedObservable.notifyObservers(e)})}addPostProcess(e){this._blockEntityCollection||(this.postProcesses.push(e),se.SetImmediate(()=>{this.onNewPostProcessAddedObservable.notifyObservers(e)}))}addEffectLayer(e){this._blockEntityCollection||(this.effectLayers.push(e),se.SetImmediate(()=>{this.onNewEffectLayerAddedObservable.notifyObservers(e)}))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){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 n=this.getCameraById(e);if(n)return n;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 n=this.getCameraByName(e);if(n)return n;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=n,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):(X.Error(c),o&&X.Error(o))}else{let c="Scene: An unexpected error occurred while trying to freeze active meshes.";i?i(c):(X.Error(c),o&&(X.Error(o),o.stack&&X.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=n,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 n=0;n0&&(n.layerMask&this.activeCamera.layerMask)!==0&&(this._skipFrustumClipping||n.alwaysSelectAsActiveMesh||n.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(n),this.activeCamera._activeMeshes.push(n),o!==n&&o._activate(this._renderId,!1);for(let l of this._preActiveMeshStage)l.action(n);n._activate(this._renderId,!1)&&(n.isAnInstance?n._internalAbstractMeshDataInfo._actAsRegularMesh&&(o=n):o._internalAbstractMeshDataInfo._onlyForInstances=!1,o._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(n,o)),n._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let r=0;r0){let r=this.getActiveSubMeshCandidates(t),n=r.length;i=i||n===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 d of this._gatherActiveCameraRenderTargetsStage)d.action(this._renderTargets);let n=!1;if(this.renderTargetsEnabled){this._intermediateRendering=!0;let d;if(this._renderTargets.length>0){se.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():[],d.length=u.renderList.length),p.render(_,this.dumpNextRenderTargets),n=!0}}u&&d&&(u.renderList.data=d,u.renderList.length=d.length),se.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}if(this._cameraDrawRenderTargetStage.length>0){let u=(h=this.getBoundingBoxRenderer)==null?void 0:h.call(this);u&&!d&&(d=u.renderList.length>0?u.renderList.data.slice():[],d.length=u.renderList.length);for(let m of this._cameraDrawRenderTargetStage)n=m.action(this.activeCamera)||n;u&&d&&(u.renderList.data=d,u.renderList.length=d.length)}this._intermediateRendering=!1}n&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(let d of this._beforeCameraDrawStage)d.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 d of this._afterCameraDrawStage)d.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){let d=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,d)}for(let d of this._afterCameraPostProcessStage)d.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(Ti.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(s.MinDeltaTime,Math.min(this._engine.getDeltaTime(),s.MaxDeltaTime))+this._timeAccumulator,t=this._engine.getTimeStep(),i=1e3/t/1e3,r=0,n=this._engine.getLockstepMaxSteps(),a=Math.floor(e/t);for(a=Math.min(a,n);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=(n=a==null?void 0:a.renderPassId)!=null?n: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;an.dispose(!0)),this._disposeList(this.transformNodes,n=>n.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&&KC(),ue._LastCreatedScene===this){ue._LastCreatedScene=null;let n=ue.Instances.length-1;for(;n>=0;){let a=ue.Instances[n];if(a.scenes.length>0){ue._LastCreatedScene=a.scenes[this._engine.scenes.length-1];break}n--}}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 n of r){if(n.computeWorldMatrix(!0),!n.subMeshes||n.subMeshes.length===0||n.infiniteDistance)continue;let a=n.getBoundingInfo(),o=a.boundingBox.minimumWorld,l=a.boundingBox.maximumWorld;S.CheckExtends(o,t,i),S.CheckExtends(l,t,i)}return t.x===Number.MAX_VALUE?{min:S.Zero(),max:S.Zero()}:{min:t,max:i}}createPickingRay(e,t,i,r,n=!1){throw Ce("Ray")}createPickingRayToRef(e,t,i,r,n,a=!1,o=!1){throw Ce("Ray")}createPickingRayInCameraSpace(e,t,i){throw Ce("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,r){throw Ce("Ray")}pick(e,t,i,r,n,a){let o=Ce("Ray",!0);return o&&X.Warn(o),new wi}pickWithBoundingInfo(e,t,i,r,n){let a=Ce("Ray",!0);return a&&X.Warn(a),new wi}pickWithRay(e,t,i,r){throw Ce("Ray")}multiPick(e,t,i,r,n){throw Ce("Ray")}multiPickWithRay(e,t,i){throw Ce("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 n in e){let a=e[n];st&&st.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,n,a,o){let l=tn(e,t,i,r?this.offlineProvider:void 0,n,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,n){return await new Promise((a,o)=>{this._loadFile(e,l=>{a(l)},t,i,r,(l,c)=>{o(c)},n)})}_requestFile(e,t,i,r,n,a,o){let l=fu(e,t,i,r?this.offlineProvider:void 0,n,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,n){return await new Promise((a,o)=>{this._requestFile(e,l=>{a(l)},t,i,r,l=>{o(l)},n)})}_readFile(e,t,i,r,n){let a=il(e,t,i,r,n);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,n)=>{this._readFile(e,a=>{r(a)},t,i,a=>{n(a)})})}getPerfCollector(){throw Ce("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)}};nt.FOGMODE_NONE=0;nt.FOGMODE_EXP=1;nt.FOGMODE_EXP2=2;nt.FOGMODE_LINEAR=3;nt.MinDeltaTime=1;nt.MaxDeltaTime=1e3;nt._OriginalDefaultMaterialFactory=nt.DefaultMaterialFactory;Ke("BABYLON.Scene",nt)});var db,vW,Lr=C(()=>{w();db="helperFunctions",vW=`const PI: f32=3.1415926535897932384626433832795;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));} +fn saturateEps(x: f32)->f32 {return clamp(x,Epsilon,1.0);} +fn maxEps(x: f32)->f32 {return max(x,Epsilon);} +fn maxEpsVec3(x: vec3f)->vec3f {return max(x,vec3f(Epsilon));} +fn absEps(x: f32)->f32 {return abs(x)+Epsilon;} +fn transposeMat3(inMatrix: mat3x3f)->mat3x3f {let i0: vec3f=inMatrix[0];let i1: vec3f=inMatrix[1];let i2: vec3f=inMatrix[2];let outMatrix:mat3x3f=mat3x3f( +vec3(i0.x,i1.x,i2.x), +vec3(i0.y,i1.y,i2.y), +vec3(i0.z,i1.z,i2.z) +);return outMatrix;} +fn inverseMat3(inMatrix: mat3x3f)->mat3x3f {let a00: f32=inMatrix[0][0];let a01: f32=inMatrix[0][1];let a02: f32=inMatrix[0][2];let a10: f32=inMatrix[1][0];let a11: f32=inMatrix[1][1];let a12: f32=inMatrix[1][2];let a20: f32=inMatrix[2][0];let a21: f32=inMatrix[2][1];let a22: f32=inMatrix[2][2];let b01: f32=a22*a11-a12*a21;let b11: f32=-a22*a10+a12*a20;let b21: f32=a21*a10-a11*a20;let det: f32=a00*b01+a01*b11+a02*b21;return mat3x3f(b01/det,(-a22*a01+a02*a21)/det,(a12*a01-a02*a11)/det, +b11/det,(a22*a00-a02*a20)/det,(-a12*a00+a02*a10)/det, +b21/det,(-a21*a00+a01*a20)/det,(a11*a00-a01*a10)/det);} +#if USE_EXACT_SRGB_CONVERSIONS +fn toLinearSpaceExact(color: vec3f)->vec3f +{let nearZeroSection: vec3f=0.0773993808*color;let remainingSection: vec3f=pow(0.947867299*(color+vec3f(0.055)),vec3f(2.4));return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.04045)));} +fn toGammaSpaceExact(color: vec3f)->vec3f +{let nearZeroSection: vec3f=12.92*color;let remainingSection: vec3f=1.055*pow(color,vec3f(0.41666))-vec3f(0.055);return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3f(0.0031308)));} +#endif +fn toLinearSpace(color: f32)->f32 +{ +#if USE_EXACT_SRGB_CONVERSIONS +var nearZeroSection=0.0773993808*color;var remainingSection=pow(0.947867299*(color+0.055),2.4);return select(remainingSection,nearZeroSection,color<=0.04045); +#else +return pow(color,LinearEncodePowerApprox); +#endif +} +fn toLinearSpaceVec3(color: vec3f)->vec3f +{ +#if USE_EXACT_SRGB_CONVERSIONS +return toLinearSpaceExact(color); +#else +return pow(color,vec3f(LinearEncodePowerApprox)); +#endif +} +fn toLinearSpaceVec4(color: vec4)->vec4 +{ +#if USE_EXACT_SRGB_CONVERSIONS +return vec4f(toLinearSpaceExact(color.rgb),color.a); +#else +return vec4f(pow(color.rgb,vec3f(LinearEncodePowerApprox)),color.a); +#endif +} +fn toGammaSpace(color: vec4)->vec4 +{ +#if USE_EXACT_SRGB_CONVERSIONS +return vec4(toGammaSpaceExact(color.rgb),color.a); +#else +return vec4(pow(color.rgb,vec3f(GammaEncodePowerApprox)),color.a); +#endif +} +fn toGammaSpaceVec3(color: vec3f)->vec3f +{ +#if USE_EXACT_SRGB_CONVERSIONS +return toGammaSpaceExact(color); +#else +return pow(color,vec3f(GammaEncodePowerApprox)); +#endif +} +fn squareVec3(value: vec3f)->vec3f +{return value*value;} +fn pow5(value: f32)->f32 {let sq: f32=value*value;return sq*sq*value;} +fn double_refract(I: vec3f,N: vec3f,eta: f32)->vec3f {let Tfront: vec3f=refract(I,N,1.0/eta);let Nback: vec3f=normalize(reflect(N,Tfront));return refract(Tfront,-Nback,eta);} +fn getLuminanceUnclamped(color: vec3f)->f32 +{return dot(color,LuminanceEncodeApprox);} +fn getLuminance(color: vec3f)->f32 +{return saturate(getLuminanceUnclamped(color));} +fn getRand(seed: vec2)->f32 {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);} +fn dither(seed: vec2,varianceAmount: f32)->f32 {let rand: f32=getRand(seed);let normVariance: f32=varianceAmount/255.0;let dither: f32=mix(-normVariance,normVariance,rand);return dither;} +const rgbdMaxRange: f32=255.0;fn toRGBD(color: vec3f)->vec4 {let maxRGB: f32=max(max(color.r,max(color.g,color.b)),Epsilon);var D: f32 =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);var rgb: vec3f =color.rgb*D;rgb=toGammaSpaceVec3(rgb);return vec4(saturateVec3(rgb),D);} +fn fromRGBD(rgbd: vec4)->vec3f {let rgb=toLinearSpaceVec3(rgbd.rgb);return rgb/rgbd.a;} +fn parallaxCorrectNormal(vertexPos: vec3f,origVec: vec3f,cubeSize: vec3f,cubePos: vec3f)->vec3f {let invOrigVec: vec3f=vec3f(1.)/origVec;let halfSize: vec3f=cubeSize*0.5;let intersecAtMaxPlane: vec3f=(cubePos+halfSize-vertexPos)*invOrigVec;let intersecAtMinPlane: vec3f=(cubePos-halfSize-vertexPos)*invOrigVec;let largestIntersec: vec3f=max(intersecAtMaxPlane,intersecAtMinPlane);let distance: f32=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);let intersectPositionWS: vec3f=vertexPos+origVec*distance;return intersectPositionWS-cubePos;} +fn equirectangularToCubemapDirection(uv : vec2f)->vec3f {var longitude : f32=uv.x*TWO_PI-PI;var latitude : f32=HALF_PI-uv.y*PI;var direction : vec3f;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;} +fn sqrtClamped(value: f32)->f32 {return sqrt(max(value,0.));} +fn avg(value: vec3f)->f32 {return dot(value,vec3f(0.333333333));} +fn singleScatterToMultiScatterAlbedo(rho_ss: vec3f)->vec3f {let s: vec3f=sqrt(max(vec3f(1.0)-rho_ss,vec3f(0.0)));return (vec3f(1.0)-s)*(vec3f(1.0)-vec3f(0.139)*s)/(vec3f(1.0)+vec3f(1.17)*s);} +fn multiScatterToSingleScatterAlbedo(rho_ms: vec3f)->vec3f {let s: vec3f=4.09712f+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return 1.0f-s*s;} +fn multiScatterToSingleScatterAlbedoWithAniso(rho_ms: vec3f,aniso: f32)->vec3f {let s: vec3f=4.09712+4.20863f*rho_ms-sqrt(9.59217f+41.6808f*rho_ms+17.7126f*rho_ms*rho_ms);return (vec3f(1.0f)-s*s)/maxEpsVec3(vec3f(1.0f)-vec3f(aniso)*s*s);} +fn min3(v: vec3f)->f32 {return min(v.x,min(v.y,v.z));} +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[db]||(E.IncludesShadersStoreWGSL[db]=vW)});var _E={};Ie(_E,{rgbdDecodePixelShaderWGSL:()=>SW});var pE,ub,SW,gE=C(()=>{w();Lr();pE="rgbdDecodePixelShader",ub=`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[pE]||(E.ShadersStoreWGSL[pE]=ub);SW={name:pE,shader:ub}});var mb,TW,Or=C(()=>{w();mb="helperFunctions",TW=`const float PI=3.1415926535897932384626433832795;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 +#define maxEps(x) max(x,Epsilon) +#define saturateEps(x) clamp(x,Epsilon,1.0) +mat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3( +vec3(i0.x,i1.x,i2.x), +vec3(i0.y,i1.y,i2.y), +vec3(i0.z,i1.z,i2.z) +);return outMatrix;} +mat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11), +b11,(a22*a00-a02*a20),(-a12*a00+a02*a10), +b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;} +#if USE_EXACT_SRGB_CONVERSIONS +vec3 toLinearSpaceExact(vec3 color) +{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4)); +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045))); +#else +return +vec3( +color.r<=0.04045 ? nearZeroSection.r : remainingSection.r, +color.g<=0.04045 ? nearZeroSection.g : remainingSection.g, +color.b<=0.04045 ? nearZeroSection.b : remainingSection.b); +#endif +} +vec3 toGammaSpaceExact(vec3 color) +{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055); +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308))); +#else +return +vec3( +color.r<=0.0031308 ? nearZeroSection.r : remainingSection.r, +color.g<=0.0031308 ? nearZeroSection.g : remainingSection.g, +color.b<=0.0031308 ? nearZeroSection.b : remainingSection.b); +#endif +} +#endif +float toLinearSpace(float color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +float nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection; +#else +return pow(color,LinearEncodePowerApprox); +#endif +} +vec3 toLinearSpace(vec3 color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +return toLinearSpaceExact(color); +#else +return pow(color,vec3(LinearEncodePowerApprox)); +#endif +} +vec4 toLinearSpace(vec4 color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +return vec4(toLinearSpaceExact(color.rgb),color.a); +#else +return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a); +#endif +} +float toGammaSpace(float color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +float nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection; +#else +return pow(color,GammaEncodePowerApprox); +#endif +} +vec3 toGammaSpace(vec3 color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +return toGammaSpaceExact(color); +#else +return pow(color,vec3(GammaEncodePowerApprox)); +#endif +} +vec4 toGammaSpace(vec4 color) +{ +#if USE_EXACT_SRGB_CONVERSIONS +return vec4(toGammaSpaceExact(color.rgb),color.a); +#else +return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a); +#endif +} +float square(float value) +{return value*value;} +vec3 square(vec3 value) +{return value*value;} +float pow5(float value) {float sq=value*value;return sq*sq*value;} +vec3 double_refract(vec3 I,vec3 N,float eta) {vec3 Tfront=refract(I,N,1.0/eta);vec3 Nback=normalize(reflect(N,Tfront));return refract(Tfront,-Nback,eta);} +float getLuminanceUnclamped(vec3 color) +{return dot(color,LuminanceEncodeApprox);} +float getLuminance(vec3 color) +{return saturate(getLuminanceUnclamped(color));} +float getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);} +float dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;} +const float rgbdMaxRange=255.;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =saturate(floor(D)/255.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(saturate(rgb),D);} +vec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;} +vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;} +vec3 equirectangularToCubemapDirection(vec2 uv) {float longitude=uv.x*TWO_PI-PI;float latitude=HALF_PI-uv.y*PI;vec3 direction;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;} +float sqrtClamped(float value) {return sqrt(max(value,0.));} +float avg(vec3 value) {return dot(value,vec3(0.333333333));} +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +uint extractBits(uint value,int offset,int width) {return (value>>offset) & ((1u<>23)-0x7f;} +vec3 singleScatterToMultiScatterAlbedo(vec3 rho_ss) {vec3 s=sqrt(max(vec3(1.0)-rho_ss,vec3(0.0)));return (vec3(1.0)-s)*(vec3(1.0)-vec3(0.139)*s)/(vec3(1.0)+vec3(1.17)*s);} +vec3 multiScatterToSingleScatterAlbedo(vec3 rho_ms) {vec3 s=4.09712+4.20863*rho_ms-sqrt(9.59217+41.6808*rho_ms+17.7126*rho_ms*rho_ms);return 1.0-s*s;} +vec3 multiScatterToSingleScatterAlbedo(vec3 rho_ms,float aniso) {vec3 s=4.09712+4.20863*rho_ms-sqrt(9.59217+41.6808*rho_ms+17.7126*rho_ms*rho_ms);return (1.0-s*s)/maxEps(1.0-aniso*s*s);} +float min3(vec3 v) {return min(v.x,min(v.y,v.z));} +float max3(vec3 v) {return max(v.x,max(v.y,v.z));} +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[mb]||(E.IncludesShadersStore[mb]=TW)});var vE={};Ie(vE,{rgbdDecodePixelShader:()=>AW});var EE,pb,AW,SE=C(()=>{w();Or();EE="rgbdDecodePixelShader",pb=`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[EE]||(E.ShadersStore[EE]=pb);AW={name:EE,shader:pb}});var gb={};Ie(gb,{rgbdEncodePixelShader:()=>RW});var TE,_b,RW,Eb=C(()=>{w();Or();TE="rgbdEncodePixelShader",_b=`varying vec2 vUV;uniform sampler2D textureSampler; +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}`;E.ShadersStore[TE]||(E.ShadersStore[TE]=_b);RW={name:TE,shader:_b}});var Sb={};Ie(Sb,{rgbdEncodePixelShaderWGSL:()=>xW});var AE,vb,xW,Tb=C(()=>{w();Lr();AE="rgbdEncodePixelShader",vb=`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[AE]||(E.ShadersStoreWGSL[AE]=vb);xW={name:AE,shader:vb}});var mc,RE=C(()=>{Kn();vu();mc=class{static ExpandRGBDTexture(e){let t=e._texture;if(!t||!e.isRGBD)return;let i=t.getEngine(),r=i.getCaps(),n=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(()=>(gE(),_E)):await Promise.resolve().then(()=>(SE(),vE));let f=new Rt("rgbdDecode","rgbdDecode",null,null,1,null,3,i,!1,void 0,t.type,void 0,null,!1,void 0,c);f.externalTextureSamplerBinding=!0;let h=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:5});f.onEffectCreatedObservable.addOnce(d=>{d.executeWhenCompiled(()=>{f.onApply=u=>{u._bindTexture("textureSampler",t),u.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([f],h,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),f&&f.dispose(),h._swapAndDie(t),t.isReady=!0})})};a&&(n?o():e.onLoadObservable.addOnce(o))}static async EncodeTextureToRGBD(e,t,i=0){return t.getEngine().isWebGPU?await Promise.resolve().then(()=>(Tb(),Sb)):await Promise.resolve().then(()=>(Eb(),gb)),await AC("rgbdEncode",e,t,i,1,5)}}});var xE=C(()=>{Lg();fc();ht.prototype._sphericalPolynomialTargetSize=0;ht.prototype.forceSphericalPolynomialsRecompute=function(){this._texture&&(this._texture._sphericalPolynomial=null,this._texture._sphericalPolynomialPromise=null,this._texture._sphericalPolynomialComputed=!1)};Object.defineProperty(ht.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=zn.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomialPromise===null?this._texture._sphericalPolynomialComputed=!0:this._texture._sphericalPolynomialPromise.then(s=>{this._texture._sphericalPolynomial=s,this._texture._sphericalPolynomialComputed=!0})),null}return null},set:function(s){this._texture&&(this._texture._sphericalPolynomial=s)},enumerable:!0,configurable:!0})});function Ib(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength),t=0;for(let a=0;aAb)throw new Error(`Unsupported babylon environment map version "${s.version}". Latest supported version is "${Ab}".`);return s.version===2||(s={...s,version:2,imageType:wu}),s}function IW(s,e){e=uh(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 n=0;n{if(t){let u=e.createTexture(null,!0,!0,null,1,null,m=>{d(m)},s);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&&s instanceof ImageBitmap?-1:1)},e.scenes.length&&(e.scenes[0].postProcessManager.directRender([i],c,!0,n,a),e.restoreDefaultFramebuffer(),u.dispose(),URL.revokeObjectURL(r),h())})})}else{if(e._uploadImageToTexture(f,s,n,a),o){let u=l[a];u&&e._uploadImageToTexture(u._texture,s,n,0)}h()}})}async function bW(s,e,t=wu){let i=s.getEngine();s.format=5,s.type=0,s.generateMipMaps=!0,s._cachedAnisotropicFilteringLevel=null,i.updateTextureSamplingMode(3,s),await bb(s,e,!0,t),s.isReady=!0}async function MW(s,e,t,i=wu,r=null){let n=s.getEngine(),a=new Dt(n,5),o=new ht(n,a);s._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,n.updateTextureSamplingMode(3,a),await bb(a,[e],!1,i),n.generateMipMapsForCubemap(a),a.isReady=!0}async function bb(s,e,t,i=wu){if(!se.IsExponentOfTwo(s.width))throw new Error("Texture size must be a power of two");let r=Tg(s.width)+1,n=s.getEngine(),a=!1,o=!1,l=null,c=null,f=null,h=n.getCaps();h.textureLOD?n._features.supportRenderAndCopyToLodForFloatTextures?h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering?(a=!0,s.type=2):h.textureFloatRender&&h.textureFloatLinearFiltering&&(a=!0,s.type=1):a=!1:(a=!1,o=t);let d=0;if(a)n.isWebGPU?(d=1,await Promise.resolve().then(()=>(gE(),_E))):await Promise.resolve().then(()=>(SE(),vE)),l=new Rt("rgbdDecode","rgbdDecode",null,null,1,null,3,n,!1,void 0,s.type,void 0,null,!1,void 0,d),s._isRGBD=!1,s.invertY=!1,c=n.createRenderTargetCubeTexture(s.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:3,type:s.type,format:5});else if(s._isRGBD=!0,s.invertY=!0,o){f={};let p=s._lodGenerationScale,_=s._lodGenerationOffset;for(let g=0;g<3;g++){let I=1-g/2,x=_,T=(r-1)*p+_,A=x+(T-x)*I,R=Math.round(Math.min(Math.max(A,0),T)),P=new Dt(n,2);P.isCube=!0,P.invertY=!0,P.generateMipMaps=!1,n.updateTextureSamplingMode(2,P);let D=new ht(null);switch(D._isCube=!0,D._texture=P,f[R]=D,g){case 0:s._lodTextureLow=D;break;case 1:s._lodTextureMid=D;break;case 2:s._lodTextureHigh=D;break}}}let u=[];for(let m=0;mawait xb(T,n,a,l,I,p,m,o,f,c,s));else{let T=new Image;T.src=I,x=new Promise((A,R)=>{T.onload=()=>{xb(T,n,a,l,I,p,m,o,f,c,s).then(()=>A()).catch(P=>{R(P)})},T.onerror=P=>{R(P)}})}u.push(x)}if(await Promise.all(u),e.length{At();Ee();Mi();Qf();Dr();fc();vr();Kn();We();RE();Yg();xE();oc();wu="image/png",Ab=2,Rb=[134,22,135,150,246,214,150,54]});var Db={};Ie(Db,{_ENVTextureLoader:()=>IE});var IE,Pb=C(()=>{yb();IE=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,n){if(Array.isArray(e))return;let a=Ib(e);if(a){t.width=a.width,t.height=a.width;try{Mb(t,a),Cb(t,e,a).then(()=>{t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()},o=>{n==null||n("Can not upload environment levels",o)})}catch(o){n==null||n("Can not upload environment file",o)}}else n&&n("Can not parse the environment file",null)}loadData(){throw".env not supported in 2d."}}});var $n,Lb=C(()=>{Ee();$n=class{static ConvertPanoramaToCubemap(e,t,i,r,n=!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,n,a,o),c=this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i,n,a,o),f=this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i,n,a,o),h=this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i,n,a,o),d=this.CreateCubemapTexture(r,this.FACE_UP,e,t,i,n,a,o),u=this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i,n,a,o);return{front:l,back:c,left:f,right:h,up:d,down:u,size:r,type:1,format:4,gammaSpace:!1}}static CreateCubemapTexture(e,t,i,r,n,a,o,l){let c=new ArrayBuffer(e*e*4*3),f=new Float32Array(c),h=a?Math.max(1,Math.round(r/4/e)):1,d=1/h,u=d*d,m=t[1].subtract(t[0]).scale(d/e),p=t[3].subtract(t[2]).scale(d/e),_=1/e,g=0;for(let v=0;vMath.PI;)o-=2*Math.PI;let c=o/Math.PI,f=l/Math.PI;c=c*.5+.5;let h=Math.round(c*i);h<0?h=0:h>=i&&(h=i-1);let d=Math.round(f*r);d<0?d=0:d>=r&&(d=r-1);let u=a?r-d-1:d,m=t[u*i*n+h*n+0],p=t[u*i*n+h*n+1],_=t[u*i*n+h*n+2];return{r:m,g:p,b:_}}};$n.FACE_LEFT=[new S(-1,-1,-1),new S(1,-1,-1),new S(-1,1,-1),new S(1,1,-1)];$n.FACE_RIGHT=[new S(1,-1,1),new S(-1,-1,1),new S(1,1,1),new S(-1,1,1)];$n.FACE_FRONT=[new S(1,-1,-1),new S(1,-1,1),new S(1,1,-1),new S(1,1,1)];$n.FACE_BACK=[new S(-1,-1,1),new S(-1,-1,-1),new S(-1,1,1),new S(-1,1,-1)];$n.FACE_DOWN=[new S(1,1,-1),new S(1,1,1),new S(-1,1,-1),new S(-1,1,1)];$n.FACE_UP=[new S(-1,-1,-1),new S(-1,-1,1),new S(1,-1,-1),new S(1,-1,1)]});function yW(s,e){return e>1023?s*Math.pow(2,1023)*Math.pow(2,e-1023):e<-1074?s*Math.pow(2,-1074)*Math.pow(2,e+1074):s*Math.pow(2,e)}function Ob(s,e,t,i,r,n){r>0?(r=yW(1,r-136),s[n+0]=e*r,s[n+1]=t*r,s[n+2]=i*r):(s[n+0]=0,s[n+1]=0,s[n+2]=0)}function CE(s,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 Fb(s,e){return DW(s,e)}function DW(s,e){let t=e.height,i=e.width,r,n,a,o,l,c=e.dataPosition,f,h,d,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=s[c++],n=s[c++],a=s[c++],o=s[c++],r!=2||n!=2||a&128||e.width<8||e.width>32767)return PW(s,e);if((a<<8|o)!=i)throw"HDR Bad header format, wrong scan line width";for(f=0,d=0;d<4;d++)for(h=(d+1)*i;f128){if(l=r-128,l==0||l>h-f)throw"HDR Bad Format, bad scanline data (run)";for(;l-- >0;)m[f++]=n}else{if(l=r,l==0||l>h-f)throw"HDR Bad Format, bad scanline data (non-run)";if(m[f++]=n,--l>0)for(let g=0;g0;){for(l=0;l{Lb()});var Bb={};Ie(Bb,{_HDRTextureLoader:()=>bE});var bE,Ub=C(()=>{wb();bE=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),n=Nb(r),a=Fb(r,n),o=n.width*n.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 Ms,Vb=C(()=>{We();Ms=class s{constructor(e,t){if(this.data=e,this.isInvalid=!1,!s.IsValid(e)){this.isInvalid=!0,X.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){X.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){X.Error("only 2D textures currently supported"),this.isInvalid=!0;return}if(this.numberOfArrayElements!==0){X.Error("texture arrays not currently supported"),this.isInvalid=!0;return}if(this.numberOfFaces!==t){X.Error("number of faces expected"+t+", but found "+this.numberOfFaces),this.isInvalid=!0;return}this.loadType=s.COMPRESSED_2D}uploadLevels(e,t){switch(this.loadType){case s.COMPRESSED_2D:this._upload2DCompressedLevels(e,t);break;case s.TEX_2D:case s.COMPRESSED_3D:case s.TEX_3D:}}_upload2DCompressedLevels(e,t){let i=s.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,n=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}};Ms.HEADER_LEN=64;Ms.COMPRESSED_2D=0;Ms.COMPRESSED_3D=1;Ms.TEX_2D=2;Ms.TEX_3D=3});var ME,mh,Gb=C(()=>{ME=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})})}},mh=class s extends ME{constructor(e,t,i=s.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 n=this._workerInfos.indexOf(e);n!==-1&&this._workerInfos.splice(n,1)},this._options.idleTimeElapsedBeforeRelease))})})}};mh.DefaultOptions={idleTimeElapsedBeforeRelease:1e3}});var kb,pc,Wb,Hb=C(()=>{(function(s){s[s.ETC1S=0]="ETC1S",s[s.UASTC4x4=1]="UASTC4x4"})(kb||(kb={}));(function(s){s[s.ASTC_4X4_RGBA=0]="ASTC_4X4_RGBA",s[s.ASTC_4x4_RGBA=0]="ASTC_4x4_RGBA",s[s.BC7_RGBA=1]="BC7_RGBA",s[s.BC3_RGBA=2]="BC3_RGBA",s[s.BC1_RGB=3]="BC1_RGB",s[s.PVRTC1_4_RGBA=4]="PVRTC1_4_RGBA",s[s.PVRTC1_4_RGB=5]="PVRTC1_4_RGB",s[s.ETC2_RGBA=6]="ETC2_RGBA",s[s.ETC1_RGB=7]="ETC1_RGB",s[s.RGBA32=8]="RGBA32",s[s.R8=9]="R8",s[s.RG8=10]="RG8"})(pc||(pc={}));(function(s){s[s.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",s[s.COMPRESSED_RGBA_ASTC_4X4_KHR=37808]="COMPRESSED_RGBA_ASTC_4X4_KHR",s[s.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",s[s.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",s[s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",s[s.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",s[s.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",s[s.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",s[s.RGBA8Format=32856]="RGBA8Format",s[s.R8Format=33321]="R8Format",s[s.RG8Format=33323]="RG8Format"})(Wb||(Wb={}))});function ph(s,e){let t=(e==null?void 0:e.jsDecoderModule)||KTX2DECODER;s&&(s.wasmBaseUrl&&(t.Transcoder.WasmBaseUrl=s.wasmBaseUrl),s.wasmUASTCToASTC&&(t.LiteTranscoder_UASTC_ASTC.WasmModuleURL=s.wasmUASTCToASTC),s.wasmUASTCToBC7&&(t.LiteTranscoder_UASTC_BC7.WasmModuleURL=s.wasmUASTCToBC7),s.wasmUASTCToRGBA_UNORM&&(t.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=s.wasmUASTCToRGBA_UNORM),s.wasmUASTCToRGBA_SRGB&&(t.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=s.wasmUASTCToRGBA_SRGB),s.wasmUASTCToR8_UNORM&&(t.LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL=s.wasmUASTCToR8_UNORM),s.wasmUASTCToRG8_UNORM&&(t.LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL=s.wasmUASTCToRG8_UNORM),s.jsMSCTranscoder&&(t.MSCTranscoder.JSModuleURL=s.jsMSCTranscoder),s.wasmMSCTranscoder&&(t.MSCTranscoder.WasmModuleURL=s.wasmMSCTranscoder),s.wasmZSTDDecoder&&(t.ZSTDDecoder.WasmModuleURL=s.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 zb(s){typeof s=="undefined"&&typeof KTX2DECODER!="undefined"&&(s=KTX2DECODER);let e;onmessage=t=>{if(t.data)switch(t.data.action){case"init":{let i=t.data.urls;i&&(i.jsDecoderModule&&typeof s=="undefined"&&(importScripts(i.jsDecoderModule),s=KTX2DECODER),ph(i)),t.data.wasmBinaries&&ph(void 0,{...t.data.wasmBinaries,jsDecoderModule:s}),e=new s.KTX2Decoder,postMessage({action:"init"});break}case"setDefaultDecoderOptions":{s.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 n=0;n{postMessage({action:"decoded",success:!1,msg:i})});break}}}async function Xb(s,e,t){return await new Promise((i,r)=>{let n=o=>{s.removeEventListener("error",n),s.removeEventListener("message",a),r(o)},a=o=>{o.data.action==="init"&&(s.removeEventListener("error",n),s.removeEventListener("message",a),i(s))};s.addEventListener("error",n),s.addEventListener("message",a),s.postMessage({action:"init",urls:t,wasmBinaries:e})})}var Yb=C(()=>{});var yE,ea,Kb=C(()=>{Gb();At();Hb();Yb();yE=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:[pc.BC1_RGB,pc.BC3_RGBA],yes:{transcodeFormat:pc.RGBA32,engineFormat:32856,roundToMultiple4:!1}}}),this._ktx2DecoderOptions=e,e}},ea=class s{static GetDefaultNumWorkers(){return typeof navigator!="object"||!navigator.hardwareConcurrency?1:Math.min(Math.floor(navigator.hardwareConcurrency*.5),4)}static _Initialize(e){if(s._WorkerPoolPromise||s._DecoderModulePromise)return;let t={wasmBaseUrl:se.ScriptBaseUrl,jsDecoderModule:se.GetBabylonScriptURL(this.URLConfig.jsDecoderModule,!0),wasmUASTCToASTC:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToASTC,!0),wasmUASTCToBC7:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToBC7,!0),wasmUASTCToRGBA_UNORM:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_UNORM,!0),wasmUASTCToRGBA_SRGB:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRGBA_SRGB,!0),wasmUASTCToR8_UNORM:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToR8_UNORM,!0),wasmUASTCToRG8_UNORM:se.GetBabylonScriptURL(this.URLConfig.wasmUASTCToRG8_UNORM,!0),jsMSCTranscoder:se.GetBabylonScriptURL(this.URLConfig.jsMSCTranscoder,!0),wasmMSCTranscoder:se.GetBabylonScriptURL(this.URLConfig.wasmMSCTranscoder,!0),wasmZSTDDecoder:se.GetBabylonScriptURL(this.URLConfig.wasmZSTDDecoder,!0)};e&&typeof Worker=="function"&&typeof URL!="undefined"?s._WorkerPoolPromise=new Promise(i=>{let r=`${ph}(${zb})()`,n=URL.createObjectURL(new Blob([r],{type:"application/javascript"}));i(new mh(e,async()=>await Xb(new Worker(n),void 0,t)))}):typeof s._KTX2DecoderModule=="undefined"?s._DecoderModulePromise=se.LoadBabylonScriptAsync(t.jsDecoderModule).then(()=>(s._KTX2DecoderModule=KTX2DECODER,s._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,s._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,ph(t,s._KTX2DecoderModule),new s._KTX2DecoderModule.KTX2Decoder)):(s._KTX2DecoderModule.MSCTranscoder.UseFromWorkerThread=!1,s._KTX2DecoderModule.WASMMemoryManager.LoadBinariesFromCurrentThread=!0,s._DecoderModulePromise=Promise.resolve(new s._KTX2DecoderModule.KTX2Decoder))}constructor(e,t=s.DefaultNumWorkers){var r,n;this._engine=e;let i=typeof t=="object"&&t.workerPool||s.WorkerPool;if(i)s._WorkerPoolPromise=Promise.resolve(i);else{typeof t=="object"?s._KTX2DecoderModule=(r=t==null?void 0:t.binariesAndModulesContainer)==null?void 0:r.jsDecoderModule:typeof KTX2DECODER!="undefined"&&(s._KTX2DecoderModule=KTX2DECODER);let a=typeof t=="number"?t:(n=t.numWorkers)!=null?n:s.DefaultNumWorkers;s._Initialize(a)}}async _uploadAsync(e,t,i){let r=this._engine.getCaps(),n={astc:!!r.astc,bptc:!!r.bptc,s3tc:!!r.s3tc,pvrtc:!!r.pvrtc,etc2:!!r.etc2,etc1:!!r.etc1};if(s._WorkerPoolPromise){let a=await s._WorkerPoolPromise;return await new Promise((o,l)=>{a.push((c,f)=>{let h=m=>{c.removeEventListener("error",h),c.removeEventListener("message",d),l(m),f()},d=m=>{if(m.data.action==="decoded"){if(c.removeEventListener("error",h),c.removeEventListener("message",d),!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",h),c.addEventListener("message",d),c.postMessage({action:"setDefaultDecoderOptions",options:s.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:n,options:i},[u.buffer])})})}else if(s._DecoderModulePromise){let a=await s._DecoderModulePromise;return s.DefaultDecoderOptions.isDirty&&(s._KTX2DecoderModule.KTX2Decoder.DefaultDecoderOptions=s.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 n=!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,n=!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}};ea.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};ea.DefaultNumWorkers=ea.GetDefaultNumWorkers();ea.DefaultDecoderOptions=new yE});var PE={};Ie(PE,{_KTXTextureLoader:()=>DE});function LW(s){switch(s){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 DE,LE=C(()=>{Vb();Kb();We();DE=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r){if(Array.isArray(e))return;t._invertVScale=!t.invertY;let n=t.getEngine(),a=new Ms(e,6),o=a.numberOfMipmapLevels>1&&t.generateMipMaps;n._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,n._setCubeMapTextureParams(t,o,a.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),r&&r()}loadData(e,t,i,r){if(Ms.IsValid(e)){t._invertVScale=!t.invertY;let n=new Ms(e,1),a=LW(n.glInternalFormat);a?(t.format=a,t._useSRGBBuffer=t.getEngine()._getUseSRGBBuffer(!0,t.generateMipMaps),t._gammaSpace=!0):t.format=n.glInternalFormat,i(n.pixelWidth,n.pixelHeight,t.generateMipMaps,!0,()=>{n.uploadLevels(t,t.generateMipMaps)},n.isInvalid)}else ea.IsValid(e)?new ea(t.getEngine())._uploadAsync(e,t,r).then(()=>{i(t.width,t.height,t.generateMipMaps,!0,()=>{},!1)},a=>{X.Warn(`Failed to load KTX2 texture data: ${a.message}`),i(0,0,!1,!1,()=>{},!0)}):(X.Error("texture missing KTX identifier"),i(0,0,!1,!1,()=>{},!0))}}});function Bu(s){let e=0;return{id_length:s[e++],colormap_type:s[e++],image_type:s[e++],colormap_index:s[e++]|s[e++]<<8,colormap_length:s[e++]|s[e++]<<8,colormap_size:s[e++],origin:[s[e++]|s[e++]<<8,s[e++]|s[e++]<<8],width:s[e++]|s[e++]<<8,height:s[e++]|s[e++]<<8,pixel_size:s[e++],flags:s[e]}}function OE(s,e){if(e.length<19){X.Error("Unable to load TGA file - Not enough data to contain header");return}let t=18,i=Bu(e);if(i.id_length+t>e.length){X.Error("Unable to load TGA file - Not enough data");return}t+=i.id_length;let r=!1,n=!1,a=!1;switch(i.image_type){case wW:r=!0;case OW:n=!0;break;case BW:r=!0;case NW:break;case UW:r=!0;case FW:a=!0;break}let o,l=i.pixel_size>>3,c=i.width*i.height*l,f;if(n&&(f=e.subarray(t,t+=i.colormap_length*(i.colormap_size>>3))),r){o=new Uint8Array(c);let x,T,A,R=0,P=new Uint8Array(l);for(;t>GW){default:case HW:h=0,u=1,_=i.width,d=0,m=1,p=i.height;break;case kW:h=0,u=1,_=i.width,d=i.height-1,m=-1,p=-1;break;case zW:h=i.width-1,u=-1,_=-1,d=0,m=1,p=i.height;break;case WW:h=i.width-1,u=-1,_=-1,d=i.height-1,m=-1,p=-1;break}let g="_getImageData"+(a?"Grey":"")+i.pixel_size+"bits",v=QW[g](i,f,o,d,m,p,h,u,_);s.getEngine()._uploadDataToTextureDirectly(s,v)}function XW(s,e,t,i,r,n,a,o,l){let c=t,f=e,h=s.width,d=s.height,u,m=0,p,_,g=new Uint8Array(h*d*4);for(_=i;_!==n;_+=r)for(p=a;p!==l;p+=o,m++)u=c[m],g[(p+h*_)*4+3]=255,g[(p+h*_)*4+2]=f[u*3+0],g[(p+h*_)*4+1]=f[u*3+1],g[(p+h*_)*4+0]=f[u*3+2];return g}function YW(s,e,t,i,r,n,a,o,l){let c=t,f=s.width,h=s.height,d,u=0,m,p,_=new Uint8Array(f*h*4);for(p=i;p!==n;p+=r)for(m=a;m!==l;m+=o,u+=2){d=c[u+0]+(c[u+1]<<8);let g=((d&31744)>>10)*255/31|0,v=((d&992)>>5)*255/31|0,I=(d&31)*255/31|0;_[(m+f*p)*4+0]=g,_[(m+f*p)*4+1]=v,_[(m+f*p)*4+2]=I,_[(m+f*p)*4+3]=d&32768?0:255}return _}function KW(s,e,t,i,r,n,a,o,l){let c=t,f=s.width,h=s.height,d=0,u,m,p=new Uint8Array(f*h*4);for(m=i;m!==n;m+=r)for(u=a;u!==l;u+=o,d+=3)p[(u+f*m)*4+3]=255,p[(u+f*m)*4+2]=c[d+0],p[(u+f*m)*4+1]=c[d+1],p[(u+f*m)*4+0]=c[d+2];return p}function jW(s,e,t,i,r,n,a,o,l){let c=t,f=s.width,h=s.height,d=0,u,m,p=new Uint8Array(f*h*4);for(m=i;m!==n;m+=r)for(u=a;u!==l;u+=o,d+=4)p[(u+f*m)*4+2]=c[d+0],p[(u+f*m)*4+1]=c[d+1],p[(u+f*m)*4+0]=c[d+2],p[(u+f*m)*4+3]=c[d+3];return p}function ZW(s,e,t,i,r,n,a,o,l){let c=t,f=s.width,h=s.height,d,u=0,m,p,_=new Uint8Array(f*h*4);for(p=i;p!==n;p+=r)for(m=a;m!==l;m+=o,u++)d=c[u],_[(m+f*p)*4+0]=d,_[(m+f*p)*4+1]=d,_[(m+f*p)*4+2]=d,_[(m+f*p)*4+3]=255;return _}function qW(s,e,t,i,r,n,a,o,l){let c=t,f=s.width,h=s.height,d=0,u,m,p=new Uint8Array(f*h*4);for(m=i;m!==n;m+=r)for(u=a;u!==l;u+=o,d+=2)p[(u+f*m)*4+0]=c[d+0],p[(u+f*m)*4+1]=c[d+0],p[(u+f*m)*4+2]=c[d+0],p[(u+f*m)*4+3]=c[d+1];return p}var OW,NW,FW,wW,BW,UW,VW,GW,kW,WW,HW,zW,QW,jb=C(()=>{We();OW=1,NW=2,FW=3,wW=9,BW=10,UW=11,VW=48,GW=4,kW=0,WW=1,HW=2,zW=3;QW={GetTGAHeader:Bu,UploadContent:OE,_getImageData8bits:XW,_getImageData16bits:YW,_getImageData24bits:KW,_getImageData32bits:jW,_getImageDataGrey8bits:ZW,_getImageDataGrey16bits:qW}});var Zb={};Ie(Zb,{_TGATextureLoader:()=>NE});var NE,qb=C(()=>{jb();NE=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),n=Bu(r);i(n.width,n.height,t.generateMipMaps,!1,()=>{OE(t,r)})}}});var _h=C(()=>{});function $W(){let s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),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 n=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,n[l]=c|f}for(let l=1024;l<2048;++l)n[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:n,exponentTable:a,offsetTable:o}}function Gu(s,e){let t=new Uint8Array(s),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 ys(s,e){let t=s.getInt32(e.value,!0);return e.value+=4,t}function Nr(s,e){let t=s.getUint32(e.value,!0);return e.value+=4,t}function gh(s,e){let t=s.getUint8(e.value);return e.value+=1,t}function _c(s,e){let t=s.getUint16(e.value,!0);return e.value+=2,t}function wE(s,e){let t=s[e.value];return e.value+=1,t}function $b(s,e){let t;return"getBigInt64"in DataView.prototype?t=Number(s.getBigInt64(e.value,!0)):t=s.getUint32(e.value+4,!0)+Number(s.getUint32(e.value,!0)<<32),e.value+=8,t}function Bi(s,e){let t=s.getFloat32(e.value,!0);return e.value+=4,t}function e0(s,e){return e4(_c(s,e))}function e4(s){let e=(s&31744)>>10,t=s&1023;return(s>>15?-1:1)*(e?e===31?t?NaN:1/0:Math.pow(2,e-15)*(1+t/1024):6103515625e-14*(t/1024))}function t4(s){if(Math.abs(s)>65504)throw new Error("Value out of range.Consider using float instead of half-float.");s=Ye(s,-65504,65504),Uu.floatView[0]=s;let e=Uu.uint32View[0],t=e>>23&511;return Uu.baseTable[t]+((e&8388607)>>Uu.shiftTable[t])}function t0(s,e){return t4(Bi(s,e))}function i4(s,e,t){let i=new TextDecoder().decode(new Uint8Array(s).slice(e.value,e.value+t));return e.value=e.value+t,i}function r4(s,e){let t=ys(s,e),i=Nr(s,e);return[t,i]}function s4(s,e){let t=Nr(s,e),i=Nr(s,e);return[t,i]}function n4(s,e){let t=Bi(s,e),i=Bi(s,e);return[t,i]}function a4(s,e){let t=Bi(s,e),i=Bi(s,e),r=Bi(s,e);return[t,i,r]}function o4(s,e,t){let i=e.value,r=[];for(;e.valuen||(e[r++]=s[t++],r>n));)e[r++]=s[i++]}var nn,FE,Uu,Eh=C(()=>{Mi();_h();(function(s){s[s.NO_COMPRESSION=0]="NO_COMPRESSION",s[s.RLE_COMPRESSION=1]="RLE_COMPRESSION",s[s.ZIPS_COMPRESSION=2]="ZIPS_COMPRESSION",s[s.ZIP_COMPRESSION=3]="ZIP_COMPRESSION",s[s.PIZ_COMPRESSION=4]="PIZ_COMPRESSION",s[s.PXR24_COMPRESSION=5]="PXR24_COMPRESSION"})(nn||(nn={}));(function(s){s[s.INCREASING_Y=0]="INCREASING_Y",s[s.DECREASING_Y=1]="DECREASING_Y"})(FE||(FE={}));Uu=$W()});function VE(s,e){if(s.getUint32(0,!0)!=d4)throw new Error("Incorrect OpenEXR format");let t=s.getUint8(4),i=s.getUint8(5),r={singleTile:!!(i&2),longName:!!(i&4),deepFormat:!!(i&8),multiPart:!!(i&16)};e.value=8;let n={},a=!0;for(;a;){let o=Gu(s.buffer,e);if(!o)a=!1;else{let l=Gu(s.buffer,e),c=Nr(s,e),f=i0(s,e,l,c);f===void 0?X.Warn(`Unknown header attribute type ${l}'.`):n[o]=f}}if((i&-5)!=0)throw new Error("Unsupported file format");return{version:t,spec:r,...n}}var d4,r0=C(()=>{We();Eh();d4=20000630});function h0(s,e){let t=0;for(let r=0;r<65536;++r)(r==0||s[r>>3]&1<<(r&7))&&(e[t++]=r);let i=t-1;for(;t<65536;)e[t++]=0;return i}function _4(s){for(let e=0;e<16384;e++)s[e]={},s[e].len=0,s[e].lit=0,s[e].p=null}function o0(s,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+vh[t]>>1;vh[t]=e,e=i}for(let t=0;t<65537;++t){let i=s[t];i>0&&(s[t]=i|vh[i]++<<6)}}function E4(s,e,t,i,r,n){let a=e,o=0,l=0;for(;i<=r;i++){if(a.value-e.value>t)return;let c=o0(6,o,l,s,a),f=c.l;if(o=c.c,l=c.lc,n[i]=f,f==63){if(a.value-e.value>t)throw new Error("Error in HufUnpackEncTable");c=o0(8,o,l,s,a);let h=c.l+6;if(o=c.c,l=c.lc,i+h>r+1)throw new Error("Error in HufUnpackEncTable");for(;h--;)n[i++]=0;i--}else if(f>=59){let h=f-59+2;if(i+h>r+1)throw new Error("Error in HufUnpackEncTable");for(;h--;)n[i++]=0;i--}}g4(n)}function d0(s){return s&63}function u0(s){return s>>6}function v4(s,e,t,i){for(;e<=t;e++){let r=u0(s[e]),n=d0(s[e]);if(r>>n)throw new Error("Invalid table entry");if(n>14){let a=i[r>>n-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-n)+a];if(l.len||l.p)throw new Error("Invalid table entry");l.len=n,l.lit=e,a++}}}return!0}function S4(s,e,t,i,r,n,a,o,l){let c=0,f=0,h=a,d=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=GE(_.lit,n,c,f,t,i,o,l,h);g&&(c=g.c,f=g.lc)}else{if(!_.p)throw new Error("hufDecode issues");let g;for(g=0;g<_.lit;g++){let v=d0(s[_.p[g]]);for(;f=v&&u0(s[_.p[g]])==(c>>f-v&(1<>=u,f-=u;f>0;){let m=e[c<<14-f&16383];if(m.len){f-=m.len;let p=GE(m.lit,n,c,f,t,i,o,l,h);p&&(c=p.c,f=p.lc)}else throw new Error("HufDecode issues")}return!0}function m0(s,e,t,i,r,n){let a={value:0},o=t.value,l=Nr(e,t),c=Nr(e,t);t.value+=4;let f=Nr(e,t);if(t.value+=4,l<0||l>=65537||c<0||c>=65537)throw new Error("Wrong HUF_ENCSIZE");let h=new Array(65537),d=new Array(16384);_4(d);let u=i-(t.value-o);if(E4(s,t,u,l,c,h),f>8*(i-(t.value-o)))throw new Error("Wrong hufUncompress");v4(h,l,c,d),S4(h,d,s,t,f,c,n,r,a)}function WE(s){return s&65535}function l0(s){let e=WE(s);return e>32767?e-65536:e}function gc(s,e){let t=l0(s),r=l0(e),n=t+(r&1)+(r>>1),a=n,o=n-r;return{a,b:o}}function Ec(s,e){let t=WE(s),i=WE(e),r=t-(i>>1)&a0;return{a:i+r-p4&a0,b:r}}function p0(s,e,t,i,r,n,a){let o=a<16384,l=t>r?r:t,c=1,f,h;for(;c<=l;)c<<=1;for(c>>=1,f=c,c>>=1;c>=1;){h=0;let d=h+n*(r-f),u=n*c,m=n*f,p=i*c,_=i*f,g,v,I,x;for(;h<=d;h+=m){let T=h,A=h+i*(t-f);for(;T<=A;T+=_){let R=T+p,P=T+u,D=P+p;if(o){let M=gc(s[T+e],s[P+e]);g=M.a,I=M.b,M=gc(s[R+e],s[D+e]),v=M.a,x=M.b,M=gc(g,v),s[T+e]=M.a,s[R+e]=M.b,M=gc(I,x),s[P+e]=M.a,s[D+e]=M.b}else{let M=Ec(s[T+e],s[P+e]);g=M.a,I=M.b,M=Ec(s[R+e],s[D+e]),v=M.a,x=M.b,M=Ec(g,v),s[T+e]=M.a,s[R+e]=M.b,M=Ec(I,x),s[P+e]=M.a,s[D+e]=M.b}}if(t&c){let R=T+u,P;o?P=gc(s[T+e],s[R+e]):P=Ec(s[T+e],s[R+e]),g=P.a,s[R+e]=P.b,s[T+e]=g}}if(r&c){let T=h,A=h+i*(t-f);for(;T<=A;T+=_){let R=T+p,P;o?P=gc(s[T+e],s[R+e]):P=Ec(s[T+e],s[R+e]),g=P.a,s[R+e]=P.b,s[T+e]=g}}f=c,c>>=1}return h}function _0(s,e,t){for(let i=0;i{Eh();_h();f0=16,p4=1<0;){let n=r.getInt8(i++);if(n<0){let a=-n;e-=a+1;for(let o=0;o{});function HE(s){return new DataView(s.array.buffer,s.offset.value,s.size)}function T0(s){let e=s.viewer.buffer.slice(s.offset.value,s.offset.value+s.size),t=new Uint8Array(E0(e)),i=new Uint8Array(t.length);return BE(t),UE(t,i),new DataView(i.buffer)}function zE(s){let e=s.array.slice(s.offset.value,s.offset.value+s.size),t=fflate.unzlibSync(e),i=new Uint8Array(t.length);return BE(t),UE(t,i),new DataView(i.buffer)}function A0(s){let e=s.array.slice(s.offset.value,s.offset.value+s.size),t=fflate.unzlibSync(e),i=s.lines*s.channels*s.width,r=s.type==1?new Uint16Array(i):new Uint32Array(i),n=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{g0();v0();Eh();_h()});var ss,an,XE=C(()=>{(function(s){s[s.Float=0]="Float",s[s.HalfFloat=1]="HalfFloat"})(ss||(ss={}));an=class{};an.DefaultOutputType=ss.HalfFloat;an.FFLATEUrl="https://unpkg.com/fflate@0.8.2"});async function YE(s,e,t,i){let r={size:0,viewer:e,array:new Uint8Array(e.buffer),offset:t,width:s.dataWindow.xMax-s.dataWindow.xMin+1,height:s.dataWindow.yMax-s.dataWindow.yMin+1,channels:s.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(s.compression){case nn.NO_COMPRESSION:r.lines=1,r.uncompress=HE;break;case nn.RLE_COMPRESSION:r.lines=1,r.uncompress=T0;break;case nn.ZIPS_COMPRESSION:r.lines=1,r.uncompress=zE,await se.LoadScriptAsync(an.FFLATEUrl);break;case nn.ZIP_COMPRESSION:r.lines=16,r.uncompress=zE,await se.LoadScriptAsync(an.FFLATEUrl);break;case nn.PIZ_COMPRESSION:r.lines=32,r.uncompress=R0;break;case nn.PXR24_COMPRESSION:r.lines=16,r.uncompress=A0,await se.LoadScriptAsync(an.FFLATEUrl);break;default:throw new Error(nn[s.compression]+" is unsupported")}r.scanlineBlockSize=r.lines;let n={};for(let c of s.channels)switch(c.name){case"R":case"G":case"B":case"A":n[c.name]=!0,r.type=c.pixelType;break;case"Y":n[c.name]=!0,r.type=c.pixelType;break;default:break}let a=!1;if(n.R&&n.G&&n.B&&n.A)r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(n.R&&n.G&&n.B)a=!0,r.outputChannels=4,r.decodeChannels={R:0,G:1,B:2,A:3};else if(n.R&&n.G)r.outputChannels=2,r.decodeChannels={R:0,G:1};else if(n.R)r.outputChannels=1,r.decodeChannels={R:0};else if(n.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 ss.Float:r.getter=e0,r.inputSize=2;break;case ss.HalfFloat:r.getter=_c,r.inputSize=2;break}else if(r.type===2)switch(i){case ss.Float:r.getter=Bi,r.inputSize=4;break;case ss.HalfFloat:r.getter=t0,r.inputSize=4}else throw new Error("Unsupported pixelType "+r.type+" for "+s.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 KE(s,e,t,i){let r={value:0};for(let n=0;ns.height?s.height-a:s.scanlineBlockSize;let l=s.size=s.height)continue;let d=c*s.bytesPerLine,u=(s.height-1-h)*s.outLineWidth;for(let m=0;m{Eh();x0();_h();At();XE()});var C0={};Ie(C0,{ReadExrDataAsync:()=>T4,_ExrTextureLoader:()=>jE});async function T4(s){let e=new DataView(s),t={value:0},i=VE(e,t);try{let r=await YE(i,e,t,ss.Float);return KE(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)}:(X.Error("Failed to decode EXR data: No byte array available."),{width:0,height:0,data:null})}catch(r){X.Error("Failed to load EXR data: ",r)}return{width:0,height:0,data:null}}var jE,b0=C(()=>{r0();I0();XE();We();jE=class{constructor(){this.supportCascades=!1}loadCubeData(e,t,i,r,n){throw".exr not supported in Cube."}loadData(e,t,i){let r=new DataView(e.buffer),n={value:0},a=VE(r,n);YE(a,r,n,an.DefaultOutputType).then(o=>{KE(o,a,r,n);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=>{X.Error("Failed to load EXR texture: ",o)})}}});function ta(s,e){A4(s)&&X.Warn(`Extension with the name '${s}' already exists`),Wu.set(s,e)}function A4(s){return Wu.delete(s)}function Hu(s,e){(e==="image/ktx"||e==="image/ktx2")&&(s=".ktx"),Wu.has(s)||(s.endsWith(".ies")&&ta(".ies",async()=>await Promise.resolve().then(()=>(CC(),IC)).then(i=>new i._IESTextureLoader)),s.endsWith(".dds")&&ta(".dds",async()=>await Promise.resolve().then(()=>(MC(),bC)).then(i=>new i._DDSTextureLoader)),s.endsWith(".basis")&&ta(".basis",async()=>await Promise.resolve().then(()=>(NC(),OC)).then(i=>new i._BasisTextureLoader)),s.endsWith(".env")&&ta(".env",async()=>await Promise.resolve().then(()=>(Pb(),Db)).then(i=>new i._ENVTextureLoader)),s.endsWith(".hdr")&&ta(".hdr",async()=>await Promise.resolve().then(()=>(Ub(),Bb)).then(i=>new i._HDRTextureLoader)),(s.endsWith(".ktx")||s.endsWith(".ktx2"))&&(ta(".ktx",async()=>await Promise.resolve().then(()=>(LE(),PE)).then(i=>new i._KTXTextureLoader)),ta(".ktx2",async()=>await Promise.resolve().then(()=>(LE(),PE)).then(i=>new i._KTXTextureLoader))),s.endsWith(".tga")&&ta(".tga",async()=>await Promise.resolve().then(()=>(qb(),Zb)).then(i=>new i._TGATextureLoader)),s.endsWith(".exr")&&ta(".exr",async()=>await Promise.resolve().then(()=>(b0(),C0)).then(i=>new i._ExrTextureLoader)));let t=Wu.get(s);return t?Promise.resolve(t(e)):null}var Wu,ZE=C(()=>{We();Wu=new Map});function M0(s){let e=s.split("?")[0],t=e.lastIndexOf(".");return t>-1?e.substring(t).toLowerCase():""}var y0=C(()=>{});var D0=C(()=>{Dr();We();Wa();rc();ci();ZE();y0();he.prototype._partialLoadFile=function(s,e,t,i,r=null){let n=o=>{t[e]=o,t._internalCount++,t._internalCount===6&&i(t)},a=(o,l)=>{r&&o&&r(o.status+" "+o.statusText,l)};this._loadFile(s,n,void 0,void 0,!0,a)};he.prototype._cascadeLoadFiles=function(s,e,t,i=null){let r=[];r._internalCount=0;for(let n=0;n<6;n++)this._partialLoadFile(t[n],n,r,e,i)};he.prototype._cascadeLoadImgs=function(s,e,t,i,r=null,n){let a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(i[o],o,a,s,e,t,r,n)};he.prototype._partialLoadImg=function(s,e,t,i,r,n,a=null,o){let l=Js();cc(s,h=>{t[e]=h,t._internalCount++,i&&i.removePendingData(l),t._internalCount===6&&n&&n(r,t)},(h,d)=>{i&&i.removePendingData(l),a&&a(h,d)},i?i.offlineProvider:null,o),i&&i.addPendingData(l)};he.prototype.createCubeTextureBase=function(s,e,t,i,r=null,n=null,a,o=null,l=!1,c=0,f=0,h=null,d=null,u=null,m=!1,p=null){let _=h||new Dt(this,7);_.isCube=!0,_.url=s,_.generateMipMaps=!i,_._lodGenerationScale=c,_._lodGenerationOffset=f,_._useSRGBBuffer=!!m&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!i),_!==h&&(_.label=s.substring(0,60)),this._doNotHandleContextLost||(_._extension=o,_._files=t,_._buffer=p);let g=s;this._transformTextureUrl&&!h&&(s=this._transformTextureUrl(s));let v=o!=null?o:M0(s),I=Hu(v),x=(A,R)=>{_.dispose(),n?n(A,R):A&&X.Warn(A)},T=(A,R)=>{s===g?A&&x(A.status+" "+A.statusText,R):(X.Warn(`Failed to load ${s}, falling back to the ${g}`),this.createCubeTextureBase(g,e,t,!!i,r,x,a,o,l,c,f,_,d,u,m,p))};if(I)I.then(A=>{let R=P=>{d&&d(_,P),A.loadCubeData(P,_,l,r,(D,M)=>{x(D,M)})};p?R(p):t&&t.length===6?A.supportCascades?this._cascadeLoadFiles(e,P=>R(P.map(D=>new Uint8Array(D))),t,x):x("Textures type does not support cascades."):this._loadFile(s,P=>R(new Uint8Array(P)),void 0,e?e.offlineProvider||null:void 0,!0,T)});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,_,(A,R)=>{u&&u(A,R)},t,x)}return this._internalTexturesCache.push(_),_}});var K0={};Ie(K0,{DDSTools:()=>Rs});function zu(s){return s.charCodeAt(0)+(s.charCodeAt(1)<<8)+(s.charCodeAt(2)<<16)+(s.charCodeAt(3)<<24)}function x4(s){return String.fromCharCode(s&255,s>>8&255,s>>16&255,s>>24&255)}var R4,P0,L0,O0,N0,F0,w0,B0,U0,qE,V0,G0,k0,W0,I4,QE,C4,b4,H0,z0,JE,X0,$E,Y0,M4,y4,D4,P4,L4,O4,N4,Rs,rE=C(()=>{Mi();We();Lg();vu();D0();R4=542327876,P0=131072,L0=512,O0=4,N0=64,F0=131072;w0=zu("DXT1"),B0=zu("DXT3"),U0=zu("DXT5"),qE=zu("DX10"),V0=113,G0=116,k0=2,W0=10,I4=88,QE=31,C4=0,b4=1,H0=2,z0=3,JE=4,X0=7,$E=20,Y0=21,M4=22,y4=23,D4=24,P4=25,L4=26,O4=28,N4=32,Rs=class s{static GetDDSInfo(e){let t=new Int32Array(e.buffer,e.byteOffset,QE),i=new Int32Array(e.buffer,e.byteOffset,QE+4),r=1;t[H0]&P0&&(r=Math.max(1,t[X0]));let n=t[Y0],a=n===qE?i[N4]:0,o=0;switch(n){case V0:o=2;break;case G0:o=1;break;case qE:if(a===W0){o=2;break}if(a===k0){o=1;break}}return{width:t[JE],height:t[z0],mipmapCount:r,isFourCC:(t[$E]&O0)===O0,isRGB:(t[$E]&N0)===N0,isLuminance:(t[$E]&F0)===F0,isCube:(t[O4]&L0)===L0,isCompressed:n===w0||n===B0||n===U0,dxgiFormat:a,textureType:o}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,i,r,n,a){let o=new Float32Array(r),l=new Uint16Array(n,i),c=0;for(let f=0;f>8)}static _GetRGBArrayBuffer(e,t,i,r,n,a,o,l){let c=new Uint8Array(r),f=new Uint8Array(n,i),h=0;for(let d=0;d0?r.sphericalPolynomial=zn.ConvertCubeMapToSphericalPolynomial({size:d[JE],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}};Rs.StoreLODInAlphaChannel=!1});var j0=C(()=>{ur();Dr();We();Qf();fc();He.prototype.createPrefilteredCubeTexture=function(s,e,t,i,r=null,n=null,a,o=null,l=!0){let c=async f=>{var g;if(!f){r&&r(null);return}let h=f.texture;if(l?f.info.sphericalPolynomial&&(h._sphericalPolynomial=f.info.sphericalPolynomial):h._sphericalPolynomial=(g=h._sphericalPolynomial)!=null?g:new Qs,h._source=9,this.getCaps().textureLOD){r&&r(h);return}let d=3,u=this._gl,m=f.width;if(!m)return;let{DDSTools:p}=await Promise.resolve().then(()=>(rE(),K0)),_=[];for(let v=0;v{ur();Yd();He.prototype.createUniformBuffer=function(s,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");let i=new Ks(t);return this.bindUniformBuffer(i),s instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,s,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(s),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};He.prototype.createDynamicUniformBuffer=function(s,e){let t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");let i=new Ks(t);return this.bindUniformBuffer(i),s instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,s,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(s),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};He.prototype.updateUniformBuffer=function(s,e,t,i){this.bindUniformBuffer(s),t===void 0&&(t=0),i===void 0?e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,e):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,new Float32Array(e)):e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,e.subarray(t,t+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(e).subarray(t,t+i)),this.bindUniformBuffer(null)};He.prototype.bindUniformBuffer=function(s){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,s?s.underlyingResource:null)};He.prototype.bindUniformBufferBase=function(s,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,s?s.underlyingResource:null)};He.prototype.bindUniformBlock=function(s,e,t){let i=s.program,r=this._gl.getUniformBlockIndex(i,e);r!==4294967295&&this._gl.uniformBlockBinding(i,r,t)}});var q0=C(()=>{Pr();ci();he.prototype.displayLoadingUI=function(){if(!Ft())return;let s=this.loadingScreen;s&&s.displayLoadingUI()};he.prototype.hideLoadingUI=function(){if(!Ft())return;let s=this._loadingScreen;s&&s.hideLoadingUI()};Object.defineProperty(he.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=he.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(s){this._loadingScreen=s},enumerable:!0,configurable:!0});Object.defineProperty(he.prototype,"loadingUIText",{set:function(s){this.loadingScreen.loadingUIText=s},enumerable:!0,configurable:!0});Object.defineProperty(he.prototype,"loadingUIBackgroundColor",{set:function(s){this.loadingScreen.loadingUIBackgroundColor=s},enumerable:!0,configurable:!0})});var Q0=C(()=>{ci();he.prototype.getInputElement=function(){return this._renderingCanvas};he.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};he.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};he.prototype.getAspectRatio=function(s,e=!1){let t=s.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};he.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};he.prototype._verifyPointerLock=function(){var s;(s=this._onPointerLockChange)==null||s.call(this)}});var ev=C(()=>{ci();he.prototype.setAlphaEquation=function(s,e=0){if(this._alphaEquation[e]!==s){switch(s){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]=s}}});var J0=C(()=>{ci();ev();he.prototype.getInputElement=function(){return this._renderingCanvas};he.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};he.prototype.setDepthFunction=function(s){this._depthCullingState.depthFunc=s};he.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};he.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};he.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};he.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};he.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};he.prototype.setDepthWrite=function(s){this._depthCullingState.depthMask=s};he.prototype.setAlphaConstants=function(s,e,t,i){this._alphaState.setAlphaBlendConstants(s,e,t,i)};he.prototype.getAlphaMode=function(s=0){return this._alphaMode[s]};he.prototype.getAlphaEquation=function(s=0){return this._alphaEquation[s]}});var $0=C(()=>{ci();ev();he.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};he.prototype.setStencilBuffer=function(s){this._stencilState.stencilTest=s};he.prototype.getStencilMask=function(){return this._stencilState.stencilMask};he.prototype.setStencilMask=function(s){this._stencilState.stencilMask=s};he.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};he.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};he.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};he.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};he.prototype.setStencilFunction=function(s){this._stencilState.stencilFunc=s};he.prototype.setStencilBackFunction=function(s){this._stencilState.stencilBackFunc=s};he.prototype.setStencilFunctionReference=function(s){this._stencilState.stencilFuncRef=s};he.prototype.setStencilFunctionMask=function(s){this._stencilState.stencilFuncMask=s};he.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};he.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};he.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};he.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};he.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};he.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};he.prototype.setStencilOperationFail=function(s){this._stencilState.stencilOpStencilFail=s};he.prototype.setStencilBackOperationFail=function(s){this._stencilState.stencilBackOpStencilFail=s};he.prototype.setStencilOperationDepthFail=function(s){this._stencilState.stencilOpDepthFail=s};he.prototype.setStencilBackOperationDepthFail=function(s){this._stencilState.stencilBackOpDepthFail=s};he.prototype.setStencilOperationPass=function(s){this._stencilState.stencilOpStencilDepthPass=s};he.prototype.setStencilBackOperationPass=function(s){this._stencilState.stencilBackOpStencilDepthPass=s};he.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()};he.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=C(()=>{ci();he.prototype.getRenderPassNames=function(){return this._renderPassNames};he.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};he.prototype.createRenderPassId=function(s){let e=++he._RenderPassIdCounter;return this._renderPassNames[e]=s!=null?s:"NONAME",e};he.prototype.releaseRenderPassId=function(s){this._renderPassNames[s]=void 0;for(let e=0;e{ci();he.prototype._loadFileAsync=async function(s,e,t){return await new Promise((i,r)=>{this._loadFile(s,n=>{i(n)},void 0,e,t,(n,a)=>{r(a)})})}});var iM=C(()=>{ZE();ci();he.GetCompatibleTextureLoader=Hu});function F4(s){!s||!s.setAttribute||(s.setAttribute("touch-action","none"),s.style.touchAction="none",s.style.webkitTapHighlightColor="transparent")}function rM(s,e,t){s._onCanvasFocus=()=>{s.onCanvasFocusObservable.notifyObservers(s)},s._onCanvasBlur=()=>{s.onCanvasBlurObservable.notifyObservers(s)},s._onCanvasContextMenu=r=>{s.disableContextMenu&&r.preventDefault()},e.addEventListener("focus",s._onCanvasFocus),e.addEventListener("blur",s._onCanvasBlur),e.addEventListener("contextmenu",s._onCanvasContextMenu),s._onBlur=()=>{s.disablePerformanceMonitorInBackground&&s.performanceMonitor.disable(),s._windowIsBackground=!0},s._onFocus=()=>{s.disablePerformanceMonitorInBackground&&s.performanceMonitor.enable(),s._windowIsBackground=!1},s._onCanvasPointerOut=r=>{document.elementFromPoint(r.clientX,r.clientY)!==e&&s.onCanvasPointerOutObservable.notifyObservers(r)};let i=s.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",s._onBlur),i.addEventListener("focus",s._onFocus)),e.addEventListener("pointerout",s._onCanvasPointerOut),t.doNotHandleTouchAction||F4(e),!he.audioEngine&&t.audioEngine&&he.AudioEngineFactory&&(he.audioEngine=he.AudioEngineFactory(s.getRenderingCanvas(),s.getAudioContext(),s.getAudioDestination())),Fa()&&(s._onFullscreenChange=()=>{s.isFullscreen=!!document.fullscreenElement,s.isFullscreen&&s._pointerLockRequested&&e&&tv(e)},document.addEventListener("fullscreenchange",s._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",s._onFullscreenChange,!1),s._onPointerLockChange=()=>{s.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",s._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",s._onPointerLockChange,!1)),s.enableOfflineSupport=he.OfflineProviderFactory!==void 0,s._deterministicLockstep=!!t.deterministicLockstep,s._lockstepMaxSteps=t.lockstepMaxSteps||0,s._timeStep=t.timeStep||1/60}function sM(s,e){ue.Instances.length===1&&he.audioEngine&&(he.audioEngine.dispose(),he.audioEngine=null);let t=s.getHostWindow();t&&typeof t.removeEventListener=="function"&&(t.removeEventListener("blur",s._onBlur),t.removeEventListener("focus",s._onFocus)),e&&(e.removeEventListener("focus",s._onCanvasFocus),e.removeEventListener("blur",s._onCanvasBlur),e.removeEventListener("pointerout",s._onCanvasPointerOut),e.removeEventListener("contextmenu",s._onCanvasContextMenu)),Fa()&&(document.removeEventListener("fullscreenchange",s._onFullscreenChange),document.removeEventListener("mozfullscreenchange",s._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",s._onFullscreenChange),document.removeEventListener("msfullscreenchange",s._onFullscreenChange),document.removeEventListener("pointerlockchange",s._onPointerLockChange),document.removeEventListener("mspointerlockchange",s._onPointerLockChange),document.removeEventListener("mozpointerlockchange",s._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",s._onPointerLockChange))}function nM(s){let e=document.createElement("span");e.textContent="Hg",e.style.font=s;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,n;try{n=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:n,descent:n-r}}async function aM(s,e,t){return await new Promise((i,r)=>{let n=new Image;n.onload=()=>{n.decode().then(()=>{s.createImageBitmap(n,t).then(a=>{i(a)})})},n.onerror=()=>{r(`Error loading image ${n.src}`)},n.src=e})}function oM(s,e,t,i){let n=s.createCanvas(t,i).getContext("2d");if(!n)throw new Error("Unable to get 2d context for resizeImageBitmap");return n.drawImage(e,0,0),n.getImageData(0,0,t,i).data}function lM(s){let e=s.requestFullscreen||s.webkitRequestFullscreen;e&&e.call(s)}function cM(){let s=document;document.exitFullscreen?document.exitFullscreen():s.webkitCancelFullScreen&&s.webkitCancelFullScreen()}function tv(s){if(s.requestPointerLock){let e=s.requestPointerLock();e instanceof Promise?e.then(()=>{s.focus()}).catch(()=>{}):s.focus()}}function fM(){document.exitPointerLock&&document.exitPointerLock()}var hM=C(()=>{Pr();ci();gt()});var ve,Xu=C(()=>{Dr();gt();ur();hI();Yd();We();mg();dI();_I();gI();EI();vI();AI();RI();xI();j0();Z0();q0();Q0();J0();$0();eM();Eg();tM();iM();ci();hM();mE();Ys();ve=class s extends He{static get NpmPackage(){return he.NpmPackage}static get Version(){return he.Version}static get Instances(){return ue.Instances}static get LastCreatedEngine(){return ue.LastCreatedEngine}static get LastCreatedScene(){return ue.LastCreatedScene}static DefaultLoadingScreenFactory(e){return he.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!s._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 jd,this._drawCalls=new sn,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 n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),n}scissorClear(e,t,i,r,n){this.enableScissor(e,t,i,r),this.clear(n,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,r){let n=this._gl;n.enable(n.SCISSOR_TEST),n.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 nM(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&&tv(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,n,a=null){n=n||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);let o=super.createShaderProgram(e,t,i,r,n,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,r,n=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&&n){let o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(a,n),e.transformFeedback=o}return r.linkProgram(a),this.webGLVersion>1&&n&&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,n){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);let a=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&s._RescalePostProcessFactory&&(this._rescalePostProcess=s._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(),n&&n()},l=this._rescalePostProcess.getEffect();l?l.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(c=>{c.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,r=0,n=0){let a=new Hl(e,this._gl),o=new Dt(this,0,!0);return o._hardwareTexture=a,o.baseWidth=r,o.baseHeight=n,o.width=r,o.height=n,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,r=0){let n=this._gl,a=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),l=this._getRGBABufferInternalSizedFormat(e.type,o),c=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);let f=n.TEXTURE_2D;e.isCube&&(f=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(f,r,l,o,a,t),this._bindTextureDirectly(c,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){X.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 Ks(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((n,a)=>{Xs(()=>{let o=r.clientWaitSync(e,t,0);if(o==r.WAIT_FAILED)throw new Error("clientWaitSync failed");return o!=r.TIMEOUT_EXPIRED},n,a,i)})}_readPixelsAsync(e,t,i,r,n,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,n,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(),sM(this,this._renderingCanvas),super.dispose()}};ve.ALPHA_DISABLE=0;ve.ALPHA_ADD=1;ve.ALPHA_COMBINE=2;ve.ALPHA_SUBTRACT=3;ve.ALPHA_MULTIPLY=4;ve.ALPHA_MAXIMIZED=5;ve.ALPHA_ONEONE=6;ve.ALPHA_PREMULTIPLIED=7;ve.ALPHA_PREMULTIPLIED_PORTERDUFF=8;ve.ALPHA_INTERPOLATE=9;ve.ALPHA_SCREENMODE=10;ve.DELAYLOADSTATE_NONE=0;ve.DELAYLOADSTATE_LOADED=1;ve.DELAYLOADSTATE_LOADING=2;ve.DELAYLOADSTATE_NOTLOADED=4;ve.NEVER=512;ve.ALWAYS=519;ve.LESS=513;ve.EQUAL=514;ve.LEQUAL=515;ve.GREATER=516;ve.GEQUAL=518;ve.NOTEQUAL=517;ve.KEEP=7680;ve.REPLACE=7681;ve.INCR=7682;ve.DECR=7683;ve.INVERT=5386;ve.INCR_WRAP=34055;ve.DECR_WRAP=34056;ve.TEXTURE_CLAMP_ADDRESSMODE=0;ve.TEXTURE_WRAP_ADDRESSMODE=1;ve.TEXTURE_MIRROR_ADDRESSMODE=2;ve.TEXTUREFORMAT_ALPHA=0;ve.TEXTUREFORMAT_LUMINANCE=1;ve.TEXTUREFORMAT_LUMINANCE_ALPHA=2;ve.TEXTUREFORMAT_RGB=4;ve.TEXTUREFORMAT_RGBA=5;ve.TEXTUREFORMAT_RED=6;ve.TEXTUREFORMAT_R=6;ve.TEXTUREFORMAT_R16_UNORM=33322;ve.TEXTUREFORMAT_RG16_UNORM=33324;ve.TEXTUREFORMAT_RGB16_UNORM=32852;ve.TEXTUREFORMAT_RGBA16_UNORM=32859;ve.TEXTUREFORMAT_R16_SNORM=36760;ve.TEXTUREFORMAT_RG16_SNORM=36761;ve.TEXTUREFORMAT_RGB16_SNORM=36762;ve.TEXTUREFORMAT_RGBA16_SNORM=36763;ve.TEXTUREFORMAT_RG=7;ve.TEXTUREFORMAT_RED_INTEGER=8;ve.TEXTUREFORMAT_R_INTEGER=8;ve.TEXTUREFORMAT_RG_INTEGER=9;ve.TEXTUREFORMAT_RGB_INTEGER=10;ve.TEXTUREFORMAT_RGBA_INTEGER=11;ve.TEXTURETYPE_UNSIGNED_BYTE=0;ve.TEXTURETYPE_UNSIGNED_INT=0;ve.TEXTURETYPE_FLOAT=1;ve.TEXTURETYPE_HALF_FLOAT=2;ve.TEXTURETYPE_BYTE=3;ve.TEXTURETYPE_SHORT=4;ve.TEXTURETYPE_UNSIGNED_SHORT=5;ve.TEXTURETYPE_INT=6;ve.TEXTURETYPE_UNSIGNED_INTEGER=7;ve.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;ve.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;ve.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;ve.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;ve.TEXTURETYPE_UNSIGNED_INT_24_8=12;ve.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;ve.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;ve.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;ve.TEXTURE_NEAREST_SAMPLINGMODE=1;ve.TEXTURE_BILINEAR_SAMPLINGMODE=2;ve.TEXTURE_TRILINEAR_SAMPLINGMODE=3;ve.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;ve.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;ve.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;ve.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;ve.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;ve.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;ve.TEXTURE_NEAREST_LINEAR=7;ve.TEXTURE_NEAREST_NEAREST=1;ve.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;ve.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;ve.TEXTURE_LINEAR_LINEAR=2;ve.TEXTURE_LINEAR_NEAREST=12;ve.TEXTURE_EXPLICIT_MODE=0;ve.TEXTURE_SPHERICAL_MODE=1;ve.TEXTURE_PLANAR_MODE=2;ve.TEXTURE_CUBIC_MODE=3;ve.TEXTURE_PROJECTION_MODE=4;ve.TEXTURE_SKYBOX_MODE=5;ve.TEXTURE_INVCUBIC_MODE=6;ve.TEXTURE_EQUIRECTANGULAR_MODE=7;ve.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;ve.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;ve.SCALEMODE_FLOOR=1;ve.SCALEMODE_NEAREST=2;ve.SCALEMODE_CEILING=3});var iv,pt,Fr=C(()=>{$e();Ee();Qe();dt();gt();Ci();jt();iv=class{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new Q,this._onClonedObservable=new Q,this._inheritVisibility=!1,this._isVisible=!0}},pt=class s{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,r){let n=this._NodeConstructors[e];return n?n(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 iv,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new Q,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=H.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new Q,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 s(e,this.getScene()),this);if(t&&(r.parent=t),!i){let n=this.getDescendants(!0);for(let a=0;a{throw Ce("AnimationRange")};pt._NodeConstructors={};b([L()],pt.prototype,"name",void 0);b([L()],pt.prototype,"id",void 0);b([L()],pt.prototype,"uniqueId",void 0);b([L()],pt.prototype,"state",void 0);b([L()],pt.prototype,"metadata",void 0)});function rv(s,e,t){try{let i=s.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function Qa(s=25){let e;return(t,i,r)=>{let n=performance.now();e===void 0||n-e>s?(e=n,setTimeout(()=>{rv(t,i,r)},0)):rv(t,i,r)}}function dM(s,e,t,i,r){let n=()=>{let a,o=l=>{l.done?t(l.value):a===void 0?a=!0:n()};do a=void 0,!r||!r.aborted?e(s,o,i):i(new Error("Aborted")),a===void 0&&(a=!1);while(a)};n()}function cl(s,e){let t;return dM(s,rv,i=>t=i,i=>{throw i},e),t}async function Ja(s,e,t){return await new Promise((i,r)=>{dM(s,e,i,r,t)})}function uM(s,e){return(...t)=>cl(s(...t),e)}var Th=C(()=>{});var we,Ds=C(()=>{$e();Qe();As();At();dt();Ee();Fr();We();Pt();Ci();$l();$d();jt();we=class s extends pt{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,n,a;let e,t;if(this.mode===s.PERSPECTIVE_CAMERA)this.fovMode===s.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=((n=this.orthoTop)!=null?n: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=S.Zero(),this._upVector=S.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=s.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new Ss(0,0,1,1),this.layerMask=268435455,this.fovMode=s.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=s.RIG_MODE_NONE,this.ignoreCameraMaxZ=!1,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new Q,this.onProjectionMatrixChangedObservable=new Q,this.onAfterCheckInputsObservable=new Q,this.onRestoreStateObservable=new Q,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new H,this._postProcesses=new Array,this._activeMeshes=new yt(256),this._globalPosition=S.Zero(),this._computedViewMatrix=H.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=H.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=Se.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?(X.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 H.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,h,d,u,m,p,_,g,v,I,x,T,A,R,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(),n=i.useReverseDepthBuffer;if(this.mode===s.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 D;r.useRightHandedSystem?D=H.PerspectiveFovRHToRef:D=H.PerspectiveFovLHToRef,D(this.fov,i.getAspectRatio(this),n?t:this.minZ,n?this.minZ:t,this._projectionMatrix,this.fovMode===s.FOVMODE_VERTICAL_FIXED,i.isNDCHalfZRange,this.projectionPlaneTilt,n)}else{let D=i.getRenderWidth()/2,M=i.getRenderHeight()/2;r.useRightHandedSystem?this.oblique?H.ObliqueOffCenterRHToRef((a=this.orthoLeft)!=null?a:-D,(o=this.orthoRight)!=null?o:D,(l=this.orthoBottom)!=null?l:-M,(c=this.orthoTop)!=null?c:M,n?t:this.minZ,n?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):H.OrthoOffCenterRHToRef((f=this.orthoLeft)!=null?f:-D,(h=this.orthoRight)!=null?h:D,(d=this.orthoBottom)!=null?d:-M,(u=this.orthoTop)!=null?u:M,n?t:this.minZ,n?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange):this.oblique?H.ObliqueOffCenterLHToRef((m=this.orthoLeft)!=null?m:-D,(p=this.orthoRight)!=null?p:D,(_=this.orthoBottom)!=null?_:-M,(g=this.orthoTop)!=null?g:M,n?t:this.minZ,n?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):H.OrthoOffCenterLHToRef((v=this.orthoLeft)!=null?v:-D,(I=this.orthoRight)!=null?I:D,(x=this.orthoBottom)!=null?x:-M,(T=this.orthoTop)!=null?T:M,n?t:this.minZ,n?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=(A=this.oblique)==null?void 0:A.angle,this._cache.obliqueLength=(R=this.oblique)==null?void 0:R.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?S.Distance(this.position,i.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Ua.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Ua.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 Ce("Ray")}getForwardRayToRef(e,t=100,i,r){throw Ce("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!==s.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let r=this._postProcesses.length;for(;--r>=0;){let n=this._postProcesses[r];n&&n.dispose(this)}}let i=this.customRenderTargets.length;for(;--i>=0;)this.customRenderTargets[i].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){let i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=se.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==s.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 H.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=se.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;es._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){let i=e.type,r=s.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),n=De.Parse(r,e,t);if(e.parentId!==void 0&&(n._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(n._waitingParentInstanceIndex=e.parentInstanceIndex),n.inputs&&(n.inputs.parse(e),n._setupInputs()),e.upVector&&(n.upVector=S.FromArray(e.upVector)),n.setPosition&&(n.position.copyFromFloats(0,0,0),n.setPosition(S.FromArray(e.position))),e.target&&n.setTarget&&n.setTarget(S.FromArray(e.target)),e.cameraRigMode){let a=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};n.setCameraRigMode(e.cameraRigMode,a)}if(e.animations){for(let a=0;a{throw Ce("UniversalCamera")};we.PERSPECTIVE_CAMERA=0;we.ORTHOGRAPHIC_CAMERA=1;we.FOVMODE_VERTICAL_FIXED=0;we.FOVMODE_HORIZONTAL_FIXED=1;we.RIG_MODE_NONE=0;we.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;we.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;we.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;we.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;we.RIG_MODE_STEREOSCOPIC_INTERLACED=14;we.RIG_MODE_VR=20;we.RIG_MODE_CUSTOM=22;we.ForceAttachControlToAlwaysPreventDefault=!1;b([ui("position")],we.prototype,"_position",void 0);b([ui("upVector")],we.prototype,"_upVector",void 0);b([L()],we.prototype,"orthoLeft",null);b([L()],we.prototype,"orthoRight",null);b([L()],we.prototype,"orthoBottom",null);b([L()],we.prototype,"orthoTop",null);b([L()],we.prototype,"fov",void 0);b([L()],we.prototype,"projectionPlaneTilt",void 0);b([L()],we.prototype,"minZ",void 0);b([L()],we.prototype,"maxZ",void 0);b([L()],we.prototype,"inertia",void 0);b([L()],we.prototype,"mode",null);b([L()],we.prototype,"layerMask",void 0);b([L()],we.prototype,"fovMode",void 0);b([L()],we.prototype,"cameraRigMode",void 0);b([L()],we.prototype,"interaxialDistance",void 0);b([L()],we.prototype,"isStereoscopicSideBySide",void 0);b([L()],we.prototype,"ignoreCameraMaxZ",void 0)});var fl,sv=C(()=>{fl=class{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}});var $a,nv=C(()=>{Zs();Ee();Wi();$a=class s{constructor(e,t,i){this.vectors=bi(8,S.Zero),this.center=S.Zero(),this.centerWorld=S.Zero(),this.extendSize=S.Zero(),this.extendSizeWorld=S.Zero(),this.directions=bi(3,S.Zero),this.vectorsWorld=bi(8,S.Zero),this.minimumWorld=S.Zero(),this.maximumWorld=S.Zero(),this.minimum=S.Zero(),this.maximum=S.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){let r=e.x,n=e.y,a=e.z,o=t.x,l=t.y,c=t.z,f=this.vectors;this.minimum.copyFromFloats(r,n,a),this.maximum.copyFromFloats(o,l,c),f[0].copyFromFloats(r,n,a),f[1].copyFromFloats(o,l,c),f[2].copyFromFloats(o,n,a),f[3].copyFromFloats(r,l,a),f[4].copyFromFloats(r,n,c),f[5].copyFromFloats(o,l,a),f[6].copyFromFloats(r,l,c),f[7].copyFromFloats(o,n,c),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||H.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){let t=s._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),r=i.length();i.normalizeFromLength(r);let n=r*e,a=i.scaleInPlace(n*.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,n=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)n[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=n[o];S.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)}S.FromArrayToRef(e.m,0,r[0]),S.FromArrayToRef(e.m,4,r[1]),S.FromArrayToRef(e.m,8,r[2]),this._worldMatrix=e}isInFrustum(e){return s.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return s.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){let t=this.minimumWorld,i=this.maximumWorld,r=t.x,n=t.y,a=t.z,o=i.x,l=i.y,c=i.z,f=e.x,h=e.y,d=e.z,u=-je;return!(o-ff-r||l-hh-n||c-dd-a)}intersectsSphere(e){return s.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){let i=this.minimumWorld,r=this.maximumWorld,n=i.x,a=i.y,o=i.z,l=r.x,c=r.y,f=r.z,h=e.x,d=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 n=s._TmpVector3[0];return S.ClampToRef(i,e,t,n),S.DistanceSquared(i,n)<=r*r}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){let r=t[i];for(let n=0;n<8;++n)if(r.dotCoordinate(e[n])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let r=!0,n=t[i];for(let a=0;a<8;++a)if(n.dotCoordinate(e[a])>=0){r=!1;break}if(r)return!1}return!0}};$a._TmpVector3=bi(3,S.Zero)});var vc,mM=C(()=>{Zs();Ee();vc=class s{constructor(e,t,i){this.center=S.Zero(),this.centerWorld=S.Zero(),this.minimum=S.Zero(),this.maximum=S.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);let r=S.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=r*.5,this._update(i||H.IdentityReadOnly)}scale(e){let t=this.radius*e,i=s._TmpVector3,r=i[0].setAll(t),n=this.center.subtractToRef(r,i[1]),a=this.center.addToRef(r,i[2]);return this.reConstruct(n,a,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{S.TransformCoordinatesToRef(this.center,e,this.centerWorld);let t=s._TmpVector3[0];S.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=S.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld{Zs();Ee();nv();mM();av={min:0,max:0},ov={min:0,max:0},pM=(s,e,t)=>{let i=S.Dot(e.centerWorld,s),r=Math.abs(S.Dot(e.directions[0],s))*e.extendSize.x,n=Math.abs(S.Dot(e.directions[1],s))*e.extendSize.y,a=Math.abs(S.Dot(e.directions[2],s))*e.extendSize.z,o=r+n+a;t.min=i-o,t.max=i+o},ir=(s,e,t)=>(pM(s,e,av),pM(s,t,ov),!(av.min>ov.max||ov.min>av.max)),ei=class s{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new $a(e,t,i),this.boundingSphere=new vc(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=s._TmpVector3[0].copyFrom(e).subtractInPlace(t),r=s._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=S.Minimize(this.minimum,e),i=S.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){let t=W.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);let i=W.Vector3[0];return S.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),S.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,s._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(!vc.Intersects(this.boundingSphere,e.boundingSphere)||!$a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;let i=this.boundingBox,r=e.boundingBox;return!(!ir(i.directions[0],i,r)||!ir(i.directions[1],i,r)||!ir(i.directions[2],i,r)||!ir(r.directions[0],i,r)||!ir(r.directions[1],i,r)||!ir(r.directions[2],i,r)||!ir(S.Cross(i.directions[0],r.directions[0]),i,r)||!ir(S.Cross(i.directions[0],r.directions[1]),i,r)||!ir(S.Cross(i.directions[0],r.directions[2]),i,r)||!ir(S.Cross(i.directions[1],r.directions[0]),i,r)||!ir(S.Cross(i.directions[1],r.directions[1]),i,r)||!ir(S.Cross(i.directions[1],r.directions[2]),i,r)||!ir(S.Cross(i.directions[2],r.directions[0]),i,r)||!ir(S.Cross(i.directions[2],r.directions[1]),i,r)||!ir(S.Cross(i.directions[2],r.directions[2]),i,r))}};ei._TmpVector3=bi(2,S.Zero)});function _M(s,e,t,i,r=null){let n=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new S(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Sc.extractMinAndMaxIndexed(s,e,t,i,n,a),r&&(n.x-=n.x*r.x+r.y,n.y-=n.y*r.x+r.y,n.z-=n.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:n,maximum:a}}function Yu(s,e,t,i=null,r){let n=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new S(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return r||(r=3),Sc.extractMinAndMax(s,e,t,r,n,a),i&&(n.x-=n.x*i.x+i.y,n.y-=n.y*i.x+i.y,n.z-=n.z*i.x+i.y,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:n,maximum:a}}var Sc,Ku=C(()=>{$e();Ee();Qe();Sc=class{static extractMinAndMaxIndexed(e,t,i,r,n,a){for(let o=i;o!Array.isArray(s[0])&&!Array.isArray(s[1]))],Sc,"extractMinAndMaxIndexed",null);b([_r.filter((...s)=>!Array.isArray(s[0]))],Sc,"extractMinAndMax",null)});var zi,Tc=C(()=>{It();sv();eo();Ku();Ya();zi=class s{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 yi(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 n=this._drawWrapper;n.setEffect(e,t,r),i!==void 0&&(n.materialContext=i),e||(n.defines=null,n.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(let i of this._drawWrappers)i==null||i.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,r,n,a,o,l=!0){return new s(e,t,i,r,n,a,o,l)}constructor(e,t,i,r,n,a,o,l=!0,c=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=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(y.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=_M(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new ei(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,n=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i),a=0;if(e.length===0)for(let o=this.indexStart;ol&&(l=d)}return new s(e,o,l-o+1,t,i,r,n,a)}}});var Ah,fe,Bt=C(()=>{$e();Ee();It();Ci();Je();We();Qe();Th();Jf();Tc();Ah=class{},fe=class s{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=uM(this._applyToCoroutine.bind(this)),this.uniqueId=s._UniqueIdGenerator,s._UniqueIdGenerator++}set(e,t){switch(e.length||X.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case y.PositionKind:this.positions=e;break;case y.NormalKind:this.normals=e;break;case y.TangentKind:this.tangents=e;break;case y.UVKind:this.uvs=e;break;case y.UV2Kind:this.uvs2=e;break;case y.UV3Kind:this.uvs3=e;break;case y.UV4Kind:this.uvs4=e;break;case y.UV5Kind:this.uvs5=e;break;case y.UV6Kind:this.uvs6=e;break;case y.ColorKind:this.colors=e;break;case y.MatricesIndicesKind:this.matricesIndices=e;break;case y.MatricesWeightsKind:this.matricesWeights=e;break;case y.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case y.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(y.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(y.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(y.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(y.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(y.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(y.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(y.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(y.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(y.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){let r=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(y.ColorKind,this.colors,t,r),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(y.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(y.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(y.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(y.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 n of this.materialInfos)new zi(n.materialIndex,n.verticesStart,n.verticesCount,n.indexStart,n.indexCount,r)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(y.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(y.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(y.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(y.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(y.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(y.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(y.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(y.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(y.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(y.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(y.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(y.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(y.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(y.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,r=e.length){let n=W.Vector3[0],a=W.Vector3[1];for(let o=i;o({vertexData:o})):[{vertexData:e}];return cl(this._mergeCoroutine(void 0,a,t,!1,i,r,n))}*_mergeCoroutine(e,t,i=!1,r,n,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,v=0,I=0,x=[],T=null,A=[];for(let P of this.splitBasedOnMaterialID())A.push({vertexData:P,transform:e});for(let P of t)if(P.vertexData)for(let D of P.vertexData.splitBasedOnMaterialID())A.push({vertexData:D,transform:P.transform});A.sort((P,D)=>{let M=P.vertexData.materialInfos?P.vertexData.materialInfos[0].materialIndex:0,F=D.vertexData.materialInfos?D.vertexData.materialInfos[0].materialIndex:0;return M>F?1:M===F?0:-1});for(let P of A){let D=P.vertexData;if(D.materialInfos?g=D.materialInfos[0].materialIndex:g=0,T&&T.materialIndex===g)T.indexCount+=D.indices.length,T.verticesCount+=D.positions.length/3;else{let M=new Ah;M.materialIndex=g,M.indexStart=v,M.indexCount=D.indices.length,M.verticesStart=I,M.verticesCount=D.positions.length/3,x.push(M),T=M}v+=D.indices.length,I+=D.positions.length/3}let R=A.splice(0,1)[0];c=R.vertexData,e=R.transform,l=A.map(P=>P.vertexData),t=A,this.materialInfos=x}let f=l.reduce((g,v)=>{var I,x;return g+((x=(I=v.indices)==null?void 0:I.length)!=null?x:0)},(m=(u=c.indices)==null?void 0:u.length)!=null?m:0),d=n||l.some(g=>g.indices===c.indices)?(p=c.indices)==null?void 0:p.slice():c.indices;if(f>0){let g=(_=d==null?void 0:d.length)!=null?_:0;if(d||(d=new Array(f)),d.length!==f){if(Array.isArray(d))d.length=f;else{let I=i||d instanceof Uint32Array?new Uint32Array(f):new Uint16Array(f);I.set(d),d=I}e&&e.determinant()<0&&s._FlipFaces(d,0,g)}let v=c.positions?c.positions.length/3:0;for(let{vertexData:I,transform:x}of t)if(I.indices){for(let T=0;T[g.vertexData.positions,g.transform])),r&&(yield),c.normals&&(this.normals=s._MergeElement(y.NormalKind,c.normals,e,t.map(g=>[g.vertexData.normals,g.transform])),r&&(yield)),c.tangents&&(this.tangents=s._MergeElement(y.TangentKind,c.tangents,e,t.map(g=>[g.vertexData.tangents,g.transform])),r&&(yield)),c.uvs&&(this.uvs=s._MergeElement(y.UVKind,c.uvs,e,t.map(g=>[g.vertexData.uvs,g.transform])),r&&(yield)),c.uvs2&&(this.uvs2=s._MergeElement(y.UV2Kind,c.uvs2,e,t.map(g=>[g.vertexData.uvs2,g.transform])),r&&(yield)),c.uvs3&&(this.uvs3=s._MergeElement(y.UV3Kind,c.uvs3,e,t.map(g=>[g.vertexData.uvs3,g.transform])),r&&(yield)),c.uvs4&&(this.uvs4=s._MergeElement(y.UV4Kind,c.uvs4,e,t.map(g=>[g.vertexData.uvs4,g.transform])),r&&(yield)),c.uvs5&&(this.uvs5=s._MergeElement(y.UV5Kind,c.uvs5,e,t.map(g=>[g.vertexData.uvs5,g.transform])),r&&(yield)),c.uvs6&&(this.uvs6=s._MergeElement(y.UV6Kind,c.uvs6,e,t.map(g=>[g.vertexData.uvs6,g.transform])),r&&(yield)),c.colors&&(this.colors=s._MergeElement(y.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=s._MergeElement(y.MatricesIndicesKind,c.matricesIndices,e,t.map(g=>[g.vertexData.matricesIndices,g.transform])),r&&(yield)),c.matricesWeights&&(this.matricesWeights=s._MergeElement(y.MatricesWeightsKind,c.matricesWeights,e,t.map(g=>[g.vertexData.matricesWeights,g.transform])),r&&(yield)),c.matricesIndicesExtra&&(this.matricesIndicesExtra=s._MergeElement(y.MatricesIndicesExtraKind,c.matricesIndicesExtra,e,t.map(g=>[g.vertexData.matricesIndicesExtra,g.transform])),r&&(yield)),c.matricesWeightsExtra&&(this.matricesWeightsExtra=s._MergeElement(y.MatricesWeightsExtraKind,c.matricesWeightsExtra,e,t.map(g=>[g.vertexData.matricesWeightsExtra,g.transform]))),this}static _MergeElement(e,t,i,r){let n=r.filter(l=>l[0]!==null&&l[0]!==void 0);if(!t&&n.length==0)return t;if(!t)return this._MergeElement(e,n[0][0],n[0][1],n.slice(1));let a=n.reduce((l,c)=>l+c[0].length,t.length),o=e===y.PositionKind?s._TransformVector3Coordinates:e===y.NormalKind?s._TransformVector3Normals:e===y.TangentKind?s._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,h]of n)l.set(f,c),h&&o(l,h,c,f.length),c+=f.length;return l}else{let l=new Array(a);for(let f=0;f{let a=y.DeduceStride(r);if(n.length%a!==0)throw new Error("The "+r+"s array count must be a multiple of "+a);return n.length/a},t=e(y.PositionKind,this.positions),i=(r,n)=>{let a=e(r,n);if(a!==t)throw new Error("The "+r+"s element count ("+a+") does not match the positions count ("+t+")")};this.normals&&i(y.NormalKind,this.normals),this.tangents&&i(y.TangentKind,this.tangents),this.uvs&&i(y.UVKind,this.uvs),this.uvs2&&i(y.UV2Kind,this.uvs2),this.uvs3&&i(y.UV3Kind,this.uvs3),this.uvs4&&i(y.UV4Kind,this.uvs4),this.uvs5&&i(y.UV5Kind,this.uvs5),this.uvs6&&i(y.UV6Kind,this.uvs6),this.colors&&i(y.ColorKind,this.colors),this.matricesIndices&&i(y.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(y.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(y.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(y.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){let e=this.serialize();return s.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 s._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return s._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){let r=new s;if(e.isVerticesDataPresent(y.PositionKind)&&(r.positions=e.getVerticesData(y.PositionKind,t,i)),e.isVerticesDataPresent(y.NormalKind)&&(r.normals=e.getVerticesData(y.NormalKind,t,i)),e.isVerticesDataPresent(y.TangentKind)&&(r.tangents=e.getVerticesData(y.TangentKind,t,i)),e.isVerticesDataPresent(y.UVKind)&&(r.uvs=e.getVerticesData(y.UVKind,t,i)),e.isVerticesDataPresent(y.UV2Kind)&&(r.uvs2=e.getVerticesData(y.UV2Kind,t,i)),e.isVerticesDataPresent(y.UV3Kind)&&(r.uvs3=e.getVerticesData(y.UV3Kind,t,i)),e.isVerticesDataPresent(y.UV4Kind)&&(r.uvs4=e.getVerticesData(y.UV4Kind,t,i)),e.isVerticesDataPresent(y.UV5Kind)&&(r.uvs5=e.getVerticesData(y.UV5Kind,t,i)),e.isVerticesDataPresent(y.UV6Kind)&&(r.uvs6=e.getVerticesData(y.UV6Kind,t,i)),e.isVerticesDataPresent(y.ColorKind)){let n=e.geometry||e,a=n.getVertexBuffer(y.ColorKind),o=n.getVerticesData(y.ColorKind,t,i);if(a.getSize()===3){let l=new Float32Array(o.length*4/3);for(let c=0,f=0;c!Array.isArray(s[0]))],fe,"_TransformVector3Coordinates",null);b([_r.filter((...s)=>!Array.isArray(s[0]))],fe,"_TransformVector3Normals",null);b([_r.filter((...s)=>!Array.isArray(s[0]))],fe,"_TransformVector4Normals",null);b([_r.filter((...s)=>!Array.isArray(s[0]))],fe,"_FlipFaces",null)});var gi,ju=C(()=>{gi=class s{static get ForceFullSceneLoadingForIncremental(){return s._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){s._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return s._ShowLoadingScreen}static set ShowLoadingScreen(e){s._ShowLoadingScreen=e}static get loggingLevel(){return s._LoggingLevel}static set loggingLevel(e){s._LoggingLevel=e}static get CleanBoneMatrixWeights(){return s._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){s._CleanBoneMatrixWeights=e}};gi._ForceFullSceneLoadingForIncremental=!1;gi._ShowLoadingScreen=!0;gi._CleanBoneMatrixWeights=!1;gi._LoggingLevel=0});var Di,Zu=C(()=>{Ee();Je();Bt();It();Tc();ju();eo();At();Ha();Ku();gt();vi();oc();Di=class s{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 s(s.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,r=!1,n=null,a=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new S(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new S(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={}),n&&(this.applyToMesh(n),n.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return this.delayLoadState===1||this.delayLoadState===0}get doNotSerialize(){for(let e=0;e{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 n=new y(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:r,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(n)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){let r=e.getKind();this._vertexBuffers[r]&&i&&this._vertexBuffers[r].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[r]=e;let n=this._meshes,a=n.length;if(r===y.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 S(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=this._extend&&this._extend.maximum||new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let c=0;c65535:e.is32Bits=r;for(let n of this._meshes)n._createGlobalSubMesh(!0),n.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 n of this._meshes)n._createGlobalSubMesh(!r),n.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?this._totalIndices!==void 0?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;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(y.PositionKind),!e))return;this._extend=Yu(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===y.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,n=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 s(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let r=!1,n;for(n in this._vertexBuffers){let a=this.getVertexBuffer(n),o=a.getData();if(!o)continue;let l=a.isUpdatable(),c=a.getSize(),{type:f,byteOffset:h,byteStride:d,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/d}let p=HI(o,c,f,h,d,m,!0),_=new y(this._engine,p,n,{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(n in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(n);return t._boundingInfo=new ei(this._extend.minimum,this._extend.maximum),t}serialize(){let e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,st&&st.HasTags(this)&&(e.tags=st.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(y.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(y.PositionKind)),this.isVertexBufferUpdatable(y.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(y.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(y.NormalKind)),this.isVertexBufferUpdatable(y.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(y.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(y.TangentKind)),this.isVertexBufferUpdatable(y.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(y.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(y.UVKind)),this.isVertexBufferUpdatable(y.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(y.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(y.UV2Kind)),this.isVertexBufferUpdatable(y.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(y.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(y.UV3Kind)),this.isVertexBufferUpdatable(y.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(y.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(y.UV4Kind)),this.isVertexBufferUpdatable(y.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(y.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(y.UV5Kind)),this.isVertexBufferUpdatable(y.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(y.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(y.UV6Kind)),this.isVertexBufferUpdatable(y.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(y.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(y.ColorKind)),this.isVertexBufferUpdatable(y.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(y.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(y.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(y.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(y.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(y.MatricesWeightsKind)),this.isVertexBufferUpdatable(y.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 se.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i0){let o=new Float32Array(e,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);t.setVerticesData(y.PositionKind,o,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){let o=new Float32Array(e,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);t.setVerticesData(y.NormalKind,o,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){let o=new Float32Array(e,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);t.setVerticesData(y.TangentKind,o,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){let o=new Float32Array(e,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);if(ze)for(let l=1;l0){let o=new Float32Array(e,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);t.setVerticesData(y.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(y.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(y.MatricesIndicesExtraKind,l,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){let o=new Float32Array(e,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);t.setVerticesData(y.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(y.MatricesIndicesKind,a,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(y.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(y.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(y.MatricesIndicesExtraKind,a,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(s._CleanMatricesWeights(e,t),t.setVerticesData(y.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(y.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let a=0;a-1){let h=t.getScene().getLastSkeletonById(e.skeletonId);if(!h)return;r=h.bones.length}else return;let n=t.getVerticesData(y.MatricesIndicesKind),a=t.getVerticesData(y.MatricesIndicesExtraKind),o=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,f=o.length;for(let h=0;hc-1)&&(u=c-1),d>.001){let m=1/d;for(let p=0;p<4;p++)o[h+p]*=m;if(l)for(let p=0;p<4;p++)l[h+p]*=m}else u>=4?(l[h+u-4]=1-d,a[h+u-4]=r):(o[h+u]=1-d,n[h+u]=r)}t.setVerticesData(y.MatricesIndicesKind,n),e.matricesWeightsExtra&&t.setVerticesData(y.MatricesIndicesExtraKind,a)}static Parse(e,t,i){let r=new s(e.id,t,void 0,e.updatable);return r._loadedUniqueId=e.uniqueId,st&&st.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=4,r.delayLoadingFile=i+e.delayLoadingFile,r._boundingInfo=new ei(S.FromArray(e.boundingBoxMinimum),S.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(y.UVKind),e.hasUVs2&&r._delayInfo.push(y.UV2Kind),e.hasUVs3&&r._delayInfo.push(y.UV3Kind),e.hasUVs4&&r._delayInfo.push(y.UV4Kind),e.hasUVs5&&r._delayInfo.push(y.UV5Kind),e.hasUVs6&&r._delayInfo.push(y.UV6Kind),e.hasColors&&r._delayInfo.push(y.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(y.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(y.MatricesWeightsKind),r._delayLoadingFunction=fe.ImportVertexData):fe.ImportVertexData(e,r),t.pushGeometry(r,!0),r}}});var at,Ac=C(()=>{$e();Qe();jt();dt();Ee();Fr();Pt();at=class s extends pt{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&s.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 S(0,0,1),this._up=new S(0,1,0),this._right=new S(1,0,0),this._position=S.Zero(),this._rotation=S.Zero(),this._rotationQuaternion=null,this._scaling=S.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=s.BILLBOARDMODE_NONE,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=H.Zero(),this._usePivotMatrix=!1,this._absolutePosition=S.Zero(),this._absoluteScaling=S.Zero(),this._absoluteRotationQuaternion=Se.Identity(),this._pivotMatrix=H.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new Q,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 S.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return S.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return S.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=H.Identity()),this._poseMatrix}_isSynchronized(){let e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==s.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=H.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 n of this.getChildTransformNodes(!0))n.instantiateHierarchy(r,t,i);return r}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||Se.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 n=W.Matrix[0];this.parent.getWorldMatrix().invertToRef(n),S.TransformCoordinatesFromFloatsToRef(t,i,r,n,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=S.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();let e=W.Matrix[0];return this._localMatrix.invertToRef(e),S.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=S.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,i=0,r=0,n=0){let a=s._LookAtVectorCache,o=n===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,a),this.setDirection(a,t,i,r),n===1&&this.parent)if(this.rotationQuaternion){let l=W.Matrix[0];this.rotationQuaternion.toRotationMatrix(l);let c=W.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(c),c.invert(),l.multiplyToRef(c,l),this.rotationQuaternion.fromRotationMatrix(l)}else{let l=W.Quaternion[0];Se.FromEulerVectorToRef(this.rotation,l);let c=W.Matrix[0];l.toRotationMatrix(c);let f=W.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=S.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return S.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,i=0,r=0){let n=-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?Se.RotationYawPitchRollToRef(n+t,o+i,r,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=n+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=W.Matrix[0];i.invertToRef(r),e=S.TransformCoordinates(e,r)}return this.setPivotMatrix(H.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){let e=S.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=S.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),S.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=W.Quaternion[0],n=W.Vector3[0],a=W.Vector3[1],o=W.Matrix[1];H.IdentityToRef(o);let l=W.Matrix[0];this.computeWorldMatrix(!0);let c=this.rotationQuaternion;return c||(c=s._TmpRotation,Se.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,c)),H.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,n,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(a),this.position.copyFrom(n),this.parent=e,i&&this.setPivotMatrix(H.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=Se.RotationAxisToRef(e,t,s._RotationAxisCache),this.rotationQuaternion.multiplyToRef(r,this.rotationQuaternion);else{if(this.parent){let n=this.parent.getWorldMatrix(),a=W.Matrix[0];n.invertToRef(a),e=S.TransformNormal(e,a),n.determinant()<0&&(t*=-1)}r=Se.RotationAxisToRef(e,t,s._RotationAxisCache),r.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=Se.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));let r=W.Vector3[0],n=W.Vector3[1],a=W.Vector3[2],o=W.Quaternion[0],l=W.Matrix[0],c=W.Matrix[1],f=W.Matrix[2],h=W.Matrix[3];return e.subtractToRef(this.position,r),H.TranslationToRef(r.x,r.y,r.z,l),H.TranslationToRef(-r.x,-r.y,-r.z,c),H.RotationAxisToRef(t,i,f),c.multiplyToRef(f,h),h.multiplyToRef(l,h),h.decompose(n,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 n=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(n)}else this.setAbsolutePosition(this.getAbsolutePosition().add(r));return this}addRotation(e,t,i){let r;this.rotationQuaternion?r=this.rotationQuaternion:(r=W.Quaternion[1],Se.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));let n=W.Quaternion[0];return Se.RotationYawPitchRollToRef(t,e,i,n),r.multiplyInPlace(n),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==s.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 n=this._getEffectiveParent(),a=s._TmpScaling,o=this._position;if(this._infiniteDistance&&!this.parent&&t){let f=t.getWorldMatrix().m;o=s._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(Se.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(l=s._TmpRotation,Se.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),this._usePivotMatrix){let c=W.Matrix[1];H.ScalingToRef(a.x,a.y,a.z,c);let f=W.Matrix[0];l.toRotationMatrix(f),this._pivotMatrix.multiplyToRef(c,W.Matrix[4]),W.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 H.ComposeToRef(a,l,o,this._localMatrix);if(n&&n.getWorldMatrix){if(e&&n.computeWorldMatrix(e),this.billboardMode){if(this._transformToBoneReferal){let d=this.parent;d.getSkeleton().prepare(),d.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),W.Matrix[7])}else W.Matrix[7].copyFrom(n.getWorldMatrix());let c=W.Vector3[5],f=W.Vector3[6],h=W.Quaternion[0];W.Matrix[7].decompose(f,h,c),H.ScalingToRef(f.x,f.y,f.z,W.Matrix[7]),W.Matrix[7].setTranslation(c),s.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(h,c),this._localMatrix.setTranslation(c)),this._localMatrix.multiplyToRef(W.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){let c=this.parent;c.getSkeleton().prepare(),this._localMatrix.multiplyToRef(c.getFinalMatrix(),W.Matrix[6]),W.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(n.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(t&&this.billboardMode)if(r.useBillboardPosition){let c=W.Vector3[0];this._worldMatrix.getTranslationToRef(c);let f=t.globalPosition;this._worldMatrix.invertToRef(W.Matrix[1]);let h=W.Vector3[1];S.TransformCoordinatesToRef(f,W.Matrix[1],h),h.normalize();let d=-Math.atan2(h.z,h.x)+Math.PI/2,u=Math.sqrt(h.x*h.x+h.z*h.z),m=-Math.atan2(h.y,u);if(Se.RotationYawPitchRollToRef(d,m,0,W.Quaternion[0]),(this.billboardMode&s.BILLBOARDMODE_ALL)!==s.BILLBOARDMODE_ALL){let p=W.Vector3[1];W.Quaternion[0].toEulerAnglesToRef(p),(this.billboardMode&s.BILLBOARDMODE_X)!==s.BILLBOARDMODE_X&&(p.x=0),(this.billboardMode&s.BILLBOARDMODE_Y)!==s.BILLBOARDMODE_Y&&(p.y=0),(this.billboardMode&s.BILLBOARDMODE_Z)!==s.BILLBOARDMODE_Z&&(p.z=0),H.RotationYawPitchRollToRef(p.y,p.x,p.z,W.Matrix[0])}else H.FromQuaternionToRef(W.Quaternion[0],W.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(W.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(W.Vector3[0])}else{let c=W.Vector3[0];this._worldMatrix.getTranslationToRef(c),W.Matrix[1].copyFrom(t.getViewMatrix());let f=this.getScene().useRightHandedSystem;if(f&&W.Matrix[1].multiplyToRef(s._TmpRHRestore,W.Matrix[1]),W.Matrix[1].setTranslationFromFloats(0,0,0),W.Matrix[1].invertToRef(W.Matrix[0]),(this.billboardMode&s.BILLBOARDMODE_ALL)!==s.BILLBOARDMODE_ALL){W.Matrix[0].decompose(void 0,W.Quaternion[0],void 0);let h=W.Vector3[1];W.Quaternion[0].toEulerAnglesToRef(h),(this.billboardMode&s.BILLBOARDMODE_X)!==s.BILLBOARDMODE_X&&(h.x=0),(this.billboardMode&s.BILLBOARDMODE_Y)!==s.BILLBOARDMODE_Y&&(h.y=0),(this.billboardMode&s.BILLBOARDMODE_Z)!==s.BILLBOARDMODE_Z&&(h.z=0),f&&(h.y+=Math.PI),H.RotationYawPitchRollToRef(h.y,h.x,h.z,W.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(W.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(W.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):n&&n._nonUniformScaling?this._updateNonUniformScalingState(n._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=H.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){let t=this.getChildren();for(let i=0;inew s(e,this.getScene()),this);if(r.name=e,r.id=e,t&&(r.parent=t),!i){let n=this.getDescendants(!0);for(let a=0;anew s(e.name,t),e,t,i);if(e.localMatrix?r.setPreTransformMatrix(H.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(H.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 n=0;n(!t||t(r))&&r instanceof s),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,n=null;t&&(this.rotationQuaternion?(n=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&&n?this.rotationQuaternion.copyFrom(n):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=Se.Zero();at._TmpScaling=S.Zero();at._TmpTranslation=S.Zero();at._TmpRHRestore=H.Scaling(1,1,-1);at._LookAtVectorCache=new S(0,0,0);at._RotationAxisCache=new Se;b([ui("position")],at.prototype,"_position",void 0);b([ui("rotation")],at.prototype,"_rotation",void 0);b([UI("rotationQuaternion")],at.prototype,"_rotationQuaternion",void 0);b([ui("scaling")],at.prototype,"_scaling",void 0);b([L("billboardMode")],at.prototype,"_billboardMode",void 0);b([L()],at.prototype,"scalingDeterminant",void 0);b([L("infiniteDistance")],at.prototype,"_infiniteDistance",void 0);b([L()],at.prototype,"ignoreNonUniformScaling",void 0);b([L()],at.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0)});var qu,gM=C(()=>{Ee();qu=class{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new S(0,0,0),this._diffPositionForCollisions=new S(0,0,0),this._collisionResponse=!0}}});function EM(s){return Math.floor(s/8)}function vM(s){return 1<{Qu=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=EM(e),i=vM(e);return(this._byteArray[t]&i)!==0}set(e,t){if(e>=this.size)throw new RangeError("Bit index out of range");let i=EM(e),r=vM(e);t?this._byteArray[i]|=r:this._byteArray[i]&=~r}}});var TM={};Ie(TM,{OptimizeIndices:()=>w4});function w4(s){let e=[],t=s.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),n.push(e[f]);for(let h of e[f]){let d=i.get(h);if(!d)return;for(let u of d)r.get(u)||c.push(u)}}}};for(let l=0;l{SM()});function B4(s,e,t){let i;switch(e){case y.PositionKind:i=r=>r.getPositions();break;case y.NormalKind:i=r=>r.getNormals();break;case y.TangentKind:i=r=>r.getTangents();break;case y.UVKind:i=r=>r.getUVs();break;case y.UV2Kind:i=r=>r.getUV2s();break;case y.ColorKind:i=r=>r.getColors();break;default:return}for(let r=0;r0&&(H.FromFloat32ArrayToRefScaled(t,Math.floor(i[d+u]*16),m,c),l.addToSelf(c));if(n&&a)for(u=0;u<4;u++)m=a[d+u],m>0&&(H.FromFloat32ArrayToRefScaled(t,Math.floor(n[d+u]*16),m,c),l.addToSelf(c));f(s[h],s[h+1],s[h+2],l,o),o.toArray(s,h)}}var lv,cv,Zt,Rc=C(()=>{$e();dt();Ee();It();Bt();Ac();hc();eo();Xa();gM();Ci();Ku();Je();Wi();Yl();Pt();Qe();ci();lv=class{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=S.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}},cv=class{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new lv,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 qu,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}},Zt=class s 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 cv,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this._waitingSkeletonId=null,this._waitingSkeletonUniqueId=null,this.cullingStrategy=s.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new Q,this.onCollisionPositionChangeObservable=new Q,this.onMaterialChangedObservable=new Q,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=s.DefaultIsPickable,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=ae.Red(),this.outlineWidth=.02,this.overlayColor=ae.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 S(.5,1,.5),this.ellipsoidOffset=new S(0,0,0),this.edgesWidth=1,this.edgesColor=new Me(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 Q,this._onCollisionPositionChange=(i,r,n=null)=>{r.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>he.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),n&&this.onCollideObservable.notifyObservers(n),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),this.layerMask=t.defaultRenderableLayerMask,t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new Wt(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 ei(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(y.MatricesIndicesKind)&&this.isVerticesDataPresent(y.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 H;(this.rotationQuaternion?this.rotationQuaternion:Se.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);let a=S.Zero(),o=this.definedFacingForward?-1:1;return S.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 S(e*r,t,i*r)}_refreshBoundingInfo(e,t){if(e){let i=Yu(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new ei(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=n(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&&B4(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){let a=n(y.MatricesIndicesKind),o=n(y.MatricesWeightsKind);if(o&&a){let l=this.numBoneInfluencers>4,c=l?n(y.MatricesIndicesExtraKind):null,f=l?n(y.MatricesWeightsExtraKind):null,h=this.skeleton.getTransformMatrices(this);s._ApplySkeleton(t,i,h,a,o,c,f)}}if(e.updatePositionsArray!==!1&&i===y.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(),n=e.getBoundingInfo();if(r.intersects(n,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 n=e.verticesStart,a=e.verticesStart+e.verticesCount;for(let o=n;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=W.Matrix[0],i=W.Matrix[1];return H.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,n,a=!1){let o=new wi,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:S.Distance(e.origin,f.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let h=null,d=this._scene.getIntersectingSubMeshCandidates(this,e),u=d.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||!h||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:S.Zero()}e.depthSortedFacets=[];for(let l=0;lje?n.maximum.x-n.minimum.x:je,e.bbSize.y=n.maximum.y-n.minimum.y>je?n.maximum.y-n.minimum.y:je,e.bbSize.z=n.maximum.z-n.minimum.z>je?n.maximum.z-n.minimum.z:je;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=n,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),S.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,r&&fe.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;cn.subDiv.max||o<0||o>n.subDiv.max||l<0||l>n.subDiv.max?null:n.facetPartitioning[a+n.subDiv.max*o+n.subDiv.max*n.subDiv.max*l]}getClosestFacetAtCoordinates(e,t,i,r,n=!1,a=!0){let o=this.getWorldMatrix(),l=W.Matrix[5];o.invertToRef(l);let c=W.Vector3[8];S.TransformCoordinatesFromFloatsToRef(e,t,i,l,c);let f=this.getClosestFacetAtLocalCoordinates(c.x,c.y,c.z,r,n,a);return r&&S.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,o,r),f}getClosestFacetAtLocalCoordinates(e,t,i,r,n=!1,a=!0){let o=null,l,c,f,h,d,u,m,p,_=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),v=this.getFacetsAtLocalCoordinates(e,t,i);if(!v)return null;let I=Number.MAX_VALUE,x,T,A,R;for(let P=0;P=0||n&&!a&&h<=0)&&(h=A.x*R.x+A.y*R.y+A.z*R.z,d=-(A.x*e+A.y*t+A.z*i-h)/(A.x*A.x+A.y*A.y+A.z*A.z),u=e+A.x*d,m=t+A.y*d,p=i+A.z*d,l=u-e,c=m-t,f=p-i,x=l*l+c*c+f*f,x(AM(),TM));return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=mr.Y);let i=W.Vector3[0],r=W.Vector3[1];return S.CrossToRef(t,e,r),S.CrossToRef(e,r,i),this.rotationQuaternion?Se.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):S.RotationFromAxisToRef(i,e,r,this.rotation),this}_checkOcclusionQuery(e=!1){return!1}disableEdgesRendering(){throw Ce("EdgesRenderer")}enableEdgesRendering(e,t,i){throw Ce("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;b([_r.filter((...s)=>!Array.isArray(s[0])&&!Array.isArray(s[3])&&!Array.isArray(s[4])&&!Array.isArray(s[5])&&!Array.isArray(s[6]))],Zt,"_ApplySkeleton",null);Ke("BABYLON.AbstractMesh",Zt)});var Xi,RM=C(()=>{$e();jt();Qe();Xi=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){De.Clone(()=>e,this)}serialize(){return De.Serialize(this)}parse(e,t,i){De.Parse(()=>this,e,t,i)}};b([L()],Xi.prototype,"func",null);b([L()],Xi.prototype,"backFunc",null);b([L()],Xi.prototype,"funcRef",null);b([L()],Xi.prototype,"funcMask",null);b([L()],Xi.prototype,"opStencilFail",null);b([L()],Xi.prototype,"opDepthFail",null);b([L()],Xi.prototype,"opStencilDepthPass",null);b([L()],Xi.prototype,"backOpStencilFail",null);b([L()],Xi.prototype,"backOpDepthFail",null);b([L()],Xi.prototype,"backOpStencilDepthPass",null);b([L()],Xi.prototype,"mask",null);b([L()],Xi.prototype,"enabled",null)});function Pi(s){s.indexOf("vClipPlane")===-1&&s.push("vClipPlane"),s.indexOf("vClipPlane2")===-1&&s.push("vClipPlane2"),s.indexOf("vClipPlane3")===-1&&s.push("vClipPlane3"),s.indexOf("vClipPlane4")===-1&&s.push("vClipPlane4"),s.indexOf("vClipPlane5")===-1&&s.push("vClipPlane5"),s.indexOf("vClipPlane6")===-1&&s.push("vClipPlane6")}function on(s,e,t){var c,f,h,d,u,m;let i=!!((c=s.clipPlane)!=null?c:e.clipPlane),r=!!((f=s.clipPlane2)!=null?f:e.clipPlane2),n=!!((h=s.clipPlane3)!=null?h:e.clipPlane3),a=!!((d=s.clipPlane4)!=null?d:e.clipPlane4),o=!!((u=s.clipPlane5)!=null?u:e.clipPlane5),l=!!((m=s.clipPlane6)!=null?m:e.clipPlane6);i&&t.push("#define CLIPPLANE"),r&&t.push("#define CLIPPLANE2"),n&&t.push("#define CLIPPLANE3"),a&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),l&&t.push("#define CLIPPLANE6")}function xM(s,e,t){var f,h,d,u,m,p;let i=!1,r=!!((f=s.clipPlane)!=null?f:e.clipPlane),n=!!((h=s.clipPlane2)!=null?h:e.clipPlane2),a=!!((d=s.clipPlane3)!=null?d:e.clipPlane3),o=!!((u=s.clipPlane4)!=null?u:e.clipPlane4),l=!!((m=s.clipPlane5)!=null?m:e.clipPlane5),c=!!((p=s.clipPlane6)!=null?p:e.clipPlane6);return t.CLIPPLANE!==r&&(t.CLIPPLANE=r,i=!0),t.CLIPPLANE2!==n&&(t.CLIPPLANE2=n,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(s,e,t){var r,n,a,o,l,c;let i=(r=e.clipPlane)!=null?r:t.clipPlane;xc(s,"vClipPlane",i),i=(n=e.clipPlane2)!=null?n:t.clipPlane2,xc(s,"vClipPlane2",i),i=(a=e.clipPlane3)!=null?a:t.clipPlane3,xc(s,"vClipPlane3",i),i=(o=e.clipPlane4)!=null?o:t.clipPlane4,xc(s,"vClipPlane4",i),i=(l=e.clipPlane5)!=null?l:t.clipPlane5,xc(s,"vClipPlane5",i),i=(c=e.clipPlane6)!=null?c:t.clipPlane6,xc(s,"vClipPlane6",i)}function xc(s,e,t){var i;if(t){let r=((i=is.getScene())==null?void 0:i.floatingOriginOffset)||S.ZeroReadOnly;s.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+S.Dot(t.normal,r))}}var Ps=C(()=>{fh();Ee()});var re,ns=C(()=>{ci();re=class{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,he.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,he.MarkAllMaterialsAsDirty(1))}};re._DiffuseTextureEnabled=!0;re._BaseWeightTextureEnabled=!0;re._BaseDiffuseRoughnessTextureEnabled=!0;re._DetailTextureEnabled=!0;re._DecalMapEnabled=!0;re._AmbientTextureEnabled=!0;re._OpacityTextureEnabled=!0;re._ReflectionTextureEnabled=!0;re._EmissiveTextureEnabled=!0;re._SpecularTextureEnabled=!0;re._BumpTextureEnabled=!0;re._LightmapTextureEnabled=!0;re._RefractionTextureEnabled=!0;re._ColorGradingTextureEnabled=!0;re._FresnelEnabled=!0;re._ClearCoatTextureEnabled=!0;re._ClearCoatBumpTextureEnabled=!0;re._ClearCoatTintTextureEnabled=!0;re._SheenTextureEnabled=!0;re._AnisotropicTextureEnabled=!0;re._ThicknessTextureEnabled=!0;re._RefractionIntensityTextureEnabled=!0;re._TranslucencyIntensityTextureEnabled=!0;re._TranslucencyColorTextureEnabled=!0;re._IridescenceTextureEnabled=!0});function ln(s,e,t){if(!s||s.LOGARITHMICDEPTH||s.indexOf&&s.indexOf("LOGARITHMICDEPTH")>=0){let i=t.activeCamera;i.mode===1&&X.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}var IM=C(()=>{We()});function cn(s,e,t,i=!1){t&&s.fogEnabled&&(!e||e.applyFog)&&s.fogMode!==0&&(t.setFloat4("vFogInfos",s.fogMode,s.fogStart,s.fogEnd,s.fogDensity),i?(s.fogColor.toLinearSpaceToRef(CM,s.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",CM)):t.setColor3("vFogColor",s.fogColor))}function fn(s,e,t,i,r,n,a,o,l,c){let f=s.numMaxInfluencers||s.numInfluencers;return f<=0?0:(e.push("#define MORPHTARGETS"),s.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),s.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),s.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),s.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),s.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),s.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),s.supportsPositions&&r&&e.push("#define MORPHTARGETS_POSITION"),s.supportsNormals&&n&&e.push("#define MORPHTARGETS_NORMAL"),s.supportsTangents&&a&&e.push("#define MORPHTARGETS_TANGENT"),s.supportsUVs&&o&&e.push("#define MORPHTARGETS_UV"),s.supportsUV2s&&l&&e.push("#define MORPHTARGETS_UV2"),s.supportsColors&&c&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+f),s.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),hl.NUM_MORPH_INFLUENCERS=f,hl.NORMAL=n,hl.TANGENT=a,hl.UV=o,hl.UV2=l,hl.COLOR=c,dl(t,i,hl,r),f)}function dl(s,e,t,i=!0){let r=t.NUM_MORPH_INFLUENCERS;if(r>0&&ue.LastCreatedEngine){let n=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,h=a&&a.supportsUV2s&&t.UV2,d=a&&a.supportsColors&&t.VERTEXCOLOR;for(let u=0;un&&X.Error("Cannot add more vertex attributes for mesh "+e.name)}}function Ls(s,e=!1){s.push("world0"),s.push("world1"),s.push("world2"),s.push("world3"),e&&(s.push("previousWorld0"),s.push("previousWorld1"),s.push("previousWorld2"),s.push("previousWorld3"))}function Yi(s,e){let t=s.morphTargetManager;!s||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function to(s,e){e.bindToEffect(s,"Scene")}function Ic(s,e,t,i,r=null,n=!1,a=!1,o=!1,l=!1,c=!1,f=!1,h=0){if(s.texturesEnabled&&r&&re.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",r.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",r.level*s.iblIntensity,h),o&&r.boundingBoxSize){let d=r;t.updateVector3("vReflectionPosition",d.boundingBoxPosition),t.updateVector3("vReflectionSize",d.boundingBoxSize)}if(n){let d=r.getSize().width;t.updateFloat2("vReflectionFilteringInfo",d,Math.log2(d))}if(c&&!e.USEIRRADIANCEMAP){let d=r.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&d)if(e.SPHERICAL_HARMONICS){let u=d.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",d.x.x,d.x.y,d.x.z),t.updateFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),t.updateFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),t.updateFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),t.updateFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),t.updateFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),t.updateFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),t.updateFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),t.updateFloat3("vSphericalZX",d.zx.x,d.zx.y,d.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 Ju(s,e,t,i=null,r=!1){if(i&&re.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 n=s.iblCdfGenerator;r&&n&&t.setTexture("icdfSampler",n.getIcdfTexture())}}function ot(s,e,t){e._needUVs=!0,e[t]=!0,s.optimizeUVAllocation&&s.getTextureMatrix().isIdentityAs3x2()?(e[t+"DIRECTUV"]=s.coordinatesIndex+1,e["MAINUV"+(s.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function lt(s,e,t){let i=s.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function Cc(s,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&s.push("bakedVertexAnimationSettingsInstanced")}function V4(s,e){return e.set(s),e}function Sr(s,e,t){if(!(!e||!s)&&(s.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(s.computeBonesUsingShaders=!1),s.useBones&&s.computeBonesUsingShaders&&s.skeleton)){let i=s.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureInfo")>-1){let r=i.getTransformMatrixTexture(s);e.setTexture("boneSampler",r),e.setFloat2("boneTextureInfo",i._textureWidth,i._textureHeight)}else{let r=i.getTransformMatrices(s);r&&(e.setMatrices("mBones",r),t&&s.getScene().prePassRenderer&&s.getScene().prePassRenderer.getIndex(2)&&(t.previousBones[s.uniqueId]||(t.previousBones[s.uniqueId]=r.slice()),e.setMatrices("mPreviousBones",t.previousBones[s.uniqueId]),V4(r,t.previousBones[s.uniqueId])))}}}function G4(s,e,t,i,r,n=!0){s._bindLight(e,t,i,r,n)}function bc(s,e,t,i,r=4){let n=Math.min(e.lightSources.length,r);for(let a=0;a0&&(i.addCPUSkinningFallback(0,e),s.push("matricesIndices"),s.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(s.push("matricesIndicesExtra"),s.push("matricesWeightsExtra")))}function io(s,e){(e.INSTANCES||e.THIN_INSTANCES)&&Ls(s,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&s.push("instanceColor")}function yc(s,e,t=4,i=0){let r=0;for(let n=0;n0&&(r=i+n,e.addFallback(r,"LIGHT"+n)),s.SHADOWS||(s["SHADOW"+n]&&e.addFallback(i,"SHADOW"+n),s["SHADOWPCF"+n]&&e.addFallback(i,"SHADOWPCF"+n),s["SHADOWPCSS"+n]&&e.addFallback(i,"SHADOWPCSS"+n),s["SHADOWPOISSON"+n]&&e.addFallback(i,"SHADOWPOISSON"+n),s["SHADOWESM"+n]&&e.addFallback(i,"SHADOWESM"+n),s["SHADOWCLOSEESM"+n]&&e.addFallback(i,"SHADOWCLOSEESM"+n));return r}function k4(s,e){return e.fogEnabled&&s.applyFog&&e.fogMode!==0}function ro(s,e,t,i,r,n,a,o=!1,l=!1,c,f){var h;if(a._areMiscDirty){a.LOGARITHMICDEPTH=t,a.POINTSIZE=i,a.FOG=r&&k4(s,e),a.NONUNIFORMSCALING=s.nonUniformScaling,a.ALPHATEST=n,a.DECAL_AFTER_DETAIL=o,a.USE_VERTEX_PULLING=l,a.RIGHT_HANDED=e.useRightHandedSystem;let d=(h=c==null?void 0:c.geometry)==null?void 0:h.getIndexBuffer(),u=c?c.isUnIndexed:!1;a.VERTEX_PULLING_USE_INDEX_BUFFER=!!d&&!u,a.VERTEX_PULLING_INDEX_BUFFER_32BITS=d&&!u?d.is32Bits:!1,a.VERTEXOUTPUT_INVARIANT=!!f}}function Dc(s,e,t,i=!1){if(!s.lightsEnabled||i)return!0;let r=e.lightSources,n=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,s.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&&s.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=n))}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 W4(s,e,t,i,r,n,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(n&&!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&&s.shadowsEnabled&&t.shadowEnabled){let l=(o=t.getShadowGenerator(s.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 no(s,e,t,i,r,n=null,a=!1){let o=Y4(s,i);n!==!1&&(o=xM(t,s,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 H4(s,e){if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){e.NUM_BONE_INFLUENCERS=s.numBoneInfluencers;let t=e.BONETEXTURE!==void 0;if(s.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=s.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;let i=s.getScene().prePassRenderer;if(i&&i.enabled){let r=i.excludedSkinnedMesh.indexOf(s)===-1;e.BONES_VELOCITY_ENABLED=r}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function z4(s,e){let t=s.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 X4(s,e){let t=s.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function ao(s,e,t,i,r=!1,n=!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&&s.isVerticesDataPresent("normal"),e._needNormals&&s.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let o=1;o<=6;++o)e["UV"+o]=e._needUVs?s.isVerticesDataPresent(`uv${o===1?"":o}`):!1;if(t){let o=s.useVertexColors&&s.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=s.hasVertexAlpha&&o&&n}return s.isVerticesDataPresent("instanceColor")&&(s.hasInstances||s.hasThinInstances)&&(e.INSTANCESCOLOR=!0),i&&H4(s,e),r&&z4(s,e),a&&X4(s,e),!0}function Lc(s,e){if(s.activeCamera){let t=e.MULTIVIEW;e.MULTIVIEW=s.activeCamera.outputRenderTarget!==null&&s.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function Oc(s,e,t){let i=e.ORDER_INDEPENDENT_TRANSPARENCY,r=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;e.ORDER_INDEPENDENT_TRANSPARENCY=s.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!s.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||r!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function Nc(s,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(s.prePassRenderer&&s.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=s.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=s.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let n=0;n{We();gt();ih();Ps();ns();pi();IM();CM={r:0,g:0,b:0},hl={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1}});var oe,Vi=C(()=>{$e();Qe();At();dt();gt();Tc();Xa();We();Jo();Ya();RM();Ui();jt();hg();oe=class s{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(e){this._useVertexPulling!==e&&(this._useVertexPulling=e,this.markAsDirty(s.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(s.MiscDirtyFlag+s.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(s.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(s.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 Q),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 Q),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new Q),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode[0]!==e&&(this._alphaMode[0]=e,this.markAsDirty(s.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(s.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(s.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case s.WireFrameFillMode:case s.LineListDrawMode:case s.LineLoopDrawMode:case s.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?s.WireFrameFillMode:s.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case s.PointFillMode:case s.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?s.PointFillMode:s.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(s.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){let t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&X.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 Q,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 Xi,this._isVertexOutputInvariant=s.ForceVertexOutputInvariant,this._useUBO=!1,this._fillMode=s.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 n=t||ue.LastCreatedScene;n&&(this._scene=n,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||se.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new yi(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new Wt(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={}),s.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 Wt(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new Wt(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===s.MATERIAL_ALPHABLEND||this._transparencyMode===s.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===s.MATERIAL_ALPHATEST||this._transparencyMode===s.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===s.MATERIAL_OPAQUE||this._transparencyMode===s.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 n of r._drawWrappers)n&&this._materialContext===n.materialContext&&(n._wasPreviouslyReady=!1,n._wasPreviouslyUsingInstances=null,n._forceRebindOnNextCall=e)}e&&this.markAsDirty(s.AllDirtyFlag)}_preBind(e,t=null){let i=this._scene.getEngine(),n=(t==null?this.sideOrientation:t)===s.ClockWiseSideOrientation,a=e||this._getDrawWrapper();return Hd(a)&&a.materialContext&&(a.materialContext.useVertexPulling=this.useVertexPulling),i.enableEffect(a),i.setState(this.backFaceCulling,this.zOffset,!1,n,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),n}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,to(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),s._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(let r of this.pluginManager._plugins){let n=e.pluginManager.getPlugin(r.name);n&&r.copyTo(n)}}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 n={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(n.clipPlane&&(a.clipPlane=new pr(0,0,0,1)),this._storeEffectOnSubMeshes){let f=!0,h=null;if(e.subMeshes){let d=new zi(0,0,0,0,0,e,void 0,!1,!1);d.materialDefines&&(d.materialDefines._renderId=-1),this.isReadyForSubMesh(e,d,n.useInstances)||(d.effect&&d.effect.getCompilationError()&&d.effect.allFallbacksProcessed()?h=d.effect.getCompilationError():(f=!1,setTimeout(l,16)))}f&&(this.allowShaderHotSwapping=o,h&&r&&r(h),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=o,t&&t(this)):setTimeout(l,16);n.clipPlane&&(a.clipPlane=c)};l()}async forceCompilationAsync(e,t){return await new Promise((i,r)=>{this.forceCompilation(e,()=>{i()},t,n=>{r(n)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(s._DirtyCallbackArray.length=0,e&s.ImageProcessingDirtyFlag&&s._DirtyCallbackArray.push(s._ImageProcessingDirtyCallBack),e&s.TextureDirtyFlag&&s._DirtyCallbackArray.push(s._TextureDirtyCallBack),e&s.LightDirtyFlag&&s._DirtyCallbackArray.push(s._LightsDirtyCallBack),e&s.FresnelDirtyFlag&&s._DirtyCallbackArray.push(s._FresnelDirtyCallBack),e&s.AttributesDirtyFlag&&s._DirtyCallbackArray.push(s._AttributeDirtyCallBack),e&s.MiscDirtyFlag&&s._DirtyCallbackArray.push(s._MiscDirtyCallBack),e&s.PrePassDirtyFlag&&s._DirtyCallbackArray.push(s._PrePassDirtyCallBack),s._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(s._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 n of r.subMeshes)if((n.getMaterial()||(t._hasDefaultMaterial?t.defaultMaterial:null))===this)for(let o of n._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(s._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(s._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(s._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(s._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(s._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(s._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(s._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(s._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(s._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(s._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 n=this._parentContainer.materials.indexOf(this);n>-1&&this._parentContainer.materials.splice(n,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(let n in this.meshMap){let a=this.meshMap[n];this._disposeMeshResources(a)}else{let n=r.meshes;for(let a of n)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 n of e.subMeshes){let a=n._drawWrappers;for(let o=0;os.markAllAsDirty();oe._ImageProcessingDirtyCallBack=s=>s.markAsImageProcessingDirty();oe._TextureDirtyCallBack=s=>s.markAsTexturesDirty();oe._FresnelDirtyCallBack=s=>s.markAsFresnelDirty();oe._MiscDirtyCallBack=s=>s.markAsMiscDirty();oe._PrePassDirtyCallBack=s=>s.markAsPrePassDirty();oe._LightsDirtyCallBack=s=>s.markAsLightDirty();oe._AttributeDirtyCallBack=s=>s.markAsAttributesDirty();oe._FresnelAndMiscDirtyCallBack=s=>{oe._FresnelDirtyCallBack(s),oe._MiscDirtyCallBack(s)};oe._TextureAndMiscDirtyCallBack=s=>{oe._TextureDirtyCallBack(s),oe._MiscDirtyCallBack(s)};oe._DirtyCallbackArray=[];oe._RunDirtyCallBacks=s=>{for(let e of oe._DirtyCallbackArray)e(s)};b([L()],oe.prototype,"id",void 0);b([L()],oe.prototype,"uniqueId",void 0);b([L()],oe.prototype,"name",void 0);b([L()],oe.prototype,"metadata",void 0);b([L()],oe.prototype,"checkReadyOnEveryCall",void 0);b([L()],oe.prototype,"checkReadyOnlyOnce",void 0);b([L()],oe.prototype,"state",void 0);b([L("alpha")],oe.prototype,"_alpha",void 0);b([L("backFaceCulling")],oe.prototype,"_backFaceCulling",void 0);b([L("cullBackFaces")],oe.prototype,"_cullBackFaces",void 0);b([L()],oe.prototype,"sideOrientation",void 0);b([L()],oe.prototype,"_alphaMode",void 0);b([L()],oe.prototype,"_needDepthPrePass",void 0);b([L()],oe.prototype,"disableDepthWrite",void 0);b([L()],oe.prototype,"disableColorWrite",void 0);b([L()],oe.prototype,"forceDepthWrite",void 0);b([L()],oe.prototype,"depthFunction",void 0);b([L()],oe.prototype,"separateCullingPass",void 0);b([L("fogEnabled")],oe.prototype,"_fogEnabled",void 0);b([L()],oe.prototype,"pointSize",void 0);b([L()],oe.prototype,"zOffset",void 0);b([L()],oe.prototype,"zOffsetUnits",void 0);b([L()],oe.prototype,"pointsCloud",null);b([L()],oe.prototype,"fillMode",null);b([L()],oe.prototype,"useLogarithmicDepth",null);b([L()],oe.prototype,"_isVertexOutputInvariant",void 0);b([L()],oe.prototype,"transparencyMode",null)});var wc,bM=C(()=>{Vi();Ha();Pt();wc=class s extends oe{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 n=t.apply(e,r);return this._markAllSubMeshesAsTexturesDirty(),n};let i=e.splice;e.splice=(r,n)=>{let a=i.call(e,r,n!=null?n: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(n,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){let i=new s(e.name,t);if(i.id=e.id,i._loadedUniqueId=e.uniqueId,st&&st.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}};Ke("BABYLON.MultiMaterial",wc)});var $u,MM=C(()=>{$u=class{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}});var Bc,em,fv,tm,hv,dv,hn,G,ut=C(()=>{dt();At();eh();Ha();Th();Ds();Ee();Je();Fr();It();Bt();Zu();Rc();Tc();Vi();bM();ju();jt();We();Pt();Ci();dc();MM();Bc=class{},em=class{constructor(){this.batchCache=new tm(this),this.batchCacheReplacementModeInFrozenMode=new tm(this),this.instancesBufferSize=512*4}},fv=class{constructor(){this.renderPasses={}}},tm=class{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}},hv=class{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}},dv=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},G=class s extends Zt{static _GetDefaultSideOrientation(e){return e||s.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(y.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(y.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 Q),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new Q),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new Q),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new Q),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new Q),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 n=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),rn.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,n.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,st&&st.HasTags(e)&&st.AddTagsTo(this,st.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,n=(h=m.doNotCloneChildren)!=null?h:!1,a=(d=m.clonePhysicsImpostor)!=null?d:!0,l=(u=m.cloneThinInstances)!=null?u:!1}else o=i;r&&this._copySource(r,n,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 Q(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 n of this.getChildTransformNodes(!0))n.getClassName()==="InstancedMesh"&&r.getClassName()==="Mesh"&&n.sourceMesh===this?n.instantiateHierarchy(r,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:r},i):n.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 X.Warn("You cannot use a mesh as LOD level twice"),this;let i=new $u(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,n))return!1}else if(!_.isReady(this,n))return!1}}else if(!a.isReady(this,n))return!1}let o=i.currentRenderPassId;for(let p of this.lightSources){let _=p.getShadowGenerators();if(!_)continue;let g=_.values();for(let v=g.next();v.done!==!0;v=g.next()){let I=v.value;if(I&&(!((l=I.getShadowMap())!=null&&l.renderList)||(c=I.getShadowMap())!=null&&c.renderList&&((h=(f=I.getShadowMap())==null?void 0:f.renderList)==null?void 0:h.indexOf(this))!==-1)){let T=(d=I.getShadowMap().renderPassIds)!=null?d:[i.currentRenderPassId];for(let A=0;A0){let i=this.getIndices();if(!i)return null;let r=i.length,n=!1;if(e)n=!0;else for(let a of this.subMeshes){if(a.indexStart+a.indexCount>r){n=!0;break}if(a.verticesStart+a.verticesCount>t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new zi(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 n=0;n=t);n++)zi.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 n=new fe;n.set(t,e);let a=this.getScene();new Di(Di.RandomId(),a,n,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=Di.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(y.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(y.PositionKind,i,!1,!1),t){let r=this.getIndices(),n=this.getVerticesData(y.NormalKind);if(!n)return this;fe.ComputeNormals(i,r,n),this.updateVerticesData(y.NormalKind,n,!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(Di.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,r=null){let n=this._geometry;n||(n=new Di(Di.RandomId(),this.getScene(),void 0,void 0,this)),n.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 n=new fe;n.indices=e;let a=this.getScene();new Di(Di.RandomId(),a,n,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 n=this.getScene().getEngine(),a;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case oe.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),n);break;default:a=null;break}else switch(this._getRenderingFillMode(i)){case oe.PointFillMode:a=null;break;case oe.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),n);break;default:case oe.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 n in r)this._userInstancedBuffersStorage.vertexBuffers[n]=r[n]}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 n=this.getScene().getEngine(),a=n._currentMaterialContext,o=a&&a.useVertexPulling;return this._unIndexed&&t!==oe.WireFrameFillMode||t==oe.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==oe.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):o?n.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):n.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){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(),n=r._isInIntermediateRendering(),a=n?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=n?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,n,a){var v;let o=t.visibleInstances[e._id],l=o?o.length:0,c=t.parent,f=this._instanceDataStorage,h=c.instancesBuffer,d=c.instancesPreviousBuffer,u=0,m=0,p=t.renderSelf[e._id],_=this._scene.floatingOriginOffset,g=!h||i!==c.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!c.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!f.isFrozen||g)){let I=this.getWorldMatrix();if(p){this._scene.needsPreviousWorldMatrices&&(f.masterMeshPreviousWorldMatrix?(f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u),f.masterMeshPreviousWorldMatrix.copyFrom(I)):(f.masterMeshPreviousWorldMatrix=I.clone(),f.masterMeshPreviousWorldMatrix.copyToArray(c.instancesPreviousData,u))),I.copyToArray(c.instancesData,u);let x=I.asArray();c.instancesData[u+12]=x[12]-_.x,c.instancesData[u+13]=x[13]-_.y,c.instancesData[u+14]=x[14]-_.z,u+=16,m++}if(o){if(s.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&((v=e.getMaterial())!=null&&v.needAlphaBlendingForMesh(e.getRenderingMesh()))){let x=this._scene.activeCamera.globalPosition;for(let T=0;TT._distanceToCamera>A._distanceToCamera?-1:T._distanceToCamera1&&r.activeCamera===r.activeCameras[0]||a<=1,l=this._occlusionDataStorage&&this._occlusionDataStorage.occlusionForRenderPassId!==-1&&this._occlusionDataStorage.occlusionForRenderPassId!==n.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,h=null;this.ignoreCameraMaxZ&&r.activeCamera&&!r._isInIntermediateRendering()&&(f=r.activeCamera.maxZ,h=r.activeCamera,r.activeCamera.maxZ=0,r.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);let d=e.getRenderingMesh(),u=c.hardwareInstancedRendering[e._id]||d.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,m=this._instanceDataStorage,p=e.getMaterial();if(!p)return h&&(h.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 h&&(h.maxZ=f,r.updateTransformMatrix(!0)),this}else if(!p.isReady(this,u))return h&&(h.maxZ=f,r.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=p}else if(p._storeEffectOnSubMeshes&&!((M=e._drawWrapper)!=null&&M._wasPreviouslyReady)||!p._storeEffectOnSubMeshes&&!p._getDrawWrapper()._wasPreviouslyReady)return h&&(h.maxZ=f,r.updateTransformMatrix(!0)),this;if(t){let N=this._internalMeshDataInfo._effectiveMaterial;if(N.alphaModes.length===1)n.setAlphaMode(N.alphaMode);else for(let V=0;Vg&&r++,T!==0&&I++,v+=T,g=T}if(c[I]++,I>a&&(a=I),v===0)n++;else{let x=1/v,T=0;for(let A=0;Af&&o++}}let h=this.skeleton.bones.length,d=this.getVerticesData(y.MatricesIndicesKind),u=this.getVerticesData(y.MatricesIndicesExtraKind),m=0;for(let _=0;_=h||v<0)&&m++}let p="Number of Weights = "+i/4+` +Maximum influences = `+a+` +Missing Weights = `+n+` +Not Sorted = `+r+` +Not Normalized = `+o+` +WeightCounts = [`+c+`] +Number of bones = `+h+` +Bad Bone Indices = `+m;return{skinned:!0,valid:n===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 se.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(y.PositionKind))return this;let t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(y.PositionKind),r=S.Zero(),n;for(n=0;n{let d=h.width,u=h.height,p=this.getEngine().createCanvas(d,u).getContext("2d");p.drawImage(h,0,0);let _=p.getImageData(0,0,d,u).data;this.applyDisplacementMapFromBuffer(_,d,u,t,i,n,a,o),r&&r(this)};return se.LoadImage(e,f,l||(()=>{}),c.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,r,n,a,o,l=!1){if(!this.isVerticesDataPresent(y.PositionKind)||!this.isVerticesDataPresent(y.NormalKind)||!this.isVerticesDataPresent(y.UVKind))return X.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;let c=this.getVerticesData(y.PositionKind,!0,!0),f=this.getVerticesData(y.NormalKind),h=this.getVerticesData(y.UVKind),d=S.Zero(),u=S.Zero(),m=me.Zero();a=a||me.Zero(),o=o||new me(1,1);for(let p=0;p{var c;return!((c=this.getVertexBuffer(l))!=null&&c.getIsInstanced())}),i=this.getIndices(!1,!0),r={},n=(l,c)=>{let f=new Float32Array(i.length*c),h=0;for(let d=0;d{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(y.MatricesIndicesExtraKind):null,f=l?this.getVerticesData(y.MatricesWeightsExtraKind):null,h=e.getTransformMatrices(this),d=S.Zero(),u=new H,m=new H,p=0,_;for(let g=0;g0&&(H.FromFloat32ArrayToRefScaled(h,Math.floor(a[p+_]*16),v,m),u.addToSelf(m));if(l)for(_=0;_<4;_++)v=f[p+_],v>0&&(H.FromFloat32ArrayToRefScaled(h,Math.floor(c[p+_]*16),v,m),u.addToSelf(m));S.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],u,d),d.toArray(r,g),t&&(S.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],u,d),d.toArray(n,g)),u.reset()}return this.updateVerticesData(y.PositionKind,r),t&&this.updateVerticesData(y.NormalKind,n),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:S.Zero(),max:S.Zero()}:{min:t,max:i}}static Center(e){let t=e instanceof Array?s.MinMax(e):e;return S.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,r,n,a){return cl(s._MergeMeshesCoroutine(e,t,i,r,n,a,!1))}static async MergeMeshesAsync(e,t=!0,i,r,n,a){return await Ja(s._MergeMeshesCoroutine(e,t,i,r,n,a,!0),Qa())}static*_MergeMeshesCoroutine(e,t=!0,i,r,n,a,o){if(e=e.filter(Boolean),e.length===0)return null;let l;if(!i){let R=0;for(l=0;l=65536)return X.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&&(n=!1,e.sort((R,P)=>{var D,M,F,N;return((M=(D=R.material)==null?void 0:D.uniqueId)!=null?M:-1)-((N=(F=P.material)==null?void 0:F.uniqueId)!=null?N:-1)}));let f=new Array,h=new Array,d=new Array,u=e[0].sideOrientation;for(l=0;lMath.max(D,M.start+M.count),0);if(a)if(R.material){let D=R.material;if(D instanceof wc){for(let M=0;M1){let R=0;for(let P=1;P{let P=R.computeWorldMatrix(!0);return{vertexData:fe.ExtractFromMesh(R,!1,!1),transform:P}},{vertexData:p,transform:_}=m(e[0]);o&&(yield);let g=new Array(e.length-1);for(let R=1;R{throw Ce("GroundMesh")};G._GoldbergMeshParser=(s,e)=>{throw Ce("GoldbergMesh")};G._LinesMeshParser=(s,e)=>{throw Ce("LinesMesh")};G._GreasedLineMeshParser=(s,e)=>{throw Ce("GreasedLineMesh")};G._GreasedLineRibbonMeshParser=(s,e)=>{throw Ce("GreasedLineRibbonMesh")};G._TrailMeshParser=(s,e)=>{throw Ce("TrailMesh")};G._GaussianSplattingMeshParser=(s,e)=>{throw Ce("GaussianSplattingMesh")};G._GaussianSplattingPartProxyMeshParser=(s,e)=>{throw Ce("GaussianSplattingPartProxyMesh")};G._GaussianSplattingCompoundMeshParser=(s,e)=>{throw Ce("GaussianSplattingCompoundMesh")};Ke("BABYLON.Mesh",G)});var Uc,uv=C(()=>{xs();Bn();Wi();Uc=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===Le.POINTERDOWN){this._isPointerDown=!0;return}i.type===Le.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;let i=Xt.Now,r=0;this._lastFrameTime!=null&&(r=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();let n=i-this._lastInteractionTime-this._idleRotationWaitTime,a=Math.max(Math.min(n/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:Xt.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha){el();Tr=class s{constructor(){this._easingMode=s.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 s.EASINGMODE_EASEIN:return this.easeInCore(e);case s.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}};Tr.EASINGMODE_EASEIN=0;Tr.EASINGMODE_EASEOUT=1;Tr.EASINGMODE_EASEINOUT=2;im=class extends Tr{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)}},rm=class extends Tr{easeInCore(e){return e*e*e}},sm=class extends Tr{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 co,mv=C(()=>{co=class s{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new s(this.name,this.from,this.to)}}});var pv,_v,gv,Ev,vv,Sv,Os,Ne,ia=C(()=>{Ee();Je();Mi();Pt();mv();Fr();eu();sc();jt();pv=Object.freeze(new Se(0,0,0,0)),_v=Object.freeze(S.Zero()),gv=Object.freeze(me.Zero()),Ev=Object.freeze(Gn.Zero()),vv=Object.freeze(ae.Black()),Sv=Object.freeze(new Me(0,0,0,0)),Os={key:0,repeatCount:0,loopMode:2},Ne=class s{static _PrepareAnimation(e,t,i,r,n,a,o,l){let c;if(!isNaN(parseFloat(n))&&isFinite(n)?c=s.ANIMATIONTYPE_FLOAT:n instanceof Se?c=s.ANIMATIONTYPE_QUATERNION:n instanceof S?c=s.ANIMATIONTYPE_VECTOR3:n instanceof me?c=s.ANIMATIONTYPE_VECTOR2:n instanceof ae?c=s.ANIMATIONTYPE_COLOR3:n instanceof Me?c=s.ANIMATIONTYPE_COLOR4:n instanceof Gn&&(c=s.ANIMATIONTYPE_SIZE),c==null)return null;let f=new s(e,t,i,c,o),h=[{frame:0,value:n},{frame:r,value:a}];return f.setKeys(h),l!==void 0&&f.setEasingFunction(l),f}static CreateAnimation(e,t,i,r){let n=new s(e+"Animation",e,i,t,s.ANIMATIONLOOPMODE_CONSTANT);return n.setEasingFunction(r),n}static CreateAndStartAnimation(e,t,i,r,n,a,o,l,c,f,h){let d=s._PrepareAnimation(e,i,r,n,a,o,l,c);return!d||(t.getScene&&(h=t.getScene()),!h)?null:h.beginDirectAnimation(t,[d],0,n,d.loopMode!==s.ANIMATIONLOOPMODE_CONSTANT,1,f)}static CreateAndStartHierarchyAnimation(e,t,i,r,n,a,o,l,c,f,h){let d=s._PrepareAnimation(e,r,n,a,o,l,c,f);return d?t.getScene().beginDirectHierarchyAnimation(t,i,[d],0,a,d.loopMode===1,1,h):null}static CreateMergeAndStartAnimation(e,t,i,r,n,a,o,l,c,f){let h=s._PrepareAnimation(e,i,r,n,a,o,l,c);return h?(t.animations.push(h),t.getScene().beginAnimation(t,0,n,h.loopMode===1,1,f)):null}static MakeAnimationAdditive(e,t,i,r=!1,n){var v,I;let a;typeof t=="object"?a=t:a={referenceFrame:t!=null?t:0,range:i,cloneOriginalAnimation:r,clonedAnimationName:n};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],h=o._keys.length-1,d=o._keys[h],u={referenceValue:f.value,referencePosition:W.Vector3[0],referenceQuaternion:W.Quaternion[0],referenceScaling:W.Vector3[1],keyPosition:W.Vector3[2],keyQuaternion:W.Quaternion[1],keyScaling:W.Vector3[3]},m=f.frame,p=d.frame;if(a.range){let x=o.getRange(a.range);x&&(m=x.from,p=x.to)}else m=(v=a.fromFrame)!=null?v:m,p=(I=a.toFrame)!=null?I:p;if(m!==f.frame&&(c=o.createKeyForFrame(m)),p!==d.frame&&(h=o.createKeyForFrame(p)),o._keys.length===1){let x=o._getKeyValue(o._keys[0]);u.referenceValue=x.clone?x.clone():x}else if(l<=f.frame){let x=o._getKeyValue(f.value);u.referenceValue=x.clone?x.clone():x}else if(l>=d.frame){let x=o._getKeyValue(d.value);u.referenceValue=x.clone?x.clone():x}else{Os.key=0;let x=o._interpolate(l,Os);u.referenceValue=x.clone?x.clone():x}o.dataType===s.ANIMATIONTYPE_QUATERNION?u.referenceValue.normalize().conjugateInPlace():o.dataType===s.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 x=c;x<=h;x++){let T=o._keys[x];if((g||a.cloneOriginalAnimation)&&(T={frame:T.frame,value:T.value.clone?T.value.clone():T.value,inTangent:T.inTangent,outTangent:T.outTangent,interpolation:T.interpolation,lockedTangent:T.lockedTangent,easingFunction:T.easingFunction},g&&(_===Number.MAX_VALUE&&(_=T.frame),T.frame-=_,g.push(T))),!(x&&o.dataType!==s.ANIMATIONTYPE_FLOAT&&T.value===f.value))switch(o.dataType){case s.ANIMATIONTYPE_MATRIX:T.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),H.ComposeToRef(u.keyScaling,u.keyQuaternion,u.keyPosition,T.value);break;case s.ANIMATIONTYPE_QUATERNION:u.referenceValue.multiplyToRef(T.value,T.value);break;case s.ANIMATIONTYPE_VECTOR2:case s.ANIMATIONTYPE_VECTOR3:case s.ANIMATIONTYPE_COLOR3:case s.ANIMATIONTYPE_COLOR4:T.value.subtractToRef(u.referenceValue,T.value);break;case s.ANIMATIONTYPE_SIZE:T.value.width-=u.referenceValue.width,T.value.height-=u.referenceValue.height;break;default:T.value-=u.referenceValue}}return g&&o.setKeys(g,!0),o}static TransitionTo(e,t,i,r,n,a,o,l=null,c=!0,f){if(o<=0)return i[e]=t,l&&l(),null;let h=n*(o/1e3);return a.setKeys(f!=null?f:[{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:h,value:t}]),i.animations||(i.animations=[]),i.animations.push(a),r.beginAnimation(i,0,h,!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,n,a){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=r,this.loopMode=n,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=n===void 0?s.ANIMATIONLOOPMODE_CYCLE:n,this.uniqueId=s._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<=n&&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,n;if(this._coreAnimation)n=this._coreAnimation._key;else{let p=r.length;for(n=t.key;n>=0&&e=r[n+1].frame;)++n;if(t.key=n,n<0)return i?void 0:this._getKeyValue(r[0].value);if(n+1>p-1)return i?void 0:this._getKeyValue(r[p-1].value);this._key=n}let a=r[n],o=r[n+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,h=o.frame-a.frame,d=(e-a.frame)/h,u=a.easingFunction||this.getEasingFunction();switch(u&&(d=u.ease(d)),this.dataType){case s.ANIMATIONTYPE_FLOAT:{let p=f?this.floatInterpolateFunctionWithTangents(l,a.outTangent*h,c,o.inTangent*h,d):this.floatInterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return((m=t.offsetValue)!=null?m:0)*t.repeatCount+p}break}case s.ANIMATIONTYPE_QUATERNION:{let p=f?this.quaternionInterpolateFunctionWithTangents(l,a.outTangent.scale(h),c,o.inTangent.scale(h),d):this.quaternionInterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.addInPlace((t.offsetValue||pv).scale(t.repeatCount))}return p}case s.ANIMATIONTYPE_VECTOR3:{let p=f?this.vector3InterpolateFunctionWithTangents(l,a.outTangent.scale(h),c,o.inTangent.scale(h),d):this.vector3InterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||_v).scale(t.repeatCount))}break}case s.ANIMATIONTYPE_VECTOR2:{let p=f?this.vector2InterpolateFunctionWithTangents(l,a.outTangent.scale(h),c,o.inTangent.scale(h),d):this.vector2InterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||gv).scale(t.repeatCount))}break}case s.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(l,c,d);case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(l,c,d).add((t.offsetValue||Ev).scale(t.repeatCount))}break}case s.ANIMATIONTYPE_COLOR3:{let p=f?this.color3InterpolateFunctionWithTangents(l,a.outTangent.scale(h),c,o.inTangent.scale(h),d):this.color3InterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||vv).scale(t.repeatCount))}break}case s.ANIMATIONTYPE_COLOR4:{let p=f?this.color4InterpolateFunctionWithTangents(l,a.outTangent.scale(h),c,o.inTangent.scale(h),d):this.color4InterpolateFunction(l,c,d);switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return p;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return p.add((t.offsetValue||Sv).scale(t.repeatCount))}break}case s.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case s.ANIMATIONLOOPMODE_CYCLE:case s.ANIMATIONLOOPMODE_CONSTANT:case s.ANIMATIONLOOPMODE_YOYO:return s.AllowMatricesInterpolation?this.matrixInterpolateFunction(l,c,d,t.workValue):l;case s.ANIMATIONLOOPMODE_RELATIVE:case s.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return l}break}}return 0}matrixInterpolateFunction(e,t,i,r){return s.AllowMatrixDecomposeForInterpolation?r?(H.DecomposeLerpToRef(e,t,i,r),r):H.DecomposeLerp(e,t,i):r?(H.LerpToRef(e,t,i,r),r):H.Lerp(e,t,i)}clone(e=!1){let t=new s(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 s.ANIMATIONTYPE_QUATERNION:if(n=Se.FromArray(o.values),o.values.length>=8){let d=Se.FromArray(o.values.slice(4,8));d.equals(Se.Zero())||(l=d)}if(o.values.length>=12){let d=Se.FromArray(o.values.slice(8,12));d.equals(Se.Zero())||(c=d)}o.values.length>=13&&(f=o.values[12]);break;case s.ANIMATIONTYPE_MATRIX:n=H.FromArray(o.values),o.values.length>=17&&(f=o.values[16]);break;case s.ANIMATIONTYPE_COLOR3:n=ae.FromArray(o.values),o.values[3]&&(l=ae.FromArray(o.values[3])),o.values[4]&&(c=ae.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break;case s.ANIMATIONTYPE_COLOR4:n=Me.FromArray(o.values),o.values[4]&&(l=Me.FromArray(o.values[4])),o.values[5]&&(c=Me.FromArray(o.values[5])),o.values[6]&&(f=Me.FromArray(o.values[6]));break;case s.ANIMATIONTYPE_VECTOR3:default:n=S.FromArray(o.values),o.values[3]&&(l=S.FromArray(o.values[3])),o.values[4]&&(c=S.FromArray(o.values[4])),o.values[5]&&(f=o.values[5]);break}let h={};h.frame=o.frame,h.value=n,l!=null&&(h.inTangent=l),c!=null&&(h.outTangent=c),f!=null&&(h.interpolation=f),r.push(h)}if(t.setKeys(r),e.ranges)for(a=0;a{let n=new mi;n.addEventListener("readystatechange",()=>{if(n.readyState==4)if(n.status==200){let a=JSON.parse(n.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")}),n.open("GET",t),n.send()})}static async ParseFromSnippetAsync(e){return await new Promise((t,i)=>{let r=new mi;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){let n=JSON.parse(JSON.parse(r.responseText).jsonPayload);if(n.animations){let a=JSON.parse(n.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(n.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()})}};Ne._UniqueIdGenerator=0;Ne.AllowMatricesInterpolation=!1;Ne.AllowMatrixDecomposeForInterpolation=!0;Ne.InheritOriginalValueFromActiveAnimations=!1;Ne.SnippetUrl="https://snippet.babylonjs.com";Ne.ANIMATIONTYPE_FLOAT=0;Ne.ANIMATIONTYPE_VECTOR3=1;Ne.ANIMATIONTYPE_QUATERNION=2;Ne.ANIMATIONTYPE_MATRIX=3;Ne.ANIMATIONTYPE_COLOR3=4;Ne.ANIMATIONTYPE_COLOR4=7;Ne.ANIMATIONTYPE_VECTOR2=5;Ne.ANIMATIONTYPE_SIZE=6;Ne.ANIMATIONLOOPMODE_RELATIVE=0;Ne.ANIMATIONLOOPMODE_CYCLE=1;Ne.ANIMATIONLOOPMODE_CONSTANT=2;Ne.ANIMATIONLOOPMODE_YOYO=4;Ne.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;Ne.CreateFromSnippetAsync=Ne.ParseFromSnippetAsync;Ke("BABYLON.Animation",Ne);pt._AnimationRangeFactory=(s,e,t)=>new co(s,e,t)});var Vc,yM=C(()=>{nm();ia();Vc=class s{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||(s.EasingFunction.setEasingMode(s.EasingMode),this._radiusBounceTransition=Ne.CreateAnimation("radius",Ne.ANIMATIONTYPE_FLOAT,60,s.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;let t=Ne.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()}};Vc.EasingFunction=new im(.3);Vc.EasingMode=Tr.EASINGMODE_EASEOUT});var fo,DM=C(()=>{nm();dt();xs();Bn();Ee();ia();fo=class s{constructor(){this.onTargetFramingAnimationEndObservable=new Q,this._mode=s.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();s.EasingFunction.setEasingMode(s.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===Le.POINTERDOWN){this._isPointerDown=!0;return}i.type===Le.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 S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new S(-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===s.IgnoreBoundsSizeMode&&(r=ri.upperRadiusLimit?i.upperRadiusLimit:r),r}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;let e=Xt.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=Ne.CreateAnimation("beta",Ne.ANIMATIONTYPE_FLOAT,60,s.EasingFunction));let r=Ne.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=Xt.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}};fo.EasingFunction=new sm;fo.EasingMode=Tr.EASINGMODE_EASEINOUT;fo.IgnoreBoundsSizeMode=0;fo.FitFrustumSidesMode=1});var am,Tv,Ar,Av=C(()=>{$e();Qe();Ds();Ee();Wi();Yl();Fr();pt.AddNodeConstructor("TargetCamera",(s,e)=>()=>new Ar(s,S.Zero(),e));am=H.Zero(),Tv=Se.Identity(),Ar=class s extends we{constructor(e,t,i,r=!0){super(e,t,i,r),this.cameraDirection=new S(0,0,0),this.cameraRotation=new me(0,0),this.updateUpVectorFromRotation=!1,this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this._panningEpsilon=je,this._rotationEpsilon=je,this.lockedTarget=null,this._currentTarget=S.Zero(),this._initialFocalDistance=1,this._viewMatrix=H.Zero(),this._cameraTransformMatrix=H.Zero(),this._cameraRotationMatrix=H.Zero(),this._transformedReferencePoint=S.Zero(),this._deferredPositionUpdate=new S,this._deferredRotationQuaternionUpdate=new Se,this._deferredRotationUpdate=new S,this._deferredUpdated=!1,this._deferOnly=!1,this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0,this._referencePoint=S.Forward(this.getScene().useRightHandedSystem),this.rotation=new S(0,this.getScene().useRightHandedSystem?Math.PI:0,0)}getFrontPosition(e){this.getWorldMatrix();let t=W.Vector3[0],i=W.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 S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new Se(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+=je),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),this.getScene().useRightHandedSystem?H.LookAtRHToRef(this.position,e,S.UpReadOnly,am):H.LookAtLHToRef(this.position,e,S.UpReadOnly,am),am.invert();let t=this.rotationQuaternion||Tv;Se.FromRotationMatrixToRef(am,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(W.Matrix[0]),S.TransformNormalToRef(this.cameraDirection,W.Matrix[0],W.Vector3[0]),this._deferredPositionUpdate.addInPlace(W.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()&&(Se.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,n=this.speed*this._rotationEpsilon;t&&(Math.abs(this.cameraDirection.x){We();jt();Ds();Ki={},Gc=class{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){let t=e.getSimpleName();if(this.attached[t]){X.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=we.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],n=De.Serialize(r);t[r.getClassName()]=n}e.inputsmgr=t}parse(e){let t=e.inputsmgr;if(t){this.clear();for(let i in t){let r=Ki[i];if(r){let n=t[i],a=De.Parse(()=>new r,n,null);this.add(a)}}}else for(let i in this.attached){let r=Ki[this.attached[i].getClassName()];if(r){let n=De.Parse(()=>new r,e,null);this.remove(this.attached[i]),this.add(n)}}}}});var Rh,PM=C(()=>{$e();Qe();At();xs();Rh=class{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement(),r=0,n=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=o=>{var h,d;let l=o.event,c=l.pointerType==="touch";if(o.type!==Le.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!==Le.POINTERDOWN&&o.type!==Le.POINTERDOUBLETAP&&c&&((h=this._pointA)==null?void 0:h.pointerId)!==l.pointerId&&((d=this._pointB)==null?void 0:d.pointerId)!==l.pointerId)return;if(o.type===Le.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===Le.POINTERDOUBLETAP)this.onDoubleTap(l.pointerType);else if(o.type===Le.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||n)&&(this.onMultiTouch(this._pointA,this._pointB,r,0,n,null),r=0,n=null),this._currentMousePointerIdDown=-1,this.onButtonUp(l),e||l.preventDefault()}else if(o.type===Le.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,_,n,g),n=g,r=_}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Le.POINTERDOWN|Le.POINTERUP|Le.POINTERMOVE|Le.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,r=0,n=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);let a=this.camera.getScene().getEngine().getHostWindow();a&&se.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){let e=this.camera.getScene().getEngine().getHostWindow();e&&se.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){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,n,a){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}};b([L()],Rh.prototype,"buttons",void 0)});var ul,LM=C(()=>{$e();Qe();PM();ul=class extends Rh{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,n,a){i===0&&n===null||r===0&&a===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,r),this._computeMultiTouchPanning(n,a)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._shouldStartPinchZoom?(this._computePinchZoom(i,r),this._isPinching=!0):this._computeMultiTouchPanning(n,a)):this.multiTouchPanning?this._computeMultiTouchPanning(n,a):this.pinchZoom&&this._computePinchZoom(i,r))}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._twoFingerActivityCount=0,this._isPinching=!1}};b([L()],ul.prototype,"pinchZoom",void 0);b([L()],ul.prototype,"multiTouchPanning",void 0);b([L()],ul.prototype,"multiTouchPanAndZoom",void 0)});var wr,OM=C(()=>{$e();Qe();dn();LM();wr=class s extends ul{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||s.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,n,a){this._shouldStartPinchZoom=this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(r)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance,super.onMultiTouch(e,t,i,r,n,a)}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton,super.onButtonDown(e)}onButtonUp(e){super.onButtonUp(e)}onLostFocus(){this._isPanClick=!1,super.onLostFocus()}};wr.MinimumRadiusForPinch=.001;b([L()],wr.prototype,"buttons",void 0);b([L()],wr.prototype,"angularSensibilityX",void 0);b([L()],wr.prototype,"angularSensibilityY",void 0);b([L()],wr.prototype,"pinchPrecision",void 0);b([L()],wr.prototype,"pinchDeltaPercentage",void 0);b([L()],wr.prototype,"useNaturalPinchZoom",void 0);b([L()],wr.prototype,"panningSensibility",void 0);Ki.ArcRotateCameraPointersInput=wr});var Rr,NM=C(()=>{$e();Qe();dn();bu();At();Rr=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=se.BackCompatCameraNoPreventDefault(arguments),!this._onCanvasBlurObserver&&(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{let i=t.event;if(!i.metaKey){if(t.type===Is.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{$e();Qe();dn();xs();Jo();Ee();Wi();Mu();Mi();At();j4=40,ho=class{constructor(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new S(0,0,0),this._globalOffset=new S(0,0,0),this._inertialPanning=S.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=se.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==Le.POINTERWHEEL)return;let i=t.event,r,n=i.deltaMode===Cs.DOM_DELTA_LINE?j4:1,a=-(i.deltaY*n);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=Ye(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,Le.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=pr.FromPositionAndNormal(e.target,t)}_getPosition(){var n;let e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,H.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=S.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));let r=0;return this._hitPlane&&(r=(n=i.intersectsPlane(this._hitPlane))!=null?n: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 n=e/i/t.radius,a=this._getPosition(),o=W.Vector3[6];a.subtractToRef(t.target,o),o.scaleInPlace(n),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x){OM();NM();FM();dn();om=class extends Gc{constructor(e){super(e)}addMouseWheel(){return this.add(new ho),this}addPointers(){return this.add(new wr),this}addKeyboard(){return this.add(new Rr),this}}});function Z4(s){let e=Math.PI/2;return s.x===0&&s.z===0||(e=Math.acos(s.x/Math.sqrt(Math.pow(s.x,2)+Math.pow(s.z,2)))),s.z<0&&(e=2*Math.PI-e),e}function q4(s,e){return Math.acos(s/e)}function ji(s,e){return isNaN(s)?e:s}var _t,lm=C(()=>{$e();Qe();dt();Ee();Mi();Fr();ut();uv();yM();DM();Ds();Av();wM();Wi();At();Pt();pt.AddNodeConstructor("ArcRotateCamera",(s,e)=>()=>new _t(s,0,0,1,S.Zero(),e));_t=class s 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 H,this._upToYMatrix=new H,this._upVector=S.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){H.RotationAlignToRef(S.UpReadOnly,this._upVector,this._yToUpMatrix),H.RotationAlignToRef(this._upVector,S.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 Vc,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 fo,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 Uc,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,r,n,a,o=!0){super(e,S.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=S.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=me.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new H,this.panningAxis=new S(1,1,0),this._transformedDirection=new S,this.mapPanning=!1,this._isInterpolating=!1,this.onMeshTargetChangedObservable=new Q,this.checkCollisions=!1,this.collisionRadius=new S(.5,.5,.5),this._previousPosition=S.Zero(),this._collisionVelocity=S.Zero(),this._newPosition=S.Zero(),this._computationVector=S.Zero(),this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget=new S(NaN,NaN,NaN),this._goalTargetScreenOffset=new me(NaN,NaN),this._onCollisionPositionChange=(l,c,f=null)=>{f?(this.setPosition(c),this.onCollide&&this.onCollide(f)):this._previousPosition.copyFrom(this._position);let h=Math.cos(this.alpha),d=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*h*m,this.radius*u,this.radius*d*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=S.Zero(),n&&this.setTarget(n),this.alpha=t,this.beta=i,this.radius=r,this.getViewMatrix(),this.inputs=new om(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new S(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=me.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>je&&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,n=this.targetScreenOffset,a){var o,l,c,f,h,d,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=ji(e,this._goalAlpha),this._goalBeta=ji(t,this._goalBeta),this._goalRadius=ji(i,this._goalRadius),this._goalTarget.set(ji(r.x,this._goalTarget.x),ji(r.y,this._goalTarget.y),ji(r.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(ji(n.x,this._goalTargetScreenOffset.x),ji(n.y,this._goalTargetScreenOffset.y)),this._goalAlpha=Ye(this._goalAlpha,(o=this.lowerAlphaLimit)!=null?o:-1/0,(l=this.upperAlphaLimit)!=null?l:1/0),this._goalBeta=Ye(this._goalBeta,(c=this.lowerBetaLimit)!=null?c:-1/0,(f=this.upperBetaLimit)!=null?f:1/0),this._goalRadius=Ye(this._goalRadius,(h=this.lowerRadiusLimit)!=null?h:-1/0,(d=this.upperRadiusLimit)!=null?d:1/0),this._goalTarget.y=Ye(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 n=arguments;t=se.BackCompatCameraNoPreventDefault(n),this._useCtrlForPanning=i,this._panningMouseButton=r,typeof n[0]=="boolean"&&(n.length>1&&(this._useCtrlForPanning=n[1]),n.length>2&&(this._panningMouseButton=n[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(this._collisionTriggered)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)&&S.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=Z4(this._computationVector),this.beta=q4(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 n;if(r=(n=this.overrideCloneAlphaBetaRadius)!=null?n: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 n=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)&&S.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),n.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,n,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget.copyFrom(n),this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;let i=G.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===we.ORTHOGRAPHIC_CAMERA){let n=this.getScene().getEngine().getAspectRatio(this),a=r*this.zoomOnFactor/2;this.orthoLeft=-a*n,this.orthoRight=a*n,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 n=e||this.getScene().meshes;i=G.MinMax(n),r=S.Distance(i.min,i.max)}else{let n=e;i=n,r=n.distance}this._target=G.Center(i),t||(this.maxZ=r*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case we.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case we.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case we.RIG_MODE_STEREOSCOPIC_OVERUNDER:case we.RIG_MODE_STEREOSCOPIC_INTERLACED:case we.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case we.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}let r=new s(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 we.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case we.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case we.RIG_MODE_STEREOSCOPIC_OVERUNDER:case we.RIG_MODE_STEREOSCOPIC_INTERLACED:case we.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case we.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=S.Distance(e,t),a=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),l=o*a,f=r*.5*i,h=f*Math.sqrt(1+1/(l*l)),d=f*Math.sqrt(1+1/(o*o));return Math.max(h,d)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}};b([L()],_t.prototype,"alpha",void 0);b([L()],_t.prototype,"beta",void 0);b([L()],_t.prototype,"radius",void 0);b([L()],_t.prototype,"overrideCloneAlphaBetaRadius",void 0);b([ui("target")],_t.prototype,"_target",void 0);b([nu("targetHost")],_t.prototype,"_targetHost",void 0);b([L()],_t.prototype,"inertialAlphaOffset",void 0);b([L()],_t.prototype,"inertialBetaOffset",void 0);b([L()],_t.prototype,"inertialRadiusOffset",void 0);b([L()],_t.prototype,"lowerAlphaLimit",void 0);b([L()],_t.prototype,"upperAlphaLimit",void 0);b([L()],_t.prototype,"lowerBetaLimit",void 0);b([L()],_t.prototype,"upperBetaLimit",void 0);b([L()],_t.prototype,"lowerRadiusLimit",void 0);b([L()],_t.prototype,"upperRadiusLimit",void 0);b([L()],_t.prototype,"lowerTargetYLimit",void 0);b([L()],_t.prototype,"inertialPanningX",void 0);b([L()],_t.prototype,"inertialPanningY",void 0);b([L()],_t.prototype,"pinchToPanMaxDistance",void 0);b([L()],_t.prototype,"panningDistanceLimit",void 0);b([ui()],_t.prototype,"panningOriginTarget",void 0);b([L()],_t.prototype,"panningInertia",void 0);b([L()],_t.prototype,"zoomToMouseLocation",null);b([L()],_t.prototype,"zoomOnFactor",void 0);b([tc()],_t.prototype,"targetScreenOffset",void 0);b([L()],_t.prototype,"allowUpsideDown",void 0);b([L()],_t.prototype,"useInputToRestoreState",void 0);b([L()],_t.prototype,"restoreStateInterpolationFactor",void 0);Ke("BABYLON.ArcRotateCamera",_t)});var tt,uo=C(()=>{$e();Qe();Ee();Je();Fr();Xa();Pt();ih();jt();tt=class s extends pt{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 ae(1,1,1),this.specular=new ae(1,1,1),this.falloffType=s.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=s.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 Wt(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,n=!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,Fi.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Fi.Color3[0],this.range,a),r&&(this.specular.scaleToRef(c,Fi.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Fi.Color3[1],this.radius,a)),o=!0}if(this.transferTexturesToEffect(i,a),t.shadowsEnabled&&this.shadowEnabled&&n){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=s.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;let r=De.Clone(i,this);return e&&(r.name=e),t&&(r.parent=t),r.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(r),r}serialize(){let e=De.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 De.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){let r=pt.Construct("Light_Type_"+e,t,i);return r||null}static Parse(e,t){let i=s.GetConstructorFromName(e.type,e.name,t);if(!i)return null;let r=De.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 n=0;n{let n=t.apply(e,r);if(this._clusteredContainer)return n;for(let a of r)a._resyncLightSource(this);return n};let i=e.splice;if(e.splice=(r,n)=>{let a=i.call(e,r,n!=null?n: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 n=t.apply(e,r);return this._resyncMeshes(),n};let i=e.splice;e.splice=(r,n)=>{let a=i.call(e,r,n!=null?n: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===s.INTENSITYMODE_AUTOMATIC&&(t===s.LIGHTTYPEID_DIRECTIONALLIGHT?i=s.INTENSITYMODE_ILLUMINANCE:i=s.INTENSITYMODE_LUMINOUSINTENSITY),t){case s.LIGHTTYPEID_POINTLIGHT:case s.LIGHTTYPEID_SPOTLIGHT:switch(i){case s.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case s.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case s.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case s.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case s.INTENSITYMODE_ILLUMINANCE:e=1;break;case s.INTENSITYMODE_LUMINANCE:{let r=this.radius;r=Math.max(r,.001),e=2*Math.PI*(1-Math.cos(r));break}}break;case s.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;b([Kt()],tt.prototype,"diffuse",void 0);b([Kt()],tt.prototype,"specular",void 0);b([L()],tt.prototype,"falloffType",void 0);b([L()],tt.prototype,"intensity",void 0);b([L()],tt.prototype,"range",null);b([L()],tt.prototype,"intensityMode",null);b([L()],tt.prototype,"radius",null);b([L()],tt.prototype,"_renderPriority",void 0);b([ie("_reorderLightsInScene")],tt.prototype,"renderPriority",void 0);b([L("shadowEnabled")],tt.prototype,"_shadowEnabled",void 0);b([L("excludeWithLayerMask")],tt.prototype,"_excludeWithLayerMask",void 0);b([L("includeOnlyWithLayerMask")],tt.prototype,"_includeOnlyWithLayerMask",void 0);b([L("lightmapMode")],tt.prototype,"_lightmapMode",void 0)});var Br,cm=C(()=>{$e();Qe();Ee();Je();Fr();uo();Pt();pt.AddNodeConstructor("Light_Type_3",(s,e)=>()=>new Br(s,S.Zero(),e));Br=class extends tt{constructor(e,t,i,r){super(e,i,r),this.groundColor=new ae(0,0,0),this.direction=t||S.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=S.Normalize(e.subtract(S.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){let i=S.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=S.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=H.Identity()),this._worldMatrix}getTypeID(){return tt.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}};b([Kt()],Br.prototype,"groundColor",void 0);b([ui()],Br.prototype,"direction",void 0);Ke("BABYLON.HemisphericLight",Br)});var as,fm=C(()=>{$e();Qe();Ee();uo();Yl();as=class extends tt{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=H.Identity(),this._projectionMatrix=H.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=S.Zero()),S.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=S.Zero()),S.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=S.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();let e=S.Cross(this.direction,mr.Y),t=S.Cross(e,this.direction);return S.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=S.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=H.Identity()),H.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=W.Vector3[0],i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),S.NormalizeToRef(this.getShadowDirection(e),t),Math.abs(S.Dot(t,S.Up()))===1&&(t.z=1e-13);let r=W.Vector3[1];return i.addToRef(t,r),H.LookAtLHToRef(i,r,S.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e!=null?e:this._viewMatrix,t!=null?t:[]),this._projectionMatrix}};b([ui()],as.prototype,"position",null);b([ui()],as.prototype,"direction",null);b([L()],as.prototype,"shadowMinZ",null);b([L()],as.prototype,"shadowMaxZ",null)});var rr,BM=C(()=>{$e();Qe();Ee();Fr();uo();fm();Pt();pt.AddNodeConstructor("Light_Type_1",(s,e)=>()=>new rr(s,S.Zero(),e));rr=class extends as{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;H.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=S.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let h=Number.MAX_VALUE,d=-Number.MAX_VALUE;for(let u=0;uthis._orthoRight&&(this._orthoRight=f.x),f.y>this._orthoTop&&(this._orthoTop=f.y),this.autoCalcShadowZBounds&&(f.zd&&(d=f.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=h,this._shadowMaxZ=d)}let n=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;H.OrthoOffCenterLHToRef(this._orthoLeft-n*this.shadowOrthoScale,this._orthoRight+n*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}};b([L()],rr.prototype,"shadowFrustumSize",null);b([L()],rr.prototype,"shadowOrthoScale",null);b([L()],rr.prototype,"autoUpdateExtends",void 0);b([L()],rr.prototype,"autoCalcShadowZBounds",void 0);b([L("orthoLeft")],rr.prototype,"_orthoLeft",void 0);b([L("orthoRight")],rr.prototype,"_orthoRight",void 0);b([L("orthoTop")],rr.prototype,"_orthoTop",void 0);b([L("orthoBottom")],rr.prototype,"_orthoBottom",void 0);Ke("BABYLON.DirectionalLight",rr)});var ra,UM=C(()=>{$e();Qe();Ee();Fr();uo();fm();Pt();pt.AddNodeConstructor("Light_Type_0",(s,e)=>()=>new ra(s,S.Zero(),e));ra=class extends as{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 S(1,0,0);case 1:return new S(-1,0,0);case 2:return new S(0,-1,0);case 3:return new S(0,1,0);case 4:return new S(0,0,1);case 5:return new S(0,0,-1)}return S.Zero()}_setDefaultShadowProjectionMatrix(e,t,i){let r=this.getScene().activeCamera,n=this.getDepthMinZ(r),a=this.getDepthMaxZ(r),o=this.getScene().getEngine().useReverseDepthBuffer;H.PerspectiveFovLHToRef(this.shadowAngle,1,o?a:n,o?n: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}};b([L()],ra.prototype,"shadowAngle",null);Ke("BABYLON.PointLight",ra)});var ni,Rv=C(()=>{$e();Qe();Ee();Fr();uo();fm();pi();Pt();pt.AddNodeConstructor("Light_Type_2",(s,e)=>()=>new ni(s,S.Zero(),S.Zero(),0,0,e));ni=class s extends as{get iesProfileTexture(){return this._iesProfileTexture}set iesProfileTexture(e){this._iesProfileTexture!==e&&(this._iesProfileTexture=e,this._iesProfileTexture&&s._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()&&(s._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled(()=>{this._markMeshesAsLightDirty()}):s._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,n,a,o){super(e,a,o),this._innerAngle=0,this._iesProfileTexture=null,this._projectionTextureMatrix=H.Zero(),this._projectionTextureLightNear=1e-6,this._projectionTextureLightFar=1e3,this._projectionTextureUpDirection=S.Up(),this._projectionTextureViewLightDirty=!0,this._projectionTextureProjectionLightDirty=!0,this._projectionTextureDirty=!0,this._projectionTextureViewTargetVector=S.Zero(),this._projectionTextureViewLightMatrix=H.Zero(),this._projectionTextureProjectionLightMatrix=H.Zero(),this._projectionTextureScalingMatrix=H.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=n}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 n=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;H.PerspectiveFovLHToRef(n,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),H.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,n=1/Math.tan(this._angle/2);H.FromValuesToRef(n/1,0,0,0,0,n,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;H.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=S.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=S.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=S.Normalize(this.transformedDirection):i=S.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())}};b([L()],ni.prototype,"angle",null);b([L()],ni.prototype,"innerAngle",null);b([L()],ni.prototype,"shadowAngleScale",null);b([L()],ni.prototype,"exponent",void 0);b([L()],ni.prototype,"projectionTextureLightNear",null);b([L()],ni.prototype,"projectionTextureLightFar",null);b([L()],ni.prototype,"projectionTextureUpDirection",null);b([qe("projectedLightTexture")],ni.prototype,"_projectionTexture",void 0);Ke("BABYLON.SpotLight",ni)});function VM(s){let e=s.pathArray,t=s.closeArray||!1,i=s.closePath||!1,r=s.invertUV||!1,n=Math.floor(e[0].length/2),a=s.offset||n;a=a>n?n:Math.floor(a);let o=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,l=s.uvs,c=s.colors,f=[],h=[],d=[],u=[],m=[],p=[],_=[],g=[],v,I=[],x=[],T,A,R;if(e.length<2){let de=[],ke=[];for(A=0;A0&&(V=F[R].subtract(F[R-1]).length(),O=V+_[T],m[T].push(O),_[T]=O),R++;i&&(R--,f.push(F[0].x,F[0].y,F[0].z),V=F[R].subtract(F[0]).length(),O=V+_[T],m[T].push(O),_[T]=O),I[T]=N+D,x[T]=P,P+=N+D}let U,k,z,Z;for(A=0;A{let m=i[0].length,p=o,_=0,g=p._originalBuilderSideOrientation===G.DOUBLESIDE?2:1;for(let v=1;v<=g;++v)for(let I=0;I{Ee();ut();It();Bt();vi();fe.CreateRibbon=VM;G.CreateRibbon=(s,e,t=!1,i,r,n,a=!1,o,l)=>Ns(s,{pathArray:e,closeArray:t,closePath:i,offset:r,updatable:a,sideOrientation:o,instance:l},n)});function GM(s){let e=[],t=[],i=[],r=[],n=s.radius||.5,a=s.tessellation||64,o=s.arc&&(s.arc<=0||s.arc>1)?1:s.arc||1,l=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE;e.push(0,0,0),r.push(.5,.5);let c=Math.PI*2*o,f=o===1?c/a:c/(a-1),h=0;for(let m=0;m{ut();Bt();vi();fe.CreateDisc=GM;G.CreateDisc=(s,e,t,i=null,r,n)=>xv(s,{radius:e,tessellation:t,sideOrientation:n,updatable:r},i)});var kc,WM=C(()=>{Ee();It();ut();G._GroundMeshParser=(s,e)=>kc.Parse(s,e);kc=class s extends G{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=W.Matrix[5];i.invertToRef(r);let n=W.Vector3[8];if(S.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.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 S.TransformCoordinatesFromFloatsToRef(0,o,0,i,n),n.y}getNormalAtCoordinates(e,t){let i=new S(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){let r=this.getWorldMatrix(),n=W.Matrix[5];r.invertToRef(n);let a=W.Vector3[8];if(S.TransformCoordinatesFromFloatsToRef(e,0,t,n,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 S.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),n=this._heightQuads[r*this._subdivisionsX+i],a;return ts.maxHeight){c=!0;let h=s.maxHeight;s.maxHeight=s.minHeight,s.minHeight=h}for(n=0;n<=s.subdivisions;n++)for(a=0;a<=s.subdivisions;a++){let h=new S(a*s.width/s.subdivisions-s.width/2,0,(s.subdivisions-n)*s.height/s.subdivisions-s.height/2),d=(h.x+s.width/2)/s.width*(s.bufferWidth-1)|0,u=(1-(h.z+s.height/2)/s.height)*(s.bufferHeight-1)|0,m=(d+u*s.bufferWidth)*4,p=s.buffer[m]/255,_=s.buffer[m+1]/255,g=s.buffer[m+2]/255,v=s.buffer[m+3]/255;c&&(p=1-p,_=1-_,g=1-g);let I=p*o.r+_*o.g+g*o.b;v>=l?h.y=s.minHeight+(s.maxHeight-s.minHeight)*I:h.y=s.minHeight-je,s.heightBuffer&&(s.heightBuffer[n*(s.subdivisions+1)+a]=h.y),t.push(h.x,h.y,h.z),i.push(0,0,0),r.push(a/s.subdivisions,1-n/s.subdivisions)}for(n=0;n=s.minHeight,_=t[d*3+1]>=s.minHeight,g=t[u*3+1]>=s.minHeight;p&&_&&g&&(e.push(h),e.push(d),e.push(u)),t[m*3+1]>=s.minHeight&&p&&g&&(e.push(m),e.push(h),e.push(u))}fe.ComputeNormals(t,e,i);let f=new fe;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function Cv(s,e={},t){let i=new kc(s,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,Iv(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function bv(s,e,t=null){let i=new G(s,t);return HM(e).applyToMesh(i,e.updatable),i}function Mv(s,e,t={},i=null){let r=t.width||10,n=t.height||10,a=t.subdivisions||1,o=t.minHeight||0,l=t.maxHeight||1,c=t.colorFilter||new ae(.3,.59,.11),f=t.alphaFilter||0,h=t.updatable,d=t.onReady;i=i||ue.LastCreatedScene;let u=new kc(s,i);u._subdivisionsX=a,u._subdivisionsY=a,u._width=r,u._height=n,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,v)=>{zM({width:r,height:n,subdivisions:a,minHeight:o,maxHeight:l,colorFilter:c,buffer:_,bufferWidth:g,bufferHeight:v,alphaFilter:f,heightBuffer:m}).applyToMesh(u,h),d&&d(u,m),u._setReady(!0)};if(typeof e=="string"){i.addPendingData(u);let _=v=>{let I=v.width,x=v.height;if(i.isDisposed){i.removePendingData(u);return}let T=i==null?void 0:i.getEngine().resizeImageBitmap(v,I,x);p(T,I,x),i.removePendingData(u)},g=(v,I)=>{i.removePendingData(u),t.onError&&t.onError(v,I)};se.LoadImage(e,_,g,i.offlineProvider)}else p(e.data,e.width,e.height);return u}var yv=C(()=>{Ee();Je();ut();Bt();WM();At();gt();Wi();vi();fe.CreateGround=Iv;fe.CreateTiledGround=HM;fe.CreateGroundFromHeightMap=zM;G.CreateGround=(s,e,t,i,r,n)=>Cv(s,{width:e,height:t,subdivisions:i,updatable:n},r);G.CreateTiledGround=(s,e,t,i,r,n,a,o,l)=>bv(s,{xmin:e,zmin:t,xmax:i,zmax:r,subdivisions:n,precision:a,updatable:l},o);G.CreateGroundFromHeightMap=(s,e,t,i,r,n,a,o,l,c,f)=>Mv(s,e,{width:t,height:i,subdivisions:r,minHeight:n,maxHeight:a,updatable:l,onReady:c,alphaFilter:f},o)});function hm(s){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=[],n=s.width||s.size||1,a=s.height||s.size||1,o=s.depth||s.size||1,l=s.wrap||!1,c=s.topBaseAt===void 0?1:s.topBaseAt,f=s.bottomBaseAt===void 0?0:s.bottomBaseAt;c=(c+4)%4,f=(f+4)%4;let h=[2,0,3,1],d=[2,0,1,3],u=h[c],m=d[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 R=[[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]],D=[17,18,19,16],M=[22,23,20,21];for(;u>0;)R.unshift(R.pop()),D.unshift(D.pop()),u--;for(;m>0;)P.unshift(P.pop()),M.unshift(M.pop()),m--;R=R.flat(),P=P.flat(),p=p.concat(R).concat(P),t.push(D[0],D[2],D[3],D[0],D[1],D[2]),t.push(M[0],M[2],M[3],M[0],M[1],M[2])}let _=[n/2,a/2,o/2],g=p.reduce((R,P,D)=>R.concat(P*_[D%3]),[]),v=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,I=s.faceUV||new Array(6),x=s.faceColors,T=[];for(let R=0;R<6;R++)I[R]===void 0&&(I[R]=new ft(0,0,1,1)),x&&x[R]===void 0&&(x[R]=new Me(1,1,1,1));for(let R=0;R<6;R++)if(r.push(I[R].z,ze?1-I[R].w:I[R].w),r.push(I[R].x,ze?1-I[R].w:I[R].w),r.push(I[R].x,ze?1-I[R].y:I[R].y),r.push(I[R].z,ze?1-I[R].y:I[R].y),x)for(let P=0;P<4;P++)T.push(x[R].r,x[R].g,x[R].b,x[R].a);fe._ComputeSides(v,g,t,i,r,s.frontUVs,s.backUVs);let A=new fe;if(A.indices=t,A.positions=g,A.normals=i,A.uvs=r,x){let R=v===fe.DOUBLESIDE?T.concat(T):T;A.colors=R}return A}function Dv(s,e={},t=null){let i=new G(s,t);return e.sideOrientation=G._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,hm(e).applyToMesh(i,e.updatable),i}var Pv=C(()=>{Ee();Je();ut();Bt();vi();yv();fe.CreateBox=hm;G.CreateBox=(s,e,t=null,i,r)=>Dv(s,{size:e,sideOrientation:r,updatable:i},t)});function Wc(s){let e=s.pattern||G.NO_FLIP,t=s.tileWidth||s.tileSize||1,i=s.tileHeight||s.tileSize||1,r=s.alignHorizontal||0,n=s.alignVertical||0,a=s.width||s.size||1,o=Math.floor(a/t),l=a-o*t,c=s.height||s.size||1,f=Math.floor(c/i),h=c-f*i,d=t*o/2,u=i*f/2,m=0,p=0,_=0,g=0,v=0,I=0;if(l>0||h>0){switch(_=-d,g=-u,v=d,I=u,r){case G.CENTER:l/=2,_-=l,v+=l;break;case G.LEFT:v+=l,m=-l/2;break;case G.RIGHT:_-=l,m=l/2;break}switch(n){case G.CENTER:h/=2,g-=h,I+=h;break;case G.BOTTOM:I+=h,p=-h/2;break;case G.TOP:g-=h,p=h/2;break}}let x=[],T=[],A=[];A[0]=[0,0,1,0,1,1,0,1],A[1]=[0,0,1,0,1,1,0,1],(e===G.ROTATE_TILE||e===G.ROTATE_ROW)&&(A[1]=[1,1,0,1,0,0,1,0]),(e===G.FLIP_TILE||e===G.FLIP_ROW)&&(A[1]=[1,0,0,0,0,1,1,1]),(e===G.FLIP_N_ROTATE_TILE||e===G.FLIP_N_ROTATE_ROW)&&(A[1]=[0,1,1,1,1,0,0,0]);let R=[],P=[],D=[],M=0;for(let O=0;O0||h>0){let O=h>0&&(n===G.CENTER||n===G.TOP),U=h>0&&(n===G.CENTER||n===G.BOTTOM),k=l>0&&(r===G.CENTER||r===G.RIGHT),z=l>0&&(r===G.CENTER||r===G.LEFT),Z,J,q,Y,K;if(O&&k&&(x.push(_+m,g+p,0),x.push(-d+m,g+p,0),x.push(-d+m,g+h+p,0),x.push(_+m,g+h+p,0),D.push(M,M+1,M+3,M+1,M+2,M+3),M+=4,J=1-l/t,q=1-h/i,Y=1,K=1,Z=[J,q,Y,q,Y,K,J,K],e===G.ROTATE_ROW&&(Z=[1-J,1-q,1-Y,1-q,1-Y,1-K,1-J,1-K]),e===G.FLIP_ROW&&(Z=[1-J,q,1-Y,q,1-Y,K,1-J,K]),e===G.FLIP_N_ROTATE_ROW&&(Z=[J,1-q,Y,1-q,Y,1-K,J,1-K]),R=R.concat(Z),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O&&z&&(x.push(d+m,g+p,0),x.push(v+m,g+p,0),x.push(v+m,g+h+p,0),x.push(d+m,g+h+p,0),D.push(M,M+1,M+3,M+1,M+2,M+3),M+=4,J=0,q=1-h/i,Y=l/t,K=1,Z=[J,q,Y,q,Y,K,J,K],(e===G.ROTATE_ROW||e===G.ROTATE_TILE&&o%2===0)&&(Z=[1-J,1-q,1-Y,1-q,1-Y,1-K,1-J,1-K]),(e===G.FLIP_ROW||e===G.FLIP_TILE&&o%2===0)&&(Z=[1-J,q,1-Y,q,1-Y,K,1-J,K]),(e===G.FLIP_N_ROTATE_ROW||e===G.FLIP_N_ROTATE_TILE&&o%2===0)&&(Z=[J,1-q,Y,1-q,Y,1-K,J,1-K]),R=R.concat(Z),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),U&&k&&(x.push(_+m,u+p,0),x.push(-d+m,u+p,0),x.push(-d+m,I+p,0),x.push(_+m,I+p,0),D.push(M,M+1,M+3,M+1,M+2,M+3),M+=4,J=1-l/t,q=0,Y=1,K=h/i,Z=[J,q,Y,q,Y,K,J,K],(e===G.ROTATE_ROW&&f%2===1||e===G.ROTATE_TILE&&f%1===0)&&(Z=[1-J,1-q,1-Y,1-q,1-Y,1-K,1-J,1-K]),(e===G.FLIP_ROW&&f%2===1||e===G.FLIP_TILE&&f%2===0)&&(Z=[1-J,q,1-Y,q,1-Y,K,1-J,K]),(e===G.FLIP_N_ROTATE_ROW&&f%2===1||e===G.FLIP_N_ROTATE_TILE&&f%2===0)&&(Z=[J,1-q,Y,1-q,Y,1-K,J,1-K]),R=R.concat(Z),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),U&&z&&(x.push(d+m,u+p,0),x.push(v+m,u+p,0),x.push(v+m,I+p,0),x.push(d+m,I+p,0),D.push(M,M+1,M+3,M+1,M+2,M+3),M+=4,J=0,q=0,Y=l/t,K=h/i,Z=[J,q,Y,q,Y,K,J,K],(e===G.ROTATE_ROW&&f%2===1||e===G.ROTATE_TILE&&(f+o)%2===1)&&(Z=[1-J,1-q,1-Y,1-q,1-Y,1-K,1-J,1-K]),(e===G.FLIP_ROW&&f%2===1||e===G.FLIP_TILE&&(f+o)%2===1)&&(Z=[1-J,q,1-Y,q,1-Y,K,1-J,K]),(e===G.FLIP_N_ROTATE_ROW&&f%2===1||e===G.FLIP_N_ROTATE_TILE&&(f+o)%2===1)&&(Z=[J,1-q,Y,1-q,Y,1-K,J,1-K]),R=R.concat(Z),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),O){let j=[];J=0,q=1-h/i,Y=1,K=1,j[0]=[J,q,Y,q,Y,K,J,K],j[1]=[J,q,Y,q,Y,K,J,K],(e===G.ROTATE_TILE||e===G.ROTATE_ROW)&&(j[1]=[1-J,1-q,1-Y,1-q,1-Y,1-K,1-J,1-K]),(e===G.FLIP_TILE||e===G.FLIP_ROW)&&(j[1]=[1-J,q,1-Y,q,1-Y,K,1-J,K]),(e===G.FLIP_N_ROTATE_TILE||e===G.FLIP_N_ROTATE_ROW)&&(j[1]=[J,1-q,Y,1-q,Y,1-K,J,1-K]);for(let ee=0;ee{ut();Bt();fe.CreateTiledPlane=Wc});function YM(s){let t=s.faceUV||new Array(6),i=s.faceColors,r=s.pattern||G.NO_FLIP,n=s.width||s.size||1,a=s.height||s.size||1,o=s.depth||s.size||1,l=s.tileWidth||s.tileSize||1,c=s.tileHeight||s.tileSize||1,f=s.alignHorizontal||0,h=s.alignVertical||0,d=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE;for(let O=0;O<6;O++)t[O]===void 0&&(t[O]=new ft(0,0,1,1)),i&&i[O]===void 0&&(i[O]=new Me(1,1,1,1));let u=n/2,m=a/2,p=o/2,_=[];for(let O=0;O<2;O++)_[O]=Wc({pattern:r,tileWidth:l,tileHeight:c,width:n,height:a,alignVertical:h,alignHorizontal:f,sideOrientation:d});for(let O=2;O<4;O++)_[O]=Wc({pattern:r,tileWidth:l,tileHeight:c,width:o,height:a,alignVertical:h,alignHorizontal:f,sideOrientation:d});let g=h;h===G.BOTTOM?g=G.TOP:h===G.TOP&&(g=G.BOTTOM);for(let O=4;O<6;O++)_[O]=Wc({pattern:r,tileWidth:l,tileHeight:c,width:n,height:o,alignVertical:g,alignHorizontal:f,sideOrientation:d});let v=[],I=[],x=[],T=[],A=[],R=[],P=[],D=[],M,F=0;for(let O=0;O<6;O++){let U=_[O].positions.length;R[O]=[],P[O]=[];for(let k=0;kk+F)),F+=R[O].length,i){let k=i[O];for(let z=0;z{Ee();Je();ut();Bt();Lv();vi();dm=1,Ov=-1;fe.CreateTiledBox=YM});function ZM(s){let e=(s.segments||32)|0,t=s.diameterX||s.diameter||1,i=s.diameterY||s.diameter||1,r=s.diameterZ||s.diameter||1,n=s.arc&&(s.arc<=0||s.arc>1)?1:s.arc||1,a=s.slice&&s.slice<=0?1:s.slice||1,o=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,l=!!s.dedupTopBottomIndices,c=new S(t/2,i/2,r/2),f=2+e,h=2*f,d=[],u=[],m=[],p=[];for(let g=0;g<=f;g++){let v=g/f,I=v*Math.PI*a;for(let x=0;x<=h;x++){let T=x/h,A=T*Math.PI*2*n,R=H.RotationZ(-I),P=H.RotationY(A),D=S.TransformCoordinates(S.Up(),R),M=S.TransformCoordinates(D,P),F=M.multiply(c),N=M.divide(c).normalize();u.push(F.x,F.y,F.z),m.push(N.x,N.y,N.z),p.push(T,ze?1-v:v)}if(g>0){let x=u.length/3;for(let T=x-2*(h+1);T+h+21&&(d.push(T),d.push(T+1),d.push(T+h+1)),(g{Ee();ut();Bt();vi();fe.CreateSphere=ZM;G.CreateSphere=(s,e,t,i,r,n)=>Nv(s,{segments:e,diameterX:t,diameterY:t,diameterZ:t,sideOrientation:n,updatable:r},i)});function QM(s){let e=s.height||2,t=s.diameterTop===0?0:s.diameterTop||s.diameter||1,i=s.diameterBottom===0?0:s.diameterBottom||s.diameter||1;t=t||1e-5,i=i||1e-5;let r=(s.tessellation||24)|0,n=(s.subdivisions||1)|0,a=!!s.hasRings,o=!!s.enclose,l=s.cap===0?0:s.cap||G.CAP_ALL,c=s.arc&&(s.arc<=0||s.arc>1)?1:s.arc||1,f=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,h=s.faceUV||new Array(3),d=s.faceColors,u=c!==1&&o?2:0,m=a?n:1,p=2+(1+u)*m,_;for(_=0;_{let te=pe?t/2:i/2;if(te===0)return;let le,xe,ce,de=pe?h[p-1]:h[0],ke=null;d&&(ke=pe?d[p-1]:d[0]);let Ze=v.length/3,Fe=pe?e/2:-e/2,Xe=new S(0,Fe,0);v.push(Xe.x,Xe.y,Xe.z),I.push(0,pe?1:-1,0);let St=de.y+(de.w-de.y)*.5;x.push(de.x+(de.z-de.x)*.5,ze?1-St:St),ke&&T.push(ke.r,ke.g,ke.b,ke.a);let bt=new me(.5,.5);for(ce=0;ce<=r;ce++){le=Math.PI*2*ce*c/r;let Gt=Math.cos(-le),si=Math.sin(-le);xe=new S(Gt*te,Fe,si*te);let Gi=new me(Gt*bt.x+.5,si*bt.y+.5);v.push(xe.x,xe.y,xe.z),I.push(0,pe?1:-1,0);let Gs=de.y+(de.w-de.y)*Gi.y;x.push(de.x+(de.z-de.x)*Gi.x,ze?1-Gs:Gs),ke&&T.push(ke.r,ke.g,ke.b,ke.a)}for(ce=0;ce{Ee();Je();ut();Bt();vr();Yl();vi();fe.CreateCylinder=QM;G.CreateCylinder=(s,e,t,i,r,n,a,o,l)=>((a===void 0||!(a instanceof nt))&&(a!==void 0&&(l=o||G.DEFAULTSIDE,o=a),a=n,n=1),Fv(s,{height:e,diameterTop:t,diameterBottom:i,tessellation:r,subdivisions:n,sideOrientation:l,updatable:o},a))});function $M(s){let e=[],t=[],i=[],r=[],n=s.diameter||1,a=s.thickness||.5,o=(s.tessellation||16)|0,l=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,c=o+1;for(let h=0;h<=o;h++){let d=h/o,u=h*Math.PI*2/o-Math.PI/2,m=H.Translation(n/2,0,0).multiply(H.RotationY(u));for(let p=0;p<=o;p++){let _=1-p/o,g=p*Math.PI*2/o+Math.PI,v=Math.cos(g),I=Math.sin(g),x=new S(v,I,0),T=x.scale(a/2),A=new me(d,_);T=S.TransformCoordinates(T,m),x=S.TransformNormal(x,m),t.push(T.x,T.y,T.z),i.push(x.x,x.y,x.z),r.push(A.x,ze?1-A.y:A.y);let R=(h+1)%c,P=(p+1)%c;e.push(h*c+p),e.push(h*c+P),e.push(R*c+p),e.push(h*c+P),e.push(R*c+P),e.push(R*c+p)}}fe._ComputeSides(l,t,e,i,r,s.frontUVs,s.backUVs);let f=new fe;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function wv(s,e={},t){let i=new G(s,t);return e.sideOrientation=G._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,$M(e).applyToMesh(i,e.updatable),i}var ey=C(()=>{Ee();ut();Bt();vi();fe.CreateTorus=$M;G.CreateTorus=(s,e,t,i,r,n,a)=>wv(s,{diameter:e,thickness:t,tessellation:i,sideOrientation:a,updatable:n},r)});function ty(s){let e=[],t=[],i=[],r=[],n=s.radius||2,a=s.tube||.5,o=s.radialSegments||32,l=s.tubularSegments||32,c=s.p||2,f=s.q||3,h=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,d=_=>{let g=Math.cos(_),v=Math.sin(_),I=f/c*_,x=Math.cos(I),T=n*(2+x)*.5*g,A=n*(2+x)*v*.5,R=n*Math.sin(I)*.5;return new S(T,A,R)},u,m;for(u=0;u<=o;u++){let g=u%o/o*2*c*Math.PI,v=d(g),I=d(g+.01),x=I.subtract(v),T=I.add(v),A=S.Cross(x,T);for(T=S.Cross(A,x),A.normalize(),T.normalize(),m=0;m{Ee();ut();Bt();vi();fe.CreateTorusKnot=ty;G.CreateTorusKnot=(s,e,t,i,r,n,a,o,l,c)=>Bv(s,{radius:e,tube:t,radialSegments:i,tubularSegments:r,p:n,q:a,sideOrientation:c,updatable:l},o)});var sa,Uv=C(()=>{Ee();We();Rc();ut();eh();Ac();It();At();Pt();G._instancedMeshFactory=(s,e)=>{let t=new sa(s,e);if(e.instancedBuffers){t.instancedBuffers={};for(let i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t};sa=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&&se.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&&se.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&&se.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&&se.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||X.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,y.PositionKind),r),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||X.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 H);let e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,W.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(W.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{Zi=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&&(n.computeBonesUsingShaders=!1);continue}if(!(!n.computeBonesUsingShaders||n.numBoneInfluencers===0)){if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes){for(let a of n.subMeshes)if(a.effect===t){n.computeBonesUsingShaders=!1;break}}}}}else{let i=this._defines[this._currentRank];if(i)for(let r=0;r{Ee();Vi();os=class extends oe{constructor(e,t,i=!0,r=!1){super(e,t,void 0,r),this._normalMatrix=new H,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 po(s){let e=s.getVertexBuffers();if(!e)return null;let t=ry.get(s);if(!t)t=new Map,ry.set(s,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 n=r.byteOffset,a=r.byteStride,o=r.type,l=r.normalized;t.set(i,{offset:n,stride:a,type:o,normalized:l})}}return t}function _o(s,e){e.forEach((t,i)=>{let r=`vp_${i}_info`;s.setFloat4(r,t.offset,t.stride,t.type,t.normalized?1:0)})}var ry,Ih=C(()=>{ry=new WeakMap});var Vv,sr,um=C(()=>{jt();vr();Ee();It();pi();Pt();mo();sc();Hc();gt();Ps();Ui();Ih();Vv={effect:null,subMesh:null},sr=class s extends os{constructor(e,t,i,r={},n=!0){super(e,t,n),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 H,this._cachedWorldViewProjectionMatrix=new H,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;rn===e||n.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 A,R,P,D;let r=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){let M=r?i._drawWrapper:this._drawWrapper;if(M.effect&&M._wasPreviouslyReady&&M._wasPreviouslyUsingInstances===t)return!0}let n=this.getScene(),a=n.getEngine(),o=[],l=[],c=null,f=this._shaderPath,h=this._options.uniforms,d=this._options.uniformBuffers,u=this._options.samplers;a.getCaps().multiview&&n.activeCamera&&n.activeCamera.outputRenderTarget&&n.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,o.push("#define MULTIVIEW"),h.indexOf("viewProjection")!==-1&&h.indexOf("viewProjectionR")===-1&&h.push("viewProjectionR"));for(let M=0;M4&&(l.push(y.MatricesIndicesExtraKind),l.push(y.MatricesWeightsExtraKind));let M=e.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),c=new Zi,c.addCPUSkinningFallback(0,e),M.isUsingTextureForMatrices?(o.push("#define BONETEXTURE"),h.indexOf("boneTextureInfo")===-1&&h.push("boneTextureInfo"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(o.push("#define BonesPerMesh "+(M.bones.length+1)),h.indexOf("mBones")===-1&&h.push("mBones"))}else o.push("#define NUM_BONE_INFLUENCERS 0");let m=0,p=e?e.morphTargetManager:null;if(p){let M=o.indexOf("#define UV1")!==-1,F=o.indexOf("#define UV2")!==-1,N=o.indexOf("#define TANGENT")!==-1,V=o.indexOf("#define NORMAL")!==-1,O=o.indexOf("#define VERTEXCOLOR")!==-1;m=fn(p,o,l,e,!0,V,N,M,F,O),p.isUsingTextureForTargets&&(h.indexOf("morphTargetTextureIndices")===-1&&h.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),m>0&&(h=h.slice(),h.push("morphTargetInfluences"),h.push("morphTargetCount"),h.push("morphTargetTextureInfo"),h.push("morphTargetTextureIndices"))}else o.push("#define NUM_MORPH_INFLUENCERS 0");if(e){let M=e.bakedVertexAnimationManager;M&&M.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),h.indexOf("bakedVertexAnimationSettings")===-1&&h.push("bakedVertexAnimationSettings"),h.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&h.push("bakedVertexAnimationTextureSizeInverted"),h.indexOf("bakedVertexAnimationTime")===-1&&h.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture"),t&&l.push("bakedVertexAnimationSettingsInstanced"))}for(let M in this._textures)if(!this._textures[M].isReady())return!1;for(let M in this._internalTextures)if(!this._internalTextures[M].isReady)return!1;e&&this.needAlphaTestingForMesh(e)&&o.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&(Pi(h),on(this,n,o)),n.fogEnabled&&(e!=null&&e.applyFog)&&n.fogMode!==nt.FOGMODE_NONE&&(o.push("#define FOG"),h.indexOf("view")===-1&&h.push("view"),h.indexOf("vFogInfos")===-1&&h.push("vFogInfos"),h.indexOf("vFogColor")===-1&&h.push("vFogColor")),this._useLogarithmicDepth&&(o.push("#define LOGARITHMICDEPTH"),h.indexOf("logarithmicDepthConstant")===-1&&h.push("logarithmicDepthConstant"));let _=i?i.getRenderingMesh():e;if(_&&this.useVertexPulling){let M=_.geometry;M&&(this._vertexPullingMetadata=po(M),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((N,V)=>{h.push(`vp_${V}_info`)})),o.push("#define USE_VERTEX_PULLING");let F=(A=_.geometry)==null?void 0:A.getIndexBuffer();F&&!_.isUnIndexed&&(o.push("#define VERTEX_PULLING_USE_INDEX_BUFFER"),F.is32Bits&&o.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS"))}this.customShaderNameResolve&&(h=h.slice(),d=d.slice(),u=u.slice(),f=this.customShaderNameResolve(this.name,h,d,u,o,l));let g=r?i._getDrawWrapper(void 0,!0):this._drawWrapper,v=(R=g==null?void 0:g.effect)!=null?R:null,I=(P=g==null?void 0:g.defines)!=null?P:null,x=o.join(` +`),T=v;return I!==x&&(T=a.createEffect(f,{attributes:l,uniformsNames:h,uniformBuffersNames:d,samplers:u,defines:x,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:m},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},a),r?i.setEffect(T,x,this._materialContext):g&&g.setEffect(T,x),this._onEffectCreatedObservable&&(Vv.effect=T,Vv.subMesh=(D=i!=null?i:e==null?void 0:e.subMeshes[0])!=null?D:null,this._onEffectCreatedObservable.notifyObservers(Vv))),g._wasPreviouslyUsingInstances=!!t,T!=null&&T.isReady()?(v!==T&&n.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 n=this.getScene();r.indexOf("worldView")!==-1&&(e.multiplyToRef(n.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),r.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(n.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),r.indexOf("view")!==-1&&i.setMatrix("view",n.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 h;let n=r&&this._storeEffectOnSubMeshes,a=i!=null?i:n?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 d=0;dnew s(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 n=this._options[r];Array.isArray(n)&&(this._options[r]=n.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 n=this._textureArrays[r];for(let a=0;anew s(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes),e,t,i),n;e.stencil&&r.stencil.parse(e.stencil,t,i);for(n in e.textures)r.setTexture(n,ne.Parse(e.textures[n],t,i));for(n in e.textureArrays){let a=e.textureArrays[n],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(n,a)}for(n in e.colors4){let a=e.colors4[n];r.setColor4(n,{r:a[0],g:a[1],b:a[2],a:a[3]})}for(n in e.colors4Arrays){let a=e.colors4Arrays[n].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(n,a)}for(n in e.vectors2){let a=e.vectors2[n];r.setVector2(n,{x:a[0],y:a[1]})}for(n in e.vectors3){let a=e.vectors3[n];r.setVector3(n,{x:a[0],y:a[1],z:a[2]})}for(n in e.vectors4){let a=e.vectors4[n];r.setVector4(n,{x:a[0],y:a[1],z:a[2],w:a[3]})}for(n in e.quaternions)r.setQuaternion(n,Se.FromArray(e.quaternions[n]));for(n in e.matrices)r.setMatrix(n,H.FromArray(e.matrices[n]));for(n in e.matrixArray)r._matrixArrays[n]=new Float32Array(e.matrixArray[n]);for(n in e.matrices3x3)r.setMatrix3x3(n,e.matrices3x3[n]);for(n in e.matrices2x2)r.setMatrix2x2(n,e.matrices2x2[n]);for(n in e.vectors2Arrays)r.setArray2(n,e.vectors2Arrays[n]);for(n in e.vectors3Arrays)r.setArray3(n,e.vectors3Arrays[n]);for(n in e.vectors4Arrays)r.setArray4(n,e.vectors4Arrays[n]);for(n in e.quaternionsArrays)r.setArray4(n,e.quaternionsArrays[n]);return r}static async ParseFromFileAsync(e,t,i,r=""){return await new Promise((n,a)=>{let o=new mi;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),n(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,n)=>{let a=new mi;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 n("Unable to load the snippet "+e)}),a.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),a.send()})}};sr.SnippetUrl="https://snippet.babylonjs.com";sr.CreateFromSnippetAsync=sr.ParseFromSnippetAsync;Ke("BABYLON.ShaderMaterial",sr)});var sy,Q4,na=C(()=>{w();sy="bonesDeclaration",Q4=`#if NUM_BONE_INFLUENCERS>0 +#ifndef USE_VERTEX_PULLING +attribute matricesIndices : vec4f;attribute matricesWeights : vec4f; +#if NUM_BONE_INFLUENCERS>4 +attribute matricesIndicesExtra : vec4f;attribute matricesWeightsExtra : vec4f; +#endif +#endif +#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +#ifdef BONETEXTURE +var boneSampler : texture_2d;uniform boneTextureInfo : vec2f; +#else +uniform mBones : array; +#endif +#ifdef BONES_VELOCITY_ENABLED +uniform mPreviousBones : array; +#endif +#ifdef BONETEXTURE +fn readMatrixFromRawSampler(smp : texture_2d,index : f32)->mat4x4f +{let offset=i32(index)*4; +let textureWidth=i32(uniforms.boneTextureInfo.x);let y=offset/textureWidth;let x=offset % textureWidth;let m0=textureLoad(smp,vec2(x+0,y),0);let m1=textureLoad(smp,vec2(x+1,y),0);let m2=textureLoad(smp,vec2(x+2,y),0);let m3=textureLoad(smp,vec2(x+3,y),0);return mat4x4f(m0,m1,m2,m3);} +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[sy]||(E.IncludesShadersStoreWGSL[sy]=Q4)});var ny,J4,aa=C(()=>{w();ny="bakedVertexAnimationDeclaration",J4=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +uniform bakedVertexAnimationTime: f32;uniform bakedVertexAnimationSettings: vec4;var bakedVertexAnimationTexture : texture_2d; +#ifdef INSTANCES +attribute bakedVertexAnimationSettingsInstanced : vec4; +#endif +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[ny]||(E.IncludesShadersStoreWGSL[ny]=J4)});var ay,$4,un=C(()=>{w();ay="clipPlaneVertexDeclaration",$4=`#ifdef CLIPPLANE +uniform vClipPlane: vec4;varying fClipDistance: f32; +#endif +#ifdef CLIPPLANE2 +uniform vClipPlane2: vec4;varying fClipDistance2: f32; +#endif +#ifdef CLIPPLANE3 +uniform vClipPlane3: vec4;varying fClipDistance3: f32; +#endif +#ifdef CLIPPLANE4 +uniform vClipPlane4: vec4;varying fClipDistance4: f32; +#endif +#ifdef CLIPPLANE5 +uniform vClipPlane5: vec4;varying fClipDistance5: f32; +#endif +#ifdef CLIPPLANE6 +uniform vClipPlane6: vec4;varying fClipDistance6: f32; +#endif +`;E.IncludesShadersStoreWGSL[ay]||(E.IncludesShadersStoreWGSL[ay]=$4)});var oy,eH,zc=C(()=>{w();oy="fogVertexDeclaration",eH=`#ifdef FOG +varying vFogDistance: vec3f; +#endif +`;E.IncludesShadersStoreWGSL[oy]||(E.IncludesShadersStoreWGSL[oy]=eH)});var ly,tH,go=C(()=>{w();ly="instancesDeclaration",tH=`#ifdef INSTANCES +attribute world0 : vec4;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4; +#ifdef INSTANCESCOLOR +attribute instanceColor : vec4; +#endif +#if defined(THIN_INSTANCES) && !defined(WORLD_UBO) +uniform world : mat4x4; +#endif +#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +attribute previousWorld0 : vec4;attribute previousWorld1 : vec4;attribute previousWorld2 : vec4;attribute previousWorld3 : vec4; +#ifdef THIN_INSTANCES +uniform previousWorld : mat4x4; +#endif +#endif +#else +#if !defined(WORLD_UBO) +uniform world : mat4x4; +#endif +#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +uniform previousWorld : mat4x4; +#endif +#endif +`;E.IncludesShadersStoreWGSL[ly]||(E.IncludesShadersStoreWGSL[ly]=tH)});var cy,iH,oa=C(()=>{w();cy="instancesVertex",iH=`#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( +vertexInputs.previousWorld0,vertexInputs.previousWorld1, +vertexInputs.previousWorld2,vertexInputs.previousWorld3); +#endif +#ifdef THIN_INSTANCES +#if !defined(WORLD_UBO) +finalWorld=uniforms.world*finalWorld; +#else +finalWorld=mesh.world*finalWorld; +#endif +#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +finalPreviousWorld=uniforms.previousWorld*finalPreviousWorld; +#endif +#endif +#else +#if !defined(WORLD_UBO) +var finalWorld=uniforms.world; +#else +var finalWorld=mesh.world; +#endif +#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +var finalPreviousWorld=uniforms.previousWorld; +#endif +#endif +`;E.IncludesShadersStoreWGSL[cy]||(E.IncludesShadersStoreWGSL[cy]=iH)});var fy,rH,la=C(()=>{w();fy="bonesVertex",rH=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +#if NUM_BONE_INFLUENCERS>0 +var influence : mat4x4; +#ifdef BONETEXTURE +influence=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0])*vertexInputs.matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1])*vertexInputs.matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[2])*vertexInputs.matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[3])*vertexInputs.matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[0])*vertexInputs.matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[1])*vertexInputs.matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[2])*vertexInputs.matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence=influence+readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndicesExtra[3])*vertexInputs.matricesWeightsExtra[3]; +#endif +#else +influence=uniforms.mBones[i32(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence=influence+uniforms.mBones[i32(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3]; +#endif +#endif +finalWorld=finalWorld*influence; +#endif +#endif +`;E.IncludesShadersStoreWGSL[fy]||(E.IncludesShadersStoreWGSL[fy]=rH)});var hy,sH,ca=C(()=>{w();hy="bakedVertexAnimation",sH=`#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; +#else +let VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w; +#endif +let totalFrames: f32=VATEndFrame-VATStartFrame+1.0;let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;let frameCorrection: f32=select(1.0,0.0,time<1.0);let numOfFrames: f32=totalFrames-frameCorrection;var VATFrameNum: f32=fract(time)*numOfFrames;VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;VATFrameNum=floor(VATFrameNum);VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;var VATInfluence : mat4x4;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[0],VATFrameNum)*vertexInputs.matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[1],VATFrameNum)*vertexInputs.matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[2],VATFrameNum)*vertexInputs.matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndices[3],VATFrameNum)*vertexInputs.matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[0],VATFrameNum)*vertexInputs.matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[1],VATFrameNum)*vertexInputs.matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[2],VATFrameNum)*vertexInputs.matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,vertexInputs.matricesIndicesExtra[3],VATFrameNum)*vertexInputs.matricesWeightsExtra[3]; +#endif +finalWorld=finalWorld*VATInfluence;} +#endif +`;E.IncludesShadersStoreWGSL[hy]||(E.IncludesShadersStoreWGSL[hy]=sH)});var dy,nH,mn=C(()=>{w();dy="clipPlaneVertex",nH=`#ifdef CLIPPLANE +vertexOutputs.fClipDistance=dot(worldPos,uniforms.vClipPlane); +#endif +#ifdef CLIPPLANE2 +vertexOutputs.fClipDistance2=dot(worldPos,uniforms.vClipPlane2); +#endif +#ifdef CLIPPLANE3 +vertexOutputs.fClipDistance3=dot(worldPos,uniforms.vClipPlane3); +#endif +#ifdef CLIPPLANE4 +vertexOutputs.fClipDistance4=dot(worldPos,uniforms.vClipPlane4); +#endif +#ifdef CLIPPLANE5 +vertexOutputs.fClipDistance5=dot(worldPos,uniforms.vClipPlane5); +#endif +#ifdef CLIPPLANE6 +vertexOutputs.fClipDistance6=dot(worldPos,uniforms.vClipPlane6); +#endif +`;E.IncludesShadersStoreWGSL[dy]||(E.IncludesShadersStoreWGSL[dy]=nH)});var uy,aH,Xc=C(()=>{w();uy="fogVertex",aH=`#ifdef FOG +#ifdef SCENE_UBO +vertexOutputs.vFogDistance=(scene.view*worldPos).xyz; +#else +vertexOutputs.vFogDistance=(uniforms.view*worldPos).xyz; +#endif +#endif +`;E.IncludesShadersStoreWGSL[uy]||(E.IncludesShadersStoreWGSL[uy]=aH)});var my,oH,Ch=C(()=>{w();my="vertexColorMixing",oH=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +vertexOutputs.vColor=vec4f(1.0); +#ifdef VERTEXCOLOR +#ifdef VERTEXALPHA +vertexOutputs.vColor*=colorUpdated; +#else +vertexOutputs.vColor=vec4f(vertexOutputs.vColor.rgb*colorUpdated.rgb,vertexOutputs.vColor.a); +#endif +#endif +#ifdef INSTANCESCOLOR +vertexOutputs.vColor*=vertexInputs.instanceColor; +#endif +#endif +`;E.IncludesShadersStoreWGSL[my]||(E.IncludesShadersStoreWGSL[my]=oH)});var _y={};Ie(_y,{colorVertexShaderWGSL:()=>lH});var Gv,py,lH,gy=C(()=>{w();na();aa();un();zc();go();oa();la();ca();mn();Xc();Ch();Gv="colorVertexShader",py=`attribute position: vec3f; +#ifdef VERTEXCOLOR +attribute color: vec4f; +#endif +#include +#include +#include +#include +#ifdef FOG +uniform view: mat4x4f; +#endif +#include +uniform viewProjection: mat4x4f; +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vertexInputs.color; +#endif +#include +#include +#include +var worldPos: vec4f=finalWorld* vec4f(vertexInputs.position,1.0);vertexOutputs.position=uniforms.viewProjection*worldPos; +#include +#include +#include +#define CUSTOM_VERTEX_MAIN_END +}`;E.ShadersStoreWGSL[Gv]||(E.ShadersStoreWGSL[Gv]=py);lH={name:Gv,shader:py}});var Ey,cH,pn=C(()=>{w();Ey="clipPlaneFragmentDeclaration",cH=`#ifdef CLIPPLANE +varying fClipDistance: f32; +#endif +#ifdef CLIPPLANE2 +varying fClipDistance2: f32; +#endif +#ifdef CLIPPLANE3 +varying fClipDistance3: f32; +#endif +#ifdef CLIPPLANE4 +varying fClipDistance4: f32; +#endif +#ifdef CLIPPLANE5 +varying fClipDistance5: f32; +#endif +#ifdef CLIPPLANE6 +varying fClipDistance6: f32; +#endif +`;E.IncludesShadersStoreWGSL[Ey]||(E.IncludesShadersStoreWGSL[Ey]=cH)});var vy,fH,Yc=C(()=>{w();vy="fogFragmentDeclaration",fH=`#ifdef FOG +#define FOGMODE_NONE 0. +#define FOGMODE_EXP 1. +#define FOGMODE_EXP2 2. +#define FOGMODE_LINEAR 3. +const E=2.71828;uniform vFogInfos: vec4f;uniform vFogColor: vec3f;varying vFogDistance: vec3f;fn CalcFogFactor()->f32 +{var fogCoeff: f32=1.0;var fogStart: f32=uniforms.vFogInfos.y;var fogEnd: f32=uniforms.vFogInfos.z;var fogDensity: f32=uniforms.vFogInfos.w;var fogDistance: f32=length(fragmentInputs.vFogDistance);if (FOGMODE_LINEAR==uniforms.vFogInfos.x) +{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);} +else if (FOGMODE_EXP==uniforms.vFogInfos.x) +{fogCoeff=1.0/pow(E,fogDistance*fogDensity);} +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[vy]||(E.IncludesShadersStoreWGSL[vy]=fH)});var Sy,hH,_n=C(()=>{w();Sy="clipPlaneFragment",hH=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +if (false) {} +#endif +#ifdef CLIPPLANE +else if (fragmentInputs.fClipDistance>0.0) +{discard;} +#endif +#ifdef CLIPPLANE2 +else if (fragmentInputs.fClipDistance2>0.0) +{discard;} +#endif +#ifdef CLIPPLANE3 +else if (fragmentInputs.fClipDistance3>0.0) +{discard;} +#endif +#ifdef CLIPPLANE4 +else if (fragmentInputs.fClipDistance4>0.0) +{discard;} +#endif +#ifdef CLIPPLANE5 +else if (fragmentInputs.fClipDistance5>0.0) +{discard;} +#endif +#ifdef CLIPPLANE6 +else if (fragmentInputs.fClipDistance6>0.0) +{discard;} +#endif +`;E.IncludesShadersStoreWGSL[Sy]||(E.IncludesShadersStoreWGSL[Sy]=hH)});var Ty,dH,Kc=C(()=>{w();Ty="fogFragment",dH=`#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[Ty]||(E.IncludesShadersStoreWGSL[Ty]=dH)});var Ry={};Ie(Ry,{colorPixelShaderWGSL:()=>uH});var kv,Ay,uH,xy=C(()=>{w();pn();Yc();_n();Kc();kv="colorPixelShader",Ay=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +#define VERTEXCOLOR +varying vColor: vec4f; +#else +uniform color: vec4f; +#endif +#include +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +fragmentOutputs.color=input.vColor; +#else +fragmentOutputs.color=uniforms.color; +#endif +#include(color,fragmentOutputs.color) +#define CUSTOM_FRAGMENT_MAIN_END +}`;E.ShadersStoreWGSL[kv]||(E.ShadersStoreWGSL[kv]=Ay);uH={name:kv,shader:Ay}});var Iy,mH,fa=C(()=>{w();Iy="bonesDeclaration",mH=`#if NUM_BONE_INFLUENCERS>0 +attribute vec4 matricesIndices;attribute vec4 matricesWeights; +#if NUM_BONE_INFLUENCERS>4 +attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra; +#endif +#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +#ifdef BONETEXTURE +uniform highp sampler2D boneSampler;uniform vec2 boneTextureInfo; +#else +uniform mat4 mBones[BonesPerMesh]; +#endif +#ifdef BONES_VELOCITY_ENABLED +uniform mat4 mPreviousBones[BonesPerMesh]; +#endif +#ifdef BONETEXTURE +#define inline +mat4 readMatrixFromRawSampler(sampler2D smp,float index) +{ +#if defined(WEBGL2) || defined(WEBGPU) +int offset=int(index)*4; +int textureWidth=int(boneTextureInfo.x);int y=int(offset)/textureWidth;int x=int(offset) % textureWidth;vec4 m0=texelFetch(smp,ivec2(x+0,y),0);vec4 m1=texelFetch(smp,ivec2(x+1,y),0);vec4 m2=texelFetch(smp,ivec2(x+2,y),0);vec4 m3=texelFetch(smp,ivec2(x+3,y),0);return mat4(m0,m1,m2,m3); +#else +float offset=index*4.0;float y=floor(offset/boneTextureInfo.x);float x=offset-y*boneTextureInfo.x;float dy=1.0/boneTextureInfo.y;float dx=1.0/boneTextureInfo.x;vec4 m0=texture2D(smp,vec2(dx*(x+0.5),dy*(y+0.5)));vec4 m1=texture2D(smp,vec2(dx*(x+1.5),dy*(y+0.5)));vec4 m2=texture2D(smp,vec2(dx*(x+2.5),dy*(y+0.5)));vec4 m3=texture2D(smp,vec2(dx*(x+3.5),dy*(y+0.5))); +return mat4(m0,m1,m2,m3); +#endif +} +#endif +#endif +#endif +`;E.IncludesShadersStore[Iy]||(E.IncludesShadersStore[Iy]=mH)});var Cy,pH,ha=C(()=>{w();Cy="bakedVertexAnimationDeclaration",pH=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +uniform float bakedVertexAnimationTime; +#if !defined(WEBGL2) && !defined(WEBGPU) +uniform vec2 bakedVertexAnimationTextureSizeInverted; +#endif +uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture; +#ifdef INSTANCES +attribute vec4 bakedVertexAnimationSettingsInstanced; +#endif +#define inline +mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame) +{ +#if defined(WEBGL2) || defined(WEBGPU) +int offset=int(index)*4;int frameUV=int(frame);vec4 m0=texelFetch(smp,ivec2(offset+0,frameUV),0);vec4 m1=texelFetch(smp,ivec2(offset+1,frameUV),0);vec4 m2=texelFetch(smp,ivec2(offset+2,frameUV),0);vec4 m3=texelFetch(smp,ivec2(offset+3,frameUV),0);return mat4(m0,m1,m2,m3); +#else +float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3); +#endif +} +#endif +`;E.IncludesShadersStore[Cy]||(E.IncludesShadersStore[Cy]=pH)});var by,_H,gn=C(()=>{w();by="clipPlaneVertexDeclaration",_H=`#ifdef CLIPPLANE +uniform vec4 vClipPlane;varying float fClipDistance; +#endif +#ifdef CLIPPLANE2 +uniform vec4 vClipPlane2;varying float fClipDistance2; +#endif +#ifdef CLIPPLANE3 +uniform vec4 vClipPlane3;varying float fClipDistance3; +#endif +#ifdef CLIPPLANE4 +uniform vec4 vClipPlane4;varying float fClipDistance4; +#endif +#ifdef CLIPPLANE5 +uniform vec4 vClipPlane5;varying float fClipDistance5; +#endif +#ifdef CLIPPLANE6 +uniform vec4 vClipPlane6;varying float fClipDistance6; +#endif +`;E.IncludesShadersStore[by]||(E.IncludesShadersStore[by]=_H)});var My,gH,jc=C(()=>{w();My="fogVertexDeclaration",gH=`#ifdef FOG +varying vec3 vFogDistance; +#endif +`;E.IncludesShadersStore[My]||(E.IncludesShadersStore[My]=gH)});var yy,EH,Eo=C(()=>{w();yy="instancesDeclaration",EH=`#ifdef INSTANCES +attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; +#ifdef INSTANCESCOLOR +attribute vec4 instanceColor; +#endif +#if defined(THIN_INSTANCES) && !defined(WORLD_UBO) +uniform mat4 world; +#endif +#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3; +#ifdef THIN_INSTANCES +uniform mat4 previousWorld; +#endif +#endif +#else +#if !defined(WORLD_UBO) +uniform mat4 world; +#endif +#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +uniform mat4 previousWorld; +#endif +#endif +`;E.IncludesShadersStore[yy]||(E.IncludesShadersStore[yy]=EH)});var Dy,vH,da=C(()=>{w();Dy="instancesVertex",vH=`#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, +previousWorld2,previousWorld3); +#endif +#ifdef THIN_INSTANCES +finalWorld=world*finalWorld; +#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +finalPreviousWorld=previousWorld*finalPreviousWorld; +#endif +#endif +#else +mat4 finalWorld=world; +#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) +mat4 finalPreviousWorld=previousWorld; +#endif +#endif +`;E.IncludesShadersStore[Dy]||(E.IncludesShadersStore[Dy]=vH)});var Py,SH,ua=C(()=>{w();Py="bonesVertex",SH=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE +#if NUM_BONE_INFLUENCERS>0 +mat4 influence; +#ifdef BONETEXTURE +influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3]; +#endif +#else +influence=mBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +influence+=mBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +influence+=mBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +influence+=mBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +#endif +finalWorld=finalWorld*influence; +#endif +#endif +`;E.IncludesShadersStore[Py]||(E.IncludesShadersStore[Py]=SH)});var Ly,TH,ma=C(()=>{w();Ly="bakedVertexAnimation",TH=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE +{ +#ifdef INSTANCES +#define BVASNAME bakedVertexAnimationSettingsInstanced +#else +#define BVASNAME bakedVertexAnimationSettings +#endif +float VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3]; +#endif +finalWorld=finalWorld*VATInfluence;} +#endif +`;E.IncludesShadersStore[Ly]||(E.IncludesShadersStore[Ly]=TH)});var Oy,AH,En=C(()=>{w();Oy="clipPlaneVertex",AH=`#ifdef CLIPPLANE +fClipDistance=dot(worldPos,vClipPlane); +#endif +#ifdef CLIPPLANE2 +fClipDistance2=dot(worldPos,vClipPlane2); +#endif +#ifdef CLIPPLANE3 +fClipDistance3=dot(worldPos,vClipPlane3); +#endif +#ifdef CLIPPLANE4 +fClipDistance4=dot(worldPos,vClipPlane4); +#endif +#ifdef CLIPPLANE5 +fClipDistance5=dot(worldPos,vClipPlane5); +#endif +#ifdef CLIPPLANE6 +fClipDistance6=dot(worldPos,vClipPlane6); +#endif +`;E.IncludesShadersStore[Oy]||(E.IncludesShadersStore[Oy]=AH)});var Ny,RH,Zc=C(()=>{w();Ny="fogVertex",RH=`#ifdef FOG +vFogDistance=(view*worldPos).xyz; +#endif +`;E.IncludesShadersStore[Ny]||(E.IncludesShadersStore[Ny]=RH)});var Fy,xH,bh=C(()=>{w();Fy="vertexColorMixing",xH=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +vColor=vec4(1.0); +#ifdef VERTEXCOLOR +#ifdef VERTEXALPHA +vColor*=colorUpdated; +#else +vColor.rgb*=colorUpdated.rgb; +#endif +#endif +#ifdef INSTANCESCOLOR +vColor*=instanceColor; +#endif +#endif +`;E.IncludesShadersStore[Fy]||(E.IncludesShadersStore[Fy]=xH)});var By={};Ie(By,{colorVertexShader:()=>IH});var Wv,wy,IH,Uy=C(()=>{w();fa();ha();gn();jc();Eo();da();ua();ma();En();Zc();bh();Wv="colorVertexShader",wy=`attribute vec3 position; +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include +#include +#include +#ifdef FOG +uniform mat4 view; +#endif +#include +uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef VERTEXCOLOR +vec4 colorUpdated=color; +#endif +#include +#include +#include +vec4 worldPos=finalWorld*vec4(position,1.0); +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} +#else +gl_Position=viewProjection*worldPos; +#endif +#include +#include +#include +#define CUSTOM_VERTEX_MAIN_END +}`;E.ShadersStore[Wv]||(E.ShadersStore[Wv]=wy);IH={name:Wv,shader:wy}});var Vy,CH,vn=C(()=>{w();Vy="clipPlaneFragmentDeclaration",CH=`#ifdef CLIPPLANE +varying float fClipDistance; +#endif +#ifdef CLIPPLANE2 +varying float fClipDistance2; +#endif +#ifdef CLIPPLANE3 +varying float fClipDistance3; +#endif +#ifdef CLIPPLANE4 +varying float fClipDistance4; +#endif +#ifdef CLIPPLANE5 +varying float fClipDistance5; +#endif +#ifdef CLIPPLANE6 +varying float fClipDistance6; +#endif +`;E.IncludesShadersStore[Vy]||(E.IncludesShadersStore[Vy]=CH)});var Gy,bH,qc=C(()=>{w();Gy="fogFragmentDeclaration",bH=`#ifdef FOG +#define FOGMODE_NONE 0. +#define FOGMODE_EXP 1. +#define FOGMODE_EXP2 2. +#define FOGMODE_LINEAR 3. +#define E 2.71828 +uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor() +{float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x) +{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);} +else if (FOGMODE_EXP==vFogInfos.x) +{fogCoeff=1.0/pow(E,fogDistance*fogDensity);} +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[Gy]||(E.IncludesShadersStore[Gy]=bH)});var ky,MH,Sn=C(()=>{w();ky="clipPlaneFragment",MH=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) +if (false) {} +#endif +#ifdef CLIPPLANE +else if (fClipDistance>0.0) +{discard;} +#endif +#ifdef CLIPPLANE2 +else if (fClipDistance2>0.0) +{discard;} +#endif +#ifdef CLIPPLANE3 +else if (fClipDistance3>0.0) +{discard;} +#endif +#ifdef CLIPPLANE4 +else if (fClipDistance4>0.0) +{discard;} +#endif +#ifdef CLIPPLANE5 +else if (fClipDistance5>0.0) +{discard;} +#endif +#ifdef CLIPPLANE6 +else if (fClipDistance6>0.0) +{discard;} +#endif +`;E.IncludesShadersStore[ky]||(E.IncludesShadersStore[ky]=MH)});var Wy,yH,Qc=C(()=>{w();Wy="fogFragment",yH=`#ifdef FOG +float fog=CalcFogFactor(); +#ifdef PBR +fog=toLinearSpace(fog); +#endif +color.rgb=mix(vFogColor,color.rgb,fog); +#endif +`;E.IncludesShadersStore[Wy]||(E.IncludesShadersStore[Wy]=yH)});var zy={};Ie(zy,{colorPixelShader:()=>DH});var Hv,Hy,DH,Xy=C(()=>{w();vn();qc();Sn();Qc();Hv="colorPixelShader",Hy=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +#define VERTEXCOLOR +varying vec4 vColor; +#else +uniform vec4 color; +#endif +#include +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +gl_FragColor=vColor; +#else +gl_FragColor=color; +#endif +#include(color,gl_FragColor) +#define CUSTOM_FRAGMENT_MAIN_END +}`;E.ShadersStore[Hv]||(E.ShadersStore[Hv]=Hy);DH={name:Hv,shader:Hy}});var ml,zv,Yy=C(()=>{Je();It();ut();Uv();Vi();um();G._LinesMeshParser=(s,e)=>ml.Parse(s,e);ml=class s extends G{_isShaderMaterial(e){return e?e.getClassName()==="ShaderMaterial":!1}constructor(e,t=null,i=null,r=null,n,a,o,l){super(e,t,i,r,n),this.useVertexColor=a,this.useVertexAlpha=o,this.color=new ae(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:[y.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(y.ColorKind)):(f.uniforms.push("color"),this._color4=new Me),l)this.material=l;else{this.getScene().getEngine().isWebGPU&&!s.ForceGLSL&&(this._shaderLanguage=1),f.shaderLanguage=this._shaderLanguage,f.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(gy(),_y)),Promise.resolve().then(()=>(xy(),Ry))]):await Promise.all([Promise.resolve().then(()=>(Uy(),By)),Promise.resolve().then(()=>(Xy(),zy))])};let d=new sr("colorShader",this.getScene(),"color",f,!1);d.doNotSerialize=!0,this._ownsMaterial=!0,this._setInternalMaterial(d)}}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=oe.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:n,b:a}=this.color;this._color4.set(r,n,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(oe.LineListDrawMode,e.verticesStart,e.verticesCount,i):r.drawElementsType(oe.LineListDrawMode,e.indexStart,e.indexCount,i),this}dispose(e,t=!1,i){var r,n;i||(this._ownsMaterial?(r=this.material)==null||r.dispose(!1,!1,!0):t&&((n=this.material)==null||n.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 s(e,this.getScene(),r.parent,r.source,r.doNotCloneChildren)}return new s(e,this.getScene(),t,this,i)}createInstance(e){let t=new zv(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 s(e.name,t);return i.color=ae.FromArray(e.color),i.alpha=e.alpha,i}};ml.ForceGLSL=!1;zv=class extends sa{constructor(e,t){super(e,t),this.intersectionThreshold=t.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}});function Ky(s){let e=[],t=[],i=s.lines,r=s.colors,n=[],a=0;for(let l=0;l0&&(e.push(a-1),e.push(a)),a++}}let o=new fe;return o.indices=e,o.positions=t,r&&(o.colors=n),o}function jy(s){let e=s.dashSize||3,t=s.gapSize||1,i=s.dashNb||200,r=s.points,n=[],a=[],o=S.Zero(),l=0,c,f,h=0,d;for(d=0;d{let h=S.Zero(),d=f.length/6,u=0,m,p,_=0,g,v;for(g=0;g{Ee();ut();Bt();Yy();It();We();fe.CreateLineSystem=Ky;fe.CreateDashedLines=jy;G.CreateLines=(s,e,t=null,i=!1,r=null)=>Yv(s,{points:e,updatable:i,instance:r},t);G.CreateDashedLines=(s,e,t,i,r,n=null,a,o)=>Kv(s,{points:e,dashSize:t,gapSize:i,dashNb:r,updatable:a,instance:o},n)});var jv,Mh,mm,qy=C(()=>{We();Ee();It();ut();Bt();el();Wi();gt();jv=class extends me{constructor(e,t){super(e.x,e.y),this.index=t}},Mh=class{constructor(){this.elements=[]}add(e){let t=[];for(let i of e){let r=new jv(i,this.elements.length);t.push(r),this.elements.push(r)}return t}computeBounds(){let e=new me(this.elements[0].x,this.elements[0].y),t=new me(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}}},mm=class{_addToepoint(e){for(let t of e)this._epoints.push(t.x,t.y)}constructor(e,t,i,r=earcut){this._points=new Mh,this._outlinepoints=new Mh,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=r,this._name=e,this._scene=i||ue.LastCreatedScene;let n;t instanceof Jl?n=t.getPoints():n=t,this._addToepoint(n),this._points.add(n),this._outlinepoints.add(n),typeof this.bjsEarcut=="undefined"&&X.Warn("Earcut was not found, the polygon will not be built.")}addHole(e){this._points.add(e);let t=new Mh;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 G(this._name,this._scene),n=this.buildVertexData(t,i);return r.setVerticesData(y.PositionKind,n.positions,e),r.setVerticesData(y.NormalKind,n.normals,e),r.setVerticesData(y.UVKind,n.uvs,e),r.setIndices(n.indices),r}buildVertexData(e=0,t=2){let i=new fe,r=[],n=[],a=[],o=this._points.computeBounds();for(let f of this._points.elements)r.push(0,1,0),n.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=n.length/3;for(let d of this._points.elements)r.push(0,-1,0),n.push(d.x,-e,d.y),a.push(1-(d.x-o.min.x)/o.width,1-(d.y-o.min.y)/o.height);let h=l.length;for(let d=0;dc?Rc?P{Ee();Je();ut();Bt();qy();It();gt();vi();fe.CreatePolygon=Qy;G.CreatePolygon=(s,e,t,i,r,n,a=earcut)=>pm(s,{shape:e,holes:i,updatable:r,sideOrientation:n},t,a);G.ExtrudePolygon=(s,e,t,i,r,n,a,o=earcut)=>yh(s,{shape:e,holes:r,depth:t,updatable:n,sideOrientation:a},i,o)});function qv(s,e,t=null){let i=e.path,r=e.shape,n=e.scale||1,a=e.rotation||0,o=e.cap===0?0:e.cap||G.NO_CAP,l=e.updatable,c=G._GetDefaultSideOrientation(e.sideOrientation),f=e.instance||null,h=e.invertUV||!1,d=e.closeShape||!1,u=e.closePath||!1,m=e.capFunction||null;return Jy(s,r,i,n,a,null,null,u,d,o,!1,t,!!l,c,f,h,e.frontUVs||null,e.backUVs||null,e.firstNormal||null,!!e.adjustFrame,m)}function Qv(s,e,t=null){var v;let i=e.path,r=e.shape,n=S.Zero(),a=(I,x)=>{var A,R;let T=(R=(A=e.scaleFunction)==null?void 0:A.call(e,I,x))!=null?R:1;return n.copyFromFloats(T,T,T)},o=e.rotationFunction||(()=>0),l=e.closePath||e.ribbonCloseArray||!1,c=e.closeShape||e.ribbonClosePath||!1,f=e.cap===0?0:e.cap||G.NO_CAP,h=e.updatable,d=e.firstNormal||null,u=e.adjustFrame||!1,m=G._GetDefaultSideOrientation(e.sideOrientation),p=e.instance,_=e.invertUV||!1,g=e.capFunction||null;return Jy(s,r,i,null,null,(v=e.scaleVectorFunction)!=null?v:a,o,l,c,f,!0,t,!!h,m,p||null,_,e.frontUVs||null,e.backUVs||null,d,u,g||null)}function Jy(s,e,t,i,r,n,a,o,l,c,f,h,d,u,m,p,_,g,v,I,x){let T=(F,N,V,O,U,k,z,Z,J,q,Y)=>{let K=V.getTangents(),j=V.getNormals(),ee=V.getBinormals(),be=V.getDistances();if(Y){for(let Fe=0;Fe0){let Xe=K[Fe-1];S.Dot(Xe,K[Fe])<0&&K[Fe].scaleInPlace(-1),Xe=j[Fe-1],S.Dot(Xe,j[Fe])<0&&j[Fe].scaleInPlace(-1),Xe=ee[Fe-1],S.Dot(Xe,ee[Fe])<0&&ee[Fe].scaleInPlace(-1)}}let _e=0,pe=()=>U!==null?U:S.OneReadOnly,le=q&&Z?Z:()=>k!==null?k:0,xe=q&&z?z:pe,ce=J===G.NO_CAP||J===G.CAP_END?0:2,de=W.Matrix[0];for(let Fe=0;Fe{let Xe=Array(),St=S.Zero(),bt;for(bt=0;bt3?0:c,R=T(e,t,P,D,A,r,n,a,c,f,I);let M=Ns(s,{pathArray:R,closeArray:o,closePath:l,updatable:d,sideOrientation:u,invertUV:p,frontUVs:_||void 0,backUVs:g||void 0},h);return M._creationDataStorage.pathArray=R,M._creationDataStorage.path3D=P,M._creationDataStorage.cap=c,M}var $y=C(()=>{Ee();ut();xh();el();G.ExtrudeShape=(s,e,t,i,r,n,a=null,o,l,c)=>{let f={shape:e,path:t,scale:i,rotation:r,cap:n===0?0:n||G.NO_CAP,sideOrientation:l,instance:c,updatable:o};return qv(s,f,a)};G.ExtrudeShapeCustom=(s,e,t,i,r,n,a,o,l,c,f,h)=>{let d={shape:e,path:t,scaleFunction:i,rotationFunction:r,ribbonCloseArray:n,ribbonClosePath:a,cap:o===0?0:o||G.NO_CAP,sideOrientation:f,instance:h,updatable:c};return Qv(s,d,l)}});function Jv(s,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,n=e.shape,a=e.radius||1,o=e.tessellation||64,l=e.clip||0,c=e.updatable,f=G._GetDefaultSideOrientation(e.sideOrientation),h=e.cap||G.NO_CAP,d=Math.PI*2,u=[],m=e.invertUV||!1,p,_,g=d/o*i,v,I;for(p=0;p<=o-l;p++){for(I=[],(h==G.CAP_START||h==G.CAP_ALL)&&(I.push(new S(0,n[0].y,0)),I.push(new S(Math.cos(p*g)*n[0].x*a,n[0].y,Math.sin(p*g)*n[0].x*a))),_=0;_{Ee();ut();xh();G.CreateLathe=(s,e,t,i,r,n,a)=>Jv(s,{shape:e,radius:t,tessellation:i,sideOrientation:a,updatable:n},r)});function tD(s){let e=[],t=[],i=[],r=[],n=s.width!==void 0?s.width:s.size!==void 0?s.size:1,a=s.height!==void 0?s.height:s.size!==void 0?s.size:1,o=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,l=n/2,c=a/2;t.push(-l,-c,0),i.push(0,0,-1),r.push(0,ze?1:0),t.push(l,-c,0),i.push(0,0,-1),r.push(1,ze?1:0),t.push(l,c,0),i.push(0,0,-1),r.push(1,ze?0:1),t.push(-l,c,0),i.push(0,0,-1),r.push(0,ze?0:1),e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),fe._ComputeSides(o,t,e,i,r,s.frontUVs,s.backUVs);let f=new fe;return f.indices=e,f.positions=t,f.normals=i,f.uvs=r,f}function $v(s,e={},t=null){let i=new G(s,t);return e.sideOrientation=G._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,tD(e).applyToMesh(i,e.updatable),e.sourcePlane&&(i.translate(e.sourcePlane.normal,-e.sourcePlane.d),i.setDirection(e.sourcePlane.normal.scale(-1))),i}var iD=C(()=>{ut();Bt();vi();fe.CreatePlane=tD;G.CreatePlane=(s,e,t,i,r)=>$v(s,{size:e,width:e,height:e,sideOrientation:r,updatable:i},t)});function eS(s,e,t=null){let i=e.path,r=e.instance,n=1;e.radius!==void 0?n=e.radius:r&&(n=r._creationDataStorage.radius);let a=e.tessellation||64,o=e.radiusFunction||null,l=e.cap||G.NO_CAP,c=e.invertUV||!1,f=e.updatable,h=G._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;let d=(g,v,I,x,T,A,R,P)=>{let D=v.getTangents(),M=v.getNormals(),F=v.getDistances(),V=Math.PI*2/T*P,U=A||(()=>x),k,z,Z,J,q=W.Matrix[0],Y=R===G.NO_CAP||R===G.CAP_END?0:2;for(let j=0;j{let be=Array();for(let _e=0;_e3?0:l,m=d(i,u,p,n,a,o,l,e.arc);let _=Ns(s,{pathArray:m,closePath:!0,closeArray:!1,updatable:f,sideOrientation:h,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=n,_}var rD=C(()=>{Ee();ut();xh();el();G.CreateTube=(s,e,t,i,r,n,a,o,l,c)=>eS(s,{path:e,radius:t,tessellation:i,radiusFunction:r,arc:1,cap:n,updatable:o,sideOrientation:l,instance:c},a)});function sD(s){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=s.type&&(s.type<0||s.type>=e.length)?0:s.type||0,i=s.size,r=s.sizeX||i||1,n=s.sizeY||i||1,a=s.sizeZ||i||1,o=s.custom||e[t],l=o.face.length,c=s.faceUV||new Array(l),f=s.faceColors,h=s.flat===void 0?!0:s.flat,d=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,u=[],m=[],p=[],_=[],g=[],v=0,I=0,x=[],T,A,R,P,D,M,F,N;if(h)for(A=0;A{Ee();Je();ut();Bt();vi();fe.CreatePolyhedron=sD;G.CreatePolyhedron=(s,e,t)=>Dh(s,e,t)});function nD(s){let e=s.sideOrientation||fe.DEFAULTSIDE,t=s.radius||1,i=s.flat===void 0?!0:s.flat,r=(s.subdivisions||4)|0,n=s.radiusX||t,a=s.radiusY||t,o=s.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],h=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],d=[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,v=20/1024,I=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],x=[],T=[],A=[],R=[],P=0,D=new Array(3),M=new Array(3),F;for(F=0;F<3;F++)D[F]=S.Zero(),M[F]=me.Zero();for(let V=0;V<20;V++){for(F=0;F<3;F++){let U=f[3*V+F];D[F].copyFromFloats(c[3*h[U]],c[3*h[U]+1],c[3*h[U]+2]),D[F].normalize(),M[F].copyFromFloats(d[2*U]*u+p+I[V]*g,d[2*U+1]*m+_+I[V]*v)}let O=(U,k,z,Z)=>{let J=S.Lerp(D[0],D[2],k/r),q=S.Lerp(D[1],D[2],k/r),Y=r===k?D[2]:S.Lerp(J,q,U/(r-k));Y.normalize();let K;if(i){let _e=S.Lerp(D[0],D[2],Z/r),pe=S.Lerp(D[1],D[2],Z/r);K=S.Lerp(_e,pe,z/(r-Z))}else K=new S(Y.x,Y.y,Y.z);K.x/=n,K.y/=a,K.z/=o,K.normalize();let j=me.Lerp(M[0],M[2],k/r),ee=me.Lerp(M[1],M[2],k/r),be=r===k?M[2]:me.Lerp(j,ee,U/(r-k));T.push(Y.x*n,Y.y*a,Y.z*o),A.push(K.x,K.y,K.z),R.push(be.x,ze?1-be.y:be.y),x.push(P),P++};for(let U=0;U{Ee();ut();Bt();vi();fe.CreateIcoSphere=nD;G.CreateIcoSphere=(s,e,t)=>iS(s,e,t)});function rS(s,e,t){var z,Z,J,q,Y;let i=!!e.skeleton,r=!!((z=e.morphTargetManager)!=null&&z.numTargets),n=t.localMode||i,a=e.getIndices(),o=i||r?e.getPositionData(!0,!0):e.getVerticesData(y.PositionKind),l=i||r?e.getNormalsData(!0,!0):e.getVerticesData(y.NormalKind),c=n?i?e.getVerticesData(y.PositionKind):o:null,f=n?i?e.getVerticesData(y.NormalKind):l:null,h=e.getVerticesData(y.UVKind),d=i?e.getVerticesData(y.MatricesIndicesKind):null,u=i?e.getVerticesData(y.MatricesWeightsKind):null,m=i?e.getVerticesData(y.MatricesIndicesExtraKind):null,p=i?e.getVerticesData(y.MatricesWeightsExtraKind):null,_=t.position||S.Zero(),g=t.normal||S.Up(),v=t.size||S.One(),I=t.angle||0;if(!g){let K=new S(0,0,1),j=e.getScene().activeCamera,ee=S.TransformCoordinates(K,j.getWorldMatrix());g=j.globalPosition.subtract(ee)}let x=-Math.atan2(g.z,g.x)-Math.PI/2,T=Math.sqrt(g.x*g.x+g.z*g.z),A=Math.atan2(g.y,T),R=new fe;R.indices=[],R.positions=[],R.normals=[],R.uvs=[],R.matricesIndices=i?[]:null,R.matricesWeights=i?[]:null,R.matricesIndicesExtra=m?[]:null,R.matricesWeightsExtra=p?[]:null;let P=0,D=(K,j)=>{let ee=new _m;if(!a||!o||!l)return ee;let be=a[K];if(ee.vertexIdx=be*3,ee.vertexIdxForBones=be*4,ee.position=new S(o[be*3],o[be*3+1],o[be*3+2]),S.TransformCoordinatesToRef(ee.position,j,ee.position),ee.normal=new S(l[be*3],l[be*3+1],l[be*3+2]),S.TransformNormalToRef(ee.normal,j,ee.normal),t.captureUVS&&h){let _e=h[be*2+1];ee.uv=new me(h[be*2],ze?1-_e:_e)}return ee},M=[0,0,0,0],F=(K,j)=>{if(K.length===0)return K;let ee=.5*Math.abs(S.Dot(v,j)),be=(te,le,xe,ce)=>{for(let de=0;de{var Oa,Vo,Ot,Ol,Nl,Gf,Pn,kf,Wf,Hf,Go,Fl,ko,di,wl,zf;let xe=S.GetClipFactor(te.position,le.position,j,ee),ce=M,de=M;if(d&&u){let Na=te.matrixIndicesOverride?0:te.vertexIdxForBones,Bl=(Oa=te.matrixIndicesOverride)!=null?Oa:d,Xf=(Vo=te.matrixWeightsOverride)!=null?Vo:u,ks=le.matrixIndicesOverride?0:le.vertexIdxForBones,Ln=(Ot=le.matrixIndicesOverride)!=null?Ot:d,Wo=(Ol=le.matrixWeightsOverride)!=null?Ol:u;ce=[0,0,0,0],de=[0,0,0,0];let Ws=0;for(let xi=0;xi<4;++xi)if(Xf[Na+xi]>0){let Ii=be(Ln,Bl[Na+xi],ks,4);ce[Ws]=Bl[Na+xi],de[Ws]=Kr(Xf[Na+xi],Ii>=0?Wo[Ii]:0,xe),Ws++}for(let xi=0;xi<4&&Ws<4;++xi){let Ii=Ln[ks+xi];be(Bl,Ii,Na,4)===-1&&(ce[Ws]=Ii,de[Ws]=Kr(0,Wo[ks+xi],xe),Ws++)}let On=de[0]+de[1]+de[2]+de[3];de[0]/=On,de[1]/=On,de[2]/=On,de[3]/=On}let ke=te.localPositionOverride?te.localPositionOverride[0]:(Nl=c==null?void 0:c[te.vertexIdx])!=null?Nl:0,Ze=te.localPositionOverride?te.localPositionOverride[1]:(Gf=c==null?void 0:c[te.vertexIdx+1])!=null?Gf:0,Fe=te.localPositionOverride?te.localPositionOverride[2]:(Pn=c==null?void 0:c[te.vertexIdx+2])!=null?Pn:0,Xe=le.localPositionOverride?le.localPositionOverride[0]:(kf=c==null?void 0:c[le.vertexIdx])!=null?kf:0,St=le.localPositionOverride?le.localPositionOverride[1]:(Wf=c==null?void 0:c[le.vertexIdx+1])!=null?Wf:0,bt=le.localPositionOverride?le.localPositionOverride[2]:(Hf=c==null?void 0:c[le.vertexIdx+2])!=null?Hf:0,Gt=te.localNormalOverride?te.localNormalOverride[0]:(Go=f==null?void 0:f[te.vertexIdx])!=null?Go:0,si=te.localNormalOverride?te.localNormalOverride[1]:(Fl=f==null?void 0:f[te.vertexIdx+1])!=null?Fl:0,Gi=te.localNormalOverride?te.localNormalOverride[2]:(ko=f==null?void 0:f[te.vertexIdx+2])!=null?ko:0,Gs=le.localNormalOverride?le.localNormalOverride[0]:(di=f==null?void 0:f[le.vertexIdx])!=null?di:0,Vf=le.localNormalOverride?le.localNormalOverride[1]:(wl=f==null?void 0:f[le.vertexIdx+1])!=null?wl:0,Sd=le.localNormalOverride?le.localNormalOverride[2]:(zf=f==null?void 0:f[le.vertexIdx+2])!=null?zf:0,Pl=Gt+(Gs-Gt)*xe,Ll=si+(Vf-si)*xe,Es=Gi+(Sd-Gi)*xe,La=Math.sqrt(Pl*Pl+Ll*Ll+Es*Es);return new _m(S.Lerp(te.position,le.position,xe),S.Lerp(te.normal,le.normal,xe).normalize(),me.Lerp(te.uv,le.uv,xe),-1,-1,c?[ke+(Xe-ke)*xe,Ze+(St-Ze)*xe,Fe+(bt-Fe)*xe]:null,f?[Pl/La,Ll/La,Es/La]:null,ce,de)},pe=null;K.length>3&&(pe=[]);for(let te=0;te0,St=Ze>0,bt=Fe>0;switch((Xe?1:0)+(St?1:0)+(bt?1:0)){case 0:K.length>3?(pe.push(K[te]),pe.push(K[te+1]),pe.push(K[te+2])):pe=K;break;case 1:if(pe=pe!=null?pe:new Array,Xe&&(le=K[te+1],xe=K[te+2],ce=_e(K[te],le),de=_e(K[te],xe)),St){le=K[te],xe=K[te+2],ce=_e(K[te+1],le),de=_e(K[te+1],xe),pe.push(ce),pe.push(xe.clone()),pe.push(le.clone()),pe.push(xe.clone()),pe.push(ce.clone()),pe.push(de);break}bt&&(le=K[te],xe=K[te+1],ce=_e(K[te+2],le),de=_e(K[te+2],xe)),le&&xe&&ce&&de&&(pe.push(le.clone()),pe.push(xe.clone()),pe.push(ce),pe.push(de),pe.push(ce.clone()),pe.push(xe.clone()));break;case 2:pe=pe!=null?pe:new Array,Xe||(le=K[te].clone(),xe=_e(le,K[te+1]),ce=_e(le,K[te+2]),pe.push(le),pe.push(xe),pe.push(ce)),St||(le=K[te+1].clone(),xe=_e(le,K[te+2]),ce=_e(le,K[te]),pe.push(le),pe.push(xe),pe.push(ce)),bt||(le=K[te+2].clone(),xe=_e(le,K[te]),ce=_e(le,K[te+1]),pe.push(le),pe.push(xe),pe.push(ce));break;case 3:break}}return pe},N=e instanceof G?e:null,V=N==null?void 0:N._thinInstanceDataStorage.matrixData,O=(N==null?void 0:N.thinInstanceCount)||1,U=W.Matrix[0];U.copyFrom(H.IdentityReadOnly);for(let K=0;K{Ee();Mi();ut();It();Bt();vi();PH=new S(1,0,0),LH=new S(-1,0,0),OH=new S(0,1,0),NH=new S(0,-1,0),FH=new S(0,0,1),wH=new S(0,0,-1),_m=class s{constructor(e=S.Zero(),t=S.Up(),i=me.Zero(),r=0,n=0,a=null,o=null,l=null,c=null){this.position=e,this.normal=t,this.uv=i,this.vertexIdx=r,this.vertexIdxForBones=n,this.localPositionOverride=a,this.localNormalOverride=o,this.matrixIndicesOverride=l,this.matrixWeightsOverride=c}clone(){var e,t,i,r;return new s(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())}};G.CreateDecal=(s,e,t,i,r,n)=>rS(s,e,{position:t,normal:i,size:r,angle:n})});function lD(s={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){let e=Math.max(s.subdivisions?s.subdivisions:2,1)|0,t=Math.max(s.tessellation?s.tessellation:16,3)|0,i=Math.max(s.height?s.height:1,0),r=Math.max(s.radius?s.radius:.25,0),n=Math.max(s.capSubdivisions?s.capSubdivisions:6,1)|0,a=t,o=e,l=Math.max(s.radiusTop?s.radiusTop:r,0),c=Math.max(s.radiusBottom?s.radiusBottom:r,0),f=i-(l+c),h=0,d=2*Math.PI,u=Math.max(s.topCapSubdivisions?s.topCapSubdivisions:n,1),m=Math.max(s.bottomCapSubdivisions?s.bottomCapSubdivisions:n,1),p=Math.acos((c-l)/i),_=[],g=[],v=[],I=[],x=0,T=[],A=f*.5,R=Math.PI*.5,P,D,M=S.Zero(),F=S.Zero(),N=Math.cos(p),V=Math.sin(p),O=new me(l*V,A+l*N).subtract(new me(c*V,-A+c*N)).length(),U=l*p+O+c*(R-p),k=0;for(D=0;D<=u;D++){let q=[],Y=R-p*(D/u);k+=l*p/u;let K=Math.cos(Y),j=Math.sin(Y),ee=K*l;for(P=0;P<=a;P++){let be=P/a,_e=be*d+h,pe=Math.sin(_e),te=Math.cos(_e);F.x=ee*pe,F.y=A+j*l,F.z=ee*te,g.push(F.x,F.y,F.z),M.set(K*pe,j,K*te),v.push(M.x,M.y,M.z),I.push(be,ze?k/U:1-k/U),q.push(x),x++}T.push(q)}let z=i-l-c+N*l-N*c,Z=V*(c-l)/z;for(D=1;D<=o;D++){let q=[];k+=O/o;let Y=V*(D*(c-l)/o+l);for(P=0;P<=a;P++){let K=P/a,j=K*d+h,ee=Math.sin(j),be=Math.cos(j);F.x=Y*ee,F.y=A+N*l-D*z/o,F.z=Y*be,g.push(F.x,F.y,F.z),M.set(ee,Z,be).normalize(),v.push(M.x,M.y,M.z),I.push(K,ze?k/U:1-k/U),q.push(x),x++}T.push(q)}for(D=1;D<=m;D++){let q=[],Y=R-p-(Math.PI-p)*(D/m);k+=c*p/m;let K=Math.cos(Y),j=Math.sin(Y),ee=K*c;for(P=0;P<=a;P++){let be=P/a,_e=be*d+h,pe=Math.sin(_e),te=Math.cos(_e);F.x=ee*pe,F.y=-A+j*c,F.z=ee*te,g.push(F.x,F.y,F.z),M.set(K*pe,j,K*te),v.push(M.x,M.y,M.z),I.push(be,ze?k/U:1-k/U),q.push(x),x++}T.push(q)}for(P=0;P{Bt();Ee();ut();vi();G.CreateCapsule=(s,e,t)=>sS(s,e,t);fe.CreateCapsule=lD});var Ut,fD=C(()=>{We();Ee();Ut=class s{constructor(e=0,t=0){this.x=e,this.y=t,e!==Math.floor(e)&&(e=Math.floor(e),X.Warn("x is not an integer, floor(x) used")),t!==Math.floor(t)&&(t=Math.floor(t),X.Warn("y is not an integer, floor(y) used"))}clone(){return new s(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),X.Warn("m not an integer only floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),X.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),X.Warn("m is not an integer, floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),X.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=S.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 s(0,0)}}});var Jc,Ph,$c,nS=C(()=>{Ee();Mi();Wi();fD();Jc=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 Ph("icosahedron","Regular",[[0,Yt,-1],[-Yt,1,0],[-1,0,-Yt],[1,0,-Yt],[Yt,1,0],[0,Yt,1],[-1,0,Yt],[-Yt,-1,0],[0,-Yt,-1],[Yt,-1,0],[1,0,Yt],[0,-Yt,1]],[[0,2,1],[0,3,2],[0,4,3],[0,5,4],[0,1,5],[7,6,1],[8,7,2],[9,8,3],[10,9,4],[6,10,5],[2,7,1],[3,8,2],[4,9,3],[5,10,4],[1,6,5],[11,6,7],[11,7,8],[11,8,9],[11,9,10],[11,10,6]])}setIndices(){let e=12,t={},i=this.m,r=this.n,n=i;r!==0&&(n=Zo(i,r));let a=i/n,o=r/n,l,c,f,h,d,u=Ut.Zero(),m=new Ut(i,r),p=new Ut(-r,i+r),_=Ut.Zero(),g=Ut.Zero(),v=Ut.Zero(),I=[],x,T,A,R,P=[],D=this.vertByDist,M=(F,N,V,O)=>{x=F+"|"+V,T=N+"|"+O,x in t||T in t?x in t&&!(T in t)?t[T]=t[x]:T in t&&!(x in t)&&(t[x]=t[T]):(t[x]=e,t[T]=e,e++),D[V][0]>2?P[t[x]]=[-D[V][0],D[V][1],t[x]]:P[t[x]]=[I[D[V][0]],D[V][1],t[x]]};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 F=0;F<20;F++){if(I=this.IDATA.face[F],f=I[2],h=I[1],d=I[0],A=u.x+"|"+u.y,x=F+"|"+A,x in t||(t[x]=f,P[f]=[I[D[A][0]],D[A][1]]),A=m.x+"|"+m.y,x=F+"|"+A,x in t||(t[x]=h,P[h]=[I[D[A][0]],D[A][1]]),A=p.x+"|"+p.y,x=F+"|"+A,x in t||(t[x]=d,P[d]=[I[D[A][0]],D[A][1]]),l=this.IDATA.edgematch[F][0],c=this.IDATA.edgematch[F][1],c==="B")for(let N=1;N2?P[t[x]]=[-D[A][0],D[A][1],t[x]]:P[t[x]]=[I[D[A][0]],D[A][1],t[x]])}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 T=Zo(e,t),A=e/T,R=t/T;for(let D=1;DT.x-A.x),i.sort((T,A)=>T.y-A.y);let o=new Array(e+t+1),l=new Array(e+t+1);for(let T=0;T{let R=T.clone();return A==="A"&&R.rotateNeg120(e,t),A==="B"&&R.rotate120(e,t),R.x<0?R.y:R.x+R.y},u=[],m=[],p=[],_=[],g={},v=[],I=-1,x=-1;for(let T=0;TT[2]-A[2]),v.sort((T,A)=>T[3]-A[3]),v.sort((T,A)=>T[1]-A[1]),v.sort((T,A)=>T[0]-A[0]);for(let T=0;Tt.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 n=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;)n=t[l],this.face[n].indexOf(o)>-1?(a=(this.face[n].indexOf(o)+1)%3,o=this.face[n][a],i.push(o),r.push(n),t.splice(l,1),l=0):l++;return this.adjacentFaces.push(i),r}toGoldbergPolyhedronData(){let e=new Ph("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,X.Warn("n > m therefore m and n swapped")}let n=new Jc;n.build(i,r);let o={custom:$c.BuildGeodesicData(n),size:e.size,sizeX:e.sizeX,sizeY:e.sizeY,sizeZ:e.sizeZ,faceUV:e.faceUV,faceColors:e.faceColors,flat:e.flat,updatable:e.updatable,sideOrientation:e.sideOrientation,frontUVs:e.frontUVs,backUVs:e.backUVs};return Dh(s,o,t)}var dD=C(()=>{tS();We();nS()});var Lh,uD=C(()=>{Ee();It();ut();Je();We();G._GoldbergMeshParser=(s,e)=>Lh.Parse(s,e);Lh=class s extends G{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&&(X.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(X.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(X.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&&(h=1),c.push(h,d);for(let u=0;u<6;u++)h=a.x+o*Math.cos(l+u*Math.PI/3),d=a.y+o*Math.sin(l+u*Math.PI/3),h<0&&(h=0),h>1&&(h=1),f.push(h,d);for(let u=r;uMe.FromArray(n)),i.faceCenters=i.faceCenters.map(n=>S.FromArray(n)),i.faceZaxis=i.faceZaxis.map(n=>S.FromArray(n)),i.faceXaxis=i.faceXaxis.map(n=>S.FromArray(n)),i.faceYaxis=i.faceYaxis.map(n=>S.FromArray(n));let r=new s(e.name,t);return r.goldbergData=i,r}}});function BH(s,e){let t=s.size,i=s.sizeX||t||1,r=s.sizeY||t||1,n=s.sizeZ||t||1,a=s.sideOrientation===0?0:s.sideOrientation||fe.DEFAULTSIDE,o=[],l=[],c=[],f=[],h=1/0,d=-1/0,u=1/0,m=-1/0;for(let g=0;go){let m=l;l=o,o=m,X.Warn("n > m therefore m and n swapped")}let c=new Jc;c.build(o,l);let f=$c.BuildGeodesicData(c),h=f.toGoldbergPolyhedronData(),d=new Lh(s,t);e.sideOrientation=G._GetDefaultSideOrientation(e.sideOrientation),d._originalBuilderSideOrientation=e.sideOrientation,BH(e,h).applyToMesh(d,e.updatable),d.goldbergData.nbSharedFaces=f.sharedNodes,d.goldbergData.nbUnsharedFaces=f.poleNodes,d.goldbergData.adjacentFaces=f.adjacentFaces,d.goldbergData.nbFaces=d.goldbergData.nbSharedFaces+d.goldbergData.nbUnsharedFaces,d.goldbergData.nbFacesAtPole=(d.goldbergData.nbUnsharedFaces-12)/12;for(let m=0;m{Ee();Je();ut();Bt();We();nS();uD();vi()});function UH(s,e,t,i,r,n){let a=n.glyphs[s]||n.glyphs["?"];if(!a)return null;let o=new aS(r);if(a.o){let l=a.o.split(" ");for(let c=0,f=l.length;c{el();Ee();ut();Ac();Zv();aS=class{constructor(e){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=e}moveTo(e,t){this._currentPath=new Jl(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,n,a){this._currentPath.addBezierCurveTo(e,t,i,r,n,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 pa,oS=C(()=>{xh();kM();Pv();jM();qM();JM();ey();iy();Zy();Zv();$y();eD();iD();Lv();yv();rD();tS();aD();oD();cD();dD();pD();gD();pa={CreateBox:Dv,CreateTiledBox:KM,CreateSphere:Nv,CreateDisc:xv,CreateIcoSphere:iS,CreateRibbon:Ns,CreateCylinder:Fv,CreateTorus:wv,CreateTorusKnot:Bv,CreateLineSystem:Xv,CreateLines:Yv,CreateDashedLines:Kv,ExtrudeShape:qv,ExtrudeShapeCustom:Qv,CreateLathe:Jv,CreateTiledPlane:XM,CreatePlane:$v,CreateGround:Cv,CreateTiledGround:bv,CreateGroundFromHeightMap:Mv,CreatePolygon:pm,ExtrudePolygon:yh,CreateTube:eS,CreatePolyhedron:Dh,CreateGeodesic:hD,CreateGoldberg:mD,CreateDecal:rS,CreateCapsule:sS,CreateText:_D}});var xr,gm=C(()=>{xr=class{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,r,n){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(t.prePassRenderer.getIndex(2)!==-1||t.prePassRenderer.getIndex(11)!==-1)){this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=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 qt,Ur=C(()=>{qt=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{Ur()});function HH(){kH.length=0,WH=!1,oe.OnEventObservable.remove(ED),ED=null}var GH,tf,kH,WH,ED,vD=C(()=>{Vi();gt();Ud();w();GH=new RegExp("^([gimus]+)!"),tf=class s{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,n),this._plugins.push(e),this._plugins.sort((r,n)=>r.priority-n.priority),this._codeInjectionPoints={};let i={};i[s._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 n=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),n){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 n=(o=this._codeInjectionPoints)==null?void 0:o[i];if(!n)return r;let a=null;for(let c in n){let f="";for(let h of this._activePlugins){let d=this._material.shaderLanguage,u=(l=h.getCustomCode(i,d))==null?void 0:l[c];u&&(h.resolveIncludes&&(a===null&&(a={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:E.GetShadersRepository(d),includesShadersStore:E.GetIncludesShadersStore(d),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",Yf(u,a,m=>u=m)),f+=u+` +`)}if(f.length>0)if(c.charAt(0)==="!"){c=c.substring(1);let h="g";if(c.charAt(0)==="!")h="",c=c.substring(1);else{let p=GH.exec(c);p&&p.length>=2&&(h=p[1],c=c.substring(h.length+1))}h.indexOf("g")<0&&(h+="g");let d=r,u=new RegExp(c,h),m=u.exec(d);for(;m!==null;){let p=f;for(let _=0;_{HH()});kH=[],WH=!1,ED=null});var hi,vo=C(()=>{$e();Qe();vD();jt();Pt();hi=class{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,r,n=!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 tf(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=r,this._pluginManager=e.pluginManager,n&&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){De.Clone(()=>e,this)}serialize(){return De.Serialize(this)}parse(e,t,i){De.Parse(()=>this,e,t,i)}};b([L()],hi.prototype,"name",void 0);b([L()],hi.prototype,"priority",void 0);b([L()],hi.prototype,"resolveIncludes",void 0);b([L()],hi.prototype,"registerForExtraEvents",void 0);Ke("BABYLON.MaterialPluginBase",hi)});var lS,ls,cS=C(()=>{$e();Vi();Qe();ns();Ur();vo();Ui();lS=class extends qt{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}},ls=class extends hi{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new lS,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=oe.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&&re.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&&re.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&&re.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),lt(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&re.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"}]}}};b([qe("detailTexture"),ie("_markAllSubMeshesAsTexturesDirty")],ls.prototype,"texture",void 0);b([L()],ls.prototype,"diffuseBlendLevel",void 0);b([L()],ls.prototype,"roughnessBlendLevel",void 0);b([L()],ls.prototype,"bumpLevel",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ls.prototype,"normalBlendMethod",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ls.prototype,"isEnabled",void 0)});var SD,qi,vm=C(()=>{Ee();(function(s){s[s.Zero=0]="Zero",s[s.One=1]="One",s[s.MaxViewZ=2]="MaxViewZ",s[s.NoClear=3]="NoClear"})(SD||(SD={}));qi=class s{static CreateConfiguration(e){return s._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:H.Zero(),currentViewProjection:H.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},s._Configurations[e]}static DeleteConfiguration(e){delete s._Configurations[e]}static GetConfiguration(e){return s._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=s._Configurations[e];if(!r)return;i.PREPASS=!0;let n=0;for(let a=0;a{});function sf(s){return class extends s{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 Tm=C(()=>{});function nf(s){return class extends s{constructor(...e){super(...e),BI()(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 Am=C(()=>{Qe()});var TD,zH,Tn=C(()=>{w();TD="sceneUboDeclaration",zH=`struct Scene {viewProjection : mat4x4, +#ifdef MULTIVIEW +viewProjectionR : mat4x4, +#endif +view : mat4x4, +projection : mat4x4, +vEyePosition : vec4, +inverseProjection : mat4x4,}; +#define SCENE_UBO +var scene : Scene; +`;E.IncludesShadersStoreWGSL[TD]||(E.IncludesShadersStoreWGSL[TD]=zH)});var AD,XH,So=C(()=>{w();AD="meshUboDeclaration",XH=`struct Mesh {world : mat4x4, +visibility : f32,};var mesh : Mesh; +#define WORLD_UBO +`;E.IncludesShadersStoreWGSL[AD]||(E.IncludesShadersStoreWGSL[AD]=XH)});var RD,YH,fS=C(()=>{w();Tn();So();RD="defaultUboDeclaration",YH=`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[RD]||(E.IncludesShadersStoreWGSL[RD]=YH)});var xD,KH,Rm=C(()=>{w();xD="uvAttributeDeclaration",KH=`#if defined(UV{X}) && !defined(USE_VERTEX_PULLING) +attribute uv{X}: vec2f; +#endif +`;E.IncludesShadersStoreWGSL[xD]||(E.IncludesShadersStoreWGSL[xD]=KH)});var ID,jH,xm=C(()=>{w();ID="prePassVertexDeclaration",jH=`#ifdef PREPASS +#ifdef PREPASS_LOCAL_POSITION +varying vPosition : vec3f; +#endif +#ifdef PREPASS_DEPTH +varying vViewPos: vec3f; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +varying vNormViewDepth: f32; +#endif +#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) +uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; +#endif +#endif +`;E.IncludesShadersStoreWGSL[ID]||(E.IncludesShadersStoreWGSL[ID]=jH)});var CD,ZH,af=C(()=>{w();CD="mainUVVaryingDeclaration",ZH=`#ifdef MAINUV{X} +varying vMainUV{X}: vec2f; +#endif +`;E.IncludesShadersStoreWGSL[CD]||(E.IncludesShadersStoreWGSL[CD]=ZH)});var bD,qH,Im=C(()=>{w();bD="samplerVertexDeclaration",qH=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +varying v_VARYINGNAME_UV: vec2f; +#endif +`;E.IncludesShadersStoreWGSL[bD]||(E.IncludesShadersStoreWGSL[bD]=qH)});var MD,QH,hS=C(()=>{w();MD="bumpVertexDeclaration",QH=`#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[MD]||(E.IncludesShadersStoreWGSL[MD]=QH)});var yD,JH,DD=C(()=>{w();yD="lightVxFragmentDeclaration",JH=`#ifdef LIGHT{X} +uniform vLightData{X}: vec4f;uniform vLightDiffuse{X}: vec4f; +#ifdef SPECULARTERM +uniform vLightSpecular{X}: vec4f; +#else +var vLightSpecular{X}: vec4f= vec4f(0.); +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform lightMatrix{X}: mat4x4f[SHADOWCSMNUM_CASCADES{X}];varying var vPositionFromLight{X}: vec4f[SHADOWCSMNUM_CASCADES{X}];varying var vDepthMetric{X}: f32[SHADOWCSMNUM_CASCADES{X}];varying var vPositionFromCamera{X}: vec4f; +#elif defined(SHADOWCUBE{X}) +#else +varying var vPositionFromLight{X}: vec4f;varying var vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f; +#endif +uniform shadowsInfo{X}: vec4f;uniform depthValues{X}: vec2f; +#endif +#ifdef SPOTLIGHT{X} +uniform vLightDirection{X}: vec4f;uniform vLightFalloff{X}: vec4f; +#elif defined(POINTLIGHT{X}) +uniform vLightFalloff{X}: vec4f; +#elif defined(HEMILIGHT{X}) +uniform vLightGround{X}: vec3f; +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +uniform vLightWidth{X}: vec4f;uniform vLightHeight{X}: vec4f; +#endif +#endif +`;E.IncludesShadersStoreWGSL[yD]||(E.IncludesShadersStoreWGSL[yD]=JH)});var PD,$H,Cm=C(()=>{w();PD="lightVxUboDeclaration",$H=`#ifdef LIGHT{X} +struct Light{X} +{vLightData: vec4f, +vLightDiffuse: vec4f, +vLightSpecular: vec4f, +#ifdef SPOTLIGHT{X} +vLightDirection: vec4f, +vLightFalloff: vec4f, +#elif defined(POINTLIGHT{X}) +vLightFalloff: vec4f, +#elif defined(HEMILIGHT{X}) +vLightGround: vec3f, +#elif defined(CLUSTLIGHT{X}) +vSliceData: vec2f, +vSliceRanges: array, +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vLightWidth: vec4f, +vLightHeight: vec4f, +#endif +shadowsInfo: vec4f, +depthValues: vec2f} ;var light{X} : Light{X}; +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform lightMatrix{X}: array;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f; +#elif defined(SHADOWCUBE{X}) +#else +varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;uniform lightMatrix{X}: mat4x4f; +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[PD]||(E.IncludesShadersStoreWGSL[PD]=$H)});var LD,ez,To=C(()=>{w();LD="morphTargetsVertexGlobalDeclaration",ez=`#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 +{ +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).xyz;} +fn readVector4FromRawSampler(targetIndex : i32,vertexIndex : f32)->vec4 +{ +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[LD]||(E.IncludesShadersStoreWGSL[LD]=ez)});var OD,tz,Ao=C(()=>{w();OD="morphTargetsVertexDeclaration",tz=`#ifdef MORPHTARGETS +#ifndef MORPHTARGETS_TEXTURE +#ifdef MORPHTARGETS_POSITION +attribute position{X} : vec3; +#endif +#ifdef MORPHTARGETS_NORMAL +attribute normal{X} : vec3; +#endif +#ifdef MORPHTARGETS_TANGENT +attribute tangent{X} : vec3; +#endif +#ifdef MORPHTARGETS_UV +attribute uv_{X} : vec2; +#endif +#ifdef MORPHTARGETS_UV2 +attribute uv2_{X} : vec2; +#endif +#ifdef MORPHTARGETS_COLOR +attribute color{X} : vec4; +#endif +#elif {X}==0 +uniform morphTargetCount: f32; +#endif +#endif +`;E.IncludesShadersStoreWGSL[OD]||(E.IncludesShadersStoreWGSL[OD]=tz)});var ND,iz,_a=C(()=>{w();ND="logDepthDeclaration",iz=`#ifdef LOGARITHMICDEPTH +uniform logarithmicDepthConstant: f32;varying vFragmentDepth: f32; +#endif +`;E.IncludesShadersStoreWGSL[ND]||(E.IncludesShadersStoreWGSL[ND]=iz)});var FD,rz,bm=C(()=>{w();FD="vertexPullingDeclaration",rz=`#ifdef USE_VERTEX_PULLING +#ifdef VERTEX_PULLING_USE_INDEX_BUFFER +var indices : array; +#endif +var position : array;uniform vp_position_info : vec4f; +#ifdef NORMAL +var normal : array;uniform vp_normal_info : vec4f; +#endif +#ifdef TANGENT +var tangent : array;uniform vp_tangent_info : vec4f; +#endif +#ifdef UV1 +var uv : array;uniform vp_uv_info : vec4f; +#define VP_UV1_SUPPORTED +#endif +#ifdef UV2 +var uv2 : array;uniform vp_uv2_info : vec4f; +#define VP_UV2_SUPPORTED +#endif +#ifdef UV3 +var uv3 : array;uniform vp_uv3_info : vec4f; +#define VP_UV3_SUPPORTED +#endif +#ifdef UV4 +var uv4 : array;uniform vp_uv4_info : vec4f; +#define VP_UV4_SUPPORTED +#endif +#ifdef UV5 +var uv5 : array;uniform vp_uv5_info : vec4f; +#define VP_UV5_SUPPORTED +#endif +#ifdef UV6 +var uv6 : array;uniform vp_uv6_info : vec4f; +#define VP_UV6_SUPPORTED +#endif +#ifdef VERTEXCOLOR +var color : array;uniform vp_color_info : vec4f; +#endif +#if NUM_BONE_INFLUENCERS>0 +var matricesIndices : array;var matricesWeights : array;uniform vp_matricesIndices_info : vec4f;uniform vp_matricesWeights_info : vec4f; +#if NUM_BONE_INFLUENCERS>4 +var matricesIndicesExtra : array;var matricesWeightsExtra : array;uniform vp_matricesIndicesExtra_info : vec4f;uniform vp_matricesWeightsExtra_info : vec4f; +#endif +#endif +fn vp_convertToFloat(word : u32,byteInWord : u32,dataType : u32,normalized : bool)->f32 {switch (dataType) {case 5120u: { +let shift=byteInWord*8u;let value=(word>>shift) & 0xFFu;let signedValue=f32(i32(value<<24u)>>24u);if (normalized) { return signedValue/127.0; } +return signedValue;} +case 5121u: { +let shift=byteInWord*8u;let value=(word>>shift) & 0xFFu;if (normalized) { return f32(value)/255.0; } +return f32(value);} +case 5122u: { +let shift=(byteInWord & 0xFFFFFFFEu)*8u;let value=(word>>shift) & 0xFFFFu;let signedValue=f32(i32(value<<16u)>>16u);if (normalized) { return signedValue/32767.0; } +return signedValue;} +case 5123u: { +let shift=(byteInWord & 0xFFFFFFFEu)*8u;let value=(word>>shift) & 0xFFFFu;if (normalized) { return f32(value)/65535.0; } +return f32(value);} +case 5126u: { +return bitcast(word);} +default: { return 0.0; }}} +fn vp_componentSize(dataType : u32)->u32 {return select(select(2u,1u,dataType==5120u || dataType==5121u),4u,dataType==5126u);} +fn vp_readVertexIndex(index : u32)->u32 { +#ifndef VERTEX_PULLING_USE_INDEX_BUFFER +return index; +#else +#ifdef VERTEX_PULLING_INDEX_BUFFER_32BITS +return indices[index]; +#else +let u32_index=index/2u;let bit_offset=(index & 1u)*16u;return (indices[u32_index]>>bit_offset) & 0xFFFFu; +#endif +#endif +} +fn vp_readPositionValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(position[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readPosition(info : vec4f,vertexIndex : u32)->vec3f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec3f( +vp_readPositionValue(offset,dataType,normalized), +vp_readPositionValue(offset+cs,dataType,normalized), +vp_readPositionValue(offset+cs*2u,dataType,normalized) +);} +#ifdef NORMAL +fn vp_readNormalValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(normal[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readNormal(info : vec4f,vertexIndex : u32)->vec3f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec3f( +vp_readNormalValue(offset,dataType,normalized), +vp_readNormalValue(offset+cs,dataType,normalized), +vp_readNormalValue(offset+cs*2u,dataType,normalized) +);} +#endif +#ifdef TANGENT +fn vp_readTangentValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(tangent[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readTangent(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readTangentValue(offset,dataType,normalized), +vp_readTangentValue(offset+cs,dataType,normalized), +vp_readTangentValue(offset+cs*2u,dataType,normalized), +vp_readTangentValue(offset+cs*3u,dataType,normalized) +);} +#endif +#ifdef UV1 +fn vp_readUVValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUVValue(offset,dataType,normalized), +vp_readUVValue(offset+cs,dataType,normalized) +);} +#endif +#ifdef UV2 +fn vp_readUV2Value(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv2[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV2(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUV2Value(offset,dataType,normalized), +vp_readUV2Value(offset+cs,dataType,normalized) +);} +#endif +#ifdef UV3 +fn vp_readUV3Value(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv3[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV3(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUV3Value(offset,dataType,normalized), +vp_readUV3Value(offset+cs,dataType,normalized) +);} +#endif +#ifdef UV4 +fn vp_readUV4Value(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv4[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV4(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUV4Value(offset,dataType,normalized), +vp_readUV4Value(offset+cs,dataType,normalized) +);} +#endif +#ifdef UV5 +fn vp_readUV5Value(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv5[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV5(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUV5Value(offset,dataType,normalized), +vp_readUV5Value(offset+cs,dataType,normalized) +);} +#endif +#ifdef UV6 +fn vp_readUV6Value(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(uv6[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readUV6(info : vec4f,vertexIndex : u32)->vec2f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec2f( +vp_readUV6Value(offset,dataType,normalized), +vp_readUV6Value(offset+cs,dataType,normalized) +);} +#endif +#ifdef VERTEXCOLOR +fn vp_readColorValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(color[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readColor(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readColorValue(offset,dataType,normalized), +vp_readColorValue(offset+cs,dataType,normalized), +vp_readColorValue(offset+cs*2u,dataType,normalized), +vp_readColorValue(offset+cs*3u,dataType,normalized) +);} +#endif +#if NUM_BONE_INFLUENCERS>0 +fn vp_readMatrixIndexValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(matricesIndices[byteOffset/4u],byteOffset % 4u,dataType,normalized);} +fn vp_readBoneIndices(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readMatrixIndexValue(offset,dataType,normalized), +vp_readMatrixIndexValue(offset+cs,dataType,normalized), +vp_readMatrixIndexValue(offset+cs*2u,dataType,normalized), +vp_readMatrixIndexValue(offset+cs*3u,dataType,normalized) +);} +fn vp_readMatrixWeightValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(matricesWeights[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readBoneWeights(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readMatrixWeightValue(offset,dataType,normalized), +vp_readMatrixWeightValue(offset+cs,dataType,normalized), +vp_readMatrixWeightValue(offset+cs*2u,dataType,normalized), +vp_readMatrixWeightValue(offset+cs*3u,dataType,normalized) +);} +#if NUM_BONE_INFLUENCERS>4 +fn vp_readMatrixIndexExtraValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(matricesIndicesExtra[byteOffset/4u],byteOffset % 4u,dataType,normalized);} +fn vp_readBoneIndicesExtra(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readMatrixIndexExtraValue(offset,dataType,normalized), +vp_readMatrixIndexExtraValue(offset+cs,dataType,normalized), +vp_readMatrixIndexExtraValue(offset+cs*2u,dataType,normalized), +vp_readMatrixIndexExtraValue(offset+cs*3u,dataType,normalized) +);} +fn vp_readMatrixWeightExtraValue(byteOffset : u32,dataType : u32,normalized : bool)->f32 {return vp_convertToFloat(bitcast(matricesWeightsExtra[byteOffset/4u]),byteOffset % 4u,dataType,normalized);} +fn vp_readBoneWeightsExtra(info : vec4f,vertexIndex : u32)->vec4f {let baseOffset=u32(info.x);let stride=u32(info.y);let dataType=u32(info.z);let normalized=info.w != 0.0;let offset=baseOffset+vertexIndex*stride;let cs=vp_componentSize(dataType);return vec4f( +vp_readMatrixWeightExtraValue(offset,dataType,normalized), +vp_readMatrixWeightExtraValue(offset+cs,dataType,normalized), +vp_readMatrixWeightExtraValue(offset+cs*2u,dataType,normalized), +vp_readMatrixWeightExtraValue(offset+cs*3u,dataType,normalized) +);} +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[FD]||(E.IncludesShadersStoreWGSL[FD]=rz)});var wD,sz,Mm=C(()=>{w();wD="vertexPullingVertex",sz=`#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); +#endif +#ifdef TANGENT +tangentUpdated=vp_readTangent(uniforms.vp_tangent_info,vpVertexIndex); +#endif +#ifdef UV1 +uvUpdated=vp_readUV(uniforms.vp_uv_info,vpVertexIndex); +#endif +#ifdef UV2 +uv2Updated=vp_readUV2(uniforms.vp_uv2_info,vpVertexIndex); +#endif +#ifdef UV3 +var uv3Updated: vec2f=vp_readUV3(uniforms.vp_uv3_info,vpVertexIndex); +#endif +#ifdef UV4 +var uv4Updated: vec2f=vp_readUV4(uniforms.vp_uv4_info,vpVertexIndex); +#endif +#ifdef UV5 +var uv5Updated: vec2f=vp_readUV5(uniforms.vp_uv5_info,vpVertexIndex); +#endif +#ifdef UV6 +var uv6Updated: vec2f=vp_readUV6(uniforms.vp_uv6_info,vpVertexIndex); +#endif +#ifdef VERTEXCOLOR +colorUpdated=vp_readColor(uniforms.vp_color_info,vpVertexIndex); +#endif +#ifdef MORPHTARGETS +let vp_basePosition: vec3f=positionUpdated; +#ifdef NORMAL +let vp_baseNormal: vec3f=normalUpdated; +#endif +#ifdef TANGENT +let vp_baseTangent: vec4f=tangentUpdated; +#endif +#ifdef UV1 +let vp_baseUV: vec2f=uvUpdated; +#endif +#ifdef UV2 +let vp_baseUV2: vec2f=uv2Updated; +#endif +#ifdef VERTEXCOLOR +let vp_baseColor: vec4f=colorUpdated; +#endif +#endif +#if NUM_BONE_INFLUENCERS>0 +var vp_matricesIndices: vec4f=vp_readBoneIndices(uniforms.vp_matricesIndices_info,vpVertexIndex);var vp_matricesWeights: vec4f=vp_readBoneWeights(uniforms.vp_matricesWeights_info,vpVertexIndex); +#if NUM_BONE_INFLUENCERS>4 +var vp_matricesIndicesExtra: vec4f=vp_readBoneIndicesExtra(uniforms.vp_matricesIndicesExtra_info,vpVertexIndex);var vp_matricesWeightsExtra: vec4f=vp_readBoneWeightsExtra(uniforms.vp_matricesWeightsExtra_info,vpVertexIndex); +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[wD]||(E.IncludesShadersStoreWGSL[wD]=sz)});var BD,nz,Ro=C(()=>{w();BD="morphTargetsVertexGlobal",nz=`#ifdef MORPHTARGETS +#ifdef MORPHTARGETS_TEXTURE +var vertexID : f32; +#endif +#endif +`;E.IncludesShadersStoreWGSL[BD]||(E.IncludesShadersStoreWGSL[BD]=nz)});var UD,az,xo=C(()=>{w();UD="morphTargetsVertex",az=`#ifdef MORPHTARGETS +#ifdef MORPHTARGETS_TEXTURE +#if {X}==0 +for (var i=0; i=uniforms.morphTargetCount) {break;} +#ifdef USE_VERTEX_PULLING +vertexID=f32(vpVertexIndex)*uniforms.morphTargetTextureInfo.x; +#else +vertexID=f32(vertexInputs.vertexIndex)*uniforms.morphTargetTextureInfo.x; +#endif +#ifdef MORPHTARGETS_POSITION +#ifdef USE_VERTEX_PULLING +positionUpdated=positionUpdated+(readVector3FromRawSampler(i,vertexID)-vp_basePosition)*uniforms.morphTargetInfluences[i]; +#else +positionUpdated=positionUpdated+(readVector3FromRawSampler(i,vertexID)-vertexInputs.position)*uniforms.morphTargetInfluences[i]; +#endif +#endif +#ifdef MORPHTARGETTEXTURE_HASPOSITIONS +vertexID=vertexID+1.0; +#endif +#ifdef MORPHTARGETS_NORMAL +#ifdef USE_VERTEX_PULLING +normalUpdated=normalUpdated+(readVector3FromRawSampler(i,vertexID) -vp_baseNormal)*uniforms.morphTargetInfluences[i]; +#else +normalUpdated=normalUpdated+(readVector3FromRawSampler(i,vertexID) -vertexInputs.normal)*uniforms.morphTargetInfluences[i]; +#endif +#endif +#ifdef MORPHTARGETTEXTURE_HASNORMALS +vertexID=vertexID+1.0; +#endif +#ifdef MORPHTARGETS_UV +#ifdef USE_VERTEX_PULLING +uvUpdated=uvUpdated+(readVector3FromRawSampler(i,vertexID).xy-vp_baseUV)*uniforms.morphTargetInfluences[i]; +#else +uvUpdated=uvUpdated+(readVector3FromRawSampler(i,vertexID).xy-vertexInputs.uv)*uniforms.morphTargetInfluences[i]; +#endif +#endif +#ifdef MORPHTARGETTEXTURE_HASUVS +vertexID=vertexID+1.0; +#endif +#ifdef MORPHTARGETS_TANGENT +#ifdef USE_VERTEX_PULLING +tangentUpdated=vec4f(tangentUpdated.xyz+(readVector3FromRawSampler(i,vertexID) -vp_baseTangent.xyz)*uniforms.morphTargetInfluences[i],tangentUpdated.a); +#else +tangentUpdated=vec4f(tangentUpdated.xyz+(readVector3FromRawSampler(i,vertexID) -vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[i],tangentUpdated.a); +#endif +#endif +#ifdef MORPHTARGETTEXTURE_HASTANGENTS +vertexID=vertexID+1.0; +#endif +#ifdef MORPHTARGETS_UV2 +#ifdef USE_VERTEX_PULLING +uv2Updated=uv2Updated+(readVector3FromRawSampler(i,vertexID).xy-vp_baseUV2)*uniforms.morphTargetInfluences[i]; +#else +uv2Updated=uv2Updated+(readVector3FromRawSampler(i,vertexID).xy-vertexInputs.uv2)*uniforms.morphTargetInfluences[i]; +#endif +#endif +#ifdef MORPHTARGETS_COLOR +#ifdef USE_VERTEX_PULLING +colorUpdated=colorUpdated+(readVector4FromRawSampler(i,vertexID)-vp_baseColor)*uniforms.morphTargetInfluences[i]; +#else +colorUpdated=colorUpdated+(readVector4FromRawSampler(i,vertexID)-vertexInputs.color)*uniforms.morphTargetInfluences[i]; +#endif +#endif +} +#endif +#else +#ifdef MORPHTARGETS_POSITION +#ifdef USE_VERTEX_PULLING +positionUpdated=positionUpdated+(vertexInputs.position{X}-vp_basePosition)*uniforms.morphTargetInfluences[{X}]; +#else +positionUpdated=positionUpdated+(vertexInputs.position{X}-vertexInputs.position)*uniforms.morphTargetInfluences[{X}]; +#endif +#endif +#ifdef MORPHTARGETS_NORMAL +#ifdef USE_VERTEX_PULLING +normalUpdated=normalUpdated+(vertexInputs.normal{X}-vp_baseNormal)*uniforms.morphTargetInfluences[{X}]; +#else +normalUpdated=normalUpdated+(vertexInputs.normal{X}-vertexInputs.normal)*uniforms.morphTargetInfluences[{X}]; +#endif +#endif +#ifdef MORPHTARGETS_TANGENT +#ifdef USE_VERTEX_PULLING +tangentUpdated=vec4f(tangentUpdated.xyz+(vertexInputs.tangent{X}-vp_baseTangent.xyz)*uniforms.morphTargetInfluences[{X}],tangentUpdated.a); +#else +tangentUpdated=vec4f(tangentUpdated.xyz+(vertexInputs.tangent{X}-vertexInputs.tangent.xyz)*uniforms.morphTargetInfluences[{X}],tangentUpdated.a); +#endif +#endif +#ifdef MORPHTARGETS_UV +#ifdef USE_VERTEX_PULLING +uvUpdated=uvUpdated+(vertexInputs.uv_{X}-vp_baseUV)*uniforms.morphTargetInfluences[{X}]; +#else +uvUpdated=uvUpdated+(vertexInputs.uv_{X}-vertexInputs.uv)*uniforms.morphTargetInfluences[{X}]; +#endif +#endif +#ifdef MORPHTARGETS_UV2 +#ifdef USE_VERTEX_PULLING +uv2Updated=uv2Updated+(vertexInputs.uv2_{X}-vp_baseUV2)*uniforms.morphTargetInfluences[{X}]; +#else +uv2Updated=uv2Updated+(vertexInputs.uv2_{X}-vertexInputs.uv2)*uniforms.morphTargetInfluences[{X}]; +#endif +#endif +#ifdef MORPHTARGETS_COLOR +#ifdef USE_VERTEX_PULLING +colorUpdated=colorUpdated+(vertexInputs.color{X}-vp_baseColor)*uniforms.morphTargetInfluences[{X}]; +#else +colorUpdated=colorUpdated+(vertexInputs.color{X}-vertexInputs.color)*uniforms.morphTargetInfluences[{X}]; +#endif +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[UD]||(E.IncludesShadersStoreWGSL[UD]=az)});var VD,oz,ym=C(()=>{w();VD="prePassVertex",oz=`#ifdef PREPASS_DEPTH +vertexOutputs.vViewPos=(scene.view*worldPos).rgb; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +vertexOutputs.vNormViewDepth=((scene.view*worldPos).z-uniforms.cameraInfo.x)/(uniforms.cameraInfo.y-uniforms.cameraInfo.x); +#endif +#ifdef PREPASS_LOCAL_POSITION +vertexOutputs.vPosition=positionUpdated.xyz; +#endif +#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED) +vertexOutputs.vCurrentPosition=scene.viewProjection*worldPos; +#if NUM_BONE_INFLUENCERS>0 +var previousInfluence: mat4x4f;previousInfluence=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3]; +#endif +vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*previousInfluence* vec4f(positionUpdated,1.0); +#else +vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0); +#endif +#endif +`;E.IncludesShadersStoreWGSL[VD]||(E.IncludesShadersStoreWGSL[VD]=oz)});var GD,lz,Dm=C(()=>{w();GD="uvVariableDeclaration",lz=`#ifdef MAINUV{X} +#if !defined(UV{X}) +var uv{X}: vec2f=vec2f(0.,0.); +#elif defined(USE_VERTEX_PULLING) +var uv{X}: vec2f=uv{X}Updated; +#else +var uv{X}: vec2f=vertexInputs.uv{X}; +#endif +vertexOutputs.vMainUV{X}=uv{X}; +#endif +`;E.IncludesShadersStoreWGSL[GD]||(E.IncludesShadersStoreWGSL[GD]=lz)});var kD,cz,Pm=C(()=>{w();kD="samplerVertexImplementation",cz=`#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 +else if (uniforms.v_INFONAME_==1.) +{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(uv2Updated,1.0,0.0)).xy;} +#endif +#ifdef UV3 +else if (uniforms.v_INFONAME_==2.) +{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv3,1.0,0.0)).xy;} +#endif +#ifdef UV4 +else if (uniforms.v_INFONAME_==3.) +{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv4,1.0,0.0)).xy;} +#endif +#ifdef UV5 +else if (uniforms.v_INFONAME_==4.) +{vertexOutputs.v_VARYINGNAME_UV= (uniforms._MATRIXNAME_Matrix* vec4f(vertexInputs.uv5,1.0,0.0)).xy;} +#endif +#ifdef UV6 +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[kD]||(E.IncludesShadersStoreWGSL[kD]=cz)});var WD,fz,Lm=C(()=>{w();WD="bumpVertex",fz=`#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[WD]||(E.IncludesShadersStoreWGSL[WD]=fz)});var HD,hz,Om=C(()=>{w();HD="shadowsVertex",hz=`#ifdef SHADOWS +#if defined(SHADOWCSM{X}) +#ifdef SCENE_UBO +vertexOutputs.vPositionFromCamera{X}=scene.view*worldPos; +#else +vertexOutputs.vPositionFromCamera{X}=uniforms.view*worldPos; +#endif +#if SHADOWCSMNUM_CASCADES{X}>0 +vertexOutputs.vPositionFromLight{X}_0=uniforms.lightMatrix{X}[0]*worldPos; +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric{X}_0=(-vertexOutputs.vPositionFromLight{X}_0.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#else +vertexOutputs.vDepthMetric{X}_0= (vertexOutputs.vPositionFromLight{X}_0.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#endif +#endif +#if SHADOWCSMNUM_CASCADES{X}>1 +vertexOutputs.vPositionFromLight{X}_1=uniforms.lightMatrix{X}[1]*worldPos; +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric{X}_1=(-vertexOutputs.vPositionFromLight{X}_1.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#else +vertexOutputs.vDepthMetric{X}_1= (vertexOutputs.vPositionFromLight{X}_1.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#endif +#endif +#if SHADOWCSMNUM_CASCADES{X}>2 +vertexOutputs.vPositionFromLight{X}_2=uniforms.lightMatrix{X}[2]*worldPos; +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric{X}_2=(-vertexOutputs.vPositionFromLight{X}_2.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#else +vertexOutputs.vDepthMetric{X}_2= (vertexOutputs.vPositionFromLight{X}_2.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#endif +#endif +#if SHADOWCSMNUM_CASCADES{X}>3 +vertexOutputs.vPositionFromLight{X}_3=uniforms.lightMatrix{X}[3]*worldPos; +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric{X}_3=(-vertexOutputs.vPositionFromLight{X}_3.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#else +vertexOutputs.vDepthMetric{X}_3= (vertexOutputs.vPositionFromLight{X}_3.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#endif +#endif +#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X}) +vertexOutputs.vPositionFromLight{X}=uniforms.lightMatrix{X}*worldPos; +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric{X}=(-vertexOutputs.vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#else +vertexOutputs.vDepthMetric{X}=(vertexOutputs.vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y; +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[HD]||(E.IncludesShadersStoreWGSL[HD]=hz)});var zD,dz,Oh=C(()=>{w();zD="logDepthVertex",dz=`#ifdef LOGARITHMICDEPTH +vertexOutputs.vFragmentDepth=1.0+vertexOutputs.position.w;vertexOutputs.position.z=log2(max(0.000001,vertexOutputs.vFragmentDepth))*uniforms.logarithmicDepthConstant; +#endif +`;E.IncludesShadersStoreWGSL[zD]||(E.IncludesShadersStoreWGSL[zD]=dz)});var YD={};Ie(YD,{defaultVertexShaderWGSL:()=>uz});var dS,XD,uz,KD=C(()=>{w();fS();Rm();Lr();na();aa();go();xm();af();Im();hS();un();zc();DD();Cm();To();Ao();_a();bm();Mm();Ro();xo();oa();la();ca();ym();Dm();Pm();Lm();mn();Xc();Om();Ch();Oh();dS="defaultVertexShader",XD=`#include +#define CUSTOM_VERTEX_BEGIN +#ifndef USE_VERTEX_PULLING +attribute position: vec3f; +#ifdef NORMAL +attribute normal: vec3f; +#endif +#ifdef TANGENT +attribute tangent: vec4f; +#endif +#ifdef UV1 +attribute uv: vec2f; +#endif +#include[2..7] +#ifdef VERTEXCOLOR +attribute color: vec4f; +#endif +#endif +#include +#include +#include +#include +#include +#include[1..7] +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular) +#endif +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +varying vPositionW: vec3f; +#ifdef NORMAL +varying vNormalW: vec3f; +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#include +#include +#include +#include<__decl__lightVxFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vPositionUVW: vec3f; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vDirectionW: vec3f; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying vViewDepth: f32; +#endif +#include +#include +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef USE_VERTEX_PULLING +var positionUpdated: vec3f=vec3f(0.0); +#ifdef NORMAL +var normalUpdated: vec3f=vec3f(0.0); +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vec4f(0.0); +#endif +#ifdef UV1 +var uvUpdated: vec2f=vec2f(0.0); +#endif +#ifdef UV2 +var uv2Updated: vec2f=vec2f(0.0); +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vec4f(0.0); +#endif +#else +var positionUpdated: vec3f=vertexInputs.position; +#ifdef NORMAL +var normalUpdated: vec3f=vertexInputs.normal; +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vertexInputs.tangent; +#endif +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vertexInputs.color; +#endif +#endif +#include +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vertexOutputs.vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*vec4f(positionUpdated,1.0); +#endif +#ifdef USE_VERTEX_PULLING +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#else +#include +#include +#endif +var worldPos: vec4f=finalWorld*vec4f(positionUpdated,1.0); +#ifdef NORMAL +var normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vertexOutputs.vNormalW=normalUpdated/ vec3f(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vertexOutputs.vNormalW=normalize(normalWorld*vertexOutputs.vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*worldPos;} else {vertexOutputs.position=scene.viewProjectionR*worldPos;} +#else +vertexOutputs.position=scene.viewProjection*worldPos; +#endif +vertexOutputs.vPositionW= worldPos.xyz; +#ifdef PREPASS +#include +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vertexOutputs.vDirectionW=normalize((finalWorld* vec4f(positionUpdated,0.0)).xyz); +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#ifdef RIGHT_HANDED +vertexOutputs.vViewDepth=-(scene.view*worldPos).z; +#else +vertexOutputs.vViewDepth=(scene.view*worldPos).z; +#endif +#endif +#ifndef UV1 +var uvUpdated: vec2f=vec2f(0.,0.); +#endif +#ifdef MAINUV1 +vertexOutputs.vMainUV1=uvUpdated; +#endif +#ifndef UV2 +var uv2Updated: vec2f=vec2f(0.,0.); +#endif +#ifdef MAINUV2 +vertexOutputs.vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x) +#endif +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStoreWGSL[dS]||(E.ShadersStoreWGSL[dS]=XD);uz={name:dS,shader:XD}});var jD,mz,Nm=C(()=>{w();jD="prePassDeclaration",mz=`#ifdef PREPASS +#ifdef PREPASS_LOCAL_POSITION +varying vPosition : vec3f; +#endif +#ifdef PREPASS_DEPTH +varying vViewPos: vec3f; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +varying vNormViewDepth: f32; +#endif +#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) +varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; +#endif +#endif +`;E.IncludesShadersStoreWGSL[jD]||(E.IncludesShadersStoreWGSL[jD]=mz)});var ZD,pz,Fm=C(()=>{w();ZD="oitDeclaration",pz=`#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[ZD]||(E.IncludesShadersStoreWGSL[ZD]=pz)});var qD,_z,wm=C(()=>{w();qD="lightUboDeclaration",_z=`#ifdef LIGHT{X} +struct Light{X} +{vLightData: vec4f, +vLightDiffuse: vec4f, +vLightSpecular: vec4f, +#ifdef SPOTLIGHT{X} +vLightDirection: vec4f, +vLightFalloff: vec4f, +#elif defined(POINTLIGHT{X}) +vLightFalloff: vec4f, +#elif defined(HEMILIGHT{X}) +vLightGround: vec3f, +#elif defined(CLUSTLIGHT{X}) +vSliceData: vec2f, +vSliceRanges: array, +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vLightWidth: vec4f, +vLightHeight: vec4f, +#endif +shadowsInfo: vec4f, +depthValues: vec2f} ;var light{X} : Light{X}; +#ifdef IESLIGHTTEXTURE{X} +var iesLightTexture{X}Sampler: sampler;var iesLightTexture{X}: texture_2d; +#endif +#ifdef RECTAREALIGHTEMISSIONTEXTURE{X} +var rectAreaLightEmissionTexture{X}Sampler: sampler;var rectAreaLightEmissionTexture{X}: texture_2d; +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}Sampler: sampler;var projectionLightTexture{X}: texture_2d; +#endif +#ifdef CLUSTLIGHT{X} +var lightDataTexture{X}: texture_2d;var tileMaskBuffer{X}: array; +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform lightMatrix{X}: array;uniform viewFrustumZ{X}: array;uniform frustumLengths{X}: array;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var vPositionFromLight{X}: array;var vDepthMetric{X} : array; +#if defined(SHADOWPCSS{X}) +var shadowTexture{X}Sampler: sampler_comparison; +var shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array;uniform lightSizeUVCorrection{X}: array;uniform depthCorrection{X}: array;uniform penumbraDarkness{X}: f32; +#elif defined(SHADOWPCF{X}) +var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array; +#else +var shadowTexture{X}Sampler: sampler; +var shadowTexture{X}: texture_2d_array; +#endif +#ifdef SHADOWCSMDEBUG{X} +const vCascadeColorsMultiplier{X}: array=array +( +vec3f ( 1.5,0.0,0.0 ), +vec3f ( 0.0,1.5,0.0 ), +vec3f ( 0.0,0.0,5.5 ), +vec3f ( 1.5,0.0,5.5 ), +vec3f ( 1.5,1.5,0.0 ), +vec3f ( 1.0,1.0,1.0 ), +vec3f ( 0.0,1.0,5.5 ), +vec3f ( 0.5,3.5,0.75 ) +); +#endif +#elif defined(SHADOWCUBE{X}) +var shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube; +#else +varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32; +#if defined(SHADOWPCSS{X}) +var shadowTexture{X}Sampler: sampler_comparison; +var shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler; +var depthTexture{X}: texture_2d; +#elif defined(SHADOWPCF{X}) +var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d; +#else +var shadowTexture{X}Sampler: sampler; +var shadowTexture{X}: texture_2d; +#endif +uniform lightMatrix{X}: mat4x4f; +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[qD]||(E.IncludesShadersStoreWGSL[qD]=_z)});var QD,gz,uS=C(()=>{w();QD="ltcHelperFunctions",gz=`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;} +else +{thetaSintheta=0.5*inverseSqrt( max( 1.0-x*x,0.00000001 ) )-v;} +return cross( v1,v2 )*thetaSintheta;} +fn LTCEvaluate( N:vec3f,V:vec3f,P:vec3f,mInv: mat3x3,rectCoords0:vec3f,rectCoords1:vec3f,rectCoords2:vec3f,rectCoords3:vec3f )->vec3f {var v1:vec3f=rectCoords1-rectCoords0;var v2:vec3f=rectCoords3-rectCoords0;var lightNormal:vec3f=cross( v1,v2 );if( dot( lightNormal,P-rectCoords0 )<0.0 ){return vec3f( 0.0 );} +var T1:vec3f=normalize( V-N*dot( V,N ) );var T2:vec3f=- cross( N,T1 ); +var mat: mat3x3=mInv*transposeMat3( mat3x3( T1,T2,N ) );var coords0: vec3f=mat*( rectCoords0-P );var coords1: vec3f=mat*( rectCoords1-P );var coords2: vec3f=mat*( rectCoords2-P );var coords3: vec3f=mat*( rectCoords3-P );coords0=normalize( coords0 );coords1=normalize( coords1 );coords2=normalize( coords2 );coords3=normalize( coords3 );var vectorFormFactor:vec3f=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords0,coords1 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords1,coords2 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords2,coords3 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords3,coords0 );var result:f32=LTCClippedSphereFormFactor( vectorFormFactor );return vec3f( result );} +struct areaLightData +{Diffuse: vec3f, +Specular: vec3f, +Fresnel: vec4f};fn computeAreaLightSpecularDiffuseFresnel(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,viewDir: vec3f,normal:vec3f,position:vec3f,lightPos:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->areaLightData {var result: areaLightData;var rectCoords0:vec3f=lightPos+halfWidth-halfHeight; +var rectCoords1:vec3f=lightPos-halfWidth-halfHeight;var rectCoords2:vec3f=lightPos-halfWidth+halfHeight;var rectCoords3:vec3f=lightPos+halfWidth+halfHeight; +#ifdef SPECULARTERM +var uv:vec2f=LTCUv( normal,viewDir,roughness );var t1:vec4f=textureSample( ltc1,ltc1Sampler,uv );var t2:vec4f=textureSample( ltc2,ltc2Sampler,uv );var mInv:mat3x3=mat3x3( +vec3f( t1.x,0,t1.y ), +vec3f( 0,1, 0 ), +vec3f( t1.z,0,t1.w ) +);result.Fresnel=t2;result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords0,rectCoords1,rectCoords2,rectCoords3 ); +#endif +var mInvEmpty:mat3x3=mat3x3( +vec3f( 1,0,0 ), +vec3f( 0,1,0 ), +vec3f( 0,0,1 ) +);result.Diffuse+=LTCEvaluate( normal,viewDir,position,mInvEmpty,rectCoords0,rectCoords1,rectCoords2,rectCoords3 );return result;} +fn FetchDiffuseFilteredTexture(texLightFiltered: texture_2d,texLightFilteredSampler: sampler,p1_: vec3f,p2_: vec3f,p3_: vec3f,p4_: vec3f)->vec3f {var V1: vec3f=p2_-p1_;var V2: vec3f=p4_-p1_;var planeOrtho: vec3f=cross(V1,V2);var planeAreaSquared: f32=dot(planeOrtho,planeOrtho);var planeDistxPlaneArea: f32=dot(planeOrtho,p1_);var P: vec3f=planeDistxPlaneArea*planeOrtho/planeAreaSquared-p1_;var dot_V1_V2: f32=dot(V1,V2);var inv_dot_V1_V1: f32=1.0/dot(V1,V1);var V2_: vec3f=V2-V1*dot_V1_V2*inv_dot_V1_V1;var Puv: vec2f;Puv.y=dot(V2_,P)/dot(V2_,V2_);Puv.x=dot(V1,P)*inv_dot_V1_V1-dot_V1_V2*inv_dot_V1_V1*Puv.y;var d: f32=abs(planeDistxPlaneArea)/pow(planeAreaSquared,0.75);var sampleLOD: f32=log(2048.0*d)/log(3.0);var sampleUV: vec2f=vec2f(0.125,0.125)+(vec2f(0.75)*Puv);sampleUV.x=1.0-sampleUV.x;return textureSampleLevel(texLightFiltered,texLightFilteredSampler,sampleUV,sampleLOD).rgb;} +fn LTCEvaluateWithEmission(N: vec3f,V: vec3f,P: vec3f,mInv: mat3x3,rectCoords0: vec3f,rectCoords1: vec3f,rectCoords2: vec3f,rectCoords3: vec3f,texFilteredMap: texture_2d,texFilteredMapSampler: sampler)->vec3f {var v1: vec3f=rectCoords1-rectCoords0;var v2: vec3f=rectCoords3-rectCoords0;var lightNormal: vec3f=cross(v1,v2);if (dot(lightNormal,P-rectCoords0)<0.0) {return vec3f(0.0);} +var T1: vec3f=normalize(V-N*dot(V,N));var T2: vec3f=-cross(N,T1);var mat: mat3x3=mInv*transposeMat3(mat3x3(T1,T2,N));var coords0: vec3f=mat*(rectCoords0-P);var coords1: vec3f=mat*(rectCoords1-P);var coords2: vec3f=mat*(rectCoords2-P);var coords3: vec3f=mat*(rectCoords3-P);var textureLight: vec3f=FetchDiffuseFilteredTexture(texFilteredMap,texFilteredMapSampler,coords0,coords1,coords2,coords3);coords0=normalize(coords0);coords1=normalize(coords1);coords2=normalize(coords2);coords3=normalize(coords3);var vectorFormFactor: vec3f=vec3f(0.0);vectorFormFactor+=LTCEdgeVectorFormFactor(coords0,coords1);vectorFormFactor+=LTCEdgeVectorFormFactor(coords1,coords2);vectorFormFactor+=LTCEdgeVectorFormFactor(coords2,coords3);vectorFormFactor+=LTCEdgeVectorFormFactor(coords3,coords0);var result: f32=LTCClippedSphereFormFactor(vectorFormFactor);return vec3f(result)*textureLight;} +fn computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,emissionTexture: texture_2d,emissionTextureSampler:sampler,viewDir: vec3f,normal:vec3f,position:vec3f,lightPos:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->areaLightData {var result: areaLightData;var rectCoords0: vec3f=lightPos+halfWidth-halfHeight; +var rectCoords1: vec3f=lightPos-halfWidth-halfHeight;var rectCoords2: vec3f=lightPos-halfWidth+halfHeight;var rectCoords3: vec3f=lightPos+halfWidth+halfHeight; +#ifdef SPECULARTERM +var uv: vec2f=LTCUv(normal,viewDir,roughness);var t1: vec4f=textureSample(ltc1,ltc1Sampler,uv);var t2: vec4f=textureSample(ltc2,ltc2Sampler,uv);var mInv: mat3x3=mat3x3( +vec3f(t1.x,0,t1.y), +vec3f(0,1,0), +vec3f(t1.z,0,t1.w) +);result.Specular=LTCEvaluateWithEmission(normal,viewDir,position,mInv,rectCoords0,rectCoords1,rectCoords2,rectCoords3,emissionTexture,emissionTextureSampler);result.Fresnel=t2; +#endif +var mInvEmpty: mat3x3=mat3x3( +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[QD]||(E.IncludesShadersStoreWGSL[QD]=gz)});var JD,Ez,mS=C(()=>{w();JD="clusteredLightingFunctions",Ez=`struct ClusteredLight {vLightData: vec4f, +vLightDiffuse: vec4f, +vLightSpecular: vec4f, +vLightDirection: vec4f, +vLightFalloff: vec4f,} +fn getClusteredLight(lightDataTexture: texture_2d,index: u32)->ClusteredLight {return ClusteredLight( +textureLoad(lightDataTexture,vec2u(0,index),0), +textureLoad(lightDataTexture,vec2u(1,index),0), +textureLoad(lightDataTexture,vec2u(2,index),0), +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[JD]||(E.IncludesShadersStoreWGSL[JD]=Ez)});var $D,vz,eP=C(()=>{w();uS();mS();$D="lightsFragmentFunctions",vz=`struct lightingInfo +{diffuse: vec3f, +#ifdef SPECULARTERM +specular: vec3f, +#endif +#ifdef NDOTL +ndl: f32, +#endif +};fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.) +{var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);} +else +{lightVectorW=normalize(-lightData.xyz);} +var ndl: f32=max(0.,dot(vNormal,lightVectorW)); +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=ndl*diffuseColor*attenuation; +#ifdef SPECULARTERM +var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; +#endif +return result;} +fn getAttenuation(cosAngle: f32,exponent: f32)->f32 {return max(0.,pow(cosAngle,exponent));} +fn getIESAttenuation(cosAngle: f32,iesLightTexture: texture_2d,iesLightTextureSampler: sampler)->f32 {var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;} +fn computeBasicSpotLighting(viewDirectionW: vec3f,lightVectorW: vec3f,vNormal: vec3f,attenuation: f32,diffuseColor: vec3f,specularColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=max(0.,dot(vNormal,lightVectorW)); +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=ndl*diffuseColor*attenuation; +#ifdef SPECULARTERM +var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; +#endif +return result;} +fn computeIESSpotLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32,iesLightTexture: texture_2d,iesLightTextureSampler: sampler)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var dotProduct=dot(lightDirection.xyz,-lightVectorW);var cosAngle: f32=max(0.,dotProduct);if (cosAngle>=lightDirection.w) +{attenuation*=getIESAttenuation(dotProduct,iesLightTexture,iesLightTextureSampler);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} +var result: lightingInfo;result.diffuse=vec3f(0.); +#ifdef SPECULARTERM +result.specular=vec3f(0.); +#endif +#ifdef NDOTL +result.ndl=0.; +#endif +return result;} +fn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w) +{attenuation*=getAttenuation(cosAngle,lightData.w);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} +var result: lightingInfo;result.diffuse=vec3f(0.); +#ifdef SPECULARTERM +result.specular=vec3f(0.); +#endif +#ifdef NDOTL +result.ndl=0.; +#endif +return result;} +fn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5; +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=mix(groundColor,diffuseColor,ndl); +#ifdef SPECULARTERM +var angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor; +#endif +return result;} +fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#include +var areaLightsLTC1SamplerSampler: sampler;var areaLightsLTC1Sampler: texture_2d;var areaLightsLTC2SamplerSampler: sampler;var areaLightsLTC2Sampler: texture_2d;fn computeAreaLighting(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightPosition:vec3f,halfWidth:vec3f, halfHeight:vec3f,diffuseColor:vec3f,specularColor:vec3f,roughness:f32 )->lightingInfo +{var result: lightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc1Sampler,ltc2,ltc2Sampler,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +var fresnel:vec3f=( specularColor*data.Fresnel.x+( vec3f( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular; +#endif +result.diffuse+=diffuseColor*data.Diffuse;return result;} +fn computeAreaLightingWithTexture(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,emissionTexture: texture_2d,emissionTextureSampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightPosition:vec3f,halfWidth:vec3f, halfHeight:vec3f,diffuseColor:vec3f,specularColor:vec3f,roughness:f32 )->lightingInfo +{var result: lightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc1Sampler,ltc2,ltc2Sampler,emissionTexture,emissionTextureSampler,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +var fresnel: vec3f=( specularColor*data.Fresnel.x+( vec3f( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular; +#endif +result.diffuse+=diffuseColor*data.Diffuse;return result;} +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#include +fn computeClusteredLighting( +lightDataTexture: texture_2d, +tileMaskBuffer: ptr>, +viewDirectionW: vec3f, +vNormal: vec3f, +lightData: vec4f, +sliceRange: vec2u, +glossiness: f32 +)->lightingInfo {var result: lightingInfo;let tilePosition=vec2u(fragmentInputs.position.xy*lightData.xy);let maskResolution=vec2u(lightData.zw);var tileIndex=(tilePosition.x*maskResolution.x+tilePosition.y)*maskResolution.y;let batchRange=sliceRange/CLUSTLIGHT_BATCH;var batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tileIndex+=batchRange.x;for (var i=batchRange.x; i<=batchRange.y; i+=1) {var mask=tileMaskBuffer[tileIndex];tileIndex+=1;let maskOffset=max(sliceRange.x,batchOffset)-batchOffset; +let maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while mask != 0 {let trailing=firstTrailingBit(mask);mask ^= 1u<{w();tP="shadowsFragmentFunctions",Sz=`#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);} +#endif +fn computeFallOff(value: f32,clipSpace: vec2f,frustumEdgeFalloff: f32)->f32 +{var mask: f32=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);} +fn computeShadowCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube,shadowSampler: sampler,darkness: f32,depthValues: vec2f)->f32 +{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; +#ifndef SHADOWFLOAT +var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight)); +#else +var shadow: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x; +#endif +return select(1.0,darkness,depth>shadow);} +fn computeShadowWithPoissonSamplingCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube,shadowSampler: sampler,mapSize: f32,darkness: f32,depthValues: vec2f)->f32 +{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;var visibility: f32=1.;var poissonDisk: array;poissonDisk[0]= vec3f(-1.0,1.0,-1.0);poissonDisk[1]= vec3f(1.0,-1.0,-1.0);poissonDisk[2]= vec3f(-1.0,-1.0,-1.0);poissonDisk[3]= vec3f(1.0,-1.0,1.0); +#ifndef SHADOWFLOAT +if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize)),shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32 +{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; +#ifndef SHADOWFLOAT +var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight)); +#else +var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x; +#endif +var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;} +fn computeShadowWithCloseESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32 +{var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; +#ifndef SHADOWFLOAT +var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight)); +#else +var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x; +#endif +var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;} +fn computeShadowCSM(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d_array,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,uv,layer)); +#else +var shadow: f32=textureSample(shadowTexture,shadowSampler,uv,layer).x; +#endif +return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );} +fn computeShadow(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +var shadow: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.)); +#else +var shadow: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x; +#endif +return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}} +fn computeShadowWithPoissonSampling(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d,shadowSampler: sampler,mapSize: f32,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);var visibility: f32=1.;var poissonDisk: array;poissonDisk[0]= vec2f(-0.94201624,-0.39906216);poissonDisk[1]= vec2f(0.94558609,-0.76890725);poissonDisk[2]= vec2f(-0.094184101,-0.92938870);poissonDisk[3]= vec2f(0.34495938,0.29387760); +#ifndef SHADOWFLOAT +if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.)),shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.)); +#else +var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x; +#endif +var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} +fn computeShadowWithCloseESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.)); +#else +var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x; +#endif +var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} +fn getZInClip(clipSpace: vec3f,uvDepth: vec3f)->f32 +{ +#ifdef IS_NDC_HALF_ZRANGE +return clipSpace.z; +#else +return uvDepth.z; +#endif +} +const GREATEST_LESS_THAN_ONE: f32=0.99999994; +#define DISABLE_UNIFORMITY_ANALYSIS +fn computeShadowWithCSMPCF1(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var shadow: f32=textureSampleCompare(shadowTexture,shadowSampler,uvDepth.xy,layer,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +fn computeShadowWithCSMPCF3(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +var st: vec2f=fract(uv); +var base_uv: vec2f=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +fn computeShadowWithCSMPCF5(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +var st: vec2f=fract(uv); +var base_uv: vec2f=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),layer,uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),layer,uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),layer,uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),layer,uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +fn computeShadowWithPCF1(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {var shadow: f32=textureSampleCompareLevel(shadowTexture,shadowSampler,uvDepth.xy,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +fn computeShadowWithPCF3(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +var st: vec2f=fract(uv); +var base_uv: vec2f=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +fn computeShadowWithPCF5(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +var st: vec2f=fract(uv); +var base_uv: vec2f=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +const PoissonSamplers32: array=array ( +vec3f(0.06407013,0.05409927,0.), +vec3f(0.7366577,0.5789394,0.), +vec3f(-0.6270542,-0.5320278,0.), +vec3f(-0.4096107,0.8411095,0.), +vec3f(0.6849564,-0.4990818,0.), +vec3f(-0.874181,-0.04579735,0.), +vec3f(0.9989998,0.0009880066,0.), +vec3f(-0.004920578,-0.9151649,0.), +vec3f(0.1805763,0.9747483,0.), +vec3f(-0.2138451,0.2635818,0.), +vec3f(0.109845,0.3884785,0.), +vec3f(0.06876755,-0.3581074,0.), +vec3f(0.374073,-0.7661266,0.), +vec3f(0.3079132,-0.1216763,0.), +vec3f(-0.3794335,-0.8271583,0.), +vec3f(-0.203878,-0.07715034,0.), +vec3f(0.5912697,0.1469799,0.), +vec3f(-0.88069,0.3031784,0.), +vec3f(0.5040108,0.8283722,0.), +vec3f(-0.5844124,0.5494877,0.), +vec3f(0.6017799,-0.1726654,0.), +vec3f(-0.5554981,0.1559997,0.), +vec3f(-0.3016369,-0.3900928,0.), +vec3f(-0.5550632,-0.1723762,0.), +vec3f(0.925029,0.2995041,0.), +vec3f(-0.2473137,0.5538505,0.), +vec3f(0.9183037,-0.2862392,0.), +vec3f(0.2469421,0.6718712,0.), +vec3f(0.3916397,-0.4328209,0.), +vec3f(-0.03576927,-0.6220032,0.), +vec3f(-0.04661255,0.7995201,0.), +vec3f(0.4402924,0.3640312,0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.), +vec3f(0.) +);const PoissonSamplers64: array=array ( +vec3f(-0.613392,0.617481,0.), +vec3f(0.170019,-0.040254,0.), +vec3f(-0.299417,0.791925,0.), +vec3f(0.645680,0.493210,0.), +vec3f(-0.651784,0.717887,0.), +vec3f(0.421003,0.027070,0.), +vec3f(-0.817194,-0.271096,0.), +vec3f(-0.705374,-0.668203,0.), +vec3f(0.977050,-0.108615,0.), +vec3f(0.063326,0.142369,0.), +vec3f(0.203528,0.214331,0.), +vec3f(-0.667531,0.326090,0.), +vec3f(-0.098422,-0.295755,0.), +vec3f(-0.885922,0.215369,0.), +vec3f(0.566637,0.605213,0.), +vec3f(0.039766,-0.396100,0.), +vec3f(0.751946,0.453352,0.), +vec3f(0.078707,-0.715323,0.), +vec3f(-0.075838,-0.529344,0.), +vec3f(0.724479,-0.580798,0.), +vec3f(0.222999,-0.215125,0.), +vec3f(-0.467574,-0.405438,0.), +vec3f(-0.248268,-0.814753,0.), +vec3f(0.354411,-0.887570,0.), +vec3f(0.175817,0.382366,0.), +vec3f(0.487472,-0.063082,0.), +vec3f(-0.084078,0.898312,0.), +vec3f(0.488876,-0.783441,0.), +vec3f(0.470016,0.217933,0.), +vec3f(-0.696890,-0.549791,0.), +vec3f(-0.149693,0.605762,0.), +vec3f(0.034211,0.979980,0.), +vec3f(0.503098,-0.308878,0.), +vec3f(-0.016205,-0.872921,0.), +vec3f(0.385784,-0.393902,0.), +vec3f(-0.146886,-0.859249,0.), +vec3f(0.643361,0.164098,0.), +vec3f(0.634388,-0.049471,0.), +vec3f(-0.688894,0.007843,0.), +vec3f(0.464034,-0.188818,0.), +vec3f(-0.440840,0.137486,0.), +vec3f(0.364483,0.511704,0.), +vec3f(0.034028,0.325968,0.), +vec3f(0.099094,-0.308023,0.), +vec3f(0.693960,-0.366253,0.), +vec3f(0.678884,-0.204688,0.), +vec3f(0.001801,0.780328,0.), +vec3f(0.145177,-0.898984,0.), +vec3f(0.062655,-0.611866,0.), +vec3f(0.315226,-0.604297,0.), +vec3f(-0.780145,0.486251,0.), +vec3f(-0.371868,0.882138,0.), +vec3f(0.200476,0.494430,0.), +vec3f(-0.494552,-0.711051,0.), +vec3f(0.612476,0.705252,0.), +vec3f(-0.578845,-0.768792,0.), +vec3f(-0.772454,-0.090976,0.), +vec3f(0.504440,0.372295,0.), +vec3f(0.155736,0.065157,0.), +vec3f(0.391522,0.849605,0.), +vec3f(-0.620106,-0.328104,0.), +vec3f(0.789239,-0.419965,0.), +vec3f(-0.545396,0.538133,0.), +vec3f(-0.178564,-0.596057,0.) +);fn computeShadowWithCSMPCSS(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,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uvDepthLayer: vec4f= vec4f(uvDepth.x,uvDepth.y,f32(layer),uvDepth.z);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;for (var i: i32=0; i,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array)->f32 +{var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} +var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;for (var i: i32=0; i,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32 +{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);} +fn computeShadowWithPCSS32(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32 +{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);} +fn computeShadowWithPCSS64(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32 +{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);} +fn computeShadowWithCSMPCSS16(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,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} +fn computeShadowWithCSMPCSS32(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,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} +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[tP]||(E.IncludesShadersStoreWGSL[tP]=Sz)});var iP,Tz,pl=C(()=>{w();iP="samplerFragmentDeclaration",Tz=`#ifdef _DEFINENAME_ +#if _DEFINENAME_DIRECTUV==1 +#define v_VARYINGNAME_UV vMainUV1 +#elif _DEFINENAME_DIRECTUV==2 +#define v_VARYINGNAME_UV vMainUV2 +#elif _DEFINENAME_DIRECTUV==3 +#define v_VARYINGNAME_UV vMainUV3 +#elif _DEFINENAME_DIRECTUV==4 +#define v_VARYINGNAME_UV vMainUV4 +#elif _DEFINENAME_DIRECTUV==5 +#define v_VARYINGNAME_UV vMainUV5 +#elif _DEFINENAME_DIRECTUV==6 +#define v_VARYINGNAME_UV vMainUV6 +#else +varying v_VARYINGNAME_UV: vec2f; +#endif +var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d; +#endif +`;E.IncludesShadersStoreWGSL[iP]||(E.IncludesShadersStoreWGSL[iP]=Tz)});var rP,Az,sP=C(()=>{w();rP="fresnelFunction",Az=`#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[rP]||(E.IncludesShadersStoreWGSL[rP]=Az)});var nP,Rz,Nh=C(()=>{w();nP="reflectionFunction",Rz=`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); } +fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f +{var cameraToVertex: vec3f=normalize(worldPos.xyz-eyePosition);var r: vec3f=normalize(reflect(cameraToVertex,worldNormal));r= (reflectionMatrix* vec4f(r,0)).xyz;var lon: f32=atan2(r.z,r.x);var lat: f32=acos(r.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 computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f +{var viewDir: vec3f=normalize((view*worldPos).xyz);var viewNormal: vec3f=normalize((view* vec4f(worldNormal,0.0)).xyz);var r: vec3f=reflect(viewDir,viewNormal);r= (reflectionMatrix* vec4f(r,0)).xyz;r.z=r.z-1.0;var m: f32=2.0*length(r);return vec3f(r.x/m+0.5,1.0-r.y/m-0.5,0);} +fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f +{var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;} +fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f +{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz; +#ifdef INVERTCUBICMAP +coords.y*=-1.0; +#endif +return coords;} +fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f +{var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=(reflectionMatrix* vec4f(coords,0)).xyz; +#ifdef INVERTCUBICMAP +coords.y*=-1.0; +#endif +return coords;} +fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f +{return (reflectionMatrix*(view*worldPos)).xyz;} +fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f +{return (reflectionMatrix* vec4f(positionW,1.)).xyz;} +#ifdef REFLECTION +fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f +{ +#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED +var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction); +#endif +#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED +var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction); +#endif +#ifdef REFLECTIONMAP_EQUIRECTANGULAR +return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_SPHERICAL +return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_PLANAR +return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_CUBIC +#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC +return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition); +#else +return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix); +#endif +#endif +#ifdef REFLECTIONMAP_PROJECTION +return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix); +#endif +#ifndef REFLECTIONMAP_CUBIC +#ifdef REFLECTIONMAP_SKYBOX +return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix); +#endif +#endif +#ifdef REFLECTIONMAP_EXPLICIT +return vec3f(0,0,0); +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[nP]||(E.IncludesShadersStoreWGSL[nP]=Rz)});var aP,xz,Um=C(()=>{w();aP="imageProcessingDeclaration",xz=`#ifdef EXPOSURE +uniform exposureLinear: f32; +#endif +#ifdef CONTRAST +uniform contrast: f32; +#endif +#if defined(VIGNETTE) || defined(DITHER) +uniform vInverseScreenSize: vec2f; +#endif +#ifdef VIGNETTE +uniform vignetteSettings1: vec4f;uniform vignetteSettings2: vec4f; +#endif +#ifdef COLORCURVES +uniform vCameraColorCurveNegative: vec4f;uniform vCameraColorCurveNeutral: vec4f;uniform vCameraColorCurvePositive: vec4f; +#endif +#ifdef COLORGRADING +#ifdef COLORGRADING3D +var txColorTransformSampler: sampler;var txColorTransform: texture_3d; +#else +var txColorTransformSampler: sampler;var txColorTransform: texture_2d; +#endif +uniform colorTransformSettings: vec4f; +#endif +#ifdef DITHER +uniform ditherIntensity: f32; +#endif +`;E.IncludesShadersStoreWGSL[aP]||(E.IncludesShadersStoreWGSL[aP]=xz)});var oP,Iz,Vm=C(()=>{w();oP="imageProcessingFunctions",Iz=`#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 (peakvec3f +{var a: vec3f=v*(v+0.0245786)-0.000090537;var b: vec3f=v*(0.983729*v+0.4329510)+0.238081;return a/b;} +fn ACESFitted(color: vec3f)->vec3f +{var output=ACESInputMat*color;output=RRTAndODTFit(output);output=ACESOutputMat*output;output=saturateVec3(output);return output;} +#endif +#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS +fn applyImageProcessing(result: vec4f)->vec4f { +#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART +var rgb=result.rgb;; +#ifdef EXPOSURE +rgb*=uniforms.exposureLinear; +#endif +#ifdef VIGNETTE +var viewportXY: vec2f=fragmentInputs.position.xy*uniforms.vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;var vignetteXY1: vec3f= vec3f(viewportXY*uniforms.vignetteSettings1.xy+uniforms.vignetteSettings1.zw,1.0);var vignetteTerm: f32=dot(vignetteXY1,vignetteXY1);var vignette: f32=pow(vignetteTerm,uniforms.vignetteSettings2.w);var vignetteColor: vec3f=uniforms.vignetteSettings2.rgb; +#ifdef VIGNETTEBLENDMODEMULTIPLY +var vignetteColorMultiplier: vec3f=mix(vignetteColor, vec3f(1,1,1),vignette);rgb*=vignetteColorMultiplier; +#endif +#ifdef VIGNETTEBLENDMODEOPAQUE +rgb=mix(vignetteColor,rgb,vignette); +#endif +#endif +#if TONEMAPPING==3 +rgb=PBRNeutralToneMapping(rgb); +#elif TONEMAPPING==2 +rgb=ACESFitted(rgb); +#elif TONEMAPPING==1 +const tonemappingCalibration: f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb); +#endif +rgb=toGammaSpaceVec3(rgb);rgb=saturateVec3(rgb); +#ifdef CONTRAST +var resultHighContrast: vec3f=rgb*rgb*(3.0-2.0*rgb);if (uniforms.contrast<1.0) {rgb=mix( vec3f(0.5,0.5,0.5),rgb,uniforms.contrast);} else {rgb=mix(rgb,resultHighContrast,uniforms.contrast-1.0);} +rgb=max(rgb,vec3f(0.)); +#endif +#ifdef COLORGRADING +var colorTransformInput: vec3f=rgb*uniforms.colorTransformSettings.xxx+uniforms.colorTransformSettings.yyy; +#ifdef COLORGRADING3D +var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput).rgb; +#else +var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput,uniforms.colorTransformSettings.yz).rgb; +#endif +rgb=mix(rgb,colorTransformOutput,uniforms.colorTransformSettings.www); +#endif +#ifdef COLORCURVES +var luma: f32=getLuminance(rgb);var curveMix: vec2f=clamp( vec2f(luma*3.0-1.5,luma*-3.0+1.5), vec2f(0.0), vec2f(1.0));var colorCurve: vec4f=uniforms.vCameraColorCurveNeutral+curveMix.x*uniforms.vCameraColorCurvePositive-curveMix.y*uniforms.vCameraColorCurveNegative;rgb*=colorCurve.rgb;rgb=mix( vec3f(luma),rgb,colorCurve.a); +#endif +#ifdef DITHER +var rand: f32=getRand(fragmentInputs.position.xy*uniforms.vInverseScreenSize);var dither: f32=mix(-uniforms.ditherIntensity,uniforms.ditherIntensity,rand);rgb=saturateVec3(rgb+ vec3f(dither)); +#endif +#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND +return vec4f(rgb,result.a);}`;E.IncludesShadersStoreWGSL[oP]||(E.IncludesShadersStoreWGSL[oP]=Iz)});var lP,Cz,Gm=C(()=>{w();lP="bumpFragmentMainFunctions",Cz=`#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 +#ifdef OBJECTSPACE_NORMALMAP +uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f +{var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0]; +var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0]; +var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4( +(a11*b11-a12*b10+a13*b09)/det, +(a02*b10-a01*b11-a03*b09)/det, +(a31*b05-a32*b04+a33*b03)/det, +(a22*b04-a21*b05-a23*b03)/det, +(a12*b08-a10*b11-a13*b07)/det, +(a00*b11-a02*b08+a03*b07)/det, +(a32*b02-a30*b05-a33*b01)/det, +(a20*b05-a22*b02+a23*b01)/det, +(a10*b10-a11*b08+a13*b06)/det, +(a01*b08-a00*b10-a03*b06)/det, +(a30*b04-a31*b02+a33*b00)/det, +(a21*b02-a20*b04-a23*b00)/det, +(a11*b07-a10*b09-a12*b06)/det, +(a00*b09-a01*b07+a02*b06)/det, +(a31*b01-a30*b03-a32*b00)/det, +(a20*b03-a21*b01+a22*b00)/det);return mat4x4(mi[0][0],mi[1][0],mi[2][0],mi[3][0], +mi[0][1],mi[1][1],mi[2][1],mi[3][1], +mi[0][2],mi[1][2],mi[2][2],mi[3][2], +mi[0][3],mi[1][3],mi[2][3],mi[3][3]);} +#endif +fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f +{var output=normal; +#ifdef NORMALXYSCALE +output=normalize(output* vec3f(scale,scale,1.0)); +#endif +return normalize(cotangentFrame*output);} +fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f +{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);} +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[lP]||(E.IncludesShadersStoreWGSL[lP]=Cz)});var cP,bz,km=C(()=>{w();pl();cP="bumpFragmentFunctions",bz=`#if defined(BUMP) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) +#endif +#if defined(DETAIL) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail) +#endif +#if defined(BUMP) && defined(PARALLAX) +const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; icurrRayHeight) +{var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;} +else +{currRayHeight-=stepSize;vLastOffset=vCurrOffset; +#ifdef PARALLAX_RHS +vCurrOffset-=stepSize*vMaxOffset; +#else +vCurrOffset+=stepSize*vMaxOffset; +#endif +lastSampledHeight=currSampledHeight;}} +return vCurrOffset;} +fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f +{var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height; +#ifdef PARALLAX_RHS +return texCoordOffset; +#else +return -texCoordOffset; +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[cP]||(E.IncludesShadersStoreWGSL[cP]=bz)});var fP,Mz,Wm=C(()=>{w();fP="bumpFragment",Mz=`var uvOffset: vec2f= vec2f(0.0,0.0); +#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) +#ifdef NORMALXYSCALE +var normalScale: f32=1.0; +#elif defined(BUMP) +var normalScale: f32=uniforms.vBumpInfos.y; +#else +var normalScale: f32=1.0; +#endif +#if defined(TANGENT) && defined(NORMAL) +var TBN: mat3x3f=mat3x3(input.vTBN0,input.vTBN1,input.vTBN2); +#elif defined(BUMP) +var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams); +#else +var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.)); +#endif +#elif defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +var TBN: mat3x3f=mat3x3(input.vTBN0,input.vTBN1,input.vTBN2); +#else +var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.)); +#endif +#endif +#ifdef PARALLAX +var invTBN: mat3x3f=transposeMat3(TBN); +#ifdef PARALLAXOCCLUSION +uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z); +#else +uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z); +#endif +#endif +#ifdef DETAIL +var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB); +#endif +#ifdef BUMP +#ifdef OBJECTSPACE_NORMALMAP +#define CUSTOM_FRAGMENT_BUMP_FRAGMENT +normalW=normalize(textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW); +#elif !defined(DETAIL) +normalW=perturbNormal(TBN,textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y); +#else +var bumpNormal: vec3f=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0; +#if DETAIL_NORMALBLENDMETHOD==0 +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z)); +#elif DETAIL_NORMALBLENDMETHOD==1 +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal; +#endif +normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y); +#endif +#elif defined(DETAIL) +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z); +#endif +`;E.IncludesShadersStoreWGSL[fP]||(E.IncludesShadersStoreWGSL[fP]=Mz)});var hP,yz,pS=C(()=>{w();hP="decalFragment",yz=`#ifdef DECAL +var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a; +#ifdef GAMMADECAL +decalTempColor=toLinearSpaceVec3(decalColor.rgb); +#endif +#ifdef DECAL_SMOOTHALPHA +decalTempAlpha=decalColor.a*decalColor.a; +#endif +surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha); +#endif +`;E.IncludesShadersStoreWGSL[hP]||(E.IncludesShadersStoreWGSL[hP]=yz)});var dP,Dz,Hm=C(()=>{w();dP="depthPrePass",Dz=`#ifdef DEPTHPREPASS +#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY) +fragmentOutputs.color= vec4f(0.,0.,0.,1.0); +#endif +return fragmentOutputs; +#endif +`;E.IncludesShadersStoreWGSL[dP]||(E.IncludesShadersStoreWGSL[dP]=Dz)});var uP,Pz,_S=C(()=>{w();uP="lightFragment",Pz=`#ifdef LIGHT{X} +#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) +#else +var diffuse{X}: vec4f=light{X}.vLightDiffuse; +#define CUSTOM_LIGHT{X}_COLOR +#if defined(PBR) && defined(CLUSTLIGHT{X}) +{let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting( +lightDataTexture{X}, +&tileMaskBuffer{X}, +light{X}.vLightData, +vec2u(light{X}.vSliceRanges[sliceIndex].xy), +viewDirectionW, +normalW, +fragmentInputs.vPositionW, +surfaceAlbedo, +reflectivityOut, +#ifdef IRIDESCENCE +iridescenceIntensity, +#endif +#ifdef SS_TRANSLUCENCY +subSurfaceOut, +#endif +#ifdef SPECULARTERM +AARoughnessFactors.x, +#endif +#ifdef ANISOTROPIC +anisotropicOut, +#endif +#ifdef SHEEN +sheenOut, +#endif +#ifdef CLEARCOAT +clearcoatOut, +#endif +);} +#elif defined(PBR) +#ifdef SPOTLIGHT{X} +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW); +#elif defined(POINTLIGHT{X}) +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW); +#elif defined(HEMILIGHT{X}) +preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(DIRLIGHT{X}) +preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#if defined(RECTAREALIGHTEMISSIONTEXTURE{X}) +preInfo=computeAreaPreLightingInfoWithTexture(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,rectAreaLightEmissionTexture{X},rectAreaLightEmissionTexture{X}Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness); +#else +preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness); +#endif +#endif +preInfo.NdotV=NdotV; +#ifdef SPOTLIGHT{X} +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w); +#endif +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w); +#endif +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X},iesLightTexture{X}Sampler); +#else +preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#endif +#elif defined(POINTLIGHT{X}) +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#endif +#else +preInfo.attenuation=1.0; +#endif +#if defined(HEMILIGHT{X}) +preInfo.roughness=roughness; +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo.roughness=roughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo; +#ifdef IRIDESCENCE +preInfo.iridescenceIntensity=iridescenceIntensity; +#endif +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission=vec3f(0.0); +#endif +#ifdef HEMILIGHT{X} +info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb); +#elif defined(SS_TRANSLUCENCY) +#ifndef SS_TRANSLUCENCY_LEGACY +info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); +#else +info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); +#endif +#else +info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb); +#endif +#ifdef SPECULARTERM +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#else +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +{let metalFresnel: vec3f=vec3f(reflectivityOut.specularWeight)*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricFresnel: vec3f=fresnelSchlickGGXVec3(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);} +#else +coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#endif +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +{let NdotH: f32=dot(normalW,preInfo.H);let fresnel: vec3f=fresnelSchlickGGXVec3(NdotH,vec3f(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3f(1.0)-fresnel);} +#endif +#ifdef ANISOTROPIC +info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); +#else +info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb); +#endif +#endif +#endif +#ifndef AREALIGHT{X} +#ifdef SHEEN +#ifdef SHEEN_LINKWITHALBEDO +preInfo.roughness=sheenOut.sheenIntensity; +#else +#ifdef HEMILIGHT{X} +preInfo.roughness=sheenOut.sheenRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +#endif +info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); +#endif +#ifdef CLEARCOAT +#ifdef HEMILIGHT{X} +preInfo.roughness=clearcoatOut.clearCoatRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb); +#ifdef CLEARCOAT_TINT +absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=absorption; +#endif +#ifdef SPECULARTERM +info.specular*=absorption; +#endif +#endif +info.diffuse*=info.clearCoat.w; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=info.clearCoat.w; +#endif +#ifdef SPECULARTERM +info.specular*=info.clearCoat.w; +#endif +#ifdef SHEEN +info.sheen*=info.clearCoat.w; +#endif +#endif +#endif +#else +#ifdef SPOTLIGHT{X} +#ifdef IESLIGHTTEXTURE{X} +info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X},iesLightTexture{X}Sampler); +#else +info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); +#endif +#elif defined(HEMILIGHT{X}) +info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness); +#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X}) +info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); +#elif define(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED) +#if defined(RECTAREALIGHTEMISSIONTEXTURE{X}) +info=computeAreaLightingWithTexture(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,rectAreaLightEmissionTexture{X},rectAreaLightEmissionTexture{X}Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,diffuse{X}.rgb,light{X}.vLightSpecular.rgb, +#ifdef AREALIGHTNOROUGHTNESS +0.5 +#else +uniforms.vReflectionInfos.y +#endif +); +#else +info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC1SamplerSampler,areaLightsLTC2Sampler,areaLightsLTC2SamplerSampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,diffuse{X}.rgb,light{X}.vLightSpecular.rgb, +#ifdef AREALIGHTNOROUGHTNESS +0.5 +#else +uniforms.vReflectionInfos.y +#endif +); +#endif +#elif defined(CLUSTLIGHT{X}) +{let sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,fragmentInputs.vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},&tileMaskBuffer{X},viewDirectionW,normalW,light{X}.vLightData,vec2u(light{X}.vSliceRanges[sliceIndex].xy),glossiness);} +#endif +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,uniforms.textureProjectionMatrix{X},fragmentInputs.vPositionW); +#endif +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSMDEBUG{X} +var shadowDebug{X}: vec3f; +#endif +#ifdef SHADOWCSM{X} +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +var index{X}: i32=-1; +#else +var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1; +#endif +var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i=0.) {index{X}=i;break;}} +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +if (index{X}>=0) +#endif +{ +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#else +shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#endif +#else +shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}]; +#endif +#ifndef SHADOWCSMNOBLEND{X} +var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.) +{index{X}+=1;var nextShadow: f32=0.; +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#else +nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X}); +#endif +#else +nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +shadow=mix(nextShadow,shadow,diffRatio); +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio); +#endif +} +#endif +} +#elif defined(SHADOWCLOSEESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithCloseESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithESMCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPOISSON{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithPoissonSamplingCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#else +#if defined(SHADOWCUBE{X}) +shadow=computeShadowCube(fragmentInputs.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#endif +#ifdef SHADOWONLY +#ifndef SHADOWINUSE +#define SHADOWINUSE +#endif +globalShadow+=shadow;shadowLightCount+=1.0; +#endif +#else +shadow=1.; +#endif +aggShadow+=shadow;numLights+=1.0; +#ifndef SHADOWONLY +#ifdef CUSTOMUSERLIGHTING +diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); +#ifdef SPECULARTERM +specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); +#endif +#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) +diffuseBase+=lightmapColor.rgb*shadow; +#ifdef SPECULARTERM +#ifndef LIGHTMAPNOSPECULAR{X} +specularBase+=info.specular*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef CLEARCOAT +#ifndef LIGHTMAPNOSPECULAR{X} +clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef SHEEN +#ifndef LIGHTMAPNOSPECULAR{X} +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#else +#ifdef SHADOWCSMDEBUG{X} +diffuseBase+=info.diffuse*shadowDebug{X}; +#else +diffuseBase+=info.diffuse*shadow; +#endif +#ifdef SS_TRANSLUCENCY +diffuseTransmissionBase+=info.diffuseTransmission*shadow; +#endif +#ifdef SPECULARTERM +specularBase+=info.specular*shadow; +#endif +#ifdef CLEARCOAT +clearCoatBase+=info.clearCoat.rgb*shadow; +#endif +#ifdef SHEEN +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[uP]||(E.IncludesShadersStoreWGSL[uP]=Pz)});var mP,Lz,Fh=C(()=>{w();mP="logDepthFragment",Lz=`#ifdef LOGARITHMICDEPTH +fragmentOutputs.fragDepth=log2(fragmentInputs.vFragmentDepth)*uniforms.logarithmicDepthConstant*0.5; +#endif +`;E.IncludesShadersStoreWGSL[mP]||(E.IncludesShadersStoreWGSL[mP]=Lz)});var pP,Oz,zm=C(()=>{w();pP="oitFragment",Oz=`#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; +#endif +var fragCoord: vec2i=vec2i(fragmentInputs.position.xy);var lastDepth: vec2f=textureLoad(oitDepthSampler,fragCoord,0).rg;var lastFrontColor: vec4f=textureLoad(oitFrontColorSampler,fragCoord,0);fragmentOutputs.depth=vec2f(-MAX_DEPTH);fragmentOutputs.frontColor=lastFrontColor;fragmentOutputs.backColor= vec4f(0.0); +#ifdef USE_REVERSE_DEPTHBUFFER +var furthestDepth: f32=-lastDepth.x;var nearestDepth: f32=lastDepth.y; +#else +var nearestDepth: f32=-lastDepth.x;var furthestDepth: f32=lastDepth.y; +#endif +var alphaMultiplier: f32=1.0-lastFrontColor.a; +#ifdef USE_REVERSE_DEPTHBUFFER +if (fragDepth>nearestDepth || fragDepthfurthestDepth) { +#endif +return fragmentOutputs;} +#ifdef USE_REVERSE_DEPTHBUFFER +if (fragDepthfurthestDepth) { +#else +if (fragDepth>nearestDepth && fragDepthNz});var gS,_P,Nz,EP=C(()=>{w();fS();Nm();Fm();af();Lr();wm();eP();Bm();pl();sP();Nh();Um();Vm();Gm();km();pn();_a();Yc();_n();Wm();pS();Hm();_S();Fh();Kc();zm();gS="defaultPixelShader",_P=`#include +#include[SCENE_MRT_COUNT] +#include +#define CUSTOM_FRAGMENT_BEGIN +varying vPositionW: vec3f; +#ifdef NORMAL +varying vNormalW: vec3f; +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying vViewDepth: f32; +#endif +#include[1..7] +#include +#include[0..maxSimultaneousLights] +#include +#include +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#ifdef REFRACTION +#ifdef REFRACTIONMAP_3D +var refractionCubeSamplerSampler: sampler;var refractionCubeSampler: texture_cube; +#else +var refraction2DSamplerSampler: sampler;var refraction2DSampler: texture_2d; +#endif +#endif +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular) +#endif +#include +#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +var reflectionCubeSamplerSampler: sampler;var reflectionCubeSampler: texture_cube; +#else +var reflection2DSamplerSampler: sampler;var reflection2DSampler: texture_2d; +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vPositionUVW: vec3f; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vDirectionW: vec3f; +#endif +#endif +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-fragmentInputs.vPositionW);var baseColor: vec4f= vec4f(1.,1.,1.,1.);var diffuseColor: vec3f=uniforms.vDiffuseColor.rgb;var alpha: f32=uniforms.vDiffuseColor.a; +#ifdef NORMAL +var normalW: vec3f=normalize(fragmentInputs.vNormalW); +#else +var normalW: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))* scene.vEyePosition.w; +#endif +#include +#ifdef TWOSIDEDLIGHTING +normalW=select(-normalW,normalW,fragmentInputs.frontFacing); +#endif +#ifdef DIFFUSE +baseColor=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vDiffuseUV+uvOffset); +#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS) +if (baseColor.a(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) +#endif +#include +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +baseColor=vec4f(baseColor.rgb*fragmentInputs.vColor.rgb,baseColor.a); +#endif +#ifdef DETAIL +baseColor=vec4f(baseColor.rgb*2.0*mix(0.5,detailColor.r,uniforms.vDetailInfos.y),baseColor.a); +#endif +#if defined(DECAL) && defined(DECAL_AFTER_DETAIL) +var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset); +#include(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) +#endif +#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE +var baseAmbientColor: vec3f= vec3f(1.,1.,1.); +#ifdef AMBIENT +baseAmbientColor=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb*uniforms.vAmbientInfos.y; +#endif +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +var glossiness: f32=uniforms.vSpecularColor.a;var specularColor: vec3f=uniforms.vSpecularColor.rgb; +#ifdef SPECULARTERM +#ifdef SPECULAR +var specularMapColor: vec4f=textureSample(specularSampler,specularSamplerSampler,fragmentInputs.vSpecularUV+uvOffset);specularColor=specularMapColor.rgb; +#ifdef GLOSSINESS +glossiness=glossiness*specularMapColor.a; +#endif +#endif +#endif +var diffuseBase: vec3f= vec3f(0.,0.,0.);var info: lightingInfo; +#ifdef SPECULARTERM +var specularBase: vec3f= vec3f(0.,0.,0.); +#endif +var shadow: f32=1.;var aggShadow: f32=0.;var numLights: f32=0.; +#ifdef LIGHTMAP +var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a); +#endif +lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a); +#endif +#include[0..maxSimultaneousLights] +aggShadow=aggShadow/numLights;var refractionColor: vec4f= vec4f(0.,0.,0.,1.); +#ifdef REFRACTION +var refractionVector: vec3f=normalize(refract(-viewDirectionW,normalW,uniforms.vRefractionInfos.y)); +#ifdef REFRACTIONMAP_3D +#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC +refractionVector=parallaxCorrectNormal(fragmentInputs.vPositionW,refractionVector,uniforms.vRefractionSize,uniforms.vRefractionPosition); +#endif +refractionVector.y=refractionVector.y*uniforms.vRefractionInfos.w;var refractionLookup: vec4f=textureSample(refractionCubeSampler,refractionCubeSamplerSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;} +#else +var vRefractionUVW: vec3f= (uniforms.refractionMatrix*(scene.view* vec4f(fragmentInputs.vPositionW+refractionVector*uniforms.vRefractionInfos.z,1.0))).xyz;var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=textureSample(refraction2DSampler,refraction2DSamplerSampler,refractionCoords); +#endif +#ifdef RGBDREFRACTION +refractionColor=vec4f(fromRGBD(refractionColor),refractionColor.a); +#endif +#ifdef IS_REFRACTION_LINEAR +refractionColor=vec4f(toGammaSpaceVec3(refractionColor.rgb),refractionColor.a); +#endif +refractionColor=vec4f(refractionColor.rgb*uniforms.vRefractionInfos.x,refractionColor.a); +#endif +var reflectionColor: vec4f= vec4f(0.,0.,0.,1.); +#ifdef REFLECTION +var vReflectionUVW: vec3f=computeReflectionCoords( vec4f(fragmentInputs.vPositionW,1.0),normalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +vReflectionUVW=vec3f(vReflectionUVW.x,vReflectionUVW.y,vReflectionUVW.z*-1.0); +#endif +#ifdef REFLECTIONMAP_3D +#ifdef ROUGHNESS +var bias: f32=uniforms.vReflectionInfos.y; +#ifdef SPECULARTERM +#ifdef SPECULAR +#ifdef GLOSSINESS +bias*=(1.0-specularMapColor.a); +#endif +#endif +#endif +reflectionColor=textureSampleLevel(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW,bias); +#else +reflectionColor=textureSample(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW); +#endif +#else +var coords: vec2f=vReflectionUVW.xy; +#ifdef REFLECTIONMAP_PROJECTION +coords/=vReflectionUVW.z; +#endif +coords.y=1.0-coords.y;reflectionColor=textureSample(reflection2DSampler,reflection2DSamplerSampler,coords); +#endif +#ifdef RGBDREFLECTION +reflectionColor=vec4f(fromRGBD(reflectionColor),reflectionColor.a); +#endif +#ifdef IS_REFLECTION_LINEAR +reflectionColor=vec4f(toGammaSpaceVec3(reflectionColor.rgb),reflectionColor.a); +#endif +reflectionColor=vec4f(reflectionColor.rgb*uniforms.vReflectionInfos.x,reflectionColor.a); +#ifdef REFLECTIONFRESNEL +var reflectionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.reflectionRightColor.a,uniforms.reflectionLeftColor.a); +#ifdef REFLECTIONFRESNELFROMSPECULAR +#ifdef SPECULARTERM +reflectionColor=vec4f(reflectionColor.rgb*specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a); +#else +reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a); +#endif +#else +reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a); +#endif +#endif +#endif +#ifdef REFRACTIONFRESNEL +var refractionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.refractionRightColor.a,uniforms.refractionLeftColor.a);refractionColor=vec4f(refractionColor.rgb*uniforms.refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*uniforms.refractionRightColor.rgb,refractionColor.a); +#endif +#ifdef OPACITY +var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset); +#ifdef OPACITYRGB +opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* uniforms.vOpacityInfos.y; +#else +alpha*=opacityMap.a*uniforms.vOpacityInfos.y; +#endif +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=fragmentInputs.vColor.a; +#endif +#ifdef OPACITYFRESNEL +var opacityFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.opacityParts.z,uniforms.opacityParts.w);alpha+=uniforms.opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*uniforms.opacityParts.y; +#endif +#ifdef ALPHATEST +#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS +if (alpha +#include +#ifdef IMAGEPROCESSINGPOSTPROCESS +color=vec4f(toLinearSpaceVec3(color.rgb),color.a); +#else +#ifdef IMAGEPROCESSING +color=vec4f(toLinearSpaceVec3(color.rgb),color.a);color=applyImageProcessing(color); +#endif +#endif +color=vec4f(color.rgb,color.a*mesh.visibility); +#ifdef PREMULTIPLYALPHA +color=vec4f(color.rgb*color.a, color.a); +#endif +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#if SCENE_MRT_COUNT>0 +var writeGeometryInfo: f32=select(0.0,1.0,color.a>0.4);var fragData: array,SCENE_MRT_COUNT>; +#ifdef PREPASS_COLOR +fragData[PREPASS_COLOR_INDEX]=color; +#endif +#ifdef PREPASS_POSITION +fragData[PREPASS_POSITION_INDEX]=vec4f(fragmentInputs.vPositionW,writeGeometryInfo); +#endif +#ifdef PREPASS_LOCAL_POSITION +fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo); +#endif +#ifdef PREPASS_VELOCITY +var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) - +(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_IRRADIANCE +fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(0.0,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_DEPTH +fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo); +#else +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +fragData[PREPASS_ALBEDO_INDEX]=vec4f(baseColor.rgb,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqrt(baseColor.rgb),writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#if defined(SPECULAR) +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec4(specularMapColor))*writeGeometryInfo; +#else +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec3(specularColor),1.0)*writeGeometryInfo; +#endif +#endif +#if SCENE_MRT_COUNT>0 +fragmentOutputs.fragData0=fragData[0]; +#endif +#if SCENE_MRT_COUNT>1 +fragmentOutputs.fragData1=fragData[1]; +#endif +#if SCENE_MRT_COUNT>2 +fragmentOutputs.fragData2=fragData[2]; +#endif +#if SCENE_MRT_COUNT>3 +fragmentOutputs.fragData3=fragData[3]; +#endif +#if SCENE_MRT_COUNT>4 +fragmentOutputs.fragData4=fragData[4]; +#endif +#if SCENE_MRT_COUNT>5 +fragmentOutputs.fragData5=fragData[5]; +#endif +#if SCENE_MRT_COUNT>6 +fragmentOutputs.fragData6=fragData[6]; +#endif +#if SCENE_MRT_COUNT>7 +fragmentOutputs.fragData7=fragData[7]; +#endif +#endif +#endif +#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY) +fragmentOutputs.color=color; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+color.rgb*color.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-color.a));} else {fragmentOutputs.backColor+=color;} +#endif +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStoreWGSL[gS]||(E.ShadersStoreWGSL[gS]=_P);Nz={name:gS,shader:_P}});var vP,Fz,Xm=C(()=>{w();vP="decalVertexDeclaration",Fz=`#ifdef DECAL +uniform vec4 vDecalInfos;uniform mat4 decalMatrix; +#endif +`;E.IncludesShadersStore[vP]||(E.IncludesShadersStore[vP]=Fz)});var SP,wz,TP=C(()=>{w();Xm();SP="defaultVertexDeclaration",wz=`uniform mat4 viewProjection; +#ifdef MULTIVIEW +mat4 viewProjectionR; +#endif +uniform mat4 view; +#ifdef DIFFUSE +uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos; +#endif +#ifdef AMBIENT +uniform mat4 ambientMatrix;uniform vec2 vAmbientInfos; +#endif +#ifdef OPACITY +uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix; +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) +uniform vec2 vSpecularInfos;uniform mat4 specularMatrix; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos;uniform mat4 bumpMatrix; +#endif +#ifdef REFLECTION +uniform mat4 reflectionMatrix; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos;uniform mat4 detailMatrix; +#endif +uniform vec4 cameraInfo; +#include +#define ADDITIONAL_VERTEX_DECLARATION +`;E.IncludesShadersStore[SP]||(E.IncludesShadersStore[SP]=wz)});var AP,Bz,Io=C(()=>{w();AP="sceneUboDeclaration",Bz=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection; +#ifdef MULTIVIEW +mat4 viewProjectionR; +#endif +mat4 view;mat4 projection;vec4 vEyePosition;mat4 inverseProjection;}; +`;E.IncludesShadersStore[AP]||(E.IncludesShadersStore[AP]=Bz)});var RP,Uz,of=C(()=>{w();RP="meshUboDeclaration",Uz=`#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[RP]||(E.IncludesShadersStore[RP]=Uz)});var xP,Vz,ES=C(()=>{w();Io();of();xP="defaultUboDeclaration",Vz=`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[xP]||(E.IncludesShadersStore[xP]=Vz)});var IP,Gz,Ym=C(()=>{w();IP="uvAttributeDeclaration",Gz=`#ifdef UV{X} +attribute vec2 uv{X}; +#endif +`;E.IncludesShadersStore[IP]||(E.IncludesShadersStore[IP]=Gz)});var CP,kz,Km=C(()=>{w();CP="prePassVertexDeclaration",kz=`#ifdef PREPASS +#ifdef PREPASS_LOCAL_POSITION +varying vec3 vPosition; +#endif +#ifdef PREPASS_DEPTH +varying vec3 vViewPos; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +varying float vNormViewDepth; +#endif +#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) +uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition; +#endif +#endif +`;E.IncludesShadersStore[CP]||(E.IncludesShadersStore[CP]=kz)});var bP,Wz,lf=C(()=>{w();bP="mainUVVaryingDeclaration",Wz=`#ifdef MAINUV{X} +varying vec2 vMainUV{X}; +#endif +`;E.IncludesShadersStore[bP]||(E.IncludesShadersStore[bP]=Wz)});var MP,Hz,jm=C(()=>{w();MP="samplerVertexDeclaration",Hz=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +varying vec2 v_VARYINGNAME_UV; +#endif +`;E.IncludesShadersStore[MP]||(E.IncludesShadersStore[MP]=Hz)});var yP,zz,vS=C(()=>{w();yP="bumpVertexDeclaration",zz=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +varying mat3 vTBN; +#endif +#endif +`;E.IncludesShadersStore[yP]||(E.IncludesShadersStore[yP]=zz)});var DP,Xz,Zm=C(()=>{w();DP="lightVxFragmentDeclaration",Xz=`#ifdef LIGHT{X} +uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; +#ifdef SPECULARTERM +uniform vec4 vLightSpecular{X}; +#else +vec4 vLightSpecular{X}=vec4(0.); +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; +#elif defined(SHADOWCUBE{X}) +#else +varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X}; +#endif +uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X}; +#endif +#ifdef SPOTLIGHT{X} +uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X}; +#elif defined(POINTLIGHT{X}) +uniform vec4 vLightFalloff{X}; +#elif defined(HEMILIGHT{X}) +uniform vec3 vLightGround{X}; +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X}; +#endif +#endif +`;E.IncludesShadersStore[DP]||(E.IncludesShadersStore[DP]=Xz)});var PP,Yz,qm=C(()=>{w();PP="lightVxUboDeclaration",Yz=`#ifdef LIGHT{X} +uniform Light{X} +{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; +#ifdef SPOTLIGHT{X} +vec4 vLightDirection;vec4 vLightFalloff; +#elif defined(POINTLIGHT{X}) +vec4 vLightFalloff; +#elif defined(HEMILIGHT{X}) +vec3 vLightGround; +#elif defined(CLUSTLIGHT{X}) +vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES]; +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vec4 vLightWidth;vec4 vLightHeight; +#endif +vec4 shadowsInfo;vec2 depthValues;} light{X}; +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; +#elif defined(SHADOWCUBE{X}) +#else +varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X}; +#endif +#endif +#endif +`;E.IncludesShadersStore[PP]||(E.IncludesShadersStore[PP]=Yz)});var LP,Kz,Co=C(()=>{w();LP="morphTargetsVertexGlobalDeclaration",Kz=`#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) +{ +#if defined(WEBGL2) || defined(WEBGPU) +int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0).xyz; +#else +float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz; +#endif +} +vec4 readVector4FromRawSampler(int targetIndex,float vertexIndex) +{ +#if defined(WEBGL2) || defined(WEBGPU) +int textureWidth=int(morphTargetTextureInfo.y);int y=int(vertexIndex)/textureWidth;int x=int(vertexIndex) % textureWidth;return texelFetch(morphTargets,ivec3(x,y,int(morphTargetTextureIndices[targetIndex])),0); +#else +float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV); +#endif +} +#endif +#endif +`;E.IncludesShadersStore[LP]||(E.IncludesShadersStore[LP]=Kz)});var OP,jz,bo=C(()=>{w();OP="morphTargetsVertexDeclaration",jz=`#ifdef MORPHTARGETS +#ifndef MORPHTARGETS_TEXTURE +#ifdef MORPHTARGETS_POSITION +attribute vec3 position{X}; +#endif +#ifdef MORPHTARGETS_NORMAL +attribute vec3 normal{X}; +#endif +#ifdef MORPHTARGETS_TANGENT +attribute vec3 tangent{X}; +#endif +#ifdef MORPHTARGETS_UV +attribute vec2 uv_{X}; +#endif +#ifdef MORPHTARGETS_UV2 +attribute vec2 uv2_{X}; +#endif +#ifdef MORPHTARGETS_COLOR +attribute vec4 color{X}; +#endif +#elif {X}==0 +uniform float morphTargetCount; +#endif +#endif +`;E.IncludesShadersStore[OP]||(E.IncludesShadersStore[OP]=jz)});var NP,Zz,ga=C(()=>{w();NP="logDepthDeclaration",Zz=`#ifdef LOGARITHMICDEPTH +uniform float logarithmicDepthConstant;varying float vFragmentDepth; +#endif +`;E.IncludesShadersStore[NP]||(E.IncludesShadersStore[NP]=Zz)});var FP,qz,Mo=C(()=>{w();FP="morphTargetsVertexGlobal",qz=`#ifdef MORPHTARGETS +#ifdef MORPHTARGETS_TEXTURE +float vertexID; +#endif +#endif +`;E.IncludesShadersStore[FP]||(E.IncludesShadersStore[FP]=qz)});var wP,Qz,yo=C(()=>{w();wP="morphTargetsVertex",Qz=`#ifdef MORPHTARGETS +#ifdef MORPHTARGETS_TEXTURE +#if {X}==0 +for (int i=0; i=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x; +#ifdef MORPHTARGETS_POSITION +positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i]; +#endif +#ifdef MORPHTARGETTEXTURE_HASPOSITIONS +vertexID+=1.0; +#endif +#ifdef MORPHTARGETS_NORMAL +normalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i]; +#endif +#ifdef MORPHTARGETTEXTURE_HASNORMALS +vertexID+=1.0; +#endif +#ifdef MORPHTARGETS_UV +uvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i]; +#endif +#ifdef MORPHTARGETTEXTURE_HASUVS +vertexID+=1.0; +#endif +#ifdef MORPHTARGETS_TANGENT +tangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i]; +#endif +#ifdef MORPHTARGETTEXTURE_HASTANGENTS +vertexID+=1.0; +#endif +#ifdef MORPHTARGETS_UV2 +uv2Updated+=(readVector3FromRawSampler(i,vertexID).xy-uv2)*morphTargetInfluences[i]; +#endif +#ifdef MORPHTARGETTEXTURE_HASUV2S +vertexID+=1.0; +#endif +#ifdef MORPHTARGETS_COLOR +colorUpdated+=(readVector4FromRawSampler(i,vertexID)-color)*morphTargetInfluences[i]; +#endif +} +#endif +#else +#ifdef MORPHTARGETS_POSITION +positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}]; +#endif +#ifdef MORPHTARGETS_NORMAL +normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}]; +#endif +#ifdef MORPHTARGETS_TANGENT +tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}]; +#endif +#ifdef MORPHTARGETS_UV +uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}]; +#endif +#ifdef MORPHTARGETS_UV2 +uv2Updated+=(uv2_{X}-uv2)*morphTargetInfluences[{X}]; +#endif +#ifdef MORPHTARGETS_COLOR +colorUpdated+=(color{X}-color)*morphTargetInfluences[{X}]; +#endif +#endif +#endif +`;E.IncludesShadersStore[wP]||(E.IncludesShadersStore[wP]=Qz)});var BP,Jz,Qm=C(()=>{w();BP="prePassVertex",Jz=`#ifdef PREPASS_DEPTH +vViewPos=(view*worldPos).rgb; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +vNormViewDepth=((view*worldPos).z-cameraInfo.x)/(cameraInfo.y-cameraInfo.x); +#endif +#ifdef PREPASS_LOCAL_POSITION +vPosition=positionUpdated.xyz; +#endif +#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*worldPos; +#if NUM_BONE_INFLUENCERS>0 +mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0); +#else +vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#endif +`;E.IncludesShadersStore[BP]||(E.IncludesShadersStore[BP]=Jz)});var UP,$z,Jm=C(()=>{w();UP="uvVariableDeclaration",$z=`#if !defined(UV{X}) && defined(MAINUV{X}) +vec2 uv{X}=vec2(0.,0.); +#endif +#ifdef MAINUV{X} +vMainUV{X}=uv{X}; +#endif +`;E.IncludesShadersStore[UP]||(E.IncludesShadersStore[UP]=$z)});var VP,eX,$m=C(()=>{w();VP="samplerVertexImplementation",eX=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 +if (v_INFONAME_==0.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));} +#ifdef UV2 +else if (v_INFONAME_==1.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2Updated,1.0,0.0));} +#endif +#ifdef UV3 +else if (v_INFONAME_==2.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));} +#endif +#ifdef UV4 +else if (v_INFONAME_==3.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));} +#endif +#ifdef UV5 +else if (v_INFONAME_==4.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));} +#endif +#ifdef UV6 +else if (v_INFONAME_==5.) +{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));} +#endif +#endif +`;E.IncludesShadersStore[VP]||(E.IncludesShadersStore[VP]=eX)});var GP,tX,ep=C(()=>{w();GP="bumpVertex",tX=`#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[GP]||(E.IncludesShadersStore[GP]=tX)});var kP,iX,tp=C(()=>{w();kP="shadowsVertex",iX=`#ifdef SHADOWS +#if defined(SHADOWCSM{X}) +vPositionFromCamera{X}=view*worldPos;for (int i=0; i{w();WP="pointCloudVertex",rX=`#if defined(POINTSIZE) && !defined(WEBGPU) +gl_PointSize=pointSize; +#endif +`;E.IncludesShadersStore[WP]||(E.IncludesShadersStore[WP]=rX)});var HP,sX,wh=C(()=>{w();HP="logDepthVertex",sX=`#ifdef LOGARITHMICDEPTH +vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant; +#endif +`;E.IncludesShadersStore[HP]||(E.IncludesShadersStore[HP]=sX)});var XP={};Ie(XP,{defaultVertexShader:()=>nX});var TS,zP,nX,YP=C(()=>{w();TP();ES();Ym();Or();fa();ha();Eo();Km();lf();jm();vS();gn();jc();Zm();qm();Co();bo();ga();Mo();yo();da();ua();ma();Qm();Jm();$m();ep();En();Zc();tp();bh();SS();wh();TS="defaultVertexShader",zP=`#define CUSTOM_VERTEX_EXTENSION +#include<__decl__defaultVertex> +#define CUSTOM_VERTEX_BEGIN +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#ifdef TANGENT +attribute vec4 tangent; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#include[2..7] +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include +#include +#include +#include +#include[1..7] +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular) +#endif +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +varying vec3 vPositionW; +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#include +#include +#include +#include<__decl__lightVxFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying float vViewDepth; +#endif +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +vec3 positionUpdated=position; +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#ifdef TANGENT +vec4 tangentUpdated=tangent; +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#ifdef VERTEXCOLOR +vec4 colorUpdated=color; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normalUpdated); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} +#else +gl_Position=viewProjection*worldPos; +#endif +vPositionW=vec3(worldPos); +#ifdef PREPASS +#include +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#ifdef RIGHT_HANDED +vViewDepth=-(view*worldPos).z; +#else +vViewDepth=(view*worldPos).z; +#endif +#endif +#ifndef UV1 +vec2 uvUpdated=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2Updated=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uvUpdated; +#endif +#ifdef MAINUV2 +vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x) +#endif +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStore[TS]||(E.ShadersStore[TS]=zP);nX={name:TS,shader:zP}});var KP,aX,ip=C(()=>{w();KP="decalFragmentDeclaration",aX=`#ifdef DECAL +uniform vec4 vDecalInfos; +#endif +`;E.IncludesShadersStore[KP]||(E.IncludesShadersStore[KP]=aX)});var jP,oX,ZP=C(()=>{w();ip();jP="defaultFragmentDeclaration",oX=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility; +#ifdef DIFFUSE +uniform vec2 vDiffuseInfos; +#endif +#ifdef AMBIENT +uniform vec2 vAmbientInfos; +#endif +#ifdef OPACITY +uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams; +#endif +#ifdef ALPHATEST +uniform float alphaCutOff; +#endif +#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS) +uniform mat4 view; +#endif +#ifdef REFRACTION +uniform vec4 vRefractionInfos; +#ifndef REFRACTIONMAP_3D +uniform mat4 refractionMatrix; +#endif +#ifdef REFRACTIONFRESNEL +uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor; +#endif +#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D) +uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; +#endif +#endif +#if defined(SPECULAR) && defined(SPECULARTERM) +uniform vec2 vSpecularInfos; +#endif +#ifdef DIFFUSEFRESNEL +uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor; +#endif +#ifdef OPACITYFRESNEL +uniform vec4 opacityParts; +#endif +#ifdef EMISSIVEFRESNEL +uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor; +#endif +#if defined(REFLECTION) || (defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)) +uniform vec2 vReflectionInfos; +#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX) +uniform mat4 reflectionMatrix; +#endif +#ifndef REFLECTIONMAP_SKYBOX +#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC) +uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; +#endif +#endif +#ifdef REFLECTIONFRESNEL +uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor; +#endif +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos; +#endif +#include +#define ADDITIONAL_FRAGMENT_DECLARATION +`;E.IncludesShadersStore[jP]||(E.IncludesShadersStore[jP]=oX)});var qP,lX,rp=C(()=>{w();qP="prePassDeclaration",lX=`#ifdef PREPASS +#extension GL_EXT_draw_buffers : require +layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor; +#ifdef PREPASS_LOCAL_POSITION +varying highp vec3 vPosition; +#endif +#ifdef PREPASS_DEPTH +varying highp vec3 vViewPos; +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +varying highp float vNormViewDepth; +#endif +#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) +varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition; +#endif +#endif +`;E.IncludesShadersStore[qP]||(E.IncludesShadersStore[qP]=lX)});var QP,cX,sp=C(()=>{w();QP="oitDeclaration",cX=`#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[QP]||(E.IncludesShadersStore[QP]=cX)});var JP,fX,np=C(()=>{w();JP="lightFragmentDeclaration",fX=`#ifdef LIGHT{X} +uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; +#ifdef SPECULARTERM +uniform vec4 vLightSpecular{X}; +#else +vec4 vLightSpecular{X}=vec4(0.); +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DArrayShadow shadowTexture{X}; +#else +uniform highp sampler2DArray shadowTexture{X}; +#endif +#ifdef SHADOWCSMDEBUG{X} +const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] +( +vec3 ( 1.5,0.0,0.0 ), +vec3 ( 0.0,1.5,0.0 ), +vec3 ( 0.0,0.0,5.5 ), +vec3 ( 1.5,0.0,5.5 ), +vec3 ( 1.5,1.5,0.0 ), +vec3 ( 1.0,1.0,1.0 ), +vec3 ( 0.0,1.0,5.5 ), +vec3 ( 0.5,3.5,0.75 ) +);vec3 shadowDebug{X}; +#endif +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +int index{X}=-1; +#else +int index{X}=SHADOWCSMNUM_CASCADES{X}-1; +#endif +float diff{X}=0.; +#elif defined(SHADOWCUBE{X}) +uniform samplerCube shadowTexture{X}; +#else +varying vec4 vPositionFromLight{X};varying float vDepthMetric{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DShadow shadowTexture{X}; +#else +uniform sampler2D shadowTexture{X}; +#endif +uniform mat4 lightMatrix{X}; +#endif +uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X}; +#endif +#ifdef SPOTLIGHT{X} +uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X}; +#elif defined(POINTLIGHT{X}) +uniform vec4 vLightFalloff{X}; +#elif defined(HEMILIGHT{X}) +uniform vec3 vLightGround{X}; +#endif +#ifdef AREALIGHT{X} +uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X}; +#ifdef RECTAREALIGHTEMISSIONTEXTURE{X} +uniform sampler2D rectAreaLightEmissionTexture{X}; +#endif +#endif +#ifdef IESLIGHTTEXTURE{X} +uniform sampler2D iesLightTexture{X}; +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X}; +#endif +#ifdef CLUSTLIGHT{X} +uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X}; +#endif +#endif +`;E.IncludesShadersStore[JP]||(E.IncludesShadersStore[JP]=fX)});var $P,hX,ap=C(()=>{w();$P="lightUboDeclaration",hX=`#ifdef LIGHT{X} +uniform Light{X} +{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; +#ifdef SPOTLIGHT{X} +vec4 vLightDirection;vec4 vLightFalloff; +#elif defined(POINTLIGHT{X}) +vec4 vLightFalloff; +#elif defined(HEMILIGHT{X}) +vec3 vLightGround; +#elif defined(CLUSTLIGHT{X}) +vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES]; +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vec4 vLightWidth;vec4 vLightHeight; +#endif +vec4 shadowsInfo;vec2 depthValues;} light{X}; +#ifdef IESLIGHTTEXTURE{X} +uniform sampler2D iesLightTexture{X}; +#endif +#ifdef RECTAREALIGHTEMISSIONTEXTURE{X} +uniform sampler2D rectAreaLightEmissionTexture{X}; +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X}; +#endif +#ifdef CLUSTLIGHT{X} +uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X}; +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DArrayShadow shadowTexture{X}; +#else +uniform highp sampler2DArray shadowTexture{X}; +#endif +#ifdef SHADOWCSMDEBUG{X} +const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] +( +vec3 ( 1.5,0.0,0.0 ), +vec3 ( 0.0,1.5,0.0 ), +vec3 ( 0.0,0.0,5.5 ), +vec3 ( 1.5,0.0,5.5 ), +vec3 ( 1.5,1.5,0.0 ), +vec3 ( 1.0,1.0,1.0 ), +vec3 ( 0.0,1.0,5.5 ), +vec3 ( 0.5,3.5,0.75 ) +);vec3 shadowDebug{X}; +#endif +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +int index{X}=-1; +#else +int index{X}=SHADOWCSMNUM_CASCADES{X}-1; +#endif +float diff{X}=0.; +#elif defined(SHADOWCUBE{X}) +uniform samplerCube shadowTexture{X}; +#else +varying vec4 vPositionFromLight{X};varying float vDepthMetric{X}; +#if defined(SHADOWPCSS{X}) +uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X}; +#elif defined(SHADOWPCF{X}) +uniform highp sampler2DShadow shadowTexture{X}; +#else +uniform sampler2D shadowTexture{X}; +#endif +uniform mat4 lightMatrix{X}; +#endif +#endif +#endif +`;E.IncludesShadersStore[$P]||(E.IncludesShadersStore[$P]=hX)});var eL,dX,AS=C(()=>{w();eL="ltcHelperFunctions",dX=`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;} +else +{thetaSintheta=0.5*inversesqrt( max( 1.0-x*x,1e-7 ) )-v;} +return cross( v1,v2 )*thetaSintheta;} +vec3 LTCEvaluate( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ] ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 ); +mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result );} +vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered,vec3 p1_,vec3 p2_,vec3 p3_,vec3 p4_) +{vec3 V1=p2_-p1_;vec3 V2=p4_-p1_;vec3 planeOrtho=(cross(V1,V2));float planeAreaSquared=dot(planeOrtho,planeOrtho);float planeDistxPlaneArea=dot(planeOrtho,p1_);vec3 P=planeDistxPlaneArea*planeOrtho/planeAreaSquared-p1_;float dot_V1_V2=dot(V1,V2);float inv_dot_V1_V1=1.0/dot(V1,V1);vec3 V2_=V2-V1*dot_V1_V2*inv_dot_V1_V1;vec2 Puv;Puv.y=dot(V2_,P)/dot(V2_,V2_);Puv.x=dot(V1,P)*inv_dot_V1_V1-dot_V1_V2*inv_dot_V1_V1*Puv.y ;float d=abs(planeDistxPlaneArea)/pow(planeAreaSquared,0.75);float sampleLOD=log(2048.0*d)/log(3.0);vec2 sampleUV=vec2(0.125,0.125)+(vec2(0.75)*Puv);sampleUV.x=1.0-sampleUV.x;return texture2DLodEXT(texLightFiltered,sampleUV,sampleLOD).rgb;} +vec3 LTCEvaluateWithEmission( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ],const in sampler2D texFilteredMap ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 ); +mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );vec3 textureLight=FetchDiffuseFilteredTexture(texFilteredMap,coords[0],coords[1],coords[2],coords[3]);coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result )*textureLight;} +struct areaLightData +{vec3 Diffuse;vec3 Specular;vec4 Fresnel;}; +#define inline +areaLightData computeAreaLightSpecularDiffuseFresnel(const in sampler2D ltc1,const in sampler2D ltc2,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness) +{areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight; +rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight; +#ifdef SPECULARTERM +vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3( +vec3( t1.x,0,t1.y ), +vec3( 0,1, 0 ), +vec3( t1.z,0,t1.w ) +);result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords );result.Fresnel=t2; +#endif +result.Diffuse=LTCEvaluate( normal,viewDir,position,mat3( 1.0 ),rectCoords );return result;} +#define inline +areaLightData computeAreaLightSpecularDiffuseFresnelWithEmission(const in sampler2D ltc1,const in sampler2D ltc2,const in sampler2D texFilteredMap,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness) +{areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight; +rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight; +#ifdef SPECULARTERM +vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3( +vec3( t1.x,0,t1.y ), +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[eL]||(E.IncludesShadersStore[eL]=dX)});var tL,uX,RS=C(()=>{w();tL="clusteredLightingFunctions",uX=`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), +texelFetch(lightDataTexture,ivec2(1,index),0), +texelFetch(lightDataTexture,ivec2(2,index),0), +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[tL]||(E.IncludesShadersStore[tL]=uX)});var iL,mX,rL=C(()=>{w();AS();RS();iL="lightsFragmentFunctions",mX=`struct lightingInfo +{vec3 diffuse; +#ifdef SPECULARTERM +vec3 specular; +#endif +#ifdef NDOTL +float ndl; +#endif +};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.) +{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);} +else +{lightVectorW=normalize(-lightData.xyz);} +float ndl=max(0.,dot(vNormal,lightVectorW)); +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=ndl*diffuseColor*attenuation; +#ifdef SPECULARTERM +vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; +#endif +return result;} +float getAttenuation(float cosAngle,float exponent) {return max(0.,pow(cosAngle,exponent));} +float getIESAttenuation(float cosAngle,sampler2D iesLightSampler) {float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;} +lightingInfo basicSpotLighting(vec3 viewDirectionW,vec3 lightVectorW,vec3 vNormal,float attenuation,vec3 diffuseColor,vec3 specularColor,float glossiness) {lightingInfo result; +float ndl=max(0.,dot(vNormal,lightVectorW)); +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=ndl*diffuseColor*attenuation; +#ifdef SPECULARTERM +vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; +#endif +return result;} +lightingInfo computeIESSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness,sampler2D iesLightSampler) { +vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float dotProduct=dot(lightDirection.xyz,-lightVectorW);float cosAngle=max(0.,dotProduct);if (cosAngle>=lightDirection.w) +{ +attenuation*=getIESAttenuation(dotProduct,iesLightSampler);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} +lightingInfo result;result.diffuse=vec3(0.); +#ifdef SPECULARTERM +result.specular=vec3(0.); +#endif +#ifdef NDOTL +result.ndl=0.; +#endif +return result;} +lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w) +{ +attenuation*=getAttenuation(cosAngle,lightData.w);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} +lightingInfo result;result.diffuse=vec3(0.); +#ifdef SPECULARTERM +result.specular=vec3(0.); +#endif +#ifdef NDOTL +result.ndl=0.; +#endif +return result;} +lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5; +#ifdef NDOTL +result.ndl=ndl; +#endif +result.diffuse=mix(groundColor,diffuseColor,ndl); +#ifdef SPECULARTERM +vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor; +#endif +return result;} +#define inline +vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#include +uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler; +#define inline +lightingInfo computeAreaLighting(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) +{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular; +#endif +result.diffuse+=diffuseColor*data.Diffuse;return result;} +lightingInfo computeAreaLightingWithTexture(sampler2D ltc1,sampler2D ltc2,sampler2D emissionTexture,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) +{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc2,emissionTexture,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular; +#endif +result.diffuse+=diffuseColor*data.Diffuse;return result;} +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#include +#define inline +lightingInfo computeClusteredLighting( +sampler2D lightDataTexture, +sampler2D tileMaskTexture, +vec3 viewDirectionW, +vec3 vNormal, +vec4 lightData, +ivec2 sliceRange, +float glossiness +) {lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);lightingInfo info;if (light.vLightDirection.w<0.0) {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} +result.diffuse+=info.diffuse; +#ifdef SPECULARTERM +result.specular+=info.specular; +#endif +} +batchOffset+=CLUSTLIGHT_BATCH;} +return result;} +#endif +`;E.IncludesShadersStore[iL]||(E.IncludesShadersStore[iL]=mX)});var sL,pX,op=C(()=>{w();sL="shadowsFragmentFunctions",pX=`#ifdef SHADOWS +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l) +#else +#define TEXTUREFUNC(s,c,b) texture2D(s,c,b) +#endif +#ifndef SHADOWFLOAT +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);} +#endif +float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff) +{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);} +#define inline +float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues) +{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; +#ifndef SHADOWFLOAT +float shadow=unpack(textureCube(shadowSampler,directionToLight)); +#else +float shadow=textureCube(shadowSampler,directionToLight).x; +#endif +return depth>shadow ? darkness : 1.0;} +#define inline +float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues) +{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0); +#ifndef SHADOWFLOAT +if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;} +#endif +#define inline +float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); +#else +float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x; +#endif +return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}} +#define inline +float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760); +#ifndef SHADOWFLOAT +if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); +#else +float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x; +#endif +float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} +#define inline +float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) +{return 1.0;} +else +{float shadowPixelDepth=clamp(depthMetric,0.,1.0); +#ifndef SHADOWFLOAT +float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); +#else +float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x; +#endif +float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} +#ifdef IS_NDC_HALF_ZRANGE +#define ZINCLIP clipSpace.z +#else +#define ZINCLIP uvDepth.z +#endif +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +#define SMALLEST_ABOVE_ZERO 1.1754943508e-38 +#define GREATEST_LESS_THAN_ONE 0.99999994 +#define DISABLE_UNIFORMITY_ANALYSIS +#define inline +float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +#ifdef USE_REVERSE_DEPTHBUFFER +uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); +#else +uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); +#endif +vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +#define inline +float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +#ifdef USE_REVERSE_DEPTHBUFFER +uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); +#else +uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); +#endif +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +#define inline +float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +#ifdef USE_REVERSE_DEPTHBUFFER +uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); +#else +uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); +#endif +vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} +#define inline +float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +#define inline +float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +#define inline +float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;if (depthMetric<0.0 || depthMetric>1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; +uv+=0.5; +vec2 st=fract(uv); +vec2 base_uv=floor(uv)-0.5; +base_uv*=shadowMapSizeAndInverse.y; +vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} +const vec3 PoissonSamplers32[64]=vec3[64]( +vec3(0.06407013,0.05409927,0.), +vec3(0.7366577,0.5789394,0.), +vec3(-0.6270542,-0.5320278,0.), +vec3(-0.4096107,0.8411095,0.), +vec3(0.6849564,-0.4990818,0.), +vec3(-0.874181,-0.04579735,0.), +vec3(0.9989998,0.0009880066,0.), +vec3(-0.004920578,-0.9151649,0.), +vec3(0.1805763,0.9747483,0.), +vec3(-0.2138451,0.2635818,0.), +vec3(0.109845,0.3884785,0.), +vec3(0.06876755,-0.3581074,0.), +vec3(0.374073,-0.7661266,0.), +vec3(0.3079132,-0.1216763,0.), +vec3(-0.3794335,-0.8271583,0.), +vec3(-0.203878,-0.07715034,0.), +vec3(0.5912697,0.1469799,0.), +vec3(-0.88069,0.3031784,0.), +vec3(0.5040108,0.8283722,0.), +vec3(-0.5844124,0.5494877,0.), +vec3(0.6017799,-0.1726654,0.), +vec3(-0.5554981,0.1559997,0.), +vec3(-0.3016369,-0.3900928,0.), +vec3(-0.5550632,-0.1723762,0.), +vec3(0.925029,0.2995041,0.), +vec3(-0.2473137,0.5538505,0.), +vec3(0.9183037,-0.2862392,0.), +vec3(0.2469421,0.6718712,0.), +vec3(0.3916397,-0.4328209,0.), +vec3(-0.03576927,-0.6220032,0.), +vec3(-0.04661255,0.7995201,0.), +vec3(0.4402924,0.3640312,0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.), +vec3(0.) +);const vec3 PoissonSamplers64[64]=vec3[64]( +vec3(-0.613392,0.617481,0.), +vec3(0.170019,-0.040254,0.), +vec3(-0.299417,0.791925,0.), +vec3(0.645680,0.493210,0.), +vec3(-0.651784,0.717887,0.), +vec3(0.421003,0.027070,0.), +vec3(-0.817194,-0.271096,0.), +vec3(-0.705374,-0.668203,0.), +vec3(0.977050,-0.108615,0.), +vec3(0.063326,0.142369,0.), +vec3(0.203528,0.214331,0.), +vec3(-0.667531,0.326090,0.), +vec3(-0.098422,-0.295755,0.), +vec3(-0.885922,0.215369,0.), +vec3(0.566637,0.605213,0.), +vec3(0.039766,-0.396100,0.), +vec3(0.751946,0.453352,0.), +vec3(0.078707,-0.715323,0.), +vec3(-0.075838,-0.529344,0.), +vec3(0.724479,-0.580798,0.), +vec3(0.222999,-0.215125,0.), +vec3(-0.467574,-0.405438,0.), +vec3(-0.248268,-0.814753,0.), +vec3(0.354411,-0.887570,0.), +vec3(0.175817,0.382366,0.), +vec3(0.487472,-0.063082,0.), +vec3(-0.084078,0.898312,0.), +vec3(0.488876,-0.783441,0.), +vec3(0.470016,0.217933,0.), +vec3(-0.696890,-0.549791,0.), +vec3(-0.149693,0.605762,0.), +vec3(0.034211,0.979980,0.), +vec3(0.503098,-0.308878,0.), +vec3(-0.016205,-0.872921,0.), +vec3(0.385784,-0.393902,0.), +vec3(-0.146886,-0.859249,0.), +vec3(0.643361,0.164098,0.), +vec3(0.634388,-0.049471,0.), +vec3(-0.688894,0.007843,0.), +vec3(0.464034,-0.188818,0.), +vec3(-0.440840,0.137486,0.), +vec3(0.364483,0.511704,0.), +vec3(0.034028,0.325968,0.), +vec3(0.099094,-0.308023,0.), +vec3(0.693960,-0.366253,0.), +vec3(0.678884,-0.204688,0.), +vec3(0.001801,0.780328,0.), +vec3(0.145177,-0.898984,0.), +vec3(0.062655,-0.611866,0.), +vec3(0.315226,-0.604297,0.), +vec3(-0.780145,0.486251,0.), +vec3(-0.371868,0.882138,0.), +vec3(0.200476,0.494430,0.), +vec3(-0.494552,-0.711051,0.), +vec3(0.612476,0.705252,0.), +vec3(-0.578845,-0.768792,0.), +vec3(-0.772454,-0.090976,0.), +vec3(0.504440,0.372295,0.), +vec3(0.155736,0.065157,0.), +vec3(0.391522,0.849605,0.), +vec3(-0.620106,-0.328104,0.), +vec3(0.789239,-0.419965,0.), +vec3(-0.545396,0.538133,0.), +vec3(-0.178564,-0.596057,0.) +); +#define inline +float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) +{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); +#ifdef USE_REVERSE_DEPTHBUFFER +uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); +#else +uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); +#endif +vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i1.0 || uvDepth.x<0. || uvDepth.x>1.0 || uvDepth.y<0. || uvDepth.y>1.0) {return 1.0;} else {float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i{w();nL="samplerFragmentDeclaration",_X=`#ifdef _DEFINENAME_ +#if _DEFINENAME_DIRECTUV==1 +#define v_VARYINGNAME_UV vMainUV1 +#elif _DEFINENAME_DIRECTUV==2 +#define v_VARYINGNAME_UV vMainUV2 +#elif _DEFINENAME_DIRECTUV==3 +#define v_VARYINGNAME_UV vMainUV3 +#elif _DEFINENAME_DIRECTUV==4 +#define v_VARYINGNAME_UV vMainUV4 +#elif _DEFINENAME_DIRECTUV==5 +#define v_VARYINGNAME_UV vMainUV5 +#elif _DEFINENAME_DIRECTUV==6 +#define v_VARYINGNAME_UV vMainUV6 +#else +varying vec2 v_VARYINGNAME_UV; +#endif +uniform sampler2D _SAMPLERNAME_Sampler; +#endif +`;E.IncludesShadersStore[nL]||(E.IncludesShadersStore[nL]=_X)});var aL,gX,oL=C(()=>{w();aL="fresnelFunction",gX=`#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[aL]||(E.IncludesShadersStore[aL]=gX)});var lL,EX,Bh=C(()=>{w();lL="reflectionFunction",EX=`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); } +vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) +{vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));r=vec3(reflectionMatrix*vec4(r,0));float lon=atan(r.z,r.x);float lat=acos(r.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 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix) +{vec3 viewDir=normalize(vec3(view*worldPos));vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));vec3 r=reflect(viewDir,viewNormal);r=vec3(reflectionMatrix*vec4(r,0));r.z=r.z-1.0;float m=2.0*length(r);return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);} +vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) +{vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));} +vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) +{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0)); +#ifdef INVERTCUBICMAP +coords.y*=-1.0; +#endif +return coords;} +vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition) +{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0)); +#ifdef INVERTCUBICMAP +coords.y*=-1.0; +#endif +return coords;} +vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix) +{return vec3(reflectionMatrix*(view*worldPos));} +vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix) +{return vec3(reflectionMatrix*vec4(positionW,1.));} +#ifdef REFLECTION +vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal) +{ +#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED +vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction); +#endif +#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED +vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction); +#endif +#ifdef REFLECTIONMAP_EQUIRECTANGULAR +return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_SPHERICAL +return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_PLANAR +return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_CUBIC +#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC +return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition); +#else +return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); +#endif +#endif +#ifdef REFLECTIONMAP_PROJECTION +return computeProjectionCoords(worldPos,view,reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_SKYBOX +return computeSkyBoxCoords(vPositionUVW,reflectionMatrix); +#endif +#ifdef REFLECTIONMAP_EXPLICIT +return vec3(0,0,0); +#endif +} +#endif +`;E.IncludesShadersStore[lL]||(E.IncludesShadersStore[lL]=EX)});var cL,vX,lp=C(()=>{w();cL="imageProcessingDeclaration",vX=`#ifdef EXPOSURE +uniform float exposureLinear; +#endif +#ifdef CONTRAST +uniform float contrast; +#endif +#if defined(VIGNETTE) || defined(DITHER) +uniform vec2 vInverseScreenSize; +#endif +#ifdef VIGNETTE +uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2; +#endif +#ifdef COLORCURVES +uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive; +#endif +#ifdef COLORGRADING +#ifdef COLORGRADING3D +uniform highp sampler3D txColorTransform; +#else +uniform sampler2D txColorTransform; +#endif +uniform vec4 colorTransformSettings; +#endif +#ifdef DITHER +uniform float ditherIntensity; +#endif +`;E.IncludesShadersStore[cL]||(E.IncludesShadersStore[cL]=vX)});var fL,SX,cp=C(()=>{w();fL="imageProcessingFunctions",SX=`#if defined(COLORGRADING) && !defined(COLORGRADING3D) +/** +* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL. +* sampler3dSetting.x=textureOffset (0.5/textureSize). +* sampler3dSetting.y=textureSize. +*/ +#define inline +vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting) +{float sliceSize=2.0*sampler3dSetting.x; +#ifdef SAMPLER3DGREENDEPTH +float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y; +#else +float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y; +#endif +float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger; +#ifdef SAMPLER3DGREENDEPTH +vec2 sliceUV=color.rb; +#else +vec2 sliceUV=color.rg; +#endif +sliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction); +#ifdef SAMPLER3DBGRMAP +color.rgb=result.rgb; +#else +color.rgb=result.bgr; +#endif +return color;} +#endif +#if TONEMAPPING==3 +const float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak{w();hL="bumpFragmentMainFunctions",TX=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) +#if defined(TANGENT) && defined(NORMAL) +varying mat3 vTBN; +#endif +#ifdef OBJECTSPACE_NORMALMAP +uniform mat4 normalMatrix; +#if defined(WEBGL2) || defined(WEBGPU) +mat4 toNormalMatrix(mat4 wMatrix) +{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;} +#else +mat4 toNormalMatrix(mat4 m) +{float +a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3], +a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3], +a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3], +a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3], +b00=a00*a11-a01*a10, +b01=a00*a12-a02*a10, +b02=a00*a13-a03*a10, +b03=a01*a12-a02*a11, +b04=a01*a13-a03*a11, +b05=a02*a13-a03*a12, +b06=a20*a31-a21*a30, +b07=a20*a32-a22*a30, +b08=a20*a33-a23*a30, +b09=a21*a32-a22*a31, +b10=a21*a33-a23*a31, +b11=a22*a33-a23*a32, +det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4( +a11*b11-a12*b10+a13*b09, +a02*b10-a01*b11-a03*b09, +a31*b05-a32*b04+a33*b03, +a22*b04-a21*b05-a23*b03, +a12*b08-a10*b11-a13*b07, +a00*b11-a02*b08+a03*b07, +a32*b02-a30*b05-a33*b01, +a20*b05-a22*b02+a23*b01, +a10*b10-a11*b08+a13*b06, +a01*b08-a00*b10-a03*b06, +a30*b04-a31*b02+a33*b00, +a21*b02-a20*b04-a23*b00, +a11*b07-a10*b09-a12*b06, +a00*b09-a01*b07+a02*b06, +a31*b01-a30*b03-a32*b00, +a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0], +mi[0][1],mi[1][1],mi[2][1],mi[3][1], +mi[0][2],mi[1][2],mi[2][2],mi[3][2], +mi[0][3],mi[1][3],mi[2][3],mi[3][3]);} +#endif +#endif +vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale) +{ +#ifdef NORMALXYSCALE +normal=normalize(normal*vec3(scale,scale,1.0)); +#endif +return normalize(cotangentFrame*normal);} +vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale) +{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,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[hL]||(E.IncludesShadersStore[hL]=TX)});var dL,AX,hp=C(()=>{w();_l();dL="bumpFragmentFunctions",AX=`#if defined(BUMP) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) +#endif +#if defined(DETAIL) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail) +#endif +#if defined(BUMP) && defined(PARALLAX) +const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; icurrRayHeight) +{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;} +else +{currRayHeight-=stepSize;vLastOffset=vCurrOffset; +#ifdef PARALLAX_RHS +vCurrOffset-=stepSize*vMaxOffset; +#else +vCurrOffset+=stepSize*vMaxOffset; +#endif +lastSampledHeight=currSampledHeight;}} +return vCurrOffset;} +vec2 parallaxOffset(vec3 viewDir,float heightScale) +{float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height; +#ifdef PARALLAX_RHS +return texCoordOffset; +#else +return -texCoordOffset; +#endif +} +#endif +`;E.IncludesShadersStore[dL]||(E.IncludesShadersStore[dL]=AX)});var uL,RX,dp=C(()=>{w();uL="bumpFragment",RX=`vec2 uvOffset=vec2(0.0,0.0); +#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) +#ifdef NORMALXYSCALE +float normalScale=1.0; +#elif defined(BUMP) +float normalScale=vBumpInfos.y; +#else +float normalScale=1.0; +#endif +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#elif defined(BUMP) +vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams); +#else +vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.)); +#endif +#elif defined(ANISOTROPIC) +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#else +vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.)); +#endif +#endif +#ifdef PARALLAX +mat3 invTBN=transposeMat3(TBN); +#ifdef PARALLAXOCCLUSION +uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z); +#else +uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z); +#endif +#endif +#ifdef DETAIL +vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB); +#endif +#ifdef BUMP +#ifdef OBJECTSPACE_NORMALMAP +#define CUSTOM_FRAGMENT_BUMP_FRAGMENT +normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW); +#elif !defined(DETAIL) +normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y); +#else +vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0; +#if DETAIL_NORMALBLENDMETHOD==0 +detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z)); +#elif DETAIL_NORMALBLENDMETHOD==1 +detailNormal.xy*=vDetailInfos.z;bumpNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal; +#endif +normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y); +#endif +#elif defined(DETAIL) +detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); +#endif +`;E.IncludesShadersStore[uL]||(E.IncludesShadersStore[uL]=RX)});var mL,xX,xS=C(()=>{w();mL="decalFragment",xX=`#ifdef DECAL +#ifdef GAMMADECAL +decalColor.rgb=toLinearSpace(decalColor.rgb); +#endif +#ifdef DECAL_SMOOTHALPHA +decalColor.a*=decalColor.a; +#endif +surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a); +#endif +`;E.IncludesShadersStore[mL]||(E.IncludesShadersStore[mL]=xX)});var pL,IX,up=C(()=>{w();pL="depthPrePass",IX=`#ifdef DEPTHPREPASS +gl_FragColor=vec4(0.,0.,0.,1.0);return; +#endif +`;E.IncludesShadersStore[pL]||(E.IncludesShadersStore[pL]=IX)});var _L,CX,IS=C(()=>{w();_L="lightFragment",CX=`#ifdef LIGHT{X} +#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) +#else +vec4 diffuse{X}=light{X}.vLightDiffuse; +#define CUSTOM_LIGHT{X}_COLOR +#if defined(PBR) && defined(CLUSTLIGHT{X}) && defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting( +lightDataTexture{X}, +tileMaskTexture{X}, +light{X}.vLightData, +ivec2(light{X}.vSliceRanges[sliceIndex]), +viewDirectionW, +normalW, +vPositionW, +surfaceAlbedo, +reflectivityOut +#ifdef IRIDESCENCE +,iridescenceIntensity +#endif +#ifdef SS_TRANSLUCENCY +,subSurfaceOut +#endif +#ifdef SPECULARTERM +,AARoughnessFactors.x +#endif +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#ifdef SHEEN +,sheenOut +#endif +#ifdef CLEARCOAT +,clearcoatOut +#endif +);} +#elif defined(PBR) +#ifdef SPOTLIGHT{X} +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW); +#elif defined(POINTLIGHT{X}) +preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW); +#elif defined(HEMILIGHT{X}) +preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(DIRLIGHT{X}) +preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#if defined(RECTAREALIGHTEMISSIONTEXTURE{X}) +preInfo=computeAreaPreLightingInfoWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness); +#else +preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness); +#endif +#endif +preInfo.NdotV=NdotV; +#ifdef SPOTLIGHT{X} +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w); +#endif +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); +#else +preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w); +#endif +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); +#else +preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#endif +#elif defined(POINTLIGHT{X}) +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); +#else +preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#endif +#else +preInfo.attenuation=1.0; +#endif +#if defined(HEMILIGHT{X}) +preInfo.roughness=roughness; +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo.roughness=roughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo; +#ifdef IRIDESCENCE +preInfo.iridescenceIntensity=iridescenceIntensity; +#endif +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission=vec3(0.0); +#endif +#ifdef HEMILIGHT{X} +info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb); +#elif defined(SS_TRANSLUCENCY) +#ifndef SS_TRANSLUCENCY_LEGACY +info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); +#else +info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); +#endif +#else +info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb); +#endif +#ifdef SPECULARTERM +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#else +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +{vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);} +#else +coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#endif +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +{float NdotH=dot(normalW,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);} +#endif +#ifdef ANISOTROPIC +info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); +#else +info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb); +#endif +#endif +#endif +#ifndef AREALIGHT{X} +#ifdef SHEEN +#ifdef SHEEN_LINKWITHALBEDO +preInfo.roughness=sheenOut.sheenIntensity; +#else +#ifdef HEMILIGHT{X} +preInfo.roughness=sheenOut.sheenRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +#endif +info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); +#endif +#ifdef CLEARCOAT +#ifdef HEMILIGHT{X} +preInfo.roughness=clearcoatOut.clearCoatRoughness; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); +#endif +info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb); +#ifdef CLEARCOAT_TINT +absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=absorption; +#endif +#ifdef SPECULARTERM +info.specular*=absorption; +#endif +#endif +info.diffuse*=info.clearCoat.w; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=info.clearCoat.w; +#endif +#ifdef SPECULARTERM +info.specular*=info.clearCoat.w; +#endif +#ifdef SHEEN +info.sheen*=info.clearCoat.w; +#endif +#endif +#endif +#else +#ifdef SPOTLIGHT{X} +#ifdef IESLIGHTTEXTURE{X} +info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X}); +#else +info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); +#endif +#elif defined(HEMILIGHT{X}) +info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness); +#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X}) +info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#if defined(RECTAREALIGHTEMISSIONTEXTURE{X}) +info=computeAreaLightingWithTexture(areaLightsLTC1Sampler,areaLightsLTC2Sampler,rectAreaLightEmissionTexture{X},viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb, +#ifdef AREALIGHTNOROUGHTNESS +0.5 +#else +vReflectionInfos.y +#endif +#else +info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb, +#ifdef AREALIGHTNOROUGHTNESS +0.5 +#else +vReflectionInfos.y +#endif +#endif +); +#elif defined(CLUSTLIGHT{X}) && CLUSTLIGHT_BATCH>0 +{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},tileMaskTexture{X},viewDirectionW,normalW,light{X}.vLightData,ivec2(light{X}.vSliceRanges[sliceIndex]),glossiness);} +#endif +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW); +#endif +#endif +#ifdef SHADOW{X} +#ifdef SHADOWCSM{X} +for (int i=0; i=0.) {index{X}=i;break;}} +#ifdef SHADOWCSMUSESHADOWMAXZ{X} +if (index{X}>=0) +#endif +{ +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#else +shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#endif +#else +shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}]; +#endif +#ifndef SHADOWCSMNOBLEND{X} +float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.) +{index{X}+=1;float nextShadow=0.; +#if defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#elif defined(SHADOWMEDIUMQUALITY{X}) +nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#else +nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); +#endif +#else +nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +shadow=mix(nextShadow,shadow,diffRatio); +#ifdef SHADOWCSMDEBUG{X} +shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio); +#endif +} +#endif +} +#elif defined(SHADOWCLOSEESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWESM{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); +#else +shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPOISSON{X}) +#if defined(SHADOWCUBE{X}) +shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCF{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#elif defined(SHADOWPCSS{X}) +#if defined(SHADOWLOWQUALITY{X}) +shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#elif defined(SHADOWMEDIUMQUALITY{X}) +shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#else +shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#else +#if defined(SHADOWCUBE{X}) +shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues); +#else +shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); +#endif +#endif +#ifdef SHADOWONLY +#ifndef SHADOWINUSE +#define SHADOWINUSE +#endif +globalShadow+=shadow;shadowLightCount+=1.0; +#endif +#else +shadow=1.; +#endif +aggShadow+=shadow;numLights+=1.0; +#ifndef SHADOWONLY +#ifdef CUSTOMUSERLIGHTING +diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); +#ifdef SPECULARTERM +specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); +#endif +#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) +diffuseBase+=lightmapColor.rgb*shadow; +#ifdef SPECULARTERM +#ifndef LIGHTMAPNOSPECULAR{X} +specularBase+=info.specular*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef CLEARCOAT +#ifndef LIGHTMAPNOSPECULAR{X} +clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb; +#endif +#endif +#ifdef SHEEN +#ifndef LIGHTMAPNOSPECULAR{X} +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#else +#ifdef SHADOWCSMDEBUG{X} +diffuseBase+=info.diffuse*shadowDebug{X}; +#else +diffuseBase+=info.diffuse*shadow; +#endif +#ifdef SS_TRANSLUCENCY +diffuseTransmissionBase+=info.diffuseTransmission*shadow; +#endif +#ifdef SPECULARTERM +specularBase+=info.specular*shadow; +#endif +#ifdef CLEARCOAT +clearCoatBase+=info.clearCoat.rgb*shadow; +#endif +#ifdef SHEEN +sheenBase+=info.sheen.rgb*shadow; +#endif +#endif +#endif +#endif +`;E.IncludesShadersStore[_L]||(E.IncludesShadersStore[_L]=CX)});var gL,bX,Uh=C(()=>{w();gL="logDepthFragment",bX=`#ifdef LOGARITHMICDEPTH +gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5; +#endif +`;E.IncludesShadersStore[gL]||(E.IncludesShadersStore[gL]=bX)});var EL,MX,mp=C(()=>{w();EL="oitFragment",MX=`#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; +#endif +ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0); +#ifdef USE_REVERSE_DEPTHBUFFER +float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y; +#else +float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y; +#endif +float alphaMultiplier=1.0-lastFrontColor.a; +#ifdef USE_REVERSE_DEPTHBUFFER +if (fragDepth>nearestDepth || fragDepthfurthestDepth) { +#endif +return;} +#ifdef USE_REVERSE_DEPTHBUFFER +if (fragDepthfurthestDepth) { +#else +if (fragDepth>nearestDepth && fragDepthyX});var CS,vL,yX,TL=C(()=>{w();ZP();ES();rp();sp();lf();Or();np();ap();rL();op();_l();oL();Bh();lp();cp();fp();hp();vn();ga();qc();Sn();dp();xS();up();IS();Uh();Qc();mp();CS="defaultPixelShader",vL=`#define CUSTOM_FRAGMENT_EXTENSION +#include<__decl__defaultFragment> +#if defined(BUMP) || !defined(NORMAL) +#extension GL_OES_standard_derivatives : enable +#endif +#include[SCENE_MRT_COUNT] +#include +#define CUSTOM_FRAGMENT_BEGIN +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif +varying vec3 vPositionW; +#ifdef NORMAL +varying vec3 vNormalW; +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying float vViewDepth; +#endif +#include[1..7] +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include +#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#ifdef REFRACTION +#ifdef REFRACTIONMAP_3D +uniform samplerCube refractionCubeSampler; +#else +uniform sampler2D refraction2DSampler; +#endif +#endif +#if defined(SPECULARTERM) +#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular) +#endif +#include +#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +uniform samplerCube reflectionCubeSampler; +#else +uniform sampler2D reflection2DSampler; +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#endif +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a; +#ifdef NORMAL +vec3 normalW=normalize(vNormalW); +#else +vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#endif +#include +#ifdef TWOSIDEDLIGHTING +normalW=gl_FrontFacing ? normalW : -normalW; +#endif +#ifdef DIFFUSE +baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset); +#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS) +if (baseColor.a(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) +#endif +#include +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +baseColor.rgb*=vColor.rgb; +#endif +#ifdef DETAIL +baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y); +#endif +#if defined(DECAL) && defined(DECAL_AFTER_DETAIL) +vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset); +#include(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) +#endif +#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE +vec3 baseAmbientColor=vec3(1.,1.,1.); +#ifdef AMBIENT +baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y; +#endif +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb; +#ifdef SPECULARTERM +#ifdef SPECULAR +vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb; +#ifdef GLOSSINESS +glossiness=glossiness*specularMapColor.a; +#endif +#endif +#endif +vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info; +#ifdef SPECULARTERM +vec3 specularBase=vec3(0.,0.,0.); +#endif +float shadow=1.;float aggShadow=0.;float numLights=0.; +#ifdef LIGHTMAP +vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor.rgb=fromRGBD(lightmapColor); +#endif +lightmapColor.rgb*=vLightmapInfos.y; +#endif +#include[0..maxSimultaneousLights] +aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.); +#ifdef REFRACTION +vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y)); +#ifdef REFRACTIONMAP_3D +#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC +refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition); +#endif +refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;} +#else +vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords); +#endif +#ifdef RGBDREFRACTION +refractionColor.rgb=fromRGBD(refractionColor); +#endif +#ifdef IS_REFRACTION_LINEAR +refractionColor.rgb=toGammaSpace(refractionColor.rgb); +#endif +refractionColor.rgb*=vRefractionInfos.x; +#endif +vec4 reflectionColor=vec4(0.,0.,0.,1.); +#ifdef REFLECTION +vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +vReflectionUVW.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +#ifdef ROUGHNESS +float bias=vReflectionInfos.y; +#ifdef SPECULARTERM +#ifdef SPECULAR +#ifdef GLOSSINESS +bias*=(1.0-specularMapColor.a); +#endif +#endif +#endif +reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias); +#else +reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW); +#endif +#else +vec2 coords=vReflectionUVW.xy; +#ifdef REFLECTIONMAP_PROJECTION +coords/=vReflectionUVW.z; +#endif +coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords); +#endif +#ifdef RGBDREFLECTION +reflectionColor.rgb=fromRGBD(reflectionColor); +#endif +#ifdef IS_REFLECTION_LINEAR +reflectionColor.rgb=toGammaSpace(reflectionColor.rgb); +#endif +reflectionColor.rgb*=vReflectionInfos.x; +#ifdef REFLECTIONFRESNEL +float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a); +#ifdef REFLECTIONFRESNELFROMSPECULAR +#ifdef SPECULARTERM +reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#else +reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#endif +#else +reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; +#endif +#endif +#endif +#ifdef REFRACTIONFRESNEL +float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb; +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); +#ifdef OPACITYRGB +opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y; +#else +alpha*=opacityMap.a*vOpacityInfos.y; +#endif +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=vColor.a; +#endif +#ifdef OPACITYFRESNEL +float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y; +#endif +#ifdef ALPHATEST +#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS +if (alpha +#include +#ifdef IMAGEPROCESSINGPOSTPROCESS +color.rgb=toLinearSpace(color.rgb); +#else +#ifdef IMAGEPROCESSING +color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color); +#endif +#endif +color.a*=visibility; +#ifdef PREMULTIPLYALPHA +color.rgb*=color.a; +#endif +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#if SCENE_MRT_COUNT>0 +float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0; +#ifdef PREPASS_COLOR +gl_FragData[PREPASS_COLOR_INDEX]=color; +#endif +#ifdef PREPASS_POSITION +gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo); +#endif +#ifdef PREPASS_LOCAL_POSITION +gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo); +#endif +#if defined(PREPASS_VELOCITY) +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_IRRADIANCE +gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_DEPTH +gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); +#else +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(baseColor.rgb,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqrt(baseColor.rgb),writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#if defined(SPECULAR) +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; +#else +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo; +#endif +#endif +#endif +#endif +#if !defined(PREPASS) || defined(WEBGL2) +gl_FragColor=color; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;} +#endif +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStore[CS]||(E.ShadersStore[CS]=vL);yX={name:CS,shader:vL}});var bS,MS,yS,DS,Te,An=C(()=>{$e();Qe();As();vr();Je();It();gm();Em();oh();Vi();Ur();Hc();Pt();ns();mo();cS();Ps();Ih();Ui();jt();vm();Sm();Tm();Am();bS={effect:null,subMesh:null},MS=class extends sf(rf(qt)){},yS=class extends ef(MS){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()}},DS=class extends nf(os){},Te=class s extends DS{get isPrePassCapable(){return!this.disableDepthWrite}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||s.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 ae(0,0,0),this.diffuseColor=new ae(1,1,1),this.specularColor=new ae(1,1,1),this.emissiveColor=new ae(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 yt(16),this._globalAmbientColor=new ae(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new ls(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new xr,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),s.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),s.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 s.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget||s.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===oe.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==oe.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 yS(this._eventInfo.defineNames));let n=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let o=n.getEngine();if(a._needNormals=Pc(n,e,a,!0,this._maxSimultaneousLights,this._disableLighting),!Dc(n,e,this._maxSimultaneousLights,this._disableLighting))return!1;Lc(n,a);let l=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Nc(n,a,this.canRenderToMRT&&!l),Oc(n,a,l),qi.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(n.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&&s.DiffuseTextureEnabled)if(this._diffuseTexture.isReadyOrNotBlocking())ot(this._diffuseTexture,a,"DIFFUSE");else return!1;else a.DIFFUSE=!1;if(this._ambientTexture&&s.AmbientTextureEnabled)if(this._ambientTexture.isReadyOrNotBlocking())ot(this._ambientTexture,a,"AMBIENT");else return!1;else a.AMBIENT=!1;if(this._opacityTexture&&s.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&&s.ReflectionTextureEnabled?(a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha):(a.ROUGHNESS=!1,a.REFLECTIONOVERALPHA=!1),!so(n,this._reflectionTexture,a))return!1;if(this._emissiveTexture&&s.EmissiveTextureEnabled)if(this._emissiveTexture.isReadyOrNotBlocking())ot(this._emissiveTexture,a,"EMISSIVE");else return!1;else a.EMISSIVE=!1;if(this._lightmapTexture&&s.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&&s.SpecularTextureEnabled)if(this._specularTexture.isReadyOrNotBlocking())ot(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha;else return!1;else a.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&s.BumpTextureEnabled){if(this._bumpTexture.isReady())ot(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=n.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&&s.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&&(s.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_${D}_info`)}))}else this._vertexPullingMetadata=null;let v={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,a,d,v));let I=a.toString(),x=t.effect,T=n.getEngine().createEffect(u,{attributes:d,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:I,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:g,processFinalCode:v.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(()=>(KD(),YD)),Promise.resolve().then(()=>(EP(),gP))]):await Promise.all([Promise.resolve().then(()=>(YP(),XP)),Promise.resolve().then(()=>(TL(),SL))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,T)if(this._onEffectCreatedObservable&&(bS.effect=T,bS.subMesh=t,this._onEffectCreatedObservable.notifyObservers(bS)),this.allowShaderHotSwapping&&x&&!T.isReady()){if(a.markAsUnprocessed(),c=this.isFrozen,f)return a._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(T,a,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(a._renderId=n.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),Fc(e,!1,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var f;let r=this.getScene(),n=i.materialDefines;if(!n)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),qi.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),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let l=this._mustRebind(r,a,i,t.visibility);Sr(t,a),this._vertexPullingMetadata&&_o(a,this._vertexPullingMetadata);let c=this._uniformBuffer;if(l){if(this.bindViewProjection(a),!c.useUbo||!this.isFrozen||!c.isSync||i._drawWrapper._forceRebindOnNextCall){if(s.FresnelEnabled&&n.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 h=Fi.Color3[0];h.set(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),c.updateColor4("opacityParts",h,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&&s.DiffuseTextureEnabled&&(c.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),lt(this._diffuseTexture,c,"diffuse")),this._ambientTexture&&s.AmbientTextureEnabled&&(c.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),lt(this._ambientTexture,c,"ambient")),this._opacityTexture&&s.OpacityTextureEnabled&&(c.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),lt(this._opacityTexture,c,"opacity")),this._hasAlphaChannel()&&c.updateFloat("alphaCutOff",this.alphaCutOff),Ic(r,n,c,ae.White(),this._reflectionTexture,!1,!1,!0,!1,!1,!1,this.roughness),(!this._reflectionTexture||!s.ReflectionTextureEnabled)&&c.updateFloat2("vReflectionInfos",0,this.roughness),this._emissiveTexture&&s.EmissiveTextureEnabled&&(c.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),lt(this._emissiveTexture,c,"emissive")),this._lightmapTexture&&s.LightmapTextureEnabled&&(c.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),lt(this._lightmapTexture,c,"lightmap")),this._specularTexture&&s.SpecularTextureEnabled&&(c.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),lt(this._specularTexture,c,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&s.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&&s.RefractionTextureEnabled)){let h=1;if(this._refractionTexture.isCube||(c.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),c.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){let d=this._refractionTexture;c.updateVector3("vRefractionPosition",d.boundingBoxPosition),c.updateVector3("vRefractionSize",d.boundingBoxSize)}}this.pointsCloud&&c.updateFloat("pointSize",this.pointSize),c.updateColor4("vSpecularColor",this.specularColor,this.specularPower),c.updateColor3("vEmissiveColor",s.EmissiveTextureEnabled?this.emissiveColor:ae.BlackReadOnly),c.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),c.updateColor3("vAmbientColor",this._globalAmbientColor)}r.texturesEnabled&&(this._diffuseTexture&&s.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&s.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&s.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&s.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&s.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&s.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&s.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&s.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&s.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&&bc(r,t,a,n,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==nt.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||n.PREPASS||n.CLUSTLIGHT_BATCH)&&this.bindView(a),cn(r,t,a),n.NUM_MORPH_INFLUENCERS&&Yi(t,a),n.BAKED_VERTEX_ANIMATION_TEXTURE&&((f=t.bakedVertexAnimationManager)==null||f.bind(a,n.INSTANCES)),this.useLogarithmicDepth&&ln(n,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,n,a,o,l,c,f,h;t&&((i=this._diffuseTexture)==null||i.dispose(),(r=this._ambientTexture)==null||r.dispose(),(n=this._opacityTexture)==null||n.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(),(h=this._refractionTexture)==null||h.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,i=""){let r=De.Clone(()=>new s(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=De.Parse(()=>new s(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),oe._ParsePlugins(e,r,t,i),r}static get DiffuseTextureEnabled(){return re.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){re.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return re.DetailTextureEnabled}static set DetailTextureEnabled(e){re.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return re.AmbientTextureEnabled}static set AmbientTextureEnabled(e){re.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return re.OpacityTextureEnabled}static set OpacityTextureEnabled(e){re.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return re.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){re.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return re.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){re.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return re.SpecularTextureEnabled}static set SpecularTextureEnabled(e){re.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return re.BumpTextureEnabled}static set BumpTextureEnabled(e){re.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return re.LightmapTextureEnabled}static set LightmapTextureEnabled(e){re.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return re.RefractionTextureEnabled}static set RefractionTextureEnabled(e){re.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return re.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){re.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return re.FresnelEnabled}static set FresnelEnabled(e){re.FresnelEnabled=e}};Te.ForceGLSL=!1;b([qe("diffuseTexture")],Te.prototype,"_diffuseTexture",void 0);b([ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Te.prototype,"diffuseTexture",void 0);b([qe("ambientTexture")],Te.prototype,"_ambientTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"ambientTexture",void 0);b([qe("opacityTexture")],Te.prototype,"_opacityTexture",void 0);b([ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Te.prototype,"opacityTexture",void 0);b([qe("reflectionTexture")],Te.prototype,"_reflectionTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"reflectionTexture",void 0);b([qe("emissiveTexture")],Te.prototype,"_emissiveTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"emissiveTexture",void 0);b([qe("specularTexture")],Te.prototype,"_specularTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"specularTexture",void 0);b([qe("bumpTexture")],Te.prototype,"_bumpTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"bumpTexture",void 0);b([qe("lightmapTexture")],Te.prototype,"_lightmapTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"lightmapTexture",void 0);b([qe("refractionTexture")],Te.prototype,"_refractionTexture",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"refractionTexture",void 0);b([Kt("ambient")],Te.prototype,"ambientColor",void 0);b([Kt("diffuse")],Te.prototype,"diffuseColor",void 0);b([Kt("specular")],Te.prototype,"specularColor",void 0);b([Kt("emissive")],Te.prototype,"emissiveColor",void 0);b([L()],Te.prototype,"specularPower",void 0);b([L("useAlphaFromDiffuseTexture")],Te.prototype,"_useAlphaFromDiffuseTexture",void 0);b([ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Te.prototype,"useAlphaFromDiffuseTexture",void 0);b([L("useEmissiveAsIllumination")],Te.prototype,"_useEmissiveAsIllumination",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useEmissiveAsIllumination",void 0);b([L("linkEmissiveWithDiffuse")],Te.prototype,"_linkEmissiveWithDiffuse",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"linkEmissiveWithDiffuse",void 0);b([L("useSpecularOverAlpha")],Te.prototype,"_useSpecularOverAlpha",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useSpecularOverAlpha",void 0);b([L("useReflectionOverAlpha")],Te.prototype,"_useReflectionOverAlpha",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useReflectionOverAlpha",void 0);b([L("disableLighting")],Te.prototype,"_disableLighting",void 0);b([ie("_markAllSubMeshesAsLightsDirty")],Te.prototype,"disableLighting",void 0);b([L("useObjectSpaceNormalMap")],Te.prototype,"_useObjectSpaceNormalMap",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useObjectSpaceNormalMap",void 0);b([L("useParallax")],Te.prototype,"_useParallax",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useParallax",void 0);b([L("useParallaxOcclusion")],Te.prototype,"_useParallaxOcclusion",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useParallaxOcclusion",void 0);b([L()],Te.prototype,"parallaxScaleBias",void 0);b([L("roughness")],Te.prototype,"_roughness",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"roughness",void 0);b([L()],Te.prototype,"indexOfRefraction",void 0);b([L()],Te.prototype,"invertRefractionY",void 0);b([L()],Te.prototype,"alphaCutOff",void 0);b([L("useLightmapAsShadowmap")],Te.prototype,"_useLightmapAsShadowmap",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useLightmapAsShadowmap",void 0);b([ec("diffuseFresnelParameters")],Te.prototype,"_diffuseFresnelParameters",void 0);b([ie("_markAllSubMeshesAsFresnelDirty")],Te.prototype,"diffuseFresnelParameters",void 0);b([ec("opacityFresnelParameters")],Te.prototype,"_opacityFresnelParameters",void 0);b([ie("_markAllSubMeshesAsFresnelAndMiscDirty")],Te.prototype,"opacityFresnelParameters",void 0);b([ec("reflectionFresnelParameters")],Te.prototype,"_reflectionFresnelParameters",void 0);b([ie("_markAllSubMeshesAsFresnelDirty")],Te.prototype,"reflectionFresnelParameters",void 0);b([ec("refractionFresnelParameters")],Te.prototype,"_refractionFresnelParameters",void 0);b([ie("_markAllSubMeshesAsFresnelDirty")],Te.prototype,"refractionFresnelParameters",void 0);b([ec("emissiveFresnelParameters")],Te.prototype,"_emissiveFresnelParameters",void 0);b([ie("_markAllSubMeshesAsFresnelDirty")],Te.prototype,"emissiveFresnelParameters",void 0);b([L("useReflectionFresnelFromSpecular")],Te.prototype,"_useReflectionFresnelFromSpecular",void 0);b([ie("_markAllSubMeshesAsFresnelDirty")],Te.prototype,"useReflectionFresnelFromSpecular",void 0);b([L("useGlossinessFromSpecularMapAlpha")],Te.prototype,"_useGlossinessFromSpecularMapAlpha",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"useGlossinessFromSpecularMapAlpha",void 0);b([L("maxSimultaneousLights")],Te.prototype,"_maxSimultaneousLights",void 0);b([ie("_markAllSubMeshesAsLightsDirty")],Te.prototype,"maxSimultaneousLights",void 0);b([L("invertNormalMapX")],Te.prototype,"_invertNormalMapX",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"invertNormalMapX",void 0);b([L("invertNormalMapY")],Te.prototype,"_invertNormalMapY",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"invertNormalMapY",void 0);b([L("twoSidedLighting")],Te.prototype,"_twoSidedLighting",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Te.prototype,"twoSidedLighting",void 0);b([L("applyDecalMapAfterDetailMap")],Te.prototype,"_applyDecalMapAfterDetailMap",void 0);b([ie("_markAllSubMeshesAsMiscDirty")],Te.prototype,"applyDecalMapAfterDetailMap",void 0);Ke("BABYLON.StandardMaterial",Te);nt.DefaultMaterialFactory=s=>new Te("default material",s)});var AL,DX,PS=C(()=>{w();AL="kernelBlurVaryingDeclaration",DX="varying sampleCoord{X}: vec2f;";E.IncludesShadersStoreWGSL[AL]||(E.IncludesShadersStoreWGSL[AL]=DX)});var RL,PX,pp=C(()=>{w();RL="packingFunctions",PX=`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[RL]||(E.IncludesShadersStoreWGSL[RL]=PX)});var xL,LX,IL=C(()=>{w();xL="kernelBlurFragment",LX=`#ifdef DOF +factor=sampleCoC(fragmentInputs.sampleCoord{X}); +computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight; +#else +computedWeight=KERNEL_WEIGHT{X}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCoord{X}))*computedWeight; +#else +blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCoord{X})*computedWeight; +#endif +`;E.IncludesShadersStoreWGSL[xL]||(E.IncludesShadersStoreWGSL[xL]=LX)});var CL,OX,bL=C(()=>{w();CL="kernelBlurFragment2",OX=`#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}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X}))*computedWeight; +#else +blend+=textureSample(textureSampler,textureSamplerSampler,fragmentInputs.sampleCenter+uniforms.delta*KERNEL_DEP_OFFSET{X})*computedWeight; +#endif +`;E.IncludesShadersStoreWGSL[CL]||(E.IncludesShadersStoreWGSL[CL]=OX)});var yL={};Ie(yL,{kernelBlurPixelShaderWGSL:()=>NX});var LS,ML,NX,DL=C(()=>{w();PS();pp();IL();bL();LS="kernelBlurPixelShader",ML=`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 +#include[0..varyingCount] +#ifdef PACKEDFLOAT +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs {var computedWeight: f32=0.0; +#ifdef PACKEDFLOAT +var blend: f32=0.; +#else +var blend: vec4f= vec4f(0.); +#endif +#ifdef DOF +var sumOfWeights: f32=CENTER_WEIGHT; +var factor: f32=0.0; +#ifdef PACKEDFLOAT +blend+=unpack(textureSample(textureSampler,textureSamplerSampler,input.sampleCenter))*CENTER_WEIGHT; +#else +blend+=textureSample(textureSampler,textureSamplerSampler,input.sampleCenter)*CENTER_WEIGHT; +#endif +#endif +#include[0..varyingCount] +#include[0..depCount] +#ifdef PACKEDFLOAT +fragmentOutputs.color=pack(blend); +#else +fragmentOutputs.color=blend; +#endif +#ifdef DOF +fragmentOutputs.color/=sumOfWeights; +#endif +}`;E.ShadersStoreWGSL[LS]||(E.ShadersStoreWGSL[LS]=ML);NX={name:LS,shader:ML}});var PL,FX,LL=C(()=>{w();PL="kernelBlurVertex",FX="vertexOutputs.sampleCoord{X}=vertexOutputs.sampleCenter+uniforms.delta*KERNEL_OFFSET{X};";E.IncludesShadersStoreWGSL[PL]||(E.IncludesShadersStoreWGSL[PL]=FX)});var NL={};Ie(NL,{kernelBlurVertexShaderWGSL:()=>wX});var OS,OL,wX,FL=C(()=>{w();PS();LL();OS="kernelBlurVertexShader",OL=`attribute position: vec2f;uniform delta: vec2f;varying sampleCenter: vec2f; +#include[0..varyingCount] +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs {const madd: vec2f= vec2f(0.5,0.5); +#define CUSTOM_VERTEX_MAIN_BEGIN +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[OS]||(E.ShadersStoreWGSL[OS]=OL);wX={name:OS,shader:OL}});var wL,BX,NS=C(()=>{w();wL="kernelBlurVaryingDeclaration",BX="varying vec2 sampleCoord{X};";E.IncludesShadersStore[wL]||(E.IncludesShadersStore[wL]=BX)});var BL,UX,_p=C(()=>{w();BL="packingFunctions",UX=`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[BL]||(E.IncludesShadersStore[BL]=UX)});var UL,VX,VL=C(()=>{w();UL="kernelBlurFragment",VX=`#ifdef DOF +factor=sampleCoC(sampleCoord{X}); +computedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight; +#else +computedWeight=KERNEL_WEIGHT{X}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight; +#else +blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight; +#endif +`;E.IncludesShadersStore[UL]||(E.IncludesShadersStore[UL]=VX)});var GL,GX,kL=C(()=>{w();GL="kernelBlurFragment2",GX=`#ifdef DOF +factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight; +#else +computedWeight=KERNEL_DEP_WEIGHT{X}; +#endif +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight; +#else +blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight; +#endif +`;E.IncludesShadersStore[GL]||(E.IncludesShadersStore[GL]=GX)});var HL={};Ie(HL,{kernelBlurPixelShader:()=>kX});var FS,WL,kX,zL=C(()=>{w();NS();_p();VL();kL();FS="kernelBlurPixelShader",WL=`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 +#include[0..varyingCount] +#ifdef PACKEDFLOAT +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{float computedWeight=0.0; +#ifdef PACKEDFLOAT +float blend=0.; +#else +vec4 blend=vec4(0.); +#endif +#ifdef DOF +float sumOfWeights=CENTER_WEIGHT; +float factor=0.0; +#ifdef PACKEDFLOAT +blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT; +#else +blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT; +#endif +#endif +#include[0..varyingCount] +#include[0..depCount] +#ifdef PACKEDFLOAT +gl_FragColor=pack(blend); +#else +gl_FragColor=blend; +#endif +#ifdef DOF +gl_FragColor/=sumOfWeights; +#endif +}`;E.ShadersStore[FS]||(E.ShadersStore[FS]=WL);kX={name:FS,shader:WL}});var XL,WX,YL=C(()=>{w();XL="kernelBlurVertex",WX="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";E.IncludesShadersStore[XL]||(E.IncludesShadersStore[XL]=WX)});var jL={};Ie(jL,{kernelBlurVertexShader:()=>HX});var wS,KL,HX,ZL=C(()=>{w();NS();YL();wS="kernelBlurVertexShader",KL=`attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter; +#include[0..varyingCount] +const vec2 madd=vec2(0.5,0.5); +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +sampleCenter=(position*madd+madd); +#include[0..varyingCount] +gl_Position=vec4(position,0.0,1.0); +#define CUSTOM_VERTEX_MAIN_END +}`;E.ShadersStore[wS]||(E.ShadersStore[wS]=KL);HX={name:wS,shader:KL}});var nr,BS=C(()=>{rl();gt();nr=class s extends _i{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([Promise.resolve().then(()=>(DL(),yL)),Promise.resolve().then(()=>(FL(),NL))]))):t.push(Promise.all([Promise.resolve().then(()=>(zL(),HL)),Promise.resolve().then(()=>(ZL(),jL))]))}constructor(e,t=null,i,r,n){let a=!!(n!=null&&n.blockCompilation);super({...n,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:s.FragmentUrl,uniforms:s.Uniforms,samplers:s.Samplers,vertexUrl:s.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this._staticDefines=n?Array.isArray(n.defines)?n.defines.join(` +`):n.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,n=[],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+$/,"")}};nr.VertexUrl="kernelBlur";nr.FragmentUrl="kernelBlur";nr.Uniforms=["delta","direction"];nr.Samplers=["circleOfConfusionSampler"]});var cs,US=C(()=>{$e();Kn();pi();Pt();Qe();jt();BS();cs=class s extends Rt{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,n=null,a=ne.BILINEAR_SAMPLINGMODE,o,l,c=0,f="",h=!1,d=5){let u=typeof r=="number"?h:!!r.blockCompilation,m={uniforms:nr.Uniforms,samplers:nr.Samplers,size:typeof r=="number"?r:void 0,camera:n,samplingMode:a,engine:o,reusable:l,textureType:c,vertexUrl:nr.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:d,defines:f,...r,blockCompilation:!0};super(e,nr.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new nr(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,n,a){this._effectWrapper._updateParameters(n,a)}static _Parse(e,t,i,r){return De.Parse(()=>new s(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1),e,i,r)}};b([tc()],cs.prototype,"direction",null);b([L()],cs.prototype,"kernel",null);b([L()],cs.prototype,"packedFloat",null);Ke("BABYLON.BlurPostProcess",cs)});var qL,zX,QL=C(()=>{w();qL="bayerDitherFunctions",zX=`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);} +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[qL]||(E.IncludesShadersStoreWGSL[qL]=zX)});var JL,XX,$L=C(()=>{w();pp();QL();JL="shadowMapFragmentExtraDeclaration",XX=`#if SM_FLOAT==0 +#include +#endif +#if SM_SOFTTRANSPARENTSHADOW==1 +#include +uniform softTransparentShadowSM: vec2f; +#endif +varying vDepthMetricSM: f32; +#if SM_USEDISTANCE==1 +uniform lightDataSM: vec3f;varying vPositionWSM: vec3f; +#endif +uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f; +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +varying zSM: f32; +#endif +`;E.IncludesShadersStoreWGSL[JL]||(E.IncludesShadersStoreWGSL[JL]=XX)});var eO,YX,tO=C(()=>{w();eO="shadowMapFragment",YX=`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; +#else +#ifdef USE_REVERSE_DEPTHBUFFER +depthSM=(-fragmentInputs.zSM+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; +#else +depthSM=(fragmentInputs.zSM+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; +#endif +#endif +depthSM=clamp(depthSM,0.0,1.0); +#ifdef USE_REVERSE_DEPTHBUFFER +fragmentOutputs.fragDepth=clamp(1.0-depthSM,0.0,1.0); +#else +fragmentOutputs.fragDepth=clamp(depthSM,0.0,1.0); +#endif +#elif SM_USEDISTANCE==1 +depthSM=(length(fragmentInputs.vPositionWSM-uniforms.lightDataSM)+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; +#endif +#if SM_ESM==1 +depthSM=clamp(exp(-min(87.,uniforms.biasAndScaleSM.z*depthSM)),0.,1.); +#endif +#if SM_FLOAT==1 +fragmentOutputs.color= vec4f(depthSM,1.0,1.0,1.0); +#else +fragmentOutputs.color=pack(depthSM); +#endif +`;E.IncludesShadersStoreWGSL[eO]||(E.IncludesShadersStoreWGSL[eO]=YX)});var rO={};Ie(rO,{shadowMapPixelShaderWGSL:()=>KX});var VS,iO,KX,sO=C(()=>{w();$L();pn();_n();tO();VS="shadowMapPixelShader",iO=`#include +#ifdef ALPHATEXTURE +varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; +#endif +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#include +#ifdef ALPHATEXTURE +var opacityMap: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUV);var alphaFromAlphaTexture: f32=opacityMap.a; +#if SM_SOFTTRANSPARENTSHADOW==1 +if (uniforms.softTransparentShadowSM.y==1.0) {opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;} +#endif +#ifdef ALPHATESTVALUE +if (alphaFromAlphaTexture=uniforms.softTransparentShadowSM.x*alphaFromAlphaTexture) {discard;} +#else +if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x) {discard;} +#endif +#endif +#include +}`;E.ShadersStoreWGSL[VS]||(E.ShadersStoreWGSL[VS]=iO);KX={name:VS,shader:iO}});var nO,jX,aO=C(()=>{w();nO="shadowMapVertexExtraDeclaration",jX=`#if SM_NORMALBIAS==1 +uniform lightDataSM: vec3f; +#endif +uniform biasAndScaleSM: vec3f;uniform depthValuesSM: vec2f;varying vDepthMetricSM: f32; +#if SM_USEDISTANCE==1 +varying vPositionWSM: vec3f; +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +varying zSM: f32; +#endif +`;E.IncludesShadersStoreWGSL[nO]||(E.IncludesShadersStoreWGSL[nO]=jX)});var oO,ZX,lO=C(()=>{w();oO="shadowMapVertexNormalBias",ZX=`#if SM_NORMALBIAS==1 +#if SM_DIRECTIONINLIGHTDATA==1 +var worldLightDirSM: vec3f=normalize(-uniforms.lightDataSM.xyz); +#else +var directionToLightSM: vec3f=uniforms.lightDataSM.xyz-worldPos.xyz;var worldLightDirSM: vec3f=normalize(directionToLightSM); +#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[oO]||(E.IncludesShadersStoreWGSL[oO]=ZX)});var cO,qX,fO=C(()=>{w();cO="shadowMapVertexMetric",qX=`#if SM_USEDISTANCE==1 +vertexOutputs.vPositionWSM=worldPos.xyz; +#endif +#if SM_DEPTHTEXTURE==1 +#ifdef IS_NDC_HALF_ZRANGE +#define BIASFACTOR 0.5 +#else +#define BIASFACTOR 1.0 +#endif +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.position.z-=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR; +#else +vertexOutputs.position.z+=uniforms.biasAndScaleSM.x*vertexOutputs.position.w*BIASFACTOR; +#endif +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +vertexOutputs.zSM=vertexOutputs.position.z;vertexOutputs.position.z=0.0; +#elif SM_USEDISTANCE==0 +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetricSM=(-vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; +#else +vertexOutputs.vDepthMetricSM=(vertexOutputs.position.z+uniforms.depthValuesSM.x)/uniforms.depthValuesSM.y+uniforms.biasAndScaleSM.x; +#endif +#endif +`;E.IncludesShadersStoreWGSL[cO]||(E.IncludesShadersStoreWGSL[cO]=qX)});var dO={};Ie(dO,{shadowMapVertexShaderWGSL:()=>QX});var GS,hO,QX,uO=C(()=>{w();na();aa();To();Ao();Lr();Tn();So();aO();un();Ro();xo();oa();la();ca();lO();fO();mn();GS="shadowMapVertexShader",hO=`attribute position: vec3f; +#ifdef NORMAL +attribute normal: vec3f; +#endif +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef INSTANCES +attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f; +#endif +#include +#include +#include +#ifdef ALPHATEXTURE +varying vUV: vec2f;uniform diffuseMatrix: mat4x4f; +#ifdef UV1 +attribute uv: vec2f; +#endif +#ifdef UV2 +attribute uv2: vec2f; +#endif +#endif +#include +#include +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position; +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#ifdef NORMAL +var normalUpdated: vec3f=vertexInputs.normal; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0); +#ifdef NORMAL +var normWorldSM: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +var vNormalW: vec3f=normalUpdated/ vec3f(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normWorldSM=transposeMat3(inverseMat3(normWorldSM)); +#endif +var vNormalW: vec3f=normalize(normWorldSM*normalUpdated); +#endif +#endif +#include +vertexOutputs.position=scene.viewProjection*worldPos; +#include +#ifdef ALPHATEXTURE +#ifdef UV1 +vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef UV2 +vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#include +}`;E.ShadersStoreWGSL[GS]||(E.ShadersStoreWGSL[GS]=hO);QX={name:GS,shader:hO}});var pO={};Ie(pO,{depthBoxBlurPixelShaderWGSL:()=>JX});var kS,mO,JX,_O=C(()=>{w();kS="depthBoxBlurPixelShader",mO=`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[kS]||(E.ShadersStoreWGSL[kS]=mO);JX={name:kS,shader:mO}});var EO={};Ie(EO,{shadowMapFragmentSoftTransparentShadowWGSL:()=>$X});var WS,gO,$X,vO=C(()=>{w();WS="shadowMapFragmentSoftTransparentShadow",gO=`#if SM_SOFTTRANSPARENTSHADOW==1 +if ((bayerDither8(floor(((fragmentInputs.position.xy)%(8.0)))))/64.0>=uniforms.softTransparentShadowSM.x*alpha) {discard;} +#endif +`;E.IncludesShadersStoreWGSL[WS]||(E.IncludesShadersStoreWGSL[WS]=gO);$X={name:WS,shader:gO}});var SO,e5,TO=C(()=>{w();SO="bayerDitherFunctions",e5=`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);} +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[SO]||(E.IncludesShadersStore[SO]=e5)});var AO,t5,RO=C(()=>{w();_p();TO();AO="shadowMapFragmentExtraDeclaration",t5=`#if SM_FLOAT==0 +#include +#endif +#if SM_SOFTTRANSPARENTSHADOW==1 +#include +uniform vec2 softTransparentShadowSM; +#endif +varying float vDepthMetricSM; +#if SM_USEDISTANCE==1 +uniform vec3 lightDataSM;varying vec3 vPositionWSM; +#endif +uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM; +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +varying float zSM; +#endif +`;E.IncludesShadersStore[AO]||(E.IncludesShadersStore[AO]=t5)});var xO,i5,IO=C(()=>{w();xO="shadowMapFragment",i5=`float depthSM=vDepthMetricSM; +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +#if SM_USEDISTANCE==1 +depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#else +#ifdef USE_REVERSE_DEPTHBUFFER +depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#else +depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#endif +#endif +depthSM=clamp(depthSM,0.0,1.0); +#ifdef USE_REVERSE_DEPTHBUFFER +gl_FragDepth=clamp(1.0-depthSM,0.0,1.0); +#else +gl_FragDepth=clamp(depthSM,0.0,1.0); +#endif +#elif SM_USEDISTANCE==1 +depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#endif +#if SM_ESM==1 +depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.); +#endif +#if SM_FLOAT==1 +gl_FragColor=vec4(depthSM,1.0,1.0,1.0); +#else +gl_FragColor=pack(depthSM); +#endif +return;`;E.IncludesShadersStore[xO]||(E.IncludesShadersStore[xO]=i5)});var bO={};Ie(bO,{shadowMapPixelShader:()=>r5});var HS,CO,r5,MO=C(()=>{w();RO();vn();Sn();IO();HS="shadowMapPixelShader",CO=`#include +#ifdef ALPHATEXTURE +varying vec2 vUV;uniform sampler2D diffuseSampler; +#endif +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{ +#include +#ifdef ALPHATEXTURE +vec4 opacityMap=texture2D(diffuseSampler,vUV);float alphaFromAlphaTexture=opacityMap.a; +#if SM_SOFTTRANSPARENTSHADOW==1 +if (softTransparentShadowSM.y==1.0) {opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;} +#endif +#ifdef ALPHATESTVALUE +if (alphaFromAlphaTexture=softTransparentShadowSM.x*alphaFromAlphaTexture) discard; +#else +if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x) discard; +#endif +#endif +#include +}`;E.ShadersStore[HS]||(E.ShadersStore[HS]=CO);r5={name:HS,shader:CO}});var yO,s5,zS=C(()=>{w();yO="sceneVertexDeclaration",s5=`uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif +uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition; +`;E.IncludesShadersStore[yO]||(E.IncludesShadersStore[yO]=s5)});var DO,n5,PO=C(()=>{w();DO="meshVertexDeclaration",n5=`uniform mat4 world;uniform float visibility; +`;E.IncludesShadersStore[DO]||(E.IncludesShadersStore[DO]=n5)});var LO,a5,OO=C(()=>{w();zS();PO();LO="shadowMapVertexDeclaration",a5=`#include +#include +`;E.IncludesShadersStore[LO]||(E.IncludesShadersStore[LO]=a5)});var NO,o5,FO=C(()=>{w();Io();of();NO="shadowMapUboDeclaration",o5=`layout(std140,column_major) uniform; +#include +#include +`;E.IncludesShadersStore[NO]||(E.IncludesShadersStore[NO]=o5)});var wO,l5,BO=C(()=>{w();wO="shadowMapVertexExtraDeclaration",l5=`#if SM_NORMALBIAS==1 +uniform vec3 lightDataSM; +#endif +uniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM; +#if SM_USEDISTANCE==1 +varying vec3 vPositionWSM; +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +varying float zSM; +#endif +`;E.IncludesShadersStore[wO]||(E.IncludesShadersStore[wO]=l5)});var UO,c5,VO=C(()=>{w();UO="shadowMapVertexNormalBias",c5=`#if SM_NORMALBIAS==1 +#if SM_DIRECTIONINLIGHTDATA==1 +vec3 worldLightDirSM=normalize(-lightDataSM.xyz); +#else +vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM); +#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[UO]||(E.IncludesShadersStore[UO]=c5)});var GO,f5,kO=C(()=>{w();GO="shadowMapVertexMetric",f5=`#if SM_USEDISTANCE==1 +vPositionWSM=worldPos.xyz; +#endif +#if SM_DEPTHTEXTURE==1 +#ifdef IS_NDC_HALF_ZRANGE +#define BIASFACTOR 0.5 +#else +#define BIASFACTOR 1.0 +#endif +#ifdef USE_REVERSE_DEPTHBUFFER +gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR; +#else +gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR; +#endif +#endif +#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1 +zSM=gl_Position.z;gl_Position.z=0.0; +#elif SM_USEDISTANCE==0 +#ifdef USE_REVERSE_DEPTHBUFFER +vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#else +vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x; +#endif +#endif +`;E.IncludesShadersStore[GO]||(E.IncludesShadersStore[GO]=f5)});var HO={};Ie(HO,{shadowMapVertexShader:()=>h5});var XS,WO,h5,zO=C(()=>{w();fa();ha();Co();bo();Or();OO();FO();BO();gn();Mo();yo();da();ua();ma();VO();kO();En();XS="shadowMapVertexShader",WO=`attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef INSTANCES +attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; +#endif +#include +#include<__decl__shadowMapVertex> +#ifdef ALPHATEXTURE +varying vec2 vUV;uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +#include +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) +{vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#ifdef NORMAL +mat3 normWorldSM=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normWorldSM=transposeMat3(inverseMat3(normWorldSM)); +#endif +vec3 vNormalW=normalize(normWorldSM*normalUpdated); +#endif +#endif +#include +gl_Position=viewProjection*worldPos; +#include +#ifdef ALPHATEXTURE +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#include +}`;E.ShadersStore[XS]||(E.ShadersStore[XS]=WO);h5={name:XS,shader:WO}});var YO={};Ie(YO,{depthBoxBlurPixelShader:()=>d5});var YS,XO,d5,KO=C(()=>{w();YS="depthBoxBlurPixelShader",XO=`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[YS]||(E.ShadersStore[YS]=XO);d5={name:YS,shader:XO}});var ZO={};Ie(ZO,{shadowMapFragmentSoftTransparentShadow:()=>u5});var KS,jO,u5,qO=C(()=>{w();KS="shadowMapFragmentSoftTransparentShadow",jO=`#if SM_SOFTTRANSPARENTSHADOW==1 +if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alpha) discard; +#endif +`;E.IncludesShadersStore[KS]||(E.IncludesShadersStore[KS]=jO);u5={name:KS,shader:jO}});var Ct,gp=C(()=>{Ee();Je();It();uo();pi();ja();Kn();US();dt();Ci();mo();pu();Ya();Ps();Ui();fh();Ct=class s{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===s.FILTER_BLUREXPONENTIALSHADOWMAP){this.useExponentialShadowMap=!0;return}else if(e===s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP){this.useCloseExponentialShadowMap=!0;return}else if(e===s.FILTER_PCF||e===s.FILTER_PCSS){this.usePoissonSampling=!0;return}}if((e===s.FILTER_PCF||e===s.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===s.FILTER_POISSONSAMPLING}set usePoissonSampling(e){let t=this._validateFilter(s.FILTER_POISSONSAMPLING);!e&&this.filter!==s.FILTER_POISSONSAMPLING||(this.filter=e?t:s.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===s.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){let t=this._validateFilter(s.FILTER_EXPONENTIALSHADOWMAP);!e&&this.filter!==s.FILTER_EXPONENTIALSHADOWMAP||(this.filter=e?t:s.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===s.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){let t=this._validateFilter(s.FILTER_BLUREXPONENTIALSHADOWMAP);!e&&this.filter!==s.FILTER_BLUREXPONENTIALSHADOWMAP||(this.filter=e?t:s.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===s.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){let t=this._validateFilter(s.FILTER_CLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==s.FILTER_CLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:s.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){let t=this._validateFilter(s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:s.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===s.FILTER_PCF}set usePercentageCloserFiltering(e){let t=this._validateFilter(s.FILTER_PCF);!e&&this.filter!==s.FILTER_PCF||(this.filter=e?t:s.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===s.FILTER_PCSS}set useContactHardeningShadow(e){let t=this._validateFilter(s.FILTER_PCSS);!e&&this.filter!==s.FILTER_PCSS||(this.filter=e?t:s.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 s.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,n,a=!1){this.onBeforeShadowMapRenderObservable=new Q,this.onAfterShadowMapRenderObservable=new Q,this.onBeforeShadowMapRenderMeshObservable=new Q,this.onAfterShadowMapRenderMeshObservable=new Q,this.doNotSerialize=!1,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=s.FILTER_NONE,this._filteringQuality=s.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=S.Zero(),this._viewMatrix=H.Zero(),this._projectionMatrix=H.Zero(),this._transformMatrix=H.Zero(),this._cachedPosition=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=H.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=!!n,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})]),s._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 fi(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 fi(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,n,a,o)=>this._renderForShadowMap(r,n,a,o),this._shadowMap.customIsReadyFunction=(r,n,a)=>{if(!a||!r.subMeshes)return!0;let o=!0;for(let l of r.subMeshes){let c=l.getRenderingMesh(),h=this._scene.getEngine(),d=l.getMaterial();if(!d||l.verticesCount===0||this.customAllowRendering&&!this.customAllowRendering(l))continue;let u=c._getInstancesRenderList(l._id,!!l.getReplacementMesh());if(u.mustReturn)continue;let m=h.getCaps().instancedArrays&&(u.visibleInstances[l._id]!==null&&u.visibleInstances[l._id]!==void 0||c.hasThinInstances),p=d.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===s.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),is.eyeAtCamera=!1,this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._sceneUBOs&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onAfterUnbindObservable.add(()=>{var n,a;if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),is.eyeAtCamera=!0,this._scene.updateTransformMatrix(),this._filter===s.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap){(n=e._debugPopGroup)==null||n.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 Me(0,0,0,0),i=new Me(1,1,1,1);this._shadowMap.onClearObservable.add(r=>{this._filter===s.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=Qr.MIN_RENDERINGGROUPS;r(sO(),rO)),Promise.resolve().then(()=>(uO(),dO)),Promise.resolve().then(()=>(_O(),pO)),Promise.resolve().then(()=>(vO(),EO))])):await Promise.all([Promise.resolve().then(()=>(MO(),bO)),Promise.resolve().then(()=>(zO(),HO)),Promise.resolve().then(()=>(KO(),YO)),Promise.resolve().then(()=>(qO(),ZO))]),this._shadersLoaded=!0}_initializeBlurRTTAndPostProcesses(){let e=this._scene.getEngine(),t=this._mapSize/this.blurScale;(!this.useKernelBlur||this.blurScale!==1)&&(this._shadowMap2=new fi(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 cs(this._light.name+"KernelBlurX",new me(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 cs(this._light.name+"KernelBlurY",new me(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 Rt(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 n;if(r.length)for(n=0;n{r!==i&&!T?(i.getMeshUniformBuffer().bindToEffect(v,"Mesh"),i.transferToEffect(A)):(r.getMeshUniformBuffer().bindToEffect(v,"Mesh"),r.transferToEffect(T?A:x))}),this.forceBackFacesOnly&&a.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(v),this.onAfterShadowMapRenderMeshObservable.notifyObservers(i)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===s.FILTER_NONE||this.filter===s.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 n=r.renderList;if(!n){e&&e(this);return}let a=[];for(let c of n)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 n=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&n.isVerticesDataPresent(y.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(),n=r==null?void 0:r.shadowDepthWrapper;if(this._opacityTexture=null,!r)return!1;let a=[];if(this._prepareShadowDefines(e,t,a,i),n){if(!n.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,h=[y.PositionKind],d=e.getMesh(),u=!1,m=!1,p=!1,_=!1;this.normalBias&&d.isVerticesDataPresent(y.NormalKind)&&(h.push(y.NormalKind),a.push("#define NORMAL"),u=!0,d.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));let g=r.needAlphaTestingForMesh(d);if((g||r.needAlphaBlendingForMesh(d))&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=r.opacityTexture:this._opacityTexture=r.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;let A=(o=r.alphaCutOff)!=null?o:s.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),g&&a.push(`#define ALPHATESTVALUE ${A}${A%1===0?".":""}`),d.isVerticesDataPresent(y.UVKind)&&(h.push(y.UVKind),a.push("#define UV1"),m=!0),d.isVerticesDataPresent(y.UV2Kind)&&this._opacityTexture.coordinatesIndex===1&&(h.push(y.UV2Kind),a.push("#define UV2"),p=!0)}let v=new Zi;if(d.useBones&&d.computeBonesUsingShaders&&d.skeleton){h.push(y.MatricesIndicesKind),h.push(y.MatricesWeightsKind),d.numBoneInfluencers>4&&(h.push(y.MatricesIndicesExtraKind),h.push(y.MatricesWeightsExtraKind));let A=d.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+d.numBoneInfluencers),d.numBoneInfluencers>0&&v.addCPUSkinningFallback(0,d),A.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(A.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");let I=d.morphTargetManager?fn(d.morphTargetManager,a,h,d,!0,u,!1,m,p,_):0;if(on(r,this._scene,a),t&&(a.push("#define INSTANCES"),Ls(h),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(let A of this.customShaderOptions.defines)a.indexOf(A)===-1&&a.push(A);let x=d.bakedVertexAnimationManager;x&&x.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&h.push("bakedVertexAnimationSettingsInstanced"));let T=a.join(` +`);if(f!==T){f=T;let A="shadowMap",R=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureInfo","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],P=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],D=["Scene","Mesh"];if(Pi(R),this.customShaderOptions){if(A=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(let F of this.customShaderOptions.attributes)h.indexOf(F)===-1&&h.push(F);if(this.customShaderOptions.uniforms)for(let F of this.customShaderOptions.uniforms)R.indexOf(F)===-1&&R.push(F);if(this.customShaderOptions.samplers)for(let F of this.customShaderOptions.samplers)P.indexOf(F)===-1&&P.push(F)}let M=this._scene.getEngine();c=M.createEffect(A,{attributes:h,uniformsNames:R,uniformBuffersNames:D,samplers:P,defines:T,fallbacks:v,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:I},shaderLanguage:this._shaderLanguage},M),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===s.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===s.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===s.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===s.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 n=this._getCamera(),a=this.getShadowMap();if(!a)return;if(!i.needCube()){let l=r.floatingOriginOffset,c=this.getTransformMatrix(),f=r.floatingOriginMode?hE(l,this._viewMatrix,this._projectionMatrix,W.Matrix[0]):c;t.setMatrix("lightMatrix"+e,f)}let o=this.getShadowMapForRendering();this._filter===s.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===s.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(n),this.getLight().getDepthMinZ(n)+this.getLight().getDepthMaxZ(n),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),S.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(S.Dot(this._lightDirection,S.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),H.LookAtLHToRef(t,t.add(this._lightDirection),S.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,n]=i.value;n===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 Ce("ShadowGeneratorSceneComponent")}});var JO={};Ie(JO,{depthPixelShader:()=>m5});var jS,QO,m5,ZS=C(()=>{w();vn();_p();Sn();jS="depthPixelShader",QO=`#ifdef ALPHATEST +varying vec2 vUV;uniform sampler2D diffuseSampler; +#endif +#include +varying float vDepthMetric; +#ifdef PACKED +#include +#endif +#ifdef STORE_CAMERASPACE_Z +varying vec4 vViewPos; +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{ +#include +#ifdef ALPHATEST +if (texture2D(diffuseSampler,vUV).a<0.4) +discard; +#endif +#ifdef STORE_CAMERASPACE_Z +#ifdef PACKED +gl_FragColor=pack(vViewPos.z); +#else +gl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0); +#endif +#else +#ifdef NONLINEARDEPTH +#ifdef PACKED +gl_FragColor=pack(gl_FragCoord.z); +#else +gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0); +#endif +#else +#ifdef PACKED +gl_FragColor=pack(vDepthMetric); +#else +gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0); +#endif +#endif +#endif +}`;E.ShadersStore[jS]||(E.ShadersStore[jS]=QO);m5={name:jS,shader:QO}});var $O,p5,eN=C(()=>{w();$O="pointCloudVertexDeclaration",p5=`#ifdef POINTSIZE +uniform float pointSize; +#endif +`;E.IncludesShadersStore[$O]||(E.IncludesShadersStore[$O]=p5)});var iN={};Ie(iN,{depthVertexShader:()=>_5});var qS,tN,_5,QS=C(()=>{w();fa();ha();Co();bo();gn();Eo();eN();Mo();yo();da();ua();ma();En();SS();qS="depthVertexShader",tN=`attribute vec3 position; +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +uniform mat4 viewProjection;uniform vec2 depthValues; +#if defined(ALPHATEST) || defined(NEED_UV) +varying vec2 vUV;uniform mat4 diffuseMatrix; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +#ifdef STORE_CAMERASPACE_Z +uniform mat4 view;varying vec4 vViewPos; +#endif +#include +varying float vDepthMetric; +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) +{vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#include +gl_Position=viewProjection*worldPos; +#ifdef STORE_CAMERASPACE_Z +vViewPos=view*worldPos; +#else +#ifdef USE_REVERSE_DEPTHBUFFER +vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y)); +#else +vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y)); +#endif +#endif +#if defined(ALPHATEST) || defined(BASIC_RENDER) +#ifdef UV1 +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef UV2 +vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#include +} +`;E.ShadersStore[qS]||(E.ShadersStore[qS]=tN);_5={name:qS,shader:tN}});var sN={};Ie(sN,{depthVertexShaderWGSL:()=>g5});var JS,rN,g5,nN=C(()=>{w();na();aa();To();Ao();un();go();Ro();xo();oa();la();ca();mn();JS="depthVertexShader",rN=`attribute position: vec3f; +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +uniform viewProjection: mat4x4f;uniform depthValues: vec2f; +#if defined(ALPHATEST) || defined(NEED_UV) +varying vUV: vec2f;uniform diffuseMatrix: mat4x4f; +#ifdef UV1 +attribute uv: vec2f; +#endif +#ifdef UV2 +attribute uv2: vec2f; +#endif +#endif +#ifdef STORE_CAMERASPACE_Z +uniform view: mat4x4f;varying vViewPos: vec4f; +#endif +varying vDepthMetric: f32; +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position; +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0); +#include +vertexOutputs.position=uniforms.viewProjection*worldPos; +#ifdef STORE_CAMERASPACE_Z +vertexOutputs.vViewPos=uniforms.view*worldPos; +#else +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric=((-vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y)); +#else +vertexOutputs.vDepthMetric=((vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y)); +#endif +#endif +#if defined(ALPHATEST) || defined(BASIC_RENDER) +#ifdef UV1 +vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef UV2 +vertexOutputs.vUV= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +} +`;E.ShadersStoreWGSL[JS]||(E.ShadersStoreWGSL[JS]=rN);g5={name:JS,shader:rN}});var oN={};Ie(oN,{depthPixelShaderWGSL:()=>E5});var $S,aN,E5,lN=C(()=>{w();pn();pp();_n();$S="depthPixelShader",aN=`#ifdef ALPHATEST +varying vUV: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; +#endif +#include +varying vDepthMetric: f32; +#ifdef PACKED +#include +#endif +#ifdef STORE_CAMERASPACE_Z +varying vViewPos: vec4f; +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#include +#ifdef ALPHATEST +if (textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV).a<0.4) {discard;} +#endif +#ifdef STORE_CAMERASPACE_Z +#ifdef PACKED +fragmentOutputs.color=pack(input.vViewPos.z); +#else +fragmentOutputs.color= vec4f(input.vViewPos.z,0.0,0.0,1.0); +#endif +#else +#ifdef NONLINEARDEPTH +#ifdef PACKED +fragmentOutputs.color=pack(input.position.z); +#else +fragmentOutputs.color= vec4f(input.position.z,0.0,0.0,0.0); +#endif +#else +#ifdef PACKED +fragmentOutputs.color=pack(input.vDepthMetric); +#else +fragmentOutputs.color= vec4f(input.vDepthMetric,0.0,0.0,1.0); +#endif +#endif +#endif +}`;E.ShadersStoreWGSL[$S]||(E.ShadersStoreWGSL[$S]=aN);E5={name:$S,shader:aN}});var cf,cN=C(()=>{Je();It();pi();ja();Ds();ZS();QS();Ci();Ps();Ui();mo();cf=class s{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 n;let i=(n=e._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:n[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,n=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 Me(1,1,1,1):this.clearColor=new Me(a?0:1,0,0,1),this._initShaderSourceAsync(),s._SceneComponentInitialization(this._scene);let c=e.getEngine();this._camera=i,n!==ne.NEAREST_SAMPLINGMODE&&(t===1&&!c._caps.textureFloatLinearFiltering&&(n=ne.NEAREST_SAMPLINGMODE),t===2&&!c._caps.textureHalfFloatLinearFiltering&&(n=ne.NEAREST_SAMPLINGMODE));let f=this.isPacked||!c._features.supportExtendedTextureFormats?5:6;this._depthMap=l!=null?l:new fi(o!=null?o:"DepthRenderer",{width:c.getRenderWidth(),height:c.getRenderHeight()},this._scene,!1,!0,t,!1,n,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(d=>{d.clear(this.clearColor,!0,!0,!0)}),this._depthMap.customIsReadyFunction=(d,u,m)=>{if((m||u===0)&&d.subMeshes)for(let p=0;p{var P;let u=d.getRenderingMesh(),m=d.getEffectiveMesh(),p=this._scene,_=p.getEngine(),g=d.getMaterial();if(m._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!g||m.infiniteDistance||g.disableDepthWrite||d.verticesCount===0||d._renderId===p.getRenderId())return;let v=m._getWorldMatrixDeterminant()<0,I=g._getEffectiveOrientation(u);v&&(I=I===0?1:0);let x=I===0;_.setState(g.backFaceCulling,0,!1,x,this.reverseCulling?!g.cullBackFaces:g.cullBackFaces);let T=u._getInstancesRenderList(d._id,!!d.getReplacementMesh());if(T.mustReturn)return;let A=_.getCaps().instancedArrays&&(T.visibleInstances[d._id]!==null&&T.visibleInstances[d._id]!==void 0||u.hasThinInstances),R=this._camera||p.activeCamera;if(this.isReady(d,A)&&R){if(d._renderId=p.getRenderId(),m.getClassName()==="GaussianSplattingMesh"){let k=this._ensureGaussianSplattingDepthMaterial(m,_.currentRenderPassId);if(k&&!k.isReadyForSubMesh(m,d,A))return;this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),m.render(d,!1);return}let M=(P=m._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:P[_.currentRenderPassId],F=d._getDrawWrapper();!F&&M&&(F=M._getDrawWrapper());let N=R.mode===we.ORTHOGRAPHIC_CAMERA;if(!F)return;let V=F.effect;_.enableEffect(F),A||u._bind(d,V,g.fillMode),M?M.bindForSubMesh(m.getWorldMatrix(),m,d):(V.setMatrix("viewProjection",p.getTransformMatrix()),V.setMatrix("world",m.getWorldMatrix()),this._storeCameraSpaceZ&&V.setMatrix("view",p.getViewMatrix()));let O,U;if(N?(O=!_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1,U=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:1):(O=_.useReverseDepthBuffer&&_.isNDCHalfZRange?R.minZ:_.isNDCHalfZRange?0:R.minZ,U=_.useReverseDepthBuffer&&_.isNDCHalfZRange?0:R.maxZ),V.setFloat2("depthValues",O,O+U),!M){if(g.needAlphaTestingForMesh(m)){let z=g.getAlphaTestTexture();z&&(V.setTexture("diffuseSampler",z),V.setMatrix("diffuseMatrix",z.getTextureMatrix()))}Sr(u,V),Li(V,g,p),Yi(u,V),u.morphTargetManager&&u.morphTargetManager.isUsingTextureForTargets&&u.morphTargetManager._bind(V);let k=d.getMesh().bakedVertexAnimationManager;k&&k.isEnabled&&k.bind(V,A),g.pointsCloud&&V.setFloat("pointSize",g.pointSize)}this.alphaBlendedDepth&&g.needAlphaBlendingForMesh(m)?_.setAlphaMode(2):_.setAlphaMode(0),u._processRendering(m,d,V,g.fillMode,T,A,(k,z)=>V.setMatrix("world",z))}};this._depthMap.customRenderFunction=(d,u,m,p)=>{let _=this._scene.getEngine(),g=_.getAlphaMode(),v;if(p.length)for(v=0;v(nN(),sN)),Promise.resolve().then(()=>(lN(),oN))])):await Promise.all([Promise.resolve().then(()=>(QS(),iN)),Promise.resolve().then(()=>(ZS(),JO))]),this._shadersLoaded=!0}isReady(e,t){var R,P;if(!this._shadersLoaded)return!1;let i=this._scene.getEngine(),r=e.getMesh(),n=r.getScene(),a=this._depthMap.renderPassId,o=(P=(R=r._internalAbstractMeshDataInfo._materialForRenderPass)==null?void 0:R[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=[y.PositionKind],h=!1,d=!1,u=!1;l.needAlphaTestingForMesh(r)&&l.getAlphaTestTexture()&&(c.push("#define ALPHATEST"),r.isVerticesDataPresent(y.UVKind)&&(f.push(y.UVKind),c.push("#define UV1"),h=!0),r.isVerticesDataPresent(y.UV2Kind)&&(f.push(y.UV2Kind),c.push("#define UV2"),d=!0));let m=new Zi;if(r.useBones&&r.computeBonesUsingShaders&&r.skeleton){f.push(y.MatricesIndicesKind),f.push(y.MatricesWeightsKind),r.numBoneInfluencers>4&&(f.push(y.MatricesIndicesExtraKind),f.push(y.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),r.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,r);let D=r.skeleton;D.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(D.bones.length+1))}else c.push("#define NUM_BONE_INFLUENCERS 0");let p=r.morphTargetManager?fn(r.morphTargetManager,c,f,r,!0,!1,!1,h,d,u):0;l.pointsCloud&&c.push("#define POINTSIZE"),t&&(c.push("#define INSTANCES"),Ls(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"),on(l,n,c);let g=i.currentRenderPassId,I=this._depthMap.renderPassIds.includes(g)?g:this._depthMap.renderPassId,x=e._getDrawWrapper(I,!0),T=x.defines,A=c.join(` +`);if(T!==A){let D=["world","mBones","boneTextureInfo","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],M=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];Pi(D),x.setEffect(i.createEffect("depth",{attributes:f,uniformsNames:D,uniformBuffersNames:[],samplers:M,defines:A,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage},i),A)}return x.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]}}};cf.ForceGLSL=!1;cf._SceneComponentInitialization=s=>{throw Ce("DepthRendererSceneComponent")}});var hN={};Ie(hN,{minmaxReduxPixelShaderWGSL:()=>v5});var eT,fN,v5,tT=C(()=>{w();eT="minmaxReduxPixelShader",fN=`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; +#ifdef DEPTH_REDUX +#ifdef VIEW_DEPTH +var minz=3.4e38;if (f1 != 0.0) { minz=f1; } +if (f2 != 0.0) { minz=min(minz,f2); } +if (f3 != 0.0) { minz=min(minz,f3); } +if (f4 != 0.0) { minz=min(minz,f4); } +let maxz=max(max(max(f1,f2),f3),f4); +#else +let minz=min(min(min(f1,f2),f3),f4);let maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4); +#endif +#else +let minz=min(min(min(f1,f2),f3),f4);let maxz=max(max(max(f1,f2),f3),f4); +#endif +fragmentOutputs.color=vec4f(minz,maxz,0.,0.);} +#elif defined(MAIN) +uniform texSize: vec2f;@fragment +fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*(uniforms.texSize-1.0));let f1=textureLoad(textureSampler,coord,0).rg;let f2=textureLoad(textureSampler,coord+vec2i(1,0),0).rg;let f3=textureLoad(textureSampler,coord+vec2i(1,1),0).rg;let f4=textureLoad(textureSampler,coord+vec2i(0,1),0).rg;let minz=min(min(min(f1.x,f2.x),f3.x),f4.x);let maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);fragmentOutputs.color=vec4(minz,maxz,0.,0.);} +#elif defined(ONEBEFORELAST) +uniform texSize: vec2i;@fragment +fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*vec2f(uniforms.texSize-1));let f1=textureLoad(textureSampler,coord % uniforms.texSize,0).rg;let f2=textureLoad(textureSampler,(coord+vec2i(1,0)) % uniforms.texSize,0).rg;let f3=textureLoad(textureSampler,(coord+vec2i(1,1)) % uniforms.texSize,0).rg;let f4=textureLoad(textureSampler,(coord+vec2i(0,1)) % uniforms.texSize,0).rg;let minz=min(min(min(f1.x,f2.x),f3.x),f4.x);let maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);fragmentOutputs.color=vec4(minz,maxz,0.,0.);} +#elif defined(LAST) +@fragment +fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);if (true) { +discard;}} +#endif +`;E.ShadersStoreWGSL[eT]||(E.ShadersStoreWGSL[eT]=fN);v5={name:eT,shader:fN}});var uN={};Ie(uN,{minmaxReduxPixelShader:()=>S5});var iT,dN,S5,rT=C(()=>{w();iT="minmaxReduxPixelShader",dN=`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; +#ifdef DEPTH_REDUX +#ifdef VIEW_DEPTH +float minz=3.4e38;if (f1 != 0.0) { minz=f1; } +if (f2 != 0.0) { minz=min(minz,f2); } +if (f3 != 0.0) { minz=min(minz,f3); } +if (f4 != 0.0) { minz=min(minz,f4); } +float maxz=max(max(max(f1,f2),f3),f4); +#else +float minz=min(min(min(f1,f2),f3),f4);float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4); +#endif +#else +float minz=min(min(min(f1,f2),f3),f4);float maxz=max(max(max(f1,f2),f3),f4); +#endif +glFragColor=vec4(minz,maxz,0.,0.);} +#elif defined(MAIN) +uniform vec2 texSize;void main(void) +{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);} +#elif defined(ONEBEFORELAST) +uniform ivec2 texSize;void main(void) +{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);} +#elif defined(LAST) +void main(void) +{glFragColor=vec4(0.);if (true) { +discard;}} +#endif +`;E.ShadersStore[iT]||(E.ShadersStore[iT]=dN);S5={name:iT,shader:dN}});var mN,Do,T5,A5,Fs,Ep,pN=C(()=>{dt();rl();gt();(function(s){s[s.NormalizedViewDepth=0]="NormalizedViewDepth",s[s.ViewDepth=1]="ViewDepth",s[s.ScreenDepth=2]="ScreenDepth"})(mN||(mN={}));Do=class s extends _i{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.resolve().then(()=>(tT(),hN)))):t.push(Promise.resolve().then(()=>(rT(),uN)))}constructor(e,t=null,i="",r){super({...r,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:s.FragmentUrl,uniforms:s.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)}};Do.FragmentUrl="minmaxRedux";Do.Uniforms=["texSize"];T5=new Float32Array(4),A5=new Uint8Array(4),Fs={min:0,max:0},Ep=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 Q,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?T5:A5;this._scene.getEngine()._readTexturePixels(e,1,1,-1,0,i,!1),Fs.min=i[0],Fs.max=i[1],t||(Fs.min=Fs.min/255,Fs.max=Fs.max/255),Fs.min>=Fs.max&&(Fs.min=0,Fs.max=1),this.onAfterReductionPerformed.notifyObservers(Fs)}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 Do("Reduction phase "+n,e.getEngine(),"#define "+(t==1&&i==1?"LAST":t==1||i==1?"ONEBEFORELAST":"MAIN"));a.textureWidth=t,a.textureHeight=i,this.reductionSteps.push(a),n++}}}});var vp,_N=C(()=>{Kn();uu();pN();rT();tT();vp=class{get onAfterReductionPerformed(){return this._thinMinMaxReducer.onAfterReductionPerformed}constructor(e){this._onAfterUnbindObserver=null,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Yn(e.getScene()),this._thinMinMaxReducer=new Ep(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 n=this._thinMinMaxReducer.reductionSteps;for(let a=0;a{c.setTexture("textureSampler",this._sourceTexture)})),a===n.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{cN();_N();Sp=class extends vp{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 cf(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 EN,R5,ti,ff,Tp,ws,vN=C(()=>{Ee();ja();Ci();gp();eo();gN();We();gt();fh();EN=S.Up(),R5=S.Zero(),ti=new S,ff=new S,Tp=new H,ws=class s extends Ct{_validateFilter(e){return e===Ct.FILTER_NONE||e===Ct.FILTER_PCF||e===Ct.FILTER_PCSS?e:(X.Error('Unsupported filter "'+e+'"!'),Ct.FILTER_NONE)}get numCascades(){return this._numCascades}set numCascades(e){e=Math.min(Math.max(e,s.MIN_CASCADES_COUNT),s.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 s.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,n=i.max;r>=n&&(r=0,n=1),(r!=this._minDistance||n!=this._maxDistance)&&this.setMinMaxDistance(r,n)}),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,n=this._minDistance,a=this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance,o=t+n*r,l=t+a*r,c=l-o,f=l/o;for(let h=0;ha||(!this._depthClamp||this.filter===Ct.FILTER_PCSS?(n=Math.min(n,l),this.filter!==Ct.FILTER_PCSS&&(a=Math.min(a,c))):(a=Math.min(a,c),n=Math.max(n,l),a=Math.max(n+1,a))),H.OrthoOffCenterLHToRef(this._cascadeMinExtents[r].x,this._cascadeMaxExtents[r].x,this._cascadeMinExtents[r].y,this._cascadeMaxExtents[r].y,i?a:n,i?n:a,this._projectionMatrices[r],e.getEngine().isNDCHalfZRange),this._cascadeMinExtents[r].z=n,this._cascadeMaxExtents[r].z=a,this._viewMatrices[r].multiplyToRef(this._projectionMatrices[r],this._transformMatrices[r]),S.TransformCoordinatesToRef(R5,this._transformMatrices[r],ti),ti.scaleInPlace(this._mapSize/2),ff.copyFromFloats(Math.round(ti.x),Math.round(ti.y),Math.round(ti.z)),ff.subtractInPlace(ti).scaleInPlace(2/this._mapSize),H.TranslationToRef(ff.x,ff.y,0,Tp),this._projectionMatrices[r].multiplyToRef(Tp,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,n=this._scene.getEngine().isNDCHalfZRange;t.getViewMatrix();let a=t.maxZ===0,o=t.maxZ;a&&(t.maxZ=this._shadowMaxZ,t.getProjectionMatrix(!0));let l=H.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===Ct.FILTER_PCF&&e.setColorWrite(!1),is.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!==Ct.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 n=this._getCamera();n&&this._shadowMaxZ<=(n.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 n=this._getCamera();if(!n)return;let a=this.getShadowMap();if(!a)return;let o=a.getSize().width,l=this._transformMatricesAsArray,c=r.floatingOriginMode?zC(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===Ct.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o,1/o,this.frustumEdgeFalloff,e);else if(this._filter===Ct.FILTER_PCSS){for(let f=0;fnew s(r,n,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}};ws._FrustumCornersNdcSpace=[new S(-1,1,-1),new S(1,1,-1),new S(1,-1,-1),new S(-1,-1,-1),new S(-1,1,1),new S(1,1,1),new S(1,-1,1),new S(-1,-1,1)];ws.CLASSNAME="CascadedShadowGenerator";ws.DEFAULT_CASCADES_COUNT=4;ws.MIN_CASCADES_COUNT=2;ws.MAX_CASCADES_COUNT=4;ws._SceneComponentInitialization=s=>{throw Ce("ShadowGeneratorSceneComponent")}});function Ap(s,e){x5[s]=e}var x5,sT=C(()=>{x5={}});var nT,SN=C(()=>{gp();vN();dc();sT();Ap(Pe.NAME_SHADOWGENERATOR,(s,e)=>{if(s.shadowGenerators!==void 0&&s.shadowGenerators!==null)for(let t=0,i=s.shadowGenerators.length;t{let e=s._getComponent(Pe.NAME_SHADOWGENERATOR);e||(e=new nT(s),s._addComponent(e))}});async function TN(s,e){let t=e.method||"GET";return await new Promise((i,r)=>{let n=new mi;n.addEventListener("readystatechange",()=>{if(n.readyState==4)if(n.status==200){let a={};if(e.responseHeaders)for(let o of e.responseHeaders)a[o]=n.getResponseHeader(o)||"";i({response:n.response,headerValues:a})}else r(`Unable to fetch data from ${s}. Error code: ${n.status}`)}),n.open(t,s),n.send()})}var AN=C(()=>{sc()});var pT={};Ie(pT,{AppendSceneAsync:()=>yN,GetRegisteredSceneLoaderPluginMetadata:()=>O5,ImportAnimationsAsync:()=>NN,ImportMeshAsync:()=>dT,LoadAssetContainerAsync:()=>PN,LoadSceneAsync:()=>bN,RegisterSceneLoaderPlugin:()=>Ea,SceneLoader:()=>ar,SceneLoaderAnimationGroupLoadingMode:()=>oT,appendSceneAsync:()=>F5,importAnimationsAsync:()=>B5,loadAssetContainerAsync:()=>w5,loadSceneAsync:()=>N5,registerSceneLoaderPlugin:()=>L5});function I5(s){return!!s.createPlugin}function C5(s){return!!s.name}function Rp(){return Bs[".babylon"]}function b5(s){for(let e in Bs){let t=Bs[e];if(t.mimeType===s)return t}}function lT(s,e){let t=Bs[s];return t||(X.Warn("Unable to find a plugin to load "+s+" 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?Rp():void 0)}function M5(s){return!!Bs[s]}function y5(s){for(let e in Bs){let t=Bs[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(s))return Bs[e]}return Rp()}function D5(s){let e=s.indexOf("?");e!==-1&&(s=s.substring(0,e));let t=s.lastIndexOf(".");return s.substring(t,s.length).toLowerCase()}function P5(s){return s.substring(0,5)==="data:"?s.substring(5):null}function cT(s,e,t){let r="Unable to load from "+(s.rawData?"binary data":s.url);return e?r+=`: ${e}`:t&&(r+=`: ${t}`),r}async function fT(s,e,t,i,r,n,a,o,l){var u;let c=P5(s.url);if(s.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";let f=!c&&!a?D5(s.url):"",h=a?lT(a,!0):c?y5(s.url):lT(f,!1);if(!h&&f){if(s.url&&!s.url.startsWith("blob:")){let m=await TN(s.url,{method:"HEAD",responseHeaders:["Content-Type"]}),p=m.headerValues?m.headerValues["Content-Type"]:"";p&&(h=b5(p))}h||(h=Rp())}if(!h)throw new Error(`No plugin or fallback for ${a!=null?a:s.url}`);if(((u=l==null?void 0:l[h.plugin.name])==null?void 0:u.enabled)===!1)throw new Error(`The '${h.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(s.rawData&&!h.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(m=>{if(I5(h.plugin)){let _=h.plugin.createPlugin(l!=null?l:{});return _ instanceof Promise?(_.then(m).catch(g=>{r("Error instantiating plugin.",g)}),null):(m(_),_)}else return m(h.plugin),h.plugin})(m=>{var A;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(RN.notifyObservers(m),c&&(m.canDirectLoad&&m.canDirectLoad(s.url)||!Ga(s.url))){if(m.directLoad){let R=m.directLoad(e,c);R instanceof Promise?R.then(P=>{t(m,P)}).catch(P=>{r("Error in directLoad of _loadData: "+P,P)}):t(m,R)}else t(m,c);return}let p=h.isBinary,_=(R,P)=>{if(e.isDisposed){r("Scene has been disposed");return}t(m,R,P)},g=null,v=!1;(A=m.onDisposeObservable)==null||A.add(()=>{v=!0,g&&(g.abort(),g=null),n()});let I=()=>{if(v)return;let R=(P,D)=>{r(P==null?void 0:P.statusText,D)};if(!m.loadFile&&s.rawData)throw"Plugin does not support loading ArrayBufferView.";g=m.loadFile?m.loadFile(e,s.rawData||s.file||s.url,s.rootUrl,_,i,p,R,o):e._loadFile(s.file||s.url,_,i,!0,p,R)},x=e.getEngine(),T=x.enableOfflineSupport;if(T){let R=!1;for(let P of e.disableOfflineSupportExceptionRules)if(P.test(s.url)){R=!0;break}T=!R}T&&he.OfflineProviderFactory?e.offlineProvider=he.OfflineProviderFactory(s.url,I,x.disableManifestCheck):I()})}function hT(s,e){let t,i,r=null,n=null;if(!e)t=s,i=se.GetFilename(s),s=se.GetFolderPath(s);else if(C5(e))t=`file:${e.name}`,i=e.name,r=e;else if(ArrayBuffer.isView(e))t="",i=Js(),n=e;else if(e.startsWith("data:"))t=e,i="";else if(s){let a=e;if(a.substring(0,1)==="/")return se.Error("Wrong sceneFilename parameter"),null;t=s+a,i=a}else t=e,i=se.GetFilename(e),s=se.GetFolderPath(e);return{url:t,rootUrl:s,name:i,file:r,rawData:n}}function Ea(s){if(typeof s.extensions=="string"){let e=s.extensions;Bs[e.toLowerCase()]={plugin:s,isBinary:!1}}else{let e=s.extensions,t=Object.keys(e);for(let i of t)Bs[i.toLowerCase()]={plugin:s,isBinary:e[i].isBinary,mimeType:e[i].mimeType}}}function L5(s){Ea(s)}function O5(){return Array.from(Object.entries(Bs).reduce((s,[e,t])=>{let i=s.get(t.plugin.name);return i||s.set(t.plugin.name,i=[]),i.push({extension:e,isBinary:t.isBinary,mimeType:t.mimeType}),s},new Map)).map(([s,e])=>({name:s,extensions:e}))}async function dT(s,e,t){let{meshNames:i,rootUrl:r="",onProgress:n,pluginExtension:a,name:o,pluginOptions:l}=t!=null?t:{};return await IN(i,r,s,e,n,a,o,l)}async function xN(s,e,t="",i=ue.LastCreatedScene,r=null,n=null,a=null,o=null,l="",c={}){if(!i)return X.Error("No scene available to import mesh to"),null;let f=hT(e,t);if(!f)return null;let h={};i.addPendingData(h);let d=()=>{i.removePendingData(h)},u=(_,g)=>{let v=cT(f,_,g);a?a(i,v,new gr(v,qr.SceneLoaderError,g)):X.Error(v),d()},m=n?_=>{try{n(_)}catch(g){u("Error in onProgress callback: "+g,g)}}:void 0,p=(_,g,v,I,x,T,A,R)=>{if(i.importedMeshesFiles.push(f.url),r)try{r(_,g,v,I,x,T,A,R)}catch(P){u("Error in onSuccess callback: "+P,P)}i.removePendingData(h)};return await fT(f,i,(_,g,v)=>{if(_.rewriteRootURL&&(f.rootUrl=_.rewriteRootURL(f.rootUrl,v)),_.importMesh){let I=_,x=[],T=[],A=[];if(!I.importMesh(s,i,g,f.rootUrl,x,T,A,u))return;i.loadingPluginName=_.name,p(x,T,A,[],[],[],[],[])}else _.importMeshAsync(s,i,g,f.rootUrl,m,f.name).then(x=>{i.loadingPluginName=_.name,p(x.meshes,x.particleSystems,x.skeletons,x.animationGroups,x.transformNodes,x.geometries,x.lights,x.spriteManagers)}).catch(x=>{u(x.message,x)})},m,u,d,o,l,c)}async function IN(s,e,t,i,r,n,a,o){return await new Promise((l,c)=>{try{xN(s,e,t,i,(f,h,d,u,m,p,_,g)=>{l({meshes:f,particleSystems:h,skeletons:d,animationGroups:u,transformNodes:m,geometries:p,lights:_,spriteManagers:g})},r,(f,h,d)=>{c(d||new Error(h))},n,a,o).catch(c)}catch(f){c(f)}})}async function CN(s,e="",t=ue.LastCreatedEngine,i=null,r=null,n=null,a=null,o="",l={}){if(!t){se.Error("No engine available");return}await uT(s,e,new nt(t),i,r,n,a,o,l)}async function bN(s,e,t){let{rootUrl:i="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=t!=null?t:{};return await MN(i,s,e,r,n,a,o)}async function N5(s,e,t){return await bN(s,e,t)}async function MN(s,e,t,i,r,n,a){return await new Promise((o,l)=>{CN(s,e,t,c=>{o(c)},i,(c,f,h)=>{l(h||new Error(f))},r,n,a)})}async function uT(s,e="",t=ue.LastCreatedScene,i=null,r=null,n=null,a=null,o="",l={}){if(!t)return X.Error("No scene available to append to"),null;let c=hT(s,e);if(!c)return null;let f={};t.addPendingData(f);let h=()=>{t.removePendingData(f)};gi.ShowLoadingScreen&&!aT&&(aT=!0,t.getEngine().displayLoadingUI(),t.executeWhenReady(()=>{t.getEngine().hideLoadingUI(),aT=!1}));let d=(p,_)=>{let g=cT(c,p,_);n?n(t,g,new gr(g,qr.SceneLoaderError,_)):X.Error(g),h()},u=r?p=>{try{r(p)}catch(_){d("Error in onProgress callback",_)}}:void 0,m=()=>{if(i)try{i(t)}catch(p){d("Error in onSuccess callback",p)}t.removePendingData(f)};return await fT(c,t,(p,_)=>{if(p.load){if(!p.load(t,_,c.rootUrl,d))return;t.loadingPluginName=p.name,m()}else p.loadAsync(t,_,c.rootUrl,u,c.name).then(()=>{t.loadingPluginName=p.name,m()}).catch(v=>{d(v.message,v)})},u,d,h,a,o,l)}async function yN(s,e,t){let{rootUrl:i="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=t!=null?t:{};await DN(i,s,e,r,n,a,o)}async function F5(s,e,t){return await yN(s,e,t)}async function DN(s,e,t,i,r,n,a){return await new Promise((o,l)=>{try{uT(s,e,t,c=>{o(c)},i,(c,f,h)=>{l(h||new Error(f))},r,n,a).catch(l)}catch(c){l(c)}})}async function mT(s,e="",t=ue.LastCreatedScene,i=null,r=null,n=null,a=null,o="",l={}){if(!t)return X.Error("No scene available to load asset container to"),null;let c=hT(s,e);if(!c)return null;let f={};t.addPendingData(f);let h=()=>{t.removePendingData(f)},d=(p,_)=>{let g=cT(c,p,_);n?n(t,g,new gr(g,qr.SceneLoaderError,_)):X.Error(g),h()},u=r?p=>{try{r(p)}catch(_){d("Error in onProgress callback",_)}}:void 0,m=p=>{if(i)try{i(p)}catch(_){d("Error in onSuccess callback",_)}t.removePendingData(f)};return await fT(c,t,(p,_)=>{if(p.loadAssetContainer){let v=p.loadAssetContainer(t,_,c.rootUrl,d);if(!v)return;v.populateRootNodes(),t.loadingPluginName=p.name,m(v)}else p.loadAssetContainerAsync?p.loadAssetContainerAsync(t,_,c.rootUrl,u,c.name).then(v=>{v.populateRootNodes(),t.loadingPluginName=p.name,m(v)}).catch(v=>{d(v.message,v)}):d("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},u,d,h,a,o,l)}async function PN(s,e,t){let{rootUrl:i="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=t!=null?t:{};return await LN(i,s,e,r,n,a,o)}async function w5(s,e,t){return await PN(s,e,t)}async function LN(s,e,t,i,r,n,a){return await new Promise((o,l)=>{try{mT(s,e,t,c=>{o(c)},i,(c,f,h)=>{l(h||new Error(f))},r,n,a).catch(l)}catch(c){l(c)}})}async function ON(s,e="",t=ue.LastCreatedScene,i=!0,r=0,n=null,a=null,o=null,l=null,c=null,f="",h={}){if(!t){X.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:X.Error("Unknown animation group loading mode value '"+r+"'");return}let d=t.animatables.length;await mT(s,e,t,m=>{m.mergeAnimationsTo(t,t.animatables.slice(d),n),m.dispose(),t.onAnimationFileImportedObservable.notifyObservers(t),a&&a(t)},o,l,c,f,h)}async function NN(s,e,t){let{rootUrl:i="",overwriteAnimations:r,animationGroupLoadingMode:n,targetConverter:a,onProgress:o,pluginExtension:l,name:c,pluginOptions:f}=t!=null?t:{};await FN(i,s,e,r,n,a,o,l,c,f)}async function B5(s,e,t){return await NN(s,e,t)}async function FN(s,e,t,i,r,n,a,o,l,c){return await new Promise((f,h)=>{try{ON(s,e,t,i,r,n,d=>{f(d)},a,(d,u,m)=>{h(m||new Error(u))},o,l,c).catch(h)}catch(d){h(d)}})}var oT,RN,Bs,aT,ar,Rn=C(()=>{At();dt();vr();gt();We();ju();Wa();Jf();rc();ci();AN();(function(s){s[s.Clean=0]="Clean",s[s.Stop=1]="Stop",s[s.Sync=2]="Sync",s[s.NoSync=3]="NoSync"})(oT||(oT={}));RN=new Q,Bs={},aT=!1;ar=class{static get ForceFullSceneLoadingForIncremental(){return gi.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){gi.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return gi.ShowLoadingScreen}static set ShowLoadingScreen(e){gi.ShowLoadingScreen=e}static get loggingLevel(){return gi.loggingLevel}static set loggingLevel(e){gi.loggingLevel=e}static get CleanBoneMatrixWeights(){return gi.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){gi.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return Rp()}static GetPluginForExtension(e){var t;return(t=lT(e,!0))==null?void 0:t.plugin}static IsPluginForExtensionAvailable(e){return M5(e)}static RegisterPlugin(e){Ea(e)}static ImportMesh(e,t,i,r,n,a,o,l,c,f){xN(e,t,i,r,n,a,o,l,c,f).catch(h=>o==null?void 0:o(ue.LastCreatedScene,h==null?void 0:h.message,h))}static async ImportMeshAsync(e,t,i,r,n,a,o){return await IN(e,t,i,r,n,a,o)}static Load(e,t,i,r,n,a,o,l){CN(e,t,i,r,n,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,n,a){return await MN(e,t,i,r,n,a)}static Append(e,t,i,r,n,a,o,l){uT(e,t,i,r,n,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,n,a){return await DN(e,t,i,r,n,a)}static LoadAssetContainer(e,t,i,r,n,a,o,l){mT(e,t,i,r,n,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,n,a){return await LN(e,t,i,r,n,a)}static ImportAnimations(e,t,i,r,n,a,o,l,c,f,h){ON(e,t,i,r,n,a,o,l,c,f,h).catch(d=>c==null?void 0:c(i!=null?i:ue.LastCreatedScene,d==null?void 0:d.message,d))}static async ImportAnimationsAsync(e,t,i,r,n,a,o,l,c,f,h){return await FN(e,t,i,r,n,a,l,f,h)}};ar.NO_LOGGING=0;ar.MINIMAL_LOGGING=1;ar.SUMMARY_LOGGING=2;ar.DETAILED_LOGGING=3;ar.OnPluginActivatedObservable=RN});var _T,xp,wN=C(()=>{Ba();rc();Ya();gt();_T=class{constructor(){this.mm=new Map}get(e,t){let i=this.mm.get(e);if(i!==void 0)return i.get(t)}set(e,t,i){let r=this.mm.get(e);r===void 0&&this.mm.set(e,r=new Map),r.set(t,i)}},xp=class{get standalone(){var e,t;return(t=(e=this._options)==null?void 0:e.standalone)!=null?t:!1}get baseMaterial(){return this._baseMaterial}get doNotInjectCode(){var e,t;return(t=(e=this._options)==null?void 0:e.doNotInjectCode)!=null?t:!1}constructor(e,t,i){this._baseMaterial=e,this._scene=t!=null?t:ue.LastCreatedScene,this._options=i,this._subMeshToEffect=new Map,this._subMeshToDepthWrapper=new _T,this._meshes=new Map,this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add(r=>{var a,o;let n=(a=r.subMesh)==null?void 0:a.getMesh();n&&!this._meshes.has(n)&&this._meshes.set(n,n.onDisposeObservable.add(l=>{let c=this._subMeshToEffect.keys();for(let f=c.next();f.done!==!0;f=c.next()){let h=f.value;(h==null?void 0:h.getMesh())===l&&(this._subMeshToEffect.delete(h),this._deleteDepthWrapperEffect(h))}})),((o=this._subMeshToEffect.get(r.subMesh))==null?void 0:o[0])!==r.effect&&(this._subMeshToEffect.set(r.subMesh,[r.effect,this._scene.getEngine().currentRenderPassId]),this._deleteDepthWrapperEffect(r.subMesh))})}_deleteDepthWrapperEffect(e){let t=this._subMeshToDepthWrapper.mm.get(e);t&&(t.forEach(i=>{var r;(r=i.mainDrawWrapper.effect)==null||r.dispose()}),this._subMeshToDepthWrapper.mm.delete(e))}getEffect(e,t,i){var a;let r=(a=this._subMeshToDepthWrapper.mm.get(e))==null?void 0:a.get(t);if(!r)return null;let n=r.drawWrapper[i];return n||(n=r.drawWrapper[i]=new yi(this._scene.getEngine()),n.setEffect(r.mainDrawWrapper.effect,r.mainDrawWrapper.defines)),n}isReadyForSubMesh(e,t,i,r,n){var a,o;return this.standalone&&!this._baseMaterial.isReadyForSubMesh(e.getMesh(),e,r)?!1:(o=(a=this._makeEffect(e,t,i,n))==null?void 0:a.isReady())!=null?o:!1}dispose(){this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),this._onEffectCreatedObserver=null;let e=this._meshes.entries();for(let t=e.next();t.done!==!0;t=e.next()){let[i,r]=t.value;i.onDisposeObservable.remove(r)}}_makeEffect(e,t,i,r){var m,p;let n=this._scene.getEngine(),a=this._subMeshToEffect.get(e);if(!a)return null;let[o,l]=a;if(!o.isReady())return null;let c=this._subMeshToDepthWrapper.get(e,i);if(!c){let _=new yi(n),g=(m=e._getDrawWrapper(l))==null?void 0:m.defines;_.defines=typeof g=="string"?null:g!=null?g:null,c={drawWrapper:[],mainDrawWrapper:_,depthDefines:"",token:Js()},c.drawWrapper[r]=_,this._subMeshToDepthWrapper.set(e,i,c)}let f=t.join(` +`);if(c.mainDrawWrapper.effect&&f===c.depthDefines)return c.mainDrawWrapper.effect;c.depthDefines=f;let h=o.getUniformNames().slice(),d=o.vertexSourceCodeBeforeMigration,u=o.fragmentSourceCodeBeforeMigration;if(!d&&!u)return null;if(!this.doNotInjectCode){let _=this._options&&this._options.remappedVariables?`#include(${this._options.remappedVariables.join(",")})`:"#include",g=this._options&&this._options.remappedVariables?`#include(${this._options.remappedVariables.join(",")})`:"#include",v=this._options&&this._options.remappedVariables?`#include(${this._options.remappedVariables.join(",")})`:"#include",I="#include",x="#include";o.shaderLanguage===0?d=d.replace(/void\s+?main/g,` +${x} +void main`):d=d.replace(/@vertex/g,` +${x} +@vertex`),d=d.replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,_),d.indexOf("#define SHADOWDEPTH_METRIC")!==-1?d=d.replace(/#define SHADOWDEPTH_METRIC/g,g):d=d.replace(/}\s*$/g,g+` +}`),d=d.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");let T=u.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||u.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,A=u.indexOf("#define SHADOWDEPTH_FRAGMENT")!==-1,R="";T?u=u.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,v):R=v+` +`,u=u.replace(/void\s+?main/g,wt.IncludesShadersStore.shadowMapFragmentExtraDeclaration+` +void main`),A?u=u.replace(/#define SHADOWDEPTH_FRAGMENT/g,I):R+=I+` +`,R&&(u=u.replace(/}\s*$/g,R+"}")),h.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM")}c.mainDrawWrapper.effect=n.createEffect({vertexSource:d,fragmentSource:u,vertexToken:c.token,fragmentToken:c.token},{attributes:o.getAttributesNames(),uniformsNames:h,uniformBuffersNames:o.getUniformBuffersNames(),samplers:o.getSamplers(),defines:f+` +`+o.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:o.getIndexParameters(),shaderLanguage:o.shaderLanguage},n);for(let _=0;_{w();Uh();Qc();BN="gaussianSplattingFragmentDeclaration",U5=`vec4 gaussianColor(vec4 inColor) +{float A=-dot(vPosition,vPosition);if (A<-4.0) discard;float B=exp(A)*inColor.a; +#include +vec3 color=inColor.rgb; +#ifdef FOG +#include +#endif +return vec4(color,B);} +`;E.IncludesShadersStore[BN]||(E.IncludesShadersStore[BN]=U5)});var GN={};Ie(GN,{gaussianSplattingPixelShader:()=>V5});var gT,VN,V5,ET=C(()=>{w();vn();ga();qc();UN();Sn();gT="gaussianSplattingPixelShader",VN=`#include +#include +#include +varying vec4 vColor;varying vec2 vPosition; +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +void main () { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +vec4 finalColor=gaussianColor(vColor); +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +gl_FragColor=finalColor; +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStore[gT]||(E.ShadersStore[gT]=VN);V5={name:gT,shader:VN}});var kN,G5,Ip=C(()=>{w();kN="gaussianSplattingVertexDeclaration",G5="attribute vec3 position;attribute vec4 splatIndex0;attribute vec4 splatIndex1;attribute vec4 splatIndex2;attribute vec4 splatIndex3;uniform mat4 view;uniform mat4 projection;uniform mat4 world;uniform vec4 vEyePosition;";E.IncludesShadersStore[kN]||(E.IncludesShadersStore[kN]=G5)});var WN,k5,Cp=C(()=>{w();Io();of();WN="gaussianSplattingUboDeclaration",k5=`#include +#include +attribute vec3 position;attribute vec4 splatIndex0;attribute vec4 splatIndex1;attribute vec4 splatIndex2;attribute vec4 splatIndex3; +`;E.IncludesShadersStore[WN]||(E.IncludesShadersStore[WN]=k5)});var HN,W5,bp=C(()=>{w();HN="gaussianSplatting",W5=`#if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE) +mat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0], +matrix[0][1],matrix[1][1],matrix[2][1], +matrix[0][2],matrix[1][2],matrix[2][2]);} +#endif +vec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);} +#if SH_DEGREE>0 || IS_COMPOUND +ivec2 getDataUVint(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return ivec2(uint(x+0.5),uint(y+0.5));} +#endif +struct Splat {vec4 center;vec4 color;vec4 covA;vec4 covB; +#if SH_DEGREE>0 +uvec4 sh0; +#endif +#if SH_DEGREE>1 +uvec4 sh1; +#endif +#if SH_DEGREE>2 +uvec4 sh2; +#endif +#if SH_DEGREE>3 +uvec4 sh3;uvec4 sh4; +#endif +#if IS_COMPOUND +uint partIndex; +#endif +#if defined(IS_FOR_VOXELIZATION) +vec4 rotationA;vec4 rotationB;vec4 rotationScale; +#endif +};float getSplatIndex(int localIndex) +{float splatIndex;switch (localIndex) +{case 0: splatIndex=splatIndex0.x; break;case 1: splatIndex=splatIndex0.y; break;case 2: splatIndex=splatIndex0.z; break;case 3: splatIndex=splatIndex0.w; break;case 4: splatIndex=splatIndex1.x; break;case 5: splatIndex=splatIndex1.y; break;case 6: splatIndex=splatIndex1.z; break;case 7: splatIndex=splatIndex1.w; break;case 8: splatIndex=splatIndex2.x; break;case 9: splatIndex=splatIndex2.y; break;case 10: splatIndex=splatIndex2.z; break;case 11: splatIndex=splatIndex2.w; break;case 12: splatIndex=splatIndex3.x; break;case 13: splatIndex=splatIndex3.y; break;case 14: splatIndex=splatIndex3.z; break;case 15: splatIndex=splatIndex3.w; break;} +return splatIndex;} +Splat readSplat(float splatIndex) +{Splat splat;vec2 splatUV=getDataUV(splatIndex,dataTextureSize);splat.center=texture2D(centersTexture,splatUV);splat.color=texture2D(colorsTexture,splatUV); +#if !defined(IS_FOR_VOXELIZATION) +splat.covA=texture2D(covariancesATexture,splatUV)*splat.center.w;splat.covB=texture2D(covariancesBTexture,splatUV)*splat.center.w; +#endif +#if SH_DEGREE>0 || IS_COMPOUND +ivec2 splatUVint=getDataUVint(splatIndex,dataTextureSize); +#endif +#if SH_DEGREE>0 +splat.sh0=texelFetch(shTexture0,splatUVint,0); +#endif +#if SH_DEGREE>1 +splat.sh1=texelFetch(shTexture1,splatUVint,0); +#endif +#if SH_DEGREE>2 +splat.sh2=texelFetch(shTexture2,splatUVint,0); +#endif +#if SH_DEGREE>3 +splat.sh3=texelFetch(shTexture3,splatUVint,0);splat.sh4=texelFetch(shTexture4,splatUVint,0); +#endif +#if IS_COMPOUND +splat.partIndex=uint(texture2D(partIndicesTexture,splatUV).r*255.0+0.5); +#endif +#if defined(IS_FOR_VOXELIZATION) +splat.rotationA=texture2D(rotationsATexture,splatUV);splat.rotationB=texture2D(rotationsBTexture,splatUV);splat.rotationScale=texture2D(rotationScaleTexture,splatUV); +#endif +return splat;} +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +vec3 computeColorFromSHDegree(vec3 dir,const vec3 sh[25]) +{const float SH_C0=0.28209479;const float SH_C1=0.48860251;float SH_C2[5];SH_C2[0]=1.092548430;SH_C2[1]=-1.09254843;SH_C2[2]=0.315391565;SH_C2[3]=-1.09254843;SH_C2[4]=0.546274215;float SH_C3[7];SH_C3[0]=-0.59004358;SH_C3[1]=2.890611442;SH_C3[2]=-0.45704579;SH_C3[3]=0.373176332;SH_C3[4]=-0.45704579;SH_C3[5]=1.445305721;SH_C3[6]=-0.59004358;float SH_C4[9];SH_C4[0]= 2.5033429418;SH_C4[1]=-1.7701307698;SH_C4[2]= 0.9461746958;SH_C4[3]=-0.6690465436;SH_C4[4]= 0.1057855469;SH_C4[5]=-0.6690465436;SH_C4[6]= 0.4730873479;SH_C4[7]=-1.7701307698;SH_C4[8]= 0.6258357354;vec3 result=/*SH_C0**/sh[0]; +#if SH_DEGREE>0 +float x=dir.x;float y=dir.y;float z=dir.z;result+=- SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3]; +#if SH_DEGREE>1 +float xx=x*x,yy=y*y,zz=z*z;float xy=x*y,yz=y*z,xz=x*z;result+= +SH_C2[0]*xy*sh[4] + +SH_C2[1]*yz*sh[5] + +SH_C2[2]*(2.0*zz-xx-yy)*sh[6] + +SH_C2[3]*xz*sh[7] + +SH_C2[4]*(xx-yy)*sh[8]; +#if SH_DEGREE>2 +result+= +SH_C3[0]*y*(3.0*xx-yy)*sh[9] + +SH_C3[1]*xy*z*sh[10] + +SH_C3[2]*y*(4.0*zz-xx-yy)*sh[11] + +SH_C3[3]*z*(2.0*zz-3.0*xx-3.0*yy)*sh[12] + +SH_C3[4]*x*(4.0*zz-xx-yy)*sh[13] + +SH_C3[5]*z*(xx-yy)*sh[14] + +SH_C3[6]*x*(xx-3.0*yy)*sh[15]; +#if SH_DEGREE>3 +result += +SH_C4[0]*x*y*(xx-yy)*sh[16] + +SH_C4[1]*y*z*(3.0*xx-yy)*sh[17] + +SH_C4[2]*x*y*(7.0*zz-1.0)*sh[18] + +SH_C4[3]*y*z*(7.0*zz-3.0)*sh[19] + +SH_C4[4]*(zz*(35.0*zz-30.0)+3.0)*sh[20] + +SH_C4[5]*x*z*(7.0*zz-3.0)*sh[21] + +SH_C4[6]*(xx-yy)*(7.0*zz-1.0)*sh[22] + +SH_C4[7]*x*z*(xx-3.0*yy)*sh[23] + +SH_C4[8]*(xx*(xx-3.0*yy)-yy*(3.0*xx-yy))*sh[24]; +#endif +#endif +#endif +#endif +return result;} +vec4 decompose(uint value) +{vec4 components=vec4( +float((value ) & 255u), +float((value>>uint( 8)) & 255u), +float((value>>uint(16)) & 255u), +float((value>>uint(24)) & 255u));return components*vec4(2./255.)-vec4(1.);} +vec3 computeSH(Splat splat,vec3 dir) +{vec3 sh[25];sh[0]=vec3(0.,0.,0.); +#if SH_DEGREE>0 +vec4 sh00=decompose(splat.sh0.x);vec4 sh01=decompose(splat.sh0.y);vec4 sh02=decompose(splat.sh0.z);sh[1]=vec3(sh00.x,sh00.y,sh00.z);sh[2]=vec3(sh00.w,sh01.x,sh01.y);sh[3]=vec3(sh01.z,sh01.w,sh02.x); +#endif +#if SH_DEGREE>1 +vec4 sh03=decompose(splat.sh0.w);vec4 sh04=decompose(splat.sh1.x);vec4 sh05=decompose(splat.sh1.y);sh[4]=vec3(sh02.y,sh02.z,sh02.w);sh[5]=vec3(sh03.x,sh03.y,sh03.z);sh[6]=vec3(sh03.w,sh04.x,sh04.y);sh[7]=vec3(sh04.z,sh04.w,sh05.x);sh[8]=vec3(sh05.y,sh05.z,sh05.w); +#endif +#if SH_DEGREE>2 +vec4 sh06=decompose(splat.sh1.z);vec4 sh07=decompose(splat.sh1.w);vec4 sh08=decompose(splat.sh2.x);vec4 sh09=decompose(splat.sh2.y);vec4 sh10=decompose(splat.sh2.z);vec4 sh11=decompose(splat.sh2.w);sh[9]=vec3(sh06.x,sh06.y,sh06.z);sh[10]=vec3(sh06.w,sh07.x,sh07.y);sh[11]=vec3(sh07.z,sh07.w,sh08.x);sh[12]=vec3(sh08.y,sh08.z,sh08.w);sh[13]=vec3(sh09.x,sh09.y,sh09.z);sh[14]=vec3(sh09.w,sh10.x,sh10.y);sh[15]=vec3(sh10.z,sh10.w,sh11.x); +#endif +#if SH_DEGREE>3 +vec4 sh12=decompose(splat.sh3.x);vec4 sh13=decompose(splat.sh3.y);vec4 sh14=decompose(splat.sh3.z);vec4 sh15=decompose(splat.sh3.w);vec4 sh16=decompose(splat.sh4.x);vec4 sh17=decompose(splat.sh4.y);sh[16]=vec3(sh11.y,sh11.z,sh11.w);sh[17]=vec3(sh12.x,sh12.y,sh12.z);sh[18]=vec3(sh12.w,sh13.x,sh13.y);sh[19]=vec3(sh13.z,sh13.w,sh14.x);sh[20]=vec3(sh14.y,sh14.z,sh14.w);sh[21]=vec3(sh15.x,sh15.y,sh15.z);sh[22]=vec3(sh15.w,sh16.x,sh16.y);sh[23]=vec3(sh16.z,sh16.w,sh17.x);sh[24]=vec3(sh17.y,sh17.z,sh17.w); +#endif +return computeColorFromSHDegree(dir,sh);} +#else +vec3 computeSH(Splat splat,vec3 dir) +{return vec3(0.,0.,0.);} +#endif +#if !defined(IS_FOR_VOXELIZATION) +vec4 gaussianSplatting(vec2 meshPos,vec3 worldPos,vec2 scale,vec3 covA,vec3 covB,mat4 worldMatrix,mat4 viewMatrix,mat4 projectionMatrix) +{mat4 modelView=viewMatrix*worldMatrix;vec4 camspace=viewMatrix*vec4(worldPos,1.);vec4 pos2d=projectionMatrix*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds +|| pos2d.y<-bounds || pos2d.y>bounds) {return vec4(0.0,0.0,2.0,1.0);} +mat3 Vrk=mat3( +covA.x,covA.y,covA.z, +covA.y,covB.x,covB.y, +covA.z,covB.y,covB.z +);bool isOrtho=abs(projectionMatrix[3][3]-1.0)<0.001;mat3 J;if (isOrtho) {J=mat3( +focal.x,0.,0., +0.,focal.y,0., +0.,0.,0. +);} else {J=mat3( +focal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z), +0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z), +0.,0.,0. +);} +mat3 T=transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T; +#if COMPENSATION +float c00=cov2d[0][0];float c11=cov2d[1][1];float c01=cov2d[0][1];float detOrig=c00*c11-c01*c01; +#endif +cov2d[0][0]+=kernelSize;cov2d[1][1]+=kernelSize; +#if COMPENSATION +vec3 c2d=vec3(cov2d[0][0],c01,cov2d[1][1]);float detBlur=c2d.x*c2d.z-c2d.y*c2d.y;float compensation=sqrt(max(0.,detOrig/detBlur));vColor.w*=compensation; +#endif +float mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float epsilon=0.0001;float lambda1=mid+radius+epsilon,lambda2=mid-radius+epsilon;if (lambda2<0.0) +{return vec4(0.0,0.0,2.0,1.0);} +vec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vec2 vCenter=vec2(pos2d);float scaleFactor=isOrtho ? 1.0 : pos2d.w;return vec4( +vCenter ++ ((meshPos.x*majorAxis ++ meshPos.y*minorAxis)*invViewport*scaleFactor)*scale,pos2d.zw);} +#endif +#if IS_COMPOUND +mat4 getPartWorld(uint partIndex) {return partWorld[partIndex];} +#endif +#if defined(IS_FOR_VOXELIZATION) +vec4 computeVoxelSplatWorldPos(vec4 rotationA,vec4 rotationB,vec4 rotationScale,vec3 center,mat4 splatWorld,mat4 viewMatrix,mat4 invWorldScale,vec2 quadPos) {mat3 splatRotation=mat3( +vec3(rotationA.x,rotationA.y,rotationA.z), +vec3(rotationA.w,rotationB.x,rotationB.y), +vec3(rotationB.z,rotationB.w,rotationScale.x) +);vec3 splatScale=vec3(rotationScale.y,rotationScale.z,rotationScale.w);mat3 rotToView=mat3(viewMatrix)*mat3(invWorldScale)*mat3(splatWorld)*splatRotation;vec3 axisLengthInViewZ=abs(vec3(rotToView[0][2],rotToView[1][2],rotToView[2][2]));float gaussianSplatCutoffStddev=1.4142135624/2.0; +vec3 offsetSplatSpace;if (axisLengthInViewZ.x>axisLengthInViewZ.y && axisLengthInViewZ.x>axisLengthInViewZ.z) {offsetSplatSpace=vec3(0.0,quadPos.x,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else if (axisLengthInViewZ.y>axisLengthInViewZ.z) {offsetSplatSpace=vec3(quadPos.x,0.0,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else {offsetSplatSpace=vec3(quadPos.x,quadPos.y,0.0)*splatScale*gaussianSplatCutoffStddev;} +vec3 vertexObjectSpace=center+splatRotation*offsetSplatSpace;return splatWorld*vec4(vertexObjectSpace,1.0);} +#endif +`;E.IncludesShadersStore[HN]||(E.IncludesShadersStore[HN]=W5)});var XN={};Ie(XN,{gaussianSplattingVertexShader:()=>H5});var vT,zN,H5,ST=C(()=>{w();Ip();Cp();gn();jc();ga();Or();bp();En();Zc();wh();vT="gaussianSplattingVertexShader",zN=`#include<__decl__gaussianSplattingVertex> +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif +#include +#include +#include +#include +uniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform float kernelSize;uniform vec3 eyePosition;uniform float alpha; +#if IS_COMPOUND +uniform mat4 partWorld[MAX_PART_COUNT];uniform float partVisibility[MAX_PART_COUNT]; +#endif +uniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture; +#if SH_DEGREE>0 +uniform highp usampler2D shTexture0; +#endif +#if SH_DEGREE>1 +uniform highp usampler2D shTexture1; +#endif +#if SH_DEGREE>2 +uniform highp usampler2D shTexture2; +#endif +#if SH_DEGREE>3 +uniform highp usampler2D shTexture3;uniform highp usampler2D shTexture4; +#endif +#if IS_COMPOUND +uniform sampler2D partIndicesTexture; +#endif +varying vec4 vColor;varying vec2 vPosition; +#define CUSTOM_VERTEX_DEFINITIONS +#include +void main () { +#define CUSTOM_VERTEX_MAIN_BEGIN +float splatIndex=getSplatIndex(int(position.z+0.5));Splat splat=readSplat(splatIndex);vec3 covA=splat.covA.xyz;vec3 covB=vec3(splat.covA.w,splat.covB.xy); +#if IS_COMPOUND +mat4 splatWorld=getPartWorld(splat.partIndex); +#else +mat4 splatWorld=world; +#endif +vec4 worldPos=splatWorld*vec4(splat.center.xyz,1.0);vColor=splat.color;vPosition=position.xy; +#if SH_DEGREE>0 +mat3 worldRot=mat3(splatWorld);mat3 normWorldRot=inverseMat3(worldRot);vec3 eyeToSplatLocalSpace=normalize(normWorldRot*(worldPos.xyz-eyePosition));vColor.xyz=splat.color.xyz+computeSH(splat,eyeToSplatLocalSpace); +#endif +vColor.w*=alpha; +#if IS_COMPOUND +vColor.w*=partVisibility[splat.partIndex]; +#endif +vec2 scale=vec2(1.,1.); +#define CUSTOM_VERTEX_UPDATE +gl_Position=gaussianSplatting(position.xy,worldPos.xyz,scale,covA,covB,splatWorld,view,projection); +#include +#include +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStore[vT]||(E.ShadersStore[vT]=zN);H5={name:vT,shader:zN}});var YN,z5,TT=C(()=>{w();Fh();Kc();YN="gaussianSplattingFragmentDeclaration",z5=`fn gaussianColor(inColor: vec4f,inPosition: vec2f)->vec4f +{var A : f32=-dot(inPosition,inPosition);if (A>-4.0) +{var B: f32=exp(A)*inColor.a; +#include +var color: vec3f=inColor.rgb; +#ifdef FOG +#include +#endif +return vec4f(color,B);} else {return vec4f(0.0);}} +`;E.IncludesShadersStoreWGSL[YN]||(E.IncludesShadersStoreWGSL[YN]=z5)});var jN={};Ie(jN,{gaussianSplattingPixelShaderWGSL:()=>X5});var AT,KN,X5,RT=C(()=>{w();pn();_a();Yc();TT();_n();AT="gaussianSplattingPixelShader",KN=`#include +#include +#include +varying vColor: vec4f;varying vPosition: vec2f; +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +var finalColor: vec4f=gaussianColor(input.vColor,input.vPosition); +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +fragmentOutputs.color=finalColor; +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStoreWGSL[AT]||(E.ShadersStoreWGSL[AT]=KN);X5={name:AT,shader:KN}});var ZN,Y5,Mp=C(()=>{w();ZN="gaussianSplatting",Y5=`fn getDataUV(index: f32,dataTextureSize: vec2f)->vec2 {let y: f32=floor(index/dataTextureSize.x);let x: f32=index-y*dataTextureSize.x;return vec2f((x+0.5),(y+0.5));} +struct Splat {center: vec4f, +color: vec4f, +covA: vec4f, +covB: vec4f, +#if SH_DEGREE>0 +sh0: vec4, +#endif +#if SH_DEGREE>1 +sh1: vec4, +#endif +#if SH_DEGREE>2 +sh2: vec4, +#endif +#if SH_DEGREE>3 +sh3: vec4, +sh4: vec4, +#endif +#if IS_COMPOUND +partIndex: u32, +#endif +#if defined(IS_FOR_VOXELIZATION) +rotationA: vec4f, +rotationB: vec4f, +rotationScale: vec4f, +#endif +};fn getSplatIndex(localIndex: i32,splatIndex0: vec4f,splatIndex1: vec4f,splatIndex2: vec4f,splatIndex3: vec4f)->f32 {var splatIndex: f32;switch (localIndex) +{case 0: +{splatIndex=splatIndex0.x;break;} +case 1: +{splatIndex=splatIndex0.y;break;} +case 2: +{splatIndex=splatIndex0.z;break;} +case 3: +{splatIndex=splatIndex0.w;break;} +case 4: +{splatIndex=splatIndex1.x;break;} +case 5: +{splatIndex=splatIndex1.y;break;} +case 6: +{splatIndex=splatIndex1.z;break;} +case 7: +{splatIndex=splatIndex1.w;break;} +case 8: +{splatIndex=splatIndex2.x;break;} +case 9: +{splatIndex=splatIndex2.y;break;} +case 10: +{splatIndex=splatIndex2.z;break;} +case 11: +{splatIndex=splatIndex2.w;break;} +case 12: +{splatIndex=splatIndex3.x;break;} +case 13: +{splatIndex=splatIndex3.y;break;} +case 14: +{splatIndex=splatIndex3.z;break;} +default: +{splatIndex=splatIndex3.w;break;}} +return splatIndex;} +fn readSplat(splatIndex: f32,dataTextureSize: vec2f)->Splat {var splat: Splat;let splatUV=getDataUV(splatIndex,dataTextureSize);let splatUVi32=vec2(i32(splatUV.x),i32(splatUV.y));splat.center=textureLoad(centersTexture,splatUVi32,0);splat.color=textureLoad(colorsTexture,splatUVi32,0); +#if !defined(IS_FOR_VOXELIZATION) +splat.covA=textureLoad(covariancesATexture,splatUVi32,0)*splat.center.w;splat.covB=textureLoad(covariancesBTexture,splatUVi32,0)*splat.center.w; +#endif +#if SH_DEGREE>0 +splat.sh0=textureLoad(shTexture0,splatUVi32,0); +#endif +#if SH_DEGREE>1 +splat.sh1=textureLoad(shTexture1,splatUVi32,0); +#endif +#if SH_DEGREE>2 +splat.sh2=textureLoad(shTexture2,splatUVi32,0); +#endif +#if SH_DEGREE>3 +splat.sh3=textureLoad(shTexture3,splatUVi32,0);splat.sh4=textureLoad(shTexture4,splatUVi32,0); +#endif +#if IS_COMPOUND +splat.partIndex=u32(textureLoad(partIndicesTexture,splatUVi32,0).r*255.0+0.5); +#endif +#if defined(IS_FOR_VOXELIZATION) +splat.rotationA=textureLoad(rotationsATexture,splatUVi32,0);splat.rotationB=textureLoad(rotationsBTexture,splatUVi32,0);splat.rotationScale=textureLoad(rotationScaleTexture,splatUVi32,0); +#endif +return splat;} +fn computeColorFromSHDegree(dir: vec3f,sh: array,25>)->vec3f +{let SH_C0: f32=0.28209479;let SH_C1: f32=0.48860251;var SH_C2: array=array( +1.092548430, +-1.09254843, +0.315391565, +-1.09254843, +0.546274215 +);var SH_C3: array=array( +-0.59004358, +2.890611442, +-0.45704579, +0.373176332, +-0.45704579, +1.445305721, +-0.59004358 +);var SH_C4: array=array( +2.5033429418, +-1.7701307698, +0.9461746958, +-0.6690465436, +0.1057855469, +-0.6690465436, +0.4730873479, +-1.7701307698, +0.6258357354 +);var result: vec3f=/*SH_C0**/sh[0]; +#if SH_DEGREE>0 +let x: f32=dir.x;let y: f32=dir.y;let z: f32=dir.z;result+=-SH_C1*y*sh[1]+SH_C1*z*sh[2]-SH_C1*x*sh[3]; +#if SH_DEGREE>1 +let xx: f32=x*x;let yy: f32=y*y;let zz: f32=z*z;let xy: f32=x*y;let yz: f32=y*z;let xz: f32=x*z;result += +SH_C2[0]*xy*sh[4] + +SH_C2[1]*yz*sh[5] + +SH_C2[2]*(2.0f*zz-xx-yy)*sh[6] + +SH_C2[3]*xz*sh[7] + +SH_C2[4]*(xx-yy)*sh[8]; +#if SH_DEGREE>2 +result += +SH_C3[0]*y*(3.0f*xx-yy)*sh[9] + +SH_C3[1]*xy*z*sh[10] + +SH_C3[2]*y*(4.0f*zz-xx-yy)*sh[11] + +SH_C3[3]*z*(2.0f*zz-3.0f*xx-3.0f*yy)*sh[12] + +SH_C3[4]*x*(4.0f*zz-xx-yy)*sh[13] + +SH_C3[5]*z*(xx-yy)*sh[14] + +SH_C3[6]*x*(xx-3.0f*yy)*sh[15]; +#if SH_DEGREE>3 +result += +SH_C4[0]*x*y*(xx-yy)*sh[16] + +SH_C4[1]*y*z*(3.0f*xx-yy)*sh[17] + +SH_C4[2]*x*y*(7.0f*zz-1.0f)*sh[18] + +SH_C4[3]*y*z*(7.0f*zz-3.0f)*sh[19] + +SH_C4[4]*(zz*(35.0f*zz-30.0f)+3.0f)*sh[20] + +SH_C4[5]*x*z*(7.0f*zz-3.0f)*sh[21] + +SH_C4[6]*(xx-yy)*(7.0f*zz-1.0f)*sh[22] + +SH_C4[7]*x*z*(xx-3.0f*yy)*sh[23] + +SH_C4[8]*(xx*(xx-3.0f*yy)-yy*(3.0f*xx-yy))*sh[24]; +#endif +#endif +#endif +#endif +return result;} +fn decompose(value: u32)->vec4f +{let components : vec4f=vec4f( +f32((value ) & 255u), +f32((value>>u32( 8)) & 255u), +f32((value>>u32(16)) & 255u), +f32((value>>u32(24)) & 255u));return components*vec4f(2./255.)-vec4f(1.);} +fn computeSH(splat: Splat,dir: vec3f)->vec3f +{var sh: array,25>;sh[0]=vec3f(0.,0.,0.); +#if SH_DEGREE>0 +let sh00: vec4f=decompose(splat.sh0.x);let sh01: vec4f=decompose(splat.sh0.y);let sh02: vec4f=decompose(splat.sh0.z);sh[1]=vec3f(sh00.x,sh00.y,sh00.z);sh[2]=vec3f(sh00.w,sh01.x,sh01.y);sh[3]=vec3f(sh01.z,sh01.w,sh02.x); +#endif +#if SH_DEGREE>1 +let sh03: vec4f=decompose(splat.sh0.w);let sh04: vec4f=decompose(splat.sh1.x);let sh05: vec4f=decompose(splat.sh1.y);sh[4]=vec3f(sh02.y,sh02.z,sh02.w);sh[5]=vec3f(sh03.x,sh03.y,sh03.z);sh[6]=vec3f(sh03.w,sh04.x,sh04.y);sh[7]=vec3f(sh04.z,sh04.w,sh05.x);sh[8]=vec3f(sh05.y,sh05.z,sh05.w); +#endif +#if SH_DEGREE>2 +let sh06: vec4f=decompose(splat.sh1.z);let sh07: vec4f=decompose(splat.sh1.w);let sh08: vec4f=decompose(splat.sh2.x);let sh09: vec4f=decompose(splat.sh2.y);let sh10: vec4f=decompose(splat.sh2.z);let sh11: vec4f=decompose(splat.sh2.w);sh[9]=vec3f(sh06.x,sh06.y,sh06.z);sh[10]=vec3f(sh06.w,sh07.x,sh07.y);sh[11]=vec3f(sh07.z,sh07.w,sh08.x);sh[12]=vec3f(sh08.y,sh08.z,sh08.w);sh[13]=vec3f(sh09.x,sh09.y,sh09.z);sh[14]=vec3f(sh09.w,sh10.x,sh10.y);sh[15]=vec3f(sh10.z,sh10.w,sh11.x); +#endif +#if SH_DEGREE>3 +let sh12: vec4f=decompose(splat.sh3.x);let sh13: vec4f=decompose(splat.sh3.y);let sh14: vec4f=decompose(splat.sh3.z);let sh15: vec4f=decompose(splat.sh3.w);let sh16: vec4f=decompose(splat.sh4.x);let sh17: vec4f=decompose(splat.sh4.y);sh[16]=vec3f(sh11.y,sh11.z,sh11.w);sh[17]=vec3f(sh12.x,sh12.y,sh12.z);sh[18]=vec3f(sh12.w,sh13.x,sh13.y);sh[19]=vec3f(sh13.z,sh13.w,sh14.x);sh[20]=vec3f(sh14.y,sh14.z,sh14.w);sh[21]=vec3f(sh15.x,sh15.y,sh15.z);sh[22]=vec3f(sh15.w,sh16.x,sh16.y);sh[23]=vec3f(sh16.z,sh16.w,sh17.x);sh[24]=vec3f(sh17.y,sh17.z,sh17.w); +#endif +return computeColorFromSHDegree(dir,sh);} +fn gaussianSplatting( +meshPos: vec2, +worldPos: vec3, +scale: vec2, +covA: vec3, +covB: vec3, +worldMatrix: mat4x4, +viewMatrix: mat4x4, +projectionMatrix: mat4x4, +focal: vec2f, +invViewport: vec2f, +kernelSize: f32 +)->vec4f {let modelView=viewMatrix*worldMatrix;let camspace=viewMatrix*vec4f(worldPos,1.0);let pos2d=projectionMatrix*camspace;let bounds=1.2*pos2d.w;if (pos2d.z<0. || pos2d.x<-bounds || pos2d.x>bounds || pos2d.y<-bounds || pos2d.y>bounds) {return vec4f(0.0,0.0,2.0,1.0);} +let Vrk=mat3x3( +covA.x,covA.y,covA.z, +covA.y,covB.x,covB.y, +covA.z,covB.y,covB.z +);let isOrtho=abs(projectionMatrix[3][3]-1.0)<0.001;var J: mat3x3;if (isOrtho) {J=mat3x3( +focal.x,0.0,0.0, +0.0,focal.y,0.0, +0.0,0.0,0.0 +);} else {J=mat3x3( +focal.x/camspace.z,0.0,-(focal.x*camspace.x)/(camspace.z*camspace.z), +0.0,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z), +0.0,0.0,0.0 +);} +let T=transpose(mat3x3( +modelView[0].xyz, +modelView[1].xyz, +modelView[2].xyz))*J;var cov2d=transpose(T)*Vrk*T; +#if COMPENSATION +let c00: f32=cov2d[0][0];let c11: f32=cov2d[1][1];let c01: f32=cov2d[0][1];let detOrig: f32=c00*c11-c01*c01; +#endif +cov2d[0][0]+=kernelSize;cov2d[1][1]+=kernelSize; +#if COMPENSATION +let c2d: vec3f=vec3f(cov2d[0][0],c01,cov2d[1][1]);let detBlur: f32=c2d.x*c2d.z-c2d.y*c2d.y;let compensation: f32=sqrt(max(0.,detOrig/detBlur));vertexOutputs.vColor.w*=compensation; +#endif +let mid=(cov2d[0][0]+cov2d[1][1])/2.0;let radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));let lambda1=mid+radius;let lambda2=mid-radius;if (lambda2<0.0) {return vec4f(0.0,0.0,2.0,1.0);} +let diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));let majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;let minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);let vCenter=vec2(pos2d.x,pos2d.y);let scaleFactor=select(pos2d.w,1.0,isOrtho);return vec4f( +vCenter+((meshPos.x*majorAxis+meshPos.y*minorAxis)*invViewport*scaleFactor)*scale, +pos2d.z, +pos2d.w +);} +#if IS_COMPOUND +fn getPartWorld(partIndex: u32)->mat4x4 {return uniforms.partWorld[partIndex];} +#endif +#if defined(IS_FOR_VOXELIZATION) +fn computeVoxelSplatWorldPos(rotationA: vec4f,rotationB: vec4f,rotationScale: vec4f,center: vec3f,splatWorld: mat4x4f,viewMatrix: mat4x4f,invWorldScale: mat4x4f,quadPos: vec2f)->vec4f {let splatRotation=mat3x3f( +rotationA.xyz, +vec3f(rotationA.w,rotationB.x,rotationB.y), +vec3f(rotationB.z,rotationB.w,rotationScale.x) +);let splatScale=rotationScale.yzw;let view3x3=mat3x3f(viewMatrix[0].xyz,viewMatrix[1].xyz,viewMatrix[2].xyz);let invWorldScale3x3=mat3x3f(invWorldScale[0].xyz,invWorldScale[1].xyz,invWorldScale[2].xyz);let splatWorld3x3=mat3x3f(splatWorld[0].xyz,splatWorld[1].xyz,splatWorld[2].xyz);let rotToView=view3x3*invWorldScale3x3*splatWorld3x3*splatRotation;let axisLengthInViewZ=abs(vec3f(rotToView[0][2],rotToView[1][2],rotToView[2][2]));let gaussianSplatCutoffStddev: f32=0.7071067812; +var offsetSplatSpace: vec3f;if (axisLengthInViewZ.x>axisLengthInViewZ.y && axisLengthInViewZ.x>axisLengthInViewZ.z) {offsetSplatSpace=vec3f(0.0,quadPos.x,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else if (axisLengthInViewZ.y>axisLengthInViewZ.z) {offsetSplatSpace=vec3f(quadPos.x,0.0,quadPos.y)*splatScale*gaussianSplatCutoffStddev;} else {offsetSplatSpace=vec3f(quadPos.x,quadPos.y,0.0)*splatScale*gaussianSplatCutoffStddev;} +let vertexObjectSpace=center+splatRotation*offsetSplatSpace;return splatWorld*vec4f(vertexObjectSpace,1.0);} +#endif +`;E.IncludesShadersStoreWGSL[ZN]||(E.IncludesShadersStoreWGSL[ZN]=Y5)});var QN={};Ie(QN,{gaussianSplattingVertexShaderWGSL:()=>K5});var xT,qN,K5,IT=C(()=>{w();Tn();So();Lr();un();zc();_a();Mp();mn();Xc();Oh();xT="gaussianSplattingVertexShader",qN=`#include +#include +#include +#include +#include +#include +attribute splatIndex0: vec4f;attribute splatIndex1: vec4f;attribute splatIndex2: vec4f;attribute splatIndex3: vec4f;attribute position: vec3f;uniform invViewport: vec2f;uniform dataTextureSize: vec2f;uniform focal: vec2f;uniform kernelSize: f32;uniform eyePosition: vec3f;uniform alpha: f32; +#if IS_COMPOUND +uniform partWorld: array,MAX_PART_COUNT>;uniform partVisibility: array; +#endif +var covariancesATexture: texture_2d;var covariancesBTexture: texture_2d;var centersTexture: texture_2d;var colorsTexture: texture_2d; +#if SH_DEGREE>0 +var shTexture0: texture_2d; +#endif +#if SH_DEGREE>1 +var shTexture1: texture_2d; +#endif +#if SH_DEGREE>2 +var shTexture2: texture_2d; +#endif +#if SH_DEGREE>3 +var shTexture3: texture_2d;var shTexture4: texture_2d; +#endif +#if IS_COMPOUND +var partIndicesTexture: texture_2d; +#endif +varying vColor: vec4f;varying vPosition: vec2f; +#define CUSTOM_VERTEX_DEFINITIONS +#include +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +let splatIndex: f32=getSplatIndex(i32(vertexInputs.position.z+0.5),vertexInputs.splatIndex0,vertexInputs.splatIndex1,vertexInputs.splatIndex2,vertexInputs.splatIndex3);var splat: Splat=readSplat(splatIndex,uniforms.dataTextureSize);var covA: vec3f=splat.covA.xyz;var covB: vec3f=vec3f(splat.covA.w,splat.covB.xy); +#if IS_COMPOUND +let splatWorld: mat4x4f=getPartWorld(splat.partIndex); +#else +let splatWorld: mat4x4f=mesh.world; +#endif +let worldPos: vec4f=splatWorld*vec4f(splat.center.xyz,1.0);vertexOutputs.vPosition=vertexInputs.position.xy; +#if SH_DEGREE>0 +let worldRot: mat3x3f= mat3x3f(splatWorld[0].xyz,splatWorld[1].xyz,splatWorld[2].xyz);let normWorldRot: mat3x3f=inverseMat3(worldRot);var eyeToSplatLocalSpace: vec3f=normalize(normWorldRot*(worldPos.xyz-uniforms.eyePosition.xyz));vertexOutputs.vColor=vec4f(splat.color.xyz+computeSH(splat,eyeToSplatLocalSpace),splat.color.w*uniforms.alpha); +#else +vertexOutputs.vColor=vec4f(splat.color.xyz,splat.color.w*uniforms.alpha); +#endif +#if IS_COMPOUND +vertexOutputs.vColor.w*=uniforms.partVisibility[splat.partIndex]; +#endif +let scale: vec2f=vec2f(1.,1.); +#define CUSTOM_VERTEX_UPDATE +vertexOutputs.position=gaussianSplatting(vertexInputs.position.xy,worldPos.xyz,scale,covA,covB,splatWorld,scene.view,scene.projection,uniforms.focal,uniforms.invViewport,uniforms.kernelSize); +#include +#include +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStoreWGSL[xT]||(E.ShadersStoreWGSL[xT]=qN);K5={name:xT,shader:qN}});var JN,j5,$N=C(()=>{w();JN="gaussianSplattingDepthPixelShader",j5=`precision highp float;varying vec2 vPosition;varying vec4 vColor; +#ifdef DEPTH_RENDER +varying float vDepthMetric; +#endif +void main(void) {float A=-dot(vPosition,vPosition); +#if (defined(SM_SOFTTRANSPARENTSHADOW) && SM_SOFTTRANSPARENTSHADOW==1) || (defined(DEPTH_RENDER) && defined(ALPHA_BLENDED_DEPTH)) +float alpha=exp(A)*vColor.a;if (A<-4.) +discard; +#else +if (A<-vColor.a) +discard; +#endif +#ifdef DEPTH_RENDER +float opacity=1.0; +#ifdef ALPHA_BLENDED_DEPTH +opacity=alpha; +#endif +gl_FragColor=vec4(vDepthMetric,0.0,0.0,opacity); +#endif +}`;E.ShadersStore[JN]||(E.ShadersStore[JN]=j5)});var eF,Z5,tF=C(()=>{w();Ip();Cp();bp();eF="gaussianSplattingDepthVertexShader",Z5=`#include<__decl__gaussianSplattingVertex> +uniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform float kernelSize;uniform float alpha;uniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture; +#if IS_COMPOUND +uniform mat4 partWorld[MAX_PART_COUNT];uniform float partVisibility[MAX_PART_COUNT];uniform sampler2D partIndicesTexture; +#endif +varying vec2 vPosition;varying vec4 vColor; +#include +#ifdef DEPTH_RENDER +uniform vec2 depthValues;varying float vDepthMetric; +#endif +void main(void) {float splatIndex=getSplatIndex(int(position.z+0.5));Splat splat=readSplat(splatIndex);vec3 covA=splat.covA.xyz;vec3 covB=vec3(splat.covA.w,splat.covB.xy); +#if IS_COMPOUND +mat4 splatWorld=getPartWorld(splat.partIndex); +#else +mat4 splatWorld=world; +#endif +vec4 worldPosGS=splatWorld*vec4(splat.center.xyz,1.0);vPosition=position.xy;vColor=splat.color;vColor.w*=alpha; +#if IS_COMPOUND +vColor.w*=partVisibility[splat.partIndex]; +#endif +gl_Position=gaussianSplatting(position.xy,worldPosGS.xyz,vec2(1.,1.),covA,covB,splatWorld,view,projection); +#ifdef DEPTH_RENDER +#ifdef USE_REVERSE_DEPTHBUFFER +vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y)); +#else +vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y)); +#endif +#endif +}`;E.ShadersStore[eF]||(E.ShadersStore[eF]=Z5)});var iF,q5,rF=C(()=>{w();TT();iF="gaussianSplattingDepthPixelShader",q5=`#include +varying vPosition: vec2f;varying vColor: vec4f; +#ifdef DEPTH_RENDER +varying vDepthMetric: f32; +#endif +fn checkDiscard(inPosition: vec2f,inColor: vec4f)->vec4f {var A : f32=-dot(inPosition,inPosition);var alpha : f32=exp(A)*inColor.a; +#if (defined(SM_SOFTTRANSPARENTSHADOW) && SM_SOFTTRANSPARENTSHADOW==1) || (defined(DEPTH_RENDER) && defined(ALPHA_BLENDED_DEPTH)) +if (A<-4.) {discard;} +#else +if (A<-inColor.a) {discard;} +#endif +#ifdef DEPTH_RENDER +var opacity : f32=1.0; +#ifdef ALPHA_BLENDED_DEPTH +opacity=alpha; +#endif +return vec4f(fragmentInputs.vDepthMetric,0.0,0.0,opacity); +#else +return vec4f(inColor.rgb,alpha); +#endif +} +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=checkDiscard(fragmentInputs.vPosition,fragmentInputs.vColor); +#if (defined(SM_SOFTTRANSPARENTSHADOW) && SM_SOFTTRANSPARENTSHADOW==1) || (defined(DEPTH_RENDER) && defined(ALPHA_BLENDED_DEPTH)) +var alpha : f32=fragmentOutputs.color.a; +#endif +} +`;E.ShadersStoreWGSL[iF]||(E.ShadersStoreWGSL[iF]=q5)});var sF,Q5,nF=C(()=>{w();Tn();So();Mp();sF="gaussianSplattingDepthVertexShader",Q5=`#include +#include +attribute splatIndex0: vec4f;attribute splatIndex1: vec4f;attribute splatIndex2: vec4f;attribute splatIndex3: vec4f;attribute position: vec3f;uniform invViewport: vec2f;uniform dataTextureSize: vec2f;uniform focal: vec2f;uniform kernelSize: f32;uniform alpha: f32;var covariancesATexture: texture_2d;var covariancesBTexture: texture_2d;var centersTexture: texture_2d;var colorsTexture: texture_2d; +#if IS_COMPOUND +uniform partWorld: array,MAX_PART_COUNT>;uniform partVisibility: array;var partIndicesTexture: texture_2d; +#endif +varying vPosition: vec2f;varying vColor: vec4f; +#ifdef DEPTH_RENDER +uniform depthValues: vec2f;varying vDepthMetric: f32; +#endif +#include +@vertex +fn main(input : VertexInputs)->FragmentInputs {let splatIndex: f32=getSplatIndex(i32(vertexInputs.position.z+0.5),vertexInputs.splatIndex0,vertexInputs.splatIndex1,vertexInputs.splatIndex2,vertexInputs.splatIndex3);var splat: Splat=readSplat(splatIndex,uniforms.dataTextureSize);var covA: vec3f=splat.covA.xyz;var covB: vec3f=vec3f(splat.covA.w,splat.covB.xy); +#if IS_COMPOUND +let splatWorld: mat4x4f=getPartWorld(splat.partIndex); +#else +let splatWorld: mat4x4f=mesh.world; +#endif +let worldPos: vec4f=splatWorld*vec4f(splat.center.xyz,1.0);vertexOutputs.vPosition=vertexInputs.position.xy;vertexOutputs.vColor=splat.color;vertexOutputs.vColor.w*=uniforms.alpha; +#if IS_COMPOUND +vertexOutputs.vColor.w*=uniforms.partVisibility[splat.partIndex]; +#endif +vertexOutputs.position=gaussianSplatting(vertexInputs.position.xy,worldPos.xyz,vec2f(1.0,1.0),covA,covB,splatWorld,scene.view,scene.projection,uniforms.focal,uniforms.invViewport,uniforms.kernelSize); +#ifdef DEPTH_RENDER +#ifdef USE_REVERSE_DEPTHBUFFER +vertexOutputs.vDepthMetric=((-vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y)); +#else +vertexOutputs.vDepthMetric=((vertexOutputs.position.z+uniforms.depthValues.x)/(uniforms.depthValues.y)); +#endif +#endif +}`;E.ShadersStoreWGSL[sF]||(E.ShadersStoreWGSL[sF]=Q5)});var oF={};Ie(oF,{gaussianSplattingVoxelPixelShader:()=>J5});var CT,aF,J5,bT=C(()=>{w();CT="gaussianSplattingVoxelPixelShader",aF=`precision highp float;layout(location=0) out highp float glFragData[MAX_DRAW_BUFFERS];varying vec3 vNormalizedPosition;varying vec3 vNormalizedCenterPosition;varying float vAlpha;varying vec2 vPatchPosition;uniform float nearPlane;uniform float farPlane;uniform float stepSize;float max3(vec3 v) { return max(max(v.x,v.y),v.z); } +float prngCanonical1d(float co) +{return fract(sin(co*91.3458)*47453.5453);} +float prngCanonical2d(vec2 co) +{return fract(sin(dot(vec2(co.x,co.y),vec2(12.9898,78.233)))*43758.5453);} +float prngCanonical3d(vec3 co) +{return prngCanonical2d(vec2(co.x,co.y)+prngCanonical1d(co.z));} +void main(void) {vec3 normPos=vNormalizedPosition.xyz;if (normPos.zfarPlane) {discard;} +float distToCenter=max3(abs(vNormalizedCenterPosition-normPos));float shadowingOpacity=clamp((distToCenter=nearPlane+stepSize && normPos.z=nearPlane+2.0*stepSize && normPos.z=nearPlane+3.0*stepSize && normPos.z4 +glFragData[4]=normPos.z>=nearPlane+4.0*stepSize && normPos.z=nearPlane+5.0*stepSize && normPos.z6 +glFragData[6]=normPos.z>=nearPlane+6.0*stepSize && normPos.z=nearPlane+7.0*stepSize && normPos.z$5});var MT,lF,$5,yT=C(()=>{w();Ip();Cp();bp();MT="gaussianSplattingVoxelVertexShader",lF=`#include<__decl__gaussianSplattingVertex> +uniform vec2 dataTextureSize;uniform float alpha;uniform mat4 invWorldScale;uniform mat4 viewMatrix;uniform sampler2D rotationsATexture;uniform sampler2D rotationsBTexture;uniform sampler2D rotationScaleTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture; +#if IS_COMPOUND +uniform mat4 partWorld[MAX_PART_COUNT];uniform float partVisibility[MAX_PART_COUNT];uniform sampler2D partIndicesTexture; +#endif +varying vec3 vNormalizedPosition;varying vec3 vNormalizedCenterPosition;varying float vAlpha;varying vec2 vPatchPosition; +#include +void main(void) {float splatIndex=getSplatIndex(int(position.z+0.5));Splat splat=readSplat(splatIndex); +#if IS_COMPOUND +mat4 splatWorld=getPartWorld(splat.partIndex); +#else +mat4 splatWorld=world; +#endif +vec4 worldPos=computeVoxelSplatWorldPos(splat.rotationA,splat.rotationB,splat.rotationScale,splat.center.xyz,splatWorld,viewMatrix,invWorldScale,position.xy);gl_Position=viewMatrix*invWorldScale*worldPos;vNormalizedPosition=gl_Position.xyz*0.5+0.5;vec4 viewCenterPos=viewMatrix*invWorldScale*splatWorld*vec4(splat.center.xyz,1.0);vNormalizedCenterPosition=viewCenterPos.xyz*0.5+0.5;vAlpha=splat.color.w*alpha; +#if IS_COMPOUND +vAlpha*=partVisibility[splat.partIndex]; +#endif +vPatchPosition=position.xy;}`;E.ShadersStore[MT]||(E.ShadersStore[MT]=lF);$5={name:MT,shader:lF}});var hF={};Ie(hF,{gaussianSplattingVoxelVertexShaderWGSL:()=>e8});var DT,fF,e8,dF=C(()=>{w();Tn();So();Mp();DT="gaussianSplattingVoxelVertexShader",fF=`#include +#include +attribute splatIndex0: vec4f;attribute splatIndex1: vec4f;attribute splatIndex2: vec4f;attribute splatIndex3: vec4f;attribute position: vec3f;uniform dataTextureSize: vec2f;uniform alpha: f32;uniform invWorldScale: mat4x4f;uniform viewMatrix: mat4x4f; +#if IS_COMPOUND +uniform partWorld: array,MAX_PART_COUNT>;uniform partVisibility: array; +#endif +var rotationsATexture: texture_2d;var rotationsBTexture: texture_2d;var rotationScaleTexture: texture_2d;var centersTexture: texture_2d;var colorsTexture: texture_2d; +#if IS_COMPOUND +var partIndicesTexture: texture_2d; +#endif +varying vNormalizedPosition: vec3f;varying vNormalizedCenterPosition: vec3f;varying vAlpha: f32;varying vPatchPosition: vec2f; +#include +@vertex +fn main(input: VertexInputs)->FragmentInputs {let splatIndex: f32=getSplatIndex( +i32(vertexInputs.position.z+0.5), +vertexInputs.splatIndex0,vertexInputs.splatIndex1, +vertexInputs.splatIndex2,vertexInputs.splatIndex3 +);var splat: Splat=readSplat(splatIndex,uniforms.dataTextureSize); +#if IS_COMPOUND +let splatWorld: mat4x4f=getPartWorld(splat.partIndex); +#else +let splatWorld: mat4x4f=mesh.world; +#endif +let quadPos: vec2f=vertexInputs.position.xy;let worldPos: vec4f=computeVoxelSplatWorldPos(splat.rotationA,splat.rotationB,splat.rotationScale,splat.center.xyz,splatWorld,uniforms.viewMatrix,uniforms.invWorldScale,quadPos);vertexOutputs.vNormalizedPosition=(uniforms.invWorldScale*worldPos).xyz*0.5+0.5;let clipPos: vec4f=uniforms.viewMatrix*uniforms.invWorldScale*worldPos;vertexOutputs.position=vec4f(clipPos.x,clipPos.y,clipPos.z*0.5+0.5,1.0);vertexOutputs.vNormalizedCenterPosition=(uniforms.invWorldScale*splatWorld*vec4f(splat.center.xyz,1.0)).xyz*0.5+0.5;vertexOutputs.vAlpha=splat.color.w*uniforms.alpha; +#if IS_COMPOUND +vertexOutputs.vAlpha*=uniforms.partVisibility[splat.partIndex]; +#endif +vertexOutputs.vPatchPosition=quadPos;} +`;E.ShadersStoreWGSL[DT]||(E.ShadersStoreWGSL[DT]=fF);e8={name:DT,shader:fF}});var mF={};Ie(mF,{gaussianSplattingVoxelPixelShaderWGSL:()=>t8});var PT,uF,t8,pF=C(()=>{w();PT="gaussianSplattingVoxelPixelShader",uF=`var voxel_storage: texture_storage_3d;varying vNormalizedPosition: vec3f;varying vNormalizedCenterPosition: vec3f;varying vAlpha: f32;varying vPatchPosition: vec2f;fn gsVoxelPrngCanonical1d(co: f32)->f32 {return fract(sin(co*91.3458)*47453.5453);} +fn gsVoxelPrngCanonical2d(co: vec2f)->f32 {return fract(sin(dot(co,vec2f(12.9898,78.233)))*43758.5453);} +fn gsVoxelPrngCanonical3d(co: vec3f)->f32 {return gsVoxelPrngCanonical2d(vec2f(co.x,co.y)+gsVoxelPrngCanonical1d(co.z));} +@fragment +fn main(input: FragmentInputs)->FragmentOutputs {let normPos: vec3f=input.vNormalizedPosition;let stepSize: f32=1.0/f32(textureDimensions(voxel_storage).x);let diff: vec3f=abs(input.vNormalizedCenterPosition-normPos);let distToCenter: f32=max(max(diff.x,diff.y),diff.z);let gaussian: f32=exp(-dot(input.vPatchPosition,input.vPatchPosition));let shadowingOpacity: f32=clamp( +select(gaussian,1.0,distToCenter(i32(normPos.x*size.x),i32(normPos.y*size.y),i32(normPos.z*size.z)), +vec4f(1.0,1.0,1.0,1.0));fragmentOutputs.color=vec4f(0.0,0.0,0.0,0.0);} +`;E.ShadersStoreWGSL[PT]||(E.ShadersStoreWGSL[PT]=uF);t8={name:PT,shader:uF}});function Vh(s){let r=s.getCaps().maxVertexUniformVectors,n=Math.max(r-40,0),a=Math.floor(n/5);return Math.min(Math.max(a,1),256)}var i8,LT,Qi,OT=C(()=>{jt();We();It();Ur();Hc();Pt();Ps();Ds();wN();um();Vi();ET();ST();RT();IT();$N();tF();rF();nF();bT();yT();Ui();Xu();i8=128,LT=class extends qt{constructor(e){super(e),this.FOG=!1,this.THIN_INSTANCES=!0,this.LOGARITHMICDEPTH=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.SH_DEGREE=0,this.COMPENSATION=!1,this.IS_COMPOUND=!1,this.MAX_PART_COUNT=i8,this.rebuild()}},Qi=class s extends os{constructor(e,t){super(e,t),this.kernelSize=s.KernelSize,this._compensation=s.Compensation,this._isDirty=!1,this._sourceMesh=null,this._voxelMissingTextureWarned=new Set,this._voxelPartWorldData=new Float32Array(0),this._voxelPartVisibilityData=[],this.backFaceCulling=!1,this.shadowDepthWrapper=s._MakeGaussianSplattingShadowDepthWrapper(t,this.shaderLanguage)}set compensation(e){this._isDirty=this._isDirty!=e,this._compensation=e}get compensation(){return this._compensation}get hasRenderTargetTextures(){return!1}needAlphaTesting(){return!1}needAlphaBlending(){return!0}isReadyForSubMesh(e,t){let r=t._drawWrapper,n=t.materialDefines;if(n&&this._isDirty&&n.markAsUnprocessed(),r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===!0)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),n=t.materialDefines=new LT(this._eventInfo.defineNames));let a=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=n,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||!this._sourceMesh)return!1;let o=a.getEngine(),l=this._sourceMesh;ro(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,!1,n,void 0,void 0,void 0,this._isVertexOutputInvariant),no(a,o,this,n,!0,null,!0),ao(e,n,!1,!1),(o.version>1||o.isWebGPU)&&(n.SH_DEGREE=l.shDegree),n.IS_COMPOUND=l.isCompound,n.MAX_PART_COUNT=Vh(o);let c=l.material;if(n.COMPENSATION=c&&c.compensation?c.compensation:s.Compensation,n.isDirty){n.markAsProcessed(),a.resetCachedMaterial(),io(s._Attribs,n);let f=s._Attribs.slice(),h=s._Uniforms.slice(),d=s._Samplers.slice(),u=s._UniformBuffers.slice();lo({uniformsNames:h,uniformBuffersNames:u,samplers:d,defines:n}),Pi(h),this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._eventInfo.fallbackRank=0,this._eventInfo.defines=n,this._eventInfo.attributes=f,this._eventInfo.uniforms=h,this._eventInfo.samplers=d,this._eventInfo.uniformBuffersNames=u,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._callbackPluginEventGeneric(128,this._eventInfo);let m=n.toString(),p=a.getEngine().createEffect("gaussianSplatting",{attributes:f,uniformsNames:h,uniformBuffersNames:u,samplers:d,defines:m,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{},processCodeAfterIncludes:this._eventInfo.customCode,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(RT(),jN)),Promise.resolve().then(()=>(IT(),QN))]):await Promise.all([Promise.resolve().then(()=>(ET(),GN)),Promise.resolve().then(()=>(ST(),XN))])}},o);t.setEffect(p,n,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(n._renderId=a.getRenderId(),r._wasPreviouslyReady=!0,r._wasPreviouslyUsingInstances=!0,this._isDirty=!1,!0)}setSourceMesh(e){this._sourceMesh=e}getSourceMesh(){return this._sourceMesh}static BindEffect(e,t,i){var d;let r=i.getEngine(),n=i.activeCamera,a=r.getRenderWidth()*n.viewport.width,o=r.getRenderHeight()*n.viewport.height,l=e.material;if(!l._sourceMesh)return;let c=l._sourceMesh,f=((d=n==null?void 0:n.rigParent)==null?void 0:d.rigCameras.length)||1;t.setFloat2("invViewport",1/(a/f),1/o);let h=1e3;if(n){let u=n.getProjectionMatrix().m[5];n.fovMode==we.FOVMODE_VERTICAL_FIXED?h=o*u/2:h=a*u/2}if(t.setFloat2("focal",h,h),t.setFloat("kernelSize",l&&l.kernelSize?l.kernelSize:s.KernelSize),t.setFloat("alpha",l.alpha),i.bindEyePosition(t,"eyePosition",!0),c.covariancesATexture){let u=c.covariancesATexture.getSize();if(t.setFloat2("dataTextureSize",u.width,u.height),t.setTexture("covariancesATexture",c.covariancesATexture),t.setTexture("covariancesBTexture",c.covariancesBTexture),t.setTexture("centersTexture",c.centersTexture),t.setTexture("colorsTexture",c.colorsTexture),c.shTextures)for(let m=0;m{t===1?await Promise.all([Promise.resolve().then(()=>(dF(),hF)),Promise.resolve().then(()=>(pF(),mF))]):await Promise.all([Promise.resolve().then(()=>(yT(),cF)),Promise.resolve().then(()=>(bT(),oF))])}});return a.cullBackFaces=!1,a.backFaceCulling=!1,a.depthFunction=ve.ALWAYS,a.onBindObservable.add(o=>{let l=o.material,c=o;this._bindVoxelEffectUniforms(c,l,a)}),a}makeDepthRenderingMaterial(e,t,i=!1,r=!1){let n=["#define DEPTH_RENDER"];i&&n.push("#define ALPHA_BLENDED_DEPTH"),r&&(n.push("#define IS_COMPOUND 1"),n.push(`#define MAX_PART_COUNT ${Vh(e.getEngine())}`));let a=new sr("gaussianSplattingDepthRender",e,{vertex:"gaussianSplattingDepth",fragment:"gaussianSplattingDepth"},{attributes:s._Attribs,uniforms:s._Uniforms,samplers:s._Samplers,uniformBuffers:s._UniformBuffers,shaderLanguage:t,defines:n,needAlphaBlending:i});return a.doNotSerialize=!0,a.backFaceCulling=!1,a.onBindObservable.add(o=>{var f;let l=o.material,c=(f=l==null?void 0:l.getSourceMesh())!=null?f:o;s._BindEffectUniforms(c,l,a,e)}),a}static _MakeGaussianSplattingShadowDepthWrapper(e,t){let i=new sr("gaussianSplattingDepth",e,{vertex:"gaussianSplattingDepth",fragment:"gaussianSplattingDepth"},{attributes:s._Attribs,uniforms:s._Uniforms,samplers:s._Samplers,uniformBuffers:s._UniformBuffers,shaderLanguage:t});i.doNotSerialize=!0,i.backFaceCulling=!1;let r=new xp(i,e,{standalone:!0});return i.onBindObservable.add(n=>{var l;let a=n.material,o=(l=a==null?void 0:a.getSourceMesh())!=null?l:n;s._BindEffectUniforms(o,a,i,e)}),r}clone(e){let t=De.Clone(()=>new s(e,this.getScene()),this);return t.id=e,t.name=e,this._clonePlugins(t,""),t}serialize(){let e=super.serialize();return e.customType="BABYLON.GaussianSplattingMaterial",e}getClassName(){return"GaussianSplattingMaterial"}static Parse(e,t,i){let r=De.Parse(()=>new s(e.name,t),e,t,i);return oe._ParsePlugins(e,r,t,i),r}};Qi.KernelSize=.3;Qi.Compensation=!1;Qi._Attribs=[y.PositionKind,"splatIndex0","splatIndex1","splatIndex2","splatIndex3"];Qi._Samplers=["covariancesATexture","covariancesBTexture","centersTexture","colorsTexture","shTexture0","shTexture1","shTexture2","shTexture3","shTexture4","partIndicesTexture"];Qi._UniformBuffers=["Scene","Mesh"];Qi._VoxelUniforms=["world","dataTextureSize","alpha","invWorldScale","viewMatrix","nearPlane","farPlane","stepSize","partWorld","partVisibility","axis"];Qi._VoxelSamplers=["rotationsATexture","rotationsBTexture","rotationScaleTexture","centersTexture","colorsTexture","partIndicesTexture"];Qi._Uniforms=["world","view","projection","vFogInfos","vFogColor","logarithmicDepthConstant","invViewport","dataTextureSize","focal","eyePosition","kernelSize","alpha","depthValues","partWorld","partVisibility"];Ke("BABYLON.GaussianSplattingMaterial",Qi)});var Vr,yp=C(()=>{pi();Vr=class s extends ne{constructor(e,t,i,r,n,a=!0,o=!1,l=3,c=0,f,h,d,u){super(null,n,!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,h!=null?h:!1,u),this.wrapU=ne.CLAMP_ADDRESSMODE,this.wrapV=ne.CLAMP_ADDRESSMODE,this._waitingForData=!!d&&!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 s(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,n=!0,a=!1,o=3){return new s(e,t,i,1,r,n,a,o)}static CreateLuminanceAlphaTexture(e,t,i,r,n=!0,a=!1,o=3){return new s(e,t,i,2,r,n,a,o)}static CreateAlphaTexture(e,t,i,r,n=!0,a=!1,o=3){return new s(e,t,i,0,r,n,a,o)}static CreateRGBTexture(e,t,i,r,n=!0,a=!1,o=3,l=0,c=0,f=!1){return new s(e,t,i,4,r,n,a,o,l,c,f)}static CreateRGBATexture(e,t,i,r,n=!0,a=!1,o=3,l=0,c=0,f=!1,h=!1){return new s(e,t,i,5,r,n,a,o,l,c,f,h)}static CreateRGBAStorageTexture(e,t,i,r,n=!0,a=!1,o=3,l=0,c=!1){return new s(e,t,i,5,r,n,a,o,l,1,c)}static CreateRTexture(e,t,i,r,n=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new s(e,t,i,6,r,n,a,o,l)}static CreateRStorageTexture(e,t,i,r,n=!0,a=!1,o=ne.TRILINEAR_SAMPLINGMODE,l=1){return new s(e,t,i,6,r,n,a,o,l,1)}}});var NT=C(()=>{ut();It();Ee();We();eo();G.prototype.thinInstanceAdd=function(s,e=!0){if(!this.getScene().getEngine().getCaps().instancedArrays)return X.Error("Thin Instances are not supported on this device as Instanced Array extension not supported"),-1;this._thinInstanceUpdateBufferSize("matrix",Array.isArray(s)?s.length:1);let t=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(s))for(let i=0;i=this._thinInstanceDataStorage.instancesCount)return!1;let i=this._thinInstanceDataStorage.matrixData;return e.copyToArray(i,s*16),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[s]=e),t&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0};G.prototype.thinInstanceSetAttributeAt=function(s,e,t,i=!0){return s===y.ColorKind&&(s=y.ColorInstanceKind),!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[s]||e>=this._thinInstanceDataStorage.instancesCount?!1:(this._thinInstanceUpdateBufferSize(s,0),this._userThinInstanceBuffersStorage.data[s].set(t,e*this._userThinInstanceBuffersStorage.strides[s]),i&&this.thinInstanceBufferUpdated(s),!0)};Object.defineProperty(G.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(s){var i,r;let e=(r=this._thinInstanceDataStorage.matrixData)!=null?r:(i=this.source)==null?void 0:i._thinInstanceDataStorage.matrixData,t=e?e.length/16:0;s<=t&&(this._thinInstanceDataStorage.instancesCount=s)},enumerable:!0,configurable:!0});G.prototype._thinInstanceCreateMatrixBuffer=function(s,e,t=!0){let i=new Er(this.getEngine(),e,!t,16,!1,!0);for(let r=0;r<4;r++)this.setVerticesBuffer(i.createVertexBuffer(s+r,r*4,4));return i};G.prototype.thinInstanceSetBuffer=function(s,e,t=0,i=!0){var r,n,a;if(t=t||16,s==="matrix")(r=this._thinInstanceDataStorage.matrixBuffer)==null||r.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=e?e.length:32*t,this._thinInstanceDataStorage.matrixData=e,this._thinInstanceDataStorage.worldMatrices=null,e!==null?(this._thinInstanceDataStorage.instancesCount=e.length/t,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",e,i),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo());else if(s==="previousMatrix")(n=this._thinInstanceDataStorage.previousMatrixBuffer)==null||n.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=e,e!==null&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",e,i));else if(s==="splatIndex"&&e){this._thinInstanceInitializeUserStorage(),this._thinInstanceDataStorage.instancesCount=e.length/t,this._userThinInstanceBuffersStorage.data[s]=e,this._userThinInstanceBuffersStorage.strides[s]=t,this._userThinInstanceBuffersStorage.sizes[s]=e.length;let o=new Er(this.getEngine(),e,!0,16,!1,!0);this._thinInstanceDataStorage.matrixBuffer=o;for(let l=0;l<4;l++)this.setVerticesBuffer(o.createVertexBuffer(s+l,l*4,4))}else s===y.ColorKind&&(s=y.ColorInstanceKind),e===null?(a=this._userThinInstanceBuffersStorage)!=null&&a.data[s]&&(this.removeVerticesData(s),delete this._userThinInstanceBuffersStorage.data[s],delete this._userThinInstanceBuffersStorage.strides[s],delete this._userThinInstanceBuffersStorage.sizes[s],delete this._userThinInstanceBuffersStorage.vertexBuffers[s]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[s]=e,this._userThinInstanceBuffersStorage.strides[s]=t,this._userThinInstanceBuffersStorage.sizes[s]=e.length,this._userThinInstanceBuffersStorage.vertexBuffers[s]=new y(this.getEngine(),e,s,!i,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[s]))};G.prototype.thinInstanceBufferUpdated=function(s){var e,t,i,r;s==="matrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.matrixBuffer&&!this._thinInstanceDataStorage.matrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(s),(e=this._thinInstanceDataStorage.matrixBuffer)==null||e.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount)):s==="previousMatrix"?(this.thinInstanceAllowAutomaticStaticBufferRecreation&&this._thinInstanceDataStorage.previousMatrixBuffer&&!this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()&&this._thinInstanceRecreateBuffer(s),(t=this._thinInstanceDataStorage.previousMatrixBuffer)==null||t.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount)):s==="splatIndex"?(i=this._thinInstanceDataStorage.matrixBuffer)==null||i.updateDirectly(this._userThinInstanceBuffersStorage.data[s],0,this._thinInstanceDataStorage.instancesCount):(s===y.ColorKind&&(s=y.ColorInstanceKind),(r=this._userThinInstanceBuffersStorage)!=null&&r.vertexBuffers[s]&&(this.thinInstanceAllowAutomaticStaticBufferRecreation&&!this._userThinInstanceBuffersStorage.vertexBuffers[s].isUpdatable()&&this._thinInstanceRecreateBuffer(s),this._userThinInstanceBuffersStorage.vertexBuffers[s].updateDirectly(this._userThinInstanceBuffersStorage.data[s],0)))};G.prototype.thinInstancePartialBufferUpdate=function(s,e,t){var i;if(s==="matrix")this._thinInstanceDataStorage.matrixBuffer&&(typeof e=="number"?this._thinInstanceDataStorage.matrixBuffer.updateDirectly(new Float32Array(this._thinInstanceDataStorage.matrixData.buffer,this._thinInstanceDataStorage.matrixData.byteOffset+t*16*Float32Array.BYTES_PER_ELEMENT,e*16),t*16):this._thinInstanceDataStorage.matrixBuffer.updateDirectly(e,t));else if(s===y.ColorKind&&(s=y.ColorInstanceKind),(i=this._userThinInstanceBuffersStorage)!=null&&i.vertexBuffers[s]){let r=this._userThinInstanceBuffersStorage.vertexBuffers[s];if(typeof e=="number"){let n=new Float32Array(this._userThinInstanceBuffersStorage.data[s].buffer,this._userThinInstanceBuffersStorage.data[s].byteOffset+t*this._userThinInstanceBuffersStorage.strides[s]*Float32Array.BYTES_PER_ELEMENT,e*this._userThinInstanceBuffersStorage.strides[s]);this._userThinInstanceBuffersStorage.vertexBuffers[s].updateDirectly(n,t*this._userThinInstanceBuffersStorage.strides[s])}else r.updateDirectly(e,t)}};G.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];let s=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=[];for(let e=0;e{Mi();r8=Zo,Qt={...Ag,TwoPi:Math.PI*2,Sign:Math.sign,Log2:Math.log2,HCF:r8}});var FT,gl,xn,_F,s8,n8,gF,EF,Ht,vF=C(()=>{Tc();ut();Bt();Ee();We();OT();yp();NT();vu();Dp();Th();gt();Rn();FT=typeof _native!="undefined",gl=FT?_native:null,xn=(s,e)=>{let t=(1<{e.x=xn(s>>>21,11),e.y=xn(s>>>11,10),e.z=xn(s,11)},s8=(s,e)=>{e[0]=xn(s>>>24,8)*255,e[1]=xn(s>>>16,8)*255,e[2]=xn(s>>>8,8)*255,e[3]=xn(s,8)*255},n8=(s,e)=>{let t=1/(Math.sqrt(2)*.5),i=(xn(s>>>20,10)-.5)*t,r=(xn(s>>>10,10)-.5)*t,n=(xn(s,10)-.5)*t,a=Math.sqrt(1-(i*i+r*r+n*n));switch(s>>>30){case 0:e.set(a,i,r,n);break;case 1:e.set(i,a,r,n);break;case 2:e.set(i,r,a,n);break;case 3:e.set(i,r,n,a);break}};(function(s){s[s.FLOAT=0]="FLOAT",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s[s.DOUBLE=3]="DOUBLE",s[s.UCHAR=4]="UCHAR",s[s.UNDEFINED=5]="UNDEFINED"})(gF||(gF={}));(function(s){s[s.MIN_X=0]="MIN_X",s[s.MIN_Y=1]="MIN_Y",s[s.MIN_Z=2]="MIN_Z",s[s.MAX_X=3]="MAX_X",s[s.MAX_Y=4]="MAX_Y",s[s.MAX_Z=5]="MAX_Z",s[s.MIN_SCALE_X=6]="MIN_SCALE_X",s[s.MIN_SCALE_Y=7]="MIN_SCALE_Y",s[s.MIN_SCALE_Z=8]="MIN_SCALE_Z",s[s.MAX_SCALE_X=9]="MAX_SCALE_X",s[s.MAX_SCALE_Y=10]="MAX_SCALE_Y",s[s.MAX_SCALE_Z=11]="MAX_SCALE_Z",s[s.PACKED_POSITION=12]="PACKED_POSITION",s[s.PACKED_ROTATION=13]="PACKED_ROTATION",s[s.PACKED_SCALE=14]="PACKED_SCALE",s[s.PACKED_COLOR=15]="PACKED_COLOR",s[s.X=16]="X",s[s.Y=17]="Y",s[s.Z=18]="Z",s[s.SCALE_0=19]="SCALE_0",s[s.SCALE_1=20]="SCALE_1",s[s.SCALE_2=21]="SCALE_2",s[s.DIFFUSE_RED=22]="DIFFUSE_RED",s[s.DIFFUSE_GREEN=23]="DIFFUSE_GREEN",s[s.DIFFUSE_BLUE=24]="DIFFUSE_BLUE",s[s.OPACITY=25]="OPACITY",s[s.F_DC_0=26]="F_DC_0",s[s.F_DC_1=27]="F_DC_1",s[s.F_DC_2=28]="F_DC_2",s[s.F_DC_3=29]="F_DC_3",s[s.ROT_0=30]="ROT_0",s[s.ROT_1=31]="ROT_1",s[s.ROT_2=32]="ROT_2",s[s.ROT_3=33]="ROT_3",s[s.MIN_COLOR_R=34]="MIN_COLOR_R",s[s.MIN_COLOR_G=35]="MIN_COLOR_G",s[s.MIN_COLOR_B=36]="MIN_COLOR_B",s[s.MAX_COLOR_R=37]="MAX_COLOR_R",s[s.MAX_COLOR_G=38]="MAX_COLOR_G",s[s.MAX_COLOR_B=39]="MAX_COLOR_B",s[s.SH_0=40]="SH_0",s[s.SH_1=41]="SH_1",s[s.SH_2=42]="SH_2",s[s.SH_3=43]="SH_3",s[s.SH_4=44]="SH_4",s[s.SH_5=45]="SH_5",s[s.SH_6=46]="SH_6",s[s.SH_7=47]="SH_7",s[s.SH_8=48]="SH_8",s[s.SH_9=49]="SH_9",s[s.SH_10=50]="SH_10",s[s.SH_11=51]="SH_11",s[s.SH_12=52]="SH_12",s[s.SH_13=53]="SH_13",s[s.SH_14=54]="SH_14",s[s.SH_15=55]="SH_15",s[s.SH_16=56]="SH_16",s[s.SH_17=57]="SH_17",s[s.SH_18=58]="SH_18",s[s.SH_19=59]="SH_19",s[s.SH_20=60]="SH_20",s[s.SH_21=61]="SH_21",s[s.SH_22=62]="SH_22",s[s.SH_23=63]="SH_23",s[s.SH_24=64]="SH_24",s[s.SH_25=65]="SH_25",s[s.SH_26=66]="SH_26",s[s.SH_27=67]="SH_27",s[s.SH_28=68]="SH_28",s[s.SH_29=69]="SH_29",s[s.SH_30=70]="SH_30",s[s.SH_31=71]="SH_31",s[s.SH_32=72]="SH_32",s[s.SH_33=73]="SH_33",s[s.SH_34=74]="SH_34",s[s.SH_35=75]="SH_35",s[s.SH_36=76]="SH_36",s[s.SH_37=77]="SH_37",s[s.SH_38=78]="SH_38",s[s.SH_39=79]="SH_39",s[s.SH_40=80]="SH_40",s[s.SH_41=81]="SH_41",s[s.SH_42=82]="SH_42",s[s.SH_43=83]="SH_43",s[s.SH_44=84]="SH_44",s[s.SH_45=85]="SH_45",s[s.SH_46=86]="SH_46",s[s.SH_47=87]="SH_47",s[s.SH_48=88]="SH_48",s[s.SH_49=89]="SH_49",s[s.SH_50=90]="SH_50",s[s.SH_51=91]="SH_51",s[s.SH_52=92]="SH_52",s[s.SH_53=93]="SH_53",s[s.SH_54=94]="SH_54",s[s.SH_55=95]="SH_55",s[s.SH_56=96]="SH_56",s[s.SH_57=97]="SH_57",s[s.SH_58=98]="SH_58",s[s.SH_59=99]="SH_59",s[s.SH_60=100]="SH_60",s[s.SH_61=101]="SH_61",s[s.SH_62=102]="SH_62",s[s.SH_63=103]="SH_63",s[s.SH_64=104]="SH_64",s[s.SH_65=105]="SH_65",s[s.SH_66=106]="SH_66",s[s.SH_67=107]="SH_67",s[s.SH_68=108]="SH_68",s[s.SH_69=109]="SH_69",s[s.SH_70=110]="SH_70",s[s.SH_71=111]="SH_71",s[s.UNDEFINED=112]="UNDEFINED"})(EF||(EF={}));Ht=class s extends G{static _GetSplatDataBytes(e){return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}static _GetSplatDataFloats(e){let t=s._GetSplatDataBytes(e),i=Float32Array.BYTES_PER_ELEMENT;if(t.byteLength%i!==0)throw new Error(`Gaussian splat data byte length (${t.byteLength}) is not divisible by ${i} and cannot be reinterpreted as Float32 data.`);if(t.byteOffset%i!==0){let r=new Uint8Array(t.byteLength);return r.set(t),new Float32Array(r.buffer,0,t.byteLength/i)}return new Float32Array(t.buffer,t.byteOffset,t.byteLength/i)}get disableDepthSort(){return this._disableDepthSort}set disableDepthSort(e){var t;!this._disableDepthSort&&e?((t=this._worker)==null||t.terminate(),this._worker=null,this._disableDepthSort=!0):this._disableDepthSort&&!e&&(this._disableDepthSort=!1,this._sortIsDirty=!0,this._instantiateWorker())}get viewDirectionFactor(){return S.OneReadOnly}get shDegree(){return this._shDegree}set shDegree(e){var r;let t=this._maxShDegree,i=Math.max(0,Math.min(Math.round(e),t));this._shDegree!==i&&(this._shDegree=i,(r=this.material)==null||r.resetDrawCache())}get maxShDegree(){return this._maxShDegree}get splatCount(){var e;return(e=this._splatIndex)==null?void 0:e.length}get splatsData(){return this._keepInRam?this._splatsData:null}get shData(){return this._keepInRam?this._shData:null}get covariancesATexture(){return this._covariancesATexture}get covariancesBTexture(){return this._covariancesBTexture}get centersTexture(){return this._centersTexture}get colorsTexture(){return this._colorsTexture}get rotationsATexture(){return this._rotationsATexture}get rotationsBTexture(){return this._rotationsBTexture}get rotationScaleTexture(){return this._rotationScaleTexture}get needsRotationScaleTextures(){return this._needsRotationScaleTextures}set needsRotationScaleTextures(e){var t;this._needsRotationScaleTextures!==e&&(this._needsRotationScaleTextures=e,e&&this._covariancesATexture&&(this._splatsData?this.updateData(this._splatsData,(t=this._shData)!=null?t:void 0,{flipY:!1}):X.Error("GaussianSplattingMeshBase: needsRotationScaleTextures was enabled after the mesh was already loaded, but the splat data is not kept in RAM. The rotation and scale matrix textures cannot be initialized. Please reload the mesh data via updateData() or construct with keepInRam=true.")))}get shTextures(){return this._shTextures}get kernelSize(){return this._material instanceof Qi?this._material.kernelSize:0}get compensation(){return this._material instanceof Qi?this._material.compensation:!1}set material(e){this._material=e,this._material.backFaceCulling=!1,this._material.cullBackFaces=!1,e.resetDrawCache()}get material(){return this._material}static _MakeSplatGeometryForMesh(e){let t=new fe,i=[-2,-2,0,2,-2,0,2,2,0,-2,2,0],r=[0,1,2,0,2,3],n=[],a=[];for(let o=0;ol+o*4))}t.positions=n,t.indices=a.flat(),t.applyToMesh(e)}constructor(e,t=null,i=null,r=!1){super(e,i),this._vertexCount=0,this._worker=null,this._modelViewProjectionMatrix=H.Identity(),this._canPostToWorker=!0,this._readyToDisplay=!1,this._sortRequestId=0,this._hasRenderedOnce=!1,this._covariancesATexture=null,this._covariancesBTexture=null,this._centersTexture=null,this._colorsTexture=null,this._rotationsATexture=null,this._rotationsBTexture=null,this._rotationScaleTexture=null,this._rotationDataA=null,this._rotationDataB=null,this._rotationScaleData=null,this._needsRotationScaleTextures=!1,this._splatPositions=null,this._splatIndex=null,this._shTextures=null,this._splatsData=null,this._shData=null,this._textureSize=new me(0,0),this._keepInRam=!1,this._alwaysRetainSplatsData=!1,this._flipY=!1,this._delayedTextureUpdate=null,this._useRGBACovariants=!1,this._material=null,this._tmpCovariances=[0,0,0,0,0,0],this._sortIsDirty=!1,this._cachedBoundingMin=null,this._cachedBoundingMax=null,this._shDegree=0,this._maxShDegree=0,this._cameraViewInfos=new Map,this.viewUpdateThreshold=s._DefaultViewUpdateThreshold,this._disableDepthSort=!1,this._loadingPromise=null,this._updateTextureFromData=(a,o,l,c,f)=>{this._getTextureDataUpdateEngine().updateTextureData(a.getInternalTexture(),o,0,c,l,f,0,0,!1)},this._updateTextureFromDataRect=(a,o,l,c,f,h)=>{this._getTextureDataUpdateEngine().updateTextureData(a.getInternalTexture(),o,l,c,f,h,0,0,!1)},this.subMeshes=[],new zi(0,0,4*s._BatchSize,0,6*s._BatchSize,this),this.setEnabled(!1),this._useRGBACovariants=!this.getEngine().isWebGPU&&this.getEngine().version===1,this._keepInRam=r,t&&(this._loadingPromise=this.loadFileAsync(t));let n=new Qi(this.name+"_material",this._scene);n.setSourceMesh(this),n.doNotSerialize=!0,this._material=n,this._scene.onCameraRemovedObservable.add(a=>{let o=a.uniqueId;if(this._cameraViewInfos.has(o)){let l=this._cameraViewInfos.get(o);l==null||l.mesh.dispose(),this._cameraViewInfos.delete(o)}})}getLoadingPromise(){return this._loadingPromise}getClassName(){return"GaussianSplattingMeshBase"}getTotalVertices(){return this._vertexCount}isReady(e=!1){var t;if(!super.isReady(e,!0))return!1;if(!this._readyToDisplay)return this._postToWorker(!0),!1;if(!this._hasRenderedOnce&&!this._disableDepthSort){let i=(t=this._scene.activeCameras)!=null&&t.length?this._scene.activeCameras:[this._scene.activeCamera],r=this.computeWorldMatrix(!0),n=!1;for(let a of i){if(!a)continue;let o=this._cameraViewInfos.get(a.uniqueId);if(!o||!o.splatIndexBufferSet){n=!0;continue}if(o.sortAppliedId!==o.sortRequestId){n=!0;continue}this._isSortStateDirty(o,r,a)&&(n=!0)}if(n)return this._postToWorker(!0),!1}if(!this._geometry&&this._cameraViewInfos.size&&(this._geometry=this._cameraViewInfos.values().next().value.mesh.geometry),this.material&&this.material.shadowDepthWrapper)for(let i of this._scene.lights){let r=i.getShadowGenerator();if(r){for(let n of this.subMeshes)if(!r.isReady(n,!0,!1))return!1}}return!0}_getCameraDirection(e){let t=e.getViewMatrix(),i=e.getProjectionMatrix(),r=W.Matrix[0];t.multiplyToRef(i,r);let n=this.computeWorldMatrix(!0),a=W.Matrix[1];n.multiplyToRef(t,a),n.multiplyToRef(r,this._modelViewProjectionMatrix);let o=W.Vector3[1];return o.set(a.m[2],a.m[6],a.m[10]),o.normalize(),o}_isSortStateDirty(e,t,i){let r=t.m,n=e.sortWorldMatrix.m;for(let l=0;l{f.frameIdLastUpdate!==i&&(r=!0)});let n=(l=this._scene.activeCameras)!=null&&l.length?this._scene.activeCameras:[this._scene.activeCamera],a=[];n.forEach(f=>{if(!f)return;let h=f.uniqueId,d=this._cameraViewInfos.get(h);if(d)a.push(d);else{let u=new G(this.name+"_cameraMesh_"+h,this._scene);if(u.doNotSerialize=!0,u.reservedDataStore={hidden:!0},u.setEnabled(!1),u.material=this.material,u.material&&u.material instanceof Qi){let p=u.material;p.getSourceMesh()||p.setSourceMesh(this)}s._MakeSplatGeometryForMesh(u);let m={camera:f,cameraDirection:new S(0,0,0),sortWorldMatrix:H.Identity(),sortCameraForward:new S(0,0,0),sortCameraPosition:new S(0,0,0),sortRequestId:0,sortAppliedId:0,mesh:u,frameIdLastUpdate:i,splatIndexBufferSet:!1};a.push(m),this._cameraViewInfos.set(h,m)}}),a.sort((f,h)=>f.splatIndexBufferSet!==h.splatIndexBufferSet?f.splatIndexBufferSet?1:-1:f.frameIdLastUpdate-h.frameIdLastUpdate);let o=this._worker||(gl==null?void 0:gl.sortSplats)||this._disableDepthSort;if((e||r)&&o&&((c=this._scene.activeCameras)!=null&&c.length||this._scene.activeCamera)&&this._canPostToWorker){let f=this.computeWorldMatrix(!0);a.forEach(h=>{let d=h.camera,u=this._getCameraDirection(d);if((e||this._isSortStateDirty(h,f,d))&&this._canPostToWorker){let m=d.getViewMatrix();h.cameraDirection.copyFrom(u),h.sortWorldMatrix.copyFrom(f),h.sortCameraForward.set(m.m[2],m.m[6],m.m[10]),h.sortCameraPosition.copyFrom(d.globalPosition),h.sortRequestId=++this._sortRequestId,h.frameIdLastUpdate=i,this._canPostToWorker=!1,this._worker?this._worker.postMessage({worldMatrix:f.m,cameraForward:[m.m[2],m.m[6],m.m[10]],cameraPosition:[d.globalPosition.x,d.globalPosition.y,d.globalPosition.z],depthMix:this._depthMix,cameraId:d.uniqueId,sortRequestId:h.sortRequestId},[this._depthMix.buffer]):gl!=null&&gl.sortSplats&&(gl.sortSplats(this._modelViewProjectionMatrix,this._splatPositions,this._splatIndex,this._scene.useRightHandedSystem),h.splatIndexBufferSet?h.mesh.thinInstanceBufferUpdated("splatIndex"):(h.mesh.thinInstanceSetBuffer("splatIndex",this._splatIndex,16,!1),h.splatIndexBufferSet=!0),h.sortAppliedId=h.sortRequestId,this._canPostToWorker=!0,this._readyToDisplay=!0)}})}else this._disableDepthSort&&(a.forEach(f=>{f.splatIndexBufferSet||(f.mesh.thinInstanceSetBuffer("splatIndex",this._splatIndex,16,!1),f.splatIndexBufferSet=!0)}),this._canPostToWorker=!0,this._readyToDisplay=!0)}render(e,t,i){this._postToWorker(),!this._geometry&&this._cameraViewInfos.size&&(this._geometry=this._cameraViewInfos.values().next().value.mesh.geometry);let r=this._scene.activeCamera.uniqueId,n=this._cameraViewInfos.get(r);if(!n||!n.splatIndexBufferSet)return this;this.onBeforeRenderObservable&&this.onBeforeRenderObservable.notifyObservers(this);let a=n.mesh;a.getWorldMatrix().copyFrom(this.getWorldMatrix());let l=this._scene.getEngine().currentRenderPassId,c=this.getMaterialForRenderPass(l);c&&a.setMaterialForRenderPass(l,c);let f=a.render(e,t,i);return this._hasRenderedOnce=!0,c&&a.setMaterialForRenderPass(l,void 0),this.onAfterRenderObservable&&this.onAfterRenderObservable.notifyObservers(this),f}static _TypeNameToEnum(e){switch(e){case"float":return 0;case"int":return 1;case"uint":return 2;case"double":return 3;case"uchar":return 4}return 5}static _ValueNameToEnum(e){switch(e){case"min_x":return 0;case"min_y":return 1;case"min_z":return 2;case"max_x":return 3;case"max_y":return 4;case"max_z":return 5;case"min_scale_x":return 6;case"min_scale_y":return 7;case"min_scale_z":return 8;case"max_scale_x":return 9;case"max_scale_y":return 10;case"max_scale_z":return 11;case"packed_position":return 12;case"packed_rotation":return 13;case"packed_scale":return 14;case"packed_color":return 15;case"x":return 16;case"y":return 17;case"z":return 18;case"scale_0":return 19;case"scale_1":return 20;case"scale_2":return 21;case"diffuse_red":case"red":return 22;case"diffuse_green":case"green":return 23;case"diffuse_blue":case"blue":return 24;case"f_dc_0":return 26;case"f_dc_1":return 27;case"f_dc_2":return 28;case"f_dc_3":return 29;case"opacity":return 25;case"rot_0":return 30;case"rot_1":return 31;case"rot_2":return 32;case"rot_3":return 33;case"min_r":return 34;case"min_g":return 35;case"min_b":return 36;case"max_r":return 37;case"max_g":return 38;case"max_b":return 39;case"f_rest_0":return 40;case"f_rest_1":return 41;case"f_rest_2":return 42;case"f_rest_3":return 43;case"f_rest_4":return 44;case"f_rest_5":return 45;case"f_rest_6":return 46;case"f_rest_7":return 47;case"f_rest_8":return 48;case"f_rest_9":return 49;case"f_rest_10":return 50;case"f_rest_11":return 51;case"f_rest_12":return 52;case"f_rest_13":return 53;case"f_rest_14":return 54;case"f_rest_15":return 55;case"f_rest_16":return 56;case"f_rest_17":return 57;case"f_rest_18":return 58;case"f_rest_19":return 59;case"f_rest_20":return 60;case"f_rest_21":return 61;case"f_rest_22":return 62;case"f_rest_23":return 63;case"f_rest_24":return 64;case"f_rest_25":return 65;case"f_rest_26":return 66;case"f_rest_27":return 67;case"f_rest_28":return 68;case"f_rest_29":return 69;case"f_rest_30":return 70;case"f_rest_31":return 71;case"f_rest_32":return 72;case"f_rest_33":return 73;case"f_rest_34":return 74;case"f_rest_35":return 75;case"f_rest_36":return 76;case"f_rest_37":return 77;case"f_rest_38":return 78;case"f_rest_39":return 79;case"f_rest_40":return 80;case"f_rest_41":return 81;case"f_rest_42":return 82;case"f_rest_43":return 83;case"f_rest_44":return 84;case"f_rest_45":return 85;case"f_rest_46":return 86;case"f_rest_47":return 87;case"f_rest_48":return 88;case"f_rest_49":return 89;case"f_rest_50":return 90;case"f_rest_51":return 91;case"f_rest_52":return 92;case"f_rest_53":return 93;case"f_rest_54":return 94;case"f_rest_55":return 95;case"f_rest_56":return 96;case"f_rest_57":return 97;case"f_rest_58":return 98;case"f_rest_59":return 99;case"f_rest_60":return 100;case"f_rest_61":return 101;case"f_rest_62":return 102;case"f_rest_63":return 103;case"f_rest_64":return 104;case"f_rest_65":return 105;case"f_rest_66":return 106;case"f_rest_67":return 107;case"f_rest_68":return 108;case"f_rest_69":return 109;case"f_rest_70":return 110;case"f_rest_71":return 111}return 112}static ParseHeader(e){let t=new Uint8Array(e),i=new TextDecoder().decode(t.slice(0,1024*10)),r=`end_header +`,n=i.indexOf(r);if(n<0||!i)return null;let a=parseInt(/element vertex (\d+)\n/.exec(i)[1]),o=/element chunk (\d+)\n/.exec(i),l=0;o&&(l=parseInt(o[1]));let c=0,f=0,h={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1,list:0},d;(function(A){A[A.Vertex=0]="Vertex",A[A.Chunk=1]="Chunk",A[A.SH=2]="SH",A[A.Unused=3]="Unused"})(d||(d={}));let u=1,m=[],p=[],_=i.slice(0,n).split(` +`),g=0;for(let A of _)if(A.startsWith("property ")){let[,R,P]=A.split(" "),D=s._ValueNameToEnum(P);D!=112&&(D>=111?g=4:D>=84?g=Math.max(g,3):D>=63?g=Math.max(g,2):D>=48&&(g=Math.max(g,1)));let M=s._TypeNameToEnum(R);u==1?(p.push({value:D,type:M,offset:f}),f+=h[R]):u==0?(m.push({value:D,type:M,offset:c}),c+=h[R]):u==2&&m.push({value:D,type:M,offset:c}),h[R]||X.Warn(`Unsupported property type: ${R}.`)}else if(A.startsWith("element ")){let[,R]=A.split(" ");R=="chunk"?u=1:R=="vertex"?u=0:R=="sh"?u=2:u=3}let v=new DataView(e,n+r.length),I=new ArrayBuffer(s._RowOutputLength*a),x=null,T=0;return g&&(T=((g+1)*(g+1)-1)*3,x=new ArrayBuffer(T*a)),{vertexCount:a,chunkCount:l,rowVertexLength:c,rowChunkLength:f,vertexProperties:m,chunkProperties:p,dataView:v,buffer:I,shDegree:g,shCoefficientCount:T,shBuffer:x}}static _GetCompressedChunks(e,t){if(!e.chunkCount)return null;let i=e.dataView,r=new Array(e.chunkCount);for(let n=0;n>8,_=255,g=0,v=0,I=0,x=[];for(let T=0;T=40&&A.value<=111){let P=A.value-40;if(A.type==4&&e.chunkCount){let D=c.getUint8(e.rowChunkLength*e.chunkCount+e.vertexCount*e.rowVertexLength+t*e.shCoefficientCount+P);x[P]=(D*(8/255)-4)*127.5+127.5}else{let D=Qt.Clamp(R*127.5+127.5,0,255);x[P]=D}}}if(m){let T=e.shDegree==1?3:e.shDegree==2?8:e.shDegree==3?15:24;for(let A=0;A{f.mesh.dispose()}),super.dispose(e,!0)}_copyTextures(e){var t,i,r,n,a,o,l;if(this._covariancesATexture=(t=e.covariancesATexture)==null?void 0:t.clone(),this._covariancesBTexture=(i=e.covariancesBTexture)==null?void 0:i.clone(),this._centersTexture=(r=e.centersTexture)==null?void 0:r.clone(),this._colorsTexture=(n=e.colorsTexture)==null?void 0:n.clone(),e._shTextures){this._shTextures=[];for(let c of e._shTextures)(a=this._shTextures)==null||a.push(c.clone())}e._rotationsATexture&&(this._rotationsATexture=e._rotationsATexture.clone(),this._rotationsBTexture=(o=e._rotationsBTexture)==null?void 0:o.clone(),this._rotationScaleTexture=(l=e._rotationScaleTexture)==null?void 0:l.clone())}clone(e=""){let t=new s(e,void 0,this.getScene());t._copySource(this),t.makeGeometryUnique(),t._vertexCount=this._vertexCount,t._copyTextures(this),t._modelViewProjectionMatrix=H.Identity(),t._splatPositions=this._splatPositions,t._readyToDisplay=!1,t._hasRenderedOnce=!1,t._disableDepthSort=this._disableDepthSort,t._instantiateWorker();let i=this.getBoundingInfo();return t.getBoundingInfo().reConstruct(i.minimum,i.maximum,this.getWorldMatrix()),t.forcedInstanceCount=this.forcedInstanceCount,t.setEnabled(!0),t}_makeEmptySplat(e,t,i,r){let n=this._useRGBACovariants?4:2;this._splatPositions[4*e+0]=0,this._splatPositions[4*e+1]=0,this._splatPositions[4*e+2]=0,t[e*4+0]=Lt(0),t[e*4+1]=Lt(0),t[e*4+2]=Lt(0),t[e*4+3]=Lt(0),i[e*n+0]=Lt(0),i[e*n+1]=Lt(0),r[e*4+3]=0}_makeSplat(e,t,i,r,n,a,o,l,c,f=e){let h=W.Matrix[0],d=W.Matrix[1],u=W.Quaternion[0],m=this._useRGBACovariants?4:2,p=t[8*f+0],_=t[8*f+1]*(c?-1:1),g=t[8*f+2];if(this._splatPositions[4*e+0]=p,this._splatPositions[4*e+1]=_,this._splatPositions[4*e+2]=g,o.minimizeInPlaceFromFloats(p,_,g),l.maximizeInPlaceFromFloats(p,_,g),u.set((i[32*f+28+1]-127.5)/127.5,(i[32*f+28+2]-127.5)/127.5,(i[32*f+28+3]-127.5)/127.5,-(i[32*f+28+0]-127.5)/127.5),u.normalize(),u.toRotationMatrix(h),H.ScalingToRef(t[8*f+3+0]*2,t[8*f+3+1]*2,t[8*f+3+2]*2,d),this._needsRotationScaleTextures){(!this._rotationDataA||this._rotationDataA.lengthnew Vr(v,I,x,T,this._scene,!1,!1,2,1),o=(v,I,x,T)=>new Vr(v,I,x,T,this._scene,!1,!1,2,0),l=(v,I,x)=>new Vr(null,v,I,x,this._scene,!1,!1,1,7),c=(v,I,x,T)=>new Vr(v,I,x,T,this._scene,!1,!1,2,2),f=this._covariancesATexture===null,h=this._textureSize.y!=n.y;if(!f&&!h){this._setDelayedTextureUpdate(e,t,i,r);let v=Float32Array.from(this._splatPositions),I=this._vertexCount;if(this._worker&&this._worker.postMessage({positions:v,vertexCount:I},[v.buffer]),r&&!this._shTextures){this._shTextures=[];for(let x=0;xt||this._splatPositions===null||this._cachedBoundingMin===null||this._cachedBoundingMax===null||this._covariancesATexture===null?!1:this._getTextureSize(t).y===this._textureSize.y}_notifyWorkerNewData(){if(this._worker){let e=Float32Array.from(this._splatPositions),t=this._vertexCount;this._worker.postMessage({positions:e,vertexCount:t},[e.buffer])}this._sortIsDirty=!0}*_updateData(e,t,i,r,{flipY:n=!1,previousVertexCount:a=0}={},o){var P;this._covariancesATexture||(this._readyToDisplay=!1),this._flipY=n;let l=new Uint8Array(e),c=new Float32Array(l.buffer);this._keepInRam||this._alwaysRetainSplatsData?(this._splatsData=l.buffer,this._shData=i?i.map(D=>new Uint8Array(D)):null):(this._splatsData=null,this._shData=null);let f=l.length/s._RowOutputLength;f!=this._vertexCount&&this._updateSplatIndexBuffer(f),this._vertexCount=f,this._maxShDegree=i&&o!=null?o:0,this._shDegree=this._maxShDegree;let h=this._getTextureSize(f),d=h.x*h.y,u=(P=s.ProgressiveUpdateAmount)!=null?P:h.y;r&&this._onIndexDataReceived(r,d);let m=new S(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),p=new S(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),_=this._useRGBACovariants?4:2,g=new Uint16Array(d*4),v=new Uint16Array(_*d),I=new Uint8Array(d*4),x=this._canReuseCachedData(a,f),T=x?Math.floor(a/h.x):0,A=T*h.x,R=this._splatPositions;if(this._splatPositions=new Float32Array(4*d),x&&(this._splatPositions.set(R.subarray(0,a*4)),m.copyFrom(this._cachedBoundingMin),p.copyFrom(this._cachedBoundingMax),this._onIncrementalUpdateStart(h)),s.ProgressiveUpdateAmount){x||this._updateTextures(g,v,I,i),this.setEnabled(!0);let D=Math.ceil(h.y/u);for(let M=0;M{i.mesh.thinInstanceSetBuffer("splatIndex",this._splatIndex,16,!1)})}(!this._depthMix||e!=this._depthMix.length)&&!FT&&(this._depthMix=new BigInt64Array(t)),this.forcedInstanceCount=Math.max(t>>4,1)}_getTextureDataUpdateEngine(){return this.getEngine()}_updateShTextureData(e,t,i,r,n){let a=this._getTextureDataUpdateEngine();if(!a._gl&&!a.isWebGPU){let m=e.getInternalTexture(),p=i*m.height*16,_;if(t.byteLength===p&&t.byteOffset%Uint32Array.BYTES_PER_ELEMENT===0)_=new Uint32Array(t.buffer,t.byteOffset,t.byteLength/Uint32Array.BYTES_PER_ELEMENT);else{let g=new Uint8Array(p);g.set(t.subarray(0,Math.min(t.byteLength,p))),_=new Uint32Array(g.buffer)}a.updateRawTexture(m,_,m.format,m.invertY,null,m.type,m._useSRGBBuffer);return}let o=16,l=4,c=r*i,f=Math.floor(t.byteLength/o);if(c>=f)return;let h=Math.min(n*i,f-c);if(h<=0)return;let d=(m,p)=>new Uint32Array(t.buffer,t.byteOffset+m,p*l),u=Math.floor(h/i);if(u>0){let m=u*i;this._updateTextureFromData(e,d(c*o,m),i,r,u),h-=m}if(h>0){let m=(c+u*i)*o;this._updateTextureFromDataRect(e,d(m,h),0,r+u,h,1)}}_updateSubTextures(e,t,i,r,n,a,o){let l=this._getTextureSize(this._vertexCount),c=this._useRGBACovariants?4:2,f=n*l.x,h=a*l.x,d=new Uint16Array(t.buffer,f*4*Uint16Array.BYTES_PER_ELEMENT,h*4),u=new Uint16Array(i.buffer,f*c*Uint16Array.BYTES_PER_ELEMENT,h*c),m=new Uint8Array(r.buffer,f*4,h*4),p=new Float32Array(e.buffer,f*4*Float32Array.BYTES_PER_ELEMENT,h*4);if(this._updateTextureFromData(this._covariancesATexture,d,l.x,n,a),this._updateTextureFromData(this._covariancesBTexture,u,l.x,n,a),this._updateTextureFromData(this._centersTexture,p,l.x,n,a),this._updateTextureFromData(this._colorsTexture,m,l.x,n,a),this._rotationsATexture&&this._rotationDataA){let _=new Uint16Array(this._rotationDataA.buffer,f*4*Uint16Array.BYTES_PER_ELEMENT,h*4),g=new Uint16Array(this._rotationDataB.buffer,f*4*Uint16Array.BYTES_PER_ELEMENT,h*4),v=new Uint16Array(this._rotationScaleData.buffer,f*4*Uint16Array.BYTES_PER_ELEMENT,h*4);this._updateTextureFromData(this._rotationsATexture,_,l.x,n,a),this._updateTextureFromData(this._rotationsBTexture,g,l.x,n,a),this._updateTextureFromData(this._rotationScaleTexture,v,l.x,n,a)}if(o)for(let _=0;_{this._canPostToWorker=!0},this._worker.onmessage=i=>{let r=this._vertexCount+15&-16;if(i.data.depthMix.length!=r){this._canPostToWorker=!0,this._postToWorker(!0),this._sortIsDirty=!1;return}this._depthMix=i.data.depthMix;let n=i.data.cameraId,a=i.data.sortRequestId,o=new Uint32Array(i.data.depthMix.buffer);if(this._splatIndex)for(let c=0;ci&&(X.Error("GaussianSplatting texture size: ("+i+", "+r+"), maxTextureSize: "+i),r=i),new me(i,r)}_onWorkerCreated(e){}bindExtraEffectUniforms(e){}_appendSourceToArrays(e,t,i,r,n,a,o,l){let c=e._vertexCount,f=16,h=e._splatsData;if(!h||c===0)return;let d=s._GetSplatDataBytes(h),u=s._GetSplatDataFloats(h);for(let m=0;mo||Math.abs(r-a)>o)return X.Error("Gaussian Splatting bakeTransformIntoVertices does not support non-uniform scaling"),this;let l=new Uint8Array(t),c=new Float32Array(t),f=W.Vector3[0],h,d=W.Quaternion[0],u=W.Quaternion[1];for(e.decompose(f,u,f),h=0;h{if(o.data.positions)e=o.data.positions;else if(o.data.partMatrices)a=o.data.partMatrices;else if(o.data.partIndices!==void 0)n=o.data.partIndices;else{let l=o.data.cameraId,c=o.data.sortRequestId,f=o.data.worldMatrix,h=o.data.cameraForward,d=o.data.cameraPosition;if(t=o.data.depthMix,!e||!h){s.postMessage({depthMix:t,cameraId:l,sortRequestId:c},[t.buffer]);return}let u=e.length/4+15&-16;i=new Uint32Array(t.buffer),r=new Float32Array(t.buffer);for(let _=0;_[h[0]*_[0]+h[1]*_[1]+h[2]*_[2],h[0]*_[4]+h[1]*_[5]+h[2]*_[6],h[0]*_[8]+h[1]*_[9]+h[2]*_[10],h[0]*_[12]+h[1]*_[13]+h[2]*_[14]-m];try{if(a&&n){let _=a.map(v=>p(v)),g=n.length;for(let v=0;v{ut();eo();hc();Ee();Gh=class s extends G{get partIndex(){return this._partIndex}get proxiedMesh(){return this.compoundSplatMesh}constructor(e,t,i,r,n,a,o,l=o){super(e,t),this._partIndex=r,this._vertexCount=a,this._splatsDataOffset=o,this._shDataOffset=l,this._minimum=n.minimum.clone(),this._maximum=n.maximum.clone(),this.compoundSplatMesh=i,this._applyBoundingInfo(),this.compoundSplatMesh.setWorldMatrixForPart(this.partIndex,this.getWorldMatrix()),this.onAfterWorldMatrixUpdateObservable.add(()=>{this.compoundSplatMesh.setWorldMatrixForPart(this.partIndex,this.getWorldMatrix())})}updateBoundingInfoFromPartData(){this._applyBoundingInfo()}updateBoundingInfoFromProxiedMesh(){this.updateBoundingInfoFromPartData()}_applyBoundingInfo(){this.setBoundingInfo(new ei(this._minimum.clone(),this._maximum.clone()))}getClassName(){return"GaussianSplattingPartProxyMesh"}updatePartIndex(e){this._partIndex=e}updatePartMetadata(e,t,i=t){this._vertexCount=e,this._splatsDataOffset=t,this._shDataOffset=i}get isVisible(){return this.compoundSplatMesh.getPartVisibility(this.partIndex)>0}set isVisible(e){this.compoundSplatMesh.setPartVisibility(this.partIndex,e?1:0)}get visibility(){return this.compoundSplatMesh.getPartVisibility(this.partIndex)}set visibility(e){this.compoundSplatMesh.setPartVisibility(this.partIndex,e)}intersects(e){let t=new wi,i=this.getBoundingInfo();return!i||!e.intersectsSphere(i.boundingSphere)||!e.intersectsBox(i.boundingBox)||(t.hit=!0,t.pickedMesh=this,t.distance=S.Distance(e.origin,i.boundingSphere.center),t.subMeshId=0),t}serialize(e={}){e=super.serialize(e),e.subMeshes=[],e.geometryUniqueId=void 0,e.geometryId=void 0,e.materialUniqueId=void 0,e.materialId=void 0,e.instances=[],e.actions=void 0,e.type=this.getClassName(),e.compoundSplatMeshId=this.compoundSplatMesh.id,e.partIndex=this._partIndex,e.vertexCount=this._vertexCount,e.splatsDataOffset=this._splatsDataOffset,e.shDataOffset=this._shDataOffset;let t=this.getBoundingInfo();return e.boundingInfo={minimum:t.minimum.asArray(),maximum:t.maximum.asArray()},e}static Parse(e,t){var h,d,u,m;let i=e.partIndex,r=(h=e.compoundSplatMesh)!=null?h:t.getLastMeshById(e.compoundSplatMeshId);if(!r)throw new Error(`GaussianSplattingPartProxyMesh: compound mesh not found with ID ${e.compoundSplatMeshId}`);let n=S.FromArray(e.boundingInfo.minimum),a=S.FromArray(e.boundingInfo.maximum),o=new ei(n,a),l=(d=e.vertexCount)!=null?d:0,c=(u=e.splatsDataOffset)!=null?u:0,f=(m=e.shDataOffset)!=null?m:c;return new s(e.name,t,r,i,o,l,c,f)}};G._GaussianSplattingPartProxyMeshParser=Gh.Parse});function a8(s){let e=[],t=s.length,i=0;for(;i{Ee();OT();vF();yp();ac();ut();NT();SF();hf=32,kh=16;fs=class s extends Ht{get partIndicesTexture(){return this._partIndicesTexture}constructor(e,t=null,i=null,r=!1,n=!1){super(e,t,i,r),this._partProxies=[],this._partMatrices=[],this._rebuilding=!1,this._partVisibility=[],this._partIndicesTexture=null,this._partIndices=null,this._alwaysRetainSplatsData=!0,this._needsRotationScaleTextures=n}getClassName(){return"GaussianSplattingMesh"}isReady(e=!1){for(let t of this._partProxies)t&&t.computeWorldMatrix(!0);return super.isReady(e)}dispose(e){var t;for(let i of this._partProxies)i.dispose();(t=this._partIndicesTexture)==null||t.dispose(),this._partProxies=[],this._partMatrices=[],this._partVisibility=[],this._partIndicesTexture=null,super.dispose(e)}_onWorkerCreated(e){e.postMessage({partMatrices:this._partMatrices.map(t=>new Float32Array(t.m))}),e.postMessage({partIndices:this._partIndices?new Uint8Array(this._partIndices):null})}_onIndexDataReceived(e,t){this._partIndices=new Uint8Array(t),this._partIndices.set(e)}get isCompound(){return this._partMatrices.length>0}_instantiateWorker(){if(this._rebuilding&&this._worker){this._updateSplatIndexBuffer(this._vertexCount);return}super._instantiateWorker()}_onIncrementalUpdateStart(e){var t;this._ensurePartIndicesTexture(e,(t=this._partIndices)!=null?t:void 0)}_notifyWorkerNewData(){var e;super._notifyWorkerNewData(),this._worker&&this._worker.postMessage({partIndices:(e=this._partIndices)!=null?e:null})}bindExtraEffectUniforms(e){var r;if(!this._partIndicesTexture)return;e.setTexture("partIndicesTexture",this._partIndicesTexture);let t=new Float32Array(this.partCount*16);for(let n=0;nnew Float32Array(i.m))}),this._postToWorker(!0)))}getWorldMatrixForPart(e){var t;return(t=this._partMatrices[e])!=null?t:this.getWorldMatrix()}getPartVisibility(e){var t;return(t=this._partVisibility[e])!=null?t:1}setPartVisibility(e,t){this._partVisibility[e]=Math.max(0,Math.min(1,t))}_copyTextures(e){var t;super._copyTextures(e),this._partIndicesTexture=(t=e._partIndicesTexture)==null?void 0:t.clone()}_onUpdateTextures(e){let t=(i,r,n,a)=>new Vr(i,r,n,a,this._scene,!1,!1,2,0);if(this._partIndices){let i=new Uint8Array(this._partIndices);if(!this._partIndicesTexture)this._partIndicesTexture=t(i,e.x,e.y,6),this._partIndicesTexture.wrapU=0,this._partIndicesTexture.wrapV=0;else{let r=this._partIndicesTexture.getSize();r.width!==e.x||r.height!==e.y?(this._partIndicesTexture.dispose(),this._partIndicesTexture=t(i,e.x,e.y,6),this._partIndicesTexture.wrapU=0,this._partIndicesTexture.wrapV=0):this._updateTextureFromData(this._partIndicesTexture,i,e.x,0,e.y)}}}_updateSubTextures(e,t,i,r,n,a,o,l){if(super._updateSubTextures(e,t,i,r,n,a,o),l&&this._partIndicesTexture){let c=this._getTextureSize(this._vertexCount),f=n*c.x,h=a*c.x,d=new Uint8Array(l.buffer,f,h);this._updateTextureFromData(this._partIndicesTexture,d,c.x,n,a),this._worker&&this._worker.postMessage({partIndices:l})}}_ensurePartIndicesTexture(e,t){if(!t||this._partIndicesTexture)return;let i=new Uint8Array(this._partIndices);this._partIndicesTexture=new Vr(i,e.x,e.y,6,this._scene,!1,!1,2,0),this._partIndicesTexture.wrapU=0,this._partIndicesTexture.wrapV=0,this._worker&&this._worker.postMessage({partIndices:t!=null?t:null})}_appendPartSourceToArrays(e,t,i,r,n,a,o,l){this._appendSourceToArrays(e,t,i,r,n,a,o,l)}_createRetainedPartSource(e){var o,l,c,f;if(!this._splatsData||this._shDegree>0&&!this._shData)return null;let t=e._splatsDataOffset*hf,i=e._vertexCount*hf,r=e._shDataOffset*kh,n=e._vertexCount*kh,a=Ht._GetSplatDataBytes(this._splatsData);return{name:e.name,_vertexCount:e._vertexCount,_splatsData:a.subarray(t,t+i),_shData:(l=(o=this._shData)==null?void 0:o.map(h=>h.subarray(r,r+n)))!=null?l:null,_shDegree:(f=(c=this._shData)==null?void 0:c.length)!=null?f:0,isCompound:!1,getWorldMatrix:()=>e.getWorldMatrix(),getBoundingInfo:()=>e.getBoundingInfo(),dispose:()=>{}}}_retainMergedPartData(e,t,i,r){if(!this._keepInRam&&!this._alwaysRetainSplatsData){this._splatsData=null,this._shData=null;return}let n=new Uint8Array(t*hf),a=0;this._splatsData&&e>0&&(n.set(Ht._GetSplatDataBytes(this._splatsData).subarray(0,e*hf),a),a+=e*hf);for(let c of i){if(!c._splatsData)continue;let f=c._vertexCount*hf;n.set(Ht._GetSplatDataBytes(c._splatsData).subarray(0,f),a),a+=f}if(this._splatsData=n.buffer,r<=0){this._shData=null;return}let o=[];for(let c=0;c0){let c=e*kh;for(let f=0;fV+O._vertexCount,0),n=i+r,a=this._getTextureSize(n),o=a.x*a.y,l=this._useRGBACovariants?4:2,c=new Uint16Array(o*4),f=new Uint16Array(l*o),h=new Uint8Array(o*4),d=(i===0||this._shData!==null)&&e.every(V=>V._shData!==null),u=d?Math.max(this._shDegree,...e.map(V=>V._shDegree)):0,m;if(d&&u>0){m=[];for(let O=0;O0?1:0),this._partIndices=new Uint8Array(o),this._partIndices.set(T.subarray(0,i));let A=[],R=[],P=i,D=Vh(this._scene.getEngine());for(let V of e){if(x>=D)throw new Error(`Cannot add part, as the maximum part count (${D}) has been reached`);let O=x++;A.push(O),R.push(P),this._partIndices.fill(O,P,P+V._vertexCount),P+=V._vertexCount}if(!p&&i>0){if(this._partProxies.length>0){let V=0;if(!this._partProxies[0]&&this._splatsData){let O=this._partProxies.reduce((k,z)=>k+(z?z._vertexCount:0),0),U=i-O;if(U>0){let k=Ht._GetSplatDataBytes(this._splatsData),z=Ht._GetSplatDataFloats(this._splatsData);for(let Z=0;Zq+(Y?Y._vertexCount:0),0),U=i-O,k=new Array(this._partProxies.length).fill(null),z=new Array(this._partProxies.length).fill(null),Z=new Array(this._partProxies.length).fill(0);!this._partProxies[0]&&this._splatsData&&U>0&&(k[0]=Ht._GetSplatDataBytes(this._splatsData),z[0]=Ht._GetSplatDataFloats(this._splatsData),Z[0]=0);let J=U;for(let q=0;qnew Float32Array(O.m))}),this._canPostToWorker=!0,this._postToWorker(!0)),{proxyMeshes:V,assignedPartIndices:A}}catch(V){throw F&&(this._rebuilding=!1,this._canPostToWorker=!0),V}}addPart(e,t=!0){let{proxyMeshes:i}=this._addPartsInternal([e],t);return i[0]}removePart(e){var r,n,a,o,l,c,f,h;if(e<0||e>=this.partCount)throw new Error(`Part index ${e} is out of range [0, ${this.partCount})`);let t=[];for(let d=0;dd.oldIndex-u.oldIndex);for(let{proxyMesh:d,source:u}of t){if(!u._splatsData)throw new Error(`Cannot remove part: the source data for part "${d.name}" is not available.`);if(u._shDegree>0&&!u._shData)throw new Error(`Cannot remove part: the SH data for part "${d.name}" is not available.`)}if(this._worker&&(this._worker.terminate(),this._worker=null),(n=this._covariancesATexture)==null||n.dispose(),(a=this._covariancesBTexture)==null||a.dispose(),(o=this._centersTexture)==null||o.dispose(),(l=this._colorsTexture)==null||l.dispose(),(c=this._rotationsATexture)==null||c.dispose(),(f=this._rotationsBTexture)==null||f.dispose(),(h=this._rotationScaleTexture)==null||h.dispose(),this._covariancesATexture=null,this._covariancesBTexture=null,this._centersTexture=null,this._colorsTexture=null,this._rotationsATexture=null,this._rotationsBTexture=null,this._rotationScaleTexture=null,this._shTextures){for(let d of this._shTextures)d.dispose();this._shTextures=null}this._partIndicesTexture&&(this._partIndicesTexture.dispose(),this._partIndicesTexture=null),this._vertexCount=0,this._splatPositions=null,this._partIndices=null,this._partMatrices=[],this._partVisibility=[],this._cachedBoundingMin=null,this._cachedBoundingMax=null,this._splatsData=null,this._shData=null,this._shDegree=0;let i=this._partProxies[e];if(i&&i.dispose(),this._partProxies=[],t.length===0){this.setEnabled(!1);return}this._rebuilding=!0,this._canPostToWorker=!1;try{let d=t.map(p=>p.source),{proxyMeshes:u}=this._addPartsInternal(d,!1);for(let p=0;pnew Float32Array(p.m))}),this._canPostToWorker=!0,this._postToWorker(!0)}catch(d){throw this._rebuilding=!1,this._canPostToWorker=!0,d}}serialize(e={},t="base64"){if(e=super.serialize(e),e.subMeshes=[],e.geometryUniqueId=void 0,e.geometryId=void 0,e.materialUniqueId=void 0,e.materialId=void 0,e.instances=[],e.actions=void 0,e.type=this.getClassName(),e.keepInRam=this._keepInRam,e.disableDepthSort=this._disableDepthSort,e.viewUpdateThreshold=this.viewUpdateThreshold,e._flipY=this._flipY,this._splatsData&&(e.splatsData=t==="base64"?$s(this._splatsData):this._splatsData),this._shData&&(e.shData=t==="base64"?this._shData.map($s):this._shData),this._partIndices){let i=a8(this._partIndices.subarray(0,this._vertexCount));e.partIndices=t==="base64"?$s(i):i}return this._partProxies.length&&(e.partProxies=this._partProxies.filter(i=>!!i).map(i=>i.serialize())),e}static _ParseInternal(e,t,i){var f,h,d;let r=new i(e.name,null,t,e.keepInRam);r.disableDepthSort=(f=e.disableDepthSort)!=null?f:!1,r.viewUpdateThreshold=(h=e.viewUpdateThreshold)!=null?h:Ht._DefaultViewUpdateThreshold;let n=e.splatsData;typeof n=="string"&&(n=nc(n));let a=e.shData,o;if(Array.isArray(a)&&a.length){let u=[];for(let m=0,p=a.length;m{ut();Ac();Rc();We();gt();Uv();uo();Ds();At();Ha();Pp=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}},BT=class extends Pp{},UT=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}},hs=class extends Pp{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 sa){let h=o.sourceMesh;t.has(h.uniqueId)&&(c.add(h.uniqueId),i.dependedBy.get(h.uniqueId).add(l))}let f=i.dependedBy.get(l);for(let h of o.getDescendants()){let d=h.uniqueId;t.has(d)&&(f.add(d),i.dependsOn.get(d).add(l))}}let r=[],n=[];for(let o of e){let l=o.uniqueId;i.dependsOn.get(l).size===0&&(n.push(o),t.delete(l))}let a=n;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&&(X.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach(o=>{X.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 n of i.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,n,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 we&&this.cameras.indexOf(e)!==-1}_isValidHierarchy(){for(let e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return X.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 X.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 X.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 X.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;return!0}instantiateModelsToScene(e,t=!1,i){this._isValidHierarchy()||se.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");let r={},n={},a=new UT,o=[],l=[],c={doNotInstantiate:!0,...i},f=(p,_)=>{if(r[p.uniqueId]=_.uniqueId,n[_.uniqueId]=_,e&&(_.name=e(p.name)),_ instanceof G){let g=_;if(g.morphTargetManager){let v=p.morphTargetManager;g.morphTargetManager=v.clone();for(let I=0;I{if(f(p,_),p.parent){let g=r[p.parent.uniqueId],v=n[g];v?_.parent=v:_.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 v=p.material;if(l.indexOf(v)===-1){let I=v.clone(e?e(v.name):"Clone of "+v.name);if(l.push(v),r[v.uniqueId]=I.uniqueId,n[I.uniqueId]=I,v.getClassName()==="MultiMaterial"){let x=v;for(let T of x.subMaterials)T&&(I=T.clone(e?e(T.name):"Clone of "+T.name),l.push(T),r[T.uniqueId]=I.uniqueId,n[I.uniqueId]=I);x.subMaterials=x.subMaterials.map(T=>T&&n[r[T.uniqueId]])}}g.getClassName()!=="InstancedMesh"&&(g.material=n[r[v.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,v=r[g.uniqueId],x=(typeof v=="number"?n[v]:g).createInstance(_.name);m(_,x)}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 v=n[r[g.uniqueId]];if(!v||v.isAnInstance||(v.skeleton=_,o.indexOf(_)!==-1))continue;o.push(_);for(let I of _.bones)I._linkedTransformNode&&(I._linkedTransformNode=n[r[I._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=>n[r[g.uniqueId]]||g);a.animationGroups.push(_)}return a}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||se.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 n of r.bones)i.add(n);for(let r of t)r.parent&&!i.has(r.parent)&&(r.setParent?r.setParent(null):r.parent=null)}}removeAllFromScene(){this._isValidHierarchy()||se.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 n=this.animationGroups.slice(0);for(let p of n)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 h=this.textures.slice(0);for(let p of h)p.dispose();this.textures.length=0;let d=this.reflectionProbes.slice(0);for(let p of d)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 n=!0;if(i){for(let a of i)if(r===a){n=!1;break}}n&&(t.push(r),r._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,e===void 0&&(e=new BT);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 G("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 X.Error("No scene available to merge animations to"),[];let r=i||(l=>{let c,f=l.animations.length?l.animations[0].targetProperty:"",h=l.name.split(".").join("").split("_primitive")[0];switch(f){case"position":case"rotationQuaternion":c=e.getTransformNodeByName(l.name)||e.getTransformNodeByName(h);break;case"influence":c=e.getMorphTargetByName(l.name)||e.getMorphTargetByName(h);break;default:c=e.getNodeByName(l.name)||e.getNodeByName(h)}return c}),n=this.getNodes();for(let l of n){let c=r(l);if(c!==null){for(let f of l.animations){let h=c.animations.filter(d=>d.targetProperty===f.targetProperty);for(let d of h){let u=c.animations.indexOf(d,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 G?(r.geometry&&this.geometries.indexOf(r.geometry)===-1&&this.geometries.push(r.geometry),this.meshes.push(r)):r instanceof sa?this.meshes.push(r):r instanceof at?this.transformNodes.push(r):r instanceof tt?this.lights.push(r):r instanceof we&&this.cameras.push(r),r instanceof Zt){if(r.material&&this.materials.indexOf(r.material)===-1){this.materials.push(r.material);for(let n of r.material.getActiveTextures())this.textures.indexOf(n)===-1&&this.textures.push(n)}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 n of r.getChildren())i.has(n)||t.push(n);i.add(r)}this.populateRootNodes()}_getByTags(e,t,i){if(t===void 0)return e;let r=[];for(let n in e){let a=e[n];st&&st.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 El,TF=C(()=>{ac();El=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 WI(this.readUint8Array(e))}skipBytes(e){this._dataByteOffset+=e,this.byteOffset+=e}}});function VT(s,e,t,i){let r={externalResourceFunction:i};return t&&(r.uri=e==="file:"?t:e+t),ArrayBuffer.isView(s)?GLTFValidator.validateBytes(s,r):GLTFValidator.validateString(s,r)}function l8(){let s=[];onmessage=e=>{let t=e.data;switch(t.id){case"init":{importScripts(t.url);break}case"validate":{VT(t.data,t.rootUrl,t.fileName,i=>new Promise((r,n)=>{let a=s.length;s.push({resolve:r,reject:n}),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":{s[t.index].resolve(t.value);break}case"getExternalResource.reject":{s[t.index].reject(t.reason);break}}}}var uf,AF=C(()=>{At();uf=class s{static ValidateAsync(e,t,i,r){return typeof Worker=="function"?new Promise((n,a)=>{let o=`${VT}(${l8})()`,l=URL.createObjectURL(new Blob([o],{type:"application/javascript"})),c=new Worker(l),f=d=>{c.removeEventListener("error",f),c.removeEventListener("message",h),a(d)},h=d=>{let u=d.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",h),s._LastResults=u.value,n(u.value),c.terminate();break}case"validate.reject":c.removeEventListener("error",f),c.removeEventListener("message",h),a(u.reason),c.terminate()}};if(c.addEventListener("error",f),c.addEventListener("message",h),c.postMessage({id:"init",url:se.GetBabylonScriptURL(this.Configuration.url)}),ArrayBuffer.isView(e)){let d=e.slice();c.postMessage({id:"validate",data:d,rootUrl:t,fileName:i},[d.buffer])}else c.postMessage({id:"validate",data:e,rootUrl:t,fileName:i})}):(this._LoadScriptPromise||(this._LoadScriptPromise=se.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>VT(e,t,i,r)))}};uf.Configuration={url:`${se._DefaultCdnUrl}/gltf_validator.js`};uf._LastResults=null});var va,Wh,RF=C(()=>{va="Z2xURg",Wh={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad(s){return s.indexOf("asset")!==-1&&s.indexOf("version")!==-1||s.startsWith("data:base64,"+va)||s.startsWith("data:;base64,"+va)||s.startsWith("data:application/octet-stream;base64,"+va)||s.startsWith("data:model/gltf-binary;base64,"+va)}}});function xF(s,e,t){try{return Promise.resolve(new Uint8Array(s,e,t))}catch(i){return Promise.reject(i)}}function c8(s,e,t){try{if(e<0||e>=s.byteLength)throw new RangeError("Offset is out of range.");if(e+t>s.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(s.buffer,s.byteOffset+e,t))}catch(i){return Promise.reject(i)}}var mf,vl,or,Lp,f8,GT,Po,kT=C(()=>{dt();At();Rn();df();We();TF();AF();RF();Wa();Jf();(function(s){s[s.AUTO=0]="AUTO",s[s.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(mf||(mf={}));(function(s){s[s.NONE=0]="NONE",s[s.FIRST=1]="FIRST",s[s.ALL=2]="ALL"})(vl||(vl={}));(function(s){s[s.LOADING=0]="LOADING",s[s.READY=1]="READY",s[s.COMPLETE=2]="COMPLETE"})(or||(or={}));Lp=class{constructor(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=vl.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=mf.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}},f8=new Lp,GT=class extends Lp{constructor(){super(...arguments),this.extensionOptions={},this.preprocessUrlAsync=e=>Promise.resolve(e)}copyFrom(e){var t,i,r,n,a,o,l,c,f,h,d,u,m,p,_,g,v,I,x,T,A,R,P,D,M,F;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=(n=e.capturePerformanceCounters)!=null?n: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=(h=e.loadAllMaterials)!=null?h:this.loadAllMaterials,this.loadMorphTargets=(d=e.loadMorphTargets)!=null?d: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=(v=e.skipMaterials)!=null?v:this.skipMaterials,this.targetFps=(I=e.targetFps)!=null?I:this.targetFps,this.transparencyAsCoverage=(x=e.transparencyAsCoverage)!=null?x:this.transparencyAsCoverage,this.useClipPlane=(T=e.useClipPlane)!=null?T:this.useClipPlane,this.useGltfTextureNames=(A=e.useGltfTextureNames)!=null?A:this.useGltfTextureNames,this.useOpenPBR=(R=e.useOpenPBR)!=null?R:this.useOpenPBR,this.useRangeRequests=(P=e.useRangeRequests)!=null?P:this.useRangeRequests,this.useSRGBBuffers=(D=e.useSRGBBuffers)!=null?D:this.useSRGBBuffers,this.validate=(M=e.validate)!=null?M:this.validate,this.dontUseTransmissionHelper=(F=e.dontUseTransmissionHelper)!=null?F:this.dontUseTransmissionHelper)}},Po=class s extends GT{constructor(e){super(),this.onParsedObservable=new Q,this.onMeshLoadedObservable=new Q,this.onSkinLoadedObservable=new Q,this.onTextureLoadedObservable=new Q,this.onMaterialLoadedObservable=new Q,this.onCameraLoadedObservable=new Q,this.onCompleteObservable=new Q,this.onErrorObservable=new Q,this.onDisposeObservable=new Q,this.onExtensionLoadedObservable=new Q,this.onValidatedObservable=new Q,this._loader=null,this._state=null,this._requests=new Array,this.name=Wh.name,this.extensions=Wh.extensions,this.onLoaderStateChangedObservable=new Q,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({...f8},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,n,a,o,l){if(ArrayBuffer.isView(t))return this._loadBinary(e,t,i,r,o,l),null;this._progressCallback=n;let c=t.name||se.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&X.Warn("glTF validation is not supported when range requests are enabled");let f={abort:()=>{},onCompleteObservable:new Q},h={readAsync:(d,u)=>new Promise((m,p)=>{this._loadFile(e,t,_=>{m(new Uint8Array(_))},!0,_=>{p(_)},_=>{_.setRequestHeader("Range",`bytes=${d}-${d+u-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new El(h)).then(d=>{f.onCompleteObservable.notifyObservers(f),r(d)},o?d=>o(void 0,d):void 0),f}return this._loadFile(e,t,f=>{this._validate(e,new Uint8Array(f,0,f.byteLength),i,c),this._unpackBinaryAsync(new El({readAsync:(h,d)=>xF(f,h,d),byteLength:f.byteLength})).then(h=>{r(h)},o?h=>o(void 0,h):void 0)},!0,o)}else return this._loadFile(e,t,f=>{try{this._validate(e,f,i,c),r({json:this._parseJson(f)})}catch(h){o&&o()}},!1,o)}_loadBinary(e,t,i,r,n,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i,a),this._unpackBinaryAsync(new El({readAsync:(o,l)=>c8(t,o,l),byteLength:t.byteLength})).then(o=>{r(o)},n?o=>n(void 0,o):void 0)}importMeshAsync(e,t,i,r,n,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,n,a)))}loadAsync(e,t,i,r,n){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,i,r,n)))}loadAssetContainerAsync(e,t,i,r,n){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(t);let a=new hs(e),o=[];this.onMaterialLoadedObservable.add(h=>{o.push(h)});let l=[];this.onTextureLoadedObservable.add(h=>{l.push(h)});let c=[];this.onCameraLoadedObservable.add(h=>{c.push(h)});let f=[];return this.onMeshLoadedObservable.add(h=>{h.morphTargetManager&&f.push(h.morphTargetManager)}),this._loader.importMeshAsync(null,e,a,t,i,r,n).then(h=>(Array.prototype.push.apply(a.geometries,h.geometries),Array.prototype.push.apply(a.meshes,h.meshes),Array.prototype.push.apply(a.particleSystems,h.particleSystems),Array.prototype.push.apply(a.skeletons,h.skeletons),Array.prototype.push.apply(a.animationGroups,h.animationGroups),Array.prototype.push.apply(a.materials,o),Array.prototype.push.apply(a.textures,l),Array.prototype.push.apply(a.lights,h.lights),Array.prototype.push.apply(a.transformNodes,h.transformNodes),Array.prototype.push.apply(a.cameras,c),Array.prototype.push.apply(a.morphTargetManagers,f),a))})}canDirectLoad(e){return Wh.canDirectLoad(e)}directLoad(e,t){if(t.startsWith("base64,"+va)||t.startsWith(";base64,"+va)||t.startsWith("application/octet-stream;base64,"+va)||t.startsWith("model/gltf-binary;base64,"+va)){let i=ka(t);return this._validate(e,new Uint8Array(i,0,i.byteLength)),this._unpackBinaryAsync(new El({readAsync:(r,n)=>xF(i,r,n),byteLength:i.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})}createPlugin(e){return new s(e[Wh.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(or[this._state]))}_loadFile(e,t,i,r,n,a){let o=e._loadFile(t,i,l=>{this._onProgress(l,o)},!0,r,n,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,n=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,n+=a._total}this._progressCallback({lengthComputable:i,loaded:r,total:i?n:0})}_validate(e,t,i="",r=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),uf.ValidateAsync(t,i,r,n=>this.preprocessUrlAsync(i+n).then(a=>e._loadFileAsync(a,void 0,!0,!0).then(o=>new Uint8Array(o,0,o.byteLength)))).then(n=>{this._endPerformanceCounter("Validate JSON"),this.onValidatedObservable.notifyObservers(n),this.onValidatedObservable.clear()},n=>{this._endPerformanceCounter("Validate JSON"),se.Warn(`Failed to validate: ${n.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=s._parseVersion(t.version);if(!i)throw new Error("Invalid version: "+t.version);if(t.minVersion!==void 0){let a=s._parseVersion(t.minVersion);if(!a)throw new Error("Invalid minimum version: "+t.minVersion);if(s._compareVersion(a,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}let n={1:s._CreateGLTF1Loader,2:s._CreateGLTF2Loader}[i.major];if(!n)throw new Error("Unsupported version: "+t.version);return n(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 gr("Unexpected magic: "+i,qr.GLTFLoaderUnexpectedMagicError);let r=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${r}`);let n=e.readUint32();!this.useRangeRequests&&n!==e.buffer.byteLength&&X.Warn(`Length in header does not match actual data length: ${n} != ${e.buffer.byteLength}`);let a;switch(r){case 1:{a=this._unpackBinaryV1Async(e,n);break}case 2:{a=this._unpackBinaryV2Async(e,n);break}default:throw new Error("Unsupported version: "+r)}return this._endPerformanceCounter("Unpack Binary"),a})}_unpackBinaryV1Async(e,t){let i={JSON:0},r=e.readUint32(),n=e.readUint32();if(n!==i.JSON)throw new Error(`Unexpected content format: ${n}`);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:(h,d)=>e.buffer.readAsync(f+h,d),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{Op=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 Ji,CF=C(()=>{$e();Qe();dn();bu();Ee();At();Ji=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=se.BackCompatCameraNoPreventDefault(arguments),!this._onCanvasBlurObserver&&(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{let i=t.event;if(!i.metaKey){if(t.type===Is.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{$e();dt();Qe();dn();xs();At();Sl=class{constructor(e=!0){this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this._previousPosition=null,this.onPointerMovedObservable=new Q,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments);let t=this.camera.getEngine(),i=t.getInputElement();this._pointerInput||(this._pointerInput=r=>{let n=r.event,a=n.pointerType==="touch";if(!this.touchEnabled&&a||r.type!==Le.POINTERMOVE&&this.buttons.indexOf(n.button)===-1)return;let o=n.target;if(r.type===Le.POINTERDOWN){if(a&&this._activePointerId!==-1||!a&&this._currentActiveButton!==-1)return;this._activePointerId=n.pointerId;try{o==null||o.setPointerCapture(n.pointerId)}catch(l){}this._currentActiveButton===-1&&(this._currentActiveButton=n.button),this._previousPosition={x:n.clientX,y:n.clientY},e||(n.preventDefault(),i&&i.focus()),t.isPointerLock&&this._onMouseMove&&this._onMouseMove(r.event)}else if(r.type===Le.POINTERUP){if(a&&this._activePointerId!==n.pointerId||!a&&this._currentActiveButton!==n.button)return;try{o==null||o.releasePointerCapture(n.pointerId)}catch(l){}this._currentActiveButton=-1,this._previousPosition=null,e||n.preventDefault(),this._activePointerId=-1}else if(r.type===Le.POINTERMOVE&&(this._activePointerId===n.pointerId||!a)){if(t.isPointerLock&&this._onMouseMove)this._onMouseMove(r.event);else if(this._previousPosition){let l=this.camera._calculateHandednessMultiplier(),c=(n.clientX-this._previousPosition.x)*l,f=(n.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:n.clientX,y:n.clientY},e||n.preventDefault()}}}),this._onMouseMove=r=>{if(!t.isPointerLock)return;let n=this.camera._calculateHandednessMultiplier();this.camera.cameraRotation.y+=r.movementX*n/this.angularSensibility,this.camera.cameraRotation.x+=r.movementY*n/this.angularSensibility,this._previousPosition=null,e||r.preventDefault()},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Le.POINTERDOWN|Le.POINTERUP|Le.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"}};b([L()],Sl.prototype,"buttons",void 0);b([L()],Sl.prototype,"angularSensibility",void 0);Ki.FreeCameraMouseInput=Sl});var Tl,MF=C(()=>{$e();Qe();dt();xs();Mu();At();Tl=class{constructor(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new Q,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}attachControl(e){e=se.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==Le.POINTERWHEEL)return;let i=t.event,r=i.deltaMode===Cs.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,Le.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"}};b([L()],Tl.prototype,"wheelPrecisionX",void 0);b([L()],Tl.prototype,"wheelPrecisionY",void 0);b([L()],Tl.prototype,"wheelPrecisionZ",void 0)});var Mt,Ir,yF=C(()=>{$e();Qe();dn();MF();Ee();(function(s){s[s.MoveRelative=0]="MoveRelative",s[s.RotateRelative=1]="RotateRelative",s[s.MoveScene=2]="MoveScene"})(Mt||(Mt={}));Ir=class extends Tl{constructor(){super(...arguments),this._moveRelative=S.Zero(),this._rotateRelative=S.Zero(),this._moveScene=S.Zero(),this._wheelXAction=Mt.MoveRelative,this._wheelXActionCoordinate=0,this._wheelYAction=Mt.MoveRelative,this._wheelYActionCoordinate=2,this._wheelZAction=null,this._wheelZActionCoordinate=null}getClassName(){return"FreeCameraMouseWheelInput"}set wheelXMoveRelative(e){e===null&&this._wheelXAction!==Mt.MoveRelative||(this._wheelXAction=Mt.MoveRelative,this._wheelXActionCoordinate=e)}get wheelXMoveRelative(){return this._wheelXAction!==Mt.MoveRelative?null:this._wheelXActionCoordinate}set wheelYMoveRelative(e){e===null&&this._wheelYAction!==Mt.MoveRelative||(this._wheelYAction=Mt.MoveRelative,this._wheelYActionCoordinate=e)}get wheelYMoveRelative(){return this._wheelYAction!==Mt.MoveRelative?null:this._wheelYActionCoordinate}set wheelZMoveRelative(e){e===null&&this._wheelZAction!==Mt.MoveRelative||(this._wheelZAction=Mt.MoveRelative,this._wheelZActionCoordinate=e)}get wheelZMoveRelative(){return this._wheelZAction!==Mt.MoveRelative?null:this._wheelZActionCoordinate}set wheelXRotateRelative(e){e===null&&this._wheelXAction!==Mt.RotateRelative||(this._wheelXAction=Mt.RotateRelative,this._wheelXActionCoordinate=e)}get wheelXRotateRelative(){return this._wheelXAction!==Mt.RotateRelative?null:this._wheelXActionCoordinate}set wheelYRotateRelative(e){e===null&&this._wheelYAction!==Mt.RotateRelative||(this._wheelYAction=Mt.RotateRelative,this._wheelYActionCoordinate=e)}get wheelYRotateRelative(){return this._wheelYAction!==Mt.RotateRelative?null:this._wheelYActionCoordinate}set wheelZRotateRelative(e){e===null&&this._wheelZAction!==Mt.RotateRelative||(this._wheelZAction=Mt.RotateRelative,this._wheelZActionCoordinate=e)}get wheelZRotateRelative(){return this._wheelZAction!==Mt.RotateRelative?null:this._wheelZActionCoordinate}set wheelXMoveScene(e){e===null&&this._wheelXAction!==Mt.MoveScene||(this._wheelXAction=Mt.MoveScene,this._wheelXActionCoordinate=e)}get wheelXMoveScene(){return this._wheelXAction!==Mt.MoveScene?null:this._wheelXActionCoordinate}set wheelYMoveScene(e){e===null&&this._wheelYAction!==Mt.MoveScene||(this._wheelYAction=Mt.MoveScene,this._wheelYActionCoordinate=e)}get wheelYMoveScene(){return this._wheelYAction!==Mt.MoveScene?null:this._wheelYActionCoordinate}set wheelZMoveScene(e){e===null&&this._wheelZAction!==Mt.MoveScene||(this._wheelZAction=Mt.MoveScene,this._wheelZActionCoordinate=e)}get wheelZMoveScene(){return this._wheelZAction!==Mt.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=H.Zero();this.camera.getViewMatrix().invertToRef(e);let t=S.Zero();S.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 Mt.MoveRelative:r=this._moveRelative;break;case Mt.RotateRelative:r=this._rotateRelative;break;case Mt.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}}};b([L()],Ir.prototype,"wheelXMoveRelative",null);b([L()],Ir.prototype,"wheelYMoveRelative",null);b([L()],Ir.prototype,"wheelZMoveRelative",null);b([L()],Ir.prototype,"wheelXRotateRelative",null);b([L()],Ir.prototype,"wheelYRotateRelative",null);b([L()],Ir.prototype,"wheelZRotateRelative",null);b([L()],Ir.prototype,"wheelXMoveScene",null);b([L()],Ir.prototype,"wheelYMoveScene",null);b([L()],Ir.prototype,"wheelZMoveScene",null);Ki.FreeCameraMouseWheelInput=Ir});var Al,DF=C(()=>{$e();Qe();dn();xs();Ee();At();Al=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=se.IsSafari()}attachControl(e){e=se.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,n=r.pointerType==="mouse"||this._isSafari&&typeof r.pointerType=="undefined";if(!(!this.allowMouse&&n)){if(i.type===Le.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===Le.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===Le.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,Le.POINTERDOWN|Le.POINTERUP|Le.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(),n=W.Vector3[0];n.copyFromFloats(0,0,this.touchMoveSensibility!==0?r*this._offsetY/this.touchMoveSensibility:0),H.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),S.TransformCoordinatesToRef(n,e._cameraRotationMatrix,n),e.cameraDirection.addInPlace(n)}}getClassName(){return"FreeCameraTouchInput"}getSimpleName(){return"touch"}};b([L()],Al.prototype,"touchAngularSensibility",void 0);b([L()],Al.prototype,"touchMoveSensibility",void 0);Ki.FreeCameraTouchInput=Al});var Np,PF=C(()=>{dn();CF();bF();yF();DF();Np=class extends Gc{constructor(e){super(e),this._mouseInput=null,this._mouseWheelInput=null}addKeyboard(){return this.add(new Ji),this}addMouse(e=!0){return this._mouseInput||(this._mouseInput=new Sl(e),this.add(this._mouseInput)),this}removeMouse(){return this._mouseInput&&this.remove(this._mouseInput),this}addMouseWheel(){return this._mouseWheelInput||(this._mouseWheelInput=new Ir,this.add(this._mouseWheelInput)),this}removeMouseWheel(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this}addTouch(){return this.add(new Al),this}clear(){super.clear(),this._mouseInput=null}}});var Sa,LF=C(()=>{$e();Qe();Ee();Av();PF();At();Pt();ci();Sa=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 S(.5,1,.5),this.ellipsoidOffset=new S(0,0,0),this.checkCollisions=!1,this.applyGravity=!1,this._needMoveForGravity=!1,this._oldPosition=S.Zero(),this._diffPosition=S.Zero(),this._newPosition=S.Zero(),this._collisionMask=-1,this._onCollisionPositionChange=(n,a,o=null)=>{this._newPosition.copyFrom(a),this._newPosition.subtractToRef(this._oldPosition,this._diffPosition),this._diffPosition.length()>he.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 Np(this),this.inputs.addKeyboard().addMouse()}attachControl(e,t){t=se.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)}detachControl(){this.inputs.detachElement(),this.cameraDirection=new S(0,0,0),this.cameraRotation=new me(0,0)}get collisionMask(){return this._collisionMask}set collisionMask(e){this._collisionMask=isNaN(e)?-1:e}_collideWithWorld(e){let t;this.parent?t=S.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=S.Zero(),this._transformedDirection=S.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"}};b([ui()],Sa.prototype,"ellipsoid",void 0);b([ui()],Sa.prototype,"ellipsoidOffset",void 0);b([L()],Sa.prototype,"checkCollisions",void 0);b([L()],Sa.prototype,"applyGravity",void 0);Ke("BABYLON.FreeCamera",Sa)});var ds,Fp=C(()=>{Ee();Zs();Fr();ds=class s extends pt{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,n=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:H.Identity(),this._restMatrix=n!=null?n:this._localMatrix.clone(),this._bindMatrix=a!=null?a:this._localMatrix.clone(),this._index=o,this._absoluteMatrix=new H,this._absoluteBindMatrix=new H,this._absoluteInverseBindMatrix=new H,this._finalMatrix=new H,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=W.Vector3[0],i=W.Quaternion[0],r=W.Vector3[1];this.getRestMatrix().decompose(t,i,r),this._linkedTransformNode.position.copyFrom(r),this._linkedTransformNode.rotationQuaternion=(e=this._linkedTransformNode.rotationQuaternion)!=null?e:Se.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=S.Zero(),this._localRotation=Se.Zero(),this._localPosition=S.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))}_compose(){if(this._needToCompose){if(!this._localScaling){this._needToCompose=!1;return}this._needToCompose=!1,H.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{Fp();dt();Ee();yp();ia();mv();gt();We();eh();wp=class s{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=H.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 Q,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 n=r._linkedTransformNode;r.position=n.position,n.rotationQuaternion?r.rotationQuaternion=n.rotationQuaternion:r.rotation=n.rotation,r.scaling=n.scaling}}let t=null;if(this.needInitialSkinMatrix)for(let r of this._meshesWithPoseMatrix){let n=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(n,W.Matrix[1]),o._updateAbsoluteBindMatrices(W.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=Vr.CreateRGBATexture(r._bonesTransformMatrices,this._textureWidth,this._textureHeight,this._scene,!1,!1,1,1))}}this._computeTransformMatrices(r._bonesTransformMatrices,n),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=Vr.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=n.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 s(e.name,e.id,t);e.dimensionsAtRest&&(i.dimensionsAtRest=S.FromArray(e.dimensionsAtRest)),i.needInitialSkinMatrix=e.needInitialSkinMatrix,e.metadata&&(i.metadata=e.metadata);let r;for(r=0;r-1&&(o=i.bones[n.parentBoneIndex]);let l=n.rest?H.FromArray(n.rest):null,c=new ds(n.name,i,o,H.FromArray(n.matrix),l,null,a);n.id!==void 0&&n.id!==null&&(c.id=n.id),n.length&&(c.length=n.length),n.metadata&&(c.metadata=n.metadata),n.animation&&c.animations.push(Ne.Parse(n.animation)),n.linkedTransformNodeId!==void 0&&n.linkedTransformNodeId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeId=n.linkedTransformNodeId),n.linkedTransformNodeUniqueId!==void 0&&n.linkedTransformNodeUniqueId!==null&&(i._hasWaitingData=!0,c._waitingTransformNodeUniqueId=n.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{$e();dt();gt();It();Qe();jt();Pt();Lo=class s{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 Q,this._onDataLayoutChanged=new Q,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=De.Clone(()=>new s(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())),De.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,t,i=null){let r=new s(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 n=0;n{pi();Bp=class s extends ne{get depth(){return this._depth}constructor(e,t,i,r,n,a,o=!0,l=!1,c=ne.TRILINEAR_SAMPLINGMODE,f=0,h,d){super(null,a,!o,l),this.format=n,this._texture=a.getEngine().createRawTexture2DArray(e,t,i,r,n,o,l,c,null,f,h!=null?h:0,d),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,n,a=!0,o=!1,l=3,c=0){return new s(e,t,i,r,5,n,a,o,l,c)}}});var Rl,FF=C(()=>{As();We();gt();WT();NF();Rl=class s{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 yt(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 s.ConstantTargetCountForTextureMode>0&&this.isUsingTextureForTargets?s.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 s.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 s(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 n=-1;for(let a of this._targets)if(n++,!(a.influence===0&&this.optimizeInfluencers)){if(this._activeTargets.length>=s.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(a),this._morphTargetTextureIndices[r]=n,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){X.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,n=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 s(t);for(let r of e.targets)i.addTarget(Lo.Parse(r,t,i));return e.metadata&&(i.metadata=e.metadata),i}};Rl.EnableTextureStorage=!0;Rl.MaxActiveMorphTargetsInVertexAttributeMode=8;Rl.ConstantTargetCountForTextureMode=0});function BF(s,e,t){zT(s)&&X.Warn(`Extension with the name '${s}' already exists`),HT.set(s,{isGLTFExtension:e,factory:t})}function zT(s){return HT.delete(s)}var HT,wF,UF=C(()=>{We();HT=new Map,wF=HT});var B,XT=C(()=>{B=class{};B.AUTOSAMPLERSUFFIX="Sampler";B.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS";B.ALPHA_DISABLE=0;B.ALPHA_ADD=1;B.ALPHA_COMBINE=2;B.ALPHA_SUBTRACT=3;B.ALPHA_MULTIPLY=4;B.ALPHA_MAXIMIZED=5;B.ALPHA_ONEONE=6;B.ALPHA_PREMULTIPLIED=7;B.ALPHA_PREMULTIPLIED_PORTERDUFF=8;B.ALPHA_INTERPOLATE=9;B.ALPHA_SCREENMODE=10;B.ALPHA_ONEONE_ONEONE=11;B.ALPHA_ALPHATOCOLOR=12;B.ALPHA_REVERSEONEMINUS=13;B.ALPHA_SRC_DSTONEMINUSSRCALPHA=14;B.ALPHA_ONEONE_ONEZERO=15;B.ALPHA_EXCLUSION=16;B.ALPHA_LAYER_ACCUMULATE=17;B.ALPHA_MIN=18;B.ALPHA_MAX=19;B.ALPHA_DUAL_SRC0_ADD_SRC1xDST=20;B.ALPHA_EQUATION_ADD=0;B.ALPHA_EQUATION_SUBSTRACT=1;B.ALPHA_EQUATION_REVERSE_SUBTRACT=2;B.ALPHA_EQUATION_MAX=3;B.ALPHA_EQUATION_MIN=4;B.ALPHA_EQUATION_DARKEN=5;B.DELAYLOADSTATE_NONE=0;B.DELAYLOADSTATE_LOADED=1;B.DELAYLOADSTATE_LOADING=2;B.DELAYLOADSTATE_NOTLOADED=4;B.NEVER=512;B.ALWAYS=519;B.LESS=513;B.EQUAL=514;B.LEQUAL=515;B.GREATER=516;B.GEQUAL=518;B.NOTEQUAL=517;B.KEEP=7680;B.ZERO=0;B.REPLACE=7681;B.INCR=7682;B.DECR=7683;B.INVERT=5386;B.INCR_WRAP=34055;B.DECR_WRAP=34056;B.TEXTURE_CLAMP_ADDRESSMODE=0;B.TEXTURE_WRAP_ADDRESSMODE=1;B.TEXTURE_MIRROR_ADDRESSMODE=2;B.TEXTURE_CREATIONFLAG_STORAGE=1;B.TEXTUREFORMAT_ALPHA=0;B.TEXTUREFORMAT_LUMINANCE=1;B.TEXTUREFORMAT_LUMINANCE_ALPHA=2;B.TEXTUREFORMAT_RGB=4;B.TEXTUREFORMAT_RGBA=5;B.TEXTUREFORMAT_RED=6;B.TEXTUREFORMAT_R=6;B.TEXTUREFORMAT_R16_UNORM=33322;B.TEXTUREFORMAT_RG16_UNORM=33324;B.TEXTUREFORMAT_RGB16_UNORM=32852;B.TEXTUREFORMAT_RGBA16_UNORM=32859;B.TEXTUREFORMAT_R16_SNORM=36760;B.TEXTUREFORMAT_RG16_SNORM=36761;B.TEXTUREFORMAT_RGB16_SNORM=36762;B.TEXTUREFORMAT_RGBA16_SNORM=36763;B.TEXTUREFORMAT_RG=7;B.TEXTUREFORMAT_RED_INTEGER=8;B.TEXTUREFORMAT_R_INTEGER=8;B.TEXTUREFORMAT_RG_INTEGER=9;B.TEXTUREFORMAT_RGB_INTEGER=10;B.TEXTUREFORMAT_RGBA_INTEGER=11;B.TEXTUREFORMAT_BGRA=12;B.TEXTUREFORMAT_DEPTH24_STENCIL8=13;B.TEXTUREFORMAT_DEPTH32_FLOAT=14;B.TEXTUREFORMAT_DEPTH16=15;B.TEXTUREFORMAT_DEPTH24=16;B.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17;B.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18;B.TEXTUREFORMAT_STENCIL8=19;B.TEXTUREFORMAT_UNDEFINED=4294967295;B.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492;B.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493;B.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495;B.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494;B.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779;B.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919;B.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778;B.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918;B.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777;B.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776;B.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917;B.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x4=37809;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_5x5=37810;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x5=37811;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_6x6=37812;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x5=37813;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x6=37814;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_8x8=37815;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x5=37816;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x6=37817;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x8=37818;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_10x10=37819;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x10=37820;B.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_12x12=37821;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853;B.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196;B.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493;B.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494;B.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495;B.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496;B.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497;B.TEXTURETYPE_UNSIGNED_BYTE=0;B.TEXTURETYPE_UNSIGNED_INT=0;B.TEXTURETYPE_FLOAT=1;B.TEXTURETYPE_HALF_FLOAT=2;B.TEXTURETYPE_BYTE=3;B.TEXTURETYPE_SHORT=4;B.TEXTURETYPE_UNSIGNED_SHORT=5;B.TEXTURETYPE_INT=6;B.TEXTURETYPE_UNSIGNED_INTEGER=7;B.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;B.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;B.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;B.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;B.TEXTURETYPE_UNSIGNED_INT_24_8=12;B.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;B.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;B.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;B.TEXTURETYPE_UNDEFINED=16;B.TEXTURE_2D=3553;B.TEXTURE_2D_ARRAY=35866;B.TEXTURE_CUBE_MAP=34067;B.TEXTURE_CUBE_MAP_ARRAY=3735928559;B.TEXTURE_3D=32879;B.TEXTURE_NEAREST_SAMPLINGMODE=1;B.TEXTURE_NEAREST_NEAREST=1;B.TEXTURE_BILINEAR_SAMPLINGMODE=2;B.TEXTURE_LINEAR_LINEAR=2;B.TEXTURE_TRILINEAR_SAMPLINGMODE=3;B.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;B.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;B.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;B.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;B.TEXTURE_NEAREST_LINEAR=7;B.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;B.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;B.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;B.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;B.TEXTURE_LINEAR_NEAREST=12;B.TEXTURE_EXPLICIT_MODE=0;B.TEXTURE_SPHERICAL_MODE=1;B.TEXTURE_PLANAR_MODE=2;B.TEXTURE_CUBIC_MODE=3;B.TEXTURE_PROJECTION_MODE=4;B.TEXTURE_SKYBOX_MODE=5;B.TEXTURE_INVCUBIC_MODE=6;B.TEXTURE_EQUIRECTANGULAR_MODE=7;B.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;B.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;B.TEXTURE_FILTERING_QUALITY_OFFLINE=4096;B.TEXTURE_FILTERING_QUALITY_HIGH=64;B.TEXTURE_FILTERING_QUALITY_MEDIUM=16;B.TEXTURE_FILTERING_QUALITY_LOW=8;B.SCALEMODE_FLOOR=1;B.SCALEMODE_NEAREST=2;B.SCALEMODE_CEILING=3;B.MATERIAL_TextureDirtyFlag=1;B.MATERIAL_LightDirtyFlag=2;B.MATERIAL_FresnelDirtyFlag=4;B.MATERIAL_AttributesDirtyFlag=8;B.MATERIAL_MiscDirtyFlag=16;B.MATERIAL_PrePassDirtyFlag=32;B.MATERIAL_ImageProcessingDirtyFlag=64;B.MATERIAL_AllDirtyFlag=127;B.MATERIAL_TriangleFillMode=0;B.MATERIAL_WireFrameFillMode=1;B.MATERIAL_PointFillMode=2;B.MATERIAL_PointListDrawMode=3;B.MATERIAL_LineListDrawMode=4;B.MATERIAL_LineLoopDrawMode=5;B.MATERIAL_LineStripDrawMode=6;B.MATERIAL_TriangleStripDrawMode=7;B.MATERIAL_TriangleFanDrawMode=8;B.MATERIAL_ClockWiseSideOrientation=0;B.MATERIAL_CounterClockWiseSideOrientation=1;B.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR=0;B.MATERIAL_DIFFUSE_MODEL_BURLEY=1;B.MATERIAL_DIFFUSE_MODEL_LAMBERT=2;B.MATERIAL_DIFFUSE_MODEL_LEGACY=3;B.MATERIAL_DIELECTRIC_SPECULAR_MODEL_GLTF=0;B.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR=1;B.MATERIAL_CONDUCTOR_SPECULAR_MODEL_GLTF=0;B.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR=1;B.ACTION_NothingTrigger=0;B.ACTION_OnPickTrigger=1;B.ACTION_OnLeftPickTrigger=2;B.ACTION_OnRightPickTrigger=3;B.ACTION_OnCenterPickTrigger=4;B.ACTION_OnPickDownTrigger=5;B.ACTION_OnDoublePickTrigger=6;B.ACTION_OnPickUpTrigger=7;B.ACTION_OnPickOutTrigger=16;B.ACTION_OnLongPressTrigger=8;B.ACTION_OnPointerOverTrigger=9;B.ACTION_OnPointerOutTrigger=10;B.ACTION_OnEveryFrameTrigger=11;B.ACTION_OnIntersectionEnterTrigger=12;B.ACTION_OnIntersectionExitTrigger=13;B.ACTION_OnKeyDownTrigger=14;B.ACTION_OnKeyUpTrigger=15;B.PARTICLES_BILLBOARDMODE_Y=2;B.PARTICLES_BILLBOARDMODE_ALL=7;B.PARTICLES_BILLBOARDMODE_STRETCHED=8;B.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9;B.MESHES_CULLINGSTRATEGY_STANDARD=0;B.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;B.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;B.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;B.SCENELOADER_NO_LOGGING=0;B.SCENELOADER_MINIMAL_LOGGING=1;B.SCENELOADER_SUMMARY_LOGGING=2;B.SCENELOADER_DETAILED_LOGGING=3;B.PREPASS_IRRADIANCE_LEGACY_TEXTURE_TYPE=0;B.PREPASS_POSITION_TEXTURE_TYPE=1;B.PREPASS_VELOCITY_TEXTURE_TYPE=2;B.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3;B.PREPASS_COLOR_TEXTURE_TYPE=4;B.PREPASS_DEPTH_TEXTURE_TYPE=5;B.PREPASS_NORMAL_TEXTURE_TYPE=6;B.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7;B.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8;B.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9;B.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10;B.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11;B.PREPASS_ALBEDO_TEXTURE_TYPE=12;B.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE=13;B.PREPASS_IRRADIANCE_TEXTURE_TYPE=14;B.BUFFER_CREATIONFLAG_READ=1;B.BUFFER_CREATIONFLAG_WRITE=2;B.BUFFER_CREATIONFLAG_READWRITE=3;B.BUFFER_CREATIONFLAG_UNIFORM=4;B.BUFFER_CREATIONFLAG_VERTEX=8;B.BUFFER_CREATIONFLAG_INDEX=16;B.BUFFER_CREATIONFLAG_STORAGE=32;B.BUFFER_CREATIONFLAG_INDIRECT=64;B.RENDERPASS_MAIN=0;B.INPUT_ALT_KEY=18;B.INPUT_CTRL_KEY=17;B.INPUT_META_KEY1=91;B.INPUT_META_KEY2=92;B.INPUT_META_KEY3=93;B.INPUT_SHIFT_KEY=16;B.SNAPSHOTRENDERING_STANDARD=0;B.SNAPSHOTRENDERING_FAST=1;B.PERSPECTIVE_CAMERA=0;B.ORTHOGRAPHIC_CAMERA=1;B.FOVMODE_VERTICAL_FIXED=0;B.FOVMODE_HORIZONTAL_FIXED=1;B.RIG_MODE_NONE=0;B.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;B.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;B.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;B.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;B.RIG_MODE_STEREOSCOPIC_INTERLACED=14;B.RIG_MODE_VR=20;B.RIG_MODE_CUSTOM=22;B.MAX_SUPPORTED_UV_SETS=6;B.GL_ALPHA_EQUATION_ADD=32774;B.GL_ALPHA_EQUATION_MIN=32775;B.GL_ALPHA_EQUATION_MAX=32776;B.GL_ALPHA_EQUATION_SUBTRACT=32778;B.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779;B.GL_ALPHA_FUNCTION_SRC=768;B.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769;B.GL_ALPHA_FUNCTION_SRC_ALPHA=770;B.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771;B.GL_ALPHA_FUNCTION_DST_ALPHA=772;B.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773;B.GL_ALPHA_FUNCTION_DST_COLOR=774;B.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775;B.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776;B.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769;B.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770;B.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771;B.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772;B.GL_ALPHA_FUNCTION_SRC1_COLOR=35065;B.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066;B.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185;B.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067;B.SnippetUrl="https://snippet.babylonjs.com";B.FOGMODE_NONE=0;B.FOGMODE_EXP=1;B.FOGMODE_EXP2=2;B.FOGMODE_LINEAR=3;B.BYTE=5120;B.UNSIGNED_BYTE=5121;B.SHORT=5122;B.UNSIGNED_SHORT=5123;B.INT=5124;B.UNSIGNED_INT=5125;B.FLOAT=5126;B.PositionKind="position";B.NormalKind="normal";B.TangentKind="tangent";B.UVKind="uv";B.UV2Kind="uv2";B.UV3Kind="uv3";B.UV4Kind="uv4";B.UV5Kind="uv5";B.UV6Kind="uv6";B.ColorKind="color";B.ColorInstanceKind="instanceColor";B.MatricesIndicesKind="matricesIndices";B.MatricesWeightsKind="matricesWeights";B.MatricesIndicesExtraKind="matricesIndicesExtra";B.MatricesWeightsExtraKind="matricesWeightsExtra";B.ANIMATIONTYPE_FLOAT=0;B.ANIMATIONTYPE_VECTOR3=1;B.ANIMATIONTYPE_QUATERNION=2;B.ANIMATIONTYPE_MATRIX=3;B.ANIMATIONTYPE_COLOR3=4;B.ANIMATIONTYPE_COLOR4=7;B.ANIMATIONTYPE_VECTOR2=5;B.ANIMATIONTYPE_SIZE=6;B.ShadowMinZ=0;B.ShadowMaxZ=1e4;B.OUTLINELAYER_SAMPLING_TRIDIRECTIONAL=0;B.OUTLINELAYER_SAMPLING_OCTADIRECTIONAL=1});var BPe,VF=C(()=>{BPe=[{regex:new RegExp("^/nodes/\\d+/extensions/")}]});function Oo(s,e,t,i){let r=Oe(s,e);return i?r[t][i]:r[t]}function Oe(s,e,t){var i,r,n;return(n=(r=s._data)==null?void 0:r[(i=t==null?void 0:t.fillMode)!=null?i:B.MATERIAL_TriangleFillMode])==null?void 0:n.babylonMaterial}function Ai(s,e){return{offset:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let n=Oo(t,r,s,e);return new me(n==null?void 0:n.uOffset,n==null?void 0:n.vOffset)},getTarget:Oe,set:(t,i,r,n)=>{let a=Oo(i,n,s,e);a.uOffset=t.x,a.vOffset=t.y},getPropertyName:[()=>`${s}${e?"."+e:""}.uOffset`,()=>`${s}${e?"."+e:""}.vOffset`]},rotation:{type:"number",get:(t,i,r)=>{var n;return(n=Oo(t,r,s,e))==null?void 0:n.wAng},getTarget:Oe,set:(t,i,r,n)=>Oo(i,n,s,e).wAng=t,getPropertyName:[()=>`${s}${e?"."+e:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(t,i,r)=>{let n=Oo(t,r,s,e);return new me(n==null?void 0:n.uScale,n==null?void 0:n.vScale)},getTarget:Oe,set:(t,i,r,n)=>{let a=Oo(i,n,s,e);a.uScale=t.x,a.vScale=t.y},getPropertyName:[()=>`${s}${e?"."+e:""}.uScale`,()=>`${s}${e?"."+e:""}.vScale`]}}}function Hh(s){let e=s.split("/").map(i=>i.replace(/{}/g,"__array__")),t=GF;for(let i of e)i&&(t=t[i]);if(t&&t.type&&t.get)return t}function zh(s,e){let t=s.split("/").map(r=>r.replace(/{}/g,"__array__")),i=GF;for(let r of t)r&&(i=i[r]);i&&i.type&&i.get&&(i.interpolation=e)}var h8,d8,u8,m8,p8,_8,GF,YT=C(()=>{Ee();XT();Je();Rv();VF();h8={length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonTransformNode),getPropertyName:[()=>"length"]},__array__:{__target__:!0,translation:{type:"Vector3",get:s=>{var e;return(e=s._babylonTransformNode)==null?void 0:e.position},set:(s,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.position.copyFrom(s)},getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"position"]},rotation:{type:"Quaternion",get:s=>{var e;return(e=s._babylonTransformNode)==null?void 0:e.rotationQuaternion},set:(s,e)=>{var t,i;return(i=(t=e._babylonTransformNode)==null?void 0:t.rotationQuaternion)==null?void 0:i.copyFrom(s)},getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"rotationQuaternion"]},scale:{type:"Vector3",get:s=>{var e;return(e=s._babylonTransformNode)==null?void 0:e.scaling},set:(s,e)=>{var t;return(t=e._babylonTransformNode)==null?void 0:t.scaling.copyFrom(s)},getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"scaling"]},weights:{length:{type:"number",get:s=>s._numMorphTargets,getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"influence"]},__array__:{__target__:!0,type:"number",get:(s,e)=>{var t,i;return e!==void 0?(i=(t=s._primitiveBabylonMeshes)==null?void 0:t[0].morphTargetManager)==null?void 0:i.getTarget(e).influence:void 0},getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"influence"]},type:"number[]",get:(s,e)=>[0],getTarget:s=>s._babylonTransformNode,getPropertyName:[()=>"influence"]},matrix:{type:"Matrix",get:s=>{var e,t,i;return H.Compose((e=s._babylonTransformNode)==null?void 0:e.scaling,(t=s._babylonTransformNode)==null?void 0:t.rotationQuaternion,(i=s._babylonTransformNode)==null?void 0:i.position)},getTarget:s=>s._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:s=>{var r,n,a,o,l,c,f;let e=H.Identity(),t=s.parent;for(;t&&t.parent;)t=t.parent;let i=((r=s._babylonTransformNode)==null?void 0:r.position._isDirty)||((a=(n=s._babylonTransformNode)==null?void 0:n.rotationQuaternion)==null?void 0:a._isDirty)||((o=s._babylonTransformNode)==null?void 0:o.scaling._isDirty);if(t){let h=(l=t._babylonTransformNode)==null?void 0:l.computeWorldMatrix(!0).invert();h&&((f=(c=s._babylonTransformNode)==null?void 0:c.computeWorldMatrix(i))==null||f.multiplyToRef(h,e))}else s._babylonTransformNode&&e.copyFrom(s._babylonTransformNode.computeWorldMatrix(i));return e},getTarget:s=>s._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:s=>{var e,t;return(t=(e=s._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.intensity},getTarget:s=>{var e;return(e=s._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(s,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.intensity=s)}}},color:{type:"Color3",get:s=>{var e,t;return(t=(e=s._babylonTransformNode)==null?void 0:e.getChildren(i=>i instanceof ni,!0)[0])==null?void 0:t.diffuse},getTarget:s=>{var e;return(e=s._babylonTransformNode)==null?void 0:e.getChildren(t=>t instanceof ni,!0)[0]},set:(s,e)=>{if(e._babylonTransformNode){let t=e._babylonTransformNode.getChildren(i=>i instanceof ni,!0)[0];t&&(t.diffuse=s)}}}},KHR_node_visibility:{visible:{type:"boolean",get:s=>s._primitiveBabylonMeshes?s._primitiveBabylonMeshes[0].isVisible:!1,getTarget:()=>{},set:(s,e)=>{e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes.forEach(t=>t.isVisible=s)}}}}}},d8={length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>"length"]},__array__:{}},u8={length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>{var t;return(t=e.primitives[0]._instanceData)==null?void 0:t.babylonSourceMesh}),getPropertyName:[()=>"length"]},__array__:{}},m8={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:s=>{var e,t,i,r;return new me((t=(e=s._babylonCamera)==null?void 0:e.orthoLeft)!=null?t:0,(r=(i=s._babylonCamera)==null?void 0:i.orthoRight)!=null?r:0)},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.orthoLeft=s.x,e._babylonCamera.orthoRight=s.y)},getTarget:s=>s,getPropertyName:[()=>"orthoLeft",()=>"orthoRight"]},ymag:{componentsCount:2,type:"Vector2",get:s=>{var e,t,i,r;return new me((t=(e=s._babylonCamera)==null?void 0:e.orthoBottom)!=null?t:0,(r=(i=s._babylonCamera)==null?void 0:i.orthoTop)!=null?r:0)},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.orthoBottom=s.x,e._babylonCamera.orthoTop=s.y)},getTarget:s=>s,getPropertyName:[()=>"orthoBottom",()=>"orthoTop"]},zfar:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.maxZ},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=s)},getTarget:s=>s,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.minZ},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=s)},getTarget:s=>s,getPropertyName:[()=>"minZ"]}},perspective:{aspectRatio:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.getEngine().getAspectRatio(s._babylonCamera)},getTarget:s=>s,getPropertyName:[()=>"aspectRatio"],isReadOnly:!0},yfov:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.fov},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.fov=s)},getTarget:s=>s,getPropertyName:[()=>"fov"]},zfar:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.maxZ},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.maxZ=s)},getTarget:s=>s,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:s=>{var e;return(e=s._babylonCamera)==null?void 0:e.minZ},set:(s,e)=>{e._babylonCamera&&(e._babylonCamera.minZ=s)},getTarget:s=>s,getPropertyName:[()=>"minZ"]}}}},p8={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:(s,e,t)=>Oe(s,e,t).emissiveColor,set:(s,e,t,i)=>Oe(e,t,i).emissiveColor.copyFrom(s),getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:Ai("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(s,e,t)=>{var i;return(i=Oo(s,t,"bumpTexture"))==null?void 0:i.level},set:(s,e,t,i)=>{let r=Oo(e,i,"bumpTexture");r&&(r.level=s)},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:Ai("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(s,e,t)=>Oe(s,e,t).ambientTextureStrength,set:(s,e,t,i)=>{let r=Oe(e,t,i);r&&(r.ambientTextureStrength=s)},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:Ai("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(s,e,t)=>{let i=Oe(s,e,t);return Me.FromColor3(i.albedoColor,i.alpha)},set:(s,e,t,i)=>{let r=Oe(e,t,i);r.albedoColor.set(s.r,s.g,s.b),r.alpha=s.a},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:Ai("albedoTexture")}},metallicFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).metallic,set:(s,e,t,i)=>{let r=Oe(e,t,i);r&&(r.metallic=s)},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).roughness,set:(s,e,t,i)=>{let r=Oe(e,t,i);r&&(r.roughness=s)},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:Ai("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(s,e,t)=>Oe(s,e,t).anisotropy.intensity,set:(s,e,t,i)=>{Oe(e,t,i).anisotropy.intensity=s},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(s,e,t)=>Oe(s,e,t).anisotropy.angle,set:(s,e,t,i)=>{Oe(e,t,i).anisotropy.angle=s},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:Ai("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).clearCoat.intensity,set:(s,e,t,i)=>{Oe(e,t,i).clearCoat.intensity=s},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).clearCoat.roughness,set:(s,e,t,i)=>{Oe(e,t,i).clearCoat.roughness=s},getTarget:(s,e,t)=>Oe(s,e,t),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:Ai("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(s,e,t)=>{var i;return(i=Oe(s,e,t).clearCoat.bumpTexture)==null?void 0:i.level},getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).clearCoat.bumpTexture.level=s},extensions:{KHR_texture_transform:Ai("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:Ai("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(s,e,t)=>Oe(s,e,t).subSurface.dispersion,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.dispersion=s}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(s,e,t)=>Oe(s,e,t).emissiveIntensity,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).emissiveIntensity=s}},KHR_materials_ior:{ior:{type:"number",get:(s,e,t)=>Oe(s,e,t).indexOfRefraction,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).indexOfRefraction=s}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).iridescence.intensity,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).iridescence.intensity=s},iridescenceIor:{type:"number",get:(s,e,t)=>Oe(s,e,t).iridescence.indexOfRefraction,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).iridescence.indexOfRefraction=s},iridescenceTexture:{extensions:{KHR_texture_transform:Ai("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(s,e,t)=>Oe(s,e,t).iridescence.maximumThickness,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).iridescence.maximumThickness=s},iridescenceThicknessMinimum:{type:"number",get:(s,e,t)=>Oe(s,e,t).iridescence.minimumThickness,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).iridescence.minimumThickness=s},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:Ai("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(s,e,t)=>Oe(s,e,t).sheen.color,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).sheen.color.copyFrom(s)},sheenColorTexture:{extensions:{KHR_texture_transform:Ai("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).sheen.intensity,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).sheen.intensity=s},sheenRoughnessTexture:{extensions:{KHR_texture_transform:Ai("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).metallicF0Factor,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).metallicF0Factor=s,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(s,e,t)=>Oe(s,e,t).metallicReflectanceColor,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).metallicReflectanceColor.copyFrom(s),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:Ai("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:Ai("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).subSurface.refractionIntensity,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.refractionIntensity=s,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:Ai("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).subSurface.translucencyIntensity,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.translucencyIntensity=s},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:Ai("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(s,e,t)=>Oe(s,e,t).subSurface.translucencyColor,getTarget:Oe,set:(s,e,t,i)=>{var r;return s&&((r=Oe(e,t,i).subSurface.translucencyColor)==null?void 0:r.copyFrom(s))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:Ai("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(s,e,t)=>Oe(s,e,t).subSurface.tintColor,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.tintColor.copyFrom(s)},attenuationDistance:{type:"number",get:(s,e,t)=>Oe(s,e,t).subSurface.tintColorAtDistance,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.tintColorAtDistance=s},thicknessFactor:{type:"number",get:(s,e,t)=>Oe(s,e,t).subSurface.maximumThickness,getTarget:Oe,set:(s,e,t,i)=>Oe(e,t,i).subSurface.maximumThickness=s},thicknessTexture:{extensions:{KHR_texture_transform:Ai("subSurface","thicknessTexture")}}}}}},_8={KHR_lights_punctual:{lights:{length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonLight),getPropertyName:[s=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.diffuse},set:(s,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(s)},getTarget:s=>s._babylonLight,getPropertyName:[s=>"diffuse"]},intensity:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.intensity},set:(s,e)=>e._babylonLight?e._babylonLight.intensity=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"intensity"]},range:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.range},set:(s,e)=>e._babylonLight?e._babylonLight.range=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"range"]},spot:{innerConeAngle:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.innerAngle},set:(s,e)=>e._babylonLight?e._babylonLight.innerAngle=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"innerConeAngle"]},outerConeAngle:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.angle},set:(s,e)=>e._babylonLight?e._babylonLight.angle=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"outerConeAngle"]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonLight),getPropertyName:[s=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.diffuse},set:(s,e)=>{var t;return(t=e._babylonLight)==null?void 0:t.diffuse.copyFrom(s)},getTarget:s=>s._babylonLight,getPropertyName:[s=>"diffuse"]},intensity:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.intensity},set:(s,e)=>e._babylonLight?e._babylonLight.intensity=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"intensity"]},size:{type:"number",get:s=>{var e;return(e=s._babylonLight)==null?void 0:e.height},set:(s,e)=>e._babylonLight?e._babylonLight.height=s:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"size"]},rect:{aspect:{type:"number",get:s=>{var e,t;return((e=s._babylonLight)==null?void 0:e.width)/((t=s._babylonLight)==null?void 0:t.height)},set:(s,e)=>e._babylonLight?e._babylonLight.width=s*e._babylonLight.height:void 0,getTarget:s=>s._babylonLight,getPropertyName:[s=>"aspect"]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonLight),getPropertyName:[s=>"length"]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:s=>s.length,getTarget:s=>s.map(e=>e._babylonTexture),getPropertyName:[s=>"length"]},__array__:{__target__:!0,intensity:{type:"number",get:s=>{var e;return(e=s._babylonTexture)==null?void 0:e.level},set:(s,e)=>{e._babylonTexture&&(e._babylonTexture.level=s)},getTarget:s=>s._babylonTexture},rotation:{type:"Quaternion",get:s=>{var e;return s._babylonTexture&&Se.FromRotationMatrix((e=s._babylonTexture)==null?void 0:e.getReflectionTextureMatrix())},set:(s,e)=>{var t;e._babylonTexture&&((t=e._babylonTexture.getScene())!=null&&t.useRightHandedSystem||(s=Se.Inverse(s)),H.FromQuaternionToRef(s,e._babylonTexture.getReflectionTextureMatrix()))},getTarget:s=>s._babylonTexture}}}}};GF={cameras:m8,nodes:h8,materials:p8,extensions:_8,animations:d8,meshes:u8}});function KT(...s){let e=t=>!!t&&typeof t=="object";return s.reduce((t,i)=>{let r=Object.keys(i);for(let n of r){let a=t[n],o=i[n];Array.isArray(a)&&Array.isArray(o)?t[n]=a.concat(...o):e(a)&&e(o)?t[n]=KT(a,o):t[n]=o}return t},{})}var kF=C(()=>{});var Xh,WF=C(()=>{Xh=class{constructor(e){this._factory=e}get value(){return this._factory&&(this._value=this._factory(),this._factory=void 0),this._value}}});var Up,HF=C(()=>{Ee();ia();Up=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===Ne.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=H.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 n=t.getEvents();if(n&&n.length>0)for(let a of n)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 n=0;n-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),d=i-t;let m,p=e*(o.framePerSecond*n)/1e3+this._absoluteFrameOffset,_=0,g=!1,v=r&&this._animationState.loopMode===Ne.ANIMATIONLOOPMODE_YOYO;if(v){let I=(p-t)/d,x=Math.sin(I*Math.PI);p=Math.abs(x)*d+t;let A=x>=0?1:-1;this._yoyoDirection!==A&&(g=!0),this._yoyoDirection=A}if(this._previousElapsedTime=e,this._previousAbsoluteFrame=p,!r&&i>=t&&(p>=d&&n>0||p<=0&&n<0))c=!1,_=o.evaluate(i);else if(!r&&t>=i&&(p<=d&&n<0||p>=0&&n>0))c=!1,_=o.evaluate(t);else if(this._animationState.loopMode!==Ne.ANIMATIONLOOPMODE_CYCLE){let I=i.toString()+t.toString();if(!this._offsetsCache[I]){this._animationState.repeatCount=0,this._animationState.loopMode=Ne.ANIMATIONLOOPMODE_CYCLE;let x=o._interpolate(t,this._animationState),T=o._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),o.dataType){case Ne.ANIMATIONTYPE_FLOAT:this._offsetsCache[I]=T-x;break;case Ne.ANIMATIONTYPE_QUATERNION:this._offsetsCache[I]=T.subtract(x);break;case Ne.ANIMATIONTYPE_VECTOR3:this._offsetsCache[I]=T.subtract(x);break;case Ne.ANIMATIONTYPE_VECTOR2:this._offsetsCache[I]=T.subtract(x);break;case Ne.ANIMATIONTYPE_SIZE:this._offsetsCache[I]=T.subtract(x);break;case Ne.ANIMATIONTYPE_COLOR3:this._offsetsCache[I]=T.subtract(x);break;default:break}this._highLimitsCache[I]=T}_=this._highLimitsCache[I],m=this._offsetsCache[I]}if(m===void 0)switch(o.dataType){case Ne.ANIMATIONTYPE_FLOAT:m=0;break;case Ne.ANIMATIONTYPE_QUATERNION:m=pv;break;case Ne.ANIMATIONTYPE_VECTOR3:m=_v;break;case Ne.ANIMATIONTYPE_VECTOR2:m=gv;break;case Ne.ANIMATIONTYPE_SIZE:m=Ev;break;case Ne.ANIMATIONTYPE_COLOR3:m=vv;break;case Ne.ANIMATIONTYPE_COLOR4:m=Sv;break}if(this._host&&this._host.syncRoot){let I=this._host.syncRoot,x=(I.masterFrame-I.fromFrame)/(I.toFrame-I.fromFrame);f=t+d*x}else p>0&&t>i||p<0&&t0&&this.currentFrame>f||n<0&&this.currentFrame0?0:o.getKeys().length-1}this._currentFrame=f,this._animationState.repeatCount=d===0?0:p/d>>0,this._animationState.highLimitValue=_,this._animationState.offsetValue=m}let u=o._interpolate(f,this._animationState);if(this.setValue(u,a),h.length){for(let m=0;m=0&&f>=h[m].frame&&h[m].frame>=t||d<0&&f<=h[m].frame&&h[m].frame<=t){let p=h[m];p.isDone||(p.onlyOnce&&(h.splice(m,1),m--),p.isDone=!0,p.action(f))}}return c||(this._stopped=!0),c}}});function g8(s){if(s.totalWeight===0&&s.totalAdditiveWeight===0)return s.originalValue;let e=1,t=W.Vector3[0],i=W.Vector3[1],r=W.Quaternion[0],n=0,a=s.animations[0],o=s.originalValue,l,c=!1;if(s.totalWeight<1)l=1-s.totalWeight,o.decompose(i,r,t);else{if(n=1,e=s.totalWeight,l=a.weight/e,l==1)if(s.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 h=n;h0?l:-l,r),u.scaleAndAddToRef(l,t)}r.normalize()}for(let h=0;h0)r.copyFrom(i);else if(s.animations.length===1){if(Se.SlerpToRef(i,t.currentValue,Math.min(1,s.totalWeight),r),s.totalAdditiveWeight===0)return r}else if(s.animations.length>1){let n=1,a,o;if(s.totalWeight<1){let c=1-s.totalWeight;a=[],o=[],a.push(i),o.push(c)}else{if(s.animations.length===2&&(Se.SlerpToRef(s.animations[0].currentValue,s.animations[1].currentValue,s.animations[1].weight/s.totalWeight,e),s.totalAdditiveWeight===0))return e;a=[],o=[],n=s.totalWeight}for(let c=0;c=l&&v.frame<=c&&(n?(x=v.value.clone(),m?(I=x.getTranslation(),x.setTranslation(I.scaleInPlace(p))):_&&a?(I=x.getTranslation(),x.setTranslation(I.multiplyInPlace(a))):x=v.value):x=v.value,g.push({frame:v.frame+r,value:x}));return this.animations[0].createRange(i,l+r,c+r),!0}),s&&(s.prototype._animate=function(t){if(!this.animationsEnabled)return;let i=Xt.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 n=this._animationTime;for(let a=0;at.playOrder-i.playOrder)},s.prototype.beginWeightedAnimation=function(t,i,r,n=1,a,o=1,l,c,f,h,d=!1){let u=this.beginAnimation(t,i,r,a,o,l,c,!1,f,h,d);return u.weight=n,u},s.prototype.beginAnimation=function(t,i,r,n,a=1,o,l,c=!0,f,h,d=!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 Yh(this,t,i,r,n,a,o,void 0,h,d));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;pn&&(o=-o),new Yh(this,t,r,n,a,o,l,i,c,f)},s.prototype.beginDirectHierarchyAnimation=function(t,i,r,n,a,o,l,c,f,h=!1){let d=t.getDescendants(i),u=[];u.push(this.beginDirectAnimation(t,r,n,a,o,l,c,f,h));for(let m of d)u.push(this.beginDirectAnimation(m,r,n,a,o,l,c,f,h));return u},s.prototype.getAnimatableByTarget=function(t){for(let i=0;i{dt();HF();ia();Bn();Ee();Yh=class s{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(n)}}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(n,1),r||this._raiseOnAnimationEnd())}}else{let n=this._scene._activeAnimatables.indexOf(this);if(n>-1){i||this._scene._activeAnimatables.splice(n,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,!s.ProcessPausedAnimatables&&this._weight===0&&this._previousWeight===0)return!0;this._previousWeight=this._weight;let t=!1,i=this._runtimeAnimations,r;for(r=0;r{Fp();jT();vr();jT();zF(nt,ds)});var YF={};Ie(YF,{AnimationGroup:()=>ZT,TargetedAnimation:()=>Vp});var Vp,ZT,KF=C(()=>{ia();dt();gt();Ha();XF();Nu();Vp=class{getClassName(){return"TargetedAnimation"}constructor(e){this.parent=e,this.uniqueId=Jn.UniqueId}serialize(){let e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e.targetUniqueId=this.target.uniqueId,e}},ZT=class s{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 s(e[0].name+"_merged",e[0]._scene,r);for(let l of e){i&&l.normalize(n,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 Q,this.onAnimationLoopObservable=new Q,this.onAnimationGroupLoopObservable=new Q,this.onAnimationGroupEndObservable=new Q,this.onAnimationGroupPauseObservable=new Q,this.onAnimationGroupPlayObservable=new Q,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 Vp(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};n.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,n){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++]=n:e&&this._checkAnimationGroupEnded(n,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 n=new s(e||this.name,this._scene,this._weight,this._playOrder);n._from=this.from,n._to=this.to,n._speedRatio=this.speedRatio,n._loopAnimation=this.loopAnimation,n._isAdditive=this.isAdditive,n._enableBlending=this.enableBlending,n._blendingSpeed=this.blendingSpeed,n.metadata=this.metadata,n.mask=this.mask;for(let a of this._targetedAnimations)n.addTargetedAnimation(i?a.animation.clone(r):a.animation,t?t(a.target):a.target);return n}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||n&&_.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),oKh,TransformNodeAnimationPropertyInfo:()=>pf,WeightAnimationPropertyInfo:()=>Gp,getQuaternion:()=>jF,getVector3:()=>qT,getWeights:()=>ZF});function qT(s,e,t,i){return S.FromArray(e,t).scaleInPlace(i)}function jF(s,e,t,i){return Se.FromArray(e,t).scaleInPlace(i)}function ZF(s,e,t,i){let r=new Array(s._numMorphTargets);for(let n=0;n{ia();Ee();YT();Kh=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 Ne(e,this.name,t,this.type);return r.setKeys(i,!0),r}},pf=class extends Kh{buildAnimations(e,t,i,r){let n=[];return n.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,i,r)}),n}},Gp=class extends Kh{buildAnimations(e,t,i,r){let n=[];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),n.push({babylonAnimatable:c,babylonAnimation:f})}}}return n}};zh("/nodes/{}/translation",[new pf(Ne.ANIMATIONTYPE_VECTOR3,"position",qT,()=>3)]);zh("/nodes/{}/rotation",[new pf(Ne.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",jF,()=>4)]);zh("/nodes/{}/scale",[new pf(Ne.ANIMATIONTYPE_VECTOR3,"scaling",qT,()=>3)]);zh("/nodes/{}/weights",[new Gp(Ne.ANIMATIONTYPE_FLOAT,"influence",ZF,s=>s._numMorphTargets)])});var S8,T8,A8,R8,QT,kp,JT,JF,Wp=C(()=>{pi();RE();S8="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+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==",T8="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==",A8="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",R8=0,QT=(s,e,t,i)=>{if(!s[t]){let r=s.useDelayedTextureLoading;s.useDelayedTextureLoading=!1;let n=s._blockEntityCollection;s._blockEntityCollection=!1;let a=ne.CreateFromBase64String(e,i+R8++,s,!0,!1,ne.BILINEAR_SAMPLINGMODE);s._blockEntityCollection=n;let o=s.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,s[t]=a,s.useDelayedTextureLoading=r,mc.ExpandRGBDTexture(a);let c=s.getEngine().onContextRestoredObservable.add(()=>{a.isRGBD=!0;let f=s.onBeforeRenderObservable.add(()=>{a.isReady()&&(s.onBeforeRenderObservable.remove(f),mc.ExpandRGBDTexture(a))})});s.onDisposeObservable.add(()=>{s.getEngine().onContextRestoredObservable.remove(c)})}return s[t]},kp=s=>QT(s,S8,"environmentBRDFTexture","EnvironmentBRDFTexture"),JT=s=>QT(s,T8,"environmentFuzzBRDFTexture","EnvironmentFuzzBRDFTexture"),JF=s=>QT(s,A8,"openPBREnvironmentBRDFTexture","OpenPBREnvironmentBRDFTexture")});function $F(s){return class extends s{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 ew=C(()=>{});var $T=C(()=>{Dr();We();ur();He.prototype.restoreSingleAttachment=function(){let s=this._gl;this.bindAttachments([s.BACK])};He.prototype.restoreSingleAttachmentForRenderTarget=function(){let s=this._gl;this.bindAttachments([s.COLOR_ATTACHMENT0])};He.prototype.buildTextureLayout=function(s,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=n?13:14);let M=this._gl,F=this._currentFramebuffer,N=M.createFramebuffer();this._bindUnboundFramebuffer(N);let V=(Y=s.width)!=null?Y:s,O=(K=s.height)!=null?K:s,U=[],k=[],z=this.webGLVersion>1&&(o===13||o===17||o===18);D.label=(j=e==null?void 0:e.label)!=null?j:"MultiRenderTargetWrapper",D._framebuffer=N,D._generateDepthBuffer=a||r,D._generateStencilBuffer=a?z:n,D._depthStencilBuffer=this._setupFramebufferDepthAttachments(D._generateStencilBuffer,D._generateDepthBuffer,V,O,1,o),D._attachments=k;for(let _e=0;_e1||this.isWebGPU);let Ze=this.webGLVersion>1,Fe=M[Ze?"COLOR_ATTACHMENT"+_e:"COLOR_ATTACHMENT"+_e+"_WEBGL"];if(k.push(Fe),ce===-1||P)continue;let Xe=new Dt(this,6);U[_e]=Xe,M.activeTexture(M["TEXTURE"+_e]),M.bindTexture(ce,Xe._hardwareTexture.underlyingResource),M.texParameteri(ce,M.TEXTURE_MAG_FILTER,ke.mag),M.texParameteri(ce,M.TEXTURE_MIN_FILTER,ke.min),M.texParameteri(ce,M.TEXTURE_WRAP_S,M.CLAMP_TO_EDGE),M.texParameteri(ce,M.TEXTURE_WRAP_T,M.CLAMP_TO_EDGE);let St=this._getRGBABufferInternalSizedFormat(te,xe,le),bt=this._getInternalFormat(xe),Gt=this._getWebGLTextureType(te);if(Ze&&(ce===35866||ce===32879))ce===35866?Xe.is2DArray=!0:Xe.is3D=!0,Xe.baseDepth=Xe.depth=de,M.texImage3D(ce,0,St,V,O,de,0,bt,Gt,null);else if(ce===34067){for(let si=0;si<6;si++)M.texImage2D(M.TEXTURE_CUBE_MAP_POSITIVE_X+si,0,St,V,O,0,bt,Gt,null);Xe.isCube=!0}else M.texImage2D(M.TEXTURE_2D,0,St,V,O,0,bt,Gt,null);i&&M.generateMipmap(ce),this._bindTextureDirectly(ce,null),Xe.baseWidth=V,Xe.baseHeight=O,Xe.width=V,Xe.height=O,Xe.isReady=!0,Xe.samples=1,Xe.generateMipMaps=i,Xe.samplingMode=pe,Xe.type=te,Xe._useSRGBBuffer=le,Xe.format=xe,Xe.label=(be=R[_e])!=null?be:D.label+"-Texture"+_e,this._internalTexturesCache.push(Xe)}if(a&&this._caps.depthTextureExtension&&!P){let _e=new Dt(this,14),pe=5,te=M.DEPTH_COMPONENT16,le=M.DEPTH_COMPONENT,xe=M.UNSIGNED_SHORT,ce=M.DEPTH_ATTACHMENT;this.webGLVersion<2?te=M.DEPTH_COMPONENT:o===14?(pe=1,xe=M.FLOAT,te=M.DEPTH_COMPONENT32F):o===18?(pe=0,xe=M.FLOAT_32_UNSIGNED_INT_24_8_REV,te=M.DEPTH32F_STENCIL8,le=M.DEPTH_STENCIL,ce=M.DEPTH_STENCIL_ATTACHMENT):o===16?(pe=0,xe=M.UNSIGNED_INT,te=M.DEPTH_COMPONENT24,ce=M.DEPTH_ATTACHMENT):(o===13||o===17)&&(pe=12,xe=M.UNSIGNED_INT_24_8,te=M.DEPTH24_STENCIL8,le=M.DEPTH_STENCIL,ce=M.DEPTH_STENCIL_ATTACHMENT),this._bindTextureDirectly(M.TEXTURE_2D,_e,!0),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MAG_FILTER,M.NEAREST),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MIN_FILTER,M.NEAREST),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_S,M.CLAMP_TO_EDGE),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_T,M.CLAMP_TO_EDGE),M.texImage2D(M.TEXTURE_2D,0,te,V,O,0,le,xe,null),M.framebufferTexture2D(M.FRAMEBUFFER,ce,M.TEXTURE_2D,_e._hardwareTexture.underlyingResource,0),this._bindTextureDirectly(M.TEXTURE_2D,null),D._depthStencilTexture=_e,D._depthStencilTextureWithStencil=z,_e.baseWidth=V,_e.baseHeight=O,_e.width=V,_e.height=O,_e.isReady=!0,_e.samples=1,_e.generateMipMaps=i,_e.samplingMode=1,_e.format=o,_e.type=pe,_e.label=D.label+"-DepthStencil",U[l]=_e,this._internalTexturesCache.push(_e)}if(D.setTextures(U),t&&M.drawBuffers(k),this._bindUnboundFramebuffer(F),D.setLayerAndFaceIndices(T,x),this.resetTextureCache(),!P)this.updateMultipleRenderTargetTextureSampleCount(D,c,t);else if(c>1){let _e=M.createFramebuffer();if(!_e)throw new Error("Unable to create multi sampled framebuffer");D._samples=c,D._MSAAFramebuffer=_e,l>0&&t&&(this._bindUnboundFramebuffer(_e),M.drawBuffers(k),this._bindUnboundFramebuffer(F))}return D};He.prototype.updateMultipleRenderTargetTextureSampleCount=function(s,e,t=!0){if(this.webGLVersion<2||!s)return 1;if(s.samples===e)return e;let i=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),s._depthStencilBuffer&&(i.deleteRenderbuffer(s._depthStencilBuffer),s._depthStencilBuffer=null),s._MSAAFramebuffer&&(i.deleteFramebuffer(s._MSAAFramebuffer),s._MSAAFramebuffer=null);let r=s._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");s._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);let o=[];for(let l=0;l1?"COLOR_ATTACHMENT"+l:"COLOR_ATTACHMENT"+l+"_WEBGL"],d=this._createRenderBuffer(c.width,c.height,e,-1,this._getRGBABufferInternalSizedFormat(c.type,c.format,c._useSRGBBuffer),h);if(!d)throw new Error("Unable to create multi sampled framebuffer");f.addMSAARenderBuffer(d),c.samples=e,o.push(h)}t&&i.drawBuffers(o)}else this._bindUnboundFramebuffer(s._framebuffer);let n=s._depthStencilTexture?s._depthStencilTexture.format:void 0;return s._depthStencilBuffer=this._setupFramebufferDepthAttachments(s._generateStencilBuffer,s._generateDepthBuffer,s.width,s.height,e,n),this._bindUnboundFramebuffer(null),s._samples=e,e};He.prototype.generateMipMapsMultiFramebuffer=function(s){let e=s,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 Hp,tw=C(()=>{pi();ja();$T();Hp=class extends fi{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,n,a,o,l,c,f){for(let h=0;h{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 iw,x8,rw=C(()=>{w();iw="mrtFragmentDeclaration",x8=`#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +layout(location=0) out vec4 glFragData[{X}]; +#endif +`;E.IncludesShadersStore[iw]||(E.IncludesShadersStore[iw]=x8)});var sw,I8,zp=C(()=>{w();sw="pbrFragmentReflectionDeclaration",I8=`#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +#define sampleReflection(s,c) textureCube(s,c) +uniform samplerCube reflectionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l) +#else +uniform samplerCube reflectionSamplerLow;uniform samplerCube reflectionSamplerHigh; +#endif +#ifdef USEIRRADIANCEMAP +uniform samplerCube irradianceSampler; +#endif +#else +#define sampleReflection(s,c) texture2D(s,c) +uniform sampler2D reflectionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l) +#else +uniform sampler2D reflectionSamplerLow;uniform sampler2D reflectionSamplerHigh; +#endif +#ifdef USEIRRADIANCEMAP +uniform sampler2D irradianceSampler; +#endif +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#endif +#endif +`;E.IncludesShadersStore[sw]||(E.IncludesShadersStore[sw]=I8)});var nw,C8,eA=C(()=>{w();nw="sceneFragmentDeclaration",C8=`uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif +uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;uniform mat4 inverseProjection; +`;E.IncludesShadersStore[nw]||(E.IncludesShadersStore[nw]=C8)});var aw,b8,_f=C(()=>{w();aw="pbrBRDFFunctions",b8=`#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 +#define BRDF_DIFFUSE_MODEL_LEGACY 3 +#define DIELECTRIC_SPECULAR_MODEL_GLTF 0 +#define DIELECTRIC_SPECULAR_MODEL_OPENPBR 1 +#define CONDUCTOR_SPECULAR_MODEL_GLTF 0 +#define CONDUCTOR_SPECULAR_MODEL_OPENPBR 1 +#if !defined(PBR_VERTEX_SHADER) && !defined(OPENPBR_VERTEX_SHADER) +#ifdef MS_BRDF_ENERGY_CONSERVATION +vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);} +#endif +#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR +#define F82_COS_THETA_MAX 0.142857143 +#define F82_ONE_MINUS_CTM_POW5 0.462664366 +#define F82_ONE_MINUS_CTM_POW6 0.396569457 +#define F82_B_DENOMINATOR_RECIP 17.6512785 +#define BRDF_Z_SCALE 16.0 +vec3 getF82Specular(float NdotV,vec3 F0,vec3 edgeTint,float roughness) {vec3 white_minus_F0=vec3(1.0)-F0;vec3 b=(F0+white_minus_F0*F82_ONE_MINUS_CTM_POW5)*(vec3(1.0)-edgeTint)*F82_B_DENOMINATOR_RECIP;float cos_theta=max(roughness,NdotV);float one_minus_cos_theta=1.0-cos_theta;vec3 offset_from_F0=(white_minus_F0-b*cos_theta*one_minus_cos_theta)*pow(one_minus_cos_theta,5.0);return clamp(F0+offset_from_F0,0.0,1.0);} +vec3 getF82B(vec3 F0,vec3 edgeTint) {return (F0+(vec3(1.0)-F0)*F82_ONE_MINUS_CTM_POW5)*(vec3(1.0)-edgeTint)*F82_B_DENOMINATOR_RECIP;} +vec3 getF82DirectionalAlbedo(vec3 F0,vec3 F90,vec3 b,vec3 environmentBrdf) {return (F90-F0)*environmentBrdf.x+F0*environmentBrdf.y-b*environmentBrdf.z;} +vec3 getF82AverageFresnel(vec3 F0,vec3 b) {return F0+(vec3(1.0)-F0)/21.0-b/126.0;} +#endif +#ifdef FUZZENVIRONMENTBRDF +vec3 getFuzzBRDFLookup(float NdotV,float perceptualRoughness) {vec2 UV=vec2(perceptualRoughness,NdotV);vec4 brdfLookup=texture2D(environmentFuzzBrdfSampler,UV);const vec2 RiRange=vec2(0.0,0.75);const vec2 ARange =vec2(0.005,0.88);const vec2 BRange =vec2(-0.18,0.002);brdfLookup.r=mix(ARange.x, ARange.y, brdfLookup.r);brdfLookup.g=mix(BRange.x, BRange.y, brdfLookup.g);brdfLookup.b=mix(RiRange.x,RiRange.y,brdfLookup.b);return brdfLookup.rgb;} +#endif +#ifdef ENVIRONMENTBRDF +vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {vec2 UV=vec2(NdotV,perceptualRoughness);vec4 brdfLookup=texture2D(environmentBrdfSampler,UV); +#ifdef ENVIRONMENTBRDF_RGBD +brdfLookup.rgb=fromRGBD(brdfLookup.rgba); +#endif +return brdfLookup.rgb;} +vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) { +#ifdef BRDF_V_HEIGHT_CORRELATED +vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y; +#else +vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y; +#endif +return reflectance;} +vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) { +#ifdef BRDF_V_HEIGHT_CORRELATED +vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0); +#else +vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y; +#endif +return reflectance;} +#endif +/* NOT USED +#if defined(SHEEN) && defined(SHEEN_SOFTER) +float getBRDFLookupCharlieSheen(float NdotV,float perceptualRoughness) +{float c=1.0-NdotV;float c3=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));} +#endif +*/ +#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL) +vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness) +{float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));} +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) +/** +* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture. +* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table +*/ +vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;} +#endif +vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90) +{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);} +float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90) +{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);} +#ifdef CLEARCOAT +vec3 getR0RemappedForClearCoat(vec3 f0) { +#ifdef CLEARCOAT_DEFAULTIOR +#ifdef MOBILE +return saturate(f0*(f0*0.526868+0.529324)-0.0482256); +#else +return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998); +#endif +#else +vec3 s=sqrt(f0);vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);return square(t); +#endif +} +#endif +#ifdef IRIDESCENCE +const mat3 XYZ_TO_REC709=mat3( +3.2404542,-0.9692660, 0.0556434, +-1.5371385, 1.8760108,-0.2040259, +-0.4985314, 0.0415560, 1.0572252 +);vec3 getIORTfromAirToSurfaceR0(vec3 f0) {vec3 sqrtF0=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);} +vec3 getR0fromIORs(vec3 iorT,float iorI) {return square((iorT-vec3(iorI))/(iorT+vec3(iorI)));} +float getR0fromIORs(float iorT,float iorI) {return square((iorT-iorI)/(iorT+iorI));} +vec3 evalSensitivity(float opd,vec3 shift) {float phase=2.0*PI*opd*1.0e-9;const vec3 val=vec3(5.4856e-13,4.4201e-13,5.2481e-13);const vec3 pos=vec3(1.6810e+06,1.7953e+06,2.2084e+06);const vec3 var=vec3(4.3278e+09,9.3046e+09,6.6121e+09);vec3 xyz=val*sqrt(2.0*PI*var)*cos(pos*phase+shift)*exp(-square(phase)*var);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;vec3 srgb=XYZ_TO_REC709*xyz;return srgb;} +vec3 evalIridescence(float outsideIOR,float eta2,float cosTheta1,float thinFilmThickness,vec3 baseF0) {vec3 I=vec3(1.0);float iridescenceIOR=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));float sinTheta2Sq=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));float cosTheta2Sq=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;} +float cosTheta2=sqrt(cosTheta2Sq);float R0=getR0fromIORs(iridescenceIOR,outsideIOR);float R12=fresnelSchlickGGX(cosTheta1,R0,1.);float R21=R12;float T121=1.0-R12;float phi12=0.0;if (iridescenceIOR0.0 ? s/max(mu_i,mu_o) : s; +float AF=1.0/(1.0+constant1_FON*sigma); +vec3 f_ss=(rho*RECIPROCAL_PI)*AF*(1.0+sigma*sovertF); +float EFo=E_FON_approx(mu_o,sigma); +float EFi=E_FON_approx(mu_i,sigma); +float avgEF=AF*(1.0+constant2_FON*sigma); +vec3 rho_ms=(rho*rho)*avgEF/(vec3(1.0)-rho*(1.0-avgEF));const float eps=1.0e-7;vec3 f_ms=(rho_ms*RECIPROCAL_PI)*max(eps,1.0-EFo) +* max(eps,1.0-EFi) +/ max(eps,1.0-avgEF);return (f_ss+f_ms);} +#ifdef SS_TRANSLUCENCY +vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {vec3 S=1./maxEps(diffusionDistance);vec3 temp=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);} +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[aw]||(E.IncludesShadersStore[aw]=b8)});var ow,M8,tA=C(()=>{w();ow="openpbrDielectricReflectance",M8=`struct ReflectanceParams +{float F0;float F90;vec3 coloredF0;vec3 coloredF90;}; +#define pbr_inline +ReflectanceParams dielectricReflectance( +in float insideIOR,in float outsideIOR,in vec3 specularColor,in float specularWeight +) +{ReflectanceParams outParams;float dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);float dielectricF0_NoSpec=pow((1.0-outsideIOR)/(1.0+outsideIOR),2.0);float f90Scale=clamp(2.0*abs(insideIOR-outsideIOR),0.0,1.0);float f90Scale_NoSpec=clamp(2.0*abs(1.0-outsideIOR),0.0,1.0); +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +vec3 dielectricColorF90=specularColor.rgb*vec3(f90Scale);vec3 dielectricColorF90_NoSpec=specularColor.rgb*vec3(f90Scale_NoSpec); +#else +vec3 dielectricColorF90=vec3(f90Scale);vec3 dielectricColorF90_NoSpec=vec3(f90Scale_NoSpec); +#endif +#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF +float maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=mix(dielectricF0_NoSpec,dielectricF0,specularWeight)*maxF0; +#else +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[ow]||(E.IncludesShadersStore[ow]=M8)});var lw,y8,Xp=C(()=>{w();lw="pbrIBLFunctions",y8=`#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 +#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION) +float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {float temp=NdotVUnclamped+ambientOcclusion;return saturate(square(temp)-1.0+ambientOcclusion);} +#endif +#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION) +float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {vec3 reflection=reflect(view,normal);float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));return square(temp);} +#endif +#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA) +#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[lw]||(E.IncludesShadersStore[lw]=y8)});var cw,D8,iA=C(()=>{w();cw="openpbrGeometryInfo",D8=`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 +geometryInfoOutParams geometryInfo( +in vec3 normalW,in vec3 viewDirectionW,in float roughness,in vec3 geometricNormalW +) +{geometryInfoOutParams outParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped); +#if defined(ENVIRONMENTBRDF) +outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness); +#else +outParams.environmentBrdf=vec3(0.0); +#endif +outParams.horizonOcclusion=1.0; +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef HORIZONOCCLUSION +#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) +#ifdef REFLECTIONMAP_3D +outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); +#endif +#endif +#endif +#endif +return outParams;} +#define pbr_inline +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[cw]||(E.IncludesShadersStore[cw]=D8)});var fw,P8,rA=C(()=>{w();fw="openpbrIblFunctions",P8=`#ifdef REFLECTION +vec3 sampleIrradiance( +in vec3 surfaceNormal +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,in vec3 vEnvironmentIrradianceSH +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,in mat4 iblMatrix +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,in samplerCube irradianceSampler +#else +,in sampler2D irradianceSampler +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,in vec3 reflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,in sampler2D icdfSampler +#endif +#endif +,in vec2 vReflectionInfos +,in vec3 viewDirectionW +,in float diffuseRoughness +,in vec3 surfaceAlbedo +) {vec3 environmentIrradiance=vec3(0.,0.,0.); +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +vec3 irradianceVector=(iblMatrix*vec4(surfaceNormal,0)).xyz;vec3 irradianceView=(iblMatrix*vec4(viewDirectionW,0)).xyz; +#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +{float NdotV=max(dot(surfaceNormal,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);} +#endif +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0;irradianceView.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0;irradianceView.y*=-1.0; +#endif +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +environmentIrradiance=vEnvironmentIrradianceSH; +#else +#if defined(REALTIME_FILTERING) +environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +); +#else +environmentIrradiance=computeEnvironmentIrradiance(irradianceVector); +#endif +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +vec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,irradianceVector); +#else +vec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,reflectionCoords); +#endif +environmentIrradiance=environmentIrradianceFromTexture.rgb; +#ifdef RGBDREFLECTION +environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture); +#endif +#ifdef GAMMAREFLECTION +environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb); +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0))); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm; +#endif +#endif +environmentIrradiance*=vReflectionInfos.x;return environmentIrradiance;} +#define pbr_inline +#ifdef REFLECTIONMAP_3D +vec3 createReflectionCoords( +#else +vec2 createReflectionCoords( +#endif +in vec3 vPositionW +,in vec3 normalW +) +{vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=reflectionVector; +#else +vec2 reflectionCoords=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0-reflectionCoords.y; +#endif +return reflectionCoords;} +#define pbr_inline +#define inline +vec3 sampleRadiance( +in float alphaG +,in vec3 vReflectionMicrosurfaceInfos +,in vec2 vReflectionInfos +,in geometryInfoOutParams geoInfo +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSampler +,const vec3 reflectionCoords +#else +,in sampler2D reflectionSampler +,const vec2 reflectionCoords +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#endif +) +{vec4 environmentRadiance=vec4(0.,0.,0.,0.); +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness); +#else +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG); +#endif +reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +#ifdef REALTIME_FILTERING +environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0); +#else +environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD); +#endif +#ifdef RGBDREFLECTION +environmentRadiance.rgb=fromRGBD(environmentRadiance); +#endif +#ifdef GAMMAREFLECTION +environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb); +#endif +environmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;} +#if defined(ANISOTROPIC) +#define pbr_inline +#define inline +vec3 sampleRadianceAnisotropic( +in float alphaG +,in vec3 vReflectionMicrosurfaceInfos +,in vec2 vReflectionInfos +,in geometryInfoAnisoOutParams geoInfo +,const vec3 normalW +,const vec3 viewDirectionW +,const vec3 positionW +,const vec3 noise +,bool isRefraction +,float ior +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSampler +#else +,in sampler2D reflectionSampler +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#endif +) +{vec4 environmentRadiance=vec4(0.,0.,0.,0.);float alphaT=alphaG*sqrt(2.0/(1.0+(1.0-geoInfo.anisotropy)*(1.0-geoInfo.anisotropy)));float alphaB=(1.0-geoInfo.anisotropy)*alphaT;alphaG=alphaB; +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness); +#else +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG); +#endif +reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +#ifdef REALTIME_FILTERING +vec3 view=(reflectionMatrix*vec4(viewDirectionW,0.0)).xyz;vec3 tangent=(reflectionMatrix*vec4(geoInfo.anisotropicTangent,0.0)).xyz;vec3 bitangent=(reflectionMatrix*vec4(geoInfo.anisotropicBitangent,0.0)).xyz;vec3 normal=(reflectionMatrix*vec4(normalW,0.0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +view.z*=-1.0;tangent.z*=-1.0;bitangent.z*=-1.0;normal.z*=-1.0; +#endif +environmentRadiance = +vec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler, +view,tangent, +bitangent,normal, +vReflectionFilteringInfo,noise.xy,isRefraction,ior), +1.0); +#else +const int samples=16;vec4 radianceSample=vec4(0.0);vec3 reflectionCoords=vec3(0.0);float sample_weight=0.0;float total_weight=0.0;float step=1.0/float(max(samples-1,1));for (int i=0; i0.0) {float blend=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;} +if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);} +reflectionCoords=vec3(reflectionMatrix*vec4(reflectionCoords,0)); +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionCoords.z*=-1.0; +#endif +radianceSample=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD); +#ifdef RGBDREFLECTION +environmentRadiance.rgb+=sample_weight*fromRGBD(radianceSample); +#elif defined(GAMMAREFLECTION) +environmentRadiance.rgb+=sample_weight*toLinearSpace(radianceSample.rgb); +#else +environmentRadiance.rgb+=sample_weight*radianceSample.rgb; +#endif +total_weight+=sample_weight;} +environmentRadiance=vec4(environmentRadiance.xyz/float(total_weight),1.0); +#endif +environmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;} +#endif +#endif +#if defined(ENVIRONMENTBRDF) +#define pbr_inline +float computeDielectricIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf) +{float dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(reflectance.F0),vec3(reflectance.F90),environmentBrdf).r;float dielectricECF=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);} +#define pbr_inline +vec3 computeConductorIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf) +{ +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF) +vec3 openPBRBrdf=vec3(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);vec3 b =getF82B(reflectance.coloredF0,reflectance.coloredF90);vec3 E_F82=getF82DirectionalAlbedo(reflectance.coloredF0,vec3(1.0),b,openPBRBrdf);vec3 F_avg=getF82AverageFresnel(reflectance.coloredF0,b);vec3 ECF =vec3(1.0)+F_avg*(vec3(1.0)/openPBRBrdf.y-vec3(1.0));return clamp(E_F82*ECF,vec3(0.0),vec3(1.0)); +#else +return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf); +#endif +} +#endif +`;E.IncludesShadersStore[fw]||(E.IncludesShadersStore[fw]=P8)});var hw,L8,sA=C(()=>{w();hw="openpbrSubsurfaceLayerData",L8=`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 +#ifdef SUBSURFACE_COLOR +vec4 subsurfaceColorFromTexture=texture2D(subsurfaceColorSampler,vSubsurfaceColorUV+uvOffset); +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +vec4 subsurfaceRadiusScaleFromTexture=texture2D(subsurfaceRadiusScaleSampler,vSubsurfaceRadiusScaleUV+uvOffset); +#endif +#ifdef SUBSURFACE_WEIGHT +subsurface_weight*=subsurfaceWeightFromTexture.r; +#endif +#ifdef SUBSURFACE_COLOR +#ifdef SUBSURFACE_COLOR_GAMMA +subsurface_color*=toLinearSpace(subsurfaceColorFromTexture.rgb); +#else +subsurface_color*=subsurfaceColorFromTexture.rgb; +#endif +subsurface_color*=vSubsurfaceColorInfos.y; +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb; +#endif +`;E.IncludesShadersStore[hw]||(E.IncludesShadersStore[hw]=L8)});var dw,O8,nA=C(()=>{w();dw="openpbrTransmissionLayerData",O8=`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 +#ifdef TRANSMISSION_COLOR +vec4 transmissionColorFromTexture=texture2D(transmissionColorSampler,vTransmissionColorUV+uvOffset); +#endif +#ifdef TRANSMISSION_DEPTH +vec4 transmissionDepthFromTexture=texture2D(transmissionDepthSampler,vTransmissionDepthUV+uvOffset); +#endif +#ifdef TRANSMISSION_SCATTER +vec4 transmissionScatterFromTexture=texture2D(transmissionScatterSampler,vTransmissionScatterUV+uvOffset); +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +vec4 transmissionDispersionScaleFromTexture=texture2D(transmissionDispersionScaleSampler,vTransmissionDispersionScaleUV+uvOffset); +#endif +#ifdef TRANSMISSION_WEIGHT +transmission_weight*=transmissionWeightFromTexture.r; +#endif +#ifdef TRANSMISSION_COLOR +#ifdef TRANSMISSION_COLOR_GAMMA +transmission_color*=toLinearSpace(transmissionColorFromTexture.rgb); +#else +transmission_color*=transmissionColorFromTexture.rgb; +#endif +transmission_color*=vTransmissionColorInfos.y; +#endif +#ifdef TRANSMISSION_DEPTH +transmission_depth*=transmissionDepthFromTexture.r; +#endif +#ifdef TRANSMISSION_SCATTER +transmission_scatter*=transmissionScatterFromTexture.rgb; +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r; +#endif +`;E.IncludesShadersStore[dw]||(E.IncludesShadersStore[dw]=O8)});var mw={};Ie(mw,{geometryPixelShader:()=>N8});var aA,uw,N8,oA=C(()=>{w();vn();rw();fp();hp();Or();zp();eA();Io();_f();tA();Xp();Bh();iA();rA();_l();Sn();dp();sA();nA();aA="geometryPixelShader",uw=`#extension GL_EXT_draw_buffers : require +#if defined(BUMP) || !defined(NORMAL) +#extension GL_OES_standard_derivatives : enable +#endif +precision highp float; +#ifdef BUMP +varying mat4 vWorldView;varying vec3 vNormalW; +#else +varying vec3 vNormalV; +#endif +varying vec4 vViewPos; +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +varying vec3 vPositionW; +#endif +#if defined(VELOCITY) || defined(VELOCITY_LINEAR) +varying vec4 vCurrentPosition;varying vec4 vPreviousPosition; +#endif +#ifdef NEED_UV +varying vec2 vUV; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams; +#endif +#if defined(REFLECTIVITY) +#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE) +uniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV; +#else +#ifdef METALLIC_TEXTURE +uniform sampler2D metallicSampler;varying vec2 vMetallicUV; +#endif +#ifdef ROUGHNESS_TEXTURE +uniform sampler2D roughnessSampler;varying vec2 vRoughnessUV; +#endif +#endif +#ifdef ALBEDOTEXTURE +varying vec2 vAlbedoUV;uniform sampler2D albedoSampler; +#endif +#ifdef REFLECTIVITYCOLOR +uniform vec3 reflectivityColor; +#endif +#ifdef ALBEDOCOLOR +uniform vec3 albedoColor; +#endif +#ifdef METALLIC +uniform float metallic; +#endif +#if defined(ROUGHNESS) || defined(GLOSSINESS) +uniform float glossiness; +#endif +#endif +#if defined(ALPHATEST) && defined(NEED_UV) +uniform sampler2D diffuseSampler; +#endif +#include +#include[SCENE_MRT_COUNT] +#include +#include +#include +#ifdef IRRADIANCE +#include +#ifdef REFLECTION +#ifdef USEIRRADIANCEMAP +#include<__decl__sceneFragment> +uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionDominantDirection; +#include +#include +#include +#include +#include +#include +#elif defined(USESPHERICALFROMREFLECTIONMAP) +varying vec3 vEnvironmentIrradiance; +#endif +#ifdef IBL_SHADOW_TEXTURE +uniform sampler2D iblShadowSampler;uniform vec2 shadowTextureSize; +#endif +#ifdef IRRADIANCE_SCATTER_MASK +uniform float vSubsurfaceWeight; +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight) +uniform float vSubsurfaceScatterAnisotropy;uniform float vTransmissionWeight; +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight) +uniform float vTransmissionScatterAnisotropy; +#endif +#endif +#endif +void main() { +#include +#ifdef ALPHATEST +if (texture2D(diffuseSampler,vUV).a<0.4) +discard; +#endif +vec3 normalOutput; +#ifdef BUMP +vec3 normalW=normalize(vNormalW); +#include +#ifdef NORMAL_WORLDSPACE +normalOutput=normalW; +#else +normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0))); +#endif +#elif defined(HAS_NORMAL_ATTRIBUTE) +normalOutput=normalize(vNormalV); +#elif defined(POSITION) +normalOutput=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW))); +#endif +#ifdef ENCODE_NORMAL +normalOutput=normalOutput*0.5+0.5; +#endif +#ifdef DEPTH +gl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0); +#endif +#ifdef NORMAL +gl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0); +#endif +#ifdef SCREENSPACE_DEPTH +gl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0); +#endif +#ifdef POSITION +gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0); +#endif +#ifdef VELOCITY +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0); +#endif +#ifdef VELOCITY_LINEAR +vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) - +(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0); +#endif +#ifdef REFLECTIVITY +vec4 reflectivity=vec4(0.0,0.0,0.0,1.0); +#ifdef METALLICWORKFLOW +float metal=1.0;float roughness=1.0; +#ifdef ORMTEXTURE +metal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g; +#else +#ifdef METALLIC_TEXTURE +metal*=texture2D(metallicSampler,vMetallicUV).r; +#endif +#ifdef ROUGHNESS_TEXTURE +roughness*=texture2D(roughnessSampler,vRoughnessUV).r; +#endif +#endif +#ifdef METALLIC +metal*=metallic; +#endif +#ifdef ROUGHNESS +roughness*=(1.0-glossiness); +#endif +reflectivity.a-=roughness;vec3 color=vec3(1.0); +#ifdef ALBEDOTEXTURE +color=texture2D(albedoSampler,vAlbedoUV).rgb; +#ifdef GAMMAALBEDO +color=toLinearSpace(color); +#endif +#endif +#ifdef ALBEDOCOLOR +color*=albedoColor.xyz; +#endif +reflectivity.rgb=mix(vec3(0.04),color,metal); +#else +#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE) +reflectivity=texture2D(reflectivitySampler,vReflectivityUV); +#ifdef GAMMAREFLECTIVITYTEXTURE +reflectivity.rgb=toLinearSpace(reflectivity.rgb); +#endif +#else +#ifdef REFLECTIVITYCOLOR +reflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0; +#endif +#endif +#ifdef GLOSSINESSS +reflectivity.a*=glossiness; +#endif +#endif +gl_FragData[REFLECTIVITY_INDEX]=reflectivity; +#endif +#ifdef IRRADIANCE +vec3 irradiance=vec3(0.0);float irradiance_alpha=1.0; +#ifdef REFLECTION +#ifdef IRRADIANCE_SCATTER_MASK +vec3 vSubsurfaceColor=vec3(1.0);float vSubsurfaceRadius=0.0;vec3 vSubsurfaceRadiusScale=vec3(1.0); +#include +float vTransmissionDepth=1.0;vec3 vTransmissionColor=vec3(1.0);vec3 vTransmissionScatter=vec3(0.0);float vTransmissionDispersionScale=0.0;float vTransmissionDispersionAbbeNumber=0.0; +#include +#endif +#ifdef IBL_SHADOW_TEXTURE +#ifdef COLORED_IBL_SHADOWS +vec3 iblShadowValue=texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).rgb; +#else +vec3 iblShadowValue=vec3(texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).r); +#endif +#endif +#if defined(USEIRRADIANCEMAP) +#ifdef IRRADIANCE_SCATTER_MASK +float bendAmount=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);bendAmount=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);vec3 viewVector=normalize(vEyePosition.xyz-vPositionW.xyz);vec3 bentNormal=mix(normalOutput,viewVector,bendAmount*dot(normalOutput,viewVector)); +#else +vec3 bentNormal=normalOutput; +#endif +irradiance=sampleIrradiance( +bentNormal +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +#endif +,vReflectionInfos +,vViewPos.xyz +,1.0 +,vec3(1.0) +); +#elif defined(USESPHERICALFROMREFLECTIONMAP) +irradiance=vEnvironmentIrradiance; +#endif +#ifdef IBL_SHADOW_TEXTURE +irradiance*=iblShadowValue; +#endif +#ifndef BUMP +vec2 uvOffset=vec2(0.0); +#endif +#ifdef IRRADIANCE_SCATTER_MASK +irradiance_alpha=min(subsurface_weight+transmission_weight,1.0); +#endif +#endif +gl_FragData[IRRADIANCE_INDEX]=vec4(irradiance,irradiance_alpha); +#endif +} +`;E.ShadersStore[aA]||(E.ShadersStore[aA]=uw);N8={name:aA,shader:uw}});var pw,F8,_w=C(()=>{w();pw="geometryVertexDeclaration",F8="uniform mat4 viewProjection;uniform mat4 view;";E.IncludesShadersStore[pw]||(E.IncludesShadersStore[pw]=F8)});var gw,w8,Ew=C(()=>{w();Io();gw="geometryUboDeclaration",w8=`#include +`;E.IncludesShadersStore[gw]||(E.IncludesShadersStore[gw]=w8)});var vw,B8,gf=C(()=>{w();vw="harmonicsFunctions",B8=`#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +vec3 computeEnvironmentIrradiance(vec3 normal) {return vSphericalL00 ++ vSphericalL1_1*(normal.y) ++ vSphericalL10*(normal.z) ++ vSphericalL11*(normal.x) ++ vSphericalL2_2*(normal.y*normal.x) ++ vSphericalL2_1*(normal.y*normal.z) ++ vSphericalL20*((3.0*normal.z*normal.z)-1.0) ++ vSphericalL21*(normal.z*normal.x) ++ vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));} +#else +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[vw]||(E.IncludesShadersStore[vw]=B8)});var Tw={};Ie(Tw,{geometryVertexShader:()=>U8});var lA,Sw,U8,cA=C(()=>{w();fa();ha();Co();bo();Eo();_w();Ew();gn();gf();Mo();yo();da();ua();ma();En();ep();lA="geometryVertexShader",Sw=`precision highp float; +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include<__decl__geometryVertex> +#include +#ifdef IRRADIANCE +#ifdef REFLECTION +uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionColor; +#ifdef USESPHERICALFROMREFLECTIONMAP +varying vec3 vEnvironmentIrradiance; +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22; +#else +uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX; +#endif +#include +#endif +#endif +#endif +attribute vec3 position; +#ifdef HAS_NORMAL_ATTRIBUTE +attribute vec3 normal; +#endif +#ifdef NEED_UV +varying vec2 vUV; +#ifdef ALPHATEST +uniform mat4 diffuseMatrix; +#endif +#ifdef BUMP +uniform mat4 bumpMatrix;varying vec2 vBumpUV; +#endif +#ifdef REFLECTIVITY +uniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV; +#endif +#ifdef METALLIC_TEXTURE +varying vec2 vMetallicUV;uniform mat4 metallicMatrix; +#endif +#ifdef ROUGHNESS_TEXTURE +varying vec2 vRoughnessUV;uniform mat4 roughnessMatrix; +#endif +#ifdef SUBSURFACE_WEIGHT +varying vec2 vSubsurfaceWeightUV;uniform mat4 subsurfaceWeightMatrix; +#endif +#ifdef TRANSMISSION_WEIGHT +varying vec2 vTransmissionWeightUV;uniform mat4 transmissionWeightMatrix; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#endif +#ifdef BUMP +varying mat4 vWorldView; +#endif +#ifdef BUMP +varying vec3 vNormalW; +#else +varying vec3 vNormalV; +#endif +varying vec4 vViewPos; +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +varying vec3 vPositionW; +#endif +#if defined(VELOCITY) || defined(VELOCITY_LINEAR) +uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) +{vec3 positionUpdated=position; +#ifdef HAS_NORMAL_ATTRIBUTE +vec3 normalUpdated=normal; +#else +vec3 normalUpdated=vec3(0.0,0.0,0.0); +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#include +#include +vec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0)); +#ifdef BUMP +vWorldView=view*finalWorld;mat3 normalWorld=mat3(finalWorld);vNormalW=normalize(normalWorld*normalUpdated); +#else +#ifdef NORMAL_WORLDSPACE +vNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0))); +#else +vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0))); +#endif +#endif +vViewPos=view*worldPos; +#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0); +#if NUM_BONE_INFLUENCERS>0 +mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; +#endif +vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0); +#else +vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#endif +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +vPositionW=worldPos.xyz/worldPos.w; +#endif +gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0); +#include +#ifdef NEED_UV +#ifdef UV1 +#if defined(ALPHATEST) && defined(ALPHATEST_UV1) +vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#else +vUV=uvUpdated; +#endif +#ifdef BUMP_UV1 +vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef REFLECTIVITY_UV1 +vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0)); +#else +#ifdef METALLIC_UV1 +vMetallicUV=vec2(metallicMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef ROUGHNESS_UV1 +vRoughnessUV=vec2(roughnessMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#endif +#ifdef ALBEDO_UV1 +vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef SUBSURFACE_COLOR_UV1 +vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef SUBSURFACE_WEIGHT_UV1 +vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#endif +#ifdef UV2 +#if defined(ALPHATEST) && defined(ALPHATEST_UV2) +vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); +#else +vUV=uv2Updated; +#endif +#ifdef BUMP_UV2 +vBumpUV=vec2(bumpMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#ifdef REFLECTIVITY_UV2 +vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2Updated,1.0,0.0)); +#else +#ifdef METALLIC_UV2 +vMetallicUV=vec2(metallicMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#ifdef ROUGHNESS_UV2 +vRoughnessUV=vec2(roughnessMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#ifdef ALBEDO_UV2 +vAlbedoUV=vec2(albedoMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#ifdef SUBSURFACE_COLOR_UV2 +vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#ifdef SUBSURFACE_WEIGHT_UV2 +vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#endif +#include +#ifdef IRRADIANCE +#ifdef REFLECTION +#ifdef USESPHERICALFROMREFLECTIONMAP +vec3 reflectionVector=vec3(reflectionMatrix*vec4(normalUpdated,0.0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*vReflectionInfos.x; +#endif +#endif +#endif +} +`;E.ShadersStore[lA]||(E.ShadersStore[lA]=Sw);U8={name:lA,shader:Sw}});var Aw,V8,Ef=C(()=>{w();Aw="harmonicsFunctions",V8=`#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +fn computeEnvironmentIrradiance(normal: vec3f)->vec3f {return uniforms.vSphericalL00 ++ uniforms.vSphericalL1_1*(normal.y) ++ uniforms.vSphericalL10*(normal.z) ++ uniforms.vSphericalL11*(normal.x) ++ uniforms.vSphericalL2_2*(normal.y*normal.x) ++ uniforms.vSphericalL2_1*(normal.y*normal.z) ++ uniforms.vSphericalL20*((3.0*normal.z*normal.z)-1.0) ++ uniforms.vSphericalL21*(normal.z*normal.x) ++ uniforms.vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));} +#else +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[Aw]||(E.IncludesShadersStoreWGSL[Aw]=V8)});var xw={};Ie(xw,{geometryVertexShaderWGSL:()=>G8});var fA,Rw,G8,Iw=C(()=>{w();na();aa();To();Ao();go();Tn();un();Ef();Ro();xo();oa();la();ca();mn();Lm();fA="geometryVertexShader",Rw=`#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +#ifdef IRRADIANCE +#ifdef REFLECTION +uniform reflectionMatrix: mat4x4f;uniform vReflectionInfos: vec2f;uniform vReflectionColor: vec3f; +#ifdef USESPHERICALFROMREFLECTIONMAP +varying vEnvironmentIrradiance: vec3f; +#ifdef SPHERICAL_HARMONICS +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; +#else +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; +#endif +#include +#endif +#endif +#endif +attribute position : vec3; +#ifdef HAS_NORMAL_ATTRIBUTE +attribute normal: vec3f; +#endif +#ifdef NEED_UV +varying vUV: vec2f; +#ifdef ALPHATEST +uniform diffuseMatrix: mat4x4f; +#endif +#ifdef BUMP +uniform bumpMatrix: mat4x4f;varying vBumpUV: vec2f; +#endif +#ifdef REFLECTIVITY +uniform reflectivityMatrix: mat4x4f;uniform albedoMatrix: mat4x4f;varying vReflectivityUV: vec2f;varying vAlbedoUV: vec2f; +#endif +#ifdef METALLIC_TEXTURE +varying vMetallicUV: vec2f;uniform metallicMatrix: mat4x4f; +#endif +#ifdef ROUGHNESS_TEXTURE +varying vRoughnessUV: vec2f;uniform roughnessMatrix: mat4x4f; +#endif +#ifdef SUBSURFACE_WEIGHT +varying vSubsurfaceWeightUV: vec2f;uniform subsurfaceWeightMatrix: mat4x4f; +#endif +#ifdef TRANSMISSION_WEIGHT +varying vTransmissionWeightUV: vec2f;uniform transmissionWeightMatrix: mat4x4f; +#endif +#ifdef UV1 +attribute uv: vec2f; +#endif +#ifdef UV2 +attribute uv2: vec2f; +#endif +#endif +#ifdef BUMP +varying vWorldView0: vec4f;varying vWorldView1: vec4f;varying vWorldView2: vec4f;varying vWorldView3: vec4f; +#endif +#ifdef BUMP +varying vNormalW: vec3f; +#else +varying vNormalV: vec3f; +#endif +varying vViewPos: vec4f; +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +varying vPositionW: vec3f; +#endif +#if defined(VELOCITY) || defined(VELOCITY_LINEAR) +uniform previousViewProjection: mat4x4f;varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position; +#ifdef HAS_NORMAL_ATTRIBUTE +var normalUpdated: vec3f=vertexInputs.normal; +#else +var normalUpdated: vec3f=vec3f(0.0,0.0,0.0); +#endif +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0); +#endif +#include +#include +var worldPos: vec4f= vec4f(finalWorld* vec4f(positionUpdated,1.0)); +#ifdef BUMP +let vWorldView=scene.view*finalWorld;vertexOutputs.vWorldView0=vWorldView[0];vertexOutputs.vWorldView1=vWorldView[1];vertexOutputs.vWorldView2=vWorldView[2];vertexOutputs.vWorldView3=vWorldView[3];let normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz);vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated); +#else +#ifdef NORMAL_WORLDSPACE +vertexOutputs.vNormalV=normalize((finalWorld* vec4f(normalUpdated,0.0)).xyz); +#else +vertexOutputs.vNormalV=normalize(((scene.view*finalWorld)* vec4f(normalUpdated,0.0)).xyz); +#endif +#endif +vertexOutputs.vViewPos=scene.view*worldPos; +#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED) +vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0); +#if NUM_BONE_INFLUENCERS>0 +var previousInfluence: mat4x4f;previousInfluence=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[0])]*vertexInputs.matricesWeights[0]; +#if NUM_BONE_INFLUENCERS>1 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[1])]*vertexInputs.matricesWeights[1]; +#endif +#if NUM_BONE_INFLUENCERS>2 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[2])]*vertexInputs.matricesWeights[2]; +#endif +#if NUM_BONE_INFLUENCERS>3 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndices[3])]*vertexInputs.matricesWeights[3]; +#endif +#if NUM_BONE_INFLUENCERS>4 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[0])]*vertexInputs.matricesWeightsExtra[0]; +#endif +#if NUM_BONE_INFLUENCERS>5 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[1])]*vertexInputs.matricesWeightsExtra[1]; +#endif +#if NUM_BONE_INFLUENCERS>6 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[2])]*vertexInputs.matricesWeightsExtra[2]; +#endif +#if NUM_BONE_INFLUENCERS>7 +previousInfluence+=uniforms.mPreviousBones[ i32(vertexInputs.matricesIndicesExtra[3])]*vertexInputs.matricesWeightsExtra[3]; +#endif +vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*previousInfluence* vec4f(positionUpdated,1.0); +#else +vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld* vec4f(positionUpdated,1.0); +#endif +#endif +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +vertexOutputs.vPositionW=worldPos.xyz/worldPos.w; +#endif +vertexOutputs.position=scene.viewProjection*finalWorld* vec4f(positionUpdated,1.0); +#include +#ifdef NEED_UV +#ifdef UV1 +#if defined(ALPHATEST) && defined(ALPHATEST_UV1) +vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#else +vertexOutputs.vUV=uvUpdated; +#endif +#ifdef BUMP_UV1 +vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef REFLECTIVITY_UV1 +vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#else +#ifdef METALLIC_UV1 +vertexOutputs.vMetallicUV=(uniforms.metallicMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef ROUGHNESS_UV1 +vertexOutputs.vRoughnessUV=(uniforms.roughnessMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#endif +#ifdef ALBEDO_UV1 +vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef SUBSURFACE_WEIGHT_UV1 +vertexOutputs.vSubsurfaceWeightUV=(uniforms.subsurfaceWeightMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef TRANSMISSION_WEIGHT_UV1 +vertexOutputs.vTransmissionWeightUV=(uniforms.transmissionWeightMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#endif +#ifdef UV2 +#if defined(ALPHATEST) && defined(ALPHATEST_UV2) +vertexOutputs.vUV=(uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#else +vertexOutputs.vUV=uv2Updated; +#endif +#ifdef BUMP_UV2 +vertexOutputs.vBumpUV=(uniforms.bumpMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#ifdef REFLECTIVITY_UV2 +vertexOutputs.vReflectivityUV=(uniforms.reflectivityMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#else +#ifdef METALLIC_UV2 +vertexOutputs.vMetallicUV=(uniforms.metallicMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#ifdef ROUGHNESS_UV2 +vertexOutputs.vRoughnessUV=(uniforms.roughnessMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#ifdef ALBEDO_UV2 +vertexOutputs.vAlbedoUV=(uniforms.albedoMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#ifdef SUBSURFACE_WEIGHT_UV2 +vertexOutputs.vSubsurfaceWeightUV=(uniforms.subsurfaceWeightMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#ifdef TRANSMISSION_WEIGHT_UV2 +vertexOutputs.vTransmissionWeightUV=(uniforms.transmissionWeightMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#endif +#include +#ifdef IRRADIANCE +#ifdef REFLECTION +#ifdef USESPHERICALFROMREFLECTIONMAP +var reflectionVector: vec3f=(uniforms.reflectionMatrix*vec4f(normalUpdated,0.0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0f; +#endif +vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*uniforms.vReflectionInfos.x; +#endif +#endif +#endif +} +`;E.ShadersStoreWGSL[fA]||(E.ShadersStoreWGSL[fA]=Rw);G8={name:fA,shader:Rw}});var Cw,k8,Yp=C(()=>{w();Cw="pbrFragmentReflectionDeclaration",k8=`#ifdef REFLECTION +#ifdef REFLECTIONMAP_3D +var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube; +#ifdef LODBASEDMICROSFURACE +#else +var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube; +#endif +#ifdef USEIRRADIANCEMAP +var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube; +#endif +#else +var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d; +#ifdef LODBASEDMICROSFURACE +#else +var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d; +#endif +#ifdef USEIRRADIANCEMAP +var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d; +#endif +#endif +#ifdef REFLECTIONMAP_SKYBOX +varying vPositionUVW: vec3f; +#else +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vDirectionW: vec3f; +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[Cw]||(E.IncludesShadersStoreWGSL[Cw]=k8)});var bw,W8,vf=C(()=>{w();bw="pbrBRDFFunctions",W8=`#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 +#define BRDF_DIFFUSE_MODEL_LEGACY 3 +#define DIELECTRIC_SPECULAR_MODEL_GLTF 0 +#define DIELECTRIC_SPECULAR_MODEL_OPENPBR 1 +#define CONDUCTOR_SPECULAR_MODEL_GLTF 0 +#define CONDUCTOR_SPECULAR_MODEL_OPENPBR 1 +#if !defined(PBR_VERTEX_SHADER) && !defined(OPENPBR_VERTEX_SHADER) +#ifdef MS_BRDF_ENERGY_CONSERVATION +fn getEnergyConservationFactor(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);} +#endif +#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR +const F82_COS_THETA_MAX: f32 =0.142857143;const F82_ONE_MINUS_CTM_POW5: f32 =0.462664366;const F82_ONE_MINUS_CTM_POW6: f32 =0.396569457;const F82_B_DENOMINATOR_RECIP: f32 =17.6512785;const BRDF_Z_SCALE: f32 =16.0;fn getF82Specular(NdotV: f32,F0: vec3f,edgeTint: vec3f,roughness: f32)->vec3f {let white_minus_F0: vec3f=vec3f(1.0f)-F0;let b_numerator: vec3f=(F0+white_minus_F0*F82_ONE_MINUS_CTM_POW5)*(vec3f(1.0)-edgeTint);let b: vec3f=b_numerator*F82_B_DENOMINATOR_RECIP;let cos_theta: f32=max(roughness,NdotV);let one_minus_cos_theta: f32=1.0-cos_theta;let offset_from_F0: vec3f=(white_minus_F0-b*cos_theta*one_minus_cos_theta)*pow(one_minus_cos_theta,5.0f);return clamp(F0+offset_from_F0,vec3f(0.0f),vec3f(1.0f));} +fn getF82B(F0: vec3f,edgeTint: vec3f)->vec3f {return (F0+(vec3f(1.0)-F0)*F82_ONE_MINUS_CTM_POW5)*(vec3f(1.0)-edgeTint)*F82_B_DENOMINATOR_RECIP;} +fn getF82DirectionalAlbedo(F0: vec3f,F90: vec3f,b: vec3f,environmentBrdf: vec3f)->vec3f {return (F90-F0)*environmentBrdf.x+F0*environmentBrdf.y-b*environmentBrdf.z;} +fn getF82AverageFresnel(F0: vec3f,b: vec3f)->vec3f {return F0+(vec3f(1.0)-F0)/21.0-b/126.0;} +#endif +#ifdef FUZZENVIRONMENTBRDF +fn getFuzzBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {let UV: vec2f=vec2f(perceptualRoughness,NdotV);var brdfLookup: vec4f=textureSample(environmentFuzzBrdfSampler,environmentFuzzBrdfSamplerSampler,UV);const RiRange: vec2f=vec2f(0.0f,0.75f);const ARange: vec2f=vec2f(0.005f,0.88f);const BRange: vec2f=vec2f(-0.18f,0.002f);brdfLookup.r=mix(ARange.x, ARange.y, brdfLookup.r);brdfLookup.g=mix(BRange.x, BRange.y, brdfLookup.g);brdfLookup.b=mix(RiRange.x,RiRange.y,brdfLookup.b);return brdfLookup.rgb;} +#endif +#ifdef ENVIRONMENTBRDF +fn getBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {var UV: vec2f= vec2f(NdotV,perceptualRoughness);var brdfLookup: vec4f= textureSample(environmentBrdfSampler,environmentBrdfSamplerSampler,UV); +#ifdef ENVIRONMENTBRDF_RGBD +brdfLookup=vec4f(fromRGBD(brdfLookup.rgba),brdfLookup.a); +#endif +return brdfLookup.rgb;} +fn getReflectanceFromBRDFWithEnvLookup(specularEnvironmentR0: vec3f,specularEnvironmentR90: vec3f,environmentBrdf: vec3f)->vec3f { +#ifdef BRDF_V_HEIGHT_CORRELATED +var reflectance: vec3f=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y; +#else +var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y; +#endif +return reflectance;} +fn getReflectanceFromBRDFLookup(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f { +#ifdef BRDF_V_HEIGHT_CORRELATED +var reflectance: vec3f=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0); +#else +var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y; +#endif +return reflectance;} +#endif +/* NOT USED +#if defined(SHEEN) && defined(SHEEN_SOFTER) +fn getBRDFLookupCharlieSheen(NdotV: f32,perceptualRoughness: f32)->f32 +{var c: f32=1.0-NdotV;var c3: f32=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));} +#endif +*/ +#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL) +fn getReflectanceFromAnalyticalBRDFLookup_Jones(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f +{var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));} +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) +/** +* The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture. +* The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table +*/ +fn getSheenReflectanceFromBRDFLookup(reflectance0: vec3f,environmentBrdf: vec3f)->vec3f {var sheenEnvironmentReflectance: vec3f=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;} +#endif +fn fresnelSchlickGGXVec3(VdotH: f32,reflectance0: vec3f,reflectance90: vec3f)->vec3f +{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);} +fn fresnelSchlickGGX(VdotH: f32,reflectance0: f32,reflectance90: f32)->f32 +{return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);} +#ifdef CLEARCOAT +fn getR0RemappedForClearCoat(f0: vec3f)->vec3f { +#ifdef CLEARCOAT_DEFAULTIOR +#ifdef MOBILE +return saturateVec3(f0*(f0*0.526868+0.529324)-0.0482256); +#else +return saturateVec3(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998); +#endif +#else +var s: vec3f=sqrt(f0);var t: vec3f=(uniforms.vClearCoatRefractionParams.z+uniforms.vClearCoatRefractionParams.w*s)/(uniforms.vClearCoatRefractionParams.w+uniforms.vClearCoatRefractionParams.z*s);return squareVec3(t); +#endif +} +#endif +#ifdef IRIDESCENCE +const XYZ_TO_REC709: mat3x3f= mat3x3f( +3.2404542,-0.9692660, 0.0556434, +-1.5371385, 1.8760108,-0.2040259, +-0.4985314, 0.0415560, 1.0572252 +);fn getIORTfromAirToSurfaceR0(f0: vec3f)->vec3f {var sqrtF0: vec3f=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);} +fn getR0fromIORsVec3(iorT: vec3f,iorI: f32)->vec3f {return squareVec3((iorT- vec3f(iorI))/(iorT+ vec3f(iorI)));} +fn getR0fromIORs(iorT: f32,iorI: f32)->f32 {return square((iorT-iorI)/(iorT+iorI));} +fn evalSensitivity(opd: f32,shift: vec3f)->vec3f {var phase: f32=2.0*PI*opd*1.0e-9;const val: vec3f= vec3f(5.4856e-13,4.4201e-13,5.2481e-13);const pos: vec3f= vec3f(1.6810e+06,1.7953e+06,2.2084e+06);const vr: vec3f= vec3f(4.3278e+09,9.3046e+09,6.6121e+09);var xyz: vec3f=val*sqrt(2.0*PI*vr)*cos(pos*phase+shift)*exp(-square(phase)*vr);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;var srgb: vec3f=XYZ_TO_REC709*xyz;return srgb;} +fn evalIridescence(outsideIOR: f32,eta2: f32,cosTheta1: f32,thinFilmThickness: f32,baseF0: vec3f)->vec3f {var I: vec3f= vec3f(1.0);var iridescenceIOR: f32=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));var sinTheta2Sq: f32=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));var cosTheta2Sq: f32=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;} +var cosTheta2: f32=sqrt(cosTheta2Sq);var R0: f32=getR0fromIORs(iridescenceIOR,outsideIOR);var R12: f32=fresnelSchlickGGX(cosTheta1,R0,1.);var R21: f32=R12;var T121: f32=1.0-R12;var phi12: f32=0.0;if (iridescenceIORf32 +{var a2: f32=alphaG*alphaG;var d: f32=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);} +#ifdef SHEEN +fn normalDistributionFunction_CharlieSheen(NdotH: f32,alphaG: f32)->f32 +{var invR: f32=1./alphaG;var cos2h: f32=NdotH*NdotH;var sin2h: f32=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);} +#endif +#ifdef ANISOTROPIC +fn normalDistributionFunction_BurleyGGX_Anisotropic(NdotH: f32,TdotH: f32,BdotH: f32,alphaTB: vec2f)->f32 {var a2: f32=alphaTB.x*alphaTB.y;var v: vec3f= vec3f(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);var v2: f32=dot(v,v);var w2: f32=a2/v2;return a2*w2*w2*RECIPROCAL_PI;} +#endif +#ifdef BRDF_V_HEIGHT_CORRELATED +fn smithVisibility_GGXCorrelated(NdotL: f32,NdotV: f32,alphaG: f32)->f32 { +#ifdef MOBILE +var GGXV: f32=NdotL*(NdotV*(1.0-alphaG)+alphaG);var GGXL: f32=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL); +#else +var a2: f32=alphaG*alphaG;var GGXV: f32=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);var GGXL: f32=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL); +#endif +} +#else +fn smithVisibilityG1_TrowbridgeReitzGGXFast(dot: f32,alphaG: f32)->f32 +{ +#ifdef MOBILE +return 1.0/(dot+alphaG+(1.0-alphaG)*dot )); +#else +var alphaSquared: f32=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot)); +#endif +} +fn smithVisibility_TrowbridgeReitzGGXFast(NdotL: f32,NdotV: f32,alphaG: f32)->f32 +{var visibility: f32=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;} +#endif +#ifdef ANISOTROPIC +fn smithVisibility_GGXCorrelated_Anisotropic(NdotL: f32,NdotV: f32,TdotV: f32,BdotV: f32,TdotL: f32,BdotL: f32,alphaTB: vec2f)->f32 {var lambdaV: f32=NdotL*length( vec3f(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));var lambdaL: f32=NdotV*length( vec3f(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));var v: f32=0.5/(lambdaV+lambdaL);return v;} +#endif +#ifdef CLEARCOAT +fn visibility_Kelemen(VdotH: f32)->f32 {return 0.25/(VdotH*VdotH); } +#endif +#ifdef SHEEN +fn visibility_Ashikhmin(NdotL: f32,NdotV: f32)->f32 +{return 1./(4.*(NdotL+NdotV-NdotL*NdotV));} +/* NOT USED +#ifdef SHEEN_SOFTER +fn l(x: f32,alphaG: f32)->f32 +{var oneMinusAlphaSq: f32=(1.0-alphaG)*(1.0-alphaG);var a: f32=mix(21.5473,25.3245,oneMinusAlphaSq);var b: f32=mix(3.82987,3.32435,oneMinusAlphaSq);var c: f32=mix(0.19823,0.16801,oneMinusAlphaSq);var d: f32=mix(-1.97760,-1.27393,oneMinusAlphaSq);var e: f32=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;} +fn lambdaSheen(cosTheta: f32,alphaG: f32)->f32 +{return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));} +fn visibility_CharlieSheen(NdotL: f32,NdotV: f32,alphaG: f32)->f32 +{var G: f32=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);} +#endif +*/ +#endif +const constant1_FON: f32=0.5f-2.0f/(3.0f*PI);const constant2_FON: f32=2.0f/3.0f-28.0f/(15.0f*PI);fn E_FON_approx(mu: f32,roughness: f32)->f32 +{var sigma: f32=roughness; +var mucomp: f32=1.0f-mu;var mucomp2: f32=mucomp*mucomp;const Gcoeffs: mat2x2f=mat2x2f(0.0571085289f,-0.332181442f, +0.491881867f,0.0714429953f);var GoverPi: f32=dot(Gcoeffs*vec2f(mucomp,mucomp2),vec2f(1.0f,mucomp2));return (1.0f+sigma*GoverPi)/(1.0f+constant1_FON*sigma);} +fn diffuseBRDF_EON(albedo: vec3f,roughness: f32,NdotL: f32,NdotV: f32,LdotV: f32)->vec3f +{var rho: vec3f=albedo;var sigma: f32=roughness; +var mu_i: f32=NdotL; +var mu_o: f32=NdotV; +var s: f32=LdotV-mu_i*mu_o; +var sovertF: f32=select(s,s/max(mu_i,mu_o),s>0.0f); +var AF: f32=1.0f/(1.0f+constant1_FON*sigma); +var f_ss: vec3f=(rho*RECIPROCAL_PI)*AF*(1.0f+sigma*sovertF); +var EFo: f32=E_FON_approx(mu_o,sigma); +var EFi: f32=E_FON_approx(mu_i,sigma); +var avgEF: f32=AF*(1.0f+constant2_FON*sigma); +var rho_ms: vec3f=(rho*rho)*avgEF/(vec3f(1.0f)-rho*(1.0f-avgEF));const eps: f32=1.0e-7f;var f_ms: vec3f=(rho_ms*RECIPROCAL_PI)*max(eps,1.0f-EFo) +* max(eps,1.0f-EFi) +/ max(eps,1.0f-avgEF);return (f_ss+f_ms);} +fn diffuseBRDF_Burley(NdotL: f32,NdotV: f32,VdotH: f32,roughness: f32)->f32 {var diffuseFresnelNV: f32=pow5(saturateEps(1.0-NdotL));var diffuseFresnelNL: f32=pow5(saturateEps(1.0-NdotV));var diffuseFresnel90: f32=0.5+2.0*VdotH*VdotH*roughness;var fresnel: f32 = +(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) * +(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;} +#ifdef SS_TRANSLUCENCY +fn transmittanceBRDF_Burley(tintColor: vec3f,diffusionDistance: vec3f,thickness: f32)->vec3f {var S: vec3f=1./maxEpsVec3(diffusionDistance);var temp: vec3f=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);} +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[bw]||(E.IncludesShadersStoreWGSL[bw]=W8)});var Mw,H8,hA=C(()=>{w();Mw="openpbrDielectricReflectance",H8=`struct ReflectanceParams +{F0: f32, +F90: f32, +coloredF0: vec3f, +coloredF90: vec3f,}; +#define pbr_inline +fn dielectricReflectance( +insideIOR: f32,outsideIOR: f32,specularColor: vec3f,specularWeight: f32 +)->ReflectanceParams +{var outParams: ReflectanceParams;let dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0); +#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF +let maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=dielectricF0*maxF0*specularWeight; +#else +outParams.F0=dielectricF0*specularWeight; +#endif +let f90Scale=clamp(2.0f*abs(insideIOR-outsideIOR),0.0f,1.0f);outParams.F90=f90Scale*specularWeight;outParams.coloredF0=vec3f(dielectricF0*specularWeight)*specularColor.rgb; +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +let dielectricColorF90: vec3f=specularColor.rgb*vec3f(f90Scale)*specularWeight; +#else +let dielectricColorF90: vec3f=vec3f(f90Scale)*specularWeight; +#endif +outParams.coloredF90=dielectricColorF90;return outParams;} +`;E.IncludesShadersStoreWGSL[Mw]||(E.IncludesShadersStoreWGSL[Mw]=H8)});var yw,z8,Kp=C(()=>{w();yw="pbrIBLFunctions",z8=`#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 +#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION) +fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);} +#endif +#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION) +fn environmentHorizonOcclusion(view: vec3f,normal: vec3f,geometricNormal: vec3f)->f32 {var reflection: vec3f=reflect(view,normal);var temp: f32=saturate(1.0+1.1*dot(reflection,geometricNormal));return temp*temp;} +#endif +#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA) +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[yw]||(E.IncludesShadersStoreWGSL[yw]=z8)});var Dw,X8,dA=C(()=>{w();Dw="openpbrGeometryInfo",X8=`struct geometryInfoOutParams +{NdotV: f32, +NdotVUnclamped: f32, +environmentBrdf: vec3f, +horizonOcclusion: f32};struct geometryInfoAnisoOutParams +{NdotV: f32, +NdotVUnclamped: f32, +environmentBrdf: vec3f, +horizonOcclusion: f32, +anisotropy: f32, +anisotropicTangent: vec3f, +anisotropicBitangent: vec3f, +TBN: mat3x3};fn geometryInfo( +normalW: vec3f,viewDirectionW: vec3f,roughness: f32,geometricNormalW: vec3f +)->geometryInfoOutParams +{var outParams: geometryInfoOutParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped); +#if defined(ENVIRONMENTBRDF) +outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness); +#else +outParams.environmentBrdf=vec3f(0.0); +#endif +outParams.horizonOcclusion=1.0f; +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef HORIZONOCCLUSION +#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) +#ifdef REFLECTIONMAP_3D +outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); +#endif +#endif +#endif +#endif +return outParams;} +fn geometryInfoAniso( +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[Dw]||(E.IncludesShadersStoreWGSL[Dw]=X8)});var Pw,Y8,uA=C(()=>{w();Pw="openpbrIblFunctions",Y8=`#ifdef REFLECTION +fn sampleIrradiance( +surfaceNormal: vec3f +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradianceSH: vec3f +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,iblMatrix: mat4x4f +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,irradianceSampler: texture_cube +,irradianceSamplerSampler: sampler +#else +,irradianceSampler: texture_2d +,irradianceSamplerSampler: sampler +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,reflectionDominantDirection: vec3f +#endif +#endif +#ifdef REALTIME_FILTERING +,reflectionFilteringInfo: vec2f +#ifdef IBL_CDF_FILTERING +,icdfSampler: texture_2d +,icdfSamplerSampler: sampler +#endif +#endif +,reflectionInfos: vec2f +,viewDirectionW: vec3f +,diffuseRoughness: f32 +,surfaceAlbedo: vec3f +)->vec3f {var environmentIrradiance=vec3f(0.,0.,0.); +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +var irradianceVector=(iblMatrix*vec4f(surfaceNormal,0.0f)).xyz;var irradianceView=(iblMatrix*vec4f(viewDirectionW,0.0f)).xyz; +#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +{let NdotV=max(dot(surfaceNormal,viewDirectionW),0.0f);irradianceVector=mix(irradianceVector,irradianceView,(0.5f*(1.0f-NdotV))*diffuseRoughness);} +#endif +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0;irradianceView.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0;irradianceView.y*=-1.0; +#endif +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +environmentIrradiance=vEnvironmentIrradianceSH; +#else +#if defined(REALTIME_FILTERING) +environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,reflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +); +#else +environmentIrradiance=computeEnvironmentIrradiance(irradianceVector); +#endif +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector); +#else +let environmentIrradianceFromTexture: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords); +#endif +environmentIrradiance=environmentIrradianceFromTexture.rgb; +#ifdef RGBDREFLECTION +environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture); +#endif +#ifdef GAMMAREFLECTION +environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb); +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +let Ls: vec3f=normalize(reflectionDominantDirection);let NoL: f32=dot(irradianceVector,Ls);let NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm=vec3f(1.0f); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +let LoV: f32=dot (Ls,irradianceView);let mag: f32=length(reflectionDominantDirection)*2.0f;let clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1f),vec3f(1.0f));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0f),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0f,1.0f))); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +let H: vec3f=(irradianceView+Ls)*0.5f;let VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm; +#endif +#endif +environmentIrradiance*=reflectionInfos.x;return environmentIrradiance;} +#ifdef REFLECTIONMAP_3D +fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec3f +#else +fn createReflectionCoords(vPositionW: vec3f,normalW: vec3f)->vec2f +#endif +{var reflectionVector: vec3f=computeReflectionCoords(vec4f(vPositionW,1.0f),normalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +var reflectionCoords: vec3f=reflectionVector; +#else +var reflectionCoords: vec2f=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0f-reflectionCoords.y; +#endif +return reflectionCoords;} +fn sampleRadiance( +alphaG: f32 +,reflectionMicrosurfaceInfos: vec3f +,reflectionInfos: vec2f +,geoInfo: geometryInfoOutParams +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +,reflectionCoords: vec3f +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +,reflectionCoords: vec2f +#endif +#ifdef REALTIME_FILTERING +,reflectionFilteringInfo: vec2f +#endif +)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f); +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness); +#else +var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,alphaG); +#endif +reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z; +#ifdef REALTIME_FILTERING +environmentRadiance=vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionFilteringInfo),1.0f); +#else +environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD); +#endif +#ifdef RGBDREFLECTION +environmentRadiance.rgb=fromRGBD(environmentRadiance); +#endif +#ifdef GAMMAREFLECTION +environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb); +#endif +environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.x,environmentRadiance.a);return environmentRadiance.rgb;} +#if defined(ANISOTROPIC) +fn sampleRadianceAnisotropic( +alphaG: f32 +,reflectionMicrosurfaceInfos: vec3f +,reflectionInfos: vec2f +,geoInfo: geometryInfoAnisoOutParams +,normalW: vec3f +,viewDirectionW: vec3f +,positionW: vec3f +,noise: vec3f +,isRefraction: bool +,ior: f32 +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +#endif +#ifdef REALTIME_FILTERING +,reflectionFilteringInfo: vec2f +#endif +)->vec3f {var environmentRadiance: vec4f=vec4f(0.f,0.f,0.f,0.f);let alphaT=alphaG*sqrt(2.0f/(1.0f+(1.0f-geoInfo.anisotropy)*(1.0f-geoInfo.anisotropy)));let alphaB=(1.0f-geoInfo.anisotropy)*alphaT;let modifiedAlphaG=alphaB; +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG,geoInfo.NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +var reflectionLOD: f32=getLinearLodFromRoughness(reflectionMicrosurfaceInfos.x,roughness); +#else +var reflectionLOD: f32=getLodFromAlphaG(reflectionMicrosurfaceInfos.x,modifiedAlphaG); +#endif +reflectionLOD=reflectionLOD*reflectionMicrosurfaceInfos.y+reflectionMicrosurfaceInfos.z; +#ifdef REALTIME_FILTERING +var view=(uniforms.reflectionMatrix*vec4f(viewDirectionW,0.0f)).xyz;var tangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicTangent,0.0f)).xyz;var bitangent=(uniforms.reflectionMatrix*vec4f(geoInfo.anisotropicBitangent,0.0f)).xyz;var normal=(uniforms.reflectionMatrix*vec4f(normalW,0.0f)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +view.z*=-1.0f;tangent.z*=-1.0f;bitangent.z*=-1.0f;normal.z*=-1.0f; +#endif +environmentRadiance = +vec4f(radianceAnisotropic(alphaT,alphaB,reflectionSampler,reflectionSamplerSampler, +view,tangent, +bitangent,normal, +reflectionFilteringInfo,noise.xy,isRefraction,ior), +1.0f); +#else +const samples: i32=16;var radianceSample=vec4f(0.0);var accumulatedRadiance=vec3f(0.0);var reflectionCoords=vec3f(0.0);var sample_weight=0.0f;var total_weight=0.0f;let step=1.0f/f32(max(samples-1,1));for (var i: i32=0; i0.0) {let blend: f32=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;} +if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);} +reflectionCoords=(uniforms.reflectionMatrix*vec4f(reflectionCoords,0.f)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionCoords.z*=-1.0f; +#endif +radianceSample=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD); +#ifdef RGBDREFLECTION +accumulatedRadiance+=vec3f(sample_weight)*fromRGBD(radianceSample); +#elif defined(GAMMAREFLECTION) +accumulatedRadiance+=vec3f(sample_weight)*toLinearSpace(radianceSample.rgb); +#else +accumulatedRadiance+=vec3f(sample_weight)*radianceSample.rgb; +#endif +total_weight+=sample_weight;} +environmentRadiance=vec4f(accumulatedRadiance/vec3f(total_weight),1.0f); +#endif +environmentRadiance=vec4f(environmentRadiance.rgb*reflectionInfos.xxx,environmentRadiance.a);return environmentRadiance.rgb;} +#endif +#endif +#ifdef ENVIRONMENTBRDF +fn computeDielectricIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->f32 +{let dielectricIblFresnel: f32=getReflectanceFromBRDFWithEnvLookup(vec3f(reflectance.F0),vec3f(reflectance.F90),environmentBrdf).r;let dielectricECF: f32=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);} +fn computeConductorIblFresnel(reflectance: ReflectanceParams,environmentBrdf: vec3f)->vec3f +{ +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +let openPBRBrdf: vec3f=vec3f(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);let b: vec3f =getF82B(reflectance.coloredF0,reflectance.coloredF90);let E_F82: vec3f=getF82DirectionalAlbedo(reflectance.coloredF0,vec3f(1.0),b,openPBRBrdf);let F_avg: vec3f=getF82AverageFresnel(reflectance.coloredF0,b);let ECF: vec3f =vec3f(1.0)+F_avg*(vec3f(1.0)/openPBRBrdf.y-vec3f(1.0));return clamp(E_F82*ECF,vec3f(0.0),vec3f(1.0)); +#else +return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf); +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[Pw]||(E.IncludesShadersStoreWGSL[Pw]=Y8)});var Lw,K8,mA=C(()=>{w();Lw="openpbrSubsurfaceLayerData",K8=`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 +#ifdef SUBSURFACE_COLOR +let subsurfaceColorFromTexture: vec4f=textureSample(subsurfaceColorSampler,subsurfaceColorSamplerSampler,fragmentInputs.vSubsurfaceColorUV+uvOffset); +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +let subsurfaceRadiusScaleFromTexture: vec4f=textureSample(subsurfaceRadiusScaleSampler,subsurfaceRadiusScaleSamplerSampler,fragmentInputs.vSubsurfaceRadiusScaleUV+uvOffset); +#endif +#ifdef SUBSURFACE_WEIGHT +subsurface_weight*=subsurfaceWeightFromTexture.r; +#endif +#ifdef SUBSURFACE_COLOR +#ifdef SUBSURFACE_COLOR_GAMMA +subsurface_color*=toLinearSpaceVec3(subsurfaceColorFromTexture.rgb); +#else +subsurface_color*=subsurfaceColorFromTexture.rgb; +#endif +subsurface_color*=uniforms.vSubsurfaceColorInfos.y; +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb; +#endif +`;E.IncludesShadersStoreWGSL[Lw]||(E.IncludesShadersStoreWGSL[Lw]=K8)});var Ow,j8,pA=C(()=>{w();Ow="openpbrTransmissionLayerData",j8=`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 +#ifdef TRANSMISSION_COLOR +let transmissionColorFromTexture: vec4f=textureSample(transmissionColorSampler,transmissionColorSamplerSampler,fragmentInputs.vTransmissionColorUV+uvOffset); +#endif +#ifdef TRANSMISSION_DEPTH +let transmissionDepthFromTexture: vec4f=textureSample(transmissionDepthSampler,transmissionDepthSamplerSampler,fragmentInputs.vTransmissionDepthUV+uvOffset); +#endif +#ifdef TRANSMISSION_SCATTER +let transmissionScatterFromTexture: vec4f=textureSample(transmissionScatterSampler,transmissionScatterSamplerSampler,fragmentInputs.vTransmissionScatterUV+uvOffset); +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +let transmissionDispersionScaleFromTexture: vec4f=textureSample(transmissionDispersionScaleSampler,transmissionDispersionScaleSamplerSampler,fragmentInputs.vTransmissionDispersionScaleUV+uvOffset); +#endif +#ifdef TRANSMISSION_WEIGHT +transmission_weight*=transmissionWeightFromTexture.r; +#endif +#ifdef TRANSMISSION_COLOR +#ifdef TRANSMISSION_COLOR_GAMMA +transmission_color*=toLinearSpace(transmissionColorFromTexture.rgb); +#else +transmission_color*=transmissionColorFromTexture.rgb; +#endif +transmission_color*=uniforms.vTransmissionColorInfos.y; +#endif +#ifdef TRANSMISSION_DEPTH +transmission_depth*=transmissionDepthFromTexture.r; +#endif +#ifdef TRANSMISSION_SCATTER +transmission_scatter*=transmissionScatterFromTexture.rgb; +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r; +#endif +`;E.IncludesShadersStoreWGSL[Ow]||(E.IncludesShadersStoreWGSL[Ow]=j8)});var Fw={};Ie(Fw,{geometryPixelShaderWGSL:()=>Z8});var _A,Nw,Z8,ww=C(()=>{w();pn();Gm();km();Lr();Yp();Tn();vf();hA();Kp();Nh();dA();uA();pl();_n();Wm();mA();pA();_A="geometryPixelShader",Nw=`#ifdef BUMP +varying vWorldView0: vec4f;varying vWorldView1: vec4f;varying vWorldView2: vec4f;varying vWorldView3: vec4f;varying vNormalW: vec3f; +#else +varying vNormalV: vec3f; +#endif +varying vViewPos: vec4f; +#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE) +varying vPositionW: vec3f; +#endif +#if defined(VELOCITY) || defined(VELOCITY_LINEAR) +varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f; +#endif +#ifdef NEED_UV +varying vUV: vec2f; +#endif +#ifdef BUMP +uniform vBumpInfos: vec3f;uniform vTangentSpaceParams: vec2f; +#endif +#if defined(REFLECTIVITY) +#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE) +var reflectivitySamplerSampler: sampler;var reflectivitySampler: texture_2d;varying vReflectivityUV: vec2f; +#else +#ifdef METALLIC_TEXTURE +var metallicSamplerSampler: sampler;var metallicSampler: texture_2d;varying vMetallicUV: vec2f; +#endif +#ifdef ROUGHNESS_TEXTURE +var roughnessSamplerSampler: sampler;var roughnessSampler: texture_2d;varying vRoughnessUV: vec2f; +#endif +#endif +#ifdef ALBEDOTEXTURE +varying vAlbedoUV: vec2f;var albedoSamplerSampler: sampler;var albedoSampler: texture_2d; +#endif +#ifdef REFLECTIVITYCOLOR +uniform reflectivityColor: vec3f; +#endif +#ifdef ALBEDOCOLOR +uniform albedoColor: vec3f; +#endif +#ifdef METALLIC +uniform metallic: f32; +#endif +#if defined(ROUGHNESS) || defined(GLOSSINESS) +uniform glossiness: f32; +#endif +#endif +#if defined(ALPHATEST) && defined(NEED_UV) +var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; +#endif +#include +#include +#include +#include +#ifdef IRRADIANCE +#include +#ifdef REFLECTION +#ifdef USEIRRADIANCEMAP +#include +uniform reflectionMatrix: mat4x4f;uniform vReflectionInfos: vec2f;uniform vReflectionDominantDirection: vec3f; +#include +#include +#include +#include +#include +#include +#elif defined(USESPHERICALFROMREFLECTIONMAP) +varying vEnvironmentIrradiance: vec3f; +#endif +#ifdef IBL_SHADOW_TEXTURE +var iblShadowSampler: texture_2d;var iblShadowSamplerSampler: sampler;uniform shadowTextureSize: vec2f; +#endif +#ifdef IRRADIANCE_SCATTER_MASK +uniform vSubsurfaceWeight: f32; +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight) +uniform vSubsurfaceScatterAnisotropy: f32;uniform vTransmissionWeight: f32; +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight) +uniform vTransmissionScatterAnisotropy: f32; +#endif +#endif +#endif +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#include +#ifdef ALPHATEST +if (textureSample(diffuseSampler,diffuseSamplerSampler,input.vUV).a<0.4) {discard;} +#endif +var normalOutput: vec3f; +#ifdef BUMP +var normalW: vec3f=normalize(input.vNormalW); +#include +#ifdef NORMAL_WORLDSPACE +normalOutput=normalW; +#else +normalOutput=normalize( (mat4x4f(input.vWorldView0,input.vWorldView1,input.vWorldView2,input.vWorldView3)* vec4f(normalW,0.0)).xyz); +#endif +#elif defined(HAS_NORMAL_ATTRIBUTE) +normalOutput=normalize(input.vNormalV); +#elif defined(POSITION) +normalOutput=normalize(-cross(dpdx(input.vPositionW),dpdy(input.vPositionW))); +#endif +#ifdef ENCODE_NORMAL +normalOutput=normalOutput*0.5+0.5; +#endif +var fragData: array,SCENE_MRT_COUNT>; +#ifdef DEPTH +fragData[DEPTH_INDEX]=vec4f(input.vViewPos.z/input.vViewPos.w,0.0,0.0,1.0); +#endif +#ifdef NORMAL +fragData[NORMAL_INDEX]=vec4f(normalOutput,1.0); +#endif +#ifdef SCREENSPACE_DEPTH +fragData[SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,1.0); +#endif +#ifdef POSITION +fragData[POSITION_INDEX]= vec4f(input.vPositionW,1.0); +#endif +#ifdef VELOCITY +var a: vec2f=(input.vCurrentPosition.xy/input.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(input.vPreviousPosition.xy/input.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[VELOCITY_INDEX]= vec4f(velocity,0.0,1.0); +#endif +#ifdef VELOCITY_LINEAR +var velocity : vec2f=vec2f(0.5)*((input.vPreviousPosition.xy / +input.vPreviousPosition.w) - +(input.vCurrentPosition.xy / +input.vCurrentPosition.w));fragData[VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,1.0); +#endif +#ifdef REFLECTIVITY +var reflectivity: vec4f= vec4f(0.0,0.0,0.0,1.0); +#ifdef METALLICWORKFLOW +var metal: f32=1.0;var roughness: f32=1.0; +#ifdef ORMTEXTURE +metal*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).b;roughness*=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV).g; +#else +#ifdef METALLIC_TEXTURE +metal*=textureSample(metallicSampler,metallicSamplerSampler,input.vMetallicUV).r; +#endif +#ifdef ROUGHNESS_TEXTURE +roughness*=textureSample(roughnessSampler,roughnessSamplerSampler,input.vRoughnessUV).r; +#endif +#endif +#ifdef METALLIC +metal*=uniforms.metallic; +#endif +#ifdef ROUGHNESS +roughness*=(1.0-uniforms.glossiness); +#endif +reflectivity=vec4f(reflectivity.rgb,reflectivity.a-roughness);var color: vec3f= vec3f(1.0); +#ifdef ALBEDOTEXTURE +color=textureSample(albedoSampler,albedoSamplerSampler,input.vAlbedoUV).rgb; +#ifdef GAMMAALBEDO +color=toLinearSpaceVec4(color); +#endif +#endif +#ifdef ALBEDOCOLOR +color*=uniforms.albedoColor.xyz; +#endif +reflectivity=vec4f(mix( vec3f(0.04),color,metal),reflectivity.a); +#else +#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE) +reflectivity=textureSample(reflectivitySampler,reflectivitySamplerSampler,input.vReflectivityUV); +#ifdef GAMMAREFLECTIVITYTEXTURE +reflectivity=vec4f(toLinearSpaceVec3(reflectivity.rgb),reflectivity.a); +#endif +#else +#ifdef REFLECTIVITYCOLOR +reflectivity=vec4f(toLinearSpaceVec3(uniforms.reflectivityColor.xyz),1.0); +#endif +#endif +#ifdef GLOSSINESSS +reflectivity=vec4f(reflectivity.rgb,reflectivity.a*glossiness); +#endif +#endif +fragData[REFLECTIVITY_INDEX]=reflectivity; +#endif +#ifdef IRRADIANCE +var irradiance: vec3f=vec3f(0.0);var irradiance_alpha: f32=1.0; +#ifdef REFLECTION +#ifdef IRRADIANCE_SCATTER_MASK +var vSubsurfaceColor: vec3f=vec3f(1.0);var vSubsurfaceRadius: f32=0.0;var vSubsurfaceRadiusScale: vec3f=vec3f(1.0); +#include(uniforms.vSubsurfaceColor,vSubsurfaceColor,uniforms.vSubsurfaceRadius,vSubsurfaceRadius,uniforms.vSubsurfaceRadiusScale,vSubsurfaceRadiusScale) +var vTransmissionDepth: f32=1.0;var vTransmissionColor: vec3f=vec3f(1.0);var vTransmissionScatter: vec3f=vec3f(0.0);var vTransmissionDispersionScale: f32=0.0;var vTransmissionDispersionAbbeNumber: f32=0.0; +#include(uniforms.vTransmissionDispersionScale,vTransmissionDispersionScale,uniforms.vTransmissionDispersionAbbeNumber,vTransmissionDispersionAbbeNumber,uniforms.vTransmissionColor,vTransmissionColor,uniforms.vTransmissionDepth,vTransmissionDepth,uniforms.vTransmissionScatter\\.,vTransmissionScatter.) +#endif +#ifdef IBL_SHADOW_TEXTURE +#ifdef COLORED_IBL_SHADOWS +let iblShadowValue: vec3f=textureSample(iblShadowSampler,iblShadowSamplerSampler,fragmentInputs.position.xy/uniforms.shadowTextureSize).rgb; +#else +let iblShadowValue: vec3f=vec3f(textureSample(iblShadowSampler,iblShadowSamplerSampler,fragmentInputs.position.xy/uniforms.shadowTextureSize).r); +#endif +#endif +#if defined(USEIRRADIANCEMAP) +#ifdef IRRADIANCE_SCATTER_MASK +let bendAmount: f32=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);let mixedBendAmount: f32=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);let viewVector: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);let bentNormal: vec3f=mix(normalOutput,viewVector,mixedBendAmount*dot(normalOutput,viewVector)); +#else +let bentNormal: vec3f=normalOutput; +#endif +irradiance=sampleIrradiance( +bentNormal +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,input.vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,uniforms.reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +,irradianceSamplerSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,uniforms.vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +#endif +,uniforms.vReflectionInfos +,input.vViewPos.xyz +,1.0 +,vec3f(1.0) +); +#elif defined(USESPHERICALFROMREFLECTIONMAP) +irradiance=input.vEnvironmentIrradiance; +#endif +#ifdef IBL_SHADOW_TEXTURE +irradiance*=iblShadowValue; +#endif +#ifndef BUMP +let uvOffset: vec2f=vec2f(0.0); +#endif +#ifdef IRRADIANCE_SCATTER_MASK +irradiance_alpha=min(subsurface_weight+transmission_weight,1.0); +#endif +#endif +fragData[IRRADIANCE_INDEX]=vec4f(irradiance,irradiance_alpha); +#endif +#if SCENE_MRT_COUNT>0 +fragmentOutputs.fragData0=fragData[0]; +#endif +#if SCENE_MRT_COUNT>1 +fragmentOutputs.fragData1=fragData[1]; +#endif +#if SCENE_MRT_COUNT>2 +fragmentOutputs.fragData2=fragData[2]; +#endif +#if SCENE_MRT_COUNT>3 +fragmentOutputs.fragData3=fragData[3]; +#endif +#if SCENE_MRT_COUNT>4 +fragmentOutputs.fragData4=fragData[4]; +#endif +#if SCENE_MRT_COUNT>5 +fragmentOutputs.fragData5=fragData[5]; +#endif +#if SCENE_MRT_COUNT>6 +fragmentOutputs.fragData6=fragData[6]; +#endif +#if SCENE_MRT_COUNT>7 +fragmentOutputs.fragData7=fragData[7]; +#endif +} +`;E.ShadersStoreWGSL[_A]||(E.ShadersStoreWGSL[_A]=Nw);Z8={name:_A,shader:Nw}});var Bw,gA,lr,Uw=C(()=>{Ee();It();pi();tw();Je();Ci();Vi();oA();cA();ns();Ps();Ui();$T();Bw=["diffuseSampler","bumpSampler","reflectivitySampler","albedoSampler","morphTargets","boneSampler","transmissionWeightSampler","subsurfaceWeightSampler","iblShadowSampler"],gA=["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"];oo(gA,Bw,!0);Pi(gA);lr=class s{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===s.POSITION_TEXTURE_TYPE?(this._positionIndex=t,this._enablePosition=!0):e===s.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=t,this._enableVelocity=!0):e===s.VELOCITY_LINEAR_TEXTURE_TYPE?(this._velocityLinearIndex=t,this._enableVelocityLinear=!0):e===s.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=t,this._enableReflectivity=!0):e===s.DEPTH_TEXTURE_TYPE?(this._depthIndex=t,this._enableDepth=!0):e===s.NORMAL_TEXTURE_TYPE?(this._normalIndex=t,this._enableNormal=!0):e===s.SCREENSPACE_DEPTH_TEXTURE_TYPE?(this._screenspaceDepthIndex=t,this._enableScreenspaceDepth=!0):e===s.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 s.POSITION_TEXTURE_TYPE:return this._positionIndex;case s.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;case s.VELOCITY_LINEAR_TEXTURE_TYPE:return this._velocityLinearIndex;case s.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;case s.DEPTH_TEXTURE_TYPE:return this._depthIndex;case s.NORMAL_TEXTURE_TYPE:return this._normalIndex;case s.SCREENSPACE_DEPTH_TEXTURE_TYPE:return this._screenspaceDepthIndex;case s.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 Me(0,0,0,0),this._clearDepthColor=new Me(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(),s._SceneComponentInitialization(this._scene),this._createRenderTargets()}async _initShaderSourceAsync(){this._scene.getEngine().isWebGPU&&!s.ForceGLSL?(this._shaderLanguage=1,await Promise.all([Promise.resolve().then(()=>(Iw(),xw)),Promise.resolve().then(()=>(ww(),Fw))])):await Promise.all([Promise.resolve().then(()=>(cA(),Tw)),Promise.resolve().then(()=>(oA(),mw))]),this._shadersLoaded=!0}isReady(e,t){if(!this._shadersLoaded)return!1;let i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;let r=[],n=[y.PositionKind],a=e.getMesh();a.isVerticesDataPresent(y.NormalKind)&&(r.push("#define HAS_NORMAL_ATTRIBUTE"),n.push(y.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)&&re.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 v=i;r.push("#define METALLIC"),r.push("#define ROUGHNESS"),v._useRoughnessFromMetallicTextureGreen&&v.baseMetalnessTexture?(r.push("#define ORMTEXTURE"),r.push(`#define REFLECTIVITY_UV${v.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):v.baseMetalnessTexture?(r.push("#define METALLIC_TEXTURE"),r.push(`#define METALLIC_UV${v.baseMetalnessTexture.coordinatesIndex+1}`),_=!0):v.specularRoughnessTexture&&(r.push("#define ROUGHNESS_TEXTURE"),r.push(`#define ROUGHNESS_UV${v.specularRoughnessTexture.coordinatesIndex+1}`),_=!0),v.baseColorTexture&&(r.push("#define ALBEDOTEXTURE"),r.push(`#define ALBEDO_UV${v.baseColorTexture.coordinatesIndex+1}`),v.baseColorTexture.gammaSpace&&r.push("#define GAMMAALBEDO"),_=!0),v.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(y.UVKind)&&(n.push(y.UVKind),r.push("#define UV1"),l=!0),a.isVerticesDataPresent(y.UV2Kind)&&(n.push(y.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={},v=!1,I=0;(i.getClassName()==="OpenPBRMaterial"||i.getClassName()==="StandardMaterial"||i.getClassName()==="PBRMetallicRoughnessMaterial"||i.getClassName()==="PBRSpecularGlossinessMaterial"||i.getClassName()==="PBRMaterial")&&(v=!!i.realtimeFiltering,I=i.realtimeFilteringQuality||0),so(_,_.environmentTexture,g,v,I,!0);for(let T in g)g[T]&&r.push("#define "+T);g.USEIRRADIANCEMAP||r.push("#define SPHERICAL_HARMONICS");let x=_.postProcessRenderPipelineManager.supportedPipelines.find(T=>T.getClassName()==="IBLShadowsRenderPipeline");if(x){let T=x;T._getAccumulatedTexture()&&(r.push("#define IBL_SHADOW_TEXTURE"),T.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?(n.push(y.MatricesIndicesKind),n.push(y.MatricesWeightsKind),a.numBoneInfluencers>4&&(n.push(y.MatricesIndicesExtraKind),n.push(y.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 h=a.morphTargetManager?fn(a.morphTargetManager,r,n,a,!0,!0,!1,l,c,f):0;t&&(r.push("#define INSTANCES"),Ls(n,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),on(i,this._scene,r);let d=this._scene.getEngine(),u=e._getDrawWrapper(void 0,!0),m=u.defines,p=r.join(` +`);return m!==p&&u.setEffect(d.createEffect("geometry",{attributes:n,uniformsNames:gA,samplers:Bw,defines:p,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:h},shaderLanguage:this.shaderLanguage},d),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[s.DEPTH_TEXTURE_TYPE])),this._enableNormal&&(this._normalIndex=i,i++,e.push("gBuffer_Normal"),t.push(this._textureTypesAndFormats[s.NORMAL_TEXTURE_TYPE])),this._enablePosition&&(this._positionIndex=i,i++,e.push("gBuffer_Position"),t.push(this._textureTypesAndFormats[s.POSITION_TEXTURE_TYPE])),this._enableVelocity&&(this._velocityIndex=i,i++,e.push("gBuffer_Velocity"),t.push(this._textureTypesAndFormats[s.VELOCITY_TEXTURE_TYPE])),this._enableVelocityLinear&&(this._velocityLinearIndex=i,i++,e.push("gBuffer_VelocityLinear"),t.push(this._textureTypesAndFormats[s.VELOCITY_LINEAR_TEXTURE_TYPE])),this._enableReflectivity&&(this._reflectivityIndex=i,i++,e.push("gBuffer_Reflectivity"),t.push(this._textureTypesAndFormats[s.REFLECTIVITY_TEXTURE_TYPE])),this._enableScreenspaceDepth&&(this._screenspaceDepthIndex=i,i++,e.push("gBuffer_ScreenspaceDepth"),t.push(this._textureTypesAndFormats[s.SCREENSPACE_DEPTH_TEXTURE_TYPE])),this._enableIrradiance&&(this._irradianceIndex=i,i++,e.push("gBuffer_Irradiance"),t.push(this._textureTypesAndFormats[s.IRRADIANCE_TEXTURE_TYPE])),[i,e,t]}_createRenderTargets(){var g;let e=this._scene.getEngine(),[t,i,r]=this._assignRenderTargetIndices(),n=0;e._caps.textureFloat&&e._caps.textureFloatLinearFiltering?n=1:e._caps.textureHalfFloat&&e._caps.textureHalfFloatLinearFiltering&&(n=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 v of r)v?(o.push(v.textureType),l.push(v.textureFormat),c.push((g=v.samplingMode)!=null?g:2)):(o.push(n),l.push(5),c.push(2));if(this._normalsAreUnsigned=o[s.NORMAL_TEXTURE_TYPE]===11||o[s.NORMAL_TEXTURE_TYPE]===13,this._multiRenderTarget=new Hp("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],h=[!1],d=[!0];for(let v=1;v{v.bindAttachments(this.useSpecificClearForDepthTexture?m:u),v.clear(this._clearColor,!0,!0,!0),this.useSpecificClearForDepthTexture&&(v.bindAttachments(p),v.clear(this._clearDepthColor,!0,!0,!0)),v.bindAttachments(u)}),this._resizeObserver=e.onResizeObservable.add(()=>{if(this._multiRenderTarget){let v=this._ratioOrDimensions.width!==void 0?this._ratioOrDimensions:{width:e.getRenderWidth()*this._ratioOrDimensions,height:e.getRenderHeight()*this._ratioOrDimensions};this._multiRenderTarget.resize(v)}});let _=v=>{let I=v.getRenderingMesh(),x=v.getEffectiveMesh(),T=this._scene,A=T.getEngine(),R=v.getMaterial();if(!R)return;if(x._internalAbstractMeshDataInfo._isActiveIntermediate=!1,(this._enableVelocity||this._enableVelocityLinear)&&!this._previousTransformationMatrices[x.uniqueId]&&(this._previousTransformationMatrices[x.uniqueId]={world:H.Identity(),viewProjection:T.getTransformMatrix()},I.skeleton)){let F=I.skeleton.getTransformMatrices(I);this._previousBonesTransformationMatrices[I.uniqueId]=this._copyBonesTransformationMatrices(F,new Float32Array(F.length))}let P=I._getInstancesRenderList(v._id,!!v.getReplacementMesh());if(P.mustReturn)return;let D=A.getCaps().instancedArrays&&(P.visibleInstances[v._id]!==null||I.hasThinInstances),M=x.getWorldMatrix();if(this.isReady(v,D)){let F=v._getDrawWrapper();if(!F)return;let N=F.effect;A.enableEffect(F),D||I._bind(v,N,R.fillMode),this._useUbo?(to(N,this._scene.getSceneUniformBuffer()),this._scene.finalizeSceneUbo()):(N.setMatrix("viewProjection",T.getTransformMatrix()),N.setMatrix("view",T.getViewMatrix()),this._scene.bindEyePosition(N,"vEyePosition"));let V;if(!I._instanceDataStorage.isFrozen&&(R.backFaceCulling||R.sideOrientation!==null)){let U=x._getWorldMatrixDeterminant();V=R._getEffectiveOrientation(I),U<0&&(V=V===oe.ClockWiseSideOrientation?oe.CounterClockWiseSideOrientation:oe.ClockWiseSideOrientation)}else V=I._effectiveSideOrientation;if(R._preBind(F,V),R.needAlphaTestingForMesh(x)){let U=R.getAlphaTestTexture();U&&(N.setTexture("diffuseSampler",U),N.setMatrix("diffuseMatrix",U.getTextureMatrix()))}if((R.bumpTexture||R.normalTexture||R.geometryNormalTexture)&&T.getEngine().getCaps().standardDerivatives&&re.BumpTextureEnabled){let U=R.bumpTexture||R.normalTexture||R.geometryNormalTexture;N.setFloat3("vBumpInfos",U.coordinatesIndex,1/U.level,R.parallaxScaleBias),N.setMatrix("bumpMatrix",U.getTextureMatrix()),N.setTexture("bumpSampler",U),N.setFloat2("vTangentSpaceParams",R.invertNormalMapX?-1:1,R.invertNormalMapY?-1:1)}if(this._enableReflectivity){if(R.getClassName()==="PBRMetallicRoughnessMaterial")R.metallicRoughnessTexture!==null&&(N.setTexture("reflectivitySampler",R.metallicRoughnessTexture),N.setMatrix("reflectivityMatrix",R.metallicRoughnessTexture.getTextureMatrix())),R.metallic!==null&&N.setFloat("metallic",R.metallic),R.roughness!==null&&N.setFloat("glossiness",1-R.roughness),R.baseTexture!==null&&(N.setTexture("albedoSampler",R.baseTexture),N.setMatrix("albedoMatrix",R.baseTexture.getTextureMatrix())),R.baseColor!==null&&N.setColor3("albedoColor",R.baseColor);else if(R.getClassName()==="PBRSpecularGlossinessMaterial")R.specularGlossinessTexture!==null?(N.setTexture("reflectivitySampler",R.specularGlossinessTexture),N.setMatrix("reflectivityMatrix",R.specularGlossinessTexture.getTextureMatrix())):R.specularColor!==null&&N.setColor3("reflectivityColor",R.specularColor),R.glossiness!==null&&N.setFloat("glossiness",R.glossiness);else if(R.getClassName()==="PBRMaterial")R.metallicTexture!==null&&(N.setTexture("reflectivitySampler",R.metallicTexture),N.setMatrix("reflectivityMatrix",R.metallicTexture.getTextureMatrix())),R.metallic!==null&&N.setFloat("metallic",R.metallic),R.roughness!==null&&N.setFloat("glossiness",1-R.roughness),R.roughness!==null||R.metallic!==null||R.metallicTexture!==null?(R.albedoTexture!==null&&(N.setTexture("albedoSampler",R.albedoTexture),N.setMatrix("albedoMatrix",R.albedoTexture.getTextureMatrix())),R.albedoColor!==null&&N.setColor3("albedoColor",R.albedoColor)):(R.reflectivityTexture!==null?(N.setTexture("reflectivitySampler",R.reflectivityTexture),N.setMatrix("reflectivityMatrix",R.reflectivityTexture.getTextureMatrix())):R.reflectivityColor!==null&&N.setColor3("reflectivityColor",R.reflectivityColor),R.microSurface!==null&&N.setFloat("glossiness",R.microSurface));else if(R.getClassName()==="StandardMaterial")R.specularTexture!==null&&(N.setTexture("reflectivitySampler",R.specularTexture),N.setMatrix("reflectivityMatrix",R.specularTexture.getTextureMatrix())),R.specularColor!==null&&N.setColor3("reflectivityColor",R.specularColor);else if(R.getClassName()==="OpenPBRMaterial"){let U=R;U._useRoughnessFromMetallicTextureGreen&&U.baseMetalnessTexture?(N.setTexture("reflectivitySampler",U.baseMetalnessTexture),N.setMatrix("reflectivityMatrix",U.baseMetalnessTexture.getTextureMatrix())):U.baseMetalnessTexture?(N.setTexture("metallicSampler",U.baseMetalnessTexture),N.setMatrix("metallicMatrix",U.baseMetalnessTexture.getTextureMatrix())):U.specularRoughnessTexture&&(N.setTexture("roughnessSampler",U.specularRoughnessTexture),N.setMatrix("roughnessMatrix",U.specularRoughnessTexture.getTextureMatrix())),N.setFloat("metallic",U.baseMetalness),N.setFloat("glossiness",1-U.specularRoughness),U.baseColorTexture!==null&&(N.setTexture("albedoSampler",U.baseColorTexture),N.setMatrix("albedoMatrix",U.baseColorTexture.getTextureMatrix())),U.baseColor!==null&&N.setColor3("albedoColor",U.baseColor)}}if(this._enableIrradiance&&T.environmentTexture){let U=T.environmentTexture,k=T.postProcessRenderPipelineManager.supportedPipelines.find(z=>z.getClassName()==="IBLShadowsRenderPipeline");if(k){let Z=k._getAccumulatedTexture();Z&&(N.setTexture("iblShadowSampler",Z),N.setFloat2("shadowTextureSize",Z.getSize().width,Z.getSize().height))}if(N.setMatrix("reflectionMatrix",U.getReflectionTextureMatrix()),N.setFloat2("vReflectionInfos",U.level*T.iblIntensity,0),N.setTexture("reflectionSampler",U),U.irradianceTexture&&(N.setTexture("irradianceSampler",U.irradianceTexture),U.irradianceTexture._dominantDirection&&N.setVector3("vReflectionDominantDirection",U.irradianceTexture._dominantDirection)),U.sphericalPolynomial){let z=U.sphericalPolynomial;if(z.preScaledHarmonics){let Z=z.preScaledHarmonics;N.setVector3("vSphericalL00",Z.l00),N.setVector3("vSphericalL1_1",Z.l1_1),N.setVector3("vSphericalL10",Z.l10),N.setVector3("vSphericalL11",Z.l11),N.setVector3("vSphericalL2_2",Z.l2_2),N.setVector3("vSphericalL2_1",Z.l2_1),N.setVector3("vSphericalL20",Z.l20),N.setVector3("vSphericalL21",Z.l21),N.setVector3("vSphericalL22",Z.l22)}else N.setFloat3("vSphericalX",z.x.x,z.x.y,z.x.z),N.setFloat3("vSphericalY",z.y.x,z.y.y,z.y.z),N.setFloat3("vSphericalZ",z.z.x,z.z.y,z.z.z),N.setFloat3("vSphericalXX_ZZ",z.xx.x-z.zz.x,z.xx.y-z.zz.y,z.xx.z-z.zz.z),N.setFloat3("vSphericalYY_ZZ",z.yy.x-z.zz.x,z.yy.y-z.zz.y,z.yy.z-z.zz.z),N.setFloat3("vSphericalZZ",z.zz.x,z.zz.y,z.zz.z),N.setFloat3("vSphericalXY",z.xy.x,z.xy.y,z.xy.z),N.setFloat3("vSphericalYZ",z.yz.x,z.yz.y,z.yz.z),N.setFloat3("vSphericalZX",z.zx.x,z.zx.y,z.zx.z)}if(this.generateIrradianceWithScatterMask&&R.getClassName()==="OpenPBRMaterial"){let z=R;N.setFloat("vSubsurfaceWeight",z.subsurfaceWeight),z.subsurfaceWeightTexture&&(N.setTexture("subsurfaceWeightSampler",z.subsurfaceWeightTexture),N.setMatrix("subsurfaceWeightMatrix",z.subsurfaceWeightTexture.getTextureMatrix())),N.setFloat("vTransmissionWeight",z.transmissionWeight),z.transmissionWeightTexture&&(N.setTexture("transmissionWeightSampler",z.transmissionWeightTexture),N.setMatrix("transmissionWeightMatrix",z.transmissionWeightTexture.getTextureMatrix())),N.setFloat("vTransmissionScatterAnisotropy",z.transmissionScatterAnisotropy),N.setFloat("vSubsurfaceScatterAnisotropy",z.subsurfaceScatterAnisotropy)}}if(Li(N,R,this._scene),I.useBones&&I.computeBonesUsingShaders&&I.skeleton){let U=I.skeleton;if(U.isUsingTextureForMatrices&&N.getUniformIndex("boneTextureInfo")>-1){let k=U.getTransformMatrixTexture(I);N.setTexture("boneSampler",k),N.setFloat2("boneTextureInfo",U._textureWidth,U._textureHeight)}else N.setMatrices("mBones",I.skeleton.getTransformMatrices(I));(this._enableVelocity||this._enableVelocityLinear)&&N.setMatrices("mPreviousBones",this._previousBonesTransformationMatrices[I.uniqueId])}Yi(I,N),I.morphTargetManager&&I.morphTargetManager.isUsingTextureForTargets&&I.morphTargetManager._bind(N),(this._enableVelocity||this._enableVelocityLinear)&&(N.setMatrix("previousWorld",this._previousTransformationMatrices[x.uniqueId].world),N.setMatrix("previousViewProjection",this._previousTransformationMatrices[x.uniqueId].viewProjection)),D&&I.hasThinInstances&&N.setMatrix("world",M),I._processRendering(x,v,N,R.fillMode,P,D,(U,k)=>{U||N.setMatrix("world",k)})}(this._enableVelocity||this._enableVelocityLinear)&&(this._previousTransformationMatrices[x.uniqueId].world=M.clone(),this._previousTransformationMatrices[x.uniqueId].viewProjection=this._scene.getTransformMatrix().clone(),I.skeleton&&this._copyBonesTransformationMatrices(I.skeleton.getTransformMatrices(I),this._previousBonesTransformationMatrices[x.uniqueId]))};this._multiRenderTarget.customIsReadyFunction=(v,I,x)=>{if((x||I===0)&&v.subMeshes)for(let T=0;T{let A;if(this._linkedWithPrePass){if(!this._prePassRenderer.enabled)return;this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass)}if(T.length){for(e.setColorWrite(!1),A=0;A{throw Ce("GeometryBufferRendererSceneComponent")}});var Vw,q8,EA=C(()=>{w();Tn();So();Vw="openpbrUboDeclaration",q8=`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[Vw]||(E.IncludesShadersStoreWGSL[Vw]=q8)});var Gw,Q8,kw=C(()=>{w();Gw="openpbrNormalMapVertexDeclaration",Q8=`#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[Gw]||(E.IncludesShadersStoreWGSL[Gw]=Q8)});var Ww,J8,Hw=C(()=>{w();Ww="openpbrNormalMapVertex",J8=`#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[Ww]||(E.IncludesShadersStoreWGSL[Ww]=J8)});var Xw={};Ie(Xw,{openpbrVertexShaderWGSL:()=>$8});var vA,zw,$8,Yw=C(()=>{w();EA();Rm();af();Lr();vf();na();aa();go();xm();Im();Ef();kw();un();zc();Cm();To();Ao();_a();bm();Mm();Ro();xo();oa();la();ca();ym();Dm();Pm();Hw();mn();Xc();Om();Ch();Oh();vA="openpbrVertexShader",zw=`#define OPENPBR_VERTEX_SHADER +#include +#define CUSTOM_VERTEX_BEGIN +#ifndef USE_VERTEX_PULLING +attribute position: vec3f; +#ifdef NORMAL +attribute normal: vec3f; +#endif +#ifdef TANGENT +attribute tangent: vec4f; +#endif +#ifdef UV1 +attribute uv: vec2f; +#endif +#include[2..7] +#ifdef VERTEXCOLOR +attribute color: vec4f; +#endif +#endif +#include[1..7] +#include +#include +#include +#include +#include +#include +#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness) +#include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy) +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight) +#include(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor) +#include(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth) +#include(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter) +#include(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale) +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight) +#include(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor) +#include(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale) +#include(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight) +#include(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor) +#include(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness) +#include(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy) +#include(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening) +#include(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight) +#include(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor) +#include(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness) +#include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal) +#include(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent) +#include(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal) +#include(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity) +#include(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness) +#include(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor) +#include(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight) +#include(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness) +#include(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +varying vPositionW: vec3f; +#if DEBUGMODE>0 +varying vClipSpacePosition: vec4f; +#endif +#ifdef NORMAL +varying vNormalW: vec3f; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vEnvironmentIrradiance: vec3f; +#include +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vPositionUVW: vec3f; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vDirectionW: vec3f; +#endif +#include +#include +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef USE_VERTEX_PULLING +var positionUpdated: vec3f=vec3f(0.0); +#ifdef NORMAL +var normalUpdated: vec3f=vec3f(0.0); +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vec4f(0.0); +#endif +#ifdef UV1 +var uvUpdated: vec2f=vec2f(0.0); +#endif +#ifdef UV2 +var uv2Updated: vec2f=vec2f(0.0); +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vec4f(0.0); +#endif +#else +var positionUpdated: vec3f=vertexInputs.position; +#ifdef NORMAL +var normalUpdated: vec3f=vertexInputs.normal; +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vertexInputs.tangent; +#endif +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vertexInputs.color; +#endif +#endif +#include +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vertexOutputs.vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*vec4f(positionUpdated,1.0); +#endif +#ifdef USE_VERTEX_PULLING +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#else +#include +#include +#endif +var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);vertexOutputs.vPositionW= worldPos.xyz; +#ifdef PREPASS +#include +#endif +#ifdef NORMAL +var normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vertexOutputs.vNormalW=normalUpdated/ vec3f(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vertexOutputs.vNormalW=normalize(normalWorld*vertexOutputs.vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated); +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-vertexOutputs.vPositionW);var NdotV: f32=max(dot(vertexOutputs.vNormalW,viewDirectionW),0.0);var roughNormal: vec3f=mix(vertexOutputs.vNormalW,viewDirectionW,(0.5*(1.0-NdotV))*uniforms.vBaseDiffuseRoughness);var reflectionVector: vec3f= (uniforms.reflectionMatrix* vec4f(roughNormal,0)).xyz; +#else +var reflectionVector: vec3f= (uniforms.reflectionMatrix* vec4f(vertexOutputs.vNormalW,0)).xyz; +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*worldPos;} else {vertexOutputs.position=scene.viewProjectionR*worldPos;} +#else +vertexOutputs.position=scene.viewProjection*worldPos; +#endif +#if DEBUGMODE>0 +vertexOutputs.vClipSpacePosition=vertexOutputs.position; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vertexOutputs.vDirectionW=normalize((finalWorld*vec4f(positionUpdated,0.0)).xyz); +#endif +#ifndef UV1 +var uvUpdated: vec2f= vec2f(0.,0.); +#endif +#ifdef MAINUV1 +vertexOutputs.vMainUV1=uvUpdated; +#endif +#ifndef UV2 +var uv2Updated: vec2f= vec2f(0.,0.); +#endif +#ifdef MAINUV2 +vertexOutputs.vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_MATRIXNAME_,baseColor,_INFONAME_,BaseColorInfos.x) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_MATRIXNAME_,baseWeight,_INFONAME_,BaseWeightInfos.x) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_MATRIXNAME_,baseDiffuseRoughness,_INFONAME_,BaseDiffuseRoughnessInfos.x) +#include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_MATRIXNAME_,baseMetalness,_INFONAME_,BaseMetalnessInfos.x) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_MATRIXNAME_,specularWeight,_INFONAME_,SpecularWeightInfos.x) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_MATRIXNAME_,specularColor,_INFONAME_,SpecularColorInfos.x) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_MATRIXNAME_,specularRoughness,_INFONAME_,SpecularRoughnessInfos.x) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_MATRIXNAME_,specularRoughnessAnisotropy,_INFONAME_,SpecularRoughnessAnisotropyInfos.x) +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_MATRIXNAME_,transmissionWeight,_INFONAME_,TransmissionWeightInfos.x) +#include(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_MATRIXNAME_,transmissionColor,_INFONAME_,TransmissionColorInfos.x) +#include(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_MATRIXNAME_,transmissionDepth,_INFONAME_,TransmissionDepthInfos.x) +#include(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_MATRIXNAME_,transmissionScatter,_INFONAME_,TransmissionScatterInfos.x) +#include(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_MATRIXNAME_,transmissionDispersionScale,_INFONAME_,TransmissionDispersionScaleInfos.x) +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_MATRIXNAME_,subsurfaceWeight,_INFONAME_,SubsurfaceWeightInfos.x) +#include(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_MATRIXNAME_,subsurfaceColor,_INFONAME_,SubsurfaceColorInfos.x) +#include(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_MATRIXNAME_,subsurfaceRadiusScale,_INFONAME_,SubsurfaceRadiusScaleInfos.x) +#include(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_MATRIXNAME_,coatWeight,_INFONAME_,CoatWeightInfos.x) +#include(_DEFINENAME_,COAT_COLOR,_VARYNAME_,CoatColor,_MATRIXNAME_,coatColor,_INFONAME_,CoatColorInfos.x) +#include(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_MATRIXNAME_,coatRoughness,_INFONAME_,CoatRoughnessInfos.x) +#include(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_MATRIXNAME_,coatRoughnessAnisotropy,_INFONAME_,CoatRoughnessAnisotropyInfos.x) +#include(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_MATRIXNAME_,coatDarkening,_INFONAME_,CoatDarkeningInfos.x) +#include(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_MATRIXNAME_,fuzzWeight,_INFONAME_,FuzzWeightInfos.x) +#include(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_MATRIXNAME_,fuzzColor,_INFONAME_,FuzzColorInfos.x) +#include(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_MATRIXNAME_,fuzzRoughness,_INFONAME_,FuzzRoughnessInfos.x) +#include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_MATRIXNAME_,geometryNormal,_INFONAME_,GeometryNormalInfos.x) +#include(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_MATRIXNAME_,geometryTangent,_INFONAME_,GeometryTangentInfos.x) +#include(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_MATRIXNAME_,geometryCoatNormal,_INFONAME_,GeometryCoatNormalInfos.x) +#include(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_MATRIXNAME_,geometryOpacity,_INFONAME_,GeometryOpacityInfos.x) +#include(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_MATRIXNAME_,geometryThickness,_INFONAME_,GeometryThicknessInfos.x) +#include(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_MATRIXNAME_,emissionColor,_INFONAME_,EmissionColorInfos.x) +#include(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_MATRIXNAME_,thinFilmWeight,_INFONAME_,ThinFilmWeightInfos.x) +#include(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_MATRIXNAME_,thinFilmThickness,_INFONAME_,ThinFilmThicknessInfos.x) +#include(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_MATRIXNAME_,ambientOcclusion,_INFONAME_,AmbientOcclusionInfos.x) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#define CUSTOM_VERTEX_MAIN_END +}`;E.ShadersStoreWGSL[vA]||(E.ShadersStoreWGSL[vA]=zw);$8={name:vA,shader:zw}});var Kw,e6,SA=C(()=>{w();af();Kw="pbrFragmentExtraDeclaration",e6=`varying vPositionW: vec3f; +#if DEBUGMODE>0 +varying vClipSpacePosition: vec4f; +#endif +#include[1..7] +#ifdef NORMAL +varying vNormalW: vec3f; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vEnvironmentIrradiance: vec3f; +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying vViewDepth: f32; +#endif +`;E.IncludesShadersStoreWGSL[Kw]||(E.IncludesShadersStoreWGSL[Kw]=e6)});var jw,t6,Zw=C(()=>{w();pl();Yp();jw="openpbrFragmentSamplersDeclaration",t6=`#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) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy) +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight) +#include(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor) +#include(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth) +#include(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter) +#include(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale) +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight) +#include(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor) +#include(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale) +#include(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight) +#include(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor) +#include(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness) +#include(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy) +#include(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening) +#include(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight) +#include(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor) +#include(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness) +#include(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity) +#include(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent) +#include(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent) +#include(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness) +#include(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor) +#include(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight) +#include(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness) +#include(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#include +#ifdef ENVIRONMENTBRDF +var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d; +#endif +#ifdef FUZZENVIRONMENTBRDF +var environmentFuzzBrdfSamplerSampler: sampler;var environmentFuzzBrdfSampler: texture_2d; +#endif +#ifdef REFRACTED_BACKGROUND +var backgroundRefractionSamplerSampler: sampler;var backgroundRefractionSampler: texture_2d; +#endif +#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING +var sceneIrradianceSampler: texture_2d;var sceneDepthSampler: texture_2d; +#endif +#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) +var blueNoiseSamplerSampler: sampler;var blueNoiseSampler: texture_2d; +#endif +#ifdef IBL_CDF_FILTERING +var icdfSamplerSampler: sampler;var icdfSampler: texture_2d; +#endif +`;E.IncludesShadersStoreWGSL[jw]||(E.IncludesShadersStoreWGSL[jw]=t6)});var qw,i6,TA=C(()=>{w();qw="subSurfaceScatteringFunctions",i6=`fn testLightingForSSS(diffusionProfile: f32)->bool +{return diffusionProfile<1.;}`;E.IncludesShadersStoreWGSL[qw]||(E.IncludesShadersStoreWGSL[qw]=i6)});var Qw,r6,AA=C(()=>{w();Qw="importanceSampling",r6=`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[Qw]||(E.IncludesShadersStoreWGSL[Qw]=r6)});var Jw,s6,RA=C(()=>{w();Jw="pbrHelperFunctions",s6=`#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;} +fn getAARoughnessFactors(normalVector: vec3f)->vec2f { +#ifdef SPECULARAA +var nDfdx: vec3f=dpdx(normalVector.xyz);var nDfdy: vec3f=dpdy(normalVector.xyz);var slopeSquare: f32=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));var geometricRoughnessFactor: f32=pow(saturate(slopeSquare),0.333);var geometricAlphaGFactor: f32=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2f(geometricRoughnessFactor,geometricAlphaGFactor); +#else +return vec2f(0.); +#endif +} +#ifdef ANISOTROPIC +#ifdef ANISOTROPIC_LEGACY +fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);} +fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var anisotropicFrameDirection: vec3f=select(T,B,anisotropy>=0.0);var anisotropicFrameTangent: vec3f=cross(normalize(anisotropicFrameDirection),V);var anisotropicFrameNormal: vec3f=cross(anisotropicFrameTangent,anisotropicFrameDirection);var anisotropicNormal: vec3f=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;} +#elif ANISOTROPIC_OPENPBR +fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*alphaG*sqrt(2.0/(1.0+(1.0-anisotropy)*(1.0-anisotropy))),MINIMUMVARIANCE);var alphaB: f32=max(alphaT*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);} +#else +fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG,MINIMUMVARIANCE);return vec2f(alphaT,alphaB);} +fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var bentNormal: vec3f=cross(B,V);bentNormal=normalize(cross(bentNormal,B));var sq=1.0-anisotropy*(1.0-roughness);var a: f32=sq*sq*sq*sq;bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;} +#endif +#endif +#if defined(CLEARCOAT) || defined(SS_REFRACTION) +fn cocaLambertVec3(alpha: vec3f,distance: f32)->vec3f {return exp(-alpha*distance);} +fn cocaLambert(NdotVRefract: f32,NdotLRefract: f32,alpha: vec3f,thickness: f32)->vec3f {return cocaLambertVec3(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));} +fn computeColorAtDistanceInMedia(color: vec3f,distance: f32)->vec3f {return -log(color)/distance;} +fn computeClearCoatAbsorption(NdotVRefract: f32,NdotLRefract: f32,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var clearCoatAbsorption: vec3f=mix( vec3f(1.0), +cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness), +clearCoatIntensity);return clearCoatAbsorption;} +#endif +#ifdef MICROSURFACEAUTOMATIC +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[Jw]||(E.IncludesShadersStoreWGSL[Jw]=s6)});var $w,n6,xA=C(()=>{w();uS();$w="pbrDirectLightingSetupFunctions",n6=`struct preLightingInfo +{lightOffset: vec3f, +lightDistanceSquared: f32, +lightDistance: f32, +attenuation: f32, +L: vec3f, +H: vec3f, +NdotV: f32, +NdotLUnclamped: f32, +NdotL: f32, +VdotH: f32, +LdotV: f32, +roughness: f32, +diffuseRoughness: f32, +surfaceAlbedo: vec3f, +#ifdef IRIDESCENCE +iridescenceIntensity: f32 +#endif +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +areaLightDiffuse: vec3f, +#ifdef SPECULARTERM +areaLightSpecular: vec3f, +areaLightFresnel: vec4f +#endif +#endif +};fn computePointAndSpotPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f,posW: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;} +fn computeDirectionalPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=dot(result.L,V);return result;} +fn computeHemisphericPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL; +#ifdef SPECULARTERM +result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H)); +#endif +return result;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#include +var areaLightsLTC1SamplerSampler: sampler;var areaLightsLTC1Sampler: texture_2d;var areaLightsLTC2SamplerSampler: sampler;var areaLightsLTC2Sampler: texture_2d;fn computeAreaPreLightingInfo(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightCenter:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->preLightingInfo {var result: preLightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc1Sampler,ltc2,ltc2Sampler,viewDirectionW,vNormal,vPosition,lightCenter,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +result.areaLightFresnel=data.Fresnel;result.areaLightSpecular=data.Specular; +#endif +result.areaLightDiffuse+=data.Diffuse;return result;} +fn computeAreaPreLightingInfoWithTexture(ltc1: texture_2d,ltc1Sampler:sampler,ltc2:texture_2d,ltc2Sampler:sampler,emissionTexture:texture_2d,emissionTextureSampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightCenter:vec3f,halfWidth:vec3f, halfHeight:vec3f,roughness:f32)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightCenter-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);var data: areaLightData=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc1Sampler,ltc2,ltc2Sampler,emissionTexture,emissionTextureSampler,viewDirectionW,vNormal,vPosition,lightCenter,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +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[$w]||(E.IncludesShadersStoreWGSL[$w]=n6)});var e1,a6,IA=C(()=>{w();e1="pbrDirectLightingFalloffFunctions",a6=`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);} +fn computeDistanceLightFalloff_GLTF(lightDistanceSquared: f32,inverseSquaredRange: f32)->f32 +{var lightDistanceFalloff: f32=1.0/maxEps(lightDistanceSquared);var factor: f32=lightDistanceSquared*inverseSquaredRange;var attenuation: f32=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;} +fn computeDirectionalLightFalloff_IES(lightDirection: vec3f,directionToLightCenterW: vec3f,iesLightTexture: texture_2d,iesLightTextureSampler: sampler)->f32 +{var cosAngle: f32=dot(-lightDirection,directionToLightCenterW);var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;} +fn computeDistanceLightFalloff(lightOffset: vec3f,lightDistanceSquared: f32,range: f32,inverseSquaredRange: f32)->f32 +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDistanceLightFalloff_Physical(lightDistanceSquared); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange); +#else +return computeDistanceLightFalloff_Standard(lightOffset,range); +#endif +} +fn computeDirectionalLightFalloff_Standard(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32)->f32 +{var falloff: f32=0.0;var cosAngle: f32=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle) +{falloff=max(0.,pow(cosAngle,exponent));} +return falloff;} +fn computeDirectionalLightFalloff_Physical(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32)->f32 +{const kMinusLog2ConeAngleIntensityRatio: f32=6.64385618977; +var concentrationKappa: f32=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);var lightDirectionSpreadSG: vec4f= vec4f(-lightDirection*concentrationKappa,-concentrationKappa);var falloff: f32=exp2(dot( vec4f(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;} +fn computeDirectionalLightFalloff_GLTF(lightDirection: vec3f,directionToLightCenterW: vec3f,lightAngleScale: f32,lightAngleOffset: f32)->f32 +{var cd: f32=dot(-lightDirection,directionToLightCenterW);var falloff: f32=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;} +fn computeDirectionalLightFalloff(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32,lightAngleScale: f32,lightAngleOffset: f32)->f32 +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset); +#else +return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); +#endif +}`;E.IncludesShadersStoreWGSL[e1]||(E.IncludesShadersStoreWGSL[e1]=a6)});var t1,o6,CA=C(()=>{w();t1="hdrFilteringFunctions",o6=`#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; } +fn hammersley(i: u32,N: u32)->vec2f +{return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));} +fn log4(x: f32)->f32 {return log2(x)/2.;} +fn uv_to_normal(uv: vec2f)->vec3f {var N: vec3f;var uvRange: vec2f=uv;var theta: f32=uvRange.x*2.0*PI;var phi: f32=uvRange.y*PI;N.x=cos(theta)*sin(phi);N.z=sin(theta)*sin(phi);N.y=cos(phi);return N;} +const NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance( +#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT +CUSTOM_IRRADIANCE_FILTERING_INPUT +#else +inputTexture: texture_cube,inputSampler: sampler, +#endif +inputN: vec3f, +filteringInfo: vec2f, +diffuseRoughness: f32, +surfaceAlbedo: vec3f, +inputV: vec3f +#ifdef IBL_CDF_FILTERING +,icdfSampler: texture_2d,icdfSamplerSampler: sampler +#endif +)->vec3f +{var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0); +#ifndef IBL_CDF_FILTERING +var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var tbnInverse: mat3x3f=transpose(tbn); +#endif +var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));for(var i: u32=0u; i0.) { +#ifdef IBL_CDF_FILTERING +var pdf: f32=textureSampleLevel(icdfSampler,icdfSamplerSampler,T,0.0).z;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,Ls,0.0).rgb; +#else +var pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel); +#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION +CUSTOM_IRRADIANCE_FILTERING_FUNCTION +#else +var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb; +#endif +#endif +#ifdef GAMMA_INPUT +c=toLinearSpaceVec3(c); +#endif +var diffuseRoughnessTerm: vec3f=vec3f(1.0); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI; +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +#ifdef IBL_CDF_FILTERING +var light: vec3f=vec3f(0.0);if (pdf>1e-6) {light=vec3f(1.0)/vec3f(pdf)*c;} +result+=NoL*diffuseRoughnessTerm*light; +#else +result+=c*diffuseRoughnessTerm; +#endif +}} +result=result*NUM_SAMPLES_FLOAT_INVERSED; +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +result=result/clampedAlbedo; +#endif +return result;} +fn radiance(alphaG: f32,inputTexture: texture_cube,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f +{var n: vec3f=normalize(inputN);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,n,0.0).rgb; +if (alphaG==0.) { +#ifdef GAMMA_INPUT +c=toLinearSpaceVec3(c); +#endif +return c;} else {var result: vec3f= vec3f(0.);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var weight: f32=0.;for(var i: u32=0u; i0.) {var pdf_inversed: f32=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp( f32(l),0.0,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*L,mipLevel).rgb; +#ifdef GAMMA_INPUT +c=toLinearSpaceVec3(c); +#endif +result+=c*NoL;}} +result=result/weight;return result;}} +#ifdef ANISOTROPIC +fn radianceAnisotropic( +alphaTangent: f32, +alphaBitangent: f32, +inputTexture: texture_cube, +inputSampler: sampler, +inputView: vec3f, +inputTangent: vec3f, +inputBitangent: vec3f, +inputNormal: vec3f, +filteringInfo: vec2f, +noiseInput: vec2f, +isRefraction: bool, +ior: f32 +)->vec3f {var V: vec3f=inputView;var N: vec3f=inputNormal;var T: vec3f=inputTangent;var B: vec3f=inputBitangent;var result: vec3f=vec3f(0.f);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;let clampedAlphaT: f32=max(alphaTangent,MINIMUMVARIANCE);let clampedAlphaB: f32=max(alphaBitangent,MINIMUMVARIANCE);var effectiveDim: f32=dim0*sqrt(clampedAlphaT*clampedAlphaB);var omegaP: f32=(4.f*PI)/(6.f*effectiveDim*effectiveDim);let noiseScale: f32=clamp(log2(f32(NUM_SAMPLES))/12.0f,0.0f,1.0f);var weight: f32=0.f;for(var i: u32=0u; i0.f) {var pdf_inversed: f32=4./normalDistributionFunction_BurleyGGX_Anisotropic( +H_tangent.z,H_tangent.x,H_tangent.y,vec2f(clampedAlphaT,clampedAlphaB) +);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0f,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,L,mipLevel).rgb; +#if GAMMA_INPUT +c=toLinearSpaceVec3(c); +#endif +result+=c*NoL;}} +result=result/weight;return result;} +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[t1]||(E.IncludesShadersStoreWGSL[t1]=o6)});var i1,l6,bA=C(()=>{w();i1="pbrBlockReflectance0",l6=`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[i1]||(E.IncludesShadersStoreWGSL[i1]=l6)});var r1,c6,MA=C(()=>{w();mS();bA();r1="pbrDirectLightingFunctions",c6=`#define CLEARCOATREFLECTANCE90 1.0 +struct lightingInfo +{diffuse: vec3f, +#ifdef SS_TRANSLUCENCY +diffuseTransmission: vec3f, +#endif +#ifdef SPECULARTERM +specular: vec3f, +#endif +#ifdef CLEARCOAT +clearCoat: vec4f, +#endif +#ifdef SHEEN +sheen: vec3f +#endif +};fn adjustRoughnessFromLightProperties(roughness: f32,lightRadius: f32,lightDistance: f32)->f32 { +#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF) +var lightRoughness: f32=lightRadius/lightDistance;var totalRoughness: f32=saturate(lightRoughness+roughness);return totalRoughness; +#else +return roughness; +#endif +} +fn computeHemisphericDiffuseLighting(info: preLightingInfo,lightColor: vec3f,groundColor: vec3f)->vec3f {return mix(groundColor,lightColor,info.NdotL);} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +fn computeAreaDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {return info.areaLightDiffuse*lightColor;} +#endif +fn computeDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {var diffuseTerm: vec3f=vec3f(1.0/PI); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY +diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseTerm=vec3f(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +var clampedAlbedo: vec3f=clamp(info.surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; +#endif +return diffuseTerm*info.attenuation*info.NdotL*lightColor;} +fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f{var strq: vec4f=textureProjectionMatrix* vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return toLinearSpaceVec3(textureColor);} +#ifdef SS_TRANSLUCENCY +fn computeDiffuseTransmittedLighting(info: preLightingInfo,lightColor: vec3f,transmittance: vec3f)->vec3f {var transmittanceNdotL=vec3f(0.0);var NdotL: f32=absEps(info.NdotLUnclamped); +#ifndef SS_TRANSLUCENCY_LEGACY +if (info.NdotLUnclamped<0.0) { +#endif +var wrapNdotL: f32=computeWrappedDiffuseNdotL(NdotL,0.02);var trAdapt: f32=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL, vec3f(wrapNdotL),trAdapt); +#ifndef SS_TRANSLUCENCY_LEGACY +} +var diffuseTerm : vec3f=vec3f(1.0/PI); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY +diffuseTerm=vec3f(diffuseBRDF_Burley( +info.NdotL,info.NdotV,info.VdotH,info.roughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseTerm=vec3f(diffuseBRDF_Burley( +info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +var clampedAlbedo: vec3f=clamp(info.surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness, +info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; +#endif +return (transmittanceNdotL*diffuseTerm)*info.attenuation*lightColor; +#else +let diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor; +#endif +} +#endif +#ifdef SPECULARTERM +fn computeSpecularLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,fresnel: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var modifiedFresnel: vec3f=fresnel; +#ifdef IRIDESCENCE +modifiedFresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); +#endif +var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG); +#ifdef BRDF_V_HEIGHT_CORRELATED +var smithVisibility: f32=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG); +#else +var smithVisibility: f32=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG); +#endif +var specTerm: vec3f=modifiedFresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +fn computeAreaSpecularLighting(info: preLightingInfo,specularColor: vec3f,reflectance0: vec3f,reflectance90: vec3f)->vec3f {var fresnel:vec3f =reflectance0*specularColor*info.areaLightFresnel.x+( vec3f( 1.0 )-specularColor )*info.areaLightFresnel.y*reflectance90;return specularColor*fresnel*info.areaLightSpecular;} +#endif +#endif +#ifdef FUZZ +fn evalFuzz(L: vec3f,NdotL: f32,NdotV: f32,T: vec3f,B: vec3f,ltcLut: vec3f)->f32 +{if (NdotL<=0.0f || NdotV<=0.0f) {return 0.0f;} +let M=mat3x3f( +vec3f(ltcLut.r,0.0f,0.0f), +vec3f(ltcLut.g,1.0f,0.0f), +vec3f(0.0f,0.0f,1.0f) +);let Llocal: vec3f=vec3f(dot(L,T),dot(L,B),NdotL);let Lwarp: vec3f=normalize(M*Llocal);let cosThetaWarp: f32=max(Lwarp.z,0.0f);return cosThetaWarp*NdotL;} +#endif +#if defined(ANISOTROPIC) && defined(ANISOTROPIC_OPENPBR) +fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=vec3f(distribution*smithVisibility);return specTerm*info.attenuation*info.NdotL*lightColor;} +#elif defined(ANISOTROPIC) +fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,vec2f(geometricRoughnessFactor*geometricRoughnessFactor));var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90); +#ifdef IRIDESCENCE +fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); +#endif +var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} +#endif +#ifdef CLEARCOAT +fn computeClearCoatLighting(info: preLightingInfo,Ncc: vec3f,geometricRoughnessFactor: f32,clearCoatIntensity: f32,lightColor: vec3f)->vec4f {var NccdotL: f32=saturateEps(dot(Ncc,info.L));var NccdotH: f32=saturateEps(dot(Ncc,info.H));var clearCoatRoughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);var fresnel: f32=fresnelSchlickGGX(info.VdotH,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);var kelemenVisibility: f32=visibility_Kelemen(info.VdotH);var clearCoatTerm: f32=fresnel*distribution*kelemenVisibility;return vec4f( +clearCoatTerm*info.attenuation*NccdotL*lightColor, +1.0-fresnel +);} +fn computeClearCoatLightingAbsorption(NdotVRefract: f32,L: vec3f,Ncc: vec3f,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var LRefract: vec3f=-refract(L,Ncc,uniforms.vClearCoatRefractionParams.y);var NdotLRefract: f32=saturateEps(dot(Ncc,LRefract));var absorption: vec3f=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;} +#endif +#ifdef SHEEN +fn computeSheenLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: f32=1.;var distribution: f32=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER +var visibility: f32=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG); +#else */ +var visibility: f32=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */ +var sheenTerm: f32=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;} +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#include +fn computeClusteredLighting( +lightDataTexture: texture_2d, +tileMaskBuffer: ptr>, +lightData: vec4f, +sliceRange: vec2u, +V: vec3f, +N: vec3f, +posW: vec3f, +surfaceAlbedo: vec3f, +reflectivityOut: reflectivityOutParams, +#ifdef IRIDESCENCE +iridescenceIntensity: f32, +#endif +#ifdef SS_TRANSLUCENCY +subSurfaceOut: subSurfaceOutParams, +#endif +#ifdef SPECULARTERM +AARoughnessFactor: f32, +#endif +#ifdef ANISOTROPIC +anisotropicOut: anisotropicOutParams, +#endif +#ifdef SHEEN +sheenOut: sheenOutParams, +#endif +#ifdef CLEARCOAT +clearcoatOut: clearcoatOutParams, +#endif +)->lightingInfo {let NdotV=absEps(dot(N,V)); +#include +#ifdef CLEARCOAT +specularEnvironmentR0=clearcoatOut.specularEnvironmentR0; +#endif +var result: lightingInfo;let tilePosition=vec2u(fragmentInputs.position.xy*lightData.xy);let maskResolution=vec2u(lightData.zw);var tileIndex=(tilePosition.x*maskResolution.x+tilePosition.y)*maskResolution.y;let batchRange=sliceRange/CLUSTLIGHT_BATCH;var batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tileIndex+=batchRange.x;for (var i=batchRange.x; i<=batchRange.y; i+=1) {var mask=tileMaskBuffer[tileIndex];tileIndex+=1;let maskOffset=max(sliceRange.x,batchOffset)-batchOffset; +let maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while mask != 0 {let trailing=firstTrailingBit(mask);mask ^= 1u<=0.0 {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);} +preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo; +#ifdef IRIDESCENCE +preInfo.iridescenceIntensity=iridescenceIntensity; +#endif +var info: lightingInfo; +#ifdef SS_TRANSLUCENCY +#ifdef SS_TRANSLUCENCY_LEGACY +info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0); +#else +info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance); +#endif +#else +info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb); +#endif +#ifdef SPECULARTERM +#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR +let metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);let dielectricFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);let coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic); +#else +let coloredFresnel=fresnelSchlickGGXVec3(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#endif +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +let NdotH=dot(N,preInfo.H);let fresnel=fresnelSchlickGGXVec3(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel); +#endif +#ifdef ANISOTROPIC +info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb); +#else +info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb); +#endif +#endif +#ifdef SHEEN +#ifdef SHEEN_LINKWITHALBEDO +preInfo.roughness=sheenOut.sheenIntensity; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance); +#endif +info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb); +#endif +#ifdef CLEARCOAT +preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb); +#ifdef CLEARCOAT_TINT +let absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=absorption; +#endif +#ifdef SPECULARTERM +info.specular*=absorption; +#endif +#endif +info.diffuse*=info.clearCoat.w; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=info.clearCoat.w; +#endif +#ifdef SPECULARTERM +info.specular*=info.clearCoat.w; +#endif +#ifdef SHEEN +info.sheen*=info.clearCoat.w; +#endif +#endif +result.diffuse+=info.diffuse; +#ifdef SS_TRANSLUCENCY +result.diffuseTransmission+=info.diffuseTransmission; +#endif +#ifdef SPECULARTERM +result.specular+=info.specular; +#endif +#ifdef CLEARCOAT +result.clearCoat+=info.clearCoat; +#endif +#ifdef SHEEN +result.sheen+=info.sheen; +#endif +} +batchOffset+=CLUSTLIGHT_BATCH;} +return result;} +#endif +`;E.IncludesShadersStoreWGSL[r1]||(E.IncludesShadersStoreWGSL[r1]=c6)});var s1,f6,n1=C(()=>{w();s1="openpbrNormalMapFragmentMainFunctions",f6=`#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 +#ifdef OBJECTSPACE_NORMALMAP +uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f +{var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0]; +var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0]; +var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4( +(a11*b11-a12*b10+a13*b09)/det, +(a02*b10-a01*b11-a03*b09)/det, +(a31*b05-a32*b04+a33*b03)/det, +(a22*b04-a21*b05-a23*b03)/det, +(a12*b08-a10*b11-a13*b07)/det, +(a00*b11-a02*b08+a03*b07)/det, +(a32*b02-a30*b05-a33*b01)/det, +(a20*b05-a22*b02+a23*b01)/det, +(a10*b10-a11*b08+a13*b06)/det, +(a01*b08-a00*b10-a03*b06)/det, +(a30*b04-a31*b02+a33*b00)/det, +(a21*b02-a20*b04-a23*b00)/det, +(a11*b07-a10*b09-a12*b06)/det, +(a00*b09-a01*b07+a02*b06)/det, +(a31*b01-a30*b03-a32*b00)/det, +(a20*b03-a21*b01+a22*b00)/det);return mat4x4(mi[0][0],mi[1][0],mi[2][0],mi[3][0], +mi[0][1],mi[1][1],mi[2][1],mi[3][1], +mi[0][2],mi[1][2],mi[2][2],mi[3][2], +mi[0][3],mi[1][3],mi[2][3],mi[3][3]);} +#endif +fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f +{var output=normal; +#ifdef NORMALXYSCALE +output=normalize(output* vec3f(scale,scale,1.0)); +#endif +return normalize(cotangentFrame*output);} +fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f +{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);} +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[s1]||(E.IncludesShadersStoreWGSL[s1]=f6)});var a1,h6,o1=C(()=>{w();pl();a1="openpbrNormalMapFragmentFunctions",h6=`#if defined(GEOMETRY_NORMAL) +#include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal) +#endif +#if defined(GEOMETRY_COAT_NORMAL) +#include(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal) +#endif +#if defined(DETAIL) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail) +#endif +#if defined(GEOMETRY_NORMAL) && defined(PARALLAX) +const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; icurrRayHeight) +{var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;} +else +{currRayHeight-=stepSize;vLastOffset=vCurrOffset; +#ifdef PARALLAX_RHS +vCurrOffset-=stepSize*vMaxOffset; +#else +vCurrOffset+=stepSize*vMaxOffset; +#endif +lastSampledHeight=currSampledHeight;}} +return vCurrOffset;} +fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f +{var height: f32=textureSample(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height; +#ifdef PARALLAX_RHS +return texCoordOffset; +#else +return -texCoordOffset; +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[a1]||(E.IncludesShadersStoreWGSL[a1]=h6)});var l1,d6,c1=C(()=>{w();l1="openpbrConductorReflectance",d6=`#define pbr_inline +fn conductorReflectance(baseColor: vec3f,specularColor: vec3f,specularWeight: f32)->ReflectanceParams +{var outParams: ReflectanceParams; +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight; +#else +outParams.coloredF0=baseColor;outParams.coloredF90=vec3f(1.0f); +#endif +outParams.F0=1.0f;outParams.F90=1.0f;return outParams;}`;E.IncludesShadersStoreWGSL[l1]||(E.IncludesShadersStoreWGSL[l1]=d6)});var f1,u6,h1=C(()=>{w();f1="openpbrAmbientOcclusionFunctions",u6=`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[f1]||(E.IncludesShadersStoreWGSL[f1]=u6)});var d1,m6,u1=C(()=>{w();d1="openpbrVolumeFunctions",m6=`struct OpenPBRHomogeneousVolume {extinction_coeff: vec3f, +ss_albedo: vec3f, +multi_scatter_color: vec3f, +absorption_coeff: vec3f, +scatter_coeff: vec3f, +anisotropy: f32, };fn computeOpenPBRTransmissionVolume( +transmission_color: vec3f, +transmission_depth: f32, +transmission_scatter: vec3f, +anisotropy: f32 +)->OpenPBRHomogeneousVolume +{var volumeParams: OpenPBRHomogeneousVolume;volumeParams.absorption_coeff=vec3f(0.0f);volumeParams.scatter_coeff=vec3f(0.0f);volumeParams.anisotropy=anisotropy; +#ifdef GEOMETRY_THIN_WALLED +volumeParams.scatter_coeff=vec3f(1.0f);volumeParams.anisotropy=1.0f; +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3f(1.0f); +#else +if (transmission_depth>0.0f) {let invDepth: vec3f=vec3f(1.f/maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEpsVec3(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;let minCoeff: f32=min3(volumeParams.absorption_coeff);if (minCoeff<0.0f) {volumeParams.absorption_coeff-=vec3f(minCoeff);} +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/(volumeParams.extinction_coeff);} else {volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3f(0.0f);} +#endif +return volumeParams;} +fn computeOpenPBRSubsurfaceVolume( +subsurface_color: vec3f, +subsurface_radius: f32, +subsurface_radius_scale: vec3f, +anisotropy: f32 +)->OpenPBRHomogeneousVolume +{var volumeParams: OpenPBRHomogeneousVolume;volumeParams.absorption_coeff=vec3f(0.0f);volumeParams.scatter_coeff=vec3f(0.0f);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;let mfp: vec3f=subsurface_radius_scale*vec3f(subsurface_radius);volumeParams.extinction_coeff=vec3f(1.0f)/maxEpsVec3(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedoWithAniso(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;let minCoeff: f32=min3(volumeParams.absorption_coeff);if (minCoeff<0.0f) {volumeParams.absorption_coeff-=vec3f(minCoeff);} +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;} +fn sss_pdf(r: f32,d: vec3f)->vec3f +{let d_clamped=max(vec3f(1e-4f),d);return (exp(-r/d_clamped)+exp(-r/(3.0f*d_clamped)))/max(vec3f(1e-5f),8.0f*PI*d_clamped*r);} +fn sss_samples_pdf(r: f32,d: f32)->f32 +{let d_clamped=max(1e-4f,d);return exp(-r/(3.0f*d_clamped))/(6.0f*PI*d_clamped*r);} +fn sss_samples_icdf(x: f32,d: f32)->f32 +{let d_clamped=max(1e-4f,d);let x_clamped=max(1e-4f,x);return -3.0f*log(x_clamped)*d_clamped;} +fn samples_scale(x: f32,d: f32)->f32 +{return 1.0f-exp(-x/(3.0f*d));} +fn sss_get_position(depth_texture: texture_2d,tex_coord: vec2f,render_resolution: vec2f,inv_proj: mat4x4f)->vec3f +{var P: vec4f=vec4f(tex_coord,textureLoad(depth_texture,vec2i(tex_coord*render_resolution),0).x,1.0f);P.x=2.0f*P.x-1.0f;P.y=2.0f*P.y-1.0f;P=inv_proj*P;return P.xyz/P.w;} +fn sss_filter_scale(currZ: f32,proj: mat4x4f)->f32 +{return 1.0f/dot(vec2f(proj[2].w,proj[3].w),vec2f(currZ,1.0f));} +fn projective_to_pixels(proj_dist: f32,proj: mat4x4f,resolution: vec2f)->f32 +{return proj_dist*proj[1][1]*resolution.y;} +fn pixels_to_projective(pixel_dist: f32,proj: mat4x4f,resolution: vec2f)->f32 +{return pixel_dist/(proj[1][1]*resolution.y);} +fn sss_convolve(sss_irradiance_texture: texture_2d,depth_texture: texture_2d,render_resolution: vec2f,d: vec3f,proj: mat4x4f,inv_proj: mat4x4f,sample_count: i32,noise: vec2f)->vec3f +{let tex_coord: vec2f=fragmentInputs.position.xy/render_resolution;let unconvolved_irradiance: vec3f=textureLoad(sss_irradiance_texture,vec2i(fragmentInputs.position.xy),0).rgb;let curr_pos: vec3f=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);var dmax: f32=max3(d);let max_dmax: f32=0.1*f32(sample_count);var d_adjusted=d;if (dmax>max_dmax) +{d_adjusted*=max_dmax/dmax;dmax=max_dmax;} +var dz: f32=dmax*sss_filter_scale(curr_pos.z,proj);let projMat2d: mat2x2f=mat2x2f(proj[0].xy,proj[1].xy);if (determinant(projMat2d)*dz<1e-4f) {return unconvolved_irradiance;} +let overscan_size_in_pixels: f32=max(render_resolution.x,render_resolution.y)*0.1;let filter_crop_ratio: f32=0.8f; +let crop_radius: f32=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels) +{d_adjusted*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;} +let filter_samples_scale: f32=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);var irradiance_sum: vec3f=vec3f(0.0f);var weight_sum: vec3f=vec3f(0.0f);for (var i: i32=0; i0.0f) +{let weights: vec3f=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d_adjusted);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}} +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[d1]||(E.IncludesShadersStoreWGSL[d1]=m6)});var m1,p6,yA=C(()=>{w();m1="pbrBlockNormalGeometric",p6=`var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW); +#ifdef NORMAL +var normalW: vec3f=normalize(input.vNormalW); +#else +var normalW: vec3f=normalize(cross(dpdx(input.vPositionW),dpdy(input.vPositionW)))*scene.vEyePosition.w; +#endif +var geometricNormalW: vec3f=normalW; +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing); +#endif +`;E.IncludesShadersStoreWGSL[m1]||(E.IncludesShadersStoreWGSL[m1]=p6)});var p1,_6,_1=C(()=>{w();p1="openpbrNormalMapFragment",_6=`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; +#elif defined(GEOMETRY_NORMAL) +var normalScale: f32=uniforms.vGeometryNormalInfos.y; +#else +var normalScale: f32=1.0; +#endif +#if defined(TANGENT) && defined(NORMAL) +var TBN: mat3x3f=mat3x3(input.vTBN0,input.vTBN1,input.vTBN2); +#elif defined(GEOMETRY_NORMAL) +var TBNUV: vec2f=select(-fragmentInputs.vGeometryNormalUV,fragmentInputs.vGeometryNormalUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams); +#elif defined(GEOMETRY_COAT_NORMAL) +var TBNUV: vec2f=select(-fragmentInputs.vGeometryCoatNormalUV,fragmentInputs.vGeometryCoatNormalUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams); +#else +var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.)); +#endif +#elif defined(ANISOTROPIC) || defined(FUZZ) +#if defined(TANGENT) && defined(NORMAL) +var TBN: mat3x3f=mat3x3(input.vTBN0,input.vTBN1,input.vTBN2); +#else +var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.)); +#endif +#endif +#ifdef PARALLAX +var invTBN: mat3x3f=transposeMat3(TBN); +#ifdef PARALLAXOCCLUSION +#else +#endif +#endif +#ifdef DETAIL +var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB); +#endif +#ifdef GEOMETRY_COAT_NORMAL +coatNormalW=perturbNormal(TBN,textureSample(geometryCoatNormalSampler,geometryCoatNormalSamplerSampler,fragmentInputs.vGeometryCoatNormalUV+uvOffset).xyz,uniforms.vGeometryCoatNormalInfos.y); +#endif +#ifdef GEOMETRY_NORMAL +#ifdef OBJECTSPACE_NORMALMAP +#define CUSTOM_FRAGMENT_BUMP_FRAGMENT +normalW=normalize(textureSample(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW); +#elif !defined(DETAIL) +normalW=perturbNormal(TBN,textureSample(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV+uvOffset).xyz,uniforms.vGeometryNormalInfos.y); +#else +var sampledNormal: vec3f=textureSample(geometryNormalSampler,geometryNormalSamplerSampler,fragmentInputs.vGeometryNormalUV+uvOffset).xyz*2.0-1.0; +#if DETAIL_NORMALBLENDMETHOD==0 +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z)); +#elif DETAIL_NORMALBLENDMETHOD==1 +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);sampledNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal; +#endif +normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vGeometryNormalInfos.y); +#endif +#elif defined(DETAIL) +detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z); +#endif +`;E.IncludesShadersStoreWGSL[p1]||(E.IncludesShadersStoreWGSL[p1]=_6)});var g1,g6,E1=C(()=>{w();g1="openpbrBlockNormalFinal",g6=`#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); +#endif +normalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +#if defined(MIRRORED) +normalW=select(normalW,-normalW,fragmentInputs.frontFacing);coatNormalW=select(coatNormalW,-coatNormalW,fragmentInputs.frontFacing); +#else +normalW=select(-normalW,normalW,fragmentInputs.frontFacing);coatNormalW=select(-coatNormalW,coatNormalW,fragmentInputs.frontFacing); +#endif +#endif +`;E.IncludesShadersStoreWGSL[g1]||(E.IncludesShadersStoreWGSL[g1]=g6)});var v1,E6,S1=C(()=>{w();v1="openpbrBaseLayerData",E6=`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 +#ifdef BASE_COLOR +let baseColorFromTexture: vec4f=textureSample(baseColorSampler,baseColorSamplerSampler,fragmentInputs.vBaseColorUV+uvOffset); +#endif +#ifdef BASE_METALNESS +let metallicFromTexture: vec4f=textureSample(baseMetalnessSampler,baseMetalnessSamplerSampler,fragmentInputs.vBaseMetalnessUV+uvOffset); +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +let baseDiffuseRoughnessFromTexture: f32=textureSample(baseDiffuseRoughnessSampler,baseDiffuseRoughnessSamplerSampler,fragmentInputs.vBaseDiffuseRoughnessUV+uvOffset).r; +#endif +#ifdef GEOMETRY_TANGENT +let geometryTangentFromTexture: vec3f=textureSample(geometryTangentSampler,geometryTangentSamplerSampler,fragmentInputs.vGeometryTangentUV+uvOffset).rgb; +#endif +#ifdef SPECULAR_ROUGHNESS_ANISOTROPY +let anisotropyFromTexture: f32=textureSample(specularRoughnessAnisotropySampler,specularRoughnessAnisotropySamplerSampler,fragmentInputs.vSpecularRoughnessAnisotropyUV+uvOffset).r*uniforms.vSpecularRoughnessAnisotropyInfos.y; +#endif +#ifdef GEOMETRY_OPACITY +let opacityFromTexture: vec4f=textureSample(geometryOpacitySampler,geometryOpacitySamplerSampler,fragmentInputs.vGeometryOpacityUV+uvOffset); +#endif +#ifdef GEOMETRY_THICKNESS +let thicknessFromTexture: vec4f=textureSample(geometryThicknessSampler,geometryThicknessSamplerSampler,fragmentInputs.vGeometryThicknessUV+uvOffset); +#endif +#ifdef DECAL +let decalFromTexture: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset); +#endif +#ifdef SPECULAR_COLOR +let specularColorFromTexture: vec4f=textureSample(specularColorSampler,specularColorSamplerSampler,fragmentInputs.vSpecularColorUV+uvOffset); +#endif +#if defined(SPECULAR_WEIGHT) +#ifdef SPECULAR_WEIGHT_IN_ALPHA +let specularWeightFromTexture: f32=textureSample(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).a; +#else +let specularWeightFromTexture: f32=textureSample(specularWeightSampler,specularWeightSamplerSampler,fragmentInputs.vSpecularWeightUV+uvOffset).r; +#endif +#endif +#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) +let noise=vec3f(2.0)*textureSample(blueNoiseSampler,blueNoiseSamplerSampler,fragmentInputs.position.xy/256.0).xyz-vec3f(1.0); +#endif +#if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS) +let roughnessFromTexture: f32=metallicFromTexture.g; +#elif defined(SPECULAR_ROUGHNESS) +let roughnessFromTexture: f32=textureSample(specularRoughnessSampler,specularRoughnessSamplerSampler,fragmentInputs.vSpecularRoughnessUV+uvOffset).r; +#endif +base_color=uniforms.vBaseColor.rgb; +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +base_color*=fragmentInputs.vColor.rgb; +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=fragmentInputs.vColor.a; +#endif +base_color*=vec3(uniforms.vBaseWeight);alpha=uniforms.vBaseColor.a;base_metalness=uniforms.vReflectanceInfo.x;base_diffuse_roughness=uniforms.vBaseDiffuseRoughness;specular_roughness=uniforms.vReflectanceInfo.y;specular_color=uniforms.vSpecularColor.rgb;specular_weight=uniforms.vReflectanceInfo.a;specular_ior=uniforms.vReflectanceInfo.z;specular_roughness_anisotropy=uniforms.vSpecularAnisotropy.b;geometry_tangent=uniforms.vSpecularAnisotropy.rg;geometry_thickness=uniforms.vGeometryThickness; +#ifdef BASE_COLOR +#ifdef BASE_COLOR_GAMMA +base_color*=toLinearSpace(baseColorFromTexture.rgb); +#else +base_color*=baseColorFromTexture.rgb; +#endif +base_color*=uniforms.vBaseColorInfos.y; +#endif +#ifdef BASE_WEIGHT +base_color*=baseWeightFromTexture.r; +#endif +#if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE) +alpha*=baseColorFromTexture.a; +#elif defined(GEOMETRY_OPACITY) +alpha*=opacityFromTexture.a;alpha*=uniforms.vGeometryOpacityInfos.y; +#endif +#ifdef GEOMETRY_THICKNESS +#ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL +geometry_thickness*=thicknessFromTexture.g; +#else +geometry_thickness*=thicknessFromTexture.r; +#endif +geometry_thickness*=uniforms.vGeometryThicknessInfos.y; +#endif +#ifdef ALPHATEST +#if DEBUGMODE != 88 +if (alpha{w();T1="openpbrCoatLayerData",v6=`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 +#ifdef COAT_COLOR +var coatColorFromTexture: vec4f=textureSample(coatColorSampler,coatColorSamplerSampler,fragmentInputs.vCoatColorUV+uvOffset); +#endif +#ifdef COAT_ROUGHNESS +var coatRoughnessFromTexture: vec4f=textureSample(coatRoughnessSampler,coatRoughnessSamplerSampler,fragmentInputs.vCoatRoughnessUV+uvOffset); +#endif +#ifdef COAT_ROUGHNESS_ANISOTROPY +var coatRoughnessAnisotropyFromTexture: f32=textureSample(coatRoughnessAnisotropySampler,coatRoughnessAnisotropySamplerSampler,fragmentInputs.vCoatRoughnessAnisotropyUV+uvOffset).r; +#endif +#ifdef COAT_DARKENING +var coatDarkeningFromTexture: vec4f=textureSample(coatDarkeningSampler,coatDarkeningSamplerSampler,fragmentInputs.vCoatDarkeningUV+uvOffset); +#endif +#ifdef GEOMETRY_COAT_TANGENT +var geometryCoatTangentFromTexture: vec3f=textureSample(geometryCoatTangentSampler,geometryCoatTangentSamplerSampler,fragmentInputs.vGeometryCoatTangentUV+uvOffset).rgb; +#endif +coat_color=uniforms.vCoatColor.rgb;coat_weight=uniforms.vCoatWeight;coat_roughness=uniforms.vCoatRoughness;coat_roughness_anisotropy=uniforms.vCoatRoughnessAnisotropy;coat_ior=uniforms.vCoatIor;coat_darkening=uniforms.vCoatDarkening;geometry_coat_tangent=uniforms.vGeometryCoatTangent.rg; +#ifdef COAT_WEIGHT +coat_weight*=coatWeightFromTexture.r; +#endif +#ifdef COAT_COLOR +#ifdef COAT_COLOR_GAMMA +coat_color*=toLinearSpace(coatColorFromTexture.rgb); +#else +coat_color*=coatColorFromTexture.rgb; +#endif +coat_color*=uniforms.vCoatColorInfos.y; +#endif +#ifdef COAT_ROUGHNESS +#ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL +coat_roughness*=coatRoughnessFromTexture.g; +#else +coat_roughness*=coatRoughnessFromTexture.r; +#endif +#endif +#if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE) +coat_roughness_anisotropy*=geometryCoatTangentFromTexture.b; +#elif defined(COAT_ROUGHNESS_ANISOTROPY) +coat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture; +#endif +#ifdef COAT_DARKENING +coat_darkening*=coatDarkeningFromTexture.r; +#endif +#ifdef GEOMETRY_COAT_TANGENT +{let tangentFromTexture: vec2f=normalize(geometryCoatTangentFromTexture.xy*vec2f(2.0f)-vec2f(1.0f));let tangent_angle_texture: f32=atan2(tangentFromTexture.y,tangentFromTexture.x);let tangent_angle_uniform: f32=atan2(geometry_coat_tangent.y,geometry_coat_tangent.x);let tangent_angle: f32=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2f(cos(tangent_angle),sin(tangent_angle));} +#endif +#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[T1]||(E.IncludesShadersStoreWGSL[T1]=v6)});var R1,S6,x1=C(()=>{w();R1="openpbrThinFilmLayerData",S6=`#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 +var thinFilmWeightFromTexture: f32=textureSample(thinFilmWeightSampler,thinFilmWeightSamplerSampler,fragmentInputs.vThinFilmWeightUV+uvOffset).r*uniforms.vThinFilmWeightInfos.y; +#endif +#ifdef THIN_FILM_THICKNESS +var thinFilmThicknessFromTexture: f32=textureSample(thinFilmThicknessSampler,thinFilmThicknessSamplerSampler,fragmentInputs.vThinFilmThicknessUV+uvOffset).g*uniforms.vThinFilmThicknessInfos.y; +#endif +#ifdef THIN_FILM_WEIGHT +thin_film_weight*=thinFilmWeightFromTexture; +#endif +#ifdef THIN_FILM_THICKNESS +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[R1]||(E.IncludesShadersStoreWGSL[R1]=S6)});var I1,T6,C1=C(()=>{w();I1="openpbrFuzzLayerData",T6=`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); +#endif +#ifdef FUZZ_COLOR +var fuzzColorFromTexture: vec4f=textureSample(fuzzColorSampler,fuzzColorSamplerSampler,fragmentInputs.vFuzzColorUV+uvOffset); +#endif +#ifdef FUZZ_ROUGHNESS +let fuzzRoughnessFromTexture: vec4f=textureSample(fuzzRoughnessSampler,fuzzRoughnessSamplerSampler,fragmentInputs.vFuzzRoughnessUV+uvOffset); +#endif +fuzz_color=uniforms.vFuzzColor.rgb;fuzz_weight=uniforms.vFuzzWeight;fuzz_roughness=uniforms.vFuzzRoughness; +#ifdef FUZZ_WEIGHT +fuzz_weight*=fuzzWeightFromTexture.r; +#endif +#ifdef FUZZ_COLOR +#ifdef FUZZ_COLOR_GAMMA +fuzz_color*=toLinearSpace(fuzzColorFromTexture.rgb); +#else +fuzz_color*=fuzzColorFromTexture.rgb; +#endif +fuzz_color*=uniforms.vFuzzColorInfos.y; +#endif +#if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA) +fuzz_roughness*=fuzzRoughnessFromTexture.a; +#elif defined(FUZZ_ROUGHNESS) +fuzz_roughness*=fuzzRoughnessFromTexture.r; +#endif +#endif +`;E.IncludesShadersStoreWGSL[I1]||(E.IncludesShadersStoreWGSL[I1]=T6)});var b1,A6,M1=C(()=>{w();b1="openpbrAmbientOcclusionData",A6=`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[b1]||(E.IncludesShadersStoreWGSL[b1]=A6)});var y1,R6,D1=C(()=>{w();y1="openpbrBackgroundTransmission",R6=`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 +{ +#ifdef REFRACTION_HIGH_QUALITY_BLUR +{var dispResult: vec3f=vec3f(0.0);var dispWeight: vec3f=vec3f(0.0);let noiseOffset: vec2f=noise.xy*select(0.0f,lodTexelSize,refractionLOD>0.0f);for (var k: i32=0; k<6; k++) {let t: f32=(f32(k)+noise.y)/6.0f;let t_rg: f32=clamp(t*2.0f,0.0f,1.0f);let t_gb: f32=clamp((t-0.5f)*2.0f,0.0f,1.0f);let refVec: vec3f=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);let uvw: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refVec*geometry_thickness,1.0f))).xyz);var coords: vec2f=uvw.xy/uvw.z;coords.y=1.0f-coords.y;let s: vec4f=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords+noiseOffset,refractionLOD);let rw: f32=max(0.0f,1.0f-2.0f*t);let gw: f32=max(0.0f,1.0f-abs(2.0f*t-1.0f));let bw: f32=max(0.0f,2.0f*t-1.0f);let w: vec3f=vec3f(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;} +slab_translucent_background=vec4f(dispResult/max(dispWeight,vec3f(1e-6)),1.0f);} +#else +for (var i: i32=0; i<3; i++) {let refractedViewVector: vec3f=refractedViewVectors[i];let uvw: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var coords: vec2f=uvw.xy/uvw.z;coords.y=1.0f-coords.y;if (refractionLOD>0.0f) {let noiseOffset: vec2f=noise.xy*lodTexelSize;slab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,coords,0.0f)[i];}} +#endif +} +#else +{let refractionUVW: vec3f=vec3f((uniforms.backgroundRefractionMatrix*(scene.view*vec4f(fragmentInputs.vPositionW+refractedViewVector*geometry_thickness,1.0f))).xyz);var refractionCoords: vec2f=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0f-refractionCoords.y;if (refractionLOD>0.0f) { +#ifdef REFRACTION_HIGH_QUALITY_BLUR +let cosA: f32=cos(noise.x*PI);let sinA: f32=sin(noise.x*PI);let u: vec2f=vec2f( cosA,sinA)*(0.5f*lodTexelSize);let v: vec2f=vec2f(-sinA,cosA)*(0.5f*lodTexelSize);slab_translucent_background=0.25f*( +textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+u+v,refractionLOD) + +textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords-u+v,refractionLOD) + +textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+u-v,refractionLOD) + +textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords-u-v,refractionLOD) +); +#else +let noiseOffset: vec2f=noise.xy*lodTexelSize;slab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords+noiseOffset,refractionLOD); +#endif +} else {slab_translucent_background=textureSampleLevel(backgroundRefractionSampler,backgroundRefractionSamplerSampler,refractionCoords,0.0f);}} +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[y1]||(E.IncludesShadersStoreWGSL[y1]=R6)});var P1,x6,L1=C(()=>{w();P1="openpbrEnvironmentLighting",x6=`#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 +#ifdef FUZZ +let environmentFuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness)); +#endif +var baseDiffuseEnvironmentLight: vec3f=sampleIrradiance( +normalW +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,uniforms.reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +,irradianceSamplerSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,uniforms.vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +#endif +,uniforms.vReflectionInfos +,viewDirectionW +,base_diffuse_roughness +,base_color +); +#ifdef REFLECTIONMAP_3D +var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f); +#else +var reflectionCoords: vec2f=vec2f(0.f,0.f); +#endif +let specularAlphaG: f32=specular_roughness*specular_roughness; +#ifdef ANISOTROPIC_BASE +var baseSpecularEnvironmentLight: vec3f=sampleRadianceAnisotropic(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,baseGeoInfo +,normalW +,viewDirectionW +,fragmentInputs.vPositionW +,noise +,false +,1.0 +,reflectionSampler +,reflectionSamplerSampler +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#else +reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,normalW);var baseSpecularEnvironmentLight: vec3f=sampleRadiance(specularAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,baseGeoInfo +,reflectionSampler +,reflectionSamplerSampler +,reflectionCoords +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#endif +#ifdef ANISOTROPIC_BASE +baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG *max(1.0f-baseGeoInfo.anisotropy,0.3f)); +#else +baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG); +#endif +var coatEnvironmentLight: vec3f=vec3f(0.f,0.f,0.f);if (coat_weight>0.0) { +#ifdef REFLECTIONMAP_3D +var reflectionCoords: vec3f=vec3f(0.f,0.f,0.f); +#else +var reflectionCoords: vec2f=vec2f(0.f,0.f); +#endif +reflectionCoords=createReflectionCoords(fragmentInputs.vPositionW,coatNormalW);var coatAlphaG: f32=coat_roughness*coat_roughness; +#ifdef ANISOTROPIC_COAT +coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,coatGeoInfo +,coatNormalW +,viewDirectionW +,fragmentInputs.vPositionW +,noise +,false +,1.0 +,reflectionSampler +,reflectionSamplerSampler +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#else +coatEnvironmentLight=sampleRadiance(coatAlphaG,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,coatGeoInfo +,reflectionSampler +,reflectionSamplerSampler +,reflectionCoords +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#endif +} +#ifdef FUZZ +let modifiedFuzzRoughness: f32=clamp(fuzz_roughness*(1.0f-0.5f*environmentFuzzBrdf.y),0.0f,1.0f);var fuzzEnvironmentLight=vec3f(0.0f,0.0f,0.0f);var totalWeight=0.0f;let fuzzIblFresnel: f32=sqrt(environmentFuzzBrdf.z);for (var i: i32=0; i0.0) {slab_coat_ibl=coatEnvironmentLight*uniforms.vLightingIntensity.z; +#ifdef AMBIENT_OCCLUSION +coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness); +#endif +} +#ifdef FUZZ +var slab_fuzz_ibl=fuzzEnvironmentLight*uniforms.vLightingIntensity.z; +#endif +var slab_translucent_base_ibl: vec3f=vec3f(0.0f,0.0f,0.0f); +#ifdef REFRACTED_ENVIRONMENT +#ifdef ANISOTROPIC_BASE +var forwardScatteredEnvironmentLight: vec3f=sampleRadianceAnisotropic(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,baseGeoInfo +#ifdef GEOMETRY_THIN_WALLED +,viewDirectionW +#else +,normalW +#endif +,viewDirectionW +,fragmentInputs.vPositionW +,noise +,true +#ifdef GEOMETRY_THIN_WALLED +,1.05f +#else +,specular_ior +#endif +,reflectionSampler +,reflectionSamplerSampler +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#else +var forwardScatteredEnvironmentLight: vec3f=vec3f(0.,0.,0.); +#ifdef DISPERSION +for (var i: i32=0; i<3; i++) {var iblRefractionCoords: vec3f=refractedViewVectors[i]; +#else +var iblRefractionCoords: vec3f=refractedViewVector; +#endif +#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ +iblRefractionCoords.z*=-1.0f; +#endif +#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE +iblRefractionCoords=parallaxCorrectNormal(fragmentInputs.vPositionW,refractedViewVector,uniforms.refractionSize,uniforms.refractionPosition); +#endif +iblRefractionCoords=(uniforms.reflectionMatrix*vec4f(iblRefractionCoords,0.0f)).xyz; +#ifdef DISPERSION +forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,baseGeoInfo +,reflectionSampler +,reflectionSamplerSampler +,iblRefractionCoords +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +)[i]; +#else +forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,uniforms.vReflectionMicrosurfaceInfos.rgb,uniforms.vReflectionInfos +,baseGeoInfo +,reflectionSampler +,reflectionSamplerSampler +,iblRefractionCoords +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +); +#endif +#ifdef DISPERSION +} +#endif +#endif +#ifdef REFRACTED_BACKGROUND +#ifdef GEOMETRY_THIN_WALLED +forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha); +#else +forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha)); +#endif +#endif +#ifdef SCATTERING +#ifdef GEOMETRY_THIN_WALLED +var scatterVector: vec3f=normalW; +#else +#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION) +var scatterVector: vec3f=mix(uniforms.vReflectionDominantDirection,normalW,max3(iso_scatter_density)); +#else +var scatterVector: vec3f=normalW; +#endif +scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend); +#endif +#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED) +var scatteredEnvironmentLight: vec3f=scattered_light_from_irradiance_texture; +#else +var scatteredEnvironmentLight: vec3f=sampleIrradiance( +scatterVector +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,uniforms.reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +,irradianceSamplerSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,uniforms.vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +#endif +,uniforms.vReflectionInfos +,viewDirectionW +#if defined(GEOMETRY_THIN_WALLED) +,base_diffuse_roughness +,subsurface_color.rgb +#else +,1.0f +,volumeParams.multi_scatter_color +#endif +); +#endif +#ifdef GEOMETRY_THIN_WALLED +let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy); +#else +let forward_scattered_light: vec3f=forwardScatteredEnvironmentLight*volume_absorption;let back_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);let iso_scattered_light: vec3f=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#endif +#else +slab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption; +#endif +#endif +#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION +slab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;let material_dielectric_base_ibl: vec3f=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);let material_dielectric_gloss_ibl: vec3f=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;let material_base_substrate_ibl: vec3f=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);let material_coated_base_ibl: vec3f=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3f(1.0f)); +#ifdef FUZZ +slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3f(1.0f),fuzz_color); +#else +material_surface_ibl=material_coated_base_ibl; +#endif +#elif defined(REFRACTED_BACKGROUND) +let black=vec3f(0.0f);var slab_translucent_base_ibl: vec3f=vec3f(0.0f); +#ifdef GEOMETRY_THIN_WALLED +#ifdef SCATTERING +let forward_scattered_light: vec3f=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy); +#else +slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint; +#endif +#else +#ifdef SCATTERING +let forward_scattered_light: vec3f=slab_translucent_background.rgb*volume_absorption;let iso_scattered_light: vec3f=(1.0f-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#else +slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint; +#endif +#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[P1]||(E.IncludesShadersStoreWGSL[P1]=x6)});var O1,I6,N1=C(()=>{w();O1="openpbrDirectLightingInit",I6=`#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 +#define CUSTOM_LIGHT{X}_COLOR +#ifdef SPOTLIGHT{X} +preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW); +#elif defined(POINTLIGHT{X}) +preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,fragmentInputs.vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,fragmentInputs.vPositionW); +#elif defined(HEMILIGHT{X}) +preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW); +#elif defined(DIRLIGHT{X}) +preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,fragmentInputs.vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness); +#endif +preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV; +#ifdef SPOTLIGHT{X} +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w); +#endif +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w); +#endif +#else +preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#endif +#elif defined(POINTLIGHT{X}) +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x); +#else +preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#endif +#else +preInfo{X}.attenuation=1.0f; +#endif +preInfoCoat{X}.attenuation=preInfo{X}.attenuation; +#if defined(HEMILIGHT{X}) +preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness; +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness; +#else +preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance); +#endif +preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb; +#endif +#endif +`;E.IncludesShadersStoreWGSL[O1]||(E.IncludesShadersStoreWGSL[O1]=I6)});var F1,C6,w1=C(()=>{w();F1="openpbrDirectLighting",C6=`#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); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb); +#else +slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb); +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},fragmentInputs.vPositionW); +#endif +#ifdef FUZZ +let fuzzNdotH: f32=max(dot(fuzzNormalW,preInfo{X}.H),0.0f);let fuzzBrdf: vec3f=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness)); +#endif +#ifdef THIN_FILM +let thin_film_desaturation_scale: f32=(thin_film_ior-1.0f)*sqrt(thin_film_thickness*0.001f); +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90); +#else +{ +#ifdef ANISOTROPIC_BASE +slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW, +baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy, +0.0f,lightColor{X}.rgb); +#else +slab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb); +#endif +specularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color; +#ifdef THIN_FILM +var thinFilmDielectricFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3f(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3f(dot(thinFilmDielectricFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale); +#endif +} +#endif +#ifdef REFRACTED_LIGHTS +var forwardScatteredLight: vec3f=vec3f(0.0f); +#if AREALIGHT{X} +#else +{var preInfoTrans=preInfo{X}; +#ifdef SCATTERING +preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05f))); +#else +preInfoTrans.roughness=transmission_roughness; +#endif +if (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;} +#ifdef GEOMETRY_THIN_WALLED +let refractNormalW: vec3f=viewDirectionW; +#else +let refractNormalW: vec3f=normalW; +#endif +preInfoTrans.NdotL=0.5f*max(dot(-refractNormalW,preInfoTrans.L),0.0f)+0.5f; +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +var dispersion_iors_local: vec3f=dispersion_iors;let diff: f32=min(dispersion_iors_local[2]-dispersion_iors_local[0],max(dispersion_iors_local[0]-1.0f,1.0f));dispersion_iors_local[2]+=diff;dispersion_iors_local[0]-=diff;for (var i: i32=0; i<3; i++) {let eta: f32=1.0f/dispersion_iors_local[i]; +#elif defined(GEOMETRY_THIN_WALLED) +let eta: f32=1.0f; +#else +let eta: f32=1.0f/specular_ior; +#endif +preInfoTrans.H=preInfoTrans.L+min(eta,0.95f)*viewDirectionW;let len2: f32=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6f) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inverseSqrt(len2);} +#ifdef ANISOTROPIC_BASE +preInfoTrans.H=-preInfoTrans.H; +#endif +preInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H); +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +forwardScatteredLight[i]+= +#else +forwardScatteredLight+= +#endif +#if defined(ANISOTROPIC_BASE) +computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW, +baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy, +transmission_roughness_alpha,lightColor{X}.rgb +#else +computeSpecularLighting(preInfoTrans,-refractNormalW,vec3f(1.0f),vec3f(1.0f),transmission_roughness_alpha,lightColor{X}.rgb +#endif +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +)[i];} +#else +); +#endif +#if !defined(GEOMETRY_THIN_WALLED) +forwardScatteredLight=mix(forwardScatteredLight,0.25f*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0f-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0f,1.0f)); +#endif +#ifdef REFRACTED_BACKGROUND +#ifdef GEOMETRY_THIN_WALLED +forwardScatteredLight=mix(vec3f(0.0f),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha); +#else +forwardScatteredLight=max(vec3f(0.0f),mix(vec3f(0.0f),forwardScatteredLight,transmission_roughness_alpha)); +#endif +#endif +#ifdef SCATTERING +#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER) +preInfoTrans.roughness=1.0f;let diffused_forward_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,normalW,vec3f(1.0f),vec3f(1.0f),1.0f,lightColor{X}.rgb)*volume_absorption; +#endif +#ifdef GEOMETRY_THIN_WALLED +let forward_scattered_light: vec3f=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;let back_scattered_light: vec3f=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5f+0.5f*volumeParams.anisotropy); +#else +let back_scattered_normal: vec3f=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0f);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0f,1.0f);preInfoTrans.roughness=0.2f;let back_scattered_light: vec3f=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3f(1.0f),vec3f(0.08f),0.0f,lightColor{X}.rgb);let forward_scattered_light: vec3f=(forwardScatteredLight*volume_absorption);let iso_scattered_light: vec3f=slab_diffuse;let back_scattering: vec3f=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density); +#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER) +let iso_scattering: vec3f=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density); +#else +let iso_scattering: vec3f=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density); +#endif +slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#endif +#else +slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption; +#endif +} +#endif +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90); +#else +{ +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +var coloredFresnel: vec3f=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness); +#else +var coloredFresnel: vec3f=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90); +#endif +#ifdef THIN_FILM +let thinFilmConductorAngle: f32=max(preInfo{X}.VdotH,specular_roughness);var thinFilmConductorFresnel: vec3f=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3f(dot(thinFilmConductorFresnel,vec3f(0.3333f))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale); +#endif +#ifdef ANISOTROPIC_BASE +slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb); +#else +slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3f(baseConductorReflectance.coloredF0),coloredFresnel,specular_roughness,lightColor{X}.rgb); +#endif +} +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90); +#else +{ +#ifdef ANISOTROPIC_COAT +slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW, +coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,0.0, +lightColor{X}.rgb); +#else +slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3f(coatReflectance.F0),vec3f(1.0f),coat_roughness,lightColor{X}.rgb); +#endif +let NdotH: f32=saturateEps(dot(coatNormalW,preInfoCoat{X}.H));coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);} +#endif +var coatAbsorption=vec3f(1.0f);if (coat_weight>0.0) {let cosTheta_view: f32=max(preInfoCoat{X}.NdotV,0.001f);let cosTheta_light: f32=max(preInfoCoat{X}.NdotL,0.001f);let fresnel_view: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_view,5.0);let fresnel_light: f32=coatReflectance.F0+(1.0f-coatReflectance.F0)*pow(1.0f-cosTheta_light,5.0);let averageReflectance: f32=(fresnel_view+fresnel_light)*0.5;var darkened_transmission: f32=(1.0f-averageReflectance)/(1.0f+averageReflectance);darkened_transmission=mix(1.0f,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*vec3f(darkened_transmission),coat_weight);} +#ifdef FUZZ +fuzzFresnel=fuzzBrdf.z;let fuzzNormalW=mix(normalW,coatNormalW,coat_weight);let fuzzNdotV: f32=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0f);let fuzzNdotL: f32=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf); +#else +let fuzz_color=vec3f(0.0); +#endif +#ifdef PREPASS_IRRADIANCE +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[F1]||(E.IncludesShadersStoreWGSL[F1]=C6)});var B1,b6,DA=C(()=>{w();B1="pbrBlockImageProcessing",b6=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) +#if !defined(SKIPFINALCOLORCLAMP) +finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a); +#endif +#else +finalColor=applyImageProcessing(finalColor); +#endif +finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility); +#ifdef PREMULTIPLYALPHA +finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);; +#endif +`;E.IncludesShadersStoreWGSL[B1]||(E.IncludesShadersStoreWGSL[B1]=b6)});var U1,M6,V1=C(()=>{w();U1="openpbrBlockPrePass",M6=`#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); +#endif +#ifdef PREPASS_LOCAL_POSITION +fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo); +#endif +#ifdef PREPASS_VELOCITY +var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) - +(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +fragData[PREPASS_ALBEDO_INDEX]=vec4f(surfaceAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +var sqAlbedo : vec3f=sqrt(surfaceAlbedo); +#endif +#ifdef PREPASS_IRRADIANCE +var irradiance : vec3f=total_direct_diffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=slab_diffuse_ibl; +#endif +#endif +#ifdef SCATTERING +let scatter_mask: f32=min(subsurface_weight+transmission_weight,1.0); +#else +let scatter_mask: f32=0.0; +#endif +fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(irradiance,writeGeometryInfo*scatter_mask); +#elif defined(PREPASS_COLOR) +fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb,finalColor.a); +#endif +#ifdef PREPASS_DEPTH +fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo); +#else +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#ifndef UNLIT +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo; +#else +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo; +#endif +#endif +#if SCENE_MRT_COUNT>0 +fragmentOutputs.fragData0=fragData[0]; +#endif +#if SCENE_MRT_COUNT>1 +fragmentOutputs.fragData1=fragData[1]; +#endif +#if SCENE_MRT_COUNT>2 +fragmentOutputs.fragData2=fragData[2]; +#endif +#if SCENE_MRT_COUNT>3 +fragmentOutputs.fragData3=fragData[3]; +#endif +#if SCENE_MRT_COUNT>4 +fragmentOutputs.fragData4=fragData[4]; +#endif +#if SCENE_MRT_COUNT>5 +fragmentOutputs.fragData5=fragData[5]; +#endif +#if SCENE_MRT_COUNT>6 +fragmentOutputs.fragData6=fragData[6]; +#endif +#if SCENE_MRT_COUNT>7 +fragmentOutputs.fragData7=fragData[7]; +#endif +#endif +`;E.IncludesShadersStoreWGSL[U1]||(E.IncludesShadersStoreWGSL[U1]=M6)});var G1,y6,PA=C(()=>{w();G1="pbrDebug",y6=`#if DEBUGMODE>0 +if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f; +#if DEBUGMODE==1 +color=fragmentInputs.vPositionW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==2 && defined(NORMAL) +color=fragmentInputs.vNormalW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC) +color=TBN[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC) +color=TBN[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==5 +color=normalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==6 && defined(MAINUV1) +color= vec3f(input.vMainUV1,0.0); +#elif DEBUGMODE==7 && defined(MAINUV2) +color= vec3f(input.vMainUV2,0.0); +#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) +color=clearcoatOut.TBNClearCoat[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) +color=clearcoatOut.TBNClearCoat[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==10 && defined(CLEARCOAT) +color=clearcoatOut.clearCoatNormalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==11 && defined(ANISOTROPIC) +color=anisotropicOut.anisotropicNormal; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==12 && defined(ANISOTROPIC) +color=anisotropicOut.anisotropicTangent; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==13 && defined(ANISOTROPIC) +color=anisotropicOut.anisotropicBitangent; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==20 && defined(ALBEDO) +color=albedoTexture.rgb; +#ifndef GAMMAALBEDO +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==21 && defined(AMBIENT) +color=aoOut.ambientOcclusionColorMap.rgb; +#elif DEBUGMODE==22 && defined(OPACITY) +color=opacityMap.rgb; +#elif DEBUGMODE==23 && defined(EMISSIVE) +color=emissiveColorTex.rgb; +#ifndef GAMMAEMISSIVE +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==24 && defined(LIGHTMAP) +color=lightmapColor; +#ifndef GAMMALIGHTMAP +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW) +color=reflectivityOut.surfaceMetallicColorMap.rgb; +#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW) +color=reflectivityOut.surfaceReflectivityColorMap.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE) +color= vec3f(clearcoatOut.clearCoatMapData.rg,0.0); +#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +color=clearcoatOut.clearCoatTintMapData.rgb; +#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE) +color=sheenOut.sheenMapData.rgb; +#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE) +color=anisotropicOut.anisotropyMapData.rgb; +#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE) +color=subSurfaceOut.thicknessMap.rgb; +#elif DEBUGMODE==32 && defined(BUMP) +color=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).rgb; +#elif DEBUGMODE==40 && defined(SS_REFRACTION) +color=subSurfaceOut.environmentRefraction.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==41 && defined(REFLECTION) +color=reflectionOut.environmentRadiance.rgb; +#ifndef GAMMAREFLECTION +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION) +color=clearcoatOut.environmentClearCoatRadiance.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==50 +color=diffuseBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==51 && defined(SPECULARTERM) +color=specularBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==52 && defined(CLEARCOAT) +color=clearCoatBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==53 && defined(SHEEN) +color=sheenBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==54 && defined(REFLECTION) +color=reflectionOut.environmentIrradiance.rgb; +#ifndef GAMMAREFLECTION +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==60 +color=surfaceAlbedo.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==61 +color=clearcoatOut.specularEnvironmentR0; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==62 && defined(METALLICWORKFLOW) +color= vec3f(reflectivityOut.metallic); +#elif DEBUGMODE==71 && defined(METALLICWORKFLOW) +color=reflectivityOut.metallicF0; +#elif DEBUGMODE==63 +color= vec3f(roughness); +#elif DEBUGMODE==64 +color= vec3f(alphaG); +#elif DEBUGMODE==65 +color= vec3f(NdotV); +#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +color=clearcoatOut.clearCoatColor; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==67 && defined(CLEARCOAT) +color= vec3f(clearcoatOut.clearCoatRoughness); +#elif DEBUGMODE==68 && defined(CLEARCOAT) +color= vec3f(clearcoatOut.clearCoatNdotV); +#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY) +color=subSurfaceOut.transmittance; +#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION) +color=subSurfaceOut.refractionTransmittance; +#elif DEBUGMODE==72 +color= vec3f(microSurface); +#elif DEBUGMODE==73 +color=uniforms.vAlbedoColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW) +color=uniforms.vReflectivityColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==75 +color=uniforms.vEmissiveColor; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION) +color= vec3f(seo); +#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +color= vec3f(eho); +#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION) +color= vec3f(energyConservationFactor); +#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +color=baseSpecularEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +color=clearcoatOut.clearCoatEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION) +color=sheenOut.sheenEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==86 && defined(ALPHABLEND) +color= vec3f(luminanceOverAlpha); +#elif DEBUGMODE==87 +color= vec3f(alpha); +#elif DEBUGMODE==88 && defined(ALBEDO) +color= vec3f(albedoTexture.a); +#elif DEBUGMODE==89 +color=aoOut.ambientOcclusionColor; +#else +var stripeWidth: f32=30.;var stripePos: f32=abs(floor(input.position.x/stripeWidth));var whichColor: f32=((stripePos)%(2.));var color1: vec3f= vec3f(.6,.2,.2);var color2: vec3f= vec3f(.3,.1,.1);color=mix(color1,color2,whichColor); +#endif +color*=uniforms.vDebugMode.y; +#ifdef DEBUGMODE_NORMALIZE +color=normalize(color)*0.5+0.5; +#endif +#ifdef DEBUGMODE_GAMMA +color=toGammaSpaceVec3(color); +#endif +fragmentOutputs.color=vec4f(color,1.0); +#ifdef PREPASS +fragmentOutputs.fragData0=toLinearSpaceVec3(color); +fragmentOutputs.fragData1=vec4f(0.,0.,0.,0.); +#endif +#ifdef DEBUGMODE_FORCERETURN +return fragmentOutputs; +#endif +} +#endif +`;E.IncludesShadersStoreWGSL[G1]||(E.IncludesShadersStoreWGSL[G1]=y6)});var W1={};Ie(W1,{openpbrPixelShaderWGSL:()=>D6});var LA,k1,D6,H1=C(()=>{w();Nm();Fm();EA();SA();wm();Zw();Um();pn();_a();Yc();Lr();TA();AA();RA();Vm();Bm();Ef();xA();IA();vf();CA();MA();Kp();n1();o1();Nh();hA();c1();h1();dA();uA();u1();_n();yA();_1();E1();S1();pA();mA();A1();x1();C1();M1();Hm();D1();L1();N1();w1();Fh();Kc();DA();V1();zm();PA();LA="openpbrPixelShader",k1=`#define OPENPBR_FRAGMENT_SHADER +#define CUSTOM_FRAGMENT_BEGIN +#include[SCENE_MRT_COUNT] +#include +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE +#endif +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REFLECTION +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +#include +#include +#include +#include +#include +fn layer(slab_bottom: vec3f,slab_top: vec3f,lerp_factor: f32,bottom_multiplier: vec3f,top_multiplier: vec3f)->vec3f {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);} +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#ifdef PREPASS_IRRADIANCE +var total_direct_diffuse: vec3f=vec3f(0.0f); +#endif +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#include +var coatNormalW: vec3f=normalW; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define CUSTOM_FRAGMENT_UPDATE_ALPHA +#include +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +#ifdef ANISOTROPIC_COAT +let coatGeoInfo: geometryInfoAnisoOutParams=geometryInfoAniso( +coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW +,vec3f(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN +); +#else +let coatGeoInfo: geometryInfoOutParams=geometryInfo( +coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW +); +#endif +specular_roughness=mix(specular_roughness,pow(min(1.0f,pow(specular_roughness,4.0f)+2.0f*pow(coat_roughness,4.0f)),0.25f),coat_weight); +#ifdef ANISOTROPIC_BASE +let baseGeoInfo: geometryInfoAnisoOutParams=geometryInfoAniso( +normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW +,vec3f(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN +); +#else +let baseGeoInfo: geometryInfoOutParams=geometryInfo( +normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW +); +#endif +#ifdef FUZZ +let fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));var fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);let fuzzBitangent=cross(fuzzNormalW,fuzzTangent);let fuzzGeoInfo: geometryInfoOutParams=geometryInfo( +fuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW +); +#endif +let coatReflectance: ReflectanceParams=dielectricReflectance( +coat_ior +,1.0f +,vec3f(1.0f) +,coat_weight +); +#ifdef THIN_FILM +let thin_film_outside_ior: f32=mix(1.0f,coat_ior,coat_weight); +#endif +let baseDielectricReflectance: ReflectanceParams=dielectricReflectance( +specular_ior +,mix(1.0f,coat_ior,coat_weight) +,specular_color +,specular_weight +);let baseConductorReflectance: ReflectanceParams=conductorReflectance(base_color,specular_color,specular_weight);var volume_absorption: vec3f=vec3f(1.0f);var transmission_tint: vec3f=vec3f(1.0f);var surface_translucency_weight: f32=0.0f; +#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS) +#if defined(GEOMETRY_THIN_WALLED) +let refractedViewVector: vec3f=-viewDirectionW; +#else +#ifdef DISPERSION +var refractedViewVectors: array;let iorDispersionSpread: f32=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0f);let dispersion_iors: vec3f=vec3f(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (var i: i32=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); } +#else +let refractedViewVector: vec3f=double_refract(-viewDirectionW,normalW,specular_ior); +#endif +#endif +#ifdef GEOMETRY_THIN_WALLED +var transmission_roughness: f32=specular_roughness; +#else +var transmission_roughness: f32=specular_roughness*clamp(4.0f*(specular_ior-1.0f),0.001f,1.0f); +#endif +#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB)) +var volumeParams: OpenPBRHomogeneousVolume;{ +#if defined(TRANSMISSION_SLAB) +let transmissionVolumeParams: OpenPBRHomogeneousVolume=computeOpenPBRTransmissionVolume( +transmission_color.rgb, +transmission_depth, +transmission_scatter.rgb, +transmission_scatter_anisotropy +); +#endif +#if defined(SUBSURFACE_SLAB) +let subsurfaceVolumeParams: OpenPBRHomogeneousVolume=computeOpenPBRSubsurfaceVolume( +subsurface_color.rgb, +subsurface_radius, +subsurface_radius_scale.rgb, +subsurface_scatter_anisotropy +); +#endif +#if !defined(TRANSMISSION_SLAB) +volumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight; +#elif !defined(SUBSURFACE_SLAB) +volumeParams=transmissionVolumeParams; +#ifdef TRANSMISSION_SLAB_VOLUME +volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo); +#endif +surface_translucency_weight=transmission_weight; +#else +let subsurface_fraction_of_dielectric: f32=(1.0f-transmission_weight)*subsurface_weight;let subsurface_and_transmission_fraction_of_dielectric: f32=subsurface_fraction_of_dielectric+transmission_weight;let reciprocal_of_subsurface_and_transmission_fraction_of_dielectric: f32 = +1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);let trans_weight: f32=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;let subsurf_weight: f32=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEpsVec3(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric; +#endif +} +volume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);var backscatter_color: vec3f=vec3f(1.0f);{let reduced_scatter: vec3f=volumeParams.scatter_coeff*vec3f(1.0f-volumeParams.anisotropy);let reduced_albedo: vec3f=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);let sqrt_term: vec3f=max(sqrt(vec3f(1.0f)-reduced_albedo),vec3f(0.0001f));backscatter_color=(vec3f(1.0f)-sqrt_term)/(vec3f(1.0f)+sqrt_term);} +#elif defined(TRANSMISSION_SLAB) +surface_translucency_weight=transmission_weight; +#endif +#ifdef SCATTERING +#ifdef GEOMETRY_THIN_WALLED +var iso_scatter_density: vec3f=vec3f(1.0f); +#else +#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING +let mfp: vec3f=vec3f(100.0f)/volumeParams.extinction_coeff;var scattered_light_from_irradiance_texture: vec3f=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,uniforms.renderTargetSize,mfp,scene.projection,scene.inverseProjection,SSS_SAMPLE_COUNT,noise.xy);var numLights=f32(LIGHTCOUNT); +#ifdef REFLECTION +numLights+=1.0f; +#endif +scattered_light_from_irradiance_texture/=vec3f(numLights); +#else +let scattered_light_from_irradiance_texture: vec3f=vec3f(0.0f); +#endif +let back_to_iso_scattering_blend: f32=min(1.0f+volumeParams.anisotropy,1.0f);let iso_to_forward_scattering_blend: f32=max(volumeParams.anisotropy,0.0f);let iso_scatter_transmittance: vec3f=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3f(0.2f));var iso_scatter_density: vec3f=clamp(vec3f(1.0f)-iso_scatter_transmittance,vec3f(0.0f),vec3f(1.0f));transmission_roughness=min(transmission_roughness+pow((1.0f-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0f),1.0f); +#endif +volumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density)); +#endif +#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED)) +transmission_tint*=transmission_color.rgb; +#ifdef GEOMETRY_THIN_WALLED +var sin2: f32=1.0f-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);let cos_t: f32=sqrt(1.0f-sin2);let pathLength: f32=1.0f/cos_t;transmission_tint=pow(transmission_tint,vec3f(pathLength)); +#else +transmission_tint*=transmission_color.rgb; +#endif +#endif +#if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED) +let unweighted_translucency: f32=mix(subsurface_weight,1.0f,transmission_weight);transmission_tint=mix(vec3f(1.0f),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0f,transmission_roughness,transmission_weight/unweighted_translucency); +#endif +let transmission_roughness_alpha: f32=transmission_roughness*transmission_roughness; +#endif +#include +var material_surface_ibl: vec3f=vec3f(0.f,0.f,0.f); +#include +var material_surface_direct: vec3f=vec3f(0.f,0.f,0.f); +#if defined(LIGHT0) +var aggShadow: f32=0.f; +#include[0..maxSimultaneousLights] +#include[0..maxSimultaneousLights] +#endif +var material_surface_emission: vec3f=uniforms.vEmissionColor; +#ifdef EMISSION_COLOR +let emissionColorTex: vec3f=textureSample(emissionColorSampler,emissionColorSamplerSampler,uniforms.vEmissionColorUV+uvOffset).rgb; +#ifdef EMISSION_COLOR_GAMMA +material_surface_emission*=toLinearSpace(emissionColorTex.rgb); +#else +material_surface_emission*=emissionColorTex.rgb; +#endif +material_surface_emission*= uniforms.vEmissionColorInfos.y; +#endif +material_surface_emission*=uniforms.vLightingIntensity.y; +#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION +var finalColor: vec4f=vec4f(material_surface_ibl+material_surface_direct+material_surface_emission,alpha); +#define CUSTOM_FRAGMENT_BEFORE_FOG +finalColor=max(finalColor,vec4f(0.0)); +#include +#include(color,finalColor) +#include +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#include +#endif +#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY) +fragmentOutputs.color=finalColor; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;} +#endif +#include +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStoreWGSL[LA]||(E.ShadersStoreWGSL[LA]=k1);D6={name:LA,shader:k1}});var z1,P6,X1=C(()=>{w();zS();Xm();z1="openpbrVertexDeclaration",P6=`#include +#ifdef BASE_COLOR +uniform vec2 vBaseColorInfos;uniform mat4 baseColorMatrix; +#endif +#ifdef BASE_WEIGHT +uniform mat4 baseWeightMatrix;uniform vec2 vBaseWeightInfos; +#endif +uniform float vBaseDiffuseRoughness; +#ifdef BASE_DIFFUSE_ROUGHNESS +uniform mat4 baseDiffuseRoughnessMatrix;uniform vec2 vBaseDiffuseRoughnessInfos; +#endif +#ifdef AMBIENT_OCCLUSION +uniform vec2 vAmbientOcclusionInfos;uniform mat4 ambientOcclusionMatrix; +#endif +#ifdef EMISSION_COLOR +uniform vec2 vEmissionColorInfos;uniform mat4 emissionColorMatrix; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix; +#endif +#ifdef BASE_METALNESS +uniform vec2 vBaseMetalnessInfos;uniform mat4 baseMetalnessMatrix; +#endif +#ifdef SPECULAR_WEIGHT +uniform vec2 vSpecularWeightInfos;uniform mat4 specularWeightMatrix; +#endif +#ifdef SPECULAR_COLOR +uniform vec2 vSpecularColorInfos;uniform mat4 specularColorMatrix; +#endif +#ifdef SPECULAR_ROUGHNESS +uniform vec2 vSpecularRoughnessInfos;uniform mat4 specularRoughnessMatrix; +#endif +#ifdef SPECULAR_ROUGHNESS_ANISOTROPY +uniform vec2 vSpecularRoughnessAnisotropyInfos;uniform mat4 specularRoughnessAnisotropyMatrix; +#endif +#ifdef TRANSMISSION_WEIGHT +uniform vec2 vTransmissionWeightInfos;uniform mat4 transmissionWeightMatrix; +#endif +#ifdef TRANSMISSION_COLOR +uniform vec2 vTransmissionColorInfos;uniform mat4 transmissionColorMatrix; +#endif +#ifdef TRANSMISSION_DEPTH +uniform vec2 vTransmissionDepthInfos;uniform mat4 transmissionDepthMatrix; +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +uniform vec2 vTransmissionDispersionScaleInfos;uniform mat4 transmissionDispersionScaleMatrix; +#endif +#ifdef SUBSURFACE_WEIGHT +uniform vec2 vSubsurfaceWeightInfos;uniform mat4 subsurfaceWeightMatrix; +#endif +#ifdef SUBSURFACE_COLOR +uniform vec2 vSubsurfaceColorInfos;uniform mat4 subsurfaceColorMatrix; +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +uniform vec2 vSubsurfaceRadiusScaleInfos;uniform mat4 subsurfaceRadiusScaleMatrix; +#endif +#ifdef COAT_WEIGHT +uniform vec2 vCoatWeightInfos;uniform mat4 coatWeightMatrix; +#endif +#ifdef COAT_COLOR +uniform vec2 vCoatColorInfos;uniform mat4 coatColorMatrix; +#endif +#ifdef COAT_ROUGHNESS +uniform vec2 vCoatRoughnessInfos;uniform mat4 coatRoughnessMatrix; +#endif +#ifdef COAT_ROUGHNESS_ANISOTROPY +uniform vec2 vCoatRoughnessAnisotropyInfos;uniform mat4 coatRoughnessAnisotropyMatrix; +#endif +#ifdef COAT_IOR +uniform vec2 vCoatIorInfos;uniform mat4 coatIorMatrix; +#endif +#ifdef COAT_DARKENING +uniform vec2 vCoatDarkeningInfos;uniform mat4 coatDarkeningMatrix; +#endif +#ifdef FUZZ_WEIGHT +uniform vec2 vFuzzWeightInfos;uniform mat4 fuzzWeightMatrix; +#endif +#ifdef FUZZ_COLOR +uniform vec2 vFuzzColorInfos;uniform mat4 fuzzColorMatrix; +#endif +#ifdef FUZZ_ROUGHNESS +uniform vec2 vFuzzRoughnessInfos;uniform mat4 fuzzRoughnessMatrix; +#endif +#ifdef GEOMETRY_NORMAL +uniform vec2 vGeometryNormalInfos;uniform mat4 geometryNormalMatrix; +#endif +#ifdef GEOMETRY_TANGENT +uniform vec2 vGeometryTangentInfos;uniform mat4 geometryTangentMatrix; +#endif +#ifdef GEOMETRY_COAT_NORMAL +uniform vec2 vGeometryCoatNormalInfos;uniform mat4 geometryCoatNormalMatrix; +#endif +#ifdef THIN_FILM_WEIGHT +uniform vec2 vThinFilmWeightInfos;uniform mat4 thinFilmWeightMatrix; +#endif +#ifdef THIN_FILM_THICKNESS +uniform vec2 vThinFilmThicknessInfos;uniform mat4 thinFilmThicknessMatrix; +#endif +#ifdef GEOMETRY_OPACITY +uniform mat4 geometryOpacityMatrix;uniform vec2 vGeometryOpacityInfos; +#endif +#ifdef GEOMETRY_THICKNESS +uniform mat4 geometryThicknessMatrix;uniform vec2 vGeometryThicknessInfos; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif +uniform vec4 cameraInfo; +#ifdef REFLECTION +uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix; +#endif +#ifdef NORMAL +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22; +#else +uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX; +#endif +#endif +#endif +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos;uniform mat4 detailMatrix; +#endif +#include +#define ADDITIONAL_VERTEX_DECLARATION +`;E.IncludesShadersStore[z1]||(E.IncludesShadersStore[z1]=P6)});var Y1,L6,OA=C(()=>{w();Io();of();Y1="openpbrUboDeclaration",L6=`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[Y1]||(E.IncludesShadersStore[Y1]=L6)});var K1,O6,j1=C(()=>{w();K1="openpbrNormalMapVertexDeclaration",O6=`#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[K1]||(E.IncludesShadersStore[K1]=O6)});var Z1,N6,q1=C(()=>{w();Z1="openpbrNormalMapVertex",N6=`#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[Z1]||(E.IncludesShadersStore[Z1]=N6)});var J1={};Ie(J1,{openpbrVertexShader:()=>F6});var NA,Q1,F6,$1=C(()=>{w();X1();OA();Ym();lf();Or();_f();fa();ha();Eo();Km();jm();gf();j1();gn();jc();Zm();qm();Co();bo();ga();Mo();yo();da();ua();ma();Qm();Jm();$m();q1();En();Zc();tp();bh();wh();NA="openpbrVertexShader",Q1=`#define OPENPBR_VERTEX_SHADER +#define CUSTOM_VERTEX_EXTENSION +precision highp float; +#include<__decl__openpbrVertex> +#define CUSTOM_VERTEX_BEGIN +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#ifdef TANGENT +attribute vec4 tangent; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#include[2..7] +#include[1..7] +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include +#include +#include +#include +#include +#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness) +#include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy) +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight) +#include(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor) +#include(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth) +#include(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter) +#include(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale) +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight) +#include(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor) +#include(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale) +#include(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight) +#include(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor) +#include(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness) +#include(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy) +#include(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening) +#include(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight) +#include(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor) +#include(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness) +#include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal) +#include(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent) +#include(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal) +#include(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity) +#include(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness) +#include(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor) +#include(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight) +#include(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness) +#include(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +varying vec3 vPositionW; +#if DEBUGMODE>0 +varying vec4 vClipSpacePosition; +#endif +#ifdef NORMAL +varying vec3 vNormalW; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vec3 vEnvironmentIrradiance; +#include +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#include +#include +#include +#include<__decl__lightVxFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +vec3 positionUpdated=position; +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#ifdef TANGENT +vec4 tangentUpdated=tangent; +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#ifdef VERTEXCOLOR +vec4 colorUpdated=color; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos); +#ifdef PREPASS +#include +#endif +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normalUpdated); +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); +#if !defined(NATIVE) && !defined(WEBGPU) +bool bbb=any(isnan(position));if (bbb) { } +#endif +float NdotV=max(dot(vNormalW,viewDirectionW),0.0);vec3 roughNormal=mix(vNormalW,viewDirectionW,(0.5*(1.0-NdotV))*vBaseDiffuseRoughness);vec3 reflectionVector=vec3(reflectionMatrix*vec4(roughNormal,0)).xyz; +#else +vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz; +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} +#else +gl_Position=viewProjection*worldPos; +#endif +#if DEBUGMODE>0 +vClipSpacePosition=gl_Position; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); +#endif +#ifndef UV1 +vec2 uvUpdated=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2Updated=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uvUpdated; +#endif +#ifdef MAINUV2 +vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_MATRIXNAME_,baseColor,_INFONAME_,BaseColorInfos.x) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_MATRIXNAME_,baseWeight,_INFONAME_,BaseWeightInfos.x) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_MATRIXNAME_,baseDiffuseRoughness,_INFONAME_,BaseDiffuseRoughnessInfos.x) +#include(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_MATRIXNAME_,baseMetalness,_INFONAME_,BaseMetalnessInfos.x) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_MATRIXNAME_,specularWeight,_INFONAME_,SpecularWeightInfos.x) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_MATRIXNAME_,specularColor,_INFONAME_,SpecularColorInfos.x) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_MATRIXNAME_,specularRoughness,_INFONAME_,SpecularRoughnessInfos.x) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_MATRIXNAME_,specularRoughnessAnisotropy,_INFONAME_,SpecularRoughnessAnisotropyInfos.x) +#include (_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_MATRIXNAME_,transmissionWeight,_INFONAME_,TransmissionWeightInfos.x) +#include (_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_MATRIXNAME_,transmissionColor,_INFONAME_,TransmissionColorInfos.x) +#include (_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_MATRIXNAME_,transmissionDepth,_INFONAME_,TransmissionDepthInfos.x) +#include (_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_MATRIXNAME_,transmissionScatter,_INFONAME_,TransmissionScatterInfos.x) +#include (_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_MATRIXNAME_,transmissionDispersionScale,_INFONAME_,TransmissionDispersionScaleInfos.x) +#include (_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_MATRIXNAME_,subsurfaceWeight,_INFONAME_,SubsurfaceWeightInfos.x) +#include (_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_MATRIXNAME_,subsurfaceColor,_INFONAME_,SubsurfaceColorInfos.x) +#include (_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_MATRIXNAME_,subsurfaceRadiusScale,_INFONAME_,SubsurfaceRadiusScaleInfos.x) +#include (_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_MATRIXNAME_,coatWeight,_INFONAME_,CoatWeightInfos.x) +#include (_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_MATRIXNAME_,coatColor,_INFONAME_,CoatColorInfos.x) +#include (_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_MATRIXNAME_,coatRoughness,_INFONAME_,CoatRoughnessInfos.x) +#include (_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_MATRIXNAME_,coatRoughnessAnisotropy,_INFONAME_,CoatRoughnessAnisotropyInfos.x) +#include (_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_MATRIXNAME_,coatDarkening,_INFONAME_,CoatDarkeningInfos.x) +#include (_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_MATRIXNAME_,fuzzWeight,_INFONAME_,FuzzWeightInfos.x) +#include (_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_MATRIXNAME_,fuzzColor,_INFONAME_,FuzzColorInfos.x) +#include (_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_MATRIXNAME_,fuzzRoughness,_INFONAME_,FuzzRoughnessInfos.x) +#include (_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_MATRIXNAME_,geometryNormal,_INFONAME_,GeometryNormalInfos.x) +#include (_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_MATRIXNAME_,geometryCoatNormal,_INFONAME_,GeometryCoatNormalInfos.x) +#include (_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_MATRIXNAME_,geometryOpacity,_INFONAME_,GeometryOpacityInfos.x) +#include (_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_MATRIXNAME_,geometryThickness,_INFONAME_,GeometryThicknessInfos.x) +#include (_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_MATRIXNAME_,geometryTangent,_INFONAME_,GeometryTangentInfos.x) +#include (_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_MATRIXNAME_,emissionColor,_INFONAME_,EmissionColorInfos.x) +#include (_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_MATRIXNAME_,thinFilmWeight,_INFONAME_,ThinFilmWeightInfos.x) +#include (_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_MATRIXNAME_,thinFilmThickness,_INFONAME_,ThinFilmThicknessInfos.x) +#include (_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_MATRIXNAME_,ambientOcclusion,_INFONAME_,AmbientOcclusionInfos.x) +#include (_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#include (_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#if defined(POINTSIZE) && !defined(WEBGPU) +gl_PointSize=pointSize; +#endif +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStore[NA]||(E.ShadersStore[NA]=Q1);F6={name:NA,shader:Q1}});var e3,w6,t3=C(()=>{w();eA();ip();e3="openpbrFragmentDeclaration",w6=`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 +#ifdef BASE_WEIGHT +uniform vec2 vBaseWeightInfos; +#endif +#ifdef BASE_METALNESS +uniform vec2 vBaseMetalnessInfos; +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +uniform vec2 vBaseDiffuseRoughnessInfos; +#endif +#ifdef SPECULAR_WEIGHT +uniform vec2 vSpecularWeightInfos; +#endif +#ifdef SPECULAR_COLOR +uniform vec2 vSpecularColorInfos; +#endif +#ifdef SPECULAR_ROUGHNESS +uniform vec2 vSpecularRoughnessInfos; +#endif +#ifdef SPECULAR_ROUGHNESS_ANISOTROPY +uniform vec2 vSpecularRoughnessAnisotropyInfos; +#endif +#ifdef SPECULAR_IOR +uniform vec2 vSpecularIorInfos; +#endif +#ifdef AMBIENT_OCCLUSION +uniform vec2 vAmbientOcclusionInfos; +#endif +#ifdef GEOMETRY_NORMAL +uniform vec2 vGeometryNormalInfos; +#endif +#ifdef GEOMETRY_TANGENT +uniform vec2 vGeometryTangentInfos; +#endif +#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) +uniform vec2 vTangentSpaceParams; +#endif +#ifdef GEOMETRY_COAT_NORMAL +uniform vec2 vGeometryCoatNormalInfos; +#endif +#ifdef GEOMETRY_OPACITY +uniform vec2 vGeometryOpacityInfos; +#endif +#ifdef GEOMETRY_THICKNESS +uniform vec2 vGeometryThicknessInfos; +#endif +#ifdef EMISSION_COLOR +uniform vec2 vEmissionColorInfos; +#endif +#ifdef TRANSMISSION_WEIGHT +uniform vec2 vTransmissionWeightInfos; +#endif +#ifdef TRANSMISSION_COLOR +uniform vec2 vTransmissionColorInfos; +#endif +#ifdef TRANSMISSION_DEPTH +uniform vec2 vTransmissionDepthInfos; +#endif +#ifdef TRANSMISSION_SCATTER +uniform vec2 vTransmissionScatterInfos; +#endif +#ifdef TRANSMISSION_DISPERSION_SCALE +uniform vec2 vTransmissionDispersionScaleInfos; +#endif +#ifdef SUBSURFACE_WEIGHT +uniform vec2 vSubsurfaceWeightInfos; +#endif +#ifdef SUBSURFACE_COLOR +uniform vec2 vSubsurfaceColorInfos; +#endif +#ifdef SUBSURFACE_RADIUS_SCALE +uniform vec2 vSubsurfaceRadiusScaleInfos; +#endif +#ifdef COAT_WEIGHT +uniform vec2 vCoatWeightInfos; +#endif +#ifdef COAT_COLOR +uniform vec2 vCoatColorInfos; +#endif +#ifdef COAT_ROUGHNESS +uniform vec2 vCoatRoughnessInfos; +#endif +#ifdef COAT_ROUGHNESS_ANISOTROPY +uniform vec2 vCoatRoughnessAnisotropyInfos; +#endif +#ifdef COAT_IOR +uniform vec2 vCoatIorInfos; +#endif +#ifdef COAT_DARKENING +uniform vec2 vCoatDarkeningInfos; +#endif +#ifdef FUZZ_WEIGHT +uniform vec2 vFuzzWeightInfos; +#endif +#ifdef FUZZ_COLOR +uniform vec2 vFuzzColorInfos; +#endif +#ifdef FUZZ_ROUGHNESS +uniform vec2 vFuzzRoughnessInfos; +#endif +#ifdef GEOMETRY_COAT_TANGENT +uniform vec2 vGeometryCoatTangentInfos; +#endif +#ifdef THIN_FILM_WEIGHT +uniform vec2 vThinFilmWeightInfos; +#endif +#ifdef THIN_FILM_THICKNESS +uniform vec2 vThinFilmThicknessInfos; +#endif +#include +#ifdef REFLECTION +uniform vec2 vReflectionInfos; +#ifdef REALTIME_FILTERING +uniform vec2 vReflectionFilteringInfo; +#endif +uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos; +#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION) +uniform vec3 vReflectionDominantDirection; +#endif +#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC) +uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; +#endif +#endif +#ifdef PREPASS +#ifdef SS_SCATTERING +uniform float scatteringDiffusionProfile; +#endif +#endif +#if DEBUGMODE>0 +uniform vec2 vDebugMode; +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos; +#endif +#include +#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22; +#else +uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX; +#endif +#endif +#ifdef REFRACTED_BACKGROUND +uniform mat4 backgroundRefractionMatrix;uniform vec3 vBackgroundRefractionInfos; +#endif +#define ADDITIONAL_FRAGMENT_DECLARATION +`;E.IncludesShadersStore[e3]||(E.IncludesShadersStore[e3]=w6)});var i3,B6,FA=C(()=>{w();lf();i3="pbrFragmentExtraDeclaration",B6=`varying vec3 vPositionW; +#if DEBUGMODE>0 +varying vec4 vClipSpacePosition; +#endif +#include[1..7] +#ifdef NORMAL +varying vec3 vNormalW; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vec3 vEnvironmentIrradiance; +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying float vViewDepth; +#endif +`;E.IncludesShadersStore[i3]||(E.IncludesShadersStore[i3]=B6)});var r3,U6,s3=C(()=>{w();_l();zp();r3="openpbrFragmentSamplersDeclaration",U6=`#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) +#include(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight) +#include(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness) +#include(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy) +#include(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight) +#include(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor) +#include(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth) +#include(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter) +#include(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale) +#include(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight) +#include(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor) +#include(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale) +#include(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight) +#include(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor) +#include(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness) +#include(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy) +#include(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening) +#include(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight) +#include(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor) +#include(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness) +#include(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity) +#include(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent) +#include(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent) +#include(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness) +#include(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor) +#include(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight) +#include(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness) +#include(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#include +#ifdef ENVIRONMENTBRDF +uniform sampler2D environmentBrdfSampler; +#endif +#ifdef FUZZENVIRONMENTBRDF +uniform sampler2D environmentFuzzBrdfSampler; +#endif +#ifdef REFRACTED_BACKGROUND +uniform sampler2D backgroundRefractionSampler; +#endif +#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING +uniform sampler2D sceneIrradianceSampler;uniform sampler2D sceneDepthSampler; +#endif +#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) +uniform sampler2D blueNoiseSampler; +#endif +#ifdef IBL_CDF_FILTERING +uniform sampler2D icdfSampler; +#endif +`;E.IncludesShadersStore[r3]||(E.IncludesShadersStore[r3]=U6)});var n3,V6,wA=C(()=>{w();n3="subSurfaceScatteringFunctions",V6=`bool testLightingForSSS(float diffusionProfile) +{return diffusionProfile<1.;}`;E.IncludesShadersStore[n3]||(E.IncludesShadersStore[n3]=V6)});var a3,G6,BA=C(()=>{w();a3="importanceSampling",G6=`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[a3]||(E.IncludesShadersStore[a3]=G6)});var o3,k6,UA=C(()=>{w();o3="pbrHelperFunctions",k6=`#define MINIMUMVARIANCE 0.0005 +float convertRoughnessToAverageSlope(float roughness) +{return square(roughness)+MINIMUMVARIANCE;} +float fresnelGrazingReflectance(float reflectance0) {float reflectance90=saturate(reflectance0*25.0);return reflectance90;} +vec2 getAARoughnessFactors(vec3 normalVector) { +#ifdef SPECULARAA +vec3 nDfdx=dFdx(normalVector.xyz);vec3 nDfdy=dFdy(normalVector.xyz);float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);float geometricAlphaGFactor=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2(geometricRoughnessFactor,geometricAlphaGFactor); +#else +return vec2(0.); +#endif +} +#ifdef ANISOTROPIC +#ifdef ANISOTROPIC_LEGACY +vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);} +vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 anisotropicFrameDirection;if (anisotropy>=0.0) {anisotropicFrameDirection=B;} else {anisotropicFrameDirection=T;} +vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;} +#elif ANISOTROPIC_OPENPBR +vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(alphaG*alphaG*sqrt(2.0/(1.0+(1.0-anisotropy)*(1.0-anisotropy))),MINIMUMVARIANCE);float alphaB=max(alphaT*(1.0-anisotropy),MINIMUMVARIANCE);return vec2(alphaT,alphaB);} +#else +vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {float alphaT=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);float alphaB=max(alphaG,MINIMUMVARIANCE);return vec2(alphaT,alphaB);} +vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy,float roughness) {vec3 bentNormal=cross(B,V);bentNormal=normalize(cross(bentNormal,B));float a=square(square(1.0-anisotropy*(1.0-roughness)));bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;} +#endif +#endif +#if defined(CLEARCOAT) || defined(SS_REFRACTION) +vec3 cocaLambert(vec3 alpha,float distance) {return exp(-alpha*distance);} +vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));} +vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {return -log(color)/distance;} +vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 clearCoatAbsorption=mix(vec3(1.0), +cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness), +clearCoatIntensity);return clearCoatAbsorption;} +#endif +#ifdef MICROSURFACEAUTOMATIC +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[o3]||(E.IncludesShadersStore[o3]=k6)});var l3,W6,VA=C(()=>{w();AS();l3="pbrDirectLightingSetupFunctions",W6=`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; +#endif +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vec3 areaLightDiffuse; +#ifdef SPECULARTERM +vec3 areaLightSpecular;vec4 areaLightFresnel; +#endif +#endif +};preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N,vec3 posW) {preLightingInfo result;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} +preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);result.LdotV=dot(result.L,V);result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} +preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {preLightingInfo result;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL; +#ifdef SPECULARTERM +result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H)); +#endif +result.LdotV=0.;result.roughness=0.;result.diffuseRoughness=0.;result.surfaceAlbedo=vec3(0.);return result;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +#include +uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler;preLightingInfo computeAreaPreLightingInfo(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec4 lightData,vec3 halfWidth,vec3 halfHeight,float roughness ) +{preLightingInfo result;result.lightOffset=lightData.xyz-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightData.xyz,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +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;} +preLightingInfo computeAreaPreLightingInfoWithTexture(sampler2D ltc1,sampler2D ltc2,sampler2D emissionTexture,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec4 lightData,vec3 halfWidth,vec3 halfHeight,float roughness ) +{preLightingInfo result;result.lightOffset=lightData.xyz-vPosition;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);areaLightData data=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc2,emissionTexture,viewDirectionW,vNormal,vPosition,lightData.xyz,halfWidth,halfHeight,roughness); +#ifdef SPECULARTERM +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[l3]||(E.IncludesShadersStore[l3]=W6)});var c3,H6,GA=C(()=>{w();c3="pbrDirectLightingFalloffFunctions",H6=`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);} +float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange) +{float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);float factor=lightDistanceSquared*inverseSquaredRange;float attenuation=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;} +float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange) +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDistanceLightFalloff_Physical(lightDistanceSquared); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange); +#else +return computeDistanceLightFalloff_Standard(lightOffset,range); +#endif +} +float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent) +{float falloff=0.0;float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle) +{falloff=max(0.,pow(cosAngle,exponent));} +return falloff;} +float computeDirectionalLightFalloff_IES(vec3 lightDirection,vec3 directionToLightCenterW,sampler2D iesLightSampler) +{float cosAngle=dot(-lightDirection,directionToLightCenterW);float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;} +float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle) +{const float kMinusLog2ConeAngleIntensityRatio=6.64385618977; +float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;} +float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset) +{float cd=dot(-lightDirection,directionToLightCenterW);float falloff=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;} +float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset) +{ +#ifdef USEPHYSICALLIGHTFALLOFF +return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle); +#elif defined(USEGLTFLIGHTFALLOFF) +return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset); +#else +return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent); +#endif +}`;E.IncludesShadersStore[c3]||(E.IncludesShadersStore[c3]=H6)});var f3,z6,kA=C(()=>{w();f3="hdrFilteringFunctions",z6=`#if NUM_SAMPLES +#if NUM_SAMPLES>0 +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +float radicalInverse_VdC(uint bits) +{bits=(bits<<16u) | (bits>>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 float(bits)*2.3283064365386963e-10; } +vec2 hammersley(uint i,uint N) +{return vec2(float(i)/float(N),radicalInverse_VdC(i));} +#else +float vanDerCorpus(int n,int base) +{float invBase=1.0/float(base);float denom =1.0;float result =0.0;for(int i=0; i<32; ++i) +{if(n>0) +{denom =mod(float(n),2.0);result+=denom*invBase;invBase=invBase/2.0;n =int(float(n)/2.0);}} +return result;} +vec2 hammersley(int i,int N) +{return vec2(float(i)/float(N),vanDerCorpus(i,2));} +#endif +float log4(float x) {return log2(x)/2.;} +vec3 uv_to_normal(vec2 uv) {vec3 N;vec2 uvRange=uv;float theta=uvRange.x*2.*PI;float phi=uvRange.y*PI;float sinPhi=sin(phi);N.x=cos(theta)*sinPhi;N.z=sin(theta)*sinPhi;N.y=cos(phi);return N;} +const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;const float K=4.; +#define inline +vec3 irradiance( +#ifdef CUSTOM_IRRADIANCE_FILTERING_INPUT +CUSTOM_IRRADIANCE_FILTERING_INPUT +#else +samplerCube inputTexture, +#endif +vec3 inputN,vec2 filteringInfo, +float diffuseRoughness, +vec3 surfaceAlbedo, +vec3 inputV +#if IBL_CDF_FILTERING +,sampler2D icdfSampler +#endif +) +{vec3 n=normalize(inputN);vec3 result=vec3(0.); +#ifndef IBL_CDF_FILTERING +vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);mat3 tbnInverse=mat3(tangent.x,bitangent.x,n.x,tangent.y,bitangent.y,n.y,tangent.z,bitangent.z,n.z); +#endif +float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0)); +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +for(uint i=0u; i0.) { +#if IBL_CDF_FILTERING +float pdf=texture2D(icdfSampler,T).z;vec3 c=textureCubeLodEXT(inputTexture,Ls,0.).rgb; +#else +float pdf_inversed=PI/NoL;float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(l,0.,maxLevel); +#ifdef CUSTOM_IRRADIANCE_FILTERING_FUNCTION +CUSTOM_IRRADIANCE_FILTERING_FUNCTION +#else +vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb; +#endif +#endif +#if GAMMA_INPUT +c=toLinearSpace(c); +#endif +vec3 diffuseRoughnessTerm=vec3(1.0); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI; +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +#if IBL_CDF_FILTERING +vec3 light=pdf<1e-6 ? vec3(0.0) : vec3(1.0)/vec3(pdf)*c;result+=NoL*diffuseRoughnessTerm*light; +#else +result+=c*diffuseRoughnessTerm; +#endif +}} +result=result*NUM_SAMPLES_FLOAT_INVERSED; +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +result=result/clampedAlbedo; +#endif +return result;} +#define inline +vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo) +{vec3 n=normalize(inputN);vec3 c=textureCubeLodEXT(inputTexture,n,0.).rgb; +if (alphaG==0.) { +#if GAMMA_INPUT +c=toLinearSpace(c); +#endif +return c;} else {vec3 result=vec3(0.);vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);tangent=normalize(cross(tangent,n));vec3 bitangent=cross(n,tangent);mat3 tbn=mat3(tangent,bitangent,n);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float omegaP=(4.*PI)/(6.*dim0*dim0);float weight=0.; +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +for(uint i=0u; i0.) {float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb; +#if GAMMA_INPUT +c=toLinearSpace(c); +#endif +result+=c*NoL;}} +result=result/weight;return result;}} +#ifdef ANISOTROPIC +#define inline +vec3 radianceAnisotropic( +float alphaTangent, +float alphaBitangent, +samplerCube inputTexture, +vec3 inputView, +vec3 inputTangent, +vec3 inputBitangent, +vec3 inputNormal, +vec2 filteringInfo, +vec2 noiseInput, +bool isRefraction, +float ior +) +{vec3 V=inputView;vec3 N=inputNormal;vec3 T=inputTangent;vec3 B=inputBitangent;vec3 result=vec3(0.);float maxLevel=filteringInfo.y;float dim0=filteringInfo.x;float clampedAlphaT=max(alphaTangent,MINIMUMVARIANCE);float clampedAlphaB=max(alphaBitangent,MINIMUMVARIANCE);float effectiveDim=dim0*sqrt(clampedAlphaT*clampedAlphaB);float omegaP=(4.*PI)/(6.*effectiveDim*effectiveDim);const float noiseScale=clamp(log2(float(NUM_SAMPLES))/12.0f,0.0f,1.0f);float weight=0.; +#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) +for(uint i=0u; i0.) {float pdf_inversed=4./normalDistributionFunction_BurleyGGX_Anisotropic( +H_tangent.z,H_tangent.x,H_tangent.y,vec2(clampedAlphaT,clampedAlphaB) +);float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;float l=log4(omegaS)-log4(omegaP)+log4(K);float mipLevel=clamp(float(l),0.0,maxLevel);weight+=NoL;vec3 c=textureCubeLodEXT(inputTexture,L,mipLevel).rgb; +#if GAMMA_INPUT +c=toLinearSpace(c); +#endif +result+=c*NoL;}} +result=result/weight;return result;} +#endif +#endif +#endif +`;E.IncludesShadersStore[f3]||(E.IncludesShadersStore[f3]=z6)});var h3,X6,WA=C(()=>{w();h3="pbrDirectLightingFunctions",X6=`#define CLEARCOATREFLECTANCE90 1.0 +struct lightingInfo +{vec3 diffuse; +#ifdef SS_TRANSLUCENCY +vec3 diffuseTransmission; +#endif +#ifdef SPECULARTERM +vec3 specular; +#endif +#ifdef CLEARCOAT +vec4 clearCoat; +#endif +#ifdef SHEEN +vec3 sheen; +#endif +};float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) { +#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF) +float lightRoughness=lightRadius/lightDistance;float totalRoughness=saturate(lightRoughness+roughness);return totalRoughness; +#else +return roughness; +#endif +} +vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {return mix(groundColor,lightColor,info.NdotL);} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vec3 computeAreaDiffuseLighting(preLightingInfo info,vec3 lightColor) {return info.areaLightDiffuse*lightColor;} +#endif +vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {vec3 diffuseTerm=vec3(1.0/PI); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY +diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; +#endif +return diffuseTerm*info.attenuation*info.NdotL*lightColor;} +#define inline +vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return toLinearSpace(textureColor);} +#ifdef SS_TRANSLUCENCY +vec3 computeDiffuseTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {vec3 transmittanceNdotL=vec3(0.);float NdotL=absEps(info.NdotLUnclamped); +#ifndef SS_TRANSLUCENCY_LEGACY +if (info.NdotLUnclamped<0.0) { +#endif +float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);float trAdapt=step(0.,info.NdotLUnclamped);transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt); +#ifndef SS_TRANSLUCENCY_LEGACY +} +vec3 diffuseTerm=vec3(1.0/PI); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_LEGACY +diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +diffuseTerm=vec3(diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.diffuseRoughness)); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +vec3 clampedAlbedo=clamp(info.surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseTerm=diffuseBRDF_EON(clampedAlbedo,info.diffuseRoughness,info.NdotL,info.NdotV,info.LdotV);diffuseTerm/=clampedAlbedo; +#endif +#else +float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness); +#endif +return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;} +#endif +#ifdef SPECULARTERM +vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 fresnel,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness); +#ifdef IRIDESCENCE +fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); +#endif +float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG); +#ifdef BRDF_V_HEIGHT_CORRELATED +float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG); +#else +float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG); +#endif +vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} +#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +vec3 computeAreaSpecularLighting(preLightingInfo info,vec3 specularColor,vec3 reflectance0,vec3 reflectance90) {vec3 fresnel=specularColor*info.areaLightFresnel.x*reflectance0+( vec3( 1.0 )-specularColor )*info.areaLightFresnel.y*reflectance90;return specularColor*fresnel*info.areaLightSpecular;} +#endif +#endif +#ifdef FUZZ +float evalFuzz(vec3 L,float NdotL,float NdotV,vec3 T,vec3 B,vec3 ltcLut) +{if (NdotL<=0.0 || NdotV<=0.0) +return 0.0;mat3 M=mat3( +vec3(ltcLut.r,0.0,0.0), +vec3(ltcLut.g,1.0,0.0), +vec3(0.0,0.0,1.0) +);vec3 Llocal=vec3(dot(L,T),dot(L,B),NdotL);vec3 Lwarp=normalize(M*Llocal);float cosThetaWarp=max(Lwarp.z,0.0);return cosThetaWarp*NdotL;} +#endif +#if defined(ANISOTROPIC) && defined(ANISOTROPIC_OPENPBR) +vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=vec3(distribution*smithVisibility);return specTerm*info.attenuation*info.NdotL*lightColor;} +#elif defined(ANISOTROPIC) +vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float TdotH=dot(T,info.H);float BdotH=dot(B,info.H);float TdotV=dot(T,V);float BdotV=dot(B,V);float TdotL=dot(T,info.L);float BdotL=dot(B,info.L);float alphaG=convertRoughnessToAverageSlope(info.roughness);vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,square(geometricRoughnessFactor));vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90); +#ifdef IRIDESCENCE +fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity); +#endif +float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);vec3 specTerm=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;} +#endif +#ifdef CLEARCOAT +vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {float NccdotL=saturateEps(dot(Ncc,info.L));float NccdotH=saturateEps(dot(Ncc,info.H));float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);float kelemenVisibility=visibility_Kelemen(info.VdotH);float clearCoatTerm=fresnel*distribution*kelemenVisibility;return vec4( +clearCoatTerm*info.attenuation*NccdotL*lightColor, +1.0-fresnel +);} +vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);float NdotLRefract=saturateEps(dot(Ncc,LRefract));vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;} +#endif +#ifdef SHEEN +vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {float NdotH=saturateEps(dot(N,info.H));float roughness=max(info.roughness,geometricRoughnessFactor);float alphaG=convertRoughnessToAverageSlope(roughness);float fresnel=1.;float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER +float visibility=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG); +#else */ +float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */ +float sheenTerm=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;} +#endif +`;E.IncludesShadersStore[h3]||(E.IncludesShadersStore[h3]=X6)});var d3,Y6,u3=C(()=>{w();d3="openpbrNormalMapFragmentMainFunctions",Y6=`#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL) +#if defined(TANGENT) && defined(NORMAL) +varying mat3 vTBN; +#endif +#ifdef OBJECTSPACE_NORMALMAP +uniform mat4 normalMatrix; +#if defined(WEBGL2) || defined(WEBGPU) +mat4 toNormalMatrix(mat4 wMatrix) +{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;} +#else +mat4 toNormalMatrix(mat4 m) +{float +a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3], +a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3], +a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3], +a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3], +b00=a00*a11-a01*a10, +b01=a00*a12-a02*a10, +b02=a00*a13-a03*a10, +b03=a01*a12-a02*a11, +b04=a01*a13-a03*a11, +b05=a02*a13-a03*a12, +b06=a20*a31-a21*a30, +b07=a20*a32-a22*a30, +b08=a20*a33-a23*a30, +b09=a21*a32-a22*a31, +b10=a21*a33-a23*a31, +b11=a22*a33-a23*a32, +det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4( +a11*b11-a12*b10+a13*b09, +a02*b10-a01*b11-a03*b09, +a31*b05-a32*b04+a33*b03, +a22*b04-a21*b05-a23*b03, +a12*b08-a10*b11-a13*b07, +a00*b11-a02*b08+a03*b07, +a32*b02-a30*b05-a33*b01, +a20*b05-a22*b02+a23*b01, +a10*b10-a11*b08+a13*b06, +a01*b08-a00*b10-a03*b06, +a30*b04-a31*b02+a33*b00, +a21*b02-a20*b04-a23*b00, +a11*b07-a10*b09-a12*b06, +a00*b09-a01*b07+a02*b06, +a31*b01-a30*b03-a32*b00, +a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0], +mi[0][1],mi[1][1],mi[2][1],mi[3][1], +mi[0][2],mi[1][2],mi[2][2],mi[3][2], +mi[0][3],mi[1][3],mi[2][3],mi[3][3]);} +#endif +#endif +vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale) +{ +#ifdef NORMALXYSCALE +normal=normalize(normal*vec3(scale,scale,1.0)); +#endif +return normalize(cotangentFrame*normal);} +vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale) +{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,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[d3]||(E.IncludesShadersStore[d3]=Y6)});var m3,K6,p3=C(()=>{w();_l();m3="openpbrNormalMapFragmentFunctions",K6=`#if defined(GEOMETRY_NORMAL) +#include(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal) +#endif +#if defined(GEOMETRY_COAT_NORMAL) +#include(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal) +#endif +#if defined(DETAIL) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail) +#endif +#if defined(GEOMETRY_NORMAL) && defined(PARALLAX) +const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; icurrRayHeight) +{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;} +else +{currRayHeight-=stepSize;vLastOffset=vCurrOffset; +#ifdef PARALLAX_RHS +vCurrOffset-=stepSize*vMaxOffset; +#else +vCurrOffset+=stepSize*vMaxOffset; +#endif +lastSampledHeight=currSampledHeight;}} +return vCurrOffset;} +vec2 parallaxOffset(vec3 viewDir,float heightScale) +{float height=texture2D(geometryNormalSampler,vGeometryNormalUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height; +#ifdef PARALLAX_RHS +return texCoordOffset; +#else +return -texCoordOffset; +#endif +} +#endif +`;E.IncludesShadersStore[m3]||(E.IncludesShadersStore[m3]=K6)});var _3,j6,g3=C(()=>{w();_3="openpbrConductorReflectance",j6=`#define pbr_inline +ReflectanceParams conductorReflectance(in vec3 baseColor,in vec3 specularColor,in float specularWeight) +{ReflectanceParams outParams; +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight; +#else +outParams.coloredF0=baseColor;outParams.coloredF90=vec3(1.0); +#endif +outParams.F0=1.0;outParams.F90=1.0;return outParams;}`;E.IncludesShadersStore[_3]||(E.IncludesShadersStore[_3]=j6)});var E3,Z6,v3=C(()=>{w();E3="openpbrAmbientOcclusionFunctions",Z6=`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[E3]||(E.IncludesShadersStore[E3]=Z6)});var S3,q6,T3=C(()=>{w();S3="openpbrVolumeFunctions",q6=`struct OpenPBRHomogeneousVolume {vec3 extinction_coeff; +vec3 ss_albedo; +vec3 multi_scatter_color; +vec3 absorption_coeff; +vec3 scatter_coeff; +float anisotropy; };OpenPBRHomogeneousVolume computeOpenPBRTransmissionVolume( +in vec3 transmission_color, +in float transmission_depth, +in vec3 transmission_scatter, +in float anisotropy +) +{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy; +#ifdef GEOMETRY_THIN_WALLED +volumeParams.scatter_coeff=vec3(1.0);volumeParams.anisotropy=1.0; +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(1.0); +#else +if (transmission_depth>0.0) {vec3 invDepth=vec3(1./maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEps(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);} +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/(volumeParams.extinction_coeff);} else {volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(0.0);} +#endif +return volumeParams;} +OpenPBRHomogeneousVolume computeOpenPBRSubsurfaceVolume( +in vec3 subsurface_color, +in float subsurface_radius, +in vec3 subsurface_radius_scale, +in float anisotropy +) +{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;vec3 mfp=subsurface_radius_scale*vec3(subsurface_radius);volumeParams.extinction_coeff=vec3(1.0)/maxEps(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedo(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);} +volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;} +vec3 sss_pdf(float r,vec3 d) +{d=max(vec3(1e-4f),d);return (exp(-r/d)+exp(-r/(3.0f*d)))/max(vec3(1e-5f),8.0f*PI*d*r);} +float sss_samples_pdf(float r,float d) +{d=max(1e-4f,d);return exp(-r/(3.0f*d))/(6.0f*PI*d*r);} +float sss_samples_icdf(float x,float d) +{d=max(1e-4f,d);x=max(1e-4f,x);return -3.0f*log(x)*d;} +float samples_scale(float x,float d) +{return 1.0f-exp(-x/(3.0f*d));} +vec3 sss_get_position(sampler2D depth_texture,vec2 tex_coord,vec2 render_resolution,mat4 inv_proj) +{vec4 P=vec4(tex_coord,texelFetch(depth_texture,ivec2(tex_coord*render_resolution),0).x,1.0f);P.xy=2.0f*P.xy-1.0f;P=inv_proj*P;return P.xyz/P.w;} +float sss_filter_scale(float currZ,mat4 proj) +{return 1.0f/dot(vec2(proj[2].w,proj[3].w),vec2(currZ,1.0f));} +float projective_to_pixels(float proj_dist,mat4 proj,vec2 resolution) +{return proj_dist*proj[1][1]*resolution.y;} +float pixels_to_projective(float pixel_dist,mat4 proj,vec2 resolution) +{return pixel_dist/(proj[1][1]*resolution.y);} +vec3 sss_convolve(sampler2D sss_irradiance_texture,sampler2D depth_texture,vec2 render_resolution,vec3 d,mat4 proj,mat4 inv_proj,int sample_count,vec2 noise) +{vec2 tex_coord=gl_FragCoord.xy/render_resolution;vec3 unconvolved_irradiance=texelFetch(sss_irradiance_texture,ivec2(gl_FragCoord.xy),0).rgb;vec3 curr_pos=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);float dmax=max3(d);float max_dmax=0.1*float(sample_count);if (dmax>max_dmax) +{d.rgb*=max_dmax/dmax;dmax=max_dmax;} +float dz=dmax*sss_filter_scale(curr_pos.z,proj);mat2 projMat2d=mat2(proj);if (determinant(projMat2d)*dz<1e-4f) +return unconvolved_irradiance;float overscan_size_in_pixels=max(render_resolution.x,render_resolution.y)*0.1;const float filter_crop_ratio=0.8f; +float crop_radius=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels) +{d.rgb*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;} +float filter_samples_scale=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);vec3 irradiance_sum=vec3(0.0f);vec3 weight_sum=vec3(0.0f);for (int i=0; i0.0f) +{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[S3]||(E.IncludesShadersStore[S3]=q6)});var A3,Q6,HA=C(()=>{w();A3="pbrBlockNormalGeometric",Q6=`vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW); +#ifdef NORMAL +vec3 normalW=normalize(vNormalW); +#else +vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#endif +vec3 geometricNormalW=normalW; +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW; +#endif +`;E.IncludesShadersStore[A3]||(E.IncludesShadersStore[A3]=Q6)});var R3,J6,x3=C(()=>{w();R3="openpbrNormalMapFragment",J6=`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; +#elif defined(GEOMETRY_NORMAL) +float normalScale=vGeometryNormalInfos.y; +#else +float normalScale=1.0; +#endif +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#elif defined(GEOMETRY_NORMAL) +vec2 TBNUV=gl_FrontFacing ? vGeometryNormalUV : -vGeometryNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams); +#elif defined(GEOMETRY_COAT_NORMAL) +vec2 TBNUV=gl_FrontFacing ? vGeometryCoatNormalUV : -vGeometryCoatNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams); +#else +vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.)); +#endif +#elif defined(ANISOTROPIC) || defined(FUZZ) +#if defined(TANGENT) && defined(NORMAL) +mat3 TBN=vTBN; +#else +vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.)); +#endif +#endif +#ifdef PARALLAX +mat3 invTBN=transposeMat3(TBN); +#ifdef PARALLAXOCCLUSION +#else +#endif +#endif +#ifdef DETAIL +vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB); +#endif +#ifdef GEOMETRY_COAT_NORMAL +coatNormalW=perturbNormal(TBN,texture2D(geometryCoatNormalSampler,vGeometryCoatNormalUV+uvOffset).xyz,vGeometryCoatNormalInfos.y); +#endif +#ifdef GEOMETRY_NORMAL +#ifdef OBJECTSPACE_NORMALMAP +#define CUSTOM_FRAGMENT_BUMP_FRAGMENT +normalW=normalize(texture2D(geometryNormalSampler,vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW); +#elif !defined(DETAIL) +normalW=perturbNormal(TBN,texture2D(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz,vGeometryNormalInfos.y); +#else +vec3 sampledNormal=texture2D(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz*2.0-1.0; +#if DETAIL_NORMALBLENDMETHOD==0 +detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z)); +#elif DETAIL_NORMALBLENDMETHOD==1 +detailNormal.xy*=vDetailInfos.z;sampledNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal; +#endif +normalW=perturbNormalBase(TBN,blendedNormal,vGeometryNormalInfos.y); +#endif +#elif defined(DETAIL) +detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); +#endif +`;E.IncludesShadersStore[R3]||(E.IncludesShadersStore[R3]=J6)});var I3,$6,C3=C(()=>{w();I3="openpbrBlockNormalFinal",$6=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#if defined(TWOSIDEDLIGHTING) +faceNormal=gl_FrontFacing ? faceNormal : -faceNormal; +#endif +normalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +#if defined(MIRRORED) +normalW=gl_FrontFacing ? -normalW : normalW;coatNormalW=gl_FrontFacing ? -coatNormalW : coatNormalW; +#else +normalW=gl_FrontFacing ? normalW : -normalW;coatNormalW=gl_FrontFacing ? coatNormalW : -coatNormalW; +#endif +#endif +`;E.IncludesShadersStore[I3]||(E.IncludesShadersStore[I3]=$6)});var b3,eY,M3=C(()=>{w();b3="openpbrBaseLayerData",eY=`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 +#ifdef BASE_COLOR +vec4 baseColorFromTexture=texture2D(baseColorSampler,vBaseColorUV+uvOffset); +#endif +#ifdef BASE_METALNESS +vec4 metallicFromTexture=texture2D(baseMetalnessSampler,vBaseMetalnessUV+uvOffset); +#endif +#if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS) +float roughnessFromTexture=metallicFromTexture.g; +#elif defined(SPECULAR_ROUGHNESS) +float roughnessFromTexture=texture2D(specularRoughnessSampler,vSpecularRoughnessUV+uvOffset).r; +#endif +#ifdef GEOMETRY_TANGENT +vec3 geometryTangentFromTexture=texture2D(geometryTangentSampler,vGeometryTangentUV+uvOffset).rgb; +#endif +#ifdef SPECULAR_ROUGHNESS_ANISOTROPY +float anisotropyFromTexture=texture2D(specularRoughnessAnisotropySampler,vSpecularRoughnessAnisotropyUV+uvOffset).r*vSpecularRoughnessAnisotropyInfos.y; +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +float baseDiffuseRoughnessFromTexture=texture2D(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r; +#endif +#ifdef GEOMETRY_OPACITY +vec4 opacityFromTexture=texture2D(geometryOpacitySampler,vGeometryOpacityUV+uvOffset); +#endif +#ifdef GEOMETRY_THICKNESS +vec4 thicknessFromTexture=texture2D(geometryThicknessSampler,vGeometryThicknessUV+uvOffset); +#endif +#ifdef DECAL +vec4 decalFromTexture=texture2D(decalSampler,vDecalUV+uvOffset); +#endif +#ifdef SPECULAR_COLOR +vec4 specularColorFromTexture=texture2D(specularColorSampler,vSpecularColorUV+uvOffset); +#endif +#ifdef SPECULAR_WEIGHT +#ifdef SPECULAR_WEIGHT_IN_ALPHA +float specularWeightFromTexture=texture2D(specularWeightSampler,vSpecularWeightUV+uvOffset).a; +#else +float specularWeightFromTexture=texture2D(specularWeightSampler,vSpecularWeightUV+uvOffset).r; +#endif +#endif +#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) +vec3 noise=vec3(2.0)*texture2D(blueNoiseSampler,gl_FragCoord.xy/256.0).xyz-vec3(1.0); +#endif +base_color=vBaseColor.rgb; +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +base_color*=vColor.rgb; +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=vColor.a; +#endif +base_color*=vec3(vBaseWeight);alpha=vBaseColor.a;base_metalness=vReflectanceInfo.x;base_diffuse_roughness=vBaseDiffuseRoughness;specular_roughness=vReflectanceInfo.y;specular_color=vSpecularColor.rgb;specular_weight=vReflectanceInfo.a;specular_ior=vReflectanceInfo.z;specular_roughness_anisotropy=vSpecularAnisotropy.b;geometry_tangent=vSpecularAnisotropy.rg;geometry_thickness=vGeometryThickness; +#ifdef BASE_COLOR +#ifdef BASE_COLOR_GAMMA +base_color*=toLinearSpace(baseColorFromTexture.rgb); +#else +base_color*=baseColorFromTexture.rgb; +#endif +base_color*=vBaseColorInfos.y; +#endif +#ifdef BASE_WEIGHT +base_color*=baseWeightFromTexture.r; +#endif +#if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE) +alpha*=baseColorFromTexture.a; +#elif defined(GEOMETRY_OPACITY) +alpha*=opacityFromTexture.r;alpha*=vGeometryOpacityInfos.y; +#endif +#ifdef GEOMETRY_THICKNESS +#ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL +geometry_thickness*=thicknessFromTexture.g; +#else +geometry_thickness*=thicknessFromTexture.r; +#endif +geometry_thickness*=vGeometryThicknessInfos.y; +#endif +#ifdef ALPHATEST +#if DEBUGMODE != 88 +if (alpha{w();y3="openpbrCoatLayerData",tY=`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 +#ifdef COAT_COLOR +vec4 coatColorFromTexture=texture2D(coatColorSampler,vCoatColorUV+uvOffset); +#endif +#ifdef COAT_ROUGHNESS +vec4 coatRoughnessFromTexture=texture2D(coatRoughnessSampler,vCoatRoughnessUV+uvOffset); +#endif +#ifdef COAT_ROUGHNESS_ANISOTROPY +float coatRoughnessAnisotropyFromTexture=texture2D(coatRoughnessAnisotropySampler,vCoatRoughnessAnisotropyUV+uvOffset).r; +#endif +#ifdef COAT_DARKENING +vec4 coatDarkeningFromTexture=texture2D(coatDarkeningSampler,vCoatDarkeningUV+uvOffset); +#endif +#ifdef GEOMETRY_COAT_TANGENT +vec3 geometryCoatTangentFromTexture=texture2D(geometryCoatTangentSampler,vGeometryCoatTangentUV+uvOffset).rgb; +#endif +coat_color=vCoatColor.rgb;coat_weight=vCoatWeight;coat_roughness=vCoatRoughness;coat_roughness_anisotropy=vCoatRoughnessAnisotropy;coat_ior=vCoatIor;coat_darkening=vCoatDarkening;geometry_coat_tangent=vGeometryCoatTangent.rg; +#ifdef COAT_WEIGHT +coat_weight*=coatWeightFromTexture.r; +#endif +#ifdef COAT_COLOR +#ifdef COAT_COLOR_GAMMA +coat_color*=toLinearSpace(coatColorFromTexture.rgb); +#else +coat_color*=coatColorFromTexture.rgb; +#endif +coat_color*=vCoatColorInfos.y; +#endif +#ifdef COAT_ROUGHNESS +#ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL +coat_roughness*=coatRoughnessFromTexture.g; +#else +coat_roughness*=coatRoughnessFromTexture.r; +#endif +#endif +#if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE) +coat_roughness_anisotropy*=geometryCoatTangentFromTexture.b; +#elif defined(COAT_ROUGHNESS_ANISOTROPY) +coat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture; +#endif +#ifdef COAT_DARKENING +coat_darkening*=coatDarkeningFromTexture.r; +#endif +#ifdef GEOMETRY_COAT_TANGENT +{vec2 tangentFromTexture=normalize(geometryCoatTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_coat_tangent.y,geometry_coat_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2(cos(tangent_angle),sin(tangent_angle));} +#endif +#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[y3]||(E.IncludesShadersStore[y3]=tY)});var P3,iY,L3=C(()=>{w();P3="openpbrThinFilmLayerData",iY=`#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 +float thinFilmWeightFromTexture=texture2D(thinFilmWeightSampler,vThinFilmWeightUV+uvOffset).r*vThinFilmWeightInfos.y; +#endif +#ifdef THIN_FILM_THICKNESS +float thinFilmThicknessFromTexture=texture2D(thinFilmThicknessSampler,vThinFilmThicknessUV+uvOffset).g*vThinFilmThicknessInfos.y; +#endif +#ifdef THIN_FILM_WEIGHT +thin_film_weight*=thinFilmWeightFromTexture; +#endif +#ifdef THIN_FILM_THICKNESS +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[P3]||(E.IncludesShadersStore[P3]=iY)});var O3,rY,N3=C(()=>{w();O3="openpbrFuzzLayerData",rY=`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); +#endif +#ifdef FUZZ_COLOR +vec4 fuzzColorFromTexture=texture2D(fuzzColorSampler,vFuzzColorUV+uvOffset); +#endif +#ifdef FUZZ_ROUGHNESS +vec4 fuzzRoughnessFromTexture=texture2D(fuzzRoughnessSampler,vFuzzRoughnessUV+uvOffset); +#endif +fuzz_color=vFuzzColor.rgb;fuzz_weight=vFuzzWeight;fuzz_roughness=vFuzzRoughness; +#ifdef FUZZ_WEIGHT +fuzz_weight*=fuzzWeightFromTexture.r; +#endif +#ifdef FUZZ_COLOR +#ifdef FUZZ_COLOR_GAMMA +fuzz_color*=toLinearSpace(fuzzColorFromTexture.rgb); +#else +fuzz_color*=fuzzColorFromTexture.rgb; +#endif +fuzz_color*=vFuzzColorInfos.y; +#endif +#if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA) +fuzz_roughness*=fuzzRoughnessFromTexture.a; +#elif defined(FUZZ_ROUGHNESS) +fuzz_roughness*=fuzzRoughnessFromTexture.r; +#endif +#endif +`;E.IncludesShadersStore[O3]||(E.IncludesShadersStore[O3]=rY)});var F3,sY,w3=C(()=>{w();F3="openpbrAmbientOcclusionData",sY=`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[F3]||(E.IncludesShadersStore[F3]=sY)});var B3,nY,U3=C(()=>{w();B3="openpbrBackgroundTransmission",nY=`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 +{ +#ifdef REFRACTION_HIGH_QUALITY_BLUR +{vec3 dispResult=vec3(0.0);vec3 dispWeight=vec3(0.0);vec2 noiseOffset=noise.xy*(refractionLOD>0.0 ? lodTexelSize : 0.0);for (int k=0; k<6; k++) {float t=(float(k)+noise.y)/6.0;float t_rg=clamp(t*2.0,0.0,1.0);float t_gb=clamp((t-0.5)*2.0,0.0,1.0);vec3 refVec=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refVec*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;vec4 s=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD);float rw=max(0.0,1.0-2.0*t);float gw=max(0.0,1.0-abs(2.0*t-1.0));float bw=max(0.0,2.0*t-1.0);vec3 w=vec3(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;} +slab_translucent_background=vec4(dispResult/max(dispWeight,vec3(1e-6)),1.0);} +#else +for (int i=0; i<3; i++) {vec3 refractedViewVector=refractedViewVectors[i];vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;if (refractionLOD>0.0) {vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords,0.0)[i];}} +#endif +} +#else +{vec3 refractionUVW=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 refractionCoords=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;if (refractionLOD>0.0) { +#ifdef REFRACTION_HIGH_QUALITY_BLUR +float cosA=cos(noise.x*PI);float sinA=sin(noise.x*PI);vec2 u=vec2( cosA,sinA)*(0.5*lodTexelSize);vec2 v=vec2(-sinA,cosA)*(0.5*lodTexelSize);slab_translucent_background=0.25*( +texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u+v,refractionLOD) + +texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u+v,refractionLOD) + +texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u-v,refractionLOD) + +texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u-v,refractionLOD) +); +#else +vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords+noiseOffset,refractionLOD); +#endif +} else {slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords,0.0);}} +#endif +} +#endif +`;E.IncludesShadersStore[B3]||(E.IncludesShadersStore[B3]=nY)});var V3,aY,G3=C(()=>{w();V3="openpbrEnvironmentLighting",aY=`#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 +#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF) +vec3 environmentFuzzBrdf=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness)); +#endif +vec3 baseDiffuseEnvironmentLight=sampleIrradiance( +normalW +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +#endif +,vReflectionInfos +,viewDirectionW +,base_diffuse_roughness +,base_color +); +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=vec3(0.,0.,0.); +#else +vec2 reflectionCoords=vec2(0.,0.); +#endif +float specularAlphaG=specular_roughness*specular_roughness; +#ifdef ANISOTROPIC_BASE +vec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,baseGeoInfo +,normalW +,viewDirectionW +,vPositionW +,noise +,false +,1.0 +,reflectionSampler +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#else +reflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,baseGeoInfo +,reflectionSampler +,reflectionCoords +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#endif +#ifdef ANISOTROPIC_BASE +baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3)); +#else +baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG); +#endif +vec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) { +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=vec3(0.,0.,0.); +#else +vec2 reflectionCoords=vec2(0.,0.); +#endif +reflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness; +#ifdef ANISOTROPIC_COAT +coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,coatGeoInfo +,coatNormalW +,viewDirectionW +,vPositionW +,noise +,false +,1.0 +,reflectionSampler +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#else +coatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,coatGeoInfo +,reflectionSampler +,reflectionCoords +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#endif +} +#if defined(FUZZ) &&defined(FUZZENVIRONMENTBRDF) +float modifiedFuzzRoughness=clamp(fuzz_roughness*(1.0-0.5*environmentFuzzBrdf.y),0.0,1.0);vec3 fuzzEnvironmentLight=vec3(0.0);float totalWeight=0.0;float fuzzIblFresnel=sqrt(environmentFuzzBrdf.z);for (int i=0; i0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z; +#ifdef AMBIENT_OCCLUSION +coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness); +#endif +} +#if defined(FUZZ) &&defined(FUZZENVIRONMENTBRDF) +vec3 slab_fuzz_ibl=fuzzEnvironmentLight*vLightingIntensity.z; +#endif +vec3 slab_translucent_base_ibl=vec3(0.0);vec3 slab_subsurface_ibl=vec3(0.,0.,0.); +#ifdef REFRACTED_ENVIRONMENT +#ifdef ANISOTROPIC_BASE +vec3 forwardScatteredEnvironmentLight=sampleRadianceAnisotropic(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,baseGeoInfo +#ifdef GEOMETRY_THIN_WALLED +,viewDirectionW +#else +,normalW +#endif +,viewDirectionW +,vPositionW +,noise +,true +#ifdef GEOMETRY_THIN_WALLED +,1.05 +#else +,specular_ior +#endif +,reflectionSampler +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#else +vec3 forwardScatteredEnvironmentLight=vec3(0.,0.,0.); +#ifdef DISPERSION +for (int i=0; i<3; i++) {vec3 iblRefractionCoords=refractedViewVectors[i]; +#else +vec3 iblRefractionCoords=refractedViewVector; +#endif +#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ +iblRefractionCoords.z*=-1.0; +#endif +#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE +iblRefractionCoords=parallaxCorrectNormal(vPositionW,refractedViewVector,refractionSize,refractionPosition); +#endif +iblRefractionCoords=vec3(reflectionMatrix*vec4(iblRefractionCoords,0)); +#ifdef DISPERSION +forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,baseGeoInfo +,reflectionSampler +,iblRefractionCoords +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +)[i]; +#else +forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos +,baseGeoInfo +,reflectionSampler +,iblRefractionCoords +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#endif +#ifdef DISPERSION +} +#endif +#endif +#ifdef REFRACTED_BACKGROUND +#ifdef GEOMETRY_THIN_WALLED +forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha); +#else +forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha)); +#endif +#endif +#ifdef SCATTERING +#ifdef GEOMETRY_THIN_WALLED +vec3 scatterVector=normalW; +#else +#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION) +vec3 scatterVector=mix(vReflectionDominantDirection,normalW,max3(iso_scatter_density)); +#else +vec3 scatterVector=normalW; +#endif +scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend); +#endif +#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED) +vec3 scatteredEnvironmentLight=scattered_light_from_irradiance_texture; +#else +vec3 scatteredEnvironmentLight=sampleIrradiance( +scatterVector +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,vReflectionDominantDirection +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +#endif +,vReflectionInfos +,viewDirectionW +#if defined(GEOMETRY_THIN_WALLED) +,base_diffuse_roughness +,subsurface_color.rgb +#else +,1.0 +,volumeParams.multi_scatter_color +#endif +); +#endif +#ifdef GEOMETRY_THIN_WALLED +vec3 forward_scattered_light=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy); +#else +vec3 forward_scattered_light=forwardScatteredEnvironmentLight*volume_absorption;vec3 back_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);vec3 iso_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#endif +#else +slab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption; +#endif +#endif +#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION +slab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;vec3 material_dielectric_base_ibl=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0)); +#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF) +slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3(1.0),fuzz_color); +#else +material_surface_ibl=material_coated_base_ibl; +#endif +#elif defined(REFRACTED_BACKGROUND) +vec3 black=vec3(0.0);vec3 slab_translucent_base_ibl=vec3(0.0); +#ifdef GEOMETRY_THIN_WALLED +#ifdef SCATTERING +vec3 forward_scattered_light=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5+0.5*volumeParams.anisotropy); +#else +slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint; +#endif +#else +#ifdef SCATTERING +vec3 forward_scattered_light=slab_translucent_background.rgb*volume_absorption;vec3 iso_scattered_light=(1.0-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#else +slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint; +#endif +#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[V3]||(E.IncludesShadersStore[V3]=aY)});var k3,oY,W3=C(()=>{w();k3="openpbrDirectLightingInit",oY=`#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 +#define CUSTOM_LIGHT{X}_COLOR +#ifdef SPOTLIGHT{X} +preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW); +#elif defined(POINTLIGHT{X}) +preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW); +#elif defined(HEMILIGHT{X}) +preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW); +#elif defined(DIRLIGHT{X}) +preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness); +#endif +preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV; +#ifdef SPOTLIGHT{X} +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w); +#endif +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w); +#endif +#else +preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#ifdef IESLIGHTTEXTURE{X} +preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X}); +#else +preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); +#endif +#endif +#elif defined(POINTLIGHT{X}) +#ifdef LIGHT_FALLOFF_GLTF{X} +preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y); +#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared); +#elif defined(LIGHT_FALLOFF_STANDARD{X}) +preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x); +#else +preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); +#endif +#else +preInfo{X}.attenuation=1.0; +#endif +preInfoCoat{X}.attenuation=preInfo{X}.attenuation; +#if defined(HEMILIGHT{X}) +preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness; +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness; +#else +preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance); +#endif +preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb; +#endif +#endif +`;E.IncludesShadersStore[k3]||(E.IncludesShadersStore[k3]=oY)});var H3,lY,z3=C(()=>{w();H3="openpbrDirectLighting",lY=`#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); +#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb); +#else +slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb); +#endif +#ifdef PROJECTEDLIGHTTEXTURE{X} +slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW); +#endif +#ifdef FUZZ +float fuzzNdotH=max(dot(fuzzNormalW,preInfo{X}.H),0.0);vec3 fuzzBrdf=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness)); +#endif +#ifdef THIN_FILM +float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001); +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90); +#else +{ +#ifdef ANISOTROPIC_BASE +slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW, +baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy, +0.0,lightColor{X}.rgb); +#else +slab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb); +#endif +specularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color; +#ifdef THIN_FILM +vec3 thinFilmDielectricFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3(dot(thinFilmDielectricFresnel,vec3(0.3333))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale); +#endif +} +#endif +#ifdef REFRACTED_LIGHTS +vec3 forwardScatteredLight=vec3(0.0); +#if AREALIGHT{X} +#else +{preLightingInfo preInfoTrans=preInfo{X}; +#ifdef SCATTERING +preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05))); +#else +preInfoTrans.roughness=transmission_roughness; +#endif +if (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;} +#ifdef GEOMETRY_THIN_WALLED +vec3 refractNormalW=viewDirectionW; +#else +vec3 refractNormalW=normalW; +#endif +preInfoTrans.NdotL=0.5*max(dot(-refractNormalW,preInfoTrans.L),0.0)+0.5; +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +float diff=min(dispersion_iors[2]-dispersion_iors[0],max(dispersion_iors[0]-1.0,1.0));dispersion_iors[2]+=diff;dispersion_iors[0]-=diff;for (int i=0; i<3; i++) {float eta=1.0/dispersion_iors[i]; +#elif defined(GEOMETRY_THIN_WALLED) +float eta=1.0; +#else +float eta=1.0/specular_ior; +#endif +preInfoTrans.H=preInfoTrans.L+min(eta,0.95)*viewDirectionW;float len2=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inversesqrt(len2);} +#ifdef ANISOTROPIC_BASE +preInfoTrans.H=-preInfoTrans.H; +#endif +preInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H); +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +forwardScatteredLight[i]+= +#else +forwardScatteredLight+= +#endif +#if defined(ANISOTROPIC_BASE) +computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW, +baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy, +transmission_roughness_alpha,lightColor{X}.rgb +#else +computeSpecularLighting(preInfoTrans,-refractNormalW,vec3(1.0),vec3(1.0),transmission_roughness_alpha,lightColor{X}.rgb +#endif +#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED) +)[i];} +#else +); +#endif +#if !defined(GEOMETRY_THIN_WALLED) +forwardScatteredLight=mix(forwardScatteredLight,0.25*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0,1.0)); +#endif +#ifdef REFRACTED_BACKGROUND +#ifdef GEOMETRY_THIN_WALLED +forwardScatteredLight=mix(vec3(0.0),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha); +#else +forwardScatteredLight=max(vec3(0.0),mix(vec3(0.0),forwardScatteredLight,transmission_roughness_alpha)); +#endif +#endif +#ifdef SCATTERING +#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER) +preInfoTrans.roughness=1.0;vec3 diffused_forward_scattered_light=computeSpecularLighting(preInfoTrans,normalW,vec3(1.0),vec3(1.0),1.0,lightColor{X}.rgb)*volume_absorption; +#endif +#ifdef GEOMETRY_THIN_WALLED +vec3 forward_scattered_light=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy); +#else +vec3 back_scattered_normal=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0,1.0);preInfoTrans.roughness=0.2;vec3 back_scattered_light=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3(1.0),vec3(0.08),0.0,lightColor{X}.rgb);vec3 forward_scattered_light=(forwardScatteredLight*volume_absorption);vec3 iso_scattered_light=slab_diffuse;vec3 back_scattering=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density); +#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER) +vec3 iso_scattering=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density); +#else +vec3 iso_scattering=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density); +#endif +slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint; +#endif +#else +slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption; +#endif +} +#endif +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90); +#else +{ +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +vec3 coloredFresnel=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness); +#else +vec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90); +#endif +#ifdef THIN_FILM +float thinFilmConductorAngle=max(preInfo{X}.VdotH,specular_roughness);vec3 thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3(0.3333))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale); +#endif +#ifdef ANISOTROPIC_BASE +slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb); +#else +slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),coloredFresnel,specular_roughness,lightColor{X}.rgb); +#endif +} +#endif +#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) +slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90); +#else +{ +#ifdef ANISOTROPIC_COAT +slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW, +coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy, +0.0,lightColor{X}.rgb); +#else +slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb); +#endif +float NdotH=max(dot(coatNormalW,preInfoCoat{X}.H),0.0);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);} +#endif +vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;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);} +#ifdef FUZZ +fuzzFresnel=fuzzBrdf.z;vec3 fuzzNormalW=mix(normalW,coatNormalW,coat_weight);float fuzzNdotV=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0);float fuzzNdotL=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf); +#else +vec3 fuzz_color=vec3(0.0); +#endif +#ifdef PREPASS_IRRADIANCE +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[H3]||(E.IncludesShadersStore[H3]=lY)});var X3,cY,zA=C(()=>{w();X3="pbrBlockImageProcessing",cY=`#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING) +#if !defined(SKIPFINALCOLORCLAMP) +finalColor.rgb=clamp(finalColor.rgb,0.,30.0); +#endif +#else +finalColor=applyImageProcessing(finalColor); +#endif +finalColor.a*=visibility; +#ifdef PREMULTIPLYALPHA +finalColor.rgb*=finalColor.a; +#endif +`;E.IncludesShadersStore[X3]||(E.IncludesShadersStore[X3]=cY)});var Y3,fY,K3=C(()=>{w();Y3="openpbrBlockPrePass",fY=`#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); +#endif +#ifdef PREPASS_LOCAL_POSITION +gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo); +#endif +#if defined(PREPASS_VELOCITY) +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(base_color,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +vec3 sqAlbedo=sqrt(base_color); +#endif +#ifdef PREPASS_IRRADIANCE +vec3 irradiance=total_direct_diffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=slab_diffuse_ibl; +#endif +#endif +#ifdef SCATTERING +float scatter_mask=min(subsurface_weight+transmission_weight,1.0); +#else +float scatter_mask=0.0; +#endif +gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo*scatter_mask); +#endif +#if defined(PREPASS_COLOR) +gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a); +#endif +#ifdef PREPASS_DEPTH +gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); +#else +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#ifndef UNLIT +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo; +#else +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo; +#endif +#endif +#endif +`;E.IncludesShadersStore[Y3]||(E.IncludesShadersStore[Y3]=fY)});var j3,hY,XA=C(()=>{w();j3="pbrDebug",hY=`#if DEBUGMODE>0 +if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) { +#if DEBUGMODE==1 +gl_FragColor.rgb=vPositionW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==2 && defined(NORMAL) +gl_FragColor.rgb=vNormalW.rgb; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC) +gl_FragColor.rgb=TBN[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC) +gl_FragColor.rgb=TBN[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==5 +gl_FragColor.rgb=normalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==6 && defined(MAINUV1) +gl_FragColor.rgb=vec3(vMainUV1,0.0); +#elif DEBUGMODE==7 && defined(MAINUV2) +gl_FragColor.rgb=vec3(vMainUV2,0.0); +#elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) +gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP) +gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1]; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==10 && defined(CLEARCOAT) +gl_FragColor.rgb=clearcoatOut.clearCoatNormalW; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==11 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicNormal; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==12 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicTangent; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==13 && defined(ANISOTROPIC) +gl_FragColor.rgb=anisotropicOut.anisotropicBitangent; +#define DEBUGMODE_NORMALIZE +#elif DEBUGMODE==20 && defined(ALBEDO) +gl_FragColor.rgb=albedoTexture.rgb; +#ifndef GAMMAALBEDO +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==21 && defined(AMBIENT) +gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb; +#elif DEBUGMODE==22 && defined(OPACITY) +gl_FragColor.rgb=opacityMap.rgb; +#elif DEBUGMODE==23 && defined(EMISSIVE) +gl_FragColor.rgb=emissiveColorTex.rgb; +#ifndef GAMMAEMISSIVE +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==24 && defined(LIGHTMAP) +gl_FragColor.rgb=lightmapColor.rgb; +#ifndef GAMMALIGHTMAP +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb; +#elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0); +#elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb; +#elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE) +gl_FragColor.rgb=sheenOut.sheenMapData.rgb; +#elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE) +gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb; +#elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE) +gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb; +#elif DEBUGMODE==32 && defined(BUMP) +gl_FragColor.rgb=texture2D(bumpSampler,vBumpUV).rgb; +#elif DEBUGMODE==40 && defined(SS_REFRACTION) +gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==41 && defined(REFLECTION) +gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb; +#ifndef GAMMAREFLECTION +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION) +gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==50 +gl_FragColor.rgb=diffuseBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==51 && defined(SPECULARTERM) +gl_FragColor.rgb=specularBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==52 && defined(CLEARCOAT) +gl_FragColor.rgb=clearCoatBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==53 && defined(SHEEN) +gl_FragColor.rgb=sheenBase.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==54 && defined(REFLECTION) +gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb; +#ifndef GAMMAREFLECTION +#define DEBUGMODE_GAMMA +#endif +#elif DEBUGMODE==60 +gl_FragColor.rgb=surfaceAlbedo.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==61 +gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==62 && defined(METALLICWORKFLOW) +gl_FragColor.rgb=vec3(reflectivityOut.metallic); +#elif DEBUGMODE==71 && defined(METALLICWORKFLOW) +gl_FragColor.rgb=reflectivityOut.metallicF0; +#elif DEBUGMODE==63 +gl_FragColor.rgb=vec3(roughness); +#elif DEBUGMODE==64 +gl_FragColor.rgb=vec3(alphaG); +#elif DEBUGMODE==65 +gl_FragColor.rgb=vec3(NdotV); +#elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==67 && defined(CLEARCOAT) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness); +#elif DEBUGMODE==68 && defined(CLEARCOAT) +gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV); +#elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY) +gl_FragColor.rgb=subSurfaceOut.transmittance; +#elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION) +gl_FragColor.rgb=subSurfaceOut.refractionTransmittance; +#elif DEBUGMODE==72 +gl_FragColor.rgb=vec3(microSurface); +#elif DEBUGMODE==73 +gl_FragColor.rgb=vAlbedoColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==74 && !defined(METALLICWORKFLOW) +gl_FragColor.rgb=vReflectivityColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==75 +gl_FragColor.rgb=vEmissiveColor.rgb; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION) +gl_FragColor.rgb=vec3(seo); +#elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +gl_FragColor.rgb=vec3(eho); +#elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION) +gl_FragColor.rgb=vec3(energyConservationFactor); +#elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +gl_FragColor.rgb=baseSpecularEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION) +gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance; +#define DEBUGMODE_GAMMA +#elif DEBUGMODE==86 && defined(ALPHABLEND) +gl_FragColor.rgb=vec3(luminanceOverAlpha); +#elif DEBUGMODE==87 +gl_FragColor.rgb=vec3(alpha); +#elif DEBUGMODE==88 && defined(ALBEDO) +gl_FragColor.rgb=vec3(albedoTexture.a); +#elif DEBUGMODE==89 +gl_FragColor.rgb=aoOut.ambientOcclusionColor.rgb; +#else +float stripeWidth=30.;float stripePos=floor(gl_FragCoord.x/stripeWidth);float whichColor=mod(stripePos,2.);vec3 color1=vec3(.6,.2,.2);vec3 color2=vec3(.3,.1,.1);gl_FragColor.rgb=mix(color1,color2,whichColor); +#endif +gl_FragColor.rgb*=vDebugMode.y; +#ifdef DEBUGMODE_NORMALIZE +gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5; +#endif +#ifdef DEBUGMODE_GAMMA +gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb); +#endif +gl_FragColor.a=1.0; +#ifdef PREPASS +gl_FragData[0]=toLinearSpace(gl_FragColor); +gl_FragData[1]=vec4(0.,0.,0.,0.); +#endif +#ifdef DEBUGMODE_FORCERETURN +return; +#endif +} +#endif +`;E.IncludesShadersStore[j3]||(E.IncludesShadersStore[j3]=hY)});var q3={};Ie(q3,{openpbrPixelShader:()=>dY});var YA,Z3,dY,Q3=C(()=>{w();rp();sp();t3();OA();FA();np();ap();s3();lp();vn();ga();qc();Or();wA();BA();UA();cp();op();gf();VA();GA();_f();kA();WA();Xp();u3();p3();Bh();tA();g3();v3();iA();rA();T3();Sn();HA();x3();C3();M3();nA();sA();D3();L3();N3();w3();up();U3();G3();W3();z3();Uh();Qc();zA();K3();mp();XA();YA="openpbrPixelShader",Z3=`#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 +#endif +#ifdef LODBASEDMICROSFURACE +#extension GL_EXT_shader_texture_lod : enable +#endif +#define CUSTOM_FRAGMENT_BEGIN +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif +#include[SCENE_MRT_COUNT] +precision highp float; +#include +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE +#endif +#include<__decl__openpbrFragment> +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REFLECTION +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +#include +#include +#include +#include +#include +vec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);} +void main(void) { +#ifdef PREPASS_IRRADIANCE +vec3 total_direct_diffuse=vec3(0.0); +#endif +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#include +vec3 coatNormalW=normalW; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define CUSTOM_FRAGMENT_UPDATE_ALPHA +#include +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +#ifdef ANISOTROPIC_COAT +geometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso( +coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW +,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN +); +#else +geometryInfoOutParams coatGeoInfo=geometryInfo( +coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW +); +#endif +specular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight); +#ifdef ANISOTROPIC_BASE +geometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso( +normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW +,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN +); +#else +geometryInfoOutParams baseGeoInfo=geometryInfo( +normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW +); +#endif +#ifdef FUZZ +vec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo( +fuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW +); +#endif +ReflectanceParams coatReflectance;coatReflectance=dielectricReflectance( +coat_ior +,1.0 +,vec3(1.0) +,coat_weight +); +#ifdef THIN_FILM +float thin_film_outside_ior=mix(1.0,coat_ior,coat_weight); +#endif +ReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance( +specular_ior +,effectiveCoatIor +,specular_color +,specular_weight +);} +ReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0; +#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS) +#if defined(GEOMETRY_THIN_WALLED) +vec3 refractedViewVector=-viewDirectionW; +#else +#ifdef DISPERSION +vec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); } +#else +vec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior); +#endif +#endif +#ifdef GEOMETRY_THIN_WALLED +float transmission_roughness=specular_roughness; +#else +float transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0); +#endif +#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB)) +OpenPBRHomogeneousVolume volumeParams;{ +#if defined(TRANSMISSION_SLAB) +OpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume( +transmission_color.rgb, +transmission_depth, +transmission_scatter.rgb, +transmission_scatter_anisotropy +); +#endif +#if defined(SUBSURFACE_SLAB) +OpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume( +subsurface_color.rgb, +subsurface_radius, +subsurface_radius_scale.rgb, +subsurface_scatter_anisotropy +); +#endif +#if !defined(TRANSMISSION_SLAB) +volumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight; +#elif !defined(SUBSURFACE_SLAB) +volumeParams=transmissionVolumeParams; +#ifdef TRANSMISSION_SLAB_VOLUME +volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo); +#endif +surface_translucency_weight=transmission_weight; +#else +float subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric = +1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric; +#endif +} +volume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);} +#elif defined(TRANSMISSION_SLAB) +surface_translucency_weight=transmission_weight; +#endif +#ifdef SCATTERING +#ifdef GEOMETRY_THIN_WALLED +vec3 iso_scatter_density=vec3(1.0); +#else +#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING +vec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,SSS_SAMPLE_COUNT,noise.xy);float numLights=float(LIGHTCOUNT); +#ifdef REFLECTION +numLights+=1.0; +#endif +scattered_light_from_irradiance_texture/=numLights; +#else +vec3 scattered_light_from_irradiance_texture=vec3(0.0); +#endif +float back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);transmission_roughness=min(transmission_roughness+pow((1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0),1.0); +#endif +volumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density)); +#endif +#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED)) +transmission_tint*=transmission_color.rgb; +#ifdef GEOMETRY_THIN_WALLED +float sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength)); +#else +transmission_tint*=transmission_color.rgb; +#endif +#endif +#if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED) +float unweighted_translucency=mix(subsurface_weight,1.0f,transmission_weight);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0,transmission_roughness,transmission_weight/unweighted_translucency); +#endif +float transmission_roughness_alpha=transmission_roughness*transmission_roughness; +#endif +#include +vec3 material_surface_ibl=vec3(0.,0.,0.); +#include +vec3 material_surface_direct=vec3(0.,0.,0.); +#if defined(LIGHT0) +float aggShadow=0.; +#include[0..maxSimultaneousLights] +#include[0..maxSimultaneousLights] +#endif +vec3 material_surface_emission=vEmissionColor; +#ifdef EMISSION_COLOR +vec3 emissionColorTex=texture2D(emissionColorSampler,vEmissionColorUV+uvOffset).rgb; +#ifdef EMISSION_COLOR_GAMMA +material_surface_emission*=toLinearSpace(emissionColorTex.rgb); +#else +material_surface_emission*=emissionColorTex.rgb; +#endif +material_surface_emission*= vEmissionColorInfos.y; +#endif +material_surface_emission*=vLightingIntensity.y; +#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION +vec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha); +#define CUSTOM_FRAGMENT_BEFORE_FOG +finalColor=max(finalColor,0.0); +#include +#include(color,finalColor) +#include +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#include +#endif +#if !defined(PREPASS) || defined(WEBGL2) +gl_FragColor=finalColor; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;} +#endif +#include +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStore[YA]||(E.ShadersStore[YA]=Z3);dY={name:YA,shader:Z3}});var J3={};Ie(J3,{OpenPBRMaterial:()=>ge,OpenPBRMaterialDefines:()=>jh});var Sf,jp,ct,Et,KA,jA,jh,ZA,ge,$3=C(()=>{$e();Qe();Wp();Je();oh();pi();Pt();Vi();jt();Ur();Em();mo();Ps();Ih();Ui();It();vm();gm();ns();We();Sm();Tm();ew();Ee();Am();Hc();As();At();Uw();Sf={effect:null,subMesh:null},jp=class s{populateVectorFromLinkedProperties(e){let t=e.dimension[0];for(let i in this.linkedProperties){let r=this.linkedProperties[i],n=r.numComponents;if(tt-n){n==1?X.Error(`Float property ${r.name} has an offset that is too large.`):X.Error(`Vector${n} property ${r.name} won't fit in Vector${t} or has an offset that is too large.`);return}typeof r.value=="number"?s._tmpArray[r.targetUniformComponentOffset]=r.value:r.value.toArray(s._tmpArray,r.targetUniformComponentOffset)}e.fromArray(s._tmpArray)}constructor(e,t){this.linkedProperties={},this.firstLinkedKey="",this.name=e,this.numComponents=t}};jp._tmpArray=[0,0,0,0];ct=class{constructor(e,t,i,r,n=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=n,this.requiredDefine=a}get numComponents(){return typeof this.defaultValue=="number"?1:this.defaultValue.dimension[0]}},Et=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}},KA=class extends sf(rf(qt)){},jA=class extends $F(KA){},jh=class extends ef(jA){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}},ZA=class extends nf(os){},ge=class s extends ZA{get geometryTangentAngle(){return Math.atan2(this.geometryTangent.y,this.geometryTangent.x)}set geometryTangentAngle(e){this.geometryTangent=new me(Math.cos(e),Math.sin(e))}get geometryCoatTangentAngle(){return Math.atan2(this.geometryCoatTangent.y,this.geometryCoatTangent.x)}set geometryCoatTangentAngle(e){this.geometryCoatTangent=new me(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(ae.BlackReadOnly)||this.subsurfaceWeight>0}get usePhysicalLightFalloff(){return this._lightFalloff===oe.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=oe.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=oe.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===oe.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=oe.LIGHTFALLOFF_GLTF:this._lightFalloff=oe.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 n;super(e,t,void 0,i||s.ForceGLSL),this._baseWeight=new ct("base_weight",1,"vBaseWeight",1),this._baseWeightTexture=new Et("base_weight","baseWeight","BASE_WEIGHT"),this._baseColor=new ct("base_color",ae.White(),"vBaseColor",4),this._baseColorTexture=new Et("base_color","baseColor","BASE_COLOR"),this._baseDiffuseRoughness=new ct("base_diffuse_roughness",0,"vBaseDiffuseRoughness",1),this._baseDiffuseRoughnessTexture=new Et("base_diffuse_roughness","baseDiffuseRoughness","BASE_DIFFUSE_ROUGHNESS"),this._baseMetalness=new ct("base_metalness",0,"vReflectanceInfo",4,0),this._baseMetalnessTexture=new Et("base_metalness","baseMetalness","BASE_METALNESS"),this._specularWeight=new ct("specular_weight",1,"vReflectanceInfo",4,3),this._specularWeightTexture=new Et("specular_weight","specularWeight","SPECULAR_WEIGHT"),this._specularColor=new ct("specular_color",ae.White(),"vSpecularColor",4),this._specularColorTexture=new Et("specular_color","specularColor","SPECULAR_COLOR"),this._specularRoughness=new ct("specular_roughness",.3,"vReflectanceInfo",4,1),this._specularRoughnessTexture=new Et("specular_roughness","specularRoughness","SPECULAR_ROUGHNESS"),this._specularRoughnessAnisotropy=new ct("specular_roughness_anisotropy",0,"vSpecularAnisotropy",3,2),this._specularRoughnessAnisotropyTexture=new Et("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 Et("transmission_weight","transmissionWeight","TRANSMISSION_WEIGHT"),this._transmissionColor=new ct("transmission_color",ae.White(),"vTransmissionColor",3,0),this._transmissionColorTexture=new Et("transmission_color","transmissionColor","TRANSMISSION_COLOR"),this._transmissionDepth=new ct("transmission_depth",0,"vTransmissionDepth",1,0),this._transmissionDepthTexture=new Et("transmission_depth","transmissionDepth","TRANSMISSION_DEPTH"),this._transmissionScatter=new ct("transmission_scatter",ae.Black(),"vTransmissionScatter",3,0),this._transmissionScatterTexture=new Et("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 Et("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 Et("subsurface_weight","subsurfaceWeight","SUBSURFACE_WEIGHT"),this._subsurfaceColor=new ct("subsurface_color",new ae(.8,.8,.8),"vSubsurfaceColor",3,0,"SUBSURFACE_SLAB"),this._subsurfaceColorTexture=new Et("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 ae(1,.5,.25),"vSubsurfaceRadiusScale",3,0,"SUBSURFACE_SLAB"),this._subsurfaceRadiusScaleTexture=new Et("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 Et("coat_weight","coatWeight","COAT_WEIGHT"),this._coatColor=new ct("coat_color",ae.White(),"vCoatColor",3,0),this._coatColorTexture=new Et("coat_color","coatColor","COAT_COLOR"),this._coatRoughness=new ct("coat_roughness",0,"vCoatRoughness",1,0),this._coatRoughnessTexture=new Et("coat_roughness","coatRoughness","COAT_ROUGHNESS"),this._coatRoughnessAnisotropy=new ct("coat_roughness_anisotropy",0,"vCoatRoughnessAnisotropy",1),this._coatRoughnessAnisotropyTexture=new Et("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 Et("coat_darkening","coatDarkening","COAT_DARKENING"),this.useCoatRoughnessFromWeightTexture=!1,this._fuzzWeight=new ct("fuzz_weight",0,"vFuzzWeight",1,0),this._fuzzWeightTexture=new Et("fuzz_weight","fuzzWeight","FUZZ_WEIGHT"),this._fuzzColor=new ct("fuzz_color",ae.White(),"vFuzzColor",3,0),this._fuzzColorTexture=new Et("fuzz_color","fuzzColor","FUZZ_COLOR"),this._fuzzRoughness=new ct("fuzz_roughness",.5,"vFuzzRoughness",1,0),this._fuzzRoughnessTexture=new Et("fuzz_roughness","fuzzRoughness","FUZZ_ROUGHNESS"),this._geometryThinWalled=new ct("geometry_thin_walled",0,"vGeometryThinWalled",1,0),this._geometryNormalTexture=new Et("geometry_normal","geometryNormal","GEOMETRY_NORMAL"),this._geometryTangent=new ct("geometry_tangent",new me(1,0),"vSpecularAnisotropy",3,0),this._geometryTangentTexture=new Et("geometry_tangent","geometryTangent","GEOMETRY_TANGENT"),this._geometryCoatNormalTexture=new Et("geometry_coat_normal","geometryCoatNormal","GEOMETRY_COAT_NORMAL"),this._geometryCoatTangent=new ct("geometry_coat_tangent",new me(1,0),"vGeometryCoatTangent",2,0),this._geometryCoatTangentTexture=new Et("geometry_coat_tangent","geometryCoatTangent","GEOMETRY_COAT_TANGENT"),this._geometryOpacity=new ct("geometry_opacity",1,"vBaseColor",4,3),this._geometryOpacityTexture=new Et("geometry_opacity","geometryOpacity","GEOMETRY_OPACITY"),this._geometryThickness=new ct("geometry_thickness",0,"vGeometryThickness",1,0),this._geometryThicknessTexture=new Et("geometry_thickness","geometryThickness","GEOMETRY_THICKNESS"),this._emissionLuminance=new ct("emission_luminance",1,"vLightingIntensity",4,1),this._emissionColor=new ct("emission_color",ae.Black(),"vEmissionColor",3),this._emissionColorTexture=new Et("emission_color","emissionColor","EMISSION_COLOR"),this._thinFilmWeight=new ct("thin_film_weight",0,"vThinFilmWeight",1,0),this._thinFilmWeightTexture=new Et("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 Et("thin_film_thickness","thinFilmThickness","THIN_FILM_THICKNESS"),this._thinFilmIor=new ct("thin_film_ior",1.4,"vThinFilmIor",1,0),this._ambientOcclusionTexture=new Et("ambient_occlusion","ambientOcclusion","AMBIENT_OCCLUSION"),this._sssQuality=s.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 ft(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=oe.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 yt(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=oe.MATERIAL_OPAQUE,this.getScene()&&!((n=this.getScene())!=null&&n.getEngine().isWebGPU)&&this.getScene().getEngine().webGLVersion<2&&X.Error("OpenPBRMaterial: WebGL 2.0 or above is required for this material."),s._noiseTextures[this.getScene().uniqueId]||(s._noiseTextures[this.getScene().uniqueId]=new ne(se.GetAssetUrl("https://assets.babylonjs.com/core/blue_noise/blue_noise_rgb.png"),this.getScene(),!1,!0,1),this.getScene().onDisposeObservable.addOnce(()=>{var a;(a=s._noiseTextures[this.getScene().uniqueId])==null||a.dispose(),delete s._noiseTextures[this.getScene().uniqueId]})),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),re.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget&&this._renderTargets.push(this._radianceTexture),re.RefractionTextureEnabled&&this._backgroundRefractionTexture&&this._backgroundRefractionTexture.isRenderTarget&&this._renderTargets.push(this._backgroundRefractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=JF(this.getScene()),this._environmentFuzzBRDFTexture=JT(this.getScene()),this.prePassConfiguration=new xr,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?X.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 jp(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 Et&&(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 re.ReflectionTextureEnabled&&this._radianceTexture&&this._radianceTexture.isRenderTarget||re.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!==oe.MATERIAL_OPAQUE&&!this.geometryOpacityTexture}_hasAlphaChannel(){return this.baseColorTexture!=null&&this.baseColorTexture.hasAlpha&&this._useAlphaFromBaseColorTexture||this.geometryOpacityTexture!=null}clone(e,t=!0,i=""){let r=De.Clone(()=>new s(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=De.Parse(()=>new s(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),oe._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 jh({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Sf.effect=o,Sf.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Sf)),o.isReady()?t&&t(this):o.onCompileObservable.add(()=>{t&&t(this)})})()}isReadyForSubMesh(e,t,i){var d;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 jh({...this._eventInfo.defineNames||{},...this._samplerDefines||{}}));let n=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(n._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&&re.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((d=u.getInternalTexture())!=null&&d._sphericalPolynomialPromise))return!1}if(this._environmentBRDFTexture&&re.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady()||this._environmentFuzzBRDFTexture&&re.ReflectionTextureEnabled&&!this._environmentFuzzBRDFTexture.isReady()||this._backgroundRefractionTexture&&re.RefractionTextureEnabled&&!this._backgroundRefractionTexture.isReadyOrNotBlocking()||s._noiseTextures[a.uniqueId]&&!s._noiseTextures[a.uniqueId].isReady()||this._sssIrradianceTexture&&this._sssDepthTexture&&(!this._sssIrradianceTexture.isReady()||!this._sssDepthTexture.isReady()))return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=n,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||n._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(n.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(W.Vector3[0]);let n=Math.max(Math.abs(W.Vector3[0].x),Math.abs(W.Vector3[0].y),Math.abs(W.Vector3[0].z));e.updateFloat("vGeometryThickness",this.geometryThickness*n)}}bindForSubMesh(e,t,i){var h;let r=this.getScene(),n=i.materialDefines;if(!n)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),qi.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),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);Sr(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&_o(this._activeEffect,this._vertexPullingMetadata);let f=this._uniformBuffer;if(c){this.bindViewProjection(a);let d=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)),Ic(r,n,f,ae.White(),d,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 n in this._samplersList)(i=this._samplersList[n].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,n=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 Zi,h=0;i.USESPHERICALINVERTEX&&f.addFallback(h++,"USESPHERICALINVERTEX"),i.FOG&&f.addFallback(h,"FOG"),i.SPECULARAA&&f.addFallback(h,"SPECULARAA"),i.POINTSIZE&&f.addFallback(h,"POINTSIZE"),i.LOGARITHMICDEPTH&&f.addFallback(h,"LOGARITHMICDEPTH"),i.PARALLAX&&f.addFallback(h,"PARALLAX"),i.PARALLAX_RHS&&f.addFallback(h,"PARALLAX_RHS"),i.PARALLAXOCCLUSION&&f.addFallback(h++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&f.addFallback(h++,"ENVIRONMENTBRDF"),i.TANGENT&&f.addFallback(h++,"TANGENT"),h=yc(i,f,this._maxSimultaneousLights,h),i.SPECULARTERM&&f.addFallback(h++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&f.addFallback(h++,"USESPHERICALFROMREFLECTIONMAP"),i.USEIRRADIANCEMAP&&f.addFallback(h++,"USEIRRADIANCEMAP"),i.NORMAL&&f.addFallback(h++,"NORMAL"),i.VERTEXCOLOR&&f.addFallback(h++,"VERTEXCOLOR"),i.MORPHTARGETS&&f.addFallback(h++,"MORPHTARGETS"),i.MULTIVIEW&&f.addFallback(0,"MULTIVIEW");let d=[y.PositionKind];i.NORMAL&&d.push(y.NormalKind),i.TANGENT&&d.push(y.TangentKind);for(let T=1;T<=6;++T)i["UV"+T]&&d.push(`uv${T===1?"":T}`);i.VERTEXCOLOR&&d.push(y.ColorKind),Mc(d,e,i,f),io(d,i),dl(d,e,i),Cc(d,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 T in this._uniformsList)m.push(T);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 T in this._samplersList){let A=this._samplersList[T];p.push(A.samplerName),m.push(A.samplerInfoName),m.push(A.samplerMatrixName)}oo(m,p,!0);let _=["Material","Scene","Mesh"],g={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS};if(this._eventInfo.fallbacks=f,this._eventInfo.fallbackRank=h,this._eventInfo.defines=i,this._eventInfo.uniforms=m,this._eventInfo.attributes=d,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),qi.AddUniformsAndSamplers(m,p),xr.AddUniforms(m),xr.AddSamplers(p),Pi(m),this._useVertexPulling){let T=t==null?void 0:t.geometry;T&&(this._vertexPullingMetadata=po(T),this._vertexPullingMetadata&&this._vertexPullingMetadata.forEach((A,R)=>{m.push(`vp_${R}_info`)}))}else this._vertexPullingMetadata=null;et&&(et.PrepareUniforms(m,i),et.PrepareSamplers(p,i)),lo({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let v={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,d,v));let I=i.toString(),x=c.createEffect(u,{attributes:d,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:I,fallbacks:f,onCompiled:r,onError:n,indexParameters:g,processFinalCode:v.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(()=>(Yw(),Xw)),Promise.resolve().then(()=>(H1(),W1))]):await Promise.all([Promise.resolve().then(()=>($1(),J1)),Promise.resolve().then(()=>(Q3(),q3))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,x}_prepareDefines(e,t,i,r=null,n=null){var h;let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Pc(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Lc(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Nc(o,i,this.canRenderToMRT&&!c),Oc(o,i,c),qi.PrepareDefines(l.currentRenderPassId,e,i),i._areTexturesDirty){i._needUVs=!1;for(let d=1;d<=6;++d)i["MAINUV"+d]=!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 d=this._getRadianceTexture(),u=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;if(so(o,d,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&&re.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&&re.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&&re.RefractionTextureEnabled,i.REFRACTION_HIGH_QUALITY_BLUR=this._refractionHighQualityBlur,i.REFRACTED_LIGHTS=!0;let m=this._getRadianceTexture();m?(i.REFRACTED_ENVIRONMENT=re.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===oe.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===oe.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)&&s._noiseTextures[o.uniqueId]&&re.ReflectionTextureEnabled?(i.ANISOTROPIC=!0,e.isVerticesDataPresent(y.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=(h=f[this._sssQuality])!=null?h: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 d=!1;if(!this.sssIrradianceTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(lr.IRRADIANCE_TEXTURE_TYPE);this.sssIrradianceTexture=o.geometryBufferRenderer.getGBuffer().textures[u],d=!0}if(!this.sssDepthTexture&&o.geometryBufferRenderer){let u=o.geometryBufferRenderer.getTextureIndex(lr.SCREENSPACE_DEPTH_TEXTURE_TYPE);this.sssDepthTexture=o.geometryBufferRenderer.getGBuffer().textures[u],d=!0}this.sssIrradianceTexture&&this.sssDepthTexture&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING=!0,d&&(i.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER=!0))}i.FUZZ=this.fuzzWeight>0&&re.ReflectionTextureEnabled,i.GEOMETRY_THIN_WALLED=this.geometryThinWalled!=0,i.FUZZ?(e.isVerticesDataPresent(y.TangentKind)||(i._needUVs=!0,i.MAINUV1=!0),this._environmentFuzzBRDFTexture=JT(this.getScene()),i.FUZZ_IBL_SAMPLES=this.fuzzSampleNumber):(this._environmentFuzzBRDFTexture=null,i.FUZZENVIRONMENTBRDF=!1,i.FUZZ_IBL_SAMPLES=0),i._areMiscDirty&&(ro(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(y.NormalKind),i.DEBUGMODE=this._debugMode),no(o,l,this,i,!!r,n,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),ao(e,i,!0,!0,!0,this._transparencyMode!==oe.MATERIAL_OPAQUE),this._callbackPluginEventPrepareDefines(this._eventInfo)}};ge.SSS_QUALITY_LOW=0;ge.SSS_QUALITY_MEDIUM=1;ge.SSS_QUALITY_HIGH=2;ge._noiseTextures={};ge.ForceGLSL=!1;b([Ue("_markAllSubMeshesAsTexturesDirty","baseWeight")],ge.prototype,"_baseWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseWeightTexture")],ge.prototype,"_baseWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseColor")],ge.prototype,"_baseColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseColorTexture")],ge.prototype,"_baseColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughness")],ge.prototype,"_baseDiffuseRoughness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseDiffuseRoughnessTexture")],ge.prototype,"_baseDiffuseRoughnessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseMetalness")],ge.prototype,"_baseMetalness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","baseMetalnessTexture")],ge.prototype,"_baseMetalnessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularWeight")],ge.prototype,"_specularWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularWeightTexture")],ge.prototype,"_specularWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularColor")],ge.prototype,"_specularColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularColorTexture")],ge.prototype,"_specularColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularRoughness")],ge.prototype,"_specularRoughness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularRoughnessTexture")],ge.prototype,"_specularRoughnessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropy")],ge.prototype,"_specularRoughnessAnisotropy",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularRoughnessAnisotropyTexture")],ge.prototype,"_specularRoughnessAnisotropyTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","specularIor")],ge.prototype,"_specularIor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionWeight")],ge.prototype,"_transmissionWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionWeightTexture")],ge.prototype,"_transmissionWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionColor")],ge.prototype,"_transmissionColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionColorTexture")],ge.prototype,"_transmissionColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionDepth")],ge.prototype,"_transmissionDepth",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionDepthTexture")],ge.prototype,"_transmissionDepthTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionScatter")],ge.prototype,"_transmissionScatter",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionScatterTexture")],ge.prototype,"_transmissionScatterTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionScatterAnisotropy")],ge.prototype,"_transmissionScatterAnisotropy",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScale")],ge.prototype,"_transmissionDispersionScale",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionDispersionScaleTexture")],ge.prototype,"_transmissionDispersionScaleTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","transmissionDispersionAbbeNumber")],ge.prototype,"_transmissionDispersionAbbeNumber",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceWeight")],ge.prototype,"_subsurfaceWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceWeightTexture")],ge.prototype,"_subsurfaceWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceColor")],ge.prototype,"_subsurfaceColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceColorTexture")],ge.prototype,"_subsurfaceColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceRadius")],ge.prototype,"_subsurfaceRadius",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScale")],ge.prototype,"_subsurfaceRadiusScale",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceRadiusScaleTexture")],ge.prototype,"_subsurfaceRadiusScaleTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","subsurfaceScatterAnisotropy")],ge.prototype,"_subsurfaceScatterAnisotropy",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatWeight")],ge.prototype,"_coatWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatWeightTexture")],ge.prototype,"_coatWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatColor")],ge.prototype,"_coatColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatColorTexture")],ge.prototype,"_coatColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatRoughness")],ge.prototype,"_coatRoughness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatRoughnessTexture")],ge.prototype,"_coatRoughnessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropy")],ge.prototype,"_coatRoughnessAnisotropy",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatRoughnessAnisotropyTexture")],ge.prototype,"_coatRoughnessAnisotropyTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatIor")],ge.prototype,"_coatIor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatDarkening")],ge.prototype,"_coatDarkening",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","coatDarkeningTexture")],ge.prototype,"_coatDarkeningTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzWeight")],ge.prototype,"_fuzzWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzWeightTexture")],ge.prototype,"_fuzzWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzColor")],ge.prototype,"_fuzzColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzColorTexture")],ge.prototype,"_fuzzColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzRoughness")],ge.prototype,"_fuzzRoughness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","fuzzRoughnessTexture")],ge.prototype,"_fuzzRoughnessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryThinWalled")],ge.prototype,"_geometryThinWalled",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryNormalTexture")],ge.prototype,"_geometryNormalTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryTangent")],ge.prototype,"_geometryTangent",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryTangentTexture")],ge.prototype,"_geometryTangentTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryCoatNormalTexture")],ge.prototype,"_geometryCoatNormalTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryCoatTangent")],ge.prototype,"_geometryCoatTangent",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryCoatTangentTexture")],ge.prototype,"_geometryCoatTangentTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryOpacity")],ge.prototype,"_geometryOpacity",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryOpacityTexture")],ge.prototype,"_geometryOpacityTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryThickness")],ge.prototype,"_geometryThickness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","geometryThicknessTexture")],ge.prototype,"_geometryThicknessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","emissionLuminance")],ge.prototype,"_emissionLuminance",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","emissionColor")],ge.prototype,"_emissionColor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","emissionColorTexture")],ge.prototype,"_emissionColorTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmWeight")],ge.prototype,"_thinFilmWeight",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmWeightTexture")],ge.prototype,"_thinFilmWeightTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmThickness")],ge.prototype,"_thinFilmThickness",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessMin")],ge.prototype,"_thinFilmThicknessMin",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmThicknessTexture")],ge.prototype,"_thinFilmThicknessTexture",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","thinFilmIor")],ge.prototype,"_thinFilmIor",void 0);b([Ue("_markAllSubMeshesAsTexturesDirty","ambientOcclusionTexture")],ge.prototype,"_ambientOcclusionTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"directIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"environmentIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useSpecularWeightFromTextureAlpha",void 0);b([L(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],ge.prototype,"forceAlphaTest",void 0);b([L(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],ge.prototype,"alphaCutOff",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useAmbientInGrayScale",void 0);b([L()],ge.prototype,"usePhysicalLightFalloff",null);b([L()],ge.prototype,"useGLTFLightFalloff",null);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useObjectSpaceNormalMap",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useParallax",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useParallaxOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"parallaxScaleBias",void 0);b([L(),ie("_markAllSubMeshesAsLightsDirty")],ge.prototype,"disableLighting",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"forceIrradianceInFragment",void 0);b([L(),ie("_markAllSubMeshesAsLightsDirty")],ge.prototype,"maxSimultaneousLights",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"invertNormalMapX",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"invertNormalMapY",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"twoSidedLighting",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useAlphaFresnel",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useLinearAlphaFresnel",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"environmentBRDFTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"forceNormalForward",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"enableSpecularAntiAliasing",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useHorizonOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],ge.prototype,"useRadianceOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ge.prototype,"unlit",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ge.prototype,"applyDecalMapAfterDetailMap",void 0);b([ie("_markAllSubMeshesAsMiscDirty")],ge.prototype,"debugMode",void 0);b([L()],ge.prototype,"transparencyMode",null);Ke("BABYLON.OpenPBRMaterial",ge)});var e2={};Ie(e2,{OpenPBRMaterialLoadingAdapter:()=>qA});var qA,t2=C(()=>{Je();qA=class{constructor(e){this._diffuseTransmissionTint=ae.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(ae.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(ae.White())||this._diffuseTransmissionTintTexture)&&(this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture):this._material.coatWeight==0&&(!this.baseColor.equals(ae.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(ae.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 QA,ai,i2=C(()=>{$e();Qe();Ur();vo();QA=class extends qt{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}},ai=class s extends hi{_markAllSubMeshesAsMiscDirty(){this._internalMarkAllSubMeshesAsMiscDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRBRDF",90,new QA,t),this._useEnergyConservation=s.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=s.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=s.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=s.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=s.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=s.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=s.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=s.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._mixIblRadianceWithIrradiance=s.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this.mixIblRadianceWithIrradiance=s.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE,this._useLegacySpecularEnergyConservation=s.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this.useLegacySpecularEnergyConservation=s.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION,this._baseDiffuseModel=s.DEFAULT_DIFFUSE_MODEL,this.baseDiffuseModel=s.DEFAULT_DIFFUSE_MODEL,this._dielectricSpecularModel=s.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this.dielectricSpecularModel=s.DEFAULT_DIELECTRIC_SPECULAR_MODEL,this._conductorSpecularModel=s.DEFAULT_CONDUCTOR_SPECULAR_MODEL,this.conductorSpecularModel=s.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"}};ai.DEFAULT_USE_ENERGY_CONSERVATION=!0;ai.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0;ai.DEFAULT_USE_SPHERICAL_HARMONICS=!0;ai.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0;ai.DEFAULT_MIX_IBL_RADIANCE_WITH_IRRADIANCE=!0;ai.DEFAULT_USE_LEGACY_SPECULAR_ENERGY_CONSERVATION=!0;ai.DEFAULT_DIFFUSE_MODEL=0;ai.DEFAULT_DIELECTRIC_SPECULAR_MODEL=0;ai.DEFAULT_CONDUCTOR_SPECULAR_MODEL=0;b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"useEnergyConservation",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"useSmithVisibilityHeightCorrelated",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"useSphericalHarmonics",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"useSpecularGlossinessInputEnergyConservation",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"mixIblRadianceWithIrradiance",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"useLegacySpecularEnergyConservation",void 0);b([L("baseDiffuseModel"),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"baseDiffuseModel",void 0);b([L("dielectricSpecularModel"),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"dielectricSpecularModel",void 0);b([L("conductorSpecularModel"),ie("_markAllSubMeshesAsMiscDirty")],ai.prototype,"conductorSpecularModel",void 0)});var JA,Ri,r2=C(()=>{$e();Qe();Je();ns();vo();Ur();Ui();JA=class extends qt{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}},Ri=class s extends hi{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRClearCoat",100,new JA,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=s._DefaultIndexOfRefraction,this.indexOfRefraction=s._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=ae.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&&re.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&re.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking()||i.getCaps().standardDerivatives&&this._bumpTexture&&re.ClearCoatBumpTextureEnabled&&!r&&!this._bumpTexture.isReady()||this._isTintEnabled&&this._tintTexture&&re.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&&re.ClearCoatTextureEnabled?ot(this._texture,e,"CLEARCOAT_TEXTURE"):e.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&re.ClearCoatTextureEnabled?ot(this._textureRoughness,e,"CLEARCOAT_TEXTURE_ROUGHNESS"):e.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&re.ClearCoatBumpTextureEnabled?ot(this._bumpTexture,e,"CLEARCOAT_BUMP"):e.CLEARCOAT_BUMP=!1,e.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===s._DefaultIndexOfRefraction,this._isTintEnabled?(e.CLEARCOAT_TINT=!0,this._tintTexture&&re.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,h,d,u,m,p,_,g;if(!this._isEnabled)return;let n=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)&&re.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",(h=(f=this._texture)==null?void 0:f.coordinatesIndex)!=null?h:0,(u=(d=this._texture)==null?void 0:d.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&&!n.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&<(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&re.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&&re.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),lt(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);let v=1-this._indexOfRefraction,I=1+this._indexOfRefraction,x=Math.pow(-v/I,2),T=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",x,T,v,I),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&&re.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!n.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&re.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&re.ClearCoatBumpTextureEnabled&&!o&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&re.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,n;e&&((t=this._texture)==null||t.dispose(),(i=this._textureRoughness)==null||i.dispose(),(r=this._bumpTexture)==null||r.dispose(),(n=this._tintTexture)==null||n.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"}]}}};Ri._DefaultIndexOfRefraction=1.5;b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"isEnabled",void 0);b([L()],Ri.prototype,"intensity",void 0);b([L()],Ri.prototype,"roughness",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"indexOfRefraction",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"texture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"useRoughnessFromMainTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"textureRoughness",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"remapF0OnInterfaceChange",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"bumpTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"isTintEnabled",void 0);b([Kt()],Ri.prototype,"tintColor",void 0);b([L()],Ri.prototype,"tintColorAtDistance",void 0);b([L()],Ri.prototype,"tintThickness",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Ri.prototype,"tintTexture",void 0)});var $A,Cr,s2=C(()=>{$e();Qe();ns();vo();Ur();Ui();$A=class extends qt{constructor(){super(...arguments),this.IRIDESCENCE=!1,this.IRIDESCENCE_TEXTURE=!1,this.IRIDESCENCE_TEXTUREDIRECTUV=0,this.IRIDESCENCE_THICKNESS_TEXTURE=!1,this.IRIDESCENCE_THICKNESS_TEXTUREDIRECTUV=0}},Cr=class s extends hi{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"PBRIridescence",110,new $A,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.minimumThickness=s._DefaultMinimumThickness,this.maximumThickness=s._DefaultMaximumThickness,this.indexOfRefraction=s._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&&re.IridescenceTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._thicknessTexture&&re.IridescenceTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())):!0}prepareDefinesBeforeAttributes(e,t){this._isEnabled?(e.IRIDESCENCE=!0,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&re.IridescenceTextureEnabled?ot(this._texture,e,"IRIDESCENCE_TEXTURE"):e.IRIDESCENCE_TEXTURE=!1,this._thicknessTexture&&re.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,n,a,o,l,c,f,h;if(!this._isEnabled)return;let i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&((this._texture||this._thicknessTexture)&&re.IridescenceTextureEnabled&&(e.updateFloat4("vIridescenceInfos",(n=(r=this._texture)==null?void 0:r.coordinatesIndex)!=null?n: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,(h=(f=this._thicknessTexture)==null?void 0:f.level)!=null?h: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&&re.IridescenceTextureEnabled&&e.setTexture("iridescenceSampler",this._texture),this._thicknessTexture&&re.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"}]}}};Cr._DefaultMinimumThickness=100;Cr._DefaultMaximumThickness=400;Cr._DefaultIndexOfRefraction=1.3;b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Cr.prototype,"isEnabled",void 0);b([L()],Cr.prototype,"intensity",void 0);b([L()],Cr.prototype,"minimumThickness",void 0);b([L()],Cr.prototype,"maximumThickness",void 0);b([L()],Cr.prototype,"indexOfRefraction",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Cr.prototype,"texture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Cr.prototype,"thicknessTexture",void 0)});var eR,Ta,n2=C(()=>{$e();Qe();It();Ee();ns();vo();Ur();Ui();eR=class extends qt{constructor(){super(...arguments),this.ANISOTROPIC=!1,this.ANISOTROPIC_TEXTURE=!1,this.ANISOTROPIC_TEXTUREDIRECTUV=0,this.ANISOTROPIC_LEGACY=!1,this.MAINUV1=!1}},Ta=class extends hi{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 eR,t),this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new me(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&&re.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking()):!0}prepareDefinesBeforeAttributes(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!i.isVerticesDataPresent(y.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&re.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&&re.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&&re.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)}};b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Ta.prototype,"isEnabled",void 0);b([L()],Ta.prototype,"intensity",void 0);b([tc()],Ta.prototype,"direction",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Ta.prototype,"texture",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],Ta.prototype,"legacy",void 0)});var tR,Gr,a2=C(()=>{$e();Qe();Je();ns();vo();Ur();Ui();tR=class extends qt{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}},Gr=class extends hi{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"Sheen",120,new tR,t),this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=ae.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&&re.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking()||this._textureRoughness&&re.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&&re.SheenTextureEnabled?(ot(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&re.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,h,d,u,m;if(!this._isEnabled)return;let n=r.materialDefines,a=this._material.isFrozen;(!e.useUbo||!a||!e.isSync)&&((this._texture||this._textureRoughness)&&re.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,(d=(h=this._textureRoughness)==null?void 0:h.coordinatesIndex)!=null?d:0,(m=(u=this._textureRoughness)==null?void 0:u.level)!=null?m:0),this._texture&<(this._texture,e,"sheen"),this._textureRoughness&&!n.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&&re.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!n.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&re.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"}]}}};b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"isEnabled",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"linkSheenWithAlbedo",void 0);b([L()],Gr.prototype,"intensity",void 0);b([Kt()],Gr.prototype,"color",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"texture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"useRoughnessFromMainTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"roughness",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"textureRoughness",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Gr.prototype,"albedoScaling",void 0)});var iR,vt,o2=C(()=>{$e();Qe();Je();ns();Ee();vo();Ur();Ui();iR=class extends qt{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}},vt=class s extends hi{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 iR,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=ae.White(),this.tintColorAtDistance=1,this.dispersion=0,this.diffusionDistance=ae.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=s.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE,this.legacyTranslucency=s.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&&re.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking()||this._refractionIntensityTexture&&re.RefractionIntensityTextureEnabled&&!this._refractionIntensityTexture.isReadyOrNotBlocking()||this._translucencyColorTexture&&re.TranslucencyColorTextureEnabled&&!this._translucencyColorTexture.isReadyOrNotBlocking()||this._translucencyIntensityTexture&&re.TranslucencyIntensityTextureEnabled&&!this._translucencyIntensityTexture.isReadyOrNotBlocking())return!1;let i=this._getRefractionTexture(t);if(i&&re.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&&re.ThicknessTextureEnabled&&ot(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&re.RefractionIntensityTextureEnabled&&ot(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&re.TranslucencyIntensityTextureEnabled&&ot(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE"),this._translucencyColorTexture&&re.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&&re.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(W.Vector3[0]);let n=Math.max(Math.abs(W.Vector3[0].x),Math.abs(W.Vector3[0].y),Math.abs(W.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*n,(this.maximumThickness-this.minimumThickness)*n)}}bindForSubMesh(e,t,i,r){var f;if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return;let n=r.materialDefines,a=this._material.isFrozen,o=this._material.realTimeFiltering,l=n.LODBASEDMICROSFURACE,c=this._getRefractionTexture(t);if(!e.useUbo||!a||!e.isSync){if(this._thicknessTexture&&re.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),lt(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&re.RefractionIntensityTextureEnabled&&n.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),lt(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyColorTexture&&re.TranslucencyColorTextureEnabled&&n.SS_TRANSLUCENCYCOLOR_TEXTURE&&(e.updateFloat2("vTranslucencyColorInfos",this._translucencyColorTexture.coordinatesIndex,this._translucencyColorTexture.level),lt(this._translucencyColorTexture,e,"translucencyColor")),this._translucencyIntensityTexture&&re.TranslucencyIntensityTextureEnabled&&n.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),lt(this._translucencyIntensityTexture,e,"translucencyIntensity")),c&&re.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",c.getRefractionTextureMatrix());let h=1;c.isCube||c.depth&&(h=c.depth);let d=c.getSize().width,u=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",c.level,1/u,h,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",d,c.lodGenerationScale,c.lodGenerationOffset,1/this.indexOfRefraction),o&&e.updateFloat2("vRefractionFilteringInfo",d,Math.log2(d)),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&&re.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&re.RefractionIntensityTextureEnabled&&n.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&re.TranslucencyIntensityTextureEnabled&&n.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),this._translucencyColorTexture&&re.TranslucencyColorTextureEnabled&&n.SS_TRANSLUCENCYCOLOR_TEXTURE&&e.setTexture("translucencyColorSampler",this._translucencyColorTexture),c&&re.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){re.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!!(re.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"}]}}};vt.DEFAULT_APPLY_ALBEDO_AFTERSUBSURFACE=!1;vt.DEFAULT_LEGACY_TRANSLUCENCY=!1;b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"isRefractionEnabled",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"isTranslucencyEnabled",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"isDispersionEnabled",void 0);b([L(),ie("_markScenePrePassDirty")],vt.prototype,"isScatteringEnabled",void 0);b([L()],vt.prototype,"_scatteringDiffusionProfileIndex",void 0);b([L()],vt.prototype,"refractionIntensity",void 0);b([L()],vt.prototype,"translucencyIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"useAlbedoToTintRefraction",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"useAlbedoToTintTranslucency",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"thicknessTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"refractionTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"indexOfRefraction",void 0);b([L()],vt.prototype,"_volumeIndexOfRefraction",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"volumeIndexOfRefraction",null);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"invertRefractionY",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"linkRefractionWithTransparency",void 0);b([L()],vt.prototype,"minimumThickness",void 0);b([L()],vt.prototype,"maximumThickness",void 0);b([L()],vt.prototype,"useThicknessAsDepth",void 0);b([Kt()],vt.prototype,"tintColor",void 0);b([L()],vt.prototype,"tintColorAtDistance",void 0);b([L()],vt.prototype,"dispersion",void 0);b([Kt()],vt.prototype,"diffusionDistance",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"useMaskFromThicknessTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"refractionIntensityTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"translucencyIntensityTexture",void 0);b([Kt()],vt.prototype,"translucencyColor",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"translucencyColorTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],vt.prototype,"useGltfStyleTextures",void 0);b([L()],vt.prototype,"applyAlbedoAfterSubSurface",void 0);b([L()],vt.prototype,"legacyTranslucency",void 0)});var l2,uY,rR=C(()=>{w();Tn();So();l2="pbrUboDeclaration",uY=`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[l2]||(E.IncludesShadersStoreWGSL[l2]=uY)});var f2={};Ie(f2,{pbrVertexShaderWGSL:()=>mY});var sR,c2,mY,h2=C(()=>{w();rR();Rm();af();Lr();vf();na();aa();go();xm();Im();Ef();hS();un();zc();Cm();To();Ao();_a();bm();Mm();Ro();xo();oa();la();ca();ym();Dm();Pm();Lm();mn();Xc();Om();Ch();Oh();sR="pbrVertexShader",c2=`#define PBR_VERTEX_SHADER +#include +#define CUSTOM_VERTEX_BEGIN +#ifndef USE_VERTEX_PULLING +attribute position: vec3f; +#ifdef NORMAL +attribute normal: vec3f; +#endif +#ifdef TANGENT +attribute tangent: vec4f; +#endif +#ifdef UV1 +attribute uv: vec2f; +#endif +#include[2..7] +#ifdef VERTEXCOLOR +attribute color: vec4f; +#endif +#endif +#include[1..7] +#include +#include +#include +#include +#include +#include +#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy) +#endif +#ifdef SUBSURFACE +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor) +#endif +varying vPositionW: vec3f; +#if DEBUGMODE>0 +varying vClipSpacePosition: vec4f; +#endif +#ifdef NORMAL +varying vNormalW: vec3f; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vEnvironmentIrradiance: vec3f; +#include +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vColor: vec4f; +#endif +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vPositionUVW: vec3f; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vDirectionW: vec3f; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying vViewDepth: f32; +#endif +#include +#include +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef USE_VERTEX_PULLING +var positionUpdated: vec3f=vec3f(0.0); +#ifdef NORMAL +var normalUpdated: vec3f=vec3f(0.0); +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vec4f(0.0); +#endif +#ifdef UV1 +var uvUpdated: vec2f=vec2f(0.0); +#endif +#ifdef UV2 +var uv2Updated: vec2f=vec2f(0.0); +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vec4f(0.0); +#endif +#else +var positionUpdated: vec3f=vertexInputs.position; +#ifdef NORMAL +var normalUpdated: vec3f=vertexInputs.normal; +#endif +#ifdef TANGENT +var tangentUpdated: vec4f=vertexInputs.tangent; +#endif +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#ifdef VERTEXCOLOR +var colorUpdated: vec4f=vertexInputs.color; +#endif +#endif +#include +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vertexOutputs.vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vertexOutputs.vCurrentPosition=scene.viewProjection*finalWorld*vec4f(positionUpdated,1.0);vertexOutputs.vPreviousPosition=uniforms.previousViewProjection*finalPreviousWorld*vec4f(positionUpdated,1.0); +#endif +#ifdef USE_VERTEX_PULLING +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#include(vertexInputs.matricesIndices,vp_matricesIndices,vertexInputs.matricesWeights,vp_matricesWeights,vertexInputs.matricesIndicesExtra,vp_matricesIndicesExtra,vertexInputs.matricesWeightsExtra,vp_matricesWeightsExtra) +#else +#include +#include +#endif +var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0);vertexOutputs.vPositionW= worldPos.xyz; +#ifdef PREPASS +#include +#endif +#ifdef NORMAL +var normalWorld: mat3x3f= mat3x3f(finalWorld[0].xyz,finalWorld[1].xyz,finalWorld[2].xyz); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vertexOutputs.vNormalW=normalUpdated/ vec3f(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vertexOutputs.vNormalW=normalize(normalWorld*vertexOutputs.vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vertexOutputs.vNormalW=normalize(normalWorld*normalUpdated); +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-vertexOutputs.vPositionW);var NdotV: f32=max(dot(vertexOutputs.vNormalW,viewDirectionW),0.0);var roughNormal: vec3f=mix(vertexOutputs.vNormalW,viewDirectionW,(0.5*(1.0-NdotV))*uniforms.baseDiffuseRoughness);var reflectionVector: vec3f= (uniforms.reflectionMatrix* vec4f(roughNormal,0)).xyz; +#else +var reflectionVector: vec3f= (uniforms.reflectionMatrix* vec4f(vertexOutputs.vNormalW,0)).xyz; +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vertexOutputs.vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {vertexOutputs.position=scene.viewProjection*worldPos;} else {vertexOutputs.position=scene.viewProjectionR*worldPos;} +#else +vertexOutputs.position=scene.viewProjection*worldPos; +#endif +#if DEBUGMODE>0 +vertexOutputs.vClipSpacePosition=vertexOutputs.position; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vertexOutputs.vDirectionW=normalize((finalWorld*vec4f(positionUpdated,0.0)).xyz); +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#ifdef RIGHT_HANDED +vertexOutputs.vViewDepth=-(scene.view*worldPos).z; +#else +vertexOutputs.vViewDepth=(scene.view*worldPos).z; +#endif +#endif +#ifndef UV1 +var uvUpdated: vec2f= vec2f(0.,0.); +#endif +#ifdef MAINUV1 +vertexOutputs.vMainUV1=uvUpdated; +#endif +#ifndef UV2 +var uv2Updated: vec2f= vec2f(0.,0.); +#endif +#ifdef MAINUV2 +vertexOutputs.vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_MATRIXNAME_,baseWeight,_INFONAME_,BaseWeightInfos.x) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_MATRIXNAME_,baseDiffuseRoughness,_INFONAME_,BaseDiffuseRoughnessInfos.x) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z) +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z) +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x) +#endif +#ifdef SUBSURFACE +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x) +#endif +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#define CUSTOM_VERTEX_MAIN_END +}`;E.ShadersStoreWGSL[sR]||(E.ShadersStoreWGSL[sR]=c2);mY={name:sR,shader:c2}});var d2,pY,u2=C(()=>{w();d2="samplerFragmentAlternateDeclaration",pY=`#ifdef _DEFINENAME_ +#if _DEFINENAME_DIRECTUV==1 +#define v_VARYINGNAME_UV vMainUV1 +#elif _DEFINENAME_DIRECTUV==2 +#define v_VARYINGNAME_UV vMainUV2 +#elif _DEFINENAME_DIRECTUV==3 +#define v_VARYINGNAME_UV vMainUV3 +#elif _DEFINENAME_DIRECTUV==4 +#define v_VARYINGNAME_UV vMainUV4 +#elif _DEFINENAME_DIRECTUV==5 +#define v_VARYINGNAME_UV vMainUV5 +#elif _DEFINENAME_DIRECTUV==6 +#define v_VARYINGNAME_UV vMainUV6 +#else +varying v_VARYINGNAME_UV: vec2f; +#endif +#endif +`;E.IncludesShadersStoreWGSL[d2]||(E.IncludesShadersStoreWGSL[d2]=pY)});var m2,_Y,p2=C(()=>{w();pl();u2();Yp();m2="pbrFragmentSamplersDeclaration",_Y=`#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) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) +var clearCoatRoughnessSamplerSampler: sampler;var clearCoatRoughnessSampler: texture_2d; +#endif +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) +var sheenRoughnessSamplerSampler: sampler;var sheenRoughnessSampler: texture_2d; +#endif +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy) +#endif +#include +#ifdef ENVIRONMENTBRDF +var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d; +#endif +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +#ifdef SS_REFRACTIONMAP_3D +var refractionSamplerSampler: sampler;var refractionSampler: texture_cube; +#ifdef LODBASEDMICROSFURACE +#else +var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_cube;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_cube; +#endif +#else +var refractionSamplerSampler: sampler;var refractionSampler: texture_2d; +#ifdef LODBASEDMICROSFURACE +#else +var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_2d; +#endif +#endif +#endif +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor) +#endif +#ifdef IBL_CDF_FILTERING +var icdfSamplerSampler: sampler;var icdfSampler: texture_2d; +#endif +`;E.IncludesShadersStoreWGSL[m2]||(E.IncludesShadersStoreWGSL[m2]=_Y)});var _2,gY,g2=C(()=>{w();pS();_2="pbrBlockAlbedoOpacity",gY=`struct albedoOpacityOutParams +{surfaceAlbedo: vec3f, +alpha: f32}; +#define pbr_inline +fn albedoOpacityBlock( +vAlbedoColor: vec4f +#ifdef ALBEDO +,albedoTexture: vec4f +,albedoInfos: vec2f +#endif +,baseWeight: f32 +#ifdef BASE_WEIGHT +,baseWeightTexture: vec4f +,vBaseWeightInfos: vec2f +#endif +#ifdef OPACITY +,opacityMap: vec4f +,vOpacityInfos: vec2f +#endif +#ifdef DETAIL +,detailColor: vec4f +,vDetailInfos: vec4f +#endif +#ifdef DECAL +,decalColor: vec4f +,vDecalInfos: vec4f +#endif +)->albedoOpacityOutParams +{var outParams: albedoOpacityOutParams;var surfaceAlbedo: vec3f=vAlbedoColor.rgb;var alpha: f32=vAlbedoColor.a; +#ifdef ALBEDO +#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST) +alpha*=albedoTexture.a; +#endif +#ifdef GAMMAALBEDO +surfaceAlbedo*=toLinearSpaceVec3(albedoTexture.rgb); +#else +surfaceAlbedo*=albedoTexture.rgb; +#endif +surfaceAlbedo*=albedoInfos.y; +#endif +#ifndef DECAL_AFTER_DETAIL +#include +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +surfaceAlbedo*=fragmentInputs.vColor.rgb; +#endif +#ifdef DETAIL +var detailAlbedo: f32=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; +#endif +#ifdef DECAL_AFTER_DETAIL +#include +#endif +#define CUSTOM_FRAGMENT_UPDATE_ALBEDO +surfaceAlbedo*=baseWeight; +#ifdef BASE_WEIGHT +surfaceAlbedo*=baseWeightTexture.r; +#endif +#ifdef OPACITY +#ifdef OPACITYRGB +alpha=getLuminance(opacityMap.rgb); +#else +alpha*=opacityMap.a; +#endif +alpha*=vOpacityInfos.y; +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=fragmentInputs.vColor.a; +#endif +#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) +#ifdef ALPHATEST +#if DEBUGMODE != 88 +if (alpha{w();E2="pbrBlockReflectivity",EY=`struct reflectivityOutParams +{microSurface: f32, +roughness: f32, +diffuseRoughness: f32, +reflectanceF0: f32, +reflectanceF90: vec3f, +colorReflectanceF0: vec3f, +colorReflectanceF90: vec3f, +#ifdef METALLICWORKFLOW +surfaceAlbedo: vec3f, +metallic: f32, +specularWeight: f32, +dielectricColorF0: vec3f, +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +ambientOcclusionColor: vec3f, +#endif +#if DEBUGMODE>0 +#ifdef METALLICWORKFLOW +#ifdef REFLECTIVITY +surfaceMetallicColorMap: vec4f, +#endif +metallicF0: vec3f, +#else +#ifdef REFLECTIVITY +surfaceReflectivityColorMap: vec4f, +#endif +#endif +#endif +}; +#define pbr_inline +fn reflectivityBlock( +reflectivityColor: vec4f +#ifdef METALLICWORKFLOW +,surfaceAlbedo: vec3f +,metallicReflectanceFactors: vec4f +#endif +,baseDiffuseRoughness: f32 +#ifdef BASE_DIFFUSE_ROUGHNESS +,baseDiffuseRoughnessTexture: f32 +,baseDiffuseRoughnessInfos: vec2f +#endif +#ifdef REFLECTIVITY +,reflectivityInfos: vec3f +,surfaceMetallicOrReflectivityColorMap: vec4f +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +,ambientOcclusionColorIn: vec3f +#endif +#ifdef MICROSURFACEMAP +,microSurfaceTexel: vec4f +#endif +#ifdef DETAIL +,detailColor: vec4f +,vDetailInfos: vec4f +#endif +)->reflectivityOutParams +{var outParams: reflectivityOutParams;var microSurface: f32=reflectivityColor.a;var surfaceReflectivityColor: vec3f=reflectivityColor.rgb; +#ifdef METALLICWORKFLOW +var metallicRoughness: vec2f=surfaceReflectivityColor.rg;var ior: f32=surfaceReflectivityColor.b; +#ifdef REFLECTIVITY +#if DEBUGMODE>0 +outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef AOSTOREINMETALMAPRED +var aoStoreInMetalMap: vec3f= vec3f(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z); +#endif +#ifdef METALLNESSSTOREINMETALMAPBLUE +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b; +#else +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r; +#endif +#ifdef ROUGHNESSSTOREINMETALMAPALPHA +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a; +#else +#ifdef ROUGHNESSSTOREINMETALMAPGREEN +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g; +#endif +#endif +#endif +#ifdef DETAIL +var detailRoughness: f32=mix(0.5,detailColor.b,vDetailInfos.w);var loLerp: f32=mix(0.,metallicRoughness.g,detailRoughness*2.);var hiLerp: f32=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5)); +#endif +#ifdef MICROSURFACEMAP +metallicRoughness.g*=microSurfaceTexel.r; +#endif +#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS +microSurface=1.0-metallicRoughness.g;var baseColor: vec3f=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;var dielectricF0 : f32=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb; +#if DEBUGMODE>0 +outParams.metallicF0=dielectricF0*surfaceReflectivityColor; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.surfaceAlbedo=baseColor.rgb*(vec3f(1.0)-vec3f(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic); +#else +outParams.surfaceAlbedo=baseColor.rgb; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +{let reflectivityColor: vec3f=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));} +#else +#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF +let maxF0: f32=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0f,outParams.metallic); +#else +outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic); +#endif +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.reflectanceF90=vec3(outParams.specularWeight);var f90Scale: f32=1.0; +#else +var f90Scale: f32=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix( +outParams.specularWeight*f90Scale,1.0,outParams.metallic)); +#endif +outParams.dielectricColorF0=vec3f(dielectricF0*surfaceReflectivityColor);var metallicColorF0: vec3f=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic); +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +let dielectricColorF90 +: vec3f=surfaceReflectivityColor * +vec3f(outParams.specularWeight*f90Scale); +#else +let dielectricColorF90 +: vec3f=vec3f(outParams.specularWeight*f90Scale); +#endif +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +let conductorColorF90: vec3f=surfaceReflectivityColor; +#else +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +let conductorColorF90: vec3f=outParams.reflectanceF90; +#else +let conductorColorF90: vec3f=vec3f(1.0f); +#endif +#endif +outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic); +#else +#ifdef REFLECTIVITY +surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb; +#if DEBUGMODE>0 +outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef MICROSURFACEFROMREFLECTIVITYMAP +microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z; +#else +#ifdef MICROSURFACEAUTOMATIC +microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor); +#endif +#ifdef MICROSURFACEMAP +microSurface*=microSurfaceTexel.r; +#endif +#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE +#endif +#endif +outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3f(1.0); +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +outParams.colorReflectanceF90=surfaceReflectivityColor; +#else +outParams.colorReflectanceF90=vec3(1.0); +#endif +#endif +microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;var diffuseRoughness: f32=baseDiffuseRoughness; +#ifdef BASE_DIFFUSE_ROUGHNESS +diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y; +#endif +outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;} +`;E.IncludesShadersStoreWGSL[E2]||(E.IncludesShadersStoreWGSL[E2]=EY)});var S2,vY,T2=C(()=>{w();S2="pbrBlockAmbientOcclusion",vY=`struct ambientOcclusionOutParams +{ambientOcclusionColor: vec3f, +#if DEBUGMODE>0 && defined(AMBIENT) +ambientOcclusionColorMap: vec3f +#endif +}; +#define pbr_inline +fn ambientOcclusionBlock( +#ifdef AMBIENT +ambientOcclusionColorMap_: vec3f, +vAmbientInfos: vec4f +#endif +)->ambientOcclusionOutParams +{ +var outParams: ambientOcclusionOutParams;var ambientOcclusionColor: vec3f= vec3f(1.,1.,1.); +#ifdef AMBIENT +var ambientOcclusionColorMap: vec3f=ambientOcclusionColorMap_*vAmbientInfos.y; +#ifdef AMBIENTINGRAYSCALE +ambientOcclusionColorMap= vec3f(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r); +#endif +ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z); +#if DEBUGMODE>0 +outParams.ambientOcclusionColorMap=ambientOcclusionColorMap; +#endif +#endif +outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;} +`;E.IncludesShadersStoreWGSL[S2]||(E.IncludesShadersStoreWGSL[S2]=vY)});var A2,SY,R2=C(()=>{w();A2="pbrBlockAlphaFresnel",SY=`#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);} +#define pbr_inline +fn alphaFresnelBlock( +normalW: vec3f, +viewDirectionW: vec3f, +alpha: f32, +microSurface: f32 +)->alphaFresnelOutParams +{var outParams: alphaFresnelOutParams;var opacityPerceptual: f32=alpha; +#ifdef LINEARALPHAFRESNEL +var opacity0: f32=opacityPerceptual; +#else +var opacity0: f32=opacityPerceptual*opacityPerceptual; +#endif +var opacity90: f32=fresnelGrazingReflectance(opacity0);var normalForward: vec3f=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)), vec3f(opacity0), vec3f(opacity90),sqrt(microSurface)).x; +#ifdef ALPHATEST +if (outParams.alpha{w();x2="pbrBlockAnisotropic",TY=`#ifdef ANISOTROPIC +struct anisotropicOutParams +{anisotropy: f32, +anisotropicTangent: vec3f, +anisotropicBitangent: vec3f, +anisotropicNormal: vec3f, +#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE) +anisotropyMapData: vec3f +#endif +}; +#define pbr_inline +fn anisotropicBlock( +vAnisotropy: vec3f, +roughness: f32, +#ifdef ANISOTROPIC_TEXTURE +anisotropyMapData: vec3f, +#endif +TBN: mat3x3f, +normalW: vec3f, +viewDirectionW: vec3f +)->anisotropicOutParams +{ +var outParams: anisotropicOutParams;var anisotropy: f32=vAnisotropy.b;var anisotropyDirection: vec3f= vec3f(vAnisotropy.xy,0.); +#ifdef ANISOTROPIC_TEXTURE +var amd=anisotropyMapData.rg;anisotropy*=anisotropyMapData.b; +#if DEBUGMODE>0 +outParams.anisotropyMapData=anisotropyMapData; +#endif +amd=amd*2.0-1.0; +#ifdef ANISOTROPIC_LEGACY +anisotropyDirection=vec3f(anisotropyDirection.xy*amd,anisotropyDirection.z); +#else +anisotropyDirection=vec3f(mat2x2f(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(amd),anisotropyDirection.z); +#endif +#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[x2]||(E.IncludesShadersStoreWGSL[x2]=TY)});var C2,AY,b2=C(()=>{w();C2="pbrBlockReflection",AY=`#ifdef REFLECTION +struct reflectionOutParams +{environmentRadiance: vec4f +,environmentIrradiance: vec3f +#ifdef REFLECTIONMAP_3D +,reflectionCoords: vec3f +#else +,reflectionCoords: vec2f +#endif +#ifdef SS_TRANSLUCENCY +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +,irradianceVector: vec3f +#endif +#endif +#endif +}; +#define pbr_inline +#ifdef REFLECTIONMAP_3D +fn createReflectionCoords( +vPositionW: vec3f, +normalW: vec3f, +#ifdef ANISOTROPIC +anisotropicOut: anisotropicOutParams, +#endif +)->vec3f +{var reflectionCoords: vec3f; +#else +fn createReflectionCoords( +vPositionW: vec3f, +normalW: vec3f, +#ifdef ANISOTROPIC +anisotropicOut: anisotropicOutParams, +#endif +)->vec2f +{ +var reflectionCoords: vec2f; +#endif +#ifdef ANISOTROPIC +var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),anisotropicOut.anisotropicNormal); +#else +var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),normalW); +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +reflectionCoords=reflectionVector; +#else +reflectionCoords=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0-reflectionCoords.y; +#endif +return reflectionCoords;} +#define pbr_inline +fn sampleReflectionTexture( +alphaG: f32 +,vReflectionMicrosurfaceInfos: vec3f +,vReflectionInfos: vec2f +,vReflectionColor: vec3f +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped: f32 +#endif +#ifdef LINEARSPECULARREFLECTION +,roughness: f32 +#endif +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +,reflectionCoords: vec3f +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +,reflectionCoords: vec2f +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,reflectionLowSampler: texture_cube +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_cube +,reflectionHighSamplerSampler: sampler +#else +,reflectionLowSampler: texture_2d +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_2d +,reflectionHighSamplerSampler: sampler +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo: vec2f +#endif +)->vec4f +{var environmentRadiance: vec4f; +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +var reflectionLOD: f32=getLodFromAlphaGNdotV(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +var reflectionLOD: f32=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness); +#else +var reflectionLOD: f32=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG); +#endif +#ifdef LODBASEDMICROSFURACE +reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +#ifdef LODINREFLECTIONALPHA +var automaticReflectionLOD: f32=UNPACK_LOD(textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords).a);var requestedReflectionLOD: f32=max(automaticReflectionLOD,reflectionLOD); +#else +var requestedReflectionLOD: f32=reflectionLOD; +#endif +#ifdef REALTIME_FILTERING +environmentRadiance= vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,vReflectionFilteringInfo),1.0); +#else +environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD); +#endif +#else +var lodReflectionNormalized: f32=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));var lodReflectionNormalizedDoubled: f32=lodReflectionNormalized*2.0;var environmentMid: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix( +textureSample(reflectionHighSampler,reflectionHighSamplerSampler,reflectionCoords), +environmentMid, +lodReflectionNormalizedDoubled +);} else {environmentRadiance=mix( +environmentMid, +textureSample(reflectionLowSampler,reflectionLowSamplerSampler,reflectionCoords), +lodReflectionNormalizedDoubled-1.0 +);} +#endif +var envRadiance=environmentRadiance.rgb; +#ifdef RGBDREFLECTION +envRadiance=fromRGBD(environmentRadiance); +#endif +#ifdef GAMMAREFLECTION +envRadiance=toLinearSpaceVec3(environmentRadiance.rgb); +#endif +envRadiance*=vReflectionInfos.x;envRadiance*=vReflectionColor.rgb;return vec4f(envRadiance,environmentRadiance.a);} +#define pbr_inline +fn reflectionBlock( +vPositionW: vec3f +,normalW: vec3f +,alphaG: f32 +,vReflectionMicrosurfaceInfos: vec3f +,vReflectionInfos: vec2f +,vReflectionColor: vec3f +#ifdef ANISOTROPIC +,anisotropicOut: anisotropicOutParams +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped: f32 +#endif +#ifdef LINEARSPECULARREFLECTION +,roughness: f32 +#endif +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +#endif +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance: vec3f +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,reflectionMatrix: mat4x4f +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,irradianceSampler: texture_cube +,irradianceSamplerSampler: sampler +#else +,irradianceSampler: texture_2d +,irradianceSamplerSampler: sampler +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,reflectionDominantDirection: vec3f +#endif +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,reflectionLowSampler: texture_cube +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_cube +,reflectionHighSamplerSampler: sampler +#else +,reflectionLowSampler: texture_2d +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_2d +,reflectionHighSamplerSampler: sampler +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo: vec2f +#ifdef IBL_CDF_FILTERING +,icdfSampler: texture_2d +,icdfSamplerSampler: sampler +#endif +#endif +,viewDirectionW: vec3f +,diffuseRoughness: f32 +,surfaceAlbedo: vec3f +)->reflectionOutParams +{var outParams: reflectionOutParams;var environmentRadiance: vec4f= vec4f(0.,0.,0.,0.); +#ifdef REFLECTIONMAP_3D +var reflectionCoords: vec3f= vec3f(0.); +#else +var reflectionCoords: vec2f= vec2f(0.); +#endif +reflectionCoords=createReflectionCoords( +vPositionW, +normalW, +#ifdef ANISOTROPIC +anisotropicOut, +#endif +);environmentRadiance=sampleReflectionTexture( +alphaG +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,roughness +#endif +#ifdef REFLECTIONMAP_3D +,reflectionSampler +,reflectionSamplerSampler +,reflectionCoords +#else +,reflectionSampler +,reflectionSamplerSampler +,reflectionCoords +#endif +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +);var environmentIrradiance: vec3f= vec3f(0.,0.,0.); +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +#ifdef ANISOTROPIC +var irradianceVector: vec3f= (reflectionMatrix* vec4f(anisotropicOut.anisotropicNormal,0)).xyz; +#else +var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz; +#endif +var irradianceView: vec3f= (reflectionMatrix* vec4f(viewDirectionW,0)).xyz; +#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +var NdotV: f32=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness); +#endif +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0;irradianceView.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0;irradianceView.y*=-1.0; +#endif +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +environmentIrradiance=vEnvironmentIrradiance; +#else +#if defined(REALTIME_FILTERING) +environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +); +#else +environmentIrradiance=computeEnvironmentIrradiance(irradianceVector); +#endif +#ifdef SS_TRANSLUCENCY +outParams.irradianceVector=irradianceVector; +#endif +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,irradianceVector); +#else +var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords); +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +var Ls: vec3f=normalize(reflectionDominantDirection);var NoL: f32=dot(irradianceVector,Ls);var NoV: f32=dot(irradianceVector,irradianceView);var diffuseRoughnessTerm: vec3f=vec3f(1.0); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +var LoV: f32=dot(Ls,irradianceView);var mag: f32=length(reflectionDominantDirection)*2.0f;var clampedAlbedo: vec3f=clamp(surfaceAlbedo,vec3f(0.1),vec3f(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3f(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0f))); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +var H: vec3f=(irradianceView+Ls)*0.5f;var VoH: f32=dot(irradianceView,H);diffuseRoughnessTerm=vec3f(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +environmentIrradiance=environmentIrradiance4.rgb*diffuseRoughnessTerm; +#else +environmentIrradiance=environmentIrradiance4.rgb; +#endif +#ifdef RGBDREFLECTION +environmentIrradiance=fromRGBD(environmentIrradiance4); +#endif +#ifdef GAMMAREFLECTION +environmentIrradiance=toLinearSpaceVec3(environmentIrradiance.rgb); +#endif +#endif +environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x; +#ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE +outParams.environmentRadiance=vec4f(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a); +#else +outParams.environmentRadiance=environmentRadiance; +#endif +outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;} +#endif +`;E.IncludesShadersStoreWGSL[C2]||(E.IncludesShadersStoreWGSL[C2]=AY)});var M2,RY,y2=C(()=>{w();M2="pbrBlockSheen",RY=`#ifdef SHEEN +struct sheenOutParams +{sheenIntensity: f32 +,sheenColor: vec3f +,sheenRoughness: f32 +#ifdef SHEEN_LINKWITHALBEDO +,surfaceAlbedo: vec3f +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +,sheenAlbedoScaling: f32 +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,finalSheenRadianceScaled: vec3f +#endif +#if DEBUGMODE>0 +#ifdef SHEEN_TEXTURE +,sheenMapData: vec4f +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,sheenEnvironmentReflectance: vec3f +#endif +#endif +}; +#define pbr_inline +fn sheenBlock( +vSheenColor: vec4f +#ifdef SHEEN_ROUGHNESS +,vSheenRoughness: f32 +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +,sheenMapRoughnessData: vec4f +#endif +#endif +,roughness: f32 +#ifdef SHEEN_TEXTURE +,sheenMapData: vec4f +,sheenMapLevel: f32 +#endif +,reflectance: f32 +#ifdef SHEEN_LINKWITHALBEDO +,baseColor: vec3f +,surfaceAlbedo: vec3f +#endif +#ifdef ENVIRONMENTBRDF +,NdotV: f32 +,environmentBrdf: vec3f +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,AARoughnessFactors: vec2f +,vReflectionMicrosurfaceInfos: vec3f +,vReflectionInfos: vec2f +,vReflectionColor: vec3f +,vLightingIntensity: vec4f +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +,reflectionCoords: vec3f +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +,reflectionCoords: vec2f +#endif +,NdotVUnclamped: f32 +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,reflectionLowSampler: texture_cube +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_cube +,reflectionHighSamplerSampler: sampler +#else +,reflectionLowSampler: texture_2d +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_2d +,reflectionHighSamplerSampler: sampler +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo: vec2f +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +,seo: f32 +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +,eho: f32 +#endif +#endif +)->sheenOutParams +{var outParams: sheenOutParams;var sheenIntensity: f32=vSheenColor.a; +#ifdef SHEEN_TEXTURE +#if DEBUGMODE>0 +outParams.sheenMapData=sheenMapData; +#endif +#endif +#ifdef SHEEN_LINKWITHALBEDO +var sheenFactor: f32=pow5(1.0-sheenIntensity);var sheenColor: vec3f=baseColor.rgb*(1.0-sheenFactor);var sheenRoughness: f32=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#else +var sheenColor: vec3f=vSheenColor.rgb; +#ifdef SHEEN_TEXTURE +#ifdef SHEEN_GAMMATEXTURE +sheenColor*=toLinearSpaceVec3(sheenMapData.rgb); +#else +sheenColor*=sheenMapData.rgb; +#endif +sheenColor*=sheenMapLevel; +#endif +#ifdef SHEEN_ROUGHNESS +var sheenRoughness: f32=vSheenRoughness; +#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE +#if defined(SHEEN_TEXTURE) +sheenRoughness*=sheenMapData.a; +#endif +#elif defined(SHEEN_TEXTURE_ROUGHNESS) +sheenRoughness*=sheenMapRoughnessData.a; +#endif +#else +var sheenRoughness: f32=roughness; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#endif +#if !defined(SHEEN_ALBEDOSCALING) +sheenIntensity*=(1.-reflectance); +#endif +sheenColor*=sheenIntensity; +#endif +#ifdef ENVIRONMENTBRDF +/*#ifdef SHEEN_SOFTER +var environmentSheenBrdf: vec3f= vec3f(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness)); +#else*/ +#ifdef SHEEN_ROUGHNESS +var environmentSheenBrdf: vec3f=getBRDFLookup(NdotV,sheenRoughness); +#else +var environmentSheenBrdf: vec3f=environmentBrdf; +#endif +/*#endif*/ +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +var sheenAlphaG: f32=convertRoughnessToAverageSlope(sheenRoughness); +#ifdef SPECULARAA +sheenAlphaG+=AARoughnessFactors.y; +#endif +var environmentSheenRadiance: vec4f= vec4f(0.,0.,0.,0.);environmentSheenRadiance=sampleReflectionTexture( +sheenAlphaG +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,sheenRoughness +#endif +,reflectionSampler +,reflectionSamplerSampler +,reflectionCoords +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +);var sheenEnvironmentReflectance: vec3f=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf); +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +sheenEnvironmentReflectance*=seo; +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +sheenEnvironmentReflectance*=eho; +#endif +#if DEBUGMODE>0 +outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance; +#endif +outParams.finalSheenRadianceScaled= +environmentSheenRadiance.rgb * +sheenEnvironmentReflectance * +vLightingIntensity.z; +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b; +#endif +outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;} +#endif +`;E.IncludesShadersStoreWGSL[M2]||(E.IncludesShadersStoreWGSL[M2]=RY)});var D2,xY,P2=C(()=>{w();D2="pbrBlockClearcoat",xY=`struct clearcoatOutParams +{specularEnvironmentR0: vec3f, +conservationFactor: f32, +clearCoatNormalW: vec3f, +clearCoatAARoughnessFactors: vec2f, +clearCoatIntensity: f32, +clearCoatRoughness: f32, +#ifdef REFLECTION +finalClearCoatRadianceScaled: vec3f, +#endif +#ifdef CLEARCOAT_TINT +absorption: vec3f, +clearCoatNdotVRefract: f32, +clearCoatColor: vec3f, +clearCoatThickness: f32, +#endif +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +energyConservationFactorClearCoat: vec3f, +#endif +#if DEBUGMODE>0 +#ifdef CLEARCOAT_BUMP +TBNClearCoat: mat3x3f, +#endif +#ifdef CLEARCOAT_TEXTURE +clearCoatMapData: vec2f, +#endif +#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +clearCoatTintMapData: vec4f, +#endif +#ifdef REFLECTION +environmentClearCoatRadiance: vec4f, +clearCoatEnvironmentReflectance: vec3f, +#endif +clearCoatNdotV: f32 +#endif +}; +#ifdef CLEARCOAT +#define pbr_inline +fn clearcoatBlock( +vPositionW: vec3f +,geometricNormalW: vec3f +,viewDirectionW: vec3f +,vClearCoatParams: vec2f +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +,clearCoatMapRoughnessData: vec4f +#endif +,specularEnvironmentR0: vec3f +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData: vec2f +#endif +#ifdef CLEARCOAT_TINT +,vClearCoatTintParams: vec4f +,clearCoatColorAtDistance: f32 +,vClearCoatRefractionParams: vec4f +#ifdef CLEARCOAT_TINT_TEXTURE +,clearCoatTintMapData: vec4f +#endif +#endif +#ifdef CLEARCOAT_BUMP +,vClearCoatBumpInfos: vec2f +,clearCoatBumpMapData: vec4f +,vClearCoatBumpUV: vec2f +#if defined(TANGENT) && defined(NORMAL) +,vTBN: mat3x3f +#else +,vClearCoatTangentSpaceParams: vec2f +#endif +#ifdef OBJECTSPACE_NORMALMAP +,normalMatrix: mat4x4f +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +,faceNormal: vec3f +#endif +#ifdef REFLECTION +,vReflectionMicrosurfaceInfos: vec3f +,vReflectionInfos: vec2f +,vReflectionColor: vec3f +,vLightingIntensity: vec4f +#ifdef REFLECTIONMAP_3D +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +#else +,reflectionSampler: texture_2d +,reflectionSamplerSampler: sampler +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,reflectionLowSampler: texture_cube +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_cube +,reflectionHighSamplerSampler: sampler +#else +,reflectionLowSampler: texture_2d +,reflectionLowSamplerSampler: sampler +,reflectionHighSampler: texture_2d +,reflectionHighSamplerSampler: sampler +#endif +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo: vec2f +#endif +#endif +#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING) +,frontFacingMultiplier: f32 +#endif +)->clearcoatOutParams +{var outParams: clearcoatOutParams;var clearCoatIntensity: f32=vClearCoatParams.x;var clearCoatRoughness: f32=vClearCoatParams.y; +#ifdef CLEARCOAT_TEXTURE +clearCoatIntensity*=clearCoatMapData.x; +#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE +clearCoatRoughness*=clearCoatMapData.y; +#endif +#if DEBUGMODE>0 +outParams.clearCoatMapData=clearCoatMapData; +#endif +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +clearCoatRoughness*=clearCoatMapRoughnessData.y; +#endif +outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness; +#ifdef CLEARCOAT_TINT +var clearCoatColor: vec3f=vClearCoatTintParams.rgb;var clearCoatThickness: f32=vClearCoatTintParams.a; +#ifdef CLEARCOAT_TINT_TEXTURE +#ifdef CLEARCOAT_TINT_GAMMATEXTURE +clearCoatColor*=toLinearSpaceVec3(clearCoatTintMapData.rgb); +#else +clearCoatColor*=clearCoatTintMapData.rgb; +#endif +clearCoatThickness*=clearCoatTintMapData.a; +#if DEBUGMODE>0 +outParams.clearCoatTintMapData=clearCoatTintMapData; +#endif +#endif +outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness; +#endif +#ifdef CLEARCOAT_REMAP_F0 +var specularEnvironmentR0Updated: vec3f=getR0RemappedForClearCoat(specularEnvironmentR0); +#else +var specularEnvironmentR0Updated: vec3f=specularEnvironmentR0; +#endif +outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);var clearCoatNormalW: vec3f=geometricNormalW; +#ifdef CLEARCOAT_BUMP +#ifdef NORMALXYSCALE +var clearCoatNormalScale: f32=1.0; +#else +var clearCoatNormalScale: f32=vClearCoatBumpInfos.y; +#endif +#if defined(TANGENT) && defined(NORMAL) +var TBNClearCoat: mat3x3f=vTBN; +#else +var TBNClearCoatUV: vec2f=vClearCoatBumpUV*frontFacingMultiplier;var TBNClearCoat: mat3x3f=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams); +#endif +#if DEBUGMODE>0 +outParams.TBNClearCoat=TBNClearCoat; +#endif +#ifdef OBJECTSPACE_NORMALMAP +clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize( mat3x3f(normalMatrix[0].xyz,normalMatrix[1].xyz,normalMatrix[2].xyz)*clearCoatNormalW); +#else +clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y); +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier; +#endif +outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);var clearCoatNdotVUnclamped: f32=dot(clearCoatNormalW,viewDirectionW);var clearCoatNdotV: f32=absEps(clearCoatNdotVUnclamped); +#if DEBUGMODE>0 +outParams.clearCoatNdotV=clearCoatNdotV; +#endif +#ifdef CLEARCOAT_TINT +var clearCoatVRefract: vec3f=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract)); +#endif +#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION)) +var environmentClearCoatBrdf: vec3f=getBRDFLookup(clearCoatNdotV,clearCoatRoughness); +#endif +#if defined(REFLECTION) +var clearCoatAlphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness); +#ifdef SPECULARAA +clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y; +#endif +var environmentClearCoatRadiance: vec4f= vec4f(0.,0.,0.,0.);var clearCoatReflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),clearCoatNormalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +clearCoatReflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +var clearCoatReflectionCoords: vec3f=clearCoatReflectionVector; +#else +var clearCoatReflectionCoords: vec2f=clearCoatReflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +clearCoatReflectionCoords/=clearCoatReflectionVector.z; +#endif +clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y; +#endif +environmentClearCoatRadiance=sampleReflectionTexture( +clearCoatAlphaG +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,clearCoatNdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,clearCoatRoughness +#endif +,reflectionSampler +,reflectionSamplerSampler +,clearCoatReflectionCoords +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +); +#if DEBUGMODE>0 +outParams.environmentClearCoatRadiance=environmentClearCoatRadiance; +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromBRDFLookup(vec3f(uniforms.vClearCoatRefractionParams.x),environmentClearCoatBrdf); +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +var clearCoatEho: f32=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho; +#endif +#endif +#endif +#else +var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV, vec3f(1.), vec3f(1.),sqrt(1.-clearCoatRoughness)); +#endif +clearCoatEnvironmentReflectance*=clearCoatIntensity; +#if DEBUGMODE>0 +outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance; +#endif +outParams.finalClearCoatRadianceScaled= +environmentClearCoatRadiance.rgb * +clearCoatEnvironmentReflectance * +vLightingIntensity.z; +#endif +#if defined(CLEARCOAT_TINT) +outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity); +#endif +var fresnelIBLClearCoat: f32=fresnelSchlickGGX(clearCoatNdotV,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat); +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf); +#endif +return outParams;} +#endif +`;E.IncludesShadersStoreWGSL[D2]||(E.IncludesShadersStoreWGSL[D2]=xY)});var L2,IY,O2=C(()=>{w();L2="pbrBlockIridescence",IY=`struct iridescenceOutParams +{iridescenceIntensity: f32, +iridescenceIOR: f32, +iridescenceThickness: f32, +specularEnvironmentR0: vec3f}; +#ifdef IRIDESCENCE +fn iridescenceBlock( +vIridescenceParams: vec4f +,viewAngle_: f32 +,specularEnvironmentR0: vec3f +#ifdef IRIDESCENCE_TEXTURE +,iridescenceMapData: vec2f +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +,iridescenceThicknessMapData: vec2f +#endif +#ifdef CLEARCOAT +,NdotVUnclamped: f32 +,vClearCoatParams: vec2f +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData: vec2f +#endif +#endif +)->iridescenceOutParams +{var outParams: iridescenceOutParams;var iridescenceIntensity: f32=vIridescenceParams.x;var iridescenceIOR: f32=vIridescenceParams.y;var iridescenceThicknessMin: f32=vIridescenceParams.z;var iridescenceThicknessMax: f32=vIridescenceParams.w;var iridescenceThicknessWeight: f32=1.;var viewAngle=viewAngle_; +#ifdef IRIDESCENCE_TEXTURE +iridescenceIntensity*=iridescenceMapData.x; +#endif +#if defined(IRIDESCENCE_THICKNESS_TEXTURE) +iridescenceThicknessWeight=iridescenceThicknessMapData.g; +#endif +var iridescenceThickness: f32=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);var topIor: f32=1.; +#ifdef CLEARCOAT +var clearCoatIntensity: f32=vClearCoatParams.x; +#ifdef CLEARCOAT_TEXTURE +clearCoatIntensity*=clearCoatMapData.x; +#endif +topIor=mix(1.0,uniforms.vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+((1.0/topIor)*(1.0/topIor))*((NdotVUnclamped*NdotVUnclamped)-1.0)); +#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[L2]||(E.IncludesShadersStoreWGSL[L2]=IY)});var N2,CY,F2=C(()=>{w();N2="pbrBlockSubSurface",CY=`struct subSurfaceOutParams +{specularEnvironmentReflectance: vec3f, +#ifdef SS_REFRACTION +finalRefraction: vec3f, +surfaceAlbedo: vec3f, +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +alpha: f32, +#endif +refractionOpacity: f32, +#endif +#ifdef SS_TRANSLUCENCY +transmittance: vec3f, +translucencyIntensity: f32, +#ifdef REFLECTION +refractionIrradiance: vec3f, +#endif +#endif +#if DEBUGMODE>0 +#ifdef SS_THICKNESSANDMASK_TEXTURE +thicknessMap: vec4f, +#endif +#ifdef SS_REFRACTION +environmentRefraction: vec4f, +refractionTransmittance: vec3f +#endif +#endif +}; +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +#define pbr_inline +fn sampleEnvironmentRefraction( +ior: f32 +,thickness: f32 +,refractionLOD: f32 +,normalW: vec3f +,vPositionW: vec3f +,viewDirectionW: vec3f +,view: mat4x4f +,vRefractionInfos: vec4f +,refractionMatrix: mat4x4f +,vRefractionMicrosurfaceInfos: vec4f +,alphaG: f32 +#ifdef SS_REFRACTIONMAP_3D +,refractionSampler: texture_cube +,refractionSamplerSampler: sampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler: texture_cube +,refractionLowSamplerSampler: sampler +,refractionHighSampler: texture_cube +,refractionHighSamplerSampler: sampler +#endif +#else +,refractionSampler: texture_2d +,refractionSamplerSampler: sampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler: texture_2d +,refractionLowSamplerSampler: sampler +,refractionHighSampler: texture_2d +,refractionHighSamplerSampler: sampler +#endif +#endif +#ifdef ANISOTROPIC +,anisotropicOut: anisotropicOutParams +#endif +#ifdef REALTIME_FILTERING +,vRefractionFilteringInfo: vec2f +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,refractionPosition: vec3f +,refractionSize: vec3f +#endif +)->vec4f {var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.); +#ifdef ANISOTROPIC +var refractionVector: vec3f=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior); +#else +var refractionVector: vec3f=refract(-viewDirectionW,normalW,ior); +#endif +#ifdef SS_REFRACTIONMAP_OPPOSITEZ +refractionVector.z*=-1.0; +#endif +#ifdef SS_REFRACTIONMAP_3D +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition); +#endif +refractionVector.y=refractionVector.y*vRefractionInfos.w;var refractionCoords: vec3f=refractionVector;refractionCoords= (refractionMatrix* vec4f(refractionCoords,0)).xyz; +#else +#ifdef SS_USE_THICKNESS_AS_DEPTH +var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*thickness,1.0))).xyz; +#else +var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*vRefractionInfos.z,1.0))).xyz; +#endif +var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y; +#endif +#ifdef LODBASEDMICROSFURACE +var lod=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z; +#ifdef SS_LODINREFRACTIONALPHA +var automaticRefractionLOD: f32=UNPACK_LOD(textureSample(refractionSampler,refractionSamplerSampler,refractionCoords).a);var requestedRefractionLOD: f32=max(automaticRefractionLOD,lod); +#else +var requestedRefractionLOD: f32=lod; +#endif +#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D) +environmentRefraction= vec4f(radiance(alphaG,refractionSampler,refractionSamplerSampler,refractionCoords,vRefractionFilteringInfo),1.0); +#else +environmentRefraction=textureSampleLevel(refractionSampler,refractionSamplerSampler,refractionCoords,requestedRefractionLOD); +#endif +#else +var lodRefractionNormalized: f32=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));var lodRefractionNormalizedDoubled: f32=lodRefractionNormalized*2.0;var environmentRefractionMid: vec4f=textureSample(refractionSampler,refractionSamplerSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix( +textureSample(refractionHighSampler,refractionHighSamplerSampler,refractionCoords), +environmentRefractionMid, +lodRefractionNormalizedDoubled +);} else {environmentRefraction=mix( +environmentRefractionMid, +textureSample(refractionLowSampler,refractionLowSamplerSampler,refractionCoords), +lodRefractionNormalizedDoubled-1.0 +);} +#endif +var refraction=environmentRefraction.rgb; +#ifdef SS_RGBDREFRACTION +refraction=fromRGBD(environmentRefraction); +#endif +#ifdef SS_GAMMAREFRACTION +refraction=toLinearSpaceVec3(environmentRefraction.rgb); +#endif +return vec4f(refraction,environmentRefraction.a);} +#endif +#define pbr_inline +fn subSurfaceBlock( +vSubSurfaceIntensity: vec3f +,vThicknessParam: vec2f +,vTintColor: vec4f +,normalW: vec3f +,specularEnvironmentReflectance: vec3f +#ifdef SS_THICKNESSANDMASK_TEXTURE +,thicknessMap: vec4f +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +,refractionIntensityMap: vec4f +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +,translucencyIntensityMap: vec4f +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +,reflectionMatrix: mat4x4f +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +,irradianceVector_: vec3f +#endif +#if defined(REALTIME_FILTERING) +,reflectionSampler: texture_cube +,reflectionSamplerSampler: sampler +,vReflectionFilteringInfo: vec2f +#ifdef IBL_CDF_FILTERING +,icdfSampler: texture_2d +,icdfSamplerSampler: sampler +#endif +#endif +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,irradianceSampler: texture_cube +,irradianceSamplerSampler: sampler +#else +,irradianceSampler: texture_2d +,irradianceSamplerSampler: sampler +#endif +#endif +#endif +#endif +#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY) +,surfaceAlbedo: vec3f +#endif +#ifdef SS_REFRACTION +,vPositionW: vec3f +,viewDirectionW: vec3f +,view: mat4x4f +,vRefractionInfos: vec4f +,refractionMatrix: mat4x4f +,vRefractionMicrosurfaceInfos: vec4f +,vLightingIntensity: vec4f +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +,alpha: f32 +#endif +#ifdef SS_LODINREFRACTIONALPHA +,NdotVUnclamped: f32 +#endif +#ifdef SS_LINEARSPECULARREFRACTION +,roughness: f32 +#endif +,alphaG: f32 +#ifdef SS_REFRACTIONMAP_3D +,refractionSampler: texture_cube +,refractionSamplerSampler: sampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler: texture_cube +,refractionLowSamplerSampler: sampler +,refractionHighSampler: texture_cube +,refractionHighSamplerSampler: sampler +#endif +#else +,refractionSampler: texture_2d +,refractionSamplerSampler: sampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler: texture_2d +,refractionLowSamplerSampler: sampler +,refractionHighSampler: texture_2d +,refractionHighSamplerSampler: sampler +#endif +#endif +#ifdef ANISOTROPIC +,anisotropicOut: anisotropicOutParams +#endif +#ifdef REALTIME_FILTERING +,vRefractionFilteringInfo: vec2f +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,refractionPosition: vec3f +,refractionSize: vec3f +#endif +#ifdef SS_DISPERSION +,dispersion: f32 +#endif +#endif +#ifdef SS_TRANSLUCENCY +,vDiffusionDistance: vec3f +,vTranslucencyColor: vec4f +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +,translucencyColorMap: vec4f +#endif +#endif +)->subSurfaceOutParams +{var outParams: subSurfaceOutParams;outParams.specularEnvironmentReflectance=specularEnvironmentReflectance; +#ifdef SS_REFRACTION +var refractionIntensity: f32=vSubSurfaceIntensity.x; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +refractionIntensity*=(1.0-alpha);outParams.alpha=1.0; +#endif +#endif +#ifdef SS_TRANSLUCENCY +var translucencyIntensity: f32=vSubSurfaceIntensity.y; +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +#ifdef SS_USE_GLTF_TEXTURES +var thickness: f32=thicknessMap.g*vThicknessParam.y+vThicknessParam.x; +#else +var thickness: f32=thicknessMap.r*vThicknessParam.y+vThicknessParam.x; +#endif +#if DEBUGMODE>0 +outParams.thicknessMap=thicknessMap; +#endif +#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS) +#ifdef SS_USE_GLTF_TEXTURES +refractionIntensity*=thicknessMap.r; +#else +refractionIntensity*=thicknessMap.g; +#endif +#endif +#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS) +#ifdef SS_USE_GLTF_TEXTURES +translucencyIntensity*=thicknessMap.a; +#else +translucencyIntensity*=thicknessMap.b; +#endif +#endif +#else +var thickness: f32=vThicknessParam.y; +#endif +#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE) +#ifdef SS_USE_GLTF_TEXTURES +refractionIntensity*=refractionIntensityMap.r; +#else +refractionIntensity*=refractionIntensityMap.g; +#endif +#endif +#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE) +#ifdef SS_USE_GLTF_TEXTURES +translucencyIntensity*=translucencyIntensityMap.a; +#else +translucencyIntensity*=translucencyIntensityMap.b; +#endif +#endif +#ifdef SS_TRANSLUCENCY +thickness=maxEps(thickness);var translucencyColor: vec4f=vTranslucencyColor; +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +translucencyColor*=translucencyColorMap; +#endif +var transmittance: vec3f=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity; +#endif +#ifdef SS_REFRACTION +var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.); +#ifdef SS_HAS_THICKNESS +var ior: f32=vRefractionInfos.y; +#else +var ior: f32=vRefractionMicrosurfaceInfos.w; +#endif +#ifdef SS_LODINREFRACTIONALPHA +var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaGNdotV(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped); +#elif defined(SS_LINEARSPECULARREFRACTION) +var refractionRoughness: f32=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness); +#else +var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG); +#endif +var refraction_ior: f32=vRefractionInfos.y; +#ifdef SS_DISPERSION +var realIOR: f32=1.0/refraction_ior;var iorDispersionSpread: f32=0.04*dispersion*(realIOR-1.0);var iors: vec3f= vec3f(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (var i: i32=0; i<3; i++) {refraction_ior=iors[i]; +#endif +var envSample: vec4f=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG +#ifdef SS_REFRACTIONMAP_3D +,refractionSampler +,refractionSamplerSampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler +,refractionLowSamplerSampler +,refractionHighSampler +,refractionHighSamplerSampler +#endif +#else +,refractionSampler +,refractionSamplerSampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler +,refractionLowSamplerSampler +,refractionHighSampler +,refractionHighSamplerSampler +#endif +#endif +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,refractionPosition +,refractionSize +#endif +); +#ifdef SS_DISPERSION +environmentRefraction[i]=envSample[i];} +#else +environmentRefraction=envSample; +#endif +environmentRefraction=vec4f(environmentRefraction.rgb*vRefractionInfos.x,environmentRefraction.a); +#endif +#ifdef SS_REFRACTION +var refractionTransmittance: vec3f= vec3f(refractionIntensity); +#ifdef SS_THICKNESSANDMASK_TEXTURE +var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,thickness); +#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY) +var maxChannel: f32=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);var volumeAlbedo: vec3f=saturateVec3(maxChannel*surfaceAlbedo);environmentRefraction=vec4f(environmentRefraction.rgb*volumeAlbedo,environmentRefraction.a); +#else +var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,vThicknessParam.y); +#endif +#ifdef SS_ALBEDOFORREFRACTIONTINT +environmentRefraction=vec4f(environmentRefraction.rgb*surfaceAlbedo.rgb,environmentRefraction.a); +#endif +outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=1.-refractionIntensity; +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.surfaceAlbedo*=outParams.refractionOpacity; +#endif +#ifdef UNUSED_MULTIPLEBOUNCES +var bounceSpecularEnvironmentReflectance: vec3f=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity); +#endif +#if DEBUGMODE>0 +outParams.refractionTransmittance=refractionTransmittance; +#endif +outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3f(1.0)-specularEnvironmentReflectance; +#if DEBUGMODE>0 +outParams.environmentRefraction=environmentRefraction; +#endif +#endif +#if defined(REFLECTION) && defined(SS_TRANSLUCENCY) +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP) +var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0; +#endif +#else +var irradianceVector: vec3f=irradianceVector_; +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) +#if defined(REALTIME_FILTERING) +var refractionIrradiance: vec3f=irradiance(reflectionSampler,reflectionSamplerSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +); +#else +var refractionIrradiance: vec3f=computeEnvironmentIrradiance(-irradianceVector); +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +var irradianceCoords: vec3f=irradianceVector; +#else +var irradianceCoords: vec2f=irradianceVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +irradianceCoords/=irradianceVector.z; +#endif +irradianceCoords.y=1.0-irradianceCoords.y; +#endif +var temp: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,-irradianceCoords);var refractionIrradiance=temp.rgb; +#ifdef RGBDREFLECTION +refractionIrradiance=fromRGBD(temp).rgb; +#endif +#ifdef GAMMAREFLECTION +refractionIrradiance=toLinearSpaceVec3(refractionIrradiance); +#endif +#else +var refractionIrradiance: vec3f= vec3f(0.); +#endif +refractionIrradiance*=transmittance; +#ifdef SS_ALBEDOFORTRANSLUCENCYTINT +refractionIrradiance*=surfaceAlbedo.rgb; +#endif +outParams.refractionIrradiance=refractionIrradiance; +#endif +return outParams;} +#endif +`;E.IncludesShadersStoreWGSL[N2]||(E.IncludesShadersStoreWGSL[N2]=CY)});var w2,bY,B2=C(()=>{w();w2="pbrBlockNormalFinal",bY=`#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); +#endif +normalW*=sign(dot(normalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +#if defined(MIRRORED) +normalW=select(normalW,-normalW,fragmentInputs.frontFacing); +#else +normalW=select(-normalW,normalW,fragmentInputs.frontFacing); +#endif +#endif +`;E.IncludesShadersStoreWGSL[w2]||(E.IncludesShadersStoreWGSL[w2]=bY)});var U2,MY,V2=C(()=>{w();U2="pbrBlockLightmapInit",MY=`#ifdef LIGHTMAP +var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a); +#endif +#ifdef GAMMALIGHTMAP +lightmapColor=vec4f(toLinearSpaceVec3(lightmapColor.rgb),lightmapColor.a); +#endif +lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a); +#endif +`;E.IncludesShadersStoreWGSL[U2]||(E.IncludesShadersStoreWGSL[U2]=MY)});var G2,yY,k2=C(()=>{w();G2="pbrBlockGeometryInfo",yY=`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 +#if defined(ENVIRONMENTBRDF) +var environmentBrdf: vec3f=getBRDFLookup(NdotV,roughness); +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef RADIANCEOCCLUSION +#ifdef AMBIENTINGRAYSCALE +var ambientMonochrome: f32=aoOut.ambientOcclusionColor.r; +#else +var ambientMonochrome: f32=getLuminance(aoOut.ambientOcclusionColor); +#endif +var seo: f32=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped); +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +var eho: f32=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); +#endif +#endif +#endif +#endif +`;E.IncludesShadersStoreWGSL[G2]||(E.IncludesShadersStoreWGSL[G2]=yY)});var W2,DY,H2=C(()=>{w();W2="pbrBlockReflectance",DY=`#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); +#else +var colorSpecularEnvironmentReflectance=getReflectanceFromBRDFWithEnvLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf); +#endif +#ifdef RADIANCEOCCLUSION +colorSpecularEnvironmentReflectance*=seo; +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +colorSpecularEnvironmentReflectance*=eho; +#endif +#endif +#endif +#else +var colorSpecularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));var baseSpecularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3f(reflectanceF0),vec3f(reflectivityOut.reflectanceF90),sqrt(microSurface)); +#endif +#ifdef CLEARCOAT +colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +colorSpecularEnvironmentReflectance*=clearcoatOut.absorption; +#endif +#endif +`;E.IncludesShadersStoreWGSL[W2]||(E.IncludesShadersStoreWGSL[W2]=DY)});var z2,PY,X2=C(()=>{w();z2="pbrBlockDirectLighting",PY=`var diffuseBase: vec3f=vec3f(0.,0.,0.); +#ifdef SS_TRANSLUCENCY +var diffuseTransmissionBase: vec3f=vec3f(0.,0.,0.); +#endif +#ifdef SPECULARTERM +var specularBase: vec3f=vec3f(0.,0.,0.); +#endif +#ifdef CLEARCOAT +var clearCoatBase: vec3f=vec3f(0.,0.,0.); +#endif +#ifdef SHEEN +var sheenBase: vec3f=vec3f(0.,0.,0.); +#endif +#if defined(SPECULARTERM) && defined(LIGHT0) +var coloredFresnel: vec3f=vec3f(0.,0.,0.); +#endif +var preInfo: preLightingInfo;var info: lightingInfo;var shadow: f32=1.; +var aggShadow: f32=0.;var numLights: f32=0.; +#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +var absorption: vec3f=vec3f(0.); +#endif +`;E.IncludesShadersStoreWGSL[z2]||(E.IncludesShadersStoreWGSL[z2]=PY)});var Y2,LY,K2=C(()=>{w();Y2="pbrBlockFinalLitComponents",LY=`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); +#endif +#endif +#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF) +surfaceAlbedo=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +#ifndef METALLICWORKFLOW +#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION +surfaceAlbedo=vec3f(1.-reflectanceF0)*surfaceAlbedo.rgb; +#endif +#endif +#endif +#ifdef REFLECTION +var finalIrradiance: vec3f=reflectionOut.environmentIrradiance; +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +#if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION) +var baseSpecularEnergy: vec3f=vec3f(baseSpecularEnvironmentReflectance); +#if defined(ENVIRONMENTBRDF) +#ifdef MS_BRDF_ENERGY_CONSERVATION +baseSpecularEnergy*=baseSpecularEnergyConservationFactor; +#endif +#endif +finalIrradiance*=clamp(vec3f(1.0)-baseSpecularEnergy,vec3f(0.0),vec3f(1.0)); +#endif +#endif +#if defined(CLEARCOAT) +finalIrradiance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +finalIrradiance*=clearcoatOut.absorption; +#endif +#endif +#ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE +finalIrradiance*=surfaceAlbedo.rgb; +#endif +#if defined(SS_REFRACTION) +finalIrradiance*=subSurfaceOut.refractionOpacity; +#endif +#if defined(SS_TRANSLUCENCY) +finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance; +#endif +#ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE +finalIrradiance*=surfaceAlbedo.rgb; +#endif +finalIrradiance*=uniforms.vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor; +#endif +#ifdef SPECULARTERM +var finalSpecular: vec3f=specularBase;finalSpecular=max(finalSpecular,vec3f(0.0));var finalSpecularScaled: vec3f=finalSpecular*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalSpecularScaled*=coloredEnergyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalSpecularScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif +#ifdef REFLECTION +var finalRadiance: vec3f=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;;var finalRadianceScaled: vec3f=finalRadiance*uniforms.vLightingIntensity.z; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalRadianceScaled*=coloredEnergyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalRadianceScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif +#ifdef SHEEN +var finalSheen: vec3f=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,vec3f(0.0));var finalSheenScaled: vec3f=finalSheen*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w; +#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption; +#endif +#endif +#endif +#ifdef CLEARCOAT +var finalClearCoat: vec3f=clearCoatBase;finalClearCoat=max(finalClearCoat,vec3f(0.0));var finalClearCoatScaled: vec3f=finalClearCoat*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat; +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor; +#ifdef CLEARCOAT_TINT +subSurfaceOut.finalRefraction*=clearcoatOut.absorption; +#endif +#endif +#endif +#ifdef ALPHABLEND +var luminanceOverAlpha: f32=0.0; +#if defined(REFLECTION) && defined(RADIANCEOVERALPHA) +luminanceOverAlpha+=getLuminance(finalRadianceScaled); +#if defined(CLEARCOAT) +luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled); +#endif +#endif +#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA) +luminanceOverAlpha+=getLuminance(finalSpecularScaled); +#endif +#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA) +luminanceOverAlpha+=getLuminance(finalClearCoatScaled); +#endif +#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA) +alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha); +#endif +#endif +`;E.IncludesShadersStoreWGSL[Y2]||(E.IncludesShadersStoreWGSL[Y2]=LY)});var j2,OY,Z2=C(()=>{w();j2="pbrBlockFinalUnlitComponents",OY=`var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo; +#if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION) +finalDiffuse*=subSurfaceOut.refractionOpacity; +#endif +#if defined(SS_TRANSLUCENCY) && !defined(UNLIT) +finalDiffuse+=diffuseTransmissionBase; +#endif +finalDiffuse=max(finalDiffuse,vec3f(0.0));finalDiffuse*=uniforms.vLightingIntensity.x;var finalAmbient: vec3f=uniforms.vAmbientColor;finalAmbient=finalAmbient*surfaceAlbedo.rgb;var finalEmissive: vec3f=uniforms.vEmissiveColor; +#ifdef EMISSIVE +var emissiveColorTex: vec3f=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb; +#ifdef GAMMAEMISSIVE +finalEmissive*=toLinearSpaceVec3(emissiveColorTex.rgb); +#else +finalEmissive*=emissiveColorTex.rgb; +#endif +finalEmissive*= uniforms.vEmissiveInfos.y; +#endif +finalEmissive*=uniforms.vLightingIntensity.y; +#ifdef AMBIENT +var ambientOcclusionForDirectDiffuse: vec3f=mix( vec3f(1.),aoOut.ambientOcclusionColor,uniforms.vAmbientInfos.w); +#else +var ambientOcclusionForDirectDiffuse: vec3f=aoOut.ambientOcclusionColor; +#endif +finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse; +`;E.IncludesShadersStoreWGSL[j2]||(E.IncludesShadersStoreWGSL[j2]=OY)});var q2,NY,Q2=C(()=>{w();q2="pbrBlockFinalColorComposition",NY=`var finalColor: vec4f= vec4f( +#ifndef UNLIT +#ifdef REFLECTION +finalIrradiance + +#endif +#ifdef SPECULARTERM +finalSpecularScaled + +#endif +#ifdef SHEEN +finalSheenScaled + +#endif +#ifdef CLEARCOAT +finalClearCoatScaled + +#endif +#ifdef REFLECTION +finalRadianceScaled + +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled + +#endif +#ifdef CLEARCOAT +clearcoatOut.finalClearCoatRadianceScaled + +#endif +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction + +#endif +#endif +finalAmbient + +finalDiffuse, +alpha); +#ifdef LIGHTMAP +#ifndef LIGHTMAPEXCLUDED +#ifdef USELIGHTMAPASSHADOWMAP +finalColor=vec4f(finalColor.rgb*lightmapColor.rgb,finalColor.a); +#else +finalColor=vec4f(finalColor.rgb+lightmapColor.rgb,finalColor.a); +#endif +#endif +#endif +finalColor=vec4f(finalColor.rgb+finalEmissive,finalColor.a); +#define CUSTOM_FRAGMENT_BEFORE_FOG +finalColor=max(finalColor,vec4f(0.0)); +`;E.IncludesShadersStoreWGSL[q2]||(E.IncludesShadersStoreWGSL[q2]=NY)});var J2,FY,$2=C(()=>{w();J2="pbrBlockPrePass",FY=`#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); +#endif +#ifdef PREPASS_LOCAL_POSITION +fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo); +#endif +#ifdef PREPASS_VELOCITY +var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) - +(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +fragData[PREPASS_ALBEDO_INDEX]=vec4f(surfaceAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +var sqAlbedo : vec3f=sqrt(surfaceAlbedo); +#endif +#ifdef PREPASS_IRRADIANCE_LEGACY +var irradiance : vec3f=finalDiffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=finalIrradiance; +#endif +#endif +#ifdef SS_SCATTERING +#ifdef PREPASS_COLOR +fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb-irradiance,finalColor.a); +#endif +irradiance/=sqAlbedo;fragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),writeGeometryInfo*uniforms.scatteringDiffusionProfile/255.); +#else +#ifdef PREPASS_COLOR +fragData[PREPASS_COLOR_INDEX]=finalColor; +#endif +fragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),writeGeometryInfo); +#endif +#else +#ifdef PREPASS_IRRADIANCE +var irradiance : vec3f=finalDiffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=finalIrradiance; +#endif +#endif +fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(irradiance,writeGeometryInfo); +#endif +#ifdef PREPASS_COLOR +fragData[PREPASS_COLOR_INDEX]=vec4f(finalColor.rgb,finalColor.a); +#endif +#endif +#ifdef PREPASS_DEPTH +fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo); +#else +fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#ifndef UNLIT +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo; +#else +fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo; +#endif +#endif +#if SCENE_MRT_COUNT>0 +fragmentOutputs.fragData0=fragData[0]; +#endif +#if SCENE_MRT_COUNT>1 +fragmentOutputs.fragData1=fragData[1]; +#endif +#if SCENE_MRT_COUNT>2 +fragmentOutputs.fragData2=fragData[2]; +#endif +#if SCENE_MRT_COUNT>3 +fragmentOutputs.fragData3=fragData[3]; +#endif +#if SCENE_MRT_COUNT>4 +fragmentOutputs.fragData4=fragData[4]; +#endif +#if SCENE_MRT_COUNT>5 +fragmentOutputs.fragData5=fragData[5]; +#endif +#if SCENE_MRT_COUNT>6 +fragmentOutputs.fragData6=fragData[6]; +#endif +#if SCENE_MRT_COUNT>7 +fragmentOutputs.fragData7=fragData[7]; +#endif +#endif +`;E.IncludesShadersStoreWGSL[J2]||(E.IncludesShadersStoreWGSL[J2]=FY)});var tB={};Ie(tB,{pbrPixelShaderWGSL:()=>wY});var nR,eB,wY,iB=C(()=>{w();Nm();Fm();rR();SA();wm();p2();Um();pn();_a();Yc();Lr();TA();AA();RA();Vm();Bm();Ef();xA();IA();vf();CA();MA();Kp();Gm();km();Nh();g2();v2();T2();R2();I2();b2();y2();P2();O2();F2();_n();yA();Wm();B2();Hm();V2();k2();bA();H2();X2();_S();K2();Z2();Q2();Fh();Kc();DA();$2();zm();PA();nR="pbrPixelShader",eB=`#define PBR_FRAGMENT_SHADER +#define CUSTOM_FRAGMENT_BEGIN +#include[SCENE_MRT_COUNT] +#include +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE +#endif +#include +#include +#include[0..maxSimultaneousLights] +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REFLECTION +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#include +#include +#include +var albedoOpacityOut: albedoOpacityOutParams; +#ifdef ALBEDO +var albedoTexture: vec4f=textureSample(albedoSampler,albedoSamplerSampler,fragmentInputs.vAlbedoUV+uvOffset); +#endif +#ifdef BASE_WEIGHT +var baseWeightTexture: vec4f=textureSample(baseWeightSampler,baseWeightSamplerSampler,fragmentInputs.vBaseWeightUV+uvOffset); +#endif +#ifdef OPACITY +var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset); +#endif +#ifdef DECAL +var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset); +#endif +albedoOpacityOut=albedoOpacityBlock( +uniforms.vAlbedoColor +#ifdef ALBEDO +,albedoTexture +,uniforms.vAlbedoInfos +#endif +,uniforms.baseWeight +#ifdef BASE_WEIGHT +,baseWeightTexture +,uniforms.vBaseWeightInfos +#endif +#ifdef OPACITY +,opacityMap +,uniforms.vOpacityInfos +#endif +#ifdef DETAIL +,detailColor +,uniforms.vDetailInfos +#endif +#ifdef DECAL +,decalColor +,uniforms.vDecalInfos +#endif +);var surfaceAlbedo: vec3f=albedoOpacityOut.surfaceAlbedo;var alpha: f32=albedoOpacityOut.alpha; +#define CUSTOM_FRAGMENT_UPDATE_ALPHA +#include +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +var aoOut: ambientOcclusionOutParams; +#ifdef AMBIENT +var ambientOcclusionColorMap: vec3f=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb; +#endif +aoOut=ambientOcclusionBlock( +#ifdef AMBIENT +ambientOcclusionColorMap, +uniforms.vAmbientInfos +#endif +); +#include +#ifdef UNLIT +var diffuseBase: vec3f= vec3f(1.,1.,1.); +#else +var baseColor: vec3f=surfaceAlbedo;var reflectivityOut: reflectivityOutParams; +#if defined(REFLECTIVITY) +var surfaceMetallicOrReflectivityColorMap: vec4f=textureSample(reflectivitySampler,reflectivitySamplerSampler,fragmentInputs.vReflectivityUV+uvOffset);var baseReflectivity: vec4f=surfaceMetallicOrReflectivityColorMap; +#ifndef METALLICWORKFLOW +#ifdef REFLECTIVITY_GAMMA +surfaceMetallicOrReflectivityColorMap=toLinearSpaceVec4(surfaceMetallicOrReflectivityColorMap); +#endif +surfaceMetallicOrReflectivityColorMap=vec4f(surfaceMetallicOrReflectivityColorMap.rgb*uniforms.vReflectivityInfos.y,surfaceMetallicOrReflectivityColorMap.a); +#endif +#endif +#if defined(MICROSURFACEMAP) +var microSurfaceTexel: vec4f=textureSample(microSurfaceSampler,microSurfaceSamplerSampler,fragmentInputs.vMicroSurfaceSamplerUV+uvOffset)*uniforms.vMicroSurfaceSamplerInfos.y; +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +var baseDiffuseRoughnessTexture: f32=textureSample(baseDiffuseRoughnessSampler,baseDiffuseRoughnessSamplerSampler,fragmentInputs.vBaseDiffuseRoughnessUV+uvOffset).x; +#endif +#ifdef METALLICWORKFLOW +var metallicReflectanceFactors: vec4f=uniforms.vMetallicReflectanceFactors; +#ifdef REFLECTANCE +var reflectanceFactorsMap: vec4f=textureSample(reflectanceSampler,reflectanceSamplerSampler,fragmentInputs.vReflectanceUV+uvOffset); +#ifdef REFLECTANCE_GAMMA +reflectanceFactorsMap=toLinearSpaceVec4(reflectanceFactorsMap); +#endif +metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a); +#endif +#ifdef METALLIC_REFLECTANCE +var metallicReflectanceFactorsMap: vec4f=textureSample(metallicReflectanceSampler,metallicReflectanceSamplerSampler,fragmentInputs.vMetallicReflectanceUV+uvOffset); +#ifdef METALLIC_REFLECTANCE_GAMMA +metallicReflectanceFactorsMap=toLinearSpaceVec4(metallicReflectanceFactorsMap); +#endif +#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY +metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*metallicReflectanceFactorsMap.rgb,metallicReflectanceFactors.a); +#endif +metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a; +#endif +#endif +reflectivityOut=reflectivityBlock( +uniforms.vReflectivityColor +#ifdef METALLICWORKFLOW +,surfaceAlbedo +,metallicReflectanceFactors +#endif +,uniforms.baseDiffuseRoughness +#ifdef BASE_DIFFUSE_ROUGHNESS +,baseDiffuseRoughnessTexture +,uniforms.vBaseDiffuseRoughnessInfos +#endif +#ifdef REFLECTIVITY +,uniforms.vReflectivityInfos +,surfaceMetallicOrReflectivityColorMap +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +,aoOut.ambientOcclusionColor +#endif +#ifdef MICROSURFACEMAP +,microSurfaceTexel +#endif +#ifdef DETAIL +,detailColor +,uniforms.vDetailInfos +#endif +);var microSurface: f32=reflectivityOut.microSurface;var roughness: f32=reflectivityOut.roughness;var diffuseRoughness: f32=reflectivityOut.diffuseRoughness; +#ifdef METALLICWORKFLOW +surfaceAlbedo=reflectivityOut.surfaceAlbedo; +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor; +#endif +#ifdef ALPHAFRESNEL +#if defined(ALPHATEST) || defined(ALPHABLEND) +var alphaFresnelOut: alphaFresnelOutParams;alphaFresnelOut=alphaFresnelBlock( +normalW, +viewDirectionW, +alpha, +microSurface +);alpha=alphaFresnelOut.alpha; +#endif +#endif +#include +#ifdef ANISOTROPIC +var anisotropicOut: anisotropicOutParams; +#ifdef ANISOTROPIC_TEXTURE +var anisotropyMapData: vec3f=textureSample(anisotropySampler,anisotropySamplerSampler,fragmentInputs.vAnisotropyUV+uvOffset).rgb*uniforms.vAnisotropyInfos.y; +#endif +anisotropicOut=anisotropicBlock( +uniforms.vAnisotropy, +roughness, +#ifdef ANISOTROPIC_TEXTURE +anisotropyMapData, +#endif +TBN, +normalW, +viewDirectionW +); +#endif +#ifdef REFLECTION +var reflectionOut: reflectionOutParams; +#ifndef USE_CUSTOM_REFLECTION +reflectionOut=reflectionBlock( +fragmentInputs.vPositionW +,normalW +,alphaG +,uniforms.vReflectionMicrosurfaceInfos +,uniforms.vReflectionInfos +,uniforms.vReflectionColor +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,roughness +#endif +,reflectionSampler +,reflectionSamplerSampler +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,fragmentInputs.vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,uniforms.reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +,irradianceSamplerSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,uniforms.vReflectionDominantDirection +#endif +#endif +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +#endif +,viewDirectionW +,diffuseRoughness +,surfaceAlbedo +); +#else +#define CUSTOM_REFLECTION +#endif +#endif +#include +#ifdef SHEEN +var sheenOut: sheenOutParams; +#ifdef SHEEN_TEXTURE +var sheenMapData: vec4f=textureSample(sheenSampler,sheenSamplerSampler,fragmentInputs.vSheenUV+uvOffset); +#endif +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +var sheenMapRoughnessData: vec4f=textureSample(sheenRoughnessSampler,sheenRoughnessSamplerSampler,fragmentInputs.vSheenRoughnessUV+uvOffset)*uniforms.vSheenInfos.w; +#endif +sheenOut=sheenBlock( +uniforms.vSheenColor +#ifdef SHEEN_ROUGHNESS +,uniforms.vSheenRoughness +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +,sheenMapRoughnessData +#endif +#endif +,roughness +#ifdef SHEEN_TEXTURE +,sheenMapData +,uniforms.vSheenInfos.y +#endif +,reflectanceF0 +#ifdef SHEEN_LINKWITHALBEDO +,baseColor +,surfaceAlbedo +#endif +#ifdef ENVIRONMENTBRDF +,NdotV +,environmentBrdf +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,AARoughnessFactors +,uniforms.vReflectionMicrosurfaceInfos +,uniforms.vReflectionInfos +,uniforms.vReflectionColor +,uniforms.vLightingIntensity +,reflectionSampler +,reflectionSamplerSampler +,reflectionOut.reflectionCoords +,NdotVUnclamped +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +,seo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +,eho +#endif +#endif +); +#ifdef SHEEN_LINKWITHALBEDO +surfaceAlbedo=sheenOut.surfaceAlbedo; +#endif +#endif +#ifdef CLEARCOAT +#ifdef CLEARCOAT_TEXTURE +var clearCoatMapData: vec2f=textureSample(clearCoatSampler,clearCoatSamplerSampler,fragmentInputs.vClearCoatUV+uvOffset).rg*uniforms.vClearCoatInfos.y; +#endif +#endif +#ifdef IRIDESCENCE +var iridescenceOut: iridescenceOutParams; +#ifdef IRIDESCENCE_TEXTURE +var iridescenceMapData: vec2f=textureSample(iridescenceSampler,iridescenceSamplerSampler,fragmentInputs.vIridescenceUV+uvOffset).rg*uniforms.vIridescenceInfos.y; +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +var iridescenceThicknessMapData: vec2f=textureSample(iridescenceThicknessSampler,iridescenceThicknessSamplerSampler,fragmentInputs.vIridescenceThicknessUV+uvOffset).rg*uniforms.vIridescenceInfos.w; +#endif +iridescenceOut=iridescenceBlock( +uniforms.vIridescenceParams +,NdotV +,specularEnvironmentR0 +#ifdef IRIDESCENCE_TEXTURE +,iridescenceMapData +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +,iridescenceThicknessMapData +#endif +#ifdef CLEARCOAT +,NdotVUnclamped +,uniforms.vClearCoatParams +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData +#endif +#endif +);var iridescenceIntensity: f32=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0; +#endif +var clearcoatOut: clearcoatOutParams; +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +var clearCoatMapRoughnessData: vec4f=textureSample(clearCoatRoughnessSampler,clearCoatRoughnessSamplerSampler,fragmentInputs.vClearCoatRoughnessUV+uvOffset)*uniforms.vClearCoatInfos.w; +#endif +#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +var clearCoatTintMapData: vec4f=textureSample(clearCoatTintSampler,clearCoatTintSamplerSampler,fragmentInputs.vClearCoatTintUV+uvOffset); +#endif +#ifdef CLEARCOAT_BUMP +var clearCoatBumpMapData: vec4f=textureSample(clearCoatBumpSampler,clearCoatBumpSamplerSampler,fragmentInputs.vClearCoatBumpUV+uvOffset); +#endif +clearcoatOut=clearcoatBlock( +fragmentInputs.vPositionW +,geometricNormalW +,viewDirectionW +,uniforms.vClearCoatParams +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +,clearCoatMapRoughnessData +#endif +,specularEnvironmentR0 +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData +#endif +#ifdef CLEARCOAT_TINT +,uniforms.vClearCoatTintParams +,uniforms.clearCoatColorAtDistance +,uniforms.vClearCoatRefractionParams +#ifdef CLEARCOAT_TINT_TEXTURE +,clearCoatTintMapData +#endif +#endif +#ifdef CLEARCOAT_BUMP +,uniforms.vClearCoatBumpInfos +,clearCoatBumpMapData +,fragmentInputs.vClearCoatBumpUV +#if defined(TANGENT) && defined(NORMAL) +,mat3x3(input.vTBN0,input.vTBN1,input.vTBN2) +#else +,uniforms.vClearCoatTangentSpaceParams +#endif +#ifdef OBJECTSPACE_NORMALMAP +,uniforms.normalMatrix +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +,faceNormal +#endif +#ifdef REFLECTION +,uniforms.vReflectionMicrosurfaceInfos +,uniforms.vReflectionInfos +,uniforms.vReflectionColor +,uniforms.vLightingIntensity +,reflectionSampler +,reflectionSamplerSampler +#ifndef LODBASEDMICROSFURACE +,reflectionLowSampler +,reflectionLowSamplerSampler +,reflectionHighSampler +,reflectionHighSamplerSampler +#endif +#ifdef REALTIME_FILTERING +,uniforms.vReflectionFilteringInfo +#endif +#endif +#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING) +,select(-1.,1.,fragmentInputs.frontFacing) +#endif +); +#else +clearcoatOut.specularEnvironmentR0=specularEnvironmentR0; +#endif +#include +var subSurfaceOut: subSurfaceOutParams; +#ifdef SUBSURFACE +#ifdef SS_THICKNESSANDMASK_TEXTURE +var thicknessMap: vec4f=textureSample(thicknessSampler,thicknessSamplerSampler,fragmentInputs.vThicknessUV+uvOffset); +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +var refractionIntensityMap: vec4f=textureSample(refractionIntensitySampler,refractionIntensitySamplerSampler,fragmentInputs.vRefractionIntensityUV+uvOffset); +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +var translucencyIntensityMap: vec4f=textureSample(translucencyIntensitySampler,translucencyIntensitySamplerSampler,fragmentInputs.vTranslucencyIntensityUV+uvOffset); +#endif +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +var translucencyColorMap: vec4f=textureSample(translucencyColorSampler,translucencyColorSamplerSampler,fragmentInputs.vTranslucencyColorUV+uvOffset); +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA +translucencyColorMap=toLinearSpaceVec4(translucencyColorMap); +#endif +#endif +subSurfaceOut=subSurfaceBlock( +uniforms.vSubSurfaceIntensity +,uniforms.vThicknessParam +,uniforms.vTintColor +,normalW +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +,vec3f(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b))) +#else +,baseSpecularEnvironmentReflectance +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +,thicknessMap +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +,refractionIntensityMap +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +,translucencyIntensityMap +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +,uniforms.reflectionMatrix +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +,reflectionOut.irradianceVector +#endif +#if defined(REALTIME_FILTERING) +,reflectionSampler +,reflectionSamplerSampler +,uniforms.vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +,icdfSamplerSampler +#endif +#endif +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +,irradianceSamplerSampler +#endif +#endif +#endif +#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY) +,surfaceAlbedo +#endif +#ifdef SS_REFRACTION +,fragmentInputs.vPositionW +,viewDirectionW +,scene.view +,uniforms.vRefractionInfos +,uniforms.refractionMatrix +,uniforms.vRefractionMicrosurfaceInfos +,uniforms.vLightingIntensity +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +,alpha +#endif +#ifdef SS_LODINREFRACTIONALPHA +,NdotVUnclamped +#endif +#ifdef SS_LINEARSPECULARREFRACTION +,roughness +#endif +,alphaG +,refractionSampler +,refractionSamplerSampler +#ifndef LODBASEDMICROSFURACE +,refractionLowSampler +,refractionLowSamplerSampler +,refractionHighSampler +,refractionHighSamplerSampler +#endif +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,uniforms.vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,uniforms.vRefractionPosition +,uniforms.vRefractionSize +#endif +#ifdef SS_DISPERSION +,uniforms.dispersion +#endif +#endif +#ifdef SS_TRANSLUCENCY +,uniforms.vDiffusionDistance +,uniforms.vTranslucencyColor +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +,translucencyColorMap +#endif +#endif +); +#ifdef SS_REFRACTION +surfaceAlbedo=subSurfaceOut.surfaceAlbedo; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +alpha=subSurfaceOut.alpha; +#endif +#endif +#else +subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance; +#endif +#include +#include[0..maxSimultaneousLights] +#include +#endif +#include +#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION +#include +#include +#include(color,finalColor) +#include +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#include +#endif +#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY) +fragmentOutputs.color=finalColor; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;} +#endif +#include +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStoreWGSL[nR]||(E.ShadersStoreWGSL[nR]=eB);wY={name:nR,shader:eB}});var rB,BY,sB=C(()=>{w();Xm();rB="pbrVertexDeclaration",BY=`uniform mat4 view;uniform mat4 viewProjection;uniform vec4 vEyePosition; +#ifdef MULTIVIEW +mat4 viewProjectionR; +#endif +#ifdef ALBEDO +uniform mat4 albedoMatrix;uniform vec2 vAlbedoInfos; +#endif +#ifdef BASE_WEIGHT +uniform mat4 baseWeightMatrix;uniform vec2 vBaseWeightInfos; +#endif +uniform float baseDiffuseRoughness; +#ifdef BASE_DIFFUSE_ROUGHNESS +uniform mat4 baseDiffuseRoughnessMatrix;uniform vec2 vBaseDiffuseRoughnessInfos; +#endif +#ifdef AMBIENT +uniform mat4 ambientMatrix;uniform vec4 vAmbientInfos; +#endif +#ifdef OPACITY +uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix; +#endif +#ifdef REFLECTIVITY +uniform vec3 vReflectivityInfos;uniform mat4 reflectivityMatrix; +#endif +#ifdef METALLIC_REFLECTANCE +uniform vec2 vMetallicReflectanceInfos;uniform mat4 metallicReflectanceMatrix; +#endif +#ifdef REFLECTANCE +uniform vec2 vReflectanceInfos;uniform mat4 reflectanceMatrix; +#endif +#ifdef MICROSURFACEMAP +uniform vec2 vMicroSurfaceSamplerInfos;uniform mat4 microSurfaceSamplerMatrix; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos;uniform mat4 bumpMatrix; +#endif +#ifdef POINTSIZE +uniform float pointSize; +#endif +uniform vec4 cameraInfo; +#ifdef REFLECTION +uniform vec2 vReflectionInfos;uniform mat4 reflectionMatrix; +#endif +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS) +uniform vec4 vClearCoatInfos; +#endif +#ifdef CLEARCOAT_TEXTURE +uniform mat4 clearCoatMatrix; +#endif +#ifdef CLEARCOAT_TEXTURE_ROUGHNESS +uniform mat4 clearCoatRoughnessMatrix; +#endif +#ifdef CLEARCOAT_BUMP +uniform vec2 vClearCoatBumpInfos;uniform mat4 clearCoatBumpMatrix; +#endif +#ifdef CLEARCOAT_TINT_TEXTURE +uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix; +#endif +#endif +#ifdef IRIDESCENCE +#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE) +uniform vec4 vIridescenceInfos; +#endif +#ifdef IRIDESCENCE_TEXTURE +uniform mat4 iridescenceMatrix; +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +uniform mat4 iridescenceThicknessMatrix; +#endif +#endif +#ifdef ANISOTROPIC +#ifdef ANISOTROPIC_TEXTURE +uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix; +#endif +#endif +#ifdef SHEEN +#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS) +uniform vec4 vSheenInfos; +#endif +#ifdef SHEEN_TEXTURE +uniform mat4 sheenMatrix; +#endif +#ifdef SHEEN_TEXTURE_ROUGHNESS +uniform mat4 sheenRoughnessMatrix; +#endif +#endif +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix; +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix; +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix; +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix; +#endif +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix; +#endif +#endif +#ifdef NORMAL +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22; +#else +uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX; +#endif +#endif +#endif +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos;uniform mat4 detailMatrix; +#endif +#include +#define ADDITIONAL_VERTEX_DECLARATION +`;E.IncludesShadersStore[rB]||(E.IncludesShadersStore[rB]=BY)});var nB,UY,aR=C(()=>{w();Io();of();nB="pbrUboDeclaration",UY=`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[nB]||(E.IncludesShadersStore[nB]=UY)});var oB={};Ie(oB,{pbrVertexShader:()=>VY});var oR,aB,VY,lB=C(()=>{w();sB();aR();Ym();lf();Or();_f();fa();ha();Eo();Km();jm();gf();vS();gn();jc();Zm();qm();Co();bo();ga();Mo();yo();da();ua();ma();Qm();Jm();$m();ep();En();Zc();tp();bh();wh();oR="pbrVertexShader",aB=`#define PBR_VERTEX_SHADER +#define CUSTOM_VERTEX_EXTENSION +precision highp float; +#include<__decl__pbrVertex> +#define CUSTOM_VERTEX_BEGIN +attribute vec3 position; +#ifdef NORMAL +attribute vec3 normal; +#endif +#ifdef TANGENT +attribute vec4 tangent; +#endif +#ifdef UV1 +attribute vec2 uv; +#endif +#include[2..7] +#include[1..7] +#ifdef VERTEXCOLOR +attribute vec4 color; +#endif +#include +#include +#include +#include +#include +#include +#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy) +#endif +#ifdef SUBSURFACE +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor) +#endif +varying vec3 vPositionW; +#if DEBUGMODE>0 +varying vec4 vClipSpacePosition; +#endif +#ifdef NORMAL +varying vec3 vNormalW; +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +varying vec3 vEnvironmentIrradiance; +#include +#endif +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +varying vec4 vColor; +#endif +#include +#include +#include +#include<__decl__lightVxFragment>[0..maxSimultaneousLights] +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +varying vec3 vPositionUVW; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +varying vec3 vDirectionW; +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +varying float vViewDepth; +#endif +#include +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +vec3 positionUpdated=position; +#ifdef NORMAL +vec3 normalUpdated=normal; +#endif +#ifdef TANGENT +vec4 tangentUpdated=tangent; +#endif +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#ifdef VERTEXCOLOR +vec4 colorUpdated=color; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#ifdef REFLECTIONMAP_SKYBOX +vPositionUVW=positionUpdated; +#endif +#define CUSTOM_VERTEX_UPDATE_POSITION +#define CUSTOM_VERTEX_UPDATE_NORMAL +#include +#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) +vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); +#endif +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos); +#ifdef PREPASS +#include +#endif +#ifdef NORMAL +mat3 normalWorld=mat3(finalWorld); +#if defined(INSTANCES) && defined(THIN_INSTANCES) +vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW); +#else +#ifdef NONUNIFORMSCALING +normalWorld=transposeMat3(inverseMat3(normalWorld)); +#endif +vNormalW=normalize(normalWorld*normalUpdated); +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);float NdotV=max(dot(vNormalW,viewDirectionW),0.0);vec3 roughNormal=mix(vNormalW,viewDirectionW,(0.5*(1.0-NdotV))*baseDiffuseRoughness);vec3 reflectionVector=vec3(reflectionMatrix*vec4(roughNormal,0)).xyz; +#else +vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz; +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector); +#endif +#endif +#define CUSTOM_VERTEX_UPDATE_WORLDPOS +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} +#else +gl_Position=viewProjection*worldPos; +#endif +#if DEBUGMODE>0 +vClipSpacePosition=gl_Position; +#endif +#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) +vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); +#endif +#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#ifdef RIGHT_HANDED +vViewDepth=-(view*worldPos).z; +#else +vViewDepth=(view*worldPos).z; +#endif +#endif +#ifndef UV1 +vec2 uvUpdated=vec2(0.,0.); +#endif +#ifndef UV2 +vec2 uv2Updated=vec2(0.,0.); +#endif +#ifdef MAINUV1 +vMainUV1=uvUpdated; +#endif +#ifdef MAINUV2 +vMainUV2=uv2Updated; +#endif +#include[3..7] +#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x) +#include(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_MATRIXNAME_,baseWeight,_INFONAME_,BaseWeightInfos.x) +#include(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_MATRIXNAME_,baseDiffuseRoughness,_INFONAME_,BaseDiffuseRoughnessInfos.x) +#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) +#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x) +#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z) +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z) +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x) +#endif +#ifdef SUBSURFACE +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_MATRIXNAME_,translucencyColor,_INFONAME_,TranslucencyColorInfos.x) +#endif +#include +#include +#include +#include[0..maxSimultaneousLights] +#include +#if defined(POINTSIZE) && !defined(WEBGPU) +gl_PointSize=pointSize; +#endif +#include +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStore[oR]||(E.ShadersStore[oR]=aB);VY={name:oR,shader:aB}});var cB,GY,fB=C(()=>{w();ip();cB="pbrFragmentDeclaration",GY=`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 +#ifdef BASE_WEIGHT +uniform vec2 vBaseWeightInfos; +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +uniform vec2 vBaseDiffuseRoughnessInfos; +#endif +#ifdef AMBIENT +uniform vec4 vAmbientInfos; +#endif +#ifdef BUMP +uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams; +#endif +#ifdef OPACITY +uniform vec2 vOpacityInfos; +#endif +#ifdef EMISSIVE +uniform vec2 vEmissiveInfos; +#endif +#ifdef LIGHTMAP +uniform vec2 vLightmapInfos; +#endif +#ifdef REFLECTIVITY +uniform vec3 vReflectivityInfos; +#endif +#ifdef MICROSURFACEMAP +uniform vec2 vMicroSurfaceSamplerInfos; +#endif +#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS) +uniform mat4 view; +#endif +#ifdef REFLECTION +uniform vec2 vReflectionInfos; +#ifdef REALTIME_FILTERING +uniform vec2 vReflectionFilteringInfo; +#endif +uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos; +#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION) +uniform vec3 vReflectionDominantDirection; +#endif +#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC) +uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; +#endif +#endif +#if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC) +uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; +#endif +#ifdef CLEARCOAT +uniform vec2 vClearCoatParams;uniform vec4 vClearCoatRefractionParams; +#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS) +uniform vec4 vClearCoatInfos; +#endif +#ifdef CLEARCOAT_TEXTURE +uniform mat4 clearCoatMatrix; +#endif +#ifdef CLEARCOAT_TEXTURE_ROUGHNESS +uniform mat4 clearCoatRoughnessMatrix; +#endif +#ifdef CLEARCOAT_BUMP +uniform vec2 vClearCoatBumpInfos;uniform vec2 vClearCoatTangentSpaceParams;uniform mat4 clearCoatBumpMatrix; +#endif +#ifdef CLEARCOAT_TINT +uniform vec4 vClearCoatTintParams;uniform float clearCoatColorAtDistance; +#ifdef CLEARCOAT_TINT_TEXTURE +uniform vec2 vClearCoatTintInfos;uniform mat4 clearCoatTintMatrix; +#endif +#endif +#endif +#ifdef IRIDESCENCE +uniform vec4 vIridescenceParams; +#if defined(IRIDESCENCE_TEXTURE) || defined(IRIDESCENCE_THICKNESS_TEXTURE) +uniform vec4 vIridescenceInfos; +#endif +#ifdef IRIDESCENCE_TEXTURE +uniform mat4 iridescenceMatrix; +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +uniform mat4 iridescenceThicknessMatrix; +#endif +#endif +#ifdef ANISOTROPIC +uniform vec3 vAnisotropy; +#ifdef ANISOTROPIC_TEXTURE +uniform vec2 vAnisotropyInfos;uniform mat4 anisotropyMatrix; +#endif +#endif +#ifdef SHEEN +uniform vec4 vSheenColor; +#ifdef SHEEN_ROUGHNESS +uniform float vSheenRoughness; +#endif +#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS) +uniform vec4 vSheenInfos; +#endif +#ifdef SHEEN_TEXTURE +uniform mat4 sheenMatrix; +#endif +#ifdef SHEEN_TEXTURE_ROUGHNESS +uniform mat4 sheenRoughnessMatrix; +#endif +#endif +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +uniform vec4 vRefractionMicrosurfaceInfos;uniform vec4 vRefractionInfos;uniform mat4 refractionMatrix; +#ifdef REALTIME_FILTERING +uniform vec2 vRefractionFilteringInfo; +#endif +#ifdef SS_DISPERSION +uniform float dispersion; +#endif +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +uniform vec2 vThicknessInfos;uniform mat4 thicknessMatrix; +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +uniform vec2 vRefractionIntensityInfos;uniform mat4 refractionIntensityMatrix; +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +uniform vec2 vTranslucencyIntensityInfos;uniform mat4 translucencyIntensityMatrix; +#endif +uniform vec2 vThicknessParam;uniform vec3 vDiffusionDistance;uniform vec4 vTintColor;uniform vec3 vSubSurfaceIntensity;uniform vec4 vTranslucencyColor; +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +uniform vec2 vTranslucencyColorInfos;uniform mat4 translucencyColorMatrix; +#endif +#endif +#ifdef PREPASS +#ifdef SS_SCATTERING +uniform float scatteringDiffusionProfile; +#endif +#endif +#if DEBUGMODE>0 +uniform vec2 vDebugMode; +#endif +#ifdef DETAIL +uniform vec4 vDetailInfos; +#endif +#include +#ifdef USESPHERICALFROMREFLECTIONMAP +#ifdef SPHERICAL_HARMONICS +uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22; +#else +uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX; +#endif +#endif +#define ADDITIONAL_FRAGMENT_DECLARATION +`;E.IncludesShadersStore[cB]||(E.IncludesShadersStore[cB]=GY)});var hB,kY,dB=C(()=>{w();hB="samplerFragmentAlternateDeclaration",kY=`#ifdef _DEFINENAME_ +#if _DEFINENAME_DIRECTUV==1 +#define v_VARYINGNAME_UV vMainUV1 +#elif _DEFINENAME_DIRECTUV==2 +#define v_VARYINGNAME_UV vMainUV2 +#elif _DEFINENAME_DIRECTUV==3 +#define v_VARYINGNAME_UV vMainUV3 +#elif _DEFINENAME_DIRECTUV==4 +#define v_VARYINGNAME_UV vMainUV4 +#elif _DEFINENAME_DIRECTUV==5 +#define v_VARYINGNAME_UV vMainUV5 +#elif _DEFINENAME_DIRECTUV==6 +#define v_VARYINGNAME_UV vMainUV6 +#else +varying vec2 v_VARYINGNAME_UV; +#endif +#endif +`;E.IncludesShadersStore[hB]||(E.IncludesShadersStore[hB]=kY)});var uB,WY,mB=C(()=>{w();_l();dB();zp();uB="pbrFragmentSamplersDeclaration",WY=`#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) +#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) +#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) +#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) +#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity) +#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface) +#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance) +#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance) +#include(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) +#ifdef CLEARCOAT +#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat) +#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness) +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) +uniform sampler2D clearCoatRoughnessSampler; +#endif +#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump) +#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint) +#endif +#ifdef IRIDESCENCE +#include(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence) +#include(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness) +#endif +#ifdef SHEEN +#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen) +#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness) +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) +uniform sampler2D sheenRoughnessSampler; +#endif +#endif +#ifdef ANISOTROPIC +#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy) +#endif +#include +#ifdef ENVIRONMENTBRDF +uniform sampler2D environmentBrdfSampler; +#endif +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +#ifdef SS_REFRACTIONMAP_3D +#define sampleRefraction(s,c) textureCube(s,c) +uniform samplerCube refractionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l) +#else +uniform samplerCube refractionSamplerLow;uniform samplerCube refractionSamplerHigh; +#endif +#else +#define sampleRefraction(s,c) texture2D(s,c) +uniform sampler2D refractionSampler; +#ifdef LODBASEDMICROSFURACE +#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l) +#else +uniform sampler2D refractionSamplerLow;uniform sampler2D refractionSamplerHigh; +#endif +#endif +#endif +#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness) +#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity) +#include(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor) +#endif +#ifdef IBL_CDF_FILTERING +uniform sampler2D icdfSampler; +#endif +`;E.IncludesShadersStore[uB]||(E.IncludesShadersStore[uB]=WY)});var pB,HY,_B=C(()=>{w();xS();pB="pbrBlockAlbedoOpacity",HY=`struct albedoOpacityOutParams +{vec3 surfaceAlbedo;float alpha;}; +#define pbr_inline +albedoOpacityOutParams albedoOpacityBlock( +in vec4 vAlbedoColor +#ifdef ALBEDO +,in vec4 albedoTexture +,in vec2 albedoInfos +#endif +,in float baseWeight +#ifdef BASE_WEIGHT +,in vec4 baseWeightTexture +,in vec2 vBaseWeightInfos +#endif +#ifdef OPACITY +,in vec4 opacityMap +,in vec2 vOpacityInfos +#endif +#ifdef DETAIL +,in vec4 detailColor +,in vec4 vDetailInfos +#endif +#ifdef DECAL +,in vec4 decalColor +,in vec4 vDecalInfos +#endif +) +{albedoOpacityOutParams outParams;vec3 surfaceAlbedo=vAlbedoColor.rgb;float alpha=vAlbedoColor.a; +#ifdef ALBEDO +#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST) +alpha*=albedoTexture.a; +#endif +#ifdef GAMMAALBEDO +surfaceAlbedo*=toLinearSpace(albedoTexture.rgb); +#else +surfaceAlbedo*=albedoTexture.rgb; +#endif +surfaceAlbedo*=albedoInfos.y; +#endif +#ifndef DECAL_AFTER_DETAIL +#include +#endif +#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) +surfaceAlbedo*=vColor.rgb; +#endif +#ifdef DETAIL +float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo; +#endif +#ifdef DECAL_AFTER_DETAIL +#include +#endif +#define CUSTOM_FRAGMENT_UPDATE_ALBEDO +surfaceAlbedo*=baseWeight; +#ifdef BASE_WEIGHT +surfaceAlbedo*=baseWeightTexture.r; +#endif +#ifdef OPACITY +#ifdef OPACITYRGB +alpha=getLuminance(opacityMap.rgb); +#else +alpha*=opacityMap.a; +#endif +alpha*=vOpacityInfos.y; +#endif +#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) +alpha*=vColor.a; +#endif +#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL) +#ifdef ALPHATEST +#if DEBUGMODE != 88 +if (alpha{w();gB="pbrBlockReflectivity",zY=`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; +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +vec3 ambientOcclusionColor; +#endif +#if DEBUGMODE>0 +#ifdef METALLICWORKFLOW +#ifdef REFLECTIVITY +vec4 surfaceMetallicColorMap; +#endif +vec3 metallicF0; +#else +#ifdef REFLECTIVITY +vec4 surfaceReflectivityColorMap; +#endif +#endif +#endif +}; +#define pbr_inline +reflectivityOutParams reflectivityBlock( +in vec4 reflectivityColor +#ifdef METALLICWORKFLOW +,in vec3 surfaceAlbedo +,in vec4 metallicReflectanceFactors +#endif +,in float baseDiffuseRoughness +#ifdef BASE_DIFFUSE_ROUGHNESS +,in float baseDiffuseRoughnessTexture +,in vec2 baseDiffuseRoughnessInfos +#endif +#ifdef REFLECTIVITY +,in vec3 reflectivityInfos +,in vec4 surfaceMetallicOrReflectivityColorMap +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +,in vec3 ambientOcclusionColorIn +#endif +#ifdef MICROSURFACEMAP +,in vec4 microSurfaceTexel +#endif +#ifdef DETAIL +,in vec4 detailColor +,in vec4 vDetailInfos +#endif +) +{reflectivityOutParams outParams;float microSurface=reflectivityColor.a;vec3 surfaceReflectivityColor=reflectivityColor.rgb; +#ifdef METALLICWORKFLOW +vec2 metallicRoughness=surfaceReflectivityColor.rg;float ior=surfaceReflectivityColor.b; +#ifdef REFLECTIVITY +#if DEBUGMODE>0 +outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef AOSTOREINMETALMAPRED +vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z); +#endif +#ifdef METALLNESSSTOREINMETALMAPBLUE +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b; +#else +metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r; +#endif +#ifdef ROUGHNESSSTOREINMETALMAPALPHA +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a; +#else +#ifdef ROUGHNESSSTOREINMETALMAPGREEN +metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g; +#endif +#endif +#endif +#ifdef DETAIL +float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5)); +#endif +#ifdef MICROSURFACEMAP +metallicRoughness.g*=microSurfaceTexel.r; +#endif +#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS +microSurface=1.0-metallicRoughness.g;vec3 baseColor=surfaceAlbedo;outParams.metallic=metallicRoughness.r;outParams.specularWeight=metallicReflectanceFactors.a;float dielectricF0=reflectivityColor.a*outParams.specularWeight;surfaceReflectivityColor=metallicReflectanceFactors.rgb; +#if DEBUGMODE>0 +outParams.metallicF0=vec3(dielectricF0)*surfaceReflectivityColor; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.surfaceAlbedo=baseColor.rgb*(vec3(1.0)-vec3(dielectricF0)*surfaceReflectivityColor)*(1.0-outParams.metallic); +#else +outParams.surfaceAlbedo=baseColor.rgb; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +{vec3 reflectivityColor=mix(dielectricF0*surfaceReflectivityColor,baseColor.rgb,outParams.metallic);outParams.reflectanceF0=max(reflectivityColor.r,max(reflectivityColor.g,reflectivityColor.b));} +#else +#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF +float maxF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF0=mix(dielectricF0*maxF0,1.0,outParams.metallic); +#else +outParams.reflectanceF0=mix(dielectricF0,1.0,outParams.metallic); +#endif +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.reflectanceF90=vec3(outParams.specularWeight);float f90Scale=1.0; +#else +float f90Scale=clamp(2.0*(ior-1.0),0.0,1.0);outParams.reflectanceF90=vec3(mix(outParams.specularWeight*f90Scale,1.0,outParams.metallic)); +#endif +outParams.dielectricColorF0=vec3(dielectricF0*surfaceReflectivityColor);vec3 metallicColorF0=baseColor.rgb;outParams.colorReflectanceF0=mix(outParams.dielectricColorF0,metallicColorF0,outParams.metallic); +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +vec3 dielectricColorF90=surfaceReflectivityColor*vec3(outParams.specularWeight)*vec3(f90Scale); +#else +vec3 dielectricColorF90=vec3(outParams.specularWeight*f90Scale); +#endif +#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) +vec3 conductorColorF90=surfaceReflectivityColor; +#else +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +vec3 conductorColorF90=outParams.reflectanceF90; +#else +vec3 conductorColorF90=vec3(1.0); +#endif +#endif +outParams.colorReflectanceF90=mix(dielectricColorF90,conductorColorF90,outParams.metallic); +#else +#ifdef REFLECTIVITY +surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb; +#if DEBUGMODE>0 +outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap; +#endif +#ifdef MICROSURFACEFROMREFLECTIVITYMAP +microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z; +#else +#ifdef MICROSURFACEAUTOMATIC +microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor); +#endif +#ifdef MICROSURFACEMAP +microSurface*=microSurfaceTexel.r; +#endif +#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE +#endif +#endif +outParams.colorReflectanceF0=surfaceReflectivityColor;outParams.reflectanceF0=max(surfaceReflectivityColor.r,max(surfaceReflectivityColor.g,surfaceReflectivityColor.b));outParams.reflectanceF90=vec3(1.0); +#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR) +outParams.colorReflectanceF90=surfaceReflectivityColor; +#else +outParams.colorReflectanceF90=vec3(1.0); +#endif +#endif +microSurface=saturate(microSurface);float roughness=1.-microSurface;float diffuseRoughness=baseDiffuseRoughness; +#ifdef BASE_DIFFUSE_ROUGHNESS +diffuseRoughness*=baseDiffuseRoughnessTexture*baseDiffuseRoughnessInfos.y; +#endif +outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.diffuseRoughness=diffuseRoughness;return outParams;} +`;E.IncludesShadersStore[gB]||(E.IncludesShadersStore[gB]=zY)});var vB,XY,SB=C(()=>{w();vB="pbrBlockAmbientOcclusion",XY=`struct ambientOcclusionOutParams +{vec3 ambientOcclusionColor; +#if DEBUGMODE>0 && defined(AMBIENT) +vec3 ambientOcclusionColorMap; +#endif +};ambientOcclusionOutParams ambientOcclusionBlock( +#ifdef AMBIENT +in vec3 ambientOcclusionColorMap_, +in vec4 vAmbientInfos +#endif +) +{ambientOcclusionOutParams outParams;vec3 ambientOcclusionColor=vec3(1.,1.,1.); +#ifdef AMBIENT +vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y; +#ifdef AMBIENTINGRAYSCALE +ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r); +#endif +ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z); +#if DEBUGMODE>0 +outParams.ambientOcclusionColorMap=ambientOcclusionColorMap; +#endif +#endif +outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;} +`;E.IncludesShadersStore[vB]||(E.IncludesShadersStore[vB]=XY)});var TB,YY,AB=C(()=>{w();TB="pbrBlockAlphaFresnel",YY=`#ifdef ALPHAFRESNEL +#if defined(ALPHATEST) || defined(ALPHABLEND) +struct alphaFresnelOutParams +{float alpha;}; +#define pbr_inline +alphaFresnelOutParams alphaFresnelBlock( +in vec3 normalW, +in vec3 viewDirectionW, +in float alpha, +in float microSurface +) +{alphaFresnelOutParams outParams;float opacityPerceptual=alpha; +#ifdef LINEARALPHAFRESNEL +float opacity0=opacityPerceptual; +#else +float opacity0=opacityPerceptual*opacityPerceptual; +#endif +float opacity90=fresnelGrazingReflectance(opacity0);vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x; +#ifdef ALPHATEST +if (outParams.alpha{w();RB="pbrBlockAnisotropic",KY=`#ifdef ANISOTROPIC +struct anisotropicOutParams +{float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;vec3 anisotropicNormal; +#if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE) +vec3 anisotropyMapData; +#endif +}; +#define pbr_inline +anisotropicOutParams anisotropicBlock( +in vec3 vAnisotropy, +in float roughness, +#ifdef ANISOTROPIC_TEXTURE +in vec3 anisotropyMapData, +#endif +in mat3 TBN, +in vec3 normalW, +in vec3 viewDirectionW +) +{anisotropicOutParams outParams;float anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.); +#ifdef ANISOTROPIC_TEXTURE +anisotropy*=anisotropyMapData.b; +#if DEBUGMODE>0 +outParams.anisotropyMapData=anisotropyMapData; +#endif +anisotropyMapData.rg=anisotropyMapData.rg*2.0-1.0; +#ifdef ANISOTROPIC_LEGACY +anisotropyDirection.rg*=anisotropyMapData.rg; +#else +anisotropyDirection.xy=mat2(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(anisotropyMapData.rg); +#endif +#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[RB]||(E.IncludesShadersStore[RB]=KY)});var IB,jY,CB=C(()=>{w();IB="pbrBlockReflection",jY=`#ifdef REFLECTION +struct reflectionOutParams +{vec4 environmentRadiance;vec3 environmentIrradiance; +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords; +#else +vec2 reflectionCoords; +#endif +#ifdef SS_TRANSLUCENCY +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +vec3 irradianceVector; +#endif +#endif +#endif +}; +#define pbr_inline +void createReflectionCoords( +in vec3 vPositionW, +in vec3 normalW, +#ifdef ANISOTROPIC +in anisotropicOutParams anisotropicOut, +#endif +#ifdef REFLECTIONMAP_3D +out vec3 reflectionCoords +#else +out vec2 reflectionCoords +#endif +) +{ +#ifdef ANISOTROPIC +vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal); +#else +vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW); +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +reflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +reflectionCoords=reflectionVector; +#else +reflectionCoords=reflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +reflectionCoords/=reflectionVector.z; +#endif +reflectionCoords.y=1.0-reflectionCoords.y; +#endif +} +#define pbr_inline +#define inline +void sampleReflectionTexture( +in float alphaG, +in vec3 vReflectionMicrosurfaceInfos, +in vec2 vReflectionInfos, +in vec3 vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +in float NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +in float roughness, +#endif +#ifdef REFLECTIONMAP_3D +in samplerCube reflectionSampler, +const vec3 reflectionCoords, +#else +in sampler2D reflectionSampler, +const vec2 reflectionCoords, +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +in samplerCube reflectionSamplerLow, +in samplerCube reflectionSamplerHigh, +#else +in sampler2D reflectionSamplerLow, +in sampler2D reflectionSamplerHigh, +#endif +#endif +#ifdef REALTIME_FILTERING +in vec2 vReflectionFilteringInfo, +#endif +out vec4 environmentRadiance +) +{ +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped); +#elif defined(LINEARSPECULARREFLECTION) +float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness); +#else +float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG); +#endif +#ifdef LODBASEDMICROSFURACE +reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z; +#ifdef LODINREFLECTIONALPHA +float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD); +#else +float requestedReflectionLOD=reflectionLOD; +#endif +#ifdef REALTIME_FILTERING +environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0); +#else +environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD); +#endif +#else +float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix( +sampleReflection(reflectionSamplerHigh,reflectionCoords), +environmentMid, +lodReflectionNormalizedDoubled +);} else {environmentRadiance=mix( +environmentMid, +sampleReflection(reflectionSamplerLow,reflectionCoords), +lodReflectionNormalizedDoubled-1.0 +);} +#endif +#ifdef RGBDREFLECTION +environmentRadiance.rgb=fromRGBD(environmentRadiance); +#endif +#ifdef GAMMAREFLECTION +environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb); +#endif +environmentRadiance.rgb*=vReflectionInfos.x;environmentRadiance.rgb*=vReflectionColor.rgb;} +#define pbr_inline +#define inline +reflectionOutParams reflectionBlock( +in vec3 vPositionW +,in vec3 normalW +,in float alphaG +,in vec3 vReflectionMicrosurfaceInfos +,in vec2 vReflectionInfos +,in vec3 vReflectionColor +#ifdef ANISOTROPIC +,in anisotropicOutParams anisotropicOut +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,in float NdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,in float roughness +#endif +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSampler +#else +,in sampler2D reflectionSampler +#endif +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,in vec3 vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,in mat4 reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,in samplerCube irradianceSampler +#else +,in sampler2D irradianceSampler +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,in vec3 reflectionDominantDirection +#endif +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSamplerLow +,in samplerCube reflectionSamplerHigh +#else +,in sampler2D reflectionSamplerLow +,in sampler2D reflectionSamplerHigh +#endif +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,in sampler2D icdfSampler +#endif +#endif +,in vec3 viewDirectionW +,in float diffuseRoughness +,in vec3 surfaceAlbedo +) +{reflectionOutParams outParams;vec4 environmentRadiance=vec4(0.,0.,0.,0.); +#ifdef REFLECTIONMAP_3D +vec3 reflectionCoords=vec3(0.); +#else +vec2 reflectionCoords=vec2(0.); +#endif +createReflectionCoords( +vPositionW, +normalW, +#ifdef ANISOTROPIC +anisotropicOut, +#endif +reflectionCoords +);sampleReflectionTexture( +alphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +roughness, +#endif +#ifdef REFLECTIONMAP_3D +reflectionSampler, +reflectionCoords, +#else +reflectionSampler, +reflectionCoords, +#endif +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentRadiance +);vec3 environmentIrradiance=vec3(0.,0.,0.); +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +#ifdef ANISOTROPIC +vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz; +#else +vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz; +#endif +vec3 irradianceView=vec3(reflectionMatrix*vec4(viewDirectionW,0)).xyz; +#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING) +#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY +float NdotV=max(dot(normalW,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness); +#endif +#endif +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0;irradianceView.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0;irradianceView.y*=-1.0; +#endif +#endif +#ifdef USESPHERICALFROMREFLECTIONMAP +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +environmentIrradiance=vEnvironmentIrradiance; +#else +#if defined(REALTIME_FILTERING) +environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +); +#else +environmentIrradiance=computeEnvironmentIrradiance(irradianceVector); +#endif +#ifdef SS_TRANSLUCENCY +outParams.irradianceVector=irradianceVector; +#endif +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +vec4 environmentIrradiance4=sampleReflection(irradianceSampler,irradianceVector); +#else +vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords); +#endif +environmentIrradiance=environmentIrradiance4.rgb; +#ifdef RGBDREFLECTION +environmentIrradiance.rgb=fromRGBD(environmentIrradiance4); +#endif +#ifdef GAMMAREFLECTION +environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb); +#endif +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0); +#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON +float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0))); +#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY +vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI); +#endif +environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm; +#endif +#endif +environmentIrradiance*=vReflectionColor.rgb*vReflectionInfos.x; +#ifdef MIX_IBL_RADIANCE_WITH_IRRADIANCE +outParams.environmentRadiance=vec4(mix(environmentRadiance.rgb,environmentIrradiance,alphaG),environmentRadiance.a); +#else +outParams.environmentRadiance=environmentRadiance; +#endif +outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;} +#endif +`;E.IncludesShadersStore[IB]||(E.IncludesShadersStore[IB]=jY)});var bB,ZY,MB=C(()=>{w();bB="pbrBlockSheen",ZY=`#ifdef SHEEN +struct sheenOutParams +{float sheenIntensity;vec3 sheenColor;float sheenRoughness; +#ifdef SHEEN_LINKWITHALBEDO +vec3 surfaceAlbedo; +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +float sheenAlbedoScaling; +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +vec3 finalSheenRadianceScaled; +#endif +#if DEBUGMODE>0 +#ifdef SHEEN_TEXTURE +vec4 sheenMapData; +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +vec3 sheenEnvironmentReflectance; +#endif +#endif +}; +#define pbr_inline +#define inline +sheenOutParams sheenBlock( +in vec4 vSheenColor +#ifdef SHEEN_ROUGHNESS +,in float vSheenRoughness +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +,in vec4 sheenMapRoughnessData +#endif +#endif +,in float roughness +#ifdef SHEEN_TEXTURE +,in vec4 sheenMapData +,in float sheenMapLevel +#endif +,in float reflectance +#ifdef SHEEN_LINKWITHALBEDO +,in vec3 baseColor +,in vec3 surfaceAlbedo +#endif +#ifdef ENVIRONMENTBRDF +,in float NdotV +,in vec3 environmentBrdf +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,in vec2 AARoughnessFactors +,in vec3 vReflectionMicrosurfaceInfos +,in vec2 vReflectionInfos +,in vec3 vReflectionColor +,in vec4 vLightingIntensity +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSampler +,in vec3 reflectionCoords +#else +,in sampler2D reflectionSampler +,in vec2 reflectionCoords +#endif +,in float NdotVUnclamped +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSamplerLow +,in samplerCube reflectionSamplerHigh +#else +,in sampler2D reflectionSamplerLow +,in sampler2D reflectionSamplerHigh +#endif +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +,in float seo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +,in float eho +#endif +#endif +) +{sheenOutParams outParams;float sheenIntensity=vSheenColor.a; +#ifdef SHEEN_TEXTURE +#if DEBUGMODE>0 +outParams.sheenMapData=sheenMapData; +#endif +#endif +#ifdef SHEEN_LINKWITHALBEDO +float sheenFactor=pow5(1.0-sheenIntensity);vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);float sheenRoughness=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#else +vec3 sheenColor=vSheenColor.rgb; +#ifdef SHEEN_TEXTURE +#ifdef SHEEN_GAMMATEXTURE +sheenColor.rgb*=toLinearSpace(sheenMapData.rgb); +#else +sheenColor.rgb*=sheenMapData.rgb; +#endif +sheenColor.rgb*=sheenMapLevel; +#endif +#ifdef SHEEN_ROUGHNESS +float sheenRoughness=vSheenRoughness; +#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE +#if defined(SHEEN_TEXTURE) +sheenRoughness*=sheenMapData.a; +#endif +#elif defined(SHEEN_TEXTURE_ROUGHNESS) +sheenRoughness*=sheenMapRoughnessData.a; +#endif +#else +float sheenRoughness=roughness; +#ifdef SHEEN_TEXTURE +sheenIntensity*=sheenMapData.a; +#endif +#endif +#if !defined(SHEEN_ALBEDOSCALING) +sheenIntensity*=(1.-reflectance); +#endif +sheenColor*=sheenIntensity; +#endif +#ifdef ENVIRONMENTBRDF +/*#ifdef SHEEN_SOFTER +vec3 environmentSheenBrdf=vec3(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness)); +#else*/ +#ifdef SHEEN_ROUGHNESS +vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness); +#else +vec3 environmentSheenBrdf=environmentBrdf; +#endif +/*#endif*/ +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness); +#ifdef SPECULARAA +sheenAlphaG+=AARoughnessFactors.y; +#endif +vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);sampleReflectionTexture( +sheenAlphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +NdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +sheenRoughness, +#endif +reflectionSampler, +reflectionCoords, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentSheenRadiance +);vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf); +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +sheenEnvironmentReflectance*=seo; +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +sheenEnvironmentReflectance*=eho; +#endif +#if DEBUGMODE>0 +outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance; +#endif +outParams.finalSheenRadianceScaled= +environmentSheenRadiance.rgb * +sheenEnvironmentReflectance * +vLightingIntensity.z; +#endif +#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b; +#endif +outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;} +#endif +`;E.IncludesShadersStore[bB]||(E.IncludesShadersStore[bB]=ZY)});var yB,qY,DB=C(()=>{w();yB="pbrBlockClearcoat",qY=`struct clearcoatOutParams +{vec3 specularEnvironmentR0;float conservationFactor;vec3 clearCoatNormalW;vec2 clearCoatAARoughnessFactors;float clearCoatIntensity;float clearCoatRoughness; +#ifdef REFLECTION +vec3 finalClearCoatRadianceScaled; +#endif +#ifdef CLEARCOAT_TINT +vec3 absorption;float clearCoatNdotVRefract;vec3 clearCoatColor;float clearCoatThickness; +#endif +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +vec3 energyConservationFactorClearCoat; +#endif +#if DEBUGMODE>0 +#ifdef CLEARCOAT_BUMP +mat3 TBNClearCoat; +#endif +#ifdef CLEARCOAT_TEXTURE +vec2 clearCoatMapData; +#endif +#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +vec4 clearCoatTintMapData; +#endif +#ifdef REFLECTION +vec4 environmentClearCoatRadiance;vec3 clearCoatEnvironmentReflectance; +#endif +float clearCoatNdotV; +#endif +}; +#ifdef CLEARCOAT +#define pbr_inline +#define inline +clearcoatOutParams clearcoatBlock( +in vec3 vPositionW +,in vec3 geometricNormalW +,in vec3 viewDirectionW +,in vec2 vClearCoatParams +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +,in vec4 clearCoatMapRoughnessData +#endif +,in vec3 specularEnvironmentR0 +#ifdef CLEARCOAT_TEXTURE +,in vec2 clearCoatMapData +#endif +#ifdef CLEARCOAT_TINT +,in vec4 vClearCoatTintParams +,in float clearCoatColorAtDistance +,in vec4 vClearCoatRefractionParams +#ifdef CLEARCOAT_TINT_TEXTURE +,in vec4 clearCoatTintMapData +#endif +#endif +#ifdef CLEARCOAT_BUMP +,in vec2 vClearCoatBumpInfos +,in vec4 clearCoatBumpMapData +,in vec2 vClearCoatBumpUV +#if defined(TANGENT) && defined(NORMAL) +,in mat3 vTBN +#else +,in vec2 vClearCoatTangentSpaceParams +#endif +#ifdef OBJECTSPACE_NORMALMAP +,in mat4 normalMatrix +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +,in vec3 faceNormal +#endif +#ifdef REFLECTION +,in vec3 vReflectionMicrosurfaceInfos +,in vec2 vReflectionInfos +,in vec3 vReflectionColor +,in vec4 vLightingIntensity +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSampler +#else +,in sampler2D reflectionSampler +#endif +#ifndef LODBASEDMICROSFURACE +#ifdef REFLECTIONMAP_3D +,in samplerCube reflectionSamplerLow +,in samplerCube reflectionSamplerHigh +#else +,in sampler2D reflectionSamplerLow +,in sampler2D reflectionSamplerHigh +#endif +#endif +#ifdef REALTIME_FILTERING +,in vec2 vReflectionFilteringInfo +#endif +#endif +#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING) +,in float frontFacingMultiplier +#endif +) +{clearcoatOutParams outParams;float clearCoatIntensity=vClearCoatParams.x;float clearCoatRoughness=vClearCoatParams.y; +#ifdef CLEARCOAT_TEXTURE +clearCoatIntensity*=clearCoatMapData.x; +#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE +clearCoatRoughness*=clearCoatMapData.y; +#endif +#if DEBUGMODE>0 +outParams.clearCoatMapData=clearCoatMapData; +#endif +#endif +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +clearCoatRoughness*=clearCoatMapRoughnessData.y; +#endif +outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness; +#ifdef CLEARCOAT_TINT +vec3 clearCoatColor=vClearCoatTintParams.rgb;float clearCoatThickness=vClearCoatTintParams.a; +#ifdef CLEARCOAT_TINT_TEXTURE +#ifdef CLEARCOAT_TINT_GAMMATEXTURE +clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb); +#else +clearCoatColor*=clearCoatTintMapData.rgb; +#endif +clearCoatThickness*=clearCoatTintMapData.a; +#if DEBUGMODE>0 +outParams.clearCoatTintMapData=clearCoatTintMapData; +#endif +#endif +outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness; +#endif +#ifdef CLEARCOAT_REMAP_F0 +vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0); +#else +vec3 specularEnvironmentR0Updated=specularEnvironmentR0; +#endif +outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);vec3 clearCoatNormalW=geometricNormalW; +#ifdef CLEARCOAT_BUMP +#ifdef NORMALXYSCALE +float clearCoatNormalScale=1.0; +#else +float clearCoatNormalScale=vClearCoatBumpInfos.y; +#endif +#if defined(TANGENT) && defined(NORMAL) +mat3 TBNClearCoat=vTBN; +#else +vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams); +#endif +#if DEBUGMODE>0 +outParams.TBNClearCoat=TBNClearCoat; +#endif +#ifdef OBJECTSPACE_NORMALMAP +clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW); +#else +clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y); +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier; +#endif +outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);float clearCoatNdotV=absEps(clearCoatNdotVUnclamped); +#if DEBUGMODE>0 +outParams.clearCoatNdotV=clearCoatNdotV; +#endif +#ifdef CLEARCOAT_TINT +vec3 clearCoatVRefract=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract)); +#endif +#if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION)) +vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness); +#endif +#if defined(REFLECTION) +float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness); +#ifdef SPECULARAA +clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y; +#endif +vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW); +#ifdef REFLECTIONMAP_OPPOSITEZ +clearCoatReflectionVector.z*=-1.0; +#endif +#ifdef REFLECTIONMAP_3D +vec3 clearCoatReflectionCoords=clearCoatReflectionVector; +#else +vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +clearCoatReflectionCoords/=clearCoatReflectionVector.z; +#endif +clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y; +#endif +sampleReflectionTexture( +clearCoatAlphaG, +vReflectionMicrosurfaceInfos, +vReflectionInfos, +vReflectionColor, +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +clearCoatNdotVUnclamped, +#endif +#ifdef LINEARSPECULARREFLECTION +clearCoatRoughness, +#endif +reflectionSampler, +clearCoatReflectionCoords, +#ifndef LODBASEDMICROSFURACE +reflectionSamplerLow, +reflectionSamplerHigh, +#endif +#ifdef REALTIME_FILTERING +vReflectionFilteringInfo, +#endif +environmentClearCoatRadiance +); +#if DEBUGMODE>0 +outParams.environmentClearCoatRadiance=environmentClearCoatRadiance; +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf); +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho; +#endif +#endif +#endif +#else +vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness)); +#endif +clearCoatEnvironmentReflectance*=clearCoatIntensity; +#if DEBUGMODE>0 +outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance; +#endif +outParams.finalClearCoatRadianceScaled= +environmentClearCoatRadiance.rgb * +clearCoatEnvironmentReflectance * +vLightingIntensity.z; +#endif +#if defined(CLEARCOAT_TINT) +outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity); +#endif +float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat); +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf); +#endif +return outParams;} +#endif +`;E.IncludesShadersStore[yB]||(E.IncludesShadersStore[yB]=qY)});var PB,QY,LB=C(()=>{w();PB="pbrBlockIridescence",QY=`struct iridescenceOutParams +{float iridescenceIntensity;float iridescenceIOR;float iridescenceThickness;vec3 specularEnvironmentR0;}; +#ifdef IRIDESCENCE +#define pbr_inline +#define inline +iridescenceOutParams iridescenceBlock( +in vec4 vIridescenceParams +,in float viewAngle +,in vec3 specularEnvironmentR0 +#ifdef IRIDESCENCE_TEXTURE +,in vec2 iridescenceMapData +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +,in vec2 iridescenceThicknessMapData +#endif +#ifdef CLEARCOAT +,in float NdotVUnclamped +,in vec2 vClearCoatParams +#ifdef CLEARCOAT_TEXTURE +,in vec2 clearCoatMapData +#endif +#endif +) +{iridescenceOutParams outParams;float iridescenceIntensity=vIridescenceParams.x;float iridescenceIOR=vIridescenceParams.y;float iridescenceThicknessMin=vIridescenceParams.z;float iridescenceThicknessMax=vIridescenceParams.w;float iridescenceThicknessWeight=1.; +#ifdef IRIDESCENCE_TEXTURE +iridescenceIntensity*=iridescenceMapData.x; +#endif +#if defined(IRIDESCENCE_THICKNESS_TEXTURE) +iridescenceThicknessWeight=iridescenceThicknessMapData.g; +#endif +float iridescenceThickness=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);float topIor=1.; +#ifdef CLEARCOAT +float clearCoatIntensity=vClearCoatParams.x; +#ifdef CLEARCOAT_TEXTURE +clearCoatIntensity*=clearCoatMapData.x; +#endif +topIor=mix(1.0,vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+square(1.0/topIor)*(square(NdotVUnclamped)-1.0)); +#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[PB]||(E.IncludesShadersStore[PB]=QY)});var OB,JY,NB=C(()=>{w();OB="pbrBlockSubSurface",JY=`struct subSurfaceOutParams +{vec3 specularEnvironmentReflectance; +#ifdef SS_REFRACTION +vec3 finalRefraction;vec3 surfaceAlbedo; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +float alpha; +#endif +float refractionOpacity; +#endif +#ifdef SS_TRANSLUCENCY +vec3 transmittance;float translucencyIntensity; +#ifdef REFLECTION +vec3 refractionIrradiance; +#endif +#endif +#if DEBUGMODE>0 +#ifdef SS_THICKNESSANDMASK_TEXTURE +vec4 thicknessMap; +#endif +#ifdef SS_REFRACTION +vec4 environmentRefraction;vec3 refractionTransmittance; +#endif +#endif +}; +#ifdef SUBSURFACE +#ifdef SS_REFRACTION +#define pbr_inline +#define inline +vec4 sampleEnvironmentRefraction( +in float ior +,in float thickness +,in float refractionLOD +,in vec3 normalW +,in vec3 vPositionW +,in vec3 viewDirectionW +,in mat4 view +,in vec4 vRefractionInfos +,in mat4 refractionMatrix +,in vec4 vRefractionMicrosurfaceInfos +,in float alphaG +#ifdef SS_REFRACTIONMAP_3D +,in samplerCube refractionSampler +#ifndef LODBASEDMICROSFURACE +,in samplerCube refractionSamplerLow +,in samplerCube refractionSamplerHigh +#endif +#else +,in sampler2D refractionSampler +#ifndef LODBASEDMICROSFURACE +,in sampler2D refractionSamplerLow +,in sampler2D refractionSamplerHigh +#endif +#endif +#ifdef ANISOTROPIC +,in anisotropicOutParams anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,in vec2 vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,in vec3 refractionPosition +,in vec3 refractionSize +#endif +) {vec4 environmentRefraction=vec4(0.,0.,0.,0.); +#ifdef ANISOTROPIC +vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior); +#else +vec3 refractionVector=refract(-viewDirectionW,normalW,ior); +#endif +#ifdef SS_REFRACTIONMAP_OPPOSITEZ +refractionVector.z*=-1.0; +#endif +#ifdef SS_REFRACTIONMAP_3D +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition); +#endif +refractionVector.y=refractionVector.y*vRefractionInfos.w;vec3 refractionCoords=refractionVector;refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0)); +#else +#ifdef SS_USE_THICKNESS_AS_DEPTH +vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0))); +#else +vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0))); +#endif +vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y; +#endif +#ifdef LODBASEDMICROSFURACE +refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z; +#ifdef SS_LODINREFRACTIONALPHA +float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD); +#else +float requestedRefractionLOD=refractionLOD; +#endif +#if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D) +environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0); +#else +environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD); +#endif +#else +float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix( +sampleRefraction(refractionSamplerHigh,refractionCoords), +environmentRefractionMid, +lodRefractionNormalizedDoubled +);} else {environmentRefraction=mix( +environmentRefractionMid, +sampleRefraction(refractionSamplerLow,refractionCoords), +lodRefractionNormalizedDoubled-1.0 +);} +#endif +#ifdef SS_RGBDREFRACTION +environmentRefraction.rgb=fromRGBD(environmentRefraction); +#endif +#ifdef SS_GAMMAREFRACTION +environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb); +#endif +return environmentRefraction;} +#endif +#define pbr_inline +#define inline +subSurfaceOutParams subSurfaceBlock( +in vec3 vSubSurfaceIntensity +,in vec2 vThicknessParam +,in vec4 vTintColor +,in vec3 normalW +,in vec3 vSpecularEnvironmentReflectance +#ifdef SS_THICKNESSANDMASK_TEXTURE +,in vec4 thicknessMap +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +,in vec4 refractionIntensityMap +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +,in vec4 translucencyIntensityMap +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +,in mat4 reflectionMatrix +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +,in vec3 irradianceVector_ +#endif +#if defined(REALTIME_FILTERING) +,in samplerCube reflectionSampler +,in vec2 vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,in sampler2D icdfSampler +#endif +#endif +#endif +#ifdef USEIRRADIANCEMAP +#ifdef REFLECTIONMAP_3D +,in samplerCube irradianceSampler +#else +,in sampler2D irradianceSampler +#endif +#endif +#endif +#endif +#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY) +,in vec3 surfaceAlbedo +#endif +#ifdef SS_REFRACTION +,in vec3 vPositionW +,in vec3 viewDirectionW +,in mat4 view +,in vec4 vRefractionInfos +,in mat4 refractionMatrix +,in vec4 vRefractionMicrosurfaceInfos +,in vec4 vLightingIntensity +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +,in float alpha +#endif +#ifdef SS_LODINREFRACTIONALPHA +,in float NdotVUnclamped +#endif +#ifdef SS_LINEARSPECULARREFRACTION +,in float roughness +#endif +,in float alphaG +#ifdef SS_REFRACTIONMAP_3D +,in samplerCube refractionSampler +#ifndef LODBASEDMICROSFURACE +,in samplerCube refractionSamplerLow +,in samplerCube refractionSamplerHigh +#endif +#else +,in sampler2D refractionSampler +#ifndef LODBASEDMICROSFURACE +,in sampler2D refractionSamplerLow +,in sampler2D refractionSamplerHigh +#endif +#endif +#ifdef ANISOTROPIC +,in anisotropicOutParams anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,in vec2 vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,in vec3 refractionPosition +,in vec3 refractionSize +#endif +#ifdef SS_DISPERSION +,in float dispersion +#endif +#endif +#ifdef SS_TRANSLUCENCY +,in vec3 vDiffusionDistance +,in vec4 vTranslucencyColor +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +,in vec4 translucencyColorMap +#endif +#endif +) +{subSurfaceOutParams outParams;outParams.specularEnvironmentReflectance=vSpecularEnvironmentReflectance; +#ifdef SS_REFRACTION +float refractionIntensity=vSubSurfaceIntensity.x; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +refractionIntensity*=(1.0-alpha);outParams.alpha=1.0; +#endif +#endif +#ifdef SS_TRANSLUCENCY +float translucencyIntensity=vSubSurfaceIntensity.y; +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +#ifdef SS_USE_GLTF_TEXTURES +float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x; +#else +float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x; +#endif +#if DEBUGMODE>0 +outParams.thicknessMap=thicknessMap; +#endif +#if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS) +#ifdef SS_USE_GLTF_TEXTURES +refractionIntensity*=thicknessMap.r; +#else +refractionIntensity*=thicknessMap.g; +#endif +#endif +#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS) +#ifdef SS_USE_GLTF_TEXTURES +translucencyIntensity*=thicknessMap.a; +#else +translucencyIntensity*=thicknessMap.b; +#endif +#endif +#else +float thickness=vThicknessParam.y; +#endif +#if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE) +#ifdef SS_USE_GLTF_TEXTURES +refractionIntensity*=refractionIntensityMap.r; +#else +refractionIntensity*=refractionIntensityMap.g; +#endif +#endif +#if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE) +#ifdef SS_USE_GLTF_TEXTURES +translucencyIntensity*=translucencyIntensityMap.a; +#else +translucencyIntensity*=translucencyIntensityMap.b; +#endif +#endif +#ifdef SS_TRANSLUCENCY +thickness=maxEps(thickness);vec4 translucencyColor=vTranslucencyColor; +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +translucencyColor*=translucencyColorMap; +#endif +vec3 transmittance=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity; +#endif +#ifdef SS_REFRACTION +vec4 environmentRefraction=vec4(0.,0.,0.,0.); +#ifdef SS_HAS_THICKNESS +float ior=vRefractionInfos.y; +#else +float ior=vRefractionMicrosurfaceInfos.w; +#endif +#ifdef SS_LODINREFRACTIONALPHA +float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped); +#elif defined(SS_LINEARSPECULARREFRACTION) +float refractionRoughness=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness); +#else +float refractionAlphaG=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG); +#endif +float refraction_ior=vRefractionInfos.y; +#ifdef SS_DISPERSION +float realIOR=1.0/refraction_ior;float iorDispersionSpread=0.04*dispersion*(realIOR-1.0);vec3 iors=vec3(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (int i=0; i<3; i++) {refraction_ior=iors[i]; +#endif +vec4 envSample=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG +#ifdef SS_REFRACTIONMAP_3D +,refractionSampler +#ifndef LODBASEDMICROSFURACE +,refractionSamplerLow +,refractionSamplerHigh +#endif +#else +,refractionSampler +#ifndef LODBASEDMICROSFURACE +,refractionSamplerLow +,refractionSamplerHigh +#endif +#endif +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,refractionPosition +,refractionSize +#endif +); +#ifdef SS_DISPERSION +environmentRefraction[i]=envSample[i];} +#else +environmentRefraction=envSample; +#endif +environmentRefraction.rgb*=vRefractionInfos.x; +#endif +#ifdef SS_REFRACTION +vec3 refractionTransmittance=vec3(refractionIntensity); +#ifdef SS_THICKNESSANDMASK_TEXTURE +vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,thickness); +#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY) +float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);environmentRefraction.rgb*=volumeAlbedo; +#else +vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y); +#endif +#ifdef SS_ALBEDOFORREFRACTIONTINT +environmentRefraction.rgb*=surfaceAlbedo.rgb; +#endif +outParams.surfaceAlbedo=surfaceAlbedo;outParams.refractionOpacity=1.-refractionIntensity; +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +outParams.surfaceAlbedo*=outParams.refractionOpacity; +#endif +#ifdef UNUSED_MULTIPLEBOUNCES +vec3 bounceSpecularEnvironmentReflectance=(2.0*vSpecularEnvironmentReflectance)/(1.0+vSpecularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,vSpecularEnvironmentReflectance,refractionIntensity); +#endif +#if DEBUGMODE>0 +outParams.refractionTransmittance=refractionTransmittance; +#endif +outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;outParams.finalRefraction*=vec3(1.0)-vSpecularEnvironmentReflectance; +#if DEBUGMODE>0 +outParams.environmentRefraction=environmentRefraction; +#endif +#endif +#if defined(REFLECTION) && defined(SS_TRANSLUCENCY) +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP) +vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz; +#ifdef REFLECTIONMAP_OPPOSITEZ +irradianceVector.z*=-1.0; +#endif +#ifdef INVERTCUBICMAP +irradianceVector.y*=-1.0; +#endif +#else +vec3 irradianceVector=irradianceVector_; +#endif +#if defined(USESPHERICALFROMREFLECTIONMAP) +#if defined(REALTIME_FILTERING) +vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo,0.0,surfaceAlbedo,irradianceVector +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +); +#else +vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector); +#endif +#elif defined(USEIRRADIANCEMAP) +#ifdef REFLECTIONMAP_3D +vec3 irradianceCoords=irradianceVector; +#else +vec2 irradianceCoords=irradianceVector.xy; +#ifdef REFLECTIONMAP_PROJECTION +irradianceCoords/=irradianceVector.z; +#endif +irradianceCoords.y=1.0-irradianceCoords.y; +#endif +vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords); +#ifdef RGBDREFLECTION +refractionIrradiance.rgb=fromRGBD(refractionIrradiance); +#endif +#ifdef GAMMAREFLECTION +refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb); +#endif +#else +vec4 refractionIrradiance=vec4(0.); +#endif +refractionIrradiance.rgb*=transmittance; +#ifdef SS_ALBEDOFORTRANSLUCENCYTINT +refractionIrradiance.rgb*=surfaceAlbedo.rgb; +#endif +outParams.refractionIrradiance=refractionIrradiance.rgb; +#endif +return outParams;} +#endif +`;E.IncludesShadersStore[OB]||(E.IncludesShadersStore[OB]=JY)});var FB,$Y,lR=C(()=>{w();FB="pbrBlockReflectance0",$Y=`float reflectanceF0=reflectivityOut.reflectanceF0;vec3 specularEnvironmentR0=reflectivityOut.colorReflectanceF0;vec3 specularEnvironmentR90=reflectivityOut.colorReflectanceF90; +#ifdef ALPHAFRESNEL +float reflectance90=fresnelGrazingReflectance(reflectanceF0);specularEnvironmentR90=specularEnvironmentR90*reflectance90; +#endif +`;E.IncludesShadersStore[FB]||(E.IncludesShadersStore[FB]=$Y)});var wB,e7,BB=C(()=>{w();RS();lR();wB="pbrClusteredLightingFunctions",e7=`#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 +#include +#define inline +lightingInfo computeClusteredLighting( +sampler2D lightDataTexture, +sampler2D tileMaskTexture, +vec4 lightData, +ivec2 sliceRange, +vec3 V, +vec3 N, +vec3 posW, +vec3 surfaceAlbedo, +reflectivityOutParams reflectivityOut +#ifdef IRIDESCENCE +,float iridescenceIntensity +#endif +#ifdef SS_TRANSLUCENCY +,subSurfaceOutParams subSurfaceOut +#endif +#ifdef SPECULARTERM +,float AARoughnessFactor +#endif +#ifdef ANISOTROPIC +,anisotropicOutParams anisotropicOut +#endif +#ifdef SHEEN +,sheenOutParams sheenOut +#endif +#ifdef CLEARCOAT +,clearcoatOutParams clearcoatOut +#endif +) {float NdotV=absEps(dot(N,V)); +#include +#ifdef CLEARCOAT +specularEnvironmentR0=clearcoatOut.specularEnvironmentR0; +#endif +lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);preLightingInfo preInfo=computePointAndSpotPreLightingInfo(light.vLightData,V,N,posW);preInfo.NdotV=NdotV;preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light.vLightFalloff.x,light.vLightFalloff.y);if (light.vLightDirection.w>=0.0) {preInfo.attenuation*=computeDirectionalLightFalloff(light.vLightDirection.xyz,preInfo.L,light.vLightDirection.w,light.vLightData.w,light.vLightFalloff.z,light.vLightFalloff.w);} +preInfo.roughness=adjustRoughnessFromLightProperties(reflectivityOut.roughness,light.vLightSpecular.a,preInfo.lightDistance);preInfo.diffuseRoughness=reflectivityOut.diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo; +#ifdef IRIDESCENCE +preInfo.iridescenceIntensity=iridescenceIntensity; +#endif +lightingInfo info; +#ifdef SS_TRANSLUCENCY +#ifdef SS_TRANSLUCENCY_LEGACY +info.diffuse=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance);info.diffuseTransmission=vec3(0); +#else +info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,light.vLightDiffuse.rgb,subSurfaceOut.transmittance); +#endif +#else +info.diffuse=computeDiffuseLighting(preInfo,light.vLightDiffuse.rgb); +#endif +#ifdef SPECULARTERM +#if CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR +vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);vec3 coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic); +#else +vec3 coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,specularEnvironmentR0,reflectivityOut.colorReflectanceF90); +#endif +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +float NdotH=dot(N,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel); +#endif +#ifdef ANISOTROPIC +info.specular=computeAnisotropicSpecularLighting(preInfo,V,N,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb); +#else +info.specular=computeSpecularLighting(preInfo,N,specularEnvironmentR0,coloredFresnel,AARoughnessFactor,light.vLightDiffuse.rgb); +#endif +#endif +#ifdef SHEEN +#ifdef SHEEN_LINKWITHALBEDO +preInfo.roughness=sheenOut.sheenIntensity; +#else +preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light.vLightSpecular.a,preInfo.lightDistance); +#endif +info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactor,light.vLightDiffuse.rgb); +#endif +#ifdef CLEARCOAT +preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light.vLightSpecular.a,preInfo.lightDistance);info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light.vLightDiffuse.rgb); +#ifdef CLEARCOAT_TINT +float absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=absorption; +#endif +#ifdef SPECULARTERM +info.specular*=absorption; +#endif +#endif +info.diffuse*=info.clearCoat.w; +#ifdef SS_TRANSLUCENCY +info.diffuseTransmission*=info.clearCoat.w; +#endif +#ifdef SPECULARTERM +info.specular*=info.clearCoat.w; +#endif +#ifdef SHEEN +info.sheen*=info.clearCoat.w; +#endif +#endif +result.diffuse+=info.diffuse; +#ifdef SS_TRANSLUCENCY +result.diffuseTransmission+=info.diffuseTransmission; +#endif +#ifdef SPECULARTERM +result.specular+=info.specular; +#endif +#ifdef CLEARCOAT +result.clearCoat+=info.clearCoat; +#endif +#ifdef SHEEN +result.sheen+=info.sheen; +#endif +} +batchOffset+=CLUSTLIGHT_BATCH;} +return result;} +#endif +`;E.IncludesShadersStore[wB]||(E.IncludesShadersStore[wB]=e7)});var UB,t7,VB=C(()=>{w();UB="pbrBlockNormalFinal",t7=`#if defined(FORCENORMALFORWARD) && defined(NORMAL) +vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; +#if defined(TWOSIDEDLIGHTING) +faceNormal=gl_FrontFacing ? faceNormal : -faceNormal; +#endif +normalW*=sign(dot(normalW,faceNormal)); +#endif +#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) +#if defined(MIRRORED) +normalW=gl_FrontFacing ? -normalW : normalW; +#else +normalW=gl_FrontFacing ? normalW : -normalW; +#endif +#endif +`;E.IncludesShadersStore[UB]||(E.IncludesShadersStore[UB]=t7)});var GB,i7,kB=C(()=>{w();GB="pbrBlockLightmapInit",i7=`#ifdef LIGHTMAP +vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); +#ifdef RGBDLIGHTMAP +lightmapColor.rgb=fromRGBD(lightmapColor); +#endif +#ifdef GAMMALIGHTMAP +lightmapColor.rgb=toLinearSpace(lightmapColor.rgb); +#endif +lightmapColor.rgb*=vLightmapInfos.y; +#endif +`;E.IncludesShadersStore[GB]||(E.IncludesShadersStore[GB]=i7)});var WB,r7,HB=C(()=>{w();WB="pbrBlockGeometryInfo",r7=`float NdotVUnclamped=dot(normalW,viewDirectionW);float NdotV=absEps(NdotVUnclamped);float alphaG=convertRoughnessToAverageSlope(roughness);vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz); +#ifdef SPECULARAA +alphaG+=AARoughnessFactors.y; +#endif +#if defined(ENVIRONMENTBRDF) +vec3 environmentBrdf=getBRDFLookup(NdotV,roughness); +#endif +#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX) +#ifdef RADIANCEOCCLUSION +#ifdef AMBIENTINGRAYSCALE +float ambientMonochrome=aoOut.ambientOcclusionColor.r; +#else +float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor); +#endif +float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped); +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW); +#endif +#endif +#endif +#endif +`;E.IncludesShadersStore[WB]||(E.IncludesShadersStore[WB]=r7)});var zB,s7,XB=C(()=>{w();zB="pbrBlockReflectance",s7=`#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); +#else +vec3 colorSpecularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,environmentBrdf); +#endif +#ifdef RADIANCEOCCLUSION +colorSpecularEnvironmentReflectance*=seo; +#endif +#ifdef HORIZONOCCLUSION +#ifdef BUMP +#ifdef REFLECTIONMAP_3D +colorSpecularEnvironmentReflectance*=eho; +#endif +#endif +#endif +#else +vec3 colorSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));vec3 baseSpecularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,vec3(reflectanceF0),reflectivityOut.reflectanceF90,sqrt(microSurface)); +#endif +#ifdef CLEARCOAT +colorSpecularEnvironmentReflectance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +colorSpecularEnvironmentReflectance*=clearcoatOut.absorption; +#endif +#endif +`;E.IncludesShadersStore[zB]||(E.IncludesShadersStore[zB]=s7)});var YB,n7,KB=C(()=>{w();YB="pbrBlockDirectLighting",n7=`vec3 diffuseBase=vec3(0.,0.,0.); +#ifdef SS_TRANSLUCENCY +vec3 diffuseTransmissionBase=vec3(0.,0.,0.); +#endif +#ifdef SPECULARTERM +vec3 specularBase=vec3(0.,0.,0.); +#endif +#ifdef CLEARCOAT +vec3 clearCoatBase=vec3(0.,0.,0.); +#endif +#ifdef SHEEN +vec3 sheenBase=vec3(0.,0.,0.); +#endif +#if defined(SPECULARTERM) && defined(LIGHT0) +vec3 coloredFresnel; +#endif +preLightingInfo preInfo;lightingInfo info;float shadow=1.; +float aggShadow=0.;float numLights=0.; +#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT) +vec3 absorption=vec3(0.); +#endif +`;E.IncludesShadersStore[YB]||(E.IncludesShadersStore[YB]=n7)});var jB,a7,ZB=C(()=>{w();jB="pbrBlockFinalLitComponents",a7=`aggShadow=aggShadow/numLights; +#if defined(ENVIRONMENTBRDF) +#ifdef MS_BRDF_ENERGY_CONSERVATION +vec3 baseSpecularEnergyConservationFactor=getEnergyConservationFactor(vec3(reflectanceF0),environmentBrdf);vec3 coloredEnergyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf); +#endif +#endif +#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF) +surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb; +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +#ifndef METALLICWORKFLOW +#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION +surfaceAlbedo.rgb=(1.-reflectanceF0)*surfaceAlbedo.rgb; +#endif +#endif +#endif +#ifdef REFLECTION +vec3 finalIrradiance=reflectionOut.environmentIrradiance; +#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION +#if defined(METALLICWORKFLOW) || defined(SPECULAR_GLOSSINESS_ENERGY_CONSERVATION) +vec3 baseSpecularEnergy=vec3(baseSpecularEnvironmentReflectance); +#if defined(ENVIRONMENTBRDF) +#ifdef MS_BRDF_ENERGY_CONSERVATION +baseSpecularEnergy*=baseSpecularEnergyConservationFactor; +#endif +#endif +finalIrradiance*=clamp(vec3(1.0)-baseSpecularEnergy,0.0,1.0); +#endif +#endif +#if defined(CLEARCOAT) +finalIrradiance*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +finalIrradiance*=clearcoatOut.absorption; +#endif +#endif +#ifndef SS_APPLY_ALBEDO_AFTER_SUBSURFACE +finalIrradiance*=surfaceAlbedo.rgb; +#endif +#if defined(SS_REFRACTION) +finalIrradiance*=subSurfaceOut.refractionOpacity; +#endif +#if defined(SS_TRANSLUCENCY) +finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance; +#endif +#ifdef SS_APPLY_ALBEDO_AFTER_SUBSURFACE +finalIrradiance*=surfaceAlbedo.rgb; +#endif +finalIrradiance*=vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor; +#endif +#ifdef SPECULARTERM +vec3 finalSpecular=specularBase;finalSpecular=max(finalSpecular,0.0);vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalSpecularScaled*=coloredEnergyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalSpecularScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif +#ifdef REFLECTION +vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;finalRadiance*=colorSpecularEnvironmentReflectance;vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalRadianceScaled*=coloredEnergyConservationFactor; +#endif +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING) +finalRadianceScaled*=sheenOut.sheenAlbedoScaling; +#endif +#endif +#ifdef SHEEN +vec3 finalSheen=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,0.0);vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w; +#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor; +#if defined(CLEARCOAT_TINT) +sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption; +#endif +#endif +#endif +#ifdef CLEARCOAT +vec3 finalClearCoat=clearCoatBase;finalClearCoat=max(finalClearCoat,0.0);vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w; +#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION) +finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat; +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor; +#ifdef CLEARCOAT_TINT +subSurfaceOut.finalRefraction*=clearcoatOut.absorption; +#endif +#endif +#endif +#ifdef ALPHABLEND +float luminanceOverAlpha=0.0; +#if defined(REFLECTION) && defined(RADIANCEOVERALPHA) +luminanceOverAlpha+=getLuminance(finalRadianceScaled); +#if defined(CLEARCOAT) +luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled); +#endif +#endif +#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA) +luminanceOverAlpha+=getLuminance(finalSpecularScaled); +#endif +#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA) +luminanceOverAlpha+=getLuminance(finalClearCoatScaled); +#endif +#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA) +alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha); +#endif +#endif +`;E.IncludesShadersStore[jB]||(E.IncludesShadersStore[jB]=a7)});var qB,o7,QB=C(()=>{w();qB="pbrBlockFinalUnlitComponents",o7=`vec3 finalDiffuse=diffuseBase;finalDiffuse*=surfaceAlbedo; +#if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION) +finalDiffuse*=subSurfaceOut.refractionOpacity; +#endif +#if defined(SS_TRANSLUCENCY) && !defined(UNLIT) +finalDiffuse+=diffuseTransmissionBase; +#endif +finalDiffuse=max(finalDiffuse,0.0);finalDiffuse*=vLightingIntensity.x;vec3 finalAmbient=vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;vec3 finalEmissive=vEmissiveColor; +#ifdef EMISSIVE +vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb; +#ifdef GAMMAEMISSIVE +finalEmissive*=toLinearSpace(emissiveColorTex.rgb); +#else +finalEmissive*=emissiveColorTex.rgb; +#endif +finalEmissive*= vEmissiveInfos.y; +#endif +finalEmissive*=vLightingIntensity.y; +#ifdef AMBIENT +vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w); +#else +vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor; +#endif +finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse; +`;E.IncludesShadersStore[qB]||(E.IncludesShadersStore[qB]=o7)});var JB,l7,$B=C(()=>{w();JB="pbrBlockFinalColorComposition",l7=`vec4 finalColor=vec4( +#ifndef UNLIT +#ifdef REFLECTION +finalIrradiance + +#endif +#ifdef SPECULARTERM +finalSpecularScaled + +#endif +#ifdef SHEEN +finalSheenScaled + +#endif +#ifdef CLEARCOAT +finalClearCoatScaled + +#endif +#ifdef REFLECTION +finalRadianceScaled + +#if defined(SHEEN) && defined(ENVIRONMENTBRDF) +sheenOut.finalSheenRadianceScaled + +#endif +#ifdef CLEARCOAT +clearcoatOut.finalClearCoatRadianceScaled + +#endif +#endif +#ifdef SS_REFRACTION +subSurfaceOut.finalRefraction + +#endif +#endif +finalAmbient + +finalDiffuse, +alpha); +#ifdef LIGHTMAP +#ifndef LIGHTMAPEXCLUDED +#ifdef USELIGHTMAPASSHADOWMAP +finalColor.rgb*=lightmapColor.rgb; +#else +finalColor.rgb+=lightmapColor.rgb; +#endif +#endif +#endif +finalColor.rgb+=finalEmissive; +#define CUSTOM_FRAGMENT_BEFORE_FOG +finalColor=max(finalColor,0.0); +`;E.IncludesShadersStore[JB]||(E.IncludesShadersStore[JB]=l7)});var eU,c7,tU=C(()=>{w();eU="pbrBlockPrePass",c7=`#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); +#endif +#ifdef PREPASS_LOCAL_POSITION +gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo); +#endif +#if defined(PREPASS_VELOCITY) +vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#elif defined(PREPASS_VELOCITY_LINEAR) +vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO +gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(surfaceAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +vec3 sqAlbedo=sqrt(surfaceAlbedo); +#endif +#ifdef PREPASS_IRRADIANCE_LEGACY +vec3 irradiance=finalDiffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=finalIrradiance; +#endif +#endif +#ifdef SS_SCATTERING +#ifdef PREPASS_COLOR +gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb-irradiance,finalColor.a); +#endif +irradiance/=sqAlbedo; +#else +#ifdef PREPASS_COLOR +gl_FragData[PREPASS_COLOR_INDEX]=finalColor; +#endif +float scatteringDiffusionProfile=255.; +#endif +gl_FragData[PREPASS_IRRADIANCE_LEGACY_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.); +#else +#ifdef PREPASS_IRRADIANCE +vec3 irradiance=finalDiffuse; +#ifndef UNLIT +#ifdef REFLECTION +irradiance+=finalIrradiance; +#endif +#endif +gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo); +#endif +#if defined(PREPASS_COLOR) +gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a); +#endif +#endif +#ifdef PREPASS_DEPTH +gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_SCREENSPACE_DEPTH +gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMALIZED_VIEW_DEPTH +gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo); +#endif +#ifdef PREPASS_NORMAL +#ifdef PREPASS_NORMAL_WORLDSPACE +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); +#else +gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); +#endif +#endif +#ifdef PREPASS_WORLD_NORMAL +gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo); +#endif +#ifdef PREPASS_ALBEDO_SQRT +gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo); +#endif +#ifdef PREPASS_REFLECTIVITY +#ifndef UNLIT +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo; +#else +gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo; +#endif +#endif +#endif +`;E.IncludesShadersStore[eU]||(E.IncludesShadersStore[eU]=c7)});var rU={};Ie(rU,{pbrPixelShader:()=>f7});var cR,iU,f7,sU=C(()=>{w();rp();sp();fB();aR();FA();np();ap();mB();lp();vn();ga();qc();Or();wA();BA();UA();cp();op();gf();VA();GA();_f();kA();WA();Xp();fp();hp();Bh();_B();EB();SB();AB();xB();CB();MB();DB();LB();NB();BB();Sn();HA();dp();VB();up();kB();HB();lR();XB();KB();IS();ZB();QB();$B();Uh();Qc();zA();tU();mp();XA();cR="pbrPixelShader",iU=`#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 +#endif +#ifdef LODBASEDMICROSFURACE +#extension GL_EXT_shader_texture_lod : enable +#endif +#define CUSTOM_FRAGMENT_BEGIN +#ifdef LOGARITHMICDEPTH +#extension GL_EXT_frag_depth : enable +#endif +#if SCENE_MRT_COUNT>0 +#include[SCENE_MRT_COUNT] +#endif +precision highp float; +#include +#ifndef FROMLINEARSPACE +#define FROMLINEARSPACE +#endif +#include<__decl__pbrFragment> +#include +#include<__decl__lightFragment>[0..maxSimultaneousLights] +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef REFLECTION +#include +#endif +#define CUSTOM_FRAGMENT_DEFINITIONS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +#include +#include +#include +#include +albedoOpacityOutParams albedoOpacityOut; +#ifdef ALBEDO +vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset); +#endif +#ifdef BASE_WEIGHT +vec4 baseWeightTexture=texture2D(baseWeightSampler,vBaseWeightUV+uvOffset); +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); +#endif +#ifdef DECAL +vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset); +#endif +albedoOpacityOut=albedoOpacityBlock( +vAlbedoColor +#ifdef ALBEDO +,albedoTexture +,vAlbedoInfos +#endif +,baseWeight +#ifdef BASE_WEIGHT +,baseWeightTexture +,vBaseWeightInfos +#endif +#ifdef OPACITY +,opacityMap +,vOpacityInfos +#endif +#ifdef DETAIL +,detailColor +,vDetailInfos +#endif +#ifdef DECAL +,decalColor +,vDecalInfos +#endif +);vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;float alpha=albedoOpacityOut.alpha; +#define CUSTOM_FRAGMENT_UPDATE_ALPHA +#include +#define CUSTOM_FRAGMENT_BEFORE_LIGHTS +ambientOcclusionOutParams aoOut; +#ifdef AMBIENT +vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb; +#endif +aoOut=ambientOcclusionBlock( +#ifdef AMBIENT +ambientOcclusionColorMap, +vAmbientInfos +#endif +); +#include +#ifdef UNLIT +vec3 diffuseBase=vec3(1.,1.,1.); +#else +vec3 baseColor=surfaceAlbedo;reflectivityOutParams reflectivityOut; +#if defined(REFLECTIVITY) +vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap; +#ifndef METALLICWORKFLOW +#ifdef REFLECTIVITY_GAMMA +surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap); +#endif +surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y; +#endif +#endif +#if defined(MICROSURFACEMAP) +vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y; +#endif +#ifdef METALLICWORKFLOW +vec4 metallicReflectanceFactors=vMetallicReflectanceFactors; +#ifdef REFLECTANCE +vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset); +#ifdef REFLECTANCE_GAMMA +reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap); +#endif +metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb; +#endif +#ifdef METALLIC_REFLECTANCE +vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset); +#ifdef METALLIC_REFLECTANCE_GAMMA +metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap); +#endif +#ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY +metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb; +#endif +metallicReflectanceFactors.a*=metallicReflectanceFactorsMap.a; +#endif +#endif +#ifdef BASE_DIFFUSE_ROUGHNESS +float baseDiffuseRoughnessTexture=texture2D(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r; +#endif +reflectivityOut=reflectivityBlock( +vReflectivityColor +#ifdef METALLICWORKFLOW +,surfaceAlbedo +,metallicReflectanceFactors +#endif +,baseDiffuseRoughness +#ifdef BASE_DIFFUSE_ROUGHNESS +,baseDiffuseRoughnessTexture +,vBaseDiffuseRoughnessInfos +#endif +#ifdef REFLECTIVITY +,vReflectivityInfos +,surfaceMetallicOrReflectivityColorMap +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +,aoOut.ambientOcclusionColor +#endif +#ifdef MICROSURFACEMAP +,microSurfaceTexel +#endif +#ifdef DETAIL +,detailColor +,vDetailInfos +#endif +);float microSurface=reflectivityOut.microSurface;float roughness=reflectivityOut.roughness;float diffuseRoughness=reflectivityOut.diffuseRoughness; +#ifdef METALLICWORKFLOW +surfaceAlbedo=reflectivityOut.surfaceAlbedo; +#endif +#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED) +aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor; +#endif +#ifdef ALPHAFRESNEL +#if defined(ALPHATEST) || defined(ALPHABLEND) +alphaFresnelOutParams alphaFresnelOut;alphaFresnelOut=alphaFresnelBlock( +normalW, +viewDirectionW, +alpha, +microSurface +);alpha=alphaFresnelOut.alpha; +#endif +#endif +#include +#ifdef ANISOTROPIC +anisotropicOutParams anisotropicOut; +#ifdef ANISOTROPIC_TEXTURE +vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y; +#endif +anisotropicOut=anisotropicBlock( +vAnisotropy, +roughness, +#ifdef ANISOTROPIC_TEXTURE +anisotropyMapData, +#endif +TBN, +normalW, +viewDirectionW +); +#endif +#ifdef REFLECTION +reflectionOutParams reflectionOut; +#ifndef USE_CUSTOM_REFLECTION +reflectionOut=reflectionBlock( +vPositionW +,normalW +,alphaG +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX) +,NdotVUnclamped +#endif +#ifdef LINEARSPECULARREFLECTION +,roughness +#endif +,reflectionSampler +#if defined(NORMAL) && defined(USESPHERICALINVERTEX) +,vEnvironmentIrradiance +#endif +#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D)) +,reflectionMatrix +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION +,vReflectionDominantDirection +#endif +#endif +#ifndef LODBASEDMICROSFURACE +,reflectionSamplerLow +,reflectionSamplerHigh +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +#endif +,viewDirectionW +,diffuseRoughness +,baseColor +); +#else +#define CUSTOM_REFLECTION +#endif +#endif +#include +#ifdef SHEEN +sheenOutParams sheenOut; +#ifdef SHEEN_TEXTURE +vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset); +#endif +#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w; +#endif +sheenOut=sheenBlock( +vSheenColor +#ifdef SHEEN_ROUGHNESS +,vSheenRoughness +#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE) +,sheenMapRoughnessData +#endif +#endif +,roughness +#ifdef SHEEN_TEXTURE +,sheenMapData +,vSheenInfos.y +#endif +,reflectanceF0 +#ifdef SHEEN_LINKWITHALBEDO +,baseColor +,surfaceAlbedo +#endif +#ifdef ENVIRONMENTBRDF +,NdotV +,environmentBrdf +#endif +#if defined(REFLECTION) && defined(ENVIRONMENTBRDF) +,AARoughnessFactors +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +,vLightingIntensity +,reflectionSampler +,reflectionOut.reflectionCoords +,NdotVUnclamped +#ifndef LODBASEDMICROSFURACE +,reflectionSamplerLow +,reflectionSamplerHigh +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION) +,seo +#endif +#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D) +,eho +#endif +#endif +); +#ifdef SHEEN_LINKWITHALBEDO +surfaceAlbedo=sheenOut.surfaceAlbedo; +#endif +#endif +#ifdef CLEARCOAT +#ifdef CLEARCOAT_TEXTURE +vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y; +#endif +#endif +#ifdef IRIDESCENCE +iridescenceOutParams iridescenceOut; +#ifdef IRIDESCENCE_TEXTURE +vec2 iridescenceMapData=texture2D(iridescenceSampler,vIridescenceUV+uvOffset).rg*vIridescenceInfos.y; +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +vec2 iridescenceThicknessMapData=texture2D(iridescenceThicknessSampler,vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w; +#endif +iridescenceOut=iridescenceBlock( +vIridescenceParams +,NdotV +,specularEnvironmentR0 +#ifdef IRIDESCENCE_TEXTURE +,iridescenceMapData +#endif +#ifdef IRIDESCENCE_THICKNESS_TEXTURE +,iridescenceThicknessMapData +#endif +#ifdef CLEARCOAT +,NdotVUnclamped +,vClearCoatParams +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData +#endif +#endif +);float iridescenceIntensity=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0; +#endif +clearcoatOutParams clearcoatOut; +#ifdef CLEARCOAT +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w; +#endif +#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE) +vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset); +#endif +#ifdef CLEARCOAT_BUMP +vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset); +#endif +clearcoatOut=clearcoatBlock( +vPositionW +,geometricNormalW +,viewDirectionW +,vClearCoatParams +#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE) +,clearCoatMapRoughnessData +#endif +,specularEnvironmentR0 +#ifdef CLEARCOAT_TEXTURE +,clearCoatMapData +#endif +#ifdef CLEARCOAT_TINT +,vClearCoatTintParams +,clearCoatColorAtDistance +,vClearCoatRefractionParams +#ifdef CLEARCOAT_TINT_TEXTURE +,clearCoatTintMapData +#endif +#endif +#ifdef CLEARCOAT_BUMP +,vClearCoatBumpInfos +,clearCoatBumpMapData +,vClearCoatBumpUV +#if defined(TANGENT) && defined(NORMAL) +,vTBN +#else +,vClearCoatTangentSpaceParams +#endif +#ifdef OBJECTSPACE_NORMALMAP +,normalMatrix +#endif +#endif +#if defined(FORCENORMALFORWARD) && defined(NORMAL) +,faceNormal +#endif +#ifdef REFLECTION +,vReflectionMicrosurfaceInfos +,vReflectionInfos +,vReflectionColor +,vLightingIntensity +,reflectionSampler +#ifndef LODBASEDMICROSFURACE +,reflectionSamplerLow +,reflectionSamplerHigh +#endif +#ifdef REALTIME_FILTERING +,vReflectionFilteringInfo +#endif +#endif +#if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING) +,(gl_FrontFacing ? 1. : -1.) +#endif +); +#else +clearcoatOut.specularEnvironmentR0=specularEnvironmentR0; +#endif +#include +subSurfaceOutParams subSurfaceOut; +#ifdef SUBSURFACE +#ifdef SS_THICKNESSANDMASK_TEXTURE +vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset); +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset); +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset); +#endif +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +vec4 translucencyColorMap=texture2D(translucencyColorSampler,vTranslucencyColorUV+uvOffset); +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE_GAMMA +translucencyColorMap=toLinearSpace(translucencyColorMap); +#endif +#endif +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +vec3 vSpecularEnvironmentReflectance=vec3(max(colorSpecularEnvironmentReflectance.r,max(colorSpecularEnvironmentReflectance.g,colorSpecularEnvironmentReflectance.b))); +#endif +subSurfaceOut=subSurfaceBlock( +vSubSurfaceIntensity +,vThicknessParam +,vTintColor +,normalW +#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION +,vSpecularEnvironmentReflectance +#else +,baseSpecularEnvironmentReflectance +#endif +#ifdef SS_THICKNESSANDMASK_TEXTURE +,thicknessMap +#endif +#ifdef SS_REFRACTIONINTENSITY_TEXTURE +,refractionIntensityMap +#endif +#ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE +,translucencyIntensityMap +#endif +#ifdef REFLECTION +#ifdef SS_TRANSLUCENCY +,reflectionMatrix +#ifdef USESPHERICALFROMREFLECTIONMAP +#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX) +,reflectionOut.irradianceVector +#endif +#if defined(REALTIME_FILTERING) +,reflectionSampler +,vReflectionFilteringInfo +#ifdef IBL_CDF_FILTERING +,icdfSampler +#endif +#endif +#endif +#ifdef USEIRRADIANCEMAP +,irradianceSampler +#endif +#endif +#endif +#if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY) +,surfaceAlbedo +#endif +#ifdef SS_REFRACTION +,vPositionW +,viewDirectionW +,view +,vRefractionInfos +,refractionMatrix +,vRefractionMicrosurfaceInfos +,vLightingIntensity +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +,alpha +#endif +#ifdef SS_LODINREFRACTIONALPHA +,NdotVUnclamped +#endif +#ifdef SS_LINEARSPECULARREFRACTION +,roughness +#endif +,alphaG +,refractionSampler +#ifndef LODBASEDMICROSFURACE +,refractionSamplerLow +,refractionSamplerHigh +#endif +#ifdef ANISOTROPIC +,anisotropicOut +#endif +#ifdef REALTIME_FILTERING +,vRefractionFilteringInfo +#endif +#ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC +,vRefractionPosition +,vRefractionSize +#endif +#ifdef SS_DISPERSION +,dispersion +#endif +#endif +#ifdef SS_TRANSLUCENCY +,vDiffusionDistance +,vTranslucencyColor +#ifdef SS_TRANSLUCENCYCOLOR_TEXTURE +,translucencyColorMap +#endif +#endif +); +#ifdef SS_REFRACTION +surfaceAlbedo=subSurfaceOut.surfaceAlbedo; +#ifdef SS_LINKREFRACTIONTOTRANSPARENCY +alpha=subSurfaceOut.alpha; +#endif +#endif +#else +subSurfaceOut.specularEnvironmentReflectance=colorSpecularEnvironmentReflectance; +#endif +#include +#include[0..maxSimultaneousLights] +#include +#endif +#include +#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION +#include +#include +#include(color,finalColor) +#include +#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR +#ifdef PREPASS +#include +#endif +#if !defined(PREPASS) || defined(WEBGL2) +gl_FragColor=finalColor; +#endif +#include +#if ORDER_INDEPENDENT_TRANSPARENCY +if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;} +#endif +#include +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStore[cR]||(E.ShadersStore[cR]=iU);f7={name:cR,shader:iU}});var Tf,fR,Zp,hR,Jt,nU=C(()=>{$e();Qe();We();As();Wp();vr();Ee();It();i2();gm();Je();Em();oh();Vi();Ur();Hc();ns();xE();mo();r2();s2();n2();a2();o2();cS();Ps();Ih();Ui();vm();Sm();Tm();Am();Tf={effect:null,subMesh:null},fR=class extends sf(rf(qt)){},Zp=class extends ef(fR){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}},hR=class extends nf(os){},Jt=class s extends hR{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||s.ForceGLSL),this._directIntensity=1,this._emissiveIntensity=1,this._environmentIntensity=1,this._specularIntensity=1,this._lightingInfos=new ft(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=s.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=ae.White(),this._useOnlyMetallicFromMetallicReflectanceTexture=!1,this._metallicReflectanceTexture=null,this._reflectanceTexture=null,this._microSurfaceTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._ambientColor=new ae(0,0,0),this._albedoColor=new ae(1,1,1),this._baseWeight=1,this._baseDiffuseRoughness=null,this._reflectivityColor=new ae(1,1,1),this._reflectionColor=new ae(1,1,1),this._emissiveColor=new ae(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=s.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 yt(16),this._globalAmbientColor=new ae(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 ai(this),this.clearCoat=new Ri(this),this.iridescence=new Cr(this),this.anisotropy=new Ta(this),this.sheen=new Gr(this),this.subSurface=new vt(this),this.detailMap=new ls(this),this._attachImageProcessingConfiguration(null),this.getRenderTargetTextures=()=>(this._renderTargets.reset(),re.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets),this._environmentBRDFTexture=kp(this.getScene()),this.prePassConfiguration=new xr}get hasRenderTargetTextures(){return re.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}get isPrePassCapable(){return!this.disableDepthWrite}getClassName(){return"PBRBaseMaterial"}get _disableAlphaBlending(){var e;return this._transparencyMode===s.PBRMATERIAL_OPAQUE||this._transparencyMode===s.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===s.PBRMATERIAL_ALPHATEST)}_shouldUseAlphaFromAlbedoTexture(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==s.PBRMATERIAL_OPAQUE}_hasAlphaChannel(){return this._albedoTexture!=null&&this._albedoTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._albedoTexture}isReadyForSubMesh(e,t,i){var d;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 Zp(this._eventInfo.defineNames));let n=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;let a=this.getScene(),o=a.getEngine();if(n._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a.texturesEnabled)){if(this._albedoTexture&&re.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking()||this._baseWeightTexture&&re.BaseWeightTextureEnabled&&!this._baseWeightTexture.isReadyOrNotBlocking()||this._baseDiffuseRoughnessTexture&&re.BaseDiffuseRoughnessTextureEnabled&&!this._baseDiffuseRoughnessTexture.isReadyOrNotBlocking()||this._ambientTexture&&re.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking()||this._opacityTexture&&re.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;let u=this._getReflectionTexture();if(u&&re.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;if(u.irradianceTexture){if(!u.irradianceTexture.isReadyOrNotBlocking())return!1}else if(!u.sphericalPolynomial&&((d=u.getInternalTexture())!=null&&d._sphericalPolynomialPromise))return!1}if(this._lightmapTexture&&re.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking()||this._emissiveTexture&&re.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(re.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&&re.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady()||this._environmentBRDFTexture&&re.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=n,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh||n._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;if(n.AREALIGHTUSED||n.CLUSTLIGHT_BATCH){for(let u=0;u{m.push(`vp_${R}_info`)}))}else this._vertexPullingMetadata=null;et&&(et.PrepareUniforms(m,i),et.PrepareSamplers(p,i)),lo({uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights,shaderLanguage:this._shaderLanguage});let v={};this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,m,_,p,i,d,v));let I=i.toString(),x=c.createEffect(u,{attributes:d,uniformsNames:m,uniformBuffersNames:_,samplers:p,defines:I,fallbacks:f,onCompiled:r,onError:n,indexParameters:g,processFinalCode:v.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(()=>(h2(),f2)),Promise.resolve().then(()=>(iB(),tB))]):await Promise.all([Promise.resolve().then(()=>(lB(),oB)),Promise.resolve().then(()=>(sU(),rU))]),this._shadersLoaded=!0}},c);return this._eventInfo.customCode=void 0,x}_prepareDefines(e,t,i,r=null,n=null){let a=t.hasThinInstances,o=this.getScene(),l=o.getEngine();Pc(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,Lc(o,i);let c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(Nc(o,i,this.canRenderToMRT&&!c),Oc(o,i,c),qi.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&&re.DiffuseTextureEnabled?(ot(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._baseWeightTexture&&re.BaseWeightTextureEnabled?ot(this._baseWeightTexture,i,"BASE_WEIGHT"):i.BASE_WEIGHT=!1,this._baseDiffuseRoughnessTexture&&re.BaseDiffuseRoughnessTextureEnabled?ot(this._baseDiffuseRoughnessTexture,i,"BASE_DIFFUSE_ROUGHNESS"):i.BASE_DIFFUSE_ROUGHNESS=!1,this._ambientTexture&&re.AmbientTextureEnabled?(ot(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&re.OpacityTextureEnabled?(ot(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;let f=this._getReflectionTexture(),h=this._forceIrradianceInFragment||this.realTimeFiltering||this._twoSidedLighting||l.getCaps().maxVaryingVectors<=8||this._baseDiffuseRoughnessTexture!=null;so(o,f,i,this.realTimeFiltering,this.realTimeFilteringQuality,!h),this._lightmapTexture&&re.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&&re.EmissiveTextureEnabled?(ot(this._emissiveTexture,i,"EMISSIVE"),i.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):i.EMISSIVE=!1,re.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&&re.BumpTextureEnabled&&!this._disableBumpMap?(ot(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&re.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&&re.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===s.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===s.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&&(ro(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(y.NormalKind),i.DEBUGMODE=this._debugMode),no(o,l,this,i,!!r,n,a),this._eventInfo.defines=i,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),ao(e,i,!0,!0,!0,this._transparencyMode!==s.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 Zp(this._eventInfo.defineNames),o=this._prepareEffect(e,e,a,void 0,void 0,r.useInstances,r.clipPlane);this._onEffectCreatedObservable&&(Tf.effect=o,Tf.subMesh=null,this._onEffectCreatedObservable.notifyObservers(Tf)),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),Fc(e,!0,!0,!0,!0,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){var d,u,m,p;let r=this.getScene(),n=i.materialDefines;if(!n)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),qi.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),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));let c=this._mustRebind(r,a,i,t.visibility);Sr(t,this._activeEffect,this.prePassConfiguration),this._vertexPullingMetadata&&_o(this._activeEffect,this._vertexPullingMetadata);let f=null,h=this._uniformBuffer;if(c){if(this.bindViewProjection(a),f=this._getReflectionTexture(),!h.useUbo||!this.isFrozen||!h.isSync||i._drawWrapper._forceRebindOnNextCall){if(r.texturesEnabled&&(this._albedoTexture&&re.DiffuseTextureEnabled&&(h.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),lt(this._albedoTexture,h,"albedo")),this._baseWeightTexture&&re.BaseWeightTextureEnabled&&(h.updateFloat2("vBaseWeightInfos",this._baseWeightTexture.coordinatesIndex,this._baseWeightTexture.level),lt(this._baseWeightTexture,h,"baseWeight")),this._baseDiffuseRoughnessTexture&&re.BaseDiffuseRoughnessTextureEnabled&&(h.updateFloat2("vBaseDiffuseRoughnessInfos",this._baseDiffuseRoughnessTexture.coordinatesIndex,this._baseDiffuseRoughnessTexture.level),lt(this._baseDiffuseRoughnessTexture,h,"baseDiffuseRoughness")),this._ambientTexture&&re.AmbientTextureEnabled&&(h.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),lt(this._ambientTexture,h,"ambient")),this._opacityTexture&&re.OpacityTextureEnabled&&(h.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),lt(this._opacityTexture,h,"opacity")),this._emissiveTexture&&re.EmissiveTextureEnabled&&(h.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),lt(this._emissiveTexture,h,"emissive")),this._lightmapTexture&&re.LightmapTextureEnabled&&(h.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),lt(this._lightmapTexture,h,"lightmap")),re.SpecularTextureEnabled&&(this._metallicTexture?(h.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),lt(this._metallicTexture,h,"reflectivity")):this._reflectivityTexture&&(h.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),lt(this._reflectivityTexture,h,"reflectivity")),this._metallicReflectanceTexture&&(h.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),lt(this._metallicReflectanceTexture,h,"metallicReflectance")),this._reflectanceTexture&&n.REFLECTANCE&&(h.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),lt(this._reflectanceTexture,h,"reflectance")),this._microSurfaceTexture&&(h.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),lt(this._microSurfaceTexture,h,"microSurfaceSampler"))),this._bumpTexture&&o.getCaps().standardDerivatives&&re.BumpTextureEnabled&&!this._disableBumpMap&&(h.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),lt(this._bumpTexture,h,"bump"),r._mirroredCameraPosition?h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),Ic(r,n,h,this._reflectionColor,f,this.realTimeFiltering,!0,!0,!0,!0,!0)),this.pointsCloud&&h.updateFloat("pointSize",this.pointSize),n.METALLICWORKFLOW){Fi.Color4[0].r=this._metallic===void 0||this._metallic===null?1:this._metallic,Fi.Color4[0].g=this._roughness===void 0||this._roughness===null?1:this._roughness;let _=(u=(d=this.subSurface)==null?void 0:d._indexOfRefraction)!=null?u:1.5,g=1;Fi.Color4[0].b=_;let v=Math.pow((_-g)/(_+g),2);Fi.Color4[0].a=v,h.updateDirectColor4("vReflectivityColor",Fi.Color4[0]),h.updateColor4("vMetallicReflectanceFactors",this._metallicReflectanceColor,this._metallicF0Factor)}else h.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);h.updateColor3("vEmissiveColor",re.EmissiveTextureEnabled?this._emissiveColor:ae.BlackReadOnly),!n.SS_REFRACTION&&((m=this.subSurface)!=null&&m._linkRefractionWithTransparency)?h.updateColor4("vAlbedoColor",this._albedoColor,1):h.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),h.updateFloat("baseWeight",this._baseWeight),h.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,h.updateVector4("vLightingIntensity",this._lightingInfos),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),h.updateColor3("vAmbientColor",this._globalAmbientColor),h.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}r.texturesEnabled&&(this._albedoTexture&&re.DiffuseTextureEnabled&&h.setTexture("albedoSampler",this._albedoTexture),this._baseWeightTexture&&re.BaseWeightTextureEnabled&&h.setTexture("baseWeightSampler",this._baseWeightTexture),this._baseDiffuseRoughnessTexture&&re.BaseDiffuseRoughnessTextureEnabled&&h.setTexture("baseDiffuseRoughnessSampler",this._baseDiffuseRoughnessTexture),this._ambientTexture&&re.AmbientTextureEnabled&&h.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&re.OpacityTextureEnabled&&h.setTexture("opacitySampler",this._opacityTexture),Ju(r,n,h,f,this.realTimeFiltering),n.ENVIRONMENTBRDF&&h.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&re.EmissiveTextureEnabled&&h.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&re.LightmapTextureEnabled&&h.setTexture("lightmapSampler",this._lightmapTexture),re.SpecularTextureEnabled&&(this._metallicTexture?h.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&h.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&h.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&n.REFLECTANCE&&h.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&h.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&o.getCaps().standardDerivatives&&re.BumpTextureEnabled&&!this._disableBumpMap&&h.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&&bc(r,t,this._activeEffect,n,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==nt.FOGMODE_NONE||f||this.subSurface.refractionTexture||t.receiveShadows||n.PREPASS||n.CLUSTLIGHT_BATCH)&&this.bindView(a),cn(r,t,this._activeEffect,!0),n.NUM_MORPH_INFLUENCERS&&Yi(t,this._activeEffect),n.BAKED_VERTEX_ANIMATION_TEXTURE&&((p=t.bakedVertexAnimationManager)==null||p.bind(a,n.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),ln(n,this._activeEffect,r)),this._afterBind(t,this._activeEffect,i),h.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,n,a,o,l,c,f,h,d,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(),(n=this._baseDiffuseRoughnessTexture)==null||n.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(),(h=this._reflectivityTexture)==null||h.dispose(),(d=this._bumpTexture)==null||d.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)}};Jt.PBRMATERIAL_OPAQUE=oe.MATERIAL_OPAQUE;Jt.PBRMATERIAL_ALPHATEST=oe.MATERIAL_ALPHATEST;Jt.PBRMATERIAL_ALPHABLEND=oe.MATERIAL_ALPHABLEND;Jt.PBRMATERIAL_ALPHATESTANDBLEND=oe.MATERIAL_ALPHATESTANDBLEND;Jt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0;Jt.LIGHTFALLOFF_PHYSICAL=0;Jt.LIGHTFALLOFF_GLTF=1;Jt.LIGHTFALLOFF_STANDARD=2;Jt.ForceGLSL=!1;b([ie("_markAllSubMeshesAsMiscDirty")],Jt.prototype,"debugMode",void 0)});var aU={};Ie(aU,{PBRMaterial:()=>Be});var Be,oU=C(()=>{$e();Qe();Wp();Je();nU();Pt();Vi();jt();Be=class s extends Jt{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===Jt.LIGHTFALLOFF_PHYSICAL}set usePhysicalLightFalloff(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Jt.LIGHTFALLOFF_PHYSICAL:this._lightFalloff=Jt.LIGHTFALLOFF_STANDARD)}get useGLTFLightFalloff(){return this._lightFalloff===Jt.LIGHTFALLOFF_GLTF}set useGLTFLightFalloff(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),e?this._lightFalloff=Jt.LIGHTFALLOFF_GLTF:this._lightFalloff=Jt.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=s.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,this.metallicF0Factor=1,this.metallicReflectanceColor=ae.White(),this.useOnlyMetallicFromMetallicReflectanceTexture=!1,this.ambientColor=new ae(0,0,0),this.albedoColor=new ae(1,1,1),this.baseWeight=1,this.reflectivityColor=new ae(1,1,1),this.reflectionColor=new ae(1,1,1),this.emissiveColor=new ae(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=kp(this.getScene())}getClassName(){return"PBRMaterial"}clone(e,t=!0,i=""){let r=De.Clone(()=>new s(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=De.Parse(()=>new s(e.name,t),e,t,i);return e.stencil&&r.stencil.parse(e.stencil,t,i),oe._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}};Be.PBRMATERIAL_OPAQUE=Jt.PBRMATERIAL_OPAQUE;Be.PBRMATERIAL_ALPHATEST=Jt.PBRMATERIAL_ALPHATEST;Be.PBRMATERIAL_ALPHABLEND=Jt.PBRMATERIAL_ALPHABLEND;Be.PBRMATERIAL_ALPHATESTANDBLEND=Jt.PBRMATERIAL_ALPHATESTANDBLEND;Be.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=Jt.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"directIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"emissiveIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"environmentIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"specularIntensity",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"disableBumpMap",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"albedoTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"baseWeightTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"baseDiffuseRoughnessTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"ambientTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"ambientTextureStrength",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"ambientTextureImpactOnAnalyticalLights",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Be.prototype,"opacityTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"reflectionTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"emissiveTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"reflectivityTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"metallicTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"metallic",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"roughness",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"metallicF0Factor",void 0);b([Kt(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"metallicReflectanceColor",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"metallicReflectanceTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"reflectanceTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"microSurfaceTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"bumpTexture",void 0);b([qe(),ie("_markAllSubMeshesAsTexturesDirty",null)],Be.prototype,"lightmapTexture",void 0);b([Kt("ambient"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"ambientColor",void 0);b([Kt("albedo"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"albedoColor",void 0);b([L("baseWeight"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"baseWeight",void 0);b([L("baseDiffuseRoughness"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"baseDiffuseRoughness",void 0);b([Kt("reflectivity"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"reflectivityColor",void 0);b([Kt("reflection"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"reflectionColor",void 0);b([Kt("emissive"),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"emissiveColor",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"microSurface",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useLightmapAsShadowmap",void 0);b([L(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Be.prototype,"useAlphaFromAlbedoTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Be.prototype,"forceAlphaTest",void 0);b([L(),ie("_markAllSubMeshesAsTexturesAndMiscDirty")],Be.prototype,"alphaCutOff",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useSpecularOverAlpha",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useRoughnessFromMetallicTextureAlpha",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useRoughnessFromMetallicTextureGreen",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useMetallnessFromMetallicTextureBlue",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useAmbientInGrayScale",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0);b([L()],Be.prototype,"usePhysicalLightFalloff",null);b([L()],Be.prototype,"useGLTFLightFalloff",null);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useRadianceOverAlpha",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useObjectSpaceNormalMap",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useParallax",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useParallaxOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"parallaxScaleBias",void 0);b([L(),ie("_markAllSubMeshesAsLightsDirty")],Be.prototype,"disableLighting",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"forceIrradianceInFragment",void 0);b([L(),ie("_markAllSubMeshesAsLightsDirty")],Be.prototype,"maxSimultaneousLights",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"invertNormalMapX",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"invertNormalMapY",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"twoSidedLighting",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useAlphaFresnel",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useLinearAlphaFresnel",void 0);b([ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"environmentBRDFTexture",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"forceNormalForward",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"enableSpecularAntiAliasing",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useHorizonOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsTexturesDirty")],Be.prototype,"useRadianceOcclusion",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],Be.prototype,"unlit",void 0);b([L(),ie("_markAllSubMeshesAsMiscDirty")],Be.prototype,"applyDecalMapAfterDetailMap",void 0);Ke("BABYLON.PBRMaterial",Be)});var lU={};Ie(lU,{PBRMaterialLoadingAdapter:()=>dR});var dR,cU=C(()=>{Je();XT();Ee();dR=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=B.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=B.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=B.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!=ae.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 ae(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 ae(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 S(-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)),n=r>0?1/r:1;this._material.subSurface.diffusionDistance=new ae(Math.exp(-i.x*n),Math.exp(-i.y*n),Math.exp(-i.z*n))}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:ae.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 u7(s){if(s.min&&s.max){let e=s.min,t=s.max,i=W.Vector3[0].copyFromFloats(e[0],e[1],e[2]),r=W.Vector3[1].copyFromFloats(t[0],t[1],t[2]);if(s.normalized&&s.componentType!==5126){let n=1;switch(s.componentType){case 5120:n=127;break;case 5121:n=255;break;case 5122:n=32767;break;case 5123:n=65535;break}let a=1/n;i.scaleInPlace(a),r.scaleInPlace(a)}return new ei(i,r)}return null}var h7,d7,rt,qp,fU=C(()=>{IF();Ee();Je();At();Ds();LF();Fp();OF();Vi();pi();Ac();It();Zu();Rc();ut();WT();FF();kT();Wa();We();eo();UF();YT();kF();oc();WF();h7=new Xh(()=>Promise.resolve().then(()=>(KF(),YF))),d7=new Xh(()=>Promise.resolve().then(()=>(QF(),qF))),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,n,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 h of this._gltf.nodes)h.name&&(c[h.name]=h.index);l=(e instanceof Array?e:[e]).map(h=>{let d=c[h];if(d===void 0)throw new Error(`Failed to find node '${h}'`);return d})}return await this._loadAsync(n,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,n=""){return this._babylonScene=e,this._loadData(t),await this._loadAsync(i,n,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(()=>($3(),J3))).OpenPBRMaterial,adapterClass:(await Promise.resolve().then(()=>(t2(),e2))).OpenPBRMaterialLoadingAdapter}:this._pbrMaterialImpl={materialClass:(await Promise.resolve().then(()=>(oU(),aU))).PBRMaterial,adapterClass:(await Promise.resolve().then(()=>(cU(),lU))).PBRMaterialLoadingAdapter});let n=`${or[or.LOADING]} => ${or[or.READY]}`,a=`${or[or.LOADING]} => ${or[or.COMPLETE]}`;this._parent._startPerformanceCounter(n),this._parent._startPerformanceCounter(a),this._parent._setState(or.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 h=f;h.maxSimultaneousLights!==void 0&&(h.maxSimultaneousLights=Math.max(h.maxSimultaneousLights,this._babylonScene.lights.length))}return this._extensionsOnReady(),this._parent._setState(or.READY),this._skipStartAnimationStep||this._startAnimations(),r()}).then(f=>(this._parent._endPerformanceCounter(n),se.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(a),this._parent._setState(or.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},h=>{this._parent.onErrorObservable.notifyObservers(h),this._parent.onErrorObservable.clear(),this.dispose()})}),f))}).catch(n=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(n),this._parent.onErrorObservable.clear(),this.dispose()),n})}_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)&&X.Warn(`Binary buffer length (${i.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else X.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(wF.forEach((i,r)=>{var n;((n=this.parent.extensionOptions[r])==null?void 0:n.enabled)===!1?i.isGLTFExtension&&this.isExtensionUsed(r)&&X.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&&X.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(n=>n.name===i&&n.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 G("__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 mf.AUTO:{this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],s._LoadTransform(t,this._rootBabylonMesh));break}case mf.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 n of t.nodes){let a=rt.Get(`${e}/nodes/${n}`,this._gltf.nodes,n);r.push(this.loadNodeAsync(`/nodes/${a.index}`,a,o=>{o.parent=this._rootBabylonMesh}))}for(let n of this._postSceneLoadActions)n();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 n=r.geometry;n&&e.indexOf(n)===-1&&e.push(n)});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 vl.NONE:break;case vl.FIRST:{let e=this._getAnimationGroups();e.length!==0&&e[0].start(!0);break}case vl.ALL:{let e=this._getAnimationGroups();for(let t of e)t.start(!0);break}default:{X.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 n=new Array;this.logOpen(`${e} ${t.name||""}`);let a=c=>{if(s.AddPointerMetadata(c,e),s._LoadTransform(t,c),t.camera!=null){let f=rt.Get(`${e}/camera`,this._gltf.cameras,t.camera);n.push(this.loadCameraAsync(`/cameras/${f.index}`,f,h=>{h.parent=c,this._babylonScene.useRightHandedSystem||(c.scaling.x=-1)}))}if(t.children)for(let f of t.children){let h=rt.Get(`${e}/children/${f}`,this._gltf.nodes,f);n.push(this.loadNodeAsync(`/nodes/${h.index}`,h,d=>{d.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);n.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,f=>{let h=t._babylonTransformNodeForSkin;f.metadata=KT(h.metadata,f.metadata||{});let d=rt.Get(`${e}/skin`,this._gltf.skins,t.skin);n.push(this._loadSkinAsync(`/skins/${d.index}`,t,d,u=>{this._forEachPrimitive(t,m=>{m.skeleton=u}),this._postSceneLoadActions.push(()=>{if(d.skeleton!=null){let m=rt.Get(`/skins/${d.index}/skeleton`,this._gltf.nodes,d.skeleton).parent;t.index===m.index?f.parent=h.parent:f.parent=m._babylonTransformNode}else f.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:h,skinnedNode:f})})}))}))}else{let c=rt.Get(`${e}/mesh`,this._gltf.meshes,t.mesh);n.push(this._loadMeshAsync(`/meshes/${c.index}`,t,c,a))}return this.logClose(),Promise.all(n).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 n=i.primitives;if(!n||!n.length)throw new Error(`${e}: Primitives are missing`);n[0].index==null&&rt.Assign(n);let a=new Array;this.logOpen(`${e} ${i.name||""}`);let o=t.name||`node${t.index}`;if(n.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 n)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,n,a){let o=this._extensionsLoadMeshPrimitiveAsync(e,t,i,r,n,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&&n._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,c=n._instanceData.babylonSourceMesh.createInstance(t),c._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=n._instanceData.promise;else{let h=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;let d=new G(t,this._babylonScene);if(d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,d.sideOrientation=this._babylonScene.useRightHandedSystem?oe.CounterClockWiseSideOrientation:oe.ClockWiseSideOrientation,this._createMorphTargets(e,i,r,n,d),h.push(this._loadVertexDataAsync(e,n,d).then(async u=>await this._loadMorphTargetsAsync(e,n,d,u).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,u.applyToMesh(d),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)}))),!this.parent.skipMaterials){let u=s._GetDrawMode(e,n.mode);if(n.material==null){let m=this._defaultBabylonMaterialData[u];m||(m=this._createDefaultMaterial("__GLTFLoader._default",u),this._parent.onMaterialLoadedObservable.notifyObservers(m),this._defaultBabylonMaterialData[u]=m),d.material=m}else{let m=rt.Get(`${e}/material`,this._gltf.materials,n.material);h.push(this._loadMaterialAsync(`/materials/${m.index}`,m,d,u,p=>{d.material=p}))}}f=Promise.all(h),l&&(n._instanceData={babylonSourceMesh:d,promise:f}),c=d}return s.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 n=t.attributes;if(!n)throw new Error(`${e}: Attributes are missing`);let a=new Array,o=new Di(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,h)=>{if(n[c]==null)return;i._delayInfo=i._delayInfo||[],i._delayInfo.indexOf(f)===-1&&i._delayInfo.push(f);let d=rt.Get(`${e}/attributes/${c}`,this._gltf.accessors,n[c]);a.push(this._loadVertexAccessorAsync(`/accessors/${d.index}`,d,f).then(u=>{if(u.getKind()===y.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!i.skeleton){let m=u7(d);m&&(o._boundingInfo=m,o.useBoundingInfoFromGeometry=!0)}o.setVerticesBuffer(u,d.count)})),f==y.MatricesIndicesExtraKind&&(i.numBoneInfluencers=8),h&&h(d)};return l("POSITION",y.PositionKind),l("NORMAL",y.NormalKind),l("TANGENT",y.TangentKind),l("TEXCOORD_0",y.UVKind),l("TEXCOORD_1",y.UV2Kind),l("TEXCOORD_2",y.UV3Kind),l("TEXCOORD_3",y.UV4Kind),l("TEXCOORD_4",y.UV5Kind),l("TEXCOORD_5",y.UV6Kind),l("JOINTS_0",y.MatricesIndicesKind),l("WEIGHTS_0",y.MatricesWeightsKind),l("JOINTS_1",y.MatricesIndicesExtraKind),l("WEIGHTS_1",y.MatricesWeightsExtraKind),l("COLOR_0",y.ColorKind,c=>{c.type==="VEC4"&&(i.hasVertexAlpha=!0)}),Promise.all(a).then(()=>o)}_createMorphTargets(e,t,i,r,n){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,n.morphTargetManager=new Rl(this._babylonScene),n.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.morphTargetManager.areUpdatesFrozen=!0;for(let o=0;o{a.areUpdatesFrozen=!1})}async _loadMorphTargetVertexDataAsync(e,t,i,r){let n=new Array,a=(o,l,c)=>{if(i[o]==null)return;let f=t.getVertexBuffer(l);if(!f)return;let h=rt.Get(`${e}/${o}`,this._gltf.accessors,i[o]);n.push(this._loadFloatAccessorAsync(`/accessors/${h.index}`,h).then(d=>{c(f,d)}))};return a("POSITION",y.PositionKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,h)=>{c[h]=l[h]+f}),r.setPositions(c)}),a("NORMAL",y.NormalKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(c.length,(f,h)=>{c[h]=l[h]+f}),r.setNormals(c)}),a("TANGENT",y.TangentKind,(o,l)=>{let c=new Float32Array(l.length/3*4),f=0;o.forEach(l.length/3*4,(h,d)=>{(d+1)%4!==0&&(c[f]=l[f]+h,f++)}),r.setTangents(c)}),a("TEXCOORD_0",y.UVKind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,h)=>{c[h]=l[h]+f}),r.setUVs(c)}),a("TEXCOORD_1",y.UV2Kind,(o,l)=>{let c=new Float32Array(l.length);o.forEach(l.length,(f,h)=>{c[h]=l[h]+f}),r.setUV2s(c)}),a("COLOR_0",y.ColorKind,(o,l)=>{let c=null,f=o.getSize();if(f===3){c=new Float32Array(l.length/3*4),o.forEach(l.length,(h,d)=>{let u=Math.floor(d/3),m=d%3;c[4*u+m]=l[3*u+m]+h});for(let h=0;h{c[d]=l[d]+h});else throw new Error(`${e}: Invalid number of components (${f}) for COLOR_0 attribute`);r.setColors(c)}),await Promise.all(n).then(()=>{})}static _LoadTransform(e,t){if(e.skin!=null)return;let i=S.Zero(),r=Se.Identity(),n=S.One();e.matrix?H.FromArray(e.matrix).decompose(n,r,i):(e.translation&&(i=S.FromArray(e.translation)),e.rotation&&(r=Se.FromArray(e.rotation)),e.scale&&(n=S.FromArray(e.scale))),t.position=i,t.rotationQuaternion=r,t.scaling=n}_loadSkinAsync(e,t,i,r){if(!this._parent.loadSkins)return Promise.resolve();let n=this._extensionsLoadSkinAsync(e,t,i);if(n)return n;if(i._data)return r(i._data.babylonSkeleton),i._data.promise;let a=`skeleton${i.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;let o=new wp(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 n=this._findSkeletonRootNode(`${e}/joints`,t.joints);if(n)if(t.skeleton===void 0)t.skeleton=n.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!==n&&!a(o,n)&&(X.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),t.skeleton=n.index)}else X.Warn(`${e}: Failed to find common root`)}let r={};for(let n of t.joints){let a=rt.Get(`${e}/joints/${n}`,this._gltf.nodes,n);this._loadBone(a,t,i,r)}}_findSkeletonRootNode(e,t){if(t.length===0)return null;let i={};for(let n of t){let a=[],o=rt.Get(`${e}/${n}`,this._gltf.nodes,n);for(;o.index!==-1;)a.unshift(o),o=o.parent;i[n]=a}let r=null;for(let n=0;;++n){let a=i[t[0]];if(n>=a.length)return r;let o=a[n];for(let l=1;l=a.length||o!==a[n])return r;r=o}}_loadBone(e,t,i,r){e._isJoint=!0;let n=r[e.index];if(n)return n;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&&X.Warn(`/skins/${t.index}/skeleton: Skeleton node is not a common root`));let o=t.joints.indexOf(e.index);return n=new ds(e.name||`joint${e.index}`,i,a,this._getNodeMatrix(e),null,null,o),r[e.index]=n,this._postSceneLoadActions.push(()=>{n.linkTransformNode(e._babylonTransformNode)}),n}_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=H.Identity(),n=i._index;t&&n!==-1&&(H.FromArrayToRef(t,n*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?H.FromArray(e.matrix):H.Compose(e.scale?S.FromArray(e.scale):S.One(),e.rotation?Se.FromArray(e.rotation):Se.Identity(),e.translation?S.FromArray(e.translation):S.Zero())}loadCameraAsync(e,t,i=()=>{}){let r=this._extensionsLoadCameraAsync(e,t,i);if(r)return r;let n=new Array;this.logOpen(`${e} ${t.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;let a=new Sa(t.name||`camera${t.index}`,S.Zero(),this._babylonScene,!1);switch(a._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonCamera=a,a.setTarget(new S(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=we.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 s.AddPointerMetadata(a,e),this._parent.onCameraLoadedObservable.notifyObservers(a),i(a),this.logClose(),Promise.all(n).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{n.targetedAnimations.length===0&&n.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||h7.value.then(({AnimationGroup:r})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;let n=new r(t.name||`animation${t.index}`,this._babylonScene);n._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=n;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),n.addTargetedAnimation(c,l)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(a).then(()=>(n.normalize(0),n))})}_loadAnimationChannelAsync(e,t,i,r,n){let a=this._extensionsLoadAnimationChannelAsync(e,t,i,r,n);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():d7.value.then(()=>{var d,u,m,p;let f;switch(l){case"translation":{f=(d=Hh("/nodes/{}/translation"))==null?void 0:d.interpolation;break}case"rotation":{f=(u=Hh("/nodes/{}/rotation"))==null?void 0:u.interpolation;break}case"scale":{f=(m=Hh("/nodes/{}/scale"))==null?void 0:m.interpolation;break}case"weights":{f=(p=Hh("/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 h={object:o,info:f};return this._loadAnimationChannelFromTargetInfoAsync(e,t,i,r,h,n)})}_loadAnimationChannelFromTargetInfoAsync(e,t,i,r,n,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 h=0,d=n.object,u=n.info;for(let m of u){let p=m.getStride(d),_=f.input,g=f.output,v=new Array(_.length),I=0;switch(f.interpolation){case"STEP":{for(let x=0;x<_.length;x++){let T=m.getValue(d,g,I,1);I+=p,v[x]={frame:_[x]*o,value:T,interpolation:1}}break}case"CUBICSPLINE":{for(let x=0;x<_.length;x++){let T=m.getValue(d,g,I,l);I+=p;let A=m.getValue(d,g,I,1);I+=p;let R=m.getValue(d,g,I,l);I+=p,v[x]={frame:_[x]*o,inTangent:T,value:A,outTangent:R}}break}case"LINEAR":{for(let x=0;x<_.length;x++){let T=m.getValue(d,g,I,1);I+=p,v[x]={frame:_[x]*o,value:T}}break}}if(I>0){let x=`${i.name||`animation${i.index}`}_channel${r.index}_${h}`,T=m.buildAnimations(d,x,o,v);for(let A of T)h++,a(A.babylonAnimatable,A.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),n=rt.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${n.index}`,n)]).then(([a,o])=>({input:a,interpolation:i,output:o})),t._data}loadBufferAsync(e,t,i,r){let n=this._extensionsLoadBufferAsync(e,t,i,r);if(n)return n;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=s._GetNumComponents(e,t.type),n=r*y.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===n))return s._GetTypedArray(e,t.componentType,l,t.byteOffset,a);{let c=new i(a);return y.ForEach(l,t.byteOffset||0,o.byteStride||n,r,t.componentType,c.length,t.normalized||!1,(f,h)=>{c[h]=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),h=rt.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${f.index}`,f),this.loadBufferViewAsync(`/bufferViews/${h.index}`,h)]).then(([d,u])=>{let m=s._GetTypedArray(`${e}/sparse/indices`,o.indices.componentType,d,o.indices.byteOffset,o.count),p=r*o.count,_;if(t.componentType===5126&&!t.normalized)_=s._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);else{let v=s._GetTypedArray(`${e}/sparse/values`,t.componentType,u,o.values.byteOffset,p);_=new i(p),y.ForEach(v,0,n,r,t.componentType,_.length,t.normalized||!1,(I,x)=>{_[x]=I})}let g=0;for(let v=0;vs._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 Er(t,i,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,t,i){var n;if((n=t._babylonVertexBuffer)!=null&&n[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 y(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=s._GetNumComponents(e,t.type);return new y(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,n=this._getOrCreateMaterialAdapter(i);return t&&(t.baseColorFactor?(n.baseColor=ae.FromArray(t.baseColorFactor),n.geometryOpacity=t.baseColorFactor[3]):n.baseColor=ae.White(),n.baseMetalness=t.metallicFactor==null?1:t.metallicFactor,n.specularRoughness=t.roughnessFactor==null?1:t.roughnessFactor,t.baseColorTexture&&r.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,t.baseColorTexture,a=>{a.name=`${i.name} (Base Color)`,n.baseColorTexture=a})),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,t.metallicRoughnessTexture,a=>{a.name=`${i.name} (Metallic Roughness)`,n.baseMetalnessTexture=a,n.specularRoughnessTexture=a})),n.useRoughnessFromMetallicTextureGreen=!0,n.useMetallicFromMetallicTextureBlue=!0)),Promise.all(r).then(()=>{})}_loadMaterialAsync(e,t,i,r,n=()=>{}){let a=this._extensionsLoadMaterialAsync(e,t,i,r,n);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,s.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)})),n(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 n=t.name||`material${t.index}`;return this._createDefaultMaterial(n,i)}loadMaterialPropertiesAsync(e,t,i){let r=this._extensionsLoadMaterialPropertiesAsync(e,t,i);if(r)return r;let n=new Array;return n.push(this.loadMaterialBasePropertiesAsync(e,t,i)),t.pbrMetallicRoughness&&n.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,i)),this.loadMaterialAlphaProperties(e,t,i),Promise.all(n).then(()=>{})}loadMaterialBasePropertiesAsync(e,t,i){let r=new Array,n=this._getOrCreateMaterialAdapter(i);n.emissionColor=t.emissiveFactor?ae.FromArray(t.emissiveFactor):new ae(0,0,0),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync(`${e}/normalTexture`,t.normalTexture,c=>{var f;c.name=`${i.name} (Normal)`,n.geometryNormalTexture=c,((f=t.normalTexture)==null?void 0:f.scale)!=null&&(c.level=t.normalTexture.scale)})),n.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&&(n.ambientOcclusionTexture=a,n.ambientOcclusionTextureStrength=o),l&&(n.emissionColorTexture=l)})}loadMaterialAlphaProperties(e,t,i){if(!this._pbrMaterialImpl)throw new Error(`${e}: Material type not supported`);let r=this._getOrCreateMaterialAdapter(i),n=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,n&&(n.hasAlpha=!0);break}case"BLEND":{i.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHABLEND,n&&(n.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 n=rt.Get(`${e}/index`,this._gltf.textures,t.index);n._textureInfo=t;let a=this._loadTextureAsync(`/textures/${t.index}`,n,o=>{o.coordinatesIndex=t.texCoord||0,s.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 n=t.sampler==null?s.DefaultSampler:rt.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),a=rt.Get(`${e}/source`,this._gltf.images,t.source),o=this._createTextureAsync(e,n,a,i,void 0,!t._textureInfo.nonColorData);return this.logClose(),o}_createTextureAsync(e,t,i,r=()=>{},n,a){var m,p;let o=this._loadSampler(`/samplers/${t.index}`,t),l=new Array,c=new Op;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:n,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},h=new ne(null,this._babylonScene,f);h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(c.promise);let d=i.uri&&!Ga(i.uri)?i.uri:void 0,u=d!=null?d:`${this._fileName}#image${i.index}`;if(l.push(this.loadImageAsync(`/images/${i.index}`,i).then(_=>{let g=`data:${this._uniqueRootUrl}${u}`;h.updateURL(g,_);let v=h.getInternalTexture();v&&(v.label=i.name)})),h.wrapU=o.wrapU,h.wrapV=o.wrapV,r(h),this._parent.useGltfTextureNames){let _=i.name||d||`image${i.index}`;h.name=_}return Promise.all(l).then(()=>h)}_loadSampler(e,t){return t._data||(t._data={noMipMaps:t.minFilter===9728||t.minFilter===9729,samplingMode:s._GetTextureSamplingMode(e,t),wrapU:s._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:s._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(!s._ValidateUri(i))throw new Error(`${e}: '${i}' is invalid`);if(Ga(i)){let n=new Uint8Array(ka(i));return this.log(`${e}: Decoded ${i.substring(0,64)}... (${n.length} bytes)`),Promise.resolve(n)}return this.log(`${e}: Loading ${i}`),this._parent.preprocessUrlAsync(this._rootUrl+i).then(n=>new Promise((a,o)=>{this._parent._loadFile(this._babylonScene,n,l=>{this._disposed||(this.log(`${e}: Loaded ${i} (${l.byteLength} bytes)`),a(new Uint8Array(l)))},!0,l=>{o(new lc(`${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 X.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 X.Warn(`${e}/minFilter: Invalid value (${r})`),ne.LINEAR_LINEAR_MIPLINEAR}else switch(i!==9728&&X.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 X.Warn(`${e}/minFilter: Invalid value (${r})`),ne.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,t){try{return yg(t)}catch(i){throw new Error(`${e}: ${i.message}`,{cause:i})}}static _GetTypedArray(e,t,i,r,n){let a=i.buffer;r=i.byteOffset+(r||0);let o=s._GetTypedArrayConstructor(`${e}/componentType`,t),l=y.GetTypeByteLength(t);return r%l!==0?(X.Warn(`${e}: Copying buffer as byte offset (${r}) is not a multiple of component type byte length (${l})`),new o(a.slice(r,r+n*l),0)):new o(a,r,n)}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 se.IsBase64(e)||e.indexOf("..")===-1}static _GetDrawMode(e,t){switch(t==null&&(t=4),t){case 0:return oe.PointListDrawMode;case 1:return oe.LineListDrawMode;case 2:return oe.LineLoopDrawMode;case 3:return oe.LineStripDrawMode;case 4:return oe.TriangleFillMode;case 5:return oe.TriangleStripDrawMode;case 6:return oe.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 n of r.babylonMeshes){n.computeWorldMatrix(!0);let a=r.babylonMaterial;e.push(a.forceCompilationAsync(n)),e.push(a.forceCompilationAsync(n,{useInstances:!0})),this._parent.useClipPlane&&(e.push(a.forceCompilationAsync(n,{clipPlane:!0})),e.push(a.forceCompilationAsync(n,{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 n=`${r.name}.${t}`,a=e;a._activeLoaderExtensionFunctions=a._activeLoaderExtensionFunctions||{};let o=a._activeLoaderExtensionFunctions;if(!o[n]){o[n]=!0;try{let l=i(r);if(l)return l}finally{delete o[n]}}}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,n,a){return this._applyExtensions(n,"loadMeshPrimitive",o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,i,r,n,a))}_extensionsLoadMaterialAsync(e,t,i,r,n){return this._applyExtensions(t,"loadMaterial",a=>a._loadMaterialAsync&&a._loadMaterialAsync(e,t,i,r,n))}_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,n){return this._applyExtensions(i,"loadAnimationChannel",a=>a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,i,r,n))}_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",n=>n.loadBufferAsync&&n.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)}};qp.DefaultSampler={index:-1};Po._CreateGLTF2Loader=s=>new qp(s)});var Qp,hU=C(()=>{Qp={name:"obj",extensions:".obj"}});var xl,dU=C(()=>{Je();pi();An();xl=class s{constructor(){this.materials=[]}parseMTL(e,t,i,r){if(t instanceof ArrayBuffer)return;let n=t.split(` +`),a=/\s+/,o,l=null;for(let c=0;c=0?f.substring(0,h):f;d=d.toLowerCase();let u=h>=0?f.substring(h+1).trim():"";if(d==="newmtl")l&&this.materials.push(l),e._blockEntityCollection=!!r,l=new Te(u,e),l._parentContainer=r,e._blockEntityCollection=!1;else if(d==="kd"&&l)o=u.split(a,3).map(parseFloat),l.diffuseColor=ae.FromArray(o);else if(d==="ka"&&l)o=u.split(a,3).map(parseFloat),l.ambientColor=ae.FromArray(o);else if(d==="ks"&&l)o=u.split(a,3).map(parseFloat),l.specularColor=ae.FromArray(o);else if(d==="ke"&&l)o=u.split(a,3).map(parseFloat),l.emissiveColor=ae.FromArray(o);else if(d==="ns"&&l)l.specularPower=parseFloat(u);else if(d==="d"&&l)l.alpha=parseFloat(u);else if(d==="map_ka"&&l)l.ambientTexture=s._GetTexture(i,u,e);else if(d==="map_kd"&&l)l.diffuseTexture=s._GetTexture(i,u,e);else if(d==="map_ks"&&l)l.specularTexture=s._GetTexture(i,u,e);else if(d!=="map_ns")if(d==="map_bump"&&l){let m=u.split(a),p=m.indexOf("-bm"),_=null;p>=0&&(_=m[p+1],m.splice(p,2)),l.bumpTexture=s._GetTexture(i,m.join(" "),e),l.bumpTexture&&_!==null&&(l.bumpTexture.level=parseFloat(_))}else d==="map_d"&&l&&(l.opacityTexture=s._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 n=t.lastIndexOf("\\");n===-1&&(n=t.lastIndexOf("/")),n>-1?r+=t.substring(n+1):r+=t}else r+=t;return new ne(r,i,!1,s.INVERT_TEXTURE_Y)}};xl.INVERT_TEXTURE_Y=!0});var Ei,uU=C(()=>{It();An();Je();Ee();Zu();ut();Bt();We();Ei=class s{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 Me(.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(y.PositionKind),i=e.getVerticesData(y.NormalKind),r={};if(!t||!i)return;for(let a=0;athis._triangles.push(d[0],d[u],d[u+1]),this._handednessSign=1):i.useRightHandedSystem?(this._pushTriangle=(d,u)=>this._triangles.push(d[0],d[u+1],d[u]),this._handednessSign=1):(this._pushTriangle=(d,u)=>this._triangles.push(d[0],d[u],d[u+1]),this._handednessSign=-1);let a=t.split(` +`),o=[],l=[];o.push(l);for(let d=0;d=7){let p=parseFloat(m[4]),_=parseFloat(m[5]),g=parseFloat(m[6]);this._colors.push(new Me(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=s.NormalPattern.exec(u))!==null)this._normals.push(new S(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])));else if((m=s.UVPattern.exec(u))!==null)this._uvs.push(new me(parseFloat(m[1])*this._loadingOptions.UVScaling.x,parseFloat(m[2])*this._loadingOptions.UVScaling.y));else if((m=s.FacePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),1);else if((m=s.FacePattern4.exec(u))!==null)this._setDataForCurrentFaceWithPattern4(m[1].trim().split(" "),1);else if((m=s.FacePattern5.exec(u))!==null)this._setDataForCurrentFaceWithPattern5(m[1].trim().split(" "),1);else if((m=s.FacePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),1);else if((m=s.FacePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),1);else if((m=s.LinePattern1.exec(u))!==null)this._setDataForCurrentFaceWithPattern1(m[1].trim().split(" "),0),this._hasLineData=!0;else if((m=s.LinePattern2.exec(u))!==null)this._setDataForCurrentFaceWithPattern2(m[1].trim().split(" "),0),this._hasLineData=!0;else if(m=s._GetZbrushMRGB(u,!this._loadingOptions.importVertexColors))for(let p of m)this._extColors.push(p);else if((m=s.LinePattern3.exec(u))!==null)this._setDataForCurrentFaceWithPattern3(m[1].trim().split(" "),0),this._hasLineData=!0;else if(s.GroupDescriptor.test(u)||s.ObjectDescriptor.test(u)){let p={name:u.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:s.ObjectDescriptor.test(u)};this._addPreviousObjMesh(),this._meshesFromObj.push(p),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else if(s.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 s.MtlLibGroupDescriptor.test(u)?n(u.substring(7).trim()):s.SmoothDescriptor.test(u)||X.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 d=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||(d=new Te(Di.RandomId(),i),d.pointsCloud=!0,this._materialNameFromObj=d.name,this._normals.length||(d.disableLighting=!0,d.emissiveColor=ae.White()))}this._meshesFromObj.push({name:Di.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:d,isObject:!0,hasLines:this._hasLineData})}for(let d=0;d=0;--p)if(this._meshesFromObj[p].isObject&&this._meshesFromObj[p]._babylonMesh){u.parent=this._meshesFromObj[p]._babylonMesh;break}}if(this._materialToUse.push(this._meshesFromObj[d].materialName),this._handledMesh.hasLines&&((f=u._internalMetadata)!=null||(u._internalMetadata={}),u._internalMetadata._isLine=!0),((h=this._handledMesh.positions)==null?void 0:h.length)===0){this._babylonMeshesArray.push(u);continue}let m=new fe;if(m.indices=this._handledMesh.indices,m.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals){let p=new Array;fe.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)}}};Ei.ObjectDescriptor=/^o/;Ei.GroupDescriptor=/^g/;Ei.MtlLibGroupDescriptor=/^mtllib /;Ei.UseMtlDescriptor=/^usemtl /;Ei.SmoothDescriptor=/^s /;Ei.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/;Ei.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;Ei.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/;Ei.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/;Ei.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;Ei.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;Ei.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;Ei.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;Ei.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/;Ei.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/;Ei.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/});var mU={};Ie(mU,{OBJFileLoader:()=>kr});var kr,uR=C(()=>{Ee();At();Rn();df();hU();dU();uU();An();kr=class s{static get INVERT_TEXTURE_Y(){return xl.INVERT_TEXTURE_Y}static set INVERT_TEXTURE_Y(e){xl.INVERT_TEXTURE_Y=e}constructor(e){this.name=Qp.name,this.extensions=Qp.extensions,this._assetContainer=null,this._loadingOptions={...s._DefaultLoadingOptions,...e!=null?e:{}}}static get _DefaultLoadingOptions(){return{computeNormals:s.COMPUTE_NORMALS,optimizeNormals:s.OPTIMIZE_NORMALS,importVertexColors:s.IMPORT_VERTEX_COLORS,invertY:s.INVERT_Y,invertTextureY:s.INVERT_TEXTURE_Y,UVScaling:s.UV_SCALING,materialLoadingFailsSilently:s.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:s.OPTIMIZE_WITH_UV,skipMaterials:s.SKIP_MATERIALS,useLegacyBehavior:s.USE_LEGACY_BEHAVIOR}}_loadMTL(e,t,i,r){let n=t+e;se.LoadFile(n,i,void 0,void 0,!1,(a,o)=>{r(n,o)})}createPlugin(e){return new s(e[Qp.name])}canDirectLoad(){return!1}importMeshAsync(e,t,i,r){return this._parseSolidAsync(e,t,i,r).then(n=>({meshes:n,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}loadAsync(e,t,i){return this.importMeshAsync(null,e,t,i).then(()=>{})}loadAssetContainerAsync(e,t,i){let r=new hs(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,i).then(n=>(n.meshes.forEach(a=>r.meshes.push(a)),n.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(n=>{throw this._assetContainer=null,n})}_parseSolidAsync(e,t,i,r){let n="",a=new xl,o=[],l=[];i=i.replace(/#.*$/gm,"").trim(),new Ei(o,l,this._loadingOptions).parse(e,i,t,this._assetContainer,h=>{n=h});let f=[];return n!==""&&!this._loadingOptions.skipMaterials&&f.push(new Promise((h,d)=>{this._loadMTL(n,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 v=0;v<_.length;v++){let I=l[_[v]],x=a.materials[m];I.material=x,I.getTotalIndices()||(x.pointsCloud=!0)}}h()}catch(m){se.Warn(`Error processing MTL file: '${n}'`),this._loadingOptions.materialLoadingFailsSilently?h():d(m)}},(u,m)=>{se.Warn(`Error downloading MTL file: '${n}'`),this._loadingOptions.materialLoadingFailsSilently?h():d(m)})})),Promise.all(f).then(()=>{let h=d=>{var u,m;return!!((m=(u=d._internalMetadata)==null?void 0:u._isLine)!=null&&m)};return l.forEach(d=>{var u,m;if(h(d)){let p=(u=d.material)!=null?u:new Te(d.name+"_line",t);p.getBindedMeshes().filter(g=>!h(g)).length>0&&(p=(m=p.clone(p.name+"_line"))!=null?m:p),p.wireframe=!0,d.material=p,d._internalMetadata&&(d._internalMetadata._isLine=void 0)}}),l})}};kr.OPTIMIZE_WITH_UV=!0;kr.INVERT_Y=!1;kr.IMPORT_VERTEX_COLORS=!1;kr.COMPUTE_NORMALS=!1;kr.OPTIMIZE_NORMALS=!1;kr.UV_SCALING=new me(1,1);kr.SKIP_MATERIALS=!1;kr.MATERIAL_LOADING_FAILS_SILENTLY=!0;kr.USE_LEGACY_BEHAVIOR=!1;Ea(new kr)});var Jp,pU=C(()=>{Jp={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0},".json":{isBinary:!1},".sog":{isBinary:!0}}}});var $p,Af,_U=C(()=>{tu();$p=class{constructor(e,t,i,r,n){this.idx=0,this.color=new Me(1,1,1,1),this.position=S.Zero(),this.rotation=S.Zero(),this.uv=new me(0,0),this.velocity=S.Zero(),this.pivot=S.Zero(),this.translateFromPivot=!1,this._pos=0,this._ind=0,this.groupId=0,this.idxInGroup=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=S.Zero(),this.idx=e,this._group=t,this.groupId=i,this.idxInGroup=r,this._pcs=n}get size(){return this.size}set size(e){this.size=e}get quaternion(){return this.rotationQuaternion}set quaternion(e){this.rotationQuaternion=e}intersectsMesh(e,t){if(!e.hasBoundingInfo)return!1;if(!this._pcs.mesh)throw new Error("Point Cloud System doesnt contain the Mesh");if(t)return e.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));let i=e.getBoundingInfo().boundingBox,r=i.maximumWorld.x,n=i.minimumWorld.x,a=i.maximumWorld.y,o=i.minimumWorld.y,l=i.maximumWorld.z,c=i.minimumWorld.z,f=this.position.x+this._pcs.mesh.position.x,h=this.position.y+this._pcs.mesh.position.y,d=this.position.z+this._pcs.mesh.position.z;return n<=f&&f<=r&&o<=h&&h<=a&&c<=d&&d<=l}getRotationMatrix(e){let t;if(this.rotationQuaternion)t=this.rotationQuaternion;else{t=W.Quaternion[0];let i=this.rotation;Se.RotationYawPitchRollToRef(i.y,i.x,i.z,t)}t.toRotationMatrix(e)}},Af=class{get groupID(){return this.groupId}set groupID(e){this.groupId=e}constructor(e,t){this.groupId=e,this._positionFunction=t}}});function t_(s,e,t,i,r,n=!1){let a=oi.Zero();return Zh(s,e,t,i,a,r,n),a}function Zh(s,e,t,i,r,n,a=!1,o=!1){let l=s.getEngine();if(!n&&!(n=s.activeCamera)&&!(n=s.cameraToUseForPointers))return s;let c=n.viewport,f=l.getRenderHeight(),{x:h,y:d,width:u,height:m}=c.toGlobal(l.getRenderWidth(),f),p=1/l.getHardwareScalingLevel();return e=e*p-h,t=t*p-(f-d-m),r.update(e,t,u,m,i||H.IdentityReadOnly,a?H.IdentityReadOnly:n.getViewMatrix(),n.getProjectionMatrix(),o),s}function vU(s,e,t,i){let r=oi.Zero();return mR(s,e,t,r,i),r}function mR(s,e,t,i,r){if(!wi)return s;let n=s.getEngine();if(!r&&!(r=s.activeCamera)&&!(r=s.cameraToUseForPointers))throw new Error("Active camera not set");let a=r.viewport,o=n.getRenderHeight(),{x:l,y:c,width:f,height:h}=a.toGlobal(n.getRenderWidth(),o),d=H.Identity(),u=1/n.getHardwareScalingLevel();return e=e*u-l,t=t*u-(o-c-h),i.update(e,t,f,h,d,d,r.getProjectionMatrix()),s}function e_(s,e,t,i,r,n,a,o){let l=e(i,t.enableDistantPicking);return pR(s,t,i,l,r,n,a,o)}function pR(s,e,t,i,r,n,a,o){let l=e.intersects(i,r,a,n,t,o);return!l||!l.hit||!r&&s!=null&&l.distance>=s.distance?null:l}function m7(s,e){return s==="InstancedLinesMesh"||s==="LinesMesh"?e.intersectionThreshold:0}function SU(s){let e=s.getClassName();if(e==="GreasedLineMesh")return{rawBoundingInfo:null,intersectionThreshold:0};let t=s.rawBoundingInfo;return{rawBoundingInfo:t,intersectionThreshold:t?m7(e,s):0}}function TU(s,e,t,i,r){let n=s(t,e.enableDistantPicking);return!n.intersectsSphere(i.boundingSphere,r)||!n.intersectsBox(i.boundingBox,r)?null:n}function _R(s,e,t,i,r,n){let a=null,o=!!(s.activeCameras&&s.activeCameras.length>1&&s.cameraToUseForPointers!==s.activeCamera),l=s.cameraToUseForPointers||s.activeCamera,c=EU.internalPickerForMesh||e_,f=c===e_;for(let h=0;h>4);for(let A=0;A1&&s.cameraToUseForPointers!==s.activeCamera),a=s.cameraToUseForPointers||s.activeCamera,o=EU.internalPickerForMesh||e_,l=o===e_;for(let c=0;c>4);for(let x=0;x(s._tempPickingRay||(s._tempPickingRay=oi.Zero()),Zh(s,e,t,o,s._tempPickingRay,n||null),s._tempPickingRay),i,r,!0);return a&&(a.ray=t_(s,e,t,H.Identity(),n||null)),a}function xU(s,e,t,i,r,n,a,o=!1){let l=_R(s,(c,f)=>(s._tempPickingRay||(s._tempPickingRay=oi.Zero()),Zh(s,e,t,c,s._tempPickingRay,n||null,!1,f),s._tempPickingRay),i,r,!1,a);return l&&(l.ray=t_(s,e,t,H.Identity(),n||null)),l}function IU(s,e,t,i,r){let n=_R(s,a=>(s._pickWithRayInverseMatrix||(s._pickWithRayInverseMatrix=H.Identity()),a.invertToRef(s._pickWithRayInverseMatrix),s._cachedRayForTransform||(s._cachedRayForTransform=oi.Zero()),oi.TransformToRef(e,s._pickWithRayInverseMatrix,s._cachedRayForTransform),s._cachedRayForTransform),t,i,!1,r);return n&&(n.ray=e),n}function CU(s,e,t,i,r,n){return AU(s,a=>t_(s,e,t,a,r||null),i,n)}function bU(s,e,t,i){return AU(s,r=>(s._pickWithRayInverseMatrix||(s._pickWithRayInverseMatrix=H.Identity()),r.invertToRef(s._pickWithRayInverseMatrix),s._cachedRayForTransform||(s._cachedRayForTransform=oi.Zero()),oi.TransformToRef(e,s._pickWithRayInverseMatrix,s._cachedRayForTransform),s._cachedRayForTransform),t,i)}function gU(s,e,t=100,i,r){i||(i=s.getWorldMatrix()),e.length=t,r?e.origin.copyFrom(r):e.origin.copyFrom(s.position);let n=W.Vector3[2];n.set(0,0,s._scene.useRightHandedSystem?-1:1);let a=W.Vector3[3];return S.TransformNormalToRef(n,i,a),S.NormalizeToRef(a,e.direction),e}function MU(s,e){e&&(e.prototype.getForwardRay=function(t=100,i,r){return gU(this,new oi(S.Zero(),S.Zero(),t),t,i,r)},e.prototype.getForwardRayToRef=function(t,i=100,r,n){return gU(this,t,i,r,n)}),s&&(ol._IsPickingAvailable=!0,s.prototype.createPickingRay=function(t,i,r,n,a=!1){return t_(this,t,i,r,n,a)})}var EU,oi,qh=C(()=>{Wi();Ee();Zs();sv();hc();gt();uE();EU={internalPickerForMesh:void 0},oi=class s{constructor(e,t,i=Number.MAX_VALUE,r=je){this.origin=e,this.direction=t,this.length=i,this.epsilon=r}clone(){return new s(this.origin.clone(),this.direction.clone(),this.length)}intersectsBoxMinMax(e,t,i=0){let r=s._TmpVector3[0].copyFromFloats(e.x-i,e.y-i,e.z-i),n=s._TmpVector3[1].copyFromFloats(t.x+i,t.y+i,t.z+i),a=0,o=Number.MAX_VALUE,l,c,f,h;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xn.x)return!1}else if(l=1/this.direction.x,c=(r.x-this.origin.x)*l,f=(n.x-this.origin.x)*l,f===-1/0&&(f=1/0),c>f&&(h=c,c=f,f=h),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.yn.y)return!1}else if(l=1/this.direction.y,c=(r.y-this.origin.y)*l,f=(n.y-this.origin.y)*l,f===-1/0&&(f=1/0),c>f&&(h=c,c=f,f=h),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.zn.z)return!1}else if(l=1/this.direction.z,c=(r.z-this.origin.z)*l,f=(n.z-this.origin.z)*l,f===-1/0&&(f=1/0),c>f&&(h=c,c=f,f=h),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,n=e.center.z-this.origin.z,a=i*i+r*r+n*n,o=e.radius+t,l=o*o;if(a<=l)return!0;let c=i*this.direction.x+r*this.direction.y+n*this.direction.z;return c<0?!1:a-c*c<=l}intersectsTriangle(e,t,i){let r=s._TmpVector3[0],n=s._TmpVector3[1],a=s._TmpVector3[2],o=s._TmpVector3[3],l=s._TmpVector3[4];t.subtractToRef(e,r),i.subtractToRef(e,n),S.CrossToRef(this.direction,n,a);let c=S.Dot(r,a);if(c===0)return null;let f=1/c;this.origin.subtractToRef(e,o);let h=S.Dot(o,a)*f;if(h<-this.epsilon||h>1+this.epsilon)return null;S.CrossToRef(o,r,l);let d=S.Dot(this.direction,l)*f;if(d<-this.epsilon||h+d>1+this.epsilon)return null;let u=S.Dot(n,l)*f;return u>this.length||u<0?null:new fl(1-h-d,h,u)}intersectsPlane(e){let t,i=S.Dot(e.normal,this.direction);if(Math.abs(i)<999999997475243e-21)return null;{let r=S.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 S(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 S(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 S(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t)}default:return null}}intersectsMesh(e,t,i,r=!1,n,a=!1){let o=W.Matrix[0];return e.getWorldMatrix().invertToRef(o),this._tmpRay?s.TransformToRef(this,o,this._tmpRay):this._tmpRay=s.Transform(this,o),e.intersects(this._tmpRay,t,i,r,n,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,n=W.Vector3[0],a=W.Vector3[1],o=W.Vector3[2],l=W.Vector3[3];t.subtractToRef(e,n),this.direction.scaleToRef(s._Rayl,o),r.addToRef(o,a),e.subtractToRef(r,l);let c=S.Dot(n,n),f=S.Dot(n,o),h=S.Dot(o,o),d=S.Dot(n,l),u=S.Dot(o,l),m=c*h-f*f,p,_=m,g,v=m;m_&&(p=_,g=u+f,v=h)),g<0?(g=0,-d<0?p=0:-d>c?p=_:(p=-d,_=c)):g>v&&(g=v,-d+f<0?p=0:-d+f>c?p=_:(p=-d+f,_=c));let I=Math.abs(p)0&&x<=this.length&&R.lengthSquared(){vr();Ds();qh();qh();MU(nt,we);nt.prototype.createPickingRayToRef=function(s,e,t,i,r,n=!1,a=!1){return Zh(this,s,e,t,i,r,n,a)};nt.prototype.createPickingRayInCameraSpace=function(s,e,t){return vU(this,s,e,t)};nt.prototype.createPickingRayInCameraSpaceToRef=function(s,e,t,i){return mR(this,s,e,t,i)};nt.prototype.pickWithBoundingInfo=function(s,e,t,i,r){return RU(this,s,e,t,i,r)};nt.prototype.pick=function(s,e,t,i,r,n,a=!1){return xU(this,s,e,t,i,r,n,a)};nt.prototype.pickWithRay=function(s,e,t,i){return IU(this,s,e,t,i)};nt.prototype.multiPick=function(s,e,t,i,r){return CU(this,s,e,t,i,r)};nt.prototype.multiPickWithRay=function(s,e,t){return bU(this,s,e,t)}});var DU,i_,PU=C(()=>{tu();Ee();We();It();Bt();ut();gt();_U();yU();An();fc();Mi();(function(s){s[s.Color=2]="Color",s[s.UV=1]="UV",s[s.Random=0]="Random",s[s.Stated=3]="Stated"})(DU||(DU={}));i_=class{get positions(){return this._positions32}get colors(){return this._colors32}get uvs(){return this._uvs32}constructor(e,t,i,r){this.particles=new Array,this.nbParticles=0,this.counter=0,this.vars={},this._promises=[],this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._updatable=!0,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._groups=new Array,this._groupCounter=0,this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeBoundingBox=!1,this._isReady=!1,this.name=e,this._size=t,this._scene=i||ue.LastCreatedScene,r&&r.updatable!==void 0?this._updatable=r.updatable:this._updatable=!0}async buildMeshAsync(e){return await Promise.all(this._promises),this._isReady=!0,await this._buildMeshAsync(e)}async _buildMeshAsync(e){this.nbParticles===0&&this.addPoints(1),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors);let t=new fe;t.set(this._positions32,y.PositionKind),this._uvs32.length>0&&t.set(this._uvs32,y.UVKind);let i=0;this._colors32.length>0&&(i=1,t.set(this._colors32,y.ColorKind));let r=new G(this.name,this._scene);t.applyToMesh(r,this._updatable),this.mesh=r,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);let n=e;return n||(n=new Te("point cloud material",this._scene),n.emissiveColor=new ae(i,i,i),n.disableLighting=!0,n.pointsCloud=!0,n.pointSize=this._size),r.material=n,r}_addParticle(e,t,i,r){let n=new $p(e,t,i,r,this);return this.particles.push(n),n}_randomUnitVector(e){e.position=new S(Math.random(),Math.random(),Math.random()),e.color=new Me(1,1,1,1)}_getColorIndicesForCoord(e,t,i,r){let n=e._groupImageData,a=i*(r*4)+t*4,o=[a,a+1,a+2,a+3],l=o[0],c=o[1],f=o[2],h=o[3],d=n[l],u=n[c],m=n[f],p=n[h];return new Me(d/255,u/255,m/255,p)}_setPointsColorOrUV(e,t,i,r,n,a,o,l){l=l!=null?l:0,i&&e.updateFacetData();let f=2*e.getBoundingInfo().boundingSphere.radius,h=e.getVerticesData(y.PositionKind),d=e.getIndices(),u=e.getVerticesData(y.UVKind+(l?l+1:"")),m=e.getVerticesData(y.ColorKind),p=S.Zero();e.computeWorldMatrix();let _=e.getWorldMatrix();if(!_.isIdentity()){h=h.slice(0);for(let di=0;di1&&(ks=1),Ln<0&&(Ln=0),Ln>1&&(Ln=1),ae.HSVtoRGBToRef(Xf,ks,Ln,On),Ot.set(On.r,On.g,On.b,1)):Ot=Gs.set(Math.random(),Math.random(),Math.random(),1),Ii.color=new Me(Ot.x,Ot.y,Ot.z,Ot.w),this._colors.push(Ot.x,Ot.y,Ot.z,Ot.w))}}_colorFromTexture(e,t,i){if(e.material===null){X.Warn(e.name+"has no material."),t._groupImageData=null,this._setPointsColorOrUV(e,t,i,!0,!1);return}let n=e.material.getActiveTextures();if(n.length===0){X.Warn(e.name+"has no usable texture."),t._groupImageData=null,this._setPointsColorOrUV(e,t,i,!0,!1);return}let a=e.clone();a.setEnabled(!1),this._promises.push(new Promise(o=>{ht.WhenAllReady(n,()=>{let l=t._textureNb;l<0&&(l=0),l>n.length-1&&(l=n.length-1);let c=()=>{t._groupImgWidth=n[l].getSize().width,t._groupImgHeight=n[l].getSize().height,this._setPointsColorOrUV(a,t,i,!0,!0,void 0,void 0,n[l].coordinatesIndex),a.dispose(),o()};t._groupImageData=null;let f=n[l].readPixels();f?f.then(h=>{t._groupImageData=h,c()}):c()})}))}_calculateDensity(e,t,i){let r,n,a,o,l,c,f,h,d,u,m,p,_=S.Zero(),g=S.Zero(),v=S.Zero(),I=S.Zero(),x=S.Zero(),T=S.Zero(),A,R=[],P=0,D=i.length/3;for(let N=0;N0;N--){let V=R[N];if(V===0)M[N]=0;else{let U=(V-R[N-1])/V*F,k=Math.floor(U),z=U-k,Z=+(Math.random()3)&&(a=0);let o=e.getVerticesData(y.PositionKind),l=e.getIndices();this._groups.push(this._groupCounter);let c=new Af(this._groupCounter,null);switch(c._groupDensity=this._calculateDensity(t,o,l),a===2?c._textureNb=r||0:r=r||new Me(1,1,1,1),a){case 2:this._colorFromTexture(e,c,!1);break;case 1:this._setPointsColorOrUV(e,c,!1,!1,!1);break;case 0:this._setPointsColorOrUV(e,c,!1);break;case 3:this._setPointsColorOrUV(e,c,!1,void 0,void 0,r,n);break}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1}addVolumePoints(e,t,i,r,n){let a=i||0;(isNaN(a)||a<0||a>3)&&(a=0);let o=e.getVerticesData(y.PositionKind),l=e.getIndices();this._groups.push(this._groupCounter);let c=new Af(this._groupCounter,null);switch(c._groupDensity=this._calculateDensity(t,o,l),a===2?c._textureNb=r||0:r=r||new Me(1,1,1,1),a){case 2:this._colorFromTexture(e,c,!0);break;case 1:this._setPointsColorOrUV(e,c,!0,!1,!1);break;case 0:this._setPointsColorOrUV(e,c,!0);break;case 3:this._setPointsColorOrUV(e,c,!0,void 0,void 0,r,n);break}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1}setParticles(e=0,t=this.nbParticles-1,i=!0){var I,x;if(!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,i);let r=W.Matrix[0],n=this.mesh,a=this._colors32,o=this._positions32,l=this._uvs32,c=W.Vector3,f=c[5].copyFromFloats(1,0,0),h=c[6].copyFromFloats(0,1,0),d=c[7].copyFromFloats(0,0,1),u=c[8].setAll(Number.MAX_VALUE),m=c[9].setAll(-Number.MAX_VALUE);H.IdentityToRef(r);let p;if((I=this.mesh)!=null&&I.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(e!=0||t!=this.nbParticles-1)){let T=(x=this.mesh)==null?void 0:x.getBoundingInfo();T&&(u.copyFrom(T.minimum),m.copyFrom(T.maximum))}let _,g,v;for(let T=e;T<=t;T++){let A=this.particles[T];p=A.idx,_=3*p,g=4*p,v=2*p,this.updateParticle(A);let R=A._rotationMatrix,P=A.position,D=A._globalPosition;if(this._computeParticleRotation&&A.getRotationMatrix(r),A.parentId!==null){let K=this.particles[A.parentId],j=K._rotationMatrix,ee=K._globalPosition,be=P.x*j[1]+P.y*j[4]+P.z*j[7],_e=P.x*j[0]+P.y*j[3]+P.z*j[6],pe=P.x*j[2]+P.y*j[5]+P.z*j[8];if(D.x=ee.x+_e,D.y=ee.y+be,D.z=ee.z+pe,this._computeParticleRotation){let te=r.m;R[0]=te[0]*j[0]+te[1]*j[3]+te[2]*j[6],R[1]=te[0]*j[1]+te[1]*j[4]+te[2]*j[7],R[2]=te[0]*j[2]+te[1]*j[5]+te[2]*j[8],R[3]=te[4]*j[0]+te[5]*j[3]+te[6]*j[6],R[4]=te[4]*j[1]+te[5]*j[4]+te[6]*j[7],R[5]=te[4]*j[2]+te[5]*j[5]+te[6]*j[8],R[6]=te[8]*j[0]+te[9]*j[3]+te[10]*j[6],R[7]=te[8]*j[1]+te[9]*j[4]+te[10]*j[7],R[8]=te[8]*j[2]+te[9]*j[5]+te[10]*j[8]}}else if(D.x=0,D.y=0,D.z=0,this._computeParticleRotation){let K=r.m;R[0]=K[0],R[1]=K[1],R[2]=K[2],R[3]=K[4],R[4]=K[5],R[5]=K[6],R[6]=K[8],R[7]=K[9],R[8]=K[10]}let F=c[11];A.translateFromPivot?F.setAll(0):F.copyFrom(A.pivot);let N=c[0];N.copyFrom(A.position);let V=N.x-A.pivot.x,O=N.y-A.pivot.y,U=N.z-A.pivot.z,k=V*R[0]+O*R[3]+U*R[6],z=V*R[1]+O*R[4]+U*R[7],Z=V*R[2]+O*R[5]+U*R[8];k+=F.x,z+=F.y,Z+=F.z;let J=o[_]=D.x+f.x*k+h.x*z+d.x*Z,q=o[_+1]=D.y+f.y*k+h.y*z+d.y*Z,Y=o[_+2]=D.z+f.z*k+h.z*z+d.z*Z;if(this._computeBoundingBox&&(u.minimizeInPlaceFromFloats(J,q,Y),m.maximizeInPlaceFromFloats(J,q,Y)),this._computeParticleColor&&A.color){let K=A.color,j=this._colors32;j[g]=K.r,j[g+1]=K.g,j[g+2]=K.b,j[g+3]=K.a}if(this._computeParticleTexture&&A.uv){let K=A.uv,j=this._uvs32;j[v]=K.x,j[v+1]=K.y}}return n&&(i&&(this._computeParticleColor&&n.updateVerticesData(y.ColorKind,a,!1,!1),this._computeParticleTexture&&n.updateVerticesData(y.UVKind,l,!1,!1),n.updateVerticesData(y.PositionKind,o,!1,!1)),this._computeBoundingBox&&(n.hasBoundingInfo?n.getBoundingInfo().reConstruct(u,m,n._worldMatrix):n.buildBoundingInfo(u,m,n._worldMatrix))),this.afterUpdateParticles(e,t,i),this}dispose(){var e;(e=this.mesh)==null||e.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._uvs32=null,this._colors32=null}refreshVisibleSize(){var e;return this._isVisibilityBoxLocked||(e=this.mesh)==null||e.refreshBoundingInfo(),this}setVisibilityBox(e){if(!this.mesh)return;let t=e/2;this.mesh.buildBoundingInfo(new S(-t,-t,-t),new S(t,t,t))}get isAlwaysVisible(){return this._alwaysVisible}set isAlwaysVisible(e){this.mesh&&(this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e)}set computeParticleRotation(e){this._computeParticleRotation=e}set computeParticleColor(e){this._computeParticleColor=e}set computeParticleTexture(e){this._computeParticleTexture=e}get computeParticleColor(){return this._computeParticleColor}get computeParticleTexture(){return this._computeParticleTexture}set computeBoundingBox(e){this._computeBoundingBox=e}get computeBoundingBox(){return this._computeBoundingBox}initParticles(){}recycleParticle(e){return e}updateParticle(e){return e}beforeUpdateParticles(e,t,i){}afterUpdateParticles(e,t,i){}}});async function LU(s,e){return await new Promise((t,i)=>{let r,n;if(Ft())r=window,n="window";else if(typeof self!="undefined")r=self,n="self";else{i(new Error("Cannot load script module outside of a window or a worker"));return}r._LoadScriptModuleResolve||(r._LoadScriptModuleResolve={}),r._LoadScriptModuleResolve[r_]=t,s+=` + ${n}._LoadScriptModuleResolve[${r_}](returnedValue); + ${n}._LoadScriptModuleResolve[${r_}] = undefined; + `,r_++,se.LoadScript(s,void 0,(a,o)=>{i(o||new Error(a))},e,!0)})}var r_,OU=C(()=>{Pr();At();r_=0});function FU(s,e,t){let i=new Uint8Array(s),r=new Uint32Array(s.slice(0,12)),n=r[2],a=i[12],o=i[13],l=i[14],c=i[15],f=r[1];if(c||r[0]!=1347635022||f<2||f>4)return new Promise(A=>{A({mode:3,data:new ArrayBuffer(0),hasVertexColors:!1})});let h=32,d=new ArrayBuffer(h*n),u=1/(1<=3){let A=Math.SQRT1_2;for(let R=0;R>>30,V=D,O=0;for(let z=3;z>=0;--z)if(z!==N){let Z=V&M,J=V>>>9&1;V=V>>>10,F[z]=A*(Z/M),J===1&&(F[z]=-F[z]),O+=F[z]*F[z]}let U=1-O;F[N]=Math.sqrt(Math.max(U,0));let k=[3,0,1,2];for(let z=0;z<4;z++)T[R*32+28+z]=Math.round(127.5+F[k[z]]*127.5);g+=4}}else for(let A=0;A{O({mode:0,data:d,hasVertexColors:!1,sh:M,shDegree:a,trainedWithAntialiasing:!!l})})}return new Promise(A=>{A({mode:0,data:d,hasVertexColors:!1,trainedWithAntialiasing:!!l})})}async function wU(s){if(gR&&NU===s)return await gR;let e=LU(`import createSpzModule from '${s}'; + const module = await createSpzModule(); + const returnedValue = module;`);return NU=s,gR=e,await e}function*_7(s,e,t=!1){let i=s.numPoints,r=32,n=new ArrayBuffer(r*i),a=new Float32Array(n),o=new Uint8Array(n),l=s.positions,c=s.scales,f=s.colors,h=s.alphas,d=s.rotations,u=null,m=s.shDegree,p=null,_=0,g=null,v=null,I=null;if(m>0&&s.sh.length>0){_=((m+1)*(m+1)-1)*3;let R=Math.ceil(_/16),D=e.getEngine().getCaps().maxTextureSize,M=Math.ceil(i/D);u=[];for(let F=0;F=255?255:F+.5|0,o[P+25]=N<=0?0:N>=255?255:N+.5|0,o[P+26]=V<=0?0:V>=255?255:V+.5|0,o[P+27]=1/(1+Math.exp(-h[A]))*255+.5|0;let O=d[M+3]*127.5+127.5,U=d[M+0]*127.5+127.5,k=d[M+1]*127.5+127.5,z=d[M+2]*127.5+127.5;if(o[P+28]=O<=0?0:O>=255?255:O+.5|0,o[P+29]=U<=0?0:U>=255?255:U+.5|0,o[P+30]=k<=0?0:k>=255?255:k+.5|0,o[P+31]=z<=0?0:z>=255?255:z+.5|0,p&&I&&g&&v){let Z=A*_,J=A*16;for(let q=0;q=255?255:be+.5|0}}}A%p7===0&&t&&(yield)}let x,T;if(s.extensions)for(let A of s.extensions){let R=A;if(R.safeOrbitRadiusMin!==void 0){x=R.safeOrbitRadiusMin,T=[R.safeOrbitElevationMin,R.safeOrbitElevationMax];break}}return{mode:0,data:n,hasVertexColors:!1,sh:u!==null?u:void 0,shDegree:m>0?m:void 0,trainedWithAntialiasing:!!s.antialiased,safeOrbitCameraRadiusMin:x,safeOrbitCameraElevationMinMax:T}}async function BU(s,e){return await Ja(_7(s,e,!0),Qa())}var p7,s_,gR,NU,UU=C(()=>{Dp();Th();OU();p7=32768,s_=.28209479177387814,gR=null,NU=null});async function GU(s,e,t){return await new Promise((r,n)=>{let a=t.createCanvasImage();if(!a)throw new Error("Failed to create ImageBitmap");a.onload=()=>{try{let l=t.createCanvas(a.width,a.height);if(!l)throw new Error("Failed to create canvas");let c=l.getContext("2d");if(!c)throw new Error("Failed to get 2D context");c.drawImage(a,0,0);let f=c.getImageData(0,0,l.width,l.height);r({bits:new Uint8Array(f.data.buffer),width:f.width})}catch(l){n(`Error loading image ${a.src} with exception: ${l}`)}},a.onerror=l=>{n(`Error loading image ${a.src} with exception: ${l}`)},a.crossOrigin="anonymous";let o;if(typeof s=="string"){if(!e)throw new Error("filename is required when using a URL");a.src=s+e}else{let l=new Blob([s],{type:"image/webp"});o=URL.createObjectURL(l),a.src=o}})}async function g7(s,e,t){let i=s.count?s.count:s.means.shape[0],r=32,n=new ArrayBuffer(r*i),a=new Float32Array(n),o=new Float32Array(n),l=new Uint8ClampedArray(n),c=new Uint8ClampedArray(n),f=g=>Math.sign(g)*(Math.exp(Math.abs(g))-1),h=e[0].bits,d=e[1].bits;if(!Array.isArray(s.means.mins)||!Array.isArray(s.means.maxs))throw new Error("Missing arrays in SOG data.");for(let g=0;g(g/255-.5)*2/Math.SQRT2,_=e[3].bits;for(let g=0;g{N({mode:0,data:n,hasVertexColors:!1,sh:P,shDegree:v})})}return await new Promise(g=>{g({mode:0,data:n,hasVertexColors:!1})})}async function ER(s,e,t){let i,r;if(s instanceof Map){r=s;let o=r.get("meta.json");if(!o)throw new Error("meta.json not found in files Map");i=JSON.parse(new TextDecoder().decode(o))}else i=s;let n=[...i.means.files,...i.scales.files,...i.quats.files,...i.sh0.files];i.shN&&n.push(...i.shN.files);let a=await Promise.all(n.map(async o=>{if(r&&r.has(o)){let l=r.get(o);return await GU(l,o,t.getEngine())}else return await GU(e,o,t.getEngine())}));return await g7(i,a,t)}var VU,kU=C(()=>{Dp();VU=.28209479177387814});var n_,WU=C(()=>{Rn();pU();wT();df();ut();We();Ee();PU();Je();Bt();UU();kU();At();n_=class s{constructor(e=s._DefaultLoadingOptions){this.name=Jp.name,this._assetContainer=null,this.extensions=Jp.extensions,this._loadingOptions=e}createPlugin(e){return new s(e[Jp.name])}async importMeshAsync(e,t,i,r,n,a){return await this._parseAsync(e,t,i,r).then(o=>({meshes:o,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))}static _BuildPointCloud(e,t){if(!t.byteLength)return!1;let i=new Uint8Array(t),r=new Float32Array(t),n=32,a=i.length/n,o=function(l,c){let f=r[8*c+0],h=r[8*c+1],d=r[8*c+2];l.position=new S(f,h,d);let u=i[n*c+24+0]/255,m=i[n*c+24+1]/255,p=i[n*c+24+2]/255;l.color=new Me(u,m,p,1)};return e.addPoints(a,o),!0}static _BuildMesh(e,t){let i=new G("PLYMesh",e),r=new Uint8Array(t.data),n=new Float32Array(t.data),a=32,o=r.length/a,l=[],c=new fe;for(let f=0;f{var p;t._blockEntityCollection=!!this._assetContainer;let m=(p=this._loadingOptions.gaussianSplattingMesh)!=null?p:new fs("GaussianSplatting",null,t,this._loadingOptions.keepInRam,this._loadingOptions.needsRotationScaleTextures);m._parentContainer=this._assetContainer,n.push(m),m.updateData(u.data,u.sh,{flipY:!1},void 0,u.shDegree),m.scaling.y*=-1,m.computeWorldMatrix(!0),t._blockEntityCollection=!1};if(typeof i=="string"){let u=JSON.parse(i);if(u&&u.means&&u.scales&&u.quats&&u.sh0)return new Promise(m=>{ER(u,r,t).then(p=>{a(p),m(n)}).catch(()=>{throw new Error("Failed to parse SOG data.")})})}let o=i instanceof ArrayBuffer?new Uint8Array(i):i;if(o[0]===80&&o[1]===75)return new Promise(u=>{this._unzipWithFFlateAsync(o).then(m=>{ER(m,r,t).then(p=>{a(p),u(n)}).catch(()=>{throw new Error("Failed to parse SOG zip data.")})})});let l=u=>{s._ConvertPLYToSplat(i).then(async m=>{var p;switch(t._blockEntityCollection=!!this._assetContainer,m.mode){case 0:{let _=(p=this._loadingOptions.gaussianSplattingMesh)!=null?p:new fs("GaussianSplatting",null,t,this._loadingOptions.keepInRam,this._loadingOptions.needsRotationScaleTextures);switch(_._parentContainer=this._assetContainer,n.push(_),_.updateData(m.data,m.sh,{flipY:!1},void 0,m.shDegree),_.scaling.y*=-1,m.chirality==="RightHanded"&&(_.scaling.y*=-1),m.upAxis){case"X":_.rotation=new S(0,0,Math.PI/2);break;case"Y":_.rotation=new S(0,0,Math.PI);break;case"Z":_.rotation=new S(-Math.PI/2,Math.PI,0);break}_.computeWorldMatrix(!0)}break;case 1:{let _=new i_("PointCloud",1,t);s._BuildPointCloud(_,m.data)?await _.buildMeshAsync().then(g=>{n.push(g)}):_.dispose()}break;case 2:if(m.faces)n.push(s._BuildMesh(t,m));else throw new Error("PLY mesh doesn't contain face informations.");break;default:throw new Error("Unsupported Splat mode")}t._blockEntityCollection=!1,this.applyAutoCameraLimits(m,t),u(n)})};if(o[0]!==31||o[1]!==139)return new Promise(u=>{l(u)});let c=(u,m)=>{var _;t._blockEntityCollection=!!this._assetContainer;let p=(_=this._loadingOptions.gaussianSplattingMesh)!=null?_:new fs("GaussianSplatting",null,t,this._loadingOptions.keepInRam,this._loadingOptions.needsRotationScaleTextures);if(u.trainedWithAntialiasing){let g=p.material;g.kernelSize=.1,g.compensation=!0}p._parentContainer=this._assetContainer,n.push(p),p.updateData(u.data,u.sh,{flipY:!1},void 0,u.shDegree),this._loadingOptions.flipY||(p.scaling.y*=-1,p.computeWorldMatrix(!0)),t._blockEntityCollection=!1,this.applyAutoCameraLimits(u,t),m(n)};if(this._loadingOptions.spzLibraryUrl)return wU(this._loadingOptions.spzLibraryUrl).then(u=>{let m=u.loadSpzFromBuffer(new Uint8Array(i),{to:u.CoordinateSystem.RUB});return BU(m,t).then(p=>new Promise(_=>{c(p,_)}))});let f=new ReadableStream({start(u){u.enqueue(new Uint8Array(i)),u.close()}}),h=new DecompressionStream("gzip"),d=f.pipeThrough(h);return new Promise(u=>{new Response(d).arrayBuffer().then(m=>{FU(m,t,this._loadingOptions).then(p=>{c(p,u)})}).catch(()=>{l(u)})})}applyAutoCameraLimits(e,t){var i;if(!this._loadingOptions.disableAutoCameraLimits&&(e.safeOrbitCameraRadiusMin!==void 0||e.safeOrbitCameraElevationMinMax!==void 0)&&((i=t.activeCamera)==null?void 0:i.getClassName())==="ArcRotateCamera"){let r=t.activeCamera;e.safeOrbitCameraElevationMinMax&&(r.lowerBetaLimit=Math.PI*.5-e.safeOrbitCameraElevationMinMax[1],r.upperBetaLimit=Math.PI*.5-e.safeOrbitCameraElevationMinMax[0]),e.safeOrbitCameraRadiusMin&&(r.lowerRadiusLimit=e.safeOrbitCameraRadiusMin)}}loadAssetContainerAsync(e,t,i){let r=new hs(e);return this._assetContainer=r,this.importMeshAsync(null,e,t,i).then(n=>{for(let a of n.meshes)r.meshes.push(a);return this._assetContainer=null,r}).catch(n=>{throw this._assetContainer=null,n})}loadAsync(e,t,i){return this.importMeshAsync(null,e,t,i).then(()=>{})}static _ConvertPLYToSplat(e){let t=new Uint8Array(e),i=new TextDecoder().decode(t.slice(0,1024*10)),r=`end_header +`,n=i.indexOf(r);if(n<0||!i)return new Promise(A=>{A({mode:0,data:e,rawSplat:!0})});let a=parseInt(/element vertex (\d+)\n/.exec(i)[1]),o=/element face (\d+)\n/.exec(i),l=0;o&&(l=parseInt(o[1]));let c=/element chunk (\d+)\n/.exec(i),f=0;c&&(f=parseInt(c[1]));let h=0,d=0,u={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1,list:0},m={Vertex:0,Chunk:1,SH:2,Float_Tuple:3,Float:4,Uchar:5},p=m.Chunk,_=[],g=[],v=i.slice(0,n).split(` +`),I={};for(let A of v)if(A.startsWith("property ")){let[,R,P]=A.split(" ");if(p==m.Chunk)g.push({name:P,type:R,offset:d}),d+=u[R];else if(p==m.Vertex)_.push({name:P,type:R,offset:h}),h+=u[R];else if(p==m.SH)_.push({name:P,type:R,offset:h});else if(p==m.Float_Tuple){let D=new DataView(e,d,u.float*2);I.safeOrbitCameraElevationMinMax=[D.getFloat32(0,!0),D.getFloat32(4,!0)]}else if(p==m.Float){let D=new DataView(e,d,u.float);I.safeOrbitCameraRadiusMin=D.getFloat32(0,!0)}else if(p==m.Uchar){let D=new DataView(e,d,u.uchar);P=="up_axis"?I.upAxis=D.getUint8(0)==0?"X":D.getUint8(0)==1?"Y":"Z":P=="chirality"&&(I.chirality=D.getUint8(0)==0?"LeftHanded":"RightHanded")}u[R]||X.Warn(`Unsupported property type: ${R}.`)}else if(A.startsWith("element ")){let[,R]=A.split(" ");R=="chunk"?p=m.Chunk:R=="vertex"?p=m.Vertex:R=="sh"?p=m.SH:R=="safe_orbit_camera_elevation_min_max_radians"?p=m.Float_Tuple:R=="safe_orbit_camera_radius_min"?p=m.Float:(R=="up_axis"||R=="chirality")&&(p=m.Uchar)}let x=h,T=d;return fs.ConvertPLYWithSHToSplatAsync(e).then(async A=>{let R=new DataView(e,n+r.length),P=T*f+x*a,D=[];if(l)for(let k=0;k{k({mode:0,data:A.buffer,sh:A.sh,shDegree:A.shDegree,faces:D,hasVertexColors:!1,compressed:!0,rawSplat:!1})});let M=0,F=0,N=["x","y","z","scale_0","scale_1","scale_2","opacity","rot_0","rot_1","rot_2","rot_3"],V=["red","green","blue","f_dc_0","f_dc_1","f_dc_2"];for(let k=0;k<_.length;k++){let z=_[k];N.includes(z.name)&&M++,V.includes(z.name)&&F++}let O=M==N.length&&F==3,U=l?2:O?0:1;return await new Promise(k=>{k({...I,mode:U,data:A.buffer,sh:A.sh,shDegree:A.shDegree,faces:D,hasVertexColors:!!F,compressed:!1,rawSplat:!1})})})}};n_._DefaultLoadingOptions={keepInRam:!1,flipY:!1,needsRotationScaleTextures:!1,spzLibraryUrl:typeof WebAssembly=="object"?"https://unpkg.com/@adobe/spz@0.2.0/dist/spz.js":void 0};Ea(new n_)});function a_(s,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,U=(I>>5&31)/31,k=(I>>10&31)/31,z=_*12;l[z+0]=O,l[z+1]=U,l[z+2]=k,l[z+3]=1,l[z+4]=O,l[z+5]=U,l[z+6]=k,l[z+7]=1,l[z+8]=O,l[z+9]=U,l[z+10]=k,l[z+11]=1,h++}let x=a[g+3]-a[g+0],T=a[g+4]-a[g+1],A=a[g+5]-a[g+2],R=a[g+6]-a[g+0],P=a[g+7]-a[g+1],D=a[g+8]-a[g+2],M=T*D-A*P,F=A*R-x*D,N=x*P-T*R,V=Math.sqrt(M*M+F*F+N*N);V>1e-8?(M/=V,F/=V,N/=V):(M=0,F=0,N=1,f++),o[g+0]=M,o[g+1]=F,o[g+2]=N,o[g+3]=M,o[g+4]=F,o[g+5]=N,o[g+6]=M,o[g+7]=F,o[g+8]=N,c[v+0]=g/3+0,c[v+1]=g/3+1,c[v+2]=g/3+2}f>0&&console.warn(`[AI3D STL] ${f} degenerate triangles with zero-area normals`),n&&console.debug(`[AI3D STL] Detected per-face colors: ${h}/${i} faces colored`);let u=new fe;u.positions=a,u.normals=o,u.indices=c,l&&(u.colors=l);let m=new G("stl-model",s);u.applyToMesh(m);let p=new Te("stl-mat",s);return p.backFaceCulling=!1,p.specularColor=new ae(.3,.3,.3),p.specularPower=32,l?(p.diffuseColor=new ae(1,1,1),p.emissiveColor=new ae(.05,.05,.05),p.vertexColorEnabled=!0):(p.diffuseColor=new ae(.85,.85,.85),p.emissiveColor=new ae(.1,.1,.1)),m.material=p,m}function HU(s,e){return a_(s,e)}async function zU(){let{SceneLoader:s}=await Promise.resolve().then(()=>(Rn(),pT));s.RegisterPlugin(E7)}var E7,vR=C(()=>{"use strict";ut();df();Bt();An();Je();E7={name:"stl",extensions:".stl",importMeshAsync(s,e,t){return Promise.resolve().then(()=>({meshes:[a_(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(s,e){return Promise.resolve().then(()=>{a_(s,e)})},loadAssetContainerAsync(s,e){return Promise.resolve().then(()=>{let t=a_(s,e),i=new hs(s);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(s){return s}}});function v7(s){let e=s.split(` +`),t=[],i="binary_little_endian",r=null;for(let n of e){let a=n.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 Rf(s){switch(s){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 o_(s,e,t,i){switch(t){case"uchar":case"uint8":return s.getUint8(e);case"char":case"int8":return s.getInt8(e);case"ushort":case"uint16":return s.getUint16(e,i);case"short":case"int16":return s.getInt16(e,i);case"uint":case"uint32":return s.getUint32(e,i);case"int":case"int32":return s.getInt32(e,i);case"float":case"float32":return s.getFloat32(e,i);case"double":case"float64":return s.getFloat64(e,i);default:return 0}}function S7(s,e,t,i){let r=i,n=new DataView(s),a=[],o=[],l=[],c=e.elements.find(h=>h.name==="vertex"),f=e.elements.find(h=>h.name==="face");if(c){let h=c.properties.some(u=>u.name==="x"),d=c.properties.some(u=>u.name==="red"||u.name==="r");for(let u=0;ud.name==="vertex"),c=e.elements.find(d=>d.name==="face"),f=0;if(l){let d=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=new Uint32Array(o.indices);let d=new Float32Array(l.length),u=o.indices,m=l.length-3;for(let p=0;pm||g>m||v>m)continue;let I=l[_],x=l[_+1],T=l[_+2],A=l[g]-I,R=l[g+1]-x,P=l[g+2]-T,D=l[v]-I,M=l[v+1]-x,F=l[v+2]-T,N=R*F-P*M,V=P*D-A*F,O=A*M-R*D;d[_]+=N,d[_+1]+=V,d[_+2]+=O,d[g]+=N,d[g+1]+=V,d[g+2]+=O,d[v]+=N,d[v+1]+=V,d[v+2]+=O}for(let p=0;p0&&(d[p]/=_,d[p+1]/=_,d[p+2]/=_)}c.normals=d}else{let d=o.positions.length/3,u=[];for(let m=0;m=3&&u.push(0,1,2),c.indices=new Uint32Array(u)}let f=new G("ply-model",s);c.applyToMesh(f);let h=new Te("ply-mat",s);return h.backFaceCulling=!1,o.colors.length>0?(c.colors=new Float32Array(o.colors),c.applyToMesh(f),h.diffuseColor=new ae(1,1,1),h.vertexColorEnabled=!0):h.diffuseColor=new ae(.7,.7,.7),f.material=h,f}function XU(s,e){return l_(s,e)}async function YU(){let{SceneLoader:s}=await Promise.resolve().then(()=>(Rn(),pT));s.RegisterPlugin(A7)}var A7,SR=C(()=>{"use strict";ut();df();Bt();An();Je();A7={name:"ply",extensions:".ply",importMeshAsync(s,e,t){return Promise.resolve().then(()=>({meshes:[l_(e,t)],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}))},loadAsync(s,e){return Promise.resolve().then(()=>{l_(s,e)})},loadAssetContainerAsync(s,e){return Promise.resolve().then(()=>{let t=l_(s,e),i=new hs(s);return i.meshes.push(t),t.material&&i.materials.push(t.material),i})},canDirectLoad(){return!1},rewriteRootURL(s){return s}}});async function Qh(){if(!KU){try{let{FBXLoader:s}=await import(R7);ar.RegisterPlugin(new s)}catch(s){}await Promise.all([zU(),YU()]),KU=!0}}var KU,R7,Jh=C(()=>{"use strict";kT();fU();uR();WU();Rn();vR();SR();KU=!1,R7="babylonjs-fbx-loader"});function jU(s,e,t){let i=s.getChildMeshes(),r=s.getBoundingInfo().boundingBox.centerWorld;for(let n of i){n.metadata||(n.metadata={});let a=n.metadata;if(!a._originalPos){let c=n.position;a._originalPos={x:c.x,y:c.y,z:c.z}}if(!a._originalCenter){let c=n.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;n.position=new S(t==="x"?l.x+o:l.x,t==="y"?l.y+o:l.y,t==="z"?l.z+o:l.z)}}function TR(s){let e=s.getChildMeshes();for(let t of e){let i=t.metadata;i!=null&&i._originalPos&&(t.position=new S(i._originalPos.x,i._originalPos.y,i._originalPos.z))}}var ZU=C(()=>{"use strict";Ee()});var c_={};Ie(c_,{glowBlurPostProcessPixelShaderWGSL:()=>x7});var AR,qU,x7,f_=C(()=>{w();AR="glowBlurPostProcessPixelShader",qU=`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[AR]||(E.ShadersStoreWGSL[AR]=qU);x7={name:AR,shader:qU}});var h_={};Ie(h_,{glowBlurPostProcessPixelShader:()=>I7});var RR,QU,I7,d_=C(()=>{w();RR="glowBlurPostProcessPixelShader",QU=`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[RR]||(E.ShadersStore[RR]=QU);I7={name:RR,shader:QU}});var $U={};Ie($U,{glowMapGenerationVertexShaderWGSL:()=>C7});var xR,JU,C7,eV=C(()=>{w();na();aa();To();Ao();un();go();Ro();xo();oa();la();ca();mn();xR="glowMapGenerationVertexShader",JU=`attribute position: vec3f; +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +uniform viewProjection: mat4x4f;varying vPosition: vec4f; +#ifdef UV1 +attribute uv: vec2f; +#endif +#ifdef UV2 +attribute uv2: vec2f; +#endif +#ifdef DIFFUSE +varying vUVDiffuse: vec2f;uniform diffuseMatrix: mat4x4f; +#endif +#ifdef OPACITY +varying vUVOpacity: vec2f;uniform opacityMatrix: mat4x4f; +#endif +#ifdef EMISSIVE +varying vUVEmissive: vec2f;uniform emissiveMatrix: mat4x4f; +#endif +#ifdef VERTEXALPHA +attribute color: vec4f;varying vColor: vec4f; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs {var positionUpdated: vec3f=vertexInputs.position; +#ifdef UV1 +var uvUpdated: vec2f=vertexInputs.uv; +#endif +#ifdef UV2 +var uv2Updated: vec2f=vertexInputs.uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +var worldPos: vec4f=finalWorld* vec4f(positionUpdated,1.0); +#ifdef CUBEMAP +vertexOutputs.vPosition=worldPos;vertexOutputs.position=uniforms.viewProjection*finalWorld* vec4f(vertexInputs.position,1.0); +#else +vertexOutputs.vPosition=uniforms.viewProjection*worldPos;vertexOutputs.position=vertexOutputs.vPosition; +#endif +#ifdef DIFFUSE +#ifdef DIFFUSEUV1 +vertexOutputs.vUVDiffuse= (uniforms.diffuseMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef DIFFUSEUV2 +vertexOutputs.vUVDiffuse= (uniforms.diffuseMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#ifdef OPACITY +#ifdef OPACITYUV1 +vertexOutputs.vUVOpacity= (uniforms.opacityMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef OPACITYUV2 +vertexOutputs.vUVOpacity= (uniforms.opacityMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#ifdef EMISSIVE +#ifdef EMISSIVEUV1 +vertexOutputs.vUVEmissive= (uniforms.emissiveMatrix* vec4f(uvUpdated,1.0,0.0)).xy; +#endif +#ifdef EMISSIVEUV2 +vertexOutputs.vUVEmissive= (uniforms.emissiveMatrix* vec4f(uv2Updated,1.0,0.0)).xy; +#endif +#endif +#ifdef VERTEXALPHA +vertexOutputs.vColor=vertexInputs.color; +#endif +#include +}`;E.ShadersStoreWGSL[xR]||(E.ShadersStoreWGSL[xR]=JU);C7={name:xR,shader:JU}});var iV={};Ie(iV,{glowMapGenerationPixelShaderWGSL:()=>b7});var IR,tV,b7,rV=C(()=>{w();Lr();pn();_n();IR="glowMapGenerationPixelShader",tV=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) +#include +#endif +#ifdef DIFFUSE +varying vUVDiffuse: vec2f;var diffuseSamplerSampler: sampler;var diffuseSampler: texture_2d; +#endif +#ifdef OPACITY +varying vUVOpacity: vec2f;var opacitySamplerSampler: sampler;var opacitySampler: texture_2d;uniform opacityIntensity: f32; +#endif +#ifdef EMISSIVE +varying vUVEmissive: vec2f;var emissiveSamplerSampler: sampler;var emissiveSampler: texture_2d; +#endif +#ifdef VERTEXALPHA +varying vColor: vec4f; +#endif +uniform glowColor: vec4f;uniform glowIntensity: f32; +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#include +var finalColor: vec4f=uniforms.glowColor; +#ifdef DIFFUSE +var albedoTexture: vec4f=textureSample(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vUVDiffuse); +#ifdef DIFFUSE_ISLINEAR +albedoTexture=toGammaSpace(albedoTexture); +#endif +#ifdef GLOW +finalColor=vec4f(finalColor.rgb,finalColor.a*albedoTexture.a); +#endif +#ifdef HIGHLIGHT +finalColor=vec4f(finalColor.rgb,albedoTexture.a); +#endif +#endif +#ifdef OPACITY +var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vUVOpacity); +#ifdef OPACITYRGB +finalColor=vec4f(finalColor.rgb,finalColor.a*getLuminance(opacityMap.rgb)); +#else +finalColor=vec4f(finalColor.rgb,finalColor.a*opacityMap.a); +#endif +finalColor=vec4f(finalColor.rgb,finalColor.a*uniforms.opacityIntensity); +#endif +#ifdef VERTEXALPHA +finalColor=vec4f(finalColor.rgb,finalColor.a*fragmentInputs.vColor.a); +#endif +#ifdef ALPHATEST +if (finalColor.aM7});var CR,sV,M7,aV=C(()=>{w();fa();ha();Co();bo();gn();Eo();Mo();yo();da();ua();ma();En();CR="glowMapGenerationVertexShader",sV=`attribute vec3 position; +#include +#include +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +uniform mat4 viewProjection;varying vec4 vPosition; +#ifdef UV1 +attribute vec2 uv; +#endif +#ifdef UV2 +attribute vec2 uv2; +#endif +#ifdef DIFFUSE +varying vec2 vUVDiffuse;uniform mat4 diffuseMatrix; +#endif +#ifdef OPACITY +varying vec2 vUVOpacity;uniform mat4 opacityMatrix; +#endif +#ifdef EMISSIVE +varying vec2 vUVEmissive;uniform mat4 emissiveMatrix; +#endif +#ifdef VERTEXALPHA +attribute vec4 color;varying vec4 vColor; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) +{vec3 positionUpdated=position; +#ifdef UV1 +vec2 uvUpdated=uv; +#endif +#ifdef UV2 +vec2 uv2Updated=uv2; +#endif +#include +#include[0..maxSimultaneousMorphTargets] +#include +#include +#include +vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); +#ifdef CUBEMAP +vPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0); +#else +vPosition=viewProjection*worldPos;gl_Position=vPosition; +#endif +#ifdef DIFFUSE +#ifdef DIFFUSEUV1 +vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef DIFFUSEUV2 +vUVDiffuse=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#ifdef OPACITY +#ifdef OPACITYUV1 +vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef OPACITYUV2 +vUVOpacity=vec2(opacityMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#ifdef EMISSIVE +#ifdef EMISSIVEUV1 +vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0)); +#endif +#ifdef EMISSIVEUV2 +vUVEmissive=vec2(emissiveMatrix*vec4(uv2Updated,1.0,0.0)); +#endif +#endif +#ifdef VERTEXALPHA +vColor=color; +#endif +#include +}`;E.ShadersStore[CR]||(E.ShadersStore[CR]=sV);M7={name:CR,shader:sV}});var lV={};Ie(lV,{glowMapGenerationPixelShader:()=>y7});var bR,oV,y7,cV=C(()=>{w();Or();vn();Sn();bR="glowMapGenerationPixelShader",oV=`#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR) +#include +#endif +#ifdef DIFFUSE +varying vec2 vUVDiffuse;uniform sampler2D diffuseSampler; +#endif +#ifdef OPACITY +varying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity; +#endif +#ifdef EMISSIVE +varying vec2 vUVEmissive;uniform sampler2D emissiveSampler; +#endif +#ifdef VERTEXALPHA +varying vec4 vColor; +#endif +uniform vec4 glowColor;uniform float glowIntensity; +#include +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) +{ +#include +vec4 finalColor=glowColor; +#ifdef DIFFUSE +vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse); +#ifdef DIFFUSE_ISLINEAR +albedoTexture=toGammaSpace(albedoTexture); +#endif +#ifdef GLOW +finalColor.a*=albedoTexture.a; +#endif +#ifdef HIGHLIGHT +finalColor.a=albedoTexture.a; +#endif +#endif +#ifdef OPACITY +vec4 opacityMap=texture2D(opacitySampler,vUVOpacity); +#ifdef OPACITYRGB +finalColor.a*=getLuminance(opacityMap.rgb); +#else +finalColor.a*=opacityMap.a; +#endif +finalColor.a*=opacityIntensity; +#endif +#ifdef VERTEXALPHA +finalColor.a*=vColor.a; +#endif +#ifdef ALPHATEST +if (finalColor.a{dt();Je();gt();It();rl();Vi();mo();Ya();Ps();Ui();Fg();Us=class s extends _i{constructor(e,t=null,i,r,n){super({...n,name:e,engine:t||ue.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:s.FragmentUrl,uniforms:s.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(()=>(f_(),c_)))):t.push(Promise.resolve().then(()=>(d_(),h_))),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)}};Us.FragmentUrl="glowBlurPostProcess";Us.Uniforms=["screenSize","direction","blurWidth"];Aa=class s{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,n)=>{if((n||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(y.MatricesIndicesExtraKind),c.push(y.MatricesWeightsExtraKind)),l.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers);let T=n.skeleton;T&&T.isUsingTextureForMatrices?l.push("#define BONETEXTURE"):l.push("#define BonesPerMesh "+(T?T.bones.length+1:0)),n.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,n)}else l.push("#define NUM_BONE_INFLUENCERS 0");let m=n.morphTargetManager?fn(n.morphTargetManager,l,c,n,!0,!1,!1,f,h,d):0;t&&(l.push("#define INSTANCES"),Ls(c),e.getRenderingMesh().hasThinInstances&&l.push("#define THIN_INSTANCES"));let p=n.bakedVertexAnimationManager;p&&p.isEnabled&&(l.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&c.push("bakedVertexAnimationSettingsInstanced")),on(o,this._scene,l),this._addCustomEffectDefines(l);let _=e._getDrawWrapper(void 0,!0),g=_.defines,v=l.join(` +`);if(g!==v){let T=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureInfo","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture","glowIntensity"];Pi(T),_.setEffect(this._engine.createEffect("glowMapGeneration",c,T,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],v,u,void 0,void 0,{maxSimultaneousMorphTargets:m},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),v)}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(()=>(eV(),$U)),Promise.resolve().then(()=>(rV(),iV))]):await Promise.all([Promise.resolve().then(()=>(aV(),nV)),Promise.resolve().then(()=>(cV(),lV))]),(e=this._additionalImportShadersAsync)==null||e.call(this)}_internalIsLayerReady(){let e=!0;for(let i=0;iv.setMatrix("world",R)),(i.disableDepthWrite||i.forceDepthWrite)&&c.setDepthWrite(I),i.disableColorWrite&&c.setColorWrite(x),i.depthFunction!==0&&c.setDepthFunction(T)}else this._objectRenderer.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(r)}_useMeshMaterial(e){return!1}_rebuild(){let e=this._vertexBuffers[y.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}dispose(){let e=this._vertexBuffers[y.PositionKind];e&&(e.dispose(),this._vertexBuffers[y.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()}};Aa.ForceGLSL=!1});var br,MR=C(()=>{$e();Qe();At();dt();gt();pi();ja();Ci();js();u_();Nu();br=class s{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 Aa.ForceGLSL}static set ForceGLSL(e){Aa.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=Jn.UniqueId,this.onDisposeObservable=new Q,this.onBeforeRenderMainTextureObservable=new Q,this.onBeforeComposeObservable=new Q,this.onBeforeRenderMeshToEffect=new Q,this.onAfterRenderMeshToEffect=new Q,this.onAfterComposeObservable=new Q,this.onSizeChangedObservable=new Q,this._internalThinEffectLayer=!r,r||(r=new Aa(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,s._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(n=>{this.onBeforeRenderMeshToEffect.notifyObservers(n)}),this._thinEffectLayer.onAfterRenderMeshToEffect.add(n=>{this.onAfterRenderMeshToEffect.notifyObservers(n)}),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?dr(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?dr(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 fi("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 Ce("EffectLayerSceneComponent")};b([L()],br.prototype,"name",null);b([ic()],br.prototype,"neutralColor",null);b([L()],br.prototype,"isEnabled",null);b([VI()],br.prototype,"camera",null);b([L()],br.prototype,"renderingGroupId",null);b([L()],br.prototype,"disableBoundingBoxesFromEffectLayer",null)});var hV={};Ie(hV,{glowMapMergePixelShaderWGSL:()=>D7});var yR,fV,D7,dV=C(()=>{w();yR="glowMapMergePixelShader",fV=`varying vUV: vec2f;var textureSamplerSampler: sampler;var textureSampler: texture_2d; +#ifdef EMISSIVE +var textureSampler2Sampler: sampler;var textureSampler2: texture_2d; +#endif +uniform offset: f32; +#define CUSTOM_FRAGMENT_DEFINITIONS +@fragment +fn main(input: FragmentInputs)->FragmentOutputs { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +var baseColor: vec4f=textureSample(textureSampler,textureSamplerSampler,input.vUV); +#ifdef EMISSIVE +baseColor+=textureSample(textureSampler2,textureSampler2Sampler,input.vUV);baseColor*=uniforms.offset; +#else +baseColor=vec4f(baseColor.rgb,abs(uniforms.offset-baseColor.a)); +#ifdef STROKE +var alpha: f32=smoothstep(.0,.1,baseColor.a);baseColor=vec4f(baseColor.rgb*alpha,alpha); +#endif +#endif +#if LDR +baseColor=clamp(baseColor,vec4f(0.),vec4f(1.0)); +#endif +fragmentOutputs.color=baseColor; +#define CUSTOM_FRAGMENT_MAIN_END +} +`;E.ShadersStoreWGSL[yR]||(E.ShadersStoreWGSL[yR]=fV);D7={name:yR,shader:fV}});var mV={};Ie(mV,{glowMapMergeVertexShaderWGSL:()=>P7});var DR,uV,P7,pV=C(()=>{w();DR="glowMapMergeVertexShader",uV=`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[DR]||(E.ShadersStoreWGSL[DR]=uV);P7={name:DR,shader:uV}});var gV={};Ie(gV,{glowMapMergePixelShader:()=>L7});var PR,_V,L7,EV=C(()=>{w();PR="glowMapMergePixelShader",_V=`varying vec2 vUV;uniform sampler2D textureSampler; +#ifdef EMISSIVE +uniform sampler2D textureSampler2; +#endif +uniform float offset; +#define CUSTOM_FRAGMENT_DEFINITIONS +void main(void) { +#define CUSTOM_FRAGMENT_MAIN_BEGIN +vec4 baseColor=texture2D(textureSampler,vUV); +#ifdef EMISSIVE +baseColor+=texture2D(textureSampler2,vUV);baseColor*=offset; +#else +baseColor.a=abs(offset-baseColor.a); +#ifdef STROKE +float alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha; +#endif +#endif +#if LDR +baseColor=clamp(baseColor,0.,1.0); +#endif +gl_FragColor=baseColor; +#define CUSTOM_FRAGMENT_MAIN_END +}`;E.ShadersStore[PR]||(E.ShadersStore[PR]=_V);L7={name:PR,shader:_V}});var SV={};Ie(SV,{glowMapMergeVertexShader:()=>O7});var LR,vV,O7,TV=C(()=>{w();LR="glowMapMergeVertexShader",vV=`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[LR]||(E.ShadersStore[LR]=vV);O7={name:LR,shader:vV}});var In,AV=C(()=>{Ee();It();Vi();qg();u_();Je();BS();In=class s extends Aa{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=s.GlowingMeshStencilReference++,this._meshes={},this._excludedMeshes={},this._mainObjectRendererRenderPassId=-1,this.numStencilBits=8,this.neutralColor=s.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(()=>(dV(),hV)),Promise.resolve().then(()=>(pV(),mV)),Promise.resolve().then(()=>(f_(),c_))]):await Promise.all([Promise.resolve().then(()=>(EV(),gV)),Promise.resolve().then(()=>(TV(),SV)),Promise.resolve().then(()=>(d_(),h_))]),await super._importShadersAsync()}getEffectName(){return s.EffectName}_numInternalDraws(){return 2}_createMergeEffect(){return this._engine.createEffect("glowMapMerge",[y.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 jn("HighlightLayerPPP",this._scene.getEngine()),this._horizontalBlurPostprocess=new Us("HighlightLayerHBP",this._scene.getEngine(),new me(1,0),this._options.blurHorizontalSize),this._verticalBlurPostprocess=new Us("HighlightLayerVBP",this._scene.getEngine(),new me(0,1),this._options.blurVerticalSize),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new nr("HighlightLayerHBP",this._scene.getEngine(),new me(1,0),this._options.blurHorizontalSize/2),this._verticalBlurPostprocess=new nr("HighlightLayerVBP",this._scene.getEngine(),new me(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 n=null,a=this._meshes[r.uniqueId];return a&&a.glowEmissiveOnly&&i&&(n=i.emissiveTexture),super._isSubMeshReady(e,t,n)}_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(oe.TriangleFillMode,0,6)),this.innerGlow&&t===1&&(e.setFloat("offset",1),i.setStencilFunction(514),i.drawElementsType(oe.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(n=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&(this._excludedMeshes&&this._excludedMeshes[n.uniqueId]?this._defaultStencilReference(n):n.getScene().getEngine().setStencilFunctionReference(this._instanceGlowingMeshStencilReference<<8-this.numStencilBits))}),observerDefault:e.onAfterRenderObservable.add(n=>{this._mainObjectRendererRenderPassId!==-1&&this._mainObjectRendererRenderPassId!==this._engine.currentRenderPassId||this.isEnabled&&this._defaultStencilReference(n)}),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(s.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()}};In.EffectName="HighlightLayer";In.NeutralColor=new Me(0,0,0,0);In.GlowingMeshStencilReference=2;In.NormalMeshStencilReference=1});var m_,Wr,RV=C(()=>{$e();Qe();dt();vr();Ee();pi();ja();Kn();Jg();US();MR();We();Pt();Je();AV();jt();js();u_();nt.prototype.getHighlightLayerByName=function(s){var e;for(let t=0;t<((e=this.effectLayers)==null?void 0:e.length);t++)if(this.effectLayers[t].name===s&&this.effectLayers[t].getEffectName()===Wr.EffectName)return this.effectLayers[t];return null};m_=class extends Rt{constructor(e,t,i,r,n=null,a=ne.BILINEAR_SAMPLINGMODE,o,l){let c={uniforms:Us.Uniforms,size:typeof r=="number"?r:void 0,camera:n,samplingMode:a,engine:o,reusable:l,...r};super(e,Us.FragmentUrl,{effectWrapper:typeof r=="number"||!r.effectWrapper?new Us(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(()=>(f_(),c_)))):t.push(Promise.resolve().then(()=>(d_(),h_))),super._gatherImports(e,t)}},Wr=class s extends br{static get NeutralColor(){return In.NeutralColor}static set NeutralColor(e){In.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 In(e,t,i)),this.onBeforeBlurObservable=new Q,this.onAfterBlurObservable=new Q,this._engine.isStencilEnable||X.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 s.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?dr(e,this._maxSize):e,t=this._engine.needPOTTextures?dr(t,this._maxSize):t;let i;this._engine.getCaps().textureHalfFloatRender?i=2:i=0,this._blurTexture=new fi("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 sl("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 m_("HighlightLayerHBP",new me(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 m_("HighlightLayerVBP",new me(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 cs("HighlightLayerHBP",new me(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 cs("HighlightLayerVBP",new me(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=De.Serialize(this);e.customType="BABYLON.HighlightLayer",e.meshes=[];let t=this._thinEffectLayer._meshes;if(t)for(let r in t){let n=t[r];n&&e.meshes.push({glowEmissiveOnly:n.glowEmissiveOnly,color:n.color.asArray(),meshId:n.mesh.id})}e.excludedMeshes=[];let i=this._thinEffectLayer._excludedMeshes;if(i)for(let r in i){let n=i[r];n&&e.excludedMeshes.push(n.mesh.id)}return e}static Parse(e,t,i){let r=De.Parse(()=>new s(e.name,t,e.options),e,t,i),n;for(n=0;n{Ds();dc();MR();gt();sT();Ap(Pe.NAME_EFFECTLAYER,(s,e,t,i)=>{if(s.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===we.RIG_MODE_NONE&&e===r.camera||r.camera.cameraRigMode!==we.RIG_MODE_NONE&&r.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||r.needStencil();let n=r._mainTexture;n._shouldRender()&&(this.scene.incrementRenderId(),n.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=s._getComponent(Pe.NAME_EFFECTLAYER);e||(e=new OR(s),s._addComponent(e))}});function IV(s,e){let t=new Wr("ai3d-pick-highlight",s),i=new ae(.15,.45,1);function r(){t.removeAllMeshes()}function n(o){o.isDisposed()||t.addMesh(o,i)}let a=s.onPointerObservable.add(o=>{var d;if(o.type!==Le.POINTERDOWN)return;let l=o.event,c=l.clientX,f=l.clientY;r();let h=o.pickInfo;h!=null&&h.hit&&h.pickedMesh?(n(h.pickedMesh),e({mesh:h.pickedMesh,pickedPoint:(d=h.pickedPoint)!=null?d:null,screenX:c,screenY:f})):e({mesh:null,pickedPoint:null,screenX:c,screenY:f})});return()=>{r(),t.dispose(),s.onPointerObservable.remove(a)}}var CV=C(()=>{"use strict";xs();Je();RV();xV()});function $h(s){let e=new Uint8Array(s),t=32768,i=[];for(let r=0;r{"use strict"});function ii(){return bV.Platform.isMobile}var bV,us=C(()=>{"use strict";bV=require("obsidian")});function N7(){if("require"in activeWindow)return activeWindow.require}function p_(){if("process"in activeWindow)return activeWindow.process}function ed(s){let e=N7();if(!e)return null;try{return e(s)}catch(t){return null}}function Hr(s,e){if(s===null)throw new Error(`${e} is not available in this environment (mobile or web).`);return s}function Mr(s,e){return Hr(td,"node:fs/promises").access(s,e)}function ms(s){return Hr(td,"node:fs/promises").readFile(s)}function If(s,e,t){return Hr(td,"node:fs/promises").writeFile(s,e,{encoding:t})}function Cf(s,e){return Hr(td,"node:fs/promises").mkdir(s,e)}function bf(s,e){return Hr(td,"node:fs/promises").rm(s,e)}function Nt(...s){return Hr(Ra,"node:path").join(...s)}function Cn(s){return Hr(Ra,"node:path").dirname(s)}function bn(s,e){return Hr(Ra,"node:path").basename(s,e)}function ps(s){return Hr(Ra,"node:path").extname(s)}function FR(s){return Hr(Ra,"node:path").normalize(s)}function cr(s){return Hr(Ra,"node:path").isAbsolute(s)}function _s(s,e,t,i){Hr(F7,"node:child_process").execFile(s,e,t,i)}function Mf(){return Hr(w7,"node:os").tmpdir()}var td,xf,Ra,F7,w7,MV,yr,yV,PV,DV,LV,zt=C(()=>{"use strict";td=ed("node:fs/promises"),xf=ed("node:fs"),Ra=ed("node:path"),F7=ed("node:child_process"),w7=ed("node:os");yr=(MV=xf==null?void 0:xf.constants.F_OK)!=null?MV:0,PV=(yV=xf==null?void 0:xf.constants.X_OK)!=null?yV:0;LV=(DV=Ra==null?void 0:Ra.delimiter)!=null?DV:":"});function NV(s){return s.replace(/\\/g,"/")}function FV(s){let e=NV(s).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function __(s){let e=NV(s).replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function zr(s){return __(s).replace(/\.[^.]+$/,"")}function B7(s){return Uint8Array.from(s).buffer}function U7(s){let e=s.vault.adapter;return typeof e.getBasePath=="function"?e.getBasePath():typeof e.basePath=="string"&&e.basePath.length>0?e.basePath:null}function yf(s,e){var r,n;let t=s.vault.getAbstractFileByPath(e);if(t)return t.path;let i=(n=(r=s.metadataCache)==null?void 0:r.getFirstLinkpathDest)==null?void 0:n.call(r,e,"");return i?i.path:null}function xa(s,e){if(cr(e))return FR(e);let t=U7(s);return t?FR(Nt(t,e)):null}async function Xr(s,e){if(cr(e)){let i=await ms(e);return B7(i)}let t=s.vault.getAbstractFileByPath(e);if(!(t instanceof OV.TFile))throw new Error(`File not found: ${e}`);return s.vault.readBinary(t)}var OV,Ia=C(()=>{"use strict";OV=require("obsidian");zt();zt()});function X7(s,e,t){let i=ae.FromHexString(e),r=new Te(s,t);return r.emissiveColor=i,r.diffuseColor=ae.Black(),r.specularColor=ae.Black(),r.backFaceCulling=!1,r}function Y7(s){let e=new Te("gizmo-origin-mat",s);return e.emissiveColor=new ae(.72,.78,.86),e.diffuseColor=ae.Black(),e.specularColor=ae.Black(),e}var V7,g_,G7,BR,k7,W7,wR,H7,z7,E_,wV=C(()=>{"use strict";vr();lm();cm();Ee();Je();$l();oS();An();V7=.32,g_=1.05,G7=.075,BR=.28,k7=.22,W7=.16,wR=(g_+BR)*.42,H7=new S(wR,wR,wR),z7=[{name:"x",color:"#e74c3c",rot:new S(0,0,-Math.PI/2),dir:new S(1,0,0)},{name:"y",color:"#2ecc71",rot:new S(0,0,0),dir:new S(0,1,0)},{name:"z",color:"#3498db",rot:new S(Math.PI/2,0,0),dir:new S(0,0,1)}];E_=class{constructor(e,t){this.engine=e,this.scene=new nt(e),this.scene.clearColor=new Me(0,0,0,0),this.scene.autoClear=!1,this.camera=new _t("gizmo-cam",0,0,4.1,H7,this.scene),this.camera.minZ=.01,this.camera.fov=.56,this.camera.detachControl(),new Br("gizmo-light",new S(0,1,.5),this.scene);let i=pa.CreateSphere("gizmo-origin",{diameter:W7,segments:16},this.scene);i.material=Y7(this.scene);for(let{name:n,color:a,rot:o,dir:l}of z7){let c=X7(`gizmo-${n}-mat`,a,this.scene),f=pa.CreateCylinder(`gizmo-${n}-shaft`,{height:g_,diameter:G7,tessellation:8},this.scene);f.material=c,f.position=l.scale(g_/2),f.rotation=o;let h=pa.CreateCylinder(`gizmo-${n}-head`,{height:BR,diameterTop:0,diameterBottom:k7,tessellation:8},this.scene);h.material=c;let d=g_+BR/2;h.position=l.scale(d),h.rotation=o}let r=V7;this.viewport=new Ss(.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,n=this.viewport.width*e,a=this.viewport.height*t;this.engine.enableScissor(i,r,n,a),this.engine.clear(null,!1,!0,!0),this.scene.render(),this.engine.disableScissor()}dispose(){this.scene.dispose()}}});var VR={};Ie(VR,{boundingBoxRendererVertexShaderWGSL:()=>K7});var UR,BV,K7,GR=C(()=>{w();UR="boundingBoxRendererVertexShader",BV=`attribute position: vec3f;uniform world: mat4x4f;uniform viewProjection: mat4x4f; +#ifdef INSTANCES +attribute world0 : vec4;attribute world1 : vec4;attribute world2 : vec4;attribute world3 : vec4; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +@vertex +fn main(input : VertexInputs)->FragmentInputs { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef INSTANCES +var finalWorld=mat4x4(vertexInputs.world0,vertexInputs.world1,vertexInputs.world2,vertexInputs.world3);var worldPos: vec4f=finalWorld* vec4f(vertexInputs.position,1.0); +#else +var worldPos: vec4f=uniforms.world* vec4f(vertexInputs.position,1.0); +#endif +vertexOutputs.position=uniforms.viewProjection*worldPos; +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStoreWGSL[UR]||(E.ShadersStoreWGSL[UR]=BV);K7={name:UR,shader:BV}});var WR={};Ie(WR,{boundingBoxRendererPixelShaderWGSL:()=>j7});var kR,UV,j7,HR=C(()=>{w();kR="boundingBoxRendererPixelShader",UV=`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[kR]||(E.ShadersStoreWGSL[kR]=UV);j7={name:kR,shader:UV}});var VV,Z7,GV=C(()=>{w();VV="boundingBoxRendererVertexDeclaration",Z7=`uniform mat4 world;uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif +`;E.IncludesShadersStore[VV]||(E.IncludesShadersStore[VV]=Z7)});var kV,q7,zR=C(()=>{w();kV="boundingBoxRendererUboDeclaration",q7=`#ifdef WEBGL2 +uniform vec4 color;uniform mat4 world;uniform mat4 viewProjection; +#ifdef MULTIVIEW +uniform mat4 viewProjectionR; +#endif +#else +layout(std140,column_major) uniform;uniform BoundingBoxRenderer {vec4 color;mat4 world;mat4 viewProjection;mat4 viewProjectionR;}; +#endif +`;E.IncludesShadersStore[kV]||(E.IncludesShadersStore[kV]=q7)});var YR={};Ie(YR,{boundingBoxRendererVertexShader:()=>Q7});var XR,WV,Q7,KR=C(()=>{w();GV();zR();XR="boundingBoxRendererVertexShader",WV=`attribute vec3 position; +#include<__decl__boundingBoxRendererVertex> +#ifdef INSTANCES +attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; +#endif +#define CUSTOM_VERTEX_DEFINITIONS +void main(void) { +#define CUSTOM_VERTEX_MAIN_BEGIN +#ifdef INSTANCES +mat4 finalWorld=mat4(world0,world1,world2,world3);vec4 worldPos=finalWorld*vec4(position,1.0); +#else +vec4 worldPos=world*vec4(position,1.0); +#endif +#ifdef MULTIVIEW +if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} +#else +gl_Position=viewProjection*worldPos; +#endif +#define CUSTOM_VERTEX_MAIN_END +} +`;E.ShadersStore[XR]||(E.ShadersStore[XR]=WV);Q7={name:XR,shader:WV}});var HV,J7,zV=C(()=>{w();HV="boundingBoxRendererFragmentDeclaration",J7=`uniform vec4 color; +`;E.IncludesShadersStore[HV]||(E.IncludesShadersStore[HV]=J7)});var ZR={};Ie(ZR,{boundingBoxRendererPixelShader:()=>$7});var jR,XV,$7,qR=C(()=>{w();zV();zR();jR="boundingBoxRendererPixelShader",XV=`#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[jR]||(E.ShadersStore[jR]=XV);$7={name:jR,shader:XV}});var jV,YV,v_,eK,tK,KV,QR,ZV=C(()=>{vr();It();Rc();Ee();As();dc();nv();Vi();um();Je();dt();Ya();Xa();Pv();Ys();We();Object.defineProperty(nt.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(s){this._forceShowBoundingBoxes=s,s&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0});nt.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new QR(this)),this._boundingBoxRenderer};Object.defineProperty(Zt.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(s){this._showBoundingBox=s,s&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});jV=H.Identity(),YV=new H,v_=new S,eK=new S,tK=jV.asArray(),KV=new $a(v_,v_),QR=class{get shaderLanguage(){return this._shaderLanguage}constructor(e){this.name=Pe.NAME_BOUNDINGBOXRENDERER,this.frontColor=new ae(1,1,1),this.backColor=new ae(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new Q,this.onAfterBoxRenderingObservable=new Q,this.onResourcesReadyObservable=new Q,this.enabled=!0,this._shaderLanguage=0,this.renderList=new yt(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 Wt(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront",!0),this._buildUniformLayout(this._uniformBufferFront),this._uniformBufferBack=new Wt(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(Pe.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(Pe.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(Pe.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(Pe.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)}async whenReadyAsync(e=16,t=3e4){return this._prepareResources(),await new Promise(i=>{Xs(()=>this._colorShader.isReady(),()=>{i()},(r,n)=>{n?(X.Error("BoundingBoxRenderer: Timeout while waiting for the renderer to be ready."),r&&X.Error(r)):(X.Error("BoundingBoxRenderer: An unexpected error occurred while waiting for the renderer to be ready."),r&&(X.Error(r),r.stack&&X.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 sr("colorShader",this.scene,"boundingBoxRenderer",{attributes:[y.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(()=>(GR(),VR)),Promise.resolve().then(()=>(HR(),WR))]):await Promise.all([Promise.resolve().then(()=>(KR(),YR)),Promise.resolve().then(()=>(qR(),ZR))])}},!1),this._colorShader.setDefine("INSTANCES",this._useInstances),this._colorShader.doNotSerialize=!0,this._colorShader.reservedDataStore={hidden:!0},this._colorShaderForOcclusionQuery=new sr("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{attributes:[y.PositionKind],uniforms:["world","viewProjection","viewProjectionR","color"],uniformBuffers:["BoundingBoxRenderer"],shaderLanguage:this._shaderLanguage,extraInitializationsAsync:async()=>{this._shaderLanguage===1?await Promise.all([Promise.resolve().then(()=>(GR(),VR)),Promise.resolve().then(()=>(HR(),WR))]):await Promise.all([Promise.resolve().then(()=>(KR(),YR)),Promise.resolve().then(()=>(qR(),ZR))])}},!0),this._colorShaderForOcclusionQuery.doNotSerialize=!0,this._colorShaderForOcclusionQuery.reservedDataStore={hidden:!0};let e=this.scene.getEngine(),t=hm({size:1});this._vertexBuffers[y.PositionKind]=new y(e,t.positions,y.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[y.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this._matrixBuffer&&this._matrixBuffer._rebuild()}reset(){this.renderList.reset()}render(e){var r,n;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(KV);let n=0,a=this.scene.floatingOriginOffset;for(let g=0;g{"use strict";Ee();qh();Je();Jo();xs();ZV();Df=class Df{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 n;this.scene=e,this.camera=t,this.meshes=i;let r=(n=e.getBoundingBoxRenderer)==null?void 0:n.call(e);r&&(r.frontColor=new ae(.25,.7,1),r.backColor=new ae(.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,n;let i=t.event;t.type===Le.POINTERDOWN?this.startDrag((n=(r=t.pickInfo)==null?void 0:r.pickedMesh)!=null?n:null,i):t.type===Le.POINTERMOVE?this.updateDrag(i):t.type===Le.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=S.Distance(t,e),r=e.subtract(t).normalize(),n=new oi(t,r,i),a=this.scene.pickWithRay(n),o=Math.max(i*.01,.01),l=!!(a!=null&&a.hit)&&a.distanceCa});function QV(s){return s.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}var S_,Ca,rd=C(()=>{"use strict";Xu();vr();lm();cm();BM();UM();Rv();Ee();Je();oS();An();gp();SN();uv();Rn();wT();Jh();Jh();vR();SR();ZU();CV();NR();us();Ia();wV();qV();S_=null;Ca=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:S.Zero()};this._lastPickResult={mesh:null,pickedPoint:null,screenX:0,screenY:0};this._onPickCallbacks=[];this.preventCanvasWheelScroll=e=>{e.preventDefault(),e.stopPropagation()};this.engine=new ve(e,!0,{preserveDrawingBuffer:!0}),this.scene=new nt(this.engine),this.scene.clearColor=new Me(.12,.12,.14,1),this.camera=new _t("cam",Math.PI/4,Math.PI/3,5,S.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 ae(.3,.3,.3);let t=new Br("default-light",new S(0,1,.5),this.scene);t.intensity=1.2,this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),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,v;await Qh(),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 n=t.toLowerCase().replace(".","");this.loadedExt=n;let a=this.scene,l=(p={glb:".glb",gltf:".gltf",stl:".stl",obj:".obj",splat:".splat",ply:".ply"}[n])!=null?p:`.${n}`,c=`data:application/octet-stream;base64,${$h(e)}`;if(n==="obj"&&i&&r){S_&&await S_;let I;S_=new Promise(x=>{I=x});try{let{OBJFileLoader:x}=await Promise.resolve().then(()=>(uR(),mU)),T=x.prototype;typeof T._loadMTL!="function"&&console.warn("[AI3D] OBJFileLoader._loadMTL not found \u2014 MTL vault resolution disabled");let A=T._loadMTL,P=new TextDecoder().decode(new Uint8Array(e)).match(/mtllib\s+(.+)/),D=null,M=0,F=0;if(P&&i&&r){let V=P[1].trim().split(/\s+/)[0],O=FV(r),U=O?`${O}/${V}`:V;try{let k=await i(U),Z=new TextDecoder().decode(new Uint8Array(k)).split(` +`),J=/^\s*(map_Kd|map_Ka|map_Ks|map_Ns|map_d|map_bump|bump|disp|decal)\s+(.+)/i,q=zr(r),Y=["jpg","jpeg","png","bmp","tga","webp","tif","tiff"];for(let ee=0;eeee!=="");if(!K.some(ee=>/^\s*Kd\s+/i.test(ee))){let ee=K.findIndex(be=>/^\s*newmtl\s+/i.test(be));K.splice(ee>=0?ee+1:0,0,"Kd 0.80 0.80 0.80")}D=K.join(` +`),console.debug(`[AI3D] MTL: ${U} | textures: ${M} loaded, ${F} missing`)}catch(k){console.debug(`[AI3D] No MTL in vault: ${U}`)}}T._loadMTL=function(V,O,U){let k=D!=null?D:"";console.debug(`[AI3D] _loadMTL called: url=${V}, content_len=${k.length}, has_Kd=${k.includes("Kd")}, has_map=${k.includes("map_")}`),U(k)};let N=await ar.ImportMeshAsync("","",c,a,void 0,l);this.loadedMeshes=N.meshes,N.meshes.length>0&&(this.rootMesh=N.meshes[0]);for(let V of N.meshes){let O=V.material;console.debug(`[AI3D] OBJ mesh "${V.name}" material:`,O?`${O.name} diffuse=${String(O==null?void 0:O.diffuseColor)}`:"NONE")}T._loadMTL=A}catch(x){throw console.error("[AI3D] OBJ load error:",x),x}finally{I(),S_=null}}else if(n==="stl")this.rootMesh=HU(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else if(n==="ply")this.rootMesh=XU(a,e),this.rootMesh&&(this.loadedMeshes=[this.rootMesh]);else{let I=await ar.ImportMeshAsync("","",c,a,void 0,l);this.loadedMeshes=I.meshes,I.meshes.length>0&&(this.rootMesh=I.meshes[0])}if(!this.rootMesh)throw new Error("No mesh found in model file");for(let I of this.getRenderableMeshes(this.rootMesh))I.material&&(I.material.backFaceCulling=!1);this.rootMesh.computeWorldMatrix(!0);let f=this.rootMesh.getHierarchyBoundingVectors(),h=f.max.subtract(f.min),d=h.length()/2,u=f.min.add(h.scale(.5));return this.camera.target=u,this.camera.radius=d*2.5,this.camera.lowerRadiusLimit=d*.05,this.camera.upperRadiusLimit=d*10,this.camera.minZ=d*.001,this.camera.maxZ=d*20,this.initialCamera={alpha:this.camera.alpha,beta:this.camera.beta,radius:this.camera.radius,target:u.clone()},this.startRenderLoop(),this.engine.resize(),(v=this.cleanupPicking)==null||v.call(this),this.cleanupPicking=IV(this.scene,I=>{this.disassemblyEnabled||(this._lastPickResult=I,this._onPickCallbacks.forEach(x=>x(I)))}),this.disassembly=new id(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,n=t.clientWidth/t.clientHeight,a=(i=e.zoom)!=null?i:1,o=r/a;this.camera.mode=1,this.camera.orthoLeft=-o*n,this.camera.orthoRight=o*n,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,n,a]=e.position;this.camera.setPosition(new S(r,n,a))}if(e.lookAt){let[r,n,a]=e.lookAt;this.camera.setTarget(new S(r,n,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 n=this.createLight(r);n&&this.configLights.push(n)}}createLight(e){var r,n;let t=e.color?ae.FromHexString(e.color):ae.White(),i=(r=e.intensity)!=null?r:1;switch(e.type){case"hemisphere":{let a=e.groundColor?ae.FromHexString(e.groundColor):new ae(.2,.2,.2),o=new Br("hemi",new S(0,1,0),this.scene);return o.diffuse=t,o.groundColor=a,o.intensity=i,o}case"directional":{let a=e.position?new S(...e.position).normalize():new S(-1,-2,-1).normalize(),o=new rr("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 S(...e.position):new S(0,5,0),o=new ra("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 S(...e.position):new S(0,5,0),l=(e.target?new S(...e.target):S.Zero()).subtract(a).normalize(),c=e.angle?e.angle*Math.PI/180:Math.PI/4,f=(n=e.penumbra)!=null?n:.5,h=new ni("spot",a,l,c,f,this.scene);return h.diffuse=t,h.intensity=i,e.decay!==void 0&&(h.decay=e.decay),e.castShadow&&this.rootMesh&&this.setupShadow(h),h}case"attachToCam":{let a=new ra("cam-light",S.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(!(e instanceof rr||e instanceof ra||e instanceof ni)){console.warn("[AI3D] Light type does not support shadows:",e.name);return}let t=new Ct(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=Me.FromColor3(ae.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 Uc,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=pa.CreateGround("ground",{width:i,height:i},this.scene),this.groundMesh.position.y=r;let n=new Te("ground-mat",this.scene);n.diffuseColor=new ae(.15,.15,.15),n.specularColor=ae.Black(),n.alpha=.5,this.groundMesh.material=n,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=pa.CreateGround("grid",{width:i,height:i,subdivisions:20},this.scene),this.gridMesh.position.y=r;let n=new Te("grid-mat",this.scene);n.wireframe=!0,n.diffuseColor=new ae(.3,.3,.3),n.emissiveColor=new ae(.1,.1,.1),this.gridMesh.material=n}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,n=[["x",ae.Red(),new S(i,0,0)],["y",ae.Green(),new S(0,i,0)],["z",ae.Blue(),new S(0,0,i)]];for(let[a,o,l]of n){let c=pa.CreateTube(`axis-${a}`,{path:[r,r.add(l)],radius:t.length()*.005,tessellation:8},this.scene),f=new Te(`axis-${a}-mat`,this.scene);f.emissiveColor=o,f.diffuseColor=ae.Black(),c.material=f,this.axisMeshes.push(c)}}setSTLColor(e){if(!this.rootMesh)return;let t=ae.FromHexString(e),i=this.rootMesh.getChildMeshes(!0);for(let r of i)if(r.material&&r.material.name==="stl-mat"){let n=r.material;n.diffuseColor=t,n.emissiveColor=t.scale(.1)}}setWireframe(e){this.rootMesh&&(this.rootMesh instanceof fs||(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 E_(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=ii()?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=pa.CreateBox("bbox",{width:r.x,height:r.y,depth:r.z},this.scene),this.bboxMesh.position=i;let n=new Te("bbox-mat",this.scene);n.wireframe=!0,n.emissiveColor=new ae(1,1,0),n.disableLighting=!0,n.alpha=.6,this.bboxMesh.material=n}else(e=this.bboxMesh)==null||e.dispose(),this.bboxMesh=null;return this.bboxEnabled}toggleDisassembly(){return this.rootMesh?(this.disassembly||(this.disassembly=new id(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&&jU(this.rootMesh,e,t)}resetExplode(){this.rootMesh&&TR(this.rootMesh)}resetView(){this.rootMesh&&TR(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,h,d;if(!this.rootMesh)return"";let t=this.computeSummary(this.rootMesh),i=this.getRenderableMeshes(this.rootMesh),r=this.rootMesh instanceof fs,n=this.loadedExt.toUpperCase(),a=e&&__(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 | ${n} |`),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=ii()?1.5:1,n=i[e]*r/Math.max(t,.25);if(this.engine.setHardwareScalingLevel(n),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,n,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,(n=this.bboxMesh)==null||n.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,n=new Set,a=e instanceof fs;for(let f of t){let h=f.getTotalIndices(),d=f.getTotalVertices();i+=Math.floor(h/3),r+=d,f.material&&n.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:n.size,boundingSize:{x:c.x,y:c.y,z:c.z},rootName:e.name}}}});var JR,$V=C(()=>{"use strict";JR={"settings.title":"AI 3d model workbench","settings.folders":"Folders","settings.behavior":"Behavior","settings.converters":"Converters","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, PLY, and SPLAT 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.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, PLY, or SPLAT 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 eG,tG=C(()=>{"use strict";eG={"settings.title":"AI 3D \u6A21\u578B\u5DE5\u4F5C\u53F0","settings.folders":"\u6587\u4EF6\u5939","settings.behavior":"\u884C\u4E3A","settings.converters":"\u8F6C\u6362\u5668","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\u3001SPLAT \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.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\u3001PLY \u6216 SPLAT\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 sd(s){iG=s;for(let e of $R)e()}function $(s){var e,t,i;return(i=(t=(e=iK[iG])==null?void 0:e[s])!=null?t:JR[s])!=null?i:s}function rG(s){return $R.add(s),()=>{$R.delete(s)}}function rK(s,e){return s.replace(/\{(\w+)\}/g,(t,i)=>{var r;return(r=e[i])!=null?r:""})}function ri(s,e){return rK($(s),e)}var iK,iG,$R,gs=C(()=>{"use strict";$V();tG();iK={en:JR,"zh-CN":eG},iG="en",$R=new Set});function nK(){return`pin-${Date.now()}-${sK++}`}var nd,Pf,sK,Mn,yn,ad=C(()=>{"use strict";nd=require("obsidian");Ee();qh();gs();Ia();Pf=["#4a9eff","#ff6b6b","#51cf66","#ffd43b","#845ef7","#ff922b","#22b8cf","#f06595","#94d82d","#ffa8a8"],sK=1;Mn=class Mn{constructor(e,t,i,r,n,a,o,l={}){this.provider=e;this.hostEl=t;this.mode=i;this.onChange=n;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 nd.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 h=f.detail,d=h==null?void 0:h.pinId;d&&this.pulsePin(d)},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 n;let r={id:nK(),position:[e.x,e.y,e.z],label:t,color:i!=null?i:Pf[this.annotations.length%Pf.length],createdAt:new Date().toISOString()};return this.annotations.push(r),this.createPinElement(r),this.updateProjections(),(n=this.onChange)==null||n.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 n;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 S(...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(),(n=this.onChange)==null||n.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(),n=r.left+r.width/2,a=r.top;this.showEditorInternal(n,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 N,V;this.hideEditor(),this._selectedHeading=null;let n=this.overlay.createDiv({cls:"ai3d-annotation-editor"}),a=n.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=n.createDiv({cls:"ai3d-editor-content-preview is-hidden"}),h=n.createDiv({cls:"ai3d-heading-dropdown is-hidden"});this._headingDropdown=h;let d=-1,u=[],m=O=>{let U=h.querySelectorAll(".ai3d-heading-dropdown-item");U.forEach(k=>k.classList.remove("active")),d=O,O>=0&&O{var z;this._selectedHeading=O,o.value=O.heading;let U=zr(O.notePath);(z=l.querySelector(".ai3d-editor-binding-text"))==null||z.remove();let k=l.createSpan({cls:"ai3d-editor-binding-text"});k.textContent=`\u{1F4C4} ${U}`,l.classList.remove("is-hidden"),_(),o.focus(),this.loadContentPreview(f,O.notePath,O.heading)},_=()=>{h.classList.add("is-hidden"),h.replaceChildren(),d=-1},g=O=>{if(h.replaceChildren(),d=-1,u=O,O.length===0){h.classList.add("is-hidden");return}for(let U=0;U{q.preventDefault(),q.stopPropagation(),p(k)}),z.addEventListener("mouseenter",()=>m(U))}h.classList.remove("is-hidden")};o.addEventListener("input",()=>{if(!this.headingSearch)return;this._headingDebounce&&activeWindow.clearTimeout(this._headingDebounce);let O=o.value.trim();if(O.length<1){_();return}this._headingDebounce=activeWindow.setTimeout(()=>{let U=this.headingSearch(O);g(U)},150)}),o.addEventListener("keydown",O=>{if(h.classList.contains("is-hidden")){O.key==="Enter"?(O.preventDefault(),R.click()):O.key==="Escape"&&(O.preventDefault(),this.hideEditor());return}let U=h.querySelectorAll(".ai3d-heading-dropdown-item");O.key==="ArrowDown"?(O.preventDefault(),m(Math.min(d+1,U.length-1))):O.key==="ArrowUp"?(O.preventDefault(),m(Math.max(d-1,0))):O.key==="Enter"?(O.preventDefault(),d>=0&&d{activeWindow.setTimeout(_,150)});let v=n.createDiv({cls:"ai3d-annotation-editor-colors"}),I=(N=r==null?void 0:r.color)==null?void 0:N.trim(),x=I||Pf[0],T=I&&!Pf.includes(I)?[I,...Pf]:Pf;for(let O of T){let U=v.createEl("button",{cls:"ai3d-pin-color-swatch"});U.type="button",U.title=O,U.setAttribute("aria-label",ri("annotation.selectColor",{color:O})),U.style.setProperty("--swatch-color",O),U.style.backgroundColor=O,O===x&&U.classList.add("is-selected"),U.addEventListener("click",k=>{k.stopPropagation(),x=O,v.querySelectorAll(".ai3d-pin-color-swatch").forEach(z=>z.classList.remove("is-selected")),U.classList.add("is-selected")})}let A=n.createDiv({cls:"ai3d-annotation-editor-actions"});if(r){let O=A.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-delete"});O.textContent="Delete",O.addEventListener("click",U=>{U.stopPropagation(),this.removePin(r.id),this.hideEditor()})}let R=A.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-confirm"});R.textContent=r?"Save":"OK",R.addEventListener("click",O=>{O.stopPropagation();let U=o.value.trim()||"Pin",k=this._selectedHeading;if(r){let z={label:U,color:x};k&&(z.notePath=k.notePath,z.headingRef=k.heading,z.headingLevel=k.level),this.updatePin(r.id,z)}else{let z=this.addPin(i,U,x);k&&this.updatePin(z.id,{notePath:k.notePath,headingRef:k.heading,headingLevel:k.level})}this.hideEditor()});let P=A.createEl("button",{cls:"ai3d-annotation-editor-btn ai3d-annotation-editor-cancel"});P.textContent="Cancel",P.addEventListener("click",O=>{O.stopPropagation(),this.hideEditor()});let D=this.overlay.getBoundingClientRect(),M=e-D.left,F=t-D.top;if(n.style.setProperty("--editor-left",`${Math.max(0,Math.min(M,D.width-220))}px`),n.style.setProperty("--editor-top",`${Math.max(0,Math.min(F-10,D.height-160))}px`),this.editorEl=n,r!=null&&r.notePath&&(r!=null&&r.headingRef)){let O=zr(r.notePath),U=l.createSpan({cls:"ai3d-editor-binding-text"});U.textContent=`\u{1F4C4} ${O}`,l.classList.remove("is-hidden"),this._selectedHeading={notePath:r.notePath,heading:r.headingRef,level:(V=r.headingLevel)!=null?V:2},this.loadContentPreview(f,r.notePath,r.headingRef)}requestAnimationFrame(()=>o.focus()),n.addEventListener("pointerdown",O=>O.stopPropagation()),n.addEventListener("mousedown",O=>O.stopPropagation())}hideEditor(){if(this._headingDebounce&&(activeWindow.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=$("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 n=activeDocument.createElement("div");n.className="ai3d-pin-popover";let a=activeDocument.createElement("div");a.className="ai3d-pin-popover-title",a.textContent=i.headingRef,n.appendChild(a);let o=activeDocument.createElement("div");if(o.className="ai3d-pin-popover-body",n.appendChild(o),await this.renderPreviewContent(o,r,i.notePath,"popover"),e!==this.hoverRequestId||!t.isConnected||!this.hostEl.isConnected){this.clearRenderedPreview(o);return}let l=t.getBoundingClientRect();n.style.setProperty("--popover-left",`${l.left+l.width/2}px`),n.style.setProperty("--popover-top",`${l.bottom+4}px`),activeDocument.body.appendChild(n),this.hoverPopover=n}hideHoverPopover(){if(this.hoverTimeout&&(activeWindow.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 n=this.previewMode==="markdown"&&!!this.previewApp,a=r==="editor";if(!n){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 nd.Component);this.previewRenderChildren.set(e,o);try{await nd.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&&(activeWindow.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=activeWindow.setTimeout(()=>{t.el.classList.remove("ai3d-pin-pulse"),this._pulseTimeout=null},1200))}destroy(){var e,t,i;this.hoverRequestId++,this.hideHoverPopover(),this._pulseTimeout&&(activeWindow.clearTimeout(this._pulseTimeout),this._pulseTimeout=null),this._headingDebounce&&(activeWindow.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 n=t.createEl("button",{cls:"ai3d-pin-delete"});n.textContent="\xD7",n.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",n=>n.stopPropagation()),e.notePath&&e.headingRef&&this.noteReader&&(t.addEventListener("mouseenter",()=>{this.hoverTimeout&&activeWindow.clearTimeout(this.hoverTimeout);let n=++this.hoverRequestId;this.hoverTimeout=activeWindow.setTimeout(()=>{this.hoverTimeout=null,n===this.hoverRequestId&&this.showHoverPopover(n,t,e)},300)}),t.addEventListener("mouseleave",()=>{this.hoverTimeout&&(activeWindow.clearTimeout(this.hoverTimeout),this.hoverTimeout=null),this.hoverRequestId++,this.hideHoverPopover()})),this.pinEls.set(e.id,{el:t,worldPos:new S(...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 n=i.getRenderWidth(),a=i.getRenderHeight();if(n===0||a===0)return;let o=r.clientWidth,l=r.clientHeight,c=o/n,f=l/a,h=e.getTransformMatrix(),d=t.viewport.toGlobal(n,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>=Mn.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=Mn._identity,v=Mn._scratchDir,I=Mn._scratchRay;for(let[,x]of this.pinEls){let T=S.Project(x.worldPos,g,h,d);if(T.z>1||T.z<0)this.hidePin(x.el);else if(x.el.style.setProperty("--pin-left",`${T.x*c}px`),x.el.style.setProperty("--pin-top",`${T.y*f}px`),p&&_){let A=S.Distance(_,x.worldPos);x.worldPos.subtractToRef(_,v),v.normalize(),I.origin=_,I.direction=v,I.length=A;let R=e.pickWithRay(I),P=Math.max(A*.01,.01),D=!!(R!=null&&R.hit)&&R.distance=5&&((a||!d&&n===5)&&(l.push(n,0,a,r),n=6),d&&(l.push(n,d,0,r),n=6)),a=""},f=0;f"?(n=1,a=""):a=i+a[0]:o?i===o?o="":a+=i:i==='"'||i==="'"?o=i:i===">"?(c(),n=1):n&&(i==="="?(n=5,r=a,a=""):i==="/"&&(n<5||t[f][h+1]===">")?(c(),n===3&&(l=l[0]),n=l,(l=l[0]).push(2,0,n),n=0):i===" "||i===" "||i===` +`||i==="\r"?(c(),n=2):a+=i),n===3&&a==="!--"&&(n=4,l=l[0])}return c(),l})(s)),e),arguments,[])).length>1?e:e[0]}var nG,sG,oG=C(()=>{nG=function(s,e,t,i){var r;e[0]=0;for(var n=1;n{"use strict"});var fr,hG=C(()=>{"use strict";oG();fG();fr=aG.bind(lG)});function ex(s){uG=s}function T_(s){return dG[s]>=dG[uG]}function A_(){return new Date().toISOString()}function R_(s){return s&&Object.keys(s).length>0?s:void 0}function li(s){let e=`[AI3D][${s}]`;return{debug(t,i){T_("debug")&&console.debug(e,A_(),t,R_(i))},info(t,i){T_("info")&&console.debug(e,A_(),t,R_(i))},warn(t,i){T_("warn")&&console.warn(e,A_(),t,R_(i))},error(t,i){T_("error")&&console.error(e,A_(),t,R_(i))}}}var dG,uG,Yr=C(()=>{"use strict";dG={debug:10,info:20,warn:30,error:40},uG="warn"});function mG(s){let e=Hs(s.sourceExt),t=[];return e!==s.sourceExt&&t.push(`Normalized extension '${s.sourceExt}' -> '${e}'.`),aK.debug("prepare direct load",{path:s.path,sourceExt:s.sourceExt,normalizedExt:e,warningCount:t.length}),{effectivePath:s.path,effectiveExt:e,warnings:t}}var aK,pG=C(()=>{"use strict";Fn();Yr();aK=li("direct-load-service")});function x_(s){return`.${s.trim().toLowerCase()}`}function No(s){return s instanceof Il}function tx(s){var e;if(s instanceof Il){let t=(e=oK[s.converterId])!=null?e:s.converterId;return ri("modelLoad.warningMessage",{ext:x_(s.sourceExt),converterName:t})}return s instanceof Lf?ri("modelLoad.mobileWarningMessage",{ext:x_(s.sourceExt)}):ri("modelLoad.errorMessage",{reason:s instanceof Error?s.message:String(s)})}function Fo(s){return s instanceof Il?{level:"warning",title:$("modelLoad.warningTitle"),message:tx(s),hint:$("modelLoad.warningHint")}:s instanceof Lf?{level:"warning",title:$("modelLoad.warningTitle"),message:tx(s),hint:$("modelLoad.mobileWarningHint")}:{level:"error",title:$("modelLoad.errorTitle"),message:tx(s),hint:$("modelLoad.errorHint")}}var oK,Il,Lf,Cl=C(()=>{"use strict";gs();oK={freecad:"FreeCAD",obj2gltf:"obj2gltf",fbx2gltf:"FBX2glTF",assimp:"mesh",sldprt:"SolidWorks"};Il=class extends Error{constructor(t,i){super(`Converter '${t}' is not registered for ${x_(i)}. Enable the matching converter in plugin settings before loading this format.`);this.converterId=t;this.sourceExt=i;this.name="MissingConverterError"}},Lf=class extends Error{constructor(t){super(`Format ${x_(t)} requires local conversion tools that are unavailable on iOS, iPadOS, and Android.`);this.sourceExt=t;this.name="MobileConversionUnavailableError"}}});function cK(s,e,t){return s.converterId!==e?!1:t?s.converterId===t.converterId&&s.converterCacheKey===t.cacheKey:!0}async function fK(s){if(!s)return!1;try{return await Mr(s,yr),!0}catch(e){return!1}}async function _G(s){var a,o,l,c,f,h,d;if(s.capability.strategy!=="convert")throw new Error(`Expected convert strategy, got '${s.capability.strategy}'.`);let e=s.capability.converterId,t=(a=s.capability.outputFormat)!=null?a:"glb";if(!e)throw new Error(`Format .${s.sourceExt} does not define a converter id.`);od.info("prepare conversion route",{sourcePath:s.sourcePath,sourceExt:s.sourceExt,targetExt:t,converterId:e});let i=s.conversionManager.canConvert(s.sourceExt)?await s.conversionManager.getConverterCacheIdentity(s.sourceExt):void 0,r=(o=s.convertedAssetCache)==null?void 0:o.get(s.sourcePath,s.sourceExt,t);if(r)if(!await fK(r.outputPath))od.warn("conversion cache stale",{sourcePath:s.sourcePath,sourceExt:s.sourceExt,targetExt:t,outputPath:r.outputPath}),(l=s.convertedAssetCache)==null||l.delete(s.sourcePath,s.sourceExt,t);else if(!cK(r,e,i))od.warn("conversion cache identity mismatch",{sourcePath:s.sourcePath,sourceExt:s.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=s.convertedAssetCache)==null||f.delete(s.sourcePath,s.sourceExt,t);else return od.info("conversion cache hit",{sourcePath:s.sourcePath,sourceExt:s.sourceExt,targetExt:t,outputPath:r.outputPath}),{effectivePath:r.outputPath,effectiveExt:r.outputExt,warnings:[...r.warnings,"Using cached conversion output."]};if(!s.conversionManager.canConvert(s.sourceExt))throw new Il(e,s.sourceExt);let n=await s.conversionManager.convert({sourcePath:s.sourcePath,sourceExt:s.sourceExt,targetExt:t});return(d=s.convertedAssetCache)==null||d.set({cacheVersion:2,converterId:e,converterCacheKey:(h=i==null?void 0:i.cacheKey)!=null?h:e,sourcePath:s.sourcePath,sourceExt:s.sourceExt,targetExt:t,outputPath:n.outputPath,outputExt:n.outputExt,warnings:n.warnings,createdAt:Date.now()}),od.info("conversion route done",{sourcePath:s.sourcePath,outputPath:n.outputPath,warningCount:n.warnings.length}),{effectivePath:n.outputPath,effectiveExt:n.outputExt,warnings:n.warnings}}var od,gG=C(()=>{"use strict";K_();Yr();zt();Cl();od=li("conversion-service")});function hK(s,e){var t;return!!((t=s.preferConversionExts)!=null&&t.includes(e))}async function Ma(s){var a,o;let e=Hs((a=s.path.split(".").pop())!=null?a:""),t=j_(e);if(ba.info("prepare model input",{path:s.path,sourceExt:e}),!t||!t.enabled)throw ba.warn("unsupported format",{sourceExt:e,path:s.path}),new Error(`Unsupported format: .${e}`);let i=hK(s,e);if(t.strategy==="convert"||i&&!!t.converterId){if(ii())throw ba.warn("conversion unavailable on mobile",{sourceExt:e,path:s.path}),new Lf(e);if(!s.absolutePath)throw ba.error("filesystem path missing for conversion",{sourceExt:e,path:s.path}),new Error(`Format .${e} requires a local filesystem path for conversion, but none was resolved for '${s.path}'.`);if(!s.conversionManager)throw ba.error("conversion manager missing",{sourceExt:e,path:s.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 ba.error("preferred conversion route missing converter id",{sourceExt:e,path:s.path}),new Error(`Format .${e} is configured to prefer conversion, but no converter id is defined.`);i&&t.strategy==="direct"&&ba.info("preferred conversion route",{sourceExt:e,path:s.path,converterId:l.converterId});let c=await _G({sourcePath:s.absolutePath,sourceExt:e,capability:l,conversionManager:s.conversionManager,convertedAssetCache:s.convertedAssetCache});return ba.info("conversion completed",{sourceExt:e,outputExt:c.effectiveExt,outputPath:c.effectivePath,warningCount:c.warnings.length}),{sourcePath:s.path,sourceExt:e,strategy:"convert",effectivePath:c.effectivePath,effectiveExt:c.effectiveExt,warnings:c.warnings}}let n=mG({path:s.path,sourceExt:e});return ba.debug("direct route",{sourceExt:e,path:s.path,warningCount:n.warnings.length}),{sourcePath:s.path,sourceExt:e,strategy:t.strategy,effectivePath:n.effectivePath,effectiveExt:n.effectiveExt,warnings:n.warnings}}var ba,ld=C(()=>{"use strict";Fn();pG();gG();Cl();Yr();us();ba=li("model-pipeline")});var cd,I_,EG=C(()=>{"use strict";Fn();Yr();cd=li("conversion-manager"),I_=class{constructor(){this.converters=new Map;this.pending=new Map}getConverter(e){return this.converters.get(Hs(e))}registerConverter(e){cd.info("register converter",{converterId:e.id,sourceExts:[...e.sourceExts]});for(let t of e.sourceExts)this.converters.set(Hs(t),e)}canConvert(e){let t=Hs(e),i=this.converters.has(t);return cd.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=Hs(e.sourceExt),i=this.getConverter(t);if(!i)throw cd.error("converter missing",{ext:t,targetExt:e.targetExt}),new Error(`No converter registered for .${t}`);let r=`${e.sourcePath}::${t}::${e.targetExt}`,n=this.pending.get(r);if(n)return cd.info("joining in-flight conversion",{key:r}),n;cd.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 sx(...s){let e=(Ae==null?void 0:Ae.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=>s.map(i=>`${t}/${i}`))))}function uK(){var r,n,a;if((Ae==null?void 0:Ae.platform)==="darwin")return["/Applications/FreeCAD.app/Contents/MacOS/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/FreeCADCmd","/Applications/FreeCAD.app/Contents/Resources/bin/freecadcmd",...sx("FreeCADCmd","freecadcmd")];if((Ae==null?void 0:Ae.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 s=[],e=(r=Ae==null?void 0:Ae.env)==null?void 0:r.LOCALAPPDATA,t=(n=Ae==null?void 0:Ae.env)==null?void 0:n.ProgramFiles,i=(a=Ae==null?void 0:Ae.env)==null?void 0:a["ProgramFiles(x86)"];if(e&&s.push(Nt(e,"Programs","FreeCAD","bin","FreeCADCmd.exe")),t&&s.push(Nt(t,"FreeCAD","bin","FreeCADCmd.exe")),e)for(let o of["1.2","1.1","1.0","0.22","0.21","0.20"])s.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"])s.push(`${t}/FreeCAD ${o}/bin/FreeCADCmd.exe`);return i&&s.push(`${i}/FreeCAD/bin/FreeCADCmd.exe`),s}function mK(s){var a,o,l,c;if((Ae==null?void 0:Ae.platform)!=="win32")return[];let e=(a=Ae==null?void 0:Ae.env)==null?void 0:a.APPDATA,t=(o=Ae==null?void 0:Ae.env)==null?void 0:o.LOCALAPPDATA,i=(l=Ae==null?void 0:Ae.env)==null?void 0:l.npm_config_prefix,r=(c=Ae==null?void 0:Ae.env)==null?void 0:c.USERPROFILE,n=[i,e?Nt(e,"npm"):void 0,t?Nt(t,"npm"):void 0,r?Nt(r,"AppData","Roaming","npm"):void 0].filter(f=>!!f);return Array.from(new Set(n.map(f=>Nt(f,s))))}function pK(...s){var n,a,o;if((Ae==null?void 0:Ae.platform)!=="win32")return[];let e=(n=Ae==null?void 0:Ae.env)==null?void 0:n.ProgramFiles,t=(a=Ae==null?void 0:Ae.env)==null?void 0:a["ProgramFiles(x86)"],i=(o=Ae==null?void 0:Ae.env)==null?void 0:o.LOCALAPPDATA,r=[e,t,i?Nt(i,"Programs"):void 0].filter(l=>!!l);return Array.from(new Set(r.flatMap(l=>s.map(c=>Nt(l,c)))))}async function ox(s){try{return await Mr(s,(Ae==null?void 0:Ae.platform)==="win32"?yr:PV),!0}catch(e){return!1}}function ix(s){let e=s==null?void 0:s.trim();if(e)return e}function _K(s){let e=[],t="",i=null;for(let r=0;rr.trim().toLowerCase()).filter(Boolean);return e!=null&&e.length?e:dK}async function SK(s){var r;let e=(r=Ae==null?void 0:Ae.env)==null?void 0:r.PATH;if(!e)return;let t=e.split(LV).map(n=>n.trim()).filter(Boolean),i=(Ae==null?void 0:Ae.platform)==="win32"?vK(s):[""];for(let n of t)for(let a of i){let o=Nt(n,a?`${s}${a}`:s);if(await ox(o))return o}}function nx(s,e,t=15e3){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:4*1024*1024},(n,a,o)=>{if(n){r(new Error((o||a||n.message).toString().trim()||n.message));return}i({stdout:a!=null?a:"",stderr:o!=null?o:""})})})}function ax(s){let t=(s instanceof Error?s.message:String(s)).replace(/\s+/g," ").trim();return t.length>180?`${t.slice(0,177)}...`:t}async function rx(s,e,t,i){let r="";for(let n of t)try{return await nx(s,[...e,...n]),{ok:!0,detail:""}}catch(a){let o=ax(a);if(i.test(o))return{ok:!0,detail:""};r=o}return{ok:!1,detail:r||"Command probe failed."}}async function TK(s){var i;if(!s.available)return[];let e=(i=s.resolvedPath)!=null?i:s.executable,t=[...s.args];if(s.id==="freecad")try{return await nx(e,[...t,"-c","import cadquery, trimesh; print('ok')"]),[{kind:"cad-python",ok:!0,detail:""}]}catch(r){return[{kind:"cad-python",ok:!1,detail:ax(r)}]}if(s.id==="assimp")try{return await nx(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:ax(r)}]}if(s.id==="freecadcmd"){let r=await rx(e,t,[["--version"],["--help"]],/freecad|usage|help|version/i);return[{kind:"freecadcmd-cli",ok:r.ok,detail:r.detail}]}if(s.id==="obj2gltf"){let r=await rx(e,t,[["--version"],["--help"]],/obj2gltf|usage|help|version/i);return[{kind:"obj2gltf-cli",ok:r.ok,detail:r.detail}]}if(s.id==="fbx2gltf"){let r=await rx(e,t,[["--version"],["--help"]],/fbx2gltf|usage|help|version/i);return[{kind:"fbx2gltf-cli",ok:r.ok,detail:r.detail}]}return[]}function AK(s){let e=SG.find(t=>t.id===s);if(!e)throw new Error(`Unknown converter command id: ${s}`);return e}function RK(s){var n,a,o,l;let e=(a=(n=Ae==null?void 0:Ae.env)==null?void 0:n.ProgramFiles)==null?void 0:a.toLowerCase(),t=(l=(o=Ae==null?void 0:Ae.env)==null?void 0:o["ProgramFiles(x86)"])==null?void 0:l.toLowerCase(),i=[],r=[];for(let c of s.knownCandidates){let f=c.toLowerCase(),h=(Ae==null?void 0:Ae.platform)==="win32"&&((e?f.startsWith(e):!1)||(t?f.startsWith(t):!1)),d=(Ae==null?void 0:Ae.platform)!=="win32"&&(c.startsWith("/usr/bin/")||c.startsWith("/snap/freecad/current/usr/bin/"));h||d?r.push(c):i.push(c)}return{userCandidates:i,systemCandidates:r}}async function vG(s,e,t){for(let i of e)if(await ox(i))return{id:s.id,label:s.label,envVar:s.envVar,settingsKey:s.settingsKey,command:i,executable:i,args:[],resolvedPath:i,available:!0,source:"candidate",detail:t,checkedCandidates:[i]}}function xK(s,e){let t=[];return s.length&&t.push(`Checked common user locations: ${s.join("; ")}`),e.length&&t.push(`Checked system fallback locations: ${e.join("; ")}`),t.join(". ")}async function C_(s,e,t,i){let r=gK(e);if(EK(r.executable)){let a=await ox(r.executable);return{id:s.id,label:s.label,envVar:s.envVar,settingsKey:s.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:a?r.executable:void 0,available:a,source:t,detail:a?`Using ${b_(t)} path.`:"Configured path was not found or is not executable.",checkedCandidates:[r.executable]}}let n=await SK(r.executable);return{id:s.id,label:s.label,envVar:s.envVar,settingsKey:s.settingsKey,configuredCommand:i,command:e,executable:r.executable,args:r.args,resolvedPath:n,available:!!n,source:t,detail:n?`Resolved from ${b_(t)} via PATH lookup.`:"Command name was not found on PATH.",checkedCandidates:[r.executable]}}function b_(s){switch(s){case"settings":return"plugin settings";case"env":return"environment variable";case"candidate":return"known install location";case"path":return"PATH fallback"}}async function TG(s,e){var d,u,m;let t=AK(s),{userCandidates:i,systemCandidates:r}=RK(t),n=ix(e);if(n)return C_(t,n,"settings",n);let a=ix((d=Ae==null?void 0:Ae.env)==null?void 0:d[t.envVar]);if(a)return C_(t,a,"env");for(let p of(u=t.envVarAliases)!=null?u:[]){let _=ix((m=Ae==null?void 0:Ae.env)==null?void 0:m[p]);if(_)return C_(t,_,"env")}let o=await vG(t,i,"Detected at a common user-managed install location.");if(o)return o;let l=[];for(let p of t.fallbackCommands){let _=await C_(t,p,"path");if(l.push(_),_.available)return _}let c=await vG(t,r,"Detected at a system fallback install location.");if(c)return c;let f=l.flatMap(p=>p.checkedCandidates),h=xK(i,r);return{...l[0],detail:h?`Command name was not found on PATH. ${h}`:"Command name was not found on PATH.",checkedCandidates:[...i,...f,...r]}}async function M_(s){let e=await Promise.all(SG.map(t=>TG(t.id,s[t.settingsKey])));return Promise.all(e.map(async t=>({...t,dependencyChecks:await TK(t)})))}async function hr(s,e){var i;let t=await TG(s,e);return{command:(i=t.resolvedPath)!=null?i:t.executable,args:[...t.args]}}var Ae,dK,SG,wo=C(()=>{"use strict";zt();zt();zt();Ae=p_(),dK=[".exe",".cmd",".bat",".com"];SG=[{id:"freecad",label:"Python (CadQuery/OCCT)",settingsKey:"freecadCommand",envVar:"AI3D_FREECAD_CMD",fallbackCommands:(Ae==null?void 0:Ae.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Ae==null?void 0:Ae.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:(Ae==null?void 0:Ae.platform)==="win32"?["obj2gltf.cmd"]:["obj2gltf"],knownCandidates:(Ae==null?void 0:Ae.platform)==="win32"?mK("obj2gltf.cmd"):sx("obj2gltf")},{id:"fbx2gltf",label:"FBX2glTF",settingsKey:"fbx2gltfCommand",envVar:"AI3D_FBX2GLTF_CMD",fallbackCommands:(Ae==null?void 0:Ae.platform)==="win32"?["FBX2glTF.exe"]:["FBX2glTF","fbx2gltf"],knownCandidates:(Ae==null?void 0:Ae.platform)==="win32"?pK(Nt("FBX2glTF","FBX2glTF-windows-x64.exe"),Nt("FBX2glTF","FBX2glTF.exe")):sx("FBX2glTF","fbx2gltf")},{id:"assimp",label:"Python (trimesh)",settingsKey:"assimpCommand",envVar:"AI3D_ASSIMP_CMD",fallbackCommands:(Ae==null?void 0:Ae.platform)==="win32"?["py","python"]:["python3","python"],knownCandidates:(Ae==null?void 0:Ae.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:(Ae==null?void 0:Ae.platform)==="win32"?["FreeCADCmd.exe"]:["freecadcmd","FreeCADCmd"],knownCandidates:uK()}]});function ya(s){if(s.includes('"'))throw new Error(`File path contains double-quote character, not supported for Python conversion: ${s}`);return s.replace(/\\/g,"/")}var y_=C(()=>{"use strict"});async function bK(s){try{return await Mr(s,yr),!0}catch(e){return!1}}function MK(s,e,t){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(n,a,o)=>{if(!n){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`CAD conversion failed: ${n.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function yK(s,e,t){let i=ya(s),r=ya(e),n=t.toLowerCase().replace(/^\./,""),a=n==="step"||n==="stp",o=n==="iges"||n==="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 IK,CK,D_,AG=C(()=>{"use strict";zt();zt();zt();zt();Yr();wo();y_();IK=li("freecad-converter"),CK=300*1e3;D_=class{constructor(e){this.configuredCommand=e;this.id="freecad";this.sourceExts=["step","stp","iges","igs","brep"];this.targetExt="glb"}async getCacheKey(){let e=await hr(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!cr(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 hr(this.id,this.configuredCommand),i=Cn(e.sourcePath),r=bn(e.sourcePath,ps(e.sourcePath)),n=Nt(i,`${r}.ai3d-converted.glb`),a=Nt(Mf(),"ai3d-freecad"),o=Nt(a,`${r}-${Date.now()}.py`);await Cf(a,{recursive:!0}),await If(o,yK(e.sourcePath,n,e.sourceExt),"utf8"),IK.info("run CAD conversion (CadQuery/OCCT)",{sourcePath:e.sourcePath,outputPath:n,command:t.command,args:t.args});try{await MK(t.command,[...t.args,o],CK)}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{bf(o,{force:!0})}if(!await bK(n))throw new Error(`CAD conversion finished but output was not found: '${n}'. Check that CadQuery supports this CAD format.`);if((await ms(n)).byteLength===0)throw new Error(`CAD conversion output is empty: '${n}'.`);return{outputPath:n,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/CadQuery(OCCT) bridge."]}}}});async function LK(s){try{return await Mr(s,yr),!0}catch(e){return!1}}function OK(s,e,t){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(n,a,o)=>{if(!n){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`obj2gltf command failed: ${n.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var DK,PK,P_,RG=C(()=>{"use strict";zt();zt();zt();Yr();wo();DK=li("obj2gltf-converter"),PK=180*1e3;P_=class{constructor(e){this.configuredCommand=e;this.id="obj2gltf";this.sourceExts=["obj"];this.targetExt="glb"}async getCacheKey(){let e=await hr(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!cr(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 hr(this.id,this.configuredCommand),i=Cn(e.sourcePath),r=bn(e.sourcePath,ps(e.sourcePath)),n=Nt(i,`${r}.ai3d-converted.glb`);DK.info("run obj2gltf conversion",{sourcePath:e.sourcePath,outputPath:n,command:t.command,args:t.args});try{await OK(t.command,[...t.args,"-i",e.sourcePath,"-o",n,"-b"],PK)}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 LK(n))throw new Error(`obj2gltf conversion finished but output was not found: '${n}'.`);if((await ms(n)).byteLength===0)throw new Error(`obj2gltf output file is empty: '${n}'.`);return{outputPath:n,outputExt:"glb",fromCache:!1,warnings:["Converted by local obj2gltf CLI bridge."]}}}});async function wK(s){try{return await Mr(s,yr),!0}catch(e){return!1}}function BK(s,e,t){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(n,a,o)=>{if(!n){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`FBX2glTF command failed: ${n.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}var NK,FK,L_,xG=C(()=>{"use strict";zt();zt();zt();Yr();wo();NK=li("fbx2gltf-converter"),FK=180*1e3;L_=class{constructor(e){this.configuredCommand=e;this.id="fbx2gltf";this.sourceExts=["fbx"];this.targetExt="glb"}async getCacheKey(){let e=await hr(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!cr(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 hr(this.id,this.configuredCommand),i=Cn(e.sourcePath),r=bn(e.sourcePath,ps(e.sourcePath)),n=Nt(i,`${r}.ai3d-converted.glb`);NK.info("run FBX2glTF conversion",{sourcePath:e.sourcePath,outputPath:n,command:t.command,args:t.args});try{await BK(t.command,[...t.args,"-i",e.sourcePath,"-o",n,"-b"],FK)}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 wK(n))throw new Error(`FBX2glTF conversion finished but output was not found: '${n}'.`);if((await ms(n)).byteLength===0)throw new Error(`FBX2glTF output file is empty: '${n}'.`);return{outputPath:n,outputExt:"glb",fromCache:!1,warnings:["Converted by local FBX2glTF CLI bridge."]}}}});async function GK(s){try{return await Mr(s,yr),!0}catch(e){return!1}}function kK(s,e,t){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(n,a,o)=>{if(!n){i();return}let l=(a!=null?a:"").toString().trim(),c=(o!=null?o:"").toString().trim(),f=[`mesh conversion failed: ${n.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function WK(s,e){let t=ya(s),i=ya(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 UK,VK,O_,IG=C(()=>{"use strict";zt();zt();zt();zt();Yr();wo();y_();UK=li("assimp-converter"),VK=300*1e3;O_=class{constructor(e){this.configuredCommand=e;this.id="assimp";this.sourceExts=["3mf","dae"];this.targetExt="glb"}async getCacheKey(){let e=await hr(this.id,this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!cr(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 hr(this.id,this.configuredCommand),i=Cn(e.sourcePath),r=bn(e.sourcePath,ps(e.sourcePath)),n=Nt(i,`${r}.ai3d-converted.glb`),a=Nt(Mf(),"ai3d-mesh-convert"),o=Nt(a,`${r}-${Date.now()}.py`);await Cf(a,{recursive:!0}),await If(o,WK(e.sourcePath,n),"utf8"),UK.info("run mesh conversion (trimesh)",{sourcePath:e.sourcePath,outputPath:n,command:t.command,args:t.args});try{await kK(t.command,[...t.args,o],VK)}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{bf(o,{force:!0})}if(!await GK(n))throw new Error(`Mesh conversion finished but output was not found: '${n}'. Check that trimesh supports this format.`);if((await ms(n)).byteLength===0)throw new Error(`Mesh conversion output is empty: '${n}'.`);return{outputPath:n,outputExt:"glb",fromCache:!1,warnings:["Converted by local Python/trimesh bridge."]}}}});async function zK(s){try{return await Mr(s,yr),!0}catch(e){return!1}}function XK(s,e,t){return new Promise((i,r)=>{_s(s,e,{timeout:t,windowsHide:!0,maxBuffer:50*1024*1024},(n,a,o)=>{if(!n){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: ${n.message}`,l?`stdout: ${l}`:"",c?`stderr: ${c}`:""].filter(Boolean);r(new Error(f.join(" | ")))})})}function YK(s,e){let t=ya(s),i=ya(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 lx,HK,N_,CG=C(()=>{"use strict";zt();zt();zt();zt();Yr();wo();y_();lx=li("sldprt-converter"),HK=600*1e3;N_=class{constructor(e){this.configuredCommand=e;this.id="sldprt";this.sourceExts=["sldprt"];this.targetExt="glb"}async getCacheKey(){let e=await hr("freecadcmd",this.configuredCommand);return`${this.id}:${e.command} ${e.args.join(" ")}`.trim()}async convert(e){if(!cr(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 hr("freecadcmd",this.configuredCommand),i=Cn(e.sourcePath),r=bn(e.sourcePath,ps(e.sourcePath)),n=Nt(i,`${r}.ai3d-converted.glb`),a=Nt(Mf(),"ai3d-sldprt"),o=Nt(a,`${r}-${Date.now()}.py`);await Cf(a,{recursive:!0}),await If(o,YK(e.sourcePath,n),"utf8"),lx.info("run SLDPRT conversion (FreeCAD + OCP)",{sourcePath:e.sourcePath,outputPath:n,command:t.command,args:t.args});try{let{stdout:c,stderr:f}=await XK(t.command,[...t.args,o],HK);c&&lx.info("FreeCAD stdout",{stdout:c.trim().slice(0,500)}),f&&lx.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{bf(o,{force:!0})}if(!await zK(n))throw new Error(`SLDPRT conversion finished but output was not found: '${n}'. Check that FreeCAD can import this SolidWorks file version.`);if((await ms(n)).byteLength===0)throw new Error(`SLDPRT conversion output is empty: '${n}'.`);return{outputPath:n,outputExt:"glb",fromCache:!1,warnings:["Converted by local FreeCAD + OpenCASCADE bridge."]}}}});function Da(s){var r;let e=new I_,t=new Set((r=s==null?void 0:s.enabledConverterIds)!=null?r:[]);cx.debug("create conversion manager",{enabledConverterIds:[...t]});let i=[new D_(s==null?void 0:s.freecadCommand),new P_(s==null?void 0:s.obj2gltfCommand),new L_(s==null?void 0:s.fbx2gltfCommand),new O_(s==null?void 0:s.assimpCommand),new N_(s==null?void 0:s.freecadcmdCommand)];for(let n of i)t.has(n.id)?(e.registerConverter(n),cx.info("enabled converter",{converterId:n.id})):cx.debug("converter disabled",{converterId:n.id});return e}var cx,fd=C(()=>{"use strict";EG();AG();RG();xG();IG();CG();Yr();cx=li("conversion-factory")});function bl(s){return{path:s.effectivePath,ext:s.effectiveExt,strategy:s.strategy,sourcePath:s.sourcePath,sourceExt:s.sourceExt,warnings:s.warnings}}var F_=C(()=>{"use strict"});function Pa(s){let e=[];return s.preferObj2gltfForObj&&e.push("obj"),s.preferFbx2gltfForFbx&&e.push("fbx"),e}var hd=C(()=>{"use strict"});function dd(s){return s.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g,"$2").replace(/\[\[([^\]]+)\]\]/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[*_~`]+/g,"").replace(/==([^=]+)==/g,"$1").replace(/\s+/g," ").trim()}function KK(s,e){let t=e.toLowerCase().trim();if(!t)return[];let i=[],r=s.vault.getMarkdownFiles();for(let n of r){let a=s.metadataCache.getFileCache(n);if(a!=null&&a.headings)for(let o of a.headings)o.heading.toLowerCase().includes(t)&&i.push({notePath:n.path,heading:o.heading,level:o.level})}return i.slice(0,15)}function w_(s){return e=>KK(s,e)}async function jK(s,e,t){try{let i=s.vault.getAbstractFileByPath(e);if(!(i instanceof bG.TFile))return null;let n=(await s.vault.cachedRead(i)).split(` +`),a=-1,o=0,l=dd(t);for(let f=0;fjK(s,e,t)}var bG,Of=C(()=>{"use strict";bG=require("obsidian")});function Uo(s,e){let t=s.createDiv({cls:"ai3d-inline-empty ai3d-load-feedback-shell"});ii()&&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 ud=C(()=>{"use strict";us()});var DG={};Ie(DG,{generateKnowledgeNote:()=>yG,mountWorkbench:()=>fx});function fx(s,e,t,i){var k,z;let r=ii();s.classList.add("ai3d-workbench"),s.classList.toggle("is-mobile",r);let n=null,a=null,o=!1,l=!1,c=t.store.getState(),f=c.currentModelPath,h=c.currentModelPath,d=c.modelPreview;function u(Z){if(!a||!n)return;let J=a.getPinPosition(Z);if(!J)return;let q=n.getCamera(),Y=new Ne("focusPin","target",30,Ne.ANIMATIONTYPE_VECTOR3,Ne.ANIMATIONLOOPMODE_CONSTANT);Y.setKeys([{frame:0,value:q.target.clone()},{frame:20,value:J}]);let K=new rm;K.setEasingMode(Tr.EASINGMODE_EASEOUT),Y.setEasingFunction(K),q.animations=[Y],n.getScene().beginAnimation(q,0,20,!1)}let m=Z=>{Z.key==="Escape"&&o&&M(!1)};activeDocument.addEventListener("keydown",m);let p=s.createDiv({cls:"ai3d-preview-host"});r&&p.classList.add("is-mobile-scroll-mode");let _=fr` +
+
3D
+
${$("workbench.emptyTitle")}
+
${$("workbench.emptyText")}
+
+ `;p.appendChild(_);let g=p.createDiv({cls:"ai3d-annot-mode-overlay is-hidden"}),v=!1,I=r?s.createDiv({cls:"ai3d-mobile-mode-bar is-detached is-hidden"}):null,x=(k=I==null?void 0:I.createDiv({cls:"ai3d-mobile-mode-hint",text:$("workbench.mobileHint")}))!=null?k:null,T=(z=I==null?void 0:I.createEl("button",{cls:"ai3d-mobile-mode-btn",text:$("helper.interactAction"),attr:{"aria-label":$("helper.enableInteractionLabel")}}))!=null?z:null;function A(Z){r&&(v=Z,p.classList.toggle("is-mobile-interactive",Z),p.classList.toggle("is-mobile-scroll-mode",!Z),T&&(T.textContent=Z?$("helper.scrollAction"):$("helper.interactAction"),T.classList.toggle("ai3d-btn-active",Z),T.setAttribute("aria-label",Z?$("helper.disableInteractionLabel"):$("helper.enableInteractionLabel"))),x&&(x.textContent=Z?$("workbench.mobileHintInteractive"):$("workbench.mobileHint")))}T==null||T.addEventListener("click",()=>{let Z=!v;!Z&&o&&M(!1),A(Z)});function R(){p.querySelectorAll(".ai3d-inline-empty:not(.ai3d-empty-state)").forEach(Z=>Z.remove())}function P(){a==null||a.hideEditor(),a==null||a.destroy(),a=null,o=!1,g.classList.add("is-hidden"),I==null||I.classList.add("is-hidden"),A(!1),n==null||n.destroy(),n=null,p.querySelectorAll(".ai3d-canvas-full").forEach(Z=>Z.remove()),R()}function D(Z){if(P(),_.classList.remove("is-hidden"),Z)if(typeof Z=="string"){let J=p.createDiv({cls:"ai3d-inline-empty"});J.textContent=Z}else Uo(p,Z)}function M(Z){o=Z,r&&Z&&A(!0),a==null||a.hideEditor(),g.classList.toggle("is-hidden",!Z),N()}let F=s.createDiv({cls:"ai3d-panels"});function N(){var q,Y,K,j;let Z=t.store.getState();if(F.replaceChildren(),F.appendChild(fr` +
+
+
+
${$("workbench.modelTitle")}
+
Babylon.js
+
+
+
+
+ + ${(q=Z.currentModelPath)!=null?q:$("workbench.noModelLoaded")} +
+
+
+ `),n){let ee=fr` +
+
+
${$("workbench.disassemblyTitle")}
+
+
+
+
+ ${$("workbench.explodeLabel")} + + 0% +
+
+ + + +
+
+
+
+ `;F.appendChild(ee);let be=ee.querySelector(".ai3d-slider"),_e=ee.querySelector(".ai3d-slider-value"),pe=ee.querySelectorAll(".ai3d-axis-btn"),te="x";be.addEventListener("input",()=>{let le=parseInt(be.value,10);_e.textContent=`${le}%`,n==null||n.setExplode(le/100,te)}),pe.forEach(le=>{le.addEventListener("click",()=>{pe.forEach(ce=>ce.classList.remove("is-active")),le.classList.add("is-active"),te=le.dataset.axis;let xe=parseInt(be.value,10);n==null||n.resetExplode(),xe>0&&(n==null||n.setExplode(xe/100,te))})})}if(Z.modelPreview){let ee=Z.modelPreview;F.appendChild(fr` +
+
+
${$("workbench.summaryTitle")}
+
+
+
+
+
${$("workbench.meshesLabel")}
+
${ee.meshCount}
+
+
+
${ee.splatCount?$("workbench.splatsLabel"):$("workbench.trianglesLabel")}
+
${((Y=ee.splatCount)!=null?Y:ee.triangleCount).toLocaleString()}
+
+
+
${$("workbench.materialsLabel")}
+
${ee.materialCount}
+
+
+
+
+ `)}if(Z.currentModelPath){let le=function(){var Fe;let xe=pe.value.trim();if(!xe)return;let ce=t.store.getState().modelAssetProfiles,de=t.store.getState().currentModelPath,ke=(Fe=ce[de])!=null?Fe:MG(),Ze=Mx([...ke.tags,xe]);t.store.setState({modelAssetProfiles:{...ce,[de]:{...ke,tags:Ze}}}),pe.value="",N()};var J=le;let ee=Z.modelAssetProfiles[Z.currentModelPath],be=(K=ee==null?void 0:ee.tags)!=null?K:[],_e=fr` +
+
+
${$("workbench.tagsTitle")}
+
+
+
+
+ ${be.length>0?be.map(xe=>fr`${xe}`):fr`${$("workbench.noTagsYet")}`} +
+
+ + +
+
+
+
+ `;F.appendChild(_e);let pe=_e.querySelector(".ai3d-input");_e.querySelector(".ai3d-axis-btn").addEventListener("click",le),pe.addEventListener("keydown",xe=>{xe.key==="Enter"&&le()})}if(Z.currentModelPath&&n){let ee=Z.modelAssetProfiles[Z.currentModelPath],be=(j=ee==null?void 0:ee.annotations)!=null?j:[],_e=fr` +
+
+
${$("workbench.annotationsTitle")}
+
+
+
+
+ + ${o?$(r?"workbench.annotateHintActiveMobile":"workbench.annotateHintActive"):ri("workbench.pinCount",{count:String(be.length)})} +
+ ${be.length>0?fr` +
+ ${be.map(te=>fr` +
+ + ${te.label} + + + + +
+ `)} +
+ `:""} +
+
+
+ `;F.appendChild(_e);let pe=_e.querySelector("[data-action='toggle-annot']");pe&&pe.addEventListener("click",()=>{M(!o)}),_e.querySelectorAll("[data-action='focus-pin']").forEach(te=>{te.addEventListener("click",()=>{let le=te.dataset.pinId;u(le)})}),_e.querySelectorAll("[data-action='edit-pin']").forEach(te=>{te.addEventListener("click",le=>{le.stopPropagation();let xe=te.dataset.pinId;a==null||a.editPin(xe)})}),_e.querySelectorAll("[data-action='delete-pin']").forEach(te=>{te.addEventListener("click",le=>{le.stopPropagation();let xe=te.dataset.pinId;a==null||a.removePin(xe)})})}if(Z.currentModelPath){let ee=fr` +
+
+
+ ${n?fr``:""} + ${n?fr``:""} + ${n!=null&&n.hasAnimations()?fr``:""} + + +
+
+
+ `;F.appendChild(ee),ee.querySelector("[data-action='save']").addEventListener("click",()=>{t.save()});let be=ee.querySelector("[data-action='reset']");be&&be.addEventListener("click",()=>{n==null||n.resetView()});let _e=ee.querySelector("[data-action='info']");_e&&_e.addEventListener("click",()=>{var ce;if(!n)return;let te=(ce=t.store.getState().currentModelPath)!=null?ce:void 0,le=n.exportModelInfo(te);if(!le)return;let xe=e.workspace.getActiveViewOfType(Ff.MarkdownView);xe&&"editor"in xe?xe.editor.replaceSelection(le):navigator.clipboard.writeText(le).catch(()=>{})});let pe=ee.querySelector("[data-action='anim']");pe&&pe.addEventListener("click",()=>{if(!(n!=null&&n.toggleAnimation))return;let te=n.toggleAnimation();pe.textContent=te?$("workbench.pauseAction"):$("workbench.playAction")}),ee.querySelector("[data-action='note']").addEventListener("click",()=>{yG(e,t.store.getState())})}}N();async function V(){var Z,J;if(!l){l=!0;try{for(;f!==void 0;){let q=f;f=void 0;let Y=t.store.getState();if(!q){D(),Y.modelPreview!==null&&t.store.setState({modelPreview:null});continue}if(!(e.vault.getAbstractFileByPath(q)instanceof Ff.TFile)){D(ri("workbench.fileNotFound",{path:q})),Y.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{Nf.info("begin model load",{path:q});let ee=(Z=xa(e,q))!=null?Z:void 0,be=Da(Y.settings),_e=await Ma({path:q,absolutePath:ee,preferConversionExts:Pa(Y.settings),conversionManager:be,convertedAssetCache:i}),pe=bl(_e);for(let Ze of pe.warnings)Nf.warn("model prepare warning",{path:q,warning:Ze});let te=await Xr(e,pe.path),le=async Ze=>Xr(e,Ze);n=new Ca(j),I==null||I.classList.remove("is-hidden");let xe=await n.loadModel(te,pe.ext,le,pe.path),ce=t.store.getState().currentModelPath;if(ce!==q){Nf.info("discard stale model load",{path:q,nextPath:ce}),n.destroy(),n=null,j.remove();continue}let de=t.store.getState().settings;n.setRenderQuality(de.renderQuality,de.renderScale);let ke=n.getCanvas();if(ke){let Ze=t.store.getState().modelAssetProfiles[q],Fe=Bo(e),Xe=w_(e);a=new yn({scene:n.getScene(),camera:n.getCamera(),engine:n.getEngine(),canvas:ke},p,"edit",(J=Ze==null?void 0:Ze.annotations)!=null?J:[],St=>{var Gi;let bt=t.store.getState().modelAssetProfiles,Gt=t.store.getState().currentModelPath;if(!Gt)return;let si=(Gi=bt[Gt])!=null?Gi:MG();t.store.setState({modelAssetProfiles:{...bt,[Gt]:{...si,annotations:St,updatedAt:new Date().toISOString()}}})},Fe,Xe,{app:e,previewMode:de.annotationPreviewMode}),n.onPick(St=>{if(!o||!a)return;let bt=St.screenX,Gt=St.screenY,si=null;St.pickedPoint?si=St.pickedPoint:St.mesh&&(si=St.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),si&&(console.debug("[AI3D] Annotation: creating pin at",si.toString(),"screen:",bt,Gt),a.showEditor(bt,Gt,si))})}t.store.setState({modelPreview:xe}),Nf.info("model load completed",{path:q,effectivePath:pe.path,effectiveExt:pe.ext,strategy:pe.strategy,meshCount:xe.meshCount,triangleCount:xe.triangleCount})}catch(ee){let be=Fo(ee);No(ee)?Nf.warn("model load blocked by converter settings",{path:q,error:ee.message}):Nf.error("model load failed",{path:q,error:ee instanceof Error?ee.message:String(ee)}),D(be)}}}finally{l=!1}}}let O=t.store.subscribe(()=>{let Z=t.store.getState(),J=Z.currentModelPath!==h,q=Z.modelPreview===null&&d!==null;h=Z.currentModelPath,d=Z.modelPreview,!(!J&&!q)&&(f=Z.currentModelPath,V())});V();let U=t.store.subscribe(()=>N());return()=>{O(),U(),activeDocument.removeEventListener("keydown",m),P(),s.replaceChildren(),s.classList.remove("ai3d-workbench")}}function MG(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}async function yG(s,e){md!==null&&await md;let t;md=new Promise(i=>{t=i});try{let i=e.currentModelPath;if(!i)return;let r=e.modelAssetProfiles[i],n=e.modelPreview,a=zr(i)||"model",o=e.settings.reportFolder,l=`${o}/${a} Report.md`,c=ZK(a,i,r,n),f=s.vault.getAbstractFileByPath(l);if(f instanceof Ff.TFile){await s.vault.modify(f,c);return}s.vault.getAbstractFileByPath(o)||await s.vault.createFolder(o).catch(()=>{});try{await s.vault.create(l,c)}catch(d){let u=s.vault.getAbstractFileByPath(l);u instanceof Ff.TFile&&await s.vault.modify(u,c)}}finally{t(),md!==null&&(md=null)}}function ZK(s,e,t,i){var n,a,o,l;return[["---",`source_model: "${e}"`,`format: ${(a=(n=e.split(".").pop())==null?void 0:n.toLowerCase())!=null?a:"unknown"}`,"status: ready",`updated_at: ${new Date().toISOString()}`,...t!=null&&t.tags.length?["knowledge_tags:",...t.tags.map(c=>` - ${c}`)]:[],"---"].join(` +`),"",`# ${s}`,"","## 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 Ff,Nf,md,hx=C(()=>{"use strict";Ff=require("obsidian");yx();rd();ad();ia();nm();hG();ld();fd();F_();Yr();Ia();hd();Of();Cl();gs();ud();us();Nf=li("workbench");md=null});function $i(s){let e=activeDocument.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width","16"),e.setAttribute("height","16");let t=new DOMParser().parseFromString(`${s}`,"image/svg+xml");for(let i of Array.from(t.documentElement.childNodes))e.appendChild(activeDocument.importNode(i,!0));return e}function LG(s){var a,o;let[e,t]=s.split(","),i=(o=(a=e.match(/:(.*?);/))==null?void 0:a[1])!=null?o:"image/png",r=atob(t),n=new Uint8Array(r.length);for(let l=0;l(f&&j.classList.add("is-secondary"),j),m=!1,p=!1,_=f?d.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-mode-btn",attr:{"aria-label":$("helper.enableInteractionLabel")}}):null;_==null||_.appendChild($i(''));let g=(K=_==null?void 0:_.createSpan({cls:"ai3d-mobile-mode-btn-label"}))!=null?K:null,v=()=>{!f||!_||(OG(e,m),_.classList.toggle("ai3d-btn-active",m),g==null||g.setText(m?$("helper.scrollAction"):$("helper.interactAction")),_.setAttribute("aria-label",m?$("helper.disableInteractionLabel"):$("helper.enableInteractionLabel")),Y==null||Y.classList.toggle("ai3d-btn-active",p),d.classList.toggle("show-secondary",p))},I=j=>{m=j,v()};_==null||_.addEventListener("click",()=>{let j=!m;l==null||l(j),I(j),$t(_,j?$("helper.interactionOn"):$("helper.interactionOff"))});let x=d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.resetViewLabel")}});x.appendChild($i('')),x.addEventListener("click",()=>{let j=i();j!=null&&j.resetView&&(j.resetView(),$t(x,$("helper.resetViewDone")))});let T=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.copyModelInfoLabel")}}));T.appendChild($i('')),T.addEventListener("click",()=>{let j=i();if(j!=null&&j.exportModelInfo)try{let ee=j.exportModelInfo(r());if(!ee)return;navigator.clipboard.writeText(ee).then(()=>{$t(T,$("helper.copied"))}).catch(()=>{$t(T,$("helper.failed"))})}catch(ee){console.error("[AI3D] Export model info failed:",ee),$t(T,$("helper.failed"))}});let A=d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.toggleWireframeLabel")}});A.appendChild($i('')),A.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.toggleWireframe))return;let ee=j.toggleWireframe();A.classList.toggle("ai3d-btn-active",ee),$t(A,ee?$("helper.wireframeOn"):$("helper.wireframeOff"))});let R=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.toggleAxesLabel")}}));R.appendChild($i('')),R.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.toggleOrientationGizmo))return;let ee=j.toggleOrientationGizmo();R.classList.toggle("ai3d-btn-active",ee),$t(R,ee?$("helper.axesOn"):$("helper.axesOff"))});let P=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.toggleBoundingBoxLabel")}}));P.appendChild($i('')),P.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.toggleBoundingBox))return;let ee=j.toggleBoundingBox();P.classList.toggle("ai3d-btn-active",ee),$t(P,ee?$("helper.boundingBoxOn"):$("helper.boundingBoxOff"))});let D=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.toggleDisassemblyLabel")}}));D.appendChild($i('')),D.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.toggleDisassembly))return;let ee=j.toggleDisassembly();D.classList.toggle("ai3d-btn-active",ee),$t(D,ee?$("helper.disassemblyOn"):$("helper.disassemblyOff"))});let M=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.resetPartsLabel")}}));M.appendChild($i('')),M.addEventListener("click",()=>{let j=i();j!=null&&j.resetDisassembly&&(j.resetDisassembly(),$t(M,$("helper.partsReset")))});let F=[.5,.75,1,1.5,2],N=2,V=u(d.createEl("button",{cls:"ai3d-inline-btn ai3d-res-btn",attr:{"aria-label":$("helper.changeResolutionLabel")}}));V.textContent="1.0x",V.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.setRenderScale))return;N=(N+1)%F.length;let ee=j.setRenderScale(F[N]);V.textContent=`${ee}x`,$t(V,ri("helper.resolutionValue",{value:`${ee}x`}))});let O=u(d.createEl("button",{cls:"ai3d-inline-btn is-hidden",attr:{"aria-label":$("helper.toggleAnimationLabel")}}));O.appendChild($i('')),O.addEventListener("click",()=>{let j=i();if(!(j!=null&&j.toggleAnimation))return;let ee=j.toggleAnimation();O.replaceChildren($i(ee?'':'')),$t(O,ee?$("helper.playing"):$("helper.paused"))});let U=d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.removePreviewLabel")}});U.appendChild($i('')),U.addEventListener("click",n);let k=d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.copySnapshotLabel")}});k.appendChild($i('')),k.addEventListener("click",()=>{let j=i();if(j)try{let ee=j.captureSnapshot();if(!ee)return;let be=LG(ee);navigator.clipboard.write([new ClipboardItem({"image/png":be})]).then(()=>{$t(k,$("helper.copied"))}).catch(()=>{$t(k,$("helper.failed"))})}catch(ee){console.error("[AI3D] Copy snapshot failed:",ee),$t(k,$("helper.failed"))}});let z=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.saveSnapshotLabel")}}));z.appendChild($i('')),z.addEventListener("click",()=>{var ee,be;let j=i();if(j)try{let _e=j.captureSnapshot();if(!_e)return;let pe=r(),te=zr(pe)||"model",le=a==null?void 0:a(),xe=(ee=le==null?void 0:le.snapshotFolder)!=null?ee:"Media/3D Previews",ce=(be=le==null?void 0:le.snapshotNaming)!=null?be:"model-name",de=Date.now(),ke=ce==="timestamp"?`snapshot_${de}.png`:`${te}_snapshot_${de}.png`,Ze=LG(_e),Fe=new FileReader;Fe.onload=()=>{let Xe=Fe.result;t.vault.adapter.exists(xe).then(St=>St?Promise.resolve():t.vault.createFolder(xe).catch(()=>{})).then(()=>t.vault.createBinary(`${xe}/${ke}`,Xe)).then(()=>{$t(z,$("helper.saved"))}).catch(St=>{console.error("[AI3D] Save snapshot failed:",St),$t(z,$("helper.failed"))})},Fe.onerror=()=>{console.error("[AI3D] FileReader error"),$t(z,$("helper.failed"))},Fe.onabort=()=>{console.error("[AI3D] FileReader aborted"),$t(z,$("helper.failed"))},Fe.readAsArrayBuffer(Ze)}catch(_e){console.error("[AI3D] Save snapshot failed:",_e),$t(z,$("helper.failed"))}});let Z=u(d.createEl("button",{cls:"ai3d-inline-btn",attr:{"aria-label":$("helper.downloadSnapshotLabel")}}));Z.appendChild($i('')),Z.addEventListener("click",()=>{let j=i();if(j)try{let ee=j.captureSnapshot();if(!ee)return;let be=r(),pe=`${zr(be)||"model"}_snapshot_${Date.now()}.png`,te=activeDocument.createElement("a");te.href=ee,te.download=pe,activeDocument.body.appendChild(te),te.click(),te.remove(),$t(Z,$("helper.downloaded"))}catch(ee){console.error("[AI3D] Download snapshot failed:",ee),$t(Z,$("helper.failed"))}});let J=u(d.createEl("button",{cls:"ai3d-inline-btn is-hidden ai3d-annot-btn",attr:{"aria-label":$(h.labelKey)}}));J.appendChild($i(''));let q=J.createSpan({cls:"ai3d-pin-badge is-hidden"});J.addEventListener("click",()=>{if(!o)return;let j=o();J.classList.toggle("ai3d-btn-active",j),$t(J,j?$(h.activeTooltipKey):$(h.inactiveTooltipKey))});let Y=f?d.createEl("button",{cls:"ai3d-inline-btn ai3d-mobile-more-toggle",attr:{"aria-label":$("helper.showMoreActionsLabel")}}):null;return Y==null||Y.appendChild($i('')),Y==null||Y.addEventListener("click",()=>{p=!p,Y.setAttribute("aria-label",p?$("helper.hideMoreActionsLabel"):$("helper.showMoreActionsLabel")),v(),$t(Y,p?$("helper.moreActionsShown"):$("helper.moreActionsHidden"))}),s.insertBefore(d,e.nextSibling),v(),{showAnimButton(){O.classList.remove("is-hidden")},showAnnotateButton(){J.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&&I(j)}}}function $t(s,e){var r;(r=dx.get(s))==null||r.remove();let t=s.parentElement;if(!t)return;let i=t.createDiv({cls:"ai3d-tooltip"});i.textContent=e,dx.set(s,i),activeWindow.setTimeout(()=>{i.remove(),dx.delete(s)},1500)}var dx,ux=C(()=>{"use strict";gs();us();Ia();dx=new WeakMap});function Ml(s){let e=s.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"}),n="loading.default",a="",o=()=>{r.textContent=n?$(n):a};o();let c=e.createDiv({cls:"ai3d-loading-bar-track"}).createDiv({cls:"ai3d-loading-bar-fill is-indeterminate"}),f=!1,h=rG(()=>{!f&&n&&o()});return{el:e,setPhase(d){n=null,a=d,f||o()},setPhaseKey(d){n=d,f||o()},setProgress(d){f||(d<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,d))}%`)))},hide(){f||(f=!0,h(),e.classList.add("is-hiding"),activeWindow.setTimeout(()=>e.remove(),300))}}}var U_=C(()=>{"use strict";gs()});function JK(s){return s.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}function wG(s,e=[]){let t=[s,...e,...s.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 wf,H_,BG=C(()=>{"use strict";Xu();vr();lm();cm();Ee();Je();$l();Rn();An();Jh();Jh();NR();us();wf=32;H_=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 ve(e,!0,{preserveDrawingBuffer:!0}),this.scene=new nt(this.engine),this.scene.clearColor=new Me(.12,.12,.14,1),this.scene.autoClear=!1,new Br("default-light",new S(0,1,.5),this.scene),this.resizeObs=new ResizeObserver(()=>this.engine.resize()),this.resizeObs.observe(e),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 h,d,u;await Qh();let r=e.length>wf?(console.warn(`[AI3D Grid] Capping ${e.length} models to ${wf} (layerMask limit)`),e.slice(0,wf)):e,n=(h=t.columns)!=null?h:Math.min(r.length,3),a=(d=t.gapX)!=null?d:.02,o=(u=t.gapY)!=null?u:.02,l=Math.ceil(r.length/n),c=(1-a*(n+1))/n,f=(1-o*(l+1))/l;for(let m=0;mwf?(console.warn(`[AI3D Preset] Capping ${e.placements.length} placements to ${wf} (layerMask limit)`),e.placements.slice(0,wf)):e.placements,r=[];for(let c=0;cc.length>0).map(c=>c[0]),a=S.Zero(),o=1;if(n.length>0){let c=new S(1/0,1/0,1/0),f=new S(-1/0,-1/0,-1/0);for(let d of n){d.computeWorldMatrix(!0);let u=d.getHierarchyBoundingVectors();c=S.Minimize(c,u.min),f=S.Maximize(f,u.max)}let h=f.subtract(c);a=c.add(h.scale(.5)),o=h.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 h,d;if(l){h=[],d=0;for(let m=0;m0&&(h.push(...r[m]),d|=1<_!==c),d=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=ii()?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 gx(s,e){return s.map((t,i)=>{let r=2*Math.PI*i/s.length;return{path:t.path,position:[Math.cos(r)*e,0,Math.sin(r)*e],color:t.color,wireframe:t.wireframe}})}var px,yl=C(()=>{"use strict";px={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 UG,VG=C(()=>{"use strict";yl();UG={name:"compare",description:"Side-by-side model comparison (2-4 models)",minModels:2,maxModels:4,compute(s,e){if(s.length<2||s.length>4)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=gd(s,t),n=s.length<=3?s.length:2,a=Math.ceil(s.length/n),o=Dn(n,a),l=s.map((c,f)=>({modelIndex:f,camera:Vs(i),viewport:o[f]}));return{placements:r,cells:l}}}});var GG,kG=C(()=>{"use strict";yl();GG={name:"showcase",description:"Single model viewed from multiple angles",minModels:1,maxModels:1,compute(s,e){if(s.length<1)return null;let t=Number(e.angles)||4,i=Number(e.radius)||2.5,r=[{path:s[0].path,position:[0,0,0],color:s[0].color,wireframe:s[0].wireframe}],n=t>=6?["front","side","top","back","iso","3/4"]:["iso","front","side","top"],a=n.length<=4?2:3,o=Math.ceil(n.length/a),l=Dn(a,o),c=n.map((f,h)=>({modelIndex:0,camera:Vs(f,void 0,i),viewport:l[h]}));return{placements:r,cells:c}}}});var WG,HG=C(()=>{"use strict";yl();WG={name:"explode",description:"Spatial arrangement of parts (3-8 models in a ring)",minModels:3,maxModels:8,compute(s,e){if(s.length<3||s.length>8)return null;let t=Number(e.radius)||8,i=e.angle||"iso",r=gx(s,t),n=Math.min(s.length,4),a=Math.ceil(s.length/n),o=Dn(n,a),l=s.map((c,f)=>({modelIndex:f,camera:Vs(i),viewport:o[f]}));return{placements:r,cells:l}}}});var zG,XG=C(()=>{"use strict";yl();zG={name:"timeline",description:"Horizontal progression of models (2-6 models in a strip)",minModels:2,maxModels:6,compute(s,e){if(s.length<2||s.length>6)return null;let t=Number(e.spacing)||6,i=e.angle||"3/4",r=gd(s,t),n=_x(s.length),a=s.map((o,l)=>({modelIndex:l,camera:Vs(i),viewport:n[l]}));return{placements:r,cells:a}}}});function Ex(s,e,t,i,r){var f,h;if(!s||s.length===0)return null;let n=s.reduce((d,u)=>{var m;return d+((m=u.weight)!=null?m:1)},0);if(n<=0)return null;let a=[],o=0;for(let d of s){let m=((f=d.weight)!=null?f:1)/n*(1-t*(s.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 d=0;d{"use strict";YG={name:"compose",description:"Combine multiple presets into one layout",minModels:1,maxModels:32,compute(s,e,t){return null}}});var KG,jG=C(()=>{"use strict";yl();KG={name:"gallery",description:"All models in one scene, single camera (no cell limit)",minModels:1,maxModels:32,compute(s,e){if(s.length===0)return null;let t=Number(e.spacing)||6,i=e.angle||"iso",r=Number(e.cols)||0,n=r>0?r:Math.ceil(Math.sqrt(s.length)),a=Math.ceil(s.length/n),o=s.map((f,h)=>{let d=h%n,u=Math.floor(h/n),m=(d-(n-1)/2)*t,p=(u-(a-1)/2)*t;return{path:f.path,position:[m,0,p],color:f.color,wireframe:f.wireframe}}),l=Dn(1,1,0),c=[{modelIndex:0,camera:Vs(i,void 0,3+Math.max(n,a)*.5),viewport:l[0]}];return{placements:o,cells:c}}}});function Bf(s){ZG.set(s.name,s)}function Sx(s){return ZG.get(s)}var ZG,qG=C(()=>{"use strict";VG();kG();HG();XG();vx();jG();yl();vx();ZG=new Map;Bf(UG);Bf(GG);Bf(WG);Bf(zG);Bf(YG);Bf(KG)});var $G={};Ie($G,{registerCodeBlockProcessor:()=>t9,registerGridCodeBlockProcessor:()=>r9});async function QG(s,e,t,i){var h,d,u;let r=typeof e=="string"?{path:e}:e,n=yf(s,r.path);if(!n)throw new Error(ri("workbench.fileNotFound",{path:r.path}));let a=(d=(h=n.split(".").pop())==null?void 0:h.toLowerCase())!=null?d:"";if(!Nn(a))throw new Error(ri("codeBlock.unsupportedFormat",{ext:`.${a}`,formats:Ho().join(", ")}));let o=(u=xa(s,n))!=null?u:void 0,l=Da(t),c=await Ma({path:n,absolutePath:o,preferConversionExts:Pa(t),conversionManager:l,convertedAssetCache:i}),f=bl(c);return{sourcePath:n,effectivePath:f.path,effectiveExt:f.ext,warnings:f.warnings,model:{...r,path:f.path}}}async function e9(s,e,t,i){let r=[];for(let n of e.models){let a=await QG(s,n,t,i);r.push(a.model)}return{...e,models:r}}function JG(s){ii()&&s.createDiv({cls:"ai3d-mobile-mode-hint ai3d-mobile-mode-hint--inline",text:$("codeBlock.mobileHint")})}function t9(s,e,t,i){return{id:"3d",handler:(r,n,a)=>{var D,M;let o=r.trim();if(!o){n.createDiv({cls:"ai3d-inline-empty",text:$("codeBlock.noModelPathOrConfig")});return}let l;if(o.startsWith("{")||o.startsWith("["))try{let F=JSON.parse(o);l=i9(F)}catch(F){let N=n.createDiv({cls:"ai3d-json-error"}),V=String(F).match(/position\s+(\d+)/),O=ri("codeBlock.jsonParseError",{error:String(F)});if(V){let U=parseInt(V[1],10),k=o.substring(0,U).split(` +`);O+=ri("codeBlock.jsonParseLine",{line:String(k.length)})}N.createEl("pre",{text:O});return}else l={models:[{path:o}]};if(!l.models||l.models.length===0){n.createDiv({cls:"ai3d-inline-empty",text:$("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],h=yf(s,f.path);if(!h){n.createDiv({cls:"ai3d-inline-empty",text:ri("workbench.fileNotFound",{path:f.path})});return}let d=(M=(D=h.split(".").pop())==null?void 0:D.toLowerCase())!=null?M:"";if(!Nn(d)){n.createDiv({cls:"ai3d-inline-empty",text:ri("codeBlock.unsupportedFormat",{ext:`.${d}`,formats:Ho().join(", ")})});return}let u=e(),m=n.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",F=>{var V,O,U,k,z;if(I||!_)return;let N=F.key.toLowerCase();N==="r"?((V=_.resetView)==null||V.call(_),F.preventDefault()):N==="w"?((O=_.toggleWireframe)==null||O.call(_),F.preventDefault()):N==="g"?((U=_.toggleOrientationGizmo)==null||U.call(_),F.preventDefault()):N==="b"?((k=_.toggleBoundingBox)==null||k.call(_),F.preventDefault()):N===" "&&((z=_.toggleAnimation)==null||z.call(_),F.preventDefault())}),m.appendChild(p);let _=null,g=null,v=!0,I=!1,x=!1,T=_d(n,m,s,()=>_,()=>h,()=>{I||(I=!0,A.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null,m.remove())},e,()=>{if(v=!v,g){let F=m.querySelector(".ai3d-annotation-overlay");F&&F.classList.toggle("is-hidden",!v)}return v},void 0,{labelKey:"helper.toggleAnnotationsVisibilityLabel",activeTooltipKey:"helper.annotationsVisible",inactiveTooltipKey:"helper.annotationsHidden"});JG(n);let A=new MutationObserver(()=>{I||n.contains(m)||(I=!0,A.disconnect(),P.disconnect(),g==null||g.destroy(),g=null,_==null||_.destroy(),_=null)});A.observe(n,{childList:!0});async function R(){var N,V;if(x||I||!h)return;x=!0;let F=Ml(m);try{let O=(N=xa(s,h))!=null?N:void 0,U=Da(u);F.setPhaseKey("loading.preparingModel");let k=await Ma({path:h,absolutePath:O,preferConversionExts:Pa(u),conversionManager:U,convertedAssetCache:t}),z=bl(k);_=new Ca(p),F.setPhaseKey("loading.loadingModel");let Z=await Xr(s,z.path),J=async q=>Xr(s,q);if(I){F.hide();return}if(await _.loadModel(Z,z.ext,J,z.path),F.setProgress(100),I){F.hide();return}if(((V=l.scene)==null?void 0:V.autoRotate)===void 0&&u.autoRotateDefault&&(l.scene={...l.scene,autoRotate:!0,autoRotateSpeed:u.autoRotateSpeed}),_.applyConfig(l),_.setRenderQuality(u.renderQuality,u.renderScale),i&&h){let q=i(h);if(q.length>0){let Y=_.getCanvas();Y&&(g=new yn({scene:_.getScene(),camera:_.getCamera(),engine:_.getEngine(),canvas:Y},m,"readonly",q,void 0,Bo(s),void 0,{app:s,previewMode:u.annotationPreviewMode}),T.showAnnotateButton(),T.updateAnnotationBadge(q.length))}}d==="stl"&&f.color&&_.setSTLColor(f.color),d==="stl"&&f.wireframe!==void 0&&_.setWireframe(f.wireframe),_.hasAnimations()&&T.showAnimButton(),F.hide()}catch(O){I=!0,A.disconnect(),P.disconnect(),F.hide(),_==null||_.destroy(),_=null,m.replaceChildren();let U=Fo(O);No(O)?console.warn("[AI3D] Inline preview blocked by converter settings:",U.message):console.error("[AI3D] Inline preview failed:",O),Uo(m,U)}}let P=new IntersectionObserver(F=>{for(let N of F)N.isIntersecting&&(P.disconnect(),R())},{rootMargin:"200px"});P.observe(m)}}}function i9(s){if(typeof s=="string")return{models:[{path:s}]};if(typeof s!="object"||s===null)return{models:[]};let e=s;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 r9(s,e,t){return{id:"3dgrid",handler:(i,r,n)=>{let a=i.trim();if(!a){r.createDiv({cls:"ai3d-inline-empty",text:$("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:$("codeBlock.noModelsSpecified")});return}let l=e(),c=Ml(r);(async()=>{var T,A,R,P;let f=[];for(let D of(T=o.models)!=null?T:[])try{let M=await QG(s,D,l,t);f.push(M)}catch(M){c.hide(),r.createDiv({cls:"ai3d-inline-empty",text:M instanceof Error?M.message:String(M)});return}let h=f.map(D=>D.model),d=(R=(A=f[0])==null?void 0:A.sourcePath)!=null?R:"",u=r.createDiv({cls:"ai3d-grid-host"}),m=u.createEl("canvas");if(m.tabIndex=0,m.addEventListener("keydown",D=>{var F,N;if(_||!p)return;let M=D.key.toLowerCase();M==="r"?((F=p.resetView)==null||F.call(p),D.preventDefault()):M==="w"&&((N=p.toggleWireframe)==null||N.call(p),D.preventDefault())}),u.appendChild(m),typeof o.rowHeight=="number"){let D=o.preset==="compose"?1:Math.ceil(h.length/((P=o.columns)!=null?P:Math.min(h.length,3)));u.style.setProperty("--grid-height",`${o.rowHeight*D}px`)}let p=null,_=!1,g=!1;_d(r,u,s,()=>p,()=>d,()=>{_||(_=!0,v.disconnect(),x.disconnect(),p==null||p.destroy(),p=null,u.remove())},e),JG(r);let v=new MutationObserver(()=>{_||r.contains(u)||(_=!0,v.disconnect(),x.disconnect(),p==null||p.destroy(),p=null)});v.observe(r,{childList:!0});async function I(){var D,M,F,N;if(!(g||_)){g=!0,c.setPhaseKey("codeBlock.renderingGrid"),c.setProgress(-1);try{p=new H_(m);let V=p,O=async U=>Xr(s,U);if(o.preset==="compose"){if(!o.sections||o.sections.length===0){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:$("codeBlock.composeRequiresSections")}),p.destroy(),p=null;return}let U=[];for(let z of o.sections)try{if(!d){let J=z.models[0];if(J){let q=typeof J=="string"?J:J.path;d=(D=yf(s,q))!=null?D:q}}let Z=await e9(s,z,l,t);U.push(Z)}catch(Z){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:Z instanceof Error?Z.message:String(Z)}),V.destroy(),p=null;return}let k=Ex(U,(M=o.direction)!=null?M:"horizontal",Number((F=o.params)==null?void 0:F.gap)||.02,z=>typeof z=="string"?null:z,Sx);if(!k){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:$("codeBlock.composeNoValidSections")}),V.destroy(),p=null;return}await V.loadWithPreset(k,O)}else if(o.preset){let U=Sx(o.preset);if(!U){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:ri("codeBlock.unknownPreset",{preset:o.preset})}),V.destroy(),p=null;return}let k=U.compute(h,(N=o.params)!=null?N:{});if(!k){c.hide(),u.createDiv({cls:"ai3d-inline-empty",text:ri("codeBlock.presetRequiresModels",{preset:o.preset,min:String(U.minModels),max:String(U.maxModels),count:String(h.length)})}),V.destroy(),p=null;return}await V.loadWithPreset(k,O)}else await V.loadModels(h,o,O);if(_){c.hide();return}c.hide()}catch(V){_=!0,v.disconnect(),x.disconnect(),c.hide(),p==null||p.destroy(),p=null,console.error("[AI3D Grid] Failed:",V),u.createDiv({cls:"ai3d-inline-empty",text:ri("codeBlock.gridFailed",{reason:String(V)})})}}}let x=new IntersectionObserver(D=>{for(let M of D)M.isIntersecting&&(x.disconnect(),I())},{rootMargin:"200px"});x.observe(u)})()}}}var ek=C(()=>{"use strict";Fn();rd();BG();ad();Ia();qG();ux();fd();ld();F_();hd();U_();Of();Cl();gs();ud();us()});function Ed(s){return activeDocument.createElement("div").createDiv(s?{cls:s}:void 0)}function Tx(s,e){return activeDocument.createElement("div").createEl(s,e?{cls:e}:void 0)}var tk=C(()=>{"use strict"});var sk={};Ie(sk,{registerLivePreviewExtension:()=>s9});function ik(s,e,t,i,r,n,a,o,l,c,f,h,d){var p,_;let u="state"in s?s.state.doc:s.doc,m=[];for(let g=1;g<=u.lines;g++){let v=u.line(g),I=v.text;if(!I.includes("!["))continue;let x=0;for(;x0&&I[T-1]==="\\"){x=T+3;continue}let A=I.indexOf("]]",T+3);if(A===-1)break;let P=I.slice(T+3,A).split("|"),D=P[0].trim(),M=(_=(p=D.split(".").pop())==null?void 0:p.toLowerCase())!=null?_:"";if(!Nn(M)){x=A+2;continue}let F=400,N=300;if(P.length>1){let U=P[1].trim().match(/^(\d+)\s*x\s*(\d+)$/);U&&(F=parseInt(U[1],10),N=parseInt(U[2],10))}let V=yf(e,D);if(!V){x=A+2;continue}let O=v.from+T;m.push(Uf.Decoration.widget({widget:new Ax(e,V,F,N,t,i,r,n,a,o,l,c,f,h,d),block:!0,side:1}).range(O)),x=A+2}}return m}function rk(s){return s.length===0?vd.RangeSet.empty:vd.RangeSet.of(s,!0)}function s9(s,e,t,i){return[vd.StateField.define({create(n){let a=e(),o=ik(n,s,a.autoRotateDefault,a.enabledConverterIds,a.freecadCommand,a.obj2gltfCommand,a.fbx2gltfCommand,a.freecadcmdCommand,a.preferObj2gltfForObj,a.preferFbx2gltfForFbx,a.annotationPreviewMode,t,i);return rk(o)},update(n,a){if(a.docChanged){let o=e(),l=ik(a.state,s,o.autoRotateDefault,o.enabledConverterIds,o.freecadCommand,o.obj2gltfCommand,o.fbx2gltfCommand,o.freecadcmdCommand,o.preferObj2gltfForObj,o.preferFbx2gltfForFbx,o.annotationPreviewMode,t,i);return rk(l)}return n.map(a.changes)},provide:n=>Uf.EditorView.decorations.from(n)})]}var Uf,vd,Ax,nk=C(()=>{"use strict";Uf=require("@codemirror/view"),vd=require("@codemirror/state");Fn();ad();Ia();fd();ld();hd();U_();Of();tk();Cl();us();ud();gs();Ax=class extends Uf.WidgetType{constructor(t,i,r,n,a,o,l,c,f,h,d,u,m,p,_){super();this.app=t;this.modelPath=i;this.width=r;this.height=n;this.autoRotate=a;this.enabledConverterIds=o;this.freecadCommand=l;this.obj2gltfCommand=c;this.fbx2gltfCommand=f;this.freecadcmdCommand=h;this.preferObj2gltfForObj=d;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=ii(),i=Ed("ai3d-embed-preview");t&&i.classList.add("is-mobile","is-mobile-scroll-mode");let r=Tx("canvas","ai3d-embed-canvas"),n=t?Math.min(this.height,220):this.height;r.style.setProperty("--ai3d-embed-height",`${n}px`),i.appendChild(r);let a=Ml(i),o=Ed("ai3d-embed-error is-hidden");if(i.appendChild(o),t){let f=!1,h=Ed("ai3d-mobile-mode-bar"),d=Ed("ai3d-mobile-mode-hint");d.textContent=$("livePreview.mobileHint");let u=Tx("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?$("helper.scrollAction"):$("helper.interactAction"),u.classList.toggle("ai3d-btn-active",f),u.setAttribute("aria-label",f?$("helper.disableInteractionLabel"):$("helper.enableInteractionLabel"))};u.addEventListener("click",()=>{f=!f,m()}),m(),h.append(d,u),i.appendChild(h)}let l=0,c=()=>{if(!this.mounted){if(i.isConnected){this.mounted=!0,this.initPreview(i,r,a,o);return}++l>120||(this.pollId=requestAnimationFrame(c))}};return this.pollId=requestAnimationFrame(c),i}async initPreview(t,i,r,n){var a,o;try{let{BabylonModelPreview:l}=await Promise.resolve().then(()=>(rd(),JV));this.preview=new l(i);let c=(a=xa(this.app,this.modelPath))!=null?a:void 0,f=Da({enabledConverterIds:this.enabledConverterIds,freecadCommand:this.freecadCommand,obj2gltfCommand:this.obj2gltfCommand,fbx2gltfCommand:this.fbx2gltfCommand,freecadcmdCommand:this.freecadcmdCommand});r.setPhaseKey("loading.preparingModel");let h=await Ma({path:this.modelPath,absolutePath:c,preferConversionExts:Pa({preferObj2gltfForObj:this.preferObj2gltfForObj,preferFbx2gltfForFbx:this.preferFbx2gltfForFbx}),conversionManager:f,convertedAssetCache:this.convertedAssetCache});r.setPhaseKey("loading.loadingModel");let d=await Xr(this.app,h.effectivePath);if(await this.preview.loadModel(d,h.effectiveExt,u=>Xr(this.app,u),h.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 yn({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:m},t,"readonly",u,void 0,Bo(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(),n.remove(),t.replaceChildren();let c=Fo(l);No(l)?console.warn("[AI3D] Live Preview blocked by converter settings:",c.message):console.error("[AI3D] Live Preview failed:",l),Uo(t,c)}}destroy(){var t;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 n9={};Ie(n9,{default:()=>z_});module.exports=fk(n9);var Dl=require("obsidian");K_();Fn();Fn();var f9=new Set(Ho());var zo={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:["freecad","sldprt"],freecadCommand:"",obj2gltfCommand:"",fbx2gltfCommand:"",assimpCommand:"",freecadcmdCommand:"",preferObj2gltfForObj:!1,preferFbx2gltfForFbx:!1,logLevel:"warn",locale:"en"};function Cx(s){let e={...s},t=new Set;return{getState:()=>e,setState(i){e={...e,...i};let r=[...t];for(let n of r)n()},subscribe(i){return t.add(i),()=>{t.delete(i)}}}}var mk={settings:{...zo},currentModelPath:null,convertedAssetRecords:[],modelAssetProfiles:{},agentDraft:"",agentPlan:null,modelPreview:null};function bx(s){let e=Cx(mk),t=null;function i(){t&&activeWindow.clearTimeout(t),t=activeWindow.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 s.saveData(o)}e.subscribe(()=>i());let n=!1;return{store:e,get localeLoadedFromSaved(){return n},async load(){var o,l,c,f,h,d;let a=await s.loadData();a&&(n=!!((o=a.settings)!=null&&o.locale),e.setState({settings:{...zo,...(l=a.settings)!=null?l:{}},convertedAssetRecords:(c=a.convertedAssetRecords)!=null?c:[],modelAssetProfiles:(f=a.modelAssetProfiles)!=null?f:{},agentDraft:(h=a.agentDraft)!=null?h:"",agentPlan:(d=a.agentPlan)!=null?d:null}))},async save(){t&&(activeWindow.clearTimeout(t),t=null),await r()},dispose(){t&&(activeWindow.clearTimeout(t),t=null)}}}var PG=require("obsidian");hx();var pd="ai-3d-workbench",B_=class extends PG.FileView{constructor(t,i,r){super(t);this.unmount=null;this.store=i,this.convertedAssetCache=r}getViewType(){return pd}getDisplayText(){return"AI 3d workbench"}getIcon(){return"box"}onOpen(){return this.unmount=fx(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 NG=require("obsidian");rd();ad();ux();fd();ld();F_();Ia();hd();Of();U_();Cl();gs();ud();us();var G_="ai3d-direct-view";function qK(){return{tags:[],notes:"",annotations:[],createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}var V_=class extends NG.FileView{constructor(t,i,r,n){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=n}getViewType(){return G_}getDisplayText(){var t,i;return(i=(t=this.file)==null?void 0:t.name)!=null?i:$("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 d,u,m,p,_;let i=++this.loadGeneration,r=ii();(d=this.annotationMgr)==null||d.destroy(),this.annotationMgr=null,this.annotationMode=!1,(u=this.preview)==null||u.destroy(),this.preview=null;let n=activeDocument.createElement("div"),a=n.createDiv({cls:"ai3d-preview-host"}),o=n.createEl("canvas");o.className="ai3d-canvas-full",a.appendChild(o);let l=n.createDiv();l.className="ai3d-annot-mode-overlay is-hidden",a.appendChild(l),this.contentEl.appendChild(a);let c=null,f=g=>{var v;this.annotationMode=g,r&&g&&(c==null||c.setMobileInteractionMode(!0)),(v=this.annotationMgr)==null||v.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=_d(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:$("directView.mobileHint")});let h=Ml(a);try{let g=this.getSettings(),v=Da(g),I=(m=xa(this.app,t.path))!=null?m:void 0;h.setPhaseKey("loading.preparingModel");let x=await Ma({path:t.path,absolutePath:I,preferConversionExts:Pa(g),conversionManager:v,convertedAssetCache:this.convertedAssetCache});if(i!==this.loadGeneration)return;let T=bl(x);this.preview=new Ca(o),h.setPhaseKey("loading.loadingModel");let A=await Xr(this.app,T.path);if(i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loading: ${t.path} via ${T.path} (${T.ext}, ${A.byteLength} bytes)`);let R=async D=>Xr(this.app,D);if(await this.preview.loadModel(A,T.ext,R,T.path),i!==this.loadGeneration){this.preview.destroy(),this.preview=null;return}console.debug(`[AI3D] DirectView loaded successfully: ${t.path}`),h.setProgress(100);let P=this.preview.getCanvas();if(P){let D=this.ps.store.getState().modelAssetProfiles[t.path],M=(p=D==null?void 0:D.annotations)!=null?p:[],F=Bo(this.app),N=w_(this.app);this.annotationMgr=new yn({scene:this.preview.getScene(),camera:this.preview.getCamera(),engine:this.preview.getEngine(),canvas:P},a,"edit",M,V=>{var k;let O=this.ps.store.getState().modelAssetProfiles,U=(k=O[t.path])!=null?k:qK();this.ps.store.setState({modelAssetProfiles:{...O,[t.path]:{...U,annotations:V,updatedAt:new Date().toISOString()}}}),c.updateAnnotationBadge(V.length)},F,N,{app:this.app,previewMode:this.getSettings().annotationPreviewMode}),c.showAnnotateButton(),c.updateAnnotationBadge(M.length),this.preview.onPick(V=>{if(!this.annotationMode||!this.annotationMgr)return;let O=V.screenX,U=V.screenY,k=null;V.pickedPoint?k=V.pickedPoint:V.mesh&&(k=V.mesh.getBoundingInfo().boundingBox.centerWorld.clone(),console.debug("[AI3D] Annotation: pickedPoint null, using bbox center fallback")),k&&(console.debug("[AI3D] Annotation: creating pin at",k.toString(),"screen:",O,U),this.annotationMgr.showEditor(O,U,k))})}h.hide()}catch(g){if(i!==this.loadGeneration)return;h.hide(),(_=this.preview)==null||_.destroy(),this.preview=null,a.replaceChildren();let v=Fo(g);No(g)?console.warn("[AI3D] Direct view blocked by converter settings:",v.message):console.error("[AI3D] Direct view failed:",g),Uo(a,v)}}};var FG=require("obsidian");Fn();gs();var k_=class extends FG.FuzzySuggestModal{constructor(e,t){super(e),this.onChoose=t,this.setPlaceholder($("modal.selectModel"))}getItems(){return this.app.vault.getFiles().filter(e=>{let t=e.extension.toLowerCase();return Nn(t)})}getItemText(e){return e.path}onChooseItem(e){this.onChoose(e)}};var xt=require("obsidian");wo();gs();us();zt();var mx=p_();function QK(){switch(mx==null?void 0:mx.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 W_=class extends xt.PluginSettingTab{constructor(t,i){super(t,i);this.diagnosticsRunId=0;this.plugin=i}display(){let{containerEl:t}=this;t.empty(),sd(this.plugin.getSettings().locale);let i,r=QK(),n=ii();if(new xt.Setting(t).setName($("settings.title")).setHeading(),new xt.Setting(t).setName($("settings.language")).setDesc($("settings.language.desc")).addDropdown(a=>a.addOption("en","English").addOption("zh-CN","\u7B80\u4F53\u4E2D\u6587").setValue(this.plugin.getSettings().locale).onChange(o=>{this.plugin.updateSettings({locale:o}),this.display()})),new xt.Setting(t).setName($("settings.folders")).setHeading(),new xt.Setting(t).setName($("settings.sourceModelFolder")).setDesc($("settings.sourceModelFolder.desc")).addText(a=>a.setPlaceholder(zo.sourceModelFolder).setValue(this.plugin.getSettings().sourceModelFolder).onChange(o=>{this.plugin.updateSettings({sourceModelFolder:o})})),new xt.Setting(t).setName($("settings.reportFolder")).setDesc($("settings.reportFolder.desc")).addText(a=>a.setPlaceholder(zo.reportFolder).setValue(this.plugin.getSettings().reportFolder).onChange(o=>{this.plugin.updateSettings({reportFolder:o})})),new xt.Setting(t).setName($("settings.snapshotFolder")).setDesc($("settings.snapshotFolder.desc")).addText(a=>a.setPlaceholder(zo.snapshotFolder).setValue(this.plugin.getSettings().snapshotFolder).onChange(o=>{this.plugin.updateSettings({snapshotFolder:o})})),new xt.Setting(t).setName($("settings.behavior")).setHeading(),new xt.Setting(t).setName($("settings.autoGenerateKnowledgeNotes")).setDesc($("settings.autoGenerateKnowledgeNotes.desc")).addToggle(a=>a.setValue(this.plugin.getSettings().autoGenerateKnowledgeNotes).onChange(o=>{this.plugin.updateSettings({autoGenerateKnowledgeNotes:o})})),new xt.Setting(t).setName($("settings.annotationPreviewMode")).setDesc($("settings.annotationPreviewMode.desc")).addDropdown(a=>a.addOption("plain-text",$("settings.annotationPreviewMode.plainText")).addOption("markdown",$("settings.annotationPreviewMode.markdown")).setValue(this.plugin.getSettings().annotationPreviewMode).onChange(o=>{this.plugin.updateSettings({annotationPreviewMode:o})})),new xt.Setting(t).setName($("settings.autoRotateDefault")).setDesc($("settings.autoRotateDefault.desc")).addToggle(a=>a.setValue(this.plugin.getSettings().autoRotateDefault).onChange(o=>{this.plugin.updateSettings({autoRotateDefault:o})})),new xt.Setting(t).setName($("settings.snapshotNaming")).setDesc($("settings.snapshotNaming.desc")).addDropdown(a=>a.addOption("model-name",$("settings.snapshotNaming.modelName")).addOption("timestamp",$("settings.snapshotNaming.timestamp")).setValue(this.plugin.getSettings().snapshotNaming).onChange(o=>{this.plugin.updateSettings({snapshotNaming:o})})),new xt.Setting(t).setName($("settings.logLevel")).setDesc($("settings.logLevel.desc")).addDropdown(a=>a.addOption("debug","Debug").addOption("info","Info").addOption("warn","Warn").addOption("error","Error").setValue(this.plugin.getSettings().logLevel).onChange(o=>{this.plugin.updateSettings({logLevel:o})})),new xt.Setting(t).setName($("settings.converters")).setHeading(),n)t.createEl("p",{cls:"setting-item-description",text:$("settings.mobileSupport.desc")});else{new xt.Setting(t).setName($("settings.enableCad")).setDesc($("settings.enableCad.desc")).addToggle(l=>{let c=this.plugin.getSettings().enabledConverterIds.includes("freecad");return l.setValue(c).onChange(f=>{let h=this.plugin.getSettings().enabledConverterIds,d=f?Array.from(new Set([...h,"freecad"])):h.filter(u=>u!=="freecad");this.plugin.updateSettings({enabledConverterIds:d})})}),new xt.Setting(t).setName($("settings.enableObj2gltf")).setDesc($("settings.enableObj2gltf.desc")).addToggle(l=>{let c=this.plugin.getSettings().enabledConverterIds.includes("obj2gltf");return l.setValue(c).onChange(f=>{let h=this.plugin.getSettings().enabledConverterIds,d=f?Array.from(new Set([...h,"obj2gltf"])):h.filter(u=>u!=="obj2gltf");this.plugin.updateSettings({enabledConverterIds:d})})}),new xt.Setting(t).setName($("settings.preferObj2gltf")).setDesc($("settings.preferObj2gltf.desc")).addToggle(l=>l.setValue(this.plugin.getSettings().preferObj2gltfForObj).onChange(c=>{this.plugin.updateSettings({preferObj2gltfForObj:c})})),new xt.Setting(t).setName($("settings.enableFbx2gltf")).setDesc($("settings.enableFbx2gltf.desc")).addToggle(l=>{let c=this.plugin.getSettings().enabledConverterIds.includes("fbx2gltf");return l.setValue(c).onChange(f=>{let h=this.plugin.getSettings().enabledConverterIds,d=f?Array.from(new Set([...h,"fbx2gltf"])):h.filter(u=>u!=="fbx2gltf");this.plugin.updateSettings({enabledConverterIds:d})})}),new xt.Setting(t).setName($("settings.enableMesh")).setDesc($("settings.enableMesh.desc")).addToggle(l=>{let c=this.plugin.getSettings().enabledConverterIds.includes("assimp");return l.setValue(c).onChange(f=>{let h=this.plugin.getSettings().enabledConverterIds,d=f?Array.from(new Set([...h,"assimp"])):h.filter(u=>u!=="assimp");this.plugin.updateSettings({enabledConverterIds:d})})}),new xt.Setting(t).setName($("settings.enableSldprt")).setDesc($("settings.enableSldprt.desc")).addToggle(l=>{let c=this.plugin.getSettings().enabledConverterIds.includes("sldprt");return l.setValue(c).onChange(f=>{let h=this.plugin.getSettings().enabledConverterIds,d=f?Array.from(new Set([...h,"sldprt"])):h.filter(u=>u!=="sldprt");this.plugin.updateSettings({enabledConverterIds:d})})}),new xt.Setting(t).setName($("settings.paths")).setHeading(),new xt.Setting(t).setName($("settings.pythonCmd")).setDesc($("settings.pythonCmd.desc")).addText(l=>l.setPlaceholder(r.python).setValue(this.plugin.getSettings().freecadCommand).onChange(c=>{this.plugin.updateSettings({freecadCommand:c.trim()}),i==null||i()})),new xt.Setting(t).setName($("settings.freecadCmd")).setDesc($("settings.freecadCmd.desc")).addText(l=>l.setPlaceholder(r.freecad).setValue(this.plugin.getSettings().freecadcmdCommand).onChange(c=>{this.plugin.updateSettings({freecadcmdCommand:c.trim()}),i==null||i()})),new xt.Setting(t).setName($("settings.obj2gltfCmd")).setDesc($("settings.obj2gltfCmd.desc")).addText(l=>l.setPlaceholder(r.obj2gltf).setValue(this.plugin.getSettings().obj2gltfCommand).onChange(c=>{this.plugin.updateSettings({obj2gltfCommand:c.trim()}),i==null||i()})),new xt.Setting(t).setName($("settings.fbx2gltfCmd")).setDesc($("settings.fbx2gltfCmd.desc")).addText(l=>l.setPlaceholder(r.fbx2gltf).setValue(this.plugin.getSettings().fbx2gltfCommand).onChange(c=>{this.plugin.updateSettings({fbx2gltfCommand:c.trim()}),i==null||i()})),new xt.Setting(t).setName($("settings.assimpCmd")).setDesc($("settings.assimpCmd.desc")).addText(l=>l.setPlaceholder(r.python).setValue(this.plugin.getSettings().assimpCommand).onChange(c=>{this.plugin.updateSettings({assimpCommand:c.trim()}),i==null||i()})),new xt.Setting(t).setName($("settings.diagnostics")).setDesc($("settings.diagnostics.desc")).addButton(l=>l.setButtonText($("settings.diagnostics.checkNow")).onClick(async()=>{l.setDisabled(!0),l.setButtonText($("settings.diagnostics.checking")),await(i==null?void 0:i()),l.setButtonText($("settings.diagnostics.checkNow")),l.setDisabled(!1),new xt.Notice($("settings.diagnostics.refreshed"))}));let o=t.createDiv({cls:"ai3d-settings-diagnostics"});i=()=>this.renderCommandDiagnostics(o),i()}new xt.Setting(t).setName($("settings.performance")).setHeading(),new xt.Setting(t).setName($("settings.canvasHeight")).setDesc($("settings.canvasHeight.desc")).addSlider(a=>a.setLimits(200,800,25).setValue(this.plugin.getSettings().defaultCanvasHeight).setDynamicTooltip().onChange(o=>{this.plugin.updateSettings({defaultCanvasHeight:o})})),new xt.Setting(t).setName($("settings.autoRotateSpeed")).setDesc($("settings.autoRotateSpeed.desc")).addSlider(a=>a.setLimits(.1,2,.1).setValue(this.plugin.getSettings().autoRotateSpeed).setDynamicTooltip().onChange(o=>{this.plugin.updateSettings({autoRotateSpeed:o})})),new xt.Setting(t).setName($("settings.renderQuality")).setDesc($("settings.renderQuality.desc")).addDropdown(a=>a.addOption("low","Low").addOption("medium","Medium").addOption("high","High").setValue(this.plugin.getSettings().renderQuality).onChange(o=>{this.plugin.updateSettings({renderQuality:o})})),new xt.Setting(t).setName($("settings.renderScale")).setDesc($("settings.renderScale.desc")).addSlider(a=>a.setLimits(.25,2,.25).setValue(this.plugin.getSettings().renderScale).setDynamicTooltip().onChange(o=>{this.plugin.updateSettings({renderScale:o})}))}async renderCommandDiagnostics(t){let i=++this.diagnosticsRunId;t.empty(),t.createEl("p",{text:$("settings.diagnostics.checkingAvailability")});let r=await M_(this.plugin.getSettings());if(i===this.diagnosticsRunId){t.empty();for(let n of r)this.renderCommandStatus(t,n)}}renderCommandStatus(t,i){var a;let r=t.createDiv({cls:"ai3d-settings-status-block"});r.createEl("strong",{text:`${i.label}: ${i.available?$("settings.diagnostics.available"):$("settings.diagnostics.notFound")}`});let n=[`${$("settings.diagnostics.sourceLabel")}: ${b_(i.source)}`,`${$("settings.diagnostics.commandLabel")}: ${i.command}`,i.resolvedPath&&i.resolvedPath!==i.command?`${$("settings.diagnostics.resolvedPathLabel")}: ${i.resolvedPath}`:"",i.detail].filter(Boolean);for(let o of n)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 $("settings.diagnostics.cadPythonCheck");case"mesh-python":return $("settings.diagnostics.meshPythonCheck");case"freecadcmd-cli":return $("settings.diagnostics.freecadCmdCheck");case"obj2gltf-cli":return $("settings.diagnostics.obj2gltfCheck");case"fbx2gltf-cli":return $("settings.diagnostics.fbx2gltfCheck")}})(),n=i.ok?$("settings.diagnostics.selfCheckOk"):$("settings.diagnostics.selfCheckFailed");t.createDiv({text:`${$("settings.diagnostics.selfCheckLabel")}: ${r} - ${n}`}),i.detail&&t.createDiv({text:i.detail})}};wo();Yr();gs();Of();us();Ia();var z_=class extends Dl.Plugin{getSettings(){return this.ps.store.getState().settings}updateSettings(e){let i={...this.ps.store.getState().settings,...e};this.ps.store.setState({settings:i}),ex(i.logLevel),sd(i.locale)}async onload(){var l;if(this.ps=bx(this),await this.ps.load(),this.convertedAssetCache=xx(this.ps.store.getState().convertedAssetRecords,c=>this.ps.store.setState({convertedAssetRecords:c})),ex(this.getSettings().logLevel),!this.ps.localeLoadedFromSaved){let f=((l=navigator.language)!=null?l:"en").startsWith("zh")?"zh-CN":"en";this.updateSettings({locale:f})}sd(this.getSettings().locale),this.registerView(pd,c=>new B_(c,this.ps,this.convertedAssetCache)),this.addRibbonIcon("box",$("main.ribbonOpenWorkbench"),()=>this.activateView()),this.addCommand({id:"import-model",name:$("main.commandImportModel"),callback:()=>this.importModel()}),this.addCommand({id:"open-workbench",name:$("main.commandOpenWorkbench"),callback:()=>this.activateView()}),this.addCommand({id:"generate-note",name:$("main.commandGenerateNote"),callback:()=>this.generateNote()}),this.addCommand({id:"clear-conversion-cache",name:$("main.commandClearConversionCache"),callback:()=>this.clearConversionCache()}),this.addCommand({id:"check-converters",name:$("main.commandCheckConverters"),callback:()=>void this.checkConverterCommands()}),this.addSettingTab(new W_(this.app,this)),this.registerView(G_,c=>new V_(c,()=>this.getSettings(),this.convertedAssetCache,this.ps)),this.registerExtensions(Ho(),G_);let{registerCodeBlockProcessor:e,registerGridCodeBlockProcessor:t}=await Promise.resolve().then(()=>(ek(),$G)),i=c=>{var f,h;return(h=(f=this.ps.store.getState().modelAssetProfiles[c])==null?void 0:f.annotations)!=null?h:[]},r=e(this.app,()=>this.getSettings(),this.convertedAssetCache,i);this.registerMarkdownCodeBlockProcessor(r.id,r.handler);let n=t(this.app,()=>this.getSettings(),this.convertedAssetCache);this.registerMarkdownCodeBlockProcessor(n.id,n.handler);let{registerLivePreviewExtension:a}=await Promise.resolve().then(()=>(nk(),sk)),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=M=>{if(M.length===0)return"var(--interactive-accent)";if(M.length===1)return M[0];let F=100/M.length;return`linear-gradient(135deg, ${M.map((N,V)=>{let O=Math.round(V*F),U=Math.round((V+1)*F);return`${N} ${O}% ${U}%`}).join(", ")})`},n=()=>{let M=new Map,F=this.ps.store.getState().modelAssetProfiles;for(let[N,V]of Object.entries(F))for(let O of V.annotations)if(O.headingRef&&O.id){let U=dd(O.headingRef);if(!U)continue;let k=M.get(U);k||(k=[],M.set(U,k)),k.push({pinId:O.id,modelPath:N,color:O.color})}return M},a=M=>M.map(F=>`${F.pinId}:${F.modelPath}:${F.color}`).sort().join("|"),o=M=>Array.from(M.entries()).map(([F,N])=>`${F}=>${a(N)}`).sort().join("||"),l=M=>dd(Array.from(M.childNodes).map(F=>{var N;return F.instanceOf(Element)&&F.classList.contains("ai3d-heading-pin-badge")?"":(N=F.textContent)!=null?N:""}).join(" ")),c=M=>{let F=i.get(M);F&&(M.removeEventListener("mouseover",F.handler),F.badge.remove(),delete M.dataset.pinBound,i.delete(M))},f=(M,F)=>{if(F.length===0){c(M);return}let N=a(F),V=i.get(M);if((V==null?void 0:V.signature)===N)return;V&&c(M),M.dataset.pinBound=N;let O=M.createSpan({cls:"ai3d-heading-pin-badge"}),U=[...new Set(F.map(q=>q.color).filter(Boolean))],k=O.createSpan({cls:"ai3d-heading-pin-badge-swatch"});if(k.style.background=r(U),k.title=F.length>1?$("headingPin.showMultiple"):$("headingPin.showSingle"),k.setAttribute("role","button"),k.setAttribute("tabindex","0"),F.length>1){let q=O.createSpan({cls:"ai3d-heading-pin-badge-count"});q.textContent=`\xD7${F.length}`}let z=[...new Set(F.map(q=>zr(q.modelPath)))];O.title=ri("headingPin.linkedTo",{models:z.join(", ")});let Z=q=>{q==null||q.stopPropagation(),q==null||q.preventDefault();for(let Y of F)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:Y.pinId}}))};k.addEventListener("click",q=>{Z(q)}),k.addEventListener("keydown",q=>{q.instanceOf(KeyboardEvent)&&(q.key!=="Enter"&&q.key!==" "||Z(q))}),O.addEventListener("click",q=>{q.stopPropagation()}),M.appendChild(O);let J=()=>{for(let q of F)activeDocument.dispatchEvent(new CustomEvent("ai3d-pin-highlight",{detail:{pinId:q.pinId}}))};M.addEventListener("mouseover",J),i.set(M,{badge:O,handler:J,signature:N})},h=(M,F)=>{var V;let N=l(M);f(M,(V=F.get(N))!=null?V:[])},d=M=>{var F;for(let[N,V]of Array.from(i.entries())){if(!N.isConnected){c(N);continue}let O=(F=M.get(l(N)))!=null?F:[],U=a(O);(O.length===0||V.signature!==U)&&f(N,O)}},u=(M,F)=>{M.querySelectorAll(t).forEach(N=>h(N,F))},m=()=>{let M=n();d(M),activeDocument.querySelectorAll(e).forEach(N=>u(N,M))},p=o(n()),_=0,g=(M=0)=>{_&&activeWindow.clearTimeout(_),_=activeWindow.setTimeout(()=>{_=0,m()},M)},v=this.ps.store.subscribe(()=>{let M=n(),F=o(M);F!==p&&(p=F,g())});this.registerEvent(this.app.workspace.on("layout-change",()=>{g(200)}));let I=M=>M.matches(e)||M.matches(t)?!0:!!M.querySelector(e)||!!M.querySelector(t),x=M=>M.isConnected&&I(M),T=M=>I(M),A=new Set,R=0,P=()=>{var N,V,O,U,k,z;let M=Array.from(A);A.clear(),R=0;let F=n();d(F);for(let Z of M)Z.isConnected&&((N=Z.matches)!=null&&N.call(Z,t)&&h(Z,F),(O=(V=Z.querySelectorAll)==null?void 0:V.call(Z,t))==null||O.forEach(J=>h(J,F)),(U=Z.matches)!=null&&U.call(Z,e)&&u(Z,F),(z=(k=Z.querySelectorAll)==null?void 0:k.call(Z,e))==null||z.forEach(J=>u(J,F)));p=o(F)},D=new MutationObserver(M=>{let F=!1;for(let N of M){for(let V of Array.from(N.addedNodes))V.instanceOf(HTMLElement)&&x(V)&&(A.add(V),F=!0);for(let V of Array.from(N.removedNodes))V.instanceOf(HTMLElement)&&T(V)&&(F=!0)}F&&!R&&(R=activeWindow.setTimeout(P,100))});D.observe(activeDocument.body,{childList:!0,subtree:!0}),this.register(()=>{v(),D.disconnect(),R&&(activeWindow.clearTimeout(R),R=0),_&&(activeWindow.clearTimeout(_),_=0);for(let M of Array.from(i.keys()))c(M)}),g(500)}async activateView(){let{workspace:e}=this.app,t=null;if(e.iterateAllLeaves(i=>{i.getViewState().type===pd&&(t=i)}),!t){if(t=e.getRightLeaf(!1),!t)return;await t.setViewState({type:pd,active:!0})}e.setActiveLeaf(t,{focus:!0})}importModel(){new k_(this.app,e=>{let t=e.extension.toLowerCase();Nn(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(()=>(hx(),DG));await e(this.app,this.ps.store.getState())}clearConversionCache(){this.convertedAssetCache.clear(),new Dl.Notice("AI 3d conversion cache cleared.")}async checkConverterCommands(){if(ii()){new Dl.Notice($("main.converterDiagnosticsMobileUnavailable"),8e3);return}let e=await M_(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 Dl.Notice(`AI 3D converter diagnostics: all commands available (${t.join(", ")}).`,8e3);return}new Dl.Notice(`AI 3D converter diagnostics: available ${t.join(", ")||"none"}; missing ${i.join(", ")}.`,1e4)}}; diff --git a/manifest.json b/manifest.json index 2b3157a..2e2daaa 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { - "id": "ai-3d-model-workbench", + "id": "ai-three-d-model-workbench", "name": "AI 3D Model Workbench", - "version": "0.1.4", + "version": "0.1.5", "minAppVersion": "1.5.0", - "description": "Turn 3D models into linked knowledge assets.", + "description": "Turn 3D models into linked knowledge assets.", "author": "flash", "authorUrl": "https://github.com/flash555588", "isDesktopOnly": false diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..dc1a7b6 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5258 @@ +{ + "name": "obsidian-ai-3d-model-workbench", + "version": "0.1.5", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "obsidian-ai-3d-model-workbench", + "version": "0.1.5", + "dependencies": { + "@babylonjs/core": "^9.6.0", + "@babylonjs/gui": "^9.6.0", + "@babylonjs/loaders": "^9.6.0", + "@babylonjs/materials": "^9.6.0", + "@babylonjs/serializers": "^9.6.0", + "htm": "^3.1.1" + }, + "devDependencies": { + "@codemirror/language": "^6.12.3", + "@codemirror/state": "^6.5.0", + "@codemirror/view": "^6.38.6", + "@lezer/common": "^1.5.2", + "@lezer/highlight": "^1.2.3", + "@lezer/lr": "^1.4.10", + "@types/node": "^22.15.17", + "@typescript-eslint/parser": "^8.59.2", + "esbuild": "^0.25.4", + "eslint": "^9.39.4", + "eslint-plugin-obsidianmd": "^0.2.9", + "obsidian": "^1.8.7", + "typescript": "^5.8.3" + } + }, + "node_modules/@babylonjs/core": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@babylonjs/core/-/core-9.6.0.tgz", + "integrity": "sha512-4WoYkdrStnszS2qKy44sDRQA8ibVlJ9YbbO9mFrOZYAAY0p2VWfQaC/qwwQJ7hrHXpoayltaaXhkK3aNiol5aA==", + "license": "Apache-2.0" + }, + "node_modules/@babylonjs/gui": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@babylonjs/gui/-/gui-9.6.0.tgz", + "integrity": "sha512-xf47iJfa+IyALzOeFvjPaa9W1DyJwcrut0/0fCYwFL0sOHiuROgzGKIxvl4+c9LwvJa67t+P+cOnC2aSkhSCcg==", + "license": "Apache-2.0", + "peerDependencies": { + "@babylonjs/core": "^9.0.0" + } + }, + "node_modules/@babylonjs/loaders": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@babylonjs/loaders/-/loaders-9.6.0.tgz", + "integrity": "sha512-f4JmYlkxwtS5NYHqwjGeX9fI1TjMA8IhMLQwGMt2D7V+AgBlwVPnPzhSCEzOMGD6Qe+1z+97DYtgHhasWRHAHw==", + "license": "Apache-2.0", + "peerDependencies": { + "@babylonjs/core": "^9.0.0", + "babylonjs-gltf2interface": "^9.0.0" + } + }, + "node_modules/@babylonjs/materials": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@babylonjs/materials/-/materials-9.6.0.tgz", + "integrity": "sha512-wm9LRhD6/v/xUNmbOQWosLDzVYxihO5Zsza7WBV8S4PB6lRYsh+tjqA73OKMNIVefM533rphQoSZ3i/mnxw7IA==", + "license": "Apache-2.0", + "peerDependencies": { + "@babylonjs/core": "^9.0.0" + } + }, + "node_modules/@babylonjs/serializers": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@babylonjs/serializers/-/serializers-9.6.0.tgz", + "integrity": "sha512-GBKlL8zlrEu7w9O2HtJTKem1bF0+lnf5EDuJm/RGgkKYU6cZjEJJw+P2S8UCL90394p6eQtEN1n7eHnvhYslGQ==", + "license": "Apache-2.0", + "peerDependencies": { + "@babylonjs/core": "^9.0.0", + "babylonjs-gltf2interface": "^9.0.0" + } + }, + "node_modules/@codemirror/language": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.3.tgz", + "integrity": "sha512-QwCZW6Tt1siP37Jet9Tb02Zs81TQt6qQrZR2H+eGMcFsL1zMrk2/b9CLC7/9ieP1fjIUMgviLWMmgiHoJrj+ZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.0.0", + "@codemirror/view": "^6.23.0", + "@lezer/common": "^1.5.0", + "@lezer/highlight": "^1.0.0", + "@lezer/lr": "^1.0.0", + "style-mod": "^4.0.0" + } + }, + "node_modules/@codemirror/state": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.0.tgz", + "integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@marijn/find-cluster-break": "^1.0.0" + } + }, + "node_modules/@codemirror/view": { + "version": "6.38.6", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.38.6.tgz", + "integrity": "sha512-qiS0z1bKs5WOvHIAC0Cybmv4AJSkAXgX5aD6Mqd2epSLlVJsQl8NG23jCVouIgkh4All/mrbdsf2UOLFnJw0tw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@codemirror/state": "^6.5.0", + "crelt": "^1.0.6", + "style-mod": "^4.1.0", + "w3c-keyname": "^2.2.4" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz", + "integrity": "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.2.tgz", + "integrity": "sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.5" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-array/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.5.tgz", + "integrity": "sha512-4IlJx0X0qftVsN5E+/vGujTRIFtwuLbNsVUe7TO6zYPDR1O6nFwvwhIKEKSrl6dZchmYBITazxKoUYOjdtjlRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.14.0", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.1", + "minimatch": "^3.1.5", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.4", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.4.tgz", + "integrity": "sha512-nE7DEIchvtiFTwBw4Lfbu59PG+kCofhjsKaCWzxTpt4lfRjRMqG6uMBzKXuEcyXhOHoUp9riAm7/aWYGhXZ9cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/json": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@eslint/json/-/json-0.14.0.tgz", + "integrity": "sha512-rvR/EZtvUG3p9uqrSmcDJPYSH7atmWr0RnFWN6m917MAPx82+zQgPUmDu0whPFG6XTyM0vB/hR6c1Q63OaYtCQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "@eslint/plugin-kit": "^0.4.1", + "@humanwhocodes/momoa": "^3.3.10", + "natural-compare": "^1.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/momoa": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/momoa/-/momoa-3.3.10.tgz", + "integrity": "sha512-KWiFQpSAqEIyrTXko3hFNLeQvSK8zXlJQzhhxsyVn58WFRYXST99b3Nqnu+ttOtjds2Pl2grUHGpe2NzhPynuQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@lezer/common": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz", + "integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@lezer/highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz", + "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.3.0" + } + }, + "node_modules/@lezer/lr": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz", + "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@lezer/common": "^1.0.0" + } + }, + "node_modules/@marijn/find-cluster-break": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz", + "integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@microsoft/eslint-plugin-sdl": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@microsoft/eslint-plugin-sdl/-/eslint-plugin-sdl-1.1.0.tgz", + "integrity": "sha512-dxdNHOemLnBhfY3eByrujX9KyLigcNtW8sU+axzWv5nLGcsSBeKW2YYyTpfPo1hV8YPOmIGnfA4fZHyKVtWqBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-plugin-n": "17.10.3", + "eslint-plugin-react": "7.37.3", + "eslint-plugin-security": "1.4.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "eslint": "^9" + } + }, + "node_modules/@microsoft/eslint-plugin-sdl/node_modules/eslint-plugin-security": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.4.0.tgz", + "integrity": "sha512-xlS7P2PLMXeqfhyf3NpqbvbnW04kN8M9NtmhpR3XGyOvt/vNKS7XPXT5EDbwKW9vCjWH4PpfQvgD/+JgN0VJKA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-regex": "^1.1.0" + } + }, + "node_modules/@microsoft/eslint-plugin-sdl/node_modules/safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ret": "~0.1.10" + } + }, + "node_modules/@pkgr/core": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.2.tgz", + "integrity": "sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/@rtsao/scc": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz", + "integrity": "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/codemirror": { + "version": "5.60.8", + "resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-5.60.8.tgz", + "integrity": "sha512-VjFgDF/eB+Aklcy15TtOTLQeMjTo07k7KAjql8OK5Dirr7a6sJY4T1uVBDuTVG9VEmn1uUsohOpYnVfgC6/jyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/tern": "*" + } + }, + "node_modules/@types/eslint": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", + "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz", + "integrity": "sha512-wGdMcf+vPYM6jikpS/qhg6WiqSV/OhG+jeeHT/KlVqxYfD40iYJf9/AE1uQxVWFvU7MipKRkRv8NSHiCGgPr8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/tern": { + "version": "0.23.9", + "resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.23.9.tgz", + "integrity": "sha512-ypzHFE/wBzh+BlH6rrBgS5I/Z7RD21pGhZ2rltb/+ZrVM1awdZwjx7hE5XfuYgHWk9uvV5HLZN3SloevCAp3Bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.59.2.tgz", + "integrity": "sha512-j/bwmkBvHUtPNxzuWe5z6BEk3q54YRyGlBXkSsmfoih7zNrBvl5A9A98anlp/7JbyZcWIJ8KXo/3Tq/DjFLtuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.59.2", + "@typescript-eslint/type-utils": "8.59.2", + "@typescript-eslint/utils": "8.59.2", + "@typescript-eslint/visitor-keys": "8.59.2", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.59.2", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", + "integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.59.2.tgz", + "integrity": "sha512-plR3pp6D+SSUn1HM7xvSkx12/DhoHInI2YF35KAcVFNZvlC0gtrWqx7Qq1oH2Ssgi0vlFRCTbP+DZc7B9+TtsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.59.2", + "@typescript-eslint/types": "8.59.2", + "@typescript-eslint/typescript-estree": "8.59.2", + "@typescript-eslint/visitor-keys": "8.59.2", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.59.2.tgz", + "integrity": "sha512-+2hqvEkeyf/0FBor67duF0Ll7Ot8jyKzDQOSrxazF/danillRq2DwR9dLptsXpoZQqxE1UisSmoZewrlPas9Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.59.2", + "@typescript-eslint/types": "^8.59.2", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.59.2.tgz", + "integrity": "sha512-JzfyEpEtOU89CcFSwyNS3mu4MLvLSXqnmX05+aKBDM+TdR5jzcGOEBwxwGNxrEQ7p/z6kK2WyioCGBf2zZBnvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.59.2", + "@typescript-eslint/visitor-keys": "8.59.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.59.2.tgz", + "integrity": "sha512-BKK4alN7oi4C/zv4VqHQ+uRU+lTa6JGIZ7s1juw7b3RHo9OfKB+bKX3u0iVZetdsUCBBkSbdWbarJbmN0fTeSw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.59.2.tgz", + "integrity": "sha512-nhqaj1nmTdVVl/BP5omXNRGO38jn5iosis2vbdmupF2txCf8ylWT8lx+JlvMYYVqzGVKtjojUFoQ3JRWK+mfzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.59.2", + "@typescript-eslint/typescript-estree": "8.59.2", + "@typescript-eslint/utils": "8.59.2", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.59.2.tgz", + "integrity": "sha512-e82GVOE8Ps3E++Egvb6Y3Dw0S10u8NkQ9KXmtRhCWJJ8kDhOJTvtMAWnFL16kB1583goCWXsr0NieKCZMs2/0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.59.2.tgz", + "integrity": "sha512-o0XPGNwcWw+FIwStOWn+BwBuEmL6QXP0rsvAFg7ET1dey1Nr6Wb1ac8p5HEsK0ygO/6mUxlk+YWQD9xcb/nnXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.59.2", + "@typescript-eslint/tsconfig-utils": "8.59.2", + "@typescript-eslint/types": "8.59.2", + "@typescript-eslint/visitor-keys": "8.59.2", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.59.2.tgz", + "integrity": "sha512-Juw3EinkXqjaffxz6roowvV7GZT/kET5vSKKZT6upl5TXdWkLkYmNPXwDDL2Vkt2DPn0nODIS4egC/0AGxKo/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.59.2", + "@typescript-eslint/types": "8.59.2", + "@typescript-eslint/typescript-estree": "8.59.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.59.2.tgz", + "integrity": "sha512-NwjLUnGy8/Zfx23fl50tRC8rYaYnM52xNRYFAXvmiil9yh1+K6aRVQMnzW6gQB/1DLgWt977lYQn7C+wtgXZiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.59.2", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/acorn": { + "version": "8.16.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", + "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-includes": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.9.tgz", + "integrity": "sha512-FmeCCAenzH0KH381SPT5FZmiA/TmpndpcaShhfgEN9eCVjnFBqq3l1xrI42y8+PPLI6hypzou4GXw00WHmPBLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.0", + "es-object-atoms": "^1.1.1", + "get-intrinsic": "^1.3.0", + "is-string": "^1.1.1", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.findlast": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz", + "integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.6.tgz", + "integrity": "sha512-F/TKATkzseUExPlfvmwQKGITM3DGTK+vkAsCZoDc5daVygbJBnjEUCbgkAvVFsgfXfX4YIqZ/27G3k3tdXrTxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-shim-unscopables": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.3.tgz", + "integrity": "sha512-rwG/ja1neyLqCuGZ5YYrznA62D4mZXg0i1cIskIUKSiqF3Cje9/wXAls9B9s1Wa2fomMsIv8czB8jZcPmxCXFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.3.tgz", + "integrity": "sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.tosorted": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", + "integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", + "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz", + "integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.1", + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "is-array-buffer": "^3.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/babylonjs-gltf2interface": { + "version": "9.6.2", + "resolved": "https://registry.npmjs.org/babylonjs-gltf2interface/-/babylonjs-gltf2interface-9.6.2.tgz", + "integrity": "sha512-4g/yELh0/E8LncRF62xt32YDlpaDX+AlLULRf6trZguVmpnwnAVAb5jpQlY97yUxajQhmkD2GZe09CrBuuQV9Q==", + "license": "Apache-2.0", + "peer": true + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz", + "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/crelt": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.6.tgz", + "integrity": "sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/data-view-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", + "integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/data-view-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz", + "integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/inspect-js" + } + }, + "node_modules/data-view-byte-offset": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz", + "integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/empathic": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/empathic/-/empathic-2.0.1.tgz", + "integrity": "sha512-YGRs8knHhKHVShLkFET/rWAU8kmHbOV5LwN938RHI0pljAJ1Gf6SzXsSmRaEzcXTtOOmVqJ5+WtQPL5uigY50Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.21.2", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.2.tgz", + "integrity": "sha512-xe9vQb5kReirPUxgQrXA3ihgbCqssmTiM7cOZ+Gzu+VeGWgpV98lLZvp0dl4yriyAePcewxGUs9UpKD8PET9KQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.3.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/es-abstract": { + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.2.tgz", + "integrity": "sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.2", + "arraybuffer.prototype.slice": "^1.0.4", + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-set-tostringtag": "^2.1.0", + "es-to-primitive": "^1.3.0", + "function.prototype.name": "^1.1.8", + "get-intrinsic": "^1.3.0", + "get-proto": "^1.0.1", + "get-symbol-description": "^1.1.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "internal-slot": "^1.1.0", + "is-array-buffer": "^3.0.5", + "is-callable": "^1.2.7", + "is-data-view": "^1.0.2", + "is-negative-zero": "^2.0.3", + "is-regex": "^1.2.1", + "is-set": "^2.0.3", + "is-shared-array-buffer": "^1.0.4", + "is-string": "^1.1.1", + "is-typed-array": "^1.1.15", + "is-weakref": "^1.1.1", + "math-intrinsics": "^1.1.0", + "object-inspect": "^1.13.4", + "object-keys": "^1.1.1", + "object.assign": "^4.1.7", + "own-keys": "^1.0.1", + "regexp.prototype.flags": "^1.5.4", + "safe-array-concat": "^1.1.3", + "safe-push-apply": "^1.0.0", + "safe-regex-test": "^1.1.0", + "set-proto": "^1.0.0", + "stop-iteration-iterator": "^1.1.0", + "string.prototype.trim": "^1.2.10", + "string.prototype.trimend": "^1.0.9", + "string.prototype.trimstart": "^1.0.8", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", + "typed-array-length": "^1.0.7", + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.19" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-iterator-helpers": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.3.2.tgz", + "integrity": "sha512-HVLACW1TppGYjJ8H6/jqH/pqOtKRw6wMlrB23xfExmFWxFquAIWCmwoLsOyN96K4a5KbmOf5At9ZUO3GZbetAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.2", + "es-errors": "^1.3.0", + "es-set-tostringtag": "^2.1.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.3.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "internal-slot": "^1.1.0", + "iterator.prototype": "^1.1.5", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.1.0.tgz", + "integrity": "sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-to-primitive": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.0.tgz", + "integrity": "sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7", + "is-date-object": "^1.0.5", + "is-symbol": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.39.4", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.4.tgz", + "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.2", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.5", + "@eslint/js": "9.39.4", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-compat-utils": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.10.tgz", + "integrity": "sha512-tRrKqFyCaKict5hOd244sL6EQFNycnMQnBe+j8uqGNXYzsImGbGUU4ibtoaBmv5FLwJwcFJNeg1GeVjQfbMrDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.16.1", + "resolve": "^2.0.0-next.6" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.1.tgz", + "integrity": "sha512-L8jSWTze7K2mTg0vos/RuLRS5soomksDPoJLXIslC7c8Wmut3bx7CPpJijDcBZtxQ5lrbUdM+s0OlNbz0DCDNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-depend": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-depend/-/eslint-plugin-depend-1.3.1.tgz", + "integrity": "sha512-1uo2rFAr9vzNrCYdp7IBZRB54LiyVxfaIso0R6/QV3t6Dax6DTbW/EV2Hktf0f4UtmGHK8UyzJWI382pwW04jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "empathic": "^2.0.0", + "module-replacements": "^2.8.0", + "semver": "^7.6.3" + } + }, + "node_modules/eslint-plugin-es-x": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.8.0.tgz", + "integrity": "sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==", + "dev": true, + "funding": [ + "https://github.com/sponsors/ota-meshi", + "https://opencollective.com/eslint" + ], + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.11.0", + "eslint-compat-utils": "^0.5.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": ">=8" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.32.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", + "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rtsao/scc": "^1.1.0", + "array-includes": "^3.1.9", + "array.prototype.findlastindex": "^1.2.6", + "array.prototype.flat": "^1.3.3", + "array.prototype.flatmap": "^1.3.3", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.9", + "eslint-module-utils": "^2.12.1", + "hasown": "^2.0.2", + "is-core-module": "^2.16.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.8", + "object.groupby": "^1.0.3", + "object.values": "^1.2.1", + "semver": "^6.3.1", + "string.prototype.trimend": "^1.0.9", + "tsconfig-paths": "^3.15.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9" + } + }, + "node_modules/eslint-plugin-import/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-import/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-json-schema-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-json-schema-validator/-/eslint-plugin-json-schema-validator-5.1.0.tgz", + "integrity": "sha512-ZmVyxRIjm58oqe2kTuy90PpmZPrrKvOjRPXKzq8WCgRgAkidCgm5X8domL2KSfadZ3QFAmifMgGTcVNhZ5ez2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.3.0", + "ajv": "^8.0.0", + "debug": "^4.3.1", + "eslint-compat-utils": "^0.5.0", + "json-schema-migrate": "^2.0.0", + "jsonc-eslint-parser": "^2.0.0", + "minimatch": "^8.0.0", + "synckit": "^0.9.0", + "toml-eslint-parser": "^0.9.0", + "tunnel-agent": "^0.6.0", + "yaml-eslint-parser": "^1.0.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, + "node_modules/eslint-plugin-json-schema-validator/node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/eslint-plugin-json-schema-validator/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-json-schema-validator/node_modules/brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/eslint-plugin-json-schema-validator/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-json-schema-validator/node_modules/minimatch": { + "version": "8.0.7", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.7.tgz", + "integrity": "sha512-V+1uQNdzybxa14e/p00HZnQNNcTjnRJjDxg2V8wtkjFctq4M7hXFws4oekyTP0Jebeq7QYtpFyOeBAjc88zvYg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/eslint-plugin-n": { + "version": "17.10.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.10.3.tgz", + "integrity": "sha512-ySZBfKe49nQZWR1yFaA0v/GsH6Fgp8ah6XV0WDz6CN8WO0ek4McMzb7A2xnf4DCYV43frjCygvb9f/wx7UUxRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "enhanced-resolve": "^5.17.0", + "eslint-plugin-es-x": "^7.5.0", + "get-tsconfig": "^4.7.0", + "globals": "^15.8.0", + "ignore": "^5.2.4", + "minimatch": "^9.0.5", + "semver": "^7.5.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": ">=8.23.0" + } + }, + "node_modules/eslint-plugin-n/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-n/node_modules/brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/eslint-plugin-n/node_modules/globals": { + "version": "15.15.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz", + "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-n/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/eslint-plugin-no-unsanitized": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-unsanitized/-/eslint-plugin-no-unsanitized-4.1.5.tgz", + "integrity": "sha512-MSB4hXPVFQrI8weqzs6gzl7reP2k/qSjtCoL2vUMSDejIIq9YL1ZKvq5/ORBXab/PvfBBrWO2jWviYpL+4Ghfg==", + "dev": true, + "license": "MPL-2.0", + "peerDependencies": { + "eslint": "^9 || ^10" + } + }, + "node_modules/eslint-plugin-obsidianmd": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/eslint-plugin-obsidianmd/-/eslint-plugin-obsidianmd-0.2.9.tgz", + "integrity": "sha512-+dF5Zz5T6/j0QYGu+wHbY3UZb45Kh+QFkFdfvkVk05o4YIIVqHMlrTFrlRVhuBd6Htu8QxcFOwzeMTN4aysVTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint/config-helpers": "^0.4.2", + "@eslint/js": "^9.30.1", + "@eslint/json": "0.14.0", + "@microsoft/eslint-plugin-sdl": "^1.1.0", + "@types/eslint": "9.6.1", + "@types/node": "20.12.12", + "@typescript-eslint/types": "^8.33.1", + "@typescript-eslint/utils": "^8.33.1", + "eslint": ">=9.0.0", + "eslint-plugin-depend": "1.3.1", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-json-schema-validator": "5.1.0", + "eslint-plugin-no-unsanitized": "^4.1.5", + "eslint-plugin-security": "2.1.1", + "globals": "14.0.0", + "obsidian": "1.12.3", + "semver": "^7.7.4", + "typescript": "5.4.5", + "typescript-eslint": "^8.35.1" + }, + "bin": { + "eslint-plugin-obsidian": "dist/lib/index.js" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@eslint/js": "^9.30.1", + "@eslint/json": "0.14.0", + "eslint": ">=9.0.0", + "obsidian": "1.8.7", + "typescript-eslint": "^8.35.1" + } + }, + "node_modules/eslint-plugin-obsidianmd/node_modules/@types/node": { + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/eslint-plugin-obsidianmd/node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/eslint-plugin-obsidianmd/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-react": { + "version": "7.37.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.3.tgz", + "integrity": "sha512-DomWuTQPFYZwF/7c9W2fkKkStqZmBd3uugfqBYLdkZ3Hii23WzZuOLUskGxB8qkSKqftxEeGL1TB2kMhrce0jA==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-includes": "^3.1.8", + "array.prototype.findlast": "^1.2.5", + "array.prototype.flatmap": "^1.3.3", + "array.prototype.tosorted": "^1.1.4", + "doctrine": "^2.1.0", + "es-iterator-helpers": "^1.2.1", + "estraverse": "^5.3.0", + "hasown": "^2.0.2", + "jsx-ast-utils": "^2.4.1 || ^3.0.0", + "minimatch": "^3.1.2", + "object.entries": "^1.1.8", + "object.fromentries": "^2.0.8", + "object.values": "^1.2.1", + "prop-types": "^15.8.1", + "resolve": "^2.0.0-next.5", + "semver": "^6.3.1", + "string.prototype.matchall": "^4.0.12", + "string.prototype.repeat": "^1.0.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" + } + }, + "node_modules/eslint-plugin-react/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint-plugin-react/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint-plugin-react/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/eslint-plugin-react/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-security": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-2.1.1.tgz", + "integrity": "sha512-7cspIGj7WTfR3EhaILzAPcfCo5R9FbeWvbgsPYWivSurTBKW88VQxtP3c4aWMG9Hz/GfJlJVdXEJ3c8LqS+u2w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-regex": "^2.1.1" + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.14.tgz", + "integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz", + "integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz", + "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==", + "dev": true, + "license": "ISC" + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.8.tgz", + "integrity": "sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "functions-have-names": "^1.2.3", + "hasown": "^2.0.2", + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generator-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", + "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-symbol-description": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", + "integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-tsconfig": { + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.0.tgz", + "integrity": "sha512-yTb+8DXzDREzgvYmh6s9vHsSVCHeC0G3PI5bEXNBHtmshPnO+S5O7qgLEOn0I5QvMy6kpZN8K1NKGyilLb93wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz", + "integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/htm": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/htm/-/htm-3.1.1.tgz", + "integrity": "sha512-983Vyg8NwUE7JkZ6NmOqpCZ+sh1bKv2iYTlUkzlWmA5JD2acKoxd4KVxbMmxX/85mtfdnDmTFoNKcg5DGAvxNQ==", + "license": "Apache-2.0" + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-async-function": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-function": "^1.0.0", + "call-bound": "^1.0.3", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz", + "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-data-view": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz", + "integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "is-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-finalizationregistry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", + "integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-generator-function": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", + "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "generator-function": "^2.0.0", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", + "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakref": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz", + "integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/iterator.prototype": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz", + "integrity": "sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.6", + "get-proto": "^1.0.0", + "has-symbols": "^1.1.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", + "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-migrate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/json-schema-migrate/-/json-schema-migrate-2.0.0.tgz", + "integrity": "sha512-r38SVTtojDRp4eD6WsCqiE0eNDt4v1WalBXb9cyZYw9ai5cGtBwzRNWjHzJl38w6TxFkXAIA7h+fyX3tnrAFhQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^8.0.0" + } + }, + "node_modules/json-schema-migrate/node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/json-schema-migrate/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/jsonc-eslint-parser": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/jsonc-eslint-parser/-/jsonc-eslint-parser-2.4.2.tgz", + "integrity": "sha512-1e4qoRgnn448pRuMvKGsFFymUCquZV0mpGgOyIKNgD3JVDTsVJyRBGH/Fm0tBb8WsWGgmB1mDe6/yJMQM37DUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.5.0", + "eslint-visitor-keys": "^3.0.0", + "espree": "^9.0.0", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/jsonc-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/jsonc-eslint-parser/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/jsx-ast-utils": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", + "integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-includes": "^3.1.6", + "array.prototype.flat": "^1.3.1", + "object.assign": "^4.1.4", + "object.values": "^1.1.6" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.5" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/module-replacements": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/module-replacements/-/module-replacements-2.11.0.tgz", + "integrity": "sha512-j5sNQm3VCpQQ7nTqGeOZtoJtV3uKERgCBm9QRhmGRiXiqkf7iRFOkfxdJRZWLkqYY8PNf4cDQF/WfXUYLENrRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-exports-info": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/node-exports-info/-/node-exports-info-1.6.0.tgz", + "integrity": "sha512-pyFS63ptit/P5WqUkt+UUfe+4oevH+bFeIiPPdfb0pFeYEu/1ELnJu5l+5EcTKYL5M7zaAa7S8ddywgXypqKCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "array.prototype.flatmap": "^1.3.3", + "es-errors": "^1.3.0", + "object.entries": "^1.1.9", + "semver": "^6.3.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/node-exports-info/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.entries": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.9.tgz", + "integrity": "sha512-8u/hfXFRBD1O0hPUjioLhoWFHRmt6tKA4/vZPyckBr18l1KE9uHrFaFaUi8MDRTpi4uak2goyPTSNJLXX2k2Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", + "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", + "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.values": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.1.tgz", + "integrity": "sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/obsidian": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.12.3.tgz", + "integrity": "sha512-HxWqe763dOqzXjnNiHmAJTRERN8KILBSqxDSEqbeSr7W8R8Jxezzbca+nz1LiiqXnMpM8lV2jzAezw3CZ4xNUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/codemirror": "5.60.8", + "moment": "2.29.4" + }, + "peerDependencies": { + "@codemirror/state": "6.5.0", + "@codemirror/view": "6.38.6" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/own-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz", + "integrity": "sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.6", + "object-keys": "^1.1.1", + "safe-push-apply": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "license": "MIT", + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/reflect.getprototypeof": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", + "integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.7", + "get-proto": "^1.0.1", + "which-builtin-type": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "2.0.0-next.6", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.6.tgz", + "integrity": "sha512-3JmVl5hMGtJ3kMmB3zi3DL25KfkCEyy3Tw7Gmw7z5w8M9WlwoPFnIvwChzu1+cF3iaK3sp18hhPz8ANeimdJfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.16.1", + "node-exports-info": "^1.6.0", + "object-keys": "^1.1.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12" + } + }, + "node_modules/safe-array-concat": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.4.tgz", + "integrity": "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", + "has-symbols": "^1.1.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-push-apply": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", + "integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz", + "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", + "dev": true, + "license": "MIT", + "dependencies": { + "regexp-tree": "~0.1.1" + } + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.0.tgz", + "integrity": "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz", + "integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.matchall": { + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.12.tgz", + "integrity": "sha512-6CC9uyBL+/48dYizRf7H7VAYCMCNTBeM78x/VTUe9bFEaxBepPJDa1Ow99LqI/1yF7kuy7Q3cQsYMrcjGUcskA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.6", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.6", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "internal-slot": "^1.1.0", + "regexp.prototype.flags": "^1.5.3", + "set-function-name": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.repeat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz", + "integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.10", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz", + "integrity": "sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-data-property": "^1.1.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-object-atoms": "^1.0.0", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz", + "integrity": "sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/style-mod": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz", + "integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/synckit": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.3.tgz", + "integrity": "sha512-JJoOEKTfL1urb1mDoEblhD9NhEbWmq9jHEMEnxoC4ujUaZ4itA8vKgwkFAyNClgxplLi9tsUKX+EduK0p/l7sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/tapable": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", + "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", + "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/toml-eslint-parser": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/toml-eslint-parser/-/toml-eslint-parser-0.9.3.tgz", + "integrity": "sha512-moYoCvkNUAPCxSW9jmHmRElhm4tVJpHL8ItC/+uYD0EpPSFXbck7yREz9tNdJVTSpHVod8+HoipcpbQ0oE6gsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.0.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/toml-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz", + "integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz", + "integrity": "sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.15", + "reflect.getprototypeof": "^1.0.9" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.7.tgz", + "integrity": "sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "is-typed-array": "^1.1.13", + "possible-typed-array-names": "^1.0.0", + "reflect.getprototypeof": "^1.0.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.59.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.59.2.tgz", + "integrity": "sha512-pJw051uomb3ZeCzGTpRb8RbEqB5Y4WWet8gl/GcTlU35BSx0PVdZ86/bqkQCyKKuraVQEK7r6kBHQXF+fBhkoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.59.2", + "@typescript-eslint/parser": "8.59.2", + "@typescript-eslint/typescript-estree": "8.59.2", + "@typescript-eslint/utils": "8.59.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/unbox-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", + "integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-bigints": "^1.0.2", + "has-symbols": "^1.1.0", + "which-boxed-primitive": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/w3c-keyname": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-builtin-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz", + "integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", + "is-async-function": "^2.0.0", + "is-date-object": "^1.1.0", + "is-finalizationregistry": "^1.1.0", + "is-generator-function": "^1.0.10", + "is-regex": "^1.2.1", + "is-weakref": "^1.0.2", + "isarray": "^2.0.5", + "which-boxed-primitive": "^1.1.0", + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.20.tgz", + "integrity": "sha512-LYfpUkmqwl0h9A2HL09Mms427Q1RZWuOHsukfVcKRq9q95iQxdw0ix1JQrqbcDR9PH1QDwf5Qo8OZb5lksZ8Xg==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yaml": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.4.tgz", + "integrity": "sha512-ml/JPOj9fOQK8RNnWojA67GbZ0ApXAUlN2UQclwv2eVgTgn7O9gg9o7paZWKMp4g0H3nTLtS9LVzhkpOFIKzog==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "node_modules/yaml-eslint-parser": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/yaml-eslint-parser/-/yaml-eslint-parser-1.3.2.tgz", + "integrity": "sha512-odxVsHAkZYYglR30aPYRY4nUGJnoJ2y1ww2HDvZALo0BDETv9kWbi16J52eHs+PWRNmF4ub6nZqfVOeesOvntg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.0.0", + "yaml": "^2.0.0" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/yaml-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json index c73655e..80d584b 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "obsidian-ai-3d-model-workbench", - "version": "0.1.4", + "version": "0.1.5", "private": true, - "description": "Obsidian plugin for turning 3D models into linked knowledge assets.", + "description": "Obsidian plugin for turning 3D models into linked knowledge assets.", "scripts": { "dev": "node esbuild.config.mjs", "build": "node esbuild.config.mjs production", diff --git a/src/main.ts b/src/main.ts index f32cb47..3768f69 100644 --- a/src/main.ts +++ b/src/main.ts @@ -123,8 +123,12 @@ export default class AI3DModelWorkbench extends Plugin { ".cm-header-4", ".cm-header-5", ".cm-header-6", ].join(", "); - // Track bound elements for cleanup - const boundEntries: { el: Element; handler: () => void }[] = []; + type BoundHeadingEntry = { + badge: HTMLSpanElement; + handler: () => void; + signature: string; + }; + const boundEntries = new Map(); // Build headingRef → [{ pinId, modelPath, color }] map from stored annotations. // Supports multiple pins/models per heading. @@ -146,8 +150,10 @@ export default class AI3DModelWorkbench extends Plugin { for (const [modelPath, profile] of Object.entries(profiles)) { for (const pin of profile.annotations) { if (pin.headingRef && pin.id) { - let arr = map.get(pin.headingRef); - if (!arr) { arr = []; map.set(pin.headingRef, arr); } + const headingKey = normalizeHeadingText(pin.headingRef); + if (!headingKey) continue; + let arr = map.get(headingKey); + if (!arr) { arr = []; map.set(headingKey, arr); } arr.push({ pinId: pin.id, modelPath, color: pin.color }); } } @@ -155,24 +161,51 @@ export default class AI3DModelWorkbench extends Plugin { return map; }; - // Normalize all headingRef keys for robust matching - const normalizedMap = new Map(); - const buildNormalizedMap = (headingMap: Map): void => { - normalizedMap.clear(); - for (const [key, entries] of headingMap) { - normalizedMap.set(normalizeHeadingText(key), entries); - } + const buildEntriesSignature = (entries: PinEntry[]): string => entries + .map((entry) => `${entry.pinId}:${entry.modelPath}:${entry.color}`) + .sort() + .join("|"); + + const buildHeadingMapSignature = (headingMap: Map): string => Array + .from(headingMap.entries()) + .map(([key, entries]) => `${key}=>${buildEntriesSignature(entries)}`) + .sort() + .join("||"); + + const getHeadingText = (el: Element): string => normalizeHeadingText( + Array.from(el.childNodes) + .map((node) => { + if (node.instanceOf(Element) && node.classList.contains("ai3d-heading-pin-badge")) { + return ""; + } + return node.textContent ?? ""; + }) + .join(" "), + ); + + const unbindHeading = (el: Element): void => { + const existing = boundEntries.get(el); + if (!existing) return; + el.removeEventListener("mouseover", existing.handler); + existing.badge.remove(); + delete (el as HTMLElement).dataset.pinBound; + boundEntries.delete(el); }; - const bindHeading = (el: Element) => { - if ((el as HTMLElement).dataset.pinBound) return; + const bindHeading = (el: Element, entries: PinEntry[]): void => { + if (entries.length === 0) { + unbindHeading(el); + return; + } - const text = el.textContent ?? ""; - const headingText = normalizeHeadingText(text); - const entries = normalizedMap.get(headingText); + const signature = buildEntriesSignature(entries); + const existing = boundEntries.get(el); + if (existing?.signature === signature) return; + if (existing) { + unbindHeading(el); + } - if (!entries || entries.length === 0) return; - (el as HTMLElement).dataset.pinBound = entries[0].pinId; + (el as HTMLElement).dataset.pinBound = signature; // Add pin badge: shows count if multiple, tooltip lists model sources // Create on heading element (in DOM) to inherit Obsidian CSS variables @@ -216,32 +249,72 @@ export default class AI3DModelWorkbench extends Plugin { } }; el.addEventListener("mouseover", handler); - boundEntries.push({ el, handler }); + boundEntries.set(el, { badge, handler, signature }); }; - const processHeadings = (container: Element) => { + const syncHeadingElement = (el: Element, headingMap: Map): void => { + const headingText = getHeadingText(el); + bindHeading(el, headingMap.get(headingText) ?? []); + }; + + const reconcileBoundHeadings = (headingMap: Map): void => { + for (const [el, entry] of Array.from(boundEntries.entries())) { + if (!el.isConnected) { + unbindHeading(el); + continue; + } + const nextEntries = headingMap.get(getHeadingText(el)) ?? []; + const nextSignature = buildEntriesSignature(nextEntries); + if (nextEntries.length === 0 || entry.signature !== nextSignature) { + bindHeading(el, nextEntries); + } + } + }; + + const processHeadings = (container: Element, headingMap: Map): void => { + container.querySelectorAll(headingSelector).forEach((el) => syncHeadingElement(el, headingMap)); + }; + + const scanAll = (): void => { const headingMap = buildHeadingMap(); - if (headingMap.size === 0) return; - buildNormalizedMap(headingMap); - container.querySelectorAll(headingSelector).forEach((el) => bindHeading(el)); + reconcileBoundHeadings(headingMap); + const containers = activeDocument.querySelectorAll(markdownContainerSelector); + containers.forEach((container) => processHeadings(container, headingMap)); }; - const scanAll = () => { - const containers = activeDocument.querySelectorAll(markdownContainerSelector); - containers.forEach(processHeadings); + let lastHeadingMapSignature = buildHeadingMapSignature(buildHeadingMap()); + let scanTimer = 0; + const scheduleScan = (delay = 0): void => { + if (scanTimer) { + activeWindow.clearTimeout(scanTimer); + } + scanTimer = activeWindow.setTimeout(() => { + scanTimer = 0; + scanAll(); + }, delay); }; + const unsubscribeStore = this.ps.store.subscribe(() => { + const nextHeadingMap = buildHeadingMap(); + const nextSignature = buildHeadingMapSignature(nextHeadingMap); + if (nextSignature === lastHeadingMapSignature) return; + lastHeadingMapSignature = nextSignature; + scheduleScan(); + }); + this.registerEvent(this.app.workspace.on("layout-change", () => { - activeWindow.setTimeout(scanAll, 200); + scheduleScan(200); })); // Debounced MutationObserver: coalesce rapid DOM changes into a single scan - const isRelevantAddedNode = (node: HTMLElement): boolean => { - if (!node.isConnected) return false; + const matchesRelevantNode = (node: HTMLElement): boolean => { if (node.matches(markdownContainerSelector) || node.matches(headingSelector)) return true; return !!node.querySelector(markdownContainerSelector) || !!node.querySelector(headingSelector); }; + const isRelevantAddedNode = (node: HTMLElement): boolean => node.isConnected && matchesRelevantNode(node); + const isRelevantRemovedNode = (node: HTMLElement): boolean => matchesRelevantNode(node); + let pendingNodes = new Set(); let debounceTimer = 0; const flushPending = () => { @@ -249,24 +322,35 @@ export default class AI3DModelWorkbench extends Plugin { pendingNodes.clear(); debounceTimer = 0; const headingMap = buildHeadingMap(); - if (headingMap.size === 0) return; - buildNormalizedMap(headingMap); + reconcileBoundHeadings(headingMap); for (const node of nodes) { if (!node.isConnected) continue; - if (node.matches?.(headingSelector)) bindHeading(node); - node.querySelectorAll?.(headingSelector)?.forEach((el: Element) => bindHeading(el)); + if (node.matches?.(headingSelector)) syncHeadingElement(node, headingMap); + node.querySelectorAll?.(headingSelector)?.forEach((el: Element) => syncHeadingElement(el, headingMap)); + if (node.matches?.(markdownContainerSelector)) { + processHeadings(node, headingMap); + } + node.querySelectorAll?.(markdownContainerSelector)?.forEach((el: Element) => processHeadings(el, headingMap)); } + lastHeadingMapSignature = buildHeadingMapSignature(headingMap); }; const observer = new MutationObserver((mutations) => { + let shouldFlush = false; for (const m of mutations) { for (const node of Array.from(m.addedNodes)) { if (!node.instanceOf(HTMLElement)) continue; if (!isRelevantAddedNode(node)) continue; pendingNodes.add(node); + shouldFlush = true; + } + for (const node of Array.from(m.removedNodes)) { + if (!node.instanceOf(HTMLElement)) continue; + if (!isRelevantRemovedNode(node)) continue; + shouldFlush = true; } } - if (pendingNodes.size > 0 && !debounceTimer) { + if (shouldFlush && !debounceTimer) { debounceTimer = activeWindow.setTimeout(flushPending, 100); } }); @@ -274,17 +358,17 @@ export default class AI3DModelWorkbench extends Plugin { // Cleanup: disconnect observer, remove all heading listeners this.register(() => { + unsubscribeStore(); observer.disconnect(); if (debounceTimer) { activeWindow.clearTimeout(debounceTimer); debounceTimer = 0; } - for (const { el, handler } of boundEntries) { - el.removeEventListener("mouseover", handler); - el.removeEventListener("click", handler); + if (scanTimer) { activeWindow.clearTimeout(scanTimer); scanTimer = 0; } + for (const el of Array.from(boundEntries.keys())) { + unbindHeading(el); } - boundEntries.length = 0; }); // Initial scan - activeWindow.setTimeout(scanAll, 500); + scheduleScan(500); } private async activateView() { diff --git a/src/render/babylon/annotations.ts b/src/render/babylon/annotations.ts index 20c8488..56775b8 100644 --- a/src/render/babylon/annotations.ts +++ b/src/render/babylon/annotations.ts @@ -62,6 +62,7 @@ export class AnnotationManager { private static readonly _scratchRay = new Ray(Vector3.Zero(), Vector3.Zero(), 1); private hoverPopover: HTMLDivElement | null = null; private hoverTimeout: ReturnType | null = null; + private hoverRequestId = 0; private _highlightHandler: ((e: Event) => void) | null = null; private _pulseTimeout: ReturnType | null = null; private _headingDropdown: HTMLDivElement | null = null; @@ -471,22 +472,31 @@ export class AnnotationManager { await this.renderPreviewContent(el, content, notePath, "editor"); } - private async showHoverPopover(pinEl: HTMLDivElement, pin: AnnotationPin): Promise { + private async showHoverPopover(requestId: number, pinEl: HTMLDivElement, pin: AnnotationPin): Promise { if (!this.noteReader || !pin.notePath || !pin.headingRef) return; this.hideHoverPopover(); const content = await this.noteReader(pin.notePath, pin.headingRef); - if (!content) return; + if (!content || requestId !== this.hoverRequestId || !pinEl.isConnected || !this.hostEl.isConnected) return; - // Create on hostEl (in DOM) to inherit Obsidian CSS variables - const popover = this.hostEl.createDiv({ cls: "ai3d-pin-popover" }); + const popover = activeDocument.createElement("div"); + popover.className = "ai3d-pin-popover"; - const title = popover.createDiv({ cls: "ai3d-pin-popover-title" }); + const title = activeDocument.createElement("div"); + title.className = "ai3d-pin-popover-title"; title.textContent = pin.headingRef; + popover.appendChild(title); - const body = popover.createDiv({ cls: "ai3d-pin-popover-body" }); + const body = activeDocument.createElement("div"); + body.className = "ai3d-pin-popover-body"; + popover.appendChild(body); await this.renderPreviewContent(body, content, pin.notePath, "popover"); + if (requestId !== this.hoverRequestId || !pinEl.isConnected || !this.hostEl.isConnected) { + this.clearRenderedPreview(body); + return; + } + // Position relative to pin const rect = pinEl.getBoundingClientRect(); popover.style.setProperty("--popover-left", `${rect.left + rect.width / 2}px`); @@ -576,6 +586,7 @@ export class AnnotationManager { } destroy(): void { + this.hoverRequestId++; this.hideHoverPopover(); if (this._pulseTimeout) { activeWindow.clearTimeout(this._pulseTimeout); this._pulseTimeout = null; } if (this._headingDebounce) { activeWindow.clearTimeout(this._headingDebounce); this._headingDebounce = null; } @@ -629,12 +640,17 @@ export class AnnotationManager { // Hover popover for linked notes if (pin.notePath && pin.headingRef && this.noteReader) { el.addEventListener("mouseenter", () => { + if (this.hoverTimeout) { activeWindow.clearTimeout(this.hoverTimeout); } + const requestId = ++this.hoverRequestId; this.hoverTimeout = activeWindow.setTimeout(() => { - void this.showHoverPopover(el, pin); + this.hoverTimeout = null; + if (requestId !== this.hoverRequestId) return; + void this.showHoverPopover(requestId, el, pin); }, 300); }); el.addEventListener("mouseleave", () => { if (this.hoverTimeout) { activeWindow.clearTimeout(this.hoverTimeout); this.hoverTimeout = null; } + this.hoverRequestId++; this.hideHoverPopover(); }); } diff --git a/versions.json b/versions.json index 08f2146..69e250a 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.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"}