playcanvas 2.13.1-preview.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v2.13.1-preview.0 revision 2c38650 (RELEASE)
3
+ * PlayCanvas Engine v2.13.1 revision 5d53ea1 (RELEASE)
4
4
  * Copyright 2011-2025 PlayCanvas Ltd. All rights reserved.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
- */let e,t,i,s,r,a,n,o,l,h,c,d,u,f,p,m,_,g;let v="RenderFrame",S="RenderFrameTime",y="RenderPass",x="RenderPassDetail",T="RenderAction",E="RenderTargetAlloc",b="TextureAlloc",w="ShaderAlloc",A="ShaderCompile",C="VRAM.Texture",P="VRAM.Vb",L="VRAM.Ib",D="VRAM.Sb",I="BindGroupAlloc",R="BindGroupFormatAlloc",M="RenderPipelineAlloc",O="ComputePipelineAlloc",F="PipelineLayoutAlloc",N="Element",B="Textures",U="RenderQueue",k="OctreeResources",z="GpuTimings",V="2.13.1-preview.0",G="2c38650";function H(e,t){for(let i in t){let s=t[i];Array.isArray(s)?e[i]=H([],s):s&&"object"==typeof s?e[i]=H({},s):e[i]=s;}return e}let W={create:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return ("x"===e?t:3&t|8).toString(16)})},X={delimiter:"/",join(...e){let t=e[0];for(let i=0;i<e.length-1;i++){let s=e[i],r=e[i+1];if(r[0]===X.delimiter){t=r;continue}s&&r&&s[s.length-1]!==X.delimiter&&r[0]!==X.delimiter?t+=X.delimiter+r:t+=r;}return t},normalize(e){let t=e.startsWith(X.delimiter),i=e.endsWith(X.delimiter),s=e.split("/"),r="",a=[];for(let e=0;e<s.length;e++)if(""!==s[e]&&"."!==s[e]){if(".."===s[e]&&a.length>0){a=a.slice(0,a.length-2);continue}e>0&&a.push(X.delimiter),a.push(s[e]);}return r=a.join(""),t||r[0]!==X.delimiter||(r=r.slice(1)),i&&r[r.length-1]!==X.delimiter&&(r+=X.delimiter),r},split(e){let t=e.lastIndexOf(X.delimiter);return -1!==t?[e.substring(0,t),e.substring(t+1)]:["",e]},getBasename:e=>X.split(e)[1],getDirectory:e=>X.split(e)[0],getExtension(e){let t=e.split("?")[0].split(".").pop();return t!==e?`.${t}`:""},isRelativePath:e=>"/"!==e.charAt(0)&&null===e.match(/:\/\//),extractPath(e){let t="",i=e.split("/"),s=0;if(i.length>1)if(X.isRelativePath(e))if("."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else if(".."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else for(s=0,t=".";s<i.length-1;++s)t+=`/${i[s]}`;else for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;return t}},Y="undefined"!=typeof navigator?navigator.userAgent:"",q="undefined"!=typeof window?"browser":"undefined"!=typeof global?"node":"worker",$=/android/i.test(Y)?"android":/ip(?:[ao]d|hone)/i.test(Y)?"ios":/windows/i.test(Y)?"windows":/mac os/i.test(Y)?"osx":/linux/i.test(Y)?"linux":/cros/i.test(Y)?"cros":null,j="browser"!==q?null:/Chrome\/|Chromium\/|Edg.*\//.test(Y)?"chrome":/Safari\//.test(Y)?"safari":/Firefox\//.test(Y)?"firefox":"other",K=/xbox/i.test(Y),Z="browser"===q&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),Q="browser"===q&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),J="undefined"!=typeof Worker,ee=(()=>{let e=false;try{let t=Object.defineProperty({},"passive",{get:function(){return e=!0,!1}});window.addEventListener("testpassive",null,t),window.removeEventListener("testpassive",null,t);}catch(e){}return e})(),et={name:$,environment:q,global:("undefined"!=typeof globalThis&&globalThis)??("browser"===q&&window)??("node"===q&&global)??("worker"===q&&self),browser:"browser"===q,worker:"worker"===q,desktop:["windows","osx","linux","cros"].includes($),mobile:["android","ios"].includes($),ios:"ios"===$,android:"android"===$,xbox:K,gamepads:Q,touch:Z,workers:J,passiveEvents:ee,browserName:j},ei="abcdefghijklmnopqrstuvwxyz",es="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function er(e,t=0){let i=e.length;if(t<0||t>=i)return null;let s=e.charCodeAt(t);if(i>1&&s>=55296&&s<=56319){let i=e.charCodeAt(t+1);if(i>=56320&&i<=57343)return {code:(s-55296)*1024+i-56320+65536,long:true}}return {code:s,long:false}}function ea(e,t,i){if(!e)return false;let s=er(e);if(s){let e=s.code;return e>=t&&e<=i}return false}let en={ASCII_LOWERCASE:ei,ASCII_UPPERCASE:es,ASCII_LETTERS:ei+es,format(e,...t){for(let i=0;i<t.length;i++)e=e.replace(`{${i}}`,t[i]);return e},getCodePoint(e,t){let i=er(e,t);return i&&i.code},getCodePoints(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=[];for(;t=er(e,i);)s.push(t.code),i+=t.long?2:1;return s},getSymbols(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=e.length,r=[],a=0;for(;i<s;){if(a+=function(e,t){if(t===e.length-1)return 1;if(ea(e[t],55296,56319)){let i=e.substring(t,t+2),s=e.substring(t+2,t+4);return ea(s,127995,127999)||ea(i,127462,127487)&&ea(s,127462,127487)?4:ea(s,65024,65039)?3:2}return ea(e[t+1],65024,65039)?2:1}(e,i+a),ea(t=e[i+a],8400,8447)&&(t=e[i+a++]),ea(t,65024,65039)&&(t=e[i+a++]),t&&8205===t.charCodeAt(0)){t=e[i+a++];continue}let s=e.substring(i,i+a);r.push(s),i+=a,a=0;}return r},fromCodePoint:(...e)=>e.map(e=>e>65535?String.fromCharCode(((e-=65536)>>10)+55296,e%1024+56320):String.fromCharCode(e)).join("")};class eo{constructor(e,t,i,s,r=false){this._removed=false,this.handler=e,this.name=t,this.callback=i,this.scope=s,this._once=r;}off(){this._removed||this.handler.offByHandle(this);}on(e,t,i=this){return this.handler._addCallback(e,t,i,false)}once(e,t,i=this){return this.handler._addCallback(e,t,i,true)}set removed(e){e&&(this._removed=true);}get removed(){return this._removed}toJSON(e){}}class el{initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map;}_addCallback(e,t,i,s){if(this._callbacks.has(e)||this._callbacks.set(e,[]),this._callbackActive.has(e)){let t=this._callbackActive.get(e);t&&t===this._callbacks.get(e)&&this._callbackActive.set(e,t.slice());}let r=new eo(this,e,t,i,s);return this._callbacks.get(e).push(r),r}on(e,t,i=this){return this._addCallback(e,t,i,false)}once(e,t,i=this){return this._addCallback(e,t,i,true)}off(e,t,i){if(e)this._callbackActive.has(e)&&this._callbackActive.get(e)===this._callbacks.get(e)&&this._callbackActive.set(e,this._callbackActive.get(e).slice());else for(let[e,t]of this._callbackActive)this._callbacks.has(e)&&this._callbacks.get(e)===t&&this._callbackActive.set(e,t.slice());if(e)if(t){let s=this._callbacks.get(e);if(!s)return this;for(let e=0;e<s.length;e++)s[e].callback===t&&(!i||s[e].scope===i)&&(s[e].removed=true,s.splice(e,1),e--);0===s.length&&this._callbacks.delete(e);}else {let t=this._callbacks.get(e);if(t){for(let e=0;e<t.length;e++)t[e].removed=true;this._callbacks.delete(e);}}else {for(let e of this._callbacks.values())for(let t=0;t<e.length;t++)e[t].removed=true;this._callbacks.clear();}return this}offByHandle(e){let t=e.name;e.removed=true,this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());let i=this._callbacks.get(t);if(!i)return this;let s=i.indexOf(e);return -1!==s&&(i.splice(s,1),0===i.length&&this._callbacks.delete(t)),this}fire(e,t,i,s,r,a,n,o,l){let h;if(!e)return this;let c=this._callbacks.get(e);if(!c)return this;this._callbackActive.has(e)?this._callbackActive.get(e)!==c&&(h=c.slice()):this._callbackActive.set(e,c);for(let c=0;(h||this._callbackActive.get(e))&&c<(h||this._callbackActive.get(e)).length;c++){let d=(h||this._callbackActive.get(e))[c];if(d.callback&&(d.callback.call(d.scope,t,i,s,r,a,n,o,l),d._once)){let t=this._callbacks.get(e),i=t?t.indexOf(d):-1;if(-1!==i){this._callbackActive.get(e)===t&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let s=this._callbacks.get(e);if(!s)continue;s[i].removed=true,s.splice(i,1),0===s.length&&this._callbacks.delete(e);}}}return h||this._callbackActive.delete(e),this}hasEvent(e){return !!this._callbacks.get(e)?.length}constructor(){this._callbacks=new Map,this._callbackActive=new Map;}}class eh{push(e,t){if(this._index[e])throw Error(`Key already in index ${e}`);let i=this._list.push(t)-1;this._index[e]=i;}has(e){return void 0!==this._index[e]}get(e){let t=this._index[e];return void 0!==t?this._list[t]:null}remove(e){let t=this._index[e];if(void 0!==t){for(e in this._list.splice(t,1),delete this._index[e],this._index){let i=this._index[e];i>t&&(this._index[e]=i-1);}return true}return false}list(){return this._list}clear(){for(let e in this._list.length=0,this._index)delete this._index[e];}constructor(){this._list=[],this._index={};}}class ec{static{this.modules={};}static{this.wasmSupported=(e=>{let t={},i=t;return ()=>(i===t&&(i=e()),i)})(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){let e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}return false});}static loadScript(e,t){let i=document.createElement("script");i.setAttribute("src",e),i.onload=()=>{t(null);},i.onerror=()=>{t(`Failed to load script='${e}'`);},document.body.appendChild(i);}static loadWasm(e,t,i){let s=ec.wasmSupported()&&t.glueUrl&&t.wasmUrl?t.glueUrl:t.fallbackUrl;s?ec.loadScript(s,s=>{if(s)i(s,null);else {let s=window[e];window[e]=void 0,s({locateFile:()=>t.wasmUrl,onAbort:()=>{i("wasm module aborted.");}}).then(e=>{i(null,e);});}}):i("No supported wasm modules found.",null);}static getModule(e){return ec.modules.hasOwnProperty(e)||(ec.modules[e]={config:null,initializing:false,instance:null,callbacks:[]}),ec.modules[e]}static initialize(e,t){if(t.initializing)return;let i=t.config;(i.glueUrl||i.wasmUrl||i.fallbackUrl)&&(t.initializing=true,ec.loadWasm(e,i,(e,s)=>{e?i.errorHandler&&i.errorHandler(e):(t.instance=s,t.callbacks.forEach(e=>{e(s);}));}));}}class ed{static setConfig(e,t){let i=ec.getModule(e);i.config=t,i.callbacks.length>0&&ec.initialize(e,i);}static getConfig(e){return ec.modules?.[e]?.config}static getInstance(e,t){let i=ec.getModule(e);i.instance?t(i.instance):(i.callbacks.push(t),i.config&&ec.initialize(e,i));}}class eu{constructor(e){this.offset=0,this.arraybuffer=e,this.dataView=new DataView(e);}get remainingBytes(){return this.dataView.byteLength-this.offset}reset(e=0){this.offset=e;}skip(e){this.offset+=e;}align(e){this.offset=this.offset+e-1&~(e-1);}_inc(e){return this.offset+=e,this.offset-e}readChar(){return String.fromCharCode(this.dataView.getUint8(this.offset++))}readChars(e){let t="";for(let i=0;i<e;++i)t+=this.readChar();return t}readU8(){return this.dataView.getUint8(this.offset++)}readU16(){return this.dataView.getUint16(this._inc(2),true)}readU32(){return this.dataView.getUint32(this._inc(4),true)}readU64(){return this.readU32()+0x100000000*this.readU32()}readU32be(){return this.dataView.getUint32(this._inc(4),false)}readArray(e){for(let t=0;t<e.length;++t)e[t]=this.readU8();}readLine(){let e=this.dataView,t="";for(;!(this.offset>=e.byteLength);){let e=String.fromCharCode(this.readU8());if("\n"===e)break;t+=e;}return t}}class ef{constructor(e){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=e.sortBy,this._sortHandler=this._doSort.bind(this);}_binarySearch(e){let t,i,s=0,r=this.items.length-1,a=e[this._sortBy];for(;s<=r;)t=Math.floor((s+r)/2),(i=this.items[t][this._sortBy])<=a?s=t+1:i>a&&(r=t-1);return s}_doSort(e,t){let i=this._sortBy;return e[i]-t[i]}insert(e){let t=this._binarySearch(e);this.items.splice(t,0,e),this.length++,this.loopIndex>=t&&this.loopIndex++;}append(e){this.items.push(e),this.length++;}remove(e){let t=this.items.indexOf(e);!(t<0)&&(this.items.splice(t,1),this.length--,this.loopIndex>=t&&this.loopIndex--);}sort(){let e=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),null!==e&&(this.loopIndex=this.items.indexOf(e));}}class ep extends el{static{this.EVENT_ADD="add";}static{this.EVENT_REMOVE="remove";}static{this.EVENT_CHANGE="change";}constructor(e){super(),this._index={},this._list=[],this._parent=e;}add(...e){let t=false,i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]||(t=true,this._index[i[e]]=true,this._list.push(i[e]),this.fire("add",i[e],this._parent));return t&&this.fire("change",this._parent),t}remove(...e){let t=false;if(!this._list.length)return t;let i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]&&(t=true,delete this._index[i[e]],this._list.splice(this._list.indexOf(i[e]),1),this.fire("remove",i[e],this._parent));return t&&this.fire("change",this._parent),t}clear(){if(!this._list.length)return;let e=this._list.slice(0);this._list=[],this._index={};for(let t=0;t<e.length;t++)this.fire("remove",e[t],this._parent);this.fire("change",this._parent);}has(...e){return !!this._list.length&&this._has(this._processArguments(e))}_has(e){if(!this._list.length||!e.length)return false;for(let t=0;t<e.length;t++)if(1===e[t].length){if(this._index[e[t][0]])return true}else {let i=true;for(let s=0;s<e[t].length;s++)if(!this._index[e[t][s]]){i=false;break}if(i)return true}return false}list(){return this._list.slice(0)}_processArguments(e,t){let i=[],s=[];if(!e||!e.length)return i;for(let r=0;r<e.length;r++)if(e[r]instanceof Array){t||(s=[]);for(let a=0;a<e[r].length;a++)"string"==typeof e[r][a]&&(t?i.push(e[r][a]):s.push(e[r][a]));!t&&s.length&&i.push(s);}else "string"==typeof e[r]&&(t?i.push(e[r]):i.push([e[r]]));return i}get size(){return this._list.length}}let em="undefined"!=typeof window&&window.performance&&window.performance.now?performance.now.bind(performance):Date.now;function e_(e){let t="";if((e.authority||e.scheme)&&(e.host||e.hostpath))throw Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(e.host&&e.hostpath)throw Error("Can't have 'host' and 'hostpath' option");if(e.path&&e.hostpath)throw Error("Can't have 'path' and 'hostpath' option");return e.scheme&&(t+=`${e.scheme}:`),e.authority&&(t+=`//${e.authority}`),e.host&&(t+=e.host),e.path&&(t+=e.path),e.hostpath&&(t+=e.hostpath),e.query&&(t+=`?${e.query}`),e.fragment&&(t+=`#${e.fragment}`),t}let eg=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class ev{constructor(e){let t=e.match(eg);this.scheme=t[2],this.authority=t[4],this.path=t[5],this.query=t[7],this.fragment=t[9];}toString(){let e="";return this.scheme&&(e+=`${this.scheme}:`),this.authority&&(e+=`//${this.authority}`),e+=this.path,this.query&&(e+=`?${this.query}`),this.fragment&&(e+=`#${this.fragment}`),e}getQuery(){let e={};if(this.query)for(let t of decodeURIComponent(this.query).split("&")){let i=t.split("=");e[i[0]]=i[1];}return e}setQuery(e){let t="";for(let i in e)e.hasOwnProperty(i)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`);this.query=t;}}class eS{static{this._traceChannels=new Set;}static{this.stack=false;}static set(e,t=true){}static get(e){return eS._traceChannels.has(e)}}let ey=0,ex=1,eT=4,eE=5,eb={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:(e,t,i)=>e>=i?i:e<=t?t:e,intToBytes24:e=>[e>>16&255,e>>8&255,255&e],intToBytes32:e=>[e>>24&255,e>>16&255,e>>8&255,255&e],bytesToInt24:(e,t,i)=>(e.length&&(i=e[2],t=e[1],e=e[0]),e<<16|t<<8|i),bytesToInt32:(e,t,i,s)=>(e.length&&(s=e[3],i=e[2],t=e[1],e=e[0]),(e<<24|t<<16|i<<8|s)>>>0),lerp:(e,t,i)=>e+(t-e)*eb.clamp(i,0,1),lerpAngle:(e,t,i)=>(t-e>180&&(t-=360),t-e<-180&&(t+=360),eb.lerp(e,t,eb.clamp(i,0,1))),powerOfTwo:e=>0!==e&&!(e&e-1),nextPowerOfTwo:e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e),nearestPowerOfTwo:e=>Math.pow(2,Math.round(Math.log2(e))),random:(e,t)=>Math.random()*(t-e)+e,smoothstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*(3-2*i),smootherstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*i*(i*(6*i-15)+10),roundUp:(e,t)=>0===t?e:Math.ceil(e/t)*t,between(e,t,i,s){let r=Math.min(t,i),a=Math.max(t,i);return s?e>=r&&e<=a:e>r&&e<a}};class ew{constructor(e=0,t=0,i=0,s=1){let r=e.length;3===r||4===r?(this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3]??1):(this.r=e,this.g=t,this.b=i,this.a=s);}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}equals(e){return this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}set(e,t,i,s=1){return this.r=e,this.g=t,this.b=i,this.a=s,this}lerp(e,t,i){return this.r=e.r+i*(t.r-e.r),this.g=e.g+i*(t.g-e.g),this.b=e.b+i*(t.b-e.b),this.a=e.a+i*(t.a-e.a),this}linear(e=this){return this.r=Math.pow(e.r,2.2),this.g=Math.pow(e.g,2.2),this.b=Math.pow(e.b,2.2),this.a=e.a,this}gamma(e=this){return this.r=Math.pow(e.r,1/2.2),this.g=Math.pow(e.g,1/2.2),this.b=Math.pow(e.b,1/2.2),this.a=e.a,this}mulScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}fromString(e){let t,i=parseInt(e.replace("#","0x"),16);return e.length>7?t=eb.intToBytes32(i):(t=eb.intToBytes24(i))[3]=255,this.set(t[0]/255,t[1]/255,t[2]/255,t[3]/255),this}fromArray(e,t=0){return this.r=e[t]??this.r,this.g=e[t+1]??this.g,this.b=e[t+2]??this.b,this.a=e[t+3]??this.a,this}toString(e,t){let{r:i,g:s,b:r,a}=this;if(t||i>1||s>1||r>1)return `${i.toFixed(3)}, ${s.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let n=`#${(0x1000000+(Math.round(255*i)<<16)+(Math.round(255*s)<<8)+Math.round(255*r)).toString(16).slice(1)}`;if(true===e){let e=Math.round(255*a).toString(16);this.a<16/255?n+=`0${e}`:n+=e;}return n}toArray(e=[],t=0,i=true){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,i&&(e[t+3]=this.a),e}static{this.BLACK=Object.freeze(new ew(0,0,0,1));}static{this.BLUE=Object.freeze(new ew(0,0,1,1));}static{this.CYAN=Object.freeze(new ew(0,1,1,1));}static{this.GRAY=Object.freeze(new ew(.5,.5,.5,1));}static{this.GREEN=Object.freeze(new ew(0,1,0,1));}static{this.MAGENTA=Object.freeze(new ew(1,0,1,1));}static{this.RED=Object.freeze(new ew(1,0,0,1));}static{this.WHITE=Object.freeze(new ew(1,1,1,1));}static{this.YELLOW=Object.freeze(new ew(1,1,0,1));}}class eA{constructor(e,t=0){this._left=-1/0,this._right=1/0,this._recip=0,this._p0=0,this._p1=0,this._m0=0,this._m1=0,this._curve=e,this._reset(t);}evaluate(e,t=false){let i;(t||e<this._left||e>=this._right)&&this._reset(e);let s=this._curve.type;if(s===eE)i=this._p0;else {let t=0===this._recip?0:(e-this._left)*this._recip;i=s===ey?eb.lerp(this._p0,this._p1,t):s===ex?eb.lerp(this._p0,this._p1,t*t*(3-2*t)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,t);}return i}_reset(e){let t=this._curve.keys,i=t.length;if(i)if(e<t[0][0])this._left=-1/0,this._right=t[0][0],this._recip=0,this._p0=this._p1=t[0][1],this._m0=this._m1=0;else if(e>=t[i-1][0])this._left=t[i-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=t[i-1][1],this._m0=this._m1=0;else {let i=0;for(;e>=t[i+1][0];)i++;this._left=t[i][0],this._right=t[i+1][0];let s=1/(this._right-this._left);this._recip=isFinite(s)?s:0,this._p0=t[i][1],this._p1=t[i+1][1],this._curve.type===eT&&this._calcTangents(t,i);}else this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0;}_calcTangents(e,t){let i,s,r=e[t],a=e[t+1];if(i=0===t?[e[0][0]+(e[0][0]-e[1][0]),e[0][1]+(e[0][1]-e[1][1])]:e[t-1],s=t===e.length-2?[e[t+1][0]+(e[t+1][0]-e[t][0]),e[t+1][1]+(e[t+1][1]-e[t][1])]:e[t+2],this._curve.type===eT){let e=2*(a[0]-r[0])/(a[0]-i[0]),t=2*(a[0]-r[0])/(s[0]-r[0]);this._m0=this._curve.tension*(isFinite(e)?e:0)*(a[1]-i[1]),this._m1=this._curve.tension*(isFinite(t)?t:0)*(s[1]-r[1]);}else {let e=(a[0]-r[0])/(r[0]-i[0]),t=(a[0]-r[0])/(s[0]-a[0]),n=r[1]+(i[1]-r[1])*(isFinite(e)?e:0),o=a[1]+(s[1]-a[1])*(isFinite(t)?t:0),l=this._curve.tension;this._m0=l*(a[1]-n),this._m1=l*(o-r[1]);}}_evaluateHermite(e,t,i,s,r){let a=r*r,n=r+r,o=1-r,l=o*o;return (1+n)*l*e+r*l*i+a*(3-n)*t+a*(r-1)*s}}class eC{constructor(e){if(this.keys=[],this.type=ex,this.tension=.5,this._eval=new eA(this),e)for(let t=0;t<e.length-1;t+=2)this.keys.push([e[t],e[t+1]]);this.sort();}get length(){return this.keys.length}add(e,t){let i=this.keys,s=i.length,r=0;for(;r<s&&!(i[r][0]>e);r++);let a=[e,t];return this.keys.splice(r,0,a),a}get(e){return this.keys[e]}sort(){this.keys.sort((e,t)=>e[0]-t[0]);}value(e){return this._eval.evaluate(e,true)}closest(e){let t=this.keys,i=t.length,s=2,r=null;for(let a=0;a<i;a++){let i=Math.abs(e-t[a][0]);if(s>=i)s=i,r=t[a];else break}return r}clone(){let e=new this.constructor;return e.keys=this.keys.map(e=>[...e]),e.type=this.type,e.tension=this.tension,e}quantize(e){let t=new Float32Array(e=Math.max(e,2)),i=1/(e-1);t[0]=this._eval.evaluate(0,true);for(let s=1;s<e;s++)t[s]=this._eval.evaluate(i*s);return t}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}class eP{constructor(...e){if(this.curves=[],this._type=ex,e.length>1)for(let t=0;t<e.length;t++)this.curves.push(new eC(e[t]));else if(0===e.length)this.curves.push(new eC);else {let t=e[0];if("number"==typeof t)for(let e=0;e<t;e++)this.curves.push(new eC);else for(let e=0;e<t.length;e++)this.curves.push(new eC(t[e]));}}get length(){return this.curves.length}set type(e){this._type=e;for(let t=0;t<this.curves.length;t++)this.curves[t].type=e;}get type(){return this._type}get(e){return this.curves[e]}value(e,t=[]){let i=this.curves.length;t.length=i;for(let s=0;s<i;s++)t[s]=this.curves[s].value(e);return t}clone(){let e=new this.constructor;e.curves=[];for(let t=0;t<this.curves.length;t++)e.curves.push(this.curves[t].clone());return e._type=this._type,e}quantize(e){e=Math.max(e,2);let t=this.curves.length,i=new Float32Array(e*t),s=1/(e-1);for(let r=0;r<t;r++){let a=new eA(this.curves[r]);for(let n=0;n<e;n++)i[n*t+r]=a.evaluate(s*n);}return i}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}let eL=new Float32Array(1),eD=new Int32Array(eL.buffer);class eI{static float2Half(e){eL[0]=e;let t=eD[0],i=t>>16&32768,s=t>>12&2047,r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=+(255!==r)&&8388607&t):r<113?(s|=2048,i|=(s>>114-r)+(s>>113-r&1)):(i|=r-112<<10|s>>1,i+=1&s)}static float2RGBA8(e,t){eL[0]=e;let i=eD[0];t.r=(i>>24&255)/255,t.g=(i>>16&255)/255,t.b=(i>>8&255)/255,t.a=(255&i)/255;}}class eR{static concentric(e,t){let i=[];i.push(0,0);let s=2*Math.PI/e/t;for(let t=1;t<=e;t++){let r=t/e,a=Math.max(1,Math.floor(2*Math.PI*r/s)),n=2*Math.PI/a;for(let e=0;e<a;e++){let t=e*n,s=r*Math.cos(t),a=r*Math.sin(t);i.push(s,a);}}return i}}class eM{constructor(e=0,t=0,i=0){3===e.length?(this.x=e[0],this.y=e[1],this.z=e[2]):(this.x=e,this.y=t,this.z=i);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}cross(e,t){let i=e.x,s=e.y,r=e.z,a=t.x,n=t.y,o=t.z;return this.x=s*o-n*r,this.y=r*a-o*i,this.z=i*n-a*s,this}distance(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return Math.sqrt(t*t+i*i+s*s)}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this}project(e){let t=(this.x*e.x+this.y*e.y+this.z*e.z)/(e.x*e.x+e.y*e.y+e.z*e.z);return this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this}toString(){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,e}static{this.ZERO=Object.freeze(new eM(0,0,0));}static{this.HALF=Object.freeze(new eM(.5,.5,.5));}static{this.ONE=Object.freeze(new eM(1,1,1));}static{this.UP=Object.freeze(new eM(0,1,0));}static{this.DOWN=Object.freeze(new eM(0,-1,0));}static{this.RIGHT=Object.freeze(new eM(1,0,0));}static{this.LEFT=Object.freeze(new eM(-1,0,0));}static{this.FORWARD=Object.freeze(new eM(0,0,-1));}static{this.BACK=Object.freeze(new eM(0,0,1));}}class eO{constructor(){this.data=new Float32Array(9),this.data[0]=this.data[4]=this.data[8]=1;}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}getX(e=new eM){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eM){return e.set(this.data[3],this.data[4],this.data[5])}getZ(e=new eM){return e.set(this.data[6],this.data[7],this.data[8])}equals(e){let t=this.data,i=e.data;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]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&1===e[4]&&0===e[5]&&0===e[6]&&0===e[7]&&1===e[8]}setIdentity(){let e=this.data;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this}toString(){return `[${this.data.join(", ")}]`}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[3],i[3]=e,e=t[2],i[2]=t[6],i[6]=e,e=t[5],i[5]=t[7],i[7]=e;}else i[0]=t[0],i[1]=t[3],i[2]=t[6],i[3]=t[1],i[4]=t[4],i[5]=t[7],i[6]=t[2],i[7]=t[5],i[8]=t[8];return this}setFromMat4(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[4],i[4]=t[5],i[5]=t[6],i[6]=t[8],i[7]=t[9],i[8]=t[10],this}setFromQuat(e){let t=e.x,i=e.y,s=e.z,r=e.w,a=t+t,n=i+i,o=s+s,l=t*a,h=t*n,c=t*o,d=i*n,u=i*o,f=s*o,p=r*a,m=r*n,_=r*o,g=this.data;return g[0]=1-(d+f),g[1]=h+_,g[2]=c-m,g[3]=h-_,g[4]=1-(l+f),g[5]=u+p,g[6]=c+m,g[7]=u-p,g[8]=1-(l+d),this}invertMat4(e){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[4],n=t[5],o=t[6],l=t[8],h=t[9],c=t[10],d=c*n-o*h,u=-c*a+o*l,f=h*a-n*l,p=i*d+s*u+r*f;if(0===p)this.setIdentity();else {let e=1/p,t=this.data;t[0]=d*e,t[1]=(-c*s+r*h)*e,t[2]=(o*s-r*n)*e,t[3]=u*e,t[4]=(c*i-r*l)*e,t[5]=(-o*i+r*a)*e,t[6]=f*e,t[7]=(-h*i+s*l)*e,t[8]=(n*i-s*a)*e;}return this}transformVector(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[3]+a*i[6],t.y=s*i[1]+r*i[4]+a*i[7],t.z=s*i[2]+r*i[5]+a*i[8],t}static{this.IDENTITY=Object.freeze(new eO);}static{this.ZERO=Object.freeze(new eO().set([0,0,0,0,0,0,0,0,0]));}}class eF{constructor(e=0,t=0){2===e.length?(this.x=e[0],this.y=e[1]):(this.x=e,this.y=t);}add(e){return this.x+=e.x,this.y+=e.y,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}cross(e){return this.x*e.y-this.y*e.x}distance(e){let t=this.x-e.x,i=this.y-e.y;return Math.sqrt(t*t+i*i)}div(e){return this.x/=e.x,this.y/=e.y,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}divScalar(e){return this.x/=e,this.y/=e,this}dot(e){return this.x*e.x+this.y*e.y}equals(e){return this.x===e.x&&this.y===e.y}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSq(){return this.x*this.x+this.y*this.y}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this}mul(e){return this.x*=e.x,this.y*=e.y,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}mulScalar(e){return this.x*=e,this.y*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i;}return this}rotate(e){let t=Math.atan2(this.x,this.y)+e*eb.DEG_TO_RAD,i=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(t)*i,this.y=Math.cos(t)*i,this}angle(){return Math.atan2(this.x,this.y)*eb.RAD_TO_DEG}angleTo(e){return Math.atan2(this.x*e.y+this.y*e.x,this.x*e.x+this.y*e.y)*eb.RAD_TO_DEG}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),this}set(e,t){return this.x=e,this.y=t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}subScalar(e){return this.x-=e,this.y-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this}toString(){return `[${this.x}, ${this.y}]`}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}static angleRad(e,t){return Math.atan2(e.x*t.y-e.y*t.x,e.x*t.x+e.y*t.y)}static{this.ZERO=Object.freeze(new eF(0,0));}static{this.HALF=Object.freeze(new eF(.5,.5));}static{this.ONE=Object.freeze(new eF(1,1));}static{this.UP=Object.freeze(new eF(0,1));}static{this.DOWN=Object.freeze(new eF(0,-1));}static{this.RIGHT=Object.freeze(new eF(1,0));}static{this.LEFT=Object.freeze(new eF(-1,0));}}class eN{constructor(e=0,t=0,i=0,s=0){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this.w=e.w/t.w,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this.w/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this.w=e.w+i*(t.w-e.w),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this.w=e.w*t.w,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i,this.w=e.w*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this.w=Math.floor(e.w),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this.w=Math.ceil(e.w),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this.w=Math.round(e.w),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){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,e}static{this.ZERO=Object.freeze(new eN(0,0,0,0));}static{this.HALF=Object.freeze(new eN(.5,.5,.5,.5));}static{this.ONE=Object.freeze(new eN(1,1,1,1));}}let eB=new eF,eU=new eM,ek=new eM,ez=new eM,eV=new eM;class eG{constructor(){this.data=new Float32Array(16),this.data[0]=this.data[5]=this.data[10]=this.data[15]=1;}static _getPerspectiveHalfSize(e,t,i,s,r){r?(e.x=s*Math.tan(t*Math.PI/360),e.y=e.x/i):(e.y=s*Math.tan(t*Math.PI/360),e.x=e.y*i);}add2(e,t){let i=e.data,s=t.data,r=this.data;return r[0]=i[0]+s[0],r[1]=i[1]+s[1],r[2]=i[2]+s[2],r[3]=i[3]+s[3],r[4]=i[4]+s[4],r[5]=i[5]+s[5],r[6]=i[6]+s[6],r[7]=i[7]+s[7],r[8]=i[8]+s[8],r[9]=i[9]+s[9],r[10]=i[10]+s[10],r[11]=i[11]+s[11],r[12]=i[12]+s[12],r[13]=i[13]+s[13],r[14]=i[14]+s[14],r[15]=i[15]+s[15],this}add(e){return this.add2(this,e)}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],this}equals(e){let t=this.data,i=e.data;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]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}mul2(e,t){let i,s,r,a,n=e.data,o=t.data,l=this.data,h=n[0],c=n[1],d=n[2],u=n[3],f=n[4],p=n[5],m=n[6],_=n[7],g=n[8],v=n[9],S=n[10],y=n[11],x=n[12],T=n[13],E=n[14],b=n[15];return i=o[0],s=o[1],r=o[2],a=o[3],l[0]=h*i+f*s+g*r+x*a,l[1]=c*i+p*s+v*r+T*a,l[2]=d*i+m*s+S*r+E*a,l[3]=u*i+_*s+y*r+b*a,i=o[4],s=o[5],r=o[6],a=o[7],l[4]=h*i+f*s+g*r+x*a,l[5]=c*i+p*s+v*r+T*a,l[6]=d*i+m*s+S*r+E*a,l[7]=u*i+_*s+y*r+b*a,i=o[8],s=o[9],r=o[10],a=o[11],l[8]=h*i+f*s+g*r+x*a,l[9]=c*i+p*s+v*r+T*a,l[10]=d*i+m*s+S*r+E*a,l[11]=u*i+_*s+y*r+b*a,i=o[12],s=o[13],r=o[14],a=o[15],l[12]=h*i+f*s+g*r+x*a,l[13]=c*i+p*s+v*r+T*a,l[14]=d*i+m*s+S*r+E*a,l[15]=u*i+_*s+y*r+b*a,this}mulAffine2(e,t){let i,s,r,a=e.data,n=t.data,o=this.data,l=a[0],h=a[1],c=a[2],d=a[4],u=a[5],f=a[6],p=a[8],m=a[9],_=a[10],g=a[12],v=a[13],S=a[14];return i=n[0],s=n[1],r=n[2],o[0]=l*i+d*s+p*r,o[1]=h*i+u*s+m*r,o[2]=c*i+f*s+_*r,o[3]=0,i=n[4],s=n[5],r=n[6],o[4]=l*i+d*s+p*r,o[5]=h*i+u*s+m*r,o[6]=c*i+f*s+_*r,o[7]=0,i=n[8],s=n[9],r=n[10],o[8]=l*i+d*s+p*r,o[9]=h*i+u*s+m*r,o[10]=c*i+f*s+_*r,o[11]=0,i=n[12],s=n[13],r=n[14],o[12]=l*i+d*s+p*r+g,o[13]=h*i+u*s+m*r+v,o[14]=c*i+f*s+_*r+S,o[15]=1,this}mul(e){return this.mul2(this,e)}transformPoint(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+i[12],t.y=s*i[1]+r*i[5]+a*i[9]+i[13],t.z=s*i[2]+r*i[6]+a*i[10]+i[14],t}transformVector(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8],t.y=s*i[1]+r*i[5]+a*i[9],t.z=s*i[2]+r*i[6]+a*i[10],t}transformVec4(e,t=new eN){let i=this.data,{x:s,y:r,z:a,w:n}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+n*i[12],t.y=s*i[1]+r*i[5]+a*i[9]+n*i[13],t.z=s*i[2]+r*i[6]+a*i[10]+n*i[14],t.w=s*i[3]+r*i[7]+a*i[11]+n*i[15],t}setLookAt(e,t,i){ez.sub2(e,t).normalize(),ek.copy(i).normalize(),eU.cross(ek,ez).normalize(),ek.cross(ez,eU);let s=this.data;return s[0]=eU.x,s[1]=eU.y,s[2]=eU.z,s[3]=0,s[4]=ek.x,s[5]=ek.y,s[6]=ek.z,s[7]=0,s[8]=ez.x,s[9]=ez.y,s[10]=ez.z,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}setFrustum(e,t,i,s,r,a){let n=2*r,o=t-e,l=s-i,h=a-r,c=this.data;return c[0]=n/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=n/l,c[6]=0,c[7]=0,c[8]=(t+e)/o,c[9]=(s+i)/l,c[10]=(-a-r)/h,c[11]=-1,c[12]=0,c[13]=0,c[14]=-n*a/h,c[15]=0,this}setPerspective(e,t,i,s,r){return eG._getPerspectiveHalfSize(eB,e,t,i,r),this.setFrustum(-eB.x,eB.x,-eB.y,eB.y,i,s)}setOrtho(e,t,i,s,r,a){let n=this.data;return n[0]=2/(t-e),n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=2/(s-i),n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=-2/(a-r),n[11]=0,n[12]=-(t+e)/(t-e),n[13]=-(s+i)/(s-i),n[14]=-(a+r)/(a-r),n[15]=1,this}setFromAxisAngle(e,t){t*=eb.DEG_TO_RAD;let{x:i,y:s,z:r}=e,a=Math.cos(t),n=Math.sin(t),o=1-a,l=o*i,h=o*s,c=this.data;return c[0]=l*i+a,c[1]=l*s+n*r,c[2]=l*r-n*s,c[3]=0,c[4]=l*s-n*r,c[5]=h*s+a,c[6]=h*r+n*i,c[7]=0,c[8]=l*r+n*s,c[9]=h*r-i*n,c[10]=o*r*r+a,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,this}setTranslate(e,t,i){let s=this.data;return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=e,s[13]=t,s[14]=i,s[15]=1,this}setScale(e,t,i){let s=this.data;return s[0]=e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=t,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=i,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}setViewport(e,t,i,s){let r=this.data;return r[0]=.5*i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=.5*s,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=e+.5*i,r[13]=t+.5*s,r[14]=.5,r[15]=1,this}setReflection(e,t){let i=e.x,s=e.y,r=e.z,a=this.data;return a[0]=1-2*i*i,a[1]=-2*i*s,a[2]=-2*i*r,a[3]=0,a[4]=-2*i*s,a[5]=1-2*s*s,a[6]=-2*s*r,a[7]=0,a[8]=-2*i*r,a[9]=-2*s*r,a[10]=1-2*r*r,a[11]=0,a[12]=-2*i*t,a[13]=-2*s*t,a[14]=-2*r*t,a[15]=1,this}invert(e=this){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[3],n=t[4],o=t[5],l=t[6],h=t[7],c=t[8],d=t[9],u=t[10],f=t[11],p=t[12],m=t[13],_=t[14],g=t[15],v=i*o-s*n,S=i*l-r*n,y=i*h-a*n,x=s*l-r*o,T=s*h-a*o,E=r*h-a*l,b=c*m-d*p,w=c*_-u*p,A=c*g-f*p,C=d*_-u*m,P=d*g-f*m,L=u*g-f*_,D=v*L-S*P+y*C+x*A-T*w+E*b;if(0===D)this.setIdentity();else {let e=1/D,t=this.data;t[0]=(o*L-l*P+h*C)*e,t[1]=(-s*L+r*P-a*C)*e,t[2]=(m*E-_*T+g*x)*e,t[3]=(-d*E+u*T-f*x)*e,t[4]=(-n*L+l*A-h*w)*e,t[5]=(i*L-r*A+a*w)*e,t[6]=(-p*E+_*y-g*S)*e,t[7]=(c*E-u*y+f*S)*e,t[8]=(n*P-o*A+h*b)*e,t[9]=(-i*P+s*A-a*b)*e,t[10]=(p*T-m*y+g*v)*e,t[11]=(-c*T+d*y-f*v)*e,t[12]=(-n*C+o*w-l*b)*e,t[13]=(i*C-s*w+r*b)*e,t[14]=(-p*x+m*S-_*v)*e,t[15]=(c*x-d*S+u*v)*e;}return this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}setIdentity(){let e=this.data;return 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,this}setTRS(e,t,i){let s=t.x,r=t.y,a=t.z,n=t.w,o=i.x,l=i.y,h=i.z,c=s+s,d=r+r,u=a+a,f=s*c,p=s*d,m=s*u,_=r*d,g=r*u,v=a*u,S=n*c,y=n*d,x=n*u,T=this.data;return T[0]=(1-(_+v))*o,T[1]=(p+x)*o,T[2]=(m-y)*o,T[3]=0,T[4]=(p-x)*l,T[5]=(1-(f+v))*l,T[6]=(g+S)*l,T[7]=0,T[8]=(m+y)*h,T[9]=(g-S)*h,T[10]=(1-(f+_))*h,T[11]=0,T[12]=e.x,T[13]=e.y,T[14]=e.z,T[15]=1,this}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[4],i[4]=e,e=t[2],i[2]=t[8],i[8]=e,e=t[3],i[3]=t[12],i[12]=e,e=t[6],i[6]=t[9],i[9]=e,e=t[7],i[7]=t[13],i[13]=e,e=t[11],i[11]=t[14],i[14]=e;}else i[0]=t[0],i[1]=t[4],i[2]=t[8],i[3]=t[12],i[4]=t[1],i[5]=t[5],i[6]=t[9],i[7]=t[13],i[8]=t[2],i[9]=t[6],i[10]=t[10],i[11]=t[14],i[12]=t[3],i[13]=t[7],i[14]=t[11],i[15]=t[15];return this}getTranslation(e=new eM){return e.set(this.data[12],this.data[13],this.data[14])}getX(e=new eM){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eM){return e.set(this.data[4],this.data[5],this.data[6])}getZ(e=new eM){return e.set(this.data[8],this.data[9],this.data[10])}getScale(e=new eM){return this.getX(eU),this.getY(ek),this.getZ(ez),e.set(eU.length(),ek.length(),ez.length()),e}get scaleSign(){return this.getX(eU),this.getY(ek),this.getZ(ez),eU.cross(eU,ek),0>eU.dot(ez)?-1:1}setFromEulerAngles(e,t,i){e*=eb.DEG_TO_RAD,t*=eb.DEG_TO_RAD,i*=eb.DEG_TO_RAD;let s=Math.sin(-e),r=Math.cos(-e),a=Math.sin(-t),n=Math.cos(-t),o=Math.sin(-i),l=Math.cos(-i),h=this.data;return h[0]=n*l,h[1]=-n*o,h[2]=a,h[3]=0,h[4]=r*o+l*s*a,h[5]=r*l-s*a*o,h[6]=-n*s,h[7]=0,h[8]=s*o-r*l*a,h[9]=l*s+r*a*o,h[10]=r*n,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,this}getEulerAngles(e=new eM){let t,i;this.getScale(eV);let s=eV.x,r=eV.y,a=eV.z;if(0===s||0===r||0===a)return e.set(0,0,0);let n=this.data,o=Math.asin(-n[2]/s),l=.5*Math.PI;return o<l?o>-l?(t=Math.atan2(n[6]/r,n[10]/a),i=Math.atan2(n[1]/s,n[0]/s)):(i=0,t=-Math.atan2(n[4]/r,n[5]/r)):(i=0,t=Math.atan2(n[4]/r,n[5]/r)),e.set(t,o,i).mulScalar(eb.RAD_TO_DEG)}toString(){return `[${this.data.join(", ")}]`}static{this.IDENTITY=Object.freeze(new eG);}static{this.ZERO=Object.freeze(new eG().set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));}}class eH{constructor(e=0,t=0,i=0,s=1){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}conjugate(e=this){return this.x=-1*e.x,this.y=-1*e.y,this.z=-1*e.z,this.w=e.w,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}getAxisAngle(e){let t=2*Math.acos(this.w),i=Math.sin(t/2);return 0!==i?(e.x=this.x/i,e.y=this.y/i,e.z=this.z/i,(e.x<0||e.y<0||e.z<0)&&(e.x*=-1,e.y*=-1,e.z*=-1,t*=-1)):(e.x=1,e.y=0,e.z=0),t*eb.RAD_TO_DEG}getEulerAngles(e=new eM){let t,i,s,r=this.x,a=this.y,n=this.z,o=this.w,l=2*(o*a-r*n);return l<=-0.99999?(t=2*Math.atan2(r,o),i=-Math.PI/2,s=0):l>=.99999?(t=2*Math.atan2(r,o),i=Math.PI/2,s=0):(t=Math.atan2(2*(o*r+a*n),1-2*(r*r+a*a)),i=Math.asin(l),s=Math.atan2(2*(o*n+r*a),1-2*(a*a+n*n))),e.set(t,i,s).mulScalar(eb.RAD_TO_DEG)}invert(e=this){return this.conjugate(e).normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){let s=(1-i)*(0>e.dot(t)?-1:1);return this.x=e.x*s+t.x*i,this.y=e.y*s+t.y*i,this.z=e.z*s+t.z*i,this.w=e.w*s+t.w*i,this.normalize()}mul(e){let t=this.x,i=this.y,s=this.z,r=this.w,a=e.x,n=e.y,o=e.z,l=e.w;return this.x=r*a+t*l+i*o-s*n,this.y=r*n+i*l+s*a-t*o,this.z=r*o+s*l+t*n-i*a,this.w=r*l-t*a-i*n-s*o,this}mulScalar(e,t=this){return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e,this}mul2(e,t){let i=e.x,s=e.y,r=e.z,a=e.w,n=t.x,o=t.y,l=t.z,h=t.w;return this.x=a*n+i*h+s*l-r*o,this.y=a*o+s*h+r*n-i*l,this.z=a*l+r*h+i*o-s*n,this.w=a*h-i*n-s*o-r*l,this}normalize(e=this){let t=e.length();return 0===t?(this.x=this.y=this.z=0,this.w=1):(t=1/t,this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this.w=e.w*t),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setFromAxisAngle(e,t){let i=Math.sin(t*=.5*eb.DEG_TO_RAD),s=Math.cos(t);return this.x=i*e.x,this.y=i*e.y,this.z=i*e.z,this.w=s,this}setFromEulerAngles(e,t,i){if(e instanceof eM){let s=e;e=s.x,t=s.y,i=s.z;}let s=.5*eb.DEG_TO_RAD;e*=s,t*=s,i*=s;let r=Math.sin(e),a=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(i),h=Math.cos(i);return this.x=r*o*h-a*n*l,this.y=a*n*h+r*o*l,this.z=a*o*l-r*n*h,this.w=a*o*h+r*n*l,this}setFromMat4(e){let t,i=e.data,s=i[0],r=i[1],a=i[2],n=i[4],o=i[5],l=i[6],h=i[8],c=i[9],d=i[10];return (s*(o*d-l*c)-r*(n*d-l*h)+a*(n*c-o*h)<0&&(s=-s,r=-r,a=-a),0==(t=s*s+r*r+a*a)||(s*=t=1/Math.sqrt(t),r*=t,a*=t,0==(t=n*n+o*o+l*l)||(n*=t=1/Math.sqrt(t),o*=t,l*=t,0==(t=h*h+c*c+d*d))))?this.set(0,0,0,1):(h*=t=1/Math.sqrt(t),c*=t,(d*=t)<0?s>o?this.set(1+s-o-d,r+n,h+a,l-c):this.set(r+n,1-s+o-d,l+c,h-a):s<-o?this.set(h+a,l+c,1-s-o+d,r-n):this.set(l-c,h-a,r-n,1+s+o+d),this.mulScalar(1/this.length()))}setFromDirections(e,t){let i=1+e.dot(t);return i<Number.EPSILON?(Math.abs(e.x)>Math.abs(e.y)?(this.x=-e.z,this.y=0,this.z=e.x):(this.x=0,this.y=-e.z,this.z=e.y),this.w=0):(this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this.w=i),this.normalize()}slerp(e,t,i){let s=e.x,r=e.y,a=e.z,n=e.w,o=t.x,l=t.y,h=t.z,c=t.w,d=n*c+s*o+r*l+a*h;if(d<0&&(c=-c,o=-o,l=-l,h=-h,d=-d),Math.abs(d)>=1)return this.w=n,this.x=s,this.y=r,this.z=a,this;let u=Math.acos(d),f=Math.sqrt(1-d*d);if(.001>Math.abs(f))return this.w=.5*n+.5*c,this.x=.5*s+.5*o,this.y=.5*r+.5*l,this.z=.5*a+.5*h,this;let p=Math.sin((1-i)*u)/f,m=Math.sin(i*u)/f;return this.w=n*p+c*m,this.x=s*p+o*m,this.y=r*p+l*m,this.z=a*p+h*m,this}transformVector(e,t=new eM){let i=e.x,s=e.y,r=e.z,a=this.x,n=this.y,o=this.z,l=this.w,h=l*i+n*r-o*s,c=l*s+o*i-a*r,d=l*r+a*s-n*i,u=-a*i-n*s-o*r;return t.x=h*l+-(u*a)+-(c*o)- -(d*n),t.y=c*l+-(u*n)+-(d*a)- -(h*o),t.z=d*l+-(u*o)+-(h*n)- -(c*a),t}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){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,e}static{this.IDENTITY=Object.freeze(new eH(0,0,0,1));}static{this.ZERO=Object.freeze(new eH(0,0,0,0));}}let eW=new eM,eX=new eM,eY=new eM,eq=new eM,e$=new eM;class ej{constructor(e,t){this.center=new eM,this.halfExtents=new eM(.5,.5,.5),this._min=new eM,this._max=new eM,e&&this.center.copy(e),t&&this.halfExtents.copy(t);}add(e){let t=this.center,i=t.x,s=t.y,r=t.z,a=this.halfExtents,n=a.x,o=a.y,l=a.z,h=i-n,c=i+n,d=s-o,u=s+o,f=r-l,p=r+l,m=e.center,_=m.x,g=m.y,v=m.z,S=e.halfExtents,y=S.x,x=S.y,T=S.z,E=_-y,b=_+y,w=g-x,A=g+x,C=v-T,P=v+T;E<h&&(h=E),b>c&&(c=b),w<d&&(d=w),A>u&&(u=A),C<f&&(f=C),P>p&&(p=P),t.x=(h+c)*.5,t.y=(d+u)*.5,t.z=(f+p)*.5,a.x=(c-h)*.5,a.y=(u-d)*.5,a.z=(p-f)*.5;}copy(e){this.center.copy(e.center),this.halfExtents.copy(e.halfExtents);}clone(){return new ej(this.center,this.halfExtents)}intersects(e){let t=this.getMax(),i=this.getMin(),s=e.getMax(),r=e.getMin();return i.x<=s.x&&t.x>=r.x&&i.y<=s.y&&t.y>=r.y&&i.z<=s.z&&t.z>=r.z}_intersectsRay(e,t){let i=eW.copy(this.getMin()).sub(e.origin),s=eX.copy(this.getMax()).sub(e.origin),r=e.direction;0===r.x?(i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.x=s.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.x/=r.x,s.x/=r.x),0===r.y?(i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.y=s.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.y/=r.y,s.y/=r.y),0===r.z?(i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.z=s.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.z/=r.z,s.z/=r.z);let a=eY.set(Math.min(i.x,s.x),Math.min(i.y,s.y),Math.min(i.z,s.z)),n=eq.set(Math.max(i.x,s.x),Math.max(i.y,s.y),Math.max(i.z,s.z)),o=Math.min(Math.min(n.x,n.y),n.z),l=Math.max(Math.max(a.x,a.y),a.z),h=o>=l&&l>=0;return h&&t.copy(e.direction).mulScalar(l).add(e.origin),h}_fastIntersectsRay(e){let t=e.direction;return eW.sub2(e.origin,this.center),eq.set(Math.abs(eW.x),Math.abs(eW.y),Math.abs(eW.z)),eY.mul2(eW,t),(!(eq.x>this.halfExtents.x)||!(eY.x>=0))&&(!(eq.y>this.halfExtents.y)||!(eY.y>=0))&&(!(eq.z>this.halfExtents.z)||!(eY.z>=0))&&(e$.set(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z)),eX.cross(t,eW),eX.set(Math.abs(eX.x),Math.abs(eX.y),Math.abs(eX.z)),!(eX.x>this.halfExtents.y*e$.z+this.halfExtents.z*e$.y)&&!(eX.y>this.halfExtents.x*e$.z+this.halfExtents.z*e$.x)&&!(eX.z>this.halfExtents.x*e$.y+this.halfExtents.y*e$.x))}intersectsRay(e,t){return t?this._intersectsRay(e,t):this._fastIntersectsRay(e)}setMinMax(e,t){this.center.add2(t,e).mulScalar(.5),this.halfExtents.sub2(t,e).mulScalar(.5);}getMin(){return this._min.copy(this.center).sub(this.halfExtents)}getMax(){return this._max.copy(this.center).add(this.halfExtents)}containsPoint(e){let t=this.getMin(),i=this.getMax();return !(e.x<t.x)&&!(e.x>i.x)&&!(e.y<t.y)&&!(e.y>i.y)&&!(e.z<t.z)&&!(e.z>i.z)}setFromTransformedAabb(e,t,i=false){let s=e.center,r=e.halfExtents,a=t.data,n=a[0],o=a[4],l=a[8],h=a[1],c=a[5],d=a[9],u=a[2],f=a[6],p=a[10];if(i){let e=n*n+o*o+l*l;if(e>0){let t=1/Math.sqrt(e);n*=t,o*=t,l*=t;}if((e=h*h+c*c+d*d)>0){let t=1/Math.sqrt(e);h*=t,c*=t,d*=t;}if((e=u*u+f*f+p*p)>0){let t=1/Math.sqrt(e);u*=t,f*=t,p*=t;}}this.center.set(a[12]+n*s.x+o*s.y+l*s.z,a[13]+h*s.x+c*s.y+d*s.z,a[14]+u*s.x+f*s.y+p*s.z),this.halfExtents.set(Math.abs(n)*r.x+Math.abs(o)*r.y+Math.abs(l)*r.z,Math.abs(h)*r.x+Math.abs(c)*r.y+Math.abs(d)*r.z,Math.abs(u)*r.x+Math.abs(f)*r.y+Math.abs(p)*r.z);}static computeMinMax(e,t,i,s=e.length/3){if(s>0){let r=e[0],a=e[1],n=e[2],o=r,l=a,h=n,c=3*s;for(let t=3;t<c;t+=3){let i=e[t],s=e[t+1],c=e[t+2];i<r&&(r=i),s<a&&(a=s),c<n&&(n=c),i>o&&(o=i),s>l&&(l=s),c>h&&(h=c);}t.set(r,a,n),i.set(o,l,h);}}compute(e,t){ej.computeMinMax(e,eW,eX,t),this.setMinMax(eW,eX);}intersectsBoundingSphere(e){return this._distanceToBoundingSphereSq(e)<=e.radius*e.radius}_distanceToBoundingSphereSq(e){let t=this.getMin(),i=this.getMax(),s=0,r=["x","y","z"];for(let a=0;a<3;++a){let n=0,o=e.center[r[a]],l=t[r[a]],h=i[r[a]],c=0;o<l&&(n+=(c=l-o)*c),o>h&&(n+=(c=o-h)*c),s+=n;}return s}_expand(e,t){eW.add2(this.getMin(),e),eX.add2(this.getMax(),t),this.setMinMax(eW,eX);}}let eK=new eM,eZ=new eM;class eQ{constructor(e=new eM,t=.5){this.center=e,this.radius=t;}containsPoint(e){let t=eK.sub2(e,this.center).lengthSq(),i=this.radius;return t<i*i}intersectsRay(e,t){let i=eK.copy(e.origin).sub(this.center),s=i.dot(eZ.copy(e.direction).normalize()),r=i.dot(i)-this.radius*this.radius;if(r>0&&s>0)return false;let a=s*s-r;if(a<0)return false;let n=Math.abs(-s-Math.sqrt(a));return t&&t.copy(e.direction).mulScalar(n).add(e.origin),true}intersectsBoundingSphere(e){eK.sub2(e.center,this.center);let t=e.radius+this.radius;return eK.lengthSq()<=t*t}}class eJ{constructor(e=eM.UP,t=0){this.normal=new eM,this.normal.copy(e),this.distance=t;}clone(){return new this.constructor().copy(this)}copy(e){return this.normal.copy(e.normal),this.distance=e.distance,this}intersectsLine(e,t,i){let s=this.distance,r=this.normal.dot(e)+s,a=r/(r-(this.normal.dot(t)+s)),n=a>=0&&a<=1;return n&&i&&i.lerp(e,t,a),n}intersectsRay(e,t){let i=this.normal.dot(e.direction);if(0===i)return false;let s=-(this.normal.dot(e.origin)+this.distance)/i;return s>=0&&t&&t.copy(e.direction).mulScalar(s).add(e.origin),s>=0}normalize(){let e=1/this.normal.length();return this.normal.mulScalar(e),this.distance*=e,this}set(e,t,i,s){return this.normal.set(e,t,i),this.distance=s,this}setFromPointNormal(e,t){return this.normal.copy(t),this.distance=-this.normal.dot(e),this}}class e0{constructor(){this.planes=[];for(let e=0;e<6;e++)this.planes[e]=new eJ;}clone(){return new this.constructor().copy(this)}copy(e){for(let t=0;t<6;t++)this.planes[t].copy(e.planes[t]);return this}setFromMat4(e){let[t,i,s,r,a,n,o,l,h,c,d,u,f,p,m,_]=e.data,g=this.planes;g[0].set(r-t,l-a,u-h,_-f).normalize(),g[1].set(r+t,l+a,u+h,_+f).normalize(),g[2].set(r+i,l+n,u+c,_+p).normalize(),g[3].set(r-i,l-n,u-c,_-p).normalize(),g[4].set(r-s,l-o,u-d,_-m).normalize(),g[5].set(r+s,l+o,u+d,_+m).normalize();}containsPoint(e){for(let t=0;t<6;t++){let{normal:i,distance:s}=this.planes[t];if(i.dot(e)+s<=0)return false}return true}containsSphere(e){let{center:t,radius:i}=e,s=0;for(let e=0;e<6;e++){let{normal:r,distance:a}=this.planes[e],n=r.dot(t)+a;if(n<=-i)return 0;n>i&&s++;}return 6===s?2:1}}class e1{constructor(e,t){this.origin=new eM,this.direction=eM.FORWARD.clone(),e&&this.origin.copy(e),t&&this.direction.copy(t);}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.set(e.origin,e.direction)}clone(){return new this.constructor(this.origin,this.direction)}}let e2=new e1,e3=new eM,e4=new eQ,e5=new eG;class e8{constructor(e=new eG,t){this.halfExtents=new eM(.5,.5,.5),t&&this.halfExtents.copy(t),this._modelTransform=e.clone().invert(),this._worldTransform=e.clone(),this._aabb=new ej(new eM,this.halfExtents);}set worldTransform(e){this._worldTransform.copy(e),this._modelTransform.copy(e).invert();}get worldTransform(){return this._worldTransform}intersectsRay(e,t){if(this._modelTransform.transformPoint(e.origin,e2.origin),this._modelTransform.transformVector(e.direction,e2.direction),t){let e=this._aabb._intersectsRay(e2,t);return e5.copy(this._modelTransform).invert().transformPoint(t,t),e}return this._aabb._fastIntersectsRay(e2)}containsPoint(e){return this._modelTransform.transformPoint(e,e3),this._aabb.containsPoint(e3)}intersectsBoundingSphere(e){return this._modelTransform.transformPoint(e.center,e4.center),e4.radius=e.radius,!!this._aabb.intersectsBoundingSphere(e4)}}let e6=new eM,e9=new eM,e7=new eM,te=new eM,tt=new eM;class ti{constructor(e=eM.ZERO,t=eM.ZERO,i=eM.ZERO){this.v0=new eM,this.v1=new eM,this.v2=new eM,this.set(e,t,i);}set(e,t,i){return this.v0.copy(e),this.v1.copy(t),this.v2.copy(i),this}intersectsRay(e,t){e6.sub2(this.v1,this.v0),e9.sub2(this.v2,this.v0),e7.cross(e.direction,e9);let i=e6.dot(e7);if(i>-1e-6&&i<1e-6)return false;let s=1/i;te.sub2(e.origin,this.v0);let r=s*te.dot(e7);if(r<0||r>1)return false;tt.cross(te,e6);let a=s*e.direction.dot(tt);if(a<0||r+a>1)return false;let n=s*e9.dot(tt);return n>1e-6&&(t instanceof eM&&t.copy(e.direction).mulScalar(n).add(e.origin),true)}toString(){return `[${this.v0.toString()}, ${this.v1.toString()}, ${this.v2.toString()}]`}}let ts=0,tr=1,ta=2,tn=0,to=1,tl=2,th=3,tc=4,td=5,tu=6,tf=7,tp=8,tm=9,t_=10,tg=11,tv=12,tS=0,ty=1,tx=2,tT=3,tE=4,tb=1,tw=2,tA=4,tC=8,tP=16,tL=32,tD=64,tI=128,tR=256,tM=0,tO=1,tF=2,tN=3,tB=1,tU=2,tk=4,tz=0,tV=1,tG=2,tH=3,tW=4,tX=5,tY=0,tq=1,t$=2,tj=3,tK=0,tZ=1,tQ=2,tJ=3,t0=4,t1=5,t2=0,t3=1,t4=2,t5=3,t8=4,t6=5,t9=6,t7=7,ie=0,it=1,ii=2,is=[1,2,4],ir=0,ia=1,io=2,il=3,ih=4,ic=5,id=6,iu=7,ip=8,im=9,i_=10,ig=11,iv=12,iS=13,iy=14,ix=15,iT=16,iE=17,ib=18,iw=19,iA=20,iC=21,iP=22,iL=23,iD=24,iI=25,iR=26,iM=27,iO=28,iF=29,iN=30,iB=31,iU=32,ik=33,iz=34,iV=35,iG=36,iH=37,iW=38,iX=39,iY=40,iq=41,i$=42,ij=43,iK=44,iZ=45,iQ=46,iJ=47,i0=48,i1=49,i2=50,i3=51,i4=52,i5=53,i8=54,i6=55,i9=56,i7=61,se=62,st=63,si=64,ss=65,sr=66,sa=67,sn=68,so=69,sl=new Map([[ir,{name:"A8",size:1,ldr:true}],[i4,{name:"R8",size:1,ldr:true}],[ia,{name:"L8",size:1,ldr:true}],[io,{name:"LA8",size:2,ldr:true}],[i5,{name:"RG8",size:2,ldr:true}],[il,{name:"RGB565",size:2,ldr:true}],[ih,{name:"RGBA5551",size:2,ldr:true}],[ic,{name:"RGBA4",size:2,ldr:true}],[id,{name:"RGB8",size:4,ldr:true}],[iu,{name:"RGBA8",size:4,ldr:true,srgbFormat:iA}],[i2,{name:"R16F",size:2}],[i3,{name:"RG16F",size:4}],[ig,{name:"RGB16F",size:8}],[iv,{name:"RGBA16F",size:8}],[iS,{name:"RGB32F",size:16}],[iy,{name:"RGBA32F",size:16}],[ix,{name:"R32F",size:4}],[iT,{name:"DEPTH",size:4}],[so,{name:"DEPTH16",size:2}],[iE,{name:"DEPTHSTENCIL",size:4}],[ib,{name:"111110F",size:4}],[iw,{name:"SRGB8",size:4,ldr:true,srgb:true}],[iA,{name:"SRGBA8",size:4,ldr:true,srgb:true}],[iB,{name:"BGRA8",size:4,ldr:true}],[si,{name:"SBGRA8",size:4,ldr:true,srgb:true}],[ip,{name:"DXT1",blockSize:8,ldr:true,srgbFormat:i8}],[im,{name:"DXT3",blockSize:16,ldr:true,srgbFormat:i6}],[i_,{name:"DXT5",blockSize:16,ldr:true,srgbFormat:i9}],[iC,{name:"ETC1",blockSize:8,ldr:true}],[iP,{name:"ETC2_RGB",blockSize:8,ldr:true,srgbFormat:i7}],[iL,{name:"ETC2_RGBA",blockSize:16,ldr:true,srgbFormat:se}],[iD,{name:"PVRTC_2BPP_RGB_1",ldr:true,blockSize:8}],[iI,{name:"PVRTC_2BPP_RGBA_1",ldr:true,blockSize:8}],[iR,{name:"PVRTC_4BPP_RGB_1",ldr:true,blockSize:8}],[iM,{name:"PVRTC_4BPP_RGBA_1",ldr:true,blockSize:8}],[iO,{name:"ASTC_4x4",blockSize:16,ldr:true,srgbFormat:st}],[iF,{name:"ATC_RGB",blockSize:8,ldr:true}],[iN,{name:"ATC_RGBA",blockSize:16,ldr:true}],[ss,{name:"BC6H_RGBF",blockSize:16}],[sr,{name:"BC6H_RGBUF",blockSize:16}],[sa,{name:"BC7_RGBA",blockSize:16,ldr:true,srgbFormat:sn}],[i8,{name:"DXT1_SRGB",blockSize:8,ldr:true,srgb:true}],[i6,{name:"DXT3_SRGBA",blockSize:16,ldr:true,srgb:true}],[i9,{name:"DXT5_SRGBA",blockSize:16,ldr:true,srgb:true}],[i7,{name:"ETC2_SRGB",blockSize:8,ldr:true,srgb:true}],[se,{name:"ETC2_SRGBA",blockSize:16,ldr:true,srgb:true}],[st,{name:"ASTC_4x4_SRGB",blockSize:16,ldr:true,srgb:true}],[sn,{name:"BC7_SRGBA",blockSize:16,ldr:true,srgb:true}],[iU,{name:"R8I",size:1,isInt:true}],[ik,{name:"R8U",size:1,isInt:true}],[iz,{name:"R16I",size:2,isInt:true}],[iV,{name:"R16U",size:2,isInt:true}],[iG,{name:"R32I",size:4,isInt:true}],[iH,{name:"R32U",size:4,isInt:true}],[iW,{name:"RG8I",size:2,isInt:true}],[iX,{name:"RG8U",size:2,isInt:true}],[iY,{name:"RG16I",size:4,isInt:true}],[iq,{name:"RG16U",size:4,isInt:true}],[i$,{name:"RG32I",size:8,isInt:true}],[ij,{name:"RG32U",size:8,isInt:true}],[iK,{name:"RGBA8I",size:4,isInt:true}],[iZ,{name:"RGBA8U",size:4,isInt:true}],[iQ,{name:"RGBA16I",size:8,isInt:true}],[iJ,{name:"RGBA16U",size:8,isInt:true}],[i0,{name:"RGBA32I",size:16,isInt:true}],[i1,{name:"RGBA32U",size:16,isInt:true}]]),sh=e=>sl.get(e)?.blockSize!==void 0,sc=e=>sl.get(e)?.srgb===true,sd=e=>sl.get(e)?.isInt===true,su=e=>sl.get(e)?.srgbFormat||e,sf=e=>{for(let[t,i]of sl)if(i.srgbFormat===e)return t;return e},sp=e=>{let t=sl.get(e);return !!(t?.ldr&&!t?.srgb)},sm=e=>{switch(e){case ix:case iS:case iy:return Float32Array;case iG:case i$:case i0:return Int32Array;case iH:case ij:case i1:return Uint32Array;case iz:case iY:case iQ:return Int16Array;case i5:case iV:case iq:case iJ:case il:case ih:case ic:case i2:case i3:case ig:case iv:return Uint16Array;case iU:case iW:case iK:return Int8Array;default:return Uint8Array}},s_=0,sg=1,sv=2,sS=3,sy=4,sx=5,sT=6,sE="POSITION",sb="NORMAL",sw="TANGENT",sA="BLENDWEIGHT",sC="BLENDINDICES",sP="COLOR",sL="TEXCOORD",sD="TEXCOORD0",sI="TEXCOORD1",sR="TEXCOORD2",sM="TEXCOORD3",sO="TEXCOORD4",sF="TEXCOORD5",sN="TEXCOORD6",sB="TEXCOORD7",sU="ATTR0",sk="ATTR1",sz="ATTR2",sV="ATTR3",sG="ATTR4",sH="ATTR5",sW="ATTR6",sX="ATTR7",sY="ATTR8",sq="ATTR9",s$="ATTR10",sj="ATTR11",sK="ATTR12",sZ="ATTR13",sQ="ATTR14",sJ="ATTR15",s0=1,s1=0,s2=1,s3=2,s4=3,s5=4,s8=5,s6=6,s9=7,s7=0,re=1,rt=2,ri="default",rs="rgbm",rr="rgbe",ra="rgbp",rn="swizzleGGGR",ro=0,rl=1,rh=2,rc=3,rd="1d",ru="2d",rf="2d-array",rp="cube",rm="cube-array",r_="3d",rg=0,rv=1,rS=2,ry=3,rx=4,rT="none",rE="cube",rb="equirect",rw="octahedral",rA="glsl",rC="wgsl",rP=0,rL=1,rD=2,rI=3,rR=4,rM=5,rO=6,rF=7,rN=0,rB=1,rU=2,rk=3,rz=4,rV=5,rG=6,rH=7,rW=8,rX=9,rY=10,rq=11,r$=12,rj=13,rK=14,rZ=15,rQ=16,rJ=17,r0=18,r1=19,r2=20,r3=21,r4=22,r5=23,r8=24,r6=25,r9=26,r7=27,ae=28,at=29,ai=30,as=31,ar=32,aa=33,an=34,ao=35,al=36,ah=37,ac=38,ad=39,au=40,af=41,ap=42,am=43,a_=44,ag=45,av=46,aS=47,ay=48,ax=49,aT=["bool","int","float","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","mat2","mat3","mat4","sampler2D","samplerCube","","sampler2DShadow","samplerCubeShadow","sampler3D","","","","","sampler2DArray","uint","uvec2","uvec3","uvec4","","","","","","","","","","","","","isampler2D","usampler2D","isamplerCube","usamplerCube","isampler3D","usampler3D","isampler2DArray","usampler2DArray"],aE=[["bool"],["i32"],["f32"],["vec2f","vec2<f32>"],["vec3f","vec3<f32>"],["vec4f","vec4<f32>"],["vec2i","vec2<i32>"],["vec3i","vec3<i32>"],["vec4i","vec4<i32>"],["vec2<bool>"],["vec3<bool>"],["vec4<bool>"],["mat2x2f","mat2x2<f32>"],["mat3x3f","mat3x3<f32>"],["mat4x4f","mat4x4<f32>"],["texture_2d<f32>"],["texture_cube<f32>"],["array<f32>"],["texture_depth_2d"],["texture_depth_cube"],["texture_3d<f32>"],["array<vec2<f32>>"],["array<vec3<f32>>"],["array<vec4<f32>>"],["array<mat4x4<f32>>"],["texture_2d_array<f32>"],["u32"],["vec2u","vec2<u32>"],["vec3u","vec3<u32>"],["vec4u","vec4<u32>"],["array<i32>"],["array<u32>"],["array<bool>"],["array<vec2i>","array<vec2<i32>>"],["array<vec2u>","array<vec2<u32>>"],["array<vec2b>","array<vec2<bool>>"],["array<vec3i>","array<vec3<i32>>"],["array<vec3u>","array<vec3<u32>>"],["array<vec3b>","array<vec3<bool>>"],["array<vec4i>","array<vec4<i32>>"],["array<vec4u>","array<vec4<u32>>"],["array<vec4b>","array<vec4<bool>>"],["texture_2d<i32>"],["texture_2d<u32>"],["texture_cube<i32>"],["texture_cube<u32>"],["texture_3d<i32>"],["texture_3d<u32>"],["texture_2d_array<i32>"],["texture_2d_array<u32>"]],ab=new Map;aE.forEach((e,t)=>{e.forEach(e=>ab.set(e,t));});let aw=new Uint8Array([rR,rR,rO,rO,rO,rO,rR,rR,rR,rR,rR,rR,rO,rO,rO,rR,rR,rO,rR,rR,rR,rO,rO,rO,rO,rR,rM,rM,rM,rM,rR,rM,rR,rR,rM,rR,rR,rM,rR,rR,rM,rR,rR,rM,rR,rM,rR,rM,rR,rM]),aA="webgl2",aC="webgpu",aP="null",aL=1,aD=2,aI=4,aR="ldr",aM="ldr_srgb",aO="hdr",aF=1,aN=2,aB=4,aU=8,ak=16,az=32,aV=64,aG=128,aH=255,aW=0,aX=1,aY=2,aq=["view","mesh","mesh_ub"],a$="default",aj="_unused_float_uniform",aK=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],aZ=[1,1,2,2,4,4,4,2],aQ=["INT8","UINT8","INT16","UINT16","INT32","UINT32","FLOAT32","FLOAT16"],aJ={Int8Array:rP,Uint8Array:rL,Int16Array:rD,Uint16Array:rI,Int32Array:rR,Uint32Array:rM,Float32Array:rO},a0=[Uint8Array,Uint16Array,Uint32Array],a1=[1,2,4],a2=new Map([["float","f32"],["vec2","vec2f"],["vec3","vec3f"],["vec4","vec4f"],["int","i32"],["ivec2","vec2i"],["ivec3","vec3i"],["ivec4","vec4i"],["uint","u32"],["uvec2","vec2u"],["uvec3","vec3u"],["uvec4","vec4u"]]),a3={};a3[sE]=0,a3[sb]=1,a3[sA]=2,a3[sC]=3,a3[sP]=4,a3[sD]=5,a3[sI]=6,a3[sR]=7,a3[sM]=8,a3[sO]=9,a3[sF]=10,a3[sN]=11,a3[sB]=12,a3[sw]=13,a3[sU]=0,a3[sk]=1,a3[sz]=2,a3[sV]=3,a3[sG]=4,a3[sH]=5,a3[sW]=6,a3[sX]=7,a3[sY]=8,a3[sq]=9,a3[s$]=10,a3[sj]=11,a3[sK]=12,a3[sZ]=13,a3[sQ]=14,a3[sJ]=15;let a4=0;class a5{constructor(e,t){this.slot=-1,this.scopeId=null,this.name=e,this.visibility=t;}}class a8 extends a5{}class a6 extends a5{constructor(e,t,i=false){super(e,t),this.format="",this.readOnly=i;}}class a9 extends a5{constructor(e,t,i=ru,s=rg,r=true,a=null){super(e,t),this.textureDimension=i,this.sampleType=s,this.hasSampler=r,this.samplerName=a??`${e}_sampler`;}}class a7 extends a5{constructor(e,t=iu,i=ru,s=true,r=false){super(e,aI),this.format=t,this.textureDimension=i,this.write=s,this.read=r;}}class ne{constructor(e,t){this.uniformBufferFormats=[],this.textureFormats=[],this.storageTextureFormats=[],this.storageBufferFormats=[],this.id=a4++;let i=0;t.forEach(e=>{e.slot=i++,e instanceof a9&&e.hasSampler&&i++,e instanceof a8?this.uniformBufferFormats.push(e):e instanceof a9?this.textureFormats.push(e):e instanceof a7?this.storageTextureFormats.push(e):e instanceof a6&&this.storageBufferFormats.push(e);}),this.device=e;let s=e.scope;this.bufferFormatsMap=new Map,this.uniformBufferFormats.forEach((e,t)=>this.bufferFormatsMap.set(e.name,t)),this.textureFormatsMap=new Map,this.textureFormats.forEach((e,t)=>{this.textureFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.storageTextureFormatsMap=new Map,this.storageTextureFormats.forEach((e,t)=>{this.storageTextureFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.storageBufferFormatsMap=new Map,this.storageBufferFormats.forEach((e,t)=>{this.storageBufferFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.impl=e.createBindGroupFormatImpl(this);}destroy(){this.impl.destroy();}getTexture(e){let t=this.textureFormatsMap.get(e);return void 0!==t?this.textureFormats[t]:null}getStorageTexture(e){let t=this.storageTextureFormatsMap.get(e);return void 0!==t?this.storageTextureFormats[t]:null}loseContext(){}}class nt{get(e,t){return this._cache.has(e)||(this._cache.set(e,t()),e.on("destroy",()=>{this.remove(e);}),e.on("devicelost",()=>{this._cache.get(e)?.loseContext?.(e);})),this._cache.get(e)}remove(e){this._cache.get(e)?.destroy?.(e),this._cache.delete(e);}constructor(){this._cache=new Map;}}class ni{static calcLevelDimension(e,t){return Math.max(e>>t,1)}static calcMipLevelsCount(e,t,i=1){return 1+Math.floor(Math.log2(Math.max(e,t,i)))}static calcLevelGpuSize(e,t,i,s){let r=sl.get(s),a=sl.get(s)?.size??0;if(a>0)return e*t*i*a;let n=r.blockSize??0,o=Math.floor((e+3)/4),l=Math.floor((t+3)/4),h=Math.floor((i+3)/4);return (s===iD||s===iI)&&(o=Math.max(Math.floor(o/2),1)),o*l*h*n}static calcGpuSize(e,t,i,s,r,a){let n=0;for(;n+=ni.calcLevelGpuSize(e,t,i,s),r&&(1!==e||1!==t||1!==i);)e=Math.max(e>>1,1),t=Math.max(t>>1,1),i=Math.max(i>>1,1);return n*(a?6:1)}}let ns=0;class nr{constructor(e,t={}){this._gpuSize=0,this.id=ns++,this._invalid=false,this._lockedLevel=-1,this._lockedMode=s7,this.renderVersionDirty=0,this._storage=false,this._numLevels=0,this.device=e,this.name=t.name??"",this._width=Math.floor(t.width??4),this._height=Math.floor(t.height??4),this._format=t.format??iu,this._compressed=sh(this._format),this._integerFormat=sd(this._format),this._integerFormat&&(t.minFilter=tK,t.magFilter=tK),this._volume=t.volume??false,this._depth=Math.floor(t.depth??1),this._arrayLength=Math.floor(t.arrayLength??0),this._storage=t.storage??false,this._cubemap=t.cubemap??false,this._flipY=t.flipY??false,this._premultiplyAlpha=t.premultiplyAlpha??false,this._mipmaps=t.mipmaps??true,this._numLevelsRequested=t.numLevels,void 0!==t.numLevels&&(this._numLevels=t.numLevels),this._updateNumLevel(),this._minFilter=t.minFilter??t1,this._magFilter=t.magFilter??tZ,this._anisotropy=t.anisotropy??1,this._addressU=t.addressU??ts,this._addressV=t.addressV??ts,this._addressW=t.addressW??ts,this._compareOnRead=t.compareOnRead??false,this._compareFunc=t.compareFunc??t3,this._type=t.type??ri,this.projection=rT,this._cubemap?this.projection=rE:t.projection&&t.projection!==rE&&(this.projection=t.projection),this._levels=t.levels;let i=!!t.levels;this._levels||this._clearLevels(),this.recreateImpl(i),e.textures.push(this);}destroy(){let e=this.device;if(e){let t=e.textures.indexOf(this);-1!==t&&e.textures.splice(t,1),e.scope.removeValue(this),this.impl.destroy(e),this.adjustVramSizeTracking(e._vram,-this._gpuSize),this._levels=null,this.device=null;}}recreateImpl(e=true){let{device:t}=this;this.impl?.destroy(t),this.impl=null,this.impl=t.createTextureImpl(this),this.dirtyAll(),e&&this.upload();}_clearLevels(){this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null];}resize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){let s=this.device;this.adjustVramSizeTracking(s._vram,-this._gpuSize),this._gpuSize=0,this.impl.destroy(s),this._clearLevels(),this._width=Math.floor(e),this._height=Math.floor(t),this._depth=Math.floor(i),this._updateNumLevel(),this.impl=s.createTextureImpl(this),this.dirtyAll();}}loseContext(){this.impl.loseContext(),this.dirtyAll();}adjustVramSizeTracking(e,t){e.tex+=t;}propertyChanged(e){this.impl.propertyChanged(e),this.renderVersionDirty=this.device.renderVersion;}_updateNumLevel(){let e=this.mipmaps?ni.calcMipLevelsCount(this.width,this.height):1,t=this._numLevelsRequested;this._numLevels=Math.min(t??e,e),this._mipmaps=this._numLevels>1;}get lockedMode(){return this._lockedMode}set minFilter(e){this._minFilter!==e&&(sd(this._format)||(this._minFilter=e,this.propertyChanged(aF)));}get minFilter(){return this._minFilter}set magFilter(e){this._magFilter!==e&&(sd(this._format)||(this._magFilter=e,this.propertyChanged(aN)));}get magFilter(){return this._magFilter}set addressU(e){this._addressU!==e&&(this._addressU=e,this.propertyChanged(aB));}get addressU(){return this._addressU}set addressV(e){this._addressV!==e&&(this._addressV=e,this.propertyChanged(aU));}get addressV(){return this._addressV}set addressW(e){this._volume&&e!==this._addressW&&(this._addressW=e,this.propertyChanged(ak));}get addressW(){return this._addressW}set compareOnRead(e){this._compareOnRead!==e&&(this._compareOnRead=e,this.propertyChanged(az));}get compareOnRead(){return this._compareOnRead}set compareFunc(e){this._compareFunc!==e&&(this._compareFunc=e,this.propertyChanged(aV));}get compareFunc(){return this._compareFunc}set anisotropy(e){this._anisotropy!==e&&(this._anisotropy=e,this.propertyChanged(aG));}get anisotropy(){return this._anisotropy}set mipmaps(e){this._mipmaps!==e&&(this.device.isWebGPU||sd(this._format)||(this._mipmaps=e),e&&(this._needsMipmapsUpload=true));}get mipmaps(){return this._mipmaps}get numLevels(){return this._numLevels}get storage(){return this._storage}get width(){return this._width}get height(){return this._height}get depth(){return this._depth}get format(){return this._format}get cubemap(){return this._cubemap}get gpuSize(){let e=this.pot&&this._mipmaps&&!(this._compressed&&1===this._levels.length);return ni.calcGpuSize(this._width,this._height,this._depth,this._format,e,this._cubemap)}get array(){return this._arrayLength>0}get arrayLength(){return this._arrayLength}get volume(){return this._volume}set type(e){this._type!==e&&(this._type=e,this.device._shadersDirty=true);}get type(){return this._type}set srgb(e){if(e!==sc(this.format))if(e){let e=su(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}else {let e=sf(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}}get srgb(){return sc(this.format)}set flipY(e){this._flipY!==e&&(this._flipY=e,this._needsUpload=true);}get flipY(){return this._flipY}set premultiplyAlpha(e){this._premultiplyAlpha!==e&&(this._premultiplyAlpha=e,this._needsUpload=true);}get premultiplyAlpha(){return this._premultiplyAlpha}get pot(){return eb.powerOfTwo(this._width)&&eb.powerOfTwo(this._height)}get encoding(){switch(this.type){case rs:return "rgbm";case rr:return "rgbe";case ra:return "rgbp"}return sp(this.format)?"srgb":"linear"}dirtyAll(){this._levelsUpdated=this._cubemap?[[true,true,true,true,true,true]]:[true],this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this._mipmapsUploaded=false,this.propertyChanged(aH);}lock(e={}){e.level??=0,e.face??=0,e.mode??=rt,this._lockedMode=e.mode,this._lockedLevel=e.level;let t=this.cubemap?this._levels[e.face]:this._levels;if(null===t[e.level]){let i=Math.max(1,this._width>>e.level),s=Math.max(1,this._height>>e.level),r=Math.max(1,this._depth>>e.level),a=new ArrayBuffer(ni.calcLevelGpuSize(i,s,r,this._format));t[e.level]=new(sm(this._format))(a);}return t[e.level]}setSource(e,t=0){let i,s,r=false;if(this._cubemap){if(e[0]){i=e[0].width||0,s=e[0].height||0;for(let t=0;t<6;t++){let a=e[t];if(!a||a.width!==i||a.height!==s||!this.device._isBrowserInterface(a)){r=true;break}}}else r=true;if(!r)for(let i=0;i<6;i++)this._levels[t][i]!==e[i]&&(this._levelsUpdated[t][i]=true);}else this.device._isBrowserInterface(e)||(r=true),r||(e!==this._levels[t]&&(this._levelsUpdated[t]=true),e instanceof HTMLVideoElement?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height));if(r)if(this._width=4,this._height=4,this._cubemap)for(let e=0;e<6;e++)this._levels[t][e]=null,this._levelsUpdated[t][e]=true;else this._levels[t]=null,this._levelsUpdated[t]=true;else 0===t&&(this._width=i,this._height=s),this._levels[t]=e;this._invalid===r&&r||(this._invalid=r,this.upload());}getSource(e=0){return this._levels[e]}unlock(){this._lockedMode,this._lockedMode===rt&&this.upload(),this._lockedLevel=-1,this._lockedMode=s7;}upload(){this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this.impl.uploadImmediate?.(this.device,this);}read(e,t,i,s,r={}){return this.impl.read?.(e,t,i,s,r)}write(e,t,i,s,r){return this.impl.write?.(e,t,i,s,r)}}let na={white:[255,255,255,255],gray:[128,128,128,255],black:[0,0,0,255],normal:[128,128,255,255],pink:[255,128,255,255]};class nn{destroy(){this.map.forEach(e=>{e.destroy();});}constructor(){this.map=new Map;}}let no=new nt,nl=(e,t)=>{let i=no.get(e,()=>new nn);if(!i.map.has(t)){let s=new nr(e,{name:`built-in-texture-${t}`,width:1,height:1,format:iu}),r=s.lock(),a=na[t];r.set(a),s.unlock(),i.map.set(t,s);}return i.map.get(t)},nh=0;class nc{constructor(){this.offsets=[];}}class nd{constructor(e,t,i){this.renderVersionUpdated=-1,this.uniformBufferOffsets=[],this.id=nh++,this.device=e,this.format=t,this.dirty=true,this.impl=e.createBindGroupImpl(this),this.textures=[],this.storageTextures=[],this.storageBuffers=[],this.uniformBuffers=[],this.defaultUniformBuffer=i,i&&this.setUniformBuffer(a$,i);}destroy(){this.impl.destroy(),this.impl=null,this.format=null,this.defaultUniformBuffer=null;}setUniformBuffer(e,t){let i=this.format.bufferFormatsMap.get(e);this.uniformBuffers[i]!==t&&(this.uniformBuffers[i]=t,this.dirty=true);}setStorageBuffer(e,t){let i=this.format.storageBufferFormatsMap.get(e);this.storageBuffers[i]!==t&&(this.storageBuffers[i]=t,this.dirty=true);}setTexture(e,t){let i=this.format.textureFormatsMap.get(e);this.textures[i]!==t?(this.textures[i]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}setStorageTexture(e,t){let i=this.format.storageTextureFormatsMap.get(e);this.storageTextures[i]!==t?(this.storageTextures[i]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}updateUniformBuffers(){for(let e=0;e<this.uniformBuffers.length;e++)this.uniformBuffers[e].update();}update(){let{textureFormats:e,storageTextureFormats:t,storageBufferFormats:i}=this.format;for(let t=0;t<e.length;t++){let i=e[t],s=i.scopeId.value;!s&&("uSceneDepthMap"===i.name&&(s=nl(this.device,"white")),"uSceneColorMap"===i.name&&(s=nl(this.device,"pink")),s||(s=nl(this.device,"pink"))),this.setTexture(i.name,s);}for(let e=0;e<t.length;e++){let i=t[e],s=i.scopeId.value;this.setStorageTexture(i.name,s);}for(let e=0;e<i.length;e++){let t=i[e],s=t.scopeId.value;this.setStorageBuffer(t.name,s);}this.uniformBufferOffsets.length=this.uniformBuffers.length;for(let e=0;e<this.uniformBuffers.length;e++){let t=this.uniformBuffers[e];this.uniformBufferOffsets[e]=t.offset,this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}this.dirty&&(this.dirty=false,this.renderVersionUpdated=this.device.renderVersion,this.impl.update(this));}}let nu={set:(e,t,i,s=1)=>e&~(s<<i)|t<<i,get:(e,t,i=1)=>e>>t&i,all(e,t,i=1){let s=i<<t;return (e&s)===s},any:(e,t,i=1)=>(e&i<<t)!=0};class nf{constructor(e=false,t=tS,i=to,s=tn,r,a,n,o=true,l=true,h=true,c=true){this.target0=0,this.setColorBlend(t,i,s),this.setAlphaBlend(r??t,a??i,n??s),this.setColorWrite(o,l,h,c),this.blend=e;}set blend(e){this.target0=nu.set(this.target0,+!!e,26);}get blend(){return nu.all(this.target0,26)}setColorBlend(e,t,i){this.target0=nu.set(this.target0,e,0,7),this.target0=nu.set(this.target0,t,3,15),this.target0=nu.set(this.target0,i,7,15);}setAlphaBlend(e,t,i){this.target0=nu.set(this.target0,e,11,7),this.target0=nu.set(this.target0,t,14,15),this.target0=nu.set(this.target0,i,18,15);}setColorWrite(e,t,i,s){this.redWrite=e,this.greenWrite=t,this.blueWrite=i,this.alphaWrite=s;}get colorOp(){return nu.get(this.target0,0,7)}get colorSrcFactor(){return nu.get(this.target0,3,15)}get colorDstFactor(){return nu.get(this.target0,7,15)}get alphaOp(){return nu.get(this.target0,11,7)}get alphaSrcFactor(){return nu.get(this.target0,14,15)}get alphaDstFactor(){return nu.get(this.target0,18,15)}set redWrite(e){this.target0=nu.set(this.target0,+!!e,22);}get redWrite(){return nu.all(this.target0,22)}set greenWrite(e){this.target0=nu.set(this.target0,+!!e,23);}get greenWrite(){return nu.all(this.target0,23)}set blueWrite(e){this.target0=nu.set(this.target0,+!!e,24);}get blueWrite(){return nu.all(this.target0,24)}set alphaWrite(e){this.target0=nu.set(this.target0,+!!e,25);}get alphaWrite(){return nu.all(this.target0,25)}get allWrite(){return nu.get(this.target0,22,15)}copy(e){return this.target0=e.target0,this}clone(){return new this.constructor().copy(this)}get key(){return this.target0}equals(e){return this.target0===e.target0}static{this.NOBLEND=Object.freeze(new nf);}static{this.NOWRITE=Object.freeze(new nf(void 0,void 0,void 0,void 0,void 0,void 0,void 0,false,false,false,false));}static{this.ALPHABLEND=Object.freeze(new nf(true,tS,tu,tp));}static{this.ADDBLEND=Object.freeze(new nf(true,tS,to,to));}}class np{get(e){let t=this.map.get(e);return void 0===t&&(t=this.id++,this.map.set(e,t)),t}constructor(){this.map=new Map,this.id=0;}}let nm=new np;class n_{constructor(e=t5,t=true){this.data=0,this._depthBias=0,this._depthBiasSlope=0,this.key=0,this.func=e,this.write=t;}set test(e){this.func=e?t5:t7,this.updateKey();}get test(){return this.func!==t7}set write(e){this.data=nu.set(this.data,+!!e,3),this.updateKey();}get write(){return nu.all(this.data,3)}set func(e){this.data=nu.set(this.data,e,0,7),this.updateKey();}get func(){return nu.get(this.data,0,7)}set depthBias(e){this._depthBias=e,this.updateKey();}get depthBias(){return this._depthBias}set depthBiasSlope(e){this._depthBiasSlope=e,this.updateKey();}get depthBiasSlope(){return this._depthBiasSlope}copy(e){return this.data=e.data,this._depthBias=e._depthBias,this._depthBiasSlope=e._depthBiasSlope,this.key=e.key,this}clone(){return new this.constructor().copy(this)}updateKey(){let{data:e,_depthBias:t,_depthBiasSlope:i}=this,s=`${e}-${t}-${i}`;this.key=nm.get(s);}equals(e){return this.key===e.key}static{this.DEFAULT=Object.freeze(new n_);}static{this.NODEPTH=Object.freeze(new n_(t7,false));}static{this.WRITEDEPTH=Object.freeze(new n_(t7,true));}}class ng{equals(e){return this.globalId===e.globalId&&this.revision===e.revision}copy(e){this.globalId=e.globalId,this.revision=e.revision;}reset(){this.globalId=0,this.revision=0;}constructor(){this.globalId=0,this.revision=0;}}let nv=0;class nS{constructor(){nv++,this.version=new ng,this.version.globalId=nv;}increment(){this.version.revision++;}}class ny{constructor(e){this.name=e,this.value=null,this.versionObject=new nS;}toJSON(e){}setValue(e){this.value=e,this.versionObject.increment();}getValue(){return this.value}}class nx{constructor(e){this.name=e,this.variables=new Map;}resolve(e){return this.variables.has(e)||this.variables.set(e,new ny(e)),this.variables.get(e)}removeValue(e){for(let t in this.variables){let i=this.variables[t];i.value===e&&(i.value=null);}}}let nT=0;class nE{constructor(e,t,i,s){this.usage=tM,this.usage=s?.usage??tM,this.device=e,this.format=t,this.numVertices=i,this.id=nT++,this.impl=e.createVertexBufferImpl(this,t,s),this.numBytes=t.verticesByteSize?t.verticesByteSize:t.size*i,this.adjustVramSizeTracking(e._vram,this.numBytes);let r=s?.data;r?this.setData(r):this.storage=new ArrayBuffer(this.numBytes),this.device.buffers.push(this);}destroy(){let e=this.device,t=e.buffers.indexOf(this);-1!==t&&e.buffers.splice(t,1),this.impl.initialized&&(this.impl.destroy(e),this.adjustVramSizeTracking(e._vram,-this.storage.byteLength));}adjustVramSizeTracking(e,t){e.vb+=t;}loseContext(){this.impl.loseContext();}getFormat(){return this.format}getUsage(){return this.usage}getNumVertices(){return this.numVertices}lock(){return this.storage}unlock(){this.impl.unlock(this);}setData(e){return e.byteLength===this.numBytes&&(this.storage=e,this.unlock(),true)}}function nb(e){if(null==e)return 0;let t=0;for(let i=0,s=e.length;i<s;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return t}function nw(e){let t=0x811c9dc5;for(let i=0;i<e.length;i++)t^=e[i],t*=0x1000193;return t>>>0}let nA=new np,nC=[2,4,8,12,16],nP=new nt;class nL{constructor(e,t,i){this.device=e,this._elements=[],this.hasUv0=false,this.hasUv1=false,this.hasColor=false,this.hasTangents=false,this.verticesByteSize=0,this.vertexCount=i,this.interleaved=void 0===i,this.instancing=false,this.size=t.reduce((e,t)=>e+4*Math.ceil(t.components*aZ[t.type]/4),0);let s=0,r;for(let e=0,a=t.length;e<a;e++){let a=t[e];r=a.components*aZ[a.type],i&&(s=eb.roundUp(s,r));let n=a.asInt??false,o=!n&&(a.normalize??false),l={name:a.semantic,offset:i?s:a.hasOwnProperty("offset")?a.offset:s,stride:i?r:a.hasOwnProperty("stride")?a.stride:this.size,dataType:a.type,numComponents:a.components,normalize:o,size:r,asInt:n};this._elements.push(l),i?s+=r*i:s+=4*Math.ceil(r/4),a.semantic===sD?this.hasUv0=true:a.semantic===sI?this.hasUv1=true:a.semantic===sP?this.hasColor=true:a.semantic===sw&&(this.hasTangents=true);}i&&(this.verticesByteSize=s),this._evaluateHash();}get elements(){return this._elements}static getDefaultInstancingFormat(e){return nP.get(e,()=>new nL(e,[{semantic:sj,components:4,type:rO},{semantic:sK,components:4,type:rO},{semantic:sQ,components:4,type:rO},{semantic:sJ,components:4,type:rO}]))}static isElementValid(e,t){let i=t.components*aZ[t.type];return !e.isWebGPU||!!nC.includes(i)}update(){this._evaluateHash();}_evaluateHash(){let e=[],t=[],i=this._elements.length;for(let s=0;s<i;s++){let{name:i,dataType:r,numComponents:a,normalize:n,offset:o,stride:l,size:h,asInt:c}=this._elements[s],d=i+r+a+n+c;e.push(d);let u=d+o+l+h;t.push(u);}e.sort();let s=e.join();this.batchingHash=nb(s),this.shaderProcessingHashString=s,this.renderingHashString=t.join("_"),this.renderingHash=nA.get(this.renderingHashString);}}let nD=new np;class nI{set func(e){this._func=e,this._dirty=true;}get func(){return this._func}set ref(e){this._ref=e,this._dirty=true;}get ref(){return this._ref}set fail(e){this._fail=e,this._dirty=true;}get fail(){return this._fail}set zfail(e){this._zfail=e,this._dirty=true;}get zfail(){return this._zfail}set zpass(e){this._zpass=e,this._dirty=true;}get zpass(){return this._zpass}set readMask(e){this._readMask=e,this._dirty=true;}get readMask(){return this._readMask}set writeMask(e){this._writeMask=e,this._dirty=true;}get writeMask(){return this._writeMask}constructor(e={}){this._dirty=true,this._func=e.func??t7,this._ref=e.ref??0,this._readMask=e.readMask??255,this._writeMask=e.writeMask??255,this._fail=e.fail??s1,this._zfail=e.zfail??s1,this._zpass=e.zpass??s1,this._evalKey();}_evalKey(){let{_func:e,_ref:t,_fail:i,_zfail:s,_zpass:r,_readMask:a,_writeMask:n}=this,o=`${e},${t},${i},${s},${r},${a},${n}`;this._key=nD.get(o),this._dirty=false;}get key(){return this._dirty&&this._evalKey(),this._key}copy(e){return this._func=e._func,this._ref=e._ref,this._readMask=e._readMask,this._writeMask=e._writeMask,this._fail=e._fail,this._zfail=e._zfail,this._zpass=e._zpass,this._dirty=e._dirty,this._key=e._key,this}clone(){return new this.constructor().copy(this)}static{this.DEFAULT=Object.freeze(new nI);}}class nR extends el{static{this.EVENT_RESIZE="resizecanvas";}constructor(e,t){super(),this.backBuffer=null,this.backBufferSize=new eF,this.backBufferAntialias=false,this.isWebGPU=false,this.isWebGL2=false,this.isNull=false,this.isHdr=false,this.maxIndirectDrawCount=1024,this.maxColorAttachments=1,this.maxSamples=1,this.supportsMultiDraw=true,this.supportsCompute=false,this.supportsStorageTextureRead=false,this.renderTarget=null,this.shaders=[],this.textures=[],this.targets=new Set,this.renderVersion=0,this.insideRenderPass=false,this.supportsUniformBuffers=false,this.supportsClipDistances=false,this.textureRG11B10Renderable=false,this.textureFloatFilterable=false,this.blendState=new nf,this.depthState=new n_,this.stencilEnabled=false,this.stencilFront=new nI,this.stencilBack=new nI,this._destroyed=false,this.defaultClearOptions={color:[0,0,0,1],depth:1,stencil:0,flags:tB|tU},this.clientRect={width:0,height:0},this._shadersDirty=false,this.capsDefines=new Map,this.mapsToClear=new Set,this.canvas=e,"setAttribute"in e&&e.setAttribute("data-engine",`PlayCanvas ${V}`),this.initOptions={...t},this.initOptions.alpha??=true,this.initOptions.depth??=true,this.initOptions.stencil??=true,this.initOptions.antialias??=true,this.initOptions.powerPreference??="high-performance",this.initOptions.displayFormat??=aR,this._maxPixelRatio=et.browser?Math.min(1,window.devicePixelRatio):1,this.buffers=[],this._vram={tex:0,vb:0,ib:0,ub:0,sb:0},this._shaderStats={vsCompiled:0,fsCompiled:0,linked:0,materialShaders:0,compileTime:0},this.initializeContextCaches(),this._drawCallsPerFrame=0,this._shaderSwitchesPerFrame=0,this._primsPerFrame=[];for(let e=s_;e<=sT;e++)this._primsPerFrame[e]=0;this._renderTargetCreationTime=0,this.scope=new nx("Device"),this.textureBias=this.scope.resolve("textureBias"),this.textureBias.setValue(0);}postInit(){let e=new nL(this,[{semantic:sE,components:2,type:rO}]),t=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.quadVertexBuffer=new nE(this,e,4,{data:t});}initCapsDefines(){let{capsDefines:e}=this;e.clear(),this.textureFloatFilterable&&e.set("CAPS_TEXTURE_FLOAT_FILTERABLE",""),this.textureFloatRenderable&&e.set("CAPS_TEXTURE_FLOAT_RENDERABLE",""),this.supportsMultiDraw&&e.set("CAPS_MULTI_DRAW",""),et.desktop&&e.set("PLATFORM_DESKTOP",""),et.mobile&&e.set("PLATFORM_MOBILE",""),et.android&&e.set("PLATFORM_ANDROID",""),et.ios&&e.set("PLATFORM_IOS","");}destroy(){this.fire("destroy"),this.quadVertexBuffer?.destroy(),this.quadVertexBuffer=null,this.dynamicBuffers?.destroy(),this.dynamicBuffers=null,this.gpuProfiler?.destroy(),this.gpuProfiler=null,this._destroyed=true;}onDestroyShader(e){this.fire("destroy:shader",e);let t=this.shaders.indexOf(e);-1!==t&&this.shaders.splice(t,1);}postDestroy(){this.scope=null,this.canvas=null;}loseContext(){for(let e of(this.contextLost=true,this.backBufferSize.set(-1,-1),this.textures))e.loseContext();for(let e of this.buffers)e.loseContext();for(let e of this.targets)e.loseContext();this.gpuProfiler?.loseContext();}restoreContext(){for(let e of(this.contextLost=false,this.initializeRenderState(),this.initializeContextCaches(),this.buffers))e.unlock();this.gpuProfiler?.restoreContext?.();}toJSON(e){}initializeContextCaches(){this.vertexBuffers=[],this.shader=null,this.shaderValid=void 0,this.shaderAsyncCompile=false,this.renderTarget=null;}initializeRenderState(){this.blendState=new nf,this.depthState=new n_,this.cullMode=tq,this.vx=this.vy=this.vw=this.vh=0,this.sx=this.sy=this.sw=this.sh=0,this.blendColor=new ew(0,0,0,0);}setStencilState(e,t){}setBlendState(e){}setBlendColor(e,t,i,s){}setDepthState(e){}setCullMode(e){}setRenderTarget(e){this.renderTarget=e;}setVertexBuffer(e){e&&this.vertexBuffers.push(e);}clearVertexBuffer(){this.vertexBuffers.length=0;}getIndirectDrawSlot(e=1){return 0}get indirectDrawBuffer(){return null}getRenderTarget(){return this.renderTarget}initRenderTarget(e){e.initialized||(e.init(),this.targets.add(e));}draw(e,t,i,s,r=true,a=true){}_isBrowserInterface(e){return this._isImageBrowserInterface(e)||this._isImageCanvasInterface(e)||this._isImageVideoInterface(e)}_isImageBrowserInterface(e){return "undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement}_isImageCanvasInterface(e){return "undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement}_isImageVideoInterface(e){return "undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement}resizeCanvas(e,t){let i=Math.min(this._maxPixelRatio,et.browser?window.devicePixelRatio:1),s=Math.floor(e*i),r=Math.floor(t*i);(s!==this.canvas.width||r!==this.canvas.height)&&this.setResolution(s,r);}setResolution(e,t){this.canvas.width=e,this.canvas.height=t,this.fire(nR.EVENT_RESIZE,e,t);}update(){this.updateClientRect();}updateClientRect(){if(et.worker)this.clientRect.width=this.canvas.width,this.clientRect.height=this.canvas.height;else {let e=this.canvas.getBoundingClientRect();this.clientRect.width=e.width,this.clientRect.height=e.height;}}get width(){return this.canvas.width}get height(){return this.canvas.height}set fullscreen(e){}get fullscreen(){return false}set maxPixelRatio(e){this._maxPixelRatio=e;}get maxPixelRatio(){return this._maxPixelRatio}get deviceType(){return this._deviceType}startRenderPass(e){}endRenderPass(e){}startComputePass(e){}endComputePass(){}frameStart(){this.renderPassIndex=0,this.renderVersion++;}frameEnd(){this.mapsToClear.forEach(e=>e.clear()),this.mapsToClear.clear();}computeDispatch(e,t="Unnamed"){}getRenderableHdrFormat(e=[ib,iv,iy],t=true,i=1){for(let s=0;s<e.length;s++){let r=e[s];switch(r){case ib:if(this.textureRG11B10Renderable)return r;break;case iv:if(this.textureHalfFloatRenderable)return r;break;case iy:if(this.isWebGPU&&i>1)continue;if(this.textureFloatRenderable&&(!t||this.textureFloatFilterable))return r}}}validateAttributes(e,t,i){}}let nM=0;class nO{constructor(e={}){this.id=nM++;let t=e.colorBuffer?.device??e.colorBuffers?.[0].device??e.depthBuffer?.device??e.graphicsDevice;this._device=t;let{maxSamples:i}=this._device;if(this._samples=Math.min(e.samples??1,i),t.isWebGPU&&(this._samples=this._samples>1?i:1),this._colorBuffer=e.colorBuffer,e.colorBuffer&&(this._colorBuffers=[e.colorBuffer]),this._depthBuffer=e.depthBuffer,this._face=e.face??0,this._depthBuffer){let e=this._depthBuffer._format;e===iT||e===so?(this._depth=true,this._stencil=false):e===iE?(this._depth=true,this._stencil=true):(e===ix&&this._depthBuffer.device.isWebGPU&&this._samples>1?this._depth=true:this._depth=false,this._stencil=false);}else this._depth=e.depth??true,this._stencil=e.stencil??false;e.colorBuffers&&!this._colorBuffers&&(this._colorBuffers=[...e.colorBuffers],this._colorBuffer=e.colorBuffers[0]),this.autoResolve=e.autoResolve??true,this.name=e.name,this.name||(this.name=this._colorBuffer?.name),this.name||(this.name=this._depthBuffer?.name),this.name||(this.name="Untitled"),this.flipY=e.flipY??false,this._mipLevel=e.mipLevel??0,this._mipLevel>0&&this._depth&&(this._mipLevel=0),this._mipmaps=void 0===e.mipLevel,this.evaluateDimensions(),this.validateMrt(),this.impl=t.createRenderTargetImpl(this);}destroy(){let e=this._device;e&&(e.targets.delete(this),e.renderTarget===this&&e.setRenderTarget(null),this.destroyFrameBuffers());}destroyFrameBuffers(){let e=this._device;e&&this.impl.destroy(e);}destroyTextureBuffers(){this._depthBuffer?.destroy(),this._depthBuffer=null,this._colorBuffers?.forEach(e=>{e.destroy();}),this._colorBuffers=null,this._colorBuffer=null;}resize(e,t){if(!(this.mipLevel>0)&&(this._depthBuffer?.resize(e,t),this._colorBuffers?.forEach(i=>{i.resize(e,t);}),this._width!==e||this._height!==t)){this.destroyFrameBuffers();let e=this._device;e.renderTarget===this&&e.setRenderTarget(null),this.evaluateDimensions(),this.validateMrt(),this.impl=e.createRenderTargetImpl(this);}}validateMrt(){}evaluateDimensions(){let e=this._colorBuffer??this._depthBuffer;e&&(this._width=e.width,this._height=e.height,this._mipLevel>0&&(this._width=ni.calcLevelDimension(this._width,this._mipLevel),this._height=ni.calcLevelDimension(this._height,this._mipLevel)));}init(){this.impl.init(this._device,this);}get initialized(){return this.impl.initialized}get device(){return this._device}loseContext(){this.impl.loseContext();}resolve(e=true,t=!!this._depthBuffer){this._device&&this._samples>1&&this.impl.resolve(this._device,this,e,t);}copy(e,t,i){if(!this._device)if(!e._device)return false;else this._device=e._device;return this._device.copyRenderTarget(e,this,t,i)}get samples(){return this._samples}get depth(){return this._depth}get stencil(){return this._stencil}get colorBuffer(){return this._colorBuffer}getColorBuffer(e){return this._colorBuffers?.[e]}get depthBuffer(){return this._depthBuffer}get face(){return this._face}get mipLevel(){return this._mipLevel}get mipmaps(){return this._mipmaps}get width(){return this._width??this._device.width}get height(){return this._height??this._device.height}isColorBufferSrgb(e=0){if(this.device.backBuffer===this)return sc(this.device.backBufferFormat);let t=this.getColorBuffer(e);return !!t&&sc(t.format)}}class nF{update(e){this.destroy();let t=e.device,i=this.createDescriptor(t,e);this.bindGroup=t.wgpu.createBindGroup(i);}destroy(){this.bindGroup=null;}createDescriptor(e,t){let i=[],s=t.format,r=t.format.uniformBufferFormats;t.uniformBuffers.forEach((e,t)=>{let s=r[t].slot,a=e.persistent?e.impl.buffer:e.allocation.gpuBuffer.buffer;i.push({binding:s,resource:{buffer:a,offset:0,size:e.format.byteSize}});});let a=t.format.textureFormats;t.textures.forEach((t,r)=>{let n=t.impl,o=s.textureFormats[r],l=a[r].slot,h=n.getView(e);if(i.push({binding:l,resource:h}),o.hasSampler){let t=n.getSampler(e,o.sampleType);i.push({binding:l+1,resource:t});}});let n=t.format.storageTextureFormats;t.storageTextures.forEach((t,s)=>{let r=t.impl,a=n[s].slot,o=r.getView(e);i.push({binding:a,resource:o});});let o=t.format.storageBufferFormats;return t.storageBuffers.forEach((e,t)=>{let s=e.impl.buffer,r=o[t].slot;i.push({binding:r,resource:{buffer:s}});}),{layout:t.format.impl.bindGroupLayout,entries:i}}}class nN{static shaderStage(e){let t=0;return e&aL&&(t|=GPUShaderStage.VERTEX),e&aD&&(t|=GPUShaderStage.FRAGMENT),e&aI&&(t|=GPUShaderStage.COMPUTE),t}}let nB=[];nB[ir]="",nB[ia]="",nB[io]="",nB[i4]="r8unorm",nB[i5]="rg8unorm",nB[il]="",nB[ih]="",nB[ic]="",nB[id]="rgba8unorm",nB[iu]="rgba8unorm",nB[ip]="bc1-rgba-unorm",nB[im]="bc2-rgba-unorm",nB[i_]="bc3-rgba-unorm",nB[ig]="",nB[iv]="rgba16float",nB[i2]="r16float",nB[i3]="rg16float",nB[iS]="",nB[iy]="rgba32float",nB[ix]="r32float",nB[iT]="depth32float",nB[so]="depth16unorm",nB[iE]="depth24plus-stencil8",nB[ib]="rg11b10ufloat",nB[iw]="",nB[iA]="rgba8unorm-srgb",nB[iC]="",nB[iP]="etc2-rgb8unorm",nB[iL]="etc2-rgba8unorm",nB[iD]="",nB[iI]="",nB[iR]="",nB[iM]="",nB[iO]="astc-4x4-unorm",nB[iF]="",nB[iN]="",nB[iB]="bgra8unorm",nB[si]="bgra8unorm-srgb",nB[iU]="r8sint",nB[ik]="r8uint",nB[iz]="r16sint",nB[iV]="r16uint",nB[iG]="r32sint",nB[iH]="r32uint",nB[iW]="rg8sint",nB[iX]="rg8uint",nB[iY]="rg16sint",nB[iq]="rg16uint",nB[i$]="rg32sint",nB[ij]="rg32uint",nB[iK]="rgba8sint",nB[iZ]="rgba8uint",nB[iQ]="rgba16sint",nB[iJ]="rgba16uint",nB[i0]="rgba32sint",nB[i1]="rgba32uint",nB[ss]="bc6h-rgb-float",nB[sr]="bc6h-rgb-ufloat",nB[sa]="bc7-rgba-unorm",nB[i8]="bc1-rgba-unorm-srgb",nB[i6]="bc2-rgba-unorm-srgb",nB[i9]="bc3-rgba-unorm-srgb",nB[i7]="etc2-rgb8unorm-srgb",nB[se]="etc2-rgba8unorm-srgb",nB[sn]="bc7-rgba-unorm-srgb",nB[st]="astc-4x4-unorm-srgb";let nU=[];nU[rg]="filtering",nU[rv]="non-filtering",nU[rS]="comparison",nU[ry]="comparison",nU[rx]="comparison";let nk=[];nk[rg]="float",nk[rv]="unfilterable-float",nk[rS]="depth",nk[ry]="sint",nk[rx]="uint";let nz=new np;class nV{constructor(e){let t=e.device,{key:i,desc:s}=this.createDescriptor(e);this.key=nz.get(i),this.bindGroupLayout=t.wgpu.createBindGroupLayout(s);}destroy(){this.bindGroupLayout=null;}loseContext(){}createDescriptor(e){let t=[],i="";return e.uniformBufferFormats.forEach(e=>{let s=nN.shaderStage(e.visibility);i+=`#${e.slot}U:${s}`,t.push({binding:e.slot,visibility:s,buffer:{type:"uniform",hasDynamicOffset:true}});}),e.textureFormats.forEach(e=>{let s=nN.shaderStage(e.visibility),r=e.sampleType,a=e.textureDimension,n=nk[r];if(i+=`#${e.slot}T:${s}-${n}-${a}-false`,t.push({binding:e.slot,visibility:s,texture:{sampleType:n,viewDimension:a,multisampled:false}}),e.hasSampler){let a=nU[r];i+=`#${e.slot+1}S:${s}-${a}`,t.push({binding:e.slot+1,visibility:s,sampler:{type:a}});}}),e.storageTextureFormats.forEach(e=>{let{format:s,textureDimension:r}=e,{read:a,write:n}=e;i+=`#${e.slot}ST:${s}-${r}-${a?"r1":"r0"}-${n?"w1":"w0"}`,t.push({binding:e.slot,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:a?n?"read-write":"read-only":"write-only",format:nB[s],viewDimension:r}});}),e.storageBufferFormats.forEach(e=>{let s=e.readOnly,r=nN.shaderStage(e.visibility);i+=`#${e.slot}SB:${r}-${s?"ro":"rw"}`,t.push({binding:e.slot,visibility:r,buffer:{type:s?"read-only-storage":"storage"}});}),{key:i,desc:{entries:t}}}}class nG{constructor(e=0){this.buffer=null,this.usageFlags=0,this.usageFlags=e;}destroy(e){this.buffer&&(this.buffer.destroy(),this.buffer=null);}get initialized(){return !!this.buffer}loseContext(){}allocate(e,t){this.buffer=e.wgpu.createBuffer({size:t,usage:this.usageFlags});}unlock(e,t){let i=e.wgpu;if(!this.buffer){let i=t.byteLength+3&-4;this.usageFlags|=GPUBufferUsage.COPY_DST,this.allocate(e,i);}let s=t.byteOffset??0,r=new Uint8Array(t.buffer??t,s,t.byteLength),a=new Uint8Array(this.buffer.size);a.set(r),i.queue.writeBuffer(this.buffer,0,a,0,a.length);}read(e,t,i,s,r){return e.readStorageBuffer(this,t,i,s,r)}write(e,t,i,s,r){e.writeStorageBuffer(this,t,i,s,r);}clear(e,t,i){e.clearStorageBuffer(this,t,i);}}class nH extends nG{constructor(e,t){super(tP|(t?.storage?tI:0)),this.format=null,this.format=e.format===it?"uint16":"uint32";}unlock(e){let t=e.device;super.unlock(t,e.storage);}}let nW={equals(e,t){if(e.length!==t.length)return false;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return false;return true}},nX=[];nX[rP]="sint8",nX[rL]="uint8",nX[rD]="sint16",nX[rI]="uint16",nX[rR]="sint32",nX[rM]="uint32",nX[rO]="float32",nX[rF]="float16";let nY=[];nY[rP]="snorm8",nY[rL]="unorm8",nY[rD]="snorm16",nY[rI]="unorm16",nY[rR]="sint32",nY[rM]="uint32",nY[rO]="float32",nY[rF]="float16";class nq{get(e,t=null){let i=this.getKey(e,t),s=this.cache.get(i);return s||(s=this.create(e,t),this.cache.set(i,s)),s}getKey(e,t=null){return `${e?.renderingHashString}-${t?.renderingHashString}`}create(e,t){let i=[],s=e=>{let t=e.interleaved,s=e.instancing?"instance":"vertex",r=[],a=e.elements.length;for(let n=0;n<a;n++){let o=e.elements[n],l=a3[o.name],h=o.normalize?nY:nX;r.push({shaderLocation:l,offset:t?o.offset:0,format:`${h[o.dataType]}${o.numComponents>1?`x${o.numComponents}`:""}`}),t&&n!==a-1||(i.push({attributes:r,arrayStride:o.stride,stepMode:s}),r=[]);}};return e&&s(e),t&&s(t),i}constructor(){this.cache=new Map;}}class n${constructor(e){this.device=e;}getPipelineLayout(e){let t=[];return e.forEach(e=>{t.push(e.bindGroupLayout);}),this.device.wgpu.createPipelineLayout({bindGroupLayouts:t})}}let nj=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],nK=["add","subtract","reverse-subtract","min","max"],nZ=["zero","one","src","one-minus-src","dst","one-minus-dst","src-alpha","src-alpha-saturated","one-minus-src-alpha","dst-alpha","one-minus-dst-alpha","constant","one-minus-constant"],nQ=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],nJ=["none","back","front"],n0=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],n1=["","uint16","uint32"];class n2{}class n3 extends n${constructor(e){super(e),this.lookupHashes=new Uint32Array(14),this.vertexBufferLayout=new nq,this.cache=new Map;}get(e,t,i,s,r,a,n,o,l,h,c,d,u){let f=e.type;s&&f!==sS&&f!==sx&&(s=void 0);let p=this.lookupHashes;p[0]=f,p[1]=r.id,p[2]=h,p[3]=l.key,p[4]=o.key,p[5]=t?.renderingHash??0,p[6]=i?.renderingHash??0,p[7]=a.impl.key,p[8]=n[0]?.key??0,p[9]=n[1]?.key??0,p[10]=n[2]?.key??0,p[11]=c?d.key:0,p[12]=c?u.key:0,p[13]=s??0;let m=nw(p),_=this.cache.get(m);if(_)for(let e=0;e<_.length;e++){let t=_[e];if(nW.equals(t.hashes,p))return t.pipeline}let g=nj[f],v=this.getPipelineLayout(n),S=this.vertexBufferLayout.get(t,i),y=new n2;return y.hashes=new Uint32Array(p),y.pipeline=this.create(g,s,r,a,v,o,l,S,h,c,d,u),_?_.push(y):_=[y],this.cache.set(m,_),y.pipeline}getBlend(e){let t;return e.blend&&(t={color:{operation:nK[e.colorOp],srcFactor:nZ[e.colorSrcFactor],dstFactor:nZ[e.colorDstFactor]},alpha:{operation:nK[e.alphaOp],srcFactor:nZ[e.alphaSrcFactor],dstFactor:nZ[e.alphaDstFactor]}}),t}getDepthStencil(e,t,i,s,r,a){let n,{depth:o,stencil:l}=t;if(o||l){if(n={format:t.impl.depthAttachment.format},o){n.depthWriteEnabled=e.write,n.depthCompare=nQ[e.func];let t="triangle-list"===a||"triangle-strip"===a;n.depthBias=t?e.depthBias:0,n.depthBiasSlopeScale=t?e.depthBiasSlope:0;}else n.depthWriteEnabled=false,n.depthCompare="always";l&&i&&(n.stencilReadMas=s.readMask,n.stencilWriteMask=s.writeMask,n.stencilFront={compare:nQ[s.func],failOp:n0[s.fail],passOp:n0[s.zpass],depthFailOp:n0[s.zfail]},n.stencilBack={compare:nQ[r.func],failOp:n0[r.fail],passOp:n0[r.zpass],depthFailOp:n0[r.zfail]});}return n}create(e,t,i,s,r,a,n,o,l,h,c,d){let u=this.device.wgpu,f=i.impl,p={vertex:{module:f.getVertexShaderModule(),entryPoint:f.vertexEntryPoint,buffers:o},primitive:{topology:e,frontFace:"ccw",cullMode:nJ[l]},depthStencil:this.getDepthStencil(n,s,h,c,d,e),multisample:{count:s.samples},layout:r};t&&(p.primitive.stripIndexFormat=n1[t]),p.fragment={module:f.getFragmentShaderModule(),entryPoint:f.fragmentEntryPoint,targets:[]};let m=s.impl.colorAttachments;if(m.length>0){let e=0;a.redWrite&&(e|=GPUColorWrite.RED),a.greenWrite&&(e|=GPUColorWrite.GREEN),a.blueWrite&&(e|=GPUColorWrite.BLUE),a.alphaWrite&&(e|=GPUColorWrite.ALPHA);let t=this.getBlend(a);m.forEach(i=>{p.fragment.targets.push({format:i.format,writeMask:e,blend:t});});}return u.createRenderPipeline(p)}}class n4 extends n${get(e,t){let i=this.getPipelineLayout([t.impl]);return this.create(e,i)}create(e,t){let i=this.device.wgpu,s=e.impl,r={compute:{module:s.getComputeShaderModule(),entryPoint:s.computeEntryPoint},layout:t};return i.createComputePipeline(r)}}class n5{incRefCount(){this._refCount++;}decRefCount(){this._refCount--;}get refCount(){return this._refCount}constructor(){this._refCount=0;}}class n8 extends n5{constructor(e){super(),this.object=e,this.incRefCount();}}class n6{destroy(){this.cache.forEach(e=>{e.object?.destroy();}),this.cache.clear();}clear(){this.cache.clear();}get(e){let t=this.cache.get(e);return t?(t.incRefCount(),t.object):null}set(e,t){this.cache.set(e,new n8(t));}release(e){let t=this.cache.get(e);t&&(t.decRefCount(),0===t.refCount&&(this.cache.delete(e),t.object?.destroy()));}constructor(){this.cache=new Map;}}class n9 extends n6{loseContext(e){this.clear();}}let n7=new nt,oe=e=>n7.get(e,()=>new n9),ot=new np;class oi{destroy(){this.multisampledBuffer?.destroy(),this.multisampledBuffer=null;}}class os{constructor(e){this.depthTexture=null,this.depthTextureInternal=false,this.multisampledDepthBuffer=null,this.format=e,this.hasStencil="depth24plus-stencil8"===e;}destroy(e){this.depthTextureInternal&&(this.depthTexture?.destroy(),this.depthTexture=null),this.multisampledDepthBuffer&&(this.multisampledDepthBuffer=null,oe(e).release(this.multisampledDepthBufferKey));}}class or{constructor(e){this.initialized=false,this.colorAttachments=[],this.depthAttachment=null,this.assignedColorTexture=null,this.renderPassDescriptor={},this.isBackbuffer=false,this.renderTarget=e;}destroy(e){this.initialized=false,this.assignedColorTexture=null,this.colorAttachments.forEach(e=>{e.destroy();}),this.colorAttachments.length=0,this.depthAttachment?.destroy(e),this.depthAttachment=null;}updateKey(){let e=this.renderTarget,t=`${e.samples}:${this.depthAttachment?this.depthAttachment.format:"nodepth"}`;this.colorAttachments.forEach(e=>{t+=`:${e.format}`;}),this.key=ot.get(t);}assignColorTexture(e,t){this.assignedColorTexture=t;let i=t.createView({format:e.backBufferViewFormat}),s=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?s.resolveTarget=i:s.view=i,this.setColorAttachment(0,void 0,e.backBufferViewFormat),this.updateKey();}setColorAttachment(e,t,i){this.colorAttachments[e]||(this.colorAttachments[e]=new oi),t&&(this.colorAttachments[e].multisampledBuffer=t),i&&(this.colorAttachments[e].format=i);}init(e,t){let i=e.wgpu;this.initDepthStencil(e,i,t),t._colorBuffers&&t._colorBuffers.forEach((e,t)=>{this.setColorAttachment(t,void 0,e.impl.format);}),this.renderPassDescriptor.colorAttachments=[];let s=this.isBackbuffer?1:t._colorBuffers?.length??0;for(let r=0;r<s;++r){let s=this.initColor(e,i,t,r),a=0===r&&this.colorAttachments[0]?.format;(s.view||a)&&this.renderPassDescriptor.colorAttachments.push(s);}this.updateKey(),this.initialized=true;}initDepthStencil(e,t,i){let{samples:s,width:r,height:a,depth:n,depthBuffer:o}=i;if(n||o){let i;if(o)if(this.depthAttachment=new os(o.impl.format),s>1){let n="depth24plus-stencil8";this.depthAttachment.format=n,this.depthAttachment.hasStencil=true;let l=`${o.id}:${r}:${a}:${s}:${n}`,h=oe(e),c=h.get(l);if(!c){let e={size:[r,a,1],dimension:"2d",sampleCount:s,format:n,usage:GPUTextureUsage.RENDER_ATTACHMENT|(n!==o.impl.format?GPUTextureUsage.TEXTURE_BINDING:0)};c=t.createTexture(e),h.set(l,c);}this.depthAttachment.multisampledDepthBuffer=c,this.depthAttachment.multisampledDepthBufferKey=l,i=c.createView();}else {let e=o.impl.gpuTexture;this.depthAttachment.depthTexture=e,i=e.createView();}else {this.depthAttachment=new os("depth24plus-stencil8");let e={size:[r,a,1],dimension:"2d",sampleCount:s,format:this.depthAttachment.format,usage:GPUTextureUsage.RENDER_ATTACHMENT};s>1?e.usage|=GPUTextureUsage.TEXTURE_BINDING:e.usage|=GPUTextureUsage.COPY_SRC;let n=t.createTexture(e);this.depthAttachment.depthTexture=n,this.depthAttachment.depthTextureInternal=true,i=n.createView();}this.renderPassDescriptor.depthStencilAttachment={view:i};}}initColor(e,t,i,s){let r={},{samples:a,width:n,height:o,mipLevel:l}=i,h=i.getColorBuffer(s),c=null;if(h&&(c=h.cubemap?h.impl.createView({dimension:"2d",baseArrayLayer:i.face,arrayLayerCount:1,mipLevelCount:1,baseMipLevel:l}):h.impl.createView({mipLevelCount:1,baseMipLevel:l})),a>1){let i={size:[n,o,1],dimension:"2d",sampleCount:a,format:this.isBackbuffer?e.backBufferViewFormat:h.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},l=t.createTexture(i);this.setColorAttachment(s,l,i.format),r.view=l.createView(),r.resolveTarget=c;}else r.view=c;return r}setupForRenderPass(e,t){let i=this.renderPassDescriptor.colorAttachments?.length??0;for(let s=0;s<i;++s){let i=this.renderPassDescriptor.colorAttachments[s],r=e.colorArrayOps[s];i.clearValue=t.isColorBufferSrgb(s)?r.clearValueLinear:r.clearValue,i.loadOp=r.clear?"clear":"load",i.storeOp=r.store?"store":"discard";}let s=this.renderPassDescriptor.depthStencilAttachment;s&&(s.depthClearValue=e.depthStencilOps.clearDepthValue,s.depthLoadOp=e.depthStencilOps.clearDepth?"clear":"load",s.depthStoreOp=e.depthStencilOps.storeDepth?"store":"discard",s.depthReadOnly=false,this.depthAttachment.hasStencil&&(s.stencilClearValue=e.depthStencilOps.clearStencilValue,s.stencilLoadOp=e.depthStencilOps.clearStencil?"clear":"load",s.stencilStoreOp=e.depthStencilOps.storeStencil?"store":"discard",s.stencilReadOnly=false));}loseContext(){this.initialized=false;}resolve(e,t,i,s){}}let oa=[];oa[rU]=1,oa[rk]=2,oa[rz]=3,oa[rV]=4,oa[rB]=1,oa[rG]=2,oa[rH]=3,oa[rW]=4,oa[rN]=1,oa[rX]=2,oa[rY]=3,oa[rq]=4,oa[r$]=8,oa[rj]=12,oa[rK]=16,oa[r9]=1,oa[r7]=2,oa[ae]=3,oa[at]=4;class on{get isArrayType(){return this.count>0}constructor(e,t,i=0){if(this.shortName=e,this.name=i?`${e}[0]`:e,this.type=t,this.numComponents=oa[t],this.updateType=t,i>0)switch(t){case rU:this.updateType=rJ;break;case rB:this.updateType=ai;break;case r9:this.updateType=as;break;case rN:this.updateType=ar;break;case rk:this.updateType=r3;break;case rG:this.updateType=aa;break;case r7:this.updateType=an;break;case rX:this.updateType=ao;break;case rz:this.updateType=r4;break;case rH:this.updateType=al;break;case ae:this.updateType=ah;break;case rY:this.updateType=ac;break;case rV:this.updateType=r5;break;case rW:this.updateType=ad;break;case at:this.updateType=au;break;case rq:this.updateType=af;break;case rK:this.updateType=r8;}this.count=i;let s=this.numComponents;i&&(s=eb.roundUp(s,4)),this.byteSize=4*s,i&&(this.byteSize*=i);}calculateOffset(e){let t=this.byteSize<=8?this.byteSize:16;this.count&&(t=16),e=eb.roundUp(e,t),this.offset=e/4;}}class oo{constructor(e,t){this.byteSize=0,this.map=new Map,this.scope=e.scope,this.uniforms=t;let i=0;for(let e=0;e<t.length;e++){let s=t[e];s.calculateOffset(i),i=4*s.offset+s.byteSize,s.scopeId=this.scope.resolve(s.name),this.map.set(s.name,s);}this.byteSize=eb.roundUp(i,16);}get(e){return this.map.get(e)}}let ol=/[ \t]*(\battribute\b|\bvarying\b|\buniform\b)/g,oh=/(\battribute\b|\bvarying\b|\bout\b|\buniform\b)[ \t]*([^;]+)(;+)/g,oc=/([\w-]+)\[(.*?)\]/,od=new Set(["highp","mediump","lowp"]),ou=new Set(["sampler2DShadow","samplerCubeShadow","sampler2DArrayShadow"]),of={sampler2D:ru,sampler3D:r_,samplerCube:rp,samplerCubeShadow:rp,sampler2DShadow:ru,sampler2DArray:rf,sampler2DArrayShadow:rf,isampler2D:ru,usampler2D:ru,isampler3D:r_,usampler3D:r_,isamplerCube:rp,usamplerCube:rp,isampler2DArray:rf,usampler2DArray:rf},op={[ru]:"texture2D",[rp]:"textureCube",[r_]:"texture3D",[rf]:"texture2DArray"},om=class{constructor(e,t){this.line=e;let i=e.trim().split(/\s+/);if(od.has(i[0])&&(this.precision=i.shift()),this.type=i.shift(),e.includes(","),e.includes("[")){let e=i.join(" "),s=oc.exec(e);this.name=s[1],this.arraySize=Number(s[2]),isNaN(this.arraySize)&&(t.failed=true);}else this.name=i.shift(),this.arraySize=0;this.isSampler=-1!==this.type.indexOf("sampler"),this.isSignedInt=-1!==this.type.indexOf("isampler"),this.isUnsignedInt=-1!==this.type.indexOf("usampler");}};class o_{static run(e,t,i){let s=new Map,r=o_.extract(t.vshader),a=o_.extract(t.fshader),n=new Map,o=o_.processAttributes(r.attributes,t.attributes,n,t.processingOptions),l=o_.processVaryings(r.varyings,s,true),h=o_.processVaryings(a.varyings,s,false),c=o_.processOuts(a.outs),d=Array.from(new Set(r.uniforms.concat(a.uniforms))).map(e=>new om(e,i)),u=o_.processUniforms(e,d,t.processingOptions,i),f=`${o}
8
+ */let e,t,i,s,r,a,n,o,l,h,c,d,u,f,p,m,_,g;let v="RenderFrame",S="RenderFrameTime",y="RenderPass",x="RenderPassDetail",T="RenderAction",E="RenderTargetAlloc",b="TextureAlloc",w="ShaderAlloc",A="ShaderCompile",C="VRAM.Texture",P="VRAM.Vb",L="VRAM.Ib",D="VRAM.Sb",I="BindGroupAlloc",R="BindGroupFormatAlloc",M="RenderPipelineAlloc",O="ComputePipelineAlloc",F="PipelineLayoutAlloc",N="Element",B="Textures",U="RenderQueue",k="OctreeResources",z="GpuTimings",V="2.13.1",G="5d53ea1";function H(e,t){for(let i in t){let s=t[i];Array.isArray(s)?e[i]=H([],s):s&&"object"==typeof s?e[i]=H({},s):e[i]=s;}return e}let W={create:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return ("x"===e?t:3&t|8).toString(16)})},X={delimiter:"/",join(...e){let t=e[0];for(let i=0;i<e.length-1;i++){let s=e[i],r=e[i+1];if(r[0]===X.delimiter){t=r;continue}s&&r&&s[s.length-1]!==X.delimiter&&r[0]!==X.delimiter?t+=X.delimiter+r:t+=r;}return t},normalize(e){let t=e.startsWith(X.delimiter),i=e.endsWith(X.delimiter),s=e.split("/"),r="",a=[];for(let e=0;e<s.length;e++)if(""!==s[e]&&"."!==s[e]){if(".."===s[e]&&a.length>0){a=a.slice(0,a.length-2);continue}e>0&&a.push(X.delimiter),a.push(s[e]);}return r=a.join(""),t||r[0]!==X.delimiter||(r=r.slice(1)),i&&r[r.length-1]!==X.delimiter&&(r+=X.delimiter),r},split(e){let t=e.lastIndexOf(X.delimiter);return -1!==t?[e.substring(0,t),e.substring(t+1)]:["",e]},getBasename:e=>X.split(e)[1],getDirectory:e=>X.split(e)[0],getExtension(e){let t=e.split("?")[0].split(".").pop();return t!==e?`.${t}`:""},isRelativePath:e=>"/"!==e.charAt(0)&&null===e.match(/:\/\//),extractPath(e){let t="",i=e.split("/"),s=0;if(i.length>1)if(X.isRelativePath(e))if("."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else if(".."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else for(s=0,t=".";s<i.length-1;++s)t+=`/${i[s]}`;else for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;return t}},Y="undefined"!=typeof navigator?navigator.userAgent:"",q="undefined"!=typeof window?"browser":"undefined"!=typeof global?"node":"worker",$=/android/i.test(Y)?"android":/ip(?:[ao]d|hone)/i.test(Y)?"ios":/windows/i.test(Y)?"windows":/mac os/i.test(Y)?"osx":/linux/i.test(Y)?"linux":/cros/i.test(Y)?"cros":null,j="browser"!==q?null:/Chrome\/|Chromium\/|Edg.*\//.test(Y)?"chrome":/Safari\//.test(Y)?"safari":/Firefox\//.test(Y)?"firefox":"other",K=/xbox/i.test(Y),Z="browser"===q&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),Q="browser"===q&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),J="undefined"!=typeof Worker,ee=(()=>{let e=false;try{let t=Object.defineProperty({},"passive",{get:function(){return e=!0,!1}});window.addEventListener("testpassive",null,t),window.removeEventListener("testpassive",null,t);}catch(e){}return e})(),et={name:$,environment:q,global:("undefined"!=typeof globalThis&&globalThis)??("browser"===q&&window)??("node"===q&&global)??("worker"===q&&self),browser:"browser"===q,worker:"worker"===q,desktop:["windows","osx","linux","cros"].includes($),mobile:["android","ios"].includes($),ios:"ios"===$,android:"android"===$,xbox:K,gamepads:Q,touch:Z,workers:J,passiveEvents:ee,browserName:j},ei="abcdefghijklmnopqrstuvwxyz",es="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function er(e,t=0){let i=e.length;if(t<0||t>=i)return null;let s=e.charCodeAt(t);if(i>1&&s>=55296&&s<=56319){let i=e.charCodeAt(t+1);if(i>=56320&&i<=57343)return {code:(s-55296)*1024+i-56320+65536,long:true}}return {code:s,long:false}}function ea(e,t,i){if(!e)return false;let s=er(e);if(s){let e=s.code;return e>=t&&e<=i}return false}let en={ASCII_LOWERCASE:ei,ASCII_UPPERCASE:es,ASCII_LETTERS:ei+es,format(e,...t){for(let i=0;i<t.length;i++)e=e.replace(`{${i}}`,t[i]);return e},getCodePoint(e,t){let i=er(e,t);return i&&i.code},getCodePoints(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=[];for(;t=er(e,i);)s.push(t.code),i+=t.long?2:1;return s},getSymbols(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=e.length,r=[],a=0;for(;i<s;){if(a+=function(e,t){if(t===e.length-1)return 1;if(ea(e[t],55296,56319)){let i=e.substring(t,t+2),s=e.substring(t+2,t+4);return ea(s,127995,127999)||ea(i,127462,127487)&&ea(s,127462,127487)?4:ea(s,65024,65039)?3:2}return ea(e[t+1],65024,65039)?2:1}(e,i+a),ea(t=e[i+a],8400,8447)&&(t=e[i+a++]),ea(t,65024,65039)&&(t=e[i+a++]),t&&8205===t.charCodeAt(0)){t=e[i+a++];continue}let s=e.substring(i,i+a);r.push(s),i+=a,a=0;}return r},fromCodePoint:(...e)=>e.map(e=>e>65535?String.fromCharCode(((e-=65536)>>10)+55296,e%1024+56320):String.fromCharCode(e)).join("")};class eo{constructor(e,t,i,s,r=false){this._removed=false,this.handler=e,this.name=t,this.callback=i,this.scope=s,this._once=r;}off(){this._removed||this.handler.offByHandle(this);}on(e,t,i=this){return this.handler._addCallback(e,t,i,false)}once(e,t,i=this){return this.handler._addCallback(e,t,i,true)}set removed(e){e&&(this._removed=true);}get removed(){return this._removed}toJSON(e){}}class el{initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map;}_addCallback(e,t,i,s){if(this._callbacks.has(e)||this._callbacks.set(e,[]),this._callbackActive.has(e)){let t=this._callbackActive.get(e);t&&t===this._callbacks.get(e)&&this._callbackActive.set(e,t.slice());}let r=new eo(this,e,t,i,s);return this._callbacks.get(e).push(r),r}on(e,t,i=this){return this._addCallback(e,t,i,false)}once(e,t,i=this){return this._addCallback(e,t,i,true)}off(e,t,i){if(e)this._callbackActive.has(e)&&this._callbackActive.get(e)===this._callbacks.get(e)&&this._callbackActive.set(e,this._callbackActive.get(e).slice());else for(let[e,t]of this._callbackActive)this._callbacks.has(e)&&this._callbacks.get(e)===t&&this._callbackActive.set(e,t.slice());if(e)if(t){let s=this._callbacks.get(e);if(!s)return this;for(let e=0;e<s.length;e++)s[e].callback===t&&(!i||s[e].scope===i)&&(s[e].removed=true,s.splice(e,1),e--);0===s.length&&this._callbacks.delete(e);}else {let t=this._callbacks.get(e);if(t){for(let e=0;e<t.length;e++)t[e].removed=true;this._callbacks.delete(e);}}else {for(let e of this._callbacks.values())for(let t=0;t<e.length;t++)e[t].removed=true;this._callbacks.clear();}return this}offByHandle(e){let t=e.name;e.removed=true,this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());let i=this._callbacks.get(t);if(!i)return this;let s=i.indexOf(e);return -1!==s&&(i.splice(s,1),0===i.length&&this._callbacks.delete(t)),this}fire(e,t,i,s,r,a,n,o,l){let h;if(!e)return this;let c=this._callbacks.get(e);if(!c)return this;this._callbackActive.has(e)?this._callbackActive.get(e)!==c&&(h=c.slice()):this._callbackActive.set(e,c);for(let c=0;(h||this._callbackActive.get(e))&&c<(h||this._callbackActive.get(e)).length;c++){let d=(h||this._callbackActive.get(e))[c];if(d.callback&&(d.callback.call(d.scope,t,i,s,r,a,n,o,l),d._once)){let t=this._callbacks.get(e),i=t?t.indexOf(d):-1;if(-1!==i){this._callbackActive.get(e)===t&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let s=this._callbacks.get(e);if(!s)continue;s[i].removed=true,s.splice(i,1),0===s.length&&this._callbacks.delete(e);}}}return h||this._callbackActive.delete(e),this}hasEvent(e){return !!this._callbacks.get(e)?.length}constructor(){this._callbacks=new Map,this._callbackActive=new Map;}}class eh{push(e,t){if(this._index[e])throw Error(`Key already in index ${e}`);let i=this._list.push(t)-1;this._index[e]=i;}has(e){return void 0!==this._index[e]}get(e){let t=this._index[e];return void 0!==t?this._list[t]:null}remove(e){let t=this._index[e];if(void 0!==t){for(e in this._list.splice(t,1),delete this._index[e],this._index){let i=this._index[e];i>t&&(this._index[e]=i-1);}return true}return false}list(){return this._list}clear(){for(let e in this._list.length=0,this._index)delete this._index[e];}constructor(){this._list=[],this._index={};}}class ec{static{this.modules={};}static{this.wasmSupported=(e=>{let t={},i=t;return ()=>(i===t&&(i=e()),i)})(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){let e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}return false});}static loadScript(e,t){let i=document.createElement("script");i.setAttribute("src",e),i.onload=()=>{t(null);},i.onerror=()=>{t(`Failed to load script='${e}'`);},document.body.appendChild(i);}static loadWasm(e,t,i){let s=ec.wasmSupported()&&t.glueUrl&&t.wasmUrl?t.glueUrl:t.fallbackUrl;s?ec.loadScript(s,s=>{if(s)i(s,null);else {let s=window[e];window[e]=void 0,s({locateFile:()=>t.wasmUrl,onAbort:()=>{i("wasm module aborted.");}}).then(e=>{i(null,e);});}}):i("No supported wasm modules found.",null);}static getModule(e){return ec.modules.hasOwnProperty(e)||(ec.modules[e]={config:null,initializing:false,instance:null,callbacks:[]}),ec.modules[e]}static initialize(e,t){if(t.initializing)return;let i=t.config;(i.glueUrl||i.wasmUrl||i.fallbackUrl)&&(t.initializing=true,ec.loadWasm(e,i,(e,s)=>{e?i.errorHandler&&i.errorHandler(e):(t.instance=s,t.callbacks.forEach(e=>{e(s);}));}));}}class ed{static setConfig(e,t){let i=ec.getModule(e);i.config=t,i.callbacks.length>0&&ec.initialize(e,i);}static getConfig(e){return ec.modules?.[e]?.config}static getInstance(e,t){let i=ec.getModule(e);i.instance?t(i.instance):(i.callbacks.push(t),i.config&&ec.initialize(e,i));}}class eu{constructor(e){this.offset=0,this.arraybuffer=e,this.dataView=new DataView(e);}get remainingBytes(){return this.dataView.byteLength-this.offset}reset(e=0){this.offset=e;}skip(e){this.offset+=e;}align(e){this.offset=this.offset+e-1&~(e-1);}_inc(e){return this.offset+=e,this.offset-e}readChar(){return String.fromCharCode(this.dataView.getUint8(this.offset++))}readChars(e){let t="";for(let i=0;i<e;++i)t+=this.readChar();return t}readU8(){return this.dataView.getUint8(this.offset++)}readU16(){return this.dataView.getUint16(this._inc(2),true)}readU32(){return this.dataView.getUint32(this._inc(4),true)}readU64(){return this.readU32()+0x100000000*this.readU32()}readU32be(){return this.dataView.getUint32(this._inc(4),false)}readArray(e){for(let t=0;t<e.length;++t)e[t]=this.readU8();}readLine(){let e=this.dataView,t="";for(;!(this.offset>=e.byteLength);){let e=String.fromCharCode(this.readU8());if("\n"===e)break;t+=e;}return t}}class ef{constructor(e){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=e.sortBy,this._sortHandler=this._doSort.bind(this);}_binarySearch(e){let t,i,s=0,r=this.items.length-1,a=e[this._sortBy];for(;s<=r;)t=Math.floor((s+r)/2),(i=this.items[t][this._sortBy])<=a?s=t+1:i>a&&(r=t-1);return s}_doSort(e,t){let i=this._sortBy;return e[i]-t[i]}insert(e){let t=this._binarySearch(e);this.items.splice(t,0,e),this.length++,this.loopIndex>=t&&this.loopIndex++;}append(e){this.items.push(e),this.length++;}remove(e){let t=this.items.indexOf(e);!(t<0)&&(this.items.splice(t,1),this.length--,this.loopIndex>=t&&this.loopIndex--);}sort(){let e=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),null!==e&&(this.loopIndex=this.items.indexOf(e));}}class ep extends el{static{this.EVENT_ADD="add";}static{this.EVENT_REMOVE="remove";}static{this.EVENT_CHANGE="change";}constructor(e){super(),this._index={},this._list=[],this._parent=e;}add(...e){let t=false,i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]||(t=true,this._index[i[e]]=true,this._list.push(i[e]),this.fire("add",i[e],this._parent));return t&&this.fire("change",this._parent),t}remove(...e){let t=false;if(!this._list.length)return t;let i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]&&(t=true,delete this._index[i[e]],this._list.splice(this._list.indexOf(i[e]),1),this.fire("remove",i[e],this._parent));return t&&this.fire("change",this._parent),t}clear(){if(!this._list.length)return;let e=this._list.slice(0);this._list=[],this._index={};for(let t=0;t<e.length;t++)this.fire("remove",e[t],this._parent);this.fire("change",this._parent);}has(...e){return !!this._list.length&&this._has(this._processArguments(e))}_has(e){if(!this._list.length||!e.length)return false;for(let t=0;t<e.length;t++)if(1===e[t].length){if(this._index[e[t][0]])return true}else {let i=true;for(let s=0;s<e[t].length;s++)if(!this._index[e[t][s]]){i=false;break}if(i)return true}return false}list(){return this._list.slice(0)}_processArguments(e,t){let i=[],s=[];if(!e||!e.length)return i;for(let r=0;r<e.length;r++)if(e[r]instanceof Array){t||(s=[]);for(let a=0;a<e[r].length;a++)"string"==typeof e[r][a]&&(t?i.push(e[r][a]):s.push(e[r][a]));!t&&s.length&&i.push(s);}else "string"==typeof e[r]&&(t?i.push(e[r]):i.push([e[r]]));return i}get size(){return this._list.length}}let em="undefined"!=typeof window&&window.performance&&window.performance.now?performance.now.bind(performance):Date.now;function e_(e){let t="";if((e.authority||e.scheme)&&(e.host||e.hostpath))throw Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(e.host&&e.hostpath)throw Error("Can't have 'host' and 'hostpath' option");if(e.path&&e.hostpath)throw Error("Can't have 'path' and 'hostpath' option");return e.scheme&&(t+=`${e.scheme}:`),e.authority&&(t+=`//${e.authority}`),e.host&&(t+=e.host),e.path&&(t+=e.path),e.hostpath&&(t+=e.hostpath),e.query&&(t+=`?${e.query}`),e.fragment&&(t+=`#${e.fragment}`),t}let eg=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class ev{constructor(e){let t=e.match(eg);this.scheme=t[2],this.authority=t[4],this.path=t[5],this.query=t[7],this.fragment=t[9];}toString(){let e="";return this.scheme&&(e+=`${this.scheme}:`),this.authority&&(e+=`//${this.authority}`),e+=this.path,this.query&&(e+=`?${this.query}`),this.fragment&&(e+=`#${this.fragment}`),e}getQuery(){let e={};if(this.query)for(let t of decodeURIComponent(this.query).split("&")){let i=t.split("=");e[i[0]]=i[1];}return e}setQuery(e){let t="";for(let i in e)e.hasOwnProperty(i)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`);this.query=t;}}class eS{static{this._traceChannels=new Set;}static{this.stack=false;}static set(e,t=true){}static get(e){return eS._traceChannels.has(e)}}let ey=0,ex=1,eT=4,eE=5,eb={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:(e,t,i)=>e>=i?i:e<=t?t:e,intToBytes24:e=>[e>>16&255,e>>8&255,255&e],intToBytes32:e=>[e>>24&255,e>>16&255,e>>8&255,255&e],bytesToInt24:(e,t,i)=>(e.length&&(i=e[2],t=e[1],e=e[0]),e<<16|t<<8|i),bytesToInt32:(e,t,i,s)=>(e.length&&(s=e[3],i=e[2],t=e[1],e=e[0]),(e<<24|t<<16|i<<8|s)>>>0),lerp:(e,t,i)=>e+(t-e)*eb.clamp(i,0,1),lerpAngle:(e,t,i)=>(t-e>180&&(t-=360),t-e<-180&&(t+=360),eb.lerp(e,t,eb.clamp(i,0,1))),powerOfTwo:e=>0!==e&&!(e&e-1),nextPowerOfTwo:e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e),nearestPowerOfTwo:e=>Math.pow(2,Math.round(Math.log2(e))),random:(e,t)=>Math.random()*(t-e)+e,smoothstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*(3-2*i),smootherstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*i*(i*(6*i-15)+10),roundUp:(e,t)=>0===t?e:Math.ceil(e/t)*t,between(e,t,i,s){let r=Math.min(t,i),a=Math.max(t,i);return s?e>=r&&e<=a:e>r&&e<a}};class ew{constructor(e=0,t=0,i=0,s=1){let r=e.length;3===r||4===r?(this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3]??1):(this.r=e,this.g=t,this.b=i,this.a=s);}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}equals(e){return this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}set(e,t,i,s=1){return this.r=e,this.g=t,this.b=i,this.a=s,this}lerp(e,t,i){return this.r=e.r+i*(t.r-e.r),this.g=e.g+i*(t.g-e.g),this.b=e.b+i*(t.b-e.b),this.a=e.a+i*(t.a-e.a),this}linear(e=this){return this.r=Math.pow(e.r,2.2),this.g=Math.pow(e.g,2.2),this.b=Math.pow(e.b,2.2),this.a=e.a,this}gamma(e=this){return this.r=Math.pow(e.r,1/2.2),this.g=Math.pow(e.g,1/2.2),this.b=Math.pow(e.b,1/2.2),this.a=e.a,this}mulScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}fromString(e){let t,i=parseInt(e.replace("#","0x"),16);return e.length>7?t=eb.intToBytes32(i):(t=eb.intToBytes24(i))[3]=255,this.set(t[0]/255,t[1]/255,t[2]/255,t[3]/255),this}fromArray(e,t=0){return this.r=e[t]??this.r,this.g=e[t+1]??this.g,this.b=e[t+2]??this.b,this.a=e[t+3]??this.a,this}toString(e,t){let{r:i,g:s,b:r,a}=this;if(t||i>1||s>1||r>1)return `${i.toFixed(3)}, ${s.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let n=`#${(0x1000000+(Math.round(255*i)<<16)+(Math.round(255*s)<<8)+Math.round(255*r)).toString(16).slice(1)}`;if(true===e){let e=Math.round(255*a).toString(16);this.a<16/255?n+=`0${e}`:n+=e;}return n}toArray(e=[],t=0,i=true){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,i&&(e[t+3]=this.a),e}static{this.BLACK=Object.freeze(new ew(0,0,0,1));}static{this.BLUE=Object.freeze(new ew(0,0,1,1));}static{this.CYAN=Object.freeze(new ew(0,1,1,1));}static{this.GRAY=Object.freeze(new ew(.5,.5,.5,1));}static{this.GREEN=Object.freeze(new ew(0,1,0,1));}static{this.MAGENTA=Object.freeze(new ew(1,0,1,1));}static{this.RED=Object.freeze(new ew(1,0,0,1));}static{this.WHITE=Object.freeze(new ew(1,1,1,1));}static{this.YELLOW=Object.freeze(new ew(1,1,0,1));}}class eA{constructor(e,t=0){this._left=-1/0,this._right=1/0,this._recip=0,this._p0=0,this._p1=0,this._m0=0,this._m1=0,this._curve=e,this._reset(t);}evaluate(e,t=false){let i;(t||e<this._left||e>=this._right)&&this._reset(e);let s=this._curve.type;if(s===eE)i=this._p0;else {let t=0===this._recip?0:(e-this._left)*this._recip;i=s===ey?eb.lerp(this._p0,this._p1,t):s===ex?eb.lerp(this._p0,this._p1,t*t*(3-2*t)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,t);}return i}_reset(e){let t=this._curve.keys,i=t.length;if(i)if(e<t[0][0])this._left=-1/0,this._right=t[0][0],this._recip=0,this._p0=this._p1=t[0][1],this._m0=this._m1=0;else if(e>=t[i-1][0])this._left=t[i-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=t[i-1][1],this._m0=this._m1=0;else {let i=0;for(;e>=t[i+1][0];)i++;this._left=t[i][0],this._right=t[i+1][0];let s=1/(this._right-this._left);this._recip=isFinite(s)?s:0,this._p0=t[i][1],this._p1=t[i+1][1],this._curve.type===eT&&this._calcTangents(t,i);}else this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0;}_calcTangents(e,t){let i,s,r=e[t],a=e[t+1];if(i=0===t?[e[0][0]+(e[0][0]-e[1][0]),e[0][1]+(e[0][1]-e[1][1])]:e[t-1],s=t===e.length-2?[e[t+1][0]+(e[t+1][0]-e[t][0]),e[t+1][1]+(e[t+1][1]-e[t][1])]:e[t+2],this._curve.type===eT){let e=2*(a[0]-r[0])/(a[0]-i[0]),t=2*(a[0]-r[0])/(s[0]-r[0]);this._m0=this._curve.tension*(isFinite(e)?e:0)*(a[1]-i[1]),this._m1=this._curve.tension*(isFinite(t)?t:0)*(s[1]-r[1]);}else {let e=(a[0]-r[0])/(r[0]-i[0]),t=(a[0]-r[0])/(s[0]-a[0]),n=r[1]+(i[1]-r[1])*(isFinite(e)?e:0),o=a[1]+(s[1]-a[1])*(isFinite(t)?t:0),l=this._curve.tension;this._m0=l*(a[1]-n),this._m1=l*(o-r[1]);}}_evaluateHermite(e,t,i,s,r){let a=r*r,n=r+r,o=1-r,l=o*o;return (1+n)*l*e+r*l*i+a*(3-n)*t+a*(r-1)*s}}class eC{constructor(e){if(this.keys=[],this.type=ex,this.tension=.5,this._eval=new eA(this),e)for(let t=0;t<e.length-1;t+=2)this.keys.push([e[t],e[t+1]]);this.sort();}get length(){return this.keys.length}add(e,t){let i=this.keys,s=i.length,r=0;for(;r<s&&!(i[r][0]>e);r++);let a=[e,t];return this.keys.splice(r,0,a),a}get(e){return this.keys[e]}sort(){this.keys.sort((e,t)=>e[0]-t[0]);}value(e){return this._eval.evaluate(e,true)}closest(e){let t=this.keys,i=t.length,s=2,r=null;for(let a=0;a<i;a++){let i=Math.abs(e-t[a][0]);if(s>=i)s=i,r=t[a];else break}return r}clone(){let e=new this.constructor;return e.keys=this.keys.map(e=>[...e]),e.type=this.type,e.tension=this.tension,e}quantize(e){let t=new Float32Array(e=Math.max(e,2)),i=1/(e-1);t[0]=this._eval.evaluate(0,true);for(let s=1;s<e;s++)t[s]=this._eval.evaluate(i*s);return t}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}class eP{constructor(...e){if(this.curves=[],this._type=ex,e.length>1)for(let t=0;t<e.length;t++)this.curves.push(new eC(e[t]));else if(0===e.length)this.curves.push(new eC);else {let t=e[0];if("number"==typeof t)for(let e=0;e<t;e++)this.curves.push(new eC);else for(let e=0;e<t.length;e++)this.curves.push(new eC(t[e]));}}get length(){return this.curves.length}set type(e){this._type=e;for(let t=0;t<this.curves.length;t++)this.curves[t].type=e;}get type(){return this._type}get(e){return this.curves[e]}value(e,t=[]){let i=this.curves.length;t.length=i;for(let s=0;s<i;s++)t[s]=this.curves[s].value(e);return t}clone(){let e=new this.constructor;e.curves=[];for(let t=0;t<this.curves.length;t++)e.curves.push(this.curves[t].clone());return e._type=this._type,e}quantize(e){e=Math.max(e,2);let t=this.curves.length,i=new Float32Array(e*t),s=1/(e-1);for(let r=0;r<t;r++){let a=new eA(this.curves[r]);for(let n=0;n<e;n++)i[n*t+r]=a.evaluate(s*n);}return i}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}let eL=new Float32Array(1),eD=new Int32Array(eL.buffer);class eI{static float2Half(e){eL[0]=e;let t=eD[0],i=t>>16&32768,s=t>>12&2047,r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=+(255!==r)&&8388607&t):r<113?(s|=2048,i|=(s>>114-r)+(s>>113-r&1)):(i|=r-112<<10|s>>1,i+=1&s)}static float2RGBA8(e,t){eL[0]=e;let i=eD[0];t.r=(i>>24&255)/255,t.g=(i>>16&255)/255,t.b=(i>>8&255)/255,t.a=(255&i)/255;}}class eR{static concentric(e,t){let i=[];i.push(0,0);let s=2*Math.PI/e/t;for(let t=1;t<=e;t++){let r=t/e,a=Math.max(1,Math.floor(2*Math.PI*r/s)),n=2*Math.PI/a;for(let e=0;e<a;e++){let t=e*n,s=r*Math.cos(t),a=r*Math.sin(t);i.push(s,a);}}return i}}class eM{constructor(e=0,t=0,i=0){3===e.length?(this.x=e[0],this.y=e[1],this.z=e[2]):(this.x=e,this.y=t,this.z=i);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}cross(e,t){let i=e.x,s=e.y,r=e.z,a=t.x,n=t.y,o=t.z;return this.x=s*o-n*r,this.y=r*a-o*i,this.z=i*n-a*s,this}distance(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return Math.sqrt(t*t+i*i+s*s)}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this}project(e){let t=(this.x*e.x+this.y*e.y+this.z*e.z)/(e.x*e.x+e.y*e.y+e.z*e.z);return this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this}toString(){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,e}static{this.ZERO=Object.freeze(new eM(0,0,0));}static{this.HALF=Object.freeze(new eM(.5,.5,.5));}static{this.ONE=Object.freeze(new eM(1,1,1));}static{this.UP=Object.freeze(new eM(0,1,0));}static{this.DOWN=Object.freeze(new eM(0,-1,0));}static{this.RIGHT=Object.freeze(new eM(1,0,0));}static{this.LEFT=Object.freeze(new eM(-1,0,0));}static{this.FORWARD=Object.freeze(new eM(0,0,-1));}static{this.BACK=Object.freeze(new eM(0,0,1));}}class eO{constructor(){this.data=new Float32Array(9),this.data[0]=this.data[4]=this.data[8]=1;}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}getX(e=new eM){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eM){return e.set(this.data[3],this.data[4],this.data[5])}getZ(e=new eM){return e.set(this.data[6],this.data[7],this.data[8])}equals(e){let t=this.data,i=e.data;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]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&1===e[4]&&0===e[5]&&0===e[6]&&0===e[7]&&1===e[8]}setIdentity(){let e=this.data;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this}toString(){return `[${this.data.join(", ")}]`}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[3],i[3]=e,e=t[2],i[2]=t[6],i[6]=e,e=t[5],i[5]=t[7],i[7]=e;}else i[0]=t[0],i[1]=t[3],i[2]=t[6],i[3]=t[1],i[4]=t[4],i[5]=t[7],i[6]=t[2],i[7]=t[5],i[8]=t[8];return this}setFromMat4(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[4],i[4]=t[5],i[5]=t[6],i[6]=t[8],i[7]=t[9],i[8]=t[10],this}setFromQuat(e){let t=e.x,i=e.y,s=e.z,r=e.w,a=t+t,n=i+i,o=s+s,l=t*a,h=t*n,c=t*o,d=i*n,u=i*o,f=s*o,p=r*a,m=r*n,_=r*o,g=this.data;return g[0]=1-(d+f),g[1]=h+_,g[2]=c-m,g[3]=h-_,g[4]=1-(l+f),g[5]=u+p,g[6]=c+m,g[7]=u-p,g[8]=1-(l+d),this}invertMat4(e){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[4],n=t[5],o=t[6],l=t[8],h=t[9],c=t[10],d=c*n-o*h,u=-c*a+o*l,f=h*a-n*l,p=i*d+s*u+r*f;if(0===p)this.setIdentity();else {let e=1/p,t=this.data;t[0]=d*e,t[1]=(-c*s+r*h)*e,t[2]=(o*s-r*n)*e,t[3]=u*e,t[4]=(c*i-r*l)*e,t[5]=(-o*i+r*a)*e,t[6]=f*e,t[7]=(-h*i+s*l)*e,t[8]=(n*i-s*a)*e;}return this}transformVector(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[3]+a*i[6],t.y=s*i[1]+r*i[4]+a*i[7],t.z=s*i[2]+r*i[5]+a*i[8],t}static{this.IDENTITY=Object.freeze(new eO);}static{this.ZERO=Object.freeze(new eO().set([0,0,0,0,0,0,0,0,0]));}}class eF{constructor(e=0,t=0){2===e.length?(this.x=e[0],this.y=e[1]):(this.x=e,this.y=t);}add(e){return this.x+=e.x,this.y+=e.y,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}cross(e){return this.x*e.y-this.y*e.x}distance(e){let t=this.x-e.x,i=this.y-e.y;return Math.sqrt(t*t+i*i)}div(e){return this.x/=e.x,this.y/=e.y,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}divScalar(e){return this.x/=e,this.y/=e,this}dot(e){return this.x*e.x+this.y*e.y}equals(e){return this.x===e.x&&this.y===e.y}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSq(){return this.x*this.x+this.y*this.y}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this}mul(e){return this.x*=e.x,this.y*=e.y,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}mulScalar(e){return this.x*=e,this.y*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i;}return this}rotate(e){let t=Math.atan2(this.x,this.y)+e*eb.DEG_TO_RAD,i=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(t)*i,this.y=Math.cos(t)*i,this}angle(){return Math.atan2(this.x,this.y)*eb.RAD_TO_DEG}angleTo(e){return Math.atan2(this.x*e.y+this.y*e.x,this.x*e.x+this.y*e.y)*eb.RAD_TO_DEG}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),this}set(e,t){return this.x=e,this.y=t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}subScalar(e){return this.x-=e,this.y-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this}toString(){return `[${this.x}, ${this.y}]`}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}static angleRad(e,t){return Math.atan2(e.x*t.y-e.y*t.x,e.x*t.x+e.y*t.y)}static{this.ZERO=Object.freeze(new eF(0,0));}static{this.HALF=Object.freeze(new eF(.5,.5));}static{this.ONE=Object.freeze(new eF(1,1));}static{this.UP=Object.freeze(new eF(0,1));}static{this.DOWN=Object.freeze(new eF(0,-1));}static{this.RIGHT=Object.freeze(new eF(1,0));}static{this.LEFT=Object.freeze(new eF(-1,0));}}class eN{constructor(e=0,t=0,i=0,s=0){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this.w=e.w/t.w,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this.w/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this.w=e.w+i*(t.w-e.w),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this.w=e.w*t.w,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i,this.w=e.w*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this.w=Math.floor(e.w),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this.w=Math.ceil(e.w),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this.w=Math.round(e.w),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){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,e}static{this.ZERO=Object.freeze(new eN(0,0,0,0));}static{this.HALF=Object.freeze(new eN(.5,.5,.5,.5));}static{this.ONE=Object.freeze(new eN(1,1,1,1));}}let eB=new eF,eU=new eM,ek=new eM,ez=new eM,eV=new eM;class eG{constructor(){this.data=new Float32Array(16),this.data[0]=this.data[5]=this.data[10]=this.data[15]=1;}static _getPerspectiveHalfSize(e,t,i,s,r){r?(e.x=s*Math.tan(t*Math.PI/360),e.y=e.x/i):(e.y=s*Math.tan(t*Math.PI/360),e.x=e.y*i);}add2(e,t){let i=e.data,s=t.data,r=this.data;return r[0]=i[0]+s[0],r[1]=i[1]+s[1],r[2]=i[2]+s[2],r[3]=i[3]+s[3],r[4]=i[4]+s[4],r[5]=i[5]+s[5],r[6]=i[6]+s[6],r[7]=i[7]+s[7],r[8]=i[8]+s[8],r[9]=i[9]+s[9],r[10]=i[10]+s[10],r[11]=i[11]+s[11],r[12]=i[12]+s[12],r[13]=i[13]+s[13],r[14]=i[14]+s[14],r[15]=i[15]+s[15],this}add(e){return this.add2(this,e)}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],this}equals(e){let t=this.data,i=e.data;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]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}mul2(e,t){let i,s,r,a,n=e.data,o=t.data,l=this.data,h=n[0],c=n[1],d=n[2],u=n[3],f=n[4],p=n[5],m=n[6],_=n[7],g=n[8],v=n[9],S=n[10],y=n[11],x=n[12],T=n[13],E=n[14],b=n[15];return i=o[0],s=o[1],r=o[2],a=o[3],l[0]=h*i+f*s+g*r+x*a,l[1]=c*i+p*s+v*r+T*a,l[2]=d*i+m*s+S*r+E*a,l[3]=u*i+_*s+y*r+b*a,i=o[4],s=o[5],r=o[6],a=o[7],l[4]=h*i+f*s+g*r+x*a,l[5]=c*i+p*s+v*r+T*a,l[6]=d*i+m*s+S*r+E*a,l[7]=u*i+_*s+y*r+b*a,i=o[8],s=o[9],r=o[10],a=o[11],l[8]=h*i+f*s+g*r+x*a,l[9]=c*i+p*s+v*r+T*a,l[10]=d*i+m*s+S*r+E*a,l[11]=u*i+_*s+y*r+b*a,i=o[12],s=o[13],r=o[14],a=o[15],l[12]=h*i+f*s+g*r+x*a,l[13]=c*i+p*s+v*r+T*a,l[14]=d*i+m*s+S*r+E*a,l[15]=u*i+_*s+y*r+b*a,this}mulAffine2(e,t){let i,s,r,a=e.data,n=t.data,o=this.data,l=a[0],h=a[1],c=a[2],d=a[4],u=a[5],f=a[6],p=a[8],m=a[9],_=a[10],g=a[12],v=a[13],S=a[14];return i=n[0],s=n[1],r=n[2],o[0]=l*i+d*s+p*r,o[1]=h*i+u*s+m*r,o[2]=c*i+f*s+_*r,o[3]=0,i=n[4],s=n[5],r=n[6],o[4]=l*i+d*s+p*r,o[5]=h*i+u*s+m*r,o[6]=c*i+f*s+_*r,o[7]=0,i=n[8],s=n[9],r=n[10],o[8]=l*i+d*s+p*r,o[9]=h*i+u*s+m*r,o[10]=c*i+f*s+_*r,o[11]=0,i=n[12],s=n[13],r=n[14],o[12]=l*i+d*s+p*r+g,o[13]=h*i+u*s+m*r+v,o[14]=c*i+f*s+_*r+S,o[15]=1,this}mul(e){return this.mul2(this,e)}transformPoint(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+i[12],t.y=s*i[1]+r*i[5]+a*i[9]+i[13],t.z=s*i[2]+r*i[6]+a*i[10]+i[14],t}transformVector(e,t=new eM){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8],t.y=s*i[1]+r*i[5]+a*i[9],t.z=s*i[2]+r*i[6]+a*i[10],t}transformVec4(e,t=new eN){let i=this.data,{x:s,y:r,z:a,w:n}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+n*i[12],t.y=s*i[1]+r*i[5]+a*i[9]+n*i[13],t.z=s*i[2]+r*i[6]+a*i[10]+n*i[14],t.w=s*i[3]+r*i[7]+a*i[11]+n*i[15],t}setLookAt(e,t,i){ez.sub2(e,t).normalize(),ek.copy(i).normalize(),eU.cross(ek,ez).normalize(),ek.cross(ez,eU);let s=this.data;return s[0]=eU.x,s[1]=eU.y,s[2]=eU.z,s[3]=0,s[4]=ek.x,s[5]=ek.y,s[6]=ek.z,s[7]=0,s[8]=ez.x,s[9]=ez.y,s[10]=ez.z,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}setFrustum(e,t,i,s,r,a){let n=2*r,o=t-e,l=s-i,h=a-r,c=this.data;return c[0]=n/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=n/l,c[6]=0,c[7]=0,c[8]=(t+e)/o,c[9]=(s+i)/l,c[10]=(-a-r)/h,c[11]=-1,c[12]=0,c[13]=0,c[14]=-n*a/h,c[15]=0,this}setPerspective(e,t,i,s,r){return eG._getPerspectiveHalfSize(eB,e,t,i,r),this.setFrustum(-eB.x,eB.x,-eB.y,eB.y,i,s)}setOrtho(e,t,i,s,r,a){let n=this.data;return n[0]=2/(t-e),n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=2/(s-i),n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=-2/(a-r),n[11]=0,n[12]=-(t+e)/(t-e),n[13]=-(s+i)/(s-i),n[14]=-(a+r)/(a-r),n[15]=1,this}setFromAxisAngle(e,t){t*=eb.DEG_TO_RAD;let{x:i,y:s,z:r}=e,a=Math.cos(t),n=Math.sin(t),o=1-a,l=o*i,h=o*s,c=this.data;return c[0]=l*i+a,c[1]=l*s+n*r,c[2]=l*r-n*s,c[3]=0,c[4]=l*s-n*r,c[5]=h*s+a,c[6]=h*r+n*i,c[7]=0,c[8]=l*r+n*s,c[9]=h*r-i*n,c[10]=o*r*r+a,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,this}setTranslate(e,t,i){let s=this.data;return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=e,s[13]=t,s[14]=i,s[15]=1,this}setScale(e,t,i){let s=this.data;return s[0]=e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=t,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=i,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}setViewport(e,t,i,s){let r=this.data;return r[0]=.5*i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=.5*s,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=e+.5*i,r[13]=t+.5*s,r[14]=.5,r[15]=1,this}setReflection(e,t){let i=e.x,s=e.y,r=e.z,a=this.data;return a[0]=1-2*i*i,a[1]=-2*i*s,a[2]=-2*i*r,a[3]=0,a[4]=-2*i*s,a[5]=1-2*s*s,a[6]=-2*s*r,a[7]=0,a[8]=-2*i*r,a[9]=-2*s*r,a[10]=1-2*r*r,a[11]=0,a[12]=-2*i*t,a[13]=-2*s*t,a[14]=-2*r*t,a[15]=1,this}invert(e=this){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[3],n=t[4],o=t[5],l=t[6],h=t[7],c=t[8],d=t[9],u=t[10],f=t[11],p=t[12],m=t[13],_=t[14],g=t[15],v=i*o-s*n,S=i*l-r*n,y=i*h-a*n,x=s*l-r*o,T=s*h-a*o,E=r*h-a*l,b=c*m-d*p,w=c*_-u*p,A=c*g-f*p,C=d*_-u*m,P=d*g-f*m,L=u*g-f*_,D=v*L-S*P+y*C+x*A-T*w+E*b;if(0===D)this.setIdentity();else {let e=1/D,t=this.data;t[0]=(o*L-l*P+h*C)*e,t[1]=(-s*L+r*P-a*C)*e,t[2]=(m*E-_*T+g*x)*e,t[3]=(-d*E+u*T-f*x)*e,t[4]=(-n*L+l*A-h*w)*e,t[5]=(i*L-r*A+a*w)*e,t[6]=(-p*E+_*y-g*S)*e,t[7]=(c*E-u*y+f*S)*e,t[8]=(n*P-o*A+h*b)*e,t[9]=(-i*P+s*A-a*b)*e,t[10]=(p*T-m*y+g*v)*e,t[11]=(-c*T+d*y-f*v)*e,t[12]=(-n*C+o*w-l*b)*e,t[13]=(i*C-s*w+r*b)*e,t[14]=(-p*x+m*S-_*v)*e,t[15]=(c*x-d*S+u*v)*e;}return this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}setIdentity(){let e=this.data;return 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,this}setTRS(e,t,i){let s=t.x,r=t.y,a=t.z,n=t.w,o=i.x,l=i.y,h=i.z,c=s+s,d=r+r,u=a+a,f=s*c,p=s*d,m=s*u,_=r*d,g=r*u,v=a*u,S=n*c,y=n*d,x=n*u,T=this.data;return T[0]=(1-(_+v))*o,T[1]=(p+x)*o,T[2]=(m-y)*o,T[3]=0,T[4]=(p-x)*l,T[5]=(1-(f+v))*l,T[6]=(g+S)*l,T[7]=0,T[8]=(m+y)*h,T[9]=(g-S)*h,T[10]=(1-(f+_))*h,T[11]=0,T[12]=e.x,T[13]=e.y,T[14]=e.z,T[15]=1,this}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[4],i[4]=e,e=t[2],i[2]=t[8],i[8]=e,e=t[3],i[3]=t[12],i[12]=e,e=t[6],i[6]=t[9],i[9]=e,e=t[7],i[7]=t[13],i[13]=e,e=t[11],i[11]=t[14],i[14]=e;}else i[0]=t[0],i[1]=t[4],i[2]=t[8],i[3]=t[12],i[4]=t[1],i[5]=t[5],i[6]=t[9],i[7]=t[13],i[8]=t[2],i[9]=t[6],i[10]=t[10],i[11]=t[14],i[12]=t[3],i[13]=t[7],i[14]=t[11],i[15]=t[15];return this}getTranslation(e=new eM){return e.set(this.data[12],this.data[13],this.data[14])}getX(e=new eM){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eM){return e.set(this.data[4],this.data[5],this.data[6])}getZ(e=new eM){return e.set(this.data[8],this.data[9],this.data[10])}getScale(e=new eM){return this.getX(eU),this.getY(ek),this.getZ(ez),e.set(eU.length(),ek.length(),ez.length()),e}get scaleSign(){return this.getX(eU),this.getY(ek),this.getZ(ez),eU.cross(eU,ek),0>eU.dot(ez)?-1:1}setFromEulerAngles(e,t,i){e*=eb.DEG_TO_RAD,t*=eb.DEG_TO_RAD,i*=eb.DEG_TO_RAD;let s=Math.sin(-e),r=Math.cos(-e),a=Math.sin(-t),n=Math.cos(-t),o=Math.sin(-i),l=Math.cos(-i),h=this.data;return h[0]=n*l,h[1]=-n*o,h[2]=a,h[3]=0,h[4]=r*o+l*s*a,h[5]=r*l-s*a*o,h[6]=-n*s,h[7]=0,h[8]=s*o-r*l*a,h[9]=l*s+r*a*o,h[10]=r*n,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,this}getEulerAngles(e=new eM){let t,i;this.getScale(eV);let s=eV.x,r=eV.y,a=eV.z;if(0===s||0===r||0===a)return e.set(0,0,0);let n=this.data,o=Math.asin(-n[2]/s),l=.5*Math.PI;return o<l?o>-l?(t=Math.atan2(n[6]/r,n[10]/a),i=Math.atan2(n[1]/s,n[0]/s)):(i=0,t=-Math.atan2(n[4]/r,n[5]/r)):(i=0,t=Math.atan2(n[4]/r,n[5]/r)),e.set(t,o,i).mulScalar(eb.RAD_TO_DEG)}toString(){return `[${this.data.join(", ")}]`}static{this.IDENTITY=Object.freeze(new eG);}static{this.ZERO=Object.freeze(new eG().set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));}}class eH{constructor(e=0,t=0,i=0,s=1){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}conjugate(e=this){return this.x=-1*e.x,this.y=-1*e.y,this.z=-1*e.z,this.w=e.w,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}getAxisAngle(e){let t=2*Math.acos(this.w),i=Math.sin(t/2);return 0!==i?(e.x=this.x/i,e.y=this.y/i,e.z=this.z/i,(e.x<0||e.y<0||e.z<0)&&(e.x*=-1,e.y*=-1,e.z*=-1,t*=-1)):(e.x=1,e.y=0,e.z=0),t*eb.RAD_TO_DEG}getEulerAngles(e=new eM){let t,i,s,r=this.x,a=this.y,n=this.z,o=this.w,l=2*(o*a-r*n);return l<=-0.99999?(t=2*Math.atan2(r,o),i=-Math.PI/2,s=0):l>=.99999?(t=2*Math.atan2(r,o),i=Math.PI/2,s=0):(t=Math.atan2(2*(o*r+a*n),1-2*(r*r+a*a)),i=Math.asin(l),s=Math.atan2(2*(o*n+r*a),1-2*(a*a+n*n))),e.set(t,i,s).mulScalar(eb.RAD_TO_DEG)}invert(e=this){return this.conjugate(e).normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){let s=(1-i)*(0>e.dot(t)?-1:1);return this.x=e.x*s+t.x*i,this.y=e.y*s+t.y*i,this.z=e.z*s+t.z*i,this.w=e.w*s+t.w*i,this.normalize()}mul(e){let t=this.x,i=this.y,s=this.z,r=this.w,a=e.x,n=e.y,o=e.z,l=e.w;return this.x=r*a+t*l+i*o-s*n,this.y=r*n+i*l+s*a-t*o,this.z=r*o+s*l+t*n-i*a,this.w=r*l-t*a-i*n-s*o,this}mulScalar(e,t=this){return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e,this}mul2(e,t){let i=e.x,s=e.y,r=e.z,a=e.w,n=t.x,o=t.y,l=t.z,h=t.w;return this.x=a*n+i*h+s*l-r*o,this.y=a*o+s*h+r*n-i*l,this.z=a*l+r*h+i*o-s*n,this.w=a*h-i*n-s*o-r*l,this}normalize(e=this){let t=e.length();return 0===t?(this.x=this.y=this.z=0,this.w=1):(t=1/t,this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this.w=e.w*t),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setFromAxisAngle(e,t){let i=Math.sin(t*=.5*eb.DEG_TO_RAD),s=Math.cos(t);return this.x=i*e.x,this.y=i*e.y,this.z=i*e.z,this.w=s,this}setFromEulerAngles(e,t,i){if(e instanceof eM){let s=e;e=s.x,t=s.y,i=s.z;}let s=.5*eb.DEG_TO_RAD;e*=s,t*=s,i*=s;let r=Math.sin(e),a=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(i),h=Math.cos(i);return this.x=r*o*h-a*n*l,this.y=a*n*h+r*o*l,this.z=a*o*l-r*n*h,this.w=a*o*h+r*n*l,this}setFromMat4(e){let t,i=e.data,s=i[0],r=i[1],a=i[2],n=i[4],o=i[5],l=i[6],h=i[8],c=i[9],d=i[10];return (s*(o*d-l*c)-r*(n*d-l*h)+a*(n*c-o*h)<0&&(s=-s,r=-r,a=-a),0==(t=s*s+r*r+a*a)||(s*=t=1/Math.sqrt(t),r*=t,a*=t,0==(t=n*n+o*o+l*l)||(n*=t=1/Math.sqrt(t),o*=t,l*=t,0==(t=h*h+c*c+d*d))))?this.set(0,0,0,1):(h*=t=1/Math.sqrt(t),c*=t,(d*=t)<0?s>o?this.set(1+s-o-d,r+n,h+a,l-c):this.set(r+n,1-s+o-d,l+c,h-a):s<-o?this.set(h+a,l+c,1-s-o+d,r-n):this.set(l-c,h-a,r-n,1+s+o+d),this.mulScalar(1/this.length()))}setFromDirections(e,t){let i=1+e.dot(t);return i<Number.EPSILON?(Math.abs(e.x)>Math.abs(e.y)?(this.x=-e.z,this.y=0,this.z=e.x):(this.x=0,this.y=-e.z,this.z=e.y),this.w=0):(this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this.w=i),this.normalize()}slerp(e,t,i){let s=e.x,r=e.y,a=e.z,n=e.w,o=t.x,l=t.y,h=t.z,c=t.w,d=n*c+s*o+r*l+a*h;if(d<0&&(c=-c,o=-o,l=-l,h=-h,d=-d),Math.abs(d)>=1)return this.w=n,this.x=s,this.y=r,this.z=a,this;let u=Math.acos(d),f=Math.sqrt(1-d*d);if(.001>Math.abs(f))return this.w=.5*n+.5*c,this.x=.5*s+.5*o,this.y=.5*r+.5*l,this.z=.5*a+.5*h,this;let p=Math.sin((1-i)*u)/f,m=Math.sin(i*u)/f;return this.w=n*p+c*m,this.x=s*p+o*m,this.y=r*p+l*m,this.z=a*p+h*m,this}transformVector(e,t=new eM){let i=e.x,s=e.y,r=e.z,a=this.x,n=this.y,o=this.z,l=this.w,h=l*i+n*r-o*s,c=l*s+o*i-a*r,d=l*r+a*s-n*i,u=-a*i-n*s-o*r;return t.x=h*l+-(u*a)+-(c*o)- -(d*n),t.y=c*l+-(u*n)+-(d*a)- -(h*o),t.z=d*l+-(u*o)+-(h*n)- -(c*a),t}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){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,e}static{this.IDENTITY=Object.freeze(new eH(0,0,0,1));}static{this.ZERO=Object.freeze(new eH(0,0,0,0));}}let eW=new eM,eX=new eM,eY=new eM,eq=new eM,e$=new eM;class ej{constructor(e,t){this.center=new eM,this.halfExtents=new eM(.5,.5,.5),this._min=new eM,this._max=new eM,e&&this.center.copy(e),t&&this.halfExtents.copy(t);}add(e){let t=this.center,i=t.x,s=t.y,r=t.z,a=this.halfExtents,n=a.x,o=a.y,l=a.z,h=i-n,c=i+n,d=s-o,u=s+o,f=r-l,p=r+l,m=e.center,_=m.x,g=m.y,v=m.z,S=e.halfExtents,y=S.x,x=S.y,T=S.z,E=_-y,b=_+y,w=g-x,A=g+x,C=v-T,P=v+T;E<h&&(h=E),b>c&&(c=b),w<d&&(d=w),A>u&&(u=A),C<f&&(f=C),P>p&&(p=P),t.x=(h+c)*.5,t.y=(d+u)*.5,t.z=(f+p)*.5,a.x=(c-h)*.5,a.y=(u-d)*.5,a.z=(p-f)*.5;}copy(e){this.center.copy(e.center),this.halfExtents.copy(e.halfExtents);}clone(){return new ej(this.center,this.halfExtents)}intersects(e){let t=this.getMax(),i=this.getMin(),s=e.getMax(),r=e.getMin();return i.x<=s.x&&t.x>=r.x&&i.y<=s.y&&t.y>=r.y&&i.z<=s.z&&t.z>=r.z}_intersectsRay(e,t){let i=eW.copy(this.getMin()).sub(e.origin),s=eX.copy(this.getMax()).sub(e.origin),r=e.direction;0===r.x?(i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.x=s.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.x/=r.x,s.x/=r.x),0===r.y?(i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.y=s.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.y/=r.y,s.y/=r.y),0===r.z?(i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.z=s.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.z/=r.z,s.z/=r.z);let a=eY.set(Math.min(i.x,s.x),Math.min(i.y,s.y),Math.min(i.z,s.z)),n=eq.set(Math.max(i.x,s.x),Math.max(i.y,s.y),Math.max(i.z,s.z)),o=Math.min(Math.min(n.x,n.y),n.z),l=Math.max(Math.max(a.x,a.y),a.z),h=o>=l&&l>=0;return h&&t.copy(e.direction).mulScalar(l).add(e.origin),h}_fastIntersectsRay(e){let t=e.direction;return eW.sub2(e.origin,this.center),eq.set(Math.abs(eW.x),Math.abs(eW.y),Math.abs(eW.z)),eY.mul2(eW,t),(!(eq.x>this.halfExtents.x)||!(eY.x>=0))&&(!(eq.y>this.halfExtents.y)||!(eY.y>=0))&&(!(eq.z>this.halfExtents.z)||!(eY.z>=0))&&(e$.set(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z)),eX.cross(t,eW),eX.set(Math.abs(eX.x),Math.abs(eX.y),Math.abs(eX.z)),!(eX.x>this.halfExtents.y*e$.z+this.halfExtents.z*e$.y)&&!(eX.y>this.halfExtents.x*e$.z+this.halfExtents.z*e$.x)&&!(eX.z>this.halfExtents.x*e$.y+this.halfExtents.y*e$.x))}intersectsRay(e,t){return t?this._intersectsRay(e,t):this._fastIntersectsRay(e)}setMinMax(e,t){this.center.add2(t,e).mulScalar(.5),this.halfExtents.sub2(t,e).mulScalar(.5);}getMin(){return this._min.copy(this.center).sub(this.halfExtents)}getMax(){return this._max.copy(this.center).add(this.halfExtents)}containsPoint(e){let t=this.getMin(),i=this.getMax();return !(e.x<t.x)&&!(e.x>i.x)&&!(e.y<t.y)&&!(e.y>i.y)&&!(e.z<t.z)&&!(e.z>i.z)}setFromTransformedAabb(e,t,i=false){let s=e.center,r=e.halfExtents,a=t.data,n=a[0],o=a[4],l=a[8],h=a[1],c=a[5],d=a[9],u=a[2],f=a[6],p=a[10];if(i){let e=n*n+o*o+l*l;if(e>0){let t=1/Math.sqrt(e);n*=t,o*=t,l*=t;}if((e=h*h+c*c+d*d)>0){let t=1/Math.sqrt(e);h*=t,c*=t,d*=t;}if((e=u*u+f*f+p*p)>0){let t=1/Math.sqrt(e);u*=t,f*=t,p*=t;}}this.center.set(a[12]+n*s.x+o*s.y+l*s.z,a[13]+h*s.x+c*s.y+d*s.z,a[14]+u*s.x+f*s.y+p*s.z),this.halfExtents.set(Math.abs(n)*r.x+Math.abs(o)*r.y+Math.abs(l)*r.z,Math.abs(h)*r.x+Math.abs(c)*r.y+Math.abs(d)*r.z,Math.abs(u)*r.x+Math.abs(f)*r.y+Math.abs(p)*r.z);}static computeMinMax(e,t,i,s=e.length/3){if(s>0){let r=e[0],a=e[1],n=e[2],o=r,l=a,h=n,c=3*s;for(let t=3;t<c;t+=3){let i=e[t],s=e[t+1],c=e[t+2];i<r&&(r=i),s<a&&(a=s),c<n&&(n=c),i>o&&(o=i),s>l&&(l=s),c>h&&(h=c);}t.set(r,a,n),i.set(o,l,h);}}compute(e,t){ej.computeMinMax(e,eW,eX,t),this.setMinMax(eW,eX);}intersectsBoundingSphere(e){return this._distanceToBoundingSphereSq(e)<=e.radius*e.radius}_distanceToBoundingSphereSq(e){let t=this.getMin(),i=this.getMax(),s=0,r=["x","y","z"];for(let a=0;a<3;++a){let n=0,o=e.center[r[a]],l=t[r[a]],h=i[r[a]],c=0;o<l&&(n+=(c=l-o)*c),o>h&&(n+=(c=o-h)*c),s+=n;}return s}_expand(e,t){eW.add2(this.getMin(),e),eX.add2(this.getMax(),t),this.setMinMax(eW,eX);}}let eK=new eM,eZ=new eM;class eQ{constructor(e=new eM,t=.5){this.center=e,this.radius=t;}containsPoint(e){let t=eK.sub2(e,this.center).lengthSq(),i=this.radius;return t<i*i}intersectsRay(e,t){let i=eK.copy(e.origin).sub(this.center),s=i.dot(eZ.copy(e.direction).normalize()),r=i.dot(i)-this.radius*this.radius;if(r>0&&s>0)return false;let a=s*s-r;if(a<0)return false;let n=Math.abs(-s-Math.sqrt(a));return t&&t.copy(e.direction).mulScalar(n).add(e.origin),true}intersectsBoundingSphere(e){eK.sub2(e.center,this.center);let t=e.radius+this.radius;return eK.lengthSq()<=t*t}}class eJ{constructor(e=eM.UP,t=0){this.normal=new eM,this.normal.copy(e),this.distance=t;}clone(){return new this.constructor().copy(this)}copy(e){return this.normal.copy(e.normal),this.distance=e.distance,this}intersectsLine(e,t,i){let s=this.distance,r=this.normal.dot(e)+s,a=r/(r-(this.normal.dot(t)+s)),n=a>=0&&a<=1;return n&&i&&i.lerp(e,t,a),n}intersectsRay(e,t){let i=this.normal.dot(e.direction);if(0===i)return false;let s=-(this.normal.dot(e.origin)+this.distance)/i;return s>=0&&t&&t.copy(e.direction).mulScalar(s).add(e.origin),s>=0}normalize(){let e=1/this.normal.length();return this.normal.mulScalar(e),this.distance*=e,this}set(e,t,i,s){return this.normal.set(e,t,i),this.distance=s,this}setFromPointNormal(e,t){return this.normal.copy(t),this.distance=-this.normal.dot(e),this}}class e0{constructor(){this.planes=[];for(let e=0;e<6;e++)this.planes[e]=new eJ;}clone(){return new this.constructor().copy(this)}copy(e){for(let t=0;t<6;t++)this.planes[t].copy(e.planes[t]);return this}setFromMat4(e){let[t,i,s,r,a,n,o,l,h,c,d,u,f,p,m,_]=e.data,g=this.planes;g[0].set(r-t,l-a,u-h,_-f).normalize(),g[1].set(r+t,l+a,u+h,_+f).normalize(),g[2].set(r+i,l+n,u+c,_+p).normalize(),g[3].set(r-i,l-n,u-c,_-p).normalize(),g[4].set(r-s,l-o,u-d,_-m).normalize(),g[5].set(r+s,l+o,u+d,_+m).normalize();}containsPoint(e){for(let t=0;t<6;t++){let{normal:i,distance:s}=this.planes[t];if(i.dot(e)+s<=0)return false}return true}containsSphere(e){let{center:t,radius:i}=e,s=0;for(let e=0;e<6;e++){let{normal:r,distance:a}=this.planes[e],n=r.dot(t)+a;if(n<=-i)return 0;n>i&&s++;}return 6===s?2:1}}class e1{constructor(e,t){this.origin=new eM,this.direction=eM.FORWARD.clone(),e&&this.origin.copy(e),t&&this.direction.copy(t);}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.set(e.origin,e.direction)}clone(){return new this.constructor(this.origin,this.direction)}}let e2=new e1,e3=new eM,e4=new eQ,e5=new eG;class e8{constructor(e=new eG,t){this.halfExtents=new eM(.5,.5,.5),t&&this.halfExtents.copy(t),this._modelTransform=e.clone().invert(),this._worldTransform=e.clone(),this._aabb=new ej(new eM,this.halfExtents);}set worldTransform(e){this._worldTransform.copy(e),this._modelTransform.copy(e).invert();}get worldTransform(){return this._worldTransform}intersectsRay(e,t){if(this._modelTransform.transformPoint(e.origin,e2.origin),this._modelTransform.transformVector(e.direction,e2.direction),t){let e=this._aabb._intersectsRay(e2,t);return e5.copy(this._modelTransform).invert().transformPoint(t,t),e}return this._aabb._fastIntersectsRay(e2)}containsPoint(e){return this._modelTransform.transformPoint(e,e3),this._aabb.containsPoint(e3)}intersectsBoundingSphere(e){return this._modelTransform.transformPoint(e.center,e4.center),e4.radius=e.radius,!!this._aabb.intersectsBoundingSphere(e4)}}let e6=new eM,e9=new eM,e7=new eM,te=new eM,tt=new eM;class ti{constructor(e=eM.ZERO,t=eM.ZERO,i=eM.ZERO){this.v0=new eM,this.v1=new eM,this.v2=new eM,this.set(e,t,i);}set(e,t,i){return this.v0.copy(e),this.v1.copy(t),this.v2.copy(i),this}intersectsRay(e,t){e6.sub2(this.v1,this.v0),e9.sub2(this.v2,this.v0),e7.cross(e.direction,e9);let i=e6.dot(e7);if(i>-1e-6&&i<1e-6)return false;let s=1/i;te.sub2(e.origin,this.v0);let r=s*te.dot(e7);if(r<0||r>1)return false;tt.cross(te,e6);let a=s*e.direction.dot(tt);if(a<0||r+a>1)return false;let n=s*e9.dot(tt);return n>1e-6&&(t instanceof eM&&t.copy(e.direction).mulScalar(n).add(e.origin),true)}toString(){return `[${this.v0.toString()}, ${this.v1.toString()}, ${this.v2.toString()}]`}}let ts=0,tr=1,ta=2,tn=0,to=1,tl=2,th=3,tc=4,td=5,tu=6,tf=7,tp=8,tm=9,t_=10,tg=11,tv=12,tS=0,ty=1,tx=2,tT=3,tE=4,tb=1,tw=2,tA=4,tC=8,tP=16,tL=32,tD=64,tI=128,tR=256,tM=0,tO=1,tF=2,tN=3,tB=1,tU=2,tk=4,tz=0,tV=1,tG=2,tH=3,tW=4,tX=5,tY=0,tq=1,t$=2,tj=3,tK=0,tZ=1,tQ=2,tJ=3,t0=4,t1=5,t2=0,t3=1,t4=2,t5=3,t8=4,t6=5,t9=6,t7=7,ie=0,it=1,ii=2,is=[1,2,4],ir=0,ia=1,io=2,il=3,ih=4,ic=5,id=6,iu=7,ip=8,im=9,i_=10,ig=11,iv=12,iS=13,iy=14,ix=15,iT=16,iE=17,ib=18,iw=19,iA=20,iC=21,iP=22,iL=23,iD=24,iI=25,iR=26,iM=27,iO=28,iF=29,iN=30,iB=31,iU=32,ik=33,iz=34,iV=35,iG=36,iH=37,iW=38,iX=39,iY=40,iq=41,i$=42,ij=43,iK=44,iZ=45,iQ=46,iJ=47,i0=48,i1=49,i2=50,i3=51,i4=52,i5=53,i8=54,i6=55,i9=56,i7=61,se=62,st=63,si=64,ss=65,sr=66,sa=67,sn=68,so=69,sl=new Map([[ir,{name:"A8",size:1,ldr:true}],[i4,{name:"R8",size:1,ldr:true}],[ia,{name:"L8",size:1,ldr:true}],[io,{name:"LA8",size:2,ldr:true}],[i5,{name:"RG8",size:2,ldr:true}],[il,{name:"RGB565",size:2,ldr:true}],[ih,{name:"RGBA5551",size:2,ldr:true}],[ic,{name:"RGBA4",size:2,ldr:true}],[id,{name:"RGB8",size:4,ldr:true}],[iu,{name:"RGBA8",size:4,ldr:true,srgbFormat:iA}],[i2,{name:"R16F",size:2}],[i3,{name:"RG16F",size:4}],[ig,{name:"RGB16F",size:8}],[iv,{name:"RGBA16F",size:8}],[iS,{name:"RGB32F",size:16}],[iy,{name:"RGBA32F",size:16}],[ix,{name:"R32F",size:4}],[iT,{name:"DEPTH",size:4}],[so,{name:"DEPTH16",size:2}],[iE,{name:"DEPTHSTENCIL",size:4}],[ib,{name:"111110F",size:4}],[iw,{name:"SRGB8",size:4,ldr:true,srgb:true}],[iA,{name:"SRGBA8",size:4,ldr:true,srgb:true}],[iB,{name:"BGRA8",size:4,ldr:true}],[si,{name:"SBGRA8",size:4,ldr:true,srgb:true}],[ip,{name:"DXT1",blockSize:8,ldr:true,srgbFormat:i8}],[im,{name:"DXT3",blockSize:16,ldr:true,srgbFormat:i6}],[i_,{name:"DXT5",blockSize:16,ldr:true,srgbFormat:i9}],[iC,{name:"ETC1",blockSize:8,ldr:true}],[iP,{name:"ETC2_RGB",blockSize:8,ldr:true,srgbFormat:i7}],[iL,{name:"ETC2_RGBA",blockSize:16,ldr:true,srgbFormat:se}],[iD,{name:"PVRTC_2BPP_RGB_1",ldr:true,blockSize:8}],[iI,{name:"PVRTC_2BPP_RGBA_1",ldr:true,blockSize:8}],[iR,{name:"PVRTC_4BPP_RGB_1",ldr:true,blockSize:8}],[iM,{name:"PVRTC_4BPP_RGBA_1",ldr:true,blockSize:8}],[iO,{name:"ASTC_4x4",blockSize:16,ldr:true,srgbFormat:st}],[iF,{name:"ATC_RGB",blockSize:8,ldr:true}],[iN,{name:"ATC_RGBA",blockSize:16,ldr:true}],[ss,{name:"BC6H_RGBF",blockSize:16}],[sr,{name:"BC6H_RGBUF",blockSize:16}],[sa,{name:"BC7_RGBA",blockSize:16,ldr:true,srgbFormat:sn}],[i8,{name:"DXT1_SRGB",blockSize:8,ldr:true,srgb:true}],[i6,{name:"DXT3_SRGBA",blockSize:16,ldr:true,srgb:true}],[i9,{name:"DXT5_SRGBA",blockSize:16,ldr:true,srgb:true}],[i7,{name:"ETC2_SRGB",blockSize:8,ldr:true,srgb:true}],[se,{name:"ETC2_SRGBA",blockSize:16,ldr:true,srgb:true}],[st,{name:"ASTC_4x4_SRGB",blockSize:16,ldr:true,srgb:true}],[sn,{name:"BC7_SRGBA",blockSize:16,ldr:true,srgb:true}],[iU,{name:"R8I",size:1,isInt:true}],[ik,{name:"R8U",size:1,isInt:true}],[iz,{name:"R16I",size:2,isInt:true}],[iV,{name:"R16U",size:2,isInt:true}],[iG,{name:"R32I",size:4,isInt:true}],[iH,{name:"R32U",size:4,isInt:true}],[iW,{name:"RG8I",size:2,isInt:true}],[iX,{name:"RG8U",size:2,isInt:true}],[iY,{name:"RG16I",size:4,isInt:true}],[iq,{name:"RG16U",size:4,isInt:true}],[i$,{name:"RG32I",size:8,isInt:true}],[ij,{name:"RG32U",size:8,isInt:true}],[iK,{name:"RGBA8I",size:4,isInt:true}],[iZ,{name:"RGBA8U",size:4,isInt:true}],[iQ,{name:"RGBA16I",size:8,isInt:true}],[iJ,{name:"RGBA16U",size:8,isInt:true}],[i0,{name:"RGBA32I",size:16,isInt:true}],[i1,{name:"RGBA32U",size:16,isInt:true}]]),sh=e=>sl.get(e)?.blockSize!==void 0,sc=e=>sl.get(e)?.srgb===true,sd=e=>sl.get(e)?.isInt===true,su=e=>sl.get(e)?.srgbFormat||e,sf=e=>{for(let[t,i]of sl)if(i.srgbFormat===e)return t;return e},sp=e=>{let t=sl.get(e);return !!(t?.ldr&&!t?.srgb)},sm=e=>{switch(e){case ix:case iS:case iy:return Float32Array;case iG:case i$:case i0:return Int32Array;case iH:case ij:case i1:return Uint32Array;case iz:case iY:case iQ:return Int16Array;case i5:case iV:case iq:case iJ:case il:case ih:case ic:case i2:case i3:case ig:case iv:return Uint16Array;case iU:case iW:case iK:return Int8Array;default:return Uint8Array}},s_=0,sg=1,sv=2,sS=3,sy=4,sx=5,sT=6,sE="POSITION",sb="NORMAL",sw="TANGENT",sA="BLENDWEIGHT",sC="BLENDINDICES",sP="COLOR",sL="TEXCOORD",sD="TEXCOORD0",sI="TEXCOORD1",sR="TEXCOORD2",sM="TEXCOORD3",sO="TEXCOORD4",sF="TEXCOORD5",sN="TEXCOORD6",sB="TEXCOORD7",sU="ATTR0",sk="ATTR1",sz="ATTR2",sV="ATTR3",sG="ATTR4",sH="ATTR5",sW="ATTR6",sX="ATTR7",sY="ATTR8",sq="ATTR9",s$="ATTR10",sj="ATTR11",sK="ATTR12",sZ="ATTR13",sQ="ATTR14",sJ="ATTR15",s0=1,s1=0,s2=1,s3=2,s4=3,s5=4,s8=5,s6=6,s9=7,s7=0,re=1,rt=2,ri="default",rs="rgbm",rr="rgbe",ra="rgbp",rn="swizzleGGGR",ro=0,rl=1,rh=2,rc=3,rd="1d",ru="2d",rf="2d-array",rp="cube",rm="cube-array",r_="3d",rg=0,rv=1,rS=2,ry=3,rx=4,rT="none",rE="cube",rb="equirect",rw="octahedral",rA="glsl",rC="wgsl",rP=0,rL=1,rD=2,rI=3,rR=4,rM=5,rO=6,rF=7,rN=0,rB=1,rU=2,rk=3,rz=4,rV=5,rG=6,rH=7,rW=8,rX=9,rY=10,rq=11,r$=12,rj=13,rK=14,rZ=15,rQ=16,rJ=17,r0=18,r1=19,r2=20,r3=21,r4=22,r5=23,r8=24,r6=25,r9=26,r7=27,ae=28,at=29,ai=30,as=31,ar=32,aa=33,an=34,ao=35,al=36,ah=37,ac=38,ad=39,au=40,af=41,ap=42,am=43,a_=44,ag=45,av=46,aS=47,ay=48,ax=49,aT=["bool","int","float","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","mat2","mat3","mat4","sampler2D","samplerCube","","sampler2DShadow","samplerCubeShadow","sampler3D","","","","","sampler2DArray","uint","uvec2","uvec3","uvec4","","","","","","","","","","","","","isampler2D","usampler2D","isamplerCube","usamplerCube","isampler3D","usampler3D","isampler2DArray","usampler2DArray"],aE=[["bool"],["i32"],["f32"],["vec2f","vec2<f32>"],["vec3f","vec3<f32>"],["vec4f","vec4<f32>"],["vec2i","vec2<i32>"],["vec3i","vec3<i32>"],["vec4i","vec4<i32>"],["vec2<bool>"],["vec3<bool>"],["vec4<bool>"],["mat2x2f","mat2x2<f32>"],["mat3x3f","mat3x3<f32>"],["mat4x4f","mat4x4<f32>"],["texture_2d<f32>"],["texture_cube<f32>"],["array<f32>"],["texture_depth_2d"],["texture_depth_cube"],["texture_3d<f32>"],["array<vec2<f32>>"],["array<vec3<f32>>"],["array<vec4<f32>>"],["array<mat4x4<f32>>"],["texture_2d_array<f32>"],["u32"],["vec2u","vec2<u32>"],["vec3u","vec3<u32>"],["vec4u","vec4<u32>"],["array<i32>"],["array<u32>"],["array<bool>"],["array<vec2i>","array<vec2<i32>>"],["array<vec2u>","array<vec2<u32>>"],["array<vec2b>","array<vec2<bool>>"],["array<vec3i>","array<vec3<i32>>"],["array<vec3u>","array<vec3<u32>>"],["array<vec3b>","array<vec3<bool>>"],["array<vec4i>","array<vec4<i32>>"],["array<vec4u>","array<vec4<u32>>"],["array<vec4b>","array<vec4<bool>>"],["texture_2d<i32>"],["texture_2d<u32>"],["texture_cube<i32>"],["texture_cube<u32>"],["texture_3d<i32>"],["texture_3d<u32>"],["texture_2d_array<i32>"],["texture_2d_array<u32>"]],ab=new Map;aE.forEach((e,t)=>{e.forEach(e=>ab.set(e,t));});let aw=new Uint8Array([rR,rR,rO,rO,rO,rO,rR,rR,rR,rR,rR,rR,rO,rO,rO,rR,rR,rO,rR,rR,rR,rO,rO,rO,rO,rR,rM,rM,rM,rM,rR,rM,rR,rR,rM,rR,rR,rM,rR,rR,rM,rR,rR,rM,rR,rM,rR,rM,rR,rM]),aA="webgl2",aC="webgpu",aP="null",aL=1,aD=2,aI=4,aR="ldr",aM="ldr_srgb",aO="hdr",aF=1,aN=2,aB=4,aU=8,ak=16,az=32,aV=64,aG=128,aH=255,aW=0,aX=1,aY=2,aq=["view","mesh","mesh_ub"],a$="default",aj="_unused_float_uniform",aK=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],aZ=[1,1,2,2,4,4,4,2],aQ=["INT8","UINT8","INT16","UINT16","INT32","UINT32","FLOAT32","FLOAT16"],aJ={Int8Array:rP,Uint8Array:rL,Int16Array:rD,Uint16Array:rI,Int32Array:rR,Uint32Array:rM,Float32Array:rO},a0=[Uint8Array,Uint16Array,Uint32Array],a1=[1,2,4],a2=new Map([["float","f32"],["vec2","vec2f"],["vec3","vec3f"],["vec4","vec4f"],["int","i32"],["ivec2","vec2i"],["ivec3","vec3i"],["ivec4","vec4i"],["uint","u32"],["uvec2","vec2u"],["uvec3","vec3u"],["uvec4","vec4u"]]),a3={};a3[sE]=0,a3[sb]=1,a3[sA]=2,a3[sC]=3,a3[sP]=4,a3[sD]=5,a3[sI]=6,a3[sR]=7,a3[sM]=8,a3[sO]=9,a3[sF]=10,a3[sN]=11,a3[sB]=12,a3[sw]=13,a3[sU]=0,a3[sk]=1,a3[sz]=2,a3[sV]=3,a3[sG]=4,a3[sH]=5,a3[sW]=6,a3[sX]=7,a3[sY]=8,a3[sq]=9,a3[s$]=10,a3[sj]=11,a3[sK]=12,a3[sZ]=13,a3[sQ]=14,a3[sJ]=15;let a4=0;class a5{constructor(e,t){this.slot=-1,this.scopeId=null,this.name=e,this.visibility=t;}}class a8 extends a5{}class a6 extends a5{constructor(e,t,i=false){super(e,t),this.format="",this.readOnly=i;}}class a9 extends a5{constructor(e,t,i=ru,s=rg,r=true,a=null){super(e,t),this.textureDimension=i,this.sampleType=s,this.hasSampler=r,this.samplerName=a??`${e}_sampler`;}}class a7 extends a5{constructor(e,t=iu,i=ru,s=true,r=false){super(e,aI),this.format=t,this.textureDimension=i,this.write=s,this.read=r;}}class ne{constructor(e,t){this.uniformBufferFormats=[],this.textureFormats=[],this.storageTextureFormats=[],this.storageBufferFormats=[],this.id=a4++;let i=0;t.forEach(e=>{e.slot=i++,e instanceof a9&&e.hasSampler&&i++,e instanceof a8?this.uniformBufferFormats.push(e):e instanceof a9?this.textureFormats.push(e):e instanceof a7?this.storageTextureFormats.push(e):e instanceof a6&&this.storageBufferFormats.push(e);}),this.device=e;let s=e.scope;this.bufferFormatsMap=new Map,this.uniformBufferFormats.forEach((e,t)=>this.bufferFormatsMap.set(e.name,t)),this.textureFormatsMap=new Map,this.textureFormats.forEach((e,t)=>{this.textureFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.storageTextureFormatsMap=new Map,this.storageTextureFormats.forEach((e,t)=>{this.storageTextureFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.storageBufferFormatsMap=new Map,this.storageBufferFormats.forEach((e,t)=>{this.storageBufferFormatsMap.set(e.name,t),e.scopeId=s.resolve(e.name);}),this.impl=e.createBindGroupFormatImpl(this);}destroy(){this.impl.destroy();}getTexture(e){let t=this.textureFormatsMap.get(e);return void 0!==t?this.textureFormats[t]:null}getStorageTexture(e){let t=this.storageTextureFormatsMap.get(e);return void 0!==t?this.storageTextureFormats[t]:null}loseContext(){}}class nt{get(e,t){return this._cache.has(e)||(this._cache.set(e,t()),e.on("destroy",()=>{this.remove(e);}),e.on("devicelost",()=>{this._cache.get(e)?.loseContext?.(e);})),this._cache.get(e)}remove(e){this._cache.get(e)?.destroy?.(e),this._cache.delete(e);}constructor(){this._cache=new Map;}}class ni{static calcLevelDimension(e,t){return Math.max(e>>t,1)}static calcMipLevelsCount(e,t,i=1){return 1+Math.floor(Math.log2(Math.max(e,t,i)))}static calcLevelGpuSize(e,t,i,s){let r=sl.get(s),a=sl.get(s)?.size??0;if(a>0)return e*t*i*a;let n=r.blockSize??0,o=Math.floor((e+3)/4),l=Math.floor((t+3)/4),h=Math.floor((i+3)/4);return (s===iD||s===iI)&&(o=Math.max(Math.floor(o/2),1)),o*l*h*n}static calcGpuSize(e,t,i,s,r,a){let n=0;for(;n+=ni.calcLevelGpuSize(e,t,i,s),r&&(1!==e||1!==t||1!==i);)e=Math.max(e>>1,1),t=Math.max(t>>1,1),i=Math.max(i>>1,1);return n*(a?6:1)}}let ns=0;class nr{constructor(e,t={}){this._gpuSize=0,this.id=ns++,this._invalid=false,this._lockedLevel=-1,this._lockedMode=s7,this.renderVersionDirty=0,this._storage=false,this._numLevels=0,this.device=e,this.name=t.name??"",this._width=Math.floor(t.width??4),this._height=Math.floor(t.height??4),this._format=t.format??iu,this._compressed=sh(this._format),this._integerFormat=sd(this._format),this._integerFormat&&(t.minFilter=tK,t.magFilter=tK),this._volume=t.volume??false,this._depth=Math.floor(t.depth??1),this._arrayLength=Math.floor(t.arrayLength??0),this._storage=t.storage??false,this._cubemap=t.cubemap??false,this._flipY=t.flipY??false,this._premultiplyAlpha=t.premultiplyAlpha??false,this._mipmaps=t.mipmaps??true,this._numLevelsRequested=t.numLevels,void 0!==t.numLevels&&(this._numLevels=t.numLevels),this._updateNumLevel(),this._minFilter=t.minFilter??t1,this._magFilter=t.magFilter??tZ,this._anisotropy=t.anisotropy??1,this._addressU=t.addressU??ts,this._addressV=t.addressV??ts,this._addressW=t.addressW??ts,this._compareOnRead=t.compareOnRead??false,this._compareFunc=t.compareFunc??t3,this._type=t.type??ri,this.projection=rT,this._cubemap?this.projection=rE:t.projection&&t.projection!==rE&&(this.projection=t.projection),this._levels=t.levels;let i=!!t.levels;this._levels||this._clearLevels(),this.recreateImpl(i),e.textures.push(this);}destroy(){let e=this.device;if(e){let t=e.textures.indexOf(this);-1!==t&&e.textures.splice(t,1),e.scope.removeValue(this),this.impl.destroy(e),this.adjustVramSizeTracking(e._vram,-this._gpuSize),this._levels=null,this.device=null;}}recreateImpl(e=true){let{device:t}=this;this.impl?.destroy(t),this.impl=null,this.impl=t.createTextureImpl(this),this.dirtyAll(),e&&this.upload();}_clearLevels(){this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null];}resize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){let s=this.device;this.adjustVramSizeTracking(s._vram,-this._gpuSize),this._gpuSize=0,this.impl.destroy(s),this._clearLevels(),this._width=Math.floor(e),this._height=Math.floor(t),this._depth=Math.floor(i),this._updateNumLevel(),this.impl=s.createTextureImpl(this),this.dirtyAll();}}loseContext(){this.impl.loseContext(),this.dirtyAll();}adjustVramSizeTracking(e,t){e.tex+=t;}propertyChanged(e){this.impl.propertyChanged(e),this.renderVersionDirty=this.device.renderVersion;}_updateNumLevel(){let e=this.mipmaps?ni.calcMipLevelsCount(this.width,this.height):1,t=this._numLevelsRequested;this._numLevels=Math.min(t??e,e),this._mipmaps=this._numLevels>1;}get lockedMode(){return this._lockedMode}set minFilter(e){this._minFilter!==e&&(sd(this._format)||(this._minFilter=e,this.propertyChanged(aF)));}get minFilter(){return this._minFilter}set magFilter(e){this._magFilter!==e&&(sd(this._format)||(this._magFilter=e,this.propertyChanged(aN)));}get magFilter(){return this._magFilter}set addressU(e){this._addressU!==e&&(this._addressU=e,this.propertyChanged(aB));}get addressU(){return this._addressU}set addressV(e){this._addressV!==e&&(this._addressV=e,this.propertyChanged(aU));}get addressV(){return this._addressV}set addressW(e){this._volume&&e!==this._addressW&&(this._addressW=e,this.propertyChanged(ak));}get addressW(){return this._addressW}set compareOnRead(e){this._compareOnRead!==e&&(this._compareOnRead=e,this.propertyChanged(az));}get compareOnRead(){return this._compareOnRead}set compareFunc(e){this._compareFunc!==e&&(this._compareFunc=e,this.propertyChanged(aV));}get compareFunc(){return this._compareFunc}set anisotropy(e){this._anisotropy!==e&&(this._anisotropy=e,this.propertyChanged(aG));}get anisotropy(){return this._anisotropy}set mipmaps(e){this._mipmaps!==e&&(this.device.isWebGPU||sd(this._format)||(this._mipmaps=e),e&&(this._needsMipmapsUpload=true));}get mipmaps(){return this._mipmaps}get numLevels(){return this._numLevels}get storage(){return this._storage}get width(){return this._width}get height(){return this._height}get depth(){return this._depth}get format(){return this._format}get cubemap(){return this._cubemap}get gpuSize(){let e=this.pot&&this._mipmaps&&!(this._compressed&&1===this._levels.length);return ni.calcGpuSize(this._width,this._height,this._depth,this._format,e,this._cubemap)}get array(){return this._arrayLength>0}get arrayLength(){return this._arrayLength}get volume(){return this._volume}set type(e){this._type!==e&&(this._type=e,this.device._shadersDirty=true);}get type(){return this._type}set srgb(e){if(e!==sc(this.format))if(e){let e=su(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}else {let e=sf(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}}get srgb(){return sc(this.format)}set flipY(e){this._flipY!==e&&(this._flipY=e,this._needsUpload=true);}get flipY(){return this._flipY}set premultiplyAlpha(e){this._premultiplyAlpha!==e&&(this._premultiplyAlpha=e,this._needsUpload=true);}get premultiplyAlpha(){return this._premultiplyAlpha}get pot(){return eb.powerOfTwo(this._width)&&eb.powerOfTwo(this._height)}get encoding(){switch(this.type){case rs:return "rgbm";case rr:return "rgbe";case ra:return "rgbp"}return sp(this.format)?"srgb":"linear"}dirtyAll(){this._levelsUpdated=this._cubemap?[[true,true,true,true,true,true]]:[true],this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this._mipmapsUploaded=false,this.propertyChanged(aH);}lock(e={}){e.level??=0,e.face??=0,e.mode??=rt,this._lockedMode=e.mode,this._lockedLevel=e.level;let t=this.cubemap?this._levels[e.face]:this._levels;if(null===t[e.level]){let i=Math.max(1,this._width>>e.level),s=Math.max(1,this._height>>e.level),r=Math.max(1,this._depth>>e.level),a=new ArrayBuffer(ni.calcLevelGpuSize(i,s,r,this._format));t[e.level]=new(sm(this._format))(a);}return t[e.level]}setSource(e,t=0){let i,s,r=false;if(this._cubemap){if(e[0]){i=e[0].width||0,s=e[0].height||0;for(let t=0;t<6;t++){let a=e[t];if(!a||a.width!==i||a.height!==s||!this.device._isBrowserInterface(a)){r=true;break}}}else r=true;if(!r)for(let i=0;i<6;i++)this._levels[t][i]!==e[i]&&(this._levelsUpdated[t][i]=true);}else this.device._isBrowserInterface(e)||(r=true),r||(e!==this._levels[t]&&(this._levelsUpdated[t]=true),e instanceof HTMLVideoElement?(i=e.videoWidth,s=e.videoHeight):(i=e.width,s=e.height));if(r)if(this._width=4,this._height=4,this._cubemap)for(let e=0;e<6;e++)this._levels[t][e]=null,this._levelsUpdated[t][e]=true;else this._levels[t]=null,this._levelsUpdated[t]=true;else 0===t&&(this._width=i,this._height=s),this._levels[t]=e;this._invalid===r&&r||(this._invalid=r,this.upload());}getSource(e=0){return this._levels[e]}unlock(){this._lockedMode,this._lockedMode===rt&&this.upload(),this._lockedLevel=-1,this._lockedMode=s7;}upload(){this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this.impl.uploadImmediate?.(this.device,this);}read(e,t,i,s,r={}){return this.impl.read?.(e,t,i,s,r)}write(e,t,i,s,r){return this.impl.write?.(e,t,i,s,r)}}let na={white:[255,255,255,255],gray:[128,128,128,255],black:[0,0,0,255],normal:[128,128,255,255],pink:[255,128,255,255]};class nn{destroy(){this.map.forEach(e=>{e.destroy();});}constructor(){this.map=new Map;}}let no=new nt,nl=(e,t)=>{let i=no.get(e,()=>new nn);if(!i.map.has(t)){let s=new nr(e,{name:`built-in-texture-${t}`,width:1,height:1,format:iu}),r=s.lock(),a=na[t];r.set(a),s.unlock(),i.map.set(t,s);}return i.map.get(t)},nh=0;class nc{constructor(){this.offsets=[];}}class nd{constructor(e,t,i){this.renderVersionUpdated=-1,this.uniformBufferOffsets=[],this.id=nh++,this.device=e,this.format=t,this.dirty=true,this.impl=e.createBindGroupImpl(this),this.textures=[],this.storageTextures=[],this.storageBuffers=[],this.uniformBuffers=[],this.defaultUniformBuffer=i,i&&this.setUniformBuffer(a$,i);}destroy(){this.impl.destroy(),this.impl=null,this.format=null,this.defaultUniformBuffer=null;}setUniformBuffer(e,t){let i=this.format.bufferFormatsMap.get(e);this.uniformBuffers[i]!==t&&(this.uniformBuffers[i]=t,this.dirty=true);}setStorageBuffer(e,t){let i=this.format.storageBufferFormatsMap.get(e);this.storageBuffers[i]!==t&&(this.storageBuffers[i]=t,this.dirty=true);}setTexture(e,t){let i=this.format.textureFormatsMap.get(e);this.textures[i]!==t?(this.textures[i]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}setStorageTexture(e,t){let i=this.format.storageTextureFormatsMap.get(e);this.storageTextures[i]!==t?(this.storageTextures[i]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}updateUniformBuffers(){for(let e=0;e<this.uniformBuffers.length;e++)this.uniformBuffers[e].update();}update(){let{textureFormats:e,storageTextureFormats:t,storageBufferFormats:i}=this.format;for(let t=0;t<e.length;t++){let i=e[t],s=i.scopeId.value;!s&&("uSceneDepthMap"===i.name&&(s=nl(this.device,"white")),"uSceneColorMap"===i.name&&(s=nl(this.device,"pink")),s||(s=nl(this.device,"pink"))),this.setTexture(i.name,s);}for(let e=0;e<t.length;e++){let i=t[e],s=i.scopeId.value;this.setStorageTexture(i.name,s);}for(let e=0;e<i.length;e++){let t=i[e],s=t.scopeId.value;this.setStorageBuffer(t.name,s);}this.uniformBufferOffsets.length=this.uniformBuffers.length;for(let e=0;e<this.uniformBuffers.length;e++){let t=this.uniformBuffers[e];this.uniformBufferOffsets[e]=t.offset,this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}this.dirty&&(this.dirty=false,this.renderVersionUpdated=this.device.renderVersion,this.impl.update(this));}}let nu={set:(e,t,i,s=1)=>e&~(s<<i)|t<<i,get:(e,t,i=1)=>e>>t&i,all(e,t,i=1){let s=i<<t;return (e&s)===s},any:(e,t,i=1)=>(e&i<<t)!=0};class nf{constructor(e=false,t=tS,i=to,s=tn,r,a,n,o=true,l=true,h=true,c=true){this.target0=0,this.setColorBlend(t,i,s),this.setAlphaBlend(r??t,a??i,n??s),this.setColorWrite(o,l,h,c),this.blend=e;}set blend(e){this.target0=nu.set(this.target0,+!!e,26);}get blend(){return nu.all(this.target0,26)}setColorBlend(e,t,i){this.target0=nu.set(this.target0,e,0,7),this.target0=nu.set(this.target0,t,3,15),this.target0=nu.set(this.target0,i,7,15);}setAlphaBlend(e,t,i){this.target0=nu.set(this.target0,e,11,7),this.target0=nu.set(this.target0,t,14,15),this.target0=nu.set(this.target0,i,18,15);}setColorWrite(e,t,i,s){this.redWrite=e,this.greenWrite=t,this.blueWrite=i,this.alphaWrite=s;}get colorOp(){return nu.get(this.target0,0,7)}get colorSrcFactor(){return nu.get(this.target0,3,15)}get colorDstFactor(){return nu.get(this.target0,7,15)}get alphaOp(){return nu.get(this.target0,11,7)}get alphaSrcFactor(){return nu.get(this.target0,14,15)}get alphaDstFactor(){return nu.get(this.target0,18,15)}set redWrite(e){this.target0=nu.set(this.target0,+!!e,22);}get redWrite(){return nu.all(this.target0,22)}set greenWrite(e){this.target0=nu.set(this.target0,+!!e,23);}get greenWrite(){return nu.all(this.target0,23)}set blueWrite(e){this.target0=nu.set(this.target0,+!!e,24);}get blueWrite(){return nu.all(this.target0,24)}set alphaWrite(e){this.target0=nu.set(this.target0,+!!e,25);}get alphaWrite(){return nu.all(this.target0,25)}get allWrite(){return nu.get(this.target0,22,15)}copy(e){return this.target0=e.target0,this}clone(){return new this.constructor().copy(this)}get key(){return this.target0}equals(e){return this.target0===e.target0}static{this.NOBLEND=Object.freeze(new nf);}static{this.NOWRITE=Object.freeze(new nf(void 0,void 0,void 0,void 0,void 0,void 0,void 0,false,false,false,false));}static{this.ALPHABLEND=Object.freeze(new nf(true,tS,tu,tp));}static{this.ADDBLEND=Object.freeze(new nf(true,tS,to,to));}}class np{get(e){let t=this.map.get(e);return void 0===t&&(t=this.id++,this.map.set(e,t)),t}constructor(){this.map=new Map,this.id=0;}}let nm=new np;class n_{constructor(e=t5,t=true){this.data=0,this._depthBias=0,this._depthBiasSlope=0,this.key=0,this.func=e,this.write=t;}set test(e){this.func=e?t5:t7,this.updateKey();}get test(){return this.func!==t7}set write(e){this.data=nu.set(this.data,+!!e,3),this.updateKey();}get write(){return nu.all(this.data,3)}set func(e){this.data=nu.set(this.data,e,0,7),this.updateKey();}get func(){return nu.get(this.data,0,7)}set depthBias(e){this._depthBias=e,this.updateKey();}get depthBias(){return this._depthBias}set depthBiasSlope(e){this._depthBiasSlope=e,this.updateKey();}get depthBiasSlope(){return this._depthBiasSlope}copy(e){return this.data=e.data,this._depthBias=e._depthBias,this._depthBiasSlope=e._depthBiasSlope,this.key=e.key,this}clone(){return new this.constructor().copy(this)}updateKey(){let{data:e,_depthBias:t,_depthBiasSlope:i}=this,s=`${e}-${t}-${i}`;this.key=nm.get(s);}equals(e){return this.key===e.key}static{this.DEFAULT=Object.freeze(new n_);}static{this.NODEPTH=Object.freeze(new n_(t7,false));}static{this.WRITEDEPTH=Object.freeze(new n_(t7,true));}}class ng{equals(e){return this.globalId===e.globalId&&this.revision===e.revision}copy(e){this.globalId=e.globalId,this.revision=e.revision;}reset(){this.globalId=0,this.revision=0;}constructor(){this.globalId=0,this.revision=0;}}let nv=0;class nS{constructor(){nv++,this.version=new ng,this.version.globalId=nv;}increment(){this.version.revision++;}}class ny{constructor(e){this.name=e,this.value=null,this.versionObject=new nS;}toJSON(e){}setValue(e){this.value=e,this.versionObject.increment();}getValue(){return this.value}}class nx{constructor(e){this.name=e,this.variables=new Map;}resolve(e){return this.variables.has(e)||this.variables.set(e,new ny(e)),this.variables.get(e)}removeValue(e){for(let t in this.variables){let i=this.variables[t];i.value===e&&(i.value=null);}}}let nT=0;class nE{constructor(e,t,i,s){this.usage=tM,this.usage=s?.usage??tM,this.device=e,this.format=t,this.numVertices=i,this.id=nT++,this.impl=e.createVertexBufferImpl(this,t,s),this.numBytes=t.verticesByteSize?t.verticesByteSize:t.size*i,this.adjustVramSizeTracking(e._vram,this.numBytes);let r=s?.data;r?this.setData(r):this.storage=new ArrayBuffer(this.numBytes),this.device.buffers.push(this);}destroy(){let e=this.device,t=e.buffers.indexOf(this);-1!==t&&e.buffers.splice(t,1),this.impl.initialized&&(this.impl.destroy(e),this.adjustVramSizeTracking(e._vram,-this.storage.byteLength));}adjustVramSizeTracking(e,t){e.vb+=t;}loseContext(){this.impl.loseContext();}getFormat(){return this.format}getUsage(){return this.usage}getNumVertices(){return this.numVertices}lock(){return this.storage}unlock(){this.impl.unlock(this);}setData(e){return e.byteLength===this.numBytes&&(this.storage=e,this.unlock(),true)}}function nb(e){if(null==e)return 0;let t=0;for(let i=0,s=e.length;i<s;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return t}function nw(e){let t=0x811c9dc5;for(let i=0;i<e.length;i++)t^=e[i],t*=0x1000193;return t>>>0}let nA=new np,nC=[2,4,8,12,16],nP=new nt;class nL{constructor(e,t,i){this.device=e,this._elements=[],this.hasUv0=false,this.hasUv1=false,this.hasColor=false,this.hasTangents=false,this.verticesByteSize=0,this.vertexCount=i,this.interleaved=void 0===i,this.instancing=false,this.size=t.reduce((e,t)=>e+4*Math.ceil(t.components*aZ[t.type]/4),0);let s=0,r;for(let e=0,a=t.length;e<a;e++){let a=t[e];r=a.components*aZ[a.type],i&&(s=eb.roundUp(s,r));let n=a.asInt??false,o=!n&&(a.normalize??false),l={name:a.semantic,offset:i?s:a.hasOwnProperty("offset")?a.offset:s,stride:i?r:a.hasOwnProperty("stride")?a.stride:this.size,dataType:a.type,numComponents:a.components,normalize:o,size:r,asInt:n};this._elements.push(l),i?s+=r*i:s+=4*Math.ceil(r/4),a.semantic===sD?this.hasUv0=true:a.semantic===sI?this.hasUv1=true:a.semantic===sP?this.hasColor=true:a.semantic===sw&&(this.hasTangents=true);}i&&(this.verticesByteSize=s),this._evaluateHash();}get elements(){return this._elements}static getDefaultInstancingFormat(e){return nP.get(e,()=>new nL(e,[{semantic:sj,components:4,type:rO},{semantic:sK,components:4,type:rO},{semantic:sQ,components:4,type:rO},{semantic:sJ,components:4,type:rO}]))}static isElementValid(e,t){let i=t.components*aZ[t.type];return !e.isWebGPU||!!nC.includes(i)}update(){this._evaluateHash();}_evaluateHash(){let e=[],t=[],i=this._elements.length;for(let s=0;s<i;s++){let{name:i,dataType:r,numComponents:a,normalize:n,offset:o,stride:l,size:h,asInt:c}=this._elements[s],d=i+r+a+n+c;e.push(d);let u=d+o+l+h;t.push(u);}e.sort();let s=e.join();this.batchingHash=nb(s),this.shaderProcessingHashString=s,this.renderingHashString=t.join("_"),this.renderingHash=nA.get(this.renderingHashString);}}let nD=new np;class nI{set func(e){this._func=e,this._dirty=true;}get func(){return this._func}set ref(e){this._ref=e,this._dirty=true;}get ref(){return this._ref}set fail(e){this._fail=e,this._dirty=true;}get fail(){return this._fail}set zfail(e){this._zfail=e,this._dirty=true;}get zfail(){return this._zfail}set zpass(e){this._zpass=e,this._dirty=true;}get zpass(){return this._zpass}set readMask(e){this._readMask=e,this._dirty=true;}get readMask(){return this._readMask}set writeMask(e){this._writeMask=e,this._dirty=true;}get writeMask(){return this._writeMask}constructor(e={}){this._dirty=true,this._func=e.func??t7,this._ref=e.ref??0,this._readMask=e.readMask??255,this._writeMask=e.writeMask??255,this._fail=e.fail??s1,this._zfail=e.zfail??s1,this._zpass=e.zpass??s1,this._evalKey();}_evalKey(){let{_func:e,_ref:t,_fail:i,_zfail:s,_zpass:r,_readMask:a,_writeMask:n}=this,o=`${e},${t},${i},${s},${r},${a},${n}`;this._key=nD.get(o),this._dirty=false;}get key(){return this._dirty&&this._evalKey(),this._key}copy(e){return this._func=e._func,this._ref=e._ref,this._readMask=e._readMask,this._writeMask=e._writeMask,this._fail=e._fail,this._zfail=e._zfail,this._zpass=e._zpass,this._dirty=e._dirty,this._key=e._key,this}clone(){return new this.constructor().copy(this)}static{this.DEFAULT=Object.freeze(new nI);}}class nR extends el{static{this.EVENT_RESIZE="resizecanvas";}constructor(e,t){super(),this.backBuffer=null,this.backBufferSize=new eF,this.backBufferAntialias=false,this.isWebGPU=false,this.isWebGL2=false,this.isNull=false,this.isHdr=false,this.maxIndirectDrawCount=1024,this.maxColorAttachments=1,this.maxSamples=1,this.supportsMultiDraw=true,this.supportsCompute=false,this.supportsStorageTextureRead=false,this.renderTarget=null,this.shaders=[],this.textures=[],this.targets=new Set,this.renderVersion=0,this.insideRenderPass=false,this.supportsUniformBuffers=false,this.supportsClipDistances=false,this.textureRG11B10Renderable=false,this.textureFloatFilterable=false,this.blendState=new nf,this.depthState=new n_,this.stencilEnabled=false,this.stencilFront=new nI,this.stencilBack=new nI,this._destroyed=false,this.defaultClearOptions={color:[0,0,0,1],depth:1,stencil:0,flags:tB|tU},this.clientRect={width:0,height:0},this._shadersDirty=false,this.capsDefines=new Map,this.mapsToClear=new Set,this.canvas=e,"setAttribute"in e&&e.setAttribute("data-engine",`PlayCanvas ${V}`),this.initOptions={...t},this.initOptions.alpha??=true,this.initOptions.depth??=true,this.initOptions.stencil??=true,this.initOptions.antialias??=true,this.initOptions.powerPreference??="high-performance",this.initOptions.displayFormat??=aR,this._maxPixelRatio=et.browser?Math.min(1,window.devicePixelRatio):1,this.buffers=[],this._vram={tex:0,vb:0,ib:0,ub:0,sb:0},this._shaderStats={vsCompiled:0,fsCompiled:0,linked:0,materialShaders:0,compileTime:0},this.initializeContextCaches(),this._drawCallsPerFrame=0,this._shaderSwitchesPerFrame=0,this._primsPerFrame=[];for(let e=s_;e<=sT;e++)this._primsPerFrame[e]=0;this._renderTargetCreationTime=0,this.scope=new nx("Device"),this.textureBias=this.scope.resolve("textureBias"),this.textureBias.setValue(0);}postInit(){let e=new nL(this,[{semantic:sE,components:2,type:rO}]),t=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.quadVertexBuffer=new nE(this,e,4,{data:t});}initCapsDefines(){let{capsDefines:e}=this;e.clear(),this.textureFloatFilterable&&e.set("CAPS_TEXTURE_FLOAT_FILTERABLE",""),this.textureFloatRenderable&&e.set("CAPS_TEXTURE_FLOAT_RENDERABLE",""),this.supportsMultiDraw&&e.set("CAPS_MULTI_DRAW",""),et.desktop&&e.set("PLATFORM_DESKTOP",""),et.mobile&&e.set("PLATFORM_MOBILE",""),et.android&&e.set("PLATFORM_ANDROID",""),et.ios&&e.set("PLATFORM_IOS","");}destroy(){this.fire("destroy"),this.quadVertexBuffer?.destroy(),this.quadVertexBuffer=null,this.dynamicBuffers?.destroy(),this.dynamicBuffers=null,this.gpuProfiler?.destroy(),this.gpuProfiler=null,this._destroyed=true;}onDestroyShader(e){this.fire("destroy:shader",e);let t=this.shaders.indexOf(e);-1!==t&&this.shaders.splice(t,1);}postDestroy(){this.scope=null,this.canvas=null;}loseContext(){for(let e of(this.contextLost=true,this.backBufferSize.set(-1,-1),this.textures))e.loseContext();for(let e of this.buffers)e.loseContext();for(let e of this.targets)e.loseContext();this.gpuProfiler?.loseContext();}restoreContext(){for(let e of(this.contextLost=false,this.initializeRenderState(),this.initializeContextCaches(),this.buffers))e.unlock();this.gpuProfiler?.restoreContext?.();}toJSON(e){}initializeContextCaches(){this.vertexBuffers=[],this.shader=null,this.shaderValid=void 0,this.shaderAsyncCompile=false,this.renderTarget=null;}initializeRenderState(){this.blendState=new nf,this.depthState=new n_,this.cullMode=tq,this.vx=this.vy=this.vw=this.vh=0,this.sx=this.sy=this.sw=this.sh=0,this.blendColor=new ew(0,0,0,0);}setStencilState(e,t){}setBlendState(e){}setBlendColor(e,t,i,s){}setDepthState(e){}setCullMode(e){}setRenderTarget(e){this.renderTarget=e;}setVertexBuffer(e){e&&this.vertexBuffers.push(e);}clearVertexBuffer(){this.vertexBuffers.length=0;}getIndirectDrawSlot(e=1){return 0}get indirectDrawBuffer(){return null}getRenderTarget(){return this.renderTarget}initRenderTarget(e){e.initialized||(e.init(),this.targets.add(e));}draw(e,t,i,s,r=true,a=true){}_isBrowserInterface(e){return this._isImageBrowserInterface(e)||this._isImageCanvasInterface(e)||this._isImageVideoInterface(e)}_isImageBrowserInterface(e){return "undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement}_isImageCanvasInterface(e){return "undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement}_isImageVideoInterface(e){return "undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement}resizeCanvas(e,t){let i=Math.min(this._maxPixelRatio,et.browser?window.devicePixelRatio:1),s=Math.floor(e*i),r=Math.floor(t*i);(s!==this.canvas.width||r!==this.canvas.height)&&this.setResolution(s,r);}setResolution(e,t){this.canvas.width=e,this.canvas.height=t,this.fire(nR.EVENT_RESIZE,e,t);}update(){this.updateClientRect();}updateClientRect(){if(et.worker)this.clientRect.width=this.canvas.width,this.clientRect.height=this.canvas.height;else {let e=this.canvas.getBoundingClientRect();this.clientRect.width=e.width,this.clientRect.height=e.height;}}get width(){return this.canvas.width}get height(){return this.canvas.height}set fullscreen(e){}get fullscreen(){return false}set maxPixelRatio(e){this._maxPixelRatio=e;}get maxPixelRatio(){return this._maxPixelRatio}get deviceType(){return this._deviceType}startRenderPass(e){}endRenderPass(e){}startComputePass(e){}endComputePass(){}frameStart(){this.renderPassIndex=0,this.renderVersion++;}frameEnd(){this.mapsToClear.forEach(e=>e.clear()),this.mapsToClear.clear();}computeDispatch(e,t="Unnamed"){}getRenderableHdrFormat(e=[ib,iv,iy],t=true,i=1){for(let s=0;s<e.length;s++){let r=e[s];switch(r){case ib:if(this.textureRG11B10Renderable)return r;break;case iv:if(this.textureHalfFloatRenderable)return r;break;case iy:if(this.isWebGPU&&i>1)continue;if(this.textureFloatRenderable&&(!t||this.textureFloatFilterable))return r}}}validateAttributes(e,t,i){}}let nM=0;class nO{constructor(e={}){this.id=nM++;let t=e.colorBuffer?.device??e.colorBuffers?.[0].device??e.depthBuffer?.device??e.graphicsDevice;this._device=t;let{maxSamples:i}=this._device;if(this._samples=Math.min(e.samples??1,i),t.isWebGPU&&(this._samples=this._samples>1?i:1),this._colorBuffer=e.colorBuffer,e.colorBuffer&&(this._colorBuffers=[e.colorBuffer]),this._depthBuffer=e.depthBuffer,this._face=e.face??0,this._depthBuffer){let e=this._depthBuffer._format;e===iT||e===so?(this._depth=true,this._stencil=false):e===iE?(this._depth=true,this._stencil=true):(e===ix&&this._depthBuffer.device.isWebGPU&&this._samples>1?this._depth=true:this._depth=false,this._stencil=false);}else this._depth=e.depth??true,this._stencil=e.stencil??false;e.colorBuffers&&!this._colorBuffers&&(this._colorBuffers=[...e.colorBuffers],this._colorBuffer=e.colorBuffers[0]),this.autoResolve=e.autoResolve??true,this.name=e.name,this.name||(this.name=this._colorBuffer?.name),this.name||(this.name=this._depthBuffer?.name),this.name||(this.name="Untitled"),this.flipY=e.flipY??false,this._mipLevel=e.mipLevel??0,this._mipLevel>0&&this._depth&&(this._mipLevel=0),this._mipmaps=void 0===e.mipLevel,this.evaluateDimensions(),this.validateMrt(),this.impl=t.createRenderTargetImpl(this);}destroy(){let e=this._device;e&&(e.targets.delete(this),e.renderTarget===this&&e.setRenderTarget(null),this.destroyFrameBuffers());}destroyFrameBuffers(){let e=this._device;e&&this.impl.destroy(e);}destroyTextureBuffers(){this._depthBuffer?.destroy(),this._depthBuffer=null,this._colorBuffers?.forEach(e=>{e.destroy();}),this._colorBuffers=null,this._colorBuffer=null;}resize(e,t){if(!(this.mipLevel>0)&&(this._depthBuffer?.resize(e,t),this._colorBuffers?.forEach(i=>{i.resize(e,t);}),this._width!==e||this._height!==t)){this.destroyFrameBuffers();let e=this._device;e.renderTarget===this&&e.setRenderTarget(null),this.evaluateDimensions(),this.validateMrt(),this.impl=e.createRenderTargetImpl(this);}}validateMrt(){}evaluateDimensions(){let e=this._colorBuffer??this._depthBuffer;e&&(this._width=e.width,this._height=e.height,this._mipLevel>0&&(this._width=ni.calcLevelDimension(this._width,this._mipLevel),this._height=ni.calcLevelDimension(this._height,this._mipLevel)));}init(){this.impl.init(this._device,this);}get initialized(){return this.impl.initialized}get device(){return this._device}loseContext(){this.impl.loseContext();}resolve(e=true,t=!!this._depthBuffer){this._device&&this._samples>1&&this.impl.resolve(this._device,this,e,t);}copy(e,t,i){if(!this._device)if(!e._device)return false;else this._device=e._device;return this._device.copyRenderTarget(e,this,t,i)}get samples(){return this._samples}get depth(){return this._depth}get stencil(){return this._stencil}get colorBuffer(){return this._colorBuffer}getColorBuffer(e){return this._colorBuffers?.[e]}get depthBuffer(){return this._depthBuffer}get face(){return this._face}get mipLevel(){return this._mipLevel}get mipmaps(){return this._mipmaps}get width(){return this._width??this._device.width}get height(){return this._height??this._device.height}isColorBufferSrgb(e=0){if(this.device.backBuffer===this)return sc(this.device.backBufferFormat);let t=this.getColorBuffer(e);return !!t&&sc(t.format)}}class nF{update(e){this.destroy();let t=e.device,i=this.createDescriptor(t,e);this.bindGroup=t.wgpu.createBindGroup(i);}destroy(){this.bindGroup=null;}createDescriptor(e,t){let i=[],s=t.format,r=t.format.uniformBufferFormats;t.uniformBuffers.forEach((e,t)=>{let s=r[t].slot,a=e.persistent?e.impl.buffer:e.allocation.gpuBuffer.buffer;i.push({binding:s,resource:{buffer:a,offset:0,size:e.format.byteSize}});});let a=t.format.textureFormats;t.textures.forEach((t,r)=>{let n=t.impl,o=s.textureFormats[r],l=a[r].slot,h=n.getView(e);if(i.push({binding:l,resource:h}),o.hasSampler){let t=n.getSampler(e,o.sampleType);i.push({binding:l+1,resource:t});}});let n=t.format.storageTextureFormats;t.storageTextures.forEach((t,s)=>{let r=t.impl,a=n[s].slot,o=r.getView(e);i.push({binding:a,resource:o});});let o=t.format.storageBufferFormats;return t.storageBuffers.forEach((e,t)=>{let s=e.impl.buffer,r=o[t].slot;i.push({binding:r,resource:{buffer:s}});}),{layout:t.format.impl.bindGroupLayout,entries:i}}}class nN{static shaderStage(e){let t=0;return e&aL&&(t|=GPUShaderStage.VERTEX),e&aD&&(t|=GPUShaderStage.FRAGMENT),e&aI&&(t|=GPUShaderStage.COMPUTE),t}}let nB=[];nB[ir]="",nB[ia]="",nB[io]="",nB[i4]="r8unorm",nB[i5]="rg8unorm",nB[il]="",nB[ih]="",nB[ic]="",nB[id]="rgba8unorm",nB[iu]="rgba8unorm",nB[ip]="bc1-rgba-unorm",nB[im]="bc2-rgba-unorm",nB[i_]="bc3-rgba-unorm",nB[ig]="",nB[iv]="rgba16float",nB[i2]="r16float",nB[i3]="rg16float",nB[iS]="",nB[iy]="rgba32float",nB[ix]="r32float",nB[iT]="depth32float",nB[so]="depth16unorm",nB[iE]="depth24plus-stencil8",nB[ib]="rg11b10ufloat",nB[iw]="",nB[iA]="rgba8unorm-srgb",nB[iC]="",nB[iP]="etc2-rgb8unorm",nB[iL]="etc2-rgba8unorm",nB[iD]="",nB[iI]="",nB[iR]="",nB[iM]="",nB[iO]="astc-4x4-unorm",nB[iF]="",nB[iN]="",nB[iB]="bgra8unorm",nB[si]="bgra8unorm-srgb",nB[iU]="r8sint",nB[ik]="r8uint",nB[iz]="r16sint",nB[iV]="r16uint",nB[iG]="r32sint",nB[iH]="r32uint",nB[iW]="rg8sint",nB[iX]="rg8uint",nB[iY]="rg16sint",nB[iq]="rg16uint",nB[i$]="rg32sint",nB[ij]="rg32uint",nB[iK]="rgba8sint",nB[iZ]="rgba8uint",nB[iQ]="rgba16sint",nB[iJ]="rgba16uint",nB[i0]="rgba32sint",nB[i1]="rgba32uint",nB[ss]="bc6h-rgb-float",nB[sr]="bc6h-rgb-ufloat",nB[sa]="bc7-rgba-unorm",nB[i8]="bc1-rgba-unorm-srgb",nB[i6]="bc2-rgba-unorm-srgb",nB[i9]="bc3-rgba-unorm-srgb",nB[i7]="etc2-rgb8unorm-srgb",nB[se]="etc2-rgba8unorm-srgb",nB[sn]="bc7-rgba-unorm-srgb",nB[st]="astc-4x4-unorm-srgb";let nU=[];nU[rg]="filtering",nU[rv]="non-filtering",nU[rS]="comparison",nU[ry]="comparison",nU[rx]="comparison";let nk=[];nk[rg]="float",nk[rv]="unfilterable-float",nk[rS]="depth",nk[ry]="sint",nk[rx]="uint";let nz=new np;class nV{constructor(e){let t=e.device,{key:i,desc:s}=this.createDescriptor(e);this.key=nz.get(i),this.bindGroupLayout=t.wgpu.createBindGroupLayout(s);}destroy(){this.bindGroupLayout=null;}loseContext(){}createDescriptor(e){let t=[],i="";return e.uniformBufferFormats.forEach(e=>{let s=nN.shaderStage(e.visibility);i+=`#${e.slot}U:${s}`,t.push({binding:e.slot,visibility:s,buffer:{type:"uniform",hasDynamicOffset:true}});}),e.textureFormats.forEach(e=>{let s=nN.shaderStage(e.visibility),r=e.sampleType,a=e.textureDimension,n=nk[r];if(i+=`#${e.slot}T:${s}-${n}-${a}-false`,t.push({binding:e.slot,visibility:s,texture:{sampleType:n,viewDimension:a,multisampled:false}}),e.hasSampler){let a=nU[r];i+=`#${e.slot+1}S:${s}-${a}`,t.push({binding:e.slot+1,visibility:s,sampler:{type:a}});}}),e.storageTextureFormats.forEach(e=>{let{format:s,textureDimension:r}=e,{read:a,write:n}=e;i+=`#${e.slot}ST:${s}-${r}-${a?"r1":"r0"}-${n?"w1":"w0"}`,t.push({binding:e.slot,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:a?n?"read-write":"read-only":"write-only",format:nB[s],viewDimension:r}});}),e.storageBufferFormats.forEach(e=>{let s=e.readOnly,r=nN.shaderStage(e.visibility);i+=`#${e.slot}SB:${r}-${s?"ro":"rw"}`,t.push({binding:e.slot,visibility:r,buffer:{type:s?"read-only-storage":"storage"}});}),{key:i,desc:{entries:t}}}}class nG{constructor(e=0){this.buffer=null,this.usageFlags=0,this.usageFlags=e;}destroy(e){this.buffer&&(this.buffer.destroy(),this.buffer=null);}get initialized(){return !!this.buffer}loseContext(){}allocate(e,t){this.buffer=e.wgpu.createBuffer({size:t,usage:this.usageFlags});}unlock(e,t){let i=e.wgpu;if(!this.buffer){let i=t.byteLength+3&-4;this.usageFlags|=GPUBufferUsage.COPY_DST,this.allocate(e,i);}let s=t.byteOffset??0,r=new Uint8Array(t.buffer??t,s,t.byteLength),a=new Uint8Array(this.buffer.size);a.set(r),i.queue.writeBuffer(this.buffer,0,a,0,a.length);}read(e,t,i,s,r){return e.readStorageBuffer(this,t,i,s,r)}write(e,t,i,s,r){e.writeStorageBuffer(this,t,i,s,r);}clear(e,t,i){e.clearStorageBuffer(this,t,i);}}class nH extends nG{constructor(e,t){super(tP|(t?.storage?tI:0)),this.format=null,this.format=e.format===it?"uint16":"uint32";}unlock(e){let t=e.device;super.unlock(t,e.storage);}}let nW={equals(e,t){if(e.length!==t.length)return false;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return false;return true}},nX=[];nX[rP]="sint8",nX[rL]="uint8",nX[rD]="sint16",nX[rI]="uint16",nX[rR]="sint32",nX[rM]="uint32",nX[rO]="float32",nX[rF]="float16";let nY=[];nY[rP]="snorm8",nY[rL]="unorm8",nY[rD]="snorm16",nY[rI]="unorm16",nY[rR]="sint32",nY[rM]="uint32",nY[rO]="float32",nY[rF]="float16";class nq{get(e,t=null){let i=this.getKey(e,t),s=this.cache.get(i);return s||(s=this.create(e,t),this.cache.set(i,s)),s}getKey(e,t=null){return `${e?.renderingHashString}-${t?.renderingHashString}`}create(e,t){let i=[],s=e=>{let t=e.interleaved,s=e.instancing?"instance":"vertex",r=[],a=e.elements.length;for(let n=0;n<a;n++){let o=e.elements[n],l=a3[o.name],h=o.normalize?nY:nX;r.push({shaderLocation:l,offset:t?o.offset:0,format:`${h[o.dataType]}${o.numComponents>1?`x${o.numComponents}`:""}`}),t&&n!==a-1||(i.push({attributes:r,arrayStride:o.stride,stepMode:s}),r=[]);}};return e&&s(e),t&&s(t),i}constructor(){this.cache=new Map;}}class n${constructor(e){this.device=e;}getPipelineLayout(e){let t=[];return e.forEach(e=>{t.push(e.bindGroupLayout);}),this.device.wgpu.createPipelineLayout({bindGroupLayouts:t})}}let nj=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],nK=["add","subtract","reverse-subtract","min","max"],nZ=["zero","one","src","one-minus-src","dst","one-minus-dst","src-alpha","src-alpha-saturated","one-minus-src-alpha","dst-alpha","one-minus-dst-alpha","constant","one-minus-constant"],nQ=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],nJ=["none","back","front"],n0=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],n1=["","uint16","uint32"];class n2{}class n3 extends n${constructor(e){super(e),this.lookupHashes=new Uint32Array(14),this.vertexBufferLayout=new nq,this.cache=new Map;}get(e,t,i,s,r,a,n,o,l,h,c,d,u){let f=e.type;s&&f!==sS&&f!==sx&&(s=void 0);let p=this.lookupHashes;p[0]=f,p[1]=r.id,p[2]=h,p[3]=l.key,p[4]=o.key,p[5]=t?.renderingHash??0,p[6]=i?.renderingHash??0,p[7]=a.impl.key,p[8]=n[0]?.key??0,p[9]=n[1]?.key??0,p[10]=n[2]?.key??0,p[11]=c?d.key:0,p[12]=c?u.key:0,p[13]=s??0;let m=nw(p),_=this.cache.get(m);if(_)for(let e=0;e<_.length;e++){let t=_[e];if(nW.equals(t.hashes,p))return t.pipeline}let g=nj[f],v=this.getPipelineLayout(n),S=this.vertexBufferLayout.get(t,i),y=new n2;return y.hashes=new Uint32Array(p),y.pipeline=this.create(g,s,r,a,v,o,l,S,h,c,d,u),_?_.push(y):_=[y],this.cache.set(m,_),y.pipeline}getBlend(e){let t;return e.blend&&(t={color:{operation:nK[e.colorOp],srcFactor:nZ[e.colorSrcFactor],dstFactor:nZ[e.colorDstFactor]},alpha:{operation:nK[e.alphaOp],srcFactor:nZ[e.alphaSrcFactor],dstFactor:nZ[e.alphaDstFactor]}}),t}getDepthStencil(e,t,i,s,r,a){let n,{depth:o,stencil:l}=t;if(o||l){if(n={format:t.impl.depthAttachment.format},o){n.depthWriteEnabled=e.write,n.depthCompare=nQ[e.func];let t="triangle-list"===a||"triangle-strip"===a;n.depthBias=t?e.depthBias:0,n.depthBiasSlopeScale=t?e.depthBiasSlope:0;}else n.depthWriteEnabled=false,n.depthCompare="always";l&&i&&(n.stencilReadMas=s.readMask,n.stencilWriteMask=s.writeMask,n.stencilFront={compare:nQ[s.func],failOp:n0[s.fail],passOp:n0[s.zpass],depthFailOp:n0[s.zfail]},n.stencilBack={compare:nQ[r.func],failOp:n0[r.fail],passOp:n0[r.zpass],depthFailOp:n0[r.zfail]});}return n}create(e,t,i,s,r,a,n,o,l,h,c,d){let u=this.device.wgpu,f=i.impl,p={vertex:{module:f.getVertexShaderModule(),entryPoint:f.vertexEntryPoint,buffers:o},primitive:{topology:e,frontFace:"ccw",cullMode:nJ[l]},depthStencil:this.getDepthStencil(n,s,h,c,d,e),multisample:{count:s.samples},layout:r};t&&(p.primitive.stripIndexFormat=n1[t]),p.fragment={module:f.getFragmentShaderModule(),entryPoint:f.fragmentEntryPoint,targets:[]};let m=s.impl.colorAttachments;if(m.length>0){let e=0;a.redWrite&&(e|=GPUColorWrite.RED),a.greenWrite&&(e|=GPUColorWrite.GREEN),a.blueWrite&&(e|=GPUColorWrite.BLUE),a.alphaWrite&&(e|=GPUColorWrite.ALPHA);let t=this.getBlend(a);m.forEach(i=>{p.fragment.targets.push({format:i.format,writeMask:e,blend:t});});}return u.createRenderPipeline(p)}}class n4 extends n${get(e,t){let i=this.getPipelineLayout([t.impl]);return this.create(e,i)}create(e,t){let i=this.device.wgpu,s=e.impl,r={compute:{module:s.getComputeShaderModule(),entryPoint:s.computeEntryPoint},layout:t};return i.createComputePipeline(r)}}class n5{incRefCount(){this._refCount++;}decRefCount(){this._refCount--;}get refCount(){return this._refCount}constructor(){this._refCount=0;}}class n8 extends n5{constructor(e){super(),this.object=e,this.incRefCount();}}class n6{destroy(){this.cache.forEach(e=>{e.object?.destroy();}),this.cache.clear();}clear(){this.cache.clear();}get(e){let t=this.cache.get(e);return t?(t.incRefCount(),t.object):null}set(e,t){this.cache.set(e,new n8(t));}release(e){let t=this.cache.get(e);t&&(t.decRefCount(),0===t.refCount&&(this.cache.delete(e),t.object?.destroy()));}constructor(){this.cache=new Map;}}class n9 extends n6{loseContext(e){this.clear();}}let n7=new nt,oe=e=>n7.get(e,()=>new n9),ot=new np;class oi{destroy(){this.multisampledBuffer?.destroy(),this.multisampledBuffer=null;}}class os{constructor(e){this.depthTexture=null,this.depthTextureInternal=false,this.multisampledDepthBuffer=null,this.format=e,this.hasStencil="depth24plus-stencil8"===e;}destroy(e){this.depthTextureInternal&&(this.depthTexture?.destroy(),this.depthTexture=null),this.multisampledDepthBuffer&&(this.multisampledDepthBuffer=null,oe(e).release(this.multisampledDepthBufferKey));}}class or{constructor(e){this.initialized=false,this.colorAttachments=[],this.depthAttachment=null,this.assignedColorTexture=null,this.renderPassDescriptor={},this.isBackbuffer=false,this.renderTarget=e;}destroy(e){this.initialized=false,this.assignedColorTexture=null,this.colorAttachments.forEach(e=>{e.destroy();}),this.colorAttachments.length=0,this.depthAttachment?.destroy(e),this.depthAttachment=null;}updateKey(){let e=this.renderTarget,t=`${e.samples}:${this.depthAttachment?this.depthAttachment.format:"nodepth"}`;this.colorAttachments.forEach(e=>{t+=`:${e.format}`;}),this.key=ot.get(t);}assignColorTexture(e,t){this.assignedColorTexture=t;let i=t.createView({format:e.backBufferViewFormat}),s=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?s.resolveTarget=i:s.view=i,this.setColorAttachment(0,void 0,e.backBufferViewFormat),this.updateKey();}setColorAttachment(e,t,i){this.colorAttachments[e]||(this.colorAttachments[e]=new oi),t&&(this.colorAttachments[e].multisampledBuffer=t),i&&(this.colorAttachments[e].format=i);}init(e,t){let i=e.wgpu;this.initDepthStencil(e,i,t),t._colorBuffers&&t._colorBuffers.forEach((e,t)=>{this.setColorAttachment(t,void 0,e.impl.format);}),this.renderPassDescriptor.colorAttachments=[];let s=this.isBackbuffer?1:t._colorBuffers?.length??0;for(let r=0;r<s;++r){let s=this.initColor(e,i,t,r),a=0===r&&this.colorAttachments[0]?.format;(s.view||a)&&this.renderPassDescriptor.colorAttachments.push(s);}this.updateKey(),this.initialized=true;}initDepthStencil(e,t,i){let{samples:s,width:r,height:a,depth:n,depthBuffer:o}=i;if(n||o){let i;if(o)if(this.depthAttachment=new os(o.impl.format),s>1){let n="depth24plus-stencil8";this.depthAttachment.format=n,this.depthAttachment.hasStencil=true;let l=`${o.id}:${r}:${a}:${s}:${n}`,h=oe(e),c=h.get(l);if(!c){let e={size:[r,a,1],dimension:"2d",sampleCount:s,format:n,usage:GPUTextureUsage.RENDER_ATTACHMENT|(n!==o.impl.format?GPUTextureUsage.TEXTURE_BINDING:0)};c=t.createTexture(e),h.set(l,c);}this.depthAttachment.multisampledDepthBuffer=c,this.depthAttachment.multisampledDepthBufferKey=l,i=c.createView();}else {let e=o.impl.gpuTexture;this.depthAttachment.depthTexture=e,i=e.createView();}else {this.depthAttachment=new os("depth24plus-stencil8");let e={size:[r,a,1],dimension:"2d",sampleCount:s,format:this.depthAttachment.format,usage:GPUTextureUsage.RENDER_ATTACHMENT};s>1?e.usage|=GPUTextureUsage.TEXTURE_BINDING:e.usage|=GPUTextureUsage.COPY_SRC;let n=t.createTexture(e);this.depthAttachment.depthTexture=n,this.depthAttachment.depthTextureInternal=true,i=n.createView();}this.renderPassDescriptor.depthStencilAttachment={view:i};}}initColor(e,t,i,s){let r={},{samples:a,width:n,height:o,mipLevel:l}=i,h=i.getColorBuffer(s),c=null;if(h&&(c=h.cubemap?h.impl.createView({dimension:"2d",baseArrayLayer:i.face,arrayLayerCount:1,mipLevelCount:1,baseMipLevel:l}):h.impl.createView({mipLevelCount:1,baseMipLevel:l})),a>1){let i={size:[n,o,1],dimension:"2d",sampleCount:a,format:this.isBackbuffer?e.backBufferViewFormat:h.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},l=t.createTexture(i);this.setColorAttachment(s,l,i.format),r.view=l.createView(),r.resolveTarget=c;}else r.view=c;return r}setupForRenderPass(e,t){let i=this.renderPassDescriptor.colorAttachments?.length??0;for(let s=0;s<i;++s){let i=this.renderPassDescriptor.colorAttachments[s],r=e.colorArrayOps[s];i.clearValue=t.isColorBufferSrgb(s)?r.clearValueLinear:r.clearValue,i.loadOp=r.clear?"clear":"load",i.storeOp=r.store?"store":"discard";}let s=this.renderPassDescriptor.depthStencilAttachment;s&&(s.depthClearValue=e.depthStencilOps.clearDepthValue,s.depthLoadOp=e.depthStencilOps.clearDepth?"clear":"load",s.depthStoreOp=e.depthStencilOps.storeDepth?"store":"discard",s.depthReadOnly=false,this.depthAttachment.hasStencil&&(s.stencilClearValue=e.depthStencilOps.clearStencilValue,s.stencilLoadOp=e.depthStencilOps.clearStencil?"clear":"load",s.stencilStoreOp=e.depthStencilOps.storeStencil?"store":"discard",s.stencilReadOnly=false));}loseContext(){this.initialized=false;}resolve(e,t,i,s){}}let oa=[];oa[rU]=1,oa[rk]=2,oa[rz]=3,oa[rV]=4,oa[rB]=1,oa[rG]=2,oa[rH]=3,oa[rW]=4,oa[rN]=1,oa[rX]=2,oa[rY]=3,oa[rq]=4,oa[r$]=8,oa[rj]=12,oa[rK]=16,oa[r9]=1,oa[r7]=2,oa[ae]=3,oa[at]=4;class on{get isArrayType(){return this.count>0}constructor(e,t,i=0){if(this.shortName=e,this.name=i?`${e}[0]`:e,this.type=t,this.numComponents=oa[t],this.updateType=t,i>0)switch(t){case rU:this.updateType=rJ;break;case rB:this.updateType=ai;break;case r9:this.updateType=as;break;case rN:this.updateType=ar;break;case rk:this.updateType=r3;break;case rG:this.updateType=aa;break;case r7:this.updateType=an;break;case rX:this.updateType=ao;break;case rz:this.updateType=r4;break;case rH:this.updateType=al;break;case ae:this.updateType=ah;break;case rY:this.updateType=ac;break;case rV:this.updateType=r5;break;case rW:this.updateType=ad;break;case at:this.updateType=au;break;case rq:this.updateType=af;break;case rK:this.updateType=r8;}this.count=i;let s=this.numComponents;i&&(s=eb.roundUp(s,4)),this.byteSize=4*s,i&&(this.byteSize*=i);}calculateOffset(e){let t=this.byteSize<=8?this.byteSize:16;this.count&&(t=16),e=eb.roundUp(e,t),this.offset=e/4;}}class oo{constructor(e,t){this.byteSize=0,this.map=new Map,this.scope=e.scope,this.uniforms=t;let i=0;for(let e=0;e<t.length;e++){let s=t[e];s.calculateOffset(i),i=4*s.offset+s.byteSize,s.scopeId=this.scope.resolve(s.name),this.map.set(s.name,s);}this.byteSize=eb.roundUp(i,16);}get(e){return this.map.get(e)}}let ol=/[ \t]*(\battribute\b|\bvarying\b|\buniform\b)/g,oh=/(\battribute\b|\bvarying\b|\bout\b|\buniform\b)[ \t]*([^;]+)(;+)/g,oc=/([\w-]+)\[(.*?)\]/,od=new Set(["highp","mediump","lowp"]),ou=new Set(["sampler2DShadow","samplerCubeShadow","sampler2DArrayShadow"]),of={sampler2D:ru,sampler3D:r_,samplerCube:rp,samplerCubeShadow:rp,sampler2DShadow:ru,sampler2DArray:rf,sampler2DArrayShadow:rf,isampler2D:ru,usampler2D:ru,isampler3D:r_,usampler3D:r_,isamplerCube:rp,usamplerCube:rp,isampler2DArray:rf,usampler2DArray:rf},op={[ru]:"texture2D",[rp]:"textureCube",[r_]:"texture3D",[rf]:"texture2DArray"},om=class{constructor(e,t){this.line=e;let i=e.trim().split(/\s+/);if(od.has(i[0])&&(this.precision=i.shift()),this.type=i.shift(),e.includes(","),e.includes("[")){let e=i.join(" "),s=oc.exec(e);this.name=s[1],this.arraySize=Number(s[2]),isNaN(this.arraySize)&&(t.failed=true);}else this.name=i.shift(),this.arraySize=0;this.isSampler=-1!==this.type.indexOf("sampler"),this.isSignedInt=-1!==this.type.indexOf("isampler"),this.isUnsignedInt=-1!==this.type.indexOf("usampler");}};class o_{static run(e,t,i){let s=new Map,r=o_.extract(t.vshader),a=o_.extract(t.fshader),n=new Map,o=o_.processAttributes(r.attributes,t.attributes,n,t.processingOptions),l=o_.processVaryings(r.varyings,s,true),h=o_.processVaryings(a.varyings,s,false),c=o_.processOuts(a.outs),d=Array.from(new Set(r.uniforms.concat(a.uniforms))).map(e=>new om(e,i)),u=o_.processUniforms(e,d,t.processingOptions,i),f=`${o}
9
9
  ${l}
10
10
  ${u.code}`,p=r.src.replace("@@@",f),m=`${h}
11
11
  ${c}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v2.13.1-preview.0 revision 2c38650 (RELEASE)
3
+ * PlayCanvas Engine v2.13.1 revision 5d53ea1 (RELEASE)
4
4
  * Copyright 2011-2025 PlayCanvas Ltd. All rights reserved.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
@@ -30,8 +30,8 @@ const TRACEID_RENDER_QUEUE = 'RenderQueue';
30
30
  const TRACEID_OCTREE_RESOURCES = 'OctreeResources';
31
31
  const TRACEID_GPU_TIMINGS = 'GpuTimings';
32
32
 
33
- const version = '2.13.1-preview.0';
34
- const revision = '2c38650';
33
+ const version = '2.13.1';
34
+ const revision = '5d53ea1';
35
35
  function extend(target, ex) {
36
36
  for(const prop in ex){
37
37
  const copy = ex[prop];
@@ -1,5 +1,5 @@
1
- const version = '2.13.1-preview.0';
2
- const revision = '2c38650';
1
+ const version = '2.13.1';
2
+ const revision = '5d53ea1';
3
3
  function extend(target, ex) {
4
4
  for(const prop in ex){
5
5
  const copy = ex[prop];