playcanvas 2.7.5-preview.3 → 2.7.5
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.
- package/build/playcanvas/src/core/core.js +2 -2
- package/build/playcanvas.dbg/src/core/core.js +2 -2
- package/build/playcanvas.dbg.js +3 -3
- package/build/playcanvas.dbg.mjs +4 -4
- package/build/playcanvas.js +3 -3
- package/build/playcanvas.min.js +1 -1
- package/build/playcanvas.min.mjs +1 -1
- package/build/playcanvas.mjs +3 -3
- package/build/playcanvas.prf/src/core/core.js +2 -2
- package/build/playcanvas.prf.js +3 -3
- package/build/playcanvas.prf.mjs +3 -3
- package/package.json +1 -1
package/build/playcanvas.min.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
let e,t,s,i,r,a,n,o,l,h,c,d,u,p,f,m,_,g;let y="RenderFrame",v="RenderFrameTime",S="RenderPass",x="RenderPassDetail",T="RenderAction",b="RenderTargetAlloc",E="TextureAlloc",A="ShaderAlloc",w="ShaderCompile",C="VRAM.Texture",P="VRAM.Vb",M="VRAM.Ib",I="VRAM.Sb",R="BindGroupAlloc",L="BindGroupFormatAlloc",D="RenderPipelineAlloc",O="ComputePipelineAlloc",F="PipelineLayoutAlloc",N="Element",B="Textures",U="RenderQueue",k="GpuTimings",z="2.7.5-preview.3",V="7893c52";function G(e,t){for(let s in t){let i=t[s];Array.isArray(i)?e[s]=G([],i):i&&"object"==typeof i?e[s]=G({},i):e[s]=i;}return e}let H={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)})},W={delimiter:"/",join(...e){let t=e[0];for(let s=0;s<e.length-1;s++){let i=e[s],r=e[s+1];if(r[0]===W.delimiter){t=r;continue}i&&r&&i[i.length-1]!==W.delimiter&&r[0]!==W.delimiter?t+=W.delimiter+r:t+=r;}return t},normalize(e){let t=e.startsWith(W.delimiter),s=e.endsWith(W.delimiter),i=e.split("/"),r="",a=[];for(let e=0;e<i.length;e++)if(""!==i[e]&&"."!==i[e]){if(".."===i[e]&&a.length>0){a=a.slice(0,a.length-2);continue}e>0&&a.push(W.delimiter),a.push(i[e]);}return r=a.join(""),t||r[0]!==W.delimiter||(r=r.slice(1)),s&&r[r.length-1]!==W.delimiter&&(r+=W.delimiter),r},split(e){let t=e.lastIndexOf(W.delimiter);return -1!==t?[e.substring(0,t),e.substring(t+1)]:["",e]},getBasename:e=>W.split(e)[1],getDirectory:e=>W.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="",s=e.split("/"),i=0;if(s.length>1){if(W.isRelativePath(e)){if("."===s[0])for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;else if(".."===s[0])for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;else for(i=0,t=".";i<s.length-1;++i)t+=`/${s[i]}`;}else for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;}return t}},X="undefined"!=typeof navigator?navigator.userAgent:"",$="undefined"!=typeof window?"browser":"undefined"!=typeof global?"node":"worker",Y=/android/i.test(X)?"android":/ip(?:[ao]d|hone)/i.test(X)?"ios":/windows/i.test(X)?"windows":/mac os/i.test(X)?"osx":/linux/i.test(X)?"linux":/cros/i.test(X)?"cros":null,q="browser"!==$?null:/Chrome\/|Chromium\/|Edg.*\//.test(X)?"chrome":/Safari\//.test(X)?"safari":/Firefox\//.test(X)?"firefox":"other",j=/xbox/i.test(X),K="browser"===$&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),Z="browser"===$&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),Q="undefined"!=typeof Worker,J=(()=>{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})(),ee={name:Y,environment:$,global:("undefined"!=typeof globalThis&&globalThis)??("browser"===$&&window)??("node"===$&&global)??("worker"===$&&self),browser:"browser"===$,worker:"worker"===$,desktop:["windows","osx","linux","cros"].includes(Y),mobile:["android","ios"].includes(Y),ios:"ios"===Y,android:"android"===Y,xbox:j,gamepads:Z,touch:K,workers:Q,passiveEvents:J,browserName:q},et="abcdefghijklmnopqrstuvwxyz",es="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function ei(e,t=0){let s=e.length;if(t<0||t>=s)return null;let i=e.charCodeAt(t);if(s>1&&i>=55296&&i<=56319){let s=e.charCodeAt(t+1);if(s>=56320&&s<=57343)return {code:(i-55296)*1024+s-56320+65536,long:true}}return {code:i,long:false}}function er(e,t,s){if(!e)return false;let i=ei(e);if(i){let e=i.code;return e>=t&&e<=s}return false}let ea={ASCII_LOWERCASE:et,ASCII_UPPERCASE:es,ASCII_LETTERS:et+es,format(e,...t){for(let s=0;s<t.length;s++)e=e.replace(`{${s}}`,t[s]);return e},getCodePoint(e,t){let s=ei(e,t);return s&&s.code},getCodePoints(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let s=0,i=[];for(;t=ei(e,s);)i.push(t.code),s+=t.long?2:1;return i},getSymbols(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let s=0,i=e.length,r=[],a=0;for(;s<i;){if(a+=function(e,t){if(t===e.length-1)return 1;if(er(e[t],55296,56319)){let s=e.substring(t,t+2),i=e.substring(t+2,t+4);return er(i,127995,127999)||er(s,127462,127487)&&er(i,127462,127487)?4:er(i,65024,65039)?3:2}return er(e[t+1],65024,65039)?2:1}(e,s+a),er(t=e[s+a],8400,8447)&&(t=e[s+a++]),er(t,65024,65039)&&(t=e[s+a++]),t&&8205===t.charCodeAt(0)){t=e[s+a++];continue}let i=e.substring(s,s+a);r.push(i),s+=a,a=0;}return r},fromCodePoint(){let e,t,s;let i=[];for(let r=0;r<arguments.length;++r)e=Number(arguments[r]),t=e-65536,s=e>65535?[(t>>10)+55296,t%1024+56320]:[e],i.push(String.fromCharCode.apply(null,s));return i.join("")}};class en{constructor(e,t,s,i,r=false){this._removed=false,this.handler=e,this.name=t,this.callback=s,this.scope=i,this._once=r;}off(){this._removed||this.handler.offByHandle(this);}on(e,t,s=this){return this.handler._addCallback(e,t,s,false)}once(e,t,s=this){return this.handler._addCallback(e,t,s,true)}set removed(e){e&&(this._removed=true);}get removed(){return this._removed}}class eo{initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map;}_addCallback(e,t,s,i){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 en(this,e,t,s,i);return this._callbacks.get(e).push(r),r}on(e,t,s=this){return this._addCallback(e,t,s,false)}once(e,t,s=this){return this._addCallback(e,t,s,true)}off(e,t,s){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 i=this._callbacks.get(e);if(!i)return this;for(let e=0;e<i.length;e++)i[e].callback===t&&(!s||i[e].scope===s)&&(i[e].removed=true,i.splice(e,1),e--);0===i.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 s=this._callbacks.get(t);if(!s)return this;let i=s.indexOf(e);return -1!==i&&(s.splice(i,1),0===s.length&&this._callbacks.delete(t)),this}fire(e,t,s,i,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,s,i,r,a,n,o,l),d._once)){let t=this._callbacks.get(e),s=t?t.indexOf(d):-1;if(-1!==s){this._callbackActive.get(e)===t&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let i=this._callbacks.get(e);if(!i)continue;i[s].removed=true,i.splice(s,1),0===i.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 el{push(e,t){if(this._index[e])throw Error(`Key already in index ${e}`);let s=this._list.push(t)-1;this._index[e]=s;}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 s=this._index[e];s>t&&(this._index[e]=s-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={};}}let eh=e=>{let t={},s=t;return ()=>(s===t&&(s=e()),s)};class ec{static{this.modules={};}static{this.wasmSupported=eh(()=>{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 s=document.createElement("script");s.setAttribute("src",e),s.onload=()=>{t(null);},s.onerror=()=>{t(`Failed to load script='${e}'`);},document.body.appendChild(s);}static loadWasm(e,t,s){let i=ec.wasmSupported()&&t.glueUrl&&t.wasmUrl?t.glueUrl:t.fallbackUrl;i?ec.loadScript(i,i=>{if(i)s(i,null);else {let i=window[e];window[e]=void 0,i({locateFile:()=>t.wasmUrl,onAbort:()=>{s("wasm module aborted.");}}).then(e=>{s(null,e);});}}):s("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 s=t.config;(s.glueUrl||s.wasmUrl||s.fallbackUrl)&&(t.initializing=true,ec.loadWasm(e,s,(e,i)=>{e?s.errorHandler&&s.errorHandler(e):(t.instance=i,t.callbacks.forEach(e=>{e(i);}));}));}}class ed{static setConfig(e,t){let s=ec.getModule(e);s.config=t,s.callbacks.length>0&&ec.initialize(e,s);}static getConfig(e){return ec.modules?.[e]?.config}static getInstance(e,t){let s=ec.getModule(e);s.instance?t(s.instance):(s.callbacks.push(t),s.config&&ec.initialize(e,s));}}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 s=0;s<e;++s)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 ep{constructor(e){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=e.sortBy,this._sortHandler=this._doSort.bind(this);}_binarySearch(e){let t,s,i=0,r=this.items.length-1,a=e[this._sortBy];for(;i<=r;)t=Math.floor((i+r)/2),(s=this.items[t][this._sortBy])<=a?i=t+1:s>a&&(r=t-1);return i}_doSort(e,t){let s=this._sortBy;return e[s]-t[s]}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 ef extends eo{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,s=this._processArguments(e,true);if(!s.length)return t;for(let e=0;e<s.length;e++)!this._index[s[e]]&&(t=true,this._index[s[e]]=true,this._list.push(s[e]),this.fire("add",s[e],this._parent));return t&&this.fire("change",this._parent),t}remove(...e){let t=false;if(!this._list.length)return t;let s=this._processArguments(e,true);if(!s.length)return t;for(let e=0;e<s.length;e++)this._index[s[e]]&&(t=true,delete this._index[s[e]],this._list.splice(this._list.indexOf(s[e]),1),this.fire("remove",s[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 s=true;for(let i=0;i<e[t].length;i++)if(!this._index[e[t][i]]){s=false;break}if(s)return true}return false}list(){return this._list.slice(0)}_processArguments(e,t){let s=[],i=[];if(!e||!e.length)return s;for(let r=0;r<e.length;r++)if(e[r]instanceof Array){t||(i=[]);for(let a=0;a<e[r].length;a++)"string"==typeof e[r][a]&&(t?s.push(e[r][a]):i.push(e[r][a]));!t&&i.length&&s.push(i);}else "string"==typeof e[r]&&(t?s.push(e[r]):s.push([e[r]]));return s}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 ey{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 s=t.split("=");e[s[0]]=s[1];}return e}setQuery(e){let t="";for(let s in e)e.hasOwnProperty(s)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`);this.query=t;}}class ev{static{this._traceChannels=new Set;}static{this.stack=false;}static set(e,t=true){}static get(e){return ev._traceChannels.has(e)}}let eS=0,ex=1,eT=4,eb=5,eE={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:(e,t,s)=>e>=s?s: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,s)=>(e.length&&(s=e[2],t=e[1],e=e[0]),e<<16|t<<8|s),bytesToInt32:(e,t,s,i)=>(e.length&&(i=e[3],s=e[2],t=e[1],e=e[0]),(e<<24|t<<16|s<<8|i)>>>0),lerp:(e,t,s)=>e+(t-e)*eE.clamp(s,0,1),lerpAngle:(e,t,s)=>(t-e>180&&(t-=360),t-e<-180&&(t+=360),eE.lerp(e,t,eE.clamp(s,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.log(e)/Math.log(2))),random:(e,t)=>Math.random()*(t-e)+e,smoothstep:(e,t,s)=>s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*(3-2*s),smootherstep:(e,t,s)=>s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*s*(s*(6*s-15)+10),roundUp:(e,t)=>0===t?e:Math.ceil(e/t)*t,between(e,t,s,i){let r=Math.min(t,s),a=Math.max(t,s);return i?e>=r&&e<=a:e>r&&e<a}};class eA{constructor(e=0,t=0,s=0,i=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=s,this.a=i);}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,s,i=1){return this.r=e,this.g=t,this.b=s,this.a=i,this}lerp(e,t,s){return this.r=e.r+s*(t.r-e.r),this.g=e.g+s*(t.g-e.g),this.b=e.b+s*(t.b-e.b),this.a=e.a+s*(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;let s=parseInt(e.replace("#","0x"),16);return e.length>7?t=eE.intToBytes32(s):(t=eE.intToBytes24(s))[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:s,g:i,b:r,a}=this;if(t||s>1||i>1||r>1)return `${s.toFixed(3)}, ${i.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let n=`#${(0x1000000+(Math.round(255*s)<<16)+(Math.round(255*i)<<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,s=true){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,s&&(e[t+3]=this.a),e}static{this.BLACK=Object.freeze(new eA(0,0,0,1));}static{this.BLUE=Object.freeze(new eA(0,0,1,1));}static{this.CYAN=Object.freeze(new eA(0,1,1,1));}static{this.GRAY=Object.freeze(new eA(.5,.5,.5,1));}static{this.GREEN=Object.freeze(new eA(0,1,0,1));}static{this.MAGENTA=Object.freeze(new eA(1,0,1,1));}static{this.RED=Object.freeze(new eA(1,0,0,1));}static{this.WHITE=Object.freeze(new eA(1,1,1,1));}static{this.YELLOW=Object.freeze(new eA(1,1,0,1));}}class ew{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 s;(t||e<this._left||e>=this._right)&&this._reset(e);let i=this._curve.type;if(i===eb)s=this._p0;else {let t=0===this._recip?0:(e-this._left)*this._recip;s=i===eS?eE.lerp(this._p0,this._p1,t):i===ex?eE.lerp(this._p0,this._p1,t*t*(3-2*t)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,t);}return s}_reset(e){let t=this._curve.keys,s=t.length;if(s){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[s-1][0])this._left=t[s-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=t[s-1][1],this._m0=this._m1=0;else {let s=0;for(;e>=t[s+1][0];)s++;this._left=t[s][0],this._right=t[s+1][0];let i=1/(this._right-this._left);this._recip=isFinite(i)?i:0,this._p0=t[s][1],this._p1=t[s+1][1],this._curve.type===eT&&this._calcTangents(t,s);}}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 s,i;let r=e[t],a=e[t+1];if(s=0===t?[e[0][0]+(e[0][0]-e[1][0]),e[0][1]+(e[0][1]-e[1][1])]:e[t-1],i=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]-s[0]),t=2*(a[0]-r[0])/(i[0]-r[0]);this._m0=this._curve.tension*(isFinite(e)?e:0)*(a[1]-s[1]),this._m1=this._curve.tension*(isFinite(t)?t:0)*(i[1]-r[1]);}else {let e=(a[0]-r[0])/(r[0]-s[0]),t=(a[0]-r[0])/(i[0]-a[0]),n=r[1]+(s[1]-r[1])*(isFinite(e)?e:0),o=a[1]+(i[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,s,i,r){let a=r*r,n=r+r,o=1-r,l=o*o;return (1+n)*l*e+r*l*s+a*(3-n)*t+a*(r-1)*i}}class eC{constructor(e){if(this.keys=[],this.type=ex,this.tension=.5,this._eval=new ew(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 s=this.keys,i=s.length,r=0;for(;r<i&&!(s[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,s=t.length,i=2,r=null;for(let a=0;a<s;a++){let s=Math.abs(e-t[a][0]);if(i>=s)i=s,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)),s=1/(e-1);t[0]=this._eval.evaluate(0,true);for(let i=1;i<e;i++)t[i]=this._eval.evaluate(s*i);return t}quantizeClamped(e,t,s){let i=this.quantize(e);for(let e=0;e<i.length;++e)i[e]=Math.min(s,Math.max(t,i[e]));return i}}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 s=this.curves.length;t.length=s;for(let i=0;i<s;i++)t[i]=this.curves[i].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,s=new Float32Array(e*t),i=1/(e-1);for(let r=0;r<t;r++){let a=new ew(this.curves[r]);for(let n=0;n<e;n++)s[n*t+r]=a.evaluate(i*n);}return s}quantizeClamped(e,t,s){let i=this.quantize(e);for(let e=0;e<i.length;++e)i[e]=Math.min(s,Math.max(t,i[e]));return i}}let eM=new Float32Array(1),eI=new Int32Array(eM.buffer);class eR{static float2Half(e){eM[0]=e;let t=eI[0],s=t>>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?s:r>142?(s|=31744,s|=+(255!==r)&&8388607&t):r<113?(i|=2048,s|=(i>>114-r)+(i>>113-r&1)):(s|=r-112<<10|i>>1,s+=1&i)}static float2RGBA8(e,t){eM[0]=e;let s=eI[0];t.r=(s>>24&255)/255,t.g=(s>>16&255)/255,t.b=(s>>8&255)/255,t.a=(255&s)/255;}}class eL{static concentric(e,t){let s=[];s.push(0,0);let i=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/i)),n=2*Math.PI/a;for(let e=0;e<a;e++){let t=e*n,i=r*Math.cos(t),a=r*Math.sin(t);s.push(i,a);}}return s}}class eD{constructor(e=0,t=0,s=0){3===e.length?(this.x=e[0],this.y=e[1],this.z=e[2]):(this.x=e,this.y=t,this.z=s);}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 s=e.x,i=e.y,r=e.z,a=t.x,n=t.y,o=t.z;return this.x=i*o-n*r,this.y=r*a-o*s,this.z=s*n-a*i,this}distance(e){let t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return Math.sqrt(t*t+s*s+i*i)}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(t.y-e.y),this.z=e.z+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s,this.z=e.z*s;}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,s){return this.x=e,this.y=t,this.z=s,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 eD(0,0,0));}static{this.HALF=Object.freeze(new eD(.5,.5,.5));}static{this.ONE=Object.freeze(new eD(1,1,1));}static{this.UP=Object.freeze(new eD(0,1,0));}static{this.DOWN=Object.freeze(new eD(0,-1,0));}static{this.RIGHT=Object.freeze(new eD(1,0,0));}static{this.LEFT=Object.freeze(new eD(-1,0,0));}static{this.FORWARD=Object.freeze(new eD(0,0,-1));}static{this.BACK=Object.freeze(new eD(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,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[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 eD){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eD){return e.set(this.data[3],this.data[4],this.data[5])}getZ(e=new eD){return e.set(this.data[6],this.data[7],this.data[8])}equals(e){let t=this.data,s=e.data;return t[0]===s[0]&&t[1]===s[1]&&t[2]===s[2]&&t[3]===s[3]&&t[4]===s[4]&&t[5]===s[5]&&t[6]===s[6]&&t[7]===s[7]&&t[8]===s[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,s=this.data;if(t===s){let e;e=t[1],s[1]=t[3],s[3]=e,e=t[2],s[2]=t[6],s[6]=e,e=t[5],s[5]=t[7],s[7]=e;}else s[0]=t[0],s[1]=t[3],s[2]=t[6],s[3]=t[1],s[4]=t[4],s[5]=t[7],s[6]=t[2],s[7]=t[5],s[8]=t[8];return this}setFromMat4(e){let t=e.data,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[4],s[4]=t[5],s[5]=t[6],s[6]=t[8],s[7]=t[9],s[8]=t[10],this}setFromQuat(e){let t=e.x,s=e.y,i=e.z,r=e.w,a=t+t,n=s+s,o=i+i,l=t*a,h=t*n,c=t*o,d=s*n,u=s*o,p=i*o,f=r*a,m=r*n,_=r*o,g=this.data;return g[0]=1-(d+p),g[1]=h+_,g[2]=c-m,g[3]=h-_,g[4]=1-(l+p),g[5]=u+f,g[6]=c+m,g[7]=u-f,g[8]=1-(l+d),this}invertMat4(e){let t=e.data,s=t[0],i=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,p=h*a-n*l,f=s*d+i*u+r*p;if(0===f)this.setIdentity();else {let e=1/f,t=this.data;t[0]=d*e,t[1]=(-c*i+r*h)*e,t[2]=(o*i-r*n)*e,t[3]=u*e,t[4]=(c*s-r*l)*e,t[5]=(-o*s+r*a)*e,t[6]=p*e,t[7]=(-h*s+i*l)*e,t[8]=(n*s-i*a)*e;}return this}transformVector(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[3]+a*s[6],t.y=i*s[1]+r*s[4]+a*s[7],t.z=i*s[2]+r*s[5]+a*s[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,s=this.y-e.y;return Math.sqrt(t*t+s*s)}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s;}return this}rotate(e){let t=Math.atan2(this.x,this.y)+e*eE.DEG_TO_RAD,s=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(t)*s,this.y=Math.cos(t)*s,this}angle(){return Math.atan2(this.x,this.y)*eE.RAD_TO_DEG}angleTo(e){return Math.atan2(this.x*e.y+this.y*e.x,this.x*e.x+this.y*e.y)*eE.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,s=0,i=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=s,this.w=i);}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(t.y-e.y),this.z=e.z+s*(t.z-e.z),this.w=e.w+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s,this.z=e.z*s,this.w=e.w*s;}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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,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 eD,ek=new eD,ez=new eD,eV=new eD;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,s,i,r){r?(e.x=i*Math.tan(t*Math.PI/360),e.y=e.x/s):(e.y=i*Math.tan(t*Math.PI/360),e.x=e.y*s);}add2(e,t){let s=e.data,i=t.data,r=this.data;return r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],r[3]=s[3]+i[3],r[4]=s[4]+i[4],r[5]=s[5]+i[5],r[6]=s[6]+i[6],r[7]=s[7]+i[7],r[8]=s[8]+i[8],r[9]=s[9]+i[9],r[10]=s[10]+i[10],r[11]=s[11]+i[11],r[12]=s[12]+i[12],r[13]=s[13]+i[13],r[14]=s[14]+i[14],r[15]=s[15]+i[15],this}add(e){return this.add2(this,e)}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[8]=t[8],s[9]=t[9],s[10]=t[10],s[11]=t[11],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15],this}equals(e){let t=this.data,s=e.data;return t[0]===s[0]&&t[1]===s[1]&&t[2]===s[2]&&t[3]===s[3]&&t[4]===s[4]&&t[5]===s[5]&&t[6]===s[6]&&t[7]===s[7]&&t[8]===s[8]&&t[9]===s[9]&&t[10]===s[10]&&t[11]===s[11]&&t[12]===s[12]&&t[13]===s[13]&&t[14]===s[14]&&t[15]===s[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 s,i,r,a;let n=e.data,o=t.data,l=this.data,h=n[0],c=n[1],d=n[2],u=n[3],p=n[4],f=n[5],m=n[6],_=n[7],g=n[8],y=n[9],v=n[10],S=n[11],x=n[12],T=n[13],b=n[14],E=n[15];return s=o[0],i=o[1],r=o[2],a=o[3],l[0]=h*s+p*i+g*r+x*a,l[1]=c*s+f*i+y*r+T*a,l[2]=d*s+m*i+v*r+b*a,l[3]=u*s+_*i+S*r+E*a,s=o[4],i=o[5],r=o[6],a=o[7],l[4]=h*s+p*i+g*r+x*a,l[5]=c*s+f*i+y*r+T*a,l[6]=d*s+m*i+v*r+b*a,l[7]=u*s+_*i+S*r+E*a,s=o[8],i=o[9],r=o[10],a=o[11],l[8]=h*s+p*i+g*r+x*a,l[9]=c*s+f*i+y*r+T*a,l[10]=d*s+m*i+v*r+b*a,l[11]=u*s+_*i+S*r+E*a,s=o[12],i=o[13],r=o[14],a=o[15],l[12]=h*s+p*i+g*r+x*a,l[13]=c*s+f*i+y*r+T*a,l[14]=d*s+m*i+v*r+b*a,l[15]=u*s+_*i+S*r+E*a,this}mulAffine2(e,t){let s,i,r;let a=e.data,n=t.data,o=this.data,l=a[0],h=a[1],c=a[2],d=a[4],u=a[5],p=a[6],f=a[8],m=a[9],_=a[10],g=a[12],y=a[13],v=a[14];return s=n[0],i=n[1],r=n[2],o[0]=l*s+d*i+f*r,o[1]=h*s+u*i+m*r,o[2]=c*s+p*i+_*r,o[3]=0,s=n[4],i=n[5],r=n[6],o[4]=l*s+d*i+f*r,o[5]=h*s+u*i+m*r,o[6]=c*s+p*i+_*r,o[7]=0,s=n[8],i=n[9],r=n[10],o[8]=l*s+d*i+f*r,o[9]=h*s+u*i+m*r,o[10]=c*s+p*i+_*r,o[11]=0,s=n[12],i=n[13],r=n[14],o[12]=l*s+d*i+f*r+g,o[13]=h*s+u*i+m*r+y,o[14]=c*s+p*i+_*r+v,o[15]=1,this}mul(e){return this.mul2(this,e)}transformPoint(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[4]+a*s[8]+s[12],t.y=i*s[1]+r*s[5]+a*s[9]+s[13],t.z=i*s[2]+r*s[6]+a*s[10]+s[14],t}transformVector(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[4]+a*s[8],t.y=i*s[1]+r*s[5]+a*s[9],t.z=i*s[2]+r*s[6]+a*s[10],t}transformVec4(e,t=new eN){let s=this.data,{x:i,y:r,z:a,w:n}=e;return t.x=i*s[0]+r*s[4]+a*s[8]+n*s[12],t.y=i*s[1]+r*s[5]+a*s[9]+n*s[13],t.z=i*s[2]+r*s[6]+a*s[10]+n*s[14],t.w=i*s[3]+r*s[7]+a*s[11]+n*s[15],t}setLookAt(e,t,s){ez.sub2(e,t).normalize(),ek.copy(s).normalize(),eU.cross(ek,ez).normalize(),ek.cross(ez,eU);let i=this.data;return i[0]=eU.x,i[1]=eU.y,i[2]=eU.z,i[3]=0,i[4]=ek.x,i[5]=ek.y,i[6]=ek.z,i[7]=0,i[8]=ez.x,i[9]=ez.y,i[10]=ez.z,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}setFrustum(e,t,s,i,r,a){let n=2*r,o=t-e,l=i-s,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]=(i+s)/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,s,i,r){return eG._getPerspectiveHalfSize(eB,e,t,s,r),this.setFrustum(-eB.x,eB.x,-eB.y,eB.y,s,i)}setOrtho(e,t,s,i,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/(i-s),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]=-(i+s)/(i-s),n[14]=-(a+r)/(a-r),n[15]=1,this}setFromAxisAngle(e,t){t*=eE.DEG_TO_RAD;let{x:s,y:i,z:r}=e,a=Math.cos(t),n=Math.sin(t),o=1-a,l=o*s,h=o*i,c=this.data;return c[0]=l*s+a,c[1]=l*i+n*r,c[2]=l*r-n*i,c[3]=0,c[4]=l*i-n*r,c[5]=h*i+a,c[6]=h*r+n*s,c[7]=0,c[8]=l*r+n*i,c[9]=h*r-s*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,s){let i=this.data;return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=e,i[13]=t,i[14]=s,i[15]=1,this}setScale(e,t,s){let i=this.data;return i[0]=e,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}setViewport(e,t,s,i){let r=this.data;return r[0]=.5*s,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=.5*i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=e+.5*s,r[13]=t+.5*i,r[14]=.5,r[15]=1,this}setReflection(e,t){let s=e.x,i=e.y,r=e.z,a=this.data;return a[0]=1-2*s*s,a[1]=-2*s*i,a[2]=-2*s*r,a[3]=0,a[4]=-2*s*i,a[5]=1-2*i*i,a[6]=-2*i*r,a[7]=0,a[8]=-2*s*r,a[9]=-2*i*r,a[10]=1-2*r*r,a[11]=0,a[12]=-2*s*t,a[13]=-2*i*t,a[14]=-2*r*t,a[15]=1,this}invert(e=this){let t=e.data,s=t[0],i=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],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=s*o-i*n,v=s*l-r*n,S=s*h-a*n,x=i*l-r*o,T=i*h-a*o,b=r*h-a*l,E=c*m-d*f,A=c*_-u*f,w=c*g-p*f,C=d*_-u*m,P=d*g-p*m,M=u*g-p*_,I=y*M-v*P+S*C+x*w-T*A+b*E;if(0===I)this.setIdentity();else {let e=1/I,t=this.data;t[0]=(o*M-l*P+h*C)*e,t[1]=(-i*M+r*P-a*C)*e,t[2]=(m*b-_*T+g*x)*e,t[3]=(-d*b+u*T-p*x)*e,t[4]=(-n*M+l*w-h*A)*e,t[5]=(s*M-r*w+a*A)*e,t[6]=(-f*b+_*S-g*v)*e,t[7]=(c*b-u*S+p*v)*e,t[8]=(n*P-o*w+h*E)*e,t[9]=(-s*P+i*w-a*E)*e,t[10]=(f*T-m*S+g*y)*e,t[11]=(-c*T+d*S-p*y)*e,t[12]=(-n*C+o*A-l*E)*e,t[13]=(s*C-i*A+r*E)*e,t[14]=(-f*x+m*v-_*y)*e,t[15]=(c*x-d*v+u*y)*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,s){let i=t.x,r=t.y,a=t.z,n=t.w,o=s.x,l=s.y,h=s.z,c=i+i,d=r+r,u=a+a,p=i*c,f=i*d,m=i*u,_=r*d,g=r*u,y=a*u,v=n*c,S=n*d,x=n*u,T=this.data;return T[0]=(1-(_+y))*o,T[1]=(f+x)*o,T[2]=(m-S)*o,T[3]=0,T[4]=(f-x)*l,T[5]=(1-(p+y))*l,T[6]=(g+v)*l,T[7]=0,T[8]=(m+S)*h,T[9]=(g-v)*h,T[10]=(1-(p+_))*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,s=this.data;if(t===s){let e;e=t[1],s[1]=t[4],s[4]=e,e=t[2],s[2]=t[8],s[8]=e,e=t[3],s[3]=t[12],s[12]=e,e=t[6],s[6]=t[9],s[9]=e,e=t[7],s[7]=t[13],s[13]=e,e=t[11],s[11]=t[14],s[14]=e;}else s[0]=t[0],s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=t[1],s[5]=t[5],s[6]=t[9],s[7]=t[13],s[8]=t[2],s[9]=t[6],s[10]=t[10],s[11]=t[14],s[12]=t[3],s[13]=t[7],s[14]=t[11],s[15]=t[15];return this}getTranslation(e=new eD){return e.set(this.data[12],this.data[13],this.data[14])}getX(e=new eD){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eD){return e.set(this.data[4],this.data[5],this.data[6])}getZ(e=new eD){return e.set(this.data[8],this.data[9],this.data[10])}getScale(e=new eD){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,s){e*=eE.DEG_TO_RAD,t*=eE.DEG_TO_RAD,s*=eE.DEG_TO_RAD;let i=Math.sin(-e),r=Math.cos(-e),a=Math.sin(-t),n=Math.cos(-t),o=Math.sin(-s),l=Math.cos(-s),h=this.data;return h[0]=n*l,h[1]=-n*o,h[2]=a,h[3]=0,h[4]=r*o+l*i*a,h[5]=r*l-i*a*o,h[6]=-n*i,h[7]=0,h[8]=i*o-r*l*a,h[9]=l*i+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 eD){let t,s;this.getScale(eV);let i=eV.x,r=eV.y,a=eV.z;if(0===i||0===r||0===a)return e.set(0,0,0);let n=this.data,o=Math.asin(-n[2]/i),l=.5*Math.PI;return o<l?o>-l?(t=Math.atan2(n[6]/r,n[10]/a),s=Math.atan2(n[1]/i,n[0]/i)):(s=0,t=-Math.atan2(n[4]/r,n[5]/r)):(s=0,t=Math.atan2(n[4]/r,n[5]/r)),e.set(t,o,s).mulScalar(eE.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,s=0,i=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=s,this.w=i);}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}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),s=Math.sin(t/2);return 0!==s?(e.x=this.x/s,e.y=this.y/s,e.z=this.z/s,(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*eE.RAD_TO_DEG}getEulerAngles(e=new eD){let t,s,i;let 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),s=-Math.PI/2,i=0):l>=.99999?(t=2*Math.atan2(r,o),s=Math.PI/2,i=0):(t=Math.atan2(2*(o*r+a*n),1-2*(r*r+a*a)),s=Math.asin(l),i=Math.atan2(2*(o*n+r*a),1-2*(a*a+n*n))),e.set(t,s,i).mulScalar(eE.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}mul(e){let t=this.x,s=this.y,i=this.z,r=this.w,a=e.x,n=e.y,o=e.z,l=e.w;return this.x=r*a+t*l+s*o-i*n,this.y=r*n+s*l+i*a-t*o,this.z=r*o+i*l+t*n-s*a,this.w=r*l-t*a-s*n-i*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 s=e.x,i=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+s*h+i*l-r*o,this.y=a*o+i*h+r*n-s*l,this.z=a*l+r*h+s*o-i*n,this.w=a*h-s*n-i*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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setFromAxisAngle(e,t){let s=Math.sin(t*=.5*eE.DEG_TO_RAD),i=Math.cos(t);return this.x=s*e.x,this.y=s*e.y,this.z=s*e.z,this.w=i,this}setFromEulerAngles(e,t,s){if(e instanceof eD){let i=e;e=i.x,t=i.y,s=i.z;}let i=.5*eE.DEG_TO_RAD;e*=i,t*=i,s*=i;let r=Math.sin(e),a=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(s),h=Math.cos(s);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;let s=e.data,i=s[0],r=s[1],a=s[2],n=s[4],o=s[5],l=s[6],h=s[8],c=s[9],d=s[10];return 0==(t=i*i+r*r+a*a)?this.set(0,0,0,1):(i*=t=1/Math.sqrt(t),r*=t,a*=t,0==(t=n*n+o*o+l*l))?this.set(0,0,0,1):(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?i>o?this.set(1+i-o-d,r+n,h+a,l-c):this.set(r+n,1-i+o-d,l+c,h-a):i<-o?this.set(h+a,l+c,1-i-o+d,r-n):this.set(l-c,h-a,r-n,1+i+o+d),this.mulScalar(1/this.length()))}setFromDirections(e,t){let s=1+e.dot(t);return s<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=s),this.normalize()}slerp(e,t,s){let i=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+i*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=i,this.y=r,this.z=a,this;let u=Math.acos(d),p=Math.sqrt(1-d*d);if(.001>Math.abs(p))return this.w=.5*n+.5*c,this.x=.5*i+.5*o,this.y=.5*r+.5*l,this.z=.5*a+.5*h,this;let f=Math.sin((1-s)*u)/p,m=Math.sin(s*u)/p;return this.w=n*f+c*m,this.x=i*f+o*m,this.y=r*f+l*m,this.z=a*f+h*m,this}transformVector(e,t=new eD){let s=e.x,i=e.y,r=e.z,a=this.x,n=this.y,o=this.z,l=this.w,h=l*s+n*r-o*i,c=l*i+o*s-a*r,d=l*r+a*i-n*s,u=-a*s-n*i-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}toString(){return `[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}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 eD,eX=new eD,e$=new eD,eY=new eD,eq=new eD;class ej{constructor(e,t){this.center=new eD,this.halfExtents=new eD(.5,.5,.5),this._min=new eD,this._max=new eD,e&&this.center.copy(e),t&&this.halfExtents.copy(t);}add(e){let t=this.center,s=t.x,i=t.y,r=t.z,a=this.halfExtents,n=a.x,o=a.y,l=a.z,h=s-n,c=s+n,d=i-o,u=i+o,p=r-l,f=r+l,m=e.center,_=m.x,g=m.y,y=m.z,v=e.halfExtents,S=v.x,x=v.y,T=v.z,b=_-S,E=_+S,A=g-x,w=g+x,C=y-T,P=y+T;b<h&&(h=b),E>c&&(c=E),A<d&&(d=A),w>u&&(u=w),C<p&&(p=C),P>f&&(f=P),t.x=(h+c)*.5,t.y=(d+u)*.5,t.z=(p+f)*.5,a.x=(c-h)*.5,a.y=(u-d)*.5,a.z=(f-p)*.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(),s=this.getMin(),i=e.getMax(),r=e.getMin();return s.x<=i.x&&t.x>=r.x&&s.y<=i.y&&t.y>=r.y&&s.z<=i.z&&t.z>=r.z}_intersectsRay(e,t){let s=eW.copy(this.getMin()).sub(e.origin),i=eX.copy(this.getMax()).sub(e.origin),r=e.direction;0===r.x?(s.x=s.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.x/=r.x,i.x/=r.x),0===r.y?(s.y=s.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.y/=r.y,i.y/=r.y),0===r.z?(s.z=s.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.z/=r.z,i.z/=r.z);let a=e$.set(Math.min(s.x,i.x),Math.min(s.y,i.y),Math.min(s.z,i.z)),n=eY.set(Math.max(s.x,i.x),Math.max(s.y,i.y),Math.max(s.z,i.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),eY.set(Math.abs(eW.x),Math.abs(eW.y),Math.abs(eW.z)),e$.mul2(eW,t),(!(eY.x>this.halfExtents.x)||!(e$.x>=0))&&(!(eY.y>this.halfExtents.y)||!(e$.y>=0))&&(!(eY.z>this.halfExtents.z)||!(e$.z>=0))&&(eq.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*eq.z+this.halfExtents.z*eq.y)&&!(eX.y>this.halfExtents.x*eq.z+this.halfExtents.z*eq.x)&&!(eX.z>this.halfExtents.x*eq.y+this.halfExtents.y*eq.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(),s=this.getMax();return !(e.x<t.x)&&!(e.x>s.x)&&!(e.y<t.y)&&!(e.y>s.y)&&!(e.z<t.z)&&!(e.z>s.z)}setFromTransformedAabb(e,t,s=false){let i=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],p=a[6],f=a[10];if(s){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+p*p+f*f)>0){let t=1/Math.sqrt(e);u*=t,p*=t,f*=t;}}this.center.set(a[12]+n*i.x+o*i.y+l*i.z,a[13]+h*i.x+c*i.y+d*i.z,a[14]+u*i.x+p*i.y+f*i.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(p)*r.y+Math.abs(f)*r.z);}static computeMinMax(e,t,s,i=e.length/3){if(i>0){let r=e[0],a=e[1],n=e[2],o=r,l=a,h=n,c=3*i;for(let t=3;t<c;t+=3){let s=e[t],i=e[t+1],c=e[t+2];s<r&&(r=s),i<a&&(a=i),c<n&&(n=c),s>o&&(o=s),i>l&&(l=i),c>h&&(h=c);}t.set(r,a,n),s.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(),s=this.getMax(),i=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=s[r[a]],c=0;o<l&&(n+=(c=l-o)*c),o>h&&(n+=(c=o-h)*c),i+=n;}return i}_expand(e,t){eW.add2(this.getMin(),e),eX.add2(this.getMax(),t),this.setMinMax(eW,eX);}}let eK=new eD,eZ=new eD;class eQ{constructor(e=new eD,t=.5){this.center=e,this.radius=t;}containsPoint(e){let t=eK.sub2(e,this.center).lengthSq(),s=this.radius;return t<s*s}intersectsRay(e,t){let s=eK.copy(e.origin).sub(this.center),i=s.dot(eZ.copy(e.direction).normalize()),r=s.dot(s)-this.radius*this.radius;if(r>0&&i>0)return false;let a=i*i-r;if(a<0)return false;let n=Math.abs(-i-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=eD.UP,t=0){this.normal=new eD,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,s){let i=this.distance,r=this.normal.dot(e)+i,a=r/(r-(this.normal.dot(t)+i)),n=a>=0&&a<=1;return n&&s&&s.lerp(e,t,a),n}intersectsRay(e,t){let s=this.normal.dot(e.direction);if(0===s)return false;let i=-(this.normal.dot(e.origin)+this.distance)/s;return i>=0&&t&&t.copy(e.direction).mulScalar(i).add(e.origin),i>=0}normalize(){let e=1/this.normal.length();return this.normal.mulScalar(e),this.distance*=e,this}set(e,t,s,i){return this.normal.set(e,t,s),this.distance=i,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,s,i,r,a,n,o,l,h,c,d,u,p,f,m,_]=e.data,g=this.planes;g[0].set(r-t,l-a,u-h,_-p).normalize(),g[1].set(r+t,l+a,u+h,_+p).normalize(),g[2].set(r+s,l+n,u+c,_+f).normalize(),g[3].set(r-s,l-n,u-c,_-f).normalize(),g[4].set(r-i,l-o,u-d,_-m).normalize(),g[5].set(r+i,l+o,u+d,_+m).normalize();}containsPoint(e){for(let t=0;t<6;t++){let{normal:s,distance:i}=this.planes[t];if(s.dot(e)+i<=0)return false}return true}containsSphere(e){let{center:t,radius:s}=e,i=0;for(let e=0;e<6;e++){let{normal:r,distance:a}=this.planes[e],n=r.dot(t)+a;if(n<=-s)return 0;n>s&&i++;}return 6===i?2:1}}class e1{constructor(e,t){this.origin=new eD,this.direction=eD.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 eD,e4=new eQ,e5=new eG;class e8{constructor(e=new eG,t){this.halfExtents=new eD(.5,.5,.5),t&&this.halfExtents.copy(t),this._modelTransform=e.clone().invert(),this._worldTransform=e.clone(),this._aabb=new ej(new eD,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 eD,e9=new eD,e7=new eD,te=new eD,tt=new eD;class ts{constructor(e=eD.ZERO,t=eD.ZERO,s=eD.ZERO){this.v0=new eD,this.v1=new eD,this.v2=new eD,this.set(e,t,s);}set(e,t,s){return this.v0.copy(e),this.v1.copy(t),this.v2.copy(s),this}intersectsRay(e,t){e6.sub2(this.v1,this.v0),e9.sub2(this.v2,this.v0),e7.cross(e.direction,e9);let s=e6.dot(e7);if(s>-1e-6&&s<1e-6)return false;let i=1/s;te.sub2(e.origin,this.v0);let r=i*te.dot(e7);if(r<0||r>1)return false;tt.cross(te,e6);let a=i*e.direction.dot(tt);if(a<0||r+a>1)return false;let n=i*e9.dot(tt);return n>1e-6&&(t instanceof eD&&t.copy(e.direction).mulScalar(n).add(e.origin),true)}toString(){return `[${this.v0.toString()}, ${this.v1.toString()}, ${this.v2.toString()}]`}}let ti="linear",tr="inverse",ta="exponential",tn=0,to=1,tl=2,th=0,tc=1,td=2,tu=3,tp=4,tf=5,tm=6,t_=7,tg=8,ty=9,tv=10,tS=11,tx=12,tT=0,tb=1,tE=2,tA=3,tw=4,tC=1,tP=2,tM=4,tI=8,tR=16,tL=32,tD=64,tO=128,tF=256,tN=0,tB=1,tU=2,tk=3,tz=1,tV=2,tG=4,tH=0,tW=1,tX=2,t$=3,tY=4,tq=5,tj=0,tK=1,tZ=2,tQ=3,tJ=0,t0=1,t1=2,t2=3,t3=4,t4=5,t5=0,t8=1,t6=2,t9=3,t7=4,se=5,st=6,ss=7,si=0,sr=1,sa=2,sn=0,so=1,sl=2,sh=3,sc=4,sd=5,su=6,sp=7,sf=8,sm=9,s_=10,sg=11,sy=12,sv=13,sS=14,sx=15,sT=16,sb=17,sE=18,sA=19,sw=20,sC=21,sP=22,sM=23,sI=24,sR=25,sL=26,sD=27,sO=28,sF=29,sN=30,sB=31,sU=32,sk=33,sz=34,sV=35,sG=36,sH=37,sW=38,sX=39,s$=40,sY=41,sq=42,sj=43,sK=44,sZ=45,sQ=46,sJ=47,s0=48,s1=49,s2=50,s3=51,s4=52,s5=53,s8=54,s6=55,s9=56,s7=61,ie=62,it=63,is=64,ii=65,ir=66,ia=67,io=68,il=69,ih=new Map([[sn,{name:"A8",size:1,ldr:true}],[s4,{name:"R8",size:1,ldr:true}],[so,{name:"L8",size:1,ldr:true}],[sl,{name:"LA8",size:2,ldr:true}],[s5,{name:"RG8",size:2,ldr:true}],[sh,{name:"RGB565",size:2,ldr:true}],[sc,{name:"RGBA5551",size:2,ldr:true}],[sd,{name:"RGBA4",size:2,ldr:true}],[su,{name:"RGB8",size:4,ldr:true}],[sp,{name:"RGBA8",size:4,ldr:true,srgbFormat:sw}],[s2,{name:"R16F",size:2}],[s3,{name:"RG16F",size:4}],[sg,{name:"RGB16F",size:8}],[sy,{name:"RGBA16F",size:8}],[sv,{name:"RGB32F",size:16}],[sS,{name:"RGBA32F",size:16}],[sx,{name:"R32F",size:4}],[sT,{name:"DEPTH",size:4}],[il,{name:"DEPTH16",size:2}],[sb,{name:"DEPTHSTENCIL",size:4}],[sE,{name:"111110F",size:4}],[sA,{name:"SRGB8",size:4,ldr:true,srgb:true}],[sw,{name:"SRGBA8",size:4,ldr:true,srgb:true}],[sB,{name:"BGRA8",size:4,ldr:true}],[is,{name:"SBGRA8",size:4,ldr:true,srgb:true}],[sf,{name:"DXT1",blockSize:8,ldr:true,srgbFormat:s8}],[sm,{name:"DXT3",blockSize:16,ldr:true,srgbFormat:s6}],[s_,{name:"DXT5",blockSize:16,ldr:true,srgbFormat:s9}],[sC,{name:"ETC1",blockSize:8,ldr:true}],[sP,{name:"ETC2_RGB",blockSize:8,ldr:true,srgbFormat:s7}],[sM,{name:"ETC2_RGBA",blockSize:16,ldr:true,srgbFormat:ie}],[sI,{name:"PVRTC_2BPP_RGB_1",ldr:true,blockSize:8}],[sR,{name:"PVRTC_2BPP_RGBA_1",ldr:true,blockSize:8}],[sL,{name:"PVRTC_4BPP_RGB_1",ldr:true,blockSize:8}],[sD,{name:"PVRTC_4BPP_RGBA_1",ldr:true,blockSize:8}],[sO,{name:"ASTC_4x4",blockSize:16,ldr:true,srgbFormat:it}],[sF,{name:"ATC_RGB",blockSize:8,ldr:true}],[sN,{name:"ATC_RGBA",blockSize:16,ldr:true}],[ii,{name:"BC6H_RGBF",blockSize:16}],[ir,{name:"BC6H_RGBUF",blockSize:16}],[ia,{name:"BC7_RGBA",blockSize:16,ldr:true,srgbFormat:io}],[s8,{name:"DXT1_SRGB",blockSize:8,ldr:true,srgb:true}],[s6,{name:"DXT3_SRGBA",blockSize:16,ldr:true,srgb:true}],[s9,{name:"DXT5_SRGBA",blockSize:16,ldr:true,srgb:true}],[s7,{name:"ETC2_SRGB",blockSize:8,ldr:true,srgb:true}],[ie,{name:"ETC2_SRGBA",blockSize:16,ldr:true,srgb:true}],[it,{name:"ASTC_4x4_SRGB",blockSize:16,ldr:true,srgb:true}],[io,{name:"BC7_SRGBA",blockSize:16,ldr:true,srgb:true}],[sU,{name:"R8I",size:1,isInt:true}],[sk,{name:"R8U",size:1,isInt:true}],[sz,{name:"R16I",size:2,isInt:true}],[sV,{name:"R16U",size:2,isInt:true}],[sG,{name:"R32I",size:4,isInt:true}],[sH,{name:"R32U",size:4,isInt:true}],[sW,{name:"RG8I",size:2,isInt:true}],[sX,{name:"RG8U",size:2,isInt:true}],[s$,{name:"RG16I",size:4,isInt:true}],[sY,{name:"RG16U",size:4,isInt:true}],[sq,{name:"RG32I",size:8,isInt:true}],[sj,{name:"RG32U",size:8,isInt:true}],[sK,{name:"RGBA8I",size:4,isInt:true}],[sZ,{name:"RGBA8U",size:4,isInt:true}],[sQ,{name:"RGBA16I",size:8,isInt:true}],[sJ,{name:"RGBA16U",size:8,isInt:true}],[s0,{name:"RGBA32I",size:16,isInt:true}],[s1,{name:"RGBA32U",size:16,isInt:true}]]),ic=e=>ih.get(e)?.blockSize!==void 0,id=e=>ih.get(e)?.srgb===true,iu=e=>ih.get(e)?.isInt===true,ip=e=>ih.get(e)?.srgbFormat||e,im=e=>{for(let[t,s]of ih)if(s.srgbFormat===e)return t;return e},i_=e=>{let t=ih.get(e);return !!(t?.ldr&&!t?.srgb)},ig=e=>{switch(e){case sx:case sv:case sS:return Float32Array;case sG:case sq:case s0:return Int32Array;case sH:case sj:case s1:return Uint32Array;case sz:case s$:case sQ:return Int16Array;case s5:case sV:case sY:case sJ:case sh:case sc:case sd:case s2:case s3:case sg:case sy:return Uint16Array;case sU:case sW:case sK:return Int8Array;default:return Uint8Array}},iy=0,iv=1,iS=2,ix=3,iT=4,ib=5,iE=6,iA="POSITION",iw="NORMAL",iC="TANGENT",iP="BLENDWEIGHT",iM="BLENDINDICES",iI="COLOR",iR="TEXCOORD",iL="TEXCOORD0",iD="TEXCOORD1",iO="TEXCOORD2",iF="TEXCOORD3",iN="TEXCOORD4",iB="TEXCOORD5",iU="TEXCOORD6",ik="TEXCOORD7",iz="ATTR0",iV="ATTR1",iG="ATTR2",iH="ATTR3",iW="ATTR4",iX="ATTR5",i$="ATTR6",iY="ATTR7",iq="ATTR8",ij="ATTR9",iK="ATTR10",iZ="ATTR11",iQ="ATTR12",iJ="ATTR13",i0="ATTR14",i1="ATTR15",i2=1,i3=0,i4=1,i5=2,i8=3,i6=4,i9=5,i7=6,re=7,rt=0,rs=1,ri=2,rr="default",ra="rgbm",rn="rgbe",ro="rgbp",rl="swizzleGGGR",rh=0,rc=1,rd=2,ru=3,rp="1d",rf="2d",rm="2d-array",r_="cube",rg="cube-array",ry="3d",rv=0,rS=1,rx=2,rT=3,rb=4,rE="none",rA="cube",rw="equirect",rC="octahedral",rP="glsl",rM="wgsl",rI=0,rR=1,rL=2,rD=3,rO=4,rF=5,rN=6,rB=7,rU=0,rk=1,rz=2,rV=3,rG=4,rH=5,rW=6,rX=7,r$=8,rY=9,rq=10,rj=11,rK=12,rZ=13,rQ=14,rJ=15,r0=16,r1=17,r2=18,r3=19,r4=20,r5=21,r8=22,r6=23,r9=24,r7=25,ae=26,at=27,as=28,ai=29,ar=30,aa=31,an=32,ao=33,al=34,ah=35,ac=36,ad=37,au=38,ap=39,af=40,am=41,a_=42,ag=43,ay=44,av=45,aS=46,ax=47,aT=48,ab=49,aE=["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"],aA=[["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>"]],aw=new Map;aA.forEach((e,t)=>{e.forEach(e=>aw.set(e,t));});let aC=new Uint8Array([rO,rO,rN,rN,rN,rN,rO,rO,rO,rO,rO,rO,rN,rN,rN,rO,rO,rN,rO,rO,rO,rN,rN,rN,rN,rO,rF,rF,rF,rF,rO,rF,rO,rO,rF,rO,rO,rF,rO,rO,rF,rO,rO,rF,rO,rF,rO,rF,rO,rF]),aP="webgl2",aM="webgpu",aI="null",aR=1,aL=2,aD=4,aO="ldr",aF="ldr_srgb",aN="hdr",aB=1,aU=2,ak=4,az=8,aV=16,aG=32,aH=64,aW=128,aX=255,a$=0,aY=1,aq=2,aj=["view","mesh","mesh_ub"],aK="default",aZ="_unused_float_uniform",aQ=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],aJ=[1,1,2,2,4,4,4,2],a0=["INT8","UINT8","INT16","UINT16","INT32","UINT32","FLOAT32","FLOAT16"],a1={Int8Array:rI,Uint8Array:rR,Int16Array:rL,Uint16Array:rD,Int32Array:rO,Uint32Array:rF,Float32Array:rN},a2=[Uint8Array,Uint16Array,Uint32Array],a3=[1,2,4],a4={};a4[iA]=0,a4[iw]=1,a4[iP]=2,a4[iM]=3,a4[iI]=4,a4[iL]=5,a4[iD]=6,a4[iO]=7,a4[iF]=8,a4[iN]=9,a4[iB]=10,a4[iU]=11,a4[ik]=12,a4[iC]=13,a4[iz]=0,a4[iV]=1,a4[iG]=2,a4[iH]=3,a4[iW]=4,a4[iX]=5,a4[i$]=6,a4[iY]=7,a4[iq]=8,a4[ij]=9,a4[iK]=10,a4[iZ]=11,a4[iQ]=12,a4[iJ]=13,a4[i0]=14,a4[i1]=15;let a5="1.51",a8="1.55",a6="1.56",a9="1.57",a7="1.58",ne="1.60",nt="1.62",ns="1.65",ni="1.70",nr="2.1",na="2.3",nn="2.5",no="2.6",nl="2.7",nh=0;class nc{constructor(e,t){this.slot=-1,this.scopeId=null,this.name=e,this.visibility=t;}}class nd extends nc{}class nu extends nc{constructor(e,t,s=false){super(e,t),this.format="",this.readOnly=s;}}class np extends nc{constructor(e,t,s=rf,i=rv,r=true,a=null){super(e,t),this.textureDimension=s,this.sampleType=i,this.hasSampler=r,this.samplerName=a??`${e}_sampler`;}}class nf extends nc{constructor(e,t=sp,s=rf,i=true,r=false){super(e,aD),this.format=t,this.textureDimension=s,this.write=i,this.read=r;}}class nm{constructor(e,t){this.uniformBufferFormats=[],this.textureFormats=[],this.storageTextureFormats=[],this.storageBufferFormats=[],this.id=nh++;let s=0;t.forEach(e=>{e.slot=s++,e instanceof np&&e.hasSampler&&s++,e instanceof nd?this.uniformBufferFormats.push(e):e instanceof np?this.textureFormats.push(e):e instanceof nf?this.storageTextureFormats.push(e):e instanceof nu&&this.storageBufferFormats.push(e);}),this.device=e;let i=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=i.resolve(e.name);}),this.storageTextureFormatsMap=new Map,this.storageTextureFormats.forEach((e,t)=>{this.storageTextureFormatsMap.set(e.name,t),e.scopeId=i.resolve(e.name);}),this.storageBufferFormatsMap=new Map,this.storageBufferFormats.forEach((e,t)=>{this.storageBufferFormatsMap.set(e.name,t),e.scopeId=i.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 n_{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 ng{static calcLevelDimension(e,t){return Math.max(e>>t,1)}static calcMipLevelsCount(e,t,s=1){return 1+Math.floor(Math.log2(Math.max(e,t,s)))}static calcLevelGpuSize(e,t,s,i){let r=ih.get(i),a=ih.get(i)?.size??0;if(a>0)return e*t*s*a;let n=r.blockSize??0,o=Math.floor((e+3)/4),l=Math.floor((t+3)/4),h=Math.floor((s+3)/4);return (i===sI||i===sR)&&(o=Math.max(Math.floor(o/2),1)),o*l*h*n}static calcGpuSize(e,t,s,i,r,a){let n=0;for(;n+=ng.calcLevelGpuSize(e,t,s,i),r&&(1!==e||1!==t||1!==s);)e=Math.max(e>>1,1),t=Math.max(t>>1,1),s=Math.max(s>>1,1);return n*(a?6:1)}}let ny=0;class nv{constructor(e,t={}){this._gpuSize=0,this.id=ny++,this._invalid=false,this._lockedLevel=-1,this._lockedMode=rt,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??sp,this._compressed=ic(this._format),this._integerFormat=iu(this._format),this._integerFormat&&(t.minFilter=tJ,t.magFilter=tJ),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??t4,this._magFilter=t.magFilter??t0,this._anisotropy=t.anisotropy??1,this._addressU=t.addressU??tn,this._addressV=t.addressV??tn,this._addressW=t.addressW??tn,this._compareOnRead=t.compareOnRead??false,this._compareFunc=t.compareFunc??t8,this._type=t.hasOwnProperty("type")?t.type:rr,this.projection=rE,this._cubemap?this.projection=rA:t.projection&&t.projection!==rA&&(this.projection=t.projection),this._levels=t.levels;let s=!!t.levels;this._levels||(this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null]),this.recreateImpl(s),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();}resize(e,t,s=1){let i=this.device;this.adjustVramSizeTracking(i._vram,-this._gpuSize),this.impl.destroy(i),this._width=Math.floor(e),this._height=Math.floor(t),this._depth=Math.floor(s),this._updateNumLevel(),this.impl=i.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?ng.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&&(iu(this._format)||(this._minFilter=e,this.propertyChanged(aB)));}get minFilter(){return this._minFilter}set magFilter(e){this._magFilter!==e&&(iu(this._format)||(this._magFilter=e,this.propertyChanged(aU)));}get magFilter(){return this._magFilter}set addressU(e){this._addressU!==e&&(this._addressU=e,this.propertyChanged(ak));}get addressU(){return this._addressU}set addressV(e){this._addressV!==e&&(this._addressV=e,this.propertyChanged(az));}get addressV(){return this._addressV}set addressW(e){this._volume&&e!==this._addressW&&(this._addressW=e,this.propertyChanged(aV));}get addressW(){return this._addressW}set compareOnRead(e){this._compareOnRead!==e&&(this._compareOnRead=e,this.propertyChanged(aG));}get compareOnRead(){return this._compareOnRead}set compareFunc(e){this._compareFunc!==e&&(this._compareFunc=e,this.propertyChanged(aH));}get compareFunc(){return this._compareFunc}set anisotropy(e){this._anisotropy!==e&&(this._anisotropy=e,this.propertyChanged(aW));}get anisotropy(){return this._anisotropy}set mipmaps(e){this._mipmaps!==e&&(this.device.isWebGPU||iu(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 ng.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!==id(this.format)){if(e){let e=ip(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}else {let e=im(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}}}get srgb(){return id(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 eE.powerOfTwo(this._width)&&eE.powerOfTwo(this._height)}get encoding(){switch(this.type){case ra:return "rgbm";case rn:return "rgbe";case ro:return "rgbp"}return i_(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(aX);}lock(e={}){e.level??=0,e.face??=0,e.mode??=ri,this._lockedMode=e.mode,this._lockedLevel=e.level;let t=this.cubemap?this._levels[e.face]:this._levels;if(null===t[e.level]){let s=Math.max(1,this._width>>e.level),i=Math.max(1,this._height>>e.level),r=Math.max(1,this._depth>>e.level),a=new ArrayBuffer(ng.calcLevelGpuSize(s,i,r,this._format));t[e.level]=new(ig(this._format))(a);}return t[e.level]}setSource(e,t=0){let s,i,r=false;if(this._cubemap){if(e[0]){s=e[0].width||0,i=e[0].height||0;for(let t=0;t<6;t++){let a=e[t];if(!a||a.width!==s||a.height!==i||!this.device._isBrowserInterface(a)){r=true;break}}}else r=true;if(!r)for(let s=0;s<6;s++)this._levels[t][s]!==e[s]&&(this._levelsUpdated[t][s]=true);}else this.device._isBrowserInterface(e)||(r=true),r||(e!==this._levels[t]&&(this._levelsUpdated[t]=true),e instanceof HTMLVideoElement?(s=e.videoWidth,i=e.videoHeight):(s=e.width,i=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=s,this._height=i),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===ri&&this.upload(),this._lockedLevel=-1,this._lockedMode=rt;}upload(){this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this.impl.uploadImmediate?.(this.device,this);}read(e,t,s,i,r={}){return this.impl.read?.(e,t,s,i,r)}}let nS={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 nx{destroy(){this.map.forEach(e=>{e.destroy();});}constructor(){this.map=new Map;}}let nT=new n_,nb=(e,t)=>{let s=nT.get(e,()=>new nx);if(!s.map.has(t)){let i=new nv(e,{name:`built-in-texture-${t}`,width:1,height:1,format:sp}),r=i.lock(),a=nS[t];r.set(a),i.unlock(),s.map.set(t,i);}return s.map.get(t)},nE=0;class nA{constructor(){this.offsets=[];}}class nw{constructor(e,t,s){this.renderVersionUpdated=-1,this.uniformBufferOffsets=[],this.id=nE++,this.device=e,this.format=t,this.dirty=true,this.impl=e.createBindGroupImpl(this),this.textures=[],this.storageTextures=[],this.storageBuffers=[],this.uniformBuffers=[],this.defaultUniformBuffer=s,s&&this.setUniformBuffer(aK,s);}destroy(){this.impl.destroy(),this.impl=null,this.format=null,this.defaultUniformBuffer=null;}setUniformBuffer(e,t){let s=this.format.bufferFormatsMap.get(e);this.uniformBuffers[s]!==t&&(this.uniformBuffers[s]=t,this.dirty=true);}setStorageBuffer(e,t){let s=this.format.storageBufferFormatsMap.get(e);this.storageBuffers[s]!==t&&(this.storageBuffers[s]=t,this.dirty=true);}setTexture(e,t){let s=this.format.textureFormatsMap.get(e);this.textures[s]!==t?(this.textures[s]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}setStorageTexture(e,t){let s=this.format.storageTextureFormatsMap.get(e);this.storageTextures[s]!==t?(this.storageTextures[s]=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:s}=this.format;for(let t=0;t<e.length;t++){let s=e[t],i=s.scopeId.value;i||("uSceneDepthMap"===s.name&&(i=nb(this.device,"white")),"uSceneColorMap"===s.name&&(i=nb(this.device,"pink")),i||(i=nb(this.device,"pink"))),this.setTexture(s.name,i);}for(let e=0;e<t.length;e++){let s=t[e],i=s.scopeId.value;this.setStorageTexture(s.name,i);}for(let e=0;e<s.length;e++){let t=s[e],i=t.scopeId.value;this.setStorageBuffer(t.name,i);}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 nC={set:(e,t,s,i=1)=>e&~(i<<s)|t<<s,get:(e,t,s=1)=>e>>t&s,all(e,t,s=1){let i=s<<t;return (e&i)===i},any:(e,t,s=1)=>(e&s<<t)!=0};class nP{constructor(e=false,t=tT,s=tc,i=th,r,a,n,o=true,l=true,h=true,c=true){this.target0=0,this.setColorBlend(t,s,i),this.setAlphaBlend(r??t,a??s,n??i),this.setColorWrite(o,l,h,c),this.blend=e;}set blend(e){this.target0=nC.set(this.target0,+!!e,26);}get blend(){return nC.all(this.target0,26)}setColorBlend(e,t,s){this.target0=nC.set(this.target0,e,0,7),this.target0=nC.set(this.target0,t,3,15),this.target0=nC.set(this.target0,s,7,15);}setAlphaBlend(e,t,s){this.target0=nC.set(this.target0,e,11,7),this.target0=nC.set(this.target0,t,14,15),this.target0=nC.set(this.target0,s,18,15);}setColorWrite(e,t,s,i){this.redWrite=e,this.greenWrite=t,this.blueWrite=s,this.alphaWrite=i;}get colorOp(){return nC.get(this.target0,0,7)}get colorSrcFactor(){return nC.get(this.target0,3,15)}get colorDstFactor(){return nC.get(this.target0,7,15)}get alphaOp(){return nC.get(this.target0,11,7)}get alphaSrcFactor(){return nC.get(this.target0,14,15)}get alphaDstFactor(){return nC.get(this.target0,18,15)}set redWrite(e){this.target0=nC.set(this.target0,+!!e,22);}get redWrite(){return nC.all(this.target0,22)}set greenWrite(e){this.target0=nC.set(this.target0,+!!e,23);}get greenWrite(){return nC.all(this.target0,23)}set blueWrite(e){this.target0=nC.set(this.target0,+!!e,24);}get blueWrite(){return nC.all(this.target0,24)}set alphaWrite(e){this.target0=nC.set(this.target0,+!!e,25);}get alphaWrite(){return nC.all(this.target0,25)}get allWrite(){return nC.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 nP);}static{this.NOWRITE=Object.freeze(new nP(void 0,void 0,void 0,void 0,void 0,void 0,void 0,false,false,false,false));}static{this.ALPHABLEND=Object.freeze(new nP(true,tT,tm,tg));}static{this.ADDBLEND=Object.freeze(new nP(true,tT,tc,tc));}}class nM{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 nI=new nM;class nR{constructor(e=t9,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?t9:ss,this.updateKey();}get test(){return this.func!==ss}set write(e){this.data=nC.set(this.data,+!!e,3),this.updateKey();}get write(){return nC.all(this.data,3)}set func(e){this.data=nC.set(this.data,e,0,7),this.updateKey();}get func(){return nC.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:s}=this,i=`${e}-${t}-${s}`;this.key=nI.get(i);}equals(e){return this.key===e.key}static{this.DEFAULT=Object.freeze(new nR);}static{this.NODEPTH=Object.freeze(new nR(ss,false));}static{this.WRITEDEPTH=Object.freeze(new nR(ss,true));}}class nL{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 nD=0;class nO{constructor(){nD++,this.version=new nL,this.version.globalId=nD;}increment(){this.version.revision++;}}class nF{constructor(e){this.name=e,this.value=null,this.versionObject=new nO;}toJSON(e){}setValue(e){this.value=e,this.versionObject.increment();}getValue(){return this.value}}class nN{constructor(e){this.name=e,this.variables=new Map;}resolve(e){return this.variables.has(e)||this.variables.set(e,new nF(e)),this.variables.get(e)}removeValue(e){for(let t in this.variables){let s=this.variables[t];s.value===e&&(s.value=null);}}}let nB=0;class nU{constructor(e,t,s,i){this.usage=tN,this.usage=i?.usage??tN,this.device=e,this.format=t,this.numVertices=s,this.id=nB++,this.impl=e.createVertexBufferImpl(this,t,i),this.numBytes=t.verticesByteSize?t.verticesByteSize:t.size*s,this.adjustVramSizeTracking(e._vram,this.numBytes);let r=i?.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 nk(e){if(null==e)return 0;let t=0;for(let s=0,i=e.length;s<i;s++)t=(t<<5)-t+e.charCodeAt(s)|0;return t}function nz(e){let t=0x811c9dc5;for(let s=0;s<e.length;s++)t^=e[s],t*=0x1000193;return t>>>0}let nV=new nM,nG=[2,4,8,12,16],nH=new n_;class nW{constructor(e,t,s){this.device=e,this._elements=[],this.hasUv0=false,this.hasUv1=false,this.hasColor=false,this.hasTangents=false,this.verticesByteSize=0,this.vertexCount=s,this.interleaved=void 0===s,this.instancing=false,this.size=t.reduce((e,t)=>e+4*Math.ceil(t.components*aJ[t.type]/4),0);let i=0,r;for(let e=0,a=t.length;e<a;e++){let a=t[e];r=a.components*aJ[a.type],s&&(i=eE.roundUp(i,r));let n=a.asInt??false,o=!n&&(a.normalize??false),l={name:a.semantic,offset:s?i:a.hasOwnProperty("offset")?a.offset:i,stride:s?r:a.hasOwnProperty("stride")?a.stride:this.size,dataType:a.type,numComponents:a.components,normalize:o,size:r,asInt:n};this._elements.push(l),s?i+=r*s:i+=4*Math.ceil(r/4),a.semantic===iL?this.hasUv0=true:a.semantic===iD?this.hasUv1=true:a.semantic===iI?this.hasColor=true:a.semantic===iC&&(this.hasTangents=true);}s&&(this.verticesByteSize=i),this._evaluateHash();}get elements(){return this._elements}static getDefaultInstancingFormat(e){return nH.get(e,()=>new nW(e,[{semantic:iQ,components:4,type:rN},{semantic:iJ,components:4,type:rN},{semantic:i0,components:4,type:rN},{semantic:i1,components:4,type:rN}]))}static isElementValid(e,t){let s=t.components*aJ[t.type];return !e.isWebGPU||!!nG.includes(s)}update(){this._evaluateHash();}_evaluateHash(){let e=[],t=[],s=this._elements.length;for(let i=0;i<s;i++){let{name:s,dataType:r,numComponents:a,normalize:n,offset:o,stride:l,size:h,asInt:c}=this._elements[i],d=s+r+a+n+c;e.push(d);let u=d+o+l+h;t.push(u);}e.sort();let i=e.join();this.batchingHash=nk(i),this.shaderProcessingHashString=i,this.renderingHashString=t.join("_"),this.renderingHash=nV.get(this.renderingHashString);}}let nX=new nM;class n${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??ss,this._ref=e.ref??0,this._readMask=e.readMask??255,this._writeMask=e.writeMask??255,this._fail=e.fail??i3,this._zfail=e.zfail??i3,this._zpass=e.zpass??i3,this._evalKey();}_evalKey(){let{_func:e,_ref:t,_fail:s,_zfail:i,_zpass:r,_readMask:a,_writeMask:n}=this,o=`${e},${t},${s},${i},${r},${a},${n}`;this._key=nX.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 n$);}}class nY extends eo{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.isHdr=false,this.maxColorAttachments=1,this.maxSamples=1,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 nP,this.depthState=new nR,this.stencilEnabled=false,this.stencilFront=new n$,this.stencilBack=new n$,this.defaultClearOptions={color:[0,0,0,1],depth:1,stencil:0,flags:tz|tV},this.clientRect={width:0,height:0},this._shadersDirty=false,this.capsDefines=new Map,this.canvas=e,"setAttribute"in e&&e.setAttribute("data-engine",`PlayCanvas ${z}`),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??=aO,this._maxPixelRatio=ee.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=iy;e<=iE;e++)this._primsPerFrame[e]=0;this._renderTargetCreationTime=0,this.scope=new nN("Device"),this.textureBias=this.scope.resolve("textureBias"),this.textureBias.setValue(0);}postInit(){let e=new nW(this,[{semantic:iA,components:2,type:rN}]),t=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.quadVertexBuffer=new nU(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","");}destroy(){this.fire("destroy"),this.quadVertexBuffer?.destroy(),this.quadVertexBuffer=null,this.dynamicBuffers?.destroy(),this.dynamicBuffers=null,this.gpuProfiler?.destroy(),this.gpuProfiler=null;}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.indexBuffer=null,this.vertexBuffers=[],this.shader=null,this.shaderValid=void 0,this.shaderAsyncCompile=false,this.renderTarget=null;}initializeRenderState(){this.blendState=new nP,this.depthState=new nR,this.cullMode=tK,this.vx=this.vy=this.vw=this.vh=0,this.sx=this.sy=this.sw=this.sh=0,this.blendColor=new eA(0,0,0,0);}setStencilState(e,t){}setBlendState(e){}setBlendColor(e,t,s,i){}setDepthState(e){}setCullMode(e){}setRenderTarget(e){this.renderTarget=e;}setIndexBuffer(e){this.indexBuffer=e;}setVertexBuffer(e){e&&this.vertexBuffers.push(e);}clearVertexBuffer(){this.vertexBuffers.length=0;}clearIndexBuffer(){this.indexBuffer=null;}getRenderTarget(){return this.renderTarget}initRenderTarget(e){e.initialized||(e.init(),this.targets.add(e));}_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 s=Math.min(this._maxPixelRatio,ee.browser?window.devicePixelRatio:1),i=Math.floor(e*s),r=Math.floor(t*s);(i!==this.canvas.width||r!==this.canvas.height)&&this.setResolution(i,r);}setResolution(e,t){this.canvas.width=e,this.canvas.height=t,this.fire(nY.EVENT_RESIZE,e,t);}updateClientRect(){if(ee.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(){}computeDispatch(e,t="Unnamed"){}getRenderableHdrFormat(e=[sE,sy,sS],t=true,s=1){for(let i=0;i<e.length;i++){let r=e[i];switch(r){case sE:if(this.textureRG11B10Renderable)return r;break;case sy:if(this.textureHalfFloatRenderable)return r;break;case sS:if(this.isWebGPU&&s>1)continue;if(this.textureFloatRenderable&&(!t||this.textureFloatFilterable))return r}}}validateAttributes(e,t,s){}}let nq=0;class nj{constructor(e={}){this.id=nq++;let t=e.colorBuffer?.device??e.colorBuffers?.[0].device??e.depthBuffer?.device??e.graphicsDevice;this._device=t;let{maxSamples:s}=this._device;if(this._samples=Math.min(e.samples??1,s),t.isWebGPU&&(this._samples=this._samples>1?s: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===sT||e===il?(this._depth=true,this._stencil=false):e===sb?(this._depth=true,this._stencil=true):(e===sx&&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.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.width!==e||this.height!==t){if(this.mipLevel>0)return;let s=this._device;this.destroyFrameBuffers(),s.renderTarget===this&&s.setRenderTarget(null),this._depthBuffer?.resize(e,t),this._colorBuffers?.forEach(s=>{s.resize(e,t);}),this.validateMrt(),this.impl=s.createRenderTargetImpl(this);}}validateMrt(){}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,s){if(!this._device){if(!e._device)return false;this._device=e._device;}return this._device.copyRenderTarget(e,this,t,s)}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(){let e=this._colorBuffer?.width||this._depthBuffer?.width||this._device.width;return this._mipLevel>0&&(e=ng.calcLevelDimension(e,this._mipLevel)),e}get height(){let e=this._colorBuffer?.height||this._depthBuffer?.height||this._device.height;return this._mipLevel>0&&(e=ng.calcLevelDimension(e,this._mipLevel)),e}isColorBufferSrgb(e=0){if(this.device.backBuffer===this)return id(this.device.backBufferFormat);let t=this.getColorBuffer(e);return !!t&&id(t.format)}}class nK{update(e){this.destroy();let t=e.device,s=this.createDescriptor(t,e);this.bindGroup=t.wgpu.createBindGroup(s);}destroy(){this.bindGroup=null;}createDescriptor(e,t){let s=[],i=t.format,r=t.format.uniformBufferFormats;t.uniformBuffers.forEach((e,t)=>{let i=r[t].slot,a=e.persistent?e.impl.buffer:e.allocation.gpuBuffer.buffer;s.push({binding:i,resource:{buffer:a,offset:0,size:e.format.byteSize}});});let a=t.format.textureFormats;t.textures.forEach((t,r)=>{let n=t.impl,o=i.textureFormats[r],l=a[r].slot,h=n.getView(e);if(s.push({binding:l,resource:h}),o.hasSampler){let t=n.getSampler(e,o.sampleType);s.push({binding:l+1,resource:t});}});let n=t.format.storageTextureFormats;t.storageTextures.forEach((t,i)=>{let r=t.impl,a=n[i].slot,o=r.getView(e);s.push({binding:a,resource:o});});let o=t.format.storageBufferFormats;return t.storageBuffers.forEach((e,t)=>{let i=e.impl.buffer,r=o[t].slot;s.push({binding:r,resource:{buffer:i}});}),{layout:t.format.impl.bindGroupLayout,entries:s}}}class nZ{static shaderStage(e){let t=0;return e&aR&&(t|=GPUShaderStage.VERTEX),e&aL&&(t|=GPUShaderStage.FRAGMENT),e&aD&&(t|=GPUShaderStage.COMPUTE),t}}let nQ=[];nQ[sn]="",nQ[so]="",nQ[sl]="",nQ[s4]="r8unorm",nQ[s5]="rg8unorm",nQ[sh]="",nQ[sc]="",nQ[sd]="",nQ[su]="rgba8unorm",nQ[sp]="rgba8unorm",nQ[sf]="bc1-rgba-unorm",nQ[sm]="bc2-rgba-unorm",nQ[s_]="bc3-rgba-unorm",nQ[sg]="",nQ[sy]="rgba16float",nQ[s2]="r16float",nQ[s3]="rg16float",nQ[sv]="",nQ[sS]="rgba32float",nQ[sx]="r32float",nQ[sT]="depth32float",nQ[il]="depth16unorm",nQ[sb]="depth24plus-stencil8",nQ[sE]="rg11b10ufloat",nQ[sA]="",nQ[sw]="rgba8unorm-srgb",nQ[sC]="",nQ[sP]="etc2-rgb8unorm",nQ[sM]="etc2-rgba8unorm",nQ[sI]="",nQ[sR]="",nQ[sL]="",nQ[sD]="",nQ[sO]="astc-4x4-unorm",nQ[sF]="",nQ[sN]="",nQ[sB]="bgra8unorm",nQ[is]="bgra8unorm-srgb",nQ[sU]="r8sint",nQ[sk]="r8uint",nQ[sz]="r16sint",nQ[sV]="r16uint",nQ[sG]="r32sint",nQ[sH]="r32uint",nQ[sW]="rg8sint",nQ[sX]="rg8uint",nQ[s$]="rg16sint",nQ[sY]="rg16uint",nQ[sq]="rg32sint",nQ[sj]="rg32uint",nQ[sK]="rgba8sint",nQ[sZ]="rgba8uint",nQ[sQ]="rgba16sint",nQ[sJ]="rgba16uint",nQ[s0]="rgba32sint",nQ[s1]="rgba32uint",nQ[ii]="bc6h-rgb-float",nQ[ir]="bc6h-rgb-ufloat",nQ[ia]="bc7-rgba-unorm",nQ[s8]="bc1-rgba-unorm-srgb",nQ[s6]="bc2-rgba-unorm-srgb",nQ[s9]="bc3-rgba-unorm-srgb",nQ[s7]="etc2-rgb8unorm-srgb",nQ[ie]="etc2-rgba8unorm-srgb",nQ[io]="bc7-rgba-unorm-srgb",nQ[it]="astc-4x4-unorm-srgb";let nJ=[];nJ[rv]="filtering",nJ[rS]="non-filtering",nJ[rx]="comparison",nJ[rT]="comparison",nJ[rb]="comparison";let n0=[];n0[rv]="float",n0[rS]="unfilterable-float",n0[rx]="depth",n0[rT]="sint",n0[rb]="uint";let n1=new nM;class n2{constructor(e){let t=e.device,{key:s,desc:i}=this.createDescriptor(e);this.key=n1.get(s),this.bindGroupLayout=t.wgpu.createBindGroupLayout(i);}destroy(){this.bindGroupLayout=null;}loseContext(){}createDescriptor(e){let t=[],s="";return e.uniformBufferFormats.forEach(e=>{let i=nZ.shaderStage(e.visibility);s+=`#${e.slot}U:${i}`,t.push({binding:e.slot,visibility:i,buffer:{type:"uniform",hasDynamicOffset:true}});}),e.textureFormats.forEach(e=>{let i=nZ.shaderStage(e.visibility),r=e.sampleType,a=e.textureDimension,n=n0[r];if(s+=`#${e.slot}T:${i}-${n}-${a}-false`,t.push({binding:e.slot,visibility:i,texture:{sampleType:n,viewDimension:a,multisampled:false}}),e.hasSampler){let a=nJ[r];s+=`#${e.slot+1}S:${i}-${a}`,t.push({binding:e.slot+1,visibility:i,sampler:{type:a}});}}),e.storageTextureFormats.forEach(e=>{let{format:i,textureDimension:r}=e,{read:a,write:n}=e;s+=`#${e.slot}ST:${i}-${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:nQ[i],viewDimension:r}});}),e.storageBufferFormats.forEach(e=>{let i=e.readOnly,r=nZ.shaderStage(e.visibility);s+=`#${e.slot}SB:${r}-${i?"ro":"rw"}`,t.push({binding:e.slot,visibility:r,buffer:{type:i?"read-only-storage":"storage"}});}),{key:s,desc:{entries:t}}}}class n3{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 s=e.wgpu;if(!this.buffer){let s=t.byteLength+3&-4;this.usageFlags|=GPUBufferUsage.COPY_DST,this.allocate(e,s);}let i=t.byteOffset??0,r=new Uint8Array(t.buffer??t,i,t.byteLength),a=new Uint8Array(this.buffer.size);a.set(r),s.queue.writeBuffer(this.buffer,0,a,0,a.length);}read(e,t,s,i){return e.readStorageBuffer(this,t,s,i)}write(e,t,s,i,r){e.writeStorageBuffer(this,t,s,i,r);}clear(e,t,s){e.clearStorageBuffer(this,t,s);}}class n4 extends n3{constructor(e,t){super(tR|(t?.storage?tO:0)),this.format=null,this.format=e.format===sr?"uint16":"uint32";}unlock(e){let t=e.device;super.unlock(t,e.storage);}}let n5={equals(e,t){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return false;return true}},n8=[];n8[rI]="sint8",n8[rR]="uint8",n8[rL]="sint16",n8[rD]="uint16",n8[rO]="sint32",n8[rF]="uint32",n8[rN]="float32",n8[rB]="float16";let n6=[];n6[rI]="snorm8",n6[rR]="unorm8",n6[rL]="snorm16",n6[rD]="unorm16",n6[rO]="sint32",n6[rF]="uint32",n6[rN]="float32",n6[rB]="float16";class n9{get(e,t=null){let s=this.getKey(e,t),i=this.cache.get(s);return i||(i=this.create(e,t),this.cache.set(s,i)),i}getKey(e,t=null){return `${e?.renderingHashString}-${t?.renderingHashString}`}create(e,t){let s=[],i=e=>{let t=e.interleaved,i=e.instancing?"instance":"vertex",r=[],a=e.elements.length;for(let n=0;n<a;n++){let o=e.elements[n],l=a4[o.name],h=o.normalize?n6:n8;r.push({shaderLocation:l,offset:t?o.offset:0,format:`${h[o.dataType]}${o.numComponents>1?`x${o.numComponents}`:""}`}),t&&n!==a-1||(s.push({attributes:r,arrayStride:o.stride,stepMode:i}),r=[]);}};return e&&i(e),t&&i(t),s}constructor(){this.cache=new Map;}}class n7{constructor(e){this.device=e;}getPipelineLayout(e){let t=[];return e.forEach(e=>{t.push(e.bindGroupLayout);}),this.device.wgpu.createPipelineLayout({bindGroupLayouts:t})}}let oe=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],ot=["add","subtract","reverse-subtract","min","max"],os=["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"],oi=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],or=["none","back","front"],oa=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],on=["","uint16","uint32"];class oo{}class ol extends n7{constructor(e){super(e),this.lookupHashes=new Uint32Array(14),this.vertexBufferLayout=new n9,this.cache=new Map;}get(e,t,s,i,r,a,n,o,l,h,c,d,u){let p=e.type;i&&p!==ix&&p!==ib&&(i=void 0);let f=this.lookupHashes;f[0]=p,f[1]=r.id,f[2]=h,f[3]=l.key,f[4]=o.key,f[5]=t?.renderingHash??0,f[6]=s?.renderingHash??0,f[7]=a.impl.key,f[8]=n[0]?.key??0,f[9]=n[1]?.key??0,f[10]=n[2]?.key??0,f[11]=c?d.key:0,f[12]=c?u.key:0,f[13]=i??0;let m=nz(f),_=this.cache.get(m);if(_)for(let e=0;e<_.length;e++){let t=_[e];if(n5.equals(t.hashes,f))return t.pipeline}let g=oe[p],y=this.getPipelineLayout(n),v=this.vertexBufferLayout.get(t,s),S=new oo;return S.hashes=new Uint32Array(f),S.pipeline=this.create(g,i,r,a,y,o,l,v,h,c,d,u),_?_.push(S):_=[S],this.cache.set(m,_),S.pipeline}getBlend(e){let t;return e.blend&&(t={color:{operation:ot[e.colorOp],srcFactor:os[e.colorSrcFactor],dstFactor:os[e.colorDstFactor]},alpha:{operation:ot[e.alphaOp],srcFactor:os[e.alphaSrcFactor],dstFactor:os[e.alphaDstFactor]}}),t}getDepthStencil(e,t,s,i,r){let a;let{depth:n,stencil:o}=t;return (n||o)&&(a={format:t.impl.depthAttachment.format},n?(a.depthWriteEnabled=e.write,a.depthCompare=oi[e.func],a.depthBias=e.depthBias,a.depthBiasSlopeScale=e.depthBiasSlope):(a.depthWriteEnabled=false,a.depthCompare="always"),o&&s&&(a.stencilReadMas=i.readMask,a.stencilWriteMask=i.writeMask,a.stencilFront={compare:oi[i.func],failOp:oa[i.fail],passOp:oa[i.zpass],depthFailOp:oa[i.zfail]},a.stencilBack={compare:oi[r.func],failOp:oa[r.fail],passOp:oa[r.zpass],depthFailOp:oa[r.zfail]})),a}create(e,t,s,i,r,a,n,o,l,h,c,d){let u=this.device.wgpu,p=s.impl,f={vertex:{module:p.getVertexShaderModule(),entryPoint:p.vertexEntryPoint,buffers:o},primitive:{topology:e,frontFace:"ccw",cullMode:or[l]},depthStencil:this.getDepthStencil(n,i,h,c,d),multisample:{count:i.samples},layout:r};t&&(f.primitive.stripIndexFormat=on[t]),f.fragment={module:p.getFragmentShaderModule(),entryPoint:p.fragmentEntryPoint,targets:[]};let m=i.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(s=>{f.fragment.targets.push({format:s.format,writeMask:e,blend:t});});}return u.createRenderPipeline(f)}}class oh extends n7{get(e,t){let s=this.getPipelineLayout([t.impl]);return this.create(e,s)}create(e,t){let s=this.device.wgpu,i=e.impl,r={compute:{module:i.getComputeShaderModule(),entryPoint:i.computeEntryPoint},layout:t};return s.createComputePipeline(r)}}class oc{incRefCount(){this._refCount++;}decRefCount(){this._refCount--;}get refCount(){return this._refCount}constructor(){this._refCount=0;}}class od extends oc{constructor(e){super(),this.object=e,this.incRefCount();}}class ou{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 od(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 op extends ou{loseContext(e){this.clear();}}let of=new n_,om=e=>of.get(e,()=>new op),o_=new nM;class og{destroy(){this.multisampledBuffer?.destroy(),this.multisampledBuffer=null;}}class oy{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,om(e).release(this.multisampledDepthBufferKey));}}class ov{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=o_.get(t);}assignColorTexture(e,t){this.assignedColorTexture=t;let s=t.createView({format:e.backBufferViewFormat}),i=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?i.resolveTarget=s:i.view=s,this.setColorAttachment(0,void 0,e.backBufferViewFormat),this.updateKey();}setColorAttachment(e,t,s){this.colorAttachments[e]||(this.colorAttachments[e]=new og),t&&(this.colorAttachments[e].multisampledBuffer=t),s&&(this.colorAttachments[e].format=s);}init(e,t){let s=e.wgpu;this.initDepthStencil(e,s,t),t._colorBuffers&&t._colorBuffers.forEach((e,t)=>{this.setColorAttachment(t,void 0,e.impl.format);}),this.renderPassDescriptor.colorAttachments=[];let i=this.isBackbuffer?1:t._colorBuffers?.length??0;for(let r=0;r<i;++r){let i=this.initColor(e,s,t,r),a=0===r&&this.colorAttachments[0]?.format;(i.view||a)&&this.renderPassDescriptor.colorAttachments.push(i);}this.updateKey(),this.initialized=true;}initDepthStencil(e,t,s){let{samples:i,width:r,height:a,depth:n,depthBuffer:o}=s;if(n||o){let s;if(o){if(this.depthAttachment=new oy(o.impl.format),i>1){let n="depth24plus-stencil8";this.depthAttachment.format=n,this.depthAttachment.hasStencil=true;let l=`${o.id}:${r}:${a}:${i}:${n}`,h=om(e),c=h.get(l);if(!c){let e={size:[r,a,1],dimension:"2d",sampleCount:i,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,s=c.createView();}else {let e=o.impl.gpuTexture;this.depthAttachment.depthTexture=e,s=e.createView();}}else {this.depthAttachment=new oy("depth24plus-stencil8");let e={size:[r,a,1],dimension:"2d",sampleCount:i,format:this.depthAttachment.format,usage:GPUTextureUsage.RENDER_ATTACHMENT};i>1?e.usage|=GPUTextureUsage.TEXTURE_BINDING:e.usage|=GPUTextureUsage.COPY_SRC;let n=t.createTexture(e);this.depthAttachment.depthTexture=n,this.depthAttachment.depthTextureInternal=true,s=n.createView();}this.renderPassDescriptor.depthStencilAttachment={view:s};}}initColor(e,t,s,i){let r={},{samples:a,width:n,height:o,mipLevel:l}=s,h=s.getColorBuffer(i),c=null;if(h&&(c=h.cubemap?h.impl.createView({dimension:"2d",baseArrayLayer:s.face,arrayLayerCount:1,mipLevelCount:1,baseMipLevel:l}):h.impl.createView({mipLevelCount:1,baseMipLevel:l})),a>1){let s={size:[n,o,1],dimension:"2d",sampleCount:a,format:this.isBackbuffer?e.backBufferViewFormat:h.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},l=t.createTexture(s);this.setColorAttachment(i,l,s.format),r.view=l.createView(),r.resolveTarget=c;}else r.view=c;return r}setupForRenderPass(e,t){let s=this.renderPassDescriptor.colorAttachments?.length??0;for(let i=0;i<s;++i){let s=this.renderPassDescriptor.colorAttachments[i],r=e.colorArrayOps[i];s.clearValue=t.isColorBufferSrgb(i)?r.clearValueLinear:r.clearValue,s.loadOp=r.clear?"clear":"load",s.storeOp=r.store?"store":"discard";}let i=this.renderPassDescriptor.depthStencilAttachment;i&&(i.depthClearValue=e.depthStencilOps.clearDepthValue,i.depthLoadOp=e.depthStencilOps.clearDepth?"clear":"load",i.depthStoreOp=e.depthStencilOps.storeDepth?"store":"discard",i.depthReadOnly=false,this.depthAttachment.hasStencil&&(i.stencilClearValue=e.depthStencilOps.clearStencilValue,i.stencilLoadOp=e.depthStencilOps.clearStencil?"clear":"load",i.stencilStoreOp=e.depthStencilOps.storeStencil?"store":"discard",i.stencilReadOnly=false));}loseContext(){this.initialized=false;}resolve(e,t,s,i){}}let oS=[];oS[rz]=1,oS[rV]=2,oS[rG]=3,oS[rH]=4,oS[rk]=1,oS[rW]=2,oS[rX]=3,oS[r$]=4,oS[rU]=1,oS[rY]=2,oS[rq]=3,oS[rj]=4,oS[rK]=8,oS[rZ]=12,oS[rQ]=16,oS[ae]=1,oS[at]=2,oS[as]=3,oS[ai]=4;class ox{get isArrayType(){return this.count>0}constructor(e,t,s=0){if(this.shortName=e,this.name=s?`${e}[0]`:e,this.type=t,this.numComponents=oS[t],this.updateType=t,s>0)switch(t){case rz:this.updateType=r1;break;case rk:this.updateType=ar;break;case ae:this.updateType=aa;break;case rU:this.updateType=an;break;case rV:this.updateType=r5;break;case rW:this.updateType=ao;break;case at:this.updateType=al;break;case rY:this.updateType=ah;break;case rG:this.updateType=r8;break;case rX:this.updateType=ac;break;case as:this.updateType=ad;break;case rq:this.updateType=au;break;case rH:this.updateType=r6;break;case r$:this.updateType=ap;break;case ai:this.updateType=af;break;case rj:this.updateType=am;break;case rQ:this.updateType=r9;}this.count=s;let i=this.numComponents;s&&(i=eE.roundUp(i,4)),this.byteSize=4*i,s&&(this.byteSize*=s);}calculateOffset(e){let t=this.byteSize<=8?this.byteSize:16;this.count&&(t=16),e=eE.roundUp(e,t),this.offset=e/4;}}class oT{constructor(e,t){this.byteSize=0,this.map=new Map,this.scope=e.scope,this.uniforms=t;let s=0;for(let e=0;e<t.length;e++){let i=t[e];i.calculateOffset(s),s=4*i.offset+i.byteSize,i.scopeId=this.scope.resolve(i.name),this.map.set(i.name,i);}this.byteSize=eE.roundUp(s,16);}get(e){return this.map.get(e)}}let ob=/[ \t]*(\battribute\b|\bvarying\b|\buniform\b)/g,oE=/(\battribute\b|\bvarying\b|\bout\b|\buniform\b)[ \t]*([^;]+)(;+)/g,oA=/([\w-]+)\[(.*?)\]/,ow=new Set(["highp","mediump","lowp"]),oC=new Set(["sampler2DShadow","samplerCubeShadow","sampler2DArrayShadow"]),oP={sampler2D:rf,sampler3D:ry,samplerCube:r_,samplerCubeShadow:r_,sampler2DShadow:rf,sampler2DArray:rm,sampler2DArrayShadow:rm,isampler2D:rf,usampler2D:rf,isampler3D:ry,usampler3D:ry,isamplerCube:r_,usamplerCube:r_,isampler2DArray:rm,usampler2DArray:rm},oM={[rf]:"texture2D",[r_]:"textureCube",[ry]:"texture3D",[rm]:"texture2DArray"},oI=class{constructor(e,t){this.line=e;let s=e.trim().split(/\s+/);if(ow.has(s[0])&&(this.precision=s.shift()),this.type=s.shift(),e.includes(","),e.includes("[")){let e=s.join(" "),i=oA.exec(e);this.name=i[1],this.arraySize=Number(i[2]),isNaN(this.arraySize)&&(t.failed=true);}else this.name=s.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 oR{static run(e,t,s){let i=new Map,r=oR.extract(t.vshader),a=oR.extract(t.fshader),n=new Map,o=oR.processAttributes(r.attributes,t.attributes,n,t.processingOptions),l=oR.processVaryings(r.varyings,i,true),h=oR.processVaryings(a.varyings,i,false),c=oR.processOuts(a.outs),d=Array.from(new Set(r.uniforms.concat(a.uniforms))).map(e=>new oI(e,s)),u=oR.processUniforms(e,d,t.processingOptions,s),p=`${o}
|
|
1
|
+
let e,t,s,i,r,a,n,o,l,h,c,d,u,p,f,m,_,g;let y="RenderFrame",v="RenderFrameTime",S="RenderPass",x="RenderPassDetail",T="RenderAction",b="RenderTargetAlloc",E="TextureAlloc",A="ShaderAlloc",w="ShaderCompile",C="VRAM.Texture",P="VRAM.Vb",M="VRAM.Ib",I="VRAM.Sb",R="BindGroupAlloc",L="BindGroupFormatAlloc",D="RenderPipelineAlloc",O="ComputePipelineAlloc",F="PipelineLayoutAlloc",N="Element",B="Textures",U="RenderQueue",k="GpuTimings",z="2.7.5",V="c00565b";function G(e,t){for(let s in t){let i=t[s];Array.isArray(i)?e[s]=G([],i):i&&"object"==typeof i?e[s]=G({},i):e[s]=i;}return e}let H={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)})},W={delimiter:"/",join(...e){let t=e[0];for(let s=0;s<e.length-1;s++){let i=e[s],r=e[s+1];if(r[0]===W.delimiter){t=r;continue}i&&r&&i[i.length-1]!==W.delimiter&&r[0]!==W.delimiter?t+=W.delimiter+r:t+=r;}return t},normalize(e){let t=e.startsWith(W.delimiter),s=e.endsWith(W.delimiter),i=e.split("/"),r="",a=[];for(let e=0;e<i.length;e++)if(""!==i[e]&&"."!==i[e]){if(".."===i[e]&&a.length>0){a=a.slice(0,a.length-2);continue}e>0&&a.push(W.delimiter),a.push(i[e]);}return r=a.join(""),t||r[0]!==W.delimiter||(r=r.slice(1)),s&&r[r.length-1]!==W.delimiter&&(r+=W.delimiter),r},split(e){let t=e.lastIndexOf(W.delimiter);return -1!==t?[e.substring(0,t),e.substring(t+1)]:["",e]},getBasename:e=>W.split(e)[1],getDirectory:e=>W.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="",s=e.split("/"),i=0;if(s.length>1){if(W.isRelativePath(e)){if("."===s[0])for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;else if(".."===s[0])for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;else for(i=0,t=".";i<s.length-1;++i)t+=`/${s[i]}`;}else for(i=0;i<s.length-1;++i)t+=0===i?s[i]:`/${s[i]}`;}return t}},X="undefined"!=typeof navigator?navigator.userAgent:"",$="undefined"!=typeof window?"browser":"undefined"!=typeof global?"node":"worker",Y=/android/i.test(X)?"android":/ip(?:[ao]d|hone)/i.test(X)?"ios":/windows/i.test(X)?"windows":/mac os/i.test(X)?"osx":/linux/i.test(X)?"linux":/cros/i.test(X)?"cros":null,q="browser"!==$?null:/Chrome\/|Chromium\/|Edg.*\//.test(X)?"chrome":/Safari\//.test(X)?"safari":/Firefox\//.test(X)?"firefox":"other",j=/xbox/i.test(X),K="browser"===$&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),Z="browser"===$&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),Q="undefined"!=typeof Worker,J=(()=>{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})(),ee={name:Y,environment:$,global:("undefined"!=typeof globalThis&&globalThis)??("browser"===$&&window)??("node"===$&&global)??("worker"===$&&self),browser:"browser"===$,worker:"worker"===$,desktop:["windows","osx","linux","cros"].includes(Y),mobile:["android","ios"].includes(Y),ios:"ios"===Y,android:"android"===Y,xbox:j,gamepads:Z,touch:K,workers:Q,passiveEvents:J,browserName:q},et="abcdefghijklmnopqrstuvwxyz",es="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function ei(e,t=0){let s=e.length;if(t<0||t>=s)return null;let i=e.charCodeAt(t);if(s>1&&i>=55296&&i<=56319){let s=e.charCodeAt(t+1);if(s>=56320&&s<=57343)return {code:(i-55296)*1024+s-56320+65536,long:true}}return {code:i,long:false}}function er(e,t,s){if(!e)return false;let i=ei(e);if(i){let e=i.code;return e>=t&&e<=s}return false}let ea={ASCII_LOWERCASE:et,ASCII_UPPERCASE:es,ASCII_LETTERS:et+es,format(e,...t){for(let s=0;s<t.length;s++)e=e.replace(`{${s}}`,t[s]);return e},getCodePoint(e,t){let s=ei(e,t);return s&&s.code},getCodePoints(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let s=0,i=[];for(;t=ei(e,s);)i.push(t.code),s+=t.long?2:1;return i},getSymbols(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let s=0,i=e.length,r=[],a=0;for(;s<i;){if(a+=function(e,t){if(t===e.length-1)return 1;if(er(e[t],55296,56319)){let s=e.substring(t,t+2),i=e.substring(t+2,t+4);return er(i,127995,127999)||er(s,127462,127487)&&er(i,127462,127487)?4:er(i,65024,65039)?3:2}return er(e[t+1],65024,65039)?2:1}(e,s+a),er(t=e[s+a],8400,8447)&&(t=e[s+a++]),er(t,65024,65039)&&(t=e[s+a++]),t&&8205===t.charCodeAt(0)){t=e[s+a++];continue}let i=e.substring(s,s+a);r.push(i),s+=a,a=0;}return r},fromCodePoint(){let e,t,s;let i=[];for(let r=0;r<arguments.length;++r)e=Number(arguments[r]),t=e-65536,s=e>65535?[(t>>10)+55296,t%1024+56320]:[e],i.push(String.fromCharCode.apply(null,s));return i.join("")}};class en{constructor(e,t,s,i,r=false){this._removed=false,this.handler=e,this.name=t,this.callback=s,this.scope=i,this._once=r;}off(){this._removed||this.handler.offByHandle(this);}on(e,t,s=this){return this.handler._addCallback(e,t,s,false)}once(e,t,s=this){return this.handler._addCallback(e,t,s,true)}set removed(e){e&&(this._removed=true);}get removed(){return this._removed}}class eo{initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map;}_addCallback(e,t,s,i){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 en(this,e,t,s,i);return this._callbacks.get(e).push(r),r}on(e,t,s=this){return this._addCallback(e,t,s,false)}once(e,t,s=this){return this._addCallback(e,t,s,true)}off(e,t,s){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 i=this._callbacks.get(e);if(!i)return this;for(let e=0;e<i.length;e++)i[e].callback===t&&(!s||i[e].scope===s)&&(i[e].removed=true,i.splice(e,1),e--);0===i.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 s=this._callbacks.get(t);if(!s)return this;let i=s.indexOf(e);return -1!==i&&(s.splice(i,1),0===s.length&&this._callbacks.delete(t)),this}fire(e,t,s,i,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,s,i,r,a,n,o,l),d._once)){let t=this._callbacks.get(e),s=t?t.indexOf(d):-1;if(-1!==s){this._callbackActive.get(e)===t&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let i=this._callbacks.get(e);if(!i)continue;i[s].removed=true,i.splice(s,1),0===i.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 el{push(e,t){if(this._index[e])throw Error(`Key already in index ${e}`);let s=this._list.push(t)-1;this._index[e]=s;}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 s=this._index[e];s>t&&(this._index[e]=s-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={};}}let eh=e=>{let t={},s=t;return ()=>(s===t&&(s=e()),s)};class ec{static{this.modules={};}static{this.wasmSupported=eh(()=>{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 s=document.createElement("script");s.setAttribute("src",e),s.onload=()=>{t(null);},s.onerror=()=>{t(`Failed to load script='${e}'`);},document.body.appendChild(s);}static loadWasm(e,t,s){let i=ec.wasmSupported()&&t.glueUrl&&t.wasmUrl?t.glueUrl:t.fallbackUrl;i?ec.loadScript(i,i=>{if(i)s(i,null);else {let i=window[e];window[e]=void 0,i({locateFile:()=>t.wasmUrl,onAbort:()=>{s("wasm module aborted.");}}).then(e=>{s(null,e);});}}):s("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 s=t.config;(s.glueUrl||s.wasmUrl||s.fallbackUrl)&&(t.initializing=true,ec.loadWasm(e,s,(e,i)=>{e?s.errorHandler&&s.errorHandler(e):(t.instance=i,t.callbacks.forEach(e=>{e(i);}));}));}}class ed{static setConfig(e,t){let s=ec.getModule(e);s.config=t,s.callbacks.length>0&&ec.initialize(e,s);}static getConfig(e){return ec.modules?.[e]?.config}static getInstance(e,t){let s=ec.getModule(e);s.instance?t(s.instance):(s.callbacks.push(t),s.config&&ec.initialize(e,s));}}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 s=0;s<e;++s)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 ep{constructor(e){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=e.sortBy,this._sortHandler=this._doSort.bind(this);}_binarySearch(e){let t,s,i=0,r=this.items.length-1,a=e[this._sortBy];for(;i<=r;)t=Math.floor((i+r)/2),(s=this.items[t][this._sortBy])<=a?i=t+1:s>a&&(r=t-1);return i}_doSort(e,t){let s=this._sortBy;return e[s]-t[s]}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 ef extends eo{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,s=this._processArguments(e,true);if(!s.length)return t;for(let e=0;e<s.length;e++)!this._index[s[e]]&&(t=true,this._index[s[e]]=true,this._list.push(s[e]),this.fire("add",s[e],this._parent));return t&&this.fire("change",this._parent),t}remove(...e){let t=false;if(!this._list.length)return t;let s=this._processArguments(e,true);if(!s.length)return t;for(let e=0;e<s.length;e++)this._index[s[e]]&&(t=true,delete this._index[s[e]],this._list.splice(this._list.indexOf(s[e]),1),this.fire("remove",s[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 s=true;for(let i=0;i<e[t].length;i++)if(!this._index[e[t][i]]){s=false;break}if(s)return true}return false}list(){return this._list.slice(0)}_processArguments(e,t){let s=[],i=[];if(!e||!e.length)return s;for(let r=0;r<e.length;r++)if(e[r]instanceof Array){t||(i=[]);for(let a=0;a<e[r].length;a++)"string"==typeof e[r][a]&&(t?s.push(e[r][a]):i.push(e[r][a]));!t&&i.length&&s.push(i);}else "string"==typeof e[r]&&(t?s.push(e[r]):s.push([e[r]]));return s}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 ey{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 s=t.split("=");e[s[0]]=s[1];}return e}setQuery(e){let t="";for(let s in e)e.hasOwnProperty(s)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`);this.query=t;}}class ev{static{this._traceChannels=new Set;}static{this.stack=false;}static set(e,t=true){}static get(e){return ev._traceChannels.has(e)}}let eS=0,ex=1,eT=4,eb=5,eE={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:(e,t,s)=>e>=s?s: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,s)=>(e.length&&(s=e[2],t=e[1],e=e[0]),e<<16|t<<8|s),bytesToInt32:(e,t,s,i)=>(e.length&&(i=e[3],s=e[2],t=e[1],e=e[0]),(e<<24|t<<16|s<<8|i)>>>0),lerp:(e,t,s)=>e+(t-e)*eE.clamp(s,0,1),lerpAngle:(e,t,s)=>(t-e>180&&(t-=360),t-e<-180&&(t+=360),eE.lerp(e,t,eE.clamp(s,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.log(e)/Math.log(2))),random:(e,t)=>Math.random()*(t-e)+e,smoothstep:(e,t,s)=>s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*(3-2*s),smootherstep:(e,t,s)=>s<=e?0:s>=t?1:(s=(s-e)/(t-e))*s*s*(s*(6*s-15)+10),roundUp:(e,t)=>0===t?e:Math.ceil(e/t)*t,between(e,t,s,i){let r=Math.min(t,s),a=Math.max(t,s);return i?e>=r&&e<=a:e>r&&e<a}};class eA{constructor(e=0,t=0,s=0,i=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=s,this.a=i);}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,s,i=1){return this.r=e,this.g=t,this.b=s,this.a=i,this}lerp(e,t,s){return this.r=e.r+s*(t.r-e.r),this.g=e.g+s*(t.g-e.g),this.b=e.b+s*(t.b-e.b),this.a=e.a+s*(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;let s=parseInt(e.replace("#","0x"),16);return e.length>7?t=eE.intToBytes32(s):(t=eE.intToBytes24(s))[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:s,g:i,b:r,a}=this;if(t||s>1||i>1||r>1)return `${s.toFixed(3)}, ${i.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let n=`#${(0x1000000+(Math.round(255*s)<<16)+(Math.round(255*i)<<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,s=true){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,s&&(e[t+3]=this.a),e}static{this.BLACK=Object.freeze(new eA(0,0,0,1));}static{this.BLUE=Object.freeze(new eA(0,0,1,1));}static{this.CYAN=Object.freeze(new eA(0,1,1,1));}static{this.GRAY=Object.freeze(new eA(.5,.5,.5,1));}static{this.GREEN=Object.freeze(new eA(0,1,0,1));}static{this.MAGENTA=Object.freeze(new eA(1,0,1,1));}static{this.RED=Object.freeze(new eA(1,0,0,1));}static{this.WHITE=Object.freeze(new eA(1,1,1,1));}static{this.YELLOW=Object.freeze(new eA(1,1,0,1));}}class ew{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 s;(t||e<this._left||e>=this._right)&&this._reset(e);let i=this._curve.type;if(i===eb)s=this._p0;else {let t=0===this._recip?0:(e-this._left)*this._recip;s=i===eS?eE.lerp(this._p0,this._p1,t):i===ex?eE.lerp(this._p0,this._p1,t*t*(3-2*t)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,t);}return s}_reset(e){let t=this._curve.keys,s=t.length;if(s){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[s-1][0])this._left=t[s-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=t[s-1][1],this._m0=this._m1=0;else {let s=0;for(;e>=t[s+1][0];)s++;this._left=t[s][0],this._right=t[s+1][0];let i=1/(this._right-this._left);this._recip=isFinite(i)?i:0,this._p0=t[s][1],this._p1=t[s+1][1],this._curve.type===eT&&this._calcTangents(t,s);}}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 s,i;let r=e[t],a=e[t+1];if(s=0===t?[e[0][0]+(e[0][0]-e[1][0]),e[0][1]+(e[0][1]-e[1][1])]:e[t-1],i=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]-s[0]),t=2*(a[0]-r[0])/(i[0]-r[0]);this._m0=this._curve.tension*(isFinite(e)?e:0)*(a[1]-s[1]),this._m1=this._curve.tension*(isFinite(t)?t:0)*(i[1]-r[1]);}else {let e=(a[0]-r[0])/(r[0]-s[0]),t=(a[0]-r[0])/(i[0]-a[0]),n=r[1]+(s[1]-r[1])*(isFinite(e)?e:0),o=a[1]+(i[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,s,i,r){let a=r*r,n=r+r,o=1-r,l=o*o;return (1+n)*l*e+r*l*s+a*(3-n)*t+a*(r-1)*i}}class eC{constructor(e){if(this.keys=[],this.type=ex,this.tension=.5,this._eval=new ew(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 s=this.keys,i=s.length,r=0;for(;r<i&&!(s[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,s=t.length,i=2,r=null;for(let a=0;a<s;a++){let s=Math.abs(e-t[a][0]);if(i>=s)i=s,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)),s=1/(e-1);t[0]=this._eval.evaluate(0,true);for(let i=1;i<e;i++)t[i]=this._eval.evaluate(s*i);return t}quantizeClamped(e,t,s){let i=this.quantize(e);for(let e=0;e<i.length;++e)i[e]=Math.min(s,Math.max(t,i[e]));return i}}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 s=this.curves.length;t.length=s;for(let i=0;i<s;i++)t[i]=this.curves[i].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,s=new Float32Array(e*t),i=1/(e-1);for(let r=0;r<t;r++){let a=new ew(this.curves[r]);for(let n=0;n<e;n++)s[n*t+r]=a.evaluate(i*n);}return s}quantizeClamped(e,t,s){let i=this.quantize(e);for(let e=0;e<i.length;++e)i[e]=Math.min(s,Math.max(t,i[e]));return i}}let eM=new Float32Array(1),eI=new Int32Array(eM.buffer);class eR{static float2Half(e){eM[0]=e;let t=eI[0],s=t>>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?s:r>142?(s|=31744,s|=+(255!==r)&&8388607&t):r<113?(i|=2048,s|=(i>>114-r)+(i>>113-r&1)):(s|=r-112<<10|i>>1,s+=1&i)}static float2RGBA8(e,t){eM[0]=e;let s=eI[0];t.r=(s>>24&255)/255,t.g=(s>>16&255)/255,t.b=(s>>8&255)/255,t.a=(255&s)/255;}}class eL{static concentric(e,t){let s=[];s.push(0,0);let i=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/i)),n=2*Math.PI/a;for(let e=0;e<a;e++){let t=e*n,i=r*Math.cos(t),a=r*Math.sin(t);s.push(i,a);}}return s}}class eD{constructor(e=0,t=0,s=0){3===e.length?(this.x=e[0],this.y=e[1],this.z=e[2]):(this.x=e,this.y=t,this.z=s);}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 s=e.x,i=e.y,r=e.z,a=t.x,n=t.y,o=t.z;return this.x=i*o-n*r,this.y=r*a-o*s,this.z=s*n-a*i,this}distance(e){let t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return Math.sqrt(t*t+s*s+i*i)}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(t.y-e.y),this.z=e.z+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s,this.z=e.z*s;}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,s){return this.x=e,this.y=t,this.z=s,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 eD(0,0,0));}static{this.HALF=Object.freeze(new eD(.5,.5,.5));}static{this.ONE=Object.freeze(new eD(1,1,1));}static{this.UP=Object.freeze(new eD(0,1,0));}static{this.DOWN=Object.freeze(new eD(0,-1,0));}static{this.RIGHT=Object.freeze(new eD(1,0,0));}static{this.LEFT=Object.freeze(new eD(-1,0,0));}static{this.FORWARD=Object.freeze(new eD(0,0,-1));}static{this.BACK=Object.freeze(new eD(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,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[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 eD){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eD){return e.set(this.data[3],this.data[4],this.data[5])}getZ(e=new eD){return e.set(this.data[6],this.data[7],this.data[8])}equals(e){let t=this.data,s=e.data;return t[0]===s[0]&&t[1]===s[1]&&t[2]===s[2]&&t[3]===s[3]&&t[4]===s[4]&&t[5]===s[5]&&t[6]===s[6]&&t[7]===s[7]&&t[8]===s[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,s=this.data;if(t===s){let e;e=t[1],s[1]=t[3],s[3]=e,e=t[2],s[2]=t[6],s[6]=e,e=t[5],s[5]=t[7],s[7]=e;}else s[0]=t[0],s[1]=t[3],s[2]=t[6],s[3]=t[1],s[4]=t[4],s[5]=t[7],s[6]=t[2],s[7]=t[5],s[8]=t[8];return this}setFromMat4(e){let t=e.data,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[4],s[4]=t[5],s[5]=t[6],s[6]=t[8],s[7]=t[9],s[8]=t[10],this}setFromQuat(e){let t=e.x,s=e.y,i=e.z,r=e.w,a=t+t,n=s+s,o=i+i,l=t*a,h=t*n,c=t*o,d=s*n,u=s*o,p=i*o,f=r*a,m=r*n,_=r*o,g=this.data;return g[0]=1-(d+p),g[1]=h+_,g[2]=c-m,g[3]=h-_,g[4]=1-(l+p),g[5]=u+f,g[6]=c+m,g[7]=u-f,g[8]=1-(l+d),this}invertMat4(e){let t=e.data,s=t[0],i=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,p=h*a-n*l,f=s*d+i*u+r*p;if(0===f)this.setIdentity();else {let e=1/f,t=this.data;t[0]=d*e,t[1]=(-c*i+r*h)*e,t[2]=(o*i-r*n)*e,t[3]=u*e,t[4]=(c*s-r*l)*e,t[5]=(-o*s+r*a)*e,t[6]=p*e,t[7]=(-h*s+i*l)*e,t[8]=(n*s-i*a)*e;}return this}transformVector(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[3]+a*s[6],t.y=i*s[1]+r*s[4]+a*s[7],t.z=i*s[2]+r*s[5]+a*s[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,s=this.y-e.y;return Math.sqrt(t*t+s*s)}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s;}return this}rotate(e){let t=Math.atan2(this.x,this.y)+e*eE.DEG_TO_RAD,s=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(t)*s,this.y=Math.cos(t)*s,this}angle(){return Math.atan2(this.x,this.y)*eE.RAD_TO_DEG}angleTo(e){return Math.atan2(this.x*e.y+this.y*e.x,this.x*e.x+this.y*e.y)*eE.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,s=0,i=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=s,this.w=i);}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,s){return this.x=e.x+s*(t.x-e.x),this.y=e.y+s*(t.y-e.y),this.z=e.z+s*(t.z-e.z),this.w=e.w+s*(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 s=1/Math.sqrt(t);this.x=e.x*s,this.y=e.y*s,this.z=e.z*s,this.w=e.w*s;}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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,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 eD,ek=new eD,ez=new eD,eV=new eD;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,s,i,r){r?(e.x=i*Math.tan(t*Math.PI/360),e.y=e.x/s):(e.y=i*Math.tan(t*Math.PI/360),e.x=e.y*s);}add2(e,t){let s=e.data,i=t.data,r=this.data;return r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],r[3]=s[3]+i[3],r[4]=s[4]+i[4],r[5]=s[5]+i[5],r[6]=s[6]+i[6],r[7]=s[7]+i[7],r[8]=s[8]+i[8],r[9]=s[9]+i[9],r[10]=s[10]+i[10],r[11]=s[11]+i[11],r[12]=s[12]+i[12],r[13]=s[13]+i[13],r[14]=s[14]+i[14],r[15]=s[15]+i[15],this}add(e){return this.add2(this,e)}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,s=this.data;return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[8]=t[8],s[9]=t[9],s[10]=t[10],s[11]=t[11],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15],this}equals(e){let t=this.data,s=e.data;return t[0]===s[0]&&t[1]===s[1]&&t[2]===s[2]&&t[3]===s[3]&&t[4]===s[4]&&t[5]===s[5]&&t[6]===s[6]&&t[7]===s[7]&&t[8]===s[8]&&t[9]===s[9]&&t[10]===s[10]&&t[11]===s[11]&&t[12]===s[12]&&t[13]===s[13]&&t[14]===s[14]&&t[15]===s[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 s,i,r,a;let n=e.data,o=t.data,l=this.data,h=n[0],c=n[1],d=n[2],u=n[3],p=n[4],f=n[5],m=n[6],_=n[7],g=n[8],y=n[9],v=n[10],S=n[11],x=n[12],T=n[13],b=n[14],E=n[15];return s=o[0],i=o[1],r=o[2],a=o[3],l[0]=h*s+p*i+g*r+x*a,l[1]=c*s+f*i+y*r+T*a,l[2]=d*s+m*i+v*r+b*a,l[3]=u*s+_*i+S*r+E*a,s=o[4],i=o[5],r=o[6],a=o[7],l[4]=h*s+p*i+g*r+x*a,l[5]=c*s+f*i+y*r+T*a,l[6]=d*s+m*i+v*r+b*a,l[7]=u*s+_*i+S*r+E*a,s=o[8],i=o[9],r=o[10],a=o[11],l[8]=h*s+p*i+g*r+x*a,l[9]=c*s+f*i+y*r+T*a,l[10]=d*s+m*i+v*r+b*a,l[11]=u*s+_*i+S*r+E*a,s=o[12],i=o[13],r=o[14],a=o[15],l[12]=h*s+p*i+g*r+x*a,l[13]=c*s+f*i+y*r+T*a,l[14]=d*s+m*i+v*r+b*a,l[15]=u*s+_*i+S*r+E*a,this}mulAffine2(e,t){let s,i,r;let a=e.data,n=t.data,o=this.data,l=a[0],h=a[1],c=a[2],d=a[4],u=a[5],p=a[6],f=a[8],m=a[9],_=a[10],g=a[12],y=a[13],v=a[14];return s=n[0],i=n[1],r=n[2],o[0]=l*s+d*i+f*r,o[1]=h*s+u*i+m*r,o[2]=c*s+p*i+_*r,o[3]=0,s=n[4],i=n[5],r=n[6],o[4]=l*s+d*i+f*r,o[5]=h*s+u*i+m*r,o[6]=c*s+p*i+_*r,o[7]=0,s=n[8],i=n[9],r=n[10],o[8]=l*s+d*i+f*r,o[9]=h*s+u*i+m*r,o[10]=c*s+p*i+_*r,o[11]=0,s=n[12],i=n[13],r=n[14],o[12]=l*s+d*i+f*r+g,o[13]=h*s+u*i+m*r+y,o[14]=c*s+p*i+_*r+v,o[15]=1,this}mul(e){return this.mul2(this,e)}transformPoint(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[4]+a*s[8]+s[12],t.y=i*s[1]+r*s[5]+a*s[9]+s[13],t.z=i*s[2]+r*s[6]+a*s[10]+s[14],t}transformVector(e,t=new eD){let s=this.data,{x:i,y:r,z:a}=e;return t.x=i*s[0]+r*s[4]+a*s[8],t.y=i*s[1]+r*s[5]+a*s[9],t.z=i*s[2]+r*s[6]+a*s[10],t}transformVec4(e,t=new eN){let s=this.data,{x:i,y:r,z:a,w:n}=e;return t.x=i*s[0]+r*s[4]+a*s[8]+n*s[12],t.y=i*s[1]+r*s[5]+a*s[9]+n*s[13],t.z=i*s[2]+r*s[6]+a*s[10]+n*s[14],t.w=i*s[3]+r*s[7]+a*s[11]+n*s[15],t}setLookAt(e,t,s){ez.sub2(e,t).normalize(),ek.copy(s).normalize(),eU.cross(ek,ez).normalize(),ek.cross(ez,eU);let i=this.data;return i[0]=eU.x,i[1]=eU.y,i[2]=eU.z,i[3]=0,i[4]=ek.x,i[5]=ek.y,i[6]=ek.z,i[7]=0,i[8]=ez.x,i[9]=ez.y,i[10]=ez.z,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}setFrustum(e,t,s,i,r,a){let n=2*r,o=t-e,l=i-s,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]=(i+s)/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,s,i,r){return eG._getPerspectiveHalfSize(eB,e,t,s,r),this.setFrustum(-eB.x,eB.x,-eB.y,eB.y,s,i)}setOrtho(e,t,s,i,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/(i-s),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]=-(i+s)/(i-s),n[14]=-(a+r)/(a-r),n[15]=1,this}setFromAxisAngle(e,t){t*=eE.DEG_TO_RAD;let{x:s,y:i,z:r}=e,a=Math.cos(t),n=Math.sin(t),o=1-a,l=o*s,h=o*i,c=this.data;return c[0]=l*s+a,c[1]=l*i+n*r,c[2]=l*r-n*i,c[3]=0,c[4]=l*i-n*r,c[5]=h*i+a,c[6]=h*r+n*s,c[7]=0,c[8]=l*r+n*i,c[9]=h*r-s*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,s){let i=this.data;return i[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=e,i[13]=t,i[14]=s,i[15]=1,this}setScale(e,t,s){let i=this.data;return i[0]=e,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=t,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=s,i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this}setViewport(e,t,s,i){let r=this.data;return r[0]=.5*s,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=.5*i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=e+.5*s,r[13]=t+.5*i,r[14]=.5,r[15]=1,this}setReflection(e,t){let s=e.x,i=e.y,r=e.z,a=this.data;return a[0]=1-2*s*s,a[1]=-2*s*i,a[2]=-2*s*r,a[3]=0,a[4]=-2*s*i,a[5]=1-2*i*i,a[6]=-2*i*r,a[7]=0,a[8]=-2*s*r,a[9]=-2*i*r,a[10]=1-2*r*r,a[11]=0,a[12]=-2*s*t,a[13]=-2*i*t,a[14]=-2*r*t,a[15]=1,this}invert(e=this){let t=e.data,s=t[0],i=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],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=s*o-i*n,v=s*l-r*n,S=s*h-a*n,x=i*l-r*o,T=i*h-a*o,b=r*h-a*l,E=c*m-d*f,A=c*_-u*f,w=c*g-p*f,C=d*_-u*m,P=d*g-p*m,M=u*g-p*_,I=y*M-v*P+S*C+x*w-T*A+b*E;if(0===I)this.setIdentity();else {let e=1/I,t=this.data;t[0]=(o*M-l*P+h*C)*e,t[1]=(-i*M+r*P-a*C)*e,t[2]=(m*b-_*T+g*x)*e,t[3]=(-d*b+u*T-p*x)*e,t[4]=(-n*M+l*w-h*A)*e,t[5]=(s*M-r*w+a*A)*e,t[6]=(-f*b+_*S-g*v)*e,t[7]=(c*b-u*S+p*v)*e,t[8]=(n*P-o*w+h*E)*e,t[9]=(-s*P+i*w-a*E)*e,t[10]=(f*T-m*S+g*y)*e,t[11]=(-c*T+d*S-p*y)*e,t[12]=(-n*C+o*A-l*E)*e,t[13]=(s*C-i*A+r*E)*e,t[14]=(-f*x+m*v-_*y)*e,t[15]=(c*x-d*v+u*y)*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,s){let i=t.x,r=t.y,a=t.z,n=t.w,o=s.x,l=s.y,h=s.z,c=i+i,d=r+r,u=a+a,p=i*c,f=i*d,m=i*u,_=r*d,g=r*u,y=a*u,v=n*c,S=n*d,x=n*u,T=this.data;return T[0]=(1-(_+y))*o,T[1]=(f+x)*o,T[2]=(m-S)*o,T[3]=0,T[4]=(f-x)*l,T[5]=(1-(p+y))*l,T[6]=(g+v)*l,T[7]=0,T[8]=(m+S)*h,T[9]=(g-v)*h,T[10]=(1-(p+_))*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,s=this.data;if(t===s){let e;e=t[1],s[1]=t[4],s[4]=e,e=t[2],s[2]=t[8],s[8]=e,e=t[3],s[3]=t[12],s[12]=e,e=t[6],s[6]=t[9],s[9]=e,e=t[7],s[7]=t[13],s[13]=e,e=t[11],s[11]=t[14],s[14]=e;}else s[0]=t[0],s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=t[1],s[5]=t[5],s[6]=t[9],s[7]=t[13],s[8]=t[2],s[9]=t[6],s[10]=t[10],s[11]=t[14],s[12]=t[3],s[13]=t[7],s[14]=t[11],s[15]=t[15];return this}getTranslation(e=new eD){return e.set(this.data[12],this.data[13],this.data[14])}getX(e=new eD){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eD){return e.set(this.data[4],this.data[5],this.data[6])}getZ(e=new eD){return e.set(this.data[8],this.data[9],this.data[10])}getScale(e=new eD){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,s){e*=eE.DEG_TO_RAD,t*=eE.DEG_TO_RAD,s*=eE.DEG_TO_RAD;let i=Math.sin(-e),r=Math.cos(-e),a=Math.sin(-t),n=Math.cos(-t),o=Math.sin(-s),l=Math.cos(-s),h=this.data;return h[0]=n*l,h[1]=-n*o,h[2]=a,h[3]=0,h[4]=r*o+l*i*a,h[5]=r*l-i*a*o,h[6]=-n*i,h[7]=0,h[8]=i*o-r*l*a,h[9]=l*i+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 eD){let t,s;this.getScale(eV);let i=eV.x,r=eV.y,a=eV.z;if(0===i||0===r||0===a)return e.set(0,0,0);let n=this.data,o=Math.asin(-n[2]/i),l=.5*Math.PI;return o<l?o>-l?(t=Math.atan2(n[6]/r,n[10]/a),s=Math.atan2(n[1]/i,n[0]/i)):(s=0,t=-Math.atan2(n[4]/r,n[5]/r)):(s=0,t=Math.atan2(n[4]/r,n[5]/r)),e.set(t,o,s).mulScalar(eE.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,s=0,i=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=s,this.w=i);}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}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),s=Math.sin(t/2);return 0!==s?(e.x=this.x/s,e.y=this.y/s,e.z=this.z/s,(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*eE.RAD_TO_DEG}getEulerAngles(e=new eD){let t,s,i;let 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),s=-Math.PI/2,i=0):l>=.99999?(t=2*Math.atan2(r,o),s=Math.PI/2,i=0):(t=Math.atan2(2*(o*r+a*n),1-2*(r*r+a*a)),s=Math.asin(l),i=Math.atan2(2*(o*n+r*a),1-2*(a*a+n*n))),e.set(t,s,i).mulScalar(eE.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}mul(e){let t=this.x,s=this.y,i=this.z,r=this.w,a=e.x,n=e.y,o=e.z,l=e.w;return this.x=r*a+t*l+s*o-i*n,this.y=r*n+s*l+i*a-t*o,this.z=r*o+i*l+t*n-s*a,this.w=r*l-t*a-s*n-i*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 s=e.x,i=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+s*h+i*l-r*o,this.y=a*o+i*h+r*n-s*l,this.z=a*l+r*h+s*o-i*n,this.w=a*h-s*n-i*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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setFromAxisAngle(e,t){let s=Math.sin(t*=.5*eE.DEG_TO_RAD),i=Math.cos(t);return this.x=s*e.x,this.y=s*e.y,this.z=s*e.z,this.w=i,this}setFromEulerAngles(e,t,s){if(e instanceof eD){let i=e;e=i.x,t=i.y,s=i.z;}let i=.5*eE.DEG_TO_RAD;e*=i,t*=i,s*=i;let r=Math.sin(e),a=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(s),h=Math.cos(s);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;let s=e.data,i=s[0],r=s[1],a=s[2],n=s[4],o=s[5],l=s[6],h=s[8],c=s[9],d=s[10];return 0==(t=i*i+r*r+a*a)?this.set(0,0,0,1):(i*=t=1/Math.sqrt(t),r*=t,a*=t,0==(t=n*n+o*o+l*l))?this.set(0,0,0,1):(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?i>o?this.set(1+i-o-d,r+n,h+a,l-c):this.set(r+n,1-i+o-d,l+c,h-a):i<-o?this.set(h+a,l+c,1-i-o+d,r-n):this.set(l-c,h-a,r-n,1+i+o+d),this.mulScalar(1/this.length()))}setFromDirections(e,t){let s=1+e.dot(t);return s<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=s),this.normalize()}slerp(e,t,s){let i=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+i*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=i,this.y=r,this.z=a,this;let u=Math.acos(d),p=Math.sqrt(1-d*d);if(.001>Math.abs(p))return this.w=.5*n+.5*c,this.x=.5*i+.5*o,this.y=.5*r+.5*l,this.z=.5*a+.5*h,this;let f=Math.sin((1-s)*u)/p,m=Math.sin(s*u)/p;return this.w=n*f+c*m,this.x=i*f+o*m,this.y=r*f+l*m,this.z=a*f+h*m,this}transformVector(e,t=new eD){let s=e.x,i=e.y,r=e.z,a=this.x,n=this.y,o=this.z,l=this.w,h=l*s+n*r-o*i,c=l*i+o*s-a*r,d=l*r+a*i-n*s,u=-a*s-n*i-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}toString(){return `[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}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 eD,eX=new eD,e$=new eD,eY=new eD,eq=new eD;class ej{constructor(e,t){this.center=new eD,this.halfExtents=new eD(.5,.5,.5),this._min=new eD,this._max=new eD,e&&this.center.copy(e),t&&this.halfExtents.copy(t);}add(e){let t=this.center,s=t.x,i=t.y,r=t.z,a=this.halfExtents,n=a.x,o=a.y,l=a.z,h=s-n,c=s+n,d=i-o,u=i+o,p=r-l,f=r+l,m=e.center,_=m.x,g=m.y,y=m.z,v=e.halfExtents,S=v.x,x=v.y,T=v.z,b=_-S,E=_+S,A=g-x,w=g+x,C=y-T,P=y+T;b<h&&(h=b),E>c&&(c=E),A<d&&(d=A),w>u&&(u=w),C<p&&(p=C),P>f&&(f=P),t.x=(h+c)*.5,t.y=(d+u)*.5,t.z=(p+f)*.5,a.x=(c-h)*.5,a.y=(u-d)*.5,a.z=(f-p)*.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(),s=this.getMin(),i=e.getMax(),r=e.getMin();return s.x<=i.x&&t.x>=r.x&&s.y<=i.y&&t.y>=r.y&&s.z<=i.z&&t.z>=r.z}_intersectsRay(e,t){let s=eW.copy(this.getMin()).sub(e.origin),i=eX.copy(this.getMax()).sub(e.origin),r=e.direction;0===r.x?(s.x=s.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.x/=r.x,i.x/=r.x),0===r.y?(s.y=s.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.y/=r.y,i.y/=r.y),0===r.z?(s.z=s.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(s.z/=r.z,i.z/=r.z);let a=e$.set(Math.min(s.x,i.x),Math.min(s.y,i.y),Math.min(s.z,i.z)),n=eY.set(Math.max(s.x,i.x),Math.max(s.y,i.y),Math.max(s.z,i.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),eY.set(Math.abs(eW.x),Math.abs(eW.y),Math.abs(eW.z)),e$.mul2(eW,t),(!(eY.x>this.halfExtents.x)||!(e$.x>=0))&&(!(eY.y>this.halfExtents.y)||!(e$.y>=0))&&(!(eY.z>this.halfExtents.z)||!(e$.z>=0))&&(eq.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*eq.z+this.halfExtents.z*eq.y)&&!(eX.y>this.halfExtents.x*eq.z+this.halfExtents.z*eq.x)&&!(eX.z>this.halfExtents.x*eq.y+this.halfExtents.y*eq.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(),s=this.getMax();return !(e.x<t.x)&&!(e.x>s.x)&&!(e.y<t.y)&&!(e.y>s.y)&&!(e.z<t.z)&&!(e.z>s.z)}setFromTransformedAabb(e,t,s=false){let i=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],p=a[6],f=a[10];if(s){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+p*p+f*f)>0){let t=1/Math.sqrt(e);u*=t,p*=t,f*=t;}}this.center.set(a[12]+n*i.x+o*i.y+l*i.z,a[13]+h*i.x+c*i.y+d*i.z,a[14]+u*i.x+p*i.y+f*i.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(p)*r.y+Math.abs(f)*r.z);}static computeMinMax(e,t,s,i=e.length/3){if(i>0){let r=e[0],a=e[1],n=e[2],o=r,l=a,h=n,c=3*i;for(let t=3;t<c;t+=3){let s=e[t],i=e[t+1],c=e[t+2];s<r&&(r=s),i<a&&(a=i),c<n&&(n=c),s>o&&(o=s),i>l&&(l=i),c>h&&(h=c);}t.set(r,a,n),s.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(),s=this.getMax(),i=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=s[r[a]],c=0;o<l&&(n+=(c=l-o)*c),o>h&&(n+=(c=o-h)*c),i+=n;}return i}_expand(e,t){eW.add2(this.getMin(),e),eX.add2(this.getMax(),t),this.setMinMax(eW,eX);}}let eK=new eD,eZ=new eD;class eQ{constructor(e=new eD,t=.5){this.center=e,this.radius=t;}containsPoint(e){let t=eK.sub2(e,this.center).lengthSq(),s=this.radius;return t<s*s}intersectsRay(e,t){let s=eK.copy(e.origin).sub(this.center),i=s.dot(eZ.copy(e.direction).normalize()),r=s.dot(s)-this.radius*this.radius;if(r>0&&i>0)return false;let a=i*i-r;if(a<0)return false;let n=Math.abs(-i-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=eD.UP,t=0){this.normal=new eD,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,s){let i=this.distance,r=this.normal.dot(e)+i,a=r/(r-(this.normal.dot(t)+i)),n=a>=0&&a<=1;return n&&s&&s.lerp(e,t,a),n}intersectsRay(e,t){let s=this.normal.dot(e.direction);if(0===s)return false;let i=-(this.normal.dot(e.origin)+this.distance)/s;return i>=0&&t&&t.copy(e.direction).mulScalar(i).add(e.origin),i>=0}normalize(){let e=1/this.normal.length();return this.normal.mulScalar(e),this.distance*=e,this}set(e,t,s,i){return this.normal.set(e,t,s),this.distance=i,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,s,i,r,a,n,o,l,h,c,d,u,p,f,m,_]=e.data,g=this.planes;g[0].set(r-t,l-a,u-h,_-p).normalize(),g[1].set(r+t,l+a,u+h,_+p).normalize(),g[2].set(r+s,l+n,u+c,_+f).normalize(),g[3].set(r-s,l-n,u-c,_-f).normalize(),g[4].set(r-i,l-o,u-d,_-m).normalize(),g[5].set(r+i,l+o,u+d,_+m).normalize();}containsPoint(e){for(let t=0;t<6;t++){let{normal:s,distance:i}=this.planes[t];if(s.dot(e)+i<=0)return false}return true}containsSphere(e){let{center:t,radius:s}=e,i=0;for(let e=0;e<6;e++){let{normal:r,distance:a}=this.planes[e],n=r.dot(t)+a;if(n<=-s)return 0;n>s&&i++;}return 6===i?2:1}}class e1{constructor(e,t){this.origin=new eD,this.direction=eD.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 eD,e4=new eQ,e5=new eG;class e8{constructor(e=new eG,t){this.halfExtents=new eD(.5,.5,.5),t&&this.halfExtents.copy(t),this._modelTransform=e.clone().invert(),this._worldTransform=e.clone(),this._aabb=new ej(new eD,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 eD,e9=new eD,e7=new eD,te=new eD,tt=new eD;class ts{constructor(e=eD.ZERO,t=eD.ZERO,s=eD.ZERO){this.v0=new eD,this.v1=new eD,this.v2=new eD,this.set(e,t,s);}set(e,t,s){return this.v0.copy(e),this.v1.copy(t),this.v2.copy(s),this}intersectsRay(e,t){e6.sub2(this.v1,this.v0),e9.sub2(this.v2,this.v0),e7.cross(e.direction,e9);let s=e6.dot(e7);if(s>-1e-6&&s<1e-6)return false;let i=1/s;te.sub2(e.origin,this.v0);let r=i*te.dot(e7);if(r<0||r>1)return false;tt.cross(te,e6);let a=i*e.direction.dot(tt);if(a<0||r+a>1)return false;let n=i*e9.dot(tt);return n>1e-6&&(t instanceof eD&&t.copy(e.direction).mulScalar(n).add(e.origin),true)}toString(){return `[${this.v0.toString()}, ${this.v1.toString()}, ${this.v2.toString()}]`}}let ti="linear",tr="inverse",ta="exponential",tn=0,to=1,tl=2,th=0,tc=1,td=2,tu=3,tp=4,tf=5,tm=6,t_=7,tg=8,ty=9,tv=10,tS=11,tx=12,tT=0,tb=1,tE=2,tA=3,tw=4,tC=1,tP=2,tM=4,tI=8,tR=16,tL=32,tD=64,tO=128,tF=256,tN=0,tB=1,tU=2,tk=3,tz=1,tV=2,tG=4,tH=0,tW=1,tX=2,t$=3,tY=4,tq=5,tj=0,tK=1,tZ=2,tQ=3,tJ=0,t0=1,t1=2,t2=3,t3=4,t4=5,t5=0,t8=1,t6=2,t9=3,t7=4,se=5,st=6,ss=7,si=0,sr=1,sa=2,sn=0,so=1,sl=2,sh=3,sc=4,sd=5,su=6,sp=7,sf=8,sm=9,s_=10,sg=11,sy=12,sv=13,sS=14,sx=15,sT=16,sb=17,sE=18,sA=19,sw=20,sC=21,sP=22,sM=23,sI=24,sR=25,sL=26,sD=27,sO=28,sF=29,sN=30,sB=31,sU=32,sk=33,sz=34,sV=35,sG=36,sH=37,sW=38,sX=39,s$=40,sY=41,sq=42,sj=43,sK=44,sZ=45,sQ=46,sJ=47,s0=48,s1=49,s2=50,s3=51,s4=52,s5=53,s8=54,s6=55,s9=56,s7=61,ie=62,it=63,is=64,ii=65,ir=66,ia=67,io=68,il=69,ih=new Map([[sn,{name:"A8",size:1,ldr:true}],[s4,{name:"R8",size:1,ldr:true}],[so,{name:"L8",size:1,ldr:true}],[sl,{name:"LA8",size:2,ldr:true}],[s5,{name:"RG8",size:2,ldr:true}],[sh,{name:"RGB565",size:2,ldr:true}],[sc,{name:"RGBA5551",size:2,ldr:true}],[sd,{name:"RGBA4",size:2,ldr:true}],[su,{name:"RGB8",size:4,ldr:true}],[sp,{name:"RGBA8",size:4,ldr:true,srgbFormat:sw}],[s2,{name:"R16F",size:2}],[s3,{name:"RG16F",size:4}],[sg,{name:"RGB16F",size:8}],[sy,{name:"RGBA16F",size:8}],[sv,{name:"RGB32F",size:16}],[sS,{name:"RGBA32F",size:16}],[sx,{name:"R32F",size:4}],[sT,{name:"DEPTH",size:4}],[il,{name:"DEPTH16",size:2}],[sb,{name:"DEPTHSTENCIL",size:4}],[sE,{name:"111110F",size:4}],[sA,{name:"SRGB8",size:4,ldr:true,srgb:true}],[sw,{name:"SRGBA8",size:4,ldr:true,srgb:true}],[sB,{name:"BGRA8",size:4,ldr:true}],[is,{name:"SBGRA8",size:4,ldr:true,srgb:true}],[sf,{name:"DXT1",blockSize:8,ldr:true,srgbFormat:s8}],[sm,{name:"DXT3",blockSize:16,ldr:true,srgbFormat:s6}],[s_,{name:"DXT5",blockSize:16,ldr:true,srgbFormat:s9}],[sC,{name:"ETC1",blockSize:8,ldr:true}],[sP,{name:"ETC2_RGB",blockSize:8,ldr:true,srgbFormat:s7}],[sM,{name:"ETC2_RGBA",blockSize:16,ldr:true,srgbFormat:ie}],[sI,{name:"PVRTC_2BPP_RGB_1",ldr:true,blockSize:8}],[sR,{name:"PVRTC_2BPP_RGBA_1",ldr:true,blockSize:8}],[sL,{name:"PVRTC_4BPP_RGB_1",ldr:true,blockSize:8}],[sD,{name:"PVRTC_4BPP_RGBA_1",ldr:true,blockSize:8}],[sO,{name:"ASTC_4x4",blockSize:16,ldr:true,srgbFormat:it}],[sF,{name:"ATC_RGB",blockSize:8,ldr:true}],[sN,{name:"ATC_RGBA",blockSize:16,ldr:true}],[ii,{name:"BC6H_RGBF",blockSize:16}],[ir,{name:"BC6H_RGBUF",blockSize:16}],[ia,{name:"BC7_RGBA",blockSize:16,ldr:true,srgbFormat:io}],[s8,{name:"DXT1_SRGB",blockSize:8,ldr:true,srgb:true}],[s6,{name:"DXT3_SRGBA",blockSize:16,ldr:true,srgb:true}],[s9,{name:"DXT5_SRGBA",blockSize:16,ldr:true,srgb:true}],[s7,{name:"ETC2_SRGB",blockSize:8,ldr:true,srgb:true}],[ie,{name:"ETC2_SRGBA",blockSize:16,ldr:true,srgb:true}],[it,{name:"ASTC_4x4_SRGB",blockSize:16,ldr:true,srgb:true}],[io,{name:"BC7_SRGBA",blockSize:16,ldr:true,srgb:true}],[sU,{name:"R8I",size:1,isInt:true}],[sk,{name:"R8U",size:1,isInt:true}],[sz,{name:"R16I",size:2,isInt:true}],[sV,{name:"R16U",size:2,isInt:true}],[sG,{name:"R32I",size:4,isInt:true}],[sH,{name:"R32U",size:4,isInt:true}],[sW,{name:"RG8I",size:2,isInt:true}],[sX,{name:"RG8U",size:2,isInt:true}],[s$,{name:"RG16I",size:4,isInt:true}],[sY,{name:"RG16U",size:4,isInt:true}],[sq,{name:"RG32I",size:8,isInt:true}],[sj,{name:"RG32U",size:8,isInt:true}],[sK,{name:"RGBA8I",size:4,isInt:true}],[sZ,{name:"RGBA8U",size:4,isInt:true}],[sQ,{name:"RGBA16I",size:8,isInt:true}],[sJ,{name:"RGBA16U",size:8,isInt:true}],[s0,{name:"RGBA32I",size:16,isInt:true}],[s1,{name:"RGBA32U",size:16,isInt:true}]]),ic=e=>ih.get(e)?.blockSize!==void 0,id=e=>ih.get(e)?.srgb===true,iu=e=>ih.get(e)?.isInt===true,ip=e=>ih.get(e)?.srgbFormat||e,im=e=>{for(let[t,s]of ih)if(s.srgbFormat===e)return t;return e},i_=e=>{let t=ih.get(e);return !!(t?.ldr&&!t?.srgb)},ig=e=>{switch(e){case sx:case sv:case sS:return Float32Array;case sG:case sq:case s0:return Int32Array;case sH:case sj:case s1:return Uint32Array;case sz:case s$:case sQ:return Int16Array;case s5:case sV:case sY:case sJ:case sh:case sc:case sd:case s2:case s3:case sg:case sy:return Uint16Array;case sU:case sW:case sK:return Int8Array;default:return Uint8Array}},iy=0,iv=1,iS=2,ix=3,iT=4,ib=5,iE=6,iA="POSITION",iw="NORMAL",iC="TANGENT",iP="BLENDWEIGHT",iM="BLENDINDICES",iI="COLOR",iR="TEXCOORD",iL="TEXCOORD0",iD="TEXCOORD1",iO="TEXCOORD2",iF="TEXCOORD3",iN="TEXCOORD4",iB="TEXCOORD5",iU="TEXCOORD6",ik="TEXCOORD7",iz="ATTR0",iV="ATTR1",iG="ATTR2",iH="ATTR3",iW="ATTR4",iX="ATTR5",i$="ATTR6",iY="ATTR7",iq="ATTR8",ij="ATTR9",iK="ATTR10",iZ="ATTR11",iQ="ATTR12",iJ="ATTR13",i0="ATTR14",i1="ATTR15",i2=1,i3=0,i4=1,i5=2,i8=3,i6=4,i9=5,i7=6,re=7,rt=0,rs=1,ri=2,rr="default",ra="rgbm",rn="rgbe",ro="rgbp",rl="swizzleGGGR",rh=0,rc=1,rd=2,ru=3,rp="1d",rf="2d",rm="2d-array",r_="cube",rg="cube-array",ry="3d",rv=0,rS=1,rx=2,rT=3,rb=4,rE="none",rA="cube",rw="equirect",rC="octahedral",rP="glsl",rM="wgsl",rI=0,rR=1,rL=2,rD=3,rO=4,rF=5,rN=6,rB=7,rU=0,rk=1,rz=2,rV=3,rG=4,rH=5,rW=6,rX=7,r$=8,rY=9,rq=10,rj=11,rK=12,rZ=13,rQ=14,rJ=15,r0=16,r1=17,r2=18,r3=19,r4=20,r5=21,r8=22,r6=23,r9=24,r7=25,ae=26,at=27,as=28,ai=29,ar=30,aa=31,an=32,ao=33,al=34,ah=35,ac=36,ad=37,au=38,ap=39,af=40,am=41,a_=42,ag=43,ay=44,av=45,aS=46,ax=47,aT=48,ab=49,aE=["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"],aA=[["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>"]],aw=new Map;aA.forEach((e,t)=>{e.forEach(e=>aw.set(e,t));});let aC=new Uint8Array([rO,rO,rN,rN,rN,rN,rO,rO,rO,rO,rO,rO,rN,rN,rN,rO,rO,rN,rO,rO,rO,rN,rN,rN,rN,rO,rF,rF,rF,rF,rO,rF,rO,rO,rF,rO,rO,rF,rO,rO,rF,rO,rO,rF,rO,rF,rO,rF,rO,rF]),aP="webgl2",aM="webgpu",aI="null",aR=1,aL=2,aD=4,aO="ldr",aF="ldr_srgb",aN="hdr",aB=1,aU=2,ak=4,az=8,aV=16,aG=32,aH=64,aW=128,aX=255,a$=0,aY=1,aq=2,aj=["view","mesh","mesh_ub"],aK="default",aZ="_unused_float_uniform",aQ=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],aJ=[1,1,2,2,4,4,4,2],a0=["INT8","UINT8","INT16","UINT16","INT32","UINT32","FLOAT32","FLOAT16"],a1={Int8Array:rI,Uint8Array:rR,Int16Array:rL,Uint16Array:rD,Int32Array:rO,Uint32Array:rF,Float32Array:rN},a2=[Uint8Array,Uint16Array,Uint32Array],a3=[1,2,4],a4={};a4[iA]=0,a4[iw]=1,a4[iP]=2,a4[iM]=3,a4[iI]=4,a4[iL]=5,a4[iD]=6,a4[iO]=7,a4[iF]=8,a4[iN]=9,a4[iB]=10,a4[iU]=11,a4[ik]=12,a4[iC]=13,a4[iz]=0,a4[iV]=1,a4[iG]=2,a4[iH]=3,a4[iW]=4,a4[iX]=5,a4[i$]=6,a4[iY]=7,a4[iq]=8,a4[ij]=9,a4[iK]=10,a4[iZ]=11,a4[iQ]=12,a4[iJ]=13,a4[i0]=14,a4[i1]=15;let a5="1.51",a8="1.55",a6="1.56",a9="1.57",a7="1.58",ne="1.60",nt="1.62",ns="1.65",ni="1.70",nr="2.1",na="2.3",nn="2.5",no="2.6",nl="2.7",nh=0;class nc{constructor(e,t){this.slot=-1,this.scopeId=null,this.name=e,this.visibility=t;}}class nd extends nc{}class nu extends nc{constructor(e,t,s=false){super(e,t),this.format="",this.readOnly=s;}}class np extends nc{constructor(e,t,s=rf,i=rv,r=true,a=null){super(e,t),this.textureDimension=s,this.sampleType=i,this.hasSampler=r,this.samplerName=a??`${e}_sampler`;}}class nf extends nc{constructor(e,t=sp,s=rf,i=true,r=false){super(e,aD),this.format=t,this.textureDimension=s,this.write=i,this.read=r;}}class nm{constructor(e,t){this.uniformBufferFormats=[],this.textureFormats=[],this.storageTextureFormats=[],this.storageBufferFormats=[],this.id=nh++;let s=0;t.forEach(e=>{e.slot=s++,e instanceof np&&e.hasSampler&&s++,e instanceof nd?this.uniformBufferFormats.push(e):e instanceof np?this.textureFormats.push(e):e instanceof nf?this.storageTextureFormats.push(e):e instanceof nu&&this.storageBufferFormats.push(e);}),this.device=e;let i=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=i.resolve(e.name);}),this.storageTextureFormatsMap=new Map,this.storageTextureFormats.forEach((e,t)=>{this.storageTextureFormatsMap.set(e.name,t),e.scopeId=i.resolve(e.name);}),this.storageBufferFormatsMap=new Map,this.storageBufferFormats.forEach((e,t)=>{this.storageBufferFormatsMap.set(e.name,t),e.scopeId=i.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 n_{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 ng{static calcLevelDimension(e,t){return Math.max(e>>t,1)}static calcMipLevelsCount(e,t,s=1){return 1+Math.floor(Math.log2(Math.max(e,t,s)))}static calcLevelGpuSize(e,t,s,i){let r=ih.get(i),a=ih.get(i)?.size??0;if(a>0)return e*t*s*a;let n=r.blockSize??0,o=Math.floor((e+3)/4),l=Math.floor((t+3)/4),h=Math.floor((s+3)/4);return (i===sI||i===sR)&&(o=Math.max(Math.floor(o/2),1)),o*l*h*n}static calcGpuSize(e,t,s,i,r,a){let n=0;for(;n+=ng.calcLevelGpuSize(e,t,s,i),r&&(1!==e||1!==t||1!==s);)e=Math.max(e>>1,1),t=Math.max(t>>1,1),s=Math.max(s>>1,1);return n*(a?6:1)}}let ny=0;class nv{constructor(e,t={}){this._gpuSize=0,this.id=ny++,this._invalid=false,this._lockedLevel=-1,this._lockedMode=rt,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??sp,this._compressed=ic(this._format),this._integerFormat=iu(this._format),this._integerFormat&&(t.minFilter=tJ,t.magFilter=tJ),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??t4,this._magFilter=t.magFilter??t0,this._anisotropy=t.anisotropy??1,this._addressU=t.addressU??tn,this._addressV=t.addressV??tn,this._addressW=t.addressW??tn,this._compareOnRead=t.compareOnRead??false,this._compareFunc=t.compareFunc??t8,this._type=t.hasOwnProperty("type")?t.type:rr,this.projection=rE,this._cubemap?this.projection=rA:t.projection&&t.projection!==rA&&(this.projection=t.projection),this._levels=t.levels;let s=!!t.levels;this._levels||(this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null]),this.recreateImpl(s),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();}resize(e,t,s=1){let i=this.device;this.adjustVramSizeTracking(i._vram,-this._gpuSize),this.impl.destroy(i),this._width=Math.floor(e),this._height=Math.floor(t),this._depth=Math.floor(s),this._updateNumLevel(),this.impl=i.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?ng.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&&(iu(this._format)||(this._minFilter=e,this.propertyChanged(aB)));}get minFilter(){return this._minFilter}set magFilter(e){this._magFilter!==e&&(iu(this._format)||(this._magFilter=e,this.propertyChanged(aU)));}get magFilter(){return this._magFilter}set addressU(e){this._addressU!==e&&(this._addressU=e,this.propertyChanged(ak));}get addressU(){return this._addressU}set addressV(e){this._addressV!==e&&(this._addressV=e,this.propertyChanged(az));}get addressV(){return this._addressV}set addressW(e){this._volume&&e!==this._addressW&&(this._addressW=e,this.propertyChanged(aV));}get addressW(){return this._addressW}set compareOnRead(e){this._compareOnRead!==e&&(this._compareOnRead=e,this.propertyChanged(aG));}get compareOnRead(){return this._compareOnRead}set compareFunc(e){this._compareFunc!==e&&(this._compareFunc=e,this.propertyChanged(aH));}get compareFunc(){return this._compareFunc}set anisotropy(e){this._anisotropy!==e&&(this._anisotropy=e,this.propertyChanged(aW));}get anisotropy(){return this._anisotropy}set mipmaps(e){this._mipmaps!==e&&(this.device.isWebGPU||iu(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 ng.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!==id(this.format)){if(e){let e=ip(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}else {let e=im(this.format);this._format!==e&&(this._format=e,this.recreateImpl(),this.device._shadersDirty=true);}}}get srgb(){return id(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 eE.powerOfTwo(this._width)&&eE.powerOfTwo(this._height)}get encoding(){switch(this.type){case ra:return "rgbm";case rn:return "rgbe";case ro:return "rgbp"}return i_(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(aX);}lock(e={}){e.level??=0,e.face??=0,e.mode??=ri,this._lockedMode=e.mode,this._lockedLevel=e.level;let t=this.cubemap?this._levels[e.face]:this._levels;if(null===t[e.level]){let s=Math.max(1,this._width>>e.level),i=Math.max(1,this._height>>e.level),r=Math.max(1,this._depth>>e.level),a=new ArrayBuffer(ng.calcLevelGpuSize(s,i,r,this._format));t[e.level]=new(ig(this._format))(a);}return t[e.level]}setSource(e,t=0){let s,i,r=false;if(this._cubemap){if(e[0]){s=e[0].width||0,i=e[0].height||0;for(let t=0;t<6;t++){let a=e[t];if(!a||a.width!==s||a.height!==i||!this.device._isBrowserInterface(a)){r=true;break}}}else r=true;if(!r)for(let s=0;s<6;s++)this._levels[t][s]!==e[s]&&(this._levelsUpdated[t][s]=true);}else this.device._isBrowserInterface(e)||(r=true),r||(e!==this._levels[t]&&(this._levelsUpdated[t]=true),e instanceof HTMLVideoElement?(s=e.videoWidth,i=e.videoHeight):(s=e.width,i=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=s,this._height=i),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===ri&&this.upload(),this._lockedLevel=-1,this._lockedMode=rt;}upload(){this._needsUpload=true,this._needsMipmapsUpload=this._mipmaps,this.impl.uploadImmediate?.(this.device,this);}read(e,t,s,i,r={}){return this.impl.read?.(e,t,s,i,r)}}let nS={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 nx{destroy(){this.map.forEach(e=>{e.destroy();});}constructor(){this.map=new Map;}}let nT=new n_,nb=(e,t)=>{let s=nT.get(e,()=>new nx);if(!s.map.has(t)){let i=new nv(e,{name:`built-in-texture-${t}`,width:1,height:1,format:sp}),r=i.lock(),a=nS[t];r.set(a),i.unlock(),s.map.set(t,i);}return s.map.get(t)},nE=0;class nA{constructor(){this.offsets=[];}}class nw{constructor(e,t,s){this.renderVersionUpdated=-1,this.uniformBufferOffsets=[],this.id=nE++,this.device=e,this.format=t,this.dirty=true,this.impl=e.createBindGroupImpl(this),this.textures=[],this.storageTextures=[],this.storageBuffers=[],this.uniformBuffers=[],this.defaultUniformBuffer=s,s&&this.setUniformBuffer(aK,s);}destroy(){this.impl.destroy(),this.impl=null,this.format=null,this.defaultUniformBuffer=null;}setUniformBuffer(e,t){let s=this.format.bufferFormatsMap.get(e);this.uniformBuffers[s]!==t&&(this.uniformBuffers[s]=t,this.dirty=true);}setStorageBuffer(e,t){let s=this.format.storageBufferFormatsMap.get(e);this.storageBuffers[s]!==t&&(this.storageBuffers[s]=t,this.dirty=true);}setTexture(e,t){let s=this.format.textureFormatsMap.get(e);this.textures[s]!==t?(this.textures[s]=t,this.dirty=true):this.renderVersionUpdated<t.renderVersionDirty&&(this.dirty=true);}setStorageTexture(e,t){let s=this.format.storageTextureFormatsMap.get(e);this.storageTextures[s]!==t?(this.storageTextures[s]=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:s}=this.format;for(let t=0;t<e.length;t++){let s=e[t],i=s.scopeId.value;i||("uSceneDepthMap"===s.name&&(i=nb(this.device,"white")),"uSceneColorMap"===s.name&&(i=nb(this.device,"pink")),i||(i=nb(this.device,"pink"))),this.setTexture(s.name,i);}for(let e=0;e<t.length;e++){let s=t[e],i=s.scopeId.value;this.setStorageTexture(s.name,i);}for(let e=0;e<s.length;e++){let t=s[e],i=t.scopeId.value;this.setStorageBuffer(t.name,i);}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 nC={set:(e,t,s,i=1)=>e&~(i<<s)|t<<s,get:(e,t,s=1)=>e>>t&s,all(e,t,s=1){let i=s<<t;return (e&i)===i},any:(e,t,s=1)=>(e&s<<t)!=0};class nP{constructor(e=false,t=tT,s=tc,i=th,r,a,n,o=true,l=true,h=true,c=true){this.target0=0,this.setColorBlend(t,s,i),this.setAlphaBlend(r??t,a??s,n??i),this.setColorWrite(o,l,h,c),this.blend=e;}set blend(e){this.target0=nC.set(this.target0,+!!e,26);}get blend(){return nC.all(this.target0,26)}setColorBlend(e,t,s){this.target0=nC.set(this.target0,e,0,7),this.target0=nC.set(this.target0,t,3,15),this.target0=nC.set(this.target0,s,7,15);}setAlphaBlend(e,t,s){this.target0=nC.set(this.target0,e,11,7),this.target0=nC.set(this.target0,t,14,15),this.target0=nC.set(this.target0,s,18,15);}setColorWrite(e,t,s,i){this.redWrite=e,this.greenWrite=t,this.blueWrite=s,this.alphaWrite=i;}get colorOp(){return nC.get(this.target0,0,7)}get colorSrcFactor(){return nC.get(this.target0,3,15)}get colorDstFactor(){return nC.get(this.target0,7,15)}get alphaOp(){return nC.get(this.target0,11,7)}get alphaSrcFactor(){return nC.get(this.target0,14,15)}get alphaDstFactor(){return nC.get(this.target0,18,15)}set redWrite(e){this.target0=nC.set(this.target0,+!!e,22);}get redWrite(){return nC.all(this.target0,22)}set greenWrite(e){this.target0=nC.set(this.target0,+!!e,23);}get greenWrite(){return nC.all(this.target0,23)}set blueWrite(e){this.target0=nC.set(this.target0,+!!e,24);}get blueWrite(){return nC.all(this.target0,24)}set alphaWrite(e){this.target0=nC.set(this.target0,+!!e,25);}get alphaWrite(){return nC.all(this.target0,25)}get allWrite(){return nC.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 nP);}static{this.NOWRITE=Object.freeze(new nP(void 0,void 0,void 0,void 0,void 0,void 0,void 0,false,false,false,false));}static{this.ALPHABLEND=Object.freeze(new nP(true,tT,tm,tg));}static{this.ADDBLEND=Object.freeze(new nP(true,tT,tc,tc));}}class nM{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 nI=new nM;class nR{constructor(e=t9,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?t9:ss,this.updateKey();}get test(){return this.func!==ss}set write(e){this.data=nC.set(this.data,+!!e,3),this.updateKey();}get write(){return nC.all(this.data,3)}set func(e){this.data=nC.set(this.data,e,0,7),this.updateKey();}get func(){return nC.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:s}=this,i=`${e}-${t}-${s}`;this.key=nI.get(i);}equals(e){return this.key===e.key}static{this.DEFAULT=Object.freeze(new nR);}static{this.NODEPTH=Object.freeze(new nR(ss,false));}static{this.WRITEDEPTH=Object.freeze(new nR(ss,true));}}class nL{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 nD=0;class nO{constructor(){nD++,this.version=new nL,this.version.globalId=nD;}increment(){this.version.revision++;}}class nF{constructor(e){this.name=e,this.value=null,this.versionObject=new nO;}toJSON(e){}setValue(e){this.value=e,this.versionObject.increment();}getValue(){return this.value}}class nN{constructor(e){this.name=e,this.variables=new Map;}resolve(e){return this.variables.has(e)||this.variables.set(e,new nF(e)),this.variables.get(e)}removeValue(e){for(let t in this.variables){let s=this.variables[t];s.value===e&&(s.value=null);}}}let nB=0;class nU{constructor(e,t,s,i){this.usage=tN,this.usage=i?.usage??tN,this.device=e,this.format=t,this.numVertices=s,this.id=nB++,this.impl=e.createVertexBufferImpl(this,t,i),this.numBytes=t.verticesByteSize?t.verticesByteSize:t.size*s,this.adjustVramSizeTracking(e._vram,this.numBytes);let r=i?.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 nk(e){if(null==e)return 0;let t=0;for(let s=0,i=e.length;s<i;s++)t=(t<<5)-t+e.charCodeAt(s)|0;return t}function nz(e){let t=0x811c9dc5;for(let s=0;s<e.length;s++)t^=e[s],t*=0x1000193;return t>>>0}let nV=new nM,nG=[2,4,8,12,16],nH=new n_;class nW{constructor(e,t,s){this.device=e,this._elements=[],this.hasUv0=false,this.hasUv1=false,this.hasColor=false,this.hasTangents=false,this.verticesByteSize=0,this.vertexCount=s,this.interleaved=void 0===s,this.instancing=false,this.size=t.reduce((e,t)=>e+4*Math.ceil(t.components*aJ[t.type]/4),0);let i=0,r;for(let e=0,a=t.length;e<a;e++){let a=t[e];r=a.components*aJ[a.type],s&&(i=eE.roundUp(i,r));let n=a.asInt??false,o=!n&&(a.normalize??false),l={name:a.semantic,offset:s?i:a.hasOwnProperty("offset")?a.offset:i,stride:s?r:a.hasOwnProperty("stride")?a.stride:this.size,dataType:a.type,numComponents:a.components,normalize:o,size:r,asInt:n};this._elements.push(l),s?i+=r*s:i+=4*Math.ceil(r/4),a.semantic===iL?this.hasUv0=true:a.semantic===iD?this.hasUv1=true:a.semantic===iI?this.hasColor=true:a.semantic===iC&&(this.hasTangents=true);}s&&(this.verticesByteSize=i),this._evaluateHash();}get elements(){return this._elements}static getDefaultInstancingFormat(e){return nH.get(e,()=>new nW(e,[{semantic:iQ,components:4,type:rN},{semantic:iJ,components:4,type:rN},{semantic:i0,components:4,type:rN},{semantic:i1,components:4,type:rN}]))}static isElementValid(e,t){let s=t.components*aJ[t.type];return !e.isWebGPU||!!nG.includes(s)}update(){this._evaluateHash();}_evaluateHash(){let e=[],t=[],s=this._elements.length;for(let i=0;i<s;i++){let{name:s,dataType:r,numComponents:a,normalize:n,offset:o,stride:l,size:h,asInt:c}=this._elements[i],d=s+r+a+n+c;e.push(d);let u=d+o+l+h;t.push(u);}e.sort();let i=e.join();this.batchingHash=nk(i),this.shaderProcessingHashString=i,this.renderingHashString=t.join("_"),this.renderingHash=nV.get(this.renderingHashString);}}let nX=new nM;class n${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??ss,this._ref=e.ref??0,this._readMask=e.readMask??255,this._writeMask=e.writeMask??255,this._fail=e.fail??i3,this._zfail=e.zfail??i3,this._zpass=e.zpass??i3,this._evalKey();}_evalKey(){let{_func:e,_ref:t,_fail:s,_zfail:i,_zpass:r,_readMask:a,_writeMask:n}=this,o=`${e},${t},${s},${i},${r},${a},${n}`;this._key=nX.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 n$);}}class nY extends eo{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.isHdr=false,this.maxColorAttachments=1,this.maxSamples=1,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 nP,this.depthState=new nR,this.stencilEnabled=false,this.stencilFront=new n$,this.stencilBack=new n$,this.defaultClearOptions={color:[0,0,0,1],depth:1,stencil:0,flags:tz|tV},this.clientRect={width:0,height:0},this._shadersDirty=false,this.capsDefines=new Map,this.canvas=e,"setAttribute"in e&&e.setAttribute("data-engine",`PlayCanvas ${z}`),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??=aO,this._maxPixelRatio=ee.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=iy;e<=iE;e++)this._primsPerFrame[e]=0;this._renderTargetCreationTime=0,this.scope=new nN("Device"),this.textureBias=this.scope.resolve("textureBias"),this.textureBias.setValue(0);}postInit(){let e=new nW(this,[{semantic:iA,components:2,type:rN}]),t=new Float32Array([-1,-1,1,-1,-1,1,1,1]);this.quadVertexBuffer=new nU(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","");}destroy(){this.fire("destroy"),this.quadVertexBuffer?.destroy(),this.quadVertexBuffer=null,this.dynamicBuffers?.destroy(),this.dynamicBuffers=null,this.gpuProfiler?.destroy(),this.gpuProfiler=null;}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.indexBuffer=null,this.vertexBuffers=[],this.shader=null,this.shaderValid=void 0,this.shaderAsyncCompile=false,this.renderTarget=null;}initializeRenderState(){this.blendState=new nP,this.depthState=new nR,this.cullMode=tK,this.vx=this.vy=this.vw=this.vh=0,this.sx=this.sy=this.sw=this.sh=0,this.blendColor=new eA(0,0,0,0);}setStencilState(e,t){}setBlendState(e){}setBlendColor(e,t,s,i){}setDepthState(e){}setCullMode(e){}setRenderTarget(e){this.renderTarget=e;}setIndexBuffer(e){this.indexBuffer=e;}setVertexBuffer(e){e&&this.vertexBuffers.push(e);}clearVertexBuffer(){this.vertexBuffers.length=0;}clearIndexBuffer(){this.indexBuffer=null;}getRenderTarget(){return this.renderTarget}initRenderTarget(e){e.initialized||(e.init(),this.targets.add(e));}_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 s=Math.min(this._maxPixelRatio,ee.browser?window.devicePixelRatio:1),i=Math.floor(e*s),r=Math.floor(t*s);(i!==this.canvas.width||r!==this.canvas.height)&&this.setResolution(i,r);}setResolution(e,t){this.canvas.width=e,this.canvas.height=t,this.fire(nY.EVENT_RESIZE,e,t);}updateClientRect(){if(ee.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(){}computeDispatch(e,t="Unnamed"){}getRenderableHdrFormat(e=[sE,sy,sS],t=true,s=1){for(let i=0;i<e.length;i++){let r=e[i];switch(r){case sE:if(this.textureRG11B10Renderable)return r;break;case sy:if(this.textureHalfFloatRenderable)return r;break;case sS:if(this.isWebGPU&&s>1)continue;if(this.textureFloatRenderable&&(!t||this.textureFloatFilterable))return r}}}validateAttributes(e,t,s){}}let nq=0;class nj{constructor(e={}){this.id=nq++;let t=e.colorBuffer?.device??e.colorBuffers?.[0].device??e.depthBuffer?.device??e.graphicsDevice;this._device=t;let{maxSamples:s}=this._device;if(this._samples=Math.min(e.samples??1,s),t.isWebGPU&&(this._samples=this._samples>1?s: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===sT||e===il?(this._depth=true,this._stencil=false):e===sb?(this._depth=true,this._stencil=true):(e===sx&&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.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.width!==e||this.height!==t){if(this.mipLevel>0)return;let s=this._device;this.destroyFrameBuffers(),s.renderTarget===this&&s.setRenderTarget(null),this._depthBuffer?.resize(e,t),this._colorBuffers?.forEach(s=>{s.resize(e,t);}),this.validateMrt(),this.impl=s.createRenderTargetImpl(this);}}validateMrt(){}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,s){if(!this._device){if(!e._device)return false;this._device=e._device;}return this._device.copyRenderTarget(e,this,t,s)}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(){let e=this._colorBuffer?.width||this._depthBuffer?.width||this._device.width;return this._mipLevel>0&&(e=ng.calcLevelDimension(e,this._mipLevel)),e}get height(){let e=this._colorBuffer?.height||this._depthBuffer?.height||this._device.height;return this._mipLevel>0&&(e=ng.calcLevelDimension(e,this._mipLevel)),e}isColorBufferSrgb(e=0){if(this.device.backBuffer===this)return id(this.device.backBufferFormat);let t=this.getColorBuffer(e);return !!t&&id(t.format)}}class nK{update(e){this.destroy();let t=e.device,s=this.createDescriptor(t,e);this.bindGroup=t.wgpu.createBindGroup(s);}destroy(){this.bindGroup=null;}createDescriptor(e,t){let s=[],i=t.format,r=t.format.uniformBufferFormats;t.uniformBuffers.forEach((e,t)=>{let i=r[t].slot,a=e.persistent?e.impl.buffer:e.allocation.gpuBuffer.buffer;s.push({binding:i,resource:{buffer:a,offset:0,size:e.format.byteSize}});});let a=t.format.textureFormats;t.textures.forEach((t,r)=>{let n=t.impl,o=i.textureFormats[r],l=a[r].slot,h=n.getView(e);if(s.push({binding:l,resource:h}),o.hasSampler){let t=n.getSampler(e,o.sampleType);s.push({binding:l+1,resource:t});}});let n=t.format.storageTextureFormats;t.storageTextures.forEach((t,i)=>{let r=t.impl,a=n[i].slot,o=r.getView(e);s.push({binding:a,resource:o});});let o=t.format.storageBufferFormats;return t.storageBuffers.forEach((e,t)=>{let i=e.impl.buffer,r=o[t].slot;s.push({binding:r,resource:{buffer:i}});}),{layout:t.format.impl.bindGroupLayout,entries:s}}}class nZ{static shaderStage(e){let t=0;return e&aR&&(t|=GPUShaderStage.VERTEX),e&aL&&(t|=GPUShaderStage.FRAGMENT),e&aD&&(t|=GPUShaderStage.COMPUTE),t}}let nQ=[];nQ[sn]="",nQ[so]="",nQ[sl]="",nQ[s4]="r8unorm",nQ[s5]="rg8unorm",nQ[sh]="",nQ[sc]="",nQ[sd]="",nQ[su]="rgba8unorm",nQ[sp]="rgba8unorm",nQ[sf]="bc1-rgba-unorm",nQ[sm]="bc2-rgba-unorm",nQ[s_]="bc3-rgba-unorm",nQ[sg]="",nQ[sy]="rgba16float",nQ[s2]="r16float",nQ[s3]="rg16float",nQ[sv]="",nQ[sS]="rgba32float",nQ[sx]="r32float",nQ[sT]="depth32float",nQ[il]="depth16unorm",nQ[sb]="depth24plus-stencil8",nQ[sE]="rg11b10ufloat",nQ[sA]="",nQ[sw]="rgba8unorm-srgb",nQ[sC]="",nQ[sP]="etc2-rgb8unorm",nQ[sM]="etc2-rgba8unorm",nQ[sI]="",nQ[sR]="",nQ[sL]="",nQ[sD]="",nQ[sO]="astc-4x4-unorm",nQ[sF]="",nQ[sN]="",nQ[sB]="bgra8unorm",nQ[is]="bgra8unorm-srgb",nQ[sU]="r8sint",nQ[sk]="r8uint",nQ[sz]="r16sint",nQ[sV]="r16uint",nQ[sG]="r32sint",nQ[sH]="r32uint",nQ[sW]="rg8sint",nQ[sX]="rg8uint",nQ[s$]="rg16sint",nQ[sY]="rg16uint",nQ[sq]="rg32sint",nQ[sj]="rg32uint",nQ[sK]="rgba8sint",nQ[sZ]="rgba8uint",nQ[sQ]="rgba16sint",nQ[sJ]="rgba16uint",nQ[s0]="rgba32sint",nQ[s1]="rgba32uint",nQ[ii]="bc6h-rgb-float",nQ[ir]="bc6h-rgb-ufloat",nQ[ia]="bc7-rgba-unorm",nQ[s8]="bc1-rgba-unorm-srgb",nQ[s6]="bc2-rgba-unorm-srgb",nQ[s9]="bc3-rgba-unorm-srgb",nQ[s7]="etc2-rgb8unorm-srgb",nQ[ie]="etc2-rgba8unorm-srgb",nQ[io]="bc7-rgba-unorm-srgb",nQ[it]="astc-4x4-unorm-srgb";let nJ=[];nJ[rv]="filtering",nJ[rS]="non-filtering",nJ[rx]="comparison",nJ[rT]="comparison",nJ[rb]="comparison";let n0=[];n0[rv]="float",n0[rS]="unfilterable-float",n0[rx]="depth",n0[rT]="sint",n0[rb]="uint";let n1=new nM;class n2{constructor(e){let t=e.device,{key:s,desc:i}=this.createDescriptor(e);this.key=n1.get(s),this.bindGroupLayout=t.wgpu.createBindGroupLayout(i);}destroy(){this.bindGroupLayout=null;}loseContext(){}createDescriptor(e){let t=[],s="";return e.uniformBufferFormats.forEach(e=>{let i=nZ.shaderStage(e.visibility);s+=`#${e.slot}U:${i}`,t.push({binding:e.slot,visibility:i,buffer:{type:"uniform",hasDynamicOffset:true}});}),e.textureFormats.forEach(e=>{let i=nZ.shaderStage(e.visibility),r=e.sampleType,a=e.textureDimension,n=n0[r];if(s+=`#${e.slot}T:${i}-${n}-${a}-false`,t.push({binding:e.slot,visibility:i,texture:{sampleType:n,viewDimension:a,multisampled:false}}),e.hasSampler){let a=nJ[r];s+=`#${e.slot+1}S:${i}-${a}`,t.push({binding:e.slot+1,visibility:i,sampler:{type:a}});}}),e.storageTextureFormats.forEach(e=>{let{format:i,textureDimension:r}=e,{read:a,write:n}=e;s+=`#${e.slot}ST:${i}-${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:nQ[i],viewDimension:r}});}),e.storageBufferFormats.forEach(e=>{let i=e.readOnly,r=nZ.shaderStage(e.visibility);s+=`#${e.slot}SB:${r}-${i?"ro":"rw"}`,t.push({binding:e.slot,visibility:r,buffer:{type:i?"read-only-storage":"storage"}});}),{key:s,desc:{entries:t}}}}class n3{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 s=e.wgpu;if(!this.buffer){let s=t.byteLength+3&-4;this.usageFlags|=GPUBufferUsage.COPY_DST,this.allocate(e,s);}let i=t.byteOffset??0,r=new Uint8Array(t.buffer??t,i,t.byteLength),a=new Uint8Array(this.buffer.size);a.set(r),s.queue.writeBuffer(this.buffer,0,a,0,a.length);}read(e,t,s,i){return e.readStorageBuffer(this,t,s,i)}write(e,t,s,i,r){e.writeStorageBuffer(this,t,s,i,r);}clear(e,t,s){e.clearStorageBuffer(this,t,s);}}class n4 extends n3{constructor(e,t){super(tR|(t?.storage?tO:0)),this.format=null,this.format=e.format===sr?"uint16":"uint32";}unlock(e){let t=e.device;super.unlock(t,e.storage);}}let n5={equals(e,t){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return false;return true}},n8=[];n8[rI]="sint8",n8[rR]="uint8",n8[rL]="sint16",n8[rD]="uint16",n8[rO]="sint32",n8[rF]="uint32",n8[rN]="float32",n8[rB]="float16";let n6=[];n6[rI]="snorm8",n6[rR]="unorm8",n6[rL]="snorm16",n6[rD]="unorm16",n6[rO]="sint32",n6[rF]="uint32",n6[rN]="float32",n6[rB]="float16";class n9{get(e,t=null){let s=this.getKey(e,t),i=this.cache.get(s);return i||(i=this.create(e,t),this.cache.set(s,i)),i}getKey(e,t=null){return `${e?.renderingHashString}-${t?.renderingHashString}`}create(e,t){let s=[],i=e=>{let t=e.interleaved,i=e.instancing?"instance":"vertex",r=[],a=e.elements.length;for(let n=0;n<a;n++){let o=e.elements[n],l=a4[o.name],h=o.normalize?n6:n8;r.push({shaderLocation:l,offset:t?o.offset:0,format:`${h[o.dataType]}${o.numComponents>1?`x${o.numComponents}`:""}`}),t&&n!==a-1||(s.push({attributes:r,arrayStride:o.stride,stepMode:i}),r=[]);}};return e&&i(e),t&&i(t),s}constructor(){this.cache=new Map;}}class n7{constructor(e){this.device=e;}getPipelineLayout(e){let t=[];return e.forEach(e=>{t.push(e.bindGroupLayout);}),this.device.wgpu.createPipelineLayout({bindGroupLayouts:t})}}let oe=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],ot=["add","subtract","reverse-subtract","min","max"],os=["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"],oi=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],or=["none","back","front"],oa=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],on=["","uint16","uint32"];class oo{}class ol extends n7{constructor(e){super(e),this.lookupHashes=new Uint32Array(14),this.vertexBufferLayout=new n9,this.cache=new Map;}get(e,t,s,i,r,a,n,o,l,h,c,d,u){let p=e.type;i&&p!==ix&&p!==ib&&(i=void 0);let f=this.lookupHashes;f[0]=p,f[1]=r.id,f[2]=h,f[3]=l.key,f[4]=o.key,f[5]=t?.renderingHash??0,f[6]=s?.renderingHash??0,f[7]=a.impl.key,f[8]=n[0]?.key??0,f[9]=n[1]?.key??0,f[10]=n[2]?.key??0,f[11]=c?d.key:0,f[12]=c?u.key:0,f[13]=i??0;let m=nz(f),_=this.cache.get(m);if(_)for(let e=0;e<_.length;e++){let t=_[e];if(n5.equals(t.hashes,f))return t.pipeline}let g=oe[p],y=this.getPipelineLayout(n),v=this.vertexBufferLayout.get(t,s),S=new oo;return S.hashes=new Uint32Array(f),S.pipeline=this.create(g,i,r,a,y,o,l,v,h,c,d,u),_?_.push(S):_=[S],this.cache.set(m,_),S.pipeline}getBlend(e){let t;return e.blend&&(t={color:{operation:ot[e.colorOp],srcFactor:os[e.colorSrcFactor],dstFactor:os[e.colorDstFactor]},alpha:{operation:ot[e.alphaOp],srcFactor:os[e.alphaSrcFactor],dstFactor:os[e.alphaDstFactor]}}),t}getDepthStencil(e,t,s,i,r){let a;let{depth:n,stencil:o}=t;return (n||o)&&(a={format:t.impl.depthAttachment.format},n?(a.depthWriteEnabled=e.write,a.depthCompare=oi[e.func],a.depthBias=e.depthBias,a.depthBiasSlopeScale=e.depthBiasSlope):(a.depthWriteEnabled=false,a.depthCompare="always"),o&&s&&(a.stencilReadMas=i.readMask,a.stencilWriteMask=i.writeMask,a.stencilFront={compare:oi[i.func],failOp:oa[i.fail],passOp:oa[i.zpass],depthFailOp:oa[i.zfail]},a.stencilBack={compare:oi[r.func],failOp:oa[r.fail],passOp:oa[r.zpass],depthFailOp:oa[r.zfail]})),a}create(e,t,s,i,r,a,n,o,l,h,c,d){let u=this.device.wgpu,p=s.impl,f={vertex:{module:p.getVertexShaderModule(),entryPoint:p.vertexEntryPoint,buffers:o},primitive:{topology:e,frontFace:"ccw",cullMode:or[l]},depthStencil:this.getDepthStencil(n,i,h,c,d),multisample:{count:i.samples},layout:r};t&&(f.primitive.stripIndexFormat=on[t]),f.fragment={module:p.getFragmentShaderModule(),entryPoint:p.fragmentEntryPoint,targets:[]};let m=i.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(s=>{f.fragment.targets.push({format:s.format,writeMask:e,blend:t});});}return u.createRenderPipeline(f)}}class oh extends n7{get(e,t){let s=this.getPipelineLayout([t.impl]);return this.create(e,s)}create(e,t){let s=this.device.wgpu,i=e.impl,r={compute:{module:i.getComputeShaderModule(),entryPoint:i.computeEntryPoint},layout:t};return s.createComputePipeline(r)}}class oc{incRefCount(){this._refCount++;}decRefCount(){this._refCount--;}get refCount(){return this._refCount}constructor(){this._refCount=0;}}class od extends oc{constructor(e){super(),this.object=e,this.incRefCount();}}class ou{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 od(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 op extends ou{loseContext(e){this.clear();}}let of=new n_,om=e=>of.get(e,()=>new op),o_=new nM;class og{destroy(){this.multisampledBuffer?.destroy(),this.multisampledBuffer=null;}}class oy{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,om(e).release(this.multisampledDepthBufferKey));}}class ov{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=o_.get(t);}assignColorTexture(e,t){this.assignedColorTexture=t;let s=t.createView({format:e.backBufferViewFormat}),i=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?i.resolveTarget=s:i.view=s,this.setColorAttachment(0,void 0,e.backBufferViewFormat),this.updateKey();}setColorAttachment(e,t,s){this.colorAttachments[e]||(this.colorAttachments[e]=new og),t&&(this.colorAttachments[e].multisampledBuffer=t),s&&(this.colorAttachments[e].format=s);}init(e,t){let s=e.wgpu;this.initDepthStencil(e,s,t),t._colorBuffers&&t._colorBuffers.forEach((e,t)=>{this.setColorAttachment(t,void 0,e.impl.format);}),this.renderPassDescriptor.colorAttachments=[];let i=this.isBackbuffer?1:t._colorBuffers?.length??0;for(let r=0;r<i;++r){let i=this.initColor(e,s,t,r),a=0===r&&this.colorAttachments[0]?.format;(i.view||a)&&this.renderPassDescriptor.colorAttachments.push(i);}this.updateKey(),this.initialized=true;}initDepthStencil(e,t,s){let{samples:i,width:r,height:a,depth:n,depthBuffer:o}=s;if(n||o){let s;if(o){if(this.depthAttachment=new oy(o.impl.format),i>1){let n="depth24plus-stencil8";this.depthAttachment.format=n,this.depthAttachment.hasStencil=true;let l=`${o.id}:${r}:${a}:${i}:${n}`,h=om(e),c=h.get(l);if(!c){let e={size:[r,a,1],dimension:"2d",sampleCount:i,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,s=c.createView();}else {let e=o.impl.gpuTexture;this.depthAttachment.depthTexture=e,s=e.createView();}}else {this.depthAttachment=new oy("depth24plus-stencil8");let e={size:[r,a,1],dimension:"2d",sampleCount:i,format:this.depthAttachment.format,usage:GPUTextureUsage.RENDER_ATTACHMENT};i>1?e.usage|=GPUTextureUsage.TEXTURE_BINDING:e.usage|=GPUTextureUsage.COPY_SRC;let n=t.createTexture(e);this.depthAttachment.depthTexture=n,this.depthAttachment.depthTextureInternal=true,s=n.createView();}this.renderPassDescriptor.depthStencilAttachment={view:s};}}initColor(e,t,s,i){let r={},{samples:a,width:n,height:o,mipLevel:l}=s,h=s.getColorBuffer(i),c=null;if(h&&(c=h.cubemap?h.impl.createView({dimension:"2d",baseArrayLayer:s.face,arrayLayerCount:1,mipLevelCount:1,baseMipLevel:l}):h.impl.createView({mipLevelCount:1,baseMipLevel:l})),a>1){let s={size:[n,o,1],dimension:"2d",sampleCount:a,format:this.isBackbuffer?e.backBufferViewFormat:h.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},l=t.createTexture(s);this.setColorAttachment(i,l,s.format),r.view=l.createView(),r.resolveTarget=c;}else r.view=c;return r}setupForRenderPass(e,t){let s=this.renderPassDescriptor.colorAttachments?.length??0;for(let i=0;i<s;++i){let s=this.renderPassDescriptor.colorAttachments[i],r=e.colorArrayOps[i];s.clearValue=t.isColorBufferSrgb(i)?r.clearValueLinear:r.clearValue,s.loadOp=r.clear?"clear":"load",s.storeOp=r.store?"store":"discard";}let i=this.renderPassDescriptor.depthStencilAttachment;i&&(i.depthClearValue=e.depthStencilOps.clearDepthValue,i.depthLoadOp=e.depthStencilOps.clearDepth?"clear":"load",i.depthStoreOp=e.depthStencilOps.storeDepth?"store":"discard",i.depthReadOnly=false,this.depthAttachment.hasStencil&&(i.stencilClearValue=e.depthStencilOps.clearStencilValue,i.stencilLoadOp=e.depthStencilOps.clearStencil?"clear":"load",i.stencilStoreOp=e.depthStencilOps.storeStencil?"store":"discard",i.stencilReadOnly=false));}loseContext(){this.initialized=false;}resolve(e,t,s,i){}}let oS=[];oS[rz]=1,oS[rV]=2,oS[rG]=3,oS[rH]=4,oS[rk]=1,oS[rW]=2,oS[rX]=3,oS[r$]=4,oS[rU]=1,oS[rY]=2,oS[rq]=3,oS[rj]=4,oS[rK]=8,oS[rZ]=12,oS[rQ]=16,oS[ae]=1,oS[at]=2,oS[as]=3,oS[ai]=4;class ox{get isArrayType(){return this.count>0}constructor(e,t,s=0){if(this.shortName=e,this.name=s?`${e}[0]`:e,this.type=t,this.numComponents=oS[t],this.updateType=t,s>0)switch(t){case rz:this.updateType=r1;break;case rk:this.updateType=ar;break;case ae:this.updateType=aa;break;case rU:this.updateType=an;break;case rV:this.updateType=r5;break;case rW:this.updateType=ao;break;case at:this.updateType=al;break;case rY:this.updateType=ah;break;case rG:this.updateType=r8;break;case rX:this.updateType=ac;break;case as:this.updateType=ad;break;case rq:this.updateType=au;break;case rH:this.updateType=r6;break;case r$:this.updateType=ap;break;case ai:this.updateType=af;break;case rj:this.updateType=am;break;case rQ:this.updateType=r9;}this.count=s;let i=this.numComponents;s&&(i=eE.roundUp(i,4)),this.byteSize=4*i,s&&(this.byteSize*=s);}calculateOffset(e){let t=this.byteSize<=8?this.byteSize:16;this.count&&(t=16),e=eE.roundUp(e,t),this.offset=e/4;}}class oT{constructor(e,t){this.byteSize=0,this.map=new Map,this.scope=e.scope,this.uniforms=t;let s=0;for(let e=0;e<t.length;e++){let i=t[e];i.calculateOffset(s),s=4*i.offset+i.byteSize,i.scopeId=this.scope.resolve(i.name),this.map.set(i.name,i);}this.byteSize=eE.roundUp(s,16);}get(e){return this.map.get(e)}}let ob=/[ \t]*(\battribute\b|\bvarying\b|\buniform\b)/g,oE=/(\battribute\b|\bvarying\b|\bout\b|\buniform\b)[ \t]*([^;]+)(;+)/g,oA=/([\w-]+)\[(.*?)\]/,ow=new Set(["highp","mediump","lowp"]),oC=new Set(["sampler2DShadow","samplerCubeShadow","sampler2DArrayShadow"]),oP={sampler2D:rf,sampler3D:ry,samplerCube:r_,samplerCubeShadow:r_,sampler2DShadow:rf,sampler2DArray:rm,sampler2DArrayShadow:rm,isampler2D:rf,usampler2D:rf,isampler3D:ry,usampler3D:ry,isamplerCube:r_,usamplerCube:r_,isampler2DArray:rm,usampler2DArray:rm},oM={[rf]:"texture2D",[r_]:"textureCube",[ry]:"texture3D",[rm]:"texture2DArray"},oI=class{constructor(e,t){this.line=e;let s=e.trim().split(/\s+/);if(ow.has(s[0])&&(this.precision=s.shift()),this.type=s.shift(),e.includes(","),e.includes("[")){let e=s.join(" "),i=oA.exec(e);this.name=i[1],this.arraySize=Number(i[2]),isNaN(this.arraySize)&&(t.failed=true);}else this.name=s.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 oR{static run(e,t,s){let i=new Map,r=oR.extract(t.vshader),a=oR.extract(t.fshader),n=new Map,o=oR.processAttributes(r.attributes,t.attributes,n,t.processingOptions),l=oR.processVaryings(r.varyings,i,true),h=oR.processVaryings(a.varyings,i,false),c=oR.processOuts(a.outs),d=Array.from(new Set(r.uniforms.concat(a.uniforms))).map(e=>new oI(e,s)),u=oR.processUniforms(e,d,t.processingOptions,s),p=`${o}
|
|
2
2
|
${l}
|
|
3
3
|
${u.code}`,f=r.src.replace("@@@",p),m=`${h}
|
|
4
4
|
${c}
|
package/build/playcanvas.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v2.7.5
|
|
3
|
+
* PlayCanvas Engine v2.7.5 revision c00565b (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
|
|
@@ -29,8 +29,8 @@ const TRACEID_TEXTURES = 'Textures';
|
|
|
29
29
|
const TRACEID_RENDER_QUEUE = 'RenderQueue';
|
|
30
30
|
const TRACEID_GPU_TIMINGS = 'GpuTimings';
|
|
31
31
|
|
|
32
|
-
const version = '2.7.5
|
|
33
|
-
const revision = '
|
|
32
|
+
const version = '2.7.5';
|
|
33
|
+
const revision = 'c00565b';
|
|
34
34
|
function extend(target, ex) {
|
|
35
35
|
for(const prop in ex){
|
|
36
36
|
const copy = ex[prop];
|
package/build/playcanvas.prf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v2.7.5
|
|
3
|
+
* PlayCanvas Engine v2.7.5 revision c00565b (PROFILE)
|
|
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
|
|
@@ -296,8 +296,8 @@
|
|
|
296
296
|
"@swc/helpers - typeof";
|
|
297
297
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
298
298
|
}
|
|
299
|
-
var version = '2.7.5
|
|
300
|
-
var revision = '
|
|
299
|
+
var version = '2.7.5';
|
|
300
|
+
var revision = 'c00565b';
|
|
301
301
|
function extend(target, ex) {
|
|
302
302
|
for(var prop in ex){
|
|
303
303
|
var copy = ex[prop];
|