playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
10 lines • 2.37 MB
JavaScript
/**
* @license
* PlayCanvas Engine v2.21.1 revision 2827828 (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 T4=Object.defineProperty;var y4=(c,t,e)=>t in c?T4(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var IA=(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)=>y4(c,typeof t!="symbol"?t+"":t,e);var Wj="RenderFrame",Xj="RenderFrameTime",Yj="RenderPass",Kj="RenderPassDetail",qj="RenderAction",jj="RenderTargetAlloc",$j="TextureAlloc",Zj="ShaderAlloc",Qj="ShaderCompile",Jj="VRAM.Texture",e$="VRAM.Vb",t$="VRAM.Ib",s$="VRAM.Sb",i$="BindGroupAlloc",r$="BindGroupFormatAlloc",a$="RenderPipelineAlloc",o$="ComputePipelineAlloc",n$="PipelineLayoutAlloc",l$="Element",c$="Textures",h$="Buffers",f$="Assets",d$="RenderQueue",u$="OctreeResources",ZI="GpuTimings";var Ap="2.21.1",bA="2827828";function Ic(c,t){for(let e in t){let s=t[e];Array.isArray(s)?c[e]=Ic([],s):s&&typeof s=="object"?c[e]=Ic({},s):c[e]=s}return c}var DA={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 Re={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]===Re.delimiter){t=i;continue}s&&i&&s[s.length-1]!==Re.delimiter&&i[0]!==Re.delimiter?t+=Re.delimiter+i:t+=i}return t},normalize(c){let t=c.startsWith(Re.delimiter),e=c.endsWith(Re.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(Re.delimiter),r.push(s[a])}return i=r.join(""),!t&&i[0]===Re.delimiter&&(i=i.slice(1)),e&&i[i.length-1]!==Re.delimiter&&(i+=Re.delimiter),i},split(c){let t=c.lastIndexOf(Re.delimiter);return t!==-1?[c.substring(0,t),c.substring(t+1)]:["",c]},getBasename(c){return Re.split(c)[1]},getDirectory(c){return Re.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(Re.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 E4=()=>{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},gr=typeof navigator<"u"?navigator.userAgent:"",bo=typeof window<"u"?"browser":typeof global<"u"?"node":"worker",Cp=/android/i.test(gr)?"android":/ip(?:[ao]d|hone)/i.test(gr)?"ios":/windows/i.test(gr)?"windows":/mac os/i.test(gr)?"osx":/linux/i.test(gr)?"linux":/cros/i.test(gr)?"cros":null,A4=bo!=="browser"?null:/Chrome\/|Chromium\/|Edg.*\//.test(gr)?"chrome":/Safari\//.test(gr)?"safari":/Firefox\//.test(gr)?"firefox":"other",C4=/xbox/i.test(gr),w4=/Macintosh/i.test(gr)&&typeof navigator<"u"&&navigator.maxTouchPoints>0&&!/iPhone|iPad|iPod/i.test(gr),P4=bo==="browser"&&("ontouchstart"in window||"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0),R4=bo==="browser"&&(!!navigator.getGamepads||!!navigator.webkitGetGamepads),I4=typeof Worker<"u",b4=E4(),ce={name:Cp,environment:bo,global:(typeof globalThis<"u"&&globalThis)??(bo==="browser"&&window)??(bo==="node"&&global)??(bo==="worker"&&self),browser:bo==="browser",worker:bo==="worker",desktop:["windows","osx","linux","cros"].includes(Cp),mobile:["android","ios"].includes(Cp),ios:Cp==="ios",android:Cp==="android",visionos:w4,xbox:C4,gamepads:R4,touch:P4,workers:I4,passiveEvents:b4,browserName:A4};var tb="abcdefghijklmnopqrstuvwxyz",sb="ABCDEFGHIJKLMNOPQRSTUVWXYZ",D4=tb+sb,LA=55296,ib=56319,QI=56320,L4=57343,M4=8205,JI=127462,eb=127487,O4=127995,F4=127999,N4=8400,B4=8447,MA=65024,OA=65039;function FA(c,t=0){let e=c.length;if(t<0||t>=e)return null;let s=c.charCodeAt(t);if(e>1&&s>=LA&&s<=ib){let i=c.charCodeAt(t+1);if(i>=QI&&i<=L4)return{code:(s-LA)*1024+i-QI+65536,long:!0}}return{code:s,long:!1}}function jn(c,t,e){if(!c)return!1;let s=FA(c);if(s){let i=s.code;return i>=t&&i<=e}return!1}function U4(c,t){if(t===c.length-1)return 1;if(jn(c[t],LA,ib)){let e=c.substring(t,t+2),s=c.substring(t+2,t+4);return jn(s,O4,F4)||jn(e,JI,eb)&&jn(s,JI,eb)?4:jn(s,MA,OA)?3:2}return jn(c[t+1],MA,OA)?2:1}var Wr={ASCII_LOWERCASE:tb,ASCII_UPPERCASE:sb,ASCII_LETTERS:D4,format(c,...t){for(let e=0;e<t.length;e++)c=c.replace(`{${e}}`,t[e]);return c},getCodePoint(c,t){let e=FA(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=FA(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+=U4(c,t+i),r=c[t+i],jn(r,N4,B4)&&(r=c[t+i++]),jn(r,MA,OA)&&(r=c[t+i++]),r&&r.charCodeAt(0)===M4){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 wp=class wp{static set(t,e=!0){}static get(t){return wp._traceChannels.has(t)}};n(wp,"_traceChannels",new Set),n(wp,"stack",!1);var Pp=wp;var Rp=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 Z=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 Rp(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 d;this._callbackActive.has(t)?this._callbackActive.get(t)!==f&&(d=f.slice()):this._callbackActive.set(t,f);for(let u=0;(d||this._callbackActive.get(t))&&u<(d||this._callbackActive.get(t)).length;u++){let p=(d||this._callbackActive.get(t))[u];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 g=this._callbacks.get(t);if(!g)continue;g[_].removed=!0,g.splice(_,1),g.length===0&&this._callbacks.delete(t)}}}return d||this._callbackActive.delete(t),this}hasEvent(t){return!!this._callbacks.get(t)?.length}};var Ip=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 k4=c=>{let t={},e=t;return()=>(e===t&&(e=c()),e)},Fa=class Fa{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=Fa.wasmSupported()&&e.glueUrl&&e.wasmUrl?e.glueUrl:e.fallbackUrl;i?Fa.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 Fa.modules.hasOwnProperty(t)||(Fa.modules[t]={config:null,initializing:!1,instance:null,callbacks:[]}),Fa.modules[t]}static initialize(t,e){if(e.initializing)return;let s=e.config;(s.glueUrl||s.wasmUrl||s.fallbackUrl)&&(e.initializing=!0,Fa.loadWasm(t,s,(i,r)=>{i?s.errorHandler&&s.errorHandler(i):(e.instance=r,e.callbacks.forEach(a=>{a(r)}))}))}};n(Fa,"modules",{}),n(Fa,"wasmSupported",k4(()=>{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 bc=Fa,Dc=class{static setConfig(t,e){let s=bc.getModule(t);s.config=e,s.callbacks.length>0&&bc.initialize(t,s)}static getConfig(t){return bc.modules?.[t]?.config}static getInstance(t,e){let s=bc.getModule(t);s.instance?e(s.instance):(s.callbacks.push(e),s.config&&bc.initialize(t,s))}};var Lc=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 Do=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 Na=class extends Z{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(Na,"EVENT_ADD","add"),n(Na,"EVENT_REMOVE","remove"),n(Na,"EVENT_CHANGE","change");var Ct=typeof window<"u"&&window.performance&&window.performance.now?performance.now.bind(performance):Date.now;function z4(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 V4=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,Mc=class{constructor(t){n(this,"scheme");n(this,"authority");n(this,"path");n(this,"query");n(this,"fragment");let e=t.match(V4);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 G4=0,NA=1,rb=4,H4=5;var I={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)*I.clamp(e,0,1)},lerpUnclamped(c,t,e){return c+(t-c)*e},lerpAngle(c,t,e){return t-c>180&&(t-=360),t-c<-180&&(t+=360),I.lerp(c,t,I.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 hs=class hs{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=I.intToBytes32(e):(s=I.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(hs,"BLACK",Object.freeze(new hs(0,0,0,1))),n(hs,"BLUE",Object.freeze(new hs(0,0,1,1))),n(hs,"CYAN",Object.freeze(new hs(0,1,1,1))),n(hs,"GRAY",Object.freeze(new hs(.5,.5,.5,1))),n(hs,"GREEN",Object.freeze(new hs(0,1,0,1))),n(hs,"MAGENTA",Object.freeze(new hs(1,0,1,1))),n(hs,"RED",Object.freeze(new hs(1,0,0,1))),n(hs,"WHITE",Object.freeze(new hs(1,1,1,1))),n(hs,"YELLOW",Object.freeze(new hs(1,1,0,1)));var O=hs;var pf=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=I.lerp(this._p0,this._p1,r):i===1?s=I.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),d=this._curve.tension;this._m0=d*(r[1]-h),this._m1=d*(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 Ts=class{constructor(t){n(this,"keys",[]);n(this,"type",1);n(this,"tension",.5);n(this,"_eval",new pf(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}remove(t){return t<0||t>=this.keys.length?null:this.keys.splice(t,1)[0]}clear(){return this.keys.length=0,this}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 zi=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 Ts(t[e]));else if(t.length===0)this.curves.push(new Ts);else{let e=t[0];if(typeof e=="number")for(let s=0;s<e;s++)this.curves.push(new Ts);else for(let s=0;s<e.length;s++)this.curves.push(new Ts(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]}add(t){let e=new Ts(t);return e.type=this._type,this.curves.push(e),e}remove(t){let e=typeof t=="number"?t:this.curves.indexOf(t);return e<0||e>=this.curves.length?null:this.curves.splice(e,1)[0]}clearKeys(){for(let t=0;t<this.curves.length;t++)this.curves[t].clear();return this}clear(){return this.curves.length=0,this}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 pf(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 BA=new Float32Array(1),ab=new Int32Array(BA.buffer),Xs=class{static float2Half(t){BA[0]=t;let e=ab[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){BA[0]=t;let s=ab[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 bp=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 d=f*h,u=a*Math.cos(d),p=a*Math.sin(d);s.push(u,p)}}return s}};var fs=class fs{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}scale(t){return this.mulScalar(t)}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(fs,"ZERO",Object.freeze(new fs(0,0,0))),n(fs,"HALF",Object.freeze(new fs(.5,.5,.5))),n(fs,"ONE",Object.freeze(new fs(1,1,1))),n(fs,"UP",Object.freeze(new fs(0,1,0))),n(fs,"DOWN",Object.freeze(new fs(0,-1,0))),n(fs,"RIGHT",Object.freeze(new fs(1,0,0))),n(fs,"LEFT",Object.freeze(new fs(-1,0,0))),n(fs,"FORWARD",Object.freeze(new fs(0,0,-1))),n(fs,"BACK",Object.freeze(new fs(0,0,1)));var v=fs;var mf=class mf{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 v){return t.set(this.data[0],this.data[1],this.data[2])}getY(t=new v){return t.set(this.data[3],this.data[4],this.data[5])}getZ(t=new v){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,d=e*l,u=s*o,p=s*l,m=i*l,_=r*a,g=r*o,S=r*l,x=this.data;return x[0]=1-(u+m),x[1]=f+S,x[2]=d-g,x[3]=f-S,x[4]=1-(h+m),x[5]=p+_,x[6]=d+g,x[7]=p-_,x[8]=1-(h+u),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],d=e[10],u=d*o-l*f,p=-d*i+r*f,m=l*i-r*o,_=-d*a+l*h,g=d*s-r*h,S=-l*s+r*a,x=f*a-o*h,E=-f*s+i*h,T=o*s-i*a,A=s*u+i*_+r*x;if(A===0)this.setIdentity();else{let y=1/A,C=this.data;C[0]=u*y,C[1]=p*y,C[2]=m*y,C[3]=_*y,C[4]=g*y,C[5]=S*y,C[6]=x*y,C[7]=E*y,C[8]=T*y}return this}transformVector(t,e=new v){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(mf,"IDENTITY",Object.freeze(new mf)),n(mf,"ZERO",Object.freeze(new mf().set([0,0,0,0,0,0,0,0,0])));var Ys=mf;var ai=class ai{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}scale(t){return this.mulScalar(t)}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*I.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)*I.RAD_TO_DEG}angleTo(t){return Math.atan2(this.x*t.y+this.y*t.x,this.x*t.x+this.y*t.y)*I.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(ai,"ZERO",Object.freeze(new ai(0,0))),n(ai,"HALF",Object.freeze(new ai(.5,.5))),n(ai,"ONE",Object.freeze(new ai(1,1))),n(ai,"UP",Object.freeze(new ai(0,1))),n(ai,"DOWN",Object.freeze(new ai(0,-1))),n(ai,"RIGHT",Object.freeze(new ai(1,0))),n(ai,"LEFT",Object.freeze(new ai(-1,0)));var B=ai;var $n=class $n{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}scale(t){return this.mulScalar(t)}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($n,"ZERO",Object.freeze(new $n(0,0,0,0))),n($n,"HALF",Object.freeze(new $n(.5,.5,.5,.5))),n($n,"ONE",Object.freeze(new $n(1,1,1,1)));var $=$n;var Dp=new B,Xr=new v,Ba=new v,Ua=new v,XS=new v,Oc=class Oc{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],d=s[5],u=s[6],p=s[7],m=s[8],_=s[9],g=s[10],S=s[11],x=s[12],E=s[13],T=s[14],A=s[15],y,C,w,P;return y=i[0],C=i[1],w=i[2],P=i[3],r[0]=a*y+f*C+m*w+x*P,r[1]=o*y+d*C+_*w+E*P,r[2]=l*y+u*C+g*w+T*P,r[3]=h*y+p*C+S*w+A*P,y=i[4],C=i[5],w=i[6],P=i[7],r[4]=a*y+f*C+m*w+x*P,r[5]=o*y+d*C+_*w+E*P,r[6]=l*y+u*C+g*w+T*P,r[7]=h*y+p*C+S*w+A*P,y=i[8],C=i[9],w=i[10],P=i[11],r[8]=a*y+f*C+m*w+x*P,r[9]=o*y+d*C+_*w+E*P,r[10]=l*y+u*C+g*w+T*P,r[11]=h*y+p*C+S*w+A*P,y=i[12],C=i[13],w=i[14],P=i[15],r[12]=a*y+f*C+m*w+x*P,r[13]=o*y+d*C+_*w+E*P,r[14]=l*y+u*C+g*w+T*P,r[15]=h*y+p*C+S*w+A*P,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],d=s[6],u=s[8],p=s[9],m=s[10],_=s[12],g=s[13],S=s[14],x,E,T;return x=i[0],E=i[1],T=i[2],r[0]=a*x+h*E+u*T,r[1]=o*x+f*E+p*T,r[2]=l*x+d*E+m*T,r[3]=0,x=i[4],E=i[5],T=i[6],r[4]=a*x+h*E+u*T,r[5]=o*x+f*E+p*T,r[6]=l*x+d*E+m*T,r[7]=0,x=i[8],E=i[9],T=i[10],r[8]=a*x+h*E+u*T,r[9]=o*x+f*E+p*T,r[10]=l*x+d*E+m*T,r[11]=0,x=i[12],E=i[13],T=i[14],r[12]=a*x+h*E+u*T+_,r[13]=o*x+f*E+p*T+g,r[14]=l*x+d*E+m*T+S,r[15]=1,this}mul(t){return this.mul2(this,t)}transformPoint(t,e=new v){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 v){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 $){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){Ua.sub2(t,e).normalize(),Ba.copy(s).normalize(),Xr.cross(Ba,Ua).normalize(),Ba.cross(Ua,Xr);let i=this.data;return i[0]=Xr.x,i[1]=Xr.y,i[2]=Xr.z,i[3]=0,i[4]=Ba.x,i[5]=Ba.y,i[6]=Ba.z,i[7]=0,i[8]=Ua.x,i[9]=Ua.y,i[10]=Ua.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,d=this.data;return d[0]=o/l,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=o/h,d[6]=0,d[7]=0,d[8]=(e+t)/l,d[9]=(i+s)/h,d[10]=(-a-r)/f,d[11]=-1,d[12]=0,d[13]=0,d[14]=-o*a/f,d[15]=0,this}setPerspective(t,e,s,i,r){return Oc._getPerspectiveHalfSize(Dp,t,e,s,r),this.setFrustum(-Dp.x,Dp.x,-Dp.y,Dp.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*=I.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,d=this.data;return d[0]=h*s+a,d[1]=h*i+o*r,d[2]=h*r-o*i,d[3]=0,d[4]=h*i-o*r,d[5]=f*i+a,d[6]=f*r+o*s,d[7]=0,d[8]=h*r+o*i,d[9]=f*r-s*o,d[10]=l*r*r+a,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[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],d=e[8],u=e[9],p=e[10],m=e[11],_=e[12],g=e[13],S=e[14],x=e[15],E=s*l-i*o,T=s*h-r*o,A=s*f-a*o,y=i*h-r*l,C=i*f-a*l,w=r*f-a*h,P=d*g-u*_,R=d*S-p*_,D=d*x-m*_,L=u*S-p*g,W=u*x-m*g,F=p*x-m*S,G=E*F-T*W+A*L+y*D-C*R+w*P;if(G===0)this.setIdentity();else{let H=1/G,M=this.data;M[0]=(l*F-h*W+f*L)*H,M[1]=(-i*F+r*W-a*L)*H,M[2]=(g*w-S*C+x*y)*H,M[3]=(-u*w+p*C-m*y)*H,M[4]=(-o*F+h*D-f*R)*H,M[5]=(s*F-r*D+a*R)*H,M[6]=(-_*w+S*A-x*T)*H,M[7]=(d*w-p*A+m*T)*H,M[8]=(o*W-l*D+f*P)*H,M[9]=(-s*W+i*D-a*P)*H,M[10]=(_*C-g*A+x*E)*H,M[11]=(-d*C+u*A-m*E)*H,M[12]=(-o*L+l*R-h*P)*H,M[13]=(s*L-i*R+r*P)*H,M[14]=(-_*y+g*T-S*E)*H,M[15]=(d*y-u*T+p*E)*H}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,d=i+i,u=r+r,p=a+a,m=i*d,_=i*u,g=i*p,S=r*u,x=r*p,E=a*p,T=o*d,A=o*u,y=o*p,C=this.data;return C[0]=(1-(S+E))*l,C[1]=(_+y)*l,C[2]=(g-A)*l,C[3]=0,C[4]=(_-y)*h,C[5]=(1-(m+E))*h,C[6]=(x+T)*h,C[7]=0,C[8]=(g+A)*f,C[9]=(x-T)*f,C[10]=(1-(m+S))*f,C[11]=0,C[12]=t.x,C[13]=t.y,C[14]=t.z,C[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 v){return t.set(this.data[12],this.data[13],this.data[14])}getX(t=new v){return t.set(this.data[0],this.data[1],this.data[2])}getY(t=new v){return t.set(this.data[4],this.data[5],this.data[6])}getZ(t=new v){return t.set(this.data[8],this.data[9],this.data[10])}getScale(t=new v){return this.getX(Xr),this.getY(Ba),this.getZ(Ua),t.set(Xr.length(),Ba.length(),Ua.length()),t}get scaleSign(){return this.getX(Xr),this.getY(Ba),this.getZ(Ua),Xr.cross(Xr,Ba),Xr.dot(Ua)<0?-1:1}setFromEulerAngles(t,e,s){t*=I.DEG_TO_RAD,e*=I.DEG_TO_RAD,s*=I.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 v){this.getScale(XS);let e=XS.x,s=XS.y,i=XS.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(I.RAD_TO_DEG)}toString(){return`[${this.data.join(", ")}]`}};n(Oc,"IDENTITY",Object.freeze(new Oc)),n(Oc,"ZERO",Object.freeze(new Oc().set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])));var V=Oc;var _f=class _f{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*I.RAD_TO_DEG}getEulerAngles(t=new v){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(I.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*I.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 v){let d=t;t=d.x,e=d.y,s=d.z}let i=.5*I.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],d=e[10];s*(o*d-l*f)-i*(a*d-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+d*d,p===0?this.set(0,0,0,1):(p=1/Math.sqrt(p),h*=p,f*=p,d*=p,d<0?s>o?this.set(1+s-o-d,i+a,h+r,l-f):this.set(i+a,1-s+o-d,l+f,h-r):s<-o?this.set(h+r,l+f,1-s-o+d,i-a):this.set(l-f,h-r,i-a,1+s+o+d),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,d=e.w,u=o*d+i*l+r*h+a*f;if(u<0&&(d=-d,l=-l,h=-h,f=-f,u=-u),Math.abs(u)>=1)return this.w=o,this.x=i,this.y=r,this.z=a,this;let p=Math.acos(u),m=Math.sqrt(1-u*u);if(Math.abs(m)<.001)return this.w=o*.5+d*.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,g=Math.sin(s*p)/m;return this.w=o*_+d*g,this.x=i*_+l*g,this.y=r*_+h*g,this.z=a*_+f*g,this}transformVector(t,e=new v){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,d=h*i+l*s-a*r,u=h*r+a*i-o*s,p=-a*s-o*i-l*r;return e.x=f*h+p*-a+d*-l-u*-o,e.y=d*h+p*-o+u*-a-f*-l,e.z=u*h+p*-l+f*-o-d*-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(_f,"IDENTITY",Object.freeze(new _f(0,0,0,1))),n(_f,"ZERO",Object.freeze(new _f(0,0,0,0)));var K=_f;var gf=new v,Sf=new v,ob=new v,nb=new v,W4=new v,le=class c{constructor(t,e){n(this,"center",new v);n(this,"halfExtents",new v(.5,.5,.5));n(this,"_min",new v);n(this,"_max",new v);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,d=s+o,u=i-l,p=i+l,m=r-h,_=r+h,g=t.center,S=g.x,x=g.y,E=g.z,T=t.halfExtents,A=T.x,y=T.y,C=T.z,w=S-A,P=S+A,R=x-y,D=x+y,L=E-C,W=E+C;w<f&&(f=w),P>d&&(d=P),R<u&&(u=R),D>p&&(p=D),L<m&&(m=L),W>_&&(_=W),e.x=(f+d)*.5,e.y=(u+p)*.5,e.z=(m+_)*.5,a.x=(d-f)*.5,a.y=(p-u)*.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=gf.copy(this.getMin()).sub(t.origin),i=Sf.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=ob.set(Math.min(s.x,i.x),Math.min(s.y,i.y),Math.min(s.z,i.z)),o=nb.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=gf,s=Sf,i=ob,r=nb,a=W4,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 v){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],