playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
10 lines • 2.38 MB
JavaScript
/**
* @license
* PlayCanvas Engine v2.19.1 revision 9069deb (RELEASE)
* Copyright 2011-2026 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.
*/
var cH=Object.defineProperty;var hH=(c,t,e)=>t in c?cH(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var PR=(c=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(c,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):c)(function(c){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+c+'" is not supported')});var n=(c,t,e)=>hH(c,typeof t!="symbol"?t+"":t,e);var bj="RenderFrame",Dj="RenderFrameTime",Lj="RenderPass",Mj="RenderPassDetail",Oj="RenderAction",Fj="RenderTargetAlloc",Nj="TextureAlloc",Bj="ShaderAlloc",Uj="ShaderCompile",kj="VRAM.Texture",zj="VRAM.Vb",Gj="VRAM.Ib",Vj="VRAM.Sb",Hj="BindGroupAlloc",Wj="BindGroupFormatAlloc",Xj="RenderPipelineAlloc",Yj="ComputePipelineAlloc",Kj="PipelineLayoutAlloc",jj="Element",qj="Textures",$j="Buffers",Zj="Assets",Qj="RenderQueue",Jj="OctreeResources",wR="GpuTimings";var Mp="2.19.1",tA="9069deb";function bc(c,t){for(let e in t){let s=t[e];Array.isArray(s)?c[e]=bc([],s):s&&typeof s=="object"?c[e]=bc({},s):c[e]=s}return c}var sA={create(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,c=>{let t=Math.random()*16|0;return(c==="x"?t:t&3|8).toString(16)})}};var ve={delimiter:"/",join(...c){let t=c[0];for(let e=0;e<c.length-1;e++){let s=c[e],i=c[e+1];if(i[0]===ve.delimiter){t=i;continue}s&&i&&s[s.length-1]!==ve.delimiter&&i[0]!==ve.delimiter?t+=ve.delimiter+i:t+=i}return t},normalize(c){let t=c.startsWith(ve.delimiter),e=c.endsWith(ve.delimiter),s=c.split("/"),i="",r=[];for(let a=0;a<s.length;a++)if(s[a]!==""&&s[a]!=="."){if(s[a]===".."&&r.length>0){r=r.slice(0,r.length-2);continue}a>0&&r.push(ve.delimiter),r.push(s[a])}return i=r.join(""),!t&&i[0]===ve.delimiter&&(i=i.slice(1)),e&&i[i.length-1]!==ve.delimiter&&(i+=ve.delimiter),i},split(c){let t=c.lastIndexOf(ve.delimiter);return t!==-1?[c.substring(0,t),c.substring(t+1)]:["",c]},getBasename(c){return ve.split(c)[1]},getDirectory(c){return ve.split(c)[0]},getExtension(c){let t=c.split("?")[0].split(".").pop();return t!==c?`.${t}`:""},isRelativePath(c){return c.charAt(0)!=="/"&&c.match(/:\/\//)===null},extractPath(c){let t="",e=c.split("/"),s=0;if(e.length>1)if(ve.isRelativePath(c))if(e[0]===".")for(s=0;s<e.length-1;++s)t+=s===0?e[s]:`/${e[s]}`;else if(e[0]==="..")for(s=0;s<e.length-1;++s)t+=s===0?e[s]:`/${e[s]}`;else for(t=".",s=0;s<e.length-1;++s)t+=`/${e[s]}`;else for(s=0;s<e.length-1;++s)t+=s===0?e[s]:`/${e[s]}`;return t}};var fH=()=>{let c=!1;try{let t=Object.defineProperty({},"passive",{get:function(){return c=!0,!1}});window.addEventListener("testpassive",null,t),window.removeEventListener("testpassive",null,t)}catch{}return c},Er=typeof navigator<"u"?navigator.userAgent:"",Lo=typeof window<"u"?"browser":typeof global<"u"?"node":"worker",Op=/android/i.test(Er)?"android":/ip(?:[ao]d|hone)/i.test(Er)?"ios":/windows/i.test(Er)?"windows":/mac os/i.test(Er)?"osx":/linux/i.test(Er)?"linux":/cros/i.test(Er)?"cros":null,uH=Lo!=="browser"?null:/Chrome\/|Chromium\/|Edg.*\//.test(Er)?"chrome":/Safari\//.test(Er)?"safari":/Firefox\//.test(Er)?"firefox":"other",dH=/xbox/i.test(Er),pH=/Macintosh/i.test(Er)&&typeof navigator<"u"&&navigator.maxTouchPoints>0&&!/iPhone|iPad|iPod/i.test(Er),mH=Lo==="browser"&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),_H=Lo==="browser"&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),gH=typeof Worker<"u",SH=fH(),de={name:Op,environment:Lo,global:(typeof globalThis<"u"&&globalThis)??(Lo==="browser"&&window)??(Lo==="node"&&global)??(Lo==="worker"&&self),browser:Lo==="browser",worker:Lo==="worker",desktop:["windows","osx","linux","cros"].includes(Op),mobile:["android","ios"].includes(Op),ios:Op==="ios",android:Op==="android",visionos:pH,xbox:dH,gamepads:_H,touch:mH,workers:gH,passiveEvents:SH,browserName:uH};var DR="abcdefghijklmnopqrstuvwxyz",LR="ABCDEFGHIJKLMNOPQRSTUVWXYZ",xH=DR+LR,iA=55296,MR=56319,IR=56320,vH=57343,TH=8205,RR=127462,bR=127487,yH=127995,EH=127999,AH=8400,CH=8447,rA=65024,aA=65039;function oA(c,t=0){let e=c.length;if(t<0||t>=e)return null;let s=c.charCodeAt(t);if(e>1&&s>=iA&&s<=MR){let i=c.charCodeAt(t+1);if(i>=IR&&i<=vH)return{code:(s-iA)*1024+i-IR+65536,long:!0}}return{code:s,long:!1}}function Jn(c,t,e){if(!c)return!1;let s=oA(c);if(s){let i=s.code;return i>=t&&i<=e}return!1}function PH(c,t){if(t===c.length-1)return 1;if(Jn(c[t],iA,MR)){let e=c.substring(t,t+2),s=c.substring(t+2,t+4);return Jn(s,yH,EH)||Jn(e,RR,bR)&&Jn(s,RR,bR)?4:Jn(s,rA,aA)?3:2}return Jn(c[t+1],rA,aA)?2:1}var qr={ASCII_LOWERCASE:DR,ASCII_UPPERCASE:LR,ASCII_LETTERS:xH,format(c,...t){for(let e=0;e<t.length;e++)c=c.replace(`{${e}}`,t[e]);return c},getCodePoint(c,t){let e=oA(c,t);return e&&e.code},getCodePoints(c){if(typeof c!="string")throw new TypeError("Not a string");let t=0,e=[],s;for(;s=oA(c,t);)e.push(s.code),t+=s.long?2:1;return e},getSymbols(c){if(typeof c!="string")throw new TypeError("Not a string");let t=0,e=c.length,s=[],i=0,r;for(;t<e;){if(i+=PH(c,t+i),r=c[t+i],Jn(r,AH,CH)&&(r=c[t+i++]),Jn(r,rA,aA)&&(r=c[t+i++]),r&&r.charCodeAt(0)===TH){r=c[t+i++];continue}let a=c.substring(t,t+i);s.push(a),t+=i,i=0}return s},fromCodePoint(...c){return c.map(t=>t>65535?(t-=65536,String.fromCharCode((t>>10)+55296,t%1024+56320)):String.fromCharCode(t)).join("")}};var Fp=class Fp{static set(t,e=!0){}static get(t){return Fp._traceChannels.has(t)}};n(Fp,"_traceChannels",new Set),n(Fp,"stack",!1);var Np=Fp;var Bp=class{constructor(t,e,s,i,r=!1){n(this,"handler");n(this,"name");n(this,"callback");n(this,"scope");n(this,"_once");n(this,"_removed",!1);this.handler=t,this.name=e,this.callback=s,this.scope=i,this._once=r}off(){this._removed||this.handler.offByHandle(this)}on(t,e,s=this){return this.handler._addCallback(t,e,s,!1)}once(t,e,s=this){return this.handler._addCallback(t,e,s,!0)}set removed(t){t&&(this._removed=!0)}get removed(){return this._removed}toJSON(t){}};var J=class{constructor(){n(this,"_callbacks",new Map);n(this,"_callbackActive",new Map)}initEventHandler(){this._callbacks=new Map,this._callbackActive=new Map}_addCallback(t,e,s,i){if(this._callbacks.has(t)||this._callbacks.set(t,[]),this._callbackActive.has(t)){let a=this._callbackActive.get(t);a&&a===this._callbacks.get(t)&&this._callbackActive.set(t,a.slice())}let r=new Bp(this,t,e,s,i);return this._callbacks.get(t).push(r),r}on(t,e,s=this){return this._addCallback(t,e,s,!1)}once(t,e,s=this){return this._addCallback(t,e,s,!0)}off(t,e,s){if(t)this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());else for(let[i,r]of this._callbackActive)this._callbacks.has(i)&&this._callbacks.get(i)===r&&this._callbackActive.set(i,r.slice());if(t)if(e){let i=this._callbacks.get(t);if(!i)return this;for(let r=0;r<i.length;r++)i[r].callback===e&&(s&&i[r].scope!==s||(i[r].removed=!0,i.splice(r,1),r--));i.length===0&&this._callbacks.delete(t)}else{let i=this._callbacks.get(t);if(i){for(let r=0;r<i.length;r++)i[r].removed=!0;this._callbacks.delete(t)}}else{for(let i of this._callbacks.values())for(let r=0;r<i.length;r++)i[r].removed=!0;this._callbacks.clear()}return this}offByHandle(t){let e=t.name;t.removed=!0,this._callbackActive.has(e)&&this._callbackActive.get(e)===this._callbacks.get(e)&&this._callbackActive.set(e,this._callbackActive.get(e).slice());let s=this._callbacks.get(e);if(!s)return this;let i=s.indexOf(t);return i!==-1&&(s.splice(i,1),s.length===0&&this._callbacks.delete(e)),this}fire(t,e,s,i,r,a,o,l,h){if(!t)return this;let f=this._callbacks.get(t);if(!f)return this;let u;this._callbackActive.has(t)?this._callbackActive.get(t)!==f&&(u=f.slice()):this._callbackActive.set(t,f);for(let d=0;(u||this._callbackActive.get(t))&&d<(u||this._callbackActive.get(t)).length;d++){let p=(u||this._callbackActive.get(t))[d];if(p.callback&&(p.callback.call(p.scope,e,s,i,r,a,o,l,h),p._once)){let m=this._callbacks.get(t),_=m?m.indexOf(p):-1;if(_!==-1){this._callbackActive.get(t)===m&&this._callbackActive.set(t,this._callbackActive.get(t).slice());let S=this._callbacks.get(t);if(!S)continue;S[_].removed=!0,S.splice(_,1),S.length===0&&this._callbacks.delete(t)}}}return u||this._callbackActive.delete(t),this}hasEvent(t){return!!this._callbacks.get(t)?.length}};var Up=class{constructor(){n(this,"_list",[]);n(this,"_index",{})}push(t,e){if(this._index[t])throw Error(`Key already in index ${t}`);let s=this._list.push(e)-1;this._index[t]=s}has(t){return this._index[t]!==void 0}get(t){let e=this._index[t];return e!==void 0?this._list[e]:null}remove(t){let e=this._index[t];if(e!==void 0){this._list.splice(e,1),delete this._index[t];for(t in this._index){let s=this._index[t];s>e&&(this._index[t]=s-1)}return!0}return!1}list(){return this._list}clear(){this._list.length=0;for(let t in this._index)delete this._index[t]}};var wH=c=>{let t={},e=t;return()=>(e===t&&(e=c()),e)},La=class La{static loadScript(t,e){let s=document.createElement("script");s.setAttribute("src",t),s.onload=()=>{e(null)},s.onerror=()=>{e(`Failed to load script='${t}'`)},document.body.appendChild(s)}static loadWasm(t,e,s){let i=La.wasmSupported()&&e.glueUrl&&e.wasmUrl?e.glueUrl:e.fallbackUrl;i?La.loadScript(i,r=>{if(r)s(r,null);else{let a=window[t];window[t]=void 0,a({locateFile:()=>e.wasmUrl,onAbort:()=>{s("wasm module aborted.")}}).then(o=>{s(null,o)})}}):s("No supported wasm modules found.",null)}static getModule(t){return La.modules.hasOwnProperty(t)||(La.modules[t]={config:null,initializing:!1,instance:null,callbacks:[]}),La.modules[t]}static initialize(t,e){if(e.initializing)return;let s=e.config;(s.glueUrl||s.wasmUrl||s.fallbackUrl)&&(e.initializing=!0,La.loadWasm(t,s,(i,r)=>{i?s.errorHandler&&s.errorHandler(i):(e.instance=r,e.callbacks.forEach(a=>{a(r)}))}))}};n(La,"modules",{}),n(La,"wasmSupported",wH(()=>{try{if(typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"){let t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch{}return!1}));var Dc=La,Lc=class{static setConfig(t,e){let s=Dc.getModule(t);s.config=e,s.callbacks.length>0&&Dc.initialize(t,s)}static getConfig(t){return Dc.modules?.[t]?.config}static getInstance(t,e){let s=Dc.getModule(t);s.instance?e(s.instance):(s.callbacks.push(e),s.config&&Dc.initialize(t,s))}};var Mc=class{constructor(t){n(this,"arraybuffer");n(this,"dataView");n(this,"offset",0);this.arraybuffer=t,this.dataView=new DataView(t)}get remainingBytes(){return this.dataView.byteLength-this.offset}reset(t=0){this.offset=t}skip(t){this.offset+=t}align(t){this.offset=this.offset+t-1&~(t-1)}_inc(t){return this.offset+=t,this.offset-t}readChar(){return String.fromCharCode(this.dataView.getUint8(this.offset++))}readChars(t){let e="";for(let s=0;s<t;++s)e+=this.readChar();return e}readU8(){return this.dataView.getUint8(this.offset++)}readU16(){return this.dataView.getUint16(this._inc(2),!0)}readU32(){return this.dataView.getUint32(this._inc(4),!0)}readU64(){return this.readU32()+2**32*this.readU32()}readU32be(){return this.dataView.getUint32(this._inc(4),!1)}readArray(t){for(let e=0;e<t.length;++e)t[e]=this.readU8()}readLine(){let t=this.dataView,e="";for(;!(this.offset>=t.byteLength);){let s=String.fromCharCode(this.readU8());if(s===`
`)break;e+=s}return e}};var Mo=class{constructor(t){n(this,"items",[]);n(this,"length",0);n(this,"loopIndex",-1);n(this,"_sortBy");n(this,"_sortHandler");this._sortBy=t.sortBy,this._sortHandler=this._doSort.bind(this)}_binarySearch(t){let e=0,s=this.items.length-1,i=t[this._sortBy],r,a;for(;e<=s;)r=Math.floor((e+s)/2),a=this.items[r][this._sortBy],a<=i?e=r+1:a>i&&(s=r-1);return e}_doSort(t,e){let s=this._sortBy;return t[s]-e[s]}insert(t){let e=this._binarySearch(t);this.items.splice(e,0,t),this.length++,this.loopIndex>=e&&this.loopIndex++}append(t){this.items.push(t),this.length++}remove(t){let e=this.items.indexOf(t);e<0||(this.items.splice(e,1),this.length--,this.loopIndex>=e&&this.loopIndex--)}sort(){let t=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),t!==null&&(this.loopIndex=this.items.indexOf(t))}};var Ma=class extends J{constructor(e){super();n(this,"_index",{});n(this,"_list",[]);n(this,"_parent");this._parent=e}add(...e){let s=!1,i=this._processArguments(e,!0);if(!i.length)return s;for(let r=0;r<i.length;r++)this._index[i[r]]||(s=!0,this._index[i[r]]=!0,this._list.push(i[r]),this.fire("add",i[r],this._parent));return s&&this.fire("change",this._parent),s}remove(...e){let s=!1;if(!this._list.length)return s;let i=this._processArguments(e,!0);if(!i.length)return s;for(let r=0;r<i.length;r++)this._index[i[r]]&&(s=!0,delete this._index[i[r]],this._list.splice(this._list.indexOf(i[r]),1),this.fire("remove",i[r],this._parent));return s&&this.fire("change",this._parent),s}clear(){if(!this._list.length)return;let e=this._list.slice(0);this._list=[],this._index={};for(let s=0;s<e.length;s++)this.fire("remove",e[s],this._parent);this.fire("change",this._parent)}has(...e){return this._list.length?this._has(this._processArguments(e)):!1}_has(e){if(!this._list.length||!e.length)return!1;for(let s=0;s<e.length;s++)if(e[s].length===1){if(this._index[e[s][0]])return!0}else{let i=!0;for(let r=0;r<e[s].length;r++)if(!this._index[e[s][r]]){i=!1;break}if(i)return!0}return!1}list(){return this._list.slice(0)}_processArguments(e,s){let i=[],r=[];if(!e||!e.length)return i;for(let a=0;a<e.length;a++)if(e[a]instanceof Array){s||(r=[]);for(let o=0;o<e[a].length;o++)typeof e[a][o]=="string"&&(s?i.push(e[a][o]):r.push(e[a][o]));!s&&r.length&&i.push(r)}else typeof e[a]=="string"&&(s?i.push(e[a]):i.push([e[a]]));return i}get size(){return this._list.length}};n(Ma,"EVENT_ADD","add"),n(Ma,"EVENT_REMOVE","remove"),n(Ma,"EVENT_CHANGE","change");var Tt=typeof window<"u"&&window.performance&&window.performance.now?performance.now.bind(performance):Date.now;function IH(c){let t="";if((c.authority||c.scheme)&&(c.host||c.hostpath))throw new Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(c.host&&c.hostpath)throw new Error("Can't have 'host' and 'hostpath' option");if(c.path&&c.hostpath)throw new Error("Can't have 'path' and 'hostpath' option");return c.scheme&&(t+=`${c.scheme}:`),c.authority&&(t+=`//${c.authority}`),c.host&&(t+=c.host),c.path&&(t+=c.path),c.hostpath&&(t+=c.hostpath),c.query&&(t+=`?${c.query}`),c.fragment&&(t+=`#${c.fragment}`),t}var RH=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,Oc=class{constructor(t){n(this,"scheme");n(this,"authority");n(this,"path");n(this,"query");n(this,"fragment");let e=t.match(RH);this.scheme=e[2],this.authority=e[4],this.path=e[5],this.query=e[7],this.fragment=e[9]}toString(){let t="";return this.scheme&&(t+=`${this.scheme}:`),this.authority&&(t+=`//${this.authority}`),t+=this.path,this.query&&(t+=`?${this.query}`),this.fragment&&(t+=`#${this.fragment}`),t}getQuery(){let t={};if(this.query){let e=decodeURIComponent(this.query).split("&");for(let s of e){let i=s.split("=");t[i[0]]=i[1]}}return t}setQuery(t){let e="";for(let s in t)t.hasOwnProperty(s)&&(e!==""&&(e+="&"),e+=`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`);this.query=e}};var bH=0,nA=1,OR=4,DH=5;var R={DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,clamp(c,t,e){return c>=e?e:c<=t?t:c},intToBytes24(c){let t=c>>16&255,e=c>>8&255,s=c&255;return[t,e,s]},intToBytes32(c){let t=c>>24&255,e=c>>16&255,s=c>>8&255,i=c&255;return[t,e,s,i]},bytesToInt24(c,t,e){return c.length&&(e=c[2],t=c[1],c=c[0]),c<<16|t<<8|e},bytesToInt32(c,t,e,s){return c.length&&(s=c[3],e=c[2],t=c[1],c=c[0]),(c<<24|t<<16|e<<8|s)>>>0},lerp(c,t,e){return c+(t-c)*R.clamp(e,0,1)},lerpAngle(c,t,e){return t-c>180&&(t-=360),t-c<-180&&(t+=360),R.lerp(c,t,R.clamp(e,0,1))},powerOfTwo(c){return c!==0&&!(c&c-1)},nextPowerOfTwo(c){return c--,c|=c>>1,c|=c>>2,c|=c>>4,c|=c>>8,c|=c>>16,c++,c},nearestPowerOfTwo(c){return Math.pow(2,Math.round(Math.log2(c)))},random(c,t){let e=t-c;return Math.random()*e+c},smoothstep(c,t,e){return e<=c?0:e>=t?1:(e=(e-c)/(t-c),e*e*(3-2*e))},smootherstep(c,t,e){return e<=c?0:e>=t?1:(e=(e-c)/(t-c),e*e*e*(e*(e*6-15)+10))},roundUp(c,t){return t===0?c:Math.ceil(c/t)*t},between(c,t,e,s){let i=Math.min(t,e),r=Math.max(t,e);return s?c>=i&&c<=r:c>i&&c<r}};var ls=class ls{constructor(t=0,e=0,s=0,i=1){n(this,"r");n(this,"g");n(this,"b");n(this,"a");let r=t.length;r===3||r===4?(this.r=t[0],this.g=t[1],this.b=t[2],this.a=t[3]??1):(this.r=t,this.g=e,this.b=s,this.a=i)}clone(){let t=this.constructor;return new t(this.r,this.g,this.b,this.a)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this}equals(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a}set(t,e,s,i=1){return this.r=t,this.g=e,this.b=s,this.a=i,this}lerp(t,e,s){return this.r=t.r+s*(e.r-t.r),this.g=t.g+s*(e.g-t.g),this.b=t.b+s*(e.b-t.b),this.a=t.a+s*(e.a-t.a),this}linear(t=this){return this.r=Math.pow(t.r,2.2),this.g=Math.pow(t.g,2.2),this.b=Math.pow(t.b,2.2),this.a=t.a,this}gamma(t=this){return this.r=Math.pow(t.r,1/2.2),this.g=Math.pow(t.g,1/2.2),this.b=Math.pow(t.b,1/2.2),this.a=t.a,this}mulScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}fromString(t){let e=parseInt(t.replace("#","0x"),16),s;return t.length>7?s=R.intToBytes32(e):(s=R.intToBytes24(e),s[3]=255),this.set(s[0]/255,s[1]/255,s[2]/255,s[3]/255),this}fromArray(t,e=0){return this.r=t[e]??this.r,this.g=t[e+1]??this.g,this.b=t[e+2]??this.b,this.a=t[e+3]??this.a,this}toString(t,e){let{r:s,g:i,b:r,a}=this;if(e||s>1||i>1||r>1)return`${s.toFixed(3)}, ${i.toFixed(3)}, ${r.toFixed(3)}, ${a.toFixed(3)}`;let o=`#${((1<<24)+(Math.round(s*255)<<16)+(Math.round(i*255)<<8)+Math.round(r*255)).toString(16).slice(1)}`;if(t===!0){let l=Math.round(a*255).toString(16);this.a<16/255?o+=`0${l}`:o+=l}return o}toArray(t=[],e=0,s=!0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,s&&(t[e+3]=this.a),t}};n(ls,"BLACK",Object.freeze(new ls(0,0,0,1))),n(ls,"BLUE",Object.freeze(new ls(0,0,1,1))),n(ls,"CYAN",Object.freeze(new ls(0,1,1,1))),n(ls,"GRAY",Object.freeze(new ls(.5,.5,.5,1))),n(ls,"GREEN",Object.freeze(new ls(0,1,0,1))),n(ls,"MAGENTA",Object.freeze(new ls(1,0,1,1))),n(ls,"RED",Object.freeze(new ls(1,0,0,1))),n(ls,"WHITE",Object.freeze(new ls(1,1,1,1))),n(ls,"YELLOW",Object.freeze(new ls(1,1,0,1)));var F=ls;var Ef=class{constructor(t,e=0){n(this,"_curve");n(this,"_left",-1/0);n(this,"_right",1/0);n(this,"_recip",0);n(this,"_p0",0);n(this,"_p1",0);n(this,"_m0",0);n(this,"_m1",0);this._curve=t,this._reset(e)}evaluate(t,e=!1){(e||t<this._left||t>=this._right)&&this._reset(t);let s,i=this._curve.type;if(i===5)s=this._p0;else{let r=this._recip===0?0:(t-this._left)*this._recip;i===0?s=R.lerp(this._p0,this._p1,r):i===1?s=R.lerp(this._p0,this._p1,r*r*(3-2*r)):s=this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,r)}return s}_reset(t){let e=this._curve.keys,s=e.length;if(!s)this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0;else if(t<e[0][0])this._left=-1/0,this._right=e[0][0],this._recip=0,this._p0=this._p1=e[0][1],this._m0=this._m1=0;else if(t>=e[s-1][0])this._left=e[s-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=e[s-1][1],this._m0=this._m1=0;else{let i=0;for(;t>=e[i+1][0];)i++;this._left=e[i][0],this._right=e[i+1][0];let r=1/(this._right-this._left);this._recip=isFinite(r)?r:0,this._p0=e[i][1],this._p1=e[i+1][1],this._curve.type===4&&this._calcTangents(e,i)}}_calcTangents(t,e){let s,i=t[e],r=t[e+1],a;if(e===0?s=[t[0][0]+(t[0][0]-t[1][0]),t[0][1]+(t[0][1]-t[1][1])]:s=t[e-1],e===t.length-2?a=[t[e+1][0]+(t[e+1][0]-t[e][0]),t[e+1][1]+(t[e+1][1]-t[e][1])]:a=t[e+2],this._curve.type===4){let o=2*(r[0]-i[0])/(r[0]-s[0]),l=2*(r[0]-i[0])/(a[0]-i[0]);this._m0=this._curve.tension*(isFinite(o)?o:0)*(r[1]-s[1]),this._m1=this._curve.tension*(isFinite(l)?l:0)*(a[1]-i[1])}else{let o=(r[0]-i[0])/(i[0]-s[0]),l=(r[0]-i[0])/(a[0]-r[0]),h=i[1]+(s[1]-i[1])*(isFinite(o)?o:0),f=r[1]+(a[1]-r[1])*(isFinite(l)?l:0),u=this._curve.tension;this._m0=u*(r[1]-h),this._m1=u*(f-i[1])}}_evaluateHermite(t,e,s,i,r){let a=r*r,o=r+r,l=1-r,h=l*l;return t*((1+o)*h)+s*(r*h)+e*(a*(3-o))+i*(a*(r-1))}};var Rs=class{constructor(t){n(this,"keys",[]);n(this,"type",1);n(this,"tension",.5);n(this,"_eval",new Ef(this));if(t)for(let e=0;e<t.length-1;e+=2)this.keys.push([t[e],t[e+1]]);this.sort()}get length(){return this.keys.length}add(t,e){let s=this.keys,i=s.length,r=0;for(;r<i&&!(s[r][0]>t);r++);let a=[t,e];return this.keys.splice(r,0,a),a}get(t){return this.keys[t]}sort(){this.keys.sort((t,e)=>t[0]-e[0])}value(t){return this._eval.evaluate(t,!0)}closest(t){let e=this.keys,s=e.length,i=2,r=null;for(let a=0;a<s;a++){let o=Math.abs(t-e[a][0]);if(i>=o)i=o,r=e[a];else break}return r}clone(){let t=new this.constructor;return t.keys=this.keys.map(e=>[...e]),t.type=this.type,t.tension=this.tension,t}quantize(t){t=Math.max(t,2);let e=new Float32Array(t),s=1/(t-1);e[0]=this._eval.evaluate(0,!0);for(let i=1;i<t;i++)e[i]=this._eval.evaluate(s*i);return e}quantizeClamped(t,e,s){let i=this.quantize(t);for(let r=0;r<i.length;++r)i[r]=Math.min(s,Math.max(e,i[r]));return i}};var Xi=class{constructor(...t){n(this,"curves",[]);n(this,"_type",1);if(t.length>1)for(let e=0;e<t.length;e++)this.curves.push(new Rs(t[e]));else if(t.length===0)this.curves.push(new Rs);else{let e=t[0];if(typeof e=="number")for(let s=0;s<e;s++)this.curves.push(new Rs);else for(let s=0;s<e.length;s++)this.curves.push(new Rs(e[s]))}}get length(){return this.curves.length}set type(t){this._type=t;for(let e=0;e<this.curves.length;e++)this.curves[e].type=t}get type(){return this._type}get(t){return this.curves[t]}value(t,e=[]){let s=this.curves.length;e.length=s;for(let i=0;i<s;i++)e[i]=this.curves[i].value(t);return e}clone(){let t=new this.constructor;t.curves=[];for(let e=0;e<this.curves.length;e++)t.curves.push(this.curves[e].clone());return t._type=this._type,t}quantize(t){t=Math.max(t,2);let e=this.curves.length,s=new Float32Array(t*e),i=1/(t-1);for(let r=0;r<e;r++){let a=new Ef(this.curves[r]);for(let o=0;o<t;o++)s[o*e+r]=a.evaluate(i*o)}return s}quantizeClamped(t,e,s){let i=this.quantize(t);for(let r=0;r<i.length;++r)i[r]=Math.min(s,Math.max(e,i[r]));return i}};var lA=new Float32Array(1),FR=new Int32Array(lA.buffer),Ys=class{static float2Half(t){lA[0]=t;let e=FR[0],s=e>>16&32768,i=e>>12&2047,r=e>>23&255;return r<103?s:r>142?(s|=31744,s|=(r===255?0:1)&&e&8388607,s):r<113?(i|=2048,s|=(i>>114-r)+(i>>113-r&1),s):(s|=r-112<<10|i>>1,s+=i&1,s)}static float2RGBA8(t,e){lA[0]=t;let s=FR[0];e.r=(s>>24&255)/255,e.g=(s>>16&255)/255,e.b=(s>>8&255)/255,e.a=(s&255)/255}};var kp=class{static concentric(t,e){let s=[];s.push(0,0);let i=2*Math.PI/t/e;for(let r=1;r<=t;r++){let a=r/t,o=2*Math.PI*a,l=Math.max(1,Math.floor(o/i)),h=2*Math.PI/l;for(let f=0;f<l;f++){let u=f*h,d=a*Math.cos(u),p=a*Math.sin(u);s.push(d,p)}}return s}};var cs=class cs{constructor(t=0,e=0,s=0){n(this,"x");n(this,"y");n(this,"z");t.length===3?(this.x=t[0],this.y=t[1],this.z=t[2]):(this.x=t,this.y=e,this.z=s)}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add2(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addScaled(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}clone(){let t=this.constructor;return new t(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}cross(t,e){let s=t.x,i=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-o*r,this.y=r*a-l*s,this.z=s*o-a*i,this}distance(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return Math.sqrt(e*e+s*s+i*i)}div(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}div2(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this}divScalar(t){return this.x/=t,this.y/=t,this.z/=t,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}equalsApprox(t,e=1e-6){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e&&Math.abs(this.z-t.z)<e}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(t,e,s){return this.x=t.x+s*(e.x-t.x),this.y=t.y+s*(e.y-t.y),this.z=t.z+s*(e.z-t.z),this}mul(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}mul2(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}mulScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}normalize(t=this){let e=t.x*t.x+t.y*t.y+t.z*t.z;if(e>0){let s=1/Math.sqrt(e);this.x=t.x*s,this.y=t.y*s,this.z=t.z*s}return this}floor(t=this){return this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this}ceil(t=this){return this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this}round(t=this){return this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this}min(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),this}max(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this}project(t){let e=this.x*t.x+this.y*t.y+this.z*t.z,s=t.x*t.x+t.y*t.y+t.z*t.z,i=e/s;return this.x=t.x*i,this.y=t.y*i,this.z=t.z*i,this}set(t,e,s){return this.x=t,this.y=e,this.z=s,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}sub2(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}fromArray(t,e=0){return this.x=t[e]??this.x,this.y=t[e+1]??this.y,this.z=t[e+2]??this.z,this}toString(){return`[${this.x}, ${this.y}, ${this.z}]`}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}};n(cs,"ZERO",Object.freeze(new cs(0,0,0))),n(cs,"HALF",Object.freeze(new cs(.5,.5,.5))),n(cs,"ONE",Object.freeze(new cs(1,1,1))),n(cs,"UP",Object.freeze(new cs(0,1,0))),n(cs,"DOWN",Object.freeze(new cs(0,-1,0))),n(cs,"RIGHT",Object.freeze(new cs(1,0,0))),n(cs,"LEFT",Object.freeze(new cs(-1,0,0))),n(cs,"FORWARD",Object.freeze(new cs(0,0,-1))),n(cs,"BACK",Object.freeze(new cs(0,0,1)));var x=cs;var Af=class Af{constructor(){n(this,"data",new Float32Array(9));this.data[0]=this.data[4]=this.data[8]=1}clone(){let t=this.constructor;return new t().copy(this)}copy(t){let e=t.data,s=this.data;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],this}set(t){let e=this.data;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}getX(t=new x){return t.set(this.data[0],this.data[1],this.data[2])}getY(t=new x){return t.set(this.data[3],this.data[4],this.data[5])}getZ(t=new x){return t.set(this.data[6],this.data[7],this.data[8])}equals(t){let e=this.data,s=t.data;return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]}isIdentity(){let t=this.data;return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===0&&t[4]===1&&t[5]===0&&t[6]===0&&t[7]===0&&t[8]===1}setIdentity(){let t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this}toString(){return`[${this.data.join(", ")}]`}transpose(t=this){let e=t.data,s=this.data;if(e===s){let i;i=e[1],s[1]=e[3],s[3]=i,i=e[2],s[2]=e[6],s[6]=i,i=e[5],s[5]=e[7],s[7]=i}else s[0]=e[0],s[1]=e[3],s[2]=e[6],s[3]=e[1],s[4]=e[4],s[5]=e[7],s[6]=e[2],s[7]=e[5],s[8]=e[8];return this}setFromMat4(t){let e=t.data,s=this.data;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[4],s[4]=e[5],s[5]=e[6],s[6]=e[8],s[7]=e[9],s[8]=e[10],this}setFromQuat(t){let e=t.x,s=t.y,i=t.z,r=t.w,a=e+e,o=s+s,l=i+i,h=e*a,f=e*o,u=e*l,d=s*o,p=s*l,m=i*l,_=r*a,S=r*o,g=r*l,T=this.data;return T[0]=1-(d+m),T[1]=f+g,T[2]=u-S,T[3]=f-g,T[4]=1-(h+m),T[5]=p+_,T[6]=u+S,T[7]=p-_,T[8]=1-(h+d),this}invertMat4(t){let e=t.data,s=e[0],i=e[1],r=e[2],a=e[4],o=e[5],l=e[6],h=e[8],f=e[9],u=e[10],d=u*o-l*f,p=-u*i+r*f,m=l*i-r*o,_=-u*a+l*h,S=u*s-r*h,g=-l*s+r*a,T=f*a-o*h,C=-f*s+i*h,v=o*s-i*a,E=s*d+i*_+r*T;if(E===0)this.setIdentity();else{let y=1/E,P=this.data;P[0]=d*y,P[1]=p*y,P[2]=m*y,P[3]=_*y,P[4]=S*y,P[5]=g*y,P[6]=T*y,P[7]=C*y,P[8]=v*y}return this}transformVector(t,e=new x){let s=this.data,{x:i,y:r,z:a}=t;return e.x=i*s[0]+r*s[3]+a*s[6],e.y=i*s[1]+r*s[4]+a*s[7],e.z=i*s[2]+r*s[5]+a*s[8],e}};n(Af,"IDENTITY",Object.freeze(new Af)),n(Af,"ZERO",Object.freeze(new Af().set([0,0,0,0,0,0,0,0,0])));var Ks=Af;var li=class li{constructor(t=0,e=0){n(this,"x");n(this,"y");t.length===2?(this.x=t[0],this.y=t[1]):(this.x=t,this.y=e)}add(t){return this.x+=t.x,this.y+=t.y,this}add2(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addScaled(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}clone(){let t=this.constructor;return new t(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}cross(t){return this.x*t.y-this.y*t.x}distance(t){let e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}div(t){return this.x/=t.x,this.y/=t.y,this}div2(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}divScalar(t){return this.x/=t,this.y/=t,this}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}equalsApprox(t,e=1e-6){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSq(){return this.x*this.x+this.y*this.y}lerp(t,e,s){return this.x=t.x+s*(e.x-t.x),this.y=t.y+s*(e.y-t.y),this}mul(t){return this.x*=t.x,this.y*=t.y,this}mul2(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}mulScalar(t){return this.x*=t,this.y*=t,this}normalize(t=this){let e=t.x*t.x+t.y*t.y;if(e>0){let s=1/Math.sqrt(e);this.x=t.x*s,this.y=t.y*s}return this}rotate(t){let e=Math.atan2(this.x,this.y)+t*R.DEG_TO_RAD,s=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(e)*s,this.y=Math.cos(e)*s,this}angle(){return Math.atan2(this.x,this.y)*R.RAD_TO_DEG}angleTo(t){return Math.atan2(this.x*t.y+this.y*t.x,this.x*t.x+this.y*t.y)*R.RAD_TO_DEG}floor(t=this){return this.x=Math.floor(t.x),this.y=Math.floor(t.y),this}ceil(t=this){return this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this}round(t=this){return this.x=Math.round(t.x),this.y=Math.round(t.y),this}min(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),this}max(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),this}set(t,e){return this.x=t,this.y=e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}sub2(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}subScalar(t){return this.x-=t,this.y-=t,this}fromArray(t,e=0){return this.x=t[e]??this.x,this.y=t[e+1]??this.y,this}toString(){return`[${this.x}, ${this.y}]`}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}static angleRad(t,e){return Math.atan2(t.x*e.y-t.y*e.x,t.x*e.x+t.y*e.y)}};n(li,"ZERO",Object.freeze(new li(0,0))),n(li,"HALF",Object.freeze(new li(.5,.5))),n(li,"ONE",Object.freeze(new li(1,1))),n(li,"UP",Object.freeze(new li(0,1))),n(li,"DOWN",Object.freeze(new li(0,-1))),n(li,"RIGHT",Object.freeze(new li(1,0))),n(li,"LEFT",Object.freeze(new li(-1,0)));var B=li;var el=class el{constructor(t=0,e=0,s=0,i=0){n(this,"x");n(this,"y");n(this,"z");n(this,"w");t.length===4?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=s,this.w=i)}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}add2(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addScaled(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}clone(){let t=this.constructor;return new t(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}div(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}div2(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this.w=t.w/e.w,this}divScalar(t){return this.x/=t,this.y/=t,this.z/=t,this.w/=t,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w}equalsApprox(t,e=1e-6){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e&&Math.abs(this.z-t.z)<e&&Math.abs(this.w-t.w)<e}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(t,e,s){return this.x=t.x+s*(e.x-t.x),this.y=t.y+s*(e.y-t.y),this.z=t.z+s*(e.z-t.z),this.w=t.w+s*(e.w-t.w),this}mul(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}mul2(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this.w=t.w*e.w,this}mulScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}normalize(t=this){let e=t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w;if(e>0){let s=1/Math.sqrt(e);this.x=t.x*s,this.y=t.y*s,this.z=t.z*s,this.w=t.w*s}return this}floor(t=this){return this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this.w=Math.floor(t.w),this}ceil(t=this){return this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this.w=Math.ceil(t.w),this}round(t=this){return this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this.w=Math.round(t.w),this}min(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),t.w<this.w&&(this.w=t.w),this}max(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}sub2(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}fromArray(t,e=0){return this.x=t[e]??this.x,this.y=t[e+1]??this.y,this.z=t[e+2]??this.z,this.w=t[e+3]??this.w,this}toString(){return`[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}};n(el,"ZERO",Object.freeze(new el(0,0,0,0))),n(el,"HALF",Object.freeze(new el(.5,.5,.5,.5))),n(el,"ONE",Object.freeze(new el(1,1,1,1)));var Q=el;var zp=new B,$r=new x,Oa=new x,Fa=new x,LS=new x,Fc=class Fc{constructor(){n(this,"data",new Float32Array(16));this.data[0]=this.data[5]=this.data[10]=this.data[15]=1}static _getPerspectiveHalfSize(t,e,s,i,r){r?(t.x=i*Math.tan(e*Math.PI/360),t.y=t.x/s):(t.y=i*Math.tan(e*Math.PI/360),t.x=t.y*s)}add2(t,e){let s=t.data,i=e.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(t){return this.add2(this,t)}clone(){let t=this.constructor;return new t().copy(this)}copy(t){let e=t.data,s=this.data;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],this}equals(t){let e=this.data,s=t.data;return e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15]}isIdentity(){let t=this.data;return t[0]===1&&t[1]===0&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===1&&t[6]===0&&t[7]===0&&t[8]===0&&t[9]===0&&t[10]===1&&t[11]===0&&t[12]===0&&t[13]===0&&t[14]===0&&t[15]===1}mul2(t,e){let s=t.data,i=e.data,r=this.data,a=s[0],o=s[1],l=s[2],h=s[3],f=s[4],u=s[5],d=s[6],p=s[7],m=s[8],_=s[9],S=s[10],g=s[11],T=s[12],C=s[13],v=s[14],E=s[15],y,P,A,w;return y=i[0],P=i[1],A=i[2],w=i[3],r[0]=a*y+f*P+m*A+T*w,r[1]=o*y+u*P+_*A+C*w,r[2]=l*y+d*P+S*A+v*w,r[3]=h*y+p*P+g*A+E*w,y=i[4],P=i[5],A=i[6],w=i[7],r[4]=a*y+f*P+m*A+T*w,r[5]=o*y+u*P+_*A+C*w,r[6]=l*y+d*P+S*A+v*w,r[7]=h*y+p*P+g*A+E*w,y=i[8],P=i[9],A=i[10],w=i[11],r[8]=a*y+f*P+m*A+T*w,r[9]=o*y+u*P+_*A+C*w,r[10]=l*y+d*P+S*A+v*w,r[11]=h*y+p*P+g*A+E*w,y=i[12],P=i[13],A=i[14],w=i[15],r[12]=a*y+f*P+m*A+T*w,r[13]=o*y+u*P+_*A+C*w,r[14]=l*y+d*P+S*A+v*w,r[15]=h*y+p*P+g*A+E*w,this}mulAffine2(t,e){let s=t.data,i=e.data,r=this.data,a=s[0],o=s[1],l=s[2],h=s[4],f=s[5],u=s[6],d=s[8],p=s[9],m=s[10],_=s[12],S=s[13],g=s[14],T,C,v;return T=i[0],C=i[1],v=i[2],r[0]=a*T+h*C+d*v,r[1]=o*T+f*C+p*v,r[2]=l*T+u*C+m*v,r[3]=0,T=i[4],C=i[5],v=i[6],r[4]=a*T+h*C+d*v,r[5]=o*T+f*C+p*v,r[6]=l*T+u*C+m*v,r[7]=0,T=i[8],C=i[9],v=i[10],r[8]=a*T+h*C+d*v,r[9]=o*T+f*C+p*v,r[10]=l*T+u*C+m*v,r[11]=0,T=i[12],C=i[13],v=i[14],r[12]=a*T+h*C+d*v+_,r[13]=o*T+f*C+p*v+S,r[14]=l*T+u*C+m*v+g,r[15]=1,this}mul(t){return this.mul2(this,t)}transformPoint(t,e=new x){let s=this.data,{x:i,y:r,z:a}=t;return e.x=i*s[0]+r*s[4]+a*s[8]+s[12],e.y=i*s[1]+r*s[5]+a*s[9]+s[13],e.z=i*s[2]+r*s[6]+a*s[10]+s[14],e}transformVector(t,e=new x){let s=this.data,{x:i,y:r,z:a}=t;return e.x=i*s[0]+r*s[4]+a*s[8],e.y=i*s[1]+r*s[5]+a*s[9],e.z=i*s[2]+r*s[6]+a*s[10],e}transformVec4(t,e=new Q){let s=this.data,{x:i,y:r,z:a,w:o}=t;return e.x=i*s[0]+r*s[4]+a*s[8]+o*s[12],e.y=i*s[1]+r*s[5]+a*s[9]+o*s[13],e.z=i*s[2]+r*s[6]+a*s[10]+o*s[14],e.w=i*s[3]+r*s[7]+a*s[11]+o*s[15],e}setLookAt(t,e,s){Fa.sub2(t,e).normalize(),Oa.copy(s).normalize(),$r.cross(Oa,Fa).normalize(),Oa.cross(Fa,$r);let i=this.data;return i[0]=$r.x,i[1]=$r.y,i[2]=$r.z,i[3]=0,i[4]=Oa.x,i[5]=Oa.y,i[6]=Oa.z,i[7]=0,i[8]=Fa.x,i[9]=Fa.y,i[10]=Fa.z,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}setFrustum(t,e,s,i,r,a){let o=2*r,l=e-t,h=i-s,f=a-r,u=this.data;return u[0]=o/l,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=o/h,u[6]=0,u[7]=0,u[8]=(e+t)/l,u[9]=(i+s)/h,u[10]=(-a-r)/f,u[11]=-1,u[12]=0,u[13]=0,u[14]=-o*a/f,u[15]=0,this}setPerspective(t,e,s,i,r){return Fc._getPerspectiveHalfSize(zp,t,e,s,r),this.setFrustum(-zp.x,zp.x,-zp.y,zp.y,s,i)}setOrtho(t,e,s,i,r,a){let o=this.data;return o[0]=2/(e-t),o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2/(i-s),o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=-2/(a-r),o[11]=0,o[12]=-(e+t)/(e-t),o[13]=-(i+s)/(i-s),o[14]=-(a+r)/(a-r),o[15]=1,this}setFromAxisAngle(t,e){e*=R.DEG_TO_RAD;let{x:s,y:i,z:r}=t,a=Math.cos(e),o=Math.sin(e),l=1-a,h=l*s,f=l*i,u=this.data;return u[0]=h*s+a,u[1]=h*i+o*r,u[2]=h*r-o*i,u[3]=0,u[4]=h*i-o*r,u[5]=f*i+a,u[6]=f*r+o*s,u[7]=0,u[8]=h*r+o*i,u[9]=f*r-s*o,u[10]=l*r*r+a,u[11]=0,u[12]=0,u[13]=0,u[14]=0,u[15]=1,this}setTranslate(t,e,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]=t,i[13]=e,i[14]=s,i[15]=1,this}setScale(t,e,s){let i=this.data;return i[0]=t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e,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(t,e,s,i){let r=this.data;return r[0]=s*.5,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i*.5,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=.5,r[11]=0,r[12]=t+s*.5,r[13]=e+i*.5,r[14]=.5,r[15]=1,this}setReflection(t,e){let s=t.x,i=t.y,r=t.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*e,a[13]=-2*i*e,a[14]=-2*r*e,a[15]=1,this}invert(t=this){let e=t.data,s=e[0],i=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=e[6],f=e[7],u=e[8],d=e[9],p=e[10],m=e[11],_=e[12],S=e[13],g=e[14],T=e[15],C=s*l-i*o,v=s*h-r*o,E=s*f-a*o,y=i*h-r*l,P=i*f-a*l,A=r*f-a*h,w=u*S-d*_,I=u*g-p*_,D=u*T-m*_,O=d*g-p*S,G=d*T-m*S,M=p*T-m*g,H=C*M-v*G+E*O+y*D-P*I+A*w;if(H===0)this.setIdentity();else{let U=1/H,L=this.data;L[0]=(l*M-h*G+f*O)*U,L[1]=(-i*M+r*G-a*O)*U,L[2]=(S*A-g*P+T*y)*U,L[3]=(-d*A+p*P-m*y)*U,L[4]=(-o*M+h*D-f*I)*U,L[5]=(s*M-r*D+a*I)*U,L[6]=(-_*A+g*E-T*v)*U,L[7]=(u*A-p*E+m*v)*U,L[8]=(o*G-l*D+f*w)*U,L[9]=(-s*G+i*D-a*w)*U,L[10]=(_*P-S*E+T*C)*U,L[11]=(-u*P+d*E-m*C)*U,L[12]=(-o*O+l*I-h*w)*U,L[13]=(s*O-i*I+r*w)*U,L[14]=(-_*y+S*v-g*C)*U,L[15]=(u*y-d*v+p*C)*U}return this}set(t){let e=this.data;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this}setIdentity(){let t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}setTRS(t,e,s){let i=e.x,r=e.y,a=e.z,o=e.w,l=s.x,h=s.y,f=s.z,u=i+i,d=r+r,p=a+a,m=i*u,_=i*d,S=i*p,g=r*d,T=r*p,C=a*p,v=o*u,E=o*d,y=o*p,P=this.data;return P[0]=(1-(g+C))*l,P[1]=(_+y)*l,P[2]=(S-E)*l,P[3]=0,P[4]=(_-y)*h,P[5]=(1-(m+C))*h,P[6]=(T+v)*h,P[7]=0,P[8]=(S+E)*f,P[9]=(T-v)*f,P[10]=(1-(m+g))*f,P[11]=0,P[12]=t.x,P[13]=t.y,P[14]=t.z,P[15]=1,this}transpose(t=this){let e=t.data,s=this.data;if(e===s){let i;i=e[1],s[1]=e[4],s[4]=i,i=e[2],s[2]=e[8],s[8]=i,i=e[3],s[3]=e[12],s[12]=i,i=e[6],s[6]=e[9],s[9]=i,i=e[7],s[7]=e[13],s[13]=i,i=e[11],s[11]=e[14],s[14]=i}else s[0]=e[0],s[1]=e[4],s[2]=e[8],s[3]=e[12],s[4]=e[1],s[5]=e[5],s[6]=e[9],s[7]=e[13],s[8]=e[2],s[9]=e[6],s[10]=e[10],s[11]=e[14],s[12]=e[3],s[13]=e[7],s[14]=e[11],s[15]=e[15];return this}getTranslation(t=new x){return t.set(this.data[12],this.data[13],this.data[14])}getX(t=new x){return t.set(this.data[0],this.data[1],this.data[2])}getY(t=new x){return t.set(this.data[4],this.data[5],this.data[6])}getZ(t=new x){return t.set(this.data[8],this.data[9],this.data[10])}getScale(t=new x){return this.getX($r),this.getY(Oa),this.getZ(Fa),t.set($r.length(),Oa.length(),Fa.length()),t}get scaleSign(){return this.getX($r),this.getY(Oa),this.getZ(Fa),$r.cross($r,Oa),$r.dot(Fa)<0?-1:1}setFromEulerAngles(t,e,s){t*=R.DEG_TO_RAD,e*=R.DEG_TO_RAD,s*=R.DEG_TO_RAD;let i=Math.sin(-t),r=Math.cos(-t),a=Math.sin(-e),o=Math.cos(-e),l=Math.sin(-s),h=Math.cos(-s),f=this.data;return f[0]=o*h,f[1]=-o*l,f[2]=a,f[3]=0,f[4]=r*l+h*i*a,f[5]=r*h-i*a*l,f[6]=-o*i,f[7]=0,f[8]=i*l-r*h*a,f[9]=h*i+r*a*l,f[10]=r*o,f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,this}getEulerAngles(t=new x){this.getScale(LS);let e=LS.x,s=LS.y,i=LS.z;if(e===0||s===0||i===0)return t.set(0,0,0);let r=this.data,a=Math.asin(-r[2]/e),o=Math.PI*.5,l,h;return a<o?a>-o?(l=Math.atan2(r[6]/s,r[10]/i),h=Math.atan2(r[1]/e,r[0]/e)):(h=0,l=-Math.atan2(r[4]/s,r[5]/s)):(h=0,l=Math.atan2(r[4]/s,r[5]/s)),t.set(l,a,h).mulScalar(R.RAD_TO_DEG)}toString(){return`[${this.data.join(", ")}]`}};n(Fc,"IDENTITY",Object.freeze(new Fc)),n(Fc,"ZERO",Object.freeze(new Fc().set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])));var W=Fc;var Cf=class Cf{constructor(t=0,e=0,s=0,i=1){n(this,"x");n(this,"y");n(this,"z");n(this,"w");t.length===4?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=s,this.w=i)}clone(){let t=this.constructor;return new t(this.x,this.y,this.z,this.w)}conjugate(t=this){return this.x=t.x*-1,this.y=t.y*-1,this.z=t.z*-1,this.w=t.w,this}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w}equalsApprox(t,e=1e-6){return Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e&&Math.abs(this.z-t.z)<e&&Math.abs(this.w-t.w)<e}getAxisAngle(t){let e=Math.acos(this.w)*2,s=Math.sin(e/2);return s!==0?(t.x=this.x/s,t.y=this.y/s,t.z=this.z/s,(t.x<0||t.y<0||t.z<0)&&(t.x*=-1,t.y*=-1,t.z*=-1,e*=-1)):(t.x=1,t.y=0,t.z=0),e*R.RAD_TO_DEG}getEulerAngles(t=new x){let e,s,i,r=this.x,a=this.y,o=this.z,l=this.w,h=2*(l*a-r*o);return h<=-.99999?(e=2*Math.atan2(r,l),s=-Math.PI/2,i=0):h>=.99999?(e=2*Math.atan2(r,l),s=Math.PI/2,i=0):(e=Math.atan2(2*(l*r+a*o),1-2*(r*r+a*a)),s=Math.asin(h),i=Math.atan2(2*(l*o+r*a),1-2*(a*a+o*o))),t.set(e,s,i).mulScalar(R.RAD_TO_DEG)}invert(t=this){return this.conjugate(t).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(t,e,s){let i=(1-s)*(t.dot(e)<0?-1:1);return this.x=t.x*i+e.x*s,this.y=t.y*i+e.y*s,this.z=t.z*i+e.z*s,this.w=t.w*i+e.w*s,this.normalize()}mul(t){let e=this.x,s=this.y,i=this.z,r=this.w,a=t.x,o=t.y,l=t.z,h=t.w;return this.x=r*a+e*h+s*l-i*o,this.y=r*o+s*h+i*a-e*l,this.z=r*l+i*h+e*o-s*a,this.w=r*h-e*a-s*o-i*l,this}mulScalar(t,e=this){return this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this.w=e.w*t,this}mul2(t,e){let s=t.x,i=t.y,r=t.z,a=t.w,o=e.x,l=e.y,h=e.z,f=e.w;return this.x=a*o+s*f+i*h-r*l,this.y=a*l+i*f+r*o-s*h,this.z=a*h+r*f+s*l-i*o,this.w=a*f-s*o-i*l-r*h,this}normalize(t=this){let e=t.length();return e===0?(this.x=this.y=this.z=0,this.w=1):(e=1/e,this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e),this}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setFromAxisAngle(t,e){e*=.5*R.DEG_TO_RAD;let s=Math.sin(e),i=Math.cos(e);return this.x=s*t.x,this.y=s*t.y,this.z=s*t.z,this.w=i,this}setFromEulerAngles(t,e,s){if(t instanceof x){let u=t;t=u.x,e=u.y,s=u.z}let i=.5*R.DEG_TO_RAD;t*=i,e*=i,s*=i;let r=Math.sin(t),a=Math.cos(t),o=Math.sin(e),l=Math.cos(e),h=Math.sin(s),f=Math.cos(s);return this.x=r*l*f-a*o*h,this.y=a*o*f+r*l*h,this.z=a*l*h-r*o*f,this.w=a*l*f+r*o*h,this}setFromMat4(t){let e=t.data,s=e[0],i=e[1],r=e[2],a=e[4],o=e[5],l=e[6],h=e[8],f=e[9],u=e[10];s*(o*u-l*f)-i*(a*u-l*h)+r*(a*f-o*h)<0&&(s=-s,i=-i,r=-r);let p;return p=s*s+i*i+r*r,p===0?this.set(0,0,0,1):(p=1/Math.sqrt(p),s*=p,i*=p,r*=p,p=a*a+o*o+l*l,p===0?this.set(0,0,0,1):(p=1/Math.sqrt(p),a*=p,o*=p,l*=p,p=h*h+f*f+u*u,p===0?this.set(0,0,0,1):(p=1/Math.sqrt(p),h*=p,f*=p,u*=p,u<0?s>o?this.set(1+s-o-u,i+a,h+r,l-f):this.set(i+a,1-s+o-u,l+f,h-r):s<-o?this.set(h+r,l+f,1-s-o+u,i-a):this.set(l-f,h-r,i-a,1+s+o+u),this.mulScalar(1/this.length()))))}setFromDirections(t,e){let s=1+t.dot(e);return s<Number.EPSILON?Math.abs(t.x)>Math.abs(t.y)?(this.x=-t.z,this.y=0,this.z=t.x,this.w=0):(this.x=0,this.y=-t.z,this.z=t.y,this.w=0):(this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this.w=s),this.normalize()}slerp(t,e,s){let i=t.x,r=t.y,a=t.z,o=t.w,l=e.x,h=e.y,f=e.z,u=e.w,d=o*u+i*l+r*h+a*f;if(d<0&&(u=-u,l=-l,h=-h,f=-f,d=-d),Math.abs(d)>=1)return this.w=o,this.x=i,this.y=r,this.z=a,this;let p=Math.acos(d),m=Math.sqrt(1-d*d);if(Math.abs(m)<.001)return this.w=o*.5+u*.5,this.x=i*.5+l*.5,this.y=r*.5+h*.5,this.z=a*.5+f*.5,this;let _=Math.sin((1-s)*p)/m,S=Math.sin(s*p)/m;return this.w=o*_+u*S,this.x=i*_+l*S,this.y=r*_+h*S,this.z=a*_+f*S,this}transformVector(t,e=new x){let s=t.x,i=t.y,r=t.z,a=this.x,o=this.y,l=this.z,h=this.w,f=h*s+o*r-l*i,u=h*i+l*s-a*r,d=h*r+a*i-o*s,p=-a*s-o*i-l*r;return e.x=f*h+p*-a+u*-l-d*-o,e.y=u*h+p*-o+d*-a-f*-l,e.z=d*h+p*-l+f*-o-u*-a,e}fromArray(t,e=0){return this.x=t[e]??this.x,this.y=t[e+1]??this.y,this.z=t[e+2]??this.z,this.w=t[e+3]??this.w,this}toString(){return`[${this.x}, ${this.y}, ${this.z}, ${this.w}]`}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}};n(Cf,"IDENTITY",Object.freeze(new Cf(0,0,0,1))),n(Cf,"ZERO",Object.freeze(new Cf(0,0,0,0)));var $=Cf;var Pf=new x,wf=new x,NR=new x,BR=new x,LH=new x,ge=class c{constructor(t,e){n(this,"center",new x);n(this,"halfExtents",new x(.5,.5,.5));n(this,"_min",new x);n(this,"_max",new x);t&&this.center.copy(t),e&&this.halfExtents.copy(e)}add(t){let e=this.center,s=e.x,i=e.y,r=e.z,a=this.halfExtents,o=a.x,l=a.y,h=a.z,f=s-o,u=s+o,d=i-l,p=i+l,m=r-h,_=r+h,S=t.center,g=S.x,T=S.y,C=S.z,v=t.halfExtents,E=v.x,y=v.y,P=v.z,A=g-E,w=g+E,I=T-y,D=T+y,O=C-P,G=C+P;A<f&&(f=A),w>u&&(u=w),I<d&&(d=I),D>p&&(p=D),O<m&&(m=O),G>_&&(_=G),e.x=(f+u)*.5,e.y=(d+p)*.5,e.z=(m+_)*.5,a.x=(u-f)*.5,a.y=(p-d)*.5,a.z=(_-m)*.5}copy(t){this.center.copy(t.center),this.halfExtents.copy(t.halfExtents)}clone(){return new c(this.center,this.halfExtents)}intersects(t){let e=this.getMax(),s=this.getMin(),i=t.getMax(),r=t.getMin();return s.x<=i.x&&e.x>=r.x&&s.y<=i.y&&e.y>=r.y&&s.z<=i.z&&e.z>=r.z}_intersectsRay(t,e){let s=Pf.copy(this.getMin()).sub(t.origin),i=wf.copy(this.getMax()).sub(t.origin),r=t.direction;r.x===0?(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),r.y===0?(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),r.z===0?(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=NR.set(Math.min(s.x,i.x),Math.min(s.y,i.y),Math.min(s.z,i.z)),o=BR.set(Math.max(s.x,i.x),Math.max(s.y,i.y),Math.max(s.z,i.z)),l=Math.min(Math.min(o.x,o.y),o.z),h=Math.max(Math.max(a.x,a.y),a.z),f=l>=h&&h>=0;return f&&e.copy(t.direction).mulScalar(h).add(t.origin),f}_fastIntersectsRay(t){let e=Pf,s=wf,i=NR,r=BR,a=LH,o=t.direction;return e.sub2(t.origin,this.center),r.set(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),i.mul2(e,o),!(r.x>this.halfExtents.x&&i.x>=0||r.y>this.halfExtents.y&&i.y>=0||r.z>this.halfExtents.z&&i.z>=0||(a.set(Math.abs(o.x),Math.abs(o.y),Math.abs(o.z)),s.cross(o,e),s.set(Math.abs(s.x),Math.abs(s.y),Math.abs(s.z)),s.x>this.halfExtents.y*a.z+this.halfExtents.z*a.y)||s.y>this.halfExtents.x*a.z+this.halfExtents.z*a.x||s.z>this.halfExtents.x*a.y+this.halfExtents.y*a.x)}intersectsRay(t,e){return e?this._intersectsRay(t,e):this._fastIntersectsRay(t)}setMinMax(t,e){this.center.add2(e,t).mulScalar(.5),this.halfExtents.sub2(e,t).mulScalar(.5)}getMin(){return this._min.copy(this.center).sub(this.halfExtents)}getMax(){return this._max.copy(this.center).add(this.halfExtents)}containsPoint(t){let e=this.center,s=this.halfExtents;return!(t.x<e.x-s.x||t.x>e.x+s.x||t.y<e.y-s.y||t.y>e.y+s.y||t.z<e.z-s.z||t.z>e.z+s.z)}closestPoint(t,e=new x){let s=this.center,i=this.halfExtents;return e.set(Math.max(s.x-i.x,Math.min(t.x,s.x+i.x)),Math.max(s.y-i.y,Math.min(t.y,s.y+i.y)),Math.max(s.z-i.z,Math.min(t.z,s.z+i.z)))}setFromTransformedAabb(t,e,s=!1){let i=t.center,r=t.halfExtents,a=e.data,o=a[0],l=a[4],h=a[8],f=a[1],u=a[5],d=a[9],p=a[2],m=a[6],_=a[10];if(s){let S=o*o+l*l+h*h;if(S>0){let g=1/Math.sqrt(S);o*=g,l*=g,h*=g}if(S=f*f+u*u+d*d,S>0){let g=1/Math.sqrt(S);f*=g,u*=g,d*=g}if(S=p*p+m*m+_*_,S>0){let g=1/Math.sqrt(S);p*=g,m*=g,_*=g}}this.center.set(a[12]+o*i.x+l*i.y+h*i.z,a[13]+f*i.x+u*i.y+d*i.z,a[14]+p*i.x+m*i.y+_*i.z),this.halfExtents.set(Math.abs(o)*r.x+Math.abs(l)*r.y+Math.abs(h)*r.z,Math.abs(f)*r.x+Math.abs(u)*r.y+Math.abs(d)*r.z,Math.abs(p)*r.x+Math.abs(m)*r.y+Math.abs(_)*r.z)}static computeMinMax(t,e,s,i=t.length/3){if(i>0){let r=t[0],a=t[1],o=t[2],l=