playcanvas
Version:
PlayCanvas WebGL game engine
8 lines • 2.07 MB
JavaScript
let e,t,i,s,r,a,n,o,l,h,c,d,u,f,p,m,_,g,v;/**
* @license
* PlayCanvas Engine v2.14.4 revision a8e9f39 (RELEASE)
* Copyright 2011-2025 PlayCanvas Ltd. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/let S="RenderFrame",y="RenderFrameTime",x="RenderPass",T="RenderPassDetail",E="RenderAction",b="RenderTargetAlloc",w="TextureAlloc",A="ShaderAlloc",C="ShaderCompile",P="VRAM.Texture",L="VRAM.Vb",D="VRAM.Ib",I="VRAM.Sb",R="BindGroupAlloc",M="BindGroupFormatAlloc",O="RenderPipelineAlloc",F="ComputePipelineAlloc",N="PipelineLayoutAlloc",B="Element",U="Textures",k="Assets",z="RenderQueue",V="OctreeResources",G="GpuTimings",H="2.14.4",W="a8e9f39";function X(e,t){for(let i in t){let s=t[i];Array.isArray(s)?e[i]=X([],s):s&&"object"==typeof s?e[i]=X({},s):e[i]=s;}return e}let Y={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)})},q={delimiter:"/",join(...e){let t=e[0];for(let i=0;i<e.length-1;i++){let s=e[i],r=e[i+1];if(r[0]===q.delimiter){t=r;continue}s&&r&&s[s.length-1]!==q.delimiter&&r[0]!==q.delimiter?t+=q.delimiter+r:t+=r;}return t},normalize(e){let t=e.startsWith(q.delimiter),i=e.endsWith(q.delimiter),s=e.split("/"),r="",a=[];for(let e=0;e<s.length;e++)if(""!==s[e]&&"."!==s[e]){if(".."===s[e]&&a.length>0){a=a.slice(0,a.length-2);continue}e>0&&a.push(q.delimiter),a.push(s[e]);}return r=a.join(""),t||r[0]!==q.delimiter||(r=r.slice(1)),i&&r[r.length-1]!==q.delimiter&&(r+=q.delimiter),r},split(e){let t=e.lastIndexOf(q.delimiter);return -1!==t?[e.substring(0,t),e.substring(t+1)]:["",e]},getBasename:e=>q.split(e)[1],getDirectory:e=>q.split(e)[0],getExtension(e){let t=e.split("?")[0].split(".").pop();return t!==e?`.${t}`:""},isRelativePath:e=>"/"!==e.charAt(0)&&null===e.match(/:\/\//),extractPath(e){let t="",i=e.split("/"),s=0;if(i.length>1)if(q.isRelativePath(e))if("."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else if(".."===i[0])for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;else for(s=0,t=".";s<i.length-1;++s)t+=`/${i[s]}`;else for(s=0;s<i.length-1;++s)t+=0===s?i[s]:`/${i[s]}`;return t}},$="undefined"!=typeof navigator?navigator.userAgent:"",j="undefined"!=typeof window?"browser":"undefined"!=typeof global?"node":"worker",K=/android/i.test($)?"android":/ip(?:[ao]d|hone)/i.test($)?"ios":/windows/i.test($)?"windows":/mac os/i.test($)?"osx":/linux/i.test($)?"linux":/cros/i.test($)?"cros":null,Z="browser"!==j?null:/Chrome\/|Chromium\/|Edg.*\//.test($)?"chrome":/Safari\//.test($)?"safari":/Firefox\//.test($)?"firefox":"other",Q=/xbox/i.test($),J="browser"===j&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),ee="browser"===j&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),et="undefined"!=typeof Worker,ei=(()=>{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})(),es={name:K,environment:j,global:("undefined"!=typeof globalThis&&globalThis)??("browser"===j&&window)??("node"===j&&global)??("worker"===j&&self),browser:"browser"===j,worker:"worker"===j,desktop:["windows","osx","linux","cros"].includes(K),mobile:["android","ios"].includes(K),ios:"ios"===K,android:"android"===K,xbox:Q,gamepads:ee,touch:J,workers:et,passiveEvents:ei,browserName:Z},er="abcdefghijklmnopqrstuvwxyz",ea="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function en(e,t=0){let i=e.length;if(t<0||t>=i)return null;let s=e.charCodeAt(t);if(i>1&&s>=55296&&s<=56319){let i=e.charCodeAt(t+1);if(i>=56320&&i<=57343)return {code:(s-55296)*1024+i-56320+65536,long:true}}return {code:s,long:false}}function eo(e,t,i){if(!e)return false;let s=en(e);if(s){let e=s.code;return e>=t&&e<=i}return false}let el={ASCII_LOWERCASE:er,ASCII_UPPERCASE:ea,ASCII_LETTERS:er+ea,format(e,...t){for(let i=0;i<t.length;i++)e=e.replace(`{${i}}`,t[i]);return e},getCodePoint(e,t){let i=en(e,t);return i&&i.code},getCodePoints(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=[];for(;t=en(e,i);)s.push(t.code),i+=t.long?2:1;return s},getSymbols(e){let t;if("string"!=typeof e)throw TypeError("Not a string");let i=0,s=e.length,r=[],a=0;for(;i<s;){if(a+=function(e,t){if(t===e.length-1)return 1;if(eo(e[t],55296,56319)){let i=e.substring(t,t+2),s=e.substring(t+2,t+4);return eo(s,127995,127999)||eo(i,127462,127487)&&eo(s,127462,127487)?4:eo(s,65024,65039)?3:2}return eo(e[t+1],65024,65039)?2:1}(e,i+a),eo(t=e[i+a],8400,8447)&&(t=e[i+a++]),eo(t,65024,65039)&&(t=e[i+a++]),t&&8205===t.charCodeAt(0)){t=e[i+a++];continue}let s=e.substring(i,i+a);r.push(s),i+=a,a=0;}return r},fromCodePoint:(...e)=>e.map(e=>e>65535?String.fromCharCode(((e-=65536)>>10)+55296,e%1024+56320):String.fromCharCode(e)).join("")};class eh{constructor(e,t,i,s,r=false){this._removed=false,this.handler=e,this.name=t,this.callback=i,this.scope=s,this._once=r;}off(){this._removed||this.handler.offByHandle(this);}on(e,t,i=this){return this.handler._addCallback(e,t,i,false)}once(e,t,i=this){return this.handler._addCallback(e,t,i,true)}set removed(e){e&&(this._removed=true);}get removed(){return this._removed}toJSON(e){}}class ec{initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map;}_addCallback(e,t,i,s){if(this._callbacks.has(e)||this._callbacks.set(e,[]),this._callbackActive.has(e)){let t=this._callbackActive.get(e);t&&t===this._callbacks.get(e)&&this._callbackActive.set(e,t.slice());}let r=new eh(this,e,t,i,s);return this._callbacks.get(e).push(r),r}on(e,t,i=this){return this._addCallback(e,t,i,false)}once(e,t,i=this){return this._addCallback(e,t,i,true)}off(e,t,i){if(e)this._callbackActive.has(e)&&this._callbackActive.get(e)===this._callbacks.get(e)&&this._callbackActive.set(e,this._callbackActive.get(e).slice());else for(let[e,t]of this._callbackActive)this._callbacks.has(e)&&this._callbacks.get(e)===t&&this._callbackActive.set(e,t.slice());if(e)if(t){let s=this._callbacks.get(e);if(!s)return this;for(let e=0;e<s.length;e++)s[e].callback===t&&(!i||s[e].scope===i)&&(s[e].removed=true,s.splice(e,1),e--);0===s.length&&this._callbacks.delete(e);}else {let t=this._callbacks.get(e);if(t){for(let e=0;e<t.length;e++)t[e].removed=true;this._callbacks.delete(e);}}else {for(let e of this._callbacks.values())for(let t=0;t<e.length;t++)e[t].removed=true;this._callbacks.clear();}return this}offByHandle(e){let t=e.name;e.removed=true,this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());let i=this._callbacks.get(t);if(!i)return this;let s=i.indexOf(e);return -1!==s&&(i.splice(s,1),0===i.length&&this._callbacks.delete(t)),this}fire(e,t,i,s,r,a,n,o,l){let h;if(!e)return this;let c=this._callbacks.get(e);if(!c)return this;this._callbackActive.has(e)?this._callbackActive.get(e)!==c&&(h=c.slice()):this._callbackActive.set(e,c);for(let c=0;(h||this._callbackActive.get(e))&&c<(h||this._callbackActive.get(e)).length;c++){let d=(h||this._callbackActive.get(e))[c];if(d.callback&&(d.callback.call(d.scope,t,i,s,r,a,n,o,l),d._once)){let t=this._callbacks.get(e),i=t?t.indexOf(d):-1;if(-1!==i){this._callbackActive.get(e)===t&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let s=this._callbacks.get(e);if(!s)continue;s[i].removed=true,s.splice(i,1),0===s.length&&this._callbacks.delete(e);}}}return h||this._callbackActive.delete(e),this}hasEvent(e){return !!this._callbacks.get(e)?.length}constructor(){this._callbacks=new Map,this._callbackActive=new Map;}}class ed{push(e,t){if(this._index[e])throw Error(`Key already in index ${e}`);let i=this._list.push(t)-1;this._index[e]=i;}has(e){return void 0!==this._index[e]}get(e){let t=this._index[e];return void 0!==t?this._list[t]:null}remove(e){let t=this._index[e];if(void 0!==t){for(e in this._list.splice(t,1),delete this._index[e],this._index){let i=this._index[e];i>t&&(this._index[e]=i-1);}return true}return false}list(){return this._list}clear(){for(let e in this._list.length=0,this._index)delete this._index[e];}constructor(){this._list=[],this._index={};}}class eu{static{this.modules={};}static{var e;let t,i;this.wasmSupported=(e=()=>{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},i=t={},()=>(i===t&&(i=e()),i));}static loadScript(e,t){let i=document.createElement("script");i.setAttribute("src",e),i.onload=()=>{t(null);},i.onerror=()=>{t(`Failed to load script='${e}'`);},document.body.appendChild(i);}static loadWasm(e,t,i){let s=eu.wasmSupported()&&t.glueUrl&&t.wasmUrl?t.glueUrl:t.fallbackUrl;s?eu.loadScript(s,s=>{if(s)i(s,null);else {let s=window[e];window[e]=void 0,s({locateFile:()=>t.wasmUrl,onAbort:()=>{i("wasm module aborted.");}}).then(e=>{i(null,e);});}}):i("No supported wasm modules found.",null);}static getModule(e){return eu.modules.hasOwnProperty(e)||(eu.modules[e]={config:null,initializing:false,instance:null,callbacks:[]}),eu.modules[e]}static initialize(e,t){if(t.initializing)return;let i=t.config;(i.glueUrl||i.wasmUrl||i.fallbackUrl)&&(t.initializing=true,eu.loadWasm(e,i,(e,s)=>{e?i.errorHandler&&i.errorHandler(e):(t.instance=s,t.callbacks.forEach(e=>{e(s);}));}));}}class ef{static setConfig(e,t){let i=eu.getModule(e);i.config=t,i.callbacks.length>0&&eu.initialize(e,i);}static getConfig(e){return eu.modules?.[e]?.config}static getInstance(e,t){let i=eu.getModule(e);i.instance?t(i.instance):(i.callbacks.push(t),i.config&&eu.initialize(e,i));}}class ep{constructor(e){this.offset=0,this.arraybuffer=e,this.dataView=new DataView(e);}get remainingBytes(){return this.dataView.byteLength-this.offset}reset(e=0){this.offset=e;}skip(e){this.offset+=e;}align(e){this.offset=this.offset+e-1&~(e-1);}_inc(e){return this.offset+=e,this.offset-e}readChar(){return String.fromCharCode(this.dataView.getUint8(this.offset++))}readChars(e){let t="";for(let i=0;i<e;++i)t+=this.readChar();return t}readU8(){return this.dataView.getUint8(this.offset++)}readU16(){return this.dataView.getUint16(this._inc(2),true)}readU32(){return this.dataView.getUint32(this._inc(4),true)}readU64(){return this.readU32()+0x100000000*this.readU32()}readU32be(){return this.dataView.getUint32(this._inc(4),false)}readArray(e){for(let t=0;t<e.length;++t)e[t]=this.readU8();}readLine(){let e=this.dataView,t="";for(;!(this.offset>=e.byteLength);){let e=String.fromCharCode(this.readU8());if("\n"===e)break;t+=e;}return t}}class em{constructor(e){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=e.sortBy,this._sortHandler=this._doSort.bind(this);}_binarySearch(e){let t,i,s=0,r=this.items.length-1,a=e[this._sortBy];for(;s<=r;)t=Math.floor((s+r)/2),(i=this.items[t][this._sortBy])<=a?s=t+1:i>a&&(r=t-1);return s}_doSort(e,t){let i=this._sortBy;return e[i]-t[i]}insert(e){let t=this._binarySearch(e);this.items.splice(t,0,e),this.length++,this.loopIndex>=t&&this.loopIndex++;}append(e){this.items.push(e),this.length++;}remove(e){let t=this.items.indexOf(e);!(t<0)&&(this.items.splice(t,1),this.length--,this.loopIndex>=t&&this.loopIndex--);}sort(){let e=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),null!==e&&(this.loopIndex=this.items.indexOf(e));}}class e_ extends ec{static{this.EVENT_ADD="add";}static{this.EVENT_REMOVE="remove";}static{this.EVENT_CHANGE="change";}constructor(e){super(),this._index={},this._list=[],this._parent=e;}add(...e){let t=false,i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]||(t=true,this._index[i[e]]=true,this._list.push(i[e]),this.fire("add",i[e],this._parent));return t&&this.fire("change",this._parent),t}remove(...e){let t=false;if(!this._list.length)return t;let i=this._processArguments(e,true);if(!i.length)return t;for(let e=0;e<i.length;e++)this._index[i[e]]&&(t=true,delete this._index[i[e]],this._list.splice(this._list.indexOf(i[e]),1),this.fire("remove",i[e],this._parent));return t&&this.fire("change",this._parent),t}clear(){if(!this._list.length)return;let e=this._list.slice(0);this._list=[],this._index={};for(let t=0;t<e.length;t++)this.fire("remove",e[t],this._parent);this.fire("change",this._parent);}has(...e){return !!this._list.length&&this._has(this._processArguments(e))}_has(e){if(!this._list.length||!e.length)return false;for(let t=0;t<e.length;t++)if(1===e[t].length){if(this._index[e[t][0]])return true}else {let i=true;for(let s=0;s<e[t].length;s++)if(!this._index[e[t][s]]){i=false;break}if(i)return true}return false}list(){return this._list.slice(0)}_processArguments(e,t){let i=[],s=[];if(!e||!e.length)return i;for(let r=0;r<e.length;r++)if(e[r]instanceof Array){t||(s=[]);for(let a=0;a<e[r].length;a++)"string"==typeof e[r][a]&&(t?i.push(e[r][a]):s.push(e[r][a]));!t&&s.length&&i.push(s);}else "string"==typeof e[r]&&(t?i.push(e[r]):i.push([e[r]]));return i}get size(){return this._list.length}}let eg="undefined"!=typeof window&&window.performance&&window.performance.now?performance.now.bind(performance):Date.now;function ev(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 eS=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class ey{constructor(e){let t=e.match(eS);this.scheme=t[2],this.authority=t[4],this.path=t[5],this.query=t[7],this.fragment=t[9];}toString(){let e="";return this.scheme&&(e+=`${this.scheme}:`),this.authority&&(e+=`//${this.authority}`),e+=this.path,this.query&&(e+=`?${this.query}`),this.fragment&&(e+=`#${this.fragment}`),e}getQuery(){let e={};if(this.query)for(let t of decodeURIComponent(this.query).split("&")){let i=t.split("=");e[i[0]]=i[1];}return e}setQuery(e){let t="";for(let i in e)e.hasOwnProperty(i)&&(""!==t&&(t+="&"),t+=`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`);this.query=t;}}class ex{static{this._traceChannels=new Set;}static{this.stack=false;}static set(e,t=true){}static get(e){return ex._traceChannels.has(e)}}let eT=0,eE=1,eb=4,ew=5,eA={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp:(e,t,i)=>e>=i?i:e<=t?t:e,intToBytes24:e=>[e>>16&255,e>>8&255,255&e],intToBytes32:e=>[e>>24&255,e>>16&255,e>>8&255,255&e],bytesToInt24:(e,t,i)=>(e.length&&(i=e[2],t=e[1],e=e[0]),e<<16|t<<8|i),bytesToInt32:(e,t,i,s)=>(e.length&&(s=e[3],i=e[2],t=e[1],e=e[0]),(e<<24|t<<16|i<<8|s)>>>0),lerp:(e,t,i)=>e+(t-e)*eA.clamp(i,0,1),lerpAngle:(e,t,i)=>(t-e>180&&(t-=360),t-e<-180&&(t+=360),eA.lerp(e,t,eA.clamp(i,0,1))),powerOfTwo:e=>0!==e&&!(e&e-1),nextPowerOfTwo:e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e),nearestPowerOfTwo:e=>Math.pow(2,Math.round(Math.log2(e))),random:(e,t)=>Math.random()*(t-e)+e,smoothstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*(3-2*i),smootherstep:(e,t,i)=>i<=e?0:i>=t?1:(i=(i-e)/(t-e))*i*i*(i*(6*i-15)+10),roundUp:(e,t)=>0===t?e:Math.ceil(e/t)*t,between(e,t,i,s){let r=Math.min(t,i),a=Math.max(t,i);return s?e>=r&&e<=a:e>r&&e<a}};class eC{constructor(e=0,t=0,i=0,s=1){let r=e.length;3===r||4===r?(this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3]??1):(this.r=e,this.g=t,this.b=i,this.a=s);}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}equals(e){return this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}set(e,t,i,s=1){return this.r=e,this.g=t,this.b=i,this.a=s,this}lerp(e,t,i){return this.r=e.r+i*(t.r-e.r),this.g=e.g+i*(t.g-e.g),this.b=e.b+i*(t.b-e.b),this.a=e.a+i*(t.a-e.a),this}linear(e=this){return this.r=Math.pow(e.r,2.2),this.g=Math.pow(e.g,2.2),this.b=Math.pow(e.b,2.2),this.a=e.a,this}gamma(e=this){return this.r=Math.pow(e.r,1/2.2),this.g=Math.pow(e.g,1/2.2),this.b=Math.pow(e.b,1/2.2),this.a=e.a,this}mulScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}fromString(e){let t,i=parseInt(e.replace("#","0x"),16);return e.length>7?t=eA.intToBytes32(i):(t=eA.intToBytes24(i))[3]=255,this.set(t[0]/255,t[1]/255,t[2]/255,t[3]/255),this}fromArray(e,t=0){return this.r=e[t]??this.r,this.g=e[t+1]??this.g,this.b=e[t+2]??this.b,this.a=e[t+3]??this.a,this}toString(e,t){let{r:i,g:s,b:r,a}=this;if(t||i>1||s>1||r>1)return `${i.toFixed(3)}, ${s.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let n=`#${(0x1000000+(Math.round(255*i)<<16)+(Math.round(255*s)<<8)+Math.round(255*r)).toString(16).slice(1)}`;if(true===e){let e=Math.round(255*a).toString(16);this.a<16/255?n+=`0${e}`:n+=e;}return n}toArray(e=[],t=0,i=true){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,i&&(e[t+3]=this.a),e}static{this.BLACK=Object.freeze(new eC(0,0,0,1));}static{this.BLUE=Object.freeze(new eC(0,0,1,1));}static{this.CYAN=Object.freeze(new eC(0,1,1,1));}static{this.GRAY=Object.freeze(new eC(.5,.5,.5,1));}static{this.GREEN=Object.freeze(new eC(0,1,0,1));}static{this.MAGENTA=Object.freeze(new eC(1,0,1,1));}static{this.RED=Object.freeze(new eC(1,0,0,1));}static{this.WHITE=Object.freeze(new eC(1,1,1,1));}static{this.YELLOW=Object.freeze(new eC(1,1,0,1));}}class eP{constructor(e,t=0){this._left=-1/0,this._right=1/0,this._recip=0,this._p0=0,this._p1=0,this._m0=0,this._m1=0,this._curve=e,this._reset(t);}evaluate(e,t=false){let i;(t||e<this._left||e>=this._right)&&this._reset(e);let s=this._curve.type;if(s===ew)i=this._p0;else {let t=0===this._recip?0:(e-this._left)*this._recip;i=s===eT?eA.lerp(this._p0,this._p1,t):s===eE?eA.lerp(this._p0,this._p1,t*t*(3-2*t)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,t);}return i}_reset(e){let t=this._curve.keys,i=t.length;if(i)if(e<t[0][0])this._left=-1/0,this._right=t[0][0],this._recip=0,this._p0=this._p1=t[0][1],this._m0=this._m1=0;else if(e>=t[i-1][0])this._left=t[i-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=t[i-1][1],this._m0=this._m1=0;else {let i=0;for(;e>=t[i+1][0];)i++;this._left=t[i][0],this._right=t[i+1][0];let s=1/(this._right-this._left);this._recip=isFinite(s)?s:0,this._p0=t[i][1],this._p1=t[i+1][1],this._curve.type===eb&&this._calcTangents(t,i);}else this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0;}_calcTangents(e,t){let i,s,r=e[t],a=e[t+1];if(i=0===t?[e[0][0]+(e[0][0]-e[1][0]),e[0][1]+(e[0][1]-e[1][1])]:e[t-1],s=t===e.length-2?[e[t+1][0]+(e[t+1][0]-e[t][0]),e[t+1][1]+(e[t+1][1]-e[t][1])]:e[t+2],this._curve.type===eb){let e=2*(a[0]-r[0])/(a[0]-i[0]),t=2*(a[0]-r[0])/(s[0]-r[0]);this._m0=this._curve.tension*(isFinite(e)?e:0)*(a[1]-i[1]),this._m1=this._curve.tension*(isFinite(t)?t:0)*(s[1]-r[1]);}else {let e=(a[0]-r[0])/(r[0]-i[0]),t=(a[0]-r[0])/(s[0]-a[0]),n=r[1]+(i[1]-r[1])*(isFinite(e)?e:0),o=a[1]+(s[1]-a[1])*(isFinite(t)?t:0),l=this._curve.tension;this._m0=l*(a[1]-n),this._m1=l*(o-r[1]);}}_evaluateHermite(e,t,i,s,r){let a=r*r,n=r+r,o=1-r,l=o*o;return (1+n)*l*e+r*l*i+a*(3-n)*t+a*(r-1)*s}}class eL{constructor(e){if(this.keys=[],this.type=eE,this.tension=.5,this._eval=new eP(this),e)for(let t=0;t<e.length-1;t+=2)this.keys.push([e[t],e[t+1]]);this.sort();}get length(){return this.keys.length}add(e,t){let i=this.keys,s=i.length,r=0;for(;r<s&&!(i[r][0]>e);r++);let a=[e,t];return this.keys.splice(r,0,a),a}get(e){return this.keys[e]}sort(){this.keys.sort((e,t)=>e[0]-t[0]);}value(e){return this._eval.evaluate(e,true)}closest(e){let t=this.keys,i=t.length,s=2,r=null;for(let a=0;a<i;a++){let i=Math.abs(e-t[a][0]);if(s>=i)s=i,r=t[a];else break}return r}clone(){let e=new this.constructor;return e.keys=this.keys.map(e=>[...e]),e.type=this.type,e.tension=this.tension,e}quantize(e){let t=new Float32Array(e=Math.max(e,2)),i=1/(e-1);t[0]=this._eval.evaluate(0,true);for(let s=1;s<e;s++)t[s]=this._eval.evaluate(i*s);return t}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}class eD{constructor(...e){if(this.curves=[],this._type=eE,e.length>1)for(let t=0;t<e.length;t++)this.curves.push(new eL(e[t]));else if(0===e.length)this.curves.push(new eL);else {let t=e[0];if("number"==typeof t)for(let e=0;e<t;e++)this.curves.push(new eL);else for(let e=0;e<t.length;e++)this.curves.push(new eL(t[e]));}}get length(){return this.curves.length}set type(e){this._type=e;for(let t=0;t<this.curves.length;t++)this.curves[t].type=e;}get type(){return this._type}get(e){return this.curves[e]}value(e,t=[]){let i=this.curves.length;t.length=i;for(let s=0;s<i;s++)t[s]=this.curves[s].value(e);return t}clone(){let e=new this.constructor;e.curves=[];for(let t=0;t<this.curves.length;t++)e.curves.push(this.curves[t].clone());return e._type=this._type,e}quantize(e){e=Math.max(e,2);let t=this.curves.length,i=new Float32Array(e*t),s=1/(e-1);for(let r=0;r<t;r++){let a=new eP(this.curves[r]);for(let n=0;n<e;n++)i[n*t+r]=a.evaluate(s*n);}return i}quantizeClamped(e,t,i){let s=this.quantize(e);for(let e=0;e<s.length;++e)s[e]=Math.min(i,Math.max(t,s[e]));return s}}let eI=new Float32Array(1),eR=new Int32Array(eI.buffer);class eM{static float2Half(e){eI[0]=e;let t=eR[0],i=t>>16&32768,s=t>>12&2047,r=t>>23&255;return r<103?i:r>142?(i|=31744,i|=+(255!==r)&&8388607&t):r<113?(s|=2048,i|=(s>>114-r)+(s>>113-r&1)):(i|=r-112<<10|s>>1,i+=1&s)}static float2RGBA8(e,t){eI[0]=e;let i=eR[0];t.r=(i>>24&255)/255,t.g=(i>>16&255)/255,t.b=(i>>8&255)/255,t.a=(255&i)/255;}}class eO{static concentric(e,t){let i=[];i.push(0,0);let s=2*Math.PI/e/t;for(let t=1;t<=e;t++){let r=t/e,a=Math.max(1,Math.floor(2*Math.PI*r/s)),n=2*Math.PI/a;for(let e=0;e<a;e++){let t=e*n,s=r*Math.cos(t),a=r*Math.sin(t);i.push(s,a);}}return i}}class eF{constructor(e=0,t=0,i=0){3===e.length?(this.x=e[0],this.y=e[1],this.z=e[2]):(this.x=e,this.y=t,this.z=i);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}cross(e,t){let i=e.x,s=e.y,r=e.z,a=t.x,n=t.y,o=t.z;return this.x=s*o-n*r,this.y=r*a-o*i,this.z=i*n-a*s,this}distance(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return Math.sqrt(t*t+i*i+s*s)}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this}project(e){let t=(this.x*e.x+this.y*e.y+this.z*e.z)/(e.x*e.x+e.y*e.y+e.z*e.z);return this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this}toString(){return `[${this.x}, ${this.y}, ${this.z}]`}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}static{this.ZERO=Object.freeze(new eF(0,0,0));}static{this.HALF=Object.freeze(new eF(.5,.5,.5));}static{this.ONE=Object.freeze(new eF(1,1,1));}static{this.UP=Object.freeze(new eF(0,1,0));}static{this.DOWN=Object.freeze(new eF(0,-1,0));}static{this.RIGHT=Object.freeze(new eF(1,0,0));}static{this.LEFT=Object.freeze(new eF(-1,0,0));}static{this.FORWARD=Object.freeze(new eF(0,0,-1));}static{this.BACK=Object.freeze(new eF(0,0,1));}}class eN{constructor(){this.data=new Float32Array(9),this.data[0]=this.data[4]=this.data[8]=1;}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}getX(e=new eF){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eF){return e.set(this.data[3],this.data[4],this.data[5])}getZ(e=new eF){return e.set(this.data[6],this.data[7],this.data[8])}equals(e){let t=this.data,i=e.data;return t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]&&t[4]===i[4]&&t[5]===i[5]&&t[6]===i[6]&&t[7]===i[7]&&t[8]===i[8]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&1===e[4]&&0===e[5]&&0===e[6]&&0===e[7]&&1===e[8]}setIdentity(){let e=this.data;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this}toString(){return `[${this.data.join(", ")}]`}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[3],i[3]=e,e=t[2],i[2]=t[6],i[6]=e,e=t[5],i[5]=t[7],i[7]=e;}else i[0]=t[0],i[1]=t[3],i[2]=t[6],i[3]=t[1],i[4]=t[4],i[5]=t[7],i[6]=t[2],i[7]=t[5],i[8]=t[8];return this}setFromMat4(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[4],i[4]=t[5],i[5]=t[6],i[6]=t[8],i[7]=t[9],i[8]=t[10],this}setFromQuat(e){let t=e.x,i=e.y,s=e.z,r=e.w,a=t+t,n=i+i,o=s+s,l=t*a,h=t*n,c=t*o,d=i*n,u=i*o,f=s*o,p=r*a,m=r*n,_=r*o,g=this.data;return g[0]=1-(d+f),g[1]=h+_,g[2]=c-m,g[3]=h-_,g[4]=1-(l+f),g[5]=u+p,g[6]=c+m,g[7]=u-p,g[8]=1-(l+d),this}invertMat4(e){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[4],n=t[5],o=t[6],l=t[8],h=t[9],c=t[10],d=c*n-o*h,u=-c*a+o*l,f=h*a-n*l,p=i*d+s*u+r*f;if(0===p)this.setIdentity();else {let e=1/p,t=this.data;t[0]=d*e,t[1]=(-c*s+r*h)*e,t[2]=(o*s-r*n)*e,t[3]=u*e,t[4]=(c*i-r*l)*e,t[5]=(-o*i+r*a)*e,t[6]=f*e,t[7]=(-h*i+s*l)*e,t[8]=(n*i-s*a)*e;}return this}transformVector(e,t=new eF){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[3]+a*i[6],t.y=s*i[1]+r*i[4]+a*i[7],t.z=s*i[2]+r*i[5]+a*i[8],t}static{this.IDENTITY=Object.freeze(new eN);}static{this.ZERO=Object.freeze(new eN().set([0,0,0,0,0,0,0,0,0]));}}class eB{constructor(e=0,t=0){2===e.length?(this.x=e[0],this.y=e[1]):(this.x=e,this.y=t);}add(e){return this.x+=e.x,this.y+=e.y,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}cross(e){return this.x*e.y-this.y*e.x}distance(e){let t=this.x-e.x,i=this.y-e.y;return Math.sqrt(t*t+i*i)}div(e){return this.x/=e.x,this.y/=e.y,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}divScalar(e){return this.x/=e,this.y/=e,this}dot(e){return this.x*e.x+this.y*e.y}equals(e){return this.x===e.x&&this.y===e.y}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSq(){return this.x*this.x+this.y*this.y}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this}mul(e){return this.x*=e.x,this.y*=e.y,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}mulScalar(e){return this.x*=e,this.y*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i;}return this}rotate(e){let t=Math.atan2(this.x,this.y)+e*eA.DEG_TO_RAD,i=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(t)*i,this.y=Math.cos(t)*i,this}angle(){return Math.atan2(this.x,this.y)*eA.RAD_TO_DEG}angleTo(e){return Math.atan2(this.x*e.y+this.y*e.x,this.x*e.x+this.y*e.y)*eA.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 eB(0,0));}static{this.HALF=Object.freeze(new eB(.5,.5));}static{this.ONE=Object.freeze(new eB(1,1));}static{this.UP=Object.freeze(new eB(0,1));}static{this.DOWN=Object.freeze(new eB(0,-1));}static{this.RIGHT=Object.freeze(new eB(1,0));}static{this.LEFT=Object.freeze(new eB(-1,0));}}class eU{constructor(e=0,t=0,i=0,s=0){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}add2(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addScaled(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}div(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}div2(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this.z=e.z/t.z,this.w=e.w/t.w,this}divScalar(e){return this.x/=e,this.y/=e,this.z/=e,this.w/=e,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){return this.x=e.x+i*(t.x-e.x),this.y=e.y+i*(t.y-e.y),this.z=e.z+i*(t.z-e.z),this.w=e.w+i*(t.w-e.w),this}mul(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}mul2(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this.w=e.w*t.w,this}mulScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}normalize(e=this){let t=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;if(t>0){let i=1/Math.sqrt(t);this.x=e.x*i,this.y=e.y*i,this.z=e.z*i,this.w=e.w*i;}return this}floor(e=this){return this.x=Math.floor(e.x),this.y=Math.floor(e.y),this.z=Math.floor(e.z),this.w=Math.floor(e.w),this}ceil(e=this){return this.x=Math.ceil(e.x),this.y=Math.ceil(e.y),this.z=Math.ceil(e.z),this.w=Math.ceil(e.w),this}round(e=this){return this.x=Math.round(e.x),this.y=Math.round(e.y),this.z=Math.round(e.z),this.w=Math.round(e.w),this}min(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this}max(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}sub2(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){return `[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}static{this.ZERO=Object.freeze(new eU(0,0,0,0));}static{this.HALF=Object.freeze(new eU(.5,.5,.5,.5));}static{this.ONE=Object.freeze(new eU(1,1,1,1));}}let ek=new eB,ez=new eF,eV=new eF,eG=new eF,eH=new eF;class eW{constructor(){this.data=new Float32Array(16),this.data[0]=this.data[5]=this.data[10]=this.data[15]=1;}static _getPerspectiveHalfSize(e,t,i,s,r){r?(e.x=s*Math.tan(t*Math.PI/360),e.y=e.x/i):(e.y=s*Math.tan(t*Math.PI/360),e.x=e.y*i);}add2(e,t){let i=e.data,s=t.data,r=this.data;return r[0]=i[0]+s[0],r[1]=i[1]+s[1],r[2]=i[2]+s[2],r[3]=i[3]+s[3],r[4]=i[4]+s[4],r[5]=i[5]+s[5],r[6]=i[6]+s[6],r[7]=i[7]+s[7],r[8]=i[8]+s[8],r[9]=i[9]+s[9],r[10]=i[10]+s[10],r[11]=i[11]+s[11],r[12]=i[12]+s[12],r[13]=i[13]+s[13],r[14]=i[14]+s[14],r[15]=i[15]+s[15],this}add(e){return this.add2(this,e)}clone(){return new this.constructor().copy(this)}copy(e){let t=e.data,i=this.data;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],this}equals(e){let t=this.data,i=e.data;return t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]&&t[4]===i[4]&&t[5]===i[5]&&t[6]===i[6]&&t[7]===i[7]&&t[8]===i[8]&&t[9]===i[9]&&t[10]===i[10]&&t[11]===i[11]&&t[12]===i[12]&&t[13]===i[13]&&t[14]===i[14]&&t[15]===i[15]}isIdentity(){let e=this.data;return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}mul2(e,t){let i,s,r,a,n=e.data,o=t.data,l=this.data,h=n[0],c=n[1],d=n[2],u=n[3],f=n[4],p=n[5],m=n[6],_=n[7],g=n[8],v=n[9],S=n[10],y=n[11],x=n[12],T=n[13],E=n[14],b=n[15];return i=o[0],s=o[1],r=o[2],a=o[3],l[0]=h*i+f*s+g*r+x*a,l[1]=c*i+p*s+v*r+T*a,l[2]=d*i+m*s+S*r+E*a,l[3]=u*i+_*s+y*r+b*a,i=o[4],s=o[5],r=o[6],a=o[7],l[4]=h*i+f*s+g*r+x*a,l[5]=c*i+p*s+v*r+T*a,l[6]=d*i+m*s+S*r+E*a,l[7]=u*i+_*s+y*r+b*a,i=o[8],s=o[9],r=o[10],a=o[11],l[8]=h*i+f*s+g*r+x*a,l[9]=c*i+p*s+v*r+T*a,l[10]=d*i+m*s+S*r+E*a,l[11]=u*i+_*s+y*r+b*a,i=o[12],s=o[13],r=o[14],a=o[15],l[12]=h*i+f*s+g*r+x*a,l[13]=c*i+p*s+v*r+T*a,l[14]=d*i+m*s+S*r+E*a,l[15]=u*i+_*s+y*r+b*a,this}mulAffine2(e,t){let i,s,r,a=e.data,n=t.data,o=this.data,l=a[0],h=a[1],c=a[2],d=a[4],u=a[5],f=a[6],p=a[8],m=a[9],_=a[10],g=a[12],v=a[13],S=a[14];return i=n[0],s=n[1],r=n[2],o[0]=l*i+d*s+p*r,o[1]=h*i+u*s+m*r,o[2]=c*i+f*s+_*r,o[3]=0,i=n[4],s=n[5],r=n[6],o[4]=l*i+d*s+p*r,o[5]=h*i+u*s+m*r,o[6]=c*i+f*s+_*r,o[7]=0,i=n[8],s=n[9],r=n[10],o[8]=l*i+d*s+p*r,o[9]=h*i+u*s+m*r,o[10]=c*i+f*s+_*r,o[11]=0,i=n[12],s=n[13],r=n[14],o[12]=l*i+d*s+p*r+g,o[13]=h*i+u*s+m*r+v,o[14]=c*i+f*s+_*r+S,o[15]=1,this}mul(e){return this.mul2(this,e)}transformPoint(e,t=new eF){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+i[12],t.y=s*i[1]+r*i[5]+a*i[9]+i[13],t.z=s*i[2]+r*i[6]+a*i[10]+i[14],t}transformVector(e,t=new eF){let i=this.data,{x:s,y:r,z:a}=e;return t.x=s*i[0]+r*i[4]+a*i[8],t.y=s*i[1]+r*i[5]+a*i[9],t.z=s*i[2]+r*i[6]+a*i[10],t}transformVec4(e,t=new eU){let i=this.data,{x:s,y:r,z:a,w:n}=e;return t.x=s*i[0]+r*i[4]+a*i[8]+n*i[12],t.y=s*i[1]+r*i[5]+a*i[9]+n*i[13],t.z=s*i[2]+r*i[6]+a*i[10]+n*i[14],t.w=s*i[3]+r*i[7]+a*i[11]+n*i[15],t}setLookAt(e,t,i){eG.sub2(e,t).normalize(),eV.copy(i).normalize(),ez.cross(eV,eG).normalize(),eV.cross(eG,ez);let s=this.data;return s[0]=ez.x,s[1]=ez.y,s[2]=ez.z,s[3]=0,s[4]=eV.x,s[5]=eV.y,s[6]=eV.z,s[7]=0,s[8]=eG.x,s[9]=eG.y,s[10]=eG.z,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}setFrustum(e,t,i,s,r,a){let n=2*r,o=t-e,l=s-i,h=a-r,c=this.data;return c[0]=n/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=n/l,c[6]=0,c[7]=0,c[8]=(t+e)/o,c[9]=(s+i)/l,c[10]=(-a-r)/h,c[11]=-1,c[12]=0,c[13]=0,c[14]=-n*a/h,c[15]=0,this}setPerspective(e,t,i,s,r){return eW._getPerspectiveHalfSize(ek,e,t,i,r),this.setFrustum(-ek.x,ek.x,-ek.y,ek.y,i,s)}setOrtho(e,t,i,s,r,a){let n=this.data;return n[0]=2/(t-e),n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=2/(s-i),n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=-2/(a-r),n[11]=0,n[12]=-(t+e)/(t-e),n[13]=-(s+i)/(s-i),n[14]=-(a+r)/(a-r),n[15]=1,this}setFromAxisAngle(e,t){t*=eA.DEG_TO_RAD;let{x:i,y:s,z:r}=e,a=Math.cos(t),n=Math.sin(t),o=1-a,l=o*i,h=o*s,c=this.data;return c[0]=l*i+a,c[1]=l*s+n*r,c[2]=l*r-n*s,c[3]=0,c[4]=l*s-n*r,c[5]=h*s+a,c[6]=h*r+n*i,c[7]=0,c[8]=l*r+n*s,c[9]=h*r-i*n,c[10]=o*r*r+a,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,this}setTranslate(e,t,i){let s=this.data;return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=e,s[13]=t,s[14]=i,s[15]=1,this}setScale(e,t,i){let s=this.data;return s[0]=e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=t,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=i,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}setViewport(e,t,i,s){let r=this.data;return r[0]=.5*i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=.5*s,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=e+.5*i,r[13]=t+.5*s,r[14]=.5,r[15]=1,this}setReflection(e,t){let i=e.x,s=e.y,r=e.z,a=this.data;return a[0]=1-2*i*i,a[1]=-2*i*s,a[2]=-2*i*r,a[3]=0,a[4]=-2*i*s,a[5]=1-2*s*s,a[6]=-2*s*r,a[7]=0,a[8]=-2*i*r,a[9]=-2*s*r,a[10]=1-2*r*r,a[11]=0,a[12]=-2*i*t,a[13]=-2*s*t,a[14]=-2*r*t,a[15]=1,this}invert(e=this){let t=e.data,i=t[0],s=t[1],r=t[2],a=t[3],n=t[4],o=t[5],l=t[6],h=t[7],c=t[8],d=t[9],u=t[10],f=t[11],p=t[12],m=t[13],_=t[14],g=t[15],v=i*o-s*n,S=i*l-r*n,y=i*h-a*n,x=s*l-r*o,T=s*h-a*o,E=r*h-a*l,b=c*m-d*p,w=c*_-u*p,A=c*g-f*p,C=d*_-u*m,P=d*g-f*m,L=u*g-f*_,D=v*L-S*P+y*C+x*A-T*w+E*b;if(0===D)this.setIdentity();else {let e=1/D,t=this.data;t[0]=(o*L-l*P+h*C)*e,t[1]=(-s*L+r*P-a*C)*e,t[2]=(m*E-_*T+g*x)*e,t[3]=(-d*E+u*T-f*x)*e,t[4]=(-n*L+l*A-h*w)*e,t[5]=(i*L-r*A+a*w)*e,t[6]=(-p*E+_*y-g*S)*e,t[7]=(c*E-u*y+f*S)*e,t[8]=(n*P-o*A+h*b)*e,t[9]=(-i*P+s*A-a*b)*e,t[10]=(p*T-m*y+g*v)*e,t[11]=(-c*T+d*y-f*v)*e,t[12]=(-n*C+o*w-l*b)*e,t[13]=(i*C-s*w+r*b)*e,t[14]=(-p*x+m*S-_*v)*e,t[15]=(c*x-d*S+u*v)*e;}return this}set(e){let t=this.data;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}setIdentity(){let e=this.data;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}setTRS(e,t,i){let s=t.x,r=t.y,a=t.z,n=t.w,o=i.x,l=i.y,h=i.z,c=s+s,d=r+r,u=a+a,f=s*c,p=s*d,m=s*u,_=r*d,g=r*u,v=a*u,S=n*c,y=n*d,x=n*u,T=this.data;return T[0]=(1-(_+v))*o,T[1]=(p+x)*o,T[2]=(m-y)*o,T[3]=0,T[4]=(p-x)*l,T[5]=(1-(f+v))*l,T[6]=(g+S)*l,T[7]=0,T[8]=(m+y)*h,T[9]=(g-S)*h,T[10]=(1-(f+_))*h,T[11]=0,T[12]=e.x,T[13]=e.y,T[14]=e.z,T[15]=1,this}transpose(e=this){let t=e.data,i=this.data;if(t===i){let e;e=t[1],i[1]=t[4],i[4]=e,e=t[2],i[2]=t[8],i[8]=e,e=t[3],i[3]=t[12],i[12]=e,e=t[6],i[6]=t[9],i[9]=e,e=t[7],i[7]=t[13],i[13]=e,e=t[11],i[11]=t[14],i[14]=e;}else i[0]=t[0],i[1]=t[4],i[2]=t[8],i[3]=t[12],i[4]=t[1],i[5]=t[5],i[6]=t[9],i[7]=t[13],i[8]=t[2],i[9]=t[6],i[10]=t[10],i[11]=t[14],i[12]=t[3],i[13]=t[7],i[14]=t[11],i[15]=t[15];return this}getTranslation(e=new eF){return e.set(this.data[12],this.data[13],this.data[14])}getX(e=new eF){return e.set(this.data[0],this.data[1],this.data[2])}getY(e=new eF){return e.set(this.data[4],this.data[5],this.data[6])}getZ(e=new eF){return e.set(this.data[8],this.data[9],this.data[10])}getScale(e=new eF){return this.getX(ez),this.getY(eV),this.getZ(eG),e.set(ez.length(),eV.length(),eG.length()),e}get scaleSign(){return this.getX(ez),this.getY(eV),this.getZ(eG),ez.cross(ez,eV),0>ez.dot(eG)?-1:1}setFromEulerAngles(e,t,i){e*=eA.DEG_TO_RAD,t*=eA.DEG_TO_RAD,i*=eA.DEG_TO_RAD;let s=Math.sin(-e),r=Math.cos(-e),a=Math.sin(-t),n=Math.cos(-t),o=Math.sin(-i),l=Math.cos(-i),h=this.data;return h[0]=n*l,h[1]=-n*o,h[2]=a,h[3]=0,h[4]=r*o+l*s*a,h[5]=r*l-s*a*o,h[6]=-n*s,h[7]=0,h[8]=s*o-r*l*a,h[9]=l*s+r*a*o,h[10]=r*n,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,this}getEulerAngles(e=new eF){let t,i;this.getScale(eH);let s=eH.x,r=eH.y,a=eH.z;if(0===s||0===r||0===a)return e.set(0,0,0);let n=this.data,o=Math.asin(-n[2]/s),l=.5*Math.PI;return o<l?o>-l?(t=Math.atan2(n[6]/r,n[10]/a),i=Math.atan2(n[1]/s,n[0]/s)):(i=0,t=-Math.atan2(n[4]/r,n[5]/r)):(i=0,t=Math.atan2(n[4]/r,n[5]/r)),e.set(t,o,i).mulScalar(eA.RAD_TO_DEG)}toString(){return `[${this.data.join(", ")}]`}static{this.IDENTITY=Object.freeze(new eW);}static{this.ZERO=Object.freeze(new eW().set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));}}class eX{constructor(e=0,t=0,i=0,s=1){4===e.length?(this.x=e[0],this.y=e[1],this.z=e[2],this.w=e[3]):(this.x=e,this.y=t,this.z=i,this.w=s);}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}conjugate(e=this){return this.x=-1*e.x,this.y=-1*e.y,this.z=-1*e.z,this.w=e.w,this}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}equals(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w}equalsApprox(e,t=1e-6){return Math.abs(this.x-e.x)<t&&Math.abs(this.y-e.y)<t&&Math.abs(this.z-e.z)<t&&Math.abs(this.w-e.w)<t}getAxisAngle(e){let t=2*Math.acos(this.w),i=Math.sin(t/2);return 0!==i?(e.x=this.x/i,e.y=this.y/i,e.z=this.z/i,(e.x<0||e.y<0||e.z<0)&&(e.x*=-1,e.y*=-1,e.z*=-1,t*=-1)):(e.x=1,e.y=0,e.z=0),t*eA.RAD_TO_DEG}getEulerAngles(e=new eF){let t,i,s,r=this.x,a=this.y,n=this.z,o=this.w,l=2*(o*a-r*n);return l<=-0.99999?(t=2*Math.atan2(r,o),i=-Math.PI/2,s=0):l>=.99999?(t=2*Math.atan2(r,o),i=Math.PI/2,s=0):(t=Math.atan2(2*(o*r+a*n),1-2*(r*r+a*a)),i=Math.asin(l),s=Math.atan2(2*(o*n+r*a),1-2*(a*a+n*n))),e.set(t,i,s).mulScalar(eA.RAD_TO_DEG)}invert(e=this){return this.conjugate(e).normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}lerp(e,t,i){let s=(1-i)*(0>e.dot(t)?-1:1);return this.x=e.x*s+t.x*i,this.y=e.y*s+t.y*i,this.z=e.z*s+t.z*i,this.w=e.w*s+t.w*i,this.normalize()}mul(e){let t=this.x,i=this.y,s=this.z,r=this.w,a=e.x,n=e.y,o=e.z,l=e.w;return this.x=r*a+t*l+i*o-s*n,this.y=r*n+i*l+s*a-t*o,this.z=r*o+s*l+t*n-i*a,this.w=r*l-t*a-i*n-s*o,this}mulScalar(e,t=this){return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e,this}mul2(e,t){let i=e.x,s=e.y,r=e.z,a=e.w,n=t.x,o=t.y,l=t.z,h=t.w;return this.x=a*n+i*h+s*l-r*o,this.y=a*o+s*h+r*n-i*l,this.z=a*l+r*h+i*o-s*n,this.w=a*h-i*n-s*o-r*l,this}normalize(e=this){let t=e.length();return 0===t?(this.x=this.y=this.z=0,this.w=1):(t=1/t,this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this.w=e.w*t),this}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setFromAxisAngle(e,t){let i=Math.sin(t*=.5*eA.DEG_TO_RAD),s=Math.cos(t);return this.x=i*e.x,this.y=i*e.y,this.z=i*e.z,this.w=s,this}setFromEulerAngles(e,t,i){if(e instanceof eF){let s=e;e=s.x,t=s.y,i=s.z;}let s=.5*eA.DEG_TO_RAD;e*=s,t*=s,i*=s;let r=Math.sin(e),a=Math.cos(e),n=Math.sin(t),o=Math.cos(t),l=Math.sin(i),h=Math.cos(i);return this.x=r*o*h-a*n*l,this.y=a*n*h+r*o*l,this.z=a*o*l-r*n*h,this.w=a*o*h+r*n*l,this}setFromMat4(e){let t,i=e.data,s=i[0],r=i[1],a=i[2],n=i[4],o=i[5],l=i[6],h=i[8],c=i[9],d=i[10];return (s*(o*d-l*c)-r*(n*d-l*h)+a*(n*c-o*h)<0&&(s=-s,r=-r,a=-a),0==(t=s*s+r*r+a*a)||(s*=t=1/Math.sqrt(t),r*=t,a*=t,0==(t=n*n+o*o+l*l)||(n*=t=1/Math.sqrt(t),o*=t,l*=t,0==(t=h*h+c*c+d*d))))?this.set(0,0,0,1):(h*=t=1/Math.sqrt(t),c*=t,(d*=t)<0?s>o?this.set(1+s-o-d,r+n,h+a,l-c):this.set(r+n,1-s+o-d,l+c,h-a):s<-o?this.set(h+a,l+c,1-s-o+d,r-n):this.set(l-c,h-a,r-n,1+s+o+d),this.mulScalar(1/this.length()))}setFromDirections(e,t){let i=1+e.dot(t);return i<Number.EPSILON?(Math.abs(e.x)>Math.abs(e.y)?(this.x=-e.z,this.y=0,this.z=e.x):(this.x=0,this.y=-e.z,this.z=e.y),this.w=0):(this.x=e.y*t.z-e.z*t.y,this.y=e.z*t.x-e.x*t.z,this.z=e.x*t.y-e.y*t.x,this.w=i),this.normalize()}slerp(e,t,i){let s=e.x,r=e.y,a=e.z,n=e.w,o=t.x,l=t.y,h=t.z,c=t.w,d=n*c+s*o+r*l+a*h;if(d<0&&(c=-c,o=-o,l=-l,h=-h,d=-d),Math.abs(d)>=1)return this.w=n,this.x=s,this.y=r,this.z=a,this;let u=Math.acos(d),f=Math.sqrt(1-d*d);if(.001>Math.abs(f))return this.w=.5*n+.5*c,this.x=.5*s+.5*o,this.y=.5*r+.5*l,this.z=.5*a+.5*h,this;let p=Math.sin((1-i)*u)/f,m=Math.sin(i*u)/f;return this.w=n*p+c*m,this.x=s*p+o*m,this.y=r*p+l*m,this.z=a*p+h*m,this}transformVector(e,t=new eF){let i=e.x,s=e.y,r=e.z,a=this.x,n=this.y,o=this.z,l=this.w,h=l*i+n*r-o*s,c=l*s+o*i-a*r,d=l*r+a*s-n*i,u=-a*i-n*s-o*r;return t.x=h*l+-(u*a)+-(c*o)- -(d*n),t.y=c*l+-(u*n)+-(d*a)- -(h*o),t.z=d*l+-(u*o)+-(h*n)- -(c*a),t}fromArray(e,t=0){return this.x=e[t]??this.x,this.y=e[t+1]??this.y,this.z=e[t+2]??this.z,this.w=e[t+3]??this.w,this}toString(){return `[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}static{this.IDENTITY=Object.freeze(new eX(0,0,0,1));}static{this.ZERO=Object.freeze(new eX(0,0,0,0));}}let eY=new eF,eq=new eF,e$=new eF,ej=new eF,eK=new eF;class eZ{constructor(e,t){this.center=new eF,this.halfExtents=new eF(.5,.5,.5),this._min=new eF,this._max=new eF,e&&this.center.copy(e),t&&this.halfExtents.copy(t);}add(e){let t=this.center,i=t.x,s=t.y,r=t.z,a=this.halfExtents,n=a.x,o=a.y,l=a.z,h=i-n,c=i+n,d=s-o,u=s+o,f=r-l,p=r+l,m=e.center,_=m.x,g=m.y,v=m.z,S=e.halfExtents,y=S.x,x=S.y,T=S.z,E=_-y,b=_+y,w=g-x,A=g+x,C=v-T,P=v+T;E<h&&(h=E),b>c&&(c=b),w<d&&(d=w),A>u&&(u=A),C<f&&(f=C),P>p&&(p=P),t.x=(h+c)*.5,t.y=(d+u)*.5,t.z=(f+p)*.5,a.x=(c-h)*.5,a.y=(u-d)*.5,a.z=(p-f)*.5;}copy(e){this.center.copy(e.center),this.halfExtents.copy(e.halfExtents);}clone(){return new eZ(this.center,this.halfExtents)}intersects(e){let t=this.getMax(),i=this.getMin(),s=e.getMax(),r=e.getMin();return i.x<=s.x&&t.x>=r.x&&i.y<=s.y&&t.y>=r.y&&i.z<=s.z&&t.z>=r.z}_intersectsRay(e,t){let i=eY.copy(this.getMin()).sub(e.origin),s=eq.copy(this.getMax()).sub(e.origin),r=e.direction;0===r.x?(i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.x=s.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.x/=r.x,s.x/=r.x),0===r.y?(i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.y=s.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.y/=r.y,s.y/=r.y),0===r.z?(i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,s.z=s.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.z/=r.z,s.z/=r.z);let a=e$.set(Math.min(i.x,s.x),Math.min(i.y,s.y),Math.min(i.z,s.z)),n=ej.set(Math.max(i.x,s.x),Math.max(i.y,s.y),Math.max(i.z,s.z)),o=Math.min(Math.min(n.x,n.y),n.z),l=Math.max(Math.max(a.x,a.y),a.z),h=o>=l&&l>=0;return h&&t.copy(e.direction).mulScalar(l).add(e.origin),h}_fastIntersectsRay(e){let t=e.direction;return eY.sub2(e.origin,this.center),ej.set(Math.abs(eY.x),Math.abs(eY.y),Math.abs(eY.z)),e$.mul2(eY,t),(!(ej.x>this.halfExtents.x)||!(e$.x>=0))&&(!(ej.y>this.halfExtents.y)||!(e$.y>=0))&&(!(ej.z>this.halfExtents.z)||!(e$.z>=0))&&(eK.set(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z)),eq.cross(t,eY),eq.set(Math.abs(eq.x),Math.abs(eq.y),Math.abs(eq.z)),!(eq.x>this.halfExtents.y*eK.z+this.halfExtents.z*eK.y)&&!(eq.y>this.halfExtents.x*eK.z+this.halfExtents.z*eK.x)&&!(eq.z>this.halfExtents.x*eK.y+this.halfExtents.y*eK.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.center,i=this.halfExtents;return !(e.x<t.x-i.x)&&!(e.x>t.x+i.x)&&!(e.y<t.y-i.y)&&!(e.y>t.y+i.y)&&!(e.z<t.z-i.z)&&!(e.z>t.z+i.z)}closestPoint(e,t=new eF){let i=this.center,s=this.halfExtents;return t.set(Math.max(i.x-s.x,Math.min(e.x,i.x+s.x)),Math.max(i.y-s.y,Math.min(e.y,i.y+s.y)),Math.max(i.z-s.z,Math.min(e.z,i.z+s.z)))}setFromTransformedAabb(e,t,i=false){let s=e.center,r=e.halfExtents,a=t.data,n=a[0],o=a[4],l=a[8],h=a[1],c=a[5],d=a[9],u=a[2],f=a[6],p=a[10];if(i){let e=n*n+o*o+l*l;if(e>0){let t=1/Math.sqrt(e);n*=t,o*=t,l*=t;}if((e=h*h+c*c+d*d)>0){let t=1/Math.sqrt(e);h*=t,c*=t,d*=t;}if((e=u*u+f*f+p*p)>0){let t=1/Math.sqrt(e);u*=t,f*=t,p*=t;}}this.center.set(a[12]+n*s.x+o*s.y+l*s.z,a[13]+h*s.x+c*s.y+d*s.z,a[14]+u*s.x+f*s.y+p*s.z),this.halfExtents.set(Math.abs(n)*r.x+Math.abs(o)*r.y+Math.abs(l)*r.z,Math.abs(h)*r.x+Math.abs(c)*r.y+Math.abs(d)*r.z,Math.abs(u)*r.x+Math.abs(f)*r.y+Math.abs(p)*r.z);}static computeMinMax(e,t,i,s=e.length/3){if(s>0){let r=e[0],a=e[1],n=e[2],o=r,l=a,h=n,c=3*s;for(let t=3;t<c;t+=3){let i=e[t],s=e[t+1],c=e[t+2];i<r&&(r=i),s<a&&(a=s),c<n&&(n=c),i>o&&(o=i),s>l&&(l=s),c>h&&(h=c);}t.set(r,a,n),i.set(o,l,h);}}compute(e,t){eZ.computeMinMax(e,eY,eq,t),this.setMinMax(eY,eq);}intersectsBoundingSphere(e){return this._distanceToBoundingSphereSq(e)<=e.radius*e.radius}_distanceToBoundingSphereSq(e){let t=this.getMin(),i=this.getMax(),s=0,r=["x","y","z"];for(let a=0;a<3;++a){let n=0,o=e.center[r[a]],l=t[r[a]],h=i[r[a]],c=0;o<l&&(n+=(c=l-o)*c),o>h&&(n+=(c=o-h)*c),s+=n;}return s}_expand(e,t){eY.add2(this.getMin(),e),eq.add2(this.getMax(),t),this.setMinMax(eY,eq);}}let eQ=new eF,eJ=new eF;class e0{constructor(e=new eF,t=.5){this.center=e,this.radius=t;}containsPoint(e){let t=eQ.sub2(e,this.center).lengthSq(),i=this.radius;return t<i*i}intersectsRay(e,t){let i=eQ.copy(e.origin).sub(this.center),s=i.dot(eJ.copy(e.direction).normalize()),r=i.dot(i)-this.radius*this.radius;if(r>0&&s>0)return false;let a=s*s-r;if(a<0)return false;let n=Math.abs(-s-Math.sqrt(a));return t&&t.copy(e.direction).mulScalar(n).add(e.origin),true}intersectsBoundingSphere(e){eQ.sub2(e.center,this.center);let t=e.radius+this.radius;return eQ.lengthSq()<=t*t}}class e1{constructor(e=eF.UP,t=