@fleox/agent3d 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -13
- package/changelog.json +15 -0
- package/dist/agent/agent3d.mjs +228 -53
- package/dist/agent/chunks/{assets-BUUM9TUB.mjs → assets-YBkgdfgy.mjs} +27 -8
- package/dist/agent/chunks/{browser-Br1tURgt.mjs → browser-Dil7VM5m.mjs} +1 -1
- package/dist/agent/chunks/{cdp-Bdtm4fBN.mjs → cdp-DLEis_Z3.mjs} +1 -1
- package/dist/agent/chunks/{check-CfZcfaPs.mjs → check-DP9fRYbK.mjs} +64 -4
- package/dist/agent/chunks/depth-0bZsQn6N.mjs +190 -0
- package/dist/agent/chunks/depth-Dih8jLqx.mjs +483 -0
- package/dist/agent/chunks/{export-BHugc2H7.mjs → export-Cdqt3mt_.mjs} +8 -4
- package/dist/agent/chunks/{imageCodec-QM0EXQDJ.mjs → imageCodec-DeGfmBp3.mjs} +3 -3
- package/dist/agent/chunks/{objects-DBAws7uf.mjs → objects-DuytRxiC.mjs} +3 -3
- package/dist/agent/chunks/{optimizeSizing-CkZ3fZRp.mjs → optimizeSizing-B-BBiUkD.mjs} +51 -3
- package/dist/agent/chunks/{package-fw4h5vsh.mjs → package-d5e08XSG.mjs} +2 -1
- package/dist/agent/chunks/{render-EHb40avl.mjs → render-B05DU4Q5.mjs} +4 -4
- package/dist/agent/chunks/{scene-BgajNvBf.mjs → scene-DWgXH6As.mjs} +2 -2
- package/dist/agent/chunks/{server-CACCerkZ.mjs → server-Dt_YFvN7.mjs} +6 -2
- package/dist/agent/chunks/{tools-DKxgjQSJ.mjs → tools-Cv6N_YBI.mjs} +60 -6
- package/dist/agent/chunks/{tree-BrNYGui2.mjs → tree-CqSj-o8T.mjs} +1 -0
- package/dist/agent/ort/LICENSE.txt +9 -0
- package/dist/agent/ort/ort-wasm-simd-threaded.wasm +0 -0
- package/dist/agent/ort/ort.wasm.bundle.min.mjs +9 -0
- package/dist/runtime/agent3d-runtime.js +6 -6
- package/dist/runtime/agent3d-runtime.single.js +311 -62
- package/dist/runtime/chunks/assets-qnxDnVkj.js +1 -0
- package/dist/runtime/chunks/materials-dC4vDNHh.js +107 -0
- package/dist/runtime/chunks/{model-DbfZaLni.js → model-BCAl_NRl.js} +1 -1
- package/dist/runtime/chunks/photo-BlDYgYFM.js +250 -0
- package/dist/runtime/chunks/svg-CLUxY6Zy.js +1 -0
- package/dist/runtime/chunks/{text-BaON-ISS.js → text-rSo_2Luk.js} +2 -2
- package/dist/studio/assets/assets-BFJsr9Oo.js +1 -0
- package/dist/studio/assets/{camera-Be6lnp3k.js → camera-DT0xHipx.js} +1 -1
- package/dist/studio/assets/{editor-Mpnz-b2E.js → editor-BjgHj9g8.js} +1 -1
- package/dist/studio/assets/{game-WMgRSJUD.js → game-BXZEc9HN.js} +3 -3
- package/dist/studio/assets/{generators-DozXE7ta.js → generators-DqkPMEzm.js} +1 -1
- package/dist/studio/assets/index-DVTzVcBD.js +479 -0
- package/dist/studio/assets/{model-C2bZTK7-.js → model-BqQW4Dg-.js} +1 -1
- package/dist/studio/assets/params-gVpEEiSK.js +1 -0
- package/dist/studio/assets/photo-DRoVO5iZ.js +250 -0
- package/dist/studio/assets/{physicsHost-CTRsIvfu.js → physicsHost-DNdZ7AsT.js} +1 -1
- package/dist/studio/assets/{postfx-DQtp0JIy.js → postfx-JFUGdY0d.js} +1 -1
- package/dist/studio/assets/runtime-CMAP4azF.js +572 -0
- package/dist/studio/assets/{shaders-BOb6Uter.js → shaders-C7u6rN_6.js} +12 -12
- package/dist/studio/assets/svg-DkIOJjzS.js +2 -0
- package/dist/studio/assets/{text-CGIZs8HE.js → text-LISSAism.js} +2 -2
- package/dist/studio/index.html +1 -1
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/skills/agent3d-assets/SKILL.md +40 -25
- package/plugin/skills/agent3d-create/SKILL.md +56 -21
- package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
- package/plugin/skills/agent3d-create/references/recipes.md +71 -6
- package/plugin/skills/agent3d-edit/SKILL.md +22 -22
- package/plugin/skills/agent3d-edit/references/patch-ops.md +11 -3
- package/plugin/skills/agent3d-game/SKILL.md +7 -7
- package/plugin/skills/agent3d-publish/SKILL.md +23 -21
- package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
- package/templates/hero-photo-3d/README.md +28 -0
- package/templates/hero-photo-3d/agent3d.json +8 -0
- package/templates/hero-photo-3d/assets/depth/street-depth.png +0 -0
- package/templates/hero-photo-3d/assets/manifest.json +25 -0
- package/templates/hero-photo-3d/assets/textures/street.jpg +0 -0
- package/templates/hero-photo-3d/preview.png +0 -0
- package/templates/hero-photo-3d/scene.json +120 -0
- package/templates/hero-photo-3d/template.json +8 -0
- package/dist/runtime/chunks/materials-w3EW0g-7.js +0 -107
- package/dist/runtime/chunks/svg-CfPIQnDG.js +0 -1
- package/dist/studio/assets/index-tSGZFEt5.js +0 -479
- package/dist/studio/assets/runtime-NGp1VdnH.js +0 -572
- package/dist/studio/assets/svg-CnUMpv_N.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=`0.2.3`,i=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function a(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function o(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(i.lastIndex=0,i.test(e))}function s(e,t){return e.includes(`{data.`)?e.replace(i,(e,n,r)=>{let i=a(t,n);return i==null||i===``?r??``:typeof i==`object`?JSON.stringify(i):String(i)}):e}var c=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function l(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=c.exec(e.trim());if(!n)return s(e,t);let r=a(t,n[1]);if(r!=null&&r!==``)return r;if(n[2]!==void 0)try{return JSON.parse(n[2])}catch{return n[2]}}function u(e,t=e.data){let n=!1,r=e=>o(e)?(n=!0,s(e,t)):e,i=e=>{if(typeof e==`string`)return o(e)?(n=!0,l(e,t)):e;if(Array.isArray(e)){let t=e.map(i);return t.every((t,n)=>t===e[n])?e:t}if(e&&typeof e==`object`){let t=!1,n={};for(let[r,a]of Object.entries(e)){let e=i(a);e!==a&&(t=!0),e!==void 0&&(n[r]=e)}return t?n:e}return e},a=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,o=r(t.href),s=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(a);return n===t.text&&o===t.href&&s===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:o},...s===t.params?{}:{params:s},...c?{children:c}:{}}},c=e.interactions?.map(e=>{let t=e.do;if(!Array.isArray(t))return e;let n=t.map(e=>{let t=e;return!t||typeof t!=`object`||!o(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),u=(e.objects??[]).map(a),d=r(e.title),f=r(e.ariaLabel),p=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:d,...e.ariaLabel===void 0?{}:{ariaLabel:f},objects:u,...e.ui&&p?{ui:{...e.ui,elements:p}}:{},...c?{interactions:c}:{}}:e}function d(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(n===`json`)try{let e=JSON.parse(r);e&&typeof e==`object`&&!Array.isArray(e)&&Object.assign(t,e)}catch{}else t[n]=r}return t}function f(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function p(e,t){return new mi[e](t)}function m(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function h(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function g(){let e=h(`canvas`);return e.style.display=`block`,e}function _(e){gi=e}function v(){return gi}function y(...e){let t=`THREE.`+e.shift();gi?gi(`log`,t,...e):console.log(t,...e)}function b(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function x(...e){e=b(e);let t=`THREE.`+e.shift();if(gi)gi(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function S(...e){e=b(e);let t=`THREE.`+e.shift();if(gi)gi(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function C(...e){let t=e.join(` `);t in hi||(hi[t]=!0,x(...e))}function w(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}function T(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(yi[e&255]+yi[e>>8&255]+yi[e>>16&255]+yi[e>>24&255]+`-`+yi[t&255]+yi[t>>8&255]+`-`+yi[t>>16&15|64]+yi[t>>24&255]+`-`+yi[n&63|128]+yi[n>>8&255]+`-`+yi[n>>16&255]+yi[n>>24&255]+yi[r&255]+yi[r>>8&255]+yi[r>>16&255]+yi[r>>24&255]).toLowerCase()}function E(e,t,n){return Math.max(t,Math.min(n,e))}function D(e,t){return(e%t+t)%t}function O(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function k(e,t,n){return e===t?0:(n-e)/(t-e)}function A(e,t,n){return(1-n)*e+n*t}function j(e,t,n,r){return A(e,t,1-Math.exp(-n*r))}function M(e,t=1){return t-Math.abs(D(e,t*2)-t)}function N(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function P(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function F(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ee(e,t){return e+Math.random()*(t-e)}function te(e){return e*(.5-Math.random())}function ne(e){e!==void 0&&(bi=e);let t=bi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function re(e){return e*xi}function ie(e){return e*Si}function ae(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function I(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function oe(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function se(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:x(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function ce(e){switch(e.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function le(e,t){if(t.constructor===Float32Array)return e;let n=ce(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.max(e/n,-1)}function ue(e,t){if(t.constructor===Float32Array)return e;let n=ce(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.round(e*n)}function de(){let e={enabled:!0,workingColorSpace:Vr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=fe(e.r),e.g=fe(e.g),e.b=fe(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=pe(e.r),e.g=pe(e.g),e.b=pe(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Hr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[n].fromXYZ).multiply(this.spaces[t].toXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Vr]:{primaries:t,whitePoint:r,transfer:Hr,toXYZ:ki,fromXYZ:Ai,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Br},outputColorSpaceConfig:{drawingBufferColorSpace:Br}},[Br]:{primaries:t,whitePoint:r,transfer:Ur,toXYZ:ki,fromXYZ:Ai,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Br}}}),e}function fe(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function pe(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}function me(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Ni.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(x(`Texture: Unable to serialize Texture.`),{})}function he(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}function ge(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){ro.fromArray(e,a);let o=i.x*Math.abs(ro.x)+i.y*Math.abs(ro.y)+i.z*Math.abs(ro.z),s=t.dot(ro),c=n.dot(ro),l=r.dot(ro);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}function _e(){let e=/* @__PURE__ */ new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=/* @__PURE__ */ new Uint32Array(512),i=/* @__PURE__ */ new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=/* @__PURE__ */ new Uint32Array(2048),o=/* @__PURE__ */ new Uint32Array(64),s=/* @__PURE__ */ new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function ve(e){Math.abs(e)>65504&&x(`DataUtils.toHalfFloat(): Value out of range.`),e=E(e,-65504,65504),io.floatView[0]=e;let t=io.uint32View[0],n=t>>23&511;return io.baseTable[n]+((t&8388607)>>io.shiftTable[n])}function ye(e){let t=e>>10;return io.uint32View[0]=io.mantissaTable[io.offsetTable[t]+(e&1023)]+io.exponentTable[t],io.floatView[0]}function be(e){return e.buffer._uuid===void 0&&(e.buffer._uuid=T()),e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer._uuid:e.buffer._uuid+`:`+e.byteOffset+`:`+e.byteLength}function xe(e,t,n,r,i,a){Uo.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?Wo.copy(Uo):(Wo.x=a*Uo.x-i*Uo.y,Wo.y=i*Uo.x+a*Uo.y),e.copy(t),e.x+=Wo.x,e.y+=Wo.y,e.applyMatrix4(Go)}function Se(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;vs.copy(s),vs.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(vs);return l<n.near||l>n.far?null:{distance:l,point:vs.clone(),object:e}}function Ce(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,fs),e.getVertexPosition(c,ps),e.getVertexPosition(l,ms);let u=Se(e,t,n,r,fs,ps,ms,_s);if(u){let e=new B;Ua.getBarycoord(_s,fs,ps,ms,e),i&&(u.uv=Ua.getInterpolatedAttribute(i,s,c,l,e,new z)),a&&(u.uv1=Ua.getInterpolatedAttribute(a,s,c,l,e,new z)),o&&(u.normal=Ua.getInterpolatedAttribute(o,s,c,l,e,new B),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new B,materialIndex:0};Ua.getNormal(fs,ps,ms,t.normal),u.face=t,u.barycoord=e}return u}function we(e,t){return e-t}function Te(e,t){return e.z-t.z}function Ee(e,t){return t.z-e.z}function L(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a<i;a++)for(let i=0;i<r;i++)t.setComponent(a+n,i,e.getComponent(a,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}function De(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)t[r]=e[r]}else{let n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}function Oe(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(dc.fromBufferAttribute(s,i),fc.fromBufferAttribute(s,a),n.distanceSqToSegment(dc,fc,gc,_c)>r)return;gc.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(gc);if(!(c<t.near||c>t.far))return{distance:c,point:_c.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}function ke(e,t,n,r,i,a,o){let s=Tc.distanceSqToPoint(e);if(s<n){let n=new B;Tc.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}function R(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}function Ae(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function je(e,t){let n=1-e;return n*n*t}function Me(e,t){return 2*(1-e)*e*t}function Ne(e,t){return e*e*t}function Pe(e,t,n,r){return je(e,t)+Me(e,n)+Ne(e,r)}function Fe(e,t){let n=1-e;return n*n*n*t}function Ie(e,t){let n=1-e;return 3*n*n*e*t}function Le(e,t){return 3*(1-e)*e*e*t}function Re(e,t){return e*e*e*t}function ze(e,t,n,r,i){return Fe(e,t)+Ie(e,n)+Le(e,r)+Re(e,i)}function Be(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=Ve(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=Je(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Ue(a,o,n,s,c,l,0),o}function Ve(e,t,n,r,i){let a;if(i===vt(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=ht(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=ht(i/r|0,e[i],e[i+1],a);return a&&st(a,a.next)&&(gt(a),a=a.next),a}function He(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(st(n,n.next)||ot(n.prev,n,n.next)===0)){if(gt(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function Ue(e,t,n,r,i,a,o){if(!e)return;!o&&a&&$e(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Ge(e,r,i,a):We(e))t.push(c.i,e.i,l.i),gt(e),e=l.next,s=l.next;else if(e=l,e===s){o?o===1?(e=Ke(He(e),t),Ue(e,t,n,r,i,a,2)):o===2&&qe(e,t,n,r,i,a):Ue(He(e),t,n,r,i,a,1);break}}}function We(e){let t=e.prev,n=e,r=e.next;if(ot(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&it(i,s,a,c,o,l,m.x,m.y)&&ot(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ge(e,t,n,r){let i=e.prev,a=e,o=e.next;if(ot(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=tt(p,m,t,n,r),v=tt(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&it(s,u,c,d,l,f,y.x,y.y)&&ot(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&it(s,u,c,d,l,f,b.x,b.y)&&ot(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&it(s,u,c,d,l,f,y.x,y.y)&&ot(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&it(s,u,c,d,l,f,b.x,b.y)&&ot(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Ke(e,t){let n=e;do{let r=n.prev,i=n.next.next;!st(r,i)&&ct(r,n,n.next,i)&&ft(r,i)&&ft(i,r)&&(t.push(r.i,n.i,i.i),gt(n),gt(n.next),n=e=i),n=n.next}while(n!==e);return He(n)}function qe(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&at(o,e)){let s=mt(o,e);o=He(o,o.next),s=He(s,s.next),Ue(o,t,n,r,i,a,0),Ue(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Je(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=Ve(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(nt(o))}i.sort(Ye);for(let e=0;e<i.length;e++)n=Xe(i[e],n);return n}function Ye(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function Xe(e,t){let n=Ze(e,t);if(!n)return t;let r=mt(n,e);return He(r,r.next),He(n,n.next)}function Ze(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(st(e,n))return n;do{if(st(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&rt(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);ft(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Qe(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Qe(e,t){return ot(e.prev,e,t.prev)<0&&ot(t.next,e,e.next)<0}function $e(e,t,n,r){let i=e;do i.z===0&&(i.z=tt(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,et(i)}function et(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function tt(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function nt(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function rt(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function it(e,t,n,r,i,a,o,s){return(e!==o||t!==s)&&rt(e,t,n,r,i,a,o,s)}function at(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!dt(e,t)&&(ft(e,t)&&ft(t,e)&&pt(e,t)&&(ot(e.prev,e,t.prev)||ot(e,t.prev,t))||st(e,t)&&ot(e.prev,e,e.next)>0&&ot(t.prev,t,t.next)>0)}function ot(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function st(e,t){return e.x===t.x&&e.y===t.y}function ct(e,t,n,r){let i=ut(ot(e,t,n)),a=ut(ot(e,t,r)),o=ut(ot(n,r,e)),s=ut(ot(n,r,t));return!!(i!==a&&o!==s||i===0&<(e,n,t)||a===0&<(e,r,t)||o===0&<(n,e,r)||s===0&<(n,t,r))}function lt(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ut(e){return e>0?1:e<0?-1:0}function dt(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ct(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ft(e,t){return ot(e.prev,e,e.next)<0?ot(e,t,e.next)>=0&&ot(e,e.prev,t)>=0:ot(e,t,e.prev)<0||ot(e,e.next,t)<0}function pt(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function mt(e,t){let n=_t(e.i,e.x,e.y),r=_t(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function ht(e,t,n,r){let i=_t(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function gt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function _t(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function vt(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function yt(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function bt(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}function xt(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function St(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}function Ct(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}function wt(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(Et(i))i.isRenderTargetTexture?(x(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(Et(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function Tt(e){let t={};for(let n=0;n<e.length;n++){let r=wt(e[n]);for(let e in r)t[e]=r[e]}return t}function Et(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Dt(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Ot(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ji.workingColorSpace}function kt(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function At(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function jt(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function Mt(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Nt(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}function Pt(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=kt(c,t.times.constructor),t.values=kt(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a}function Ft(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant();e.evaluate(a),f=e.resultBuffer.slice()}i===`quaternion`&&new wi().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)wi.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=Fr,e}function It(e,t,n,r,i){let a=1-e;return a*a*a*t+3*a*a*e*n+3*a*e*e*r+e*e*e*i}function Lt(e,t,n,r,i){let a=1-e;return 3*a*a*(n-t)+6*a*e*(r-n)+3*e*e*(i-r)}function Rt(e,t,n,r,i){let a=(e-t)/(i-t);for(let o=0;o<8;o++){let o=It(a,t,n,r,i)-e;if(Math.abs(o)<1e-10)break;let s=Lt(a,t,n,r,i);if(Math.abs(s)<1e-10)break;a=Math.max(0,Math.min(1,a-o/s))}return a}function zt(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]+=t}function Bt(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}function Vt(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return su;case`vector`:case`vector2`:case`vector3`:case`vector4`:return du;case`color`:return ou;case`quaternion`:return lu;case`bool`:case`boolean`:return au;case`string`:return uu}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function Ht(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=Vt(e.type);if(e.times===void 0){let t=[],n=[];Nt(e.keys,t,n,`value`),e.times=t,e.values=n}let n;return n=t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e),At(e.settings)&&(n.settings={inTangents:kt(e.settings.inTangents,Float32Array),outTangents:kt(e.settings.outTangents,Float32Array)}),n}function Ut(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}function Wt(){this._document.hidden===!1&&this.reset()}function Gt(e,t){return e.distance-t.distance}function Kt(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Kt(r[e],t,n,!0)}}function qt(e){let t=[];e.isBone===!0&&t.push(e);for(let n=0;n<e.children.length;n++)t.push(...qt(e.children[n]));return t}function Jt(e,t,n,r,i,a,o){Rf.set(i,a,o).unproject(r);let s=t[e];if(s!==void 0){let e=n.getAttribute(`position`);for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],Rf.x,Rf.y,Rf.z)}}function Yt(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Xt(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function Zt(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function Qt(e,t,n,r){let i=$t(r);switch(n){case jn:return e*t;case In:return e*t/i.components*i.byteLength;case Ln:return e*t/i.components*i.byteLength;case Rn:return e*t*2/i.components*i.byteLength;case zn:return e*t*2/i.components*i.byteLength;case Mn:return e*t*3/i.components*i.byteLength;case Nn:return e*t*4/i.components*i.byteLength;case Vn:return e*t*4/i.components*i.byteLength;case Hn:case Un:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Wn:case Gn:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case qn:case Yn:return Math.max(e,16)*Math.max(t,8)/4;case Kn:case Jn:return Math.max(e,8)*Math.max(t,8)/2;case Xn:case Zn:case $n:case er:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Qn:case tr:case nr:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case rr:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case ir:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case ar:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case or:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case sr:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case cr:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case lr:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case ur:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case dr:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case fr:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case pr:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case mr:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case hr:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case gr:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case _r:case vr:case yr:return Math.ceil(e/4)*Math.ceil(t/4)*16;case br:case xr:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Sr:case Cr:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function $t(e){switch(e){case vn:case yn:return{byteLength:1,components:1};case xn:case bn:case Tn:return{byteLength:2,components:1};case En:case Dn:return{byteLength:2,components:4};case Cn:case Sn:case wn:return{byteLength:4,components:1};case kn:case An:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii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491,rr=37808,ir=37809,ar=37810,or=37811,sr=37812,cr=37813,lr=37814,ur=37815,dr=37816,fr=37817,pr=37818,mr=37819,hr=37820,gr=37821,_r=36492,vr=36494,yr=36495,br=36283,xr=36284,Sr=36285,Cr=36286,wr=2200,Tr=2201,Er=2202,Dr=2300,Or=2301,kr=2302,Ar=2303,jr=2400,Mr=2401,Nr=2402,Pr=2500,Fr=2501,Ir=3200,Lr=3201,Rr=3202,zr=3203,Br=`srgb`,Vr=`srgb-linear`,Hr=`linear`,Ur=`srgb`,Wr=7680,Gr=7681,Kr=7682,qr=7683,Jr=34055,Yr=34056,Xr=5386,Zr=35044,Qr=35048,$r=35040,ei=35045,ti=35049,ni=35041,ri=35046,ii=35050,ai=35042,oi=`300 es`,si=2e3,ci=2001,li={COMPUTE:`compute`,RENDER:`render`},ui={PERSPECTIVE:`perspective`,LINEAR:`linear`,FLAT:`flat`},di={NORMAL:`normal`,CENTROID:`centroid`,SAMPLE:`sample`,FIRST:`first`,EITHER:`either`},fi={TEXTURE_COMPARE:`depthTextureCompare`},pi={NONE:0,SHARED:1,FULL:2},mi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array},hi={},gi=null,_i={0:0,2:6,4:4,3:5,1:1,6:2,7:7,5:3},vi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},yi=/* @__PURE__ */ `00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),bi=1234567,xi=Math.PI/180,Si=180/Math.PI,Ci={DEG2RAD:xi,RAD2DEG:Si,generateUUID:T,clamp:E,euclideanModulo:D,mapLinear:O,inverseLerp:k,lerp:A,damp:j,pingpong:M,smoothstep:N,smootherstep:P,randInt:F,randFloat:ee,randFloatSpread:te,seededRandom:ne,degToRad:re,radToDeg:ie,isPowerOfTwo:ae,ceilPowerOfTwo:I,floorPowerOfTwo:oe,setQuaternionFromProperEuler:se,normalize:ue,denormalize:le},z=class{static{this.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(E(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},wi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:x(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(E(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},B=class{static{this.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ei.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ei.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this.z=E(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this.z=E(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ti.copy(this).projectOnVector(e),this.sub(Ti)}reflect(e){return this.sub(Ti.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(E(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ti=/*@__PURE__*/ new B,Ei=/*@__PURE__*/ new wi,Di=class{static{this.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return C(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Oi.makeScale(e,t)),this}rotate(e){return C(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Oi.makeRotation(-e)),this}translate(e,t){return C(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Oi.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Oi=/*@__PURE__*/ new Di,ki=/*@__PURE__*/ new Di().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ai=/*@__PURE__*/ new Di().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),ji=/*@__PURE__*/ de(),Ni=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Mi===void 0&&(Mi=h(`canvas`)),Mi.width=e.width,Mi.height=e.height;let t=Mi.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Mi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=h(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=fe(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(fe(t[e]/255)*255):t[e]=fe(t[e]);return{data:t,width:e.width,height:e.height}}return x(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Pi=0,Fi=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Pi++}),this.uuid=T(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width||0,t.height||0,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(me(r[t].image)):e.push(me(r[t]))}else e=me(r);n.url=e}return t||(e.images[this.uuid]=n),n}},Ii=class extends Fi{constructor(e=null){C(`Source: "Source" has been renamed to "TextureSource". Please update your code to use "THREE.TextureSource" instead.`),super(e),this.isSource=!0}},Li=0,Ri=/*@__PURE__*/ new B,zi=class e extends vi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=on,i=on,a=pn,o=gn,s=Nn,c=vn,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Li++}),this.uuid=T(),this.name=``,this.source=new Fi(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new z(0,0),this.repeat=new z(1,1),this.center=new z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Di,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Ri).x}get height(){return this.source.getSize(Ri).y}get depth(){return this.source.getSize(Ri).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.mipmapsAutoUpdate=e.mipmapsAutoUpdate,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){x(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?x(`Texture.setValues(): property '${t}' does not exist.`):r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,mipmapsAutoUpdate:this.mipmapsAutoUpdate,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case an:e.x-=Math.floor(e.x);break;case on:e.x=e.x<0?0:1;break;case sn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case an:e.y-=Math.floor(e.y);break;case on:e.y=e.y<0?0:1;break;case sn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}},zi.DEFAULT_IMAGE=null,zi.DEFAULT_MAPPING=300,zi.DEFAULT_ANISOTROPY=1,Bi=class{static{this.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this.z=E(this.z,e.z,t.z),this.w=E(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this.z=E(this.z,e,t),this.w=E(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Vi=class extends vi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:pn,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Bi(0,0,e,t),this.scissorTest=!1,this.viewport=new Bi(0,0,e,t),this.textures=[];let r=n.count;for(let i=0;i<r;i++)this.textures[i]=new zi({width:e,height:t,depth:n.depth}),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:pn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Fi(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Hi=class extends Vi{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ui=class extends zi{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=cn,this.minFilter=cn,this.wrapR=on,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=/* @__PURE__ */ new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Wi=class extends Hi{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ui(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},Gi=class extends zi{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=cn,this.minFilter=cn,this.wrapR=on,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},Ki=class extends Hi{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Gi(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},V=class e{static{this.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/qi.setFromMatrixColumn(e,0).length(),i=1/qi.setFromMatrixColumn(e,1).length(),a=1/qi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Yi,e,Xi)}lookAt(e,t,n){let r=this.elements;return $i.subVectors(e,t),$i.lengthSq()===0&&($i.z=1),$i.normalize(),Zi.crossVectors(n,$i),Zi.lengthSq()===0&&(Math.abs(n.z)===1?$i.x+=1e-4:$i.z+=1e-4,$i.normalize(),Zi.crossVectors(n,$i)),Zi.normalize(),Qi.crossVectors($i,Zi),r[0]=Zi.x,r[4]=Qi.x,r[8]=$i.x,r[1]=Zi.y,r[5]=Qi.y,r[9]=$i.y,r[2]=Zi.z,r[6]=Qi.z,r[10]=$i.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],ee=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*ee,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*ee,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*ee,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*ee,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=qi.set(r[0],r[1],r[2]).length(),o=qi.set(r[4],r[5],r[6]).length(),s=qi.set(r[8],r[9],r[10]).length();i<0&&(a=-a),Ji.copy(this);let c=1/a,l=1/o,u=1/s;return Ji.elements[0]*=c,Ji.elements[1]*=c,Ji.elements[2]*=c,Ji.elements[4]*=l,Ji.elements[5]*=l,Ji.elements[6]*=l,Ji.elements[8]*=u,Ji.elements[9]*=u,Ji.elements[10]*=u,t.setFromRotationMatrix(Ji),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=si,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=si,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},qi=/*@__PURE__*/ new B,Ji=/*@__PURE__*/ new V,Yi=/*@__PURE__*/ new B(0,0,0),Xi=/*@__PURE__*/ new B(1,1,1),Zi=/*@__PURE__*/ new B,Qi=/*@__PURE__*/ new B,$i=/*@__PURE__*/ new B,ea=/*@__PURE__*/ new V,ta=/*@__PURE__*/ new wi,na=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(E(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-E(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(E(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-E(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(E(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-E(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:x(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ea.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ea,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ta.setFromEuler(this),this.setFromQuaternion(ta,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}},na.DEFAULT_ORDER=`XYZ`,ra=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&1<<e)}},ia=0,aa=/*@__PURE__*/ new B,oa=/*@__PURE__*/ new wi,sa=/*@__PURE__*/ new V,ca=/*@__PURE__*/ new B,la=/*@__PURE__*/ new B,ua=/*@__PURE__*/ new B,da=/*@__PURE__*/ new wi,fa=/*@__PURE__*/ new B(1,0,0),pa=/*@__PURE__*/ new B(0,1,0),ma=/*@__PURE__*/ new B(0,0,1),ha={type:`added`},ga={type:`removed`},_a={type:`childadded`,child:null},va={type:`childremoved`,child:null},ya=class e extends vi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ia++}),this.uuid=T(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new B,n=new na,r=new wi,i=new B(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new V},normalMatrix:{value:new Di}}),this.matrix=new V,this.matrixWorld=new V,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ra,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return oa.setFromAxisAngle(e,t),this.quaternion.multiply(oa),this}rotateOnWorldAxis(e,t){return oa.setFromAxisAngle(e,t),this.quaternion.premultiply(oa),this}rotateX(e){return this.rotateOnAxis(fa,e)}rotateY(e){return this.rotateOnAxis(pa,e)}rotateZ(e){return this.rotateOnAxis(ma,e)}translateOnAxis(e,t){return aa.copy(e).applyQuaternion(this.quaternion),this.position.add(aa.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(fa,e)}translateY(e){return this.translateOnAxis(pa,e)}translateZ(e){return this.translateOnAxis(ma,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(sa.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ca.copy(e):ca.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),la.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?sa.lookAt(la,ca,this.up):sa.lookAt(ca,la,this.up),this.quaternion.setFromRotationMatrix(sa),r&&(sa.extractRotation(r.matrixWorld),oa.setFromRotationMatrix(sa),this.quaternion.premultiply(oa.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(S(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ha),_a.child=e,this.dispatchEvent(_a),_a.child=null):S(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ga),va.child=e,this.dispatchEvent(va),va.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),sa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),sa.multiply(e.parent.matrixWorld)),e.applyMatrix4(sa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ha),_a.child=e,this.dispatchEvent(_a),_a.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(la,e,ua),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(la,da,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}},ya.DEFAULT_UP=/*@__PURE__*/ new B(0,1,0),ya.DEFAULT_MATRIX_AUTO_UPDATE=!0,ya.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0,ba=class extends ya{constructor(){super(),this.isGroup=!0,this.type=`Group`}},xa={type:`move`},Sa=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ba,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ba,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ba,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xa)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ba;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ca={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wa={h:0,s:0,l:0},Ta={h:0,s:0,l:0},H=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Br){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ji.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ji.workingColorSpace){return this.r=e,this.g=t,this.b=n,ji.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ji.workingColorSpace){if(e=D(e,1),t=E(t,0,1),n=E(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=he(i,r,e+1/3),this.g=he(i,r,e),this.b=he(i,r,e-1/3)}return ji.colorSpaceToWorking(this,r),this}setStyle(e,t=Br){function n(t){t!==void 0&&parseFloat(t)<1&&x(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseFloat(i[1]))/100,Math.min(100,parseFloat(i[2]))/100,Math.min(100,parseFloat(i[3]))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:x(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);x(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Br){let n=Ca[e.toLowerCase()];return n===void 0?x(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fe(e.r),this.g=fe(e.g),this.b=fe(e.b),this}copyLinearToSRGB(e){return this.r=pe(e.r),this.g=pe(e.g),this.b=pe(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Br){return ji.workingToColorSpace(Ea.copy(this),e),Math.round(E(Ea.r*255,0,255))*65536+Math.round(E(Ea.g*255,0,255))*256+Math.round(E(Ea.b*255,0,255))}getHexString(e=Br){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ji.workingColorSpace){ji.workingToColorSpace(Ea.copy(this),t);let n=Ea.r,r=Ea.g,i=Ea.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=ji.workingColorSpace){return ji.workingToColorSpace(Ea.copy(this),t),e.r=Ea.r,e.g=Ea.g,e.b=Ea.b,e}getStyle(e=Br){ji.workingToColorSpace(Ea.copy(this),e);let t=Ea.r,n=Ea.g,r=Ea.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(wa),this.setHSL(wa.h+e,wa.s+t,wa.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(wa),e.getHSL(Ta);let n=A(wa.h,Ta.h,t),r=A(wa.s,Ta.s,t),i=A(wa.l,Ta.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ea=/*@__PURE__*/ new H,H.NAMES=Ca,Da=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new H(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Oa=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new H(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ka=class extends ya{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new na,this.environmentIntensity=1,this.environmentRotation=new na,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background===null?null:e.background.clone(),this.environment=e.environment===null?null:e.environment.clone(),this.fog=e.fog===null?null:e.fog.clone(),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial===null?null:e.overrideMaterial.clone(),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Aa=/*@__PURE__*/ new B,ja=/*@__PURE__*/ new B,Ma=/*@__PURE__*/ new B,Na=/*@__PURE__*/ new B,Pa=/*@__PURE__*/ new B,Fa=/*@__PURE__*/ new B,Ia=/*@__PURE__*/ new B,La=/*@__PURE__*/ new B,Ra=/*@__PURE__*/ new B,za=/*@__PURE__*/ new B,Ba=/*@__PURE__*/ new Bi,Va=/*@__PURE__*/ new Bi,Ha=/*@__PURE__*/ new Bi,Ua=class e{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Aa.subVectors(e,t),r.cross(Aa);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Aa.subVectors(r,t),ja.subVectors(n,t),Ma.subVectors(e,t);let a=Aa.dot(Aa),o=Aa.dot(ja),s=Aa.dot(Ma),c=ja.dot(ja),l=ja.dot(Ma),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Na)!==null&&Na.x>=0&&Na.y>=0&&Na.x+Na.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Na)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Na.x),s.addScaledVector(a,Na.y),s.addScaledVector(o,Na.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Ba.setScalar(0),Va.setScalar(0),Ha.setScalar(0),Ba.fromBufferAttribute(e,t),Va.fromBufferAttribute(e,n),Ha.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Ba,i.x),a.addScaledVector(Va,i.y),a.addScaledVector(Ha,i.z),a}static isFrontFacing(e,t,n,r){return Aa.subVectors(n,t),ja.subVectors(e,t),Aa.cross(ja).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Aa.subVectors(this.c,this.b),ja.subVectors(this.a,this.b),Aa.cross(ja).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Pa.subVectors(r,n),Fa.subVectors(i,n),La.subVectors(e,n);let s=Pa.dot(La),c=Fa.dot(La);if(s<=0&&c<=0)return t.copy(n);Ra.subVectors(e,r);let l=Pa.dot(Ra),u=Fa.dot(Ra);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0&&s-l>0)return a=s/(s-l),t.copy(n).addScaledVector(Pa,a);za.subVectors(e,i);let f=Pa.dot(za),p=Fa.dot(za);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Fa,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ia.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ia,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Pa,a).addScaledVector(Fa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Wa=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ka.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ka.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Ka.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Ka):Ka.fromBufferAttribute(r,t),Ka.applyMatrix4(e.matrixWorld),this.expandByPoint(Ka);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),qa.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),qa.copy(e.boundingBox)),qa.applyMatrix4(e.matrixWorld),this.union(qa)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ka),Ka.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eo),to.subVectors(this.max,eo),Ja.subVectors(e.a,eo),Ya.subVectors(e.b,eo),Xa.subVectors(e.c,eo),Za.subVectors(Ya,Ja),Qa.subVectors(Xa,Ya),$a.subVectors(Ja,Xa);let t=[0,-Za.z,Za.y,0,-Qa.z,Qa.y,0,-$a.z,$a.y,Za.z,0,-Za.x,Qa.z,0,-Qa.x,$a.z,0,-$a.x,-Za.y,Za.x,0,-Qa.y,Qa.x,0,-$a.y,$a.x,0];return!ge(t,Ja,Ya,Xa,to)||(t=[1,0,0,0,1,0,0,0,1],!ge(t,Ja,Ya,Xa,to))?!1:(no.crossVectors(Za,Qa),t=[no.x,no.y,no.z],ge(t,Ja,Ya,Xa,to))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ka).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ka).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ga=[/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B],Ka=/*@__PURE__*/ new B,qa=/*@__PURE__*/ new Wa,Ja=/*@__PURE__*/ new B,Ya=/*@__PURE__*/ new B,Xa=/*@__PURE__*/ new B,Za=/*@__PURE__*/ new B,Qa=/*@__PURE__*/ new B,$a=/*@__PURE__*/ new B,eo=/*@__PURE__*/ new B,to=/*@__PURE__*/ new B,no=/*@__PURE__*/ new B,ro=/*@__PURE__*/ new B,io=/*@__PURE__*/ _e(),U=class{static toHalfFloat(e){return ve(e)}static fromHalfFloat(e){return ye(e)}},ao=/*@__PURE__*/ new B,oo=/*@__PURE__*/ new z,so=0,co=class extends vi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:so++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Zr,this.updateRanges=[],this.gpuType=wn,this.version=0,this._normalizationScale=e===void 0?void 0:ce(e)}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)oo.fromBufferAttribute(this,t),oo.applyMatrix3(e),this.setXY(t,oo.x,oo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyMatrix3(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyMatrix4(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyNormalMatrix(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.transformDirection(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}_denormalize(e){let t=this._normalizationScale;return t===void 0?le(e,this.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?ue(e,this.array):Math.round(e*t)}},lo=class extends co{constructor(e,t,n){super(new Int8Array(e),t,n)}},uo=class extends co{constructor(e,t,n){super(new Uint8Array(e),t,n)}},fo=class extends co{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},po=class extends co{constructor(e,t,n){super(new Int16Array(e),t,n)}},mo=class extends co{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ho=class extends co{constructor(e,t,n){super(new Int32Array(e),t,n)}},go=class extends co{constructor(e,t,n){super(new Uint32Array(e),t,n)}},_o=class extends co{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=ye(this.array[e*this.itemSize]);return this.normalized&&(t=le(t,this.array)),t}setX(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize]=ve(t),this}getY(e){let t=ye(this.array[e*this.itemSize+1]);return this.normalized&&(t=le(t,this.array)),t}setY(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+1]=ve(t),this}getZ(e){let t=ye(this.array[e*this.itemSize+2]);return this.normalized&&(t=le(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+2]=ve(t),this}getW(e){let t=ye(this.array[e*this.itemSize+3]);return this.normalized&&(t=le(t,this.array)),t}setW(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+3]=ve(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array),r=ue(r,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this.array[e+2]=ve(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array),r=ue(r,this.array),i=ue(i,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this.array[e+2]=ve(r),this.array[e+3]=ve(i),this}},W=class extends co{constructor(e,t,n){super(new Float32Array(e),t,n)}},vo=/*@__PURE__*/ new Wa,yo=/*@__PURE__*/ new B,bo=/*@__PURE__*/ new B,xo=class{constructor(e=new B,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?vo.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yo.subVectors(e,this.center);let t=yo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(yo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(bo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yo.copy(e.center).add(bo)),this.expandByPoint(yo.copy(e.center).sub(bo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},So=0,Co=/*@__PURE__*/ new V,wo=/*@__PURE__*/ new ya,To=/*@__PURE__*/ new B,Eo=/*@__PURE__*/ new Wa,Do=/*@__PURE__*/ new Wa,Oo=/*@__PURE__*/ new B,G=class e extends vi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:So++}),this.uuid=T(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(f(e)?go:mo)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Di().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Co.makeRotationFromQuaternion(e),this.applyMatrix4(Co),this}rotateX(e){return Co.makeRotationX(e),this.applyMatrix4(Co),this}rotateY(e){return Co.makeRotationY(e),this.applyMatrix4(Co),this}rotateZ(e){return Co.makeRotationZ(e),this.applyMatrix4(Co),this}translate(e,t,n){return Co.makeTranslation(e,t,n),this.applyMatrix4(Co),this}scale(e,t,n){return Co.makeScale(e,t,n),this.applyMatrix4(Co),this}lookAt(e){return wo.lookAt(e),wo.updateMatrix(),this.applyMatrix4(wo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(To).negate(),this.translate(To.x,To.y,To.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new W(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&x(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)S(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Eo.setFromBufferAttribute(n),this.morphTargetsRelative?(Oo.addVectors(this.boundingBox.min,Eo.min),this.boundingBox.expandByPoint(Oo),Oo.addVectors(this.boundingBox.max,Eo.max),this.boundingBox.expandByPoint(Oo)):(this.boundingBox.expandByPoint(Eo.min),this.boundingBox.expandByPoint(Eo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&S(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xo);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)S(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new B,1/0);else if(e){let n=this.boundingSphere.center;if(Eo.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Do.setFromBufferAttribute(n),this.morphTargetsRelative?(Oo.addVectors(Eo.min,Do.min),Eo.expandByPoint(Oo),Oo.addVectors(Eo.max,Do.max),Eo.expandByPoint(Oo)):(Eo.expandByPoint(Do.min),Eo.expandByPoint(Do.max))}Eo.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Oo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Oo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Oo.fromBufferAttribute(a,t),o&&(To.fromBufferAttribute(e,t),Oo.add(To)),r=Math.max(r,n.distanceToSquared(Oo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&S(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){S(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new co(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[],c=new Uint8Array(n.count);for(let e=0;e<n.count;e++)o[e]=new B,s[e]=new B;let l=new B,u=new B,d=new B,f=new z,p=new z,m=new z,h=new B,g=new B;function _(e,t,r){c[e]=c[t]=c[r]=1,l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),d.fromBufferAttribute(n,r),f.fromBufferAttribute(i,e),p.fromBufferAttribute(i,t),m.fromBufferAttribute(i,r),u.sub(l),d.sub(l),p.sub(f),m.sub(f);let a=1/(p.x*m.y-m.x*p.y);isFinite(a)&&(h.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(a),g.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(a),o[e].add(h),o[t].add(h),o[r].add(h),s[e].add(g),s[t].add(g),s[r].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){let n=v[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let y=new B,b=new B,x=new B,C=new B;function w(e){x.fromBufferAttribute(r,e),C.copy(x);let t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(C,t);let n=b.dot(s[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let e=0,t=n.count;e<t;++e)c[e]&&w(e);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new co(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new B,i=new B,a=new B,o=new B,s=new B,c=new B,l=new B,u=new B;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Oo.fromBufferAttribute(e,t),Oo.normalize(),e.setXYZ(t,Oo.x,Oo.y,Oo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new co(a,r,i)}if(this.index===null)return x(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},ko=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Zr,this.updateRanges=[],this.version=0,this.uuid=T()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=be(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=be(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}},Ao=/*@__PURE__*/ new B,jo=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r,this._normalizationScale=e===void 0?void 0:ce(e.array)}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.applyMatrix4(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.applyNormalMatrix(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.transformDirection(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){y(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new co(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){y(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t===void 0?le(e,this.data.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?ue(e,this.data.array):Math.round(e*t)}},Mo=/*@__PURE__*/ new B,No=/*@__PURE__*/ new B,Po=/*@__PURE__*/ new Di,Fo=class{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Mo.subVectors(n,t).cross(No.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(Mo),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Po.getNormalMatrix(e),r=this.coplanarPoint(Mo).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Io=0,Lo=class extends vi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Io++}),this.uuid=T(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new H(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wr,this.stencilZFail=Wr,this.stencilZPass=Wr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){x(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?x(`Material: '${t}' is not a property of THREE.${this.type}.`):r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new H().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new Fo().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new z().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new z().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Ro=class extends Lo{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new H(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Bo=/*@__PURE__*/ new B,Vo=/*@__PURE__*/ new B,Ho=/*@__PURE__*/ new B,Uo=/*@__PURE__*/ new z,Wo=/*@__PURE__*/ new z,Go=/*@__PURE__*/ new V,Ko=/*@__PURE__*/ new B,qo=/*@__PURE__*/ new B,Jo=/*@__PURE__*/ new B,Yo=/*@__PURE__*/ new z,Xo=/*@__PURE__*/ new z,Zo=/*@__PURE__*/ new z,Qo=class extends ya{constructor(e=new Ro){if(super(),this.isSprite=!0,this.type=`Sprite`,zo===void 0){zo=new G;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new ko(e,5);zo.setIndex([0,1,2,0,2,3]),zo.setAttribute(`position`,new jo(t,3,0,!1)),zo.setAttribute(`uv`,new jo(t,2,3,!1))}this.geometry=zo,this.material=e,this.center=new z(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&S(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Vo.setFromMatrixScale(this.matrixWorld),Go.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ho.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Vo.multiplyScalar(-Ho.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;xe(Ko.set(-.5,-.5,0),Ho,a,Vo,r,i),xe(qo.set(.5,-.5,0),Ho,a,Vo,r,i),xe(Jo.set(.5,.5,0),Ho,a,Vo,r,i),Yo.set(0,0),Xo.set(1,0),Zo.set(1,1);let o=e.ray.intersectTriangle(Ko,qo,Jo,!1,Bo);if(o===null&&(xe(qo.set(-.5,.5,0),Ho,a,Vo,r,i),Xo.set(0,1),o=e.ray.intersectTriangle(Ko,Jo,qo,!1,Bo),o===null))return;let s=e.ray.origin.distanceTo(Bo);s<e.near||s>e.far||t.push({distance:s,point:Bo.clone(),uv:Ua.getInterpolation(Bo,Ko,qo,Jo,Yo,Xo,Zo,new z),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}toJSON(e){let t=super.toJSON(e);return t.object.center=this.center.toArray(),t}},$o=/*@__PURE__*/ new B,es=/*@__PURE__*/ new B,ts=class extends ya{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,i=0;for(;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){$o.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo($o);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){$o.setFromMatrixPosition(e.matrixWorld),es.setFromMatrixPosition(this.matrixWorld);let n=$o.distanceTo(es)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),n>=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);t.object.autoUpdate=this.autoUpdate,t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}},ns=/*@__PURE__*/ new B,rs=/*@__PURE__*/ new B,is=/*@__PURE__*/ new B,as=/*@__PURE__*/ new B,os=class{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ns)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ns.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ns.copy(this.origin).addScaledVector(this.direction,t),ns.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){rs.copy(e).add(t).multiplyScalar(.5),is.copy(t).sub(e).normalize(),as.copy(this.origin).sub(rs);let i=e.distanceTo(t)*.5,a=-this.direction.dot(is),o=as.dot(this.direction),s=-as.dot(is),c=as.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(rs).addScaledVector(is,d),f}intersectSphere(e,t){if(e.radius<0)return null;ns.subVectors(e.center,this.origin);let n=ns.dot(this.direction),r=ns.dot(ns)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ns)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,M,N;if(y>=b&&y>=x?(w=s,D=u,A=p,N=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,M=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,M=_)):b>=x?(w=c,D=d,A=m,N=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,M=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,M=v)):(w=l,D=f,A=h,N=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,M=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,M=g)),w===0)return null;let P=S/w,F=C/w,ee=1/w,te=T-P*D,ne=E-F*D,re=O-P*A,ie=k-F*A,ae=j-P*N,I=M-F*N,oe=ae*ie-I*re,se=te*I-ne*ae,ce=re*ne-ie*te;if(r){if(oe<0||se<0||ce<0)return null}else if((oe<0||se<0||ce<0)&&(oe>0||se>0||ce>0))return null;let le=oe+se+ce;if(le===0)return null;let ue=ee*(oe*D+se*A+ce*N);return(le>0?ue<0:ue>0)?null:this.at(ue/le,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ss=class extends Lo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new H(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new na,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},cs=/*@__PURE__*/ new V,ls=/*@__PURE__*/ new os,us=/*@__PURE__*/ new xo,ds=/*@__PURE__*/ new B,fs=/*@__PURE__*/ new B,ps=/*@__PURE__*/ new B,ms=/*@__PURE__*/ new B,hs=/*@__PURE__*/ new B,gs=/*@__PURE__*/ new B,_s=/*@__PURE__*/ new B,vs=/*@__PURE__*/ new B,K=class extends ya{constructor(e=new G,t=new ss){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){gs.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(hs.fromBufferAttribute(s,e),a?gs.addScaledVector(hs,r):gs.addScaledVector(hs.sub(t),r))}t.add(gs)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),us.copy(n.boundingSphere),us.applyMatrix4(i),ls.copy(e.ray).recast(e.near),us.containsPoint(ls.origin)===!1&&(ls.intersectSphere(us,ds)===null||ls.origin.distanceToSquared(ds)>(e.far-e.near)**2)||(cs.copy(i).invert(),ls.copy(e.ray).applyMatrix4(cs),(n.boundingBox===null||ls.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,ls)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ce(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ce(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ce(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ce(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}},ys=/*@__PURE__*/ new Bi,bs=/*@__PURE__*/ new Bi,xs=/*@__PURE__*/ new Bi,Ss=/*@__PURE__*/ new Bi,Cs=/*@__PURE__*/ new V,ws=/*@__PURE__*/ new B,Ts=/*@__PURE__*/ new xo,Es=/*@__PURE__*/ new V,Ds=/*@__PURE__*/ new os,Os=class extends K{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=nn,this.bindMatrix=new V,this.bindMatrixInverse=new V,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Wa),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,ws),this.boundingBox.expandByPoint(ws)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new xo),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,ws),this.boundingSphere.expandByPoint(ws)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ts.copy(this.boundingSphere),Ts.applyMatrix4(r),e.ray.intersectsSphere(Ts)!==!1&&(Es.copy(r).invert(),Ds.copy(e.ray).applyMatrix4(Es),(this.boundingBox===null||Ds.intersectsBox(this.boundingBox)!==!1)&&this._computeIntersections(e,t,Ds)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Bi,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():x(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;bs.fromBufferAttribute(r.attributes.skinIndex,e),xs.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(ys.copy(t),t.set(0,0,0,0)):(ys.set(t.x,t.y,t.z,1),t.set(0,0,0)),ys.applyMatrix4(this.bindMatrix);for(let e=0;e<4;e++){let r=xs.getComponent(e);if(r!==0){let i=bs.getComponent(e);Cs.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Ss.copy(ys).applyMatrix4(Cs),r)}}return t.isVector4&&(t.w=ys.w),t.applyMatrix4(this.bindMatrixInverse)}},ks=class extends ya{constructor(){super(),this.isBone=!0,this.type=`Bone`}},As=class extends zi{constructor(e=null,t=1,n=1,r,i,a,o,s,c=cn,l=cn,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},js=/*@__PURE__*/ new V,Ms=/*@__PURE__*/ new V,Ns=class e{constructor(e=[],t=[]){this.uuid=T(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.previousBoneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){x(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new V)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new V;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Ms;js.multiplyMatrices(i,t[r]),js.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new As(t,e,e,Nn,wn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null),this.previousBoneTexture!==null&&(this.previousBoneTexture.dispose(),this.previousBoneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(x(`Skeleton: No bone found with UUID:`,r),i=new ks),this.bones.push(i),this.boneInverses.push(new V().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Ps=class extends co{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Fs=/*@__PURE__*/ new V,Is=/*@__PURE__*/ new V,Ls=[],Rs=/*@__PURE__*/ new Wa,zs=/*@__PURE__*/ new V,Bs=/*@__PURE__*/ new K,Vs=/*@__PURE__*/ new xo,Hs=class extends K{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ps(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,zs)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Wa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fs),Rs.copy(e.boundingBox).applyMatrix4(Fs),this.boundingBox.union(Rs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new xo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fs),Vs.copy(e.boundingSphere).applyMatrix4(Fs),this.boundingSphere.union(Vs)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),this.morphTexture=e.morphTexture===null?null:e.morphTexture.clone(),this.instanceColor=e.instanceColor===null?null:e.instanceColor.clone(),this.count=e.count,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(Bs.geometry=this.geometry,Bs.material=this.material,Bs.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Vs.copy(this.boundingSphere),Vs.applyMatrix4(n),e.ray.intersectsSphere(Vs)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Fs),Is.multiplyMatrices(n,Fs),Bs.matrixWorld=Is,Bs.raycast(e,Ls);for(let e=0,n=Ls.length;e<n;e++){let n=Ls[e];n.instanceId=i,n.object=this,t.push(n)}Ls.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Ps(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new As(new Float32Array(r*this.count),r,this.count,In,wn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;return i[s]=o,i.set(n,s+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.instanceMatrix.dispose(),this.instanceColor!==null&&this.instanceColor.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Us=/*@__PURE__*/ new xo,Ws=/*@__PURE__*/ new z(.5,.5),Gs=/*@__PURE__*/ new B,Ks=class{constructor(e=new Fo,t=new Fo,n=new Fo,r=new Fo,i=new Fo,a=new Fo){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=si,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Us.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Us.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Us)}intersectsSprite(e){Us.center.set(0,0,0);let t=Ws.distanceTo(e.center);return Us.radius=.7071067811865476+t,Us.applyMatrix4(e.matrixWorld),this.intersectsSphere(Us)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Gs.x=r.normal.x>0?e.max.x:e.min.x,Gs.y=r.normal.y>0?e.max.y:e.min.y,Gs.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gs)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},qs=/*@__PURE__*/ new V,Js=class e{constructor(){this.coordinateSystem=si,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];qs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new Ks),n[e].setFromProjectionMatrix(qs,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new Ks),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}},Ys=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let i=this.pool,a=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}},Xs=/*@__PURE__*/ new V,Zs=/*@__PURE__*/ new H(1,1,1),Qs=/*@__PURE__*/ new Ks,$s=/*@__PURE__*/ new Js,ec=/*@__PURE__*/ new Wa,tc=/*@__PURE__*/ new xo,nc=/*@__PURE__*/ new B,rc=/*@__PURE__*/ new B,ic=/*@__PURE__*/ new B,ac=/*@__PURE__*/ new B,oc=/*@__PURE__*/ new Ys,sc=/*@__PURE__*/ new K,cc=[],lc=class extends K{constructor(e,t,n=t*2,r){super(new G,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawBytesPerElement=1,this._mergedDrawCounts=new Int32Array(e),this._mergedDrawStarts=new Int32Array(e),this._mergedDrawInstanceCounts=new Int32Array(e),this._mergedDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._previousMatricesTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),n=new As(t,e,e,Nn,wn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Uint32Array(e*e),n=new As(t,e,e,Ln,Cn);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Float32Array(e*e*4).fill(1),n=new As(t,e,e,Nn,wn);n.colorSpace=ji.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in e.attributes){let{array:i,itemSize:a,normalized:o}=e.getAttribute(r),s=new i.constructor(n*a),c=new co(s,a,o);t.setAttribute(r,c)}if(e.getIndex()!==null){let e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new co(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`THREE.BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`THREE.BatchedMesh: Added geometry attribute "${n}" has an inconsistent itemSize or normalized value.`)}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingBoxAt(r,ec).applyMatrix4(Xs),e.union(ec)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xo);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingSphereAt(r,tc).applyMatrix4(Xs),e.union(tc)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`THREE.BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(we),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let r=this._matricesTexture;Xs.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;let i=this._colorsTexture;return i&&(Zs.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute(`position`).count:t;let a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error(`THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(we),o=this._availableGeometryIds.shift(),i[o]=r):(o=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`THREE.BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw Error(`THREE.BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute(`position`).count;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);L(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e<t;e++){let t=s+e;for(let e=0;e<a;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(s*a,c*a)}if(r){let e=o.indexStart,n=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let t=0;t<a.count;t++)i.setX(e+t,s+a.getX(t));for(let t=a.count,r=n;t<r;t++)i.setX(e+t,s);i.needsUpdate=!0,i.addUpdateRange(e,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let t=0,r=n.length;t<r;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,r=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),i=this.geometry;for(let a=0,o=n.length;a<o;a++){let o=n[r[a]];if(o.active!==!1){if(i.index!==null){if(o.indexStart!==t){let{indexStart:n,vertexStart:r,reservedIndexCount:a}=o,s=i.index,c=s.array,l=e-r;for(let e=n;e<n+a;e++)c[e]=c[e]+l;s.array.copyWithin(t,n,n+a),s.addUpdateRange(t,a),s.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){let{vertexStart:t,reservedVertexCount:n}=o,r=i.attributes;for(let i in r){let a=r[i],{array:o,itemSize:s}=a;o.copyWithin(e*s,t*s,(t+n)*s),a.addUpdateRange(e*s,n*s),a.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=i.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let e=new Wa,t=n.index,i=n.attributes.position;for(let n=r.start,a=r.start+r.count;n<a;n++){let r=n;t&&(r=t.getX(r)),e.expandByPoint(nc.fromBufferAttribute(i,r))}r.boundingBox=e}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let t=new xo;this.getBoundingBoxAt(e,ec),ec.getCenter(t.center);let i=n.index,a=n.attributes.position,o=0;for(let e=r.start,n=r.start+r.count;e<n;e++){let n=e;i&&(n=i.getX(n)),nc.fromBufferAttribute(a,n),o=Math.max(o,t.center.distanceToSquared(nc))}t.radius=Math.sqrt(o),r.boundingSphere=t}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(this._instanceInfo[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this._visibilityChanged=!0,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(we);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),i=new Int32Array(e);De(this._multiDrawCounts,r),De(this._multiDrawStarts,i),this._multiDrawCounts=r,this._multiDrawStarts=i;let a=new Int32Array(e),o=new Int32Array(e),s=new Int32Array(e);De(this._mergedDrawCounts,a),De(this._mergedDrawStarts,o),De(this._mergedDrawInstanceCounts,s),this._mergedDrawCounts=a,this._mergedDrawStarts=o,this._mergedDrawInstanceCounts=s,this._maxInstanceCount=e;let c=this._indirectTexture,l=this._matricesTexture,u=this._colorsTexture;c.dispose(),this._initIndirectTexture(),De(c.image.data,this._indirectTexture.image.data),l.dispose(),this._initMatricesTexture(),De(l.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),De(u.image.data,this._colorsTexture.image.data)),this._previousMatricesTexture!==null&&(this._previousMatricesTexture.dispose(),this._previousMatricesTexture=null)}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new G,this._initializeGeometry(r));let i=this.geometry;r.index&&De(r.index.array,i.index.array);for(let e in r.attributes)De(r.attributes[e].array,i.attributes[e].array);this._visibilityChanged=!0}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,i=this.matrixWorld,a=this.geometry;sc.material=this.material,sc.geometry.index=a.index,sc.geometry.attributes=a.attributes,sc.geometry.boundingBox===null&&(sc.geometry.boundingBox=new Wa),sc.geometry.boundingSphere===null&&(sc.geometry.boundingSphere=new xo);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;let o=n[a].geometryIndex,s=r[o];sc.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(a,sc.matrixWorld).premultiply(i),this.getBoundingBoxAt(o,sc.geometry.boundingBox),this.getBoundingSphereAt(o,sc.geometry.boundingSphere),sc.raycast(e,cc);for(let e=0,n=cc.length;e<n;e++){let n=cc[e];n.object=this,n.batchId=a,t.push(n)}cc.length=0}sc.material=null,sc.geometry.index=null,sc.geometry.attributes={},sc.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox===null?null:e.boundingBox.clone(),boundingSphere:e.boundingSphere===null?null:e.boundingSphere.clone()})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._multiDrawBytesPerElement=e._multiDrawBytesPerElement,this._mergedDrawCounts=e._mergedDrawCounts.slice(),this._mergedDrawStarts=e._mergedDrawStarts.slice(),this._mergedDrawInstanceCounts=e._mergedDrawInstanceCounts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),e._colorsTexture===null?this._colorsTexture=null:(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){super.dispose(),this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this._previousMatricesTexture!==null&&(this._previousMatricesTexture.dispose(),this._previousMatricesTexture=null)}_updateDrawParameters(e,t,n,r=`multiDraw`){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let i=t.getIndex(),a=i===null?1:i.array.BYTES_PER_ELEMENT,o=1;n.wireframe&&(o=2,a=t.attributes.position.count>65535?4:2);let s=this._instanceInfo,c=this._multiDrawStarts,l=this._multiDrawCounts,u=this._mergedDrawStarts,d=this._mergedDrawCounts,f=this._mergedDrawInstanceCounts,p=this._geometryInfo,m=this.perObjectFrustumCulled,h=this._indirectTexture,g=h.image.data,_=e.isArrayCamera?$s:Qs;m&&(e.isArrayCamera?_.setFromArrayCamera(e):(Xs.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse).multiply(this.matrixWorld),_.setFromProjectionMatrix(Xs,e.coordinateSystem,e.reversedDepth)));let v=0,y=0;if(this.sortObjects){Xs.copy(this.matrixWorld).invert(),rc.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Xs),ic.set(0,0,-1).transformDirection(e.matrixWorld).transformDirection(Xs);for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex;this.getMatrixAt(e,Xs),this.getBoundingSphereAt(t,tc).applyMatrix4(Xs);let n=!1;if(m&&(n=!_.intersectsSphere(tc)),!n){let n=p[t],r=ac.subVectors(tc.center,rc).dot(ic);oc.push(n.start,n.count,r,e)}}let t=oc.list,i=this.customSort;i===null?t.sort(n.transparent?Ee:Te):i.call(this,t,e);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.start*a*o,s=n.count*o;r===`merged`?y>0&&u[y-1]===i&&d[y-1]===s?f[y-1]++:(u[y]=i,d[y]=s,f[y]=1,y++):(c[v]=i,l[v]=s),g[v]=n.index,v++}oc.reset()}else for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex,n=!1;if(m&&(this.getMatrixAt(e,Xs),this.getBoundingSphereAt(t,tc).applyMatrix4(Xs),n=!_.intersectsSphere(tc)),!n){let n=p[t],i=n.start*a*o,s=n.count*o;r===`merged`?y>0&&u[y-1]===i&&d[y-1]===s?f[y-1]++:(u[y]=i,d[y]=s,f[y]=1,y++):(c[v]=i,l[v]=s),g[v]=e,v++}}h.needsUpdate=!0,this._multiDrawCount=v,this._mergedDrawCount=y,this._multiDrawBytesPerElement=a,this._visibilityChanged=!1}onBeforeRender(e,t,n,r,i){e.isWebGPURenderer===!0?(this._visibilityChanged||this.perObjectFrustumCulled||this.sortObjects)&&(this._indirectTexture.needsUpdate=!0):this._updateDrawParameters(n,r,i)}onBeforeShadow(e,t,n,r,i,a){e.isWebGPURenderer!==!0&&this._updateDrawParameters(r,i,a)}},uc=class extends Lo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new H(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},dc=/*@__PURE__*/ new B,fc=/*@__PURE__*/ new B,pc=/*@__PURE__*/ new V,mc=/*@__PURE__*/ new os,hc=/*@__PURE__*/ new xo,gc=/*@__PURE__*/ new B,_c=/*@__PURE__*/ new B,vc=class extends ya{constructor(e=new G,t=new uc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)dc.fromBufferAttribute(t,e-1),fc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=dc.distanceTo(fc);e.setAttribute(`lineDistance`,new W(n,1))}else x(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hc.copy(n.boundingSphere),hc.applyMatrix4(r),hc.radius+=i,e.ray.intersectsSphere(hc)===!1)return;pc.copy(r).invert(),mc.copy(e.ray).applyMatrix4(pc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=Oe(this,e,mc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=Oe(this,e,mc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=Oe(this,e,mc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=Oe(this,e,mc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},yc=/*@__PURE__*/ new B,bc=/*@__PURE__*/ new B,xc=class extends vc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)yc.fromBufferAttribute(t,e),bc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+yc.distanceTo(bc);e.setAttribute(`lineDistance`,new W(n,1))}else x(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},Sc=class extends vc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},Cc=class extends Lo{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new H(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},wc=/*@__PURE__*/ new V,Tc=/*@__PURE__*/ new os,Ec=/*@__PURE__*/ new xo,Dc=/*@__PURE__*/ new B,Oc=class extends ya{constructor(e=new G,t=new Cc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ec.copy(n.boundingSphere),Ec.applyMatrix4(r),Ec.radius+=i,e.ray.intersectsSphere(Ec)===!1)return;wc.copy(r).invert(),Tc.copy(e.ray).applyMatrix4(wc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Dc.fromBufferAttribute(l,n),ke(Dc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Dc.fromBufferAttribute(l,a),ke(Dc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},kc=class extends zi{constructor(e,t,n,r,i=pn,a=pn,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let l=this;function u(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},Ac=class extends kc{constructor(e,t,n,r,i,a,o,s){super({},e,t,n,r,i,a,o,s),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},jc=class extends zi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=cn,this.minFilter=cn,this.generateMipmaps=!1,this.needsUpdate=!0}copy(e){return super.copy(e),this.source=new Fi(Object.assign({},e.image)),this}},Mc=class extends zi{constructor(e=[],t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Nc=class extends Mc{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=on,this.layerUpdates=/* @__PURE__ */ new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Pc=class extends Mc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Fc=class extends zi{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ic=class extends zi{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Lc=class extends zi{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let l=e?e.parentNode:null;l!==null&&`requestPaint`in l&&(l.onpaint=()=>{this.needsUpdate=!0},l.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&`onpaint`in e&&(e.onpaint=null),super.dispose()}},Rc=class extends zi{constructor(e,t,n=Cn,r,i,a,o=cn,s=cn,c,l=Pn,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Fi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},zc=class extends Rc{constructor(e,t=Cn,n=301,r,i,a=cn,o=cn,s,c=Pn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Bc=class extends zi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Vc=class e extends G{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new W(c,3)),this.setAttribute(`normal`,new W(l,3)),this.setAttribute(`uv`,new W(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new B;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Hc=class e extends G{constructor(e=1,t=1,n=4,r=8,i=1){super(),this.type=`CapsuleGeometry`,this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:i},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),i=Math.max(1,Math.floor(i));let a=[],o=[],s=[],c=[],l=t/2,u=Math.PI/2*e,d=t,f=2*u+d,p=n*2+i,m=r+1,h=new B,g=new B;for(let _=0;_<=p;_++){let v=0,y=0,b=0,x=0;if(_<=n){let t=_/n,r=t*Math.PI/2;y=-l-e*Math.cos(r),b=e*Math.sin(r),x=-e*Math.cos(r),v=t*u}else if(_<=n+i){let r=(_-n)/i;y=-l+r*t,b=e,x=0,v=u+r*d}else{let t=(_-n-i)/n,r=t*Math.PI/2;y=l+e*Math.sin(r),b=e*Math.cos(r),x=e*Math.sin(r),v=u+d+t*u}let S=Math.max(0,Math.min(1,v/f)),C=0;_===0?C=.5/r:_===p&&(C=-.5/r);for(let e=0;e<=r;e++){let t=e/r,n=t*Math.PI*2,i=Math.sin(n),a=Math.cos(n);g.x=-b*a,g.y=y,g.z=b*i,o.push(g.x,g.y,g.z),h.set(-b*a,x,b*i),h.normalize(),s.push(h.x,h.y,h.z),c.push(t+C,S)}if(_>0){let e=(_-1)*m;for(let t=0;t<r;t++){let n=e+t,r=e+t+1,i=_*m+t,o=_*m+t+1;a.push(n,r,i),a.push(r,o,i)}}}this.setIndex(a),this.setAttribute(`position`,new W(o,3)),this.setAttribute(`normal`,new W(s,3)),this.setAttribute(`uv`,new W(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},Uc=class e extends G{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type=`CircleGeometry`,this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let i=[],a=[],o=[],s=[],c=new B,l=new z;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new W(a,3)),this.setAttribute(`normal`,new W(o,3)),this.setAttribute(`uv`,new W(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},Wc=class e extends G{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new W(u,3)),this.setAttribute(`normal`,new W(d,3)),this.setAttribute(`uv`,new W(f,2));function _(){let a=new B,_=new B,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new z,m=new B,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Gc=class e extends Wc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Kc=class e extends G{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];o(r),c(n),l(),this.setAttribute(`position`,new W(i,3)),this.setAttribute(`normal`,new W(i.slice(),3)),this.setAttribute(`uv`,new W(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(e){let n=new B,r=new B,i=new B;for(let a=0;a<t.length;a+=3)f(t[a+0],n),f(t[a+1],r),f(t[a+2],i),s(n,r,i,e)}function s(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)e===0&&r===i?a[r][e]=o:a[r][e]=o.clone().lerp(s,e/c)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){let n=Math.floor(t/2);t%2==0?(d(a[e][n+1]),d(a[e+1][n]),d(a[e][n])):(d(a[e][n+1]),d(a[e+1][n+1]),d(a[e+1][n]))}}function c(e){let t=new B;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}function l(){let e=new B;for(let t=0;t<i.length;t+=3){e.x=i[t+0],e.y=i[t+1],e.z=i[t+2];let n=h(e)/2/Math.PI+.5,r=g(e)/Math.PI+.5;a.push(n,1-r)}p(),u()}function u(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],r=a[e+4];Math.max(t,n,r)>.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new B,t=new B,n=new B,r=new B,o=new z,s=new z,c=new z;for(let l=0,u=0;l<i.length;l+=9,u+=6){e.set(i[l+0],i[l+1],i[l+2]),t.set(i[l+3],i[l+4],i[l+5]),n.set(i[l+6],i[l+7],i[l+8]),o.set(a[u+0],a[u+1]),s.set(a[u+2],a[u+3]),c.set(a[u+4],a[u+5]),r.copy(e).add(t).add(n).divideScalar(3);let d=h(r);m(o,u+0,e,d),m(s,u+2,t,d),m(c,u+4,n,d)}}function m(e,t,n,r){r<0&&e.x===1&&(a[t]=e.x-1),n.x===0&&n.z===0&&(a[t]=r/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}function g(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.detail)}},qc=class e extends Kc{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];super(i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Jc=/*@__PURE__*/ new B,Yc=/*@__PURE__*/ new B,Xc=/*@__PURE__*/ new B,Zc=/*@__PURE__*/ new Ua,Qc=class extends G{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(xi*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u=/* @__PURE__ */ new Map,d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=Zc;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),Zc.getNormal(Xc),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=Zc[c[e]],o=Zc[c[t]],f=`${n}_${i}`,p=`${i}_${n}`,m=u.get(p);m?(Xc.dot(m.normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u.set(p,null)):u.has(f)||u.set(f,{index0:s[e],index1:s[t],normal:Xc.clone()})}}for(let e of u.values())if(e){let{index0:t,index1:n}=e;Jc.fromBufferAttribute(a,t),Yc.fromBufferAttribute(a,n),d.push(Jc.x,Jc.y,Jc.z),d.push(Yc.x,Yc.y,Yc.z)}this.setAttribute(`position`,new W(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},$c=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){x(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new z:new B);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new B,r=[],i=[],a=[],o=new B,s=new V;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new B)}i[0]=new B,a[0]=new B;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(E(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(E(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this.cacheArcLengths=null,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this.cacheArcLengths=null,this}},el=class extends $c{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new z){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},tl=class extends el{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}},nl=/*@__PURE__*/ new B,rl=/*@__PURE__*/ new B,il=/*@__PURE__*/ new R,al=/*@__PURE__*/ new R,ol=/*@__PURE__*/ new R,sl=class extends $c{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new B){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(rl.subVectors(r[0],r[1]).add(r[0]),c=rl);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(nl.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=nl),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),il.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),al.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),ol.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(il.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),al.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),ol.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(il.calc(s),al.calc(s),ol.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new B().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},cl=class extends $c{constructor(e=new z,t=new z,n=new z,r=new z){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new z){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(ze(e,r.x,i.x,a.x,o.x),ze(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ll=class extends $c{constructor(e=new B,t=new B,n=new B,r=new B){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(ze(e,r.x,i.x,a.x,o.x),ze(e,r.y,i.y,a.y,o.y),ze(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ul=class extends $c{constructor(e=new z,t=new z){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new z){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new z){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},dl=class extends $c{constructor(e=new B,t=new B){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new B){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},fl=class extends $c{constructor(e=new z,t=new z,n=new z){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new z){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Pe(e,r.x,i.x,a.x),Pe(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pl=class extends $c{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Pe(e,r.x,i.x,a.x),Pe(e,r.y,i.y,a.y),Pe(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ml=class extends $c{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new z){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Ae(o,s.x,c.x,l.x,u.x),Ae(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new z().fromArray(n))}return this}},hl=/*#__PURE__*/ Object.freeze({__proto__:null,ArcCurve:tl,CatmullRomCurve3:sl,CubicBezierCurve:cl,CubicBezierCurve3:ll,EllipseCurve:el,LineCurve:ul,LineCurve3:dl,QuadraticBezierCurve:fl,QuadraticBezierCurve3:pl,SplineCurve:ml}),gl=class extends $c{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1,this.cacheLengths=null}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new hl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this.cacheLengths=null,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new hl[n.type]().fromJSON(n))}return this.cacheLengths=null,this}},_l=class extends gl{constructor(e){super(),this.type=`Path`,this.currentPoint=new z,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ul(this.currentPoint.clone(),new z(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new fl(this.currentPoint.clone(),new z(e,t),new z(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new cl(this.currentPoint.clone(),new z(e,t),new z(n,r),new z(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new ml(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new el(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},vl=class extends _l{constructor(e){super(e),this.uuid=T(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new _l().fromJSON(n))}return this}},yl=class{static triangulate(e,t,n=2){return Be(e,t,n)}},bl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];yt(e),bt(n,e);let a=e.length;t.forEach(yt);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,bt(n,t[e]);let o=yl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}},xl=class e extends G{constructor(e=new vl([new z(.5,.5),new z(-.5,.5),new z(-.5,-.5),new z(.5,-.5)]),t={}){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new W(r,3)),this.setAttribute(`uv`,new W(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?1:t.depth,l=t.bevelEnabled===void 0||t.bevelEnabled,u=t.bevelThickness===void 0?.2:t.bevelThickness,d=t.bevelSize===void 0?u-.1:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?Sl:t.UVGenerator,g,_=!1,v,y,b,x;if(m){g=m.getSpacedPoints(s),_=!0,l=!1;let e=m.isCatmullRomCurve3?m.closed:!1;v=m.computeFrenetFrames(s,e),y=new B,b=new B,x=new B}l||(p=0,u=0,d=0,f=0);let C=e.extractPoints(o),w=C.shape,T=C.holes;if(!bl.isClockWise(w)){w=w.reverse();for(let e=0,t=T.length;e<t;e++){let t=T[e];bl.isClockWise(t)&&(T[e]=t.reverse())}}function E(e){let t=e[0];for(let n=1;n<=e.length;n++){let r=n%e.length,i=e[r],a=i.x-t.x,o=i.y-t.y,s=a*a+o*o,c=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(t.x),Math.abs(t.y));s<=10000000000000001e-36*c*c?(e.splice(r,1),n--):t=i}}E(w),T.forEach(E);let D=T.length,O=w;for(let e=0;e<D;e++){let t=T[e];w=w.concat(t)}function k(e,t,n){return t||S(`ExtrudeGeometry: vec does not exist`),e.clone().addScaledVector(t,n)}let A=w.length;function j(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new z(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new z(r/a,i/a)}let M=[];for(let e=0,t=O.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),M[e]=j(O[e],O[n],O[r]);let N=[],P,F=M.concat();for(let e=0,t=D;e<t;e++){let t=T[e];P=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),P[e]=j(t[e],t[r],t[i]);N.push(P),F=F.concat(P)}let ee;if(p===0)ee=bl.triangulateShape(O,T);else{let e=[],t=[];for(let n=0;n<p;n++){let r=n/p,i=u*Math.cos(r*Math.PI/2),a=d*Math.sin(r*Math.PI/2)+f;for(let t=0,n=O.length;t<n;t++){let n=k(O[t],M[t],a);I(n.x,n.y,-i),r===0&&e.push(n)}for(let e=0,n=D;e<n;e++){let n=T[e];P=N[e];let o=[];for(let e=0,t=n.length;e<t;e++){let t=k(n[e],P[e],a);I(t.x,t.y,-i),r===0&&o.push(t)}r===0&&t.push(o)}}ee=bl.triangulateShape(e,t)}let te=ee.length,ne=d+f;for(let e=0;e<A;e++){let t=l?k(w[e],F[e],ne):w[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),I(x.x,x.y,x.z)):I(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<A;t++){let n=l?k(w[t],F[t],ne):w[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),I(x.x,x.y,x.z)):I(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=O.length;e<t;e++){let t=k(O[e],M[e],r);I(t.x,t.y,c+n)}for(let e=0,t=T.length;e<t;e++){let t=T[e];P=N[e];for(let e=0,i=t.length;e<i;e++){let i=k(t[e],P[e],r);_?I(i.x,i.y+g[s-1].y,g[s-1].x+n):I(i.x,i.y,c+n)}}}re(),ie();function re(){let e=r.length/3;if(l){let e=0,t=A*e;for(let e=0;e<te;e++){let n=ee[e];oe(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=A*e;for(let e=0;e<te;e++){let n=ee[e];oe(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<te;e++){let t=ee[e];oe(t[2],t[1],t[0])}for(let e=0;e<te;e++){let t=ee[e];oe(t[0]+A*s,t[1]+A*s,t[2]+A*s)}}n.addGroup(e,r.length/3-e,0)}function ie(){let e=r.length/3,t=0;ae(O,t),t+=O.length;for(let e=0,n=T.length;e<n;e++){let n=T[e];ae(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function ae(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=A*e,a=A*(e+1);se(t+r+n,t+i+n,t+i+a,t+r+a)}}}function I(e,t,n){a.push(e),a.push(t),a.push(n)}function oe(e,t,i){ce(e),ce(t),ce(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);le(o[0]),le(o[1]),le(o[2])}function se(e,t,i,a){ce(e),ce(t),ce(a),ce(t),ce(i),ce(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);le(s[0]),le(s[1]),le(s[3]),le(s[1]),le(s[2]),le(s[3])}function ce(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function le(e){i.push(e.x),i.push(e.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return xt(t,n,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new hl[i.type]().fromJSON(i)),new e(r,t.options)}},Sl={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new z(a,o),new z(s,c),new z(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<Math.abs(o-l)?[new z(o,1-c),new z(l,1-d),new z(f,1-m),new z(h,1-_)]:[new z(s,1-c),new z(u,1-d),new z(p,1-m),new z(g,1-_)]}},Cl=class e extends Kc{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];super(r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type=`IcosahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},wl=class e extends G{constructor(e=[new z(0,-.5),new z(.5,0),new z(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type=`LatheGeometry`,this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=E(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new B,d=new z,f=new B,p=new B,m=new B,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:m.normalize(),s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){let r=t+n*e.length,a=r,o=r+e.length,s=r+e.length+1,c=r+1;i.push(a,o,c),i.push(s,c,o)}this.setIndex(i),this.setAttribute(`position`,new W(a,3)),this.setAttribute(`uv`,new W(o,2)),this.setAttribute(`normal`,new W(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.points,t.segments,t.phiStart,t.phiLength)}},Tl=class e extends Kc{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=`OctahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},El=class e extends G{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new W(p,3)),this.setAttribute(`normal`,new W(m,3)),this.setAttribute(`uv`,new W(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},Dl=class e extends G{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new B,p=new z;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new W(s,3)),this.setAttribute(`normal`,new W(c,3)),this.setAttribute(`uv`,new W(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},Ol=class e extends G{constructor(e=new vl([new z(0,.5),new z(-.5,-.5),new z(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new W(r,3)),this.setAttribute(`normal`,new W(i,3)),this.setAttribute(`uv`,new W(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;bl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];bl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=bl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return St(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}},kl=class e extends G{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new B,d=new B,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=a+_*o,y=e*Math.cos(v),b=Math.sqrt(e*e-y*y),x=0;f===0&&a===0?x=.5/t:f===n&&s===Math.PI&&(x=-.5/t);for(let e=0;e<=t;e++){let n=e/t,a=r+n*i;u.x=-b*Math.cos(a),u.y=y,u.z=b*Math.sin(a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(n+x,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new W(p,3)),this.setAttribute(`normal`,new W(m,3)),this.setAttribute(`uv`,new W(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},Al=class e extends Kc{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=`TetrahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},jl=class e extends G{constructor(e=1,t=.4,n=12,r=48,i=Math.PI*2,a=0,o=Math.PI*2){super(),this.type=`TorusGeometry`,this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i,thetaStart:a,thetaLength:o},n=Math.floor(n),r=Math.floor(r);let s=[],c=[],l=[],u=[],d=new B,f=new B,p=new B;for(let s=0;s<=n;s++){let m=a+s/n*o;for(let a=0;a<=r;a++){let o=a/r*i;f.x=(e+t*Math.cos(m))*Math.cos(o),f.y=(e+t*Math.cos(m))*Math.sin(o),f.z=t*Math.sin(m),c.push(f.x,f.y,f.z),d.x=e*Math.cos(o),d.y=e*Math.sin(o),p.subVectors(f,d).normalize(),l.push(p.x,p.y,p.z),u.push(a/r),u.push(s/n)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,o=(r+1)*e+t;s.push(n,i,o),s.push(i,a,o)}this.setIndex(s),this.setAttribute(`position`,new W(c,3)),this.setAttribute(`normal`,new W(l,3)),this.setAttribute(`uv`,new W(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc,t.thetaStart,t.thetaLength)}},Ml=class e extends G{constructor(e=1,t=.4,n=64,r=8,i=2,a=3){super(),this.type=`TorusKnotGeometry`,this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},n=Math.floor(n),r=Math.floor(r);let o=[],s=[],c=[],l=[],u=new B,d=new B,f=new B,p=new B,m=new B,h=new B,g=new B;for(let o=0;o<=n;++o){let v=o/n*i*Math.PI*2;_(v,i,a,e,f),_(v+.01,i,a,e,p),h.subVectors(p,f),g.addVectors(p,f),m.crossVectors(h,g),g.crossVectors(m,h),m.normalize(),g.normalize();for(let e=0;e<=r;++e){let i=e/r*Math.PI*2,a=-t*Math.cos(i),p=t*Math.sin(i);u.x=f.x+(a*g.x+p*m.x),u.y=f.y+(a*g.y+p*m.y),u.z=f.z+(a*g.z+p*m.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),l.push(o/n),l.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,s=(r+1)*(e-1)+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute(`position`,new W(s,3)),this.setAttribute(`normal`,new W(c,3)),this.setAttribute(`uv`,new W(l,2));function _(e,t,n,r,i){let a=Math.cos(e),o=Math.sin(e),s=n/t*e,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},Nl=class e extends G{constructor(e=new pl(new B(-1,-1,0),new B(-1,1,0),new B(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type=`TubeGeometry`,this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};let a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new B,s=new B,c=new z,l=new B,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute(`position`,new W(u,3)),this.setAttribute(`normal`,new W(d,3)),this.setAttribute(`uv`,new W(f,2));function m(){for(let e=0;e<t;e++)h(e);h(i===!1?t:0),_(),g()}function h(i){l=e.getPointAt(i/t,l);let c=a.normals[i],f=a.binormals[i];for(let e=0;e<=r;e++){let t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*c.x+i*f.x,s.y=a*c.y+i*f.y,s.z=a*c.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,u.push(o.x,o.y,o.z)}}function g(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;p.push(n,i,o),p.push(i,a,o)}}function _(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)c.x=e/t,c.y=n/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(t){return new e(new hl[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},Pl=class extends G{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=/* @__PURE__ */ new Set,r=new B,i=new B;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),Ct(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),Ct(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new W(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fl=/*#__PURE__*/ Object.freeze({__proto__:null,BoxGeometry:Vc,CapsuleGeometry:Hc,CircleGeometry:Uc,ConeGeometry:Gc,CylinderGeometry:Wc,DodecahedronGeometry:qc,EdgesGeometry:Qc,ExtrudeGeometry:xl,IcosahedronGeometry:Cl,LatheGeometry:wl,OctahedronGeometry:Tl,PlaneGeometry:El,PolyhedronGeometry:Kc,RingGeometry:Dl,ShapeGeometry:Ol,SphereGeometry:kl,TetrahedronGeometry:Al,TorusGeometry:jl,TorusKnotGeometry:Ml,TubeGeometry:Nl,WireframeGeometry:Pl}),Il=class extends Lo{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new H(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Ll={clone:wt,merge:Tt},Rl=`void main() {
|
|
1
|
+
var e=Object.defineProperty,t=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},r=`0.3.0`,i=/\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}/g;function a(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function o(e){return typeof e!=`string`||!e.includes(`{data.`)?!1:(i.lastIndex=0,i.test(e))}function s(e,t){return e.includes(`{data.`)?e.replace(i,(e,n,r)=>{let i=a(t,n);return i==null||i===``?r??``:typeof i==`object`?JSON.stringify(i):String(i)}):e}var c=/^\{data\.([a-zA-Z_$][\w$-]*(?:\.[a-zA-Z_$][\w$-]*)*)(?:\|([^}]*))?\}$/;function l(e,t){if(typeof e!=`string`||!e.includes(`{data.`))return e;let n=c.exec(e.trim());if(!n)return s(e,t);let r=a(t,n[1]);if(r!=null&&r!==``)return r;if(n[2]!==void 0)try{return JSON.parse(n[2])}catch{return n[2]}}function u(e,t=e.data){let n=!1,r=e=>o(e)?(n=!0,s(e,t)):e,i=e=>{if(typeof e==`string`)return o(e)?(n=!0,l(e,t)):e;if(Array.isArray(e)){let t=e.map(i);return t.every((t,n)=>t===e[n])?e:t}if(e&&typeof e==`object`){let t=!1,n={};for(let[r,a]of Object.entries(e)){let e=i(a);e!==a&&(t=!0),e!==void 0&&(n[r]=e)}return t?n:e}return e},a=e=>{let t=e,n=t.kind===`text`?r(t.text):t.text,o=r(t.href),s=t.kind===`generator`&&t.params?i(t.params):t.params,c=e.children?.map(a);return n===t.text&&o===t.href&&s===t.params&&(!c||c.every((t,n)=>t===e.children[n]))?e:{...e,...t.kind===`text`?{text:n}:{},...t.href===void 0?{}:{href:o},...s===t.params?{}:{params:s},...c?{children:c}:{}}},c=e.interactions?.map(e=>{let t=e.do;if(!Array.isArray(t))return e;let n=t.map(e=>{let t=e;return!t||typeof t!=`object`||!o(t.openUrl)?e:{...t,openUrl:r(t.openUrl)}});return n.every((e,n)=>e===t[n])?e:{...e,do:n}}),u=(e.objects??[]).map(a),d=r(e.title),f=r(e.ariaLabel),p=e.ui?.elements?.map(e=>{let t=e,n=r(t.text);return n===t.text?e:{...e,text:n}});return n?{...e,title:d,...e.ariaLabel===void 0?{}:{ariaLabel:f},objects:u,...e.ui&&p?{ui:{...e.ui,elements:p}}:{},...c?{interactions:c}:{}}:e}function d(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(n===`json`)try{let e=JSON.parse(r);e&&typeof e==`object`&&!Array.isArray(e)&&Object.assign(t,e)}catch{}else t[n]=r}return t}function f(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function p(e,t){return new mi[e](t)}function m(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function h(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function g(){let e=h(`canvas`);return e.style.display=`block`,e}function _(e){gi=e}function v(){return gi}function y(...e){let t=`THREE.`+e.shift();gi?gi(`log`,t,...e):console.log(t,...e)}function b(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function x(...e){e=b(e);let t=`THREE.`+e.shift();if(gi)gi(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function S(...e){e=b(e);let t=`THREE.`+e.shift();if(gi)gi(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function C(...e){let t=e.join(` `);t in hi||(hi[t]=!0,x(...e))}function w(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}function T(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(yi[e&255]+yi[e>>8&255]+yi[e>>16&255]+yi[e>>24&255]+`-`+yi[t&255]+yi[t>>8&255]+`-`+yi[t>>16&15|64]+yi[t>>24&255]+`-`+yi[n&63|128]+yi[n>>8&255]+`-`+yi[n>>16&255]+yi[n>>24&255]+yi[r&255]+yi[r>>8&255]+yi[r>>16&255]+yi[r>>24&255]).toLowerCase()}function E(e,t,n){return Math.max(t,Math.min(n,e))}function D(e,t){return(e%t+t)%t}function O(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function k(e,t,n){return e===t?0:(n-e)/(t-e)}function A(e,t,n){return(1-n)*e+n*t}function j(e,t,n,r){return A(e,t,1-Math.exp(-n*r))}function M(e,t=1){return t-Math.abs(D(e,t*2)-t)}function N(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function P(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function F(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ee(e,t){return e+Math.random()*(t-e)}function te(e){return e*(.5-Math.random())}function ne(e){e!==void 0&&(bi=e);let t=bi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function re(e){return e*xi}function ie(e){return e*Si}function ae(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function I(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function oe(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function se(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:x(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function ce(e){switch(e.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function le(e,t){if(t.constructor===Float32Array)return e;let n=ce(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.max(e/n,-1)}function ue(e,t){if(t.constructor===Float32Array)return e;let n=ce(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.round(e*n)}function de(){let e={enabled:!0,workingColorSpace:Vr,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=fe(e.r),e.g=fe(e.g),e.b=fe(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=pe(e.r),e.g=pe(e.g),e.b=pe(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Hr:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[n].fromXYZ).multiply(this.spaces[t].toXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Vr]:{primaries:t,whitePoint:r,transfer:Hr,toXYZ:ki,fromXYZ:Ai,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Br},outputColorSpaceConfig:{drawingBufferColorSpace:Br}},[Br]:{primaries:t,whitePoint:r,transfer:Ur,toXYZ:ki,fromXYZ:Ai,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Br}}}),e}function fe(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function pe(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}function me(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Ni.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(x(`Texture: Unable to serialize Texture.`),{})}function he(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}function ge(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){ro.fromArray(e,a);let o=i.x*Math.abs(ro.x)+i.y*Math.abs(ro.y)+i.z*Math.abs(ro.z),s=t.dot(ro),c=n.dot(ro),l=r.dot(ro);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}function _e(){let e=/* @__PURE__ */ new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=/* @__PURE__ */ new Uint32Array(512),i=/* @__PURE__ */ new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=/* @__PURE__ */ new Uint32Array(2048),o=/* @__PURE__ */ new Uint32Array(64),s=/* @__PURE__ */ new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function ve(e){Math.abs(e)>65504&&x(`DataUtils.toHalfFloat(): Value out of range.`),e=E(e,-65504,65504),io.floatView[0]=e;let t=io.uint32View[0],n=t>>23&511;return io.baseTable[n]+((t&8388607)>>io.shiftTable[n])}function ye(e){let t=e>>10;return io.uint32View[0]=io.mantissaTable[io.offsetTable[t]+(e&1023)]+io.exponentTable[t],io.floatView[0]}function be(e){return e.buffer._uuid===void 0&&(e.buffer._uuid=T()),e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer._uuid:e.buffer._uuid+`:`+e.byteOffset+`:`+e.byteLength}function xe(e,t,n,r,i,a){Uo.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?Wo.copy(Uo):(Wo.x=a*Uo.x-i*Uo.y,Wo.y=i*Uo.x+a*Uo.y),e.copy(t),e.x+=Wo.x,e.y+=Wo.y,e.applyMatrix4(Go)}function Se(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;vs.copy(s),vs.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(vs);return l<n.near||l>n.far?null:{distance:l,point:vs.clone(),object:e}}function Ce(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,fs),e.getVertexPosition(c,ps),e.getVertexPosition(l,ms);let u=Se(e,t,n,r,fs,ps,ms,_s);if(u){let e=new B;Ua.getBarycoord(_s,fs,ps,ms,e),i&&(u.uv=Ua.getInterpolatedAttribute(i,s,c,l,e,new z)),a&&(u.uv1=Ua.getInterpolatedAttribute(a,s,c,l,e,new z)),o&&(u.normal=Ua.getInterpolatedAttribute(o,s,c,l,e,new B),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new B,materialIndex:0};Ua.getNormal(fs,ps,ms,t.normal),u.face=t,u.barycoord=e}return u}function we(e,t){return e-t}function Te(e,t){return e.z-t.z}function Ee(e,t){return t.z-e.z}function L(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a<i;a++)for(let i=0;i<r;i++)t.setComponent(a+n,i,e.getComponent(a,i))}else t.array.set(e.array,n*r);t.needsUpdate=!0}function De(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)t[r]=e[r]}else{let n=Math.min(e.length,t.length);t.set(new e.constructor(e.buffer,0,n))}}function Oe(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(dc.fromBufferAttribute(s,i),fc.fromBufferAttribute(s,a),n.distanceSqToSegment(dc,fc,gc,_c)>r)return;gc.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(gc);if(!(c<t.near||c>t.far))return{distance:c,point:_c.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}function ke(e,t,n,r,i,a,o){let s=Tc.distanceSqToPoint(e);if(s<n){let n=new B;Tc.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}function R(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let c=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;c*=o,l*=o,i(t,n,c,l)},calc:function(i){let a=i*i,o=a*i;return e+t*i+n*a+r*o}}}function Ae(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}function je(e,t){let n=1-e;return n*n*t}function Me(e,t){return 2*(1-e)*e*t}function Ne(e,t){return e*e*t}function Pe(e,t,n,r){return je(e,t)+Me(e,n)+Ne(e,r)}function Fe(e,t){let n=1-e;return n*n*n*t}function Ie(e,t){let n=1-e;return 3*n*n*e*t}function Le(e,t){return 3*(1-e)*e*e*t}function Re(e,t){return e*e*e*t}function ze(e,t,n,r,i){return Fe(e,t)+Ie(e,n)+Le(e,r)+Re(e,i)}function Be(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=Ve(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=Je(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return Ue(a,o,n,s,c,l,0),o}function Ve(e,t,n,r,i){let a;if(i===vt(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=ht(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=ht(i/r|0,e[i],e[i+1],a);return a&&st(a,a.next)&&(gt(a),a=a.next),a}function He(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(st(n,n.next)||ot(n.prev,n,n.next)===0)){if(gt(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function Ue(e,t,n,r,i,a,o){if(!e)return;!o&&a&&$e(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?Ge(e,r,i,a):We(e))t.push(c.i,e.i,l.i),gt(e),e=l.next,s=l.next;else if(e=l,e===s){o?o===1?(e=Ke(He(e),t),Ue(e,t,n,r,i,a,2)):o===2&&qe(e,t,n,r,i,a):Ue(He(e),t,n,r,i,a,1);break}}}function We(e){let t=e.prev,n=e,r=e.next;if(ot(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&it(i,s,a,c,o,l,m.x,m.y)&&ot(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Ge(e,t,n,r){let i=e.prev,a=e,o=e.next;if(ot(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=tt(p,m,t,n,r),v=tt(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&it(s,u,c,d,l,f,y.x,y.y)&&ot(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&it(s,u,c,d,l,f,b.x,b.y)&&ot(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&it(s,u,c,d,l,f,y.x,y.y)&&ot(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&it(s,u,c,d,l,f,b.x,b.y)&&ot(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Ke(e,t){let n=e;do{let r=n.prev,i=n.next.next;!st(r,i)&&ct(r,n,n.next,i)&&ft(r,i)&&ft(i,r)&&(t.push(r.i,n.i,i.i),gt(n),gt(n.next),n=e=i),n=n.next}while(n!==e);return He(n)}function qe(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&at(o,e)){let s=mt(o,e);o=He(o,o.next),s=He(s,s.next),Ue(o,t,n,r,i,a,0),Ue(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function Je(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=Ve(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(nt(o))}i.sort(Ye);for(let e=0;e<i.length;e++)n=Xe(i[e],n);return n}function Ye(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function Xe(e,t){let n=Ze(e,t);if(!n)return t;let r=mt(n,e);return He(r,r.next),He(n,n.next)}function Ze(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(st(e,n))return n;do{if(st(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&rt(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);ft(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&Qe(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function Qe(e,t){return ot(e.prev,e,t.prev)<0&&ot(t.next,e,e.next)<0}function $e(e,t,n,r){let i=e;do i.z===0&&(i.z=tt(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,et(i)}function et(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function tt(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function nt(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function rt(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function it(e,t,n,r,i,a,o,s){return(e!==o||t!==s)&&rt(e,t,n,r,i,a,o,s)}function at(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!dt(e,t)&&(ft(e,t)&&ft(t,e)&&pt(e,t)&&(ot(e.prev,e,t.prev)||ot(e,t.prev,t))||st(e,t)&&ot(e.prev,e,e.next)>0&&ot(t.prev,t,t.next)>0)}function ot(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function st(e,t){return e.x===t.x&&e.y===t.y}function ct(e,t,n,r){let i=ut(ot(e,t,n)),a=ut(ot(e,t,r)),o=ut(ot(n,r,e)),s=ut(ot(n,r,t));return!!(i!==a&&o!==s||i===0&<(e,n,t)||a===0&<(e,r,t)||o===0&<(n,e,r)||s===0&<(n,t,r))}function lt(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ut(e){return e>0?1:e<0?-1:0}function dt(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ct(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ft(e,t){return ot(e.prev,e,e.next)<0?ot(e,t,e.next)>=0&&ot(e,e.prev,t)>=0:ot(e,t,e.prev)<0||ot(e,e.next,t)<0}function pt(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function mt(e,t){let n=_t(e.i,e.x,e.y),r=_t(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function ht(e,t,n,r){let i=_t(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function gt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function _t(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function vt(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function yt(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function bt(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}function xt(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);return n.options=Object.assign({},t),t.extrudePath!==void 0&&(n.options.extrudePath=t.extrudePath.toJSON()),n}function St(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=e[n];t.shapes.push(r.uuid)}else t.shapes.push(e.uuid);return t}function Ct(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}function wt(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(Et(i))i.isRenderTargetTexture?(x(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(Et(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function Tt(e){let t={};for(let n=0;n<e.length;n++){let r=wt(e[n]);for(let e in r)t[e]=r[e]}return t}function Et(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function Dt(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Ot(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ji.workingColorSpace}function kt(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function At(e){return e!==void 0&&e.inTangents!==void 0&&e.outTangents!==void 0}function jt(e){function t(t,n){return e[t]-e[n]}let n=e.length,r=Array(n);for(let e=0;e!==n;++e)r[e]=e;return r.sort(t),r}function Mt(e,t,n){let r=e.length,i=new e.constructor(r);for(let a=0,o=0;o!==r;++a){let r=n[a]*t;for(let n=0;n!==t;++n)i[o++]=e[r+n]}return i}function Nt(e,t,n,r){let i=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[i++];if(a===void 0)return;let o=a[r];if(o!==void 0){if(Array.isArray(o))do o=a[r],o!==void 0&&(t.push(a.time),n.push(...o)),a=e[i++];while(a!==void 0);else if(o.toArray!==void 0)do o=a[r],o!==void 0&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++];while(a!==void 0);else do o=a[r],o!==void 0&&(t.push(a.time),n.push(o)),a=e[i++];while(a!==void 0)}}function Pt(e,t,n,r,i=30){let a=e.clone();a.name=t;let o=[];for(let e=0;e<a.tracks.length;++e){let t=a.tracks[e],s=t.getValueSize(),c=[],l=[];for(let e=0;e<t.times.length;++e){let a=t.times[e]*i;if(!(a<n||a>=r)){c.push(t.times[e]);for(let n=0;n<s;++n)l.push(t.values[e*s+n])}}c.length!==0&&(t.times=kt(c,t.times.constructor),t.values=kt(l,t.values.constructor),o.push(t))}a.tracks=o;let s=1/0;for(let e=0;e<a.tracks.length;++e)s>a.tracks[e].times[0]&&(s=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*s);return a.resetDuration(),a}function Ft(e,t=0,n=e,r=30){r<=0&&(r=30);let i=n.tracks.length,a=t/r;for(let t=0;t<i;++t){let r=n.tracks[t],i=r.ValueTypeName;if(i===`bool`||i===`string`)continue;let o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(o===void 0)continue;let s=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=c/3);let l=0,u=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=u/3);let d=r.times.length-1,f;if(a<=r.times[0]){let e=s,t=c-s;f=r.values.slice(e,t)}else if(a>=r.times[d]){let e=d*c+s,t=e+c-s;f=r.values.slice(e,t)}else{let e=r.createInterpolant();e.evaluate(a),f=e.resultBuffer.slice()}i===`quaternion`&&new wi().fromArray(f).normalize().conjugate().toArray(f);let p=o.times.length;for(let e=0;e<p;++e){let t=e*u+l;if(i===`quaternion`)wi.multiplyQuaternionsFlat(o.values,t,f,0,o.values,t);else{let e=u-l*2;for(let n=0;n<e;++n)o.values[t+n]-=f[n]}}}return e.blendMode=Fr,e}function It(e,t,n,r,i){let a=1-e;return a*a*a*t+3*a*a*e*n+3*a*e*e*r+e*e*e*i}function Lt(e,t,n,r,i){let a=1-e;return 3*a*a*(n-t)+6*a*e*(r-n)+3*e*e*(i-r)}function Rt(e,t,n,r,i){let a=(e-t)/(i-t);for(let o=0;o<8;o++){let o=It(a,t,n,r,i)-e;if(Math.abs(o)<1e-10)break;let s=Lt(a,t,n,r,i);if(Math.abs(s)<1e-10)break;a=Math.max(0,Math.min(1,a-o/s))}return a}function zt(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]+=t}function Bt(e,t){for(let n=0,r=e.length;n!==r;n+=2)e[n]*=t}function Vt(e){switch(e.toLowerCase()){case`scalar`:case`double`:case`float`:case`number`:case`integer`:return su;case`vector`:case`vector2`:case`vector3`:case`vector4`:return du;case`color`:return ou;case`quaternion`:return lu;case`bool`:case`boolean`:return au;case`string`:return uu}throw Error(`THREE.KeyframeTrack: Unsupported typeName: `+e)}function Ht(e){if(e.type===void 0)throw Error(`THREE.KeyframeTrack: track type undefined, can not parse`);let t=Vt(e.type);if(e.times===void 0){let t=[],n=[];Nt(e.keys,t,n,`value`),e.times=t,e.values=n}let n;return n=t.parse===void 0?new t(e.name,e.times,e.values,e.interpolation):t.parse(e),At(e.settings)&&(n.settings={inTangents:kt(e.settings.inTangents,Float32Array),outTangents:kt(e.settings.outTangents,Float32Array)}),n}function Ut(e){try{let t=e.slice(e.indexOf(`:`)+1);return new URL(t).protocol===`blob:`}catch{return!1}}function Wt(){this._document.hidden===!1&&this.reset()}function Gt(e,t){return e.distance-t.distance}function Kt(e,t,n,r){let i=!0;if(e.layers.test(t.layers)&&e.raycast(t,n)===!1&&(i=!1),i===!0&&r===!0){let r=e.children;for(let e=0,i=r.length;e<i;e++)Kt(r[e],t,n,!0)}}function qt(e){let t=[];e.isBone===!0&&t.push(e);for(let n=0;n<e.children.length;n++)t.push(...qt(e.children[n]));return t}function Jt(e,t,n,r,i,a,o){Rf.set(i,a,o).unproject(r);let s=t[e];if(s!==void 0){let e=n.getAttribute(`position`);for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],Rf.x,Rf.y,Rf.z)}}function Yt(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}function Xt(e,t){let n=e.image&&e.image.width?e.image.width/e.image.height:1;return n>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}function Zt(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}function Qt(e,t,n,r){let i=$t(r);switch(n){case jn:return e*t;case In:return e*t/i.components*i.byteLength;case Ln:return e*t/i.components*i.byteLength;case Rn:return e*t*2/i.components*i.byteLength;case zn:return e*t*2/i.components*i.byteLength;case Mn:return e*t*3/i.components*i.byteLength;case Nn:return e*t*4/i.components*i.byteLength;case Vn:return e*t*4/i.components*i.byteLength;case Hn:case Un:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Wn:case Gn:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case qn:case Yn:return Math.max(e,16)*Math.max(t,8)/4;case Kn:case Jn:return Math.max(e,8)*Math.max(t,8)/2;case Xn:case Zn:case $n:case er:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case Qn:case tr:case nr:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case rr:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case ir:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case ar:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case or:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case sr:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case cr:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case lr:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case ur:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case dr:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case fr:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case pr:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case mr:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case hr:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case gr:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case _r:case vr:case yr:return Math.ceil(e/4)*Math.ceil(t/4)*16;case br:case xr:return Math.ceil(e/4)*Math.ceil(t/4)*8;case Sr:case Cr:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${n} format.`)}function $t(e){switch(e){case vn:case yn:return{byteLength:1,components:1};case xn:case bn:case Tn:return{byteLength:2,components:1};case En:case Dn:return{byteLength:2,components:4};case Cn:case Sn:case wn:return{byteLength:4,components:1};case kn:case An:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}var en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln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1008,_n=1008,vn=1009,yn=1010,bn=1011,xn=1012,Sn=1013,Cn=1014,wn=1015,Tn=1016,En=1017,Dn=1018,On=1020,kn=35902,An=35899,jn=1021,Mn=1022,Nn=1023,Pn=1026,Fn=1027,In=1028,Ln=1029,Rn=1030,zn=1031,Bn=1032,Vn=1033,Hn=33776,Un=33777,Wn=33778,Gn=33779,Kn=35840,qn=35841,Jn=35842,Yn=35843,Xn=36196,Zn=37492,Qn=37496,$n=37488,er=37489,tr=37490,nr=37491,rr=37808,ir=37809,ar=37810,or=37811,sr=37812,cr=37813,lr=37814,ur=37815,dr=37816,fr=37817,pr=37818,mr=37819,hr=37820,gr=37821,_r=36492,vr=36494,yr=36495,br=36283,xr=36284,Sr=36285,Cr=36286,wr=2200,Tr=2201,Er=2202,Dr=2300,Or=2301,kr=2302,Ar=2303,jr=2400,Mr=2401,Nr=2402,Pr=2500,Fr=2501,Ir=3200,Lr=3201,Rr=3202,zr=3203,Br=`srgb`,Vr=`srgb-linear`,Hr=`linear`,Ur=`srgb`,Wr=7680,Gr=7681,Kr=7682,qr=7683,Jr=34055,Yr=34056,Xr=5386,Zr=35044,Qr=35048,$r=35040,ei=35045,ti=35049,ni=35041,ri=35046,ii=35050,ai=35042,oi=`300 es`,si=2e3,ci=2001,li={COMPUTE:`compute`,RENDER:`render`},ui={PERSPECTIVE:`perspective`,LINEAR:`linear`,FLAT:`flat`},di={NORMAL:`normal`,CENTROID:`centroid`,SAMPLE:`sample`,FIRST:`first`,EITHER:`either`},fi={TEXTURE_COMPARE:`depthTextureCompare`},pi={NONE:0,SHARED:1,FULL:2},mi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array},hi={},gi=null,_i={0:0,2:6,4:4,3:5,1:1,6:2,7:7,5:3},vi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n!==void 0&&n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},yi=/* @__PURE__ */ `00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),bi=1234567,xi=Math.PI/180,Si=180/Math.PI,Ci={DEG2RAD:xi,RAD2DEG:Si,generateUUID:T,clamp:E,euclideanModulo:D,mapLinear:O,inverseLerp:k,lerp:A,damp:j,pingpong:M,smoothstep:N,smootherstep:P,randInt:F,randFloat:ee,randFloatSpread:te,seededRandom:ne,degToRad:re,radToDeg:ie,isPowerOfTwo:ae,ceilPowerOfTwo:I,floorPowerOfTwo:oe,setQuaternionFromProperEuler:se,normalize:ue,denormalize:le},z=class{static{this.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`THREE.Vector2: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`THREE.Vector2: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(E(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},wi=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:x(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(E(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},B=class{static{this.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`THREE.Vector3: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`THREE.Vector3: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ei.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ei.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this.z=E(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this.z=E(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ti.copy(this).projectOnVector(e),this.sub(Ti)}reflect(e){return this.sub(Ti.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(E(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ti=/*@__PURE__*/ new B,Ei=/*@__PURE__*/ new wi,Di=class{static{this.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return C(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Oi.makeScale(e,t)),this}rotate(e){return C(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Oi.makeRotation(-e)),this}translate(e,t){return C(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Oi.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Oi=/*@__PURE__*/ new Di,ki=/*@__PURE__*/ new Di().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ai=/*@__PURE__*/ new Di().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),ji=/*@__PURE__*/ de(),Ni=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Mi===void 0&&(Mi=h(`canvas`)),Mi.width=e.width,Mi.height=e.height;let t=Mi.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Mi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=h(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=fe(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(fe(t[e]/255)*255):t[e]=fe(t[e]);return{data:t,width:e.width,height:e.height}}return x(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Pi=0,Fi=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Pi++}),this.uuid=T(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width||0,t.height||0,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(me(r[t].image)):e.push(me(r[t]))}else e=me(r);n.url=e}return t||(e.images[this.uuid]=n),n}},Ii=class extends Fi{constructor(e=null){C(`Source: "Source" has been renamed to "TextureSource". Please update your code to use "THREE.TextureSource" instead.`),super(e),this.isSource=!0}},Li=0,Ri=/*@__PURE__*/ new B,zi=class e extends vi{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=on,i=on,a=pn,o=gn,s=Nn,c=vn,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Li++}),this.uuid=T(),this.name=``,this.source=new Fi(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new z(0,0),this.repeat=new z(1,1),this.center=new z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Di,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Ri).x}get height(){return this.source.getSize(Ri).y}get depth(){return this.source.getSize(Ri).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.mipmapsAutoUpdate=e.mipmapsAutoUpdate,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){x(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?x(`Texture.setValues(): property '${t}' does not exist.`):r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,mipmapsAutoUpdate:this.mipmapsAutoUpdate,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case an:e.x-=Math.floor(e.x);break;case on:e.x=e.x<0?0:1;break;case sn:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case an:e.y-=Math.floor(e.y);break;case on:e.y=e.y<0?0:1;break;case sn:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}},zi.DEFAULT_IMAGE=null,zi.DEFAULT_MAPPING=300,zi.DEFAULT_ANISOTROPY=1,Bi=class{static{this.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`THREE.Vector4: index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`THREE.Vector4: index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=E(this.x,e.x,t.x),this.y=E(this.y,e.y,t.y),this.z=E(this.z,e.z,t.z),this.w=E(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=E(this.x,e,t),this.y=E(this.y,e,t),this.z=E(this.z,e,t),this.w=E(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(E(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Vi=class extends vi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:pn,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new Bi(0,0,e,t),this.scissorTest=!1,this.viewport=new Bi(0,0,e,t),this.textures=[];let r=n.count;for(let i=0;i<r;i++)this.textures[i]=new zi({width:e,height:t,depth:n.depth}),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:pn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Fi(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Hi=class extends Vi{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ui=class extends zi{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=cn,this.minFilter=cn,this.wrapR=on,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=/* @__PURE__ */ new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Wi=class extends Hi{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Ui(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},Gi=class extends zi{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=cn,this.minFilter=cn,this.wrapR=on,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},Ki=class extends Hi{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Gi(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}},V=class e{static{this.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/qi.setFromMatrixColumn(e,0).length(),i=1/qi.setFromMatrixColumn(e,1).length(),a=1/qi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Yi,e,Xi)}lookAt(e,t,n){let r=this.elements;return $i.subVectors(e,t),$i.lengthSq()===0&&($i.z=1),$i.normalize(),Zi.crossVectors(n,$i),Zi.lengthSq()===0&&(Math.abs(n.z)===1?$i.x+=1e-4:$i.z+=1e-4,$i.normalize(),Zi.crossVectors(n,$i)),Zi.normalize(),Qi.crossVectors($i,Zi),r[0]=Zi.x,r[4]=Qi.x,r[8]=$i.x,r[1]=Zi.y,r[5]=Qi.y,r[9]=$i.y,r[2]=Zi.z,r[6]=Qi.z,r[10]=$i.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],ee=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*ee,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*ee,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*ee,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*ee,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=qi.set(r[0],r[1],r[2]).length(),o=qi.set(r[4],r[5],r[6]).length(),s=qi.set(r[8],r[9],r[10]).length();i<0&&(a=-a),Ji.copy(this);let c=1/a,l=1/o,u=1/s;return Ji.elements[0]*=c,Ji.elements[1]*=c,Ji.elements[2]*=c,Ji.elements[4]*=l,Ji.elements[5]*=l,Ji.elements[6]*=l,Ji.elements[8]*=u,Ji.elements[9]*=u,Ji.elements[10]*=u,t.setFromRotationMatrix(Ji),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=si,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=si,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},qi=/*@__PURE__*/ new B,Ji=/*@__PURE__*/ new V,Yi=/*@__PURE__*/ new B(0,0,0),Xi=/*@__PURE__*/ new B(1,1,1),Zi=/*@__PURE__*/ new B,Qi=/*@__PURE__*/ new B,$i=/*@__PURE__*/ new B,ea=/*@__PURE__*/ new V,ta=/*@__PURE__*/ new wi,na=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(E(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-E(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(E(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-E(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(E(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-E(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:x(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ea.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ea,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ta.setFromEuler(this),this.setFromQuaternion(ta,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}},na.DEFAULT_ORDER=`XYZ`,ra=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&1<<e)}},ia=0,aa=/*@__PURE__*/ new B,oa=/*@__PURE__*/ new wi,sa=/*@__PURE__*/ new V,ca=/*@__PURE__*/ new B,la=/*@__PURE__*/ new B,ua=/*@__PURE__*/ new B,da=/*@__PURE__*/ new wi,fa=/*@__PURE__*/ new B(1,0,0),pa=/*@__PURE__*/ new B(0,1,0),ma=/*@__PURE__*/ new B(0,0,1),ha={type:`added`},ga={type:`removed`},_a={type:`childadded`,child:null},va={type:`childremoved`,child:null},ya=class e extends vi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ia++}),this.uuid=T(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new B,n=new na,r=new wi,i=new B(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new V},normalMatrix:{value:new Di}}),this.matrix=new V,this.matrixWorld=new V,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ra,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return oa.setFromAxisAngle(e,t),this.quaternion.multiply(oa),this}rotateOnWorldAxis(e,t){return oa.setFromAxisAngle(e,t),this.quaternion.premultiply(oa),this}rotateX(e){return this.rotateOnAxis(fa,e)}rotateY(e){return this.rotateOnAxis(pa,e)}rotateZ(e){return this.rotateOnAxis(ma,e)}translateOnAxis(e,t){return aa.copy(e).applyQuaternion(this.quaternion),this.position.add(aa.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(fa,e)}translateY(e){return this.translateOnAxis(pa,e)}translateZ(e){return this.translateOnAxis(ma,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(sa.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ca.copy(e):ca.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),la.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?sa.lookAt(la,ca,this.up):sa.lookAt(ca,la,this.up),this.quaternion.setFromRotationMatrix(sa),r&&(sa.extractRotation(r.matrixWorld),oa.setFromRotationMatrix(sa),this.quaternion.premultiply(oa.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(S(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ha),_a.child=e,this.dispatchEvent(_a),_a.child=null):S(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ga),va.child=e,this.dispatchEvent(va),va.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),sa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),sa.multiply(e.parent.matrixWorld)),e.applyMatrix4(sa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ha),_a.child=e,this.dispatchEvent(_a),_a.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(la,e,ua),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(la,da,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}},ya.DEFAULT_UP=/*@__PURE__*/ new B(0,1,0),ya.DEFAULT_MATRIX_AUTO_UPDATE=!0,ya.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0,ba=class extends ya{constructor(){super(),this.isGroup=!0,this.type=`Group`}},xa={type:`move`},Sa=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ba,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ba,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ba,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xa)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ba;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Ca={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},wa={h:0,s:0,l:0},Ta={h:0,s:0,l:0},H=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Br){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ji.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ji.workingColorSpace){return this.r=e,this.g=t,this.b=n,ji.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ji.workingColorSpace){if(e=D(e,1),t=E(t,0,1),n=E(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=he(i,r,e+1/3),this.g=he(i,r,e),this.b=he(i,r,e-1/3)}return ji.colorSpaceToWorking(this,r),this}setStyle(e,t=Br){function n(t){t!==void 0&&parseFloat(t)<1&&x(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseFloat(i[1]))/100,Math.min(100,parseFloat(i[2]))/100,Math.min(100,parseFloat(i[3]))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:x(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);x(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Br){let n=Ca[e.toLowerCase()];return n===void 0?x(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=fe(e.r),this.g=fe(e.g),this.b=fe(e.b),this}copyLinearToSRGB(e){return this.r=pe(e.r),this.g=pe(e.g),this.b=pe(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Br){return ji.workingToColorSpace(Ea.copy(this),e),Math.round(E(Ea.r*255,0,255))*65536+Math.round(E(Ea.g*255,0,255))*256+Math.round(E(Ea.b*255,0,255))}getHexString(e=Br){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ji.workingColorSpace){ji.workingToColorSpace(Ea.copy(this),t);let n=Ea.r,r=Ea.g,i=Ea.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=ji.workingColorSpace){return ji.workingToColorSpace(Ea.copy(this),t),e.r=Ea.r,e.g=Ea.g,e.b=Ea.b,e}getStyle(e=Br){ji.workingToColorSpace(Ea.copy(this),e);let t=Ea.r,n=Ea.g,r=Ea.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(wa),this.setHSL(wa.h+e,wa.s+t,wa.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(wa),e.getHSL(Ta);let n=A(wa.h,Ta.h,t),r=A(wa.s,Ta.s,t),i=A(wa.l,Ta.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Ea=/*@__PURE__*/ new H,H.NAMES=Ca,Da=class e{constructor(e,t=25e-5){this.isFogExp2=!0,this.name=``,this.color=new H(e),this.density=t}clone(){return new e(this.color,this.density)}toJSON(){return{type:`FogExp2`,name:this.name,color:this.color.getHex(),density:this.density}}},Oa=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new H(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ka=class extends ya{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new na,this.environmentIntensity=1,this.environmentRotation=new na,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background===null?null:e.background.clone(),this.environment=e.environment===null?null:e.environment.clone(),this.fog=e.fog===null?null:e.fog.clone(),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial===null?null:e.overrideMaterial.clone(),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Aa=/*@__PURE__*/ new B,ja=/*@__PURE__*/ new B,Ma=/*@__PURE__*/ new B,Na=/*@__PURE__*/ new B,Pa=/*@__PURE__*/ new B,Fa=/*@__PURE__*/ new B,Ia=/*@__PURE__*/ new B,La=/*@__PURE__*/ new B,Ra=/*@__PURE__*/ new B,za=/*@__PURE__*/ new B,Ba=/*@__PURE__*/ new Bi,Va=/*@__PURE__*/ new Bi,Ha=/*@__PURE__*/ new Bi,Ua=class e{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Aa.subVectors(e,t),r.cross(Aa);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Aa.subVectors(r,t),ja.subVectors(n,t),Ma.subVectors(e,t);let a=Aa.dot(Aa),o=Aa.dot(ja),s=Aa.dot(Ma),c=ja.dot(ja),l=ja.dot(Ma),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Na)!==null&&Na.x>=0&&Na.y>=0&&Na.x+Na.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Na)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Na.x),s.addScaledVector(a,Na.y),s.addScaledVector(o,Na.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Ba.setScalar(0),Va.setScalar(0),Ha.setScalar(0),Ba.fromBufferAttribute(e,t),Va.fromBufferAttribute(e,n),Ha.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Ba,i.x),a.addScaledVector(Va,i.y),a.addScaledVector(Ha,i.z),a}static isFrontFacing(e,t,n,r){return Aa.subVectors(n,t),ja.subVectors(e,t),Aa.cross(ja).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Aa.subVectors(this.c,this.b),ja.subVectors(this.a,this.b),Aa.cross(ja).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Pa.subVectors(r,n),Fa.subVectors(i,n),La.subVectors(e,n);let s=Pa.dot(La),c=Fa.dot(La);if(s<=0&&c<=0)return t.copy(n);Ra.subVectors(e,r);let l=Pa.dot(Ra),u=Fa.dot(Ra);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0&&s-l>0)return a=s/(s-l),t.copy(n).addScaledVector(Pa,a);za.subVectors(e,i);let f=Pa.dot(za),p=Fa.dot(za);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Fa,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Ia.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Ia,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Pa,a).addScaledVector(Fa,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Wa=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Ka.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Ka.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Ka.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,Ka):Ka.fromBufferAttribute(r,t),Ka.applyMatrix4(e.matrixWorld),this.expandByPoint(Ka);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),qa.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),qa.copy(e.boundingBox)),qa.applyMatrix4(e.matrixWorld),this.union(qa)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Ka),Ka.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eo),to.subVectors(this.max,eo),Ja.subVectors(e.a,eo),Ya.subVectors(e.b,eo),Xa.subVectors(e.c,eo),Za.subVectors(Ya,Ja),Qa.subVectors(Xa,Ya),$a.subVectors(Ja,Xa);let t=[0,-Za.z,Za.y,0,-Qa.z,Qa.y,0,-$a.z,$a.y,Za.z,0,-Za.x,Qa.z,0,-Qa.x,$a.z,0,-$a.x,-Za.y,Za.x,0,-Qa.y,Qa.x,0,-$a.y,$a.x,0];return!ge(t,Ja,Ya,Xa,to)||(t=[1,0,0,0,1,0,0,0,1],!ge(t,Ja,Ya,Xa,to))?!1:(no.crossVectors(Za,Qa),t=[no.x,no.y,no.z],ge(t,Ja,Ya,Xa,to))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ka).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ka).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Ga[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ga[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ga[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ga[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ga[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ga[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ga[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ga[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ga)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Ga=[/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B,/*@__PURE__*/ new B],Ka=/*@__PURE__*/ new B,qa=/*@__PURE__*/ new Wa,Ja=/*@__PURE__*/ new B,Ya=/*@__PURE__*/ new B,Xa=/*@__PURE__*/ new B,Za=/*@__PURE__*/ new B,Qa=/*@__PURE__*/ new B,$a=/*@__PURE__*/ new B,eo=/*@__PURE__*/ new B,to=/*@__PURE__*/ new B,no=/*@__PURE__*/ new B,ro=/*@__PURE__*/ new B,io=/*@__PURE__*/ _e(),U=class{static toHalfFloat(e){return ve(e)}static fromHalfFloat(e){return ye(e)}},ao=/*@__PURE__*/ new B,oo=/*@__PURE__*/ new z,so=0,co=class extends vi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:so++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Zr,this.updateRanges=[],this.gpuType=wn,this.version=0,this._normalizationScale=e===void 0?void 0:ce(e)}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)oo.fromBufferAttribute(this,t),oo.applyMatrix3(e),this.setXY(t,oo.x,oo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyMatrix3(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyMatrix4(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.applyNormalMatrix(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ao.fromBufferAttribute(this,t),ao.transformDirection(e),this.setXYZ(t,ao.x,ao.y,ao.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}_denormalize(e){let t=this._normalizationScale;return t===void 0?le(e,this.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?ue(e,this.array):Math.round(e*t)}},lo=class extends co{constructor(e,t,n){super(new Int8Array(e),t,n)}},uo=class extends co{constructor(e,t,n){super(new Uint8Array(e),t,n)}},fo=class extends co{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},po=class extends co{constructor(e,t,n){super(new Int16Array(e),t,n)}},mo=class extends co{constructor(e,t,n){super(new Uint16Array(e),t,n)}},ho=class extends co{constructor(e,t,n){super(new Int32Array(e),t,n)}},go=class extends co{constructor(e,t,n){super(new Uint32Array(e),t,n)}},_o=class extends co{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=ye(this.array[e*this.itemSize]);return this.normalized&&(t=le(t,this.array)),t}setX(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize]=ve(t),this}getY(e){let t=ye(this.array[e*this.itemSize+1]);return this.normalized&&(t=le(t,this.array)),t}setY(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+1]=ve(t),this}getZ(e){let t=ye(this.array[e*this.itemSize+2]);return this.normalized&&(t=le(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+2]=ve(t),this}getW(e){let t=ye(this.array[e*this.itemSize+3]);return this.normalized&&(t=le(t,this.array)),t}setW(e,t){return this.normalized&&(t=ue(t,this.array)),this.array[e*this.itemSize+3]=ve(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array),r=ue(r,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this.array[e+2]=ve(r),this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=ue(t,this.array),n=ue(n,this.array),r=ue(r,this.array),i=ue(i,this.array)),this.array[e+0]=ve(t),this.array[e+1]=ve(n),this.array[e+2]=ve(r),this.array[e+3]=ve(i),this}},W=class extends co{constructor(e,t,n){super(new Float32Array(e),t,n)}},vo=/*@__PURE__*/ new Wa,yo=/*@__PURE__*/ new B,bo=/*@__PURE__*/ new B,xo=class{constructor(e=new B,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?vo.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yo.subVectors(e,this.center);let t=yo.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(yo,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(bo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yo.copy(e.center).add(bo)),this.expandByPoint(yo.copy(e.center).sub(bo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},So=0,Co=/*@__PURE__*/ new V,wo=/*@__PURE__*/ new ya,To=/*@__PURE__*/ new B,Eo=/*@__PURE__*/ new Wa,Do=/*@__PURE__*/ new Wa,Oo=/*@__PURE__*/ new B,G=class e extends vi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:So++}),this.uuid=T(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return this.index=Array.isArray(e)?new(f(e)?go:mo)(e,1):e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new Di().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Co.makeRotationFromQuaternion(e),this.applyMatrix4(Co),this}rotateX(e){return Co.makeRotationX(e),this.applyMatrix4(Co),this}rotateY(e){return Co.makeRotationY(e),this.applyMatrix4(Co),this}rotateZ(e){return Co.makeRotationZ(e),this.applyMatrix4(Co),this}translate(e,t,n){return Co.makeTranslation(e,t,n),this.applyMatrix4(Co),this}scale(e,t,n){return Co.makeScale(e,t,n),this.applyMatrix4(Co),this}lookAt(e){return wo.lookAt(e),wo.updateMatrix(),this.applyMatrix4(wo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(To).negate(),this.translate(To.x,To.y,To.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new W(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&x(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)S(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Eo.setFromBufferAttribute(n),this.morphTargetsRelative?(Oo.addVectors(this.boundingBox.min,Eo.min),this.boundingBox.expandByPoint(Oo),Oo.addVectors(this.boundingBox.max,Eo.max),this.boundingBox.expandByPoint(Oo)):(this.boundingBox.expandByPoint(Eo.min),this.boundingBox.expandByPoint(Eo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&S(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xo);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)S(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new B,1/0);else if(e){let n=this.boundingSphere.center;if(Eo.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Do.setFromBufferAttribute(n),this.morphTargetsRelative?(Oo.addVectors(Eo.min,Do.min),Eo.expandByPoint(Oo),Oo.addVectors(Eo.max,Do.max),Eo.expandByPoint(Oo)):(Eo.expandByPoint(Do.min),Eo.expandByPoint(Do.max))}Eo.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Oo.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Oo));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Oo.fromBufferAttribute(a,t),o&&(To.fromBufferAttribute(e,t),Oo.add(To)),r=Math.max(r,n.distanceToSquared(Oo))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&S(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){S(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new co(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[],c=new Uint8Array(n.count);for(let e=0;e<n.count;e++)o[e]=new B,s[e]=new B;let l=new B,u=new B,d=new B,f=new z,p=new z,m=new z,h=new B,g=new B;function _(e,t,r){c[e]=c[t]=c[r]=1,l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),d.fromBufferAttribute(n,r),f.fromBufferAttribute(i,e),p.fromBufferAttribute(i,t),m.fromBufferAttribute(i,r),u.sub(l),d.sub(l),p.sub(f),m.sub(f);let a=1/(p.x*m.y-m.x*p.y);isFinite(a)&&(h.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(a),g.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(a),o[e].add(h),o[t].add(h),o[r].add(h),s[e].add(g),s[t].add(g),s[r].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){let n=v[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let y=new B,b=new B,x=new B,C=new B;function w(e){x.fromBufferAttribute(r,e),C.copy(x);let t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(C,t);let n=b.dot(s[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let e=0,t=n.count;e<t;++e)c[e]&&w(e);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new co(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new B,i=new B,a=new B,o=new B,s=new B,c=new B,l=new B,u=new B;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Oo.fromBufferAttribute(e,t),Oo.normalize(),e.setXYZ(t,Oo.x,Oo.y,Oo.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new co(a,r,i)}if(this.index===null)return x(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},ko=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Zr,this.updateRanges=[],this.version=0,this.uuid=T()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=be(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=be(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}},Ao=/*@__PURE__*/ new B,jo=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r,this._normalizationScale=e===void 0?void 0:ce(e.array)}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.applyMatrix4(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.applyNormalMatrix(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Ao.fromBufferAttribute(this,t),Ao.transformDirection(e),this.setXYZ(t,Ao.x,Ao.y,Ao.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){y(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new co(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){y(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t===void 0?le(e,this.data.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?ue(e,this.data.array):Math.round(e*t)}},Mo=/*@__PURE__*/ new B,No=/*@__PURE__*/ new B,Po=/*@__PURE__*/ new Di,Fo=class{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Mo.subVectors(n,t).cross(No.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(Mo),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Po.getNormalMatrix(e),r=this.coplanarPoint(Mo).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Io=0,Lo=class extends vi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Io++}),this.uuid=T(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new H(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wr,this.stencilZFail=Wr,this.stencilZPass=Wr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){x(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?x(`Material: '${t}' is not a property of THREE.${this.type}.`):r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(e=>e.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new H().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(e=>new Fo().fromJSON(e))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0:e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new z().fromArray(t)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new z().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Ro=class extends Lo{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new H(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Bo=/*@__PURE__*/ new B,Vo=/*@__PURE__*/ new B,Ho=/*@__PURE__*/ new B,Uo=/*@__PURE__*/ new z,Wo=/*@__PURE__*/ new z,Go=/*@__PURE__*/ new V,Ko=/*@__PURE__*/ new B,qo=/*@__PURE__*/ new B,Jo=/*@__PURE__*/ new B,Yo=/*@__PURE__*/ new z,Xo=/*@__PURE__*/ new z,Zo=/*@__PURE__*/ new z,Qo=class extends ya{constructor(e=new Ro){if(super(),this.isSprite=!0,this.type=`Sprite`,zo===void 0){zo=new G;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new ko(e,5);zo.setIndex([0,1,2,0,2,3]),zo.setAttribute(`position`,new jo(t,3,0,!1)),zo.setAttribute(`uv`,new jo(t,2,3,!1))}this.geometry=zo,this.material=e,this.center=new z(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&S(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Vo.setFromMatrixScale(this.matrixWorld),Go.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ho.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Vo.multiplyScalar(-Ho.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;xe(Ko.set(-.5,-.5,0),Ho,a,Vo,r,i),xe(qo.set(.5,-.5,0),Ho,a,Vo,r,i),xe(Jo.set(.5,.5,0),Ho,a,Vo,r,i),Yo.set(0,0),Xo.set(1,0),Zo.set(1,1);let o=e.ray.intersectTriangle(Ko,qo,Jo,!1,Bo);if(o===null&&(xe(qo.set(-.5,.5,0),Ho,a,Vo,r,i),Xo.set(0,1),o=e.ray.intersectTriangle(Ko,Jo,qo,!1,Bo),o===null))return;let s=e.ray.origin.distanceTo(Bo);s<e.near||s>e.far||t.push({distance:s,point:Bo.clone(),uv:Ua.getInterpolation(Bo,Ko,qo,Jo,Yo,Xo,Zo,new z),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}toJSON(e){let t=super.toJSON(e);return t.object.center=this.center.toArray(),t}},$o=/*@__PURE__*/ new B,es=/*@__PURE__*/ new B,ts=class extends ya{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type=`LOD`,Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,i=0;for(;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let e=t.splice(n,1);return this.remove(e[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){$o.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo($o);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){$o.setFromMatrixPosition(e.matrixWorld),es.setFromMatrixPosition(this.matrixWorld);let n=$o.distanceTo(es)/e.zoom;t[0].object.visible=!0;let r,i;for(r=1,i=t.length;r<i;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),n>=e)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<i;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);t.object.autoUpdate=this.autoUpdate,t.object.levels=[];let n=this.levels;for(let e=0,r=n.length;e<r;e++){let r=n[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}},ns=/*@__PURE__*/ new B,rs=/*@__PURE__*/ new B,is=/*@__PURE__*/ new B,as=/*@__PURE__*/ new B,os=class{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ns)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ns.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ns.copy(this.origin).addScaledVector(this.direction,t),ns.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){rs.copy(e).add(t).multiplyScalar(.5),is.copy(t).sub(e).normalize(),as.copy(this.origin).sub(rs);let i=e.distanceTo(t)*.5,a=-this.direction.dot(is),o=as.dot(this.direction),s=-as.dot(is),c=as.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(rs).addScaledVector(is,d),f}intersectSphere(e,t){if(e.radius<0)return null;ns.subVectors(e.center,this.origin);let n=ns.dot(this.direction),r=ns.dot(ns)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,ns)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,M,N;if(y>=b&&y>=x?(w=s,D=u,A=p,N=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,M=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,M=_)):b>=x?(w=c,D=d,A=m,N=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,M=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,M=v)):(w=l,D=f,A=h,N=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,M=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,M=g)),w===0)return null;let P=S/w,F=C/w,ee=1/w,te=T-P*D,ne=E-F*D,re=O-P*A,ie=k-F*A,ae=j-P*N,I=M-F*N,oe=ae*ie-I*re,se=te*I-ne*ae,ce=re*ne-ie*te;if(r){if(oe<0||se<0||ce<0)return null}else if((oe<0||se<0||ce<0)&&(oe>0||se>0||ce>0))return null;let le=oe+se+ce;if(le===0)return null;let ue=ee*(oe*D+se*A+ce*N);return(le>0?ue<0:ue>0)?null:this.at(ue/le,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ss=class extends Lo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new H(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new na,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},cs=/*@__PURE__*/ new V,ls=/*@__PURE__*/ new os,us=/*@__PURE__*/ new xo,ds=/*@__PURE__*/ new B,fs=/*@__PURE__*/ new B,ps=/*@__PURE__*/ new B,ms=/*@__PURE__*/ new B,hs=/*@__PURE__*/ new B,gs=/*@__PURE__*/ new B,_s=/*@__PURE__*/ new B,vs=/*@__PURE__*/ new B,K=class extends ya{constructor(e=new G,t=new ss){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){gs.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(hs.fromBufferAttribute(s,e),a?gs.addScaledVector(hs,r):gs.addScaledVector(hs.sub(t),r))}t.add(gs)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),us.copy(n.boundingSphere),us.applyMatrix4(i),ls.copy(e.ray).recast(e.near),us.containsPoint(ls.origin)===!1&&(ls.intersectSphere(us,ds)===null||ls.origin.distanceToSquared(ds)>(e.far-e.near)**2)||(cs.copy(i).invert(),ls.copy(e.ray).applyMatrix4(cs),(n.boundingBox===null||ls.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,ls)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Ce(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Ce(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Ce(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Ce(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}},ys=/*@__PURE__*/ new Bi,bs=/*@__PURE__*/ new Bi,xs=/*@__PURE__*/ new Bi,Ss=/*@__PURE__*/ new Bi,Cs=/*@__PURE__*/ new V,ws=/*@__PURE__*/ new B,Ts=/*@__PURE__*/ new xo,Es=/*@__PURE__*/ new V,Ds=/*@__PURE__*/ new os,Os=class extends K{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type=`SkinnedMesh`,this.bindMode=nn,this.bindMatrix=new V,this.bindMatrixInverse=new V,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Wa),this.boundingBox.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,ws),this.boundingBox.expandByPoint(ws)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new xo),this.boundingSphere.makeEmpty();let t=e.getAttribute(`position`);for(let e=0;e<t.count;e++)this.getVertexPosition(e,ws),this.boundingSphere.expandByPoint(ws)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ts.copy(this.boundingSphere),Ts.applyMatrix4(r),e.ray.intersectsSphere(Ts)!==!1&&(Es.copy(r).invert(),Ds.copy(e.ray).applyMatrix4(Es),(this.boundingBox===null||Ds.intersectsBox(this.boundingBox)!==!1)&&this._computeIntersections(e,t,Ds)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Bi,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r===1/0?e.set(1,0,0,0):e.multiplyScalar(r),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===`attached`?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===`detached`?this.bindMatrixInverse.copy(this.bindMatrix).invert():x(`SkinnedMesh: Unrecognized bindMode: `+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;bs.fromBufferAttribute(r.attributes.skinIndex,e),xs.fromBufferAttribute(r.attributes.skinWeight,e),t.isVector4?(ys.copy(t),t.set(0,0,0,0)):(ys.set(t.x,t.y,t.z,1),t.set(0,0,0)),ys.applyMatrix4(this.bindMatrix);for(let e=0;e<4;e++){let r=xs.getComponent(e);if(r!==0){let i=bs.getComponent(e);Cs.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(Ss.copy(ys).applyMatrix4(Cs),r)}}return t.isVector4&&(t.w=ys.w),t.applyMatrix4(this.bindMatrixInverse)}},ks=class extends ya{constructor(){super(),this.isBone=!0,this.type=`Bone`}},As=class extends zi{constructor(e=null,t=1,n=1,r,i,a,o,s,c=cn,l=cn,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},js=/*@__PURE__*/ new V,Ms=/*@__PURE__*/ new V,Ns=class e{constructor(e=[],t=[]){this.uuid=T(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.previousBoneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){x(`Skeleton: Number of inverse bone matrices does not match amount of bones.`),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new V)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new V;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let r=0,i=e.length;r<i;r++){let i=e[r]?e[r].matrixWorld:Ms;js.multiplyMatrices(i,t[r]),js.toArray(n,r*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new e(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new As(t,e,e,Nn,wn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let n=this.bones[t];if(n.name===e)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null),this.previousBoneTexture!==null&&(this.previousBoneTexture.dispose(),this.previousBoneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let r=e.bones[n],i=t[r];i===void 0&&(x(`Skeleton: No bone found with UUID:`,r),i=new ks),this.bones.push(i),this.boneInverses.push(new V().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.7,type:`Skeleton`,generator:`Skeleton.toJSON`},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,i=t.length;r<i;r++){let i=t[r];e.bones.push(i.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Ps=class extends co{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Fs=/*@__PURE__*/ new V,Is=/*@__PURE__*/ new V,Ls=[],Rs=/*@__PURE__*/ new Wa,zs=/*@__PURE__*/ new V,Bs=/*@__PURE__*/ new K,Vs=/*@__PURE__*/ new xo,Hs=class extends K{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Ps(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<n;e++)this.setMatrixAt(e,zs)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Wa),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fs),Rs.copy(e.boundingBox).applyMatrix4(Fs),this.boundingBox.union(Rs)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new xo),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Fs),Vs.copy(e.boundingSphere).applyMatrix4(Fs),this.boundingSphere.union(Vs)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),this.morphTexture=e.morphTexture===null?null:e.morphTexture.clone(),this.instanceColor=e.instanceColor===null?null:e.instanceColor.clone(),this.count=e.count,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,i=e*(n.length+1)+1;for(let e=0;e<n.length;e++)n[e]=r[i+e]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(Bs.geometry=this.geometry,Bs.material=this.material,Bs.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Vs.copy(this.boundingSphere),Vs.applyMatrix4(n),e.ray.intersectsSphere(Vs)!==!1))for(let i=0;i<r;i++){this.getMatrixAt(i,Fs),Is.multiplyMatrices(n,Fs),Bs.matrixWorld=Is,Bs.raycast(e,Ls);for(let e=0,n=Ls.length;e<n;e++){let n=Ls[e];n.instanceId=i,n.object=this,t.push(n)}Ls.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Ps(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new As(new Float32Array(r*this.count),r,this.count,In,wn));let i=this.morphTexture.source.data.data,a=0;for(let e=0;e<n.length;e++)a+=n[e];let o=this.geometry.morphTargetsRelative?1:1-a,s=r*e;return i[s]=o,i.set(n,s+1),this}updateMorphTargets(){}dispose(){super.dispose(),this.instanceMatrix.dispose(),this.instanceColor!==null&&this.instanceColor.dispose(),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Us=/*@__PURE__*/ new xo,Ws=/*@__PURE__*/ new z(.5,.5),Gs=/*@__PURE__*/ new B,Ks=class{constructor(e=new Fo,t=new Fo,n=new Fo,r=new Fo,i=new Fo,a=new Fo){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=si,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Us.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Us.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Us)}intersectsSprite(e){Us.center.set(0,0,0);let t=Ws.distanceTo(e.center);return Us.radius=.7071067811865476+t,Us.applyMatrix4(e.matrixWorld),this.intersectsSphere(Us)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Gs.x=r.normal.x>0?e.max.x:e.min.x,Gs.y=r.normal.y>0?e.max.y:e.min.y,Gs.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Gs)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},qs=/*@__PURE__*/ new V,Js=class e{constructor(){this.coordinateSystem=si,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];qs.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new Ks),n[e].setFromProjectionMatrix(qs,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new Ks),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}},Ys=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let i=this.pool,a=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});let o=i[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=n,o.index=r}reset(){this.list.length=0,this.index=0}},Xs=/*@__PURE__*/ new V,Zs=/*@__PURE__*/ new H(1,1,1),Qs=/*@__PURE__*/ new Ks,$s=/*@__PURE__*/ new Js,ec=/*@__PURE__*/ new Wa,tc=/*@__PURE__*/ new xo,nc=/*@__PURE__*/ new B,rc=/*@__PURE__*/ new B,ic=/*@__PURE__*/ new B,ac=/*@__PURE__*/ new B,oc=/*@__PURE__*/ new Ys,sc=/*@__PURE__*/ new K,cc=[],lc=class extends K{constructor(e,t,n=t*2,r){super(new G,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawBytesPerElement=1,this._mergedDrawCounts=new Int32Array(e),this._mergedDrawStarts=new Int32Array(e),this._mergedDrawInstanceCounts=new Int32Array(e),this._mergedDrawCount=0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._previousMatricesTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),n=new As(t,e,e,Nn,wn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Uint32Array(e*e),n=new As(t,e,e,Ln,Cn);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Float32Array(e*e*4).fill(1),n=new As(t,e,e,Nn,wn);n.colorSpace=ji.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in e.attributes){let{array:i,itemSize:a,normalized:o}=e.getAttribute(r),s=new i.constructor(n*a),c=new co(s,a,o);t.setAttribute(r,c)}if(e.getIndex()!==null){let e=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new co(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`THREE.BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`THREE.BatchedMesh: Added geometry attribute "${n}" has an inconsistent itemSize or normalized value.`)}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Wa);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingBoxAt(r,ec).applyMatrix4(Xs),e.union(ec)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xo);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingSphereAt(r,tc).applyMatrix4(Xs),e.union(tc)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw Error(`THREE.BatchedMesh: Maximum item count reached.`);let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(we),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let r=this._matricesTexture;Xs.identity().toArray(r.image.data,n*16),r.needsUpdate=!0;let i=this._colorsTexture;return i&&(Zs.toArray(i.image.data,n*4),i.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute(`position`).count:t;let a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error(`THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(we),o=this._availableGeometryIds.shift(),i[o]=r):(o=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(o,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,o}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error(`THREE.BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(r&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw Error(`THREE.BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute(`position`).count;for(let e in n.attributes){let r=t.getAttribute(e),i=n.getAttribute(e);L(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e<t;e++){let t=s+e;for(let e=0;e<a;e++)i.setComponent(t,e,0)}i.needsUpdate=!0,i.addUpdateRange(s*a,c*a)}if(r){let e=o.indexStart,n=o.reservedIndexCount;o.indexCount=t.getIndex().count;for(let t=0;t<a.count;t++)i.setX(e+t,s+a.getX(t));for(let t=a.count,r=n;t<r;t++)i.setX(e+t,s);i.needsUpdate=!0,i.addUpdateRange(e,o.reservedIndexCount)}return o.start=r?o.indexStart:o.vertexStart,o.count=r?o.indexCount:o.vertexCount,o.boundingBox=null,t.boundingBox!==null&&(o.boundingBox=t.boundingBox.clone()),o.boundingSphere=null,t.boundingSphere!==null&&(o.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let t=0,r=n.length;t<r;t++)n[t].active&&n[t].geometryIndex===e&&this.deleteInstance(t);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,r=n.map((e,t)=>t).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),i=this.geometry;for(let a=0,o=n.length;a<o;a++){let o=n[r[a]];if(o.active!==!1){if(i.index!==null){if(o.indexStart!==t){let{indexStart:n,vertexStart:r,reservedIndexCount:a}=o,s=i.index,c=s.array,l=e-r;for(let e=n;e<n+a;e++)c[e]=c[e]+l;s.array.copyWithin(t,n,n+a),s.addUpdateRange(t,a),s.needsUpdate=!0,o.indexStart=t}t+=o.reservedIndexCount}if(o.vertexStart!==e){let{vertexStart:t,reservedVertexCount:n}=o,r=i.attributes;for(let i in r){let a=r[i],{array:o,itemSize:s}=a;o.copyWithin(e*s,t*s,(t+n)*s),a.addUpdateRange(e*s,n*s),a.needsUpdate=!0}o.vertexStart=e}e+=o.reservedVertexCount,o.start=i.index?o.indexStart:o.vertexStart}}return this._nextIndexStart=t,this._nextVertexStart=e,this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let e=new Wa,t=n.index,i=n.attributes.position;for(let n=r.start,a=r.start+r.count;n<a;n++){let r=n;t&&(r=t.getX(r)),e.expandByPoint(nc.fromBufferAttribute(i,r))}r.boundingBox=e}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let t=new xo;this.getBoundingBoxAt(e,ec),ec.getCenter(t.center);let i=n.index,a=n.attributes.position,o=0;for(let e=r.start,n=r.start+r.count;e<n;e++){let n=e;i&&(n=i.getX(n)),nc.fromBufferAttribute(a,n),o=Math.max(o,t.center.distanceToSquared(nc))}t.radius=Math.sqrt(o),r.boundingSphere=t}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null?t.isVector4?t.set(1,1,1,1):t.setRGB(1,1,1):t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t||(this._instanceInfo[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this._visibilityChanged=!0,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(we);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw Error(`THREE.BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),i=new Int32Array(e);De(this._multiDrawCounts,r),De(this._multiDrawStarts,i),this._multiDrawCounts=r,this._multiDrawStarts=i;let a=new Int32Array(e),o=new Int32Array(e),s=new Int32Array(e);De(this._mergedDrawCounts,a),De(this._mergedDrawStarts,o),De(this._mergedDrawInstanceCounts,s),this._mergedDrawCounts=a,this._mergedDrawStarts=o,this._mergedDrawInstanceCounts=s,this._maxInstanceCount=e;let c=this._indirectTexture,l=this._matricesTexture,u=this._colorsTexture;c.dispose(),this._initIndirectTexture(),De(c.image.data,this._indirectTexture.image.data),l.dispose(),this._initMatricesTexture(),De(l.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),De(u.image.data,this._colorsTexture.image.data)),this._previousMatricesTexture!==null&&(this._previousMatricesTexture.dispose(),this._previousMatricesTexture=null)}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(e=>e.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new G,this._initializeGeometry(r));let i=this.geometry;r.index&&De(r.index.array,i.index.array);for(let e in r.attributes)De(r.attributes[e].array,i.attributes[e].array);this._visibilityChanged=!0}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,i=this.matrixWorld,a=this.geometry;sc.material=this.material,sc.geometry.index=a.index,sc.geometry.attributes=a.attributes,sc.geometry.boundingBox===null&&(sc.geometry.boundingBox=new Wa),sc.geometry.boundingSphere===null&&(sc.geometry.boundingSphere=new xo);for(let a=0,o=n.length;a<o;a++){if(!n[a].visible||!n[a].active)continue;let o=n[a].geometryIndex,s=r[o];sc.geometry.setDrawRange(s.start,s.count),this.getMatrixAt(a,sc.matrixWorld).premultiply(i),this.getBoundingBoxAt(o,sc.geometry.boundingBox),this.getBoundingSphereAt(o,sc.geometry.boundingSphere),sc.raycast(e,cc);for(let e=0,n=cc.length;e<n;e++){let n=cc[e];n.object=this,n.batchId=a,t.push(n)}cc.length=0}sc.material=null,sc.geometry.index=null,sc.geometry.attributes={},sc.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox===null?null:e.boundingBox.clone(),this.boundingSphere=e.boundingSphere===null?null:e.boundingSphere.clone(),this._geometryInfo=e._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox===null?null:e.boundingBox.clone(),boundingSphere:e.boundingSphere===null?null:e.boundingSphere.clone()})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._multiDrawBytesPerElement=e._multiDrawBytesPerElement,this._mergedDrawCounts=e._mergedDrawCounts.slice(),this._mergedDrawStarts=e._mergedDrawStarts.slice(),this._mergedDrawInstanceCounts=e._mergedDrawInstanceCounts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),e._colorsTexture===null?this._colorsTexture=null:(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){super.dispose(),this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this._previousMatricesTexture!==null&&(this._previousMatricesTexture.dispose(),this._previousMatricesTexture=null)}_updateDrawParameters(e,t,n,r=`multiDraw`){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let i=t.getIndex(),a=i===null?1:i.array.BYTES_PER_ELEMENT,o=1;n.wireframe&&(o=2,a=t.attributes.position.count>65535?4:2);let s=this._instanceInfo,c=this._multiDrawStarts,l=this._multiDrawCounts,u=this._mergedDrawStarts,d=this._mergedDrawCounts,f=this._mergedDrawInstanceCounts,p=this._geometryInfo,m=this.perObjectFrustumCulled,h=this._indirectTexture,g=h.image.data,_=e.isArrayCamera?$s:Qs;m&&(e.isArrayCamera?_.setFromArrayCamera(e):(Xs.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse).multiply(this.matrixWorld),_.setFromProjectionMatrix(Xs,e.coordinateSystem,e.reversedDepth)));let v=0,y=0;if(this.sortObjects){Xs.copy(this.matrixWorld).invert(),rc.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Xs),ic.set(0,0,-1).transformDirection(e.matrixWorld).transformDirection(Xs);for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex;this.getMatrixAt(e,Xs),this.getBoundingSphereAt(t,tc).applyMatrix4(Xs);let n=!1;if(m&&(n=!_.intersectsSphere(tc)),!n){let n=p[t],r=ac.subVectors(tc.center,rc).dot(ic);oc.push(n.start,n.count,r,e)}}let t=oc.list,i=this.customSort;i===null?t.sort(n.transparent?Ee:Te):i.call(this,t,e);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.start*a*o,s=n.count*o;r===`merged`?y>0&&u[y-1]===i&&d[y-1]===s?f[y-1]++:(u[y]=i,d[y]=s,f[y]=1,y++):(c[v]=i,l[v]=s),g[v]=n.index,v++}oc.reset()}else for(let e=0,t=s.length;e<t;e++)if(s[e].visible&&s[e].active){let t=s[e].geometryIndex,n=!1;if(m&&(this.getMatrixAt(e,Xs),this.getBoundingSphereAt(t,tc).applyMatrix4(Xs),n=!_.intersectsSphere(tc)),!n){let n=p[t],i=n.start*a*o,s=n.count*o;r===`merged`?y>0&&u[y-1]===i&&d[y-1]===s?f[y-1]++:(u[y]=i,d[y]=s,f[y]=1,y++):(c[v]=i,l[v]=s),g[v]=e,v++}}h.needsUpdate=!0,this._multiDrawCount=v,this._mergedDrawCount=y,this._multiDrawBytesPerElement=a,this._visibilityChanged=!1}onBeforeRender(e,t,n,r,i){e.isWebGPURenderer===!0?(this._visibilityChanged||this.perObjectFrustumCulled||this.sortObjects)&&(this._indirectTexture.needsUpdate=!0):this._updateDrawParameters(n,r,i)}onBeforeShadow(e,t,n,r,i,a){e.isWebGPURenderer!==!0&&this._updateDrawParameters(r,i,a)}},uc=class extends Lo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new H(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},dc=/*@__PURE__*/ new B,fc=/*@__PURE__*/ new B,pc=/*@__PURE__*/ new V,mc=/*@__PURE__*/ new os,hc=/*@__PURE__*/ new xo,gc=/*@__PURE__*/ new B,_c=/*@__PURE__*/ new B,vc=class extends ya{constructor(e=new G,t=new uc){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)dc.fromBufferAttribute(t,e-1),fc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=dc.distanceTo(fc);e.setAttribute(`lineDistance`,new W(n,1))}else x(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hc.copy(n.boundingSphere),hc.applyMatrix4(r),hc.radius+=i,e.ray.intersectsSphere(hc)===!1)return;pc.copy(r).invert(),mc.copy(e.ray).applyMatrix4(pc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=Oe(this,e,mc,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=Oe(this,e,mc,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=Oe(this,e,mc,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=Oe(this,e,mc,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},yc=/*@__PURE__*/ new B,bc=/*@__PURE__*/ new B,xc=class extends vc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)yc.fromBufferAttribute(t,e),bc.fromBufferAttribute(t,e+1),n[e]=e===0?0:n[e-1],n[e+1]=n[e]+yc.distanceTo(bc);e.setAttribute(`lineDistance`,new W(n,1))}else x(`LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}},Sc=class extends vc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type=`LineLoop`}},Cc=class extends Lo{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new H(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},wc=/*@__PURE__*/ new V,Tc=/*@__PURE__*/ new os,Ec=/*@__PURE__*/ new xo,Dc=/*@__PURE__*/ new B,Oc=class extends ya{constructor(e=new G,t=new Cc){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ec.copy(n.boundingSphere),Ec.applyMatrix4(r),Ec.radius+=i,e.ray.intersectsSphere(Ec)===!1)return;wc.copy(r).invert(),Tc.copy(e.ray).applyMatrix4(wc);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Dc.fromBufferAttribute(l,n),ke(Dc,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Dc.fromBufferAttribute(l,a),ke(Dc,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},kc=class extends zi{constructor(e,t,n,r,i=pn,a=pn,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let l=this;function u(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u)}`requestVideoFrameCallback`in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(u))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!(`requestVideoFrameCallback`in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}},Ac=class extends kc{constructor(e,t,n,r,i,a,o,s){super({},e,t,n,r,i,a,o,s),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}},jc=class extends zi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=cn,this.minFilter=cn,this.generateMipmaps=!1,this.needsUpdate=!0}copy(e){return super.copy(e),this.source=new Fi(Object.assign({},e.image)),this}},Mc=class extends zi{constructor(e=[],t,n,r,i,a,o,s,c,l,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Nc=class extends Mc{constructor(e,t,n,r,i,a){super(e,t,n,i,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=on,this.layerUpdates=/* @__PURE__ */ new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Pc=class extends Mc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Fc=class extends zi{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Ic=class extends zi{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},Lc=class extends zi{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;let l=e?e.parentNode:null;l!==null&&`requestPaint`in l&&(l.onpaint=()=>{this.needsUpdate=!0},l.requestPaint())}dispose(){let e=this.image?this.image.parentNode:null;e!==null&&`onpaint`in e&&(e.onpaint=null),super.dispose()}},Rc=class extends zi{constructor(e,t,n=Cn,r,i,a,o=cn,s=cn,c,l=Pn,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Fi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},zc=class extends Rc{constructor(e,t=Cn,n=301,r,i,a=cn,o=cn,s,c=Pn){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Bc=class extends zi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Vc=class e extends G{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new W(c,3)),this.setAttribute(`normal`,new W(l,3)),this.setAttribute(`uv`,new W(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new B;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},Hc=class e extends G{constructor(e=1,t=1,n=4,r=8,i=1){super(),this.type=`CapsuleGeometry`,this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:i},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),i=Math.max(1,Math.floor(i));let a=[],o=[],s=[],c=[],l=t/2,u=Math.PI/2*e,d=t,f=2*u+d,p=n*2+i,m=r+1,h=new B,g=new B;for(let _=0;_<=p;_++){let v=0,y=0,b=0,x=0;if(_<=n){let t=_/n,r=t*Math.PI/2;y=-l-e*Math.cos(r),b=e*Math.sin(r),x=-e*Math.cos(r),v=t*u}else if(_<=n+i){let r=(_-n)/i;y=-l+r*t,b=e,x=0,v=u+r*d}else{let t=(_-n-i)/n,r=t*Math.PI/2;y=l+e*Math.sin(r),b=e*Math.cos(r),x=e*Math.sin(r),v=u+d+t*u}let S=Math.max(0,Math.min(1,v/f)),C=0;_===0?C=.5/r:_===p&&(C=-.5/r);for(let e=0;e<=r;e++){let t=e/r,n=t*Math.PI*2,i=Math.sin(n),a=Math.cos(n);g.x=-b*a,g.y=y,g.z=b*i,o.push(g.x,g.y,g.z),h.set(-b*a,x,b*i),h.normalize(),s.push(h.x,h.y,h.z),c.push(t+C,S)}if(_>0){let e=(_-1)*m;for(let t=0;t<r;t++){let n=e+t,r=e+t+1,i=_*m+t,o=_*m+t+1;a.push(n,r,i),a.push(r,o,i)}}}this.setIndex(a),this.setAttribute(`position`,new W(o,3)),this.setAttribute(`normal`,new W(s,3)),this.setAttribute(`uv`,new W(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},Uc=class e extends G{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type=`CircleGeometry`,this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let i=[],a=[],o=[],s=[],c=new B,l=new z;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=t;i++,u+=3){let d=n+i/t*r;c.x=e*Math.cos(d),c.y=e*Math.sin(d),a.push(c.x,c.y,c.z),o.push(0,0,1),l.x=(a[u]/e+1)/2,l.y=(a[u+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute(`position`,new W(a,3)),this.setAttribute(`normal`,new W(o,3)),this.setAttribute(`uv`,new W(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.segments,t.thetaStart,t.thetaLength)}},Wc=class e extends G{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new W(u,3)),this.setAttribute(`normal`,new W(d,3)),this.setAttribute(`uv`,new W(f,2));function _(){let a=new B,_=new B,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new z,m=new B,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Gc=class e extends Wc{constructor(e=1,t=1,n=32,r=1,i=!1,a=0,o=Math.PI*2){super(0,e,t,n,r,i,a,o),this.type=`ConeGeometry`,this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}static fromJSON(t){return new e(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Kc=class e extends G{constructor(e=[],t=[],n=1,r=0){super(),this.type=`PolyhedronGeometry`,this.parameters={vertices:e,indices:t,radius:n,detail:r};let i=[],a=[];o(r),c(n),l(),this.setAttribute(`position`,new W(i,3)),this.setAttribute(`normal`,new W(i.slice(),3)),this.setAttribute(`uv`,new W(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function o(e){let n=new B,r=new B,i=new B;for(let a=0;a<t.length;a+=3)f(t[a+0],n),f(t[a+1],r),f(t[a+2],i),s(n,r,i,e)}function s(e,t,n,r){let i=r+1,a=[];for(let r=0;r<=i;r++){a[r]=[];let o=e.clone().lerp(n,r/i),s=t.clone().lerp(n,r/i),c=i-r;for(let e=0;e<=c;e++)e===0&&r===i?a[r][e]=o:a[r][e]=o.clone().lerp(s,e/c)}for(let e=0;e<i;e++)for(let t=0;t<2*(i-e)-1;t++){let n=Math.floor(t/2);t%2==0?(d(a[e][n+1]),d(a[e+1][n]),d(a[e][n])):(d(a[e][n+1]),d(a[e+1][n+1]),d(a[e+1][n]))}}function c(e){let t=new B;for(let n=0;n<i.length;n+=3)t.x=i[n+0],t.y=i[n+1],t.z=i[n+2],t.normalize().multiplyScalar(e),i[n+0]=t.x,i[n+1]=t.y,i[n+2]=t.z}function l(){let e=new B;for(let t=0;t<i.length;t+=3){e.x=i[t+0],e.y=i[t+1],e.z=i[t+2];let n=h(e)/2/Math.PI+.5,r=g(e)/Math.PI+.5;a.push(n,1-r)}p(),u()}function u(){for(let e=0;e<a.length;e+=6){let t=a[e+0],n=a[e+2],r=a[e+4];Math.max(t,n,r)>.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new B,t=new B,n=new B,r=new B,o=new z,s=new z,c=new z;for(let l=0,u=0;l<i.length;l+=9,u+=6){e.set(i[l+0],i[l+1],i[l+2]),t.set(i[l+3],i[l+4],i[l+5]),n.set(i[l+6],i[l+7],i[l+8]),o.set(a[u+0],a[u+1]),s.set(a[u+2],a[u+3]),c.set(a[u+4],a[u+5]),r.copy(e).add(t).add(n).divideScalar(3);let d=h(r);m(o,u+0,e,d),m(s,u+2,t,d),m(c,u+4,n,d)}}function m(e,t,n,r){r<0&&e.x===1&&(a[t]=e.x-1),n.x===0&&n.z===0&&(a[t]=r/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}function g(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.vertices,t.indices,t.radius,t.detail)}},qc=class e extends Kc{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];super(i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type=`DodecahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},Jc=/*@__PURE__*/ new B,Yc=/*@__PURE__*/ new B,Xc=/*@__PURE__*/ new B,Zc=/*@__PURE__*/ new Ua,Qc=class extends G{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(xi*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u=/* @__PURE__ */ new Map,d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=Zc;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),Zc.getNormal(Xc),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=Zc[c[e]],o=Zc[c[t]],f=`${n}_${i}`,p=`${i}_${n}`,m=u.get(p);m?(Xc.dot(m.normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u.set(p,null)):u.has(f)||u.set(f,{index0:s[e],index1:s[t],normal:Xc.clone()})}}for(let e of u.values())if(e){let{index0:t,index1:n}=e;Jc.fromBufferAttribute(a,t),Yc.fromBufferAttribute(a,n),d.push(Jc.x,Jc.y,Jc.z),d.push(Yc.x,Yc.y,Yc.z)}this.setAttribute(`position`,new W(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},$c=class{constructor(){this.type=`Curve`,this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){x(`Curve: .getPoint() not implemented.`)}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){let n=this.getLengths(),r=0,i=n.length,a;a=t||e*n[i-1];let o=0,s=i-1,c;for(;o<=s;)if(r=Math.floor(o+(s-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)s=r-1;else{s=r;break}if(r=s,n[r]===a)return r/(i-1);let l=n[r],u=n[r+1]-l,d=(a-l)/u;return(r+d)/(i-1)}getTangent(e,t){let n=1e-4,r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);let a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new z:new B);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new B,r=[],i=[],a=[],o=new B,s=new V;for(let t=0;t<=e;t++){let n=t/e;r[t]=this.getTangentAt(n,new B)}i[0]=new B,a[0]=new B;let c=Number.MAX_VALUE,l=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);l<=c&&(c=l,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>2**-52){o.normalize();let e=Math.acos(E(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(t===!0){let t=Math.acos(E(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this.cacheArcLengths=null,this}toJSON(){let e={metadata:{version:4.7,type:`Curve`,generator:`Curve.toJSON`}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this.cacheArcLengths=null,this}},el=class extends $c{constructor(e=0,t=0,n=1,r=1,i=0,a=Math.PI*2,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type=`EllipseCurve`,this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t=new z){let n=t,r=Math.PI*2,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)<2**-52;for(;i<0;)i+=r;for(;i>r;)i-=r;i<2**-52&&(i=a?0:r),this.aClockwise===!0&&!a&&(i===r?i=-r:i-=r);let o=this.aStartAngle+e*i,s=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){let e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=c-this.aY;s=n*e-r*t+this.aX,c=n*t+r*e+this.aY}return n.set(s,c)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},tl=class extends el{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type=`ArcCurve`}},nl=/*@__PURE__*/ new B,rl=/*@__PURE__*/ new B,il=/*@__PURE__*/ new R,al=/*@__PURE__*/ new R,ol=/*@__PURE__*/ new R,sl=class extends $c{constructor(e=[],t=!1,n=`centripetal`,r=.5){super(),this.isCatmullRomCurve3=!0,this.type=`CatmullRomCurve3`,this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new B){let n=t,r=this.points,i=r.length,a=(i-+!this.closed)*e,o=Math.floor(a),s=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:s===0&&o===i-1&&(o=i-2,s=1);let c,l;this.closed||o>0?c=r[(o-1)%i]:(rl.subVectors(r[0],r[1]).add(r[0]),c=rl);let u=r[o%i],d=r[(o+1)%i];if(this.closed||o+2<i?l=r[(o+2)%i]:(nl.subVectors(r[i-1],r[i-2]).add(r[i-1]),l=nl),this.curveType===`centripetal`||this.curveType===`chordal`){let e=this.curveType===`chordal`?.5:.25,t=c.distanceToSquared(u)**+e,n=u.distanceToSquared(d)**+e,r=d.distanceToSquared(l)**+e;n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),il.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,t,n,r),al.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,t,n,r),ol.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,t,n,r)}else this.curveType===`catmullrom`&&(il.initCatmullRom(c.x,u.x,d.x,l.x,this.tension),al.initCatmullRom(c.y,u.y,d.y,l.y,this.tension),ol.initCatmullRom(c.z,u.z,d.z,l.z,this.tension));return n.set(il.calc(s),al.calc(s),ol.calc(s)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new B().fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},cl=class extends $c{constructor(e=new z,t=new z,n=new z,r=new z){super(),this.isCubicBezierCurve=!0,this.type=`CubicBezierCurve`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new z){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(ze(e,r.x,i.x,a.x,o.x),ze(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ll=class extends $c{constructor(e=new B,t=new B,n=new B,r=new B){super(),this.isCubicBezierCurve3=!0,this.type=`CubicBezierCurve3`,this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(ze(e,r.x,i.x,a.x,o.x),ze(e,r.y,i.y,a.y,o.y),ze(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ul=class extends $c{constructor(e=new z,t=new z){super(),this.isLineCurve=!0,this.type=`LineCurve`,this.v1=e,this.v2=t}getPoint(e,t=new z){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new z){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},dl=class extends $c{constructor(e=new B,t=new B){super(),this.isLineCurve3=!0,this.type=`LineCurve3`,this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new B){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},fl=class extends $c{constructor(e=new z,t=new z,n=new z){super(),this.isQuadraticBezierCurve=!0,this.type=`QuadraticBezierCurve`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new z){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Pe(e,r.x,i.x,a.x),Pe(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},pl=class extends $c{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve3=!0,this.type=`QuadraticBezierCurve3`,this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Pe(e,r.x,i.x,a.x),Pe(e,r.y,i.y,a.y),Pe(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ml=class extends $c{constructor(e=[]){super(),this.isSplineCurve=!0,this.type=`SplineCurve`,this.points=e}getPoint(e,t=new z){let n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[a===0?a:a-1],c=r[a],l=r[a>r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Ae(o,s.x,c.x,l.x,u.x),Ae(o,s.y,c.y,l.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let n=e.points[t];this.points.push(new z().fromArray(n))}return this}},hl=/*#__PURE__*/ Object.freeze({__proto__:null,ArcCurve:tl,CatmullRomCurve3:sl,CubicBezierCurve:cl,CubicBezierCurve3:ll,EllipseCurve:el,LineCurve:ul,LineCurve3:dl,QuadraticBezierCurve:fl,QuadraticBezierCurve3:pl,SplineCurve:ml}),gl=class extends $c{constructor(){super(),this.type=`CurvePath`,this.curves=[],this.autoClose=!1,this.cacheLengths=null}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?`LineCurve`:`LineCurve3`;this.curves.push(new hl[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),i=0;for(;i<r.length;){if(r[i]>=n){let e=r[i]-n,a=this.curves[i],o=a.getLength(),s=o===0?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,i=this.curves;r<i.length;r++){let a=i[r],o=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){let r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this.cacheLengths=null,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let n=e.curves[t];this.curves.push(new hl[n.type]().fromJSON(n))}return this.cacheLengths=null,this}},_l=class extends gl{constructor(e){super(),this.type=`Path`,this.currentPoint=new z,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new ul(this.currentPoint.clone(),new z(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let i=new fl(this.currentPoint.clone(),new z(e,t),new z(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){let o=new cl(this.currentPoint.clone(),new z(e,t),new z(n,r),new z(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new ml(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){let o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){let c=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+c,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){let c=new el(e,t,n,r,i,a,o,s);if(this.curves.length>0){let e=c.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(c);let l=c.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},vl=class extends _l{constructor(e){super(e),this.uuid=T(),this.type=`Shape`,this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let n=e.holes[t];this.holes.push(new _l().fromJSON(n))}return this}},yl=class{static triangulate(e,t,n=2){return Be(e,t,n)}},bl=class e{static area(e){let t=e.length,n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return n*.5}static isClockWise(t){return e.area(t)<0}static triangulateShape(e,t){let n=[],r=[],i=[];yt(e),bt(n,e);let a=e.length;t.forEach(yt);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,bt(n,t[e]);let o=yl.triangulate(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}},xl=class e extends G{constructor(e=new vl([new z(.5,.5),new z(-.5,.5),new z(-.5,-.5),new z(.5,-.5)]),t={}){super(),this.type=`ExtrudeGeometry`,this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];a(n)}this.setAttribute(`position`,new W(r,3)),this.setAttribute(`uv`,new W(i,2)),this.computeVertexNormals();function a(e){let a=[],o=t.curveSegments===void 0?12:t.curveSegments,s=t.steps===void 0?1:t.steps,c=t.depth===void 0?1:t.depth,l=t.bevelEnabled===void 0||t.bevelEnabled,u=t.bevelThickness===void 0?.2:t.bevelThickness,d=t.bevelSize===void 0?u-.1:t.bevelSize,f=t.bevelOffset===void 0?0:t.bevelOffset,p=t.bevelSegments===void 0?3:t.bevelSegments,m=t.extrudePath,h=t.UVGenerator===void 0?Sl:t.UVGenerator,g,_=!1,v,y,b,x;if(m){g=m.getSpacedPoints(s),_=!0,l=!1;let e=m.isCatmullRomCurve3?m.closed:!1;v=m.computeFrenetFrames(s,e),y=new B,b=new B,x=new B}l||(p=0,u=0,d=0,f=0);let C=e.extractPoints(o),w=C.shape,T=C.holes;if(!bl.isClockWise(w)){w=w.reverse();for(let e=0,t=T.length;e<t;e++){let t=T[e];bl.isClockWise(t)&&(T[e]=t.reverse())}}function E(e){let t=e[0];for(let n=1;n<=e.length;n++){let r=n%e.length,i=e[r],a=i.x-t.x,o=i.y-t.y,s=a*a+o*o,c=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(t.x),Math.abs(t.y));s<=10000000000000001e-36*c*c?(e.splice(r,1),n--):t=i}}E(w),T.forEach(E);let D=T.length,O=w;for(let e=0;e<D;e++){let t=T[e];w=w.concat(t)}function k(e,t,n){return t||S(`ExtrudeGeometry: vec does not exist`),e.clone().addScaledVector(t,n)}let A=w.length;function j(e,t,n){let r,i,a,o=e.x-t.x,s=e.y-t.y,c=n.x-e.x,l=n.y-e.y,u=o*o+s*s,d=o*l-s*c;if(Math.abs(d)>2**-52){let d=Math.sqrt(u),f=Math.sqrt(c*c+l*l),p=t.x-s/d,m=t.y+o/d,h=n.x-l/f,g=n.y+c/f,_=((h-p)*l-(g-m)*c)/(o*l-s*c);r=p+o*_-e.x,i=m+s*_-e.y;let v=r*r+i*i;if(v<=2)return new z(r,i);a=Math.sqrt(v/2)}else{let e=!1;o>2**-52?c>2**-52&&(e=!0):o<-(2**-52)?c<-(2**-52)&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new z(r/a,i/a)}let M=[];for(let e=0,t=O.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),M[e]=j(O[e],O[n],O[r]);let N=[],P,F=M.concat();for(let e=0,t=D;e<t;e++){let t=T[e];P=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),P[e]=j(t[e],t[r],t[i]);N.push(P),F=F.concat(P)}let ee;if(p===0)ee=bl.triangulateShape(O,T);else{let e=[],t=[];for(let n=0;n<p;n++){let r=n/p,i=u*Math.cos(r*Math.PI/2),a=d*Math.sin(r*Math.PI/2)+f;for(let t=0,n=O.length;t<n;t++){let n=k(O[t],M[t],a);I(n.x,n.y,-i),r===0&&e.push(n)}for(let e=0,n=D;e<n;e++){let n=T[e];P=N[e];let o=[];for(let e=0,t=n.length;e<t;e++){let t=k(n[e],P[e],a);I(t.x,t.y,-i),r===0&&o.push(t)}r===0&&t.push(o)}}ee=bl.triangulateShape(e,t)}let te=ee.length,ne=d+f;for(let e=0;e<A;e++){let t=l?k(w[e],F[e],ne):w[e];_?(b.copy(v.normals[0]).multiplyScalar(t.x),y.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(b).add(y),I(x.x,x.y,x.z)):I(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<A;t++){let n=l?k(w[t],F[t],ne):w[t];_?(b.copy(v.normals[e]).multiplyScalar(n.x),y.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(b).add(y),I(x.x,x.y,x.z)):I(n.x,n.y,c/s*e)}for(let e=p-1;e>=0;e--){let t=e/p,n=u*Math.cos(t*Math.PI/2),r=d*Math.sin(t*Math.PI/2)+f;for(let e=0,t=O.length;e<t;e++){let t=k(O[e],M[e],r);I(t.x,t.y,c+n)}for(let e=0,t=T.length;e<t;e++){let t=T[e];P=N[e];for(let e=0,i=t.length;e<i;e++){let i=k(t[e],P[e],r);_?I(i.x,i.y+g[s-1].y,g[s-1].x+n):I(i.x,i.y,c+n)}}}re(),ie();function re(){let e=r.length/3;if(l){let e=0,t=A*e;for(let e=0;e<te;e++){let n=ee[e];oe(n[2]+t,n[1]+t,n[0]+t)}e=s+p*2,t=A*e;for(let e=0;e<te;e++){let n=ee[e];oe(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<te;e++){let t=ee[e];oe(t[2],t[1],t[0])}for(let e=0;e<te;e++){let t=ee[e];oe(t[0]+A*s,t[1]+A*s,t[2]+A*s)}}n.addGroup(e,r.length/3-e,0)}function ie(){let e=r.length/3,t=0;ae(O,t),t+=O.length;for(let e=0,n=T.length;e<n;e++){let n=T[e];ae(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}function ae(e,t){let n=e.length;for(;--n>=0;){let r=n,i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+p*2;e<n;e++){let n=A*e,a=A*(e+1);se(t+r+n,t+i+n,t+i+a,t+r+a)}}}function I(e,t,n){a.push(e),a.push(t),a.push(n)}function oe(e,t,i){ce(e),ce(t),ce(i);let a=r.length/3,o=h.generateTopUV(n,r,a-3,a-2,a-1);le(o[0]),le(o[1]),le(o[2])}function se(e,t,i,a){ce(e),ce(t),ce(a),ce(t),ce(i),ce(a);let o=r.length/3,s=h.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);le(s[0]),le(s[1]),le(s[3]),le(s[1]),le(s[2]),le(s[3])}function ce(e){r.push(a[e*3+0]),r.push(a[e*3+1]),r.push(a[e*3+2])}function le(e){i.push(e.x),i.push(e.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return xt(t,n,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new hl[i.type]().fromJSON(i)),new e(r,t.options)}},Sl={generateTopUV:function(e,t,n,r,i){let a=t[n*3],o=t[n*3+1],s=t[r*3],c=t[r*3+1],l=t[i*3],u=t[i*3+1];return[new z(a,o),new z(s,c),new z(l,u)]},generateSideWallUV:function(e,t,n,r,i,a){let o=t[n*3],s=t[n*3+1],c=t[n*3+2],l=t[r*3],u=t[r*3+1],d=t[r*3+2],f=t[i*3],p=t[i*3+1],m=t[i*3+2],h=t[a*3],g=t[a*3+1],_=t[a*3+2];return Math.abs(s-u)<Math.abs(o-l)?[new z(o,1-c),new z(l,1-d),new z(f,1-m),new z(h,1-_)]:[new z(s,1-c),new z(u,1-d),new z(p,1-m),new z(g,1-_)]}},Cl=class e extends Kc{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];super(r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type=`IcosahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},wl=class e extends G{constructor(e=[new z(0,-.5),new z(.5,0),new z(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type=`LatheGeometry`,this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=E(r,0,Math.PI*2);let i=[],a=[],o=[],s=[],c=[],l=1/t,u=new B,d=new z,f=new B,p=new B,m=new B,h=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,m.copy(f),f.normalize(),s.push(f.x,f.y,f.z);break;case e.length-1:m.normalize(),s.push(m.x,m.y,m.z);break;default:h=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,f.x=g*1,f.y=-h,f.z=g*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),s.push(f.x,f.y,f.z),m.copy(p)}for(let i=0;i<=t;i++){let f=n+i*l*r,p=Math.sin(f),m=Math.cos(f);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*m,a.push(u.x,u.y,u.z),d.x=i/t,d.y=n/(e.length-1),o.push(d.x,d.y);let r=s[3*n+0]*p,l=s[3*n+1],f=s[3*n+0]*m;c.push(r,l,f)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){let r=t+n*e.length,a=r,o=r+e.length,s=r+e.length+1,c=r+1;i.push(a,o,c),i.push(s,c,o)}this.setIndex(i),this.setAttribute(`position`,new W(a,3)),this.setAttribute(`uv`,new W(o,2)),this.setAttribute(`normal`,new W(c,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.points,t.segments,t.phiStart,t.phiLength)}},Tl=class e extends Kc{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type=`OctahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},El=class e extends G{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new W(p,3)),this.setAttribute(`normal`,new W(m,3)),this.setAttribute(`uv`,new W(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},Dl=class e extends G{constructor(e=.5,t=1,n=32,r=1,i=0,a=Math.PI*2){super(),this.type=`RingGeometry`,this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:i,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);let o=[],s=[],c=[],l=[],u=e,d=(t-e)/r,f=new B,p=new z;for(let e=0;e<=r;e++){for(let e=0;e<=n;e++){let r=i+e/n*a;f.x=u*Math.cos(r),f.y=u*Math.sin(r),s.push(f.x,f.y,f.z),c.push(0,0,1),p.x=(f.x/t+1)/2,p.y=(f.y/t+1)/2,l.push(p.x,p.y)}u+=d}for(let e=0;e<r;e++){let t=e*(n+1);for(let e=0;e<n;e++){let r=e+t,i=r,a=r+n+1,s=r+n+2,c=r+1;o.push(i,a,c),o.push(a,s,c)}}this.setIndex(o),this.setAttribute(`position`,new W(s,3)),this.setAttribute(`normal`,new W(c,3)),this.setAttribute(`uv`,new W(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},Ol=class e extends G{constructor(e=new vl([new z(0,.5),new z(-.5,-.5),new z(.5,-.5)]),t=12){super(),this.type=`ShapeGeometry`,this.parameters={shapes:e,curveSegments:t};let n=[],r=[],i=[],a=[],o=0,s=0;if(Array.isArray(e)===!1)c(e);else for(let t=0;t<e.length;t++)c(e[t]),this.addGroup(o,s,t),o+=s,s=0;this.setIndex(n),this.setAttribute(`position`,new W(r,3)),this.setAttribute(`normal`,new W(i,3)),this.setAttribute(`uv`,new W(a,2));function c(e){let o=r.length/3,c=e.extractPoints(t),l=c.shape,u=c.holes;bl.isClockWise(l)===!1&&(l=l.reverse());for(let e=0,t=u.length;e<t;e++){let t=u[e];bl.isClockWise(t)===!0&&(u[e]=t.reverse())}let d=bl.triangulateShape(l,u);for(let e=0,t=u.length;e<t;e++){let t=u[e];l=l.concat(t)}for(let e=0,t=l.length;e<t;e++){let t=l[e];r.push(t.x,t.y,0),i.push(0,0,1),a.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){let t=d[e],r=t[0]+o,i=t[1]+o,a=t[2]+o;n.push(r,i,a),s+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return St(t,e)}static fromJSON(t,n){let r=[];for(let e=0,i=t.shapes.length;e<i;e++){let i=n[t.shapes[e]];r.push(i)}return new e(r,t.curveSegments)}},kl=class e extends G{constructor(e=1,t=32,n=16,r=0,i=Math.PI*2,a=0,o=Math.PI){super(),this.type=`SphereGeometry`,this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let s=Math.min(a+o,Math.PI),c=0,l=[],u=new B,d=new B,f=[],p=[],m=[],h=[];for(let f=0;f<=n;f++){let g=[],_=f/n,v=a+_*o,y=e*Math.cos(v),b=Math.sqrt(e*e-y*y),x=0;f===0&&a===0?x=.5/t:f===n&&s===Math.PI&&(x=-.5/t);for(let e=0;e<=t;e++){let n=e/t,a=r+n*i;u.x=-b*Math.cos(a),u.y=y,u.z=b*Math.sin(a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),h.push(n+x,1-_),g.push(c++)}l.push(g)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){let t=l[e][r+1],i=l[e][r],o=l[e+1][r],c=l[e+1][r+1];(e!==0||a>0)&&f.push(t,i,c),(e!==n-1||s<Math.PI)&&f.push(i,o,c)}this.setIndex(f),this.setAttribute(`position`,new W(p,3)),this.setAttribute(`normal`,new W(m,3)),this.setAttribute(`uv`,new W(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},Al=class e extends Kc{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type=`TetrahedronGeometry`,this.parameters={radius:e,detail:t}}static fromJSON(t){return new e(t.radius,t.detail)}},jl=class e extends G{constructor(e=1,t=.4,n=12,r=48,i=Math.PI*2,a=0,o=Math.PI*2){super(),this.type=`TorusGeometry`,this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:i,thetaStart:a,thetaLength:o},n=Math.floor(n),r=Math.floor(r);let s=[],c=[],l=[],u=[],d=new B,f=new B,p=new B;for(let s=0;s<=n;s++){let m=a+s/n*o;for(let a=0;a<=r;a++){let o=a/r*i;f.x=(e+t*Math.cos(m))*Math.cos(o),f.y=(e+t*Math.cos(m))*Math.sin(o),f.z=t*Math.sin(m),c.push(f.x,f.y,f.z),d.x=e*Math.cos(o),d.y=e*Math.sin(o),p.subVectors(f,d).normalize(),l.push(p.x,p.y,p.z),u.push(a/r),u.push(s/n)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*e+t-1,i=(r+1)*(e-1)+t-1,a=(r+1)*(e-1)+t,o=(r+1)*e+t;s.push(n,i,o),s.push(i,a,o)}this.setIndex(s),this.setAttribute(`position`,new W(c,3)),this.setAttribute(`normal`,new W(l,3)),this.setAttribute(`uv`,new W(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc,t.thetaStart,t.thetaLength)}},Ml=class e extends G{constructor(e=1,t=.4,n=64,r=8,i=2,a=3){super(),this.type=`TorusKnotGeometry`,this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:i,q:a},n=Math.floor(n),r=Math.floor(r);let o=[],s=[],c=[],l=[],u=new B,d=new B,f=new B,p=new B,m=new B,h=new B,g=new B;for(let o=0;o<=n;++o){let v=o/n*i*Math.PI*2;_(v,i,a,e,f),_(v+.01,i,a,e,p),h.subVectors(p,f),g.addVectors(p,f),m.crossVectors(h,g),g.crossVectors(m,h),m.normalize(),g.normalize();for(let e=0;e<=r;++e){let i=e/r*Math.PI*2,a=-t*Math.cos(i),p=t*Math.sin(i);u.x=f.x+(a*g.x+p*m.x),u.y=f.y+(a*g.y+p*m.y),u.z=f.z+(a*g.z+p*m.z),s.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),c.push(d.x,d.y,d.z),l.push(o/n),l.push(e/r)}}for(let e=1;e<=n;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,s=(r+1)*(e-1)+t;o.push(n,i,s),o.push(i,a,s)}this.setIndex(o),this.setAttribute(`position`,new W(s,3)),this.setAttribute(`normal`,new W(c,3)),this.setAttribute(`uv`,new W(l,2));function _(e,t,n,r,i){let a=Math.cos(e),o=Math.sin(e),s=n/t*e,c=Math.cos(s);i.x=r*(2+c)*.5*a,i.y=r*(2+c)*o*.5,i.z=r*Math.sin(s)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},Nl=class e extends G{constructor(e=new pl(new B(-1,-1,0),new B(-1,1,0),new B(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type=`TubeGeometry`,this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};let a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let o=new B,s=new B,c=new z,l=new B,u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute(`position`,new W(u,3)),this.setAttribute(`normal`,new W(d,3)),this.setAttribute(`uv`,new W(f,2));function m(){for(let e=0;e<t;e++)h(e);h(i===!1?t:0),_(),g()}function h(i){l=e.getPointAt(i/t,l);let c=a.normals[i],f=a.binormals[i];for(let e=0;e<=r;e++){let t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*c.x+i*f.x,s.y=a*c.y+i*f.y,s.z=a*c.z+i*f.z,s.normalize(),d.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,u.push(o.x,o.y,o.z)}}function g(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){let n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;p.push(n,i,o),p.push(i,a,o)}}function _(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)c.x=e/t,c.y=n/r,f.push(c.x,c.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(t){return new e(new hl[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},Pl=class extends G{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=/* @__PURE__ */ new Set,r=new B,i=new B;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),Ct(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),Ct(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new W(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fl=/*#__PURE__*/ Object.freeze({__proto__:null,BoxGeometry:Vc,CapsuleGeometry:Hc,CircleGeometry:Uc,ConeGeometry:Gc,CylinderGeometry:Wc,DodecahedronGeometry:qc,EdgesGeometry:Qc,ExtrudeGeometry:xl,IcosahedronGeometry:Cl,LatheGeometry:wl,OctahedronGeometry:Tl,PlaneGeometry:El,PolyhedronGeometry:Kc,RingGeometry:Dl,ShapeGeometry:Ol,SphereGeometry:kl,TetrahedronGeometry:Al,TorusGeometry:jl,TorusKnotGeometry:Ml,TubeGeometry:Nl,WireframeGeometry:Pl}),Il=class extends Lo{constructor(e){super(),this.isShadowMaterial=!0,this.type=`ShadowMaterial`,this.color=new H(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Ll={clone:wt,merge:Tt},Rl=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,zl=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -5793,36 +5793,285 @@ varying vec4 vShadowClip;
|
|
|
5793
5793
|
\t}
|
|
5794
5794
|
\t#include <tonemapping_fragment>`)},n.customProgramCacheKey=()=>`agent3d-shadow-catcher`,n}var OD=.45;function kD(e,t){let n=e.background;return e.fog?.color?e.fog.color:t||(n&&typeof n==`object`&&`sky`in n&&n.sky?.horizon?n.sky.horizon:n&&typeof n==`object`&&`meshGradient`in n&&n.meshGradient[0]?n.meshGradient[0]:typeof n==`string`&&n!==`transparent`?n:`#ffffff`)}async function AD(e,t,n,r,i){let a=[],o=[],s=i.renderer,c=e.background,l=!!n.isOrthographicCamera,u=null,d=0,f=null,p=null,m=null;t.background=null,t.backgroundIntensity=1,t.backgroundRotation.set(0,0,0),t.environmentRotation.set(0,0,0);let h=c&&typeof c==`object`?c:null,g=h&&`sky`in h?h.sky??{}:null;if(g&&gE(g))try{f=await wE(g)}catch(e){i.issue(`asset-load`,e.message,`environment.background.sky`)}if(!r&&c!==void 0&&c!==`transparent`){if(typeof c==`string`)t.background=AS(c);else if(`gradient`in c)t.background=_D(c.gradient,`linear`,Q(c.angle,0),{grain:c.grain});else if(`radial`in c)t.background=_D(c.radial,`radial`,0,{center:c.center,radius:c.radius,grain:c.grain});else if(`meshGradient`in c)m=c.meshGradient,a.push(vD(c.meshGradient,c,i));else if(`sky`in c){let e=c.sky??{};if(f){if(!l){a.push(f.mesh);let e=f;i.onUpdate(t=>e.setTime(t))}}else p=e,l?t.background=_D([e.bottom??e.horizon??`#e8eef5`,e.horizon??`#cfe6ff`,e.top??`#2f6fd6`],`linear`,0):a.push(xD(e,i))}else if(`hdri`in c)try{if(u=await wD(i.resolveAsset(c.hdri)),d=Q(c.rotation,0)*LS,t.backgroundRotation.set(0,d,0),t.backgroundIntensity=Q(c.intensity,1),o.push(u),c.groundProjection&&!l){let n=typeof c.groundProjection==`object`?c.groundProjection:{},{GroundedSkybox:r}=await Promise.resolve().then(()=>(fD(),uD)),i=Q(n.height,2),o=Q(n.radius,60),s=new r(u,i,o);s.position.y=i-.01+Q(e.ground?.y,0),s.rotation.y=d,s.material.color.setScalar(t.backgroundIntensity),s.name=`__groundProjection`,s.userData.helper=!0,s.renderOrder=-999,a.push(s),t.background=AS(`#000000`)}else t.background=u,t.backgroundBlurriness=Q(c.blur,0)}catch(e){i.issue(`asset-load`,e.message,`environment.background.hdri`)}t.background instanceof zi&&t.background!==u&&o.push(t.background)}t.fog=null,WT(t,null);let _=null;e.fog&&(_=AS(kD(e,f?.values.haze)),!e.fog.color&&f&&_.multiplyScalar(.82),`density`in e.fog?(t.fog=new Da(_,e.fog.density),e.fog.height!==void 0&&WT(t,{uA3dFogHeight:{value:e.fog.height},uA3dFogFalloff:{value:Q(e.fog.falloff,.25)}})):t.fog=new Oa(_,Q(e.fog.near,10),Q(e.fog.far,60)),f?.setHaze(_,.85));let v=u?{hdri:``}:f?`sky`:`soft`,y=e.lighting??v;if(t.environment=null,t.environmentIntensity=Q(e.lightingIntensity,1),s&&y!==`none`){let n=new vh(s),a=null;try{if(typeof y==`object`){let e=y.hdri?await wD(i.resolveAsset(y.hdri)):u;e&&(a=n.fromEquirectangular(e)),y.intensity!==void 0&&(t.environmentIntensity=y.intensity),t.environmentRotation.set(0,y.hdri?Q(y.rotation,0)*LS:y.rotation===void 0?d:y.rotation*LS,0),e&&e!==u&&e.dispose()}else if(y===`sky`){if(f){let e=f.envScene();a=n.fromScene(e,0,.1,100),CD(e)}else if(p){let e=p,t=e.sun===!1?void 0:e.sun,r=SD(e.top??`#2f6fd6`,e.horizon??`#cfe6ff`,e.bottom??e.horizon??`#e8eef5`,t?{dir:new B(...OS(t.direction,[.4,.35,-1])),color:t.color??`#fff2d6`,power:4,size:.9}:void 0,!1);a=n.fromScene(r,.02),CD(r)}else if(m){let e=m,t=SD(e[1]??e[0],e[0],e[2]??e[0],void 0,!0);a=n.fromScene(t,.04),CD(t)}else{let{RoomEnvironment:e}=await Promise.resolve().then(()=>(gD(),pD)),t=new e;a=n.fromScene(t,.06),t.dispose?.()}}else if(y===`studio`||y===`soft`){let{RoomEnvironment:r}=await Promise.resolve().then(()=>(gD(),pD)),i=new r;a=n.fromScene(i,y===`soft`?.06:.02),y===`soft`&&e.lightingIntensity===void 0&&(t.environmentIntensity=.8),i.dispose?.()}else{let e={neutral:[`#d8d8dc`,`#b9b9bd`,`#5a5a60`],sunset:[`#33306e`,`#ff9a5a`,`#3a2531`,{dir:new B(1,.15,-.6),color:`#ffb36b`,power:6,size:1.6}],night:[`#060a1a`,`#1d2a55`,`#05060c`,{dir:new B(-.5,.7,-.5),color:`#cfdcff`,power:3,size:.8}]},t=SD(...e[y]??e.neutral);a=n.fromScene(t,.03),CD(t)}}catch(e){i.issue(`asset-load`,e.message,`environment.lighting`)}a&&(t.environment=a.texture,o.push(a),l&&f&&!r&&(t.background=a.texture,t.backgroundBlurriness=0)),n.dispose();let c=e.lightingIntensity!==void 0||typeof y==`object`&&y.intensity!==void 0;e.rig&&!c&&(t.environmentIntensity*=OD)}let b=[],x=g&&g.sun!==!1?g.sun??{}:null;if(f&&x&&x.light!==!1){let t=bE(f.values.elevation),n=new qu(x.color?AS(x.color):t.color,Q(x.intensity,t.intensity));n.position.copy(f.sunDir).multiplyScalar(30),n.name=`__sun`,n.userData.a3dId=`sun`,x.castShadow!==!1&&n.intensity>0&&tE(n,{type:`directional`,shadow:{softness:3}},e.shadows),b.push(n)}for(let t of dE(e.rig)){let n=await oE(t,e.shadows);b.push(n)}for(let e of b)a.push(e),(e instanceof qu||e instanceof Hu)&&a.push(e.target);let S;if(e.ground){let t=e.ground,n=Q(t.size,60),r=Q(t.y,0),i=t.shadowOnly?DD(AS(t.color??`#000000`),Q(t.opacity,.28)):TD(AS(t.color??`#d9d9d9`),Q(t.roughness,.9));!t.shadowOnly&&t.opacity!==void 0&&(i.opacity=t.opacity);let o=new K(new El(n,n),i);if(o.rotation.x=-Math.PI/2,o.position.y=r,o.receiveShadow=!0,o.name=`__ground`,o.renderOrder=-20,o.userData.helper=!0,o.userData.ground=!0,a.push(o),S=o,t.grid){let e=new Mf(n,Math.round(n),AS(`#000000`),AS(`#000000`)),t=e.material;t.transparent=!0,t.opacity=.12,t.depthWrite=!1,e.position.y=r+.002,e.userData.helper=!0,a.push(e)}}if(e.contactShadows){let n=PT(e.contactShadows,t,e.ground?Q(e.ground.y,0):void 0,i);n&&(a.push(n.object),o.push(n))}return{objects:a,ground:S,dispose(){for(let e of o)e.dispose();for(let e of a)e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose?.(),e.shadow?.dispose?.()})}}}J(),W_(),Xg(),zS();function jD(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=2).map(e=>new z(Number(e[0]),Number(e[1]))):[]}function MD(e){return Array.isArray(e)?e.filter(e=>Array.isArray(e)&&e.length>=3).map(e=>new B(Number(e[0]),Number(e[1]),Number(e[2]))):[]}var ND=(e,t=`segments`,n=32)=>Math.max(3,Math.round(Q(e[t],n))),PD={box:e=>new Vc(Q(e.width,1),Q(e.height,1),Q(e.depth,1)),roundedBox:e=>{let t=Q(e.width,1),n=Q(e.height,1),r=Q(e.depth,1),i=Math.min(Q(e.radius,.1),Math.min(t,n,r)/2-1e-4);return new U_(t,n,r,Math.max(1,Math.round(Q(e.segments,4))),Math.max(0,i))},sphere:e=>new kl(Q(e.radius,.5),ND(e),Math.max(2,Math.round(Q(e.heightSegments,24)))),cylinder:e=>new Wc(Q(e.radiusTop,.5),Q(e.radiusBottom,.5),Q(e.height,1),ND(e),1,ES(e.openEnded,!1)),cone:e=>new Gc(Q(e.radius,.5),Q(e.height,1),ND(e)),capsule:e=>{let t=Math.max(2,Math.round(Q(e.segments,16)));return new Hc(Q(e.radius,.3),Q(e.length,.6),Math.max(2,Math.round(t/2)),t*2)},torus:e=>new jl(Q(e.radius,.5),Q(e.tube,.15),Math.max(2,Math.round(Q(e.radialSegments,24))),Math.max(3,Math.round(Q(e.tubularSegments,64))),Q(e.arc,360)*LS),torusKnot:e=>new Ml(Q(e.radius,.5),Q(e.tube,.15),Math.round(Q(e.tubularSegments,128)),Math.round(Q(e.radialSegments,16)),Math.round(Q(e.p,2)),Math.round(Q(e.q,3))),plane:e=>new El(Q(e.width,1),Q(e.height,1),Math.max(1,Math.round(Q(e.widthSegments,1))),Math.max(1,Math.round(Q(e.heightSegments,1)))),circle:e=>new Uc(Q(e.radius,.5),ND(e)),ring:e=>new Dl(Q(e.innerRadius,.3),Q(e.outerRadius,.5),ND(e)),icosahedron:e=>new Cl(Q(e.radius,.5),Math.round(Q(e.detail,0))),dodecahedron:e=>new qc(Q(e.radius,.5),Math.round(Q(e.detail,0))),octahedron:e=>new Tl(Q(e.radius,.5),Math.round(Q(e.detail,0))),tetrahedron:e=>new Al(Q(e.radius,.5),Math.round(Q(e.detail,0))),lathe:e=>{let t=jD(e.points);return t.length<2&&(t=[new z(.5,-.5),new z(.5,.5)]),new wl(t,ND(e))},extrude:e=>{let t=jD(e.shape);t.length<3&&(t=[new z(-.5,-.5),new z(.5,-.5),new z(0,.5)]);let n=new vl(t),r=Q(e.depth,.2),i=Q(e.bevel,.02),a=new xl(n,{depth:r,bevelEnabled:i>0,bevelSize:i,bevelThickness:i,bevelSegments:3,curveSegments:12});return a.translate(0,0,-r/2),a},tube:e=>{let t=MD(e.points);t.length<2&&(t=[new B(-1,0,0),new B(1,0,0)]);let n=new sl(t,ES(e.closed,!1),`catmullrom`,.5);return new Nl(n,Math.max(2,Math.round(Q(e.tubularSegments,64))),Q(e.radius,.05),Math.max(3,Math.round(Q(e.radialSegments,8))),ES(e.closed,!1))}};function FD(e){let t=(PD[e.type]??PD.box)(jS(Og.find(t=>t.id===e.type),e));return t.computeBoundingBox(),t.computeBoundingSphere(),t}J(),zS();function ID(e,t){let n=[],r=(e,t=new na,r=new B(1,1,1))=>n.push({position:e,rotation:t,scale:r});switch(e.type){case`grid`:{let[t,n,i]=e.count.map(e=>Math.max(1,Math.round(e))),[a,o,s]=e.spacing;for(let e=0;e<t;e++)for(let c=0;c<n;c++)for(let l=0;l<i;l++)r(new B((e-(t-1)/2)*a,(c-(n-1)/2)*o,(l-(i-1)/2)*s));break}case`scatter`:{let n=Q(e.minScale,1),i=Q(e.maxScale,1),[a,o,s]=e.area;for(let c=0;c<Math.max(0,Math.round(e.count));c++){let c=new B(t.range(-a/2,a/2),t.range(-o/2,o/2),t.range(-s/2,s/2)),l=e.randomRotation===!1?new na:new na(0,t.range(0,Math.PI*2),0),u=t.range(n,i);r(c,l,new B(u,u,u))}break}case`circle`:{let t=Math.max(1,Math.round(e.count));for(let n=0;n<t;n++){let i=n/t*Math.PI*2;r(new B(Math.cos(i)*e.radius,0,Math.sin(i)*e.radius),new na(0,-i,0))}break}case`list`:for(let t of e.items){let e=t.position??[0,0,0],n=t.rotation??[0,0,0],i=t.scale??1;r(new B(...e),new na(n[0]*LS,n[1]*LS,n[2]*LS),typeof i==`number`?new B(i,i,i):new B(...i))}}return n}function LD(e,t,n,r,i){let a=ID(e.layout,r),o=new Hs(t,n,Math.max(1,a.length));o.count=a.length;let s=new V,c=new wi;if(a.forEach((e,t)=>{s.compose(e.position,c.setFromEuler(e.rotation),e.scale),o.setMatrixAt(t,s)}),e.colors?.length){let t=e.layout.type===`scatter`;a.forEach((n,a)=>o.setColorAt(a,i(t?r.pick(e.colors):e.colors[a%e.colors.length]))),o.instanceColor&&(o.instanceColor.needsUpdate=!0)}return o.instanceMatrix.needsUpdate=!0,o.computeBoundingBox(),o.computeBoundingSphere(),o}function RD(e,t,n=4,r=256){let i=[];for(let a of e.curves){let e=a.isLineCurve?1:Math.max(n,Math.min(r,Math.ceil(a.getLength()/t))),o=a.getPoints(e);for(let e of o)i.length&&i[i.length-1].equals(e)||i.push(e)}return e.autoClose&&i.length>1&&!i[0].equals(i[i.length-1])&&i.push(i[0].clone()),i}function zD(e,t,n=4,r=256){let i=e=>(e.length>2&&e[0].equals(e[e.length-1])&&e.pop(),e),a=new vl(i(RD(e,t,n,r)));return a.holes=e.holes.map(e=>new _l(i(RD(e,t,n,r)))),a}function BD(e,t,n){let r=n.toCreasedNormals(e,t);r!==e&&e.dispose();let i=r.getAttribute(`position`),a=r.getAttribute(`normal`),o=new B,s=new B,c=new B;for(let e=0;e+2<i.count;e+=3){o.fromBufferAttribute(i,e),s.fromBufferAttribute(i,e+1).sub(o),c.fromBufferAttribute(i,e+2).sub(o);let t=s.cross(c),n=t.length();if(n<1e-12)continue;let r=t.z/n;if(Math.abs(r)>.9999)for(let t=0;t<3;t++)a.setXYZ(e+t,0,0,Math.sign(r))}return a.needsUpdate=!0,r}function VD(e,t){let n=e.index?e.toNonIndexed():e,r=n.getAttribute(`position`),i=r.count-r.count%3;n.computeBoundingBox();let a=n.boundingBox,o=Math.max(a.max.x-a.min.x,a.max.y-a.min.y,1e-9)*1e-6,s=/* @__PURE__ */ new Map,c=[],l=e=>{let t=r.getX(e),n=r.getY(e),i=`${Math.round(t/o)},${Math.round(n/o)}`,a=s.get(i);return a===void 0&&(a=c.length,s.set(i,a),c.push([t,n])),a},u=[];for(let e=0;e<i;e+=3){let t=l(e),n=l(e+1),r=l(e+2);if(t===n||n===r||t===r)continue;let i=(c[n][0]-c[t][0])*(c[r][1]-c[t][1])-(c[r][0]-c[t][0])*(c[n][1]-c[t][1]);Math.abs(i)<o*o||(i<0&&([n,r]=[r,n]),u.push([t,n,r]))}let d=/* @__PURE__ */ new Map;for(let[e,t,n]of u)for(let[r,i]of[[e,t],[t,n],[n,e]]){let e=r<i?`${r}_${i}`:`${i}_${r}`,t=d.get(e);t?t.count++:d.set(e,{a:r,b:i,count:1})}let f=[],p=[],m=[],h=Math.max(a.max.x-a.min.x,1e-9),g=Math.max(a.max.y-a.min.y,1e-9),_=(e,t,n,r,i,o,s,c)=>{f.push(e,t,n),p.push(r,i,o),m.push(s??(e-a.min.x)/h,c??(t-a.min.y)/g)};for(let[e,n,r]of u){for(let i of[e,n,r])_(c[i][0],c[i][1],t,0,0,1);for(let t of[e,r,n])_(c[t][0],c[t][1],0,0,0,-1)}if(t>0)for(let e of d.values()){if(e.count!==1)continue;let[n,r]=c[e.a],[i,a]=c[e.b],s=i-n,l=a-r,u=Math.hypot(s,l);if(u<o)continue;let d=l/u,f=-s/u;_(n,r,0,d,f,0,0,0),_(i,a,0,d,f,0,1,0),_(i,a,t,d,f,0,1,1),_(n,r,0,d,f,0,0,0),_(i,a,t,d,f,0,1,1),_(n,r,t,d,f,0,0,1)}n!==e&&n.dispose();let v=new G;return v.setAttribute(`position`,new W(f,3)),v.setAttribute(`normal`,new W(p,3)),v.setAttribute(`uv`,new W(m,2)),v}var HD=t((()=>{J()})),UD=/* @__PURE__ */ n({Font:()=>qD,FontLoader:()=>KD});function WD(e,t,n,r){let i=Array.from(e),a=t/n.resolution,o=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*a,s=[],c=0,l=0;(r==`rtl`||r==`tb`)&&i.reverse();for(let e=0;e<i.length;e++){let t=i[e];if(t===`
|
|
5795
5795
|
`)c=0,l-=o;else{let e=GD(t,a,c,l,n);r==`tb`?(c=0,l+=n.ascender*a):c+=e.offsetX,s.push(e.path)}}return s}function GD(e,t,n,r,i){let a=i.glyphs[e]||i.glyphs[`?`];if(!a){console.error(`THREE.Font: character "`+e+`" does not exists in font family `+i.familyName+`.`);return}let o=new Xf,s,c,l,u,d,f,p,m;if(a.o){let e=a._cachedOutline||=a.o.split(` `);for(let i=0,a=e.length;i<a;)switch(e[i++]){case`m`:s=e[i++]*t+n,c=e[i++]*t+r,o.moveTo(s,c);break;case`l`:s=e[i++]*t+n,c=e[i++]*t+r,o.lineTo(s,c);break;case`q`:l=e[i++]*t+n,u=e[i++]*t+r,d=e[i++]*t+n,f=e[i++]*t+r,o.quadraticCurveTo(d,f,l,u);break;case`b`:l=e[i++]*t+n,u=e[i++]*t+r,d=e[i++]*t+n,f=e[i++]*t+r,p=e[i++]*t+n,m=e[i++]*t+r,o.bezierCurveTo(d,f,p,m,l,u)}}return{offsetX:a.ha*t,path:o}}var KD,qD,JD=t((()=>{J(),KD=class extends gu{constructor(e){super(e)}load(e,t,n,r){let i=this,a=new yu(this.manager);a.setPriority(this.priority),a.setCache(this.cache),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){let n=i.parse(JSON.parse(e));t&&t(n)},n,r)}parse(e){return new qD(e)}},qD=class{constructor(e){this.isFont=!0,this.type=`Font`,this.data=e}generateShapes(e,t=100,n=`ltr`){let r=[],i=WD(e,t,this.data,n);for(let e=0,t=i.length;e<t;e++)r.push(...i[e].toShapes());return r}}})),YD=/* @__PURE__ */ n({REVEAL_EFFECTS:()=>bO,buildText:()=>gO,buildTextGeometry:()=>_O,depthTwin:()=>pO,fontUrl:()=>mO,kerningOf:()=>ZD,layoutText:()=>QD,loadFont:()=>XD,offsetRing:()=>oO,offsetShapes:()=>sO,outlineSpec:()=>iO,revealDelay:()=>dO,revealImpl:()=>fO,textGeometry:()=>lO,textMetrics:()=>eO});function XD(e){let t=vO.get(e);return t||(t=Promise.all([Promise.resolve().then(()=>(JD(),UD)),hg(e)]).then(([e,t])=>new e.FontLoader().parse(t)),t.catch(()=>vO.delete(e)),vO.set(e,t)),t}function ZD(e,t,n){let r=e.kerning;if(!r)return 0;let i=r[t]?.[n];if(i!==void 0)return i;let a=yO(t),o=yO(n);return a===t&&o===n?0:r[a]?.[o]??0}function QD(e,t){let n=t.em/e.resolution,r=Q(t.letterSpacing,0),i=Q(t.lineHeight,1.25)*t.em,a=t.kerning!==!1,o=t=>(e.glyphs[t]??e.glyphs[`?`])?.ha??e.resolution*.5,s=t=>{let i=[],s=0;return t.forEach((c,l)=>{l>0&&(s+=r+(a?ZD(e,t[l-1],c)*n:0)),i.push(s),s+=o(c)*n}),{xs:i,width:s}},c=[],l=typeof t.maxWidth==`number`&&t.maxWidth>0?t.maxWidth:1/0;for(let e of String(t.text??``).split(`
|
|
5796
|
-
`)){if(l===1/0){c.push(Array.from(e));continue}let t=e.split(/ +/),n=[];for(let e of t){let t=n.length?[...n,` `,...Array.from(e)]:Array.from(e);n.length&&s(t).width>l?(c.push(n),n=Array.from(e)):n=t}c.push(n)}let u=[],d=[],f=0;return c.forEach((e,n)=>{for(;e.length&&e[e.length-1]===` `;)e.pop();let{xs:r,width:a}=s(e);f=Math.max(f,a);let o=t.align===`left`?0:t.align===`right`?-a:-a/2;e.forEach((e,t)=>{e.trim()&&u.push({ch:e,x:r[t]+o,line:n})}),d.push({width:a,y:-n*i})}),{glyphs:u,lines:d,lineHeight:i,width:f}}function $D(e){let t=e.data;if(t.capHeight&&t.resolution)return t.capHeight/t.resolution;let n=e.generateShapes(`H`,1);if(!n.length)return .72;let r=new Ol(n);r.computeBoundingBox();let i=r.boundingBox.max.y-r.boundingBox.min.y;return r.dispose(),i>0?i:.72}function eO(e,t){let n=e.data,r=Q(t.size,1),i=r/$D(e),a=Math.max(0,Q(t.depth,.2)),o=a>0?Math.max(0,Math.min(Q(t.bevel,Math.min(a*.3,r*.035)),a*.45,r*.08)):0,s=Math.round(Math.max(2,Math.min(32,Q(t.curveSegments,a>0?5+r*3:8+r*4)))),c=QD(n,{text:t.text,em:i,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,align:t.align??`center`,maxWidth:t.maxWidth,kerning:t.kerning});return{size:r,em:i,depth:a,bevel:o,curveSegments:s,layout:c,offsetY:-(r+(c.lines.length?c.lines[c.lines.length-1].y:0))/2,frontZ:a/2,backZ:-a/2}}function tO(e){let t=e.bevel;return{depth:Math.max(e.depth-t*2,1e-4),curveSegments:e.curveSegments,bevelEnabled:t>0,bevelThickness:t,bevelSize:t*.6,bevelOffset:0,bevelSegments:3}}function nO(e,t,n){let r=n.em/(n.curveSegments*5);return e.generateShapes(t,n.em).map(e=>zD(e,r,1,n.curveSegments))}function rO(e,t,n,r){let i=nO(e,t,n);if(!i.length)return null;if(n.depth<=0)return new Ol(i,n.curveSegments);let a=new xl(i,tO(n));return a.translate(0,0,n.backZ+n.bevel),a.clearGroups(),BD(a,50*Math.PI/180,r)}function iO(e,t){let n=e.outline;if(!n)return null;let r=n===!0?{}:n,i=Math.max(1e-4,Q(r.width,t.size*.06)),a=t.depth>0?t.depth*.5:t.size*.01,o=t.frontZ-a;return{width:i,frontZ:o,backZ:o-Math.max(Q(r.depth,t.depth>0?t.depth*.6:t.size*.01),1e-4),material:r.material,color:r.color??`#111111`}}function aO(e){let t=0;for(let n=0,r=e.length-1;n<e.length;r=n++)t+=(e[r].x-e[n].x)*(e[r].y+e[n].y);return t/2}function oO(e,t,n=2){let r=e.filter((t,n)=>{let r=e[(n+1)%e.length];return Math.hypot(r.x-t.x,r.y-t.y)>1e-9}),i=r.length,a=[];if(i<3)return r.map(e=>new z(e.x,e.y));let o=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.hypot(n,r)||1;return{x:r/i,y:-n/i}};for(let e=0;e<i;e++){let s=r[(e-1+i)%i],c=r[e],l=r[(e+1)%i],u=o(s,c),d=o(c,l),f=(c.x-s.x)*(l.y-c.y)-(c.y-s.y)*(l.x-c.x),p=u.x*d.x+u.y*d.y;if(f>0&&p<.995){let e=Math.atan2(u.y,u.x),n=Math.atan2(d.y,d.x);for(;n<e;)n+=Math.PI*2;for(;n>e+Math.PI*2;)n-=Math.PI*2;let r=Math.max(1,Math.ceil(Math.abs(n-e)/(Math.PI/8)));for(let i=0;i<=r;i++){let o=e+(n-e)*i/r;a.push(new z(c.x+Math.cos(o)*t,c.y+Math.sin(o)*t))}}else{let e=u.x+d.x,r=u.y+d.y,i=Math.hypot(e,r)||1;e/=i,r/=i;let o=Math.max(e*u.x+r*u.y,1/n);a.push(new z(c.x+e*t/o,c.y+r*t/o))}}return a}function sO(e,t){let n=[];for(let r of e){let{shape:e,holes:i}=r.extractPoints(1),a=e.slice();aO(a)<0&&(a=a.reverse());let o=new vl(oO(a,t));for(let e of i){let n=e.slice(),r=Math.abs(aO(n));aO(n)>0&&(n=n.reverse());let i=n.map(e=>e.x),a=n.map(e=>e.y);if(Math.max(...i)-Math.min(...i)<=2*t||Math.max(...a)-Math.min(...a)<=2*t)continue;let s=oO(n,t),c=aO(s);c<0&&-c>r*.02&&o.holes.push(new _l(s))}n.push(o)}return n}function cO(e,t,n,r,i){let a=nO(e,t,n);if(!a.length)return null;let o=new xl(sO(a,r.width),{depth:r.frontZ-r.backZ,curveSegments:1,bevelEnabled:!1});return o.translate(0,0,r.backZ),o.clearGroups(),BD(o,40*Math.PI/180,i)}function lO(e,t,n){let r=eO(e,t);return uO(r,t=>rO(e,t,r,n),n)}function uO(e,t,n){let r=/* @__PURE__ */ new Map,i=[];for(let n of e.layout.glyphs){r.has(n.ch)||r.set(n.ch,t(n.ch));let a=r.get(n.ch);if(!a)continue;let o=a.clone();o.translate(n.x,e.layout.lines[n.line].y+e.offsetY,0),i.push(o)}for(let e of r.values())e?.dispose();let a;if(!i.length)a=new G;else{a=(i.length===1?i[0].clone():n.mergeGeometries(i,!1))??new G;for(let e of i)e.dispose()}return a.computeBoundingBox(),a.computeBoundingSphere(),a}function dO(e,t,n){let r=Q(e.stagger,.04),i=t;if(e.order===`reverse`)i=n-1-t;else if(e.order===`center`)i=Math.abs(t-(n-1)/2);else if(e.order===`random`){let e=(t+1)*2654435761;e=(e^e>>>13)>>>0,i=e%1e3/1e3*(n-1)}return Q(e.delay,0)+i*r}function fO(e,t){return(n,r)=>{let i=e.effect??`rise`,a=Math.max(Q(e.duration,.6),.001),o=e.ease??(i===`scale`||i===`spin`?`outBack`:`outCubic`),s=i!==`scale`,c=[],l=[];if(s){let e=[];r.object.traverse(t=>{let n=t.material;if(n&&!t.userData.depthTwin){e.push(t);for(let e of Array.isArray(n)?n:[n])e.userData.baseOpacity===void 0&&(e.userData.baseOpacity=e.opacity),e.userData.baseTransparent===void 0&&(e.userData.baseTransparent=e.transparent),c.push(e)}});for(let t of e)l.push(pO(t))}return{update(e){let n=Math.min(Math.max(e/a,0),1),u=eS(o,n),d=r.object;if(s){let e=eS(`outCubic`,Math.min(1,n*1.6));for(let t of c)t.opacity=t.userData.baseOpacity*e,t.transparent=e<1||t.userData.baseTransparent;for(let t of l)t.visible=e>0&&e<1}switch(n<=0&&(d.visible=!1),i){case`rise`:d.position.y-=(1-u)*t*.6;break;case`drop`:d.position.y+=(1-u)*t*1.2;break;case`scale`:d.scale.multiplyScalar(Math.max(1e-4,u));break;case`spin`:d.rotation.y+=(1-u)*Math.PI,d.scale.multiplyScalar(Math.max(1e-4,Math.min(1,n*2)))}}}}}function pO(e){xO??=new ss({colorWrite:!1,depthWrite:!0});let t=new K(e.geometry,xO);return t.name=`${e.name}#depth`,t.visible=!1,t.castShadow=!1,t.receiveShadow=!1,t.renderOrder=-1,t.userData.helper=!0,t.userData.depthTwin=!0,e.add(t),t}function mO(e,t){let n=e.font??`sans-bold`;return t.resolveAsset(n.includes(`/`)||n.includes(`:`)?n:`library:fonts/${n}`)}function hO(e,t,n){let r=e.userData.gradient;r&&(r.uGradMin.value=t,r.uGradMax.value=n)}async function gO(e,t){let[n,r]=await Promise.all([XD(mO(e,t)),Promise.resolve().then(()=>(Wv(),kv))]),i=eO(n,e),a=iO(e,i),o=!!e.splitLetters||!!e.reveal,s=i.depth<=0,c=()=>yw(e.material,t,{defaultColor:`#ffffff`}),l=()=>a?yw(a.material??{color:a.color,roughness:.55},t):null,u=(i.layout.lines.length?i.layout.lines[i.layout.lines.length-1].y:0)+i.offsetY,d=i.size+i.offsetY,f=e=>(s&&(e.side=2),e);if(!o){let t=uO(i,e=>rO(n,e,i,r),r),o=f(await c());hO(o,u,d);let s=new K(t,o);if(a){let t=uO(i,e=>cO(n,e,i,a,r),r),o=await l();if(o){hO(o,u,d);let n=new K(t,o);n.name=`${e.id}/outline`,s.add(n)}}return{object:s,letters:[]}}let p=new ba,m=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map,g=i.size/2,_=[],v=i.layout.glyphs.length,y=0;for(let t of i.layout.glyphs){if(!m.has(t.ch)){let e=rO(n,t.ch,i,r),o=0;if(e&&(e.computeBoundingBox(),o=(e.boundingBox.min.x+e.boundingBox.max.x)/2,e.translate(-o,-g,0),e.computeBoundingSphere()),m.set(t.ch,e),a){let e=cO(n,t.ch,i,a,r);e?.translate(-o,-g,0),h.set(t.ch,e)}e&&(e.userData.cx=o)}let o=m.get(t.ch);if(!o)continue;let s=o.userData.cx,b=i.layout.lines[t.line].y+i.offsetY,x=f(await c());hO(x,u-b-g,d-b-g);let S=new K(o,x);S.position.set(t.x+s,b+g,0);let C=`${e.id}/${y}`;S.name=C,S.userData.a3dId=C;let w=h.get(t.ch);if(w){let e=await l();if(e){hO(e,u-b-g,d-b-g);let t=new K(w,e);t.name=`${C}/outline`,S.add(t)}}p.add(S);let T={id:C,object:S,def:{id:C,kind:`text`,text:t.ch}};e.reveal&&(T.reveal={def:{type:`appear`,when:`visible`,delay:dO(e.reveal,y,v)},impl:fO(e.reveal,i.size)}),_.push(T),y++}return{object:p,letters:_}}async function _O(e,t){let[n,r]=await Promise.all([XD(mO(e,t)),Promise.resolve().then(()=>(Wv(),kv))]);return lO(n,e,r)}var vO,yO,bO,xO,SO=t((()=>{J(),yg(),wS(),zS(),HD(),jw(),vO=/* @__PURE__ */ new Map,yO=e=>{let t=e.normalize(`NFD`);return t.length>1?t[0]:e},bO=[`rise`,`fade`,`scale`,`spin`,`drop`],xO=null})),CO=/* @__PURE__ */ n({SVGLoader:()=>OO});function wO(e,t,n=256){if(!e||!Array.isArray(e.stops)||e.stops.length===0)return null;let r=t.userData.transform,i=e.gradientUnits===`objectBoundingBox`,a=null;if(i&&(a=TO(t,r),a===null))return null;function o(t,n,o){o.set(t,n,1),e.gradientTransform&&o.applyMatrix3(e.gradientTransform),i&&o.set(a.minX+o.x*a.width,a.minY+o.y*a.height,1),r&&o.applyMatrix3(r)}let s=document.createElement(`canvas`),c;if(e.type===`linearGradient`){s.width=n,s.height=1;let t=s.getContext(`2d`),r=t.createLinearGradient(0,0,n,0);EO(r,e.stops),t.fillStyle=r,t.fillRect(0,0,n,1);let i=new B,a=new B;o(e.x1,e.y1,i),o(e.x2,e.y2,a);let l=a.x-i.x,u=a.y-i.y,d=l*l+u*u||1e-20,f=l/d,p=u/d,m=-(f*i.x+p*i.y);c=new Di().set(f,p,m,0,0,.5,0,0,1)}else{let t=e.cx,o=e.cy,l=e.fx,u=e.fy,d=e.r;if(e.gradientTransform){let n=new B;n.set(t,o,1).applyMatrix3(e.gradientTransform),t=n.x,o=n.y,n.set(l,u,1).applyMatrix3(e.gradientTransform),l=n.x,u=n.y}if(i&&(t=a.minX+t*a.width,o=a.minY+o*a.height,l=a.minX+l*a.width,u=a.minY+u*a.height,d*=Math.sqrt((a.width*a.width+a.height*a.height)/2)),d<=0)return null;s.width=n,s.height=n;let f=s.getContext(`2d`),p=t-d,m=o-d,h=2*d,g=n/h;f.setTransform(g,0,0,g,-p*g,-m*g);let _=f.createRadialGradient(l,u,0,t,o,d);EO(_,e.stops),f.fillStyle=_,f.fillRect(p,m,h,h);let v=r?r.clone().invert():new Di;c=new Di().set(1/h,0,-p/h,0,1/h,-m/h,0,0,1).multiply(v)}let l=new Ic(s);l.colorSpace=DO,l.flipY=!1,l.matrixAutoUpdate=!1,l.matrix=c;let u=e.spreadMethod===`reflect`?sn:e.spreadMethod===`repeat`?an:on;return l.wrapS=u,l.wrapT=u,l}function TO(e,t){let n=t?t.clone().invert():null,r=new z,i=new ff;for(let t of e.subPaths)for(let e of t.getPoints())r.copy(e),n&&r.applyMatrix3(n),i.expandByPoint(r);return i.isEmpty()?null:{minX:i.min.x,minY:i.min.y,width:i.max.x-i.min.x,height:i.max.y-i.min.y}}function EO(e,t){let n=new H;for(let r of t){let t=r.color;if(r.opacity<1){n.setStyle(r.color,DO);let e=/rgb\(([^)]+)\)/.exec(n.getStyle(DO));e&&(t=`rgba(${e[1]},${r.opacity})`)}e.addColorStop(Math.max(0,Math.min(1,r.offset)),t)}}var DO,OO,kO,AO=t((()=>{J(),DO=Br,OO=class e extends gu{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit=`px`}load(e,t,n,r){let i=this,a=new yu(i.manager);a.setPriority(i.priority),a.setCache(i.cache),a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t=this;function n(e,t){if(e.nodeType!==1)return;e.hasAttribute(`filter`)&&console.warn(`THREE.SVGLoader: Filters are not supported.`);let a=b(e),o=!1,p=null;switch(e.nodeName){case`svg`:t=m(e,t);break;case`style`:i(e);break;case`g`:t=m(e,t);break;case`path`:t=m(e,t),e.hasAttribute(`d`)&&(p=r(e));break;case`rect`:t=m(e,t),p=s(e);break;case`polygon`:t=m(e,t),p=c(e);break;case`polyline`:t=m(e,t),p=l(e);break;case`circle`:t=m(e,t),p=u(e);break;case`ellipse`:t=m(e,t),p=d(e);break;case`line`:t=m(e,t),p=f(e);break;case`defs`:o=!0;break;case`use`:t=m(e,t);let a=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),h=e.viewportElement.getElementById(a);h?n(h,t):console.warn(`SVGLoader: 'use node' references non-existent node id: `+a)}if(p){t.fill!==void 0&&t.fill!==`none`&&!t.fill.startsWith(`url`)&&p.color.setStyle(t.fill,DO),C(p,ie),A.push(p);let n=Object.assign({},t);n.strokeWidth=t.strokeWidth*O(ie),p.userData={node:e,style:n,transform:ie.clone(),gradients:M}}let h=e.childNodes;for(let e=0;e<h.length;e++){let r=h[e];o&&r.nodeName!==`style`&&r.nodeName!==`defs`||n(r,t)}a&&(N.pop(),N.length>0?ie.copy(N[N.length-1]):ie.identity())}function r(e){let t=new Xf,n=new z,r=new z,i=new z,o=!1,s=e.getAttribute(`d`);if(s===``||s===`none`)return null;let c=s.match(/[a-df-z][^a-df-z]*/gi);for(let e=0,s=c.length;e<s;e++){let s=c[e],l=s.charAt(0),u=s.slice(1).trim();o===!0&&(l!==`M`&&l!==`m`&&l!==`Z`&&l!==`z`&&t.moveTo(i.x,i.y),o=!1);let d;switch(l){case`M`:d=g(u);for(let e=0,a=d.length;e<a;e+=2)n.x=d[e+0],n.y=d[e+1],r.x=n.x,r.y=n.y,e===0?t.moveTo(n.x,n.y):t.lineTo(n.x,n.y),e===0&&i.copy(n);break;case`H`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.x=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`V`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.y=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`L`:d=g(u);for(let e=0,i=d.length;e<i;e+=2)n.x=d[e+0],n.y=d[e+1],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`C`:d=g(u);for(let e=0,i=d.length;e<i;e+=6)t.bezierCurveTo(d[e+0],d[e+1],d[e+2],d[e+3],d[e+4],d[e+5]),r.x=d[e+2],r.y=d[e+3],n.x=d[e+4],n.y=d[e+5];break;case`S`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.bezierCurveTo(h(n.x,r.x),h(n.y,r.y),d[e+0],d[e+1],d[e+2],d[e+3]),r.x=d[e+0],r.y=d[e+1],n.x=d[e+2],n.y=d[e+3];break;case`Q`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.quadraticCurveTo(d[e+0],d[e+1],d[e+2],d[e+3]),r.x=d[e+0],r.y=d[e+1],n.x=d[e+2],n.y=d[e+3];break;case`T`:d=g(u);for(let e=0,i=d.length;e<i;e+=2){let i=h(n.x,r.x),a=h(n.y,r.y);t.quadraticCurveTo(i,a,d[e+0],d[e+1]),r.x=i,r.y=a,n.x=d[e+0],n.y=d[e+1]}break;case`A`:d=g(u,[3,4],7);for(let e=0,i=d.length;e<i;e+=7){if(d[e+5]==n.x&&d[e+6]==n.y)continue;let i=n.clone();n.x=d[e+5],n.y=d[e+6],r.x=n.x,r.y=n.y,a(t,d[e],d[e+1],d[e+2],d[e+3],d[e+4],i,n)}break;case`m`:d=g(u);for(let e=0,a=d.length;e<a;e+=2)n.x+=d[e+0],n.y+=d[e+1],r.x=n.x,r.y=n.y,e===0?t.moveTo(n.x,n.y):t.lineTo(n.x,n.y),e===0&&i.copy(n);break;case`h`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.x+=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`v`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.y+=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`l`:d=g(u);for(let e=0,i=d.length;e<i;e+=2)n.x+=d[e+0],n.y+=d[e+1],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`c`:d=g(u);for(let e=0,i=d.length;e<i;e+=6)t.bezierCurveTo(n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3],n.x+d[e+4],n.y+d[e+5]),r.x=n.x+d[e+2],r.y=n.y+d[e+3],n.x+=d[e+4],n.y+=d[e+5];break;case`s`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.bezierCurveTo(h(n.x,r.x),h(n.y,r.y),n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3]),r.x=n.x+d[e+0],r.y=n.y+d[e+1],n.x+=d[e+2],n.y+=d[e+3];break;case`q`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.quadraticCurveTo(n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3]),r.x=n.x+d[e+0],r.y=n.y+d[e+1],n.x+=d[e+2],n.y+=d[e+3];break;case`t`:d=g(u);for(let e=0,i=d.length;e<i;e+=2){let i=h(n.x,r.x),a=h(n.y,r.y);t.quadraticCurveTo(i,a,n.x+d[e+0],n.y+d[e+1]),r.x=i,r.y=a,n.x+=d[e+0],n.y+=d[e+1]}break;case`a`:d=g(u,[3,4],7);for(let e=0,i=d.length;e<i;e+=7){if(d[e+5]==0&&d[e+6]==0)continue;let i=n.clone();n.x+=d[e+5],n.y+=d[e+6],r.x=n.x,r.y=n.y,a(t,d[e],d[e+1],d[e+2],d[e+3],d[e+4],i,n)}break;case`Z`:case`z`:t.currentPath.autoClose=!0,t.currentPath.curves.length>0&&(n.copy(i),t.currentPath.currentPoint.copy(n),o=!0);break;default:console.warn(s)}}return t}function i(e){if(e.sheet&&e.sheet.cssRules&&e.sheet.cssRules.length)for(let t=0;t<e.sheet.cssRules.length;t++){let n=e.sheet.cssRules[t];if(n.type!==1)continue;let r=n.selectorText.split(/,/gm).filter(Boolean).map(e=>e.trim()),i={};for(let e=0;e<n.style.length;e++){let t=n.style[e];i[t]=n.style.getPropertyValue(t)}for(let e=0;e<r.length;e++)j[r[e]]=Object.assign(j[r[e]]||{},i)}}function a(e,t,n,r,i,a,s,c){if(t==0||n==0){e.lineTo(c.x,c.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let l=(s.x-c.x)/2,u=(s.y-c.y)/2,d=Math.cos(r)*l+Math.sin(r)*u,f=-Math.sin(r)*l+Math.cos(r)*u,p=t*t,m=n*n,h=d*d,g=f*f,_=h/p+g/m;if(_>1){let e=Math.sqrt(_);t=e*t,n=e*n,p=t*t,m=n*n}let v=p*g+m*h,y=(p*m-v)/v,b=Math.sqrt(Math.max(0,y));i===a&&(b=-b);let x=b*t*f/n,S=-b*n*d/t,C=Math.cos(r)*x-Math.sin(r)*S+(s.x+c.x)/2,w=Math.sin(r)*x+Math.cos(r)*S+(s.y+c.y)/2,T=o(1,0,(d-x)/t,(f-S)/n),E=o((d-x)/t,(f-S)/n,(-d-x)/t,(-f-S)/n)%(Math.PI*2);e.currentPath.absellipse(C,w,t,n,T,T+E,a===0,r)}function o(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function s(e){let t=y(e.getAttribute(`x`)||0),n=y(e.getAttribute(`y`)||0),r=y(e.getAttribute(`rx`)||e.getAttribute(`ry`)||0),i=y(e.getAttribute(`ry`)||e.getAttribute(`rx`)||0),a=y(e.getAttribute(`width`)),o=y(e.getAttribute(`height`)),s=.448084975506,c=new Xf;return c.moveTo(t+r,n),c.lineTo(t+a-r,n),(r!==0||i!==0)&&c.bezierCurveTo(t+a-r*s,n,t+a,n+i*s,t+a,n+i),c.lineTo(t+a,n+o-i),(r!==0||i!==0)&&c.bezierCurveTo(t+a,n+o-i*s,t+a-r*s,n+o,t+a-r,n+o),c.lineTo(t+r,n+o),(r!==0||i!==0)&&c.bezierCurveTo(t+r*s,n+o,t,n+o-i*s,t,n+o-i),c.lineTo(t,n+i),(r!==0||i!==0)&&c.bezierCurveTo(t,n+i*s,t+r*s,n,t+r,n),c}function c(e){function t(e,t,n){let a=y(t),o=y(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)/g,r=new Xf,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!0,r}function l(e){function t(e,t,n){let a=y(t),o=y(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)/g,r=new Xf,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!1,r}function u(e){let t=y(e.getAttribute(`cx`)||0),n=y(e.getAttribute(`cy`)||0),r=y(e.getAttribute(`r`)||0),i=new _l;i.absarc(t,n,r,0,Math.PI*2);let a=new Xf;return a.subPaths.push(i),a}function d(e){let t=y(e.getAttribute(`cx`)||0),n=y(e.getAttribute(`cy`)||0),r=y(e.getAttribute(`rx`)||0),i=y(e.getAttribute(`ry`)||0),a=new _l;a.absellipse(t,n,r,i,0,Math.PI*2);let o=new Xf;return o.subPaths.push(a),o}function f(e){let t=y(e.getAttribute(`x1`)||0),n=y(e.getAttribute(`y1`)||0),r=y(e.getAttribute(`x2`)||0),i=y(e.getAttribute(`y2`)||0),a=new Xf;return a.moveTo(t,n),a.lineTo(r,i),a.currentPath.autoClose=!1,a}function p(e){let t=e.querySelectorAll(`linearGradient, radialGradient`),n=[`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`],r={};for(let e of t){let t=e.getAttribute(`id`);if(!t)continue;let i={type:e.nodeName===`radialGradient`?`radialGradient`:`linearGradient`,attrs:{},stops:null,href:null},a=e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``;a.startsWith(`#`)&&(i.href=a.substring(1));for(let t of n)e.hasAttribute(t)&&(i.attrs[t]=e.getAttribute(t));let o=e.querySelectorAll(`stop`);if(o.length>0){i.stops=[];for(let e of o){let t=e.getAttribute(`stop-color`);!t&&e.style&&(t=e.style[`stop-color`]),t||=`#000`;let n=e.getAttribute(`stop-opacity`);(n===null||n===``)&&e.style&&(n=e.style[`stop-opacity`]),n=n===null||n===``||n===void 0?1:Math.max(0,Math.min(1,parseFloat(n)));let r=Math.max(0,Math.min(1,parseFloat(e.getAttribute(`offset`)||`0`)));i.stops.push({offset:r,color:t,opacity:n})}}r[t]=i}function i(e,t){let n=r[e];if(!n||t.has(e))return n;if(t.add(e),n.href&&r[n.href]){let e=i(n.href,t);if(e){n.stops||=e.stops;for(let t in e.attrs)t in n.attrs||(n.attrs[t]=e.attrs[t])}}return n}for(let e in r)i(e,/* @__PURE__ */ new Set);for(let e in r){let t=r[e],n=t.attrs,i=n.gradientUnits===`userSpaceOnUse`?`userSpaceOnUse`:`objectBoundingBox`,a={type:t.type,gradientUnits:i,spreadMethod:n.spreadMethod===`reflect`||n.spreadMethod===`repeat`?n.spreadMethod:`pad`,gradientTransform:null,stops:(t.stops||[]).slice().sort((e,t)=>e.offset-t.offset)};n.gradientTransform&&(a.gradientTransform=new Di,S(n.gradientTransform,a.gradientTransform));function o(e){return typeof e==`string`?e.endsWith(`%`)?parseFloat(e)/100:y(e):0}if(t.type===`linearGradient`)a.x1=n.x1===void 0?0:o(n.x1),a.y1=n.y1===void 0?0:o(n.y1),a.x2=n.x2===void 0?+(i===`objectBoundingBox`):o(n.x2),a.y2=n.y2===void 0?0:o(n.y2);else{let e=i===`objectBoundingBox`?.5:0,t=i===`objectBoundingBox`?.5:0;a.cx=n.cx===void 0?e:o(n.cx),a.cy=n.cy===void 0?e:o(n.cy),a.r=n.r===void 0?t:o(n.r),a.fx=n.fx===void 0?a.cx:o(n.fx),a.fy=n.fy===void 0?a.cy:o(n.fy)}M[e]=a}}function m(e,t){t=Object.assign({},t);let n={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)n=Object.assign(n,j[`.`+t[e]])}e.hasAttribute(`id`)&&(n=Object.assign(n,j[`#`+e.getAttribute(`id`)]));function r(r,i,a){a===void 0&&(a=function(e){return e}),e.hasAttribute(r)&&(t[i]=a(e.getAttribute(r))),n[r]&&(t[i]=a(n[r])),e.style&&e.style[r]!==``&&(t[i]=a(e.style[r]))}function i(e){return Math.max(0,Math.min(1,y(e)))}function a(e){return Math.max(0,y(e))}return r(`fill`,`fill`),r(`fill-opacity`,`fillOpacity`,i),r(`fill-rule`,`fillRule`),r(`opacity`,`opacity`,i),r(`stroke`,`stroke`),r(`stroke-opacity`,`strokeOpacity`,i),r(`stroke-width`,`strokeWidth`,a),r(`stroke-linejoin`,`strokeLineJoin`),r(`stroke-linecap`,`strokeLineCap`),r(`stroke-miterlimit`,`strokeMiterLimit`,a),r(`visibility`,`visibility`),t}function h(e,t){return e-(t-e)}function g(e,t,n){if(typeof e!=`string`)throw TypeError(`Invalid input: `+typeof e);let r={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},i=0,a=!0,o=``,s=``,c=[];function l(e,t,n){let r=/* @__PURE__ */ SyntaxError(`Unexpected character "`+e+`" at index `+t+`.`);throw r.partial=n,r}function u(){o!==``&&(s===``?c.push(Number(o)):c.push(Number(o)*10**Number(s))),o=``,s=``}let d,f=e.length;for(let p=0;p<f;p++)if(d=e[p],Array.isArray(t)&&t.includes(c.length%n)&&r.FLAGS.test(d))i=1,o=d,u();else{if(i===0){if(r.WHITESPACE.test(d))continue;if(r.DIGIT.test(d)||r.SIGN.test(d)){i=1,o=d;continue}if(r.POINT.test(d)){i=2,o=d;continue}r.COMMA.test(d)&&(a&&l(d,p,c),a=!0)}if(i===1){if(r.DIGIT.test(d)){o+=d;continue}if(r.POINT.test(d)){o+=d,i=2;continue}if(r.EXP.test(d)){i=3;continue}r.SIGN.test(d)&&o.length===1&&r.SIGN.test(o[0])&&l(d,p,c)}if(i===2){if(r.DIGIT.test(d)){o+=d;continue}if(r.EXP.test(d)){i=3;continue}r.POINT.test(d)&&o[o.length-1]===`.`&&l(d,p,c)}if(i===3){if(r.DIGIT.test(d)){s+=d;continue}if(r.SIGN.test(d)){if(s===``){s+=d;continue}s.length===1&&r.SIGN.test(s)&&l(d,p,c)}}r.WHITESPACE.test(d)?(u(),i=0,a=!1):r.COMMA.test(d)?(u(),i=0,a=!0):r.SIGN.test(d)?(u(),i=1,o=d):r.POINT.test(d)?(u(),i=2,o=d):l(d,p,c)}return u(),c}let _=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],v={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:12,pc:1,px:-1},px:{px:1}};function y(e){let n=`px`;if(typeof e==`string`||e instanceof String)for(let t=0,r=_.length;t<r;t++){let r=_[t];if(e.endsWith(r)){n=r,e=e.substring(0,e.length-r.length);break}}let r;return n===`px`&&t.defaultUnit!==`px`?r=v.in[t.defaultUnit]/t.defaultDPI:(r=v[n][t.defaultUnit],r<0&&(r=v[n].in*t.defaultDPI)),r*parseFloat(e)}function b(e){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let t=x(e);return N.length>0&&t.premultiply(N[N.length-1]),ie.copy(t),N.push(t),t}function x(e){let t=new Di;if(e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))){let n=y(e.getAttribute(`x`)||0),r=y(e.getAttribute(`y`)||0);t.makeTranslation(n,r)}return e.hasAttribute(`transform`)&&S(e.getAttribute(`transform`),t),t}function S(e,t){let n=P,r=e.split(`)`);for(let e=r.length-1;e>=0;e--){let i=r[e].trim();if(i===``)continue;let a=i.indexOf(`(`),o=i.length;if(a>0&&a<o){let e=i.slice(0,a),r=g(i.slice(a+1));switch(n.identity(),e){case`translate`:if(r.length>=1){let e=r[0],t=0;r.length>=2&&(t=r[1]),n.makeTranslation(e,t)}break;case`rotate`:if(r.length>=1){let e=0,t=0,i=0;e=r[0]*Math.PI/180,r.length>=3&&(t=r[1],i=r[2]),F.makeTranslation(-t,-i),ee.makeRotation(e),te.multiplyMatrices(ee,F),F.makeTranslation(t,i),n.multiplyMatrices(F,te)}break;case`scale`:if(r.length>=1){let e=r[0],t=e;r.length>=2&&(t=r[1]),n.makeScale(e,t)}break;case`skewX`:r.length===1&&n.set(1,Math.tan(r[0]*Math.PI/180),0,0,1,0,0,0,1);break;case`skewY`:r.length===1&&n.set(1,0,0,Math.tan(r[0]*Math.PI/180),1,0,0,0,1);break;case`matrix`:r.length===6&&n.set(r[0],r[2],r[4],r[1],r[3],r[5],0,0,1)}t.premultiply(n)}}return t}function C(e,t){function n(e){re.set(e.x,e.y,1).applyMatrix3(t),e.set(re.x,re.y)}function r(e){let n=e.xRadius,r=e.yRadius,i=Math.cos(e.aRotation),a=Math.sin(e.aRotation),o=new B(n*i,n*a,0),s=new B(-r*a,r*i,0),c=o.applyMatrix3(t),l=s.applyMatrix3(t),u=P.set(c.x,l.x,0,c.y,l.y,0,0,0,1),d=F.copy(u).invert(),f=ee.copy(d).transpose().multiply(d).elements,p=k(f[0],f[1],f[4]),m=Math.sqrt(p.rt1),h=Math.sqrt(p.rt2);if(e.xRadius=1/m,e.yRadius=1/h,e.aRotation=Math.atan2(p.sn,p.cs),!((e.aEndAngle-e.aStartAngle)%(2*Math.PI)<2**-52)){let n=F.set(m,0,0,0,h,0,0,0,1),r=ee.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),i=n.multiply(r).multiply(u),a=e=>{let{x:t,y:n}=new B(Math.cos(e),Math.sin(e),0).applyMatrix3(i);return Math.atan2(n,t)};e.aStartAngle=a(e.aStartAngle),e.aEndAngle=a(e.aEndAngle),w(t)&&(e.aClockwise=!e.aClockwise)}}function i(e){let n=E(t),r=D(t);e.xRadius*=n,e.yRadius*=r;let i=n>2**-52?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);e.aRotation+=i,w(t)&&(e.aStartAngle*=-1,e.aEndAngle*=-1,e.aClockwise=!e.aClockwise)}let a=e.subPaths;for(let e=0,o=a.length;e<o;e++){let o=a[e].curves;for(let e=0;e<o.length;e++){let a=o[e];a.isLineCurve?(n(a.v1),n(a.v2)):a.isCubicBezierCurve?(n(a.v0),n(a.v1),n(a.v2),n(a.v3)):a.isQuadraticBezierCurve?(n(a.v0),n(a.v1),n(a.v2)):a.isEllipseCurve&&(ne.set(a.aX,a.aY),n(ne),a.aX=ne.x,a.aY=ne.y,T(t)?r(a):i(a))}}}function w(e){let t=e.elements;return t[0]*t[4]-t[1]*t[3]<0}function T(e){let t=e.elements,n=t[0]*t[3]+t[1]*t[4];if(n===0)return!1;let r=E(e),i=D(e);return Math.abs(n/(r*i))>2**-52}function E(e){let t=e.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function D(e){let t=e.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function O(e){let t=e.elements,n=t[0]*t[4]-t[1]*t[3];return Math.sqrt(Math.abs(n))}function k(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?i=.5*(c-u):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}let A=[],j={},M={},N=[],P=new Di,F=new Di,ee=new Di,te=new Di,ne=new z,re=new B,ie=new Di,ae=new DOMParser().parseFromString(e,`image/svg+xml`);return p(ae),n(ae.documentElement,{fill:`#000`,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:`miter`,strokeLineCap:`butt`,strokeMiterLimit:4}),{paths:A,gradients:M,xml:ae.documentElement}}static createFillMaterial(e){let t=e.userData.style;if(t.fill===void 0||t.fill===`none`)return null;let n=e.color,r=null,i=kO.exec(t.fill);i&&(r=wO(e.userData.gradients&&e.userData.gradients[i[1]],e));let a=new ss({opacity:t.fillOpacity*(t.opacity||1),transparent:!0,side:2,depthWrite:!1});return r===null?a.color=n:a.map=r,a}static createStrokeMaterial(e){let t=e.userData.style;return t.stroke===void 0||t.stroke===`none`?null:(kO.test(t.stroke)&&console.warn(`THREE.SVGLoader: Gradient strokes are not supported.`),new ss({color:new H().setStyle(t.stroke,DO),opacity:t.strokeOpacity*(t.opacity||1),transparent:!0,side:2,depthWrite:!1}))}static createShapes(e){return console.warn(`SVGLoader: createShapes() is deprecated. Use shapePath.toShapes() instead.`),e.toShapes()}static getStrokeStyle(e,t,n,r,i){return e=e===void 0?1:e,t=t===void 0?`#000`:t,n=n===void 0?`miter`:n,r=r===void 0?`butt`:r,i=i===void 0?4:i,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:r,strokeMiterLimit:i}}static pointsToStroke(t,n,r,i){let a=[],o=[],s=[];if(e.pointsToStrokeWithBuffers(t,n,r,i,a,o,s)===0)return null;let c=new G;return c.setAttribute(`position`,new W(a,3)),c.setAttribute(`normal`,new W(o,3)),c.setAttribute(`uv`,new W(s,2)),c}static pointsToStrokeWithBuffers(e,t,n,r,i,a,o,s){let c=new z,l=new z,u=new z,d=new z,f=new z,p=new z,m=new z,h=new z,g=new z,_=new z,v=new z,y=new z,b=new z,x=new z,S=new z,C=new z,w=new z;n=n===void 0?12:n,r=r===void 0?.001:r,s=s===void 0?0:s,e=de(e);let T=e.length;if(T<2)return 0;let E=e[0].equals(e[T-1]),D,O=e[0],k,A=t.strokeWidth/2,j=1/(T-1),M=0,N,P,F,ee,te=!1,ne=0,re=s*3,ie=s*2;ae(e[0],e[1],c).multiplyScalar(A),h.copy(e[0]).sub(c),g.copy(e[0]).add(c),_.copy(h),v.copy(g);for(let n=1;n<T;n++){D=e[n],k=n===T-1?E?e[1]:void 0:e[n+1];let r=c;if(ae(O,D,r),u.copy(r).multiplyScalar(A),y.copy(D).sub(u),b.copy(D).add(u),N=M+j,P=!1,k!==void 0){ae(D,k,l),u.copy(l).multiplyScalar(A),x.copy(D).sub(u),S.copy(D).add(u),F=!0,u.subVectors(k,O),r.dot(u)<0&&(F=!1),n===1&&(te=F),u.subVectors(k,D),u.normalize();let e=Math.abs(r.dot(u));if(e>2**-52){let n=A/e;u.multiplyScalar(-n),d.subVectors(D,O),f.copy(d).setLength(n).add(u),C.copy(f).negate();let r=f.length(),i=d.length();d.divideScalar(i),p.subVectors(k,D);let a=p.length();if(p.divideScalar(a),d.dot(C)<i&&p.dot(C)<a&&(P=!0),w.copy(f).add(D),C.add(D),P){let e=F?g:h,t=(w.x-e.x)*(C.y-e.y)-(w.y-e.y)*(C.x-e.x);(F&&t<0||!F&&t>0)&&C.copy(e)}switch(ee=!1,P?F?(S.copy(C),b.copy(C)):(x.copy(C),y.copy(C)):se(),t.strokeLineJoin){case`bevel`:ce(F,P,N);break;case`round`:le(F,P),F?oe(D,y,x,N,0):oe(D,S,b,N,1);break;default:let e=A*t.strokeMiterLimit/r;if(e<1){if(t.strokeLineJoin!==`miter-clip`){ce(F,P,N);break}le(F,P),F?(p.subVectors(w,y).multiplyScalar(e).add(y),m.subVectors(w,x).multiplyScalar(e).add(x),I(y,N,0),I(p,N,0),I(D,N,.5),I(D,N,.5),I(p,N,0),I(m,N,0),I(D,N,.5),I(m,N,0),I(x,N,0)):(p.subVectors(w,b).multiplyScalar(e).add(b),m.subVectors(w,S).multiplyScalar(e).add(S),I(b,N,1),I(p,N,1),I(D,N,.5),I(D,N,.5),I(p,N,1),I(m,N,1),I(D,N,.5),I(m,N,1),I(S,N,1))}else P?(F?(I(g,M,1),I(h,M,0),I(w,N,0),I(g,M,1),I(w,N,0),I(C,N,1)):(I(g,M,1),I(h,M,0),I(w,N,1),I(h,M,0),I(C,N,0),I(w,N,1)),F?x.copy(w):S.copy(w)):F?(I(y,N,0),I(w,N,0),I(D,N,.5),I(D,N,.5),I(w,N,0),I(x,N,0)):(I(b,N,1),I(w,N,1),I(D,N,.5),I(D,N,.5),I(w,N,1),I(S,N,1)),ee=!0}}else se()}else se();!E&&n===T-1&&ue(e[0],_,v,F,!0,M),M=N,O=D,h.copy(x),g.copy(S)}if(!E)ue(D,y,b,F,!1,N);else if(P&&i){let e=w,t=C;te!==F&&(e=C,t=w),F?(ee||te)&&(t.toArray(i,0),t.toArray(i,9),ee&&e.toArray(i,3)):(ee||!te)&&(t.toArray(i,3),t.toArray(i,9),ee&&e.toArray(i,0))}if(i){let e=[new z,new z,new z],t=s*3;for(let n=t;n<re;n+=9)e[0].set(i[n],i[n+1]),e[1].set(i[n+3],i[n+4]),e[2].set(i[n+6],i[n+7]),bl.area(e)<0&&(i[n+3]=e[0].x,i[n+4]=e[0].y)}return ne;function ae(e,t,n){return n.subVectors(t,e),n.set(-n.y,n.x).normalize()}function I(e,t,n){i&&(i[re]=e.x,i[re+1]=e.y,i[re+2]=0,a&&(a[re]=0,a[re+1]=0,a[re+2]=1),re+=3,o&&(o[ie]=t,o[ie+1]=n,ie+=2)),ne+=3}function oe(e,t,r,i,a){c.copy(t).sub(e).normalize(),l.copy(r).sub(e).normalize();let o=Math.PI,s=c.dot(l);Math.abs(s)<1&&(o=Math.abs(Math.acos(s))),o/=n,u.copy(t);for(let t=0,r=n-1;t<r;t++)d.copy(u).rotateAround(e,o),I(u,i,a),I(d,i,a),I(e,i,.5),u.copy(d);I(u,i,a),I(r,i,a),I(e,i,.5)}function se(){I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(b,N,1)}function ce(e,t,n){t?e?(I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(C,N,1),I(y,n,0),I(x,n,0),I(C,n,.5)):(I(g,M,1),I(h,M,0),I(b,N,1),I(h,M,0),I(C,N,0),I(b,N,1),I(b,n,1),I(C,n,0),I(S,n,1)):e?(I(y,n,0),I(x,n,0),I(D,n,.5)):(I(b,n,1),I(S,n,0),I(D,n,.5))}function le(e,t){t&&(e?(I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(C,N,1),I(y,M,0),I(D,N,.5),I(C,N,1),I(D,N,.5),I(x,M,0),I(C,N,1)):(I(g,M,1),I(h,M,0),I(b,N,1),I(h,M,0),I(C,N,0),I(b,N,1),I(b,M,1),I(C,N,0),I(D,N,.5),I(D,N,.5),I(C,N,0),I(S,M,1)))}function ue(e,n,r,a,s,f){switch(t.strokeLineCap){case`round`:s?oe(e,r,n,f,.5):oe(e,n,r,f,.5);break;case`square`:if(s)c.subVectors(n,e),l.set(c.y,-c.x),u.addVectors(c,l).add(e),d.subVectors(l,c).add(e),a?(u.toArray(i,3),d.toArray(i,0),d.toArray(i,9)):(u.toArray(i,3),o[7]===1?d.toArray(i,9):u.toArray(i,9),d.toArray(i,0));else{c.subVectors(r,e),l.set(c.y,-c.x),u.addVectors(c,l).add(e),d.subVectors(l,c).add(e);let t=i.length;a?(u.toArray(i,t-3),d.toArray(i,t-6),d.toArray(i,t-12)):(d.toArray(i,t-6),u.toArray(i,t-3),d.toArray(i,t-12))}}}function de(e){let t=!1;for(let n=1,i=e.length-1;n<i;n++)if(e[n].distanceTo(e[n+1])<r){t=!0;break}if(!t)return e;let n=[];n.push(e[0]);for(let t=1,i=e.length-1;t<i;t++)e[t].distanceTo(e[t+1])>=r&&n.push(e[t]);return n.push(e[e.length-1]),n}}},kO=/^\s*url\(\s*(?:["']\s*)?#([^)'"\s]+)(?:\s*["'])?\s*\)\s*$/})),jO=/* @__PURE__ */ n({buildSvg:()=>RO,partsBounds:()=>IO,svgParts:()=>PO});function MO(e,t,n){if(e===`currentColor`)return n;let r=/^url\(\s*['"]?#([^'")]+)['"]?\s*\)/.exec(e);if(r){let e=t.userData?.gradients?.[r[1]]?.stops??[];if(!e.length)return n;let i=new H(e[0].color),a=new H(e[e.length-1].color);return`#${i.lerp(a,.5).getHexString()}`}try{let t=new H;return t.setStyle(e,Br),`#${t.getHexString(Br)}`}catch{return n}}function NO(e,t){let n=new ff;for(let t of e.paths)for(let e of t.subPaths)for(let t of e.getPoints(4))n.expandByPoint(t);return(n.isEmpty()?100:Math.max(n.max.x-n.min.x,n.max.y-n.min.y,1e-6))/(t*10)}function PO(e,t,n={}){let r=[],i=Math.max(1,Math.round(Q(n.curveSegments,12))),a=NO(e,i),o=n.currentColor??`#1f2330`;for(let s of e.paths){let e=s.userData?.style??{};if(e.visibility===`hidden`||e.visibility===`collapse`)continue;let c=Q(e.opacity,1);if(zO(e.fill)){let t=s.toShapes().map(e=>zD(e,a));t.length&&r.push({kind:`fill`,color:MO(e.fill,s,o),opacity:Q(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&zO(e.stroke)&&Q(e.strokeWidth,1)>0){let n=t.getStrokeStyle(Q(e.strokeWidth,1),`#000`,e.strokeLineJoin??`miter`,e.strokeLineCap??`butt`,Q(e.strokeMiterLimit,4)),l=[];for(let e of s.subPaths){let r=RD(e,a);if(r.length<2)continue;let o=t.pointsToStroke(r,n,i);o&&l.push(o)}if(l.length){let t=l.length===1?l[0]:FO(l);r.push({kind:`stroke`,color:MO(e.stroke,s,o),opacity:Q(e.strokeOpacity,1)*c,stroke:t})}}}return r}function FO(e){let t=0;for(let n of e)t+=n.getAttribute(`position`).count;let n=new Float32Array(t*3),r=0;for(let t of e){let e=t.getAttribute(`position`).array;n.set(e,r),r+=e.length,t.dispose()}let i=new G;return i.setAttribute(`position`,new co(n,3)),i}function IO(e,t=12){let n=new ff;for(let r of e){if(r.shapes)for(let e of r.shapes)for(let r of e.getPoints(t))n.expandByPoint(r);if(r.stroke){let e=r.stroke.getAttribute(`position`);for(let t=0;t<e.count;t++)n.expandByPoint(new z(e.getX(t),e.getY(t)))}}return n}function LO(e,t,n,r,i){if(e.kind===`stroke`)return e.stroke?VD(e.stroke,t):null;if(!e.shapes?.length)return null;if(t<=0)return new Ol(e.shapes,r);let a=Math.min(n,t*.45),o=new xl(e.shapes,{depth:Math.max(t-a*2,t*.05),curveSegments:r,bevelEnabled:a>0,bevelThickness:a,bevelSize:a*.6,bevelOffset:0,bevelSegments:3});return o.translate(0,0,a),o.clearGroups(),BD(o,50*Math.PI/180,i)}async function RO(e,t){let[{SVGLoader:n},r]=await Promise.all([Promise.resolve().then(()=>(AO(),CO)),Promise.resolve().then(()=>(Wv(),kv))]),i=e.src.trim().startsWith(`<`)?e.src:await mg(t.resolveAsset(e.src)),a=new n().parse(i),o=e.material?lw(e.material):void 0,s=typeof o?.color==`string`?o.color:void 0,c=Math.max(1,Math.round(Q(e.curveSegments,12))),l=PO(a,n,{strokes:e.strokes,curveSegments:c,currentColor:s}),u=new ba,d=IO(l,c);if(!l.length||d.isEmpty())return u;let f=Q(e.size,2),p=Math.max(d.max.x-d.min.x,1e-6),m=Math.max(d.max.y-d.min.y,1e-6),h=e.fit??`width`,g=f/(h===`height`?m:h===`max`?Math.max(p,m):p),_=Math.max(0,Q(e.depth,.2)),v=_/g,y=Q(e.bevel,0)/g,b=Q(e.layerGap,_>0?_*.02:f*.002),x=e.keepColors??!e.material,S=/* @__PURE__ */ new Map,C=async(n,r)=>{let i=x?`${n}|${r}`:`|${r}`,a=S.get(i);return a||(a=await yw(x?{roughness:.4,metalness:.1,...e.material??{},color:n,...r<1?{opacity:r}:{}}:e.material?{...e.material,...r<1?{opacity:r}:{}}:{color:`#dddddd`,roughness:.4,metalness:.1},t,{defaultColor:n}),r<1&&(a.transparent=!0),_<=0&&(a.side=2),S.set(i,a)),a},w=[];for(let e of l){let t=LO(e,v,y,c,r);if(!t)continue;t.getAttribute(`normal`)||t.computeVertexNormals();let n=x?`${e.color}|${e.opacity}`:`|${e.opacity}`,i=w[w.length-1];i&&i.key===n?i.geos.push(t):w.push({key:n,color:e.color,opacity:e.opacity,geos:[t]})}let T=new ba;for(let[e,t]of w.entries()){for(let e of t.geos){for(let t of Object.keys(e.attributes))[`position`,`normal`,`uv`].includes(t)||e.deleteAttribute(t);e.getAttribute(`uv`)||e.setAttribute(`uv`,new W(new Float32Array(e.getAttribute(`position`).count*2),2))}let n=t.geos.length===1?t.geos[0]:r.mergeGeometries(t.geos.map(e=>e.index?e.toNonIndexed():e),!1)??t.geos[0],i=new K(n,await C(t.color,t.opacity));i.position.z=e*b/g,T.add(i)}let E=(d.min.x+d.max.x)/2,D=(d.min.y+d.max.y)/2;return T.scale.set(g,-g,g),T.position.set(-E*g,D*g,-(_+Math.max(0,w.length-1)*b)/2),u.add(T),u}var zO,BO=t((()=>{J(),yg(),zS(),HD(),jw(),zO=e=>!!e&&e!==`none`&&e!==`transparent`})),VO=/* @__PURE__ */ n({clone:()=>GO,retarget:()=>UO,retargetClip:()=>WO});function HO(e,t){return t.getBoneName===void 0?t.names[e.name]:t.getBoneName(e)}function UO(e,t,n={}){let r=new wi,i=new B,a=new V,o=new V;n.preserveBoneMatrix=n.preserveBoneMatrix===void 0||n.preserveBoneMatrix,n.preserveBonePositions=n.preserveBonePositions===void 0||n.preserveBonePositions,n.useTargetMatrix=n.useTargetMatrix!==void 0&&n.useTargetMatrix,n.hip=n.hip===void 0?`hip`:n.hip,n.hipInfluence=n.hipInfluence===void 0?new B(1,1,1):n.hipInfluence,n.scale=n.scale===void 0?1:n.scale,n.names=n.names||{};let s=t.isObject3D?t.skeleton.bones:qO(t),c=e.isObject3D?e.skeleton.bones:qO(e),l,u,d,f;if(e.isObject3D?e.skeleton.pose():(n.useTargetMatrix=!0,n.preserveBoneMatrix=!1),n.preserveBonePositions){f=[];for(let e=0;e<c.length;e++)f.push(c[e].position.clone())}if(n.preserveBoneMatrix){e.updateMatrixWorld(),e.matrixWorld.identity();for(let t=0;t<e.children.length;++t)e.children[t].updateMatrixWorld(!0)}for(let t=0;t<c.length;++t)l=c[t],u=HO(l,n),d=KO(u,s),o.copy(l.matrixWorld),d&&(d.updateMatrixWorld(),n.useTargetMatrix?a.copy(d.matrixWorld):(a.copy(e.matrixWorld).invert(),a.multiply(d.matrixWorld)),i.setFromMatrixScale(a),a.scale(i.set(1/i.x,1/i.y,1/i.z)),o.makeRotationFromQuaternion(r.setFromRotationMatrix(a)),e.isObject3D&&n.localOffsets&&n.localOffsets[l.name]&&o.multiply(n.localOffsets[l.name]),o.copyPosition(a)),u===n.hip&&(o.elements[12]*=n.scale*n.hipInfluence.x,o.elements[13]*=n.scale*n.hipInfluence.y,o.elements[14]*=n.scale*n.hipInfluence.z,n.hipPosition!==void 0&&(o.elements[12]+=n.hipPosition.x*n.scale,o.elements[13]+=n.hipPosition.y*n.scale,o.elements[14]+=n.hipPosition.z*n.scale)),l.parent?(l.matrix.copy(l.parent.matrixWorld).invert(),l.matrix.multiply(o)):l.matrix.copy(o),l.matrix.decompose(l.position,l.quaternion,l.scale),l.updateMatrixWorld();if(n.preserveBonePositions)for(let e=0;e<c.length;++e)l=c[e],u=HO(l,n)||l.name,u!==n.hip&&l.position.copy(f[e]);n.preserveBoneMatrix&&e.updateMatrixWorld(!0)}function WO(e,t,n,r={}){r.useFirstFramePosition=r.useFirstFramePosition!==void 0&&r.useFirstFramePosition,r.fps=r.fps===void 0?Math.max(...n.tracks.map(e=>e.times.length))/n.duration:r.fps,r.names=r.names||[],t.isObject3D||(t=JO(t));let i=Math.round(n.duration*(r.fps/1e3)*1e3),a=n.duration/(i-1),o=[],s=new Zd(t),c=qO(e.skeleton),l=[],u,d,f,p,m;s.clipAction(n).play();let h=0,g=i;r.trim===void 0?s.update(0):(h=Math.round(r.trim[0]*r.fps),g=Math.min(Math.round(r.trim[1]*r.fps),i)-h,s.update(r.trim[0])),t.updateMatrixWorld();for(let n=0;n<g;++n){let i=n*a;UO(e,t,r);for(let e=0;e<c.length;++e)d=c[e],m=HO(d,r)||d.name,f=KO(m,t.skeleton),f&&(p=l[e]=l[e]||{bone:d},r.hip===m&&(p.pos||(p.pos={times:new Float32Array(g),values:new Float32Array(g*3)}),r.useFirstFramePosition&&(n===0&&(u=d.position.clone()),d.position.sub(u)),p.pos.times[n]=i,d.position.toArray(p.pos.values,n*3)),p.quat||(p.quat={times:new Float32Array(g),values:new Float32Array(g*4)}),p.quat.times[n]=i,d.quaternion.toArray(p.quat.values,n*4));n===g-2?s.update(a-1e-7):s.update(a),t.updateMatrixWorld()}for(let e=0;e<l.length;++e)p=l[e],p&&(p.pos&&o.push(new du(`.bones[`+p.bone.name+`].position`,p.pos.times,p.pos.values)),o.push(new lu(`.bones[`+p.bone.name+`].quaternion`,p.quat.times,p.quat.values)));return s.uncacheAction(n),new fu(n.name,-1,o)}function GO(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=e.clone();return YO(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function KO(e,t){for(let n=0,r=qO(t);n<r.length;n++)if(e===r[n].name)return r[n]}function qO(e){return Array.isArray(e)?e:e.bones}function JO(e){let t=new Ef(e.bones[0]);return t.skeleton=e,t}function YO(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)YO(e.children[r],t.children[r],n)}var XO=t((()=>{J()})),ZO=/* @__PURE__ */ n({GLTFLoader:()=>dk});function QO(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function $O(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}function ek(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Hl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function tk(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function nk(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function rk(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function ik(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function ak(e){let t,n=e.extensions&&e.extensions[fk.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+ok(n.attributes):e.indices+`:`+ok(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+ok(e.targets[n]);return t}function ok(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function sk(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function ck(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}function lk(e,t,n){let r=t.attributes,i=new Wa;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new B(t[0],t[1],t[2]),new B(a[0],a[1],a[2])),e.normalized){let t=sk(Uk[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new B,t=new B;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=sk(Uk[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new xo;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function uk(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=qk[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return ji.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ji.workingColorSpace}" not supported.`),nk(e,t),lk(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:rk(e,t.targets,n)})}var dk,fk,pk,mk,hk,gk,_k,vk,yk,bk,xk,Sk,Ck,wk,Tk,Ek,Dk,Ok,kk,Ak,jk,Mk,Nk,Pk,Fk,Ik,Lk,Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k=t((()=>{J(),Wv(),XO(),dk=class extends gu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new gk(e)}),this.register(function(e){return new _k(e)}),this.register(function(e){return new vk(e)}),this.register(function(e){return new Dk(e)}),this.register(function(e){return new Ok(e)}),this.register(function(e){return new kk(e)}),this.register(function(e){return new bk(e)}),this.register(function(e){return new xk(e)}),this.register(function(e){return new Sk(e)}),this.register(function(e){return new Ck(e)}),this.register(function(e){return new hk(e)}),this.register(function(e){return new wk(e)}),this.register(function(e){return new yk(e)}),this.register(function(e){return new Ek(e)}),this.register(function(e){return new Tk(e)}),this.register(function(e){return new pk(e)}),this.register(function(e){return new Ak(e,fk.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new Ak(e,fk.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new jk(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=ed.extractUrlBase(e);a=ed.resolveURL(t,this.path)}else a=ed.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new yu(this.manager);s.setPriority(this.priority),s.setCache(this.cache),s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===Mk){try{a[fk.KHR_BINARY_GLTF]=new Fk(e)}catch(e){r&&r(e);return}i=JSON.parse(a[fk.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(/* @__PURE__ */ Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new Qk(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case fk.KHR_MATERIALS_UNLIT:a[t]=new mk;break;case fk.KHR_DRACO_MESH_COMPRESSION:a[t]=new Ik(i,this.dracoLoader);break;case fk.KHR_TEXTURE_TRANSFORM:a[t]=new Lk;break;case fk.KHR_MESH_QUANTIZATION:a[t]=new Rk;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}},fk={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DIFFUSE_ROUGHNESS:`KHR_materials_diffuse_roughness`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},pk=class{constructor(e){this.parser=e,this.name=fk.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new H(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Vr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new qu(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Wu(s),o.distance=c;break;case`spot`:o=new Hu(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),nk(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},mk=class{constructor(){this.name=fk.KHR_MATERIALS_UNLIT}getMaterialType(){return ss}extendParams(e,t,n){let r=[];e.color=new H(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Vr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Br))}return Promise.all(r)}},hk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},gk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new z(e,e)}return Promise.all(r)}},_k=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.diffuseRoughness=n.diffuseRoughnessFactor===void 0?0:n.diffuseRoughnessFactor,n.diffuseRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`diffuseRoughnessMap`,n.diffuseRoughnessTexture)),Promise.all(r)}},vk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_DISPERSION}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},yk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},bk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_SHEEN}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new H(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Vr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Br)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},xk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},Sk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_VOLUME}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new H().setRGB(i[0],i[1],i[2],Vr),Promise.all(r)}},Ck=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_IOR}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},wk=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_SPECULAR}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new H().setRGB(i[0],i[1],i[2],Vr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Br)),Promise.all(r)}},Tk=class{constructor(e){this.parser=e,this.name=fk.EXT_MATERIALS_BUMP}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},Ek=class{constructor(e){this.parser=e,this.name=fk.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return $O(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=$O(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},Dk=class{constructor(e){this.parser=e,this.name=fk.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},Ok=class{constructor(e){this.parser=e,this.name=fk.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},kk=class{constructor(e){this.parser=e,this.name=fk.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},Ak=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},jk=class{constructor(e){this.name=fk.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==Hk.TRIANGLES&&e.mode!==Hk.TRIANGLE_STRIP&&e.mode!==Hk.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new V,n=new B,a=new wi,s=new B(1,1,1),c=new Hs(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));let l=null;for(let e in o)if(e===`_COLOR_0`){let t=o[e];c.instanceColor=new Ps(t.array,t.itemSize,t.normalized)}else if(e!==`TRANSLATION`&&e!==`ROTATION`&&e!==`SCALE`){if(l===null){let e=c.geometry;l=new G,l.name=e.name;for(let t in e.attributes)l.setAttribute(t,e.attributes[t]);for(let t in e.morphAttributes)l.morphAttributes[t]=e.morphAttributes[t];e.index!==null&&l.setIndex(e.index),l.morphTargetsRelative=e.morphTargetsRelative;for(let t of e.groups)l.addGroup(t.start,t.count,t.materialIndex);e.boundingBox!==null&&(l.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(l.boundingSphere=e.boundingSphere.clone()),l.drawRange.start=e.drawRange.start,l.drawRange.count=e.drawRange.count,l.userData=Object.assign({},e.userData),c.geometry=l}let t=o[e];l.setAttribute(e,new Ps(t.array,t.itemSize,t.normalized))}ya.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},Mk=`glTF`,Nk=12,Pk={JSON:1313821514,BIN:5130562},Fk=class{constructor(e){this.name=fk.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Nk),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mk)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-Nk,i=new DataView(e,Nk),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===Pk.JSON){let r=new Uint8Array(e,Nk+a,t);this.content=n.decode(r)}else if(r===Pk.BIN){let n=Nk+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},Ik=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=fk.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=qk[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=qk[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=Uk[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Vr,n)})})}},Lk=class{constructor(){this.name=fk.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let t=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},Rk=class{constructor(){this.name=fk.KHR_MESH_QUANTIZATION}},zk=class extends $l{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},Bk=new wi,Vk=class extends zk{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return Bk.fromArray(i).normalize().toArray(i),i}},Hk={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Uk={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wk={9728:cn,9729:pn,9984:ln,9985:mn,9986:dn,9987:gn},Gk={33071:on,33648:sn,10497:an},Kk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qk={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},Jk={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Yk={CUBICSPLINE:void 0,LINEAR:Or,STEP:Dr},Xk={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`},Zk=new V,Qk=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new QO,this.associations=/* @__PURE__ */ new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?(this.textureLoader=new Eu(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new ld(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yu(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType(`arraybuffer`),(this.options.withCredentials||this.options.crossOrigin===`use-credentials`)&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return tk(i,a,r),nk(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[fk.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(ed.resolveURL(t.uri,r.path),e,void 0,function(){i(/* @__PURE__ */ Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=Kk[r.type],t=Uk[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new co(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=Kk[r.type],o=Uk[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new ko(f,u/s),t.cache.add(n,c)),p=new jo(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new co(f,a,d);if(r.sparse!==void 0){let t=Kk.SCALAR,n=Uk[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new co(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=Wk[n.magFilter]||1006,t.minFilter=Wk[n.minFilter]||1008,t.wrapS=Gk[n.wrapS]||1e3,t.wrapT=Gk[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1,l;if(t.isKTX2Loader===!0&&a.bufferView!==void 0)l=n.getDependency(`bufferView`,a.bufferView).then(function(e){return new Promise(function(n,r){t.parse(e,n,r)})});else{if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new zi(e);t.needsUpdate=!0,n(t)}),t.load(ed.resolveURL(e,i.path),a,void 0,r)})})}let u=l.then(function(e){return c===!0&&o.revokeObjectURL(s),nk(e,a),e.userData.mimeType=a.mimeType||ck(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[fk.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[fk.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[fk.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Cc,Lo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new uc,Lo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Hl}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[fk.KHR_MATERIALS_UNLIT]){let e=r[fk.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new H(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Vr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Br)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||Xk.OPAQUE;if(l===Xk.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===Xk.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==ss&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new z(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==ss&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==ss){let e=i.emissiveFactor;o.emissive=new H().setRGB(e[0],e[1],e[2],Vr)}return i.emissiveTexture!==void 0&&a!==ss&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Br)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),nk(n,i),t.associations.set(n,{materials:e}),i.extensions&&tk(r,n,i),n})}createUniqueName(e){let t=qd.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[fk.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return uk(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=ak(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[fk.KHR_DRACO_MESH_COMPRESSION]?i(o):uk(new G,o,t),o.mode===Hk.TRIANGLE_STRIP?e=e.then(e=>zv(e,1)):o.mode===Hk.TRIANGLE_FAN&&(e=e.then(e=>zv(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?ek(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(async function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===Hk.TRIANGLES||u.mode===Hk.TRIANGLE_STRIP||u.mode===Hk.TRIANGLE_FAN||u.mode===void 0){let e=i.isSkinnedMesh===!0,t=l.hasAttribute(`skinIndex`)&&l.hasAttribute(`skinWeight`);e&&t===!1&&console.warn(`THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.`),d=e&&t?new Os(l,f):new K(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights()}else if(u.mode===Hk.LINES)d=new xc(l,f);else if(u.mode===Hk.LINE_STRIP)d=new vc(l,f);else if(u.mode===Hk.LINE_LOOP)d=new Sc(l,f);else if(u.mode===Hk.POINTS)d=new Oc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&ik(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),nk(d,i),u.extensions&&tk(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&tk(r,c[0],i),c[0];let l=new ba;i.extensions&&tk(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r)console.warn(`THREE.GLTFLoader: Missing camera parameters.`);else return n.type===`perspective`?t=new Bu(Ci.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Gu(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),nk(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new V;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new Ns(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new fu(i,void 0,l);return nk(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,Zk)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new B().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new ks:t.length>1?new ba:t.length===1?t[0]:new ya,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),nk(o,i),i.extensions&&tk(n,o,i),i.matrix!==void 0){let e=new V;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new ba;n.name&&(i.name=r.createUniqueName(n.name)),nk(i,n),n.extensions&&tk(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(GO(n))}return r.associations=(e=>{let t=/* @__PURE__ */ new Map;for(let[e,n]of r.associations)(e instanceof Lo||e instanceof zi)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}Jk[i.path]===Jk.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(Jk[i.path]){case Jk.weights:l=su;break;case Jk.rotation:l=lu;break;case Jk.translation:case Jk.scale:l=du;break;default:switch(n.itemSize){case 1:l=su;break;default:l=du}}let u=r.interpolation===void 0?Or:Yk[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+Jk[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=sk(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof lu?Vk:zk)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}})),eA=/* @__PURE__ */ n({MeshoptDecoder:()=>tA}),tA,nA=t((()=>{tA=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G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PsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;self.ready.then(function(e){if(!t.id)return self.close();try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})()})),rA=/* @__PURE__ */ n({applyMorph:()=>oA,buildModel:()=>sA,gltfExtensionsUsed:()=>iA});function iA(e){let t=new Uint8Array(e),n;if(t.byteLength>=20&&new DataView(e).getUint32(0,!0)===1179937895){let r=new DataView(e).getUint32(12,!0);n=new TextDecoder().decode(t.subarray(20,20+r))}else n=new TextDecoder().decode(t);try{let e=JSON.parse(n);return Array.isArray(e.extensionsUsed)?e.extensionsUsed.filter(e=>typeof e==`string`):[]}catch{return[]}}async function aA(e){let t=cA.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([Promise.resolve().then(()=>($k(),ZO)),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=iA(r);if(i.includes(`KHR_draco_mesh_compression`))throw Error(`${e} uses Draco compression (KHR_draco_mesh_compression), which the Agent3D runtime does not decode. Re-export it without Draco (Blender: uncheck "Compression"), or convert it to meshopt with gltfpack (\`gltfpack -i in.glb -o out.glb -cc\`), then run \`agent3d assets optimize\`.`);let a=new t;if(i.includes(`EXT_meshopt_compression`)){let{MeshoptDecoder:e}=await Promise.resolve().then(()=>(nA(),eA));await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>cA.delete(e)),cA.set(e,t)),t}function oA(e,t){e.traverse(e=>{let n=e;if(n.isMesh&&n.morphTargetDictionary&&n.morphTargetInfluences)for(let[e,r]of Object.entries(t)){let t=n.morphTargetDictionary[e];t!==void 0&&typeof r==`number`&&(n.morphTargetInfluences[t]=r)}})}async function sA(e,t){let n=await aA(t.resolveAsset(e.src)),{clone:r}=await Promise.resolve().then(()=>(XO(),VO)),i=r(n.scene),a=new ba;a.add(i),i.updateMatrixWorld(!0);let o=new Wa().setFromObject(i);if(!o.isEmpty()){let t=o.getSize(new B),n=Math.max(t.x,t.y,t.z),r=e.fit&&n>0?e.fit/n:1;if(i.scale.multiplyScalar(r),e.center!==!1){let e=o.getCenter(new B);i.position.set(-e.x*r,-o.min.y*r,-e.z*r)}}i.traverse(t=>{let n=t;n.isMesh&&(n.castShadow=e.castShadow??!0,n.receiveShadow=e.receiveShadow??!1)}),e.material&&await bw(i,e.material,t),e.morph&&oA(i,e.morph);let s;if(n.animations.length){let r=new Zd(i),a=null,o=e=>typeof e==`number`||/^\d+$/.test(String(e))?n.animations[Number(e)]:n.animations.find(t=>t.name===e)??n.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),c=/* @__PURE__ */ new Set,l=r=>{let i=o(r);return!i&&!c.has(String(r))&&(c.add(String(r)),t.issue(`asset-load`,`Model ${e.id} has no animation clip "${r}" (clips: ${n.animations.map(e=>e.name).join(`, `)})`,`objects#${e.id}.animation.clip`)),i},u=(e,t={})=>{let n=l(e);if(!n)return;let i=r.clipAction(n);i.setLoop(t.loop===!1?wr:Tr,1/0),i.clampWhenFinished=t.loop===!1,i.timeScale=Q(t.speed,1),i.enabled=!0,a&&a!==i?(i.reset().setEffectiveWeight(1).play(),a.crossFadeTo(i,Q(t.crossfade,.3),!1)):i.setEffectiveWeight(1).play(),a=i},d=e=>{let t=l(e);if(!t)return null;let n=r.clipAction(t);return n.isRunning()||(n.enabled=!0,n.setLoop(Tr,1/0),n.play()),n},f={weight(e,t){d(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=d(e);n&&(n.timeScale=t)},time(e,t){let n=d(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},p=e.animation??{},m=()=>{r.stopAllAction(),a=null,u(p.clip??0,p),p.offset&&a&&(a.time=Math.max(0,p.offset));for(let[e,t]of Object.entries(p.blend??{}))f.weight(e,t);r.update(0)};s={mixer:r,clips:n.animations,play:u,control:f,reset:m},m()}return{object:a,animator:s}}var cA,lA=t((()=>{J(),zS(),jw(),cA=/* @__PURE__ */ new Map}));J(),Xg(),Tv(),zS(),jw();function uA(e){let t={position:e.position.clone(),quaternion:e.quaternion.clone(),scale:e.scale.clone(),visible:e.visible},n=e;return n.isLight&&(t.intensity=n.intensity,t.color=n.color.clone()),t}function dA(e,t){t.position&&e.position.set(t.position[0]??0,t.position[1]??0,t.position[2]??0),t.rotation&&e.rotation.set((t.rotation[0]??0)*LS,(t.rotation[1]??0)*LS,(t.rotation[2]??0)*LS),t.scale!==void 0&&(typeof t.scale==`number`?e.scale.setScalar(t.scale):e.scale.set(t.scale[0]??1,t.scale[1]??1,t.scale[2]??1))}var fA=/* @__PURE__ */ new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),pA=class e{def;ctx;scene=new ka;camera;rig;env=null;entries=/* @__PURE__ */ new Map;timeline=null;settleEntrances=!1;updaters=[];cameraRest0={position:new B,target:new B,fov:45,zoom:10,focus:void 0};motionHost;overrides;shots=[];focusWritten=!1;postfxParam=null;viewportH=600;input={pointer:{x:0,y:0,inside:!1},scroll:0,hovered:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ new Set,timelineT:null};disposed=!1;constructor(e,t){this.def=e,this.ctx=t,t.onUpdate=e=>this.updaters.push(e)}static async create(t,n,r,i,a=!1){let o=new e(t,n);return await o.build(r,i,a),o}async build(e,t,n){let{def:r,ctx:i}=this;{this.camera=wT(r.camera,e),this.rig=await kT(r.camera,this.camera,t,i.deterministic),this.cameraRest0.position.copy(this.rig.rest.position),this.cameraRest0.target.copy(this.rig.rest.target),this.cameraRest0.fov=this.rig.rest.fov,this.cameraRest0.zoom=this.rig.rest.zoom;let n=r.postfx?.find(e=>e.type===`dof`);this.cameraRest0.focus=n&&typeof n.focus==`number`?n.focus:n?8:void 0,this.rig.rest.focus=this.cameraRest0.focus;let a=AD(r.environment??{background:`#ffffff`},this.scene,this.camera,!!r.target?.transparent,i),o=Promise.all((r.lights??[]).map((e,t)=>this.addLight(e,t))),s=/* @__PURE__ */ new Map,c=r.objects??[],l=e=>e.attach===`camera`?this.camera:this.scene;c.some(e=>e.attach===`camera`)&&this.scene.add(this.camera),await Promise.all(c.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(e=>this.addObject(e,l(e),void 0,s))),mA(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,l(e),void 0,s)));let u=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(u.get(e.userData.a3dId)??-1)-(u.get(t.userData.a3dId)??-1)),this.env=await a;for(let e of this.env.objects)this.scene.add(e);if(await o,this.canonicalOrder(r),this.motionHost={object:e=>this.entries.get(e)?.object??null,select:e=>this.select(e),camera:this.rig.rest,scene:this.scene,renderer:i.renderer,postfx:{set:(e,t,n)=>this.postfxParam?.(e,t,n),base:(e,t)=>{let n=Ox(r.postfx).find(t=>t.type===e)?.[t];return typeof n==`number`||typeof n==`string`?n:void 0}},clips:e=>this.entries.get(e)?.animator?.control,issue:i.issue,seed:r.seed??1},this.overrides=new Gw(this.motionHost),this.shots=Zw(r.camera?.shots),r.timeline){this.timeline=Uw(r.timeline,this.motionHost);for(let e of this.timeline.targets){let t=this.entries.get(e);t&&(t.animated=!0)}}for(let e of r.interactions??[]){if(e.target&&(e.on===`click`||e.on===`hover`||e.on===`hoverEnd`)){let t=this.entries.get(e.target);t&&(t.interactive=!0)}for(let t of e.do??[]){let e=t.set?.path;if(typeof e==`string`)for(let t of this.overrides.idsOf(e)){let e=this.entries.get(t);e&&(e.animated=!0)}}}this.fitShadows()}}canonicalOrder(e){let t=this.entries,n=/* @__PURE__ */ new Map,r=e=>{let r=t.get(e);r&&!n.has(e)&&n.set(e,r)};(e.lights??[]).forEach((e,t)=>r(e.id??`light${t}`));let i=e=>{for(let n of e){r(n.id);let e=`${n.id}/`;for(let i of t.keys())i.startsWith(e)&&t.get(i).parentId===n.id&&r(i);if(!n.children?.length)continue;let a=t.get(n.id)?.object;if(a){let e=new Map(n.children.map((e,t)=>[e.id,t]));a.children.sort((t,n)=>(e.get(t.userData.a3dId)??-1)-(e.get(n.userData.a3dId)??-1))}i(n.children)}};i(e.objects??[]);for(let[e,r]of t)n.has(e)||n.set(e,r);this.entries=n}async overrideGeneratorMaterial(e,t,n){let r=lw(t),i=await yw(t,n,{vertexColors:r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map}),a=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&a.push(e)});for(let e of a)e.material.dispose(),e.material=i,pw(i,e.geometry)}rngFor(e,t){return dv(t??fv(this.def.seed??1,e))}behaviourContext(e){let t=this;return{object:e.object,base:{position:e.rest.position,rotation:new na().setFromQuaternion(e.rest.quaternion),scale:e.rest.scale},get pointer(){return t.input.pointer},hovered:()=>t.input.hovered.has(e.id),clicked:()=>t.input.clicked.has(e.id),scroll:()=>t.input.scroll,get camera(){return t.camera},rng:this.rngFor(e.id+`:behaviours`),find:e=>e===`camera`?t.camera:t.entries.get(e)?.object??null}}attachBehaviours(e){let t=e.def.behaviours??[];e.runners=[];for(let n of t){let t=FC[n.type];t?(e.runners.push(HC(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),(fA.has(n.type)||n.when===`hover`||n.when===`click`)&&(e.interactive=!0)):this.ctx.issue(`unknown-catalog-id`,`Unknown behaviour "${n.type}"`,`objects#${e.id}.behaviours`)}e.runners.length&&(e.animated=!0)}resetBehaviours(){for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.def.behaviours?.length&&this.attachBehaviours(e),e.animator?.reset?e.animator.reset():e.animator?.mixer.setTime(0)}this.overrides?.reset()}async addLight(e,t){let n=await oE(e,this.def.environment?.shadows),r=e.id??`light${t}`;this.scene.add(n),(n instanceof qu||n instanceof Hu)&&this.scene.add(n.target),n.userData.a3dId=r;let i={id:r,kind:`light`,def:e,object:n,rest:uA(n),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(r,i),this.attachBehaviours(i)}async addObject(e,t,n,r){let i=this.ctx,a,o,s,c,l=[],u=e.kind!==`particles`&&e.kind!==`generator`;try{switch(e.kind){case`mesh`:{let t=FD(e.geometry),n=await yw(e.material,i,{defaultColor:`#dddddd`});pw(n,t),a=new K(t,n);break}case`text`:{let{buildText:t}=await Promise.resolve().then(()=>(SO(),YD)),n=await i.track(t(e,i));a=n.object,l=n.letters;break}case`svg`:{let{buildSvg:t}=await Promise.resolve().then(()=>(BO(),jO));a=await i.track(t(e,i));break}case`model`:{let{buildModel:t}=await Promise.resolve().then(()=>(lA(),rA)),n=await i.track(t(e,i));a=n.object,s=n.animator;break}case`instances`:{let t=FD(e.geometry),n=await yw(e.material,i,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});pw(n,t),a=LD(e,t,n,this.rngFor(e.id,e.layout.seed),e=>AS(e));break}case`particles`:{c=YC(e,this.rngFor(e.id,e.seed)),c.setViewport(this.viewportH),a=c.points;let t=c;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await i.generators())[e.generator];if(!t){i.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),a=new ba;break}let n=Lg.find(t=>t.id===e.generator),s=jS(n,e.params??{}),c=e.scale,l={position:[...e.position??[0,0,0]],scale:typeof c==`number`?[c,c,c]:c?[...c]:[1,1,1]},u={...i,siblings:r,rng:this.rngFor(e.id,e.seed),placement:l};if(o=await i.track(Promise.resolve(t(s,u))),a=o.object,o.update){let e=o.update.bind(o);this.updaters.push((t,n)=>e(t,n))}r.set(e.id,o),e.material&&n?.material&&await this.overrideGeneratorMaterial(a,e.material,i);break}default:a=new ba}}catch(t){i.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),a=new ba}if(this.disposed)return null;a.name=e.name??e.id,a.userData={...e.userData??{},...a.userData,a3dId:e.id,tags:e.tags??[]},dA(a,e),e.visible===!1&&(a.visible=!1);let d=e.castShadow??(u?!0:void 0),f=e.receiveShadow??(u?!0:void 0);(d!==void 0||f!==void 0)&&a.traverse(e=>{e.isMesh&&(d!==void 0&&(e.castShadow=d),f!==void 0&&(e.receiveShadow=f))}),t.add(a);let p={id:e.id,kind:e.kind,def:e,object:a,rest:uA(a),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:o,animator:s,particles:c,interactive:!!e.href};this.entries.set(e.id,p),this.attachBehaviours(p);for(let t of l){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:uA(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(HC(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=/* @__PURE__ */ new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,a,e.id,t))),mA(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,a,e.id,t)))}return p}removeEntry(e){let t=this.entries.get(e);if(t){t.object.traverse(t=>{let n=t.userData.a3dId;n&&n!==e&&this.entries.delete(n)}),t.object.removeFromParent();for(let e of t.runners)e.dispose();this.entries.delete(e)}}idsFor(e){let t=[];for(let n=e;n;n=n.parent){let e=n.userData?.a3dId;e&&this.entries.has(e)&&t.push(e)}return t}select(e){if(e.startsWith(`tag:`)){let t=e.slice(4),n=[],r=e=>{for(let i of e??[])i.tags?.includes(t)&&this.entries.has(i.id)&&n.push(i.id),r(i.children)};return r(this.def.objects),n}if(e.startsWith(`children:`)){let t=e.slice(9);return[...this.entries.values()].filter(e=>e.parentId===t).map(e=>e.id)}return Vw(e,{object:()=>null,camera:null,issue:()=>void 0}).filter(e=>e!==``)}objectPosition(e){let t=this.entries.get(e);return t?t.object.getWorldPosition(new B):null}interactiveRoots(){let e=[];for(let t of this.entries.values())t.interactive&&t.kind!==`light`&&e.push(t.object);return e}fitShadows(){let e=[];if(this.scene.traverse(t=>{t instanceof qu&&t.castShadow&&e.push(t)}),!e.length)return;let t=new Wa,n=new Wa;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(n.setFromObject(e.object),n.isEmpty()||n.getSize(new B).length()>200||t.union(n));t.isEmpty()&&t.set(new B(-5,-1,-5),new B(5,5,5));let r=this.env?.ground?this.env.ground.position.y:t.min.y;t.expandByPoint(new B(t.min.x,r,t.min.z)),t.expandByPoint(new B(t.max.x,r,t.max.z)),t.expandByScalar(.3);for(let n of e)sE(n,t)}setViewport(e,t,n){this.viewportH=t*n;let r=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(this.def.target?.aspect??``),i=r?Number(r[1])/Number(r[2]):void 0;DT(this.camera,this.def.camera,e/Math.max(t,1),i&&Number.isFinite(i)&&i>0?i:void 0);for(let e of this.entries.values())e.particles?.setViewport(this.viewportH)}frame(e,t,n,r){this.input=n;for(let e of this.entries.values()){if(!e.animated)continue;let t=e.object;t.position.copy(e.rest.position),t.quaternion.copy(e.rest.quaternion),t.scale.copy(e.rest.scale),t.visible=e.rest.visible;let n=t;n.isLight&&e.rest.intensity!==void 0&&(n.intensity=e.rest.intensity,e.rest.color&&!this.timeline?.targets.has(e.id)&&n.color.copy(e.rest.color))}let i=this.def.timeline?n.timelineT??0:e;if(this.shots.length||this.timeline?.animatesCamera){let e=this.rig.rest;if(e.position.copy(this.cameraRest0.position),e.target.copy(this.cameraRest0.target),e.fov=this.cameraRest0.fov,e.zoom=this.cameraRest0.zoom,e.focus=this.cameraRest0.focus,this.shots.length){let t=Qw(this.shots,i,e,{objectPosition:e=>this.objectPosition(e)});e.position.copy(t.position),e.target.copy(t.target),e.fov=t.fov,e.focus=t.focus}}this.timeline&&n.timelineT!==null&&this.timeline.apply(n.timelineT),this.overrides?.apply(e),this.rig.rest.focus!==void 0&&(this.focusWritten||this.rig.rest.focus!==this.cameraRest0.focus)&&(this.postfxParam?.(`dof`,`focus`,this.rig.rest.focus),this.focusWritten=!0);for(let n of this.entries.values())for(let r of n.runners)r.late||r.step(e,t);for(let e of this.entries.values()){let t=e.object.userData.setPointer?e.object:e.object.children[0],r=t?.userData.setPointer;if(!r)continue;r(n.pointer.x,n.pointer.y);let i=t.userData.setPointerLocal;if(i&&this.camera){let e=this.pointerOnPlane(t,n.pointer.x,n.pointer.y);e&&i(e.x,e.z)}}for(let n of this.updaters)n(e,t);for(let e of this.entries.values())e.animator?.mixer.update(t);let a=this.def.camera?.lookAt;this.rig.update(e,t,{pointer:n.pointer,scroll:n.scroll,followTarget:r,lookAt:a?this.objectPosition(a):null}),this.camera.updateMatrixWorld();for(let n of this.entries.values())for(let r of n.runners)r.late&&r.step(e,t)}hasStatefulMotion(){if(this.def.camera?.controls===`follow`&&this.def.camera.follow)return!0;for(let e of this.entries.values())for(let t of e.runners)if(t.stateful)return!0;return!1}pointerRay=new of;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new z(t,n),this.camera);let r=e.matrixWorld.clone().invert(),i=this.pointerRay.ray.clone().applyMatrix4(r);if(Math.abs(i.direction.y)<1e-6)return null;let a=-i.origin.y/i.direction.y;return a<0?null:i.origin.addScaledVector(i.direction,a)}dispose(){this.disposed=!0;for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.built?.dispose?.()}this.rig?.dispose(),this.env?.dispose(),PS(this.scene);let e=this.scene.environment;e&&e.dispose();let t=this.scene.background;t&&t.isTexture&&t.dispose(),this.scene.traverse(e=>e.shadow?.dispose?.()),this.entries.clear()}};function mA(e,t){let n=[...e.entries()],r=new Map(t.map((e,t)=>[e.id,t]));n.sort((e,t)=>(r.get(e[0])??1/0)-(r.get(t[0])??1/0)),e.clear();for(let[t,r]of n)e.set(t,r)}var hA=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function gA(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:/* @__PURE__ */ new Set,pressed:/* @__PURE__ */ new Set,swipe:null,clicks:[],scroll:0}}function _A(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function vA(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function yA(e,t,n){let r=e.ownerDocument.defaultView??window,i=!1,a=!1,o=null,s=t=>{let n=e.getBoundingClientRect();return{x:(t.clientX-n.left)/Math.max(n.width,1)*2-1,y:-((t.clientY-n.top)/Math.max(n.height,1)*2-1)}},c=e=>{let r=s(e);t.pointer.x=r.x,t.pointer.y=r.y,t.pointer.inside=!0,n.onPointerMove?.()},l=()=>{a=!0,t.pointer.inside=!0},u=()=>{a=!1,t.pointer.inside=!1,t.pointer.down=!1},d=e=>{i=!0;let n=s(e);t.pointer.x=n.x,t.pointer.y=n.y,t.pointer.down=!0,t.pointer.justPressed=!0,o={x:n.x,y:n.y,t:performance.now(),px:e.clientX,py:e.clientY}},f=e=>{if(t.pointer.down=!1,!o)return;let n=e.clientX-o.px,r=e.clientY-o.py,i=Math.hypot(n,r);i<8?t.clicks.push(s(e)):i>30&&performance.now()-o.t<600&&(t.swipe=Math.abs(n)>Math.abs(r)?n>0?`right`:`left`:r>0?`down`:`up`),o=null},p=()=>i||a||e.contains(e.ownerDocument.activeElement),m=e=>{if(!p())return;let r=e.target;(!r||r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&!r.isContentEditable)&&(vA(t,e.code,e.type===`keydown`),n.game&&hA.has(e.code)&&e.preventDefault())},h=()=>t.keys.clear(),g=t=>{e.contains(t.target)||(i=!1)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerenter`,l),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointerdown`,d),r.addEventListener(`pointerup`,f),r.addEventListener(`keydown`,m,{passive:!1}),r.addEventListener(`keyup`,m),r.addEventListener(`blur`,h),r.document.addEventListener(`pointerdown`,g,!0),n.game&&(e.style.touchAction=`none`,e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`)),{dispose(){e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerenter`,l),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointerdown`,d),r.removeEventListener(`pointerup`,f),r.removeEventListener(`keydown`,m),r.removeEventListener(`keyup`,m),r.removeEventListener(`blur`,h),r.document.removeEventListener(`pointerdown`,g,!0)}}}function bA(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=e.getBoundingClientRect(),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var xA=(e,t,n)=>e<t?t:e>n?n:e;function SA(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function CA(e,t){let n=Math.max(e.duration||0,.001);if(t===`timeline`)return{from:0,to:n,loop:e.loop,speed:1};let r=e.segments?.[t];if(!r)return null;let i=Array.isArray(r)?{from:r[0],to:r[1]}:r;return{from:xA(SA(i.from,e.markers,0),0,n),to:xA(SA(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function wA(e,t,n){let r=Math.abs(e.to-e.from),i=e.to>=e.from?1:-1,a=n===void 0?0:Math.abs(n-e.from),o=r<=0?0:YS(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function TA(e,t,n){let r=Math.max(e.duration||0,.001),i=n&&n!==`seek`&&n!==`timeline`&&e.segments?.[n]?n:``;if(!i)for(let n of Object.keys(e.segments??{})){let a=CA(e,n);if(!a)continue;let o=Math.min(a.from,a.to),s=Math.max(a.from,a.to);if(t>=o&&(t<s||s>=r-1e-6&&t<=s)){i=n;break}}let a=``,o=-1/0;for(let[n,r]of Object.entries(e.markers??{}))typeof r==`number`&&r<=t+1e-6&&r>=o&&(o=r,a=n);return{time:t,duration:r,progress:xA(t/r,0,1),segment:i,marker:a}}var EA=class{def;hoverClock=0;clickAt=-1;active=null;toggled=/* @__PURE__ */ new Map;prevLocal=null;lastLocal=0;lastT=0;pending=[];constructor(e){this.def=e}get duration(){return Math.max(this.def.duration||0,.001)}reset(){this.hoverClock=0,this.clickAt=-1,this.active=null,this.toggled.clear(),this.prevLocal=null,this.lastLocal=0,this.lastT=0,this.pending=[]}get local(){return this.lastLocal}play(e,t,n={}){let r=CA(this.def,e);if(!r)return!1;let i=n.reverse?{...r,from:r.to,to:r.from}:r;return this.active={...i,name:e,start:t},this.toggled.set(e,!n.reverse),!0}toggle(e,t){let n=CA(this.def,e);if(!n)return!1;let r=!this.toggled.get(e),i=r?n:{...n,from:n.to,to:n.from},a=this.active?.name===e?this.lastLocal:void 0,o=a!==void 0&&a>=Math.min(n.from,n.to)&&a<=Math.max(n.from,n.to);return this.active={...i,loop:!1,name:e,start:t,startLocal:o?a:void 0},this.toggled.set(e,r),!0}seek(e,t){let n=xA(SA(e,this.def.markers,0),0,this.duration);this.active={name:`seek`,from:n,to:n,loop:!1,speed:1,start:t}}autoRange(){let e=typeof this.def.autoplay==`string`?this.def.autoplay:null,t=e?CA(this.def,e):null,n=typeof this.def.speed==`number`&&this.def.speed>0?this.def.speed:1;return t?{...t,speed:t.speed*n}:{from:0,to:this.duration,loop:this.def.loop,speed:n}}autoLocal(e){let t=this.autoRange(),n=this.def.trigger??`visible`;if(e.staticMotion)return typeof this.def.autoplay==`string`?t.to:wA({...t,speed:1},e.posterTime??0);if(n===`manual`||this.def.autoplay===!1)return t.from;if(n===`scroll`)return t.from+(t.to-t.from)*xA(e.scroll,0,1);if(e.deterministic)return wA(t,e.t);switch(n){case`hover`:{this.hoverClock+=e.hovered?e.dt:t.loop?0:-e.dt;let n=Math.abs(t.to-t.from)/t.speed;return t.loop||(this.hoverClock=xA(this.hoverClock,0,n)),wA(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:wA(t,e.t-this.clickAt);default:return wA(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?wA(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=xA(t,0,this.duration),this.collectMarkers(this.prevLocal,t,e.t<this.lastT),this.prevLocal=t,this.lastLocal=t,this.lastT=e.t,t}collectMarkers(e,t,n){let r=this.def.markers;if(r&&!n)for(let[n,i]of Object.entries(r)){if(typeof i!=`number`)continue;let r;r=e===null?i<=t:t>e?i>e&&i<=t:t<e?this.isLoopingForward()?i>e||i<=t:i<e&&i>=t:!1,r&&this.pending.push({name:n,time:i})}}isLoopingForward(){let e=this.active??this.autoRange();return!!e.loop&&e.loop!==`pingpong`&&e.to>=e.from}info(){return TA(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function DA(e,t){if(typeof e!=`string`||!e.trim())return null;try{let n=new URL(e.trim(),t);return n.protocol===`http:`||n.protocol===`https:`?n.href:null}catch{return null}}var OA=/* @__PURE__ */ new Set([`click`,`key`]),kA=class{defs;host;hoverPrev=/* @__PURE__ */ new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=/* @__PURE__ */ new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=/* @__PURE__ */ new Set;for(let t of this.defs)t.target&&(t.on===`click`||t.on===`hover`||t.on===`hoverEnd`)&&e.add(t.target);return e}reset(){this.hoverPrev.clear(),this.insidePrev=!1,this.scrollPrev=null,this.visibleFired=!1,this.fired.clear(),this.queue=[]}event(e,t){this.queue.length<64&&this.queue.push({name:e,payload:t})}fire(e,t,n){let r=0;return this.defs.forEach((i,a)=>{if(i.on===e&&!(e===`key`?i.key!==t:e===`event`?i.event!==t:(i.target??void 0)!==t)&&!(i.once&&this.fired.has(a))){this.fired.add(a),r++;for(let t of i.do??[])this.run(t,n&&OA.has(e))}}),r}step(e){for(let t of this.targets()){let n=e.hovered.has(t),r=this.hoverPrev.has(t);n&&!r&&this.fire(`hover`,t,!1),!n&&r&&this.fire(`hoverEnd`,t,!1)}this.hoverPrev=new Set([...e.hovered].filter(e=>this.isTarget(e))),e.pointerInside!==this.insidePrev&&this.fire(e.pointerInside?`hover`:`hoverEnd`,void 0,!1),this.insidePrev=e.pointerInside;for(let t of e.clicked)this.fire(`click`,t,e.userGesture);e.canvasClicked&&this.fire(`click`,void 0,e.userGesture);for(let t of e.pressed)this.fire(`key`,t,e.userGesture);e.visible&&!this.visibleFired&&(this.visibleFired=!0,this.fire(`visible`,void 0,!1)),this.scrollPrev!==null&&e.scroll!==this.scrollPrev&&this.defs.forEach((t,n)=>{if(t.on===`scroll`&&typeof t.at==`number`&&!(!(this.scrollPrev<t.at&&e.scroll>=t.at)||t.once&&this.fired.has(n))){this.fired.add(n);for(let e of t.do??[])this.run(e,!1)}}),this.scrollPrev=e.scroll,this.flush()}flush(){for(let e=0;this.queue.length&&e<16;e++){let e=this.queue;this.queue=[];for(let t of e)this.fire(`event`,t.name,!1)}this.queue=[]}isTarget(e){return this.defs.some(t=>t.target===e)}run(e,t){let n=e;if(typeof n.play==`string`)this.host.play(n.play,n.reverse===!0);else if(typeof n.toggle==`string`)this.host.toggle(n.toggle);else if(typeof n.seek==`number`||typeof n.seek==`string`)this.host.seek(n.seek);else if(n.set&&typeof n.set==`object`){let e=n.set;typeof e.path==`string`&&e.value!==void 0&&this.host.set(e.path,e.value,typeof n.duration==`number`?n.duration:0,typeof n.ease==`string`?n.ease:void 0)}else typeof n.emit==`string`?this.host.emit(n.emit,n.payload):typeof n.openUrl==`string`?t?this.host.openUrl(n.openUrl,typeof n.newTab==`boolean`?n.newTab:void 0):this.host.emit(`openUrl`,{url:n.openUrl,blocked:!0}):n.playClip!==void 0&&typeof n.target==`string`&&this.host.playClip(n.target,n.playClip,{loop:n.loop,speed:n.speed,crossfade:n.crossfade})}},AA=`top bottom`,jA=`bottom top`;function MA(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:e.endsWith(`%`)?Number(e.slice(0,-1))/100*t:e.endsWith(`px`)?Number(e.slice(0,-2)):null}function NA(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=MA(r[0],t),a=MA(r[1],n);return i===null||a===null?null:i-a}function PA(e,t,n,r=AA,i=jA){let a=NA(r,t,n)??-n,o=NA(i,t,n)??t,s=0-e;if(Math.abs(o-a)<1e-6)return+(s>=o);let c=(s-a)/(o-a);return c<0?0:c>1?1:c}J();var FA=8e3;function IA(e,t,n=FA){let r=[],i=0;if(e.traverseVisible(e=>{let t=e;if(!(t.isMesh||e.isLine)||e.isPoints)return;let n=t.geometry?.getAttribute(`position`);if(!n)return;let a=t.isInstancedMesh?t.count:1;a&&(r.push(t),i+=n.count*a)}),!r.length||!i)return null;let a=Math.max(1,Math.ceil(i/n)),o=new B,s=new V,c=new V,l=0,u=0;for(let e of r){let n=e.geometry.getAttribute(`position`),r=e,i=e.isSkinnedMesh?e:null,d=r.isInstancedMesh?r.count:1;for(let f=0;f<d;f++){r.isInstancedMesh?c.multiplyMatrices(e.matrixWorld,(r.getMatrixAt(f,s),s)):c.copy(e.matrixWorld);for(let e=f%a;e<n.count;e+=a)if(o.fromBufferAttribute(n,e),i&&i.applyBoneTransform(e,o),o.applyMatrix4(c),t.containsPoint(o)?l++:u++,l&&u)return`partial`}}return!l&&!u?null:u?`partial`:`full`}function LA(e,t,n){if(n!==`parts`){let r=e.worldToLocal(t.clone()),i=n.heightAt(r.x,r.z);return Number.isFinite(i)&&r.y<i}let r=new Wa,i=new V,a=!1;return e.traverseVisible(e=>{let n=e;if(a||!n.isMesh||!n.geometry)return;n.geometry.boundingBox||n.geometry.computeBoundingBox();let o=n.geometry.boundingBox,s=e;if(s.isInstancedMesh)for(let e=0;e<s.count&&!a;e++)s.getMatrixAt(e,i),r.copy(o).applyMatrix4(i.premultiply(s.matrixWorld)).containsPoint(t)&&(a=zA(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=zA(n,t,r))}),a}var RA=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)];function zA(e,t,n,r){let i=(Array.isArray(e.material)?e.material:[e.material]).filter(Boolean),a=i.map(e=>e.side);for(let e of i)e.side=2;try{let i=new of;return i.far=n.getSize(new B).length()+.001,RA.every(n=>(i.set(t,n),i.intersectObject(e,!1).some(e=>r===void 0||e.instanceId===r)))}finally{i.forEach((e,t)=>e.side=a[t])}}function BA(e,t,n){let r=e.createGain();return r.gain.value=Math.max(0,n),r.connect(t),{ctx:e,out:r,sources:[],timers:[],stopped:!1}}function VA(e,t=.06){if(e.stopped)return;e.stopped=!0;for(let t of e.timers)clearTimeout(t);let n=e.ctx.currentTime;try{e.out.gain.cancelScheduledValues(n),e.out.gain.setValueAtTime(e.out.gain.value,n),e.out.gain.linearRampToValueAtTime(0,n+t)}catch{}for(let r of e.sources)try{r.stop(n+t+.02)}catch{}setTimeout(()=>{try{e.out.disconnect()}catch{}},(t+.1)*1e3)}function HA(e,t){return e.timers.push(setTimeout(()=>VA(e,.01),(t+.2)*1e3)),{stop:()=>VA(e)}}function UA(e,t){let{ctx:n}=e,r=n.currentTime+(t.start??0),i=n.createOscillator();i.type=t.type??`square`,i.frequency.setValueAtTime(t.freq,r),t.to&&i.frequency.exponentialRampToValueAtTime(Math.max(1,t.to),r+t.dur),t.detune&&(i.detune.value=t.detune);let a=n.createGain(),o=t.gain??.3,s=t.attack??.005;a.gain.setValueAtTime(1e-4,r),a.gain.linearRampToValueAtTime(o,r+s);let c=Math.min(t.release??t.dur,t.dur);a.gain.setValueAtTime(o,r+Math.max(s,t.dur-c)),a.gain.exponentialRampToValueAtTime(1e-4,r+t.dur);let l=i;if(t.filter){let e=n.createBiquadFilter();e.type=t.filter.type,e.frequency.setValueAtTime(t.filter.freq,r),t.filter.to&&e.frequency.exponentialRampToValueAtTime(Math.max(10,t.filter.to),r+t.dur),e.Q.value=t.filter.q??1,i.connect(e),l=e}if(t.vibrato){let a=n.createOscillator();a.frequency.value=t.vibrato.rate;let o=n.createGain();o.gain.value=t.vibrato.depth,a.connect(o),o.connect(i.detune),a.start(r),a.stop(r+t.dur+.05),e.sources.push(a)}l.connect(a),a.connect(t.dest??e.out),i.start(r),i.stop(r+t.dur+.05),e.sources.push(i)}function WA(e){let t=qA.get(e);if(!t){t=e.createBuffer(1,Math.floor(e.sampleRate*2),e.sampleRate);let n=t.getChannelData(0),r=625341585;for(let e=0;e<n.length;e++)r^=r<<13,r^=r>>>17,r^=r<<5,n[e]=(r>>>0)/4294967296*2-1;qA.set(e,t)}return t}function GA(e,t){let{ctx:n}=e,r=n.currentTime+(t.start??0),i=n.createBufferSource();i.buffer=WA(n),i.loop=!0;let a=n.createGain(),o=t.gain??.3;a.gain.setValueAtTime(1e-4,r),a.gain.linearRampToValueAtTime(o,r+(t.attack??.003)),a.gain.exponentialRampToValueAtTime(1e-4,r+t.dur);let s=i;if(t.filter){let e=n.createBiquadFilter();e.type=t.filter.type,e.Q.value=t.filter.q??1,e.frequency.setValueAtTime(t.filter.freq,r),t.filter.mid&&e.frequency.exponentialRampToValueAtTime(t.filter.mid,r+t.dur*.45),t.filter.to&&e.frequency.exponentialRampToValueAtTime(t.filter.to,r+t.dur),i.connect(e),s=e}s.connect(a),a.connect(t.dest??e.out),i.start(r,r*.37%1.5),i.stop(r+t.dur+.05),e.sources.push(i)}function KA(e,t,n){let{ctx:r}=e,i=r.currentTime+.06,a=0,o=()=>{if(!e.stopped){for(;i<r.currentTime+.15;)n(a,i-r.currentTime),a++,i+=t;e.sources.length>400&&e.sources.splice(0,e.sources.length-200),e.timers.length=0,e.timers.push(setTimeout(o,40))}};o()}var qA,JA,YA=t((()=>{qA=/* @__PURE__ */ new WeakMap,JA=e=>440*2**((e-69)/12)})),XA=/* @__PURE__ */ n({SOUND_IMPLS:()=>uj}),ZA,QA,$A,ej,tj,nj,rj,ij,aj,oj,sj,cj,lj,uj,dj=t((()=>{YA(),ZA=(e,t)=>({play(n,r,i){let a=BA(n,r,i);return t(a),HA(a,e)}}),QA=ZA(.4,e=>{UA(e,{type:`square`,freq:JA(83),dur:.08,gain:.18,release:.02}),UA(e,{type:`square`,freq:JA(88),start:.075,dur:.32,gain:.18,release:.3}),UA(e,{type:`triangle`,freq:JA(100),start:.075,dur:.25,gain:.06,release:.24})}),$A=ZA(.3,e=>{UA(e,{type:`square`,freq:220,to:660,dur:.2,gain:.16,release:.12,filter:{type:`lowpass`,freq:2400}}),UA(e,{type:`triangle`,freq:330,to:990,dur:.18,gain:.12,release:.1})}),ej=ZA(.3,e=>{GA(e,{dur:.16,gain:.45,filter:{type:`lowpass`,freq:2200,to:300,q:.7}}),UA(e,{type:`sine`,freq:180,to:55,dur:.18,gain:.5,release:.15}),UA(e,{type:`square`,freq:120,to:60,dur:.08,gain:.12,release:.06})}),tj=ZA(1.6,e=>{GA(e,{dur:1.4,gain:.7,attack:.01,filter:{type:`lowpass`,freq:2600,to:90,q:.8}}),GA(e,{dur:.25,gain:.35,filter:{type:`highpass`,freq:1200,q:.5}}),UA(e,{type:`sine`,freq:90,to:28,dur:1.1,gain:.7,release:1}),UA(e,{type:`triangle`,freq:60,to:30,start:.05,dur:.8,gain:.3,release:.7})}),nj=ZA(.1,e=>{UA(e,{type:`sine`,freq:1700,to:900,dur:.035,gain:.25,release:.03}),GA(e,{dur:.02,gain:.12,filter:{type:`highpass`,freq:4e3}})}),rj=ZA(.8,e=>{let t=[60,64,67,72,76,79,84];t.forEach((t,n)=>{UA(e,{type:`square`,freq:JA(t),start:n*.06,dur:.1,gain:.13,release:.06,filter:{type:`lowpass`,freq:3500}}),UA(e,{type:`triangle`,freq:JA(t+12),start:n*.06+.02,dur:.12,gain:.07,release:.1})}),UA(e,{type:`square`,freq:JA(84),start:t.length*.06,dur:.3,gain:.1,release:.28,vibrato:{rate:9,depth:35},filter:{type:`lowpass`,freq:3e3}})}),ij=ZA(.35,e=>{UA(e,{type:`sawtooth`,freq:1800,to:160,dur:.24,gain:.16,release:.2,filter:{type:`bandpass`,freq:2400,to:400,q:2}}),UA(e,{type:`square`,freq:1200,to:120,dur:.18,gain:.07,release:.15})}),aj=ZA(1.6,e=>{let t=[72,76,79,84];t.forEach((t,n)=>{UA(e,{type:`square`,freq:JA(t),start:n*.12,dur:.14,gain:.12,release:.08,filter:{type:`lowpass`,freq:3200}}),UA(e,{type:`triangle`,freq:JA(t-12),start:n*.12,dur:.14,gain:.15,release:.1})});let n=t.length*.12+.04;for(let t of[79,84,88])UA(e,{type:`square`,freq:JA(t),start:n,dur:.9,gain:.08,attack:.01,release:.7,vibrato:{rate:6,depth:12},filter:{type:`lowpass`,freq:2800}});UA(e,{type:`triangle`,freq:JA(60),start:n,dur:.9,gain:.2,release:.6})}),oj=ZA(1.6,e=>{[67,66,65].forEach((t,n)=>UA(e,{type:`sawtooth`,freq:JA(t),start:n*.25,dur:.24,gain:.12,release:.1,filter:{type:`lowpass`,freq:1400}})),UA(e,{type:`sawtooth`,freq:JA(64),to:JA(52),start:.75,dur:.8,gain:.13,release:.5,vibrato:{rate:7,depth:40},filter:{type:`lowpass`,freq:1400,to:400}}),UA(e,{type:`triangle`,freq:JA(40),start:.75,dur:.8,gain:.18,release:.6})}),sj=ZA(.8,e=>{GA(e,{dur:.65,gain:.45,attack:.25,filter:{type:`bandpass`,freq:300,mid:2600,to:500,q:1.4}}),GA(e,{dur:.5,gain:.15,attack:.2,filter:{type:`lowpass`,freq:600,to:200}})}),cj={play(e,t,n){let r=BA(e,t,n),i=e.createBiquadFilter();i.type=`lowpass`,i.frequency.value=900,i.Q.value=.6;let a=e.createOscillator();a.frequency.value=.07;let o=e.createGain();o.gain.value=450,a.connect(o),o.connect(i.frequency),a.start(),r.sources.push(a);let s=e.createDelay(1);s.delayTime.value=.42;let c=e.createGain();c.gain.value=.38,s.connect(c),c.connect(s),i.connect(r.out),i.connect(s),s.connect(r.out);let l=[[48,55,59,64],[45,52,55,60],[41,48,52,57],[43,50,55,59]];return KA(r,4,(e,t)=>{let n=l[e%l.length];for(let e of n)for(let n of[-7,7])UA(r,{type:`sawtooth`,freq:JA(e),start:t,dur:5.6,gain:.035,attack:1.4,release:1.8,detune:n,dest:i});UA(r,{type:`sine`,freq:JA(n[0]-12),start:t,dur:5.2,gain:.12,attack:1,release:1.5}),UA(r,{type:`triangle`,freq:JA(n[3]+24),start:t+1.3,dur:1.5,gain:.025,attack:.05,release:1.4,dest:s})}),{stop:()=>VA(r,.8)}}},lj={play(e,t,n){let r=BA(e,t,n),i=[72,0,76,79,84,0,79,76,77,0,76,74,72,0,74,76,69,0,72,76,81,0,79,76,77,76,74,72,74,0,0,0,77,0,81,84,89,0,84,81,79,0,77,76,77,0,79,81,79,0,83,86,91,0,86,83,84,0,83,81,79,0,74,0],a=[48,45,41,43],o=60/140/4;return KA(r,o,(e,t)=>{let n=e%64,s=i[n];s&&UA(r,{type:`square`,freq:JA(s),start:t,dur:o*1.6,gain:.075,release:o*1.2,filter:{type:`lowpass`,freq:3800}});let c=a[Math.floor(n/16)];if(n%2==0){let e=c+(n/2%4==3?7:n/2%2?12:0);UA(r,{type:`triangle`,freq:JA(e-12),start:t,dur:o*1.8,gain:.22,release:o*1.2})}n%4==2&&UA(r,{type:`square`,freq:JA(c+24+(n/4%2?4:7)),start:t,dur:o*.8,gain:.03,release:o*.6}),n%4==0&&UA(r,{type:`sine`,freq:150,to:45,start:t,dur:.12,gain:.35,release:.1}),n%8==4&&GA(r,{start:t,dur:.12,gain:.16,filter:{type:`bandpass`,freq:1800,q:.8}}),n%2==1&&GA(r,{start:t,dur:.035,gain:.06,filter:{type:`highpass`,freq:7e3}})}),{stop:()=>VA(r,.1)}}},uj={coin:QA,jump:$A,hit:ej,explosion:tj,click:nj,powerup:rj,laser:ij,win:aj,lose:oj,whoosh:sj,"ambient-pad":cj,"chiptune-loop":lj}}));function fj(e,t,n){let r=null,i=null,a=!!e?.muted,o=null,s=/* @__PURE__ */ new Map,c=null,l=!!e?.music,u=()=>Promise.resolve().then(()=>(dj(),XA)).then(e=>o=e.SOUND_IMPLS).catch(()=>o={}),d=e=>{let i=s.get(e);if(!i&&r){let a=r;i=fetch(t(e)).then(e=>e.arrayBuffer()).then(e=>a.decodeAudioData(e)).catch(t=>(n(t.message,e),null)),s.set(e,i)}return i??Promise.resolve(null)},f=(e,t=!1)=>{if(!r||!i)return null;let n=e.volume??1;if(e.preset){let t=o?.[e.preset];return t?t.play(r,i,n):null}if(e.src){let a=r,o=i,s=null,c=!1;return d(e.src).then(e=>{if(!e||c)return;s=a.createBufferSource(),s.buffer=e,s.loop=t;let r=a.createGain();r.gain.value=n,s.connect(r).connect(o),s.start()}),{stop(){c=!0;try{s?.stop()}catch{}}}}return null},p=()=>{!c&&e?.music&&!a&&r&&(c=f(e.music,e.music.loop!==!1))};return u(),{play(t){if(a||!r)return;let n=e?.sounds?.[t];n?f(n):o?.[t]&&o[t].play(r,i,1)},music(e){l=e,e?p():(c?.stop(),c=null)},muted:()=>a,setMuted(t){a=t,i&&r&&i.gain.setTargetAtTime(+!t,r.currentTime,.02),t?(c?.stop(),c=null):(l||e?.music)&&(l=!0,p())},unlock(){if(r){r.state===`suspended`&&r.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{r=new e,i=r.createGain(),i.gain.value=+!a,i.connect(r.destination),l&&p()}catch(e){n(e.message)}},dispose(){c?.stop(),r?.close().catch(()=>void 0),r=null}}}var pj=t((()=>{}));function mj(e){if(!/^[0-9a-f]+$/i.test(e)||((e.length===3||e.length===4)&&(e=[...e].map(e=>e+e).join(``)),e.length!==6&&e.length!==8))return null;let t=t=>parseInt(e.slice(t,t+2),16);return{r:t(0),g:t(2),b:t(4),a:e.length===8?t(6)/255:1}}function hj(e,t){let n=/^(-?\d*\.?\d+(?:e-?\d+)?)(%?)$/i.exec(e.trim());if(!n)return null;let r=Number(n[1]);return n[2]?r/100*t:r}function gj(e){let t=/^(-?\d*\.?\d+)(deg|rad|turn|grad)?$/i.exec(e.trim());if(!t)return null;let n=Number(t[1]);switch((t[2]??`deg`).toLowerCase()){case`rad`:return n*180/Math.PI;case`turn`:return n*360;case`grad`:return n*.9;default:return n}}function _j(e){let t=e.split(`/`);if(t.length>2)return null;let n=(t[0].includes(`,`)?t[0].split(`,`):t[0].trim().split(/\s+/)).map(e=>e.trim()).filter(e=>e!==``);return t.length===2&&n.push(t[1].trim()),n}function vj(e,t,n){e=(e%360+360)%360;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r/2,[o,s,c]=e<60?[r,i,0]:e<120?[i,r,0]:e<180?[0,r,i]:e<240?[0,i,r]:e<300?[i,0,r]:[r,0,i];return[(o+a)*255,(s+a)*255,(c+a)*255]}function yj(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();if(!t)return null;if(t.startsWith(`#`))return mj(t.slice(1));if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=Cj[t];if(n)return mj(n);let r=/^(rgba?|hsla?)\((.*)\)$/.exec(t);if(!r)return null;let i=_j(r[2]);if(!i||i.length!==3&&i.length!==4)return null;let a=i.length===4?hj(i[3],1):1;if(a===null)return null;if(r[1].startsWith(`rgb`)){let[e,t,n]=i.slice(0,3).map(e=>hj(e,255));return e===null||t===null||n===null?null:{r:wj(e,0,255),g:wj(t,0,255),b:wj(n,0,255),a:wj(a,0,1)}}let o=gj(i[0]),s=hj(i[1],1),c=hj(i[2],1);if(o===null||s===null||c===null||!i[1].trim().endsWith(`%`)||!i[2].trim().endsWith(`%`))return null;let[l,u,d]=vj(o,wj(s,0,1),wj(c,0,1));return{r:l,g:u,b:d,a:wj(a,0,1)}}function bj(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function xj(e,t){let n=bj(e),r=bj(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Sj(e){let t=yj(e);return t?xj(t,{r:255,g:255,b:255,a:1})>=xj(t,{r:17,g:19,b:24,a:1})?`#ffffff`:`#111318`:`#ffffff`}var Cj,wj,Tj=t((()=>{Cj={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`778899`,lightslategrey:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`},wj=(e,t,n)=>Math.min(n,Math.max(t,e))}));function Ej(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(/[0-9]/.test(r)||r===`-`&&/[0-9]/.test(e[n+1]??``)&&(t.length===0||t[t.length-1].t===`op`)){let r=n+1;for(;r<e.length&&/[0-9.]/.test(e[r]);)r++;t.push({t:`num`,v:Number(e.slice(n,r))}),n=r;continue}if(r===`'`||r===`"`){let i=n+1,a=``;for(;i<e.length&&e[i]!==r;)e[i]===`\\`&&i+1<e.length&&i++,a+=e[i++];if(i>=e.length)throw Error(`Unterminated string`);t.push({t:`str`,v:a}),n=i+1;continue}if(/[A-Za-z_$]/.test(r)){let r=n+1;for(;r<e.length&&/[A-Za-z0-9_$.]/.test(e[r]);)r++;t.push({t:`id`,v:e.slice(n,r)}),n=r;continue}let i=e.slice(n,n+3),a=e.slice(n,n+2);if(i===`===`||i===`!==`)t.push({t:`op`,v:i.slice(0,2)}),n+=3;else if([`==`,`!=`,`>=`,`<=`,`&&`,`||`].includes(a))t.push({t:`op`,v:a}),n+=2;else if(`!<>()`.includes(r))t.push({t:`op`,v:r}),n++;else throw Error(`Unexpected "${r}"`)}return t}function Dj(e,t){let n=t.split(`.`);n[0]===`state`&&n.shift();let r=e;for(let e of n){if(jj.has(e)||typeof r!=`object`||!r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function Oj(e,t){let n=Ej(e),r=0,i=()=>n[r],a=e=>i()?.t===`op`&&i().v===e;function o(){let e=n[r++];if(!e)throw Error(`Unexpected end`);if(e.t===`num`||e.t===`str`)return e.v;if(e.t===`id`)return e.v===`true`?!0:e.v===`false`?!1:e.v===`null`||e.v===`undefined`?null:Dj(t,e.v);if(e.v===`(`){let e=u();if(!a(`)`))throw Error(`Missing )`);return r++,e}throw Error(`Unexpected "${e.v}"`)}function s(){let e=o(),t=i();if(t?.t===`op`&&[`==`,`!=`,`>`,`<`,`>=`,`<=`].includes(t.v)){r++;let n=o(),i=e,a=n;switch(t.v){case`==`:return e==n||e==null&&n==null;case`!=`:return e!=n;case`>`:return i>a;case`<`:return i<a;case`>=`:return i>=a;default:return i<=a}}return e}function c(){return a(`!`)?(r++,!c()):s()}function l(){let e=c();for(;a(`&&`);){r++;let t=c();e&&=t}return e}function u(){let e=l();for(;a(`||`);){r++;let t=l();e||=t}return e}let d=u();if(r<n.length)throw Error(`Unexpected "${n[r].v}"`);return d}function kj(e,t){if(e===void 0)return!0;if(typeof e==`boolean`)return e;try{return!!Oj(e,t)}catch{return!1}}function Aj(e,t){return e.replace(/\{([^{}]+)\}/g,(e,n)=>{let r=n.trim(),i;try{i=/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(r)?Dj(t,r):Oj(r,t)}catch{i=void 0}return i==null?``:String(typeof i==`number`?Number.isInteger(i)?i:Math.round(i*100)/100:i)})}var jj,Mj=t((()=>{jj=/* @__PURE__ */ new Set([`__proto__`,`prototype`,`constructor`])}));function Nj(e,t,n){let r=e.ownerDocument,i=r.createElement(`div`);i.className=`a3d-hud`,i.setAttribute(`aria-live`,`polite`);let a=r.createElement(`style`),o=t?.accent??`#ff006e`;a.textContent=Ij(t?.font??`system-ui,-apple-system,'Segoe UI',Roboto,sans-serif`,t?.color??`#ffffff`,o,t?.buttonText??Sj(o)),i.appendChild(a);let s=/* @__PURE__ */ new Map,c=e=>{let t=s.get(e);return t||(t=r.createElement(`div`),t.className=`a3d-zone`,t.style.cssText=Pj[e]??Pj[`top-left`],t.dataset.anchor=e,i.appendChild(t),s.set(e,t)),t},l=[[`top-left`,`top`,`top-right`],[`left`,`center`,`right`],[`bottom-left`,`bottom`,`bottom-right`]],u=()=>{for(let[e,t,n]of l){let r=s.get(t);r&&(r.style.gridColumn=s.has(e)||s.has(n)?`2`:`1 / -1`)}},d=/* @__PURE__ */ new Map;for(let e of t?.elements??[]){let t,i;if(e.type===`button`){let i=r.createElement(`button`);i.type=`button`,i.className=`a3d-btn`,i.addEventListener(`click`,t=>{t.stopPropagation(),e.action&&n(e.action)}),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),t=i}else e.type===`bar`?(t=r.createElement(`div`),t.className=`a3d-bar`,i=r.createElement(`i`),t.appendChild(i)):(t=r.createElement(`div`),t.className=`a3d-el a3d-${e.style??`plain`}`);e.color&&(t.style.color=e.color,e.type===`bar`&&i&&(i.style.background=e.color)),e.background&&(t.style.background=e.background),e.type===`button`&&e.background&&!e.color&&(t.style.color=Sj(e.background)),t.dataset.id=e.id,c(e.anchor??`top-left`).appendChild(t),d.set(e.id,{def:e,node:t,fill:i,override:{},last:``})}u(),e.appendChild(i);let f=null,p=0,m=null,h=null,g=null;return{root:i,setTimeline(e){g=e},set(e,t){let n=d.get(e);n&&Object.assign(n.override,t)},toast(e,t=2){m={text:e,seconds:t}},update(e,t){let n=g&&!Object.prototype.hasOwnProperty.call(e,`timeline`)?{...e,timeline:g}:e;for(let e of d.values()){let t=e.override.visible??kj(e.def.visible,n);if(e.node.style.display=t?``:`none`,!t)continue;if(e.def.type===`bar`){let t=e.override.value??Number(e.def.value?Dj(n,e.def.value):0),r=Math.max(0,Math.min(1,Number.isFinite(t)?t:0));e.fill.style.width=`${(r*100).toFixed(1)}%`;continue}let r=e.override.text??Aj(e.def.text??``,n);r!==e.last&&(e.node.textContent=r,e.last=r)}m&&=(f||(f=r.createElement(`div`),f.className=`a3d-toast`,i.appendChild(f)),f.textContent=m.text,f.style.opacity=`1`,p=t+m.seconds,null),f&&t>p&&(f.style.opacity=`0`)},setMuteButton(e,t){e===null?(h?.remove(),h=null):(h||(h=r.createElement(`button`),h.type=`button`,h.className=`a3d-mute`,h.addEventListener(`pointerdown`,e=>e.stopPropagation()),h.addEventListener(`click`,e=>{e.stopPropagation(),t?.()}),c(`bottom-right`).appendChild(h),u()),h.innerHTML=e?Rj:Lj,h.setAttribute(`aria-label`,e?`Unmute sound`:`Mute sound`))},dispose(){i.remove()}}}var Pj,Fj,Ij,Lj,Rj,zj=t((()=>{Tj(),Mj(),Pj={"top-left":`grid-row:1;grid-column:1;align-items:flex-start;align-self:start;`,top:`grid-row:1;grid-column:2;align-items:center;align-self:start;text-align:center;`,"top-right":`grid-row:1;grid-column:3;align-items:flex-end;align-self:start;text-align:right;`,left:`grid-row:2;grid-column:1;align-items:flex-start;align-self:center;`,center:`grid-row:2;grid-column:2;align-items:center;align-self:center;text-align:center;`,right:`grid-row:2;grid-column:3;align-items:flex-end;align-self:center;text-align:right;`,"bottom-left":`grid-row:3;grid-column:1;align-items:flex-start;align-self:end;`,bottom:`grid-row:3;grid-column:2;align-items:center;align-self:end;text-align:center;`,"bottom-right":`grid-row:3;grid-column:3;align-items:flex-end;align-self:end;text-align:right;`},Fj=(e,t,n)=>`font-size:${n}px;font-size:clamp(${e}px,min(${t}cqw,${(t*1.6).toFixed(1)}cqh),${n}px)`,Ij=(e,t,n,r)=>`
|
|
5796
|
+
`)){if(l===1/0){c.push(Array.from(e));continue}let t=e.split(/ +/),n=[];for(let e of t){let t=n.length?[...n,` `,...Array.from(e)]:Array.from(e);n.length&&s(t).width>l?(c.push(n),n=Array.from(e)):n=t}c.push(n)}let u=[],d=[],f=0;return c.forEach((e,n)=>{for(;e.length&&e[e.length-1]===` `;)e.pop();let{xs:r,width:a}=s(e);f=Math.max(f,a);let o=t.align===`left`?0:t.align===`right`?-a:-a/2;e.forEach((e,t)=>{e.trim()&&u.push({ch:e,x:r[t]+o,line:n})}),d.push({width:a,y:-n*i})}),{glyphs:u,lines:d,lineHeight:i,width:f}}function $D(e){let t=e.data;if(t.capHeight&&t.resolution)return t.capHeight/t.resolution;let n=e.generateShapes(`H`,1);if(!n.length)return .72;let r=new Ol(n);r.computeBoundingBox();let i=r.boundingBox.max.y-r.boundingBox.min.y;return r.dispose(),i>0?i:.72}function eO(e,t){let n=e.data,r=Q(t.size,1),i=r/$D(e),a=Math.max(0,Q(t.depth,.2)),o=a>0?Math.max(0,Math.min(Q(t.bevel,Math.min(a*.3,r*.035)),a*.45,r*.08)):0,s=Math.round(Math.max(2,Math.min(32,Q(t.curveSegments,a>0?5+r*3:8+r*4)))),c=QD(n,{text:t.text,em:i,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,align:t.align??`center`,maxWidth:t.maxWidth,kerning:t.kerning});return{size:r,em:i,depth:a,bevel:o,curveSegments:s,layout:c,offsetY:-(r+(c.lines.length?c.lines[c.lines.length-1].y:0))/2,frontZ:a/2,backZ:-a/2}}function tO(e){let t=e.bevel;return{depth:Math.max(e.depth-t*2,1e-4),curveSegments:e.curveSegments,bevelEnabled:t>0,bevelThickness:t,bevelSize:t*.6,bevelOffset:0,bevelSegments:3}}function nO(e,t,n){let r=n.em/(n.curveSegments*5);return e.generateShapes(t,n.em).map(e=>zD(e,r,1,n.curveSegments))}function rO(e,t,n,r){let i=nO(e,t,n);if(!i.length)return null;if(n.depth<=0)return new Ol(i,n.curveSegments);let a=new xl(i,tO(n));return a.translate(0,0,n.backZ+n.bevel),a.clearGroups(),BD(a,50*Math.PI/180,r)}function iO(e,t){let n=e.outline;if(!n)return null;let r=n===!0?{}:n,i=Math.max(1e-4,Q(r.width,t.size*.06)),a=t.depth>0?t.depth*.5:t.size*.01,o=t.frontZ-a;return{width:i,frontZ:o,backZ:o-Math.max(Q(r.depth,t.depth>0?t.depth*.6:t.size*.01),1e-4),material:r.material,color:r.color??`#111111`}}function aO(e){let t=0;for(let n=0,r=e.length-1;n<e.length;r=n++)t+=(e[r].x-e[n].x)*(e[r].y+e[n].y);return t/2}function oO(e,t,n=2){let r=e.filter((t,n)=>{let r=e[(n+1)%e.length];return Math.hypot(r.x-t.x,r.y-t.y)>1e-9}),i=r.length,a=[];if(i<3)return r.map(e=>new z(e.x,e.y));let o=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.hypot(n,r)||1;return{x:r/i,y:-n/i}};for(let e=0;e<i;e++){let s=r[(e-1+i)%i],c=r[e],l=r[(e+1)%i],u=o(s,c),d=o(c,l),f=(c.x-s.x)*(l.y-c.y)-(c.y-s.y)*(l.x-c.x),p=u.x*d.x+u.y*d.y;if(f>0&&p<.995){let e=Math.atan2(u.y,u.x),n=Math.atan2(d.y,d.x);for(;n<e;)n+=Math.PI*2;for(;n>e+Math.PI*2;)n-=Math.PI*2;let r=Math.max(1,Math.ceil(Math.abs(n-e)/(Math.PI/8)));for(let i=0;i<=r;i++){let o=e+(n-e)*i/r;a.push(new z(c.x+Math.cos(o)*t,c.y+Math.sin(o)*t))}}else{let e=u.x+d.x,r=u.y+d.y,i=Math.hypot(e,r)||1;e/=i,r/=i;let o=Math.max(e*u.x+r*u.y,1/n);a.push(new z(c.x+e*t/o,c.y+r*t/o))}}return a}function sO(e,t){let n=[];for(let r of e){let{shape:e,holes:i}=r.extractPoints(1),a=e.slice();aO(a)<0&&(a=a.reverse());let o=new vl(oO(a,t));for(let e of i){let n=e.slice(),r=Math.abs(aO(n));aO(n)>0&&(n=n.reverse());let i=n.map(e=>e.x),a=n.map(e=>e.y);if(Math.max(...i)-Math.min(...i)<=2*t||Math.max(...a)-Math.min(...a)<=2*t)continue;let s=oO(n,t),c=aO(s);c<0&&-c>r*.02&&o.holes.push(new _l(s))}n.push(o)}return n}function cO(e,t,n,r,i){let a=nO(e,t,n);if(!a.length)return null;let o=new xl(sO(a,r.width),{depth:r.frontZ-r.backZ,curveSegments:1,bevelEnabled:!1});return o.translate(0,0,r.backZ),o.clearGroups(),BD(o,40*Math.PI/180,i)}function lO(e,t,n){let r=eO(e,t);return uO(r,t=>rO(e,t,r,n),n)}function uO(e,t,n){let r=/* @__PURE__ */ new Map,i=[];for(let n of e.layout.glyphs){r.has(n.ch)||r.set(n.ch,t(n.ch));let a=r.get(n.ch);if(!a)continue;let o=a.clone();o.translate(n.x,e.layout.lines[n.line].y+e.offsetY,0),i.push(o)}for(let e of r.values())e?.dispose();let a;if(!i.length)a=new G;else{a=(i.length===1?i[0].clone():n.mergeGeometries(i,!1))??new G;for(let e of i)e.dispose()}return a.computeBoundingBox(),a.computeBoundingSphere(),a}function dO(e,t,n){let r=Q(e.stagger,.04),i=t;if(e.order===`reverse`)i=n-1-t;else if(e.order===`center`)i=Math.abs(t-(n-1)/2);else if(e.order===`random`){let e=(t+1)*2654435761;e=(e^e>>>13)>>>0,i=e%1e3/1e3*(n-1)}return Q(e.delay,0)+i*r}function fO(e,t){return(n,r)=>{let i=e.effect??`rise`,a=Math.max(Q(e.duration,.6),.001),o=e.ease??(i===`scale`||i===`spin`?`outBack`:`outCubic`),s=i!==`scale`,c=[],l=[];if(s){let e=[];r.object.traverse(t=>{let n=t.material;if(n&&!t.userData.depthTwin){e.push(t);for(let e of Array.isArray(n)?n:[n])e.userData.baseOpacity===void 0&&(e.userData.baseOpacity=e.opacity),e.userData.baseTransparent===void 0&&(e.userData.baseTransparent=e.transparent),c.push(e)}});for(let t of e)l.push(pO(t))}return{update(e){let n=Math.min(Math.max(e/a,0),1),u=eS(o,n),d=r.object;if(s){let e=eS(`outCubic`,Math.min(1,n*1.6));for(let t of c)t.opacity=t.userData.baseOpacity*e,t.transparent=e<1||t.userData.baseTransparent;for(let t of l)t.visible=e>0&&e<1}switch(n<=0&&(d.visible=!1),i){case`rise`:d.position.y-=(1-u)*t*.6;break;case`drop`:d.position.y+=(1-u)*t*1.2;break;case`scale`:d.scale.multiplyScalar(Math.max(1e-4,u));break;case`spin`:d.rotation.y+=(1-u)*Math.PI,d.scale.multiplyScalar(Math.max(1e-4,Math.min(1,n*2)))}}}}}function pO(e){xO??=new ss({colorWrite:!1,depthWrite:!0});let t=new K(e.geometry,xO);return t.name=`${e.name}#depth`,t.visible=!1,t.castShadow=!1,t.receiveShadow=!1,t.renderOrder=-1,t.userData.helper=!0,t.userData.depthTwin=!0,e.add(t),t}function mO(e,t){let n=e.font??`sans-bold`;return t.resolveAsset(n.includes(`/`)||n.includes(`:`)?n:`library:fonts/${n}`)}function hO(e,t,n){let r=e.userData.gradient;r&&(r.uGradMin.value=t,r.uGradMax.value=n)}async function gO(e,t){let[n,r]=await Promise.all([XD(mO(e,t)),Promise.resolve().then(()=>(Wv(),kv))]),i=eO(n,e),a=iO(e,i),o=!!e.splitLetters||!!e.reveal,s=i.depth<=0,c=()=>yw(e.material,t,{defaultColor:`#ffffff`}),l=()=>a?yw(a.material??{color:a.color,roughness:.55},t):null,u=(i.layout.lines.length?i.layout.lines[i.layout.lines.length-1].y:0)+i.offsetY,d=i.size+i.offsetY,f=e=>(s&&(e.side=2),e);if(!o){let t=uO(i,e=>rO(n,e,i,r),r),o=f(await c());hO(o,u,d);let s=new K(t,o);if(a){let t=uO(i,e=>cO(n,e,i,a,r),r),o=await l();if(o){hO(o,u,d);let n=new K(t,o);n.name=`${e.id}/outline`,s.add(n)}}return{object:s,letters:[]}}let p=new ba,m=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map,g=i.size/2,_=[],v=i.layout.glyphs.length,y=0;for(let t of i.layout.glyphs){if(!m.has(t.ch)){let e=rO(n,t.ch,i,r),o=0;if(e&&(e.computeBoundingBox(),o=(e.boundingBox.min.x+e.boundingBox.max.x)/2,e.translate(-o,-g,0),e.computeBoundingSphere()),m.set(t.ch,e),a){let e=cO(n,t.ch,i,a,r);e?.translate(-o,-g,0),h.set(t.ch,e)}e&&(e.userData.cx=o)}let o=m.get(t.ch);if(!o)continue;let s=o.userData.cx,b=i.layout.lines[t.line].y+i.offsetY,x=f(await c());hO(x,u-b-g,d-b-g);let S=new K(o,x);S.position.set(t.x+s,b+g,0);let C=`${e.id}/${y}`;S.name=C,S.userData.a3dId=C;let w=h.get(t.ch);if(w){let e=await l();if(e){hO(e,u-b-g,d-b-g);let t=new K(w,e);t.name=`${C}/outline`,S.add(t)}}p.add(S);let T={id:C,object:S,def:{id:C,kind:`text`,text:t.ch}};e.reveal&&(T.reveal={def:{type:`appear`,when:`visible`,delay:dO(e.reveal,y,v)},impl:fO(e.reveal,i.size)}),_.push(T),y++}return{object:p,letters:_}}async function _O(e,t){let[n,r]=await Promise.all([XD(mO(e,t)),Promise.resolve().then(()=>(Wv(),kv))]);return lO(n,e,r)}var vO,yO,bO,xO,SO=t((()=>{J(),yg(),wS(),zS(),HD(),jw(),vO=/* @__PURE__ */ new Map,yO=e=>{let t=e.normalize(`NFD`);return t.length>1?t[0]:e},bO=[`rise`,`fade`,`scale`,`spin`,`drop`],xO=null})),CO=/* @__PURE__ */ n({SVGLoader:()=>OO});function wO(e,t,n=256){if(!e||!Array.isArray(e.stops)||e.stops.length===0)return null;let r=t.userData.transform,i=e.gradientUnits===`objectBoundingBox`,a=null;if(i&&(a=TO(t,r),a===null))return null;function o(t,n,o){o.set(t,n,1),e.gradientTransform&&o.applyMatrix3(e.gradientTransform),i&&o.set(a.minX+o.x*a.width,a.minY+o.y*a.height,1),r&&o.applyMatrix3(r)}let s=document.createElement(`canvas`),c;if(e.type===`linearGradient`){s.width=n,s.height=1;let t=s.getContext(`2d`),r=t.createLinearGradient(0,0,n,0);EO(r,e.stops),t.fillStyle=r,t.fillRect(0,0,n,1);let i=new B,a=new B;o(e.x1,e.y1,i),o(e.x2,e.y2,a);let l=a.x-i.x,u=a.y-i.y,d=l*l+u*u||1e-20,f=l/d,p=u/d,m=-(f*i.x+p*i.y);c=new Di().set(f,p,m,0,0,.5,0,0,1)}else{let t=e.cx,o=e.cy,l=e.fx,u=e.fy,d=e.r;if(e.gradientTransform){let n=new B;n.set(t,o,1).applyMatrix3(e.gradientTransform),t=n.x,o=n.y,n.set(l,u,1).applyMatrix3(e.gradientTransform),l=n.x,u=n.y}if(i&&(t=a.minX+t*a.width,o=a.minY+o*a.height,l=a.minX+l*a.width,u=a.minY+u*a.height,d*=Math.sqrt((a.width*a.width+a.height*a.height)/2)),d<=0)return null;s.width=n,s.height=n;let f=s.getContext(`2d`),p=t-d,m=o-d,h=2*d,g=n/h;f.setTransform(g,0,0,g,-p*g,-m*g);let _=f.createRadialGradient(l,u,0,t,o,d);EO(_,e.stops),f.fillStyle=_,f.fillRect(p,m,h,h);let v=r?r.clone().invert():new Di;c=new Di().set(1/h,0,-p/h,0,1/h,-m/h,0,0,1).multiply(v)}let l=new Ic(s);l.colorSpace=DO,l.flipY=!1,l.matrixAutoUpdate=!1,l.matrix=c;let u=e.spreadMethod===`reflect`?sn:e.spreadMethod===`repeat`?an:on;return l.wrapS=u,l.wrapT=u,l}function TO(e,t){let n=t?t.clone().invert():null,r=new z,i=new ff;for(let t of e.subPaths)for(let e of t.getPoints())r.copy(e),n&&r.applyMatrix3(n),i.expandByPoint(r);return i.isEmpty()?null:{minX:i.min.x,minY:i.min.y,width:i.max.x-i.min.x,height:i.max.y-i.min.y}}function EO(e,t){let n=new H;for(let r of t){let t=r.color;if(r.opacity<1){n.setStyle(r.color,DO);let e=/rgb\(([^)]+)\)/.exec(n.getStyle(DO));e&&(t=`rgba(${e[1]},${r.opacity})`)}e.addColorStop(Math.max(0,Math.min(1,r.offset)),t)}}var DO,OO,kO,AO=t((()=>{J(),DO=Br,OO=class e extends gu{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit=`px`}load(e,t,n,r){let i=this,a=new yu(i.manager);a.setPriority(i.priority),a.setCache(i.cache),a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){let t=this;function n(e,t){if(e.nodeType!==1)return;e.hasAttribute(`filter`)&&console.warn(`THREE.SVGLoader: Filters are not supported.`);let a=b(e),o=!1,p=null;switch(e.nodeName){case`svg`:t=m(e,t);break;case`style`:i(e);break;case`g`:t=m(e,t);break;case`path`:t=m(e,t),e.hasAttribute(`d`)&&(p=r(e));break;case`rect`:t=m(e,t),p=s(e);break;case`polygon`:t=m(e,t),p=c(e);break;case`polyline`:t=m(e,t),p=l(e);break;case`circle`:t=m(e,t),p=u(e);break;case`ellipse`:t=m(e,t),p=d(e);break;case`line`:t=m(e,t),p=f(e);break;case`defs`:o=!0;break;case`use`:t=m(e,t);let a=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),h=e.viewportElement.getElementById(a);h?n(h,t):console.warn(`SVGLoader: 'use node' references non-existent node id: `+a)}if(p){t.fill!==void 0&&t.fill!==`none`&&!t.fill.startsWith(`url`)&&p.color.setStyle(t.fill,DO),C(p,ie),A.push(p);let n=Object.assign({},t);n.strokeWidth=t.strokeWidth*O(ie),p.userData={node:e,style:n,transform:ie.clone(),gradients:M}}let h=e.childNodes;for(let e=0;e<h.length;e++){let r=h[e];o&&r.nodeName!==`style`&&r.nodeName!==`defs`||n(r,t)}a&&(N.pop(),N.length>0?ie.copy(N[N.length-1]):ie.identity())}function r(e){let t=new Xf,n=new z,r=new z,i=new z,o=!1,s=e.getAttribute(`d`);if(s===``||s===`none`)return null;let c=s.match(/[a-df-z][^a-df-z]*/gi);for(let e=0,s=c.length;e<s;e++){let s=c[e],l=s.charAt(0),u=s.slice(1).trim();o===!0&&(l!==`M`&&l!==`m`&&l!==`Z`&&l!==`z`&&t.moveTo(i.x,i.y),o=!1);let d;switch(l){case`M`:d=g(u);for(let e=0,a=d.length;e<a;e+=2)n.x=d[e+0],n.y=d[e+1],r.x=n.x,r.y=n.y,e===0?t.moveTo(n.x,n.y):t.lineTo(n.x,n.y),e===0&&i.copy(n);break;case`H`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.x=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`V`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.y=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`L`:d=g(u);for(let e=0,i=d.length;e<i;e+=2)n.x=d[e+0],n.y=d[e+1],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`C`:d=g(u);for(let e=0,i=d.length;e<i;e+=6)t.bezierCurveTo(d[e+0],d[e+1],d[e+2],d[e+3],d[e+4],d[e+5]),r.x=d[e+2],r.y=d[e+3],n.x=d[e+4],n.y=d[e+5];break;case`S`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.bezierCurveTo(h(n.x,r.x),h(n.y,r.y),d[e+0],d[e+1],d[e+2],d[e+3]),r.x=d[e+0],r.y=d[e+1],n.x=d[e+2],n.y=d[e+3];break;case`Q`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.quadraticCurveTo(d[e+0],d[e+1],d[e+2],d[e+3]),r.x=d[e+0],r.y=d[e+1],n.x=d[e+2],n.y=d[e+3];break;case`T`:d=g(u);for(let e=0,i=d.length;e<i;e+=2){let i=h(n.x,r.x),a=h(n.y,r.y);t.quadraticCurveTo(i,a,d[e+0],d[e+1]),r.x=i,r.y=a,n.x=d[e+0],n.y=d[e+1]}break;case`A`:d=g(u,[3,4],7);for(let e=0,i=d.length;e<i;e+=7){if(d[e+5]==n.x&&d[e+6]==n.y)continue;let i=n.clone();n.x=d[e+5],n.y=d[e+6],r.x=n.x,r.y=n.y,a(t,d[e],d[e+1],d[e+2],d[e+3],d[e+4],i,n)}break;case`m`:d=g(u);for(let e=0,a=d.length;e<a;e+=2)n.x+=d[e+0],n.y+=d[e+1],r.x=n.x,r.y=n.y,e===0?t.moveTo(n.x,n.y):t.lineTo(n.x,n.y),e===0&&i.copy(n);break;case`h`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.x+=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`v`:d=g(u);for(let e=0,i=d.length;e<i;e++)n.y+=d[e],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`l`:d=g(u);for(let e=0,i=d.length;e<i;e+=2)n.x+=d[e+0],n.y+=d[e+1],r.x=n.x,r.y=n.y,t.lineTo(n.x,n.y);break;case`c`:d=g(u);for(let e=0,i=d.length;e<i;e+=6)t.bezierCurveTo(n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3],n.x+d[e+4],n.y+d[e+5]),r.x=n.x+d[e+2],r.y=n.y+d[e+3],n.x+=d[e+4],n.y+=d[e+5];break;case`s`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.bezierCurveTo(h(n.x,r.x),h(n.y,r.y),n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3]),r.x=n.x+d[e+0],r.y=n.y+d[e+1],n.x+=d[e+2],n.y+=d[e+3];break;case`q`:d=g(u);for(let e=0,i=d.length;e<i;e+=4)t.quadraticCurveTo(n.x+d[e+0],n.y+d[e+1],n.x+d[e+2],n.y+d[e+3]),r.x=n.x+d[e+0],r.y=n.y+d[e+1],n.x+=d[e+2],n.y+=d[e+3];break;case`t`:d=g(u);for(let e=0,i=d.length;e<i;e+=2){let i=h(n.x,r.x),a=h(n.y,r.y);t.quadraticCurveTo(i,a,n.x+d[e+0],n.y+d[e+1]),r.x=i,r.y=a,n.x+=d[e+0],n.y+=d[e+1]}break;case`a`:d=g(u,[3,4],7);for(let e=0,i=d.length;e<i;e+=7){if(d[e+5]==0&&d[e+6]==0)continue;let i=n.clone();n.x+=d[e+5],n.y+=d[e+6],r.x=n.x,r.y=n.y,a(t,d[e],d[e+1],d[e+2],d[e+3],d[e+4],i,n)}break;case`Z`:case`z`:t.currentPath.autoClose=!0,t.currentPath.curves.length>0&&(n.copy(i),t.currentPath.currentPoint.copy(n),o=!0);break;default:console.warn(s)}}return t}function i(e){if(e.sheet&&e.sheet.cssRules&&e.sheet.cssRules.length)for(let t=0;t<e.sheet.cssRules.length;t++){let n=e.sheet.cssRules[t];if(n.type!==1)continue;let r=n.selectorText.split(/,/gm).filter(Boolean).map(e=>e.trim()),i={};for(let e=0;e<n.style.length;e++){let t=n.style[e];i[t]=n.style.getPropertyValue(t)}for(let e=0;e<r.length;e++)j[r[e]]=Object.assign(j[r[e]]||{},i)}}function a(e,t,n,r,i,a,s,c){if(t==0||n==0){e.lineTo(c.x,c.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let l=(s.x-c.x)/2,u=(s.y-c.y)/2,d=Math.cos(r)*l+Math.sin(r)*u,f=-Math.sin(r)*l+Math.cos(r)*u,p=t*t,m=n*n,h=d*d,g=f*f,_=h/p+g/m;if(_>1){let e=Math.sqrt(_);t=e*t,n=e*n,p=t*t,m=n*n}let v=p*g+m*h,y=(p*m-v)/v,b=Math.sqrt(Math.max(0,y));i===a&&(b=-b);let x=b*t*f/n,S=-b*n*d/t,C=Math.cos(r)*x-Math.sin(r)*S+(s.x+c.x)/2,w=Math.sin(r)*x+Math.cos(r)*S+(s.y+c.y)/2,T=o(1,0,(d-x)/t,(f-S)/n),E=o((d-x)/t,(f-S)/n,(-d-x)/t,(-f-S)/n)%(Math.PI*2);e.currentPath.absellipse(C,w,t,n,T,T+E,a===0,r)}function o(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function s(e){let t=y(e.getAttribute(`x`)||0),n=y(e.getAttribute(`y`)||0),r=y(e.getAttribute(`rx`)||e.getAttribute(`ry`)||0),i=y(e.getAttribute(`ry`)||e.getAttribute(`rx`)||0),a=y(e.getAttribute(`width`)),o=y(e.getAttribute(`height`)),s=.448084975506,c=new Xf;return c.moveTo(t+r,n),c.lineTo(t+a-r,n),(r!==0||i!==0)&&c.bezierCurveTo(t+a-r*s,n,t+a,n+i*s,t+a,n+i),c.lineTo(t+a,n+o-i),(r!==0||i!==0)&&c.bezierCurveTo(t+a,n+o-i*s,t+a-r*s,n+o,t+a-r,n+o),c.lineTo(t+r,n+o),(r!==0||i!==0)&&c.bezierCurveTo(t+r*s,n+o,t,n+o-i*s,t,n+o-i),c.lineTo(t,n+i),(r!==0||i!==0)&&c.bezierCurveTo(t,n+i*s,t+r*s,n,t+r,n),c}function c(e){function t(e,t,n){let a=y(t),o=y(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)/g,r=new Xf,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!0,r}function l(e){function t(e,t,n){let a=y(t),o=y(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)/g,r=new Xf,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!1,r}function u(e){let t=y(e.getAttribute(`cx`)||0),n=y(e.getAttribute(`cy`)||0),r=y(e.getAttribute(`r`)||0),i=new _l;i.absarc(t,n,r,0,Math.PI*2);let a=new Xf;return a.subPaths.push(i),a}function d(e){let t=y(e.getAttribute(`cx`)||0),n=y(e.getAttribute(`cy`)||0),r=y(e.getAttribute(`rx`)||0),i=y(e.getAttribute(`ry`)||0),a=new _l;a.absellipse(t,n,r,i,0,Math.PI*2);let o=new Xf;return o.subPaths.push(a),o}function f(e){let t=y(e.getAttribute(`x1`)||0),n=y(e.getAttribute(`y1`)||0),r=y(e.getAttribute(`x2`)||0),i=y(e.getAttribute(`y2`)||0),a=new Xf;return a.moveTo(t,n),a.lineTo(r,i),a.currentPath.autoClose=!1,a}function p(e){let t=e.querySelectorAll(`linearGradient, radialGradient`),n=[`x1`,`y1`,`x2`,`y2`,`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`],r={};for(let e of t){let t=e.getAttribute(`id`);if(!t)continue;let i={type:e.nodeName===`radialGradient`?`radialGradient`:`linearGradient`,attrs:{},stops:null,href:null},a=e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``;a.startsWith(`#`)&&(i.href=a.substring(1));for(let t of n)e.hasAttribute(t)&&(i.attrs[t]=e.getAttribute(t));let o=e.querySelectorAll(`stop`);if(o.length>0){i.stops=[];for(let e of o){let t=e.getAttribute(`stop-color`);!t&&e.style&&(t=e.style[`stop-color`]),t||=`#000`;let n=e.getAttribute(`stop-opacity`);(n===null||n===``)&&e.style&&(n=e.style[`stop-opacity`]),n=n===null||n===``||n===void 0?1:Math.max(0,Math.min(1,parseFloat(n)));let r=Math.max(0,Math.min(1,parseFloat(e.getAttribute(`offset`)||`0`)));i.stops.push({offset:r,color:t,opacity:n})}}r[t]=i}function i(e,t){let n=r[e];if(!n||t.has(e))return n;if(t.add(e),n.href&&r[n.href]){let e=i(n.href,t);if(e){n.stops||=e.stops;for(let t in e.attrs)t in n.attrs||(n.attrs[t]=e.attrs[t])}}return n}for(let e in r)i(e,/* @__PURE__ */ new Set);for(let e in r){let t=r[e],n=t.attrs,i=n.gradientUnits===`userSpaceOnUse`?`userSpaceOnUse`:`objectBoundingBox`,a={type:t.type,gradientUnits:i,spreadMethod:n.spreadMethod===`reflect`||n.spreadMethod===`repeat`?n.spreadMethod:`pad`,gradientTransform:null,stops:(t.stops||[]).slice().sort((e,t)=>e.offset-t.offset)};n.gradientTransform&&(a.gradientTransform=new Di,S(n.gradientTransform,a.gradientTransform));function o(e){return typeof e==`string`?e.endsWith(`%`)?parseFloat(e)/100:y(e):0}if(t.type===`linearGradient`)a.x1=n.x1===void 0?0:o(n.x1),a.y1=n.y1===void 0?0:o(n.y1),a.x2=n.x2===void 0?+(i===`objectBoundingBox`):o(n.x2),a.y2=n.y2===void 0?0:o(n.y2);else{let e=i===`objectBoundingBox`?.5:0,t=i===`objectBoundingBox`?.5:0;a.cx=n.cx===void 0?e:o(n.cx),a.cy=n.cy===void 0?e:o(n.cy),a.r=n.r===void 0?t:o(n.r),a.fx=n.fx===void 0?a.cx:o(n.fx),a.fy=n.fy===void 0?a.cy:o(n.fy)}M[e]=a}}function m(e,t){t=Object.assign({},t);let n={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)n=Object.assign(n,j[`.`+t[e]])}e.hasAttribute(`id`)&&(n=Object.assign(n,j[`#`+e.getAttribute(`id`)]));function r(r,i,a){a===void 0&&(a=function(e){return e}),e.hasAttribute(r)&&(t[i]=a(e.getAttribute(r))),n[r]&&(t[i]=a(n[r])),e.style&&e.style[r]!==``&&(t[i]=a(e.style[r]))}function i(e){return Math.max(0,Math.min(1,y(e)))}function a(e){return Math.max(0,y(e))}return r(`fill`,`fill`),r(`fill-opacity`,`fillOpacity`,i),r(`fill-rule`,`fillRule`),r(`opacity`,`opacity`,i),r(`stroke`,`stroke`),r(`stroke-opacity`,`strokeOpacity`,i),r(`stroke-width`,`strokeWidth`,a),r(`stroke-linejoin`,`strokeLineJoin`),r(`stroke-linecap`,`strokeLineCap`),r(`stroke-miterlimit`,`strokeMiterLimit`,a),r(`visibility`,`visibility`),t}function h(e,t){return e-(t-e)}function g(e,t,n){if(typeof e!=`string`)throw TypeError(`Invalid input: `+typeof e);let r={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},i=0,a=!0,o=``,s=``,c=[];function l(e,t,n){let r=/* @__PURE__ */ SyntaxError(`Unexpected character "`+e+`" at index `+t+`.`);throw r.partial=n,r}function u(){o!==``&&(s===``?c.push(Number(o)):c.push(Number(o)*10**Number(s))),o=``,s=``}let d,f=e.length;for(let p=0;p<f;p++)if(d=e[p],Array.isArray(t)&&t.includes(c.length%n)&&r.FLAGS.test(d))i=1,o=d,u();else{if(i===0){if(r.WHITESPACE.test(d))continue;if(r.DIGIT.test(d)||r.SIGN.test(d)){i=1,o=d;continue}if(r.POINT.test(d)){i=2,o=d;continue}r.COMMA.test(d)&&(a&&l(d,p,c),a=!0)}if(i===1){if(r.DIGIT.test(d)){o+=d;continue}if(r.POINT.test(d)){o+=d,i=2;continue}if(r.EXP.test(d)){i=3;continue}r.SIGN.test(d)&&o.length===1&&r.SIGN.test(o[0])&&l(d,p,c)}if(i===2){if(r.DIGIT.test(d)){o+=d;continue}if(r.EXP.test(d)){i=3;continue}r.POINT.test(d)&&o[o.length-1]===`.`&&l(d,p,c)}if(i===3){if(r.DIGIT.test(d)){s+=d;continue}if(r.SIGN.test(d)){if(s===``){s+=d;continue}s.length===1&&r.SIGN.test(s)&&l(d,p,c)}}r.WHITESPACE.test(d)?(u(),i=0,a=!1):r.COMMA.test(d)?(u(),i=0,a=!0):r.SIGN.test(d)?(u(),i=1,o=d):r.POINT.test(d)?(u(),i=2,o=d):l(d,p,c)}return u(),c}let _=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],v={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:12,pc:1,px:-1},px:{px:1}};function y(e){let n=`px`;if(typeof e==`string`||e instanceof String)for(let t=0,r=_.length;t<r;t++){let r=_[t];if(e.endsWith(r)){n=r,e=e.substring(0,e.length-r.length);break}}let r;return n===`px`&&t.defaultUnit!==`px`?r=v.in[t.defaultUnit]/t.defaultDPI:(r=v[n][t.defaultUnit],r<0&&(r=v[n].in*t.defaultDPI)),r*parseFloat(e)}function b(e){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let t=x(e);return N.length>0&&t.premultiply(N[N.length-1]),ie.copy(t),N.push(t),t}function x(e){let t=new Di;if(e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))){let n=y(e.getAttribute(`x`)||0),r=y(e.getAttribute(`y`)||0);t.makeTranslation(n,r)}return e.hasAttribute(`transform`)&&S(e.getAttribute(`transform`),t),t}function S(e,t){let n=P,r=e.split(`)`);for(let e=r.length-1;e>=0;e--){let i=r[e].trim();if(i===``)continue;let a=i.indexOf(`(`),o=i.length;if(a>0&&a<o){let e=i.slice(0,a),r=g(i.slice(a+1));switch(n.identity(),e){case`translate`:if(r.length>=1){let e=r[0],t=0;r.length>=2&&(t=r[1]),n.makeTranslation(e,t)}break;case`rotate`:if(r.length>=1){let e=0,t=0,i=0;e=r[0]*Math.PI/180,r.length>=3&&(t=r[1],i=r[2]),F.makeTranslation(-t,-i),ee.makeRotation(e),te.multiplyMatrices(ee,F),F.makeTranslation(t,i),n.multiplyMatrices(F,te)}break;case`scale`:if(r.length>=1){let e=r[0],t=e;r.length>=2&&(t=r[1]),n.makeScale(e,t)}break;case`skewX`:r.length===1&&n.set(1,Math.tan(r[0]*Math.PI/180),0,0,1,0,0,0,1);break;case`skewY`:r.length===1&&n.set(1,0,0,Math.tan(r[0]*Math.PI/180),1,0,0,0,1);break;case`matrix`:r.length===6&&n.set(r[0],r[2],r[4],r[1],r[3],r[5],0,0,1)}t.premultiply(n)}}return t}function C(e,t){function n(e){re.set(e.x,e.y,1).applyMatrix3(t),e.set(re.x,re.y)}function r(e){let n=e.xRadius,r=e.yRadius,i=Math.cos(e.aRotation),a=Math.sin(e.aRotation),o=new B(n*i,n*a,0),s=new B(-r*a,r*i,0),c=o.applyMatrix3(t),l=s.applyMatrix3(t),u=P.set(c.x,l.x,0,c.y,l.y,0,0,0,1),d=F.copy(u).invert(),f=ee.copy(d).transpose().multiply(d).elements,p=k(f[0],f[1],f[4]),m=Math.sqrt(p.rt1),h=Math.sqrt(p.rt2);if(e.xRadius=1/m,e.yRadius=1/h,e.aRotation=Math.atan2(p.sn,p.cs),!((e.aEndAngle-e.aStartAngle)%(2*Math.PI)<2**-52)){let n=F.set(m,0,0,0,h,0,0,0,1),r=ee.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),i=n.multiply(r).multiply(u),a=e=>{let{x:t,y:n}=new B(Math.cos(e),Math.sin(e),0).applyMatrix3(i);return Math.atan2(n,t)};e.aStartAngle=a(e.aStartAngle),e.aEndAngle=a(e.aEndAngle),w(t)&&(e.aClockwise=!e.aClockwise)}}function i(e){let n=E(t),r=D(t);e.xRadius*=n,e.yRadius*=r;let i=n>2**-52?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);e.aRotation+=i,w(t)&&(e.aStartAngle*=-1,e.aEndAngle*=-1,e.aClockwise=!e.aClockwise)}let a=e.subPaths;for(let e=0,o=a.length;e<o;e++){let o=a[e].curves;for(let e=0;e<o.length;e++){let a=o[e];a.isLineCurve?(n(a.v1),n(a.v2)):a.isCubicBezierCurve?(n(a.v0),n(a.v1),n(a.v2),n(a.v3)):a.isQuadraticBezierCurve?(n(a.v0),n(a.v1),n(a.v2)):a.isEllipseCurve&&(ne.set(a.aX,a.aY),n(ne),a.aX=ne.x,a.aY=ne.y,T(t)?r(a):i(a))}}}function w(e){let t=e.elements;return t[0]*t[4]-t[1]*t[3]<0}function T(e){let t=e.elements,n=t[0]*t[3]+t[1]*t[4];if(n===0)return!1;let r=E(e),i=D(e);return Math.abs(n/(r*i))>2**-52}function E(e){let t=e.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function D(e){let t=e.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function O(e){let t=e.elements,n=t[0]*t[4]-t[1]*t[3];return Math.sqrt(Math.abs(n))}function k(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?i=.5*(c-u):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}let A=[],j={},M={},N=[],P=new Di,F=new Di,ee=new Di,te=new Di,ne=new z,re=new B,ie=new Di,ae=new DOMParser().parseFromString(e,`image/svg+xml`);return p(ae),n(ae.documentElement,{fill:`#000`,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:`miter`,strokeLineCap:`butt`,strokeMiterLimit:4}),{paths:A,gradients:M,xml:ae.documentElement}}static createFillMaterial(e){let t=e.userData.style;if(t.fill===void 0||t.fill===`none`)return null;let n=e.color,r=null,i=kO.exec(t.fill);i&&(r=wO(e.userData.gradients&&e.userData.gradients[i[1]],e));let a=new ss({opacity:t.fillOpacity*(t.opacity||1),transparent:!0,side:2,depthWrite:!1});return r===null?a.color=n:a.map=r,a}static createStrokeMaterial(e){let t=e.userData.style;return t.stroke===void 0||t.stroke===`none`?null:(kO.test(t.stroke)&&console.warn(`THREE.SVGLoader: Gradient strokes are not supported.`),new ss({color:new H().setStyle(t.stroke,DO),opacity:t.strokeOpacity*(t.opacity||1),transparent:!0,side:2,depthWrite:!1}))}static createShapes(e){return console.warn(`SVGLoader: createShapes() is deprecated. Use shapePath.toShapes() instead.`),e.toShapes()}static getStrokeStyle(e,t,n,r,i){return e=e===void 0?1:e,t=t===void 0?`#000`:t,n=n===void 0?`miter`:n,r=r===void 0?`butt`:r,i=i===void 0?4:i,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:r,strokeMiterLimit:i}}static pointsToStroke(t,n,r,i){let a=[],o=[],s=[];if(e.pointsToStrokeWithBuffers(t,n,r,i,a,o,s)===0)return null;let c=new G;return c.setAttribute(`position`,new W(a,3)),c.setAttribute(`normal`,new W(o,3)),c.setAttribute(`uv`,new W(s,2)),c}static pointsToStrokeWithBuffers(e,t,n,r,i,a,o,s){let c=new z,l=new z,u=new z,d=new z,f=new z,p=new z,m=new z,h=new z,g=new z,_=new z,v=new z,y=new z,b=new z,x=new z,S=new z,C=new z,w=new z;n=n===void 0?12:n,r=r===void 0?.001:r,s=s===void 0?0:s,e=de(e);let T=e.length;if(T<2)return 0;let E=e[0].equals(e[T-1]),D,O=e[0],k,A=t.strokeWidth/2,j=1/(T-1),M=0,N,P,F,ee,te=!1,ne=0,re=s*3,ie=s*2;ae(e[0],e[1],c).multiplyScalar(A),h.copy(e[0]).sub(c),g.copy(e[0]).add(c),_.copy(h),v.copy(g);for(let n=1;n<T;n++){D=e[n],k=n===T-1?E?e[1]:void 0:e[n+1];let r=c;if(ae(O,D,r),u.copy(r).multiplyScalar(A),y.copy(D).sub(u),b.copy(D).add(u),N=M+j,P=!1,k!==void 0){ae(D,k,l),u.copy(l).multiplyScalar(A),x.copy(D).sub(u),S.copy(D).add(u),F=!0,u.subVectors(k,O),r.dot(u)<0&&(F=!1),n===1&&(te=F),u.subVectors(k,D),u.normalize();let e=Math.abs(r.dot(u));if(e>2**-52){let n=A/e;u.multiplyScalar(-n),d.subVectors(D,O),f.copy(d).setLength(n).add(u),C.copy(f).negate();let r=f.length(),i=d.length();d.divideScalar(i),p.subVectors(k,D);let a=p.length();if(p.divideScalar(a),d.dot(C)<i&&p.dot(C)<a&&(P=!0),w.copy(f).add(D),C.add(D),P){let e=F?g:h,t=(w.x-e.x)*(C.y-e.y)-(w.y-e.y)*(C.x-e.x);(F&&t<0||!F&&t>0)&&C.copy(e)}switch(ee=!1,P?F?(S.copy(C),b.copy(C)):(x.copy(C),y.copy(C)):se(),t.strokeLineJoin){case`bevel`:ce(F,P,N);break;case`round`:le(F,P),F?oe(D,y,x,N,0):oe(D,S,b,N,1);break;default:let e=A*t.strokeMiterLimit/r;if(e<1){if(t.strokeLineJoin!==`miter-clip`){ce(F,P,N);break}le(F,P),F?(p.subVectors(w,y).multiplyScalar(e).add(y),m.subVectors(w,x).multiplyScalar(e).add(x),I(y,N,0),I(p,N,0),I(D,N,.5),I(D,N,.5),I(p,N,0),I(m,N,0),I(D,N,.5),I(m,N,0),I(x,N,0)):(p.subVectors(w,b).multiplyScalar(e).add(b),m.subVectors(w,S).multiplyScalar(e).add(S),I(b,N,1),I(p,N,1),I(D,N,.5),I(D,N,.5),I(p,N,1),I(m,N,1),I(D,N,.5),I(m,N,1),I(S,N,1))}else P?(F?(I(g,M,1),I(h,M,0),I(w,N,0),I(g,M,1),I(w,N,0),I(C,N,1)):(I(g,M,1),I(h,M,0),I(w,N,1),I(h,M,0),I(C,N,0),I(w,N,1)),F?x.copy(w):S.copy(w)):F?(I(y,N,0),I(w,N,0),I(D,N,.5),I(D,N,.5),I(w,N,0),I(x,N,0)):(I(b,N,1),I(w,N,1),I(D,N,.5),I(D,N,.5),I(w,N,1),I(S,N,1)),ee=!0}}else se()}else se();!E&&n===T-1&&ue(e[0],_,v,F,!0,M),M=N,O=D,h.copy(x),g.copy(S)}if(!E)ue(D,y,b,F,!1,N);else if(P&&i){let e=w,t=C;te!==F&&(e=C,t=w),F?(ee||te)&&(t.toArray(i,0),t.toArray(i,9),ee&&e.toArray(i,3)):(ee||!te)&&(t.toArray(i,3),t.toArray(i,9),ee&&e.toArray(i,0))}if(i){let e=[new z,new z,new z],t=s*3;for(let n=t;n<re;n+=9)e[0].set(i[n],i[n+1]),e[1].set(i[n+3],i[n+4]),e[2].set(i[n+6],i[n+7]),bl.area(e)<0&&(i[n+3]=e[0].x,i[n+4]=e[0].y)}return ne;function ae(e,t,n){return n.subVectors(t,e),n.set(-n.y,n.x).normalize()}function I(e,t,n){i&&(i[re]=e.x,i[re+1]=e.y,i[re+2]=0,a&&(a[re]=0,a[re+1]=0,a[re+2]=1),re+=3,o&&(o[ie]=t,o[ie+1]=n,ie+=2)),ne+=3}function oe(e,t,r,i,a){c.copy(t).sub(e).normalize(),l.copy(r).sub(e).normalize();let o=Math.PI,s=c.dot(l);Math.abs(s)<1&&(o=Math.abs(Math.acos(s))),o/=n,u.copy(t);for(let t=0,r=n-1;t<r;t++)d.copy(u).rotateAround(e,o),I(u,i,a),I(d,i,a),I(e,i,.5),u.copy(d);I(u,i,a),I(r,i,a),I(e,i,.5)}function se(){I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(b,N,1)}function ce(e,t,n){t?e?(I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(C,N,1),I(y,n,0),I(x,n,0),I(C,n,.5)):(I(g,M,1),I(h,M,0),I(b,N,1),I(h,M,0),I(C,N,0),I(b,N,1),I(b,n,1),I(C,n,0),I(S,n,1)):e?(I(y,n,0),I(x,n,0),I(D,n,.5)):(I(b,n,1),I(S,n,0),I(D,n,.5))}function le(e,t){t&&(e?(I(g,M,1),I(h,M,0),I(y,N,0),I(g,M,1),I(y,N,0),I(C,N,1),I(y,M,0),I(D,N,.5),I(C,N,1),I(D,N,.5),I(x,M,0),I(C,N,1)):(I(g,M,1),I(h,M,0),I(b,N,1),I(h,M,0),I(C,N,0),I(b,N,1),I(b,M,1),I(C,N,0),I(D,N,.5),I(D,N,.5),I(C,N,0),I(S,M,1)))}function ue(e,n,r,a,s,f){switch(t.strokeLineCap){case`round`:s?oe(e,r,n,f,.5):oe(e,n,r,f,.5);break;case`square`:if(s)c.subVectors(n,e),l.set(c.y,-c.x),u.addVectors(c,l).add(e),d.subVectors(l,c).add(e),a?(u.toArray(i,3),d.toArray(i,0),d.toArray(i,9)):(u.toArray(i,3),o[7]===1?d.toArray(i,9):u.toArray(i,9),d.toArray(i,0));else{c.subVectors(r,e),l.set(c.y,-c.x),u.addVectors(c,l).add(e),d.subVectors(l,c).add(e);let t=i.length;a?(u.toArray(i,t-3),d.toArray(i,t-6),d.toArray(i,t-12)):(d.toArray(i,t-6),u.toArray(i,t-3),d.toArray(i,t-12))}}}function de(e){let t=!1;for(let n=1,i=e.length-1;n<i;n++)if(e[n].distanceTo(e[n+1])<r){t=!0;break}if(!t)return e;let n=[];n.push(e[0]);for(let t=1,i=e.length-1;t<i;t++)e[t].distanceTo(e[t+1])>=r&&n.push(e[t]);return n.push(e[e.length-1]),n}}},kO=/^\s*url\(\s*(?:["']\s*)?#([^)'"\s]+)(?:\s*["'])?\s*\)\s*$/})),jO=/* @__PURE__ */ n({buildSvg:()=>RO,partsBounds:()=>IO,svgParts:()=>PO});function MO(e,t,n){if(e===`currentColor`)return n;let r=/^url\(\s*['"]?#([^'")]+)['"]?\s*\)/.exec(e);if(r){let e=t.userData?.gradients?.[r[1]]?.stops??[];if(!e.length)return n;let i=new H(e[0].color),a=new H(e[e.length-1].color);return`#${i.lerp(a,.5).getHexString()}`}try{let t=new H;return t.setStyle(e,Br),`#${t.getHexString(Br)}`}catch{return n}}function NO(e,t){let n=new ff;for(let t of e.paths)for(let e of t.subPaths)for(let t of e.getPoints(4))n.expandByPoint(t);return(n.isEmpty()?100:Math.max(n.max.x-n.min.x,n.max.y-n.min.y,1e-6))/(t*10)}function PO(e,t,n={}){let r=[],i=Math.max(1,Math.round(Q(n.curveSegments,12))),a=NO(e,i),o=n.currentColor??`#1f2330`;for(let s of e.paths){let e=s.userData?.style??{};if(e.visibility===`hidden`||e.visibility===`collapse`)continue;let c=Q(e.opacity,1);if(zO(e.fill)){let t=s.toShapes().map(e=>zD(e,a));t.length&&r.push({kind:`fill`,color:MO(e.fill,s,o),opacity:Q(e.fillOpacity,1)*c,shapes:t})}if(n.strokes!==!1&&zO(e.stroke)&&Q(e.strokeWidth,1)>0){let n=t.getStrokeStyle(Q(e.strokeWidth,1),`#000`,e.strokeLineJoin??`miter`,e.strokeLineCap??`butt`,Q(e.strokeMiterLimit,4)),l=[];for(let e of s.subPaths){let r=RD(e,a);if(r.length<2)continue;let o=t.pointsToStroke(r,n,i);o&&l.push(o)}if(l.length){let t=l.length===1?l[0]:FO(l);r.push({kind:`stroke`,color:MO(e.stroke,s,o),opacity:Q(e.strokeOpacity,1)*c,stroke:t})}}}return r}function FO(e){let t=0;for(let n of e)t+=n.getAttribute(`position`).count;let n=new Float32Array(t*3),r=0;for(let t of e){let e=t.getAttribute(`position`).array;n.set(e,r),r+=e.length,t.dispose()}let i=new G;return i.setAttribute(`position`,new co(n,3)),i}function IO(e,t=12){let n=new ff;for(let r of e){if(r.shapes)for(let e of r.shapes)for(let r of e.getPoints(t))n.expandByPoint(r);if(r.stroke){let e=r.stroke.getAttribute(`position`);for(let t=0;t<e.count;t++)n.expandByPoint(new z(e.getX(t),e.getY(t)))}}return n}function LO(e,t,n,r,i){if(e.kind===`stroke`)return e.stroke?VD(e.stroke,t):null;if(!e.shapes?.length)return null;if(t<=0)return new Ol(e.shapes,r);let a=Math.min(n,t*.45),o=new xl(e.shapes,{depth:Math.max(t-a*2,t*.05),curveSegments:r,bevelEnabled:a>0,bevelThickness:a,bevelSize:a*.6,bevelOffset:0,bevelSegments:3});return o.translate(0,0,a),o.clearGroups(),BD(o,50*Math.PI/180,i)}async function RO(e,t){let[{SVGLoader:n},r]=await Promise.all([Promise.resolve().then(()=>(AO(),CO)),Promise.resolve().then(()=>(Wv(),kv))]),i=e.src.trim().startsWith(`<`)?e.src:await mg(t.resolveAsset(e.src)),a=new n().parse(i),o=e.material?lw(e.material):void 0,s=typeof o?.color==`string`?o.color:void 0,c=Math.max(1,Math.round(Q(e.curveSegments,12))),l=PO(a,n,{strokes:e.strokes,curveSegments:c,currentColor:s}),u=new ba,d=IO(l,c);if(!l.length||d.isEmpty())return u;let f=Q(e.size,2),p=Math.max(d.max.x-d.min.x,1e-6),m=Math.max(d.max.y-d.min.y,1e-6),h=e.fit??`width`,g=f/(h===`height`?m:h===`max`?Math.max(p,m):p),_=Math.max(0,Q(e.depth,.2)),v=_/g,y=Q(e.bevel,0)/g,b=Q(e.layerGap,_>0?_*.02:f*.002),x=e.keepColors??!e.material,S=/* @__PURE__ */ new Map,C=async(n,r)=>{let i=x?`${n}|${r}`:`|${r}`,a=S.get(i);return a||(a=await yw(x?{roughness:.4,metalness:.1,...e.material??{},color:n,...r<1?{opacity:r}:{}}:e.material?{...e.material,...r<1?{opacity:r}:{}}:{color:`#dddddd`,roughness:.4,metalness:.1},t,{defaultColor:n}),r<1&&(a.transparent=!0),_<=0&&(a.side=2),S.set(i,a)),a},w=[];for(let e of l){let t=LO(e,v,y,c,r);if(!t)continue;t.getAttribute(`normal`)||t.computeVertexNormals();let n=x?`${e.color}|${e.opacity}`:`|${e.opacity}`,i=w[w.length-1];i&&i.key===n?i.geos.push(t):w.push({key:n,color:e.color,opacity:e.opacity,geos:[t]})}let T=new ba;for(let[e,t]of w.entries()){for(let e of t.geos){for(let t of Object.keys(e.attributes))[`position`,`normal`,`uv`].includes(t)||e.deleteAttribute(t);e.getAttribute(`uv`)||e.setAttribute(`uv`,new W(new Float32Array(e.getAttribute(`position`).count*2),2))}let n=t.geos.length===1?t.geos[0]:r.mergeGeometries(t.geos.map(e=>e.index?e.toNonIndexed():e),!1)??t.geos[0],i=new K(n,await C(t.color,t.opacity));i.position.z=e*b/g,T.add(i)}let E=(d.min.x+d.max.x)/2,D=(d.min.y+d.max.y)/2;return T.scale.set(g,-g,g),T.position.set(-E*g,D*g,-(_+Math.max(0,w.length-1)*b)/2),u.add(T),u}var zO,BO=t((()=>{J(),yg(),zS(),HD(),jw(),zO=e=>!!e&&e!==`none`&&e!==`transparent`})),VO=/* @__PURE__ */ n({PHOTO_DEFAULTS:()=>ik,autoDrift:()=>UO,buildMeshGeometry:()=>nk,buildPhoto:()=>rk,layerBands:()=>ZO,meshRange:()=>YO,meshSegments:()=>JO,motionSettings:()=>WO,parallaxParams:()=>qO,photoSize:()=>HO,smoothToward:()=>KO,tiltToOffset:()=>QO,triangleCut:()=>XO,viewOffset:()=>GO});function HO(e,t,n){let r=t>0&&n>0?t/n:1,i=typeof e.width==`number`&&e.width>0?e.width:void 0,a=typeof e.height==`number`&&e.height>0?e.height:void 0;if(i!==void 0&&a!==void 0)return{width:i,height:a};if(a!==void 0)return{width:a*r,height:a};let o=i??ik.width;return{width:o,height:o/r}}function UO(e,t,n){let r=2*Math.PI*Math.max(0,t)/10*n;switch(e??`sway`){case`sway`:return{x:.9*Math.sin(r),y:.35*Math.sin(2*r),zoom:0};case`orbit`:{let e=Math.min(1,r/Math.PI),t=.8*e*e*(3-2*e);return{x:t*Math.sin(r),y:t*Math.cos(r),zoom:0}}case`zoom`:return{x:0,y:0,zoom:.5-.5*Math.cos(r)};default:return{x:0,y:0,zoom:0}}}function WO(e){let t=TS(Q(e?.pointer,1),0,1);return{pointer:t,scroll:TS(Q(e?.scroll,0),0,1),gyro:typeof e?.gyro==`boolean`?e.gyro:t>0,auto:e?.auto??`sway`,speed:Math.max(0,Q(e?.speed,ik.speed)),smoothing:TS(Q(e?.smoothing,ik.smoothing),0,.99)}}function GO(e,t){let n=t.reduced?{x:0,y:0,zoom:0}:UO(e.auto,e.speed,t.t),r=e.pointer*(t.reduced?.5:1),i=0,a=0,o=0;t.gyro&&e.gyro&&t.pointer.weight<.5?(i=t.gyro.x,a=t.gyro.y,o=+(r>0)):r>0&&(i=t.pointer.x,a=t.pointer.y,o=TS(t.pointer.weight,0,1));let s=n.x*(1-o)+i*r*o,c=n.y*(1-o)+a*r*o;return e.scroll>0&&(c+=(TS(t.scroll,0,1)*2-1)*e.scroll),{x:TS(s,-1,1),y:TS(c,-1,1),zoom:n.zoom*(1-o)}}function KO(e,t,n,r){if(r<=0||n<=0)return n<=0&&r>0?e:t;let i=1-TS(r,0,.99)**(n*60),a=e+(t-e)*i;return Math.abs(t-a)<1e-4?t:a}function qO(e,t,n){let r=TS(e,0,1),i=Math.min(t,n),a=i/t,o=i/n;return{maxOffset:[r*.06*a,r*.06*o],inset:[1/(1+r*.1*a),1/(1+r*.1*o)]}}function JO(e,t,n){let r=Math.round(TS(Q(e,ik.segments),2,1024));return t>=n?[r,Math.max(1,Math.round(r*n/t))]:[Math.max(1,Math.round(r*t/n)),r]}function YO(e,t){return TS(e,0,1)*t*.25}function XO(e,t,n){return Math.min(t[0],t[1],t[2])<.5?!0:n<=0?!1:Math.max(Math.abs(e[0]-e[1]),Math.abs(e[1]-e[2]),Math.abs(e[0]-e[2]))>n}function ZO(e,t,n,r){let i=Math.round(TS(Q(e,ik.layers),2,16)),a=[],o=TS(n,0,1)*r*.1;for(let e=0;e<i;e++){let n=e/i,s=(e+1)/i,c=(n+s)/2;a.push({lo:n,hi:s,center:c,feather:.35/i,z:(c-t)*o+e*.001*r,background:e===0})}return a}function QO(e,t,n,r){let i=t-n.gamma,a=e-n.beta,o=(Math.round(r/90)%4+4)%4;return o===1?[i,a]=[a,-i]:o===2?[i,a]=[-i,-a]:o===3&&([i,a]=[-a,i]),{x:TS(i/20,-1,1),y:TS(-a/20,-1,1)}}function $O(e){let t=e.image;return{w:t?.naturalWidth||t?.width||1,h:t?.naturalHeight||t?.height||1}}function ek(e,t,n){let r=t.material??{};return{uMap:{value:e},uTint:{value:r.color?n.color(r.color):new H(1,1,1)},uOpacity:{value:TS(Q(r.opacity,1),0,1)},uIntensity:{value:Math.max(0,Q(r.emissiveIntensity,1))}}}function tk(e,t,n,r){let i=new Bl({vertexShader:e,fragmentShader:t,uniforms:n,transparent:r,toneMapped:!1,fog:!1,side:0});return i.depthWrite=!r,i}function nk(e,t,n,r){let i=n*r*2,a=new Float32Array(i*9),o=new Float32Array(i*6),s=new Float32Array(i*12),c=0,l=(n,r,i)=>{let l=[n,r,i];for(let n=0;n<3;n++){let[r,i]=l[n],u=l[(n+1)%3],d=l[(n+2)%3];a.set([(r-.5)*e,(i-.5)*t,0],c*3),o.set([r,i],c*2),s.set([u[0],u[1],d[0],d[1]],c*4),c++}};for(let e=0;e<r;e++)for(let t=0;t<n;t++){let i=t/n,a=(t+1)/n,o=e/r,s=(e+1)/r;l([i,o],[a,o],[a,s]),l([i,o],[a,s],[i,s])}let u=new G;return u.setAttribute(`position`,new co(a,3)),u.setAttribute(`uv`,new co(o,2)),u.setAttribute(`uvOther`,new co(s,4)),u}async function rk(e,t){let[n,r]=await Promise.all([gg(t.resolveAsset(e.src)),e.depth?gg(t.resolveAsset(e.depth)).catch(n=>(t.issue(`asset-load`,`${e.id}: depth map: ${n.message} — showing the photo flat`,`objects#${e.id}.depth`),null)):Promise.resolve(null)]);n.colorSpace=Br,n.wrapS=n.wrapT=sn,n.anisotropy=4,n.needsUpdate=!0,r&&(r.colorSpace=``,r.premultiplyAlpha=!1,r.wrapS=r.wrapT=sn,r.generateMipmaps=!1,r.minFilter=pn,r.magFilter=pn,r.needsUpdate=!0);let i=$O(n),{width:a,height:o}=HO(e,i.w,i.h),s=TS(Q(e.strength,ik.strength),0,1),c=TS(Q(e.focus,ik.focus),0,1),l=TS(Q(e.material?.opacity,1),0,1),u=l<1||/\.(png|webp)$/i.test(e.src),d=WO(e.motion),f=r?e.mode??`parallax`:`flat`,p=new ba,m=new ba;p.add(m);let h=[],g=[],_=[],v=[],y=null,b=()=>{let e=new El(a,o);return g.push(e),e};if(f===`flat`){let r=e.material??{},i=new ss({map:n,transparent:u,opacity:l,toneMapped:!1,fog:!1});r.color&&i.color.copy(t.color(r.color)),i.color.multiplyScalar(Math.max(0,Q(r.emissiveIntensity,1))),u&&(i.alphaTest=l<1?0:.004),h.push(i),m.add(new K(b(),i))}else if(f===`parallax`){let i=qO(s,a,o),l={...ek(n,e,t),uDepth:{value:r},uView:{value:new z},uZoom:{value:0},uMaxOffset:{value:new z(...i.maxOffset)},uInset:{value:new z(...i.inset)},uFocus:{value:c},uWallSlope:{value:.02}},d=tk(ok,sk,l,u);h.push(d),_.push(d),m.add(new K(b(),d))}else if(f===`mesh`){let[i,u]=JO(Q(e.segments,ik.segments),a,o),d=YO(s,a),f=nk(a,o,i,u);f.boundingBox=new Wa(new B(-a/2,-o/2,-c*d),new B(a/2,o/2,(1-c)*d)),f.boundingSphere=f.boundingBox.getBoundingSphere(new xo),g.push(f);let p={...ek(n,e,t),uDepth:{value:r},uRange:{value:d},uFocus:{value:c},uEdgeCut:{value:TS(Q(e.edgeCut,ik.edgeCut),0,1)},uCam:{value:new B(0,0,1e6)},uPerspective:{value:0}};y=p;let _=tk(ck,lk,p,l<1);_.side=2,h.push(_);let v=new K(f,_);v.renderOrder=1,m.add(v);{let e=new El(a,o,Math.max(1,Math.round(i/2)),Math.max(1,Math.round(u/2)));e.boundingBox=f.boundingBox.clone(),e.boundingSphere=f.boundingSphere.clone(),g.push(e);let t=new z(6/i,6/u),n=tk(uk,dk,{...p,uReach:{value:t}},l<1);n.side=2,h.push(n);let r=new K(e,n);r.renderOrder=0,r.raycast=()=>void 0,m.add(r)}}else{let i=qO(s,a,o),l=b(),d=ZO(Q(e.layers,ik.layers),c,s,a),f=TS(Q(e.edgeCut,ik.edgeCut),0,1);d.forEach((a,o)=>{let s={...ek(n,e,t),uDepth:{value:r},uView:{value:new z},uZoom:{value:0},uMaxOffset:{value:new z(...i.maxOffset)},uInset:{value:new z(...i.inset)},uFocus:{value:c},uCenter:{value:a.center},uLo:{value:a.lo},uHi:{value:a.hi},uFeather:{value:f>0?Math.min(a.feather,f):.002},uBackground:{value:+!!a.background}},d=tk(ok,fk,s,!a.background||u);h.push(d),_.push(d);let p=new K(l,d);p.position.z=a.z,p.renderOrder=o,p.userData.a3dPhotoLayer=o,m.add(p),v.push({mesh:p,band:a})})}let x=!t.deterministic,S={x:0,y:0,weight:0,init:!1},C=null,w=null,T=null;if(x&&d.gyro&&d.pointer>0&&f!==`flat`&&typeof window<`u`&&typeof window.addEventListener==`function`){let e=e=>{if(e.beta===null||e.gamma===null)return;w??={beta:e.beta,gamma:e.gamma};let t=typeof screen<`u`&&screen.orientation?.angle||0;C=QO(e.beta,e.gamma,w,t)};window.addEventListener(`deviceorientation`,e),T=()=>window.removeEventListener(`deviceorientation`,e)}let E=new B,D=!1,O=s*8*LS;return{object:p,update:(e,t,n)=>{if(f===`flat`)return;let r=n.pointer,i=r.inside?TS(r.x,-1,1):0,o=r.inside?TS(r.y,-1,1):0,c=+!!r.inside;!x||!S.init?(S.x=i,S.y=o,S.weight=c,S.init=x):(S.x=KO(S.x,i,t,d.smoothing),S.y=KO(S.y,o,t,d.smoothing),S.weight=KO(S.weight,c,t,d.smoothing));let l=GO(d,{t:e,pointer:S,gyro:x?C:null,scroll:n.scroll,reduced:n.reduced});for(let e of _)e.uniforms.uView.value.set(l.x,l.y),e.uniforms.uZoom.value=l.zoom;let u=!!n.camera&&!!n.camera.isPerspectiveCamera;if(n.camera&&!D&&f!==`parallax`&&(n.camera.updateMatrixWorld(),p.updateWorldMatrix(!0,!1),E.setFromMatrixPosition(n.camera.matrixWorld),p.worldToLocal(E),D=!0),f===`mesh`)m.rotation.set(l.y*O,-l.x*O,0),m.position.z=l.zoom*YO(s,a)*.5,y&&(y.uCam.value.copy(E),y.uPerspective.value=u&&E.z>0?1:0);else if(f===`layers`&&D){let e=E.z;for(let{mesh:t,band:n}of v)if(u&&e>n.z+.001){let r=(e-n.z)/e;t.scale.set(r,r,1),t.position.set(E.x*n.z/e,E.y*n.z/e,n.z)}else t.scale.set(1,1,1),t.position.set(0,0,n.z)}},dispose(){T?.(),T=null;for(let e of h)e.dispose();for(let e of g)e.dispose();n.dispose(),r?.dispose()}}}var ik,ak,ok,sk,ck,lk,uk,dk,fk,pk=t((()=>{J(),yg(),zS(),ik={width:4,strength:.5,focus:.5,segments:256,layers:6,edgeCut:.08,speed:1,smoothing:.9},ak=`
|
|
5797
|
+
uniform sampler2D uMap;
|
|
5798
|
+
uniform vec3 uTint;
|
|
5799
|
+
uniform float uOpacity;
|
|
5800
|
+
uniform float uIntensity;
|
|
5801
|
+
vec4 shade(vec4 c, float a) {
|
|
5802
|
+
return vec4(c.rgb * uTint * uIntensity, c.a * a * uOpacity);
|
|
5803
|
+
}
|
|
5804
|
+
`,ok=`
|
|
5805
|
+
varying vec2 vUv;
|
|
5806
|
+
void main() {
|
|
5807
|
+
vUv = uv;
|
|
5808
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
5809
|
+
}
|
|
5810
|
+
`,sk=`
|
|
5811
|
+
${ak}
|
|
5812
|
+
uniform sampler2D uDepth;
|
|
5813
|
+
uniform vec2 uView;
|
|
5814
|
+
uniform float uZoom;
|
|
5815
|
+
uniform vec2 uMaxOffset;
|
|
5816
|
+
uniform vec2 uInset;
|
|
5817
|
+
uniform float uFocus;
|
|
5818
|
+
uniform float uWallSlope;
|
|
5819
|
+
varying vec2 vUv;
|
|
5820
|
+
const int STEPS = 32;
|
|
5821
|
+
void main() {
|
|
5822
|
+
// the zoom drift also pushes in slightly (stays inside the inset margin)
|
|
5823
|
+
vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
|
|
5824
|
+
vec2 v = uView - (vUv - 0.5) * 2.0 * uZoom;
|
|
5825
|
+
vec2 dir = v * uMaxOffset;
|
|
5826
|
+
vec2 uv = base;
|
|
5827
|
+
if (dot(dir, dir) > 1e-10) {
|
|
5828
|
+
float stepH = 1.0 / float(STEPS);
|
|
5829
|
+
float h = 1.0;
|
|
5830
|
+
float prevH = 1.0 + stepH;
|
|
5831
|
+
bool hit = false;
|
|
5832
|
+
for (int i = 0; i <= STEPS; i++) {
|
|
5833
|
+
h = 1.0 - float(i) * stepH;
|
|
5834
|
+
float d = textureLod(uDepth, base + (h - uFocus) * dir, 0.0).r;
|
|
5835
|
+
if (d >= h) { hit = true; break; }
|
|
5836
|
+
prevH = h;
|
|
5837
|
+
}
|
|
5838
|
+
float lo = h, hi = min(prevH, 1.0);
|
|
5839
|
+
if (hit) {
|
|
5840
|
+
for (int j = 0; j < 6; j++) {
|
|
5841
|
+
float mid = 0.5 * (lo + hi);
|
|
5842
|
+
float d = textureLod(uDepth, base + (mid - uFocus) * dir, 0.0).r;
|
|
5843
|
+
if (d >= mid) lo = mid; else hi = mid;
|
|
5844
|
+
}
|
|
5845
|
+
}
|
|
5846
|
+
uv = base + (lo - uFocus) * dir;
|
|
5847
|
+
// Disocclusion: the ray hit the steep "wall" of a depth edge. Stretching
|
|
5848
|
+
// the foreground edge colour reads as a smear: take the colour from just
|
|
5849
|
+
// past the edge on the far side instead (the background continues).
|
|
5850
|
+
vec2 texel = 1.0 / vec2(textureSize(uDepth, 0));
|
|
5851
|
+
vec4 dh = textureLod(uDepth, uv, 0.0);
|
|
5852
|
+
vec2 grad = vec2(
|
|
5853
|
+
textureLod(uDepth, uv + vec2(texel.x * 1.5, 0.0), 0.0).r - textureLod(uDepth, uv - vec2(texel.x * 1.5, 0.0), 0.0).r,
|
|
5854
|
+
textureLod(uDepth, uv + vec2(0.0, texel.y * 1.5), 0.0).r - textureLod(uDepth, uv - vec2(0.0, texel.y * 1.5), 0.0).r) / 3.0;
|
|
5855
|
+
float g = length(grad);
|
|
5856
|
+
vec2 toNear = grad / max(g, 1e-6);
|
|
5857
|
+
float dNear = textureLod(uDepth, uv + toNear * texel * 3.0, 0.0).r;
|
|
5858
|
+
if (hit && (g > uWallSlope || dh.a < 0.5) && dNear > lo + 0.04) {
|
|
5859
|
+
vec2 away = -toNear;
|
|
5860
|
+
vec2 probe = uv;
|
|
5861
|
+
for (int k = 1; k <= 6; k++) {
|
|
5862
|
+
vec2 q = uv + away * texel * float(k * 2);
|
|
5863
|
+
probe = q;
|
|
5864
|
+
if (textureLod(uDepth, q, 0.0).r < lo - 0.05) break;
|
|
5865
|
+
}
|
|
5866
|
+
uv = probe + away * texel * 2.0;
|
|
5867
|
+
}
|
|
5868
|
+
}
|
|
5869
|
+
vec4 c = textureGrad(uMap, uv, dFdx(base), dFdy(base));
|
|
5870
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
5871
|
+
gl_FragColor = shade(c, 1.0);
|
|
5872
|
+
#include <tonemapping_fragment>
|
|
5873
|
+
#include <colorspace_fragment>
|
|
5874
|
+
}
|
|
5875
|
+
`,ck=`
|
|
5876
|
+
uniform sampler2D uDepth;
|
|
5877
|
+
uniform float uRange;
|
|
5878
|
+
uniform float uFocus;
|
|
5879
|
+
uniform float uEdgeCut;
|
|
5880
|
+
uniform vec3 uCam;
|
|
5881
|
+
uniform float uPerspective;
|
|
5882
|
+
attribute vec4 uvOther;
|
|
5883
|
+
varying vec2 vUv;
|
|
5884
|
+
varying float vDepth;
|
|
5885
|
+
varying float vCut;
|
|
5886
|
+
varying float vMotion;
|
|
5887
|
+
vec3 displaced(vec3 p, float z) {
|
|
5888
|
+
if (uPerspective > 0.5 && uCam.z > z + 1e-3) p.xy = mix(p.xy, uCam.xy, z / uCam.z);
|
|
5889
|
+
p.z = z;
|
|
5890
|
+
return p;
|
|
5891
|
+
}
|
|
5892
|
+
void main() {
|
|
5893
|
+
vUv = uv;
|
|
5894
|
+
vec4 d0 = textureLod(uDepth, uv, 0.0);
|
|
5895
|
+
vec4 d1 = textureLod(uDepth, uvOther.xy, 0.0);
|
|
5896
|
+
vec4 d2 = textureLod(uDepth, uvOther.zw, 0.0);
|
|
5897
|
+
float jump = max(max(abs(d0.r - d1.r), abs(d1.r - d2.r)), abs(d0.r - d2.r));
|
|
5898
|
+
bool cut = min(d0.a, min(d1.a, d2.a)) < 0.5 || (uEdgeCut > 0.0 && jump > uEdgeCut);
|
|
5899
|
+
vCut = cut ? 1.0 : 0.0;
|
|
5900
|
+
vDepth = d0.r;
|
|
5901
|
+
vec4 c = projectionMatrix * modelViewMatrix * vec4(displaced(position, (d0.r - uFocus) * uRange), 1.0);
|
|
5902
|
+
vMotion = 0.0;
|
|
5903
|
+
if (cut) {
|
|
5904
|
+
vec4 a = projectionMatrix * modelViewMatrix * vec4(displaced(position, -uFocus * uRange), 1.0);
|
|
5905
|
+
vec4 b = projectionMatrix * modelViewMatrix * vec4(displaced(position, (1.0 - uFocus) * uRange), 1.0);
|
|
5906
|
+
vMotion = length(b.xy / b.w - a.xy / a.w);
|
|
5907
|
+
}
|
|
5908
|
+
gl_Position = c;
|
|
5909
|
+
}
|
|
5910
|
+
`,lk=`
|
|
5911
|
+
${ak}
|
|
5912
|
+
uniform sampler2D uDepth;
|
|
5913
|
+
varying vec2 vUv;
|
|
5914
|
+
varying float vDepth;
|
|
5915
|
+
varying float vCut;
|
|
5916
|
+
varying float vMotion;
|
|
5917
|
+
void main() {
|
|
5918
|
+
if (vCut > 0.5) {
|
|
5919
|
+
float d = textureLod(uDepth, vUv, 0.0).r;
|
|
5920
|
+
if (abs(d - vDepth) * vMotion > 0.004) discard;
|
|
5921
|
+
}
|
|
5922
|
+
vec4 c = texture2D(uMap, vUv);
|
|
5923
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
5924
|
+
gl_FragColor = shade(c, 1.0);
|
|
5925
|
+
#include <tonemapping_fragment>
|
|
5926
|
+
#include <colorspace_fragment>
|
|
5927
|
+
}
|
|
5928
|
+
`,uk=`
|
|
5929
|
+
uniform sampler2D uDepth;
|
|
5930
|
+
uniform float uRange;
|
|
5931
|
+
uniform float uFocus;
|
|
5932
|
+
uniform vec3 uCam;
|
|
5933
|
+
uniform float uPerspective;
|
|
5934
|
+
uniform vec2 uReach;
|
|
5935
|
+
varying vec2 vUv;
|
|
5936
|
+
varying float vDepth;
|
|
5937
|
+
void main() {
|
|
5938
|
+
vUv = uv;
|
|
5939
|
+
float d = textureLod(uDepth, uv, 0.0).r;
|
|
5940
|
+
for (int i = 1; i <= 2; i++) {
|
|
5941
|
+
vec2 r = uReach * float(i) * 0.5;
|
|
5942
|
+
d = min(d, textureLod(uDepth, uv + vec2(r.x, 0.0), 0.0).r);
|
|
5943
|
+
d = min(d, textureLod(uDepth, uv - vec2(r.x, 0.0), 0.0).r);
|
|
5944
|
+
d = min(d, textureLod(uDepth, uv + vec2(0.0, r.y), 0.0).r);
|
|
5945
|
+
d = min(d, textureLod(uDepth, uv - vec2(0.0, r.y), 0.0).r);
|
|
5946
|
+
d = min(d, textureLod(uDepth, uv + r, 0.0).r);
|
|
5947
|
+
d = min(d, textureLod(uDepth, uv - r, 0.0).r);
|
|
5948
|
+
d = min(d, textureLod(uDepth, uv + vec2(r.x, -r.y), 0.0).r);
|
|
5949
|
+
d = min(d, textureLod(uDepth, uv + vec2(-r.x, r.y), 0.0).r);
|
|
5950
|
+
}
|
|
5951
|
+
vDepth = d;
|
|
5952
|
+
float z = (d - uFocus) * uRange - uRange * 0.02;
|
|
5953
|
+
vec3 p = position;
|
|
5954
|
+
if (uPerspective > 0.5 && uCam.z > z + 1e-3) p.xy = mix(p.xy, uCam.xy, z / uCam.z);
|
|
5955
|
+
p.z = z;
|
|
5956
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
|
|
5957
|
+
}
|
|
5958
|
+
`,dk=`
|
|
5959
|
+
${ak}
|
|
5960
|
+
uniform sampler2D uDepth;
|
|
5961
|
+
varying vec2 vUv;
|
|
5962
|
+
varying float vDepth;
|
|
5963
|
+
void main() {
|
|
5964
|
+
vec2 uv = vUv;
|
|
5965
|
+
float d = textureLod(uDepth, uv, 0.0).r;
|
|
5966
|
+
if (d > vDepth + 0.04) {
|
|
5967
|
+
vec2 texel = 1.0 / vec2(textureSize(uDepth, 0));
|
|
5968
|
+
vec2 grad = vec2(
|
|
5969
|
+
textureLod(uDepth, uv + vec2(texel.x * 2.0, 0.0), 0.0).r - textureLod(uDepth, uv - vec2(texel.x * 2.0, 0.0), 0.0).r,
|
|
5970
|
+
textureLod(uDepth, uv + vec2(0.0, texel.y * 2.0), 0.0).r - textureLod(uDepth, uv - vec2(0.0, texel.y * 2.0), 0.0).r);
|
|
5971
|
+
vec2 away = length(grad) > 1e-5 ? -normalize(grad) : vec2(0.0);
|
|
5972
|
+
// walk towards the background until the depth reaches this surface's
|
|
5973
|
+
for (int k = 1; k <= 24; k++) {
|
|
5974
|
+
uv = vUv + away * texel * float(k * 3);
|
|
5975
|
+
if (textureLod(uDepth, uv, 0.0).r <= vDepth + 0.04) break;
|
|
5976
|
+
}
|
|
5977
|
+
uv += away * texel * 2.0;
|
|
5978
|
+
}
|
|
5979
|
+
vec4 c = texture2D(uMap, uv);
|
|
5980
|
+
if (c.a * uOpacity < 0.004) discard;
|
|
5981
|
+
gl_FragColor = shade(c, 1.0);
|
|
5982
|
+
#include <tonemapping_fragment>
|
|
5983
|
+
#include <colorspace_fragment>
|
|
5984
|
+
}
|
|
5985
|
+
`,fk=`
|
|
5986
|
+
${ak}
|
|
5987
|
+
uniform sampler2D uDepth;
|
|
5988
|
+
uniform vec2 uView;
|
|
5989
|
+
uniform float uZoom;
|
|
5990
|
+
uniform vec2 uMaxOffset;
|
|
5991
|
+
uniform vec2 uInset;
|
|
5992
|
+
uniform float uFocus;
|
|
5993
|
+
uniform float uCenter;
|
|
5994
|
+
uniform float uLo;
|
|
5995
|
+
uniform float uHi;
|
|
5996
|
+
uniform float uFeather;
|
|
5997
|
+
uniform float uBackground;
|
|
5998
|
+
varying vec2 vUv;
|
|
5999
|
+
void main() {
|
|
6000
|
+
// the zoom drift also pushes in slightly (stays inside the inset margin)
|
|
6001
|
+
vec2 base = 0.5 + (vUv - 0.5) * uInset * (1.0 - 0.06 * uZoom);
|
|
6002
|
+
vec2 v = uView - (vUv - 0.5) * 2.0 * uZoom;
|
|
6003
|
+
// Each layer moves with the depth it shows, clamped to its band: a smooth
|
|
6004
|
+
// surface crossing two bands stays continuous (no tear at the band edge);
|
|
6005
|
+
// only real depth jumps separate the layers. Fixed-point solve, from the
|
|
6006
|
+
// band centre.
|
|
6007
|
+
vec2 dir = v * uMaxOffset;
|
|
6008
|
+
vec2 uv = base + (uCenter - uFocus) * dir;
|
|
6009
|
+
for (int i = 0; i < 3; i++) {
|
|
6010
|
+
float di = clamp(textureLod(uDepth, uv, 0.0).r, uLo, uHi);
|
|
6011
|
+
uv = base + (di - uFocus) * dir;
|
|
6012
|
+
}
|
|
6013
|
+
vec4 dd = textureLod(uDepth, uv, 0.0);
|
|
6014
|
+
float d = dd.r;
|
|
6015
|
+
// soft slice edges, but hard on marked depth edges (alpha 0): a blend of
|
|
6016
|
+
// two layers there would draw a thin double outline
|
|
6017
|
+
float a = uBackground > 0.5 ? 1.0 : dd.a < 0.5 ? step(uLo, d) : smoothstep(uLo - uFeather, uLo + uFeather, d);
|
|
6018
|
+
if (a < 0.004) discard;
|
|
6019
|
+
vec2 cuv = uv;
|
|
6020
|
+
// covered by nearer content
|
|
6021
|
+
if (d > uHi + uFeather) {
|
|
6022
|
+
bool found = false;
|
|
6023
|
+
vec2 reach = v * uMaxOffset * 1.25;
|
|
6024
|
+
for (int k = 1; k <= 16; k++) {
|
|
6025
|
+
vec2 q = uv + reach * (float(k) / 16.0);
|
|
6026
|
+
vec4 dq = textureLod(uDepth, q, 0.0);
|
|
6027
|
+
if (dq.r <= uHi && dq.a >= 0.5 && (uBackground > 0.5 || dq.r >= uLo - uFeather)) {
|
|
6028
|
+
// step past the edge's blended texels
|
|
6029
|
+
vec2 texel = 1.0 / vec2(textureSize(uMap, 0));
|
|
6030
|
+
cuv = q + normalize(reach) * texel * 3.0;
|
|
6031
|
+
found = true;
|
|
6032
|
+
break;
|
|
6033
|
+
}
|
|
6034
|
+
}
|
|
6035
|
+
// Nothing of this band to extend: let the layers below show (the
|
|
6036
|
+
// background keeps the source texel).
|
|
6037
|
+
if (!found && uBackground < 0.5) discard;
|
|
6038
|
+
}
|
|
6039
|
+
vec4 c = textureGrad(uMap, cuv, dFdx(base), dFdy(base));
|
|
6040
|
+
gl_FragColor = shade(c, a);
|
|
6041
|
+
if (gl_FragColor.a < 0.004) discard;
|
|
6042
|
+
#include <tonemapping_fragment>
|
|
6043
|
+
#include <colorspace_fragment>
|
|
6044
|
+
}
|
|
6045
|
+
`})),mk=/* @__PURE__ */ n({clone:()=>vk,retarget:()=>gk,retargetClip:()=>_k});function hk(e,t){return t.getBoneName===void 0?t.names[e.name]:t.getBoneName(e)}function gk(e,t,n={}){let r=new wi,i=new B,a=new V,o=new V;n.preserveBoneMatrix=n.preserveBoneMatrix===void 0||n.preserveBoneMatrix,n.preserveBonePositions=n.preserveBonePositions===void 0||n.preserveBonePositions,n.useTargetMatrix=n.useTargetMatrix!==void 0&&n.useTargetMatrix,n.hip=n.hip===void 0?`hip`:n.hip,n.hipInfluence=n.hipInfluence===void 0?new B(1,1,1):n.hipInfluence,n.scale=n.scale===void 0?1:n.scale,n.names=n.names||{};let s=t.isObject3D?t.skeleton.bones:bk(t),c=e.isObject3D?e.skeleton.bones:bk(e),l,u,d,f;if(e.isObject3D?e.skeleton.pose():(n.useTargetMatrix=!0,n.preserveBoneMatrix=!1),n.preserveBonePositions){f=[];for(let e=0;e<c.length;e++)f.push(c[e].position.clone())}if(n.preserveBoneMatrix){e.updateMatrixWorld(),e.matrixWorld.identity();for(let t=0;t<e.children.length;++t)e.children[t].updateMatrixWorld(!0)}for(let t=0;t<c.length;++t)l=c[t],u=hk(l,n),d=yk(u,s),o.copy(l.matrixWorld),d&&(d.updateMatrixWorld(),n.useTargetMatrix?a.copy(d.matrixWorld):(a.copy(e.matrixWorld).invert(),a.multiply(d.matrixWorld)),i.setFromMatrixScale(a),a.scale(i.set(1/i.x,1/i.y,1/i.z)),o.makeRotationFromQuaternion(r.setFromRotationMatrix(a)),e.isObject3D&&n.localOffsets&&n.localOffsets[l.name]&&o.multiply(n.localOffsets[l.name]),o.copyPosition(a)),u===n.hip&&(o.elements[12]*=n.scale*n.hipInfluence.x,o.elements[13]*=n.scale*n.hipInfluence.y,o.elements[14]*=n.scale*n.hipInfluence.z,n.hipPosition!==void 0&&(o.elements[12]+=n.hipPosition.x*n.scale,o.elements[13]+=n.hipPosition.y*n.scale,o.elements[14]+=n.hipPosition.z*n.scale)),l.parent?(l.matrix.copy(l.parent.matrixWorld).invert(),l.matrix.multiply(o)):l.matrix.copy(o),l.matrix.decompose(l.position,l.quaternion,l.scale),l.updateMatrixWorld();if(n.preserveBonePositions)for(let e=0;e<c.length;++e)l=c[e],u=hk(l,n)||l.name,u!==n.hip&&l.position.copy(f[e]);n.preserveBoneMatrix&&e.updateMatrixWorld(!0)}function _k(e,t,n,r={}){r.useFirstFramePosition=r.useFirstFramePosition!==void 0&&r.useFirstFramePosition,r.fps=r.fps===void 0?Math.max(...n.tracks.map(e=>e.times.length))/n.duration:r.fps,r.names=r.names||[],t.isObject3D||(t=xk(t));let i=Math.round(n.duration*(r.fps/1e3)*1e3),a=n.duration/(i-1),o=[],s=new Zd(t),c=bk(e.skeleton),l=[],u,d,f,p,m;s.clipAction(n).play();let h=0,g=i;r.trim===void 0?s.update(0):(h=Math.round(r.trim[0]*r.fps),g=Math.min(Math.round(r.trim[1]*r.fps),i)-h,s.update(r.trim[0])),t.updateMatrixWorld();for(let n=0;n<g;++n){let i=n*a;gk(e,t,r);for(let e=0;e<c.length;++e)d=c[e],m=hk(d,r)||d.name,f=yk(m,t.skeleton),f&&(p=l[e]=l[e]||{bone:d},r.hip===m&&(p.pos||(p.pos={times:new Float32Array(g),values:new Float32Array(g*3)}),r.useFirstFramePosition&&(n===0&&(u=d.position.clone()),d.position.sub(u)),p.pos.times[n]=i,d.position.toArray(p.pos.values,n*3)),p.quat||(p.quat={times:new Float32Array(g),values:new Float32Array(g*4)}),p.quat.times[n]=i,d.quaternion.toArray(p.quat.values,n*4));n===g-2?s.update(a-1e-7):s.update(a),t.updateMatrixWorld()}for(let e=0;e<l.length;++e)p=l[e],p&&(p.pos&&o.push(new du(`.bones[`+p.bone.name+`].position`,p.pos.times,p.pos.values)),o.push(new lu(`.bones[`+p.bone.name+`].quaternion`,p.quat.times,p.quat.values)));return s.uncacheAction(n),new fu(n.name,-1,o)}function vk(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=e.clone();return Sk(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function yk(e,t){for(let n=0,r=bk(t);n<r.length;n++)if(e===r[n].name)return r[n]}function bk(e){return Array.isArray(e)?e:e.bones}function xk(e){let t=new Ef(e.bones[0]);return t.skeleton=e,t}function Sk(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)Sk(e.children[r],t.children[r],n)}var Ck=t((()=>{J()})),wk=/* @__PURE__ */ n({GLTFLoader:()=>Rk});function Tk(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function Ek(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}function Dk(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Hl({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Ok(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function kk(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function Ak(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function jk(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function Mk(e){let t,n=e.extensions&&e.extensions[zk.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Nk(n.attributes):e.indices+`:`+Nk(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Nk(e.targets[n]);return t}function Nk(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function Pk(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function Fk(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}function Ik(e,t,n){let r=t.attributes,i=new Wa;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new B(t[0],t[1],t[2]),new B(a[0],a[1],a[2])),e.normalized){let t=Pk(gA[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new B,t=new B;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=Pk(gA[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new xo;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function Lk(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=bA[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return ji.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ji.workingColorSpace}" not supported.`),kk(e,t),Ik(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:Ak(e,t.targets,n)})}var Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k,eA,tA,nA,rA,iA,aA,oA,sA,cA,lA,uA,dA,fA,pA,mA,hA,gA,_A,vA,yA,bA,xA,SA,CA,wA,TA,EA=t((()=>{J(),Wv(),Ck(),Rk=class extends gu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Uk(e)}),this.register(function(e){return new Wk(e)}),this.register(function(e){return new Gk(e)}),this.register(function(e){return new eA(e)}),this.register(function(e){return new tA(e)}),this.register(function(e){return new nA(e)}),this.register(function(e){return new qk(e)}),this.register(function(e){return new Jk(e)}),this.register(function(e){return new Yk(e)}),this.register(function(e){return new Xk(e)}),this.register(function(e){return new Hk(e)}),this.register(function(e){return new Zk(e)}),this.register(function(e){return new Kk(e)}),this.register(function(e){return new $k(e)}),this.register(function(e){return new Qk(e)}),this.register(function(e){return new Bk(e)}),this.register(function(e){return new rA(e,zk.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new rA(e,zk.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new iA(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=ed.extractUrlBase(e);a=ed.resolveURL(t,this.path)}else a=ed.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new yu(this.manager);s.setPriority(this.priority),s.setCache(this.cache),s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===aA){try{a[zk.KHR_BINARY_GLTF]=new cA(e)}catch(e){r&&r(e);return}i=JSON.parse(a[zk.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(/* @__PURE__ */ Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new TA(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case zk.KHR_MATERIALS_UNLIT:a[t]=new Vk;break;case zk.KHR_DRACO_MESH_COMPRESSION:a[t]=new lA(i,this.dracoLoader);break;case zk.KHR_TEXTURE_TRANSFORM:a[t]=new uA;break;case zk.KHR_MESH_QUANTIZATION:a[t]=new dA;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}},zk={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DIFFUSE_ROUGHNESS:`KHR_materials_diffuse_roughness`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},Bk=class{constructor(e){this.parser=e,this.name=zk.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new H(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Vr);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new qu(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Wu(s),o.distance=c;break;case`spot`:o=new Hu(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),kk(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},Vk=class{constructor(){this.name=zk.KHR_MATERIALS_UNLIT}getMaterialType(){return ss}extendParams(e,t,n){let r=[];e.color=new H(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Vr),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Br))}return Promise.all(r)}},Hk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},Uk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new z(e,e)}return Promise.all(r)}},Wk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.diffuseRoughness=n.diffuseRoughnessFactor===void 0?0:n.diffuseRoughnessFactor,n.diffuseRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`diffuseRoughnessMap`,n.diffuseRoughnessTexture)),Promise.all(r)}},Gk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},Kk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},qk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new H(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Vr)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Br)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},Jk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},Yk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new H().setRGB(i[0],i[1],i[2],Vr),Promise.all(r)}},Xk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_IOR}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},Zk=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new H().setRGB(i[0],i[1],i[2],Vr),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Br)),Promise.all(r)}},Qk=class{constructor(e){this.parser=e,this.name=zk.EXT_MATERIALS_BUMP}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},$k=class{constructor(e){this.parser=e,this.name=zk.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ek(this.parser,e,this.name)===null?null:Ul}extendMaterialParams(e,t){let n=Ek(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},eA=class{constructor(e){this.parser=e,this.name=zk.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},tA=class{constructor(e){this.parser=e,this.name=zk.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},nA=class{constructor(e){this.parser=e,this.name=zk.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},rA=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},iA=class{constructor(e){this.name=zk.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==hA.TRIANGLES&&e.mode!==hA.TRIANGLE_STRIP&&e.mode!==hA.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new V,n=new B,a=new wi,s=new B(1,1,1),c=new Hs(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));let l=null;for(let e in o)if(e===`_COLOR_0`){let t=o[e];c.instanceColor=new Ps(t.array,t.itemSize,t.normalized)}else if(e!==`TRANSLATION`&&e!==`ROTATION`&&e!==`SCALE`){if(l===null){let e=c.geometry;l=new G,l.name=e.name;for(let t in e.attributes)l.setAttribute(t,e.attributes[t]);for(let t in e.morphAttributes)l.morphAttributes[t]=e.morphAttributes[t];e.index!==null&&l.setIndex(e.index),l.morphTargetsRelative=e.morphTargetsRelative;for(let t of e.groups)l.addGroup(t.start,t.count,t.materialIndex);e.boundingBox!==null&&(l.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(l.boundingSphere=e.boundingSphere.clone()),l.drawRange.start=e.drawRange.start,l.drawRange.count=e.drawRange.count,l.userData=Object.assign({},e.userData),c.geometry=l}let t=o[e];l.setAttribute(e,new Ps(t.array,t.itemSize,t.normalized))}ya.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},aA=`glTF`,oA=12,sA={JSON:1313821514,BIN:5130562},cA=class{constructor(e){this.name=zk.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,oA),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==aA)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-oA,i=new DataView(e,oA),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===sA.JSON){let r=new Uint8Array(e,oA+a,t);this.content=n.decode(r)}else if(r===sA.BIN){let n=oA+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},lA=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=zk.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=bA[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=bA[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=gA[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Vr,n)})})}},uA=class{constructor(){this.name=zk.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let t=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},dA=class{constructor(){this.name=zk.KHR_MESH_QUANTIZATION}},fA=class extends $l{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},pA=new wi,mA=class extends fA{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return pA.fromArray(i).normalize().toArray(i),i}},hA={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},gA={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},_A={9728:cn,9729:pn,9984:ln,9985:mn,9986:dn,9987:gn},vA={33071:on,33648:sn,10497:an},yA={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bA={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},xA={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},SA={CUBICSPLINE:void 0,LINEAR:Or,STEP:Dr},CA={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`},wA=new V,TA=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Tk,this.associations=/* @__PURE__ */ new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&a<98?(this.textureLoader=new Eu(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new ld(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yu(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType(`arraybuffer`),(this.options.withCredentials||this.options.crossOrigin===`use-credentials`)&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Ok(i,a,r),kk(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[zk.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(ed.resolveURL(t.uri,r.path),e,void 0,function(){i(/* @__PURE__ */ Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=yA[r.type],t=gA[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new co(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=yA[r.type],o=gA[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new ko(f,u/s),t.cache.add(n,c)),p=new jo(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new co(f,a,d);if(r.sparse!==void 0){let t=yA.SCALAR,n=gA[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new co(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=_A[n.magFilter]||1006,t.minFilter=_A[n.minFilter]||1008,t.wrapS=vA[n.wrapS]||1e3,t.wrapT=vA[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1,l;if(t.isKTX2Loader===!0&&a.bufferView!==void 0)l=n.getDependency(`bufferView`,a.bufferView).then(function(e){return new Promise(function(n,r){t.parse(e,n,r)})});else{if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new zi(e);t.needsUpdate=!0,n(t)}),t.load(ed.resolveURL(e,i.path),a,void 0,r)})})}let u=l.then(function(e){return c===!0&&o.revokeObjectURL(s),kk(e,a),e.userData.mimeType=a.mimeType||Fk(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[zk.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[zk.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[zk.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new Cc,Lo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new uc,Lo.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Hl}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[zk.KHR_MATERIALS_UNLIT]){let e=r[zk.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new H(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Vr),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Br)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||CA.OPAQUE;if(l===CA.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===CA.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==ss&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new z(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==ss&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==ss){let e=i.emissiveFactor;o.emissive=new H().setRGB(e[0],e[1],e[2],Vr)}return i.emissiveTexture!==void 0&&a!==ss&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Br)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),kk(n,i),t.associations.set(n,{materials:e}),i.extensions&&Ok(r,n,i),n})}createUniqueName(e){let t=qd.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[zk.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return Lk(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=Mk(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[zk.KHR_DRACO_MESH_COMPRESSION]?i(o):Lk(new G,o,t),o.mode===hA.TRIANGLE_STRIP?e=e.then(e=>zv(e,1)):o.mode===hA.TRIANGLE_FAN&&(e=e.then(e=>zv(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?Dk(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(async function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===hA.TRIANGLES||u.mode===hA.TRIANGLE_STRIP||u.mode===hA.TRIANGLE_FAN||u.mode===void 0){let e=i.isSkinnedMesh===!0,t=l.hasAttribute(`skinIndex`)&&l.hasAttribute(`skinWeight`);e&&t===!1&&console.warn(`THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.`),d=e&&t?new Os(l,f):new K(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights()}else if(u.mode===hA.LINES)d=new xc(l,f);else if(u.mode===hA.LINE_STRIP)d=new vc(l,f);else if(u.mode===hA.LINE_LOOP)d=new Sc(l,f);else if(u.mode===hA.POINTS)d=new Oc(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&jk(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),kk(d,i),u.extensions&&Ok(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&Ok(r,c[0],i),c[0];let l=new ba;i.extensions&&Ok(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r)console.warn(`THREE.GLTFLoader: Missing camera parameters.`);else return n.type===`perspective`?t=new Bu(Ci.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Gu(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),kk(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new V;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new Ns(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new fu(i,void 0,l);return kk(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,wA)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new B().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new ks:t.length>1?new ba:t.length===1?t[0]:new ya,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),kk(o,i),i.extensions&&Ok(n,o,i),i.matrix!==void 0){let e=new V;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new ba;n.name&&(i.name=r.createUniqueName(n.name)),kk(i,n),n.extensions&&Ok(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(vk(n))}return r.associations=(e=>{let t=/* @__PURE__ */ new Map;for(let[e,n]of r.associations)(e instanceof Lo||e instanceof zi)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}xA[i.path]===xA.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(xA[i.path]){case xA.weights:l=su;break;case xA.rotation:l=lu;break;case xA.translation:case xA.scale:l=du;break;default:switch(n.itemSize){case 1:l=su;break;default:l=du}}let u=r.interpolation===void 0?Or:SA[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+xA[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=Pk(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof lu?mA:fA)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}})),DA=/* @__PURE__ */ n({MeshoptDecoder:()=>OA}),OA,kA=t((()=>{OA=(function(){var e=`b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb`,t=`b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiii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qkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb`,n=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),r=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!=`object`)return{supported:!1};var i=WebAssembly.validate(n)?s(t):s(e),a,o=WebAssembly.instantiate(i,{}).then(function(e){a=e.instance,a.exports.__wasm_call_ctors()});function s(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;++n){var i=e.charCodeAt(n);t[n]=i>96?i-97:i>64?i-39:i+4}for(var a=0,n=0;n<e.length;++n)t[a++]=t[n]<60?r[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,a)}function c(e,t,n,r,i,a,o){var s=e.exports.sbrk,c=r+3&-4,l=s(c*i),u=s(a.length),d=new Uint8Array(e.exports.memory.buffer);d.set(a,u);var f=t(l,r,i,u,a.length);if(f==0&&o&&o(l,c,i),n.set(d.subarray(l,l+r*i)),s(l-s(0)),f!=0)throw Error(`Malformed buffer data: `+f)}var l={NONE:``,OCTAHEDRAL:`meshopt_decodeFilterOct`,QUATERNION:`meshopt_decodeFilterQuat`,EXPONENTIAL:`meshopt_decodeFilterExp`,COLOR:`meshopt_decodeFilterColor`},u={ATTRIBUTES:`meshopt_decodeVertexBuffer`,TRIANGLES:`meshopt_decodeIndexBuffer`,INDICES:`meshopt_decodeIndexSequence`},d=[],f=0;function p(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}function m(e){for(var t=`self.ready = WebAssembly.instantiate(new Uint8Array([`+new Uint8Array(i)+`]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = `+g.name+`;`+c.toString()+g.toString(),n=new Blob([t],{type:`text/javascript`}),r=URL.createObjectURL(n),a=d.length;a<e;++a)d[a]=p(r);for(var a=e;a<d.length;++a)d[a].object.postMessage({});d.length=e,URL.revokeObjectURL(r)}function h(e,t,n,r,i){for(var a=d[0],o=1;o<d.length;++o)d[o].pending<a.pending&&(a=d[o]);return new Promise(function(o,s){var c=new Uint8Array(n),l=++f;a.pending+=e,a.requests[l]={resolve:o,reject:s},a.object.postMessage({id:l,count:e,size:t,source:c,mode:r,filter:i},[c.buffer])})}function g(e){var t=e.data;self.ready.then(function(e){if(!t.id)return self.close();try{var n=new Uint8Array(t.count*t.size);c(e,e.exports[t.mode],n,t.count,t.size,t.source,e.exports[t.filter]),self.postMessage({id:t.id,count:t.count,action:`resolve`,value:n},[n.buffer])}catch(e){self.postMessage({id:t.id,count:t.count,action:`reject`,value:e})}})}return{ready:o,supported:!0,useWorkers:function(e){m(e)},decodeVertexBuffer:function(e,t,n,r,i){c(a,a.exports.meshopt_decodeVertexBuffer,e,t,n,r,a.exports[l[i]])},decodeIndexBuffer:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexBuffer,e,t,n,r)},decodeIndexSequence:function(e,t,n,r){c(a,a.exports.meshopt_decodeIndexSequence,e,t,n,r)},decodeGltfBuffer:function(e,t,n,r,i,o){c(a,a.exports[u[i]],e,t,n,r,a.exports[l[o]])},decodeGltfBufferAsync:function(e,t,n,r,i){return d.length>0?h(e,t,n,u[r],l[i]):o.then(function(){var o=new Uint8Array(e*t);return c(a,a.exports[u[r]],o,e,t,n,a.exports[l[i]]),o})}}})()})),AA=/* @__PURE__ */ n({applyMorph:()=>NA,buildModel:()=>PA,gltfExtensionsUsed:()=>jA});function jA(e){let t=new Uint8Array(e),n;if(t.byteLength>=20&&new DataView(e).getUint32(0,!0)===1179937895){let r=new DataView(e).getUint32(12,!0);n=new TextDecoder().decode(t.subarray(20,20+r))}else n=new TextDecoder().decode(t);try{let e=JSON.parse(n);return Array.isArray(e.extensionsUsed)?e.extensionsUsed.filter(e=>typeof e==`string`):[]}catch{return[]}}async function MA(e){let t=FA.get(e);return t||(t=(async()=>{let[{GLTFLoader:t},n]=await Promise.all([Promise.resolve().then(()=>(EA(),wk)),fetch(e)]);if(!n.ok)throw Error(`HTTP ${n.status} for ${e}`);let r=await n.arrayBuffer(),i=jA(r);if(i.includes(`KHR_draco_mesh_compression`))throw Error(`${e} uses Draco compression (KHR_draco_mesh_compression), which the Agent3D runtime does not decode. Re-export it without Draco (Blender: uncheck "Compression"), or convert it to meshopt with gltfpack (\`gltfpack -i in.glb -o out.glb -cc\`), then run \`agent3d assets optimize\`.`);let a=new t;if(i.includes(`EXT_meshopt_compression`)){let{MeshoptDecoder:e}=await Promise.resolve().then(()=>(kA(),DA));await e.ready,a.setMeshoptDecoder(e)}let o=e.slice(0,e.lastIndexOf(`/`)+1);return a.parseAsync(r,/^data:/.test(e)?``:o)})(),t.catch(()=>FA.delete(e)),FA.set(e,t)),t}function NA(e,t){e.traverse(e=>{let n=e;if(n.isMesh&&n.morphTargetDictionary&&n.morphTargetInfluences)for(let[e,r]of Object.entries(t)){let t=n.morphTargetDictionary[e];t!==void 0&&typeof r==`number`&&(n.morphTargetInfluences[t]=r)}})}async function PA(e,t){let n=await MA(t.resolveAsset(e.src)),{clone:r}=await Promise.resolve().then(()=>(Ck(),mk)),i=r(n.scene),a=new ba;a.add(i),i.updateMatrixWorld(!0);let o=new Wa().setFromObject(i);if(!o.isEmpty()){let t=o.getSize(new B),n=Math.max(t.x,t.y,t.z),r=e.fit&&n>0?e.fit/n:1;if(i.scale.multiplyScalar(r),e.center!==!1){let e=o.getCenter(new B);i.position.set(-e.x*r,-o.min.y*r,-e.z*r)}}i.traverse(t=>{let n=t;n.isMesh&&(n.castShadow=e.castShadow??!0,n.receiveShadow=e.receiveShadow??!1)}),e.material&&await bw(i,e.material,t),e.morph&&NA(i,e.morph);let s;if(n.animations.length){let r=new Zd(i),a=null,o=e=>typeof e==`number`||/^\d+$/.test(String(e))?n.animations[Number(e)]:n.animations.find(t=>t.name===e)??n.animations.find(t=>t.name.toLowerCase().includes(String(e).toLowerCase())),c=/* @__PURE__ */ new Set,l=r=>{let i=o(r);return!i&&!c.has(String(r))&&(c.add(String(r)),t.issue(`asset-load`,`Model ${e.id} has no animation clip "${r}" (clips: ${n.animations.map(e=>e.name).join(`, `)})`,`objects#${e.id}.animation.clip`)),i},u=(e,t={})=>{let n=l(e);if(!n)return;let i=r.clipAction(n);i.setLoop(t.loop===!1?wr:Tr,1/0),i.clampWhenFinished=t.loop===!1,i.timeScale=Q(t.speed,1),i.enabled=!0,a&&a!==i?(i.reset().setEffectiveWeight(1).play(),a.crossFadeTo(i,Q(t.crossfade,.3),!1)):i.setEffectiveWeight(1).play(),a=i},d=e=>{let t=l(e);if(!t)return null;let n=r.clipAction(t);return n.isRunning()||(n.enabled=!0,n.setLoop(Tr,1/0),n.play()),n},f={weight(e,t){d(e)?.setEffectiveWeight(Math.max(0,t))},speed(e,t){let n=d(e);n&&(n.timeScale=t)},time(e,t){let n=d(e);n&&(n.paused=!0,n.time=Math.max(0,t))}},p=e.animation??{},m=()=>{r.stopAllAction(),a=null,u(p.clip??0,p),p.offset&&a&&(a.time=Math.max(0,p.offset));for(let[e,t]of Object.entries(p.blend??{}))f.weight(e,t);r.update(0)};s={mixer:r,clips:n.animations,play:u,control:f,reset:m},m()}return{object:a,animator:s}}var FA,IA=t((()=>{J(),zS(),jw(),FA=/* @__PURE__ */ new Map}));J(),Xg(),Tv(),zS(),jw();function LA(e){let t={position:e.position.clone(),quaternion:e.quaternion.clone(),scale:e.scale.clone(),visible:e.visible},n=e;return n.isLight&&(t.intensity=n.intensity,t.color=n.color.clone()),t}function RA(e,t){t.position&&e.position.set(t.position[0]??0,t.position[1]??0,t.position[2]??0),t.rotation&&e.rotation.set((t.rotation[0]??0)*LS,(t.rotation[1]??0)*LS,(t.rotation[2]??0)*LS),t.scale!==void 0&&(typeof t.scale==`number`?e.scale.setScalar(t.scale):e.scale.set(t.scale[0]??1,t.scale[1]??1,t.scale[2]??1))}var zA=/* @__PURE__ */ new Set([`hoverScale`,`hoverLift`,`clickBounce`,`spinOnClick`]),BA=class e{def;ctx;scene=new ka;camera;rig;env=null;entries=/* @__PURE__ */ new Map;timeline=null;settleEntrances=!1;updaters=[];cameraRest0={position:new B,target:new B,fov:45,zoom:10,focus:void 0};motionHost;overrides;shots=[];focusWritten=!1;postfxParam=null;viewportH=600;input={pointer:{x:0,y:0,inside:!1},scroll:0,hovered:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ new Set,timelineT:null};disposed=!1;constructor(e,t){this.def=e,this.ctx=t,t.onUpdate=e=>this.updaters.push(e)}static async create(t,n,r,i,a=!1){let o=new e(t,n);return await o.build(r,i,a),o}async build(e,t,n){let{def:r,ctx:i}=this;{this.camera=wT(r.camera,e),this.rig=await kT(r.camera,this.camera,t,i.deterministic),this.cameraRest0.position.copy(this.rig.rest.position),this.cameraRest0.target.copy(this.rig.rest.target),this.cameraRest0.fov=this.rig.rest.fov,this.cameraRest0.zoom=this.rig.rest.zoom;let n=r.postfx?.find(e=>e.type===`dof`);this.cameraRest0.focus=n&&typeof n.focus==`number`?n.focus:n?8:void 0,this.rig.rest.focus=this.cameraRest0.focus;let a=AD(r.environment??{background:`#ffffff`},this.scene,this.camera,!!r.target?.transparent,i),o=Promise.all((r.lights??[]).map((e,t)=>this.addLight(e,t))),s=/* @__PURE__ */ new Map,c=r.objects??[],l=e=>e.attach===`camera`?this.camera:this.scene;c.some(e=>e.attach===`camera`)&&this.scene.add(this.camera),await Promise.all(c.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(e=>this.addObject(e,l(e),void 0,s))),VA(s,c),await Promise.all(c.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(e=>this.addObject(e,l(e),void 0,s)));let u=new Map(c.map((e,t)=>[e.id,t]));this.scene.children.sort((e,t)=>(u.get(e.userData.a3dId)??-1)-(u.get(t.userData.a3dId)??-1)),this.env=await a;for(let e of this.env.objects)this.scene.add(e);if(await o,this.canonicalOrder(r),this.motionHost={object:e=>this.entries.get(e)?.object??null,select:e=>this.select(e),camera:this.rig.rest,scene:this.scene,renderer:i.renderer,postfx:{set:(e,t,n)=>this.postfxParam?.(e,t,n),base:(e,t)=>{let n=Ox(r.postfx).find(t=>t.type===e)?.[t];return typeof n==`number`||typeof n==`string`?n:void 0}},clips:e=>this.entries.get(e)?.animator?.control,issue:i.issue,seed:r.seed??1},this.overrides=new Gw(this.motionHost),this.shots=Zw(r.camera?.shots),r.timeline){this.timeline=Uw(r.timeline,this.motionHost);for(let e of this.timeline.targets){let t=this.entries.get(e);t&&(t.animated=!0)}}for(let e of r.interactions??[]){if(e.target&&(e.on===`click`||e.on===`hover`||e.on===`hoverEnd`)){let t=this.entries.get(e.target);t&&(t.interactive=!0)}for(let t of e.do??[]){let e=t.set?.path;if(typeof e==`string`)for(let t of this.overrides.idsOf(e)){let e=this.entries.get(t);e&&(e.animated=!0)}}}this.fitShadows()}}canonicalOrder(e){let t=this.entries,n=/* @__PURE__ */ new Map,r=e=>{let r=t.get(e);r&&!n.has(e)&&n.set(e,r)};(e.lights??[]).forEach((e,t)=>r(e.id??`light${t}`));let i=e=>{for(let n of e){r(n.id);let e=`${n.id}/`;for(let i of t.keys())i.startsWith(e)&&t.get(i).parentId===n.id&&r(i);if(!n.children?.length)continue;let a=t.get(n.id)?.object;if(a){let e=new Map(n.children.map((e,t)=>[e.id,t]));a.children.sort((t,n)=>(e.get(t.userData.a3dId)??-1)-(e.get(n.userData.a3dId)??-1))}i(n.children)}};i(e.objects??[]);for(let[e,r]of t)n.has(e)||n.set(e,r);this.entries=n}async overrideGeneratorMaterial(e,t,n){let r=lw(t),i=await yw(t,n,{vertexColors:r.type!==`shader`&&r.type!==`normal`&&r.type!==`gradient`&&!r.color&&!r.map}),a=[];e.traverse(e=>{e.isMesh&&e.userData.materialTarget&&a.push(e)});for(let e of a)e.material.dispose(),e.material=i,pw(i,e.geometry)}rngFor(e,t){return dv(t??fv(this.def.seed??1,e))}behaviourContext(e){let t=this;return{object:e.object,base:{position:e.rest.position,rotation:new na().setFromQuaternion(e.rest.quaternion),scale:e.rest.scale},get pointer(){return t.input.pointer},hovered:()=>t.input.hovered.has(e.id),clicked:()=>t.input.clicked.has(e.id),scroll:()=>t.input.scroll,get camera(){return t.camera},rng:this.rngFor(e.id+`:behaviours`),find:e=>e===`camera`?t.camera:t.entries.get(e)?.object??null}}attachBehaviours(e){let t=e.def.behaviours??[];e.runners=[];for(let n of t){let t=FC[n.type];t?(e.runners.push(HC(n,t,this.behaviourContext(e),{settled:()=>this.settleEntrances})),(zA.has(n.type)||n.when===`hover`||n.when===`click`)&&(e.interactive=!0)):this.ctx.issue(`unknown-catalog-id`,`Unknown behaviour "${n.type}"`,`objects#${e.id}.behaviours`)}e.runners.length&&(e.animated=!0)}resetBehaviours(){for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.def.behaviours?.length&&this.attachBehaviours(e),e.animator?.reset?e.animator.reset():e.animator?.mixer.setTime(0)}this.overrides?.reset()}async addLight(e,t){let n=await oE(e,this.def.environment?.shadows),r=e.id??`light${t}`;this.scene.add(n),(n instanceof qu||n instanceof Hu)&&this.scene.add(n.target),n.userData.a3dId=r;let i={id:r,kind:`light`,def:e,object:n,rest:LA(n),runners:[],animated:!1,topLevel:!1,interactive:!1};this.entries.set(r,i),this.attachBehaviours(i)}async addObject(e,t,n,r){let i=this.ctx,a,o,s,c,l=[],u=e.kind!==`particles`&&e.kind!==`generator`&&e.kind!==`photo`;try{switch(e.kind){case`mesh`:{let t=FD(e.geometry),n=await yw(e.material,i,{defaultColor:`#dddddd`});pw(n,t),a=new K(t,n);break}case`text`:{let{buildText:t}=await Promise.resolve().then(()=>(SO(),YD)),n=await i.track(t(e,i));a=n.object,l=n.letters;break}case`svg`:{let{buildSvg:t}=await Promise.resolve().then(()=>(BO(),jO));a=await i.track(t(e,i));break}case`photo`:{let{buildPhoto:t}=await Promise.resolve().then(()=>(pk(),VO)),n=await i.track(t(e,i));a=n.object,o={object:n.object,dispose:()=>n.dispose()},this.updaters.push((e,t)=>n.update(e,t,{pointer:this.input.pointer,scroll:this.input.scroll,camera:this.camera??null,reduced:this.settleEntrances}));break}case`model`:{let{buildModel:t}=await Promise.resolve().then(()=>(IA(),AA)),n=await i.track(t(e,i));a=n.object,s=n.animator;break}case`instances`:{let t=FD(e.geometry),n=await yw(e.material,i,{defaultColor:e.colors?.length?`#ffffff`:`#dddddd`});pw(n,t),a=LD(e,t,n,this.rngFor(e.id,e.layout.seed),e=>AS(e));break}case`particles`:{c=YC(e,this.rngFor(e.id,e.seed)),c.setViewport(this.viewportH),a=c.points;let t=c;this.updaters.push(e=>t.update(e));break}case`generator`:{let t=(await i.generators())[e.generator];if(!t){i.issue(`unknown-catalog-id`,`Unknown generator "${e.generator}"`,`objects#${e.id}.generator`),a=new ba;break}let n=Lg.find(t=>t.id===e.generator),s=jS(n,e.params??{}),c=e.scale,l={position:[...e.position??[0,0,0]],scale:typeof c==`number`?[c,c,c]:c?[...c]:[1,1,1]},u={...i,siblings:r,rng:this.rngFor(e.id,e.seed),placement:l};if(o=await i.track(Promise.resolve(t(s,u))),a=o.object,o.update){let e=o.update.bind(o);this.updaters.push((t,n)=>e(t,n))}r.set(e.id,o),e.material&&n?.material&&await this.overrideGeneratorMaterial(a,e.material,i);break}default:a=new ba}}catch(t){i.issue(e.kind===`model`||e.kind===`text`||e.kind===`svg`||e.kind===`photo`?`asset-load`:`build-error`,`${e.id}: ${t.message}`,`objects#${e.id}`),a=new ba}if(this.disposed)return null;a.name=e.name??e.id,a.userData={...e.userData??{},...a.userData,a3dId:e.id,tags:e.tags??[]},RA(a,e),e.visible===!1&&(a.visible=!1);let d=e.castShadow??(u?!0:void 0),f=e.receiveShadow??(u?!0:void 0);(d!==void 0||f!==void 0)&&a.traverse(e=>{e.isMesh&&(d!==void 0&&(e.castShadow=d),f!==void 0&&(e.receiveShadow=f))}),t.add(a);let p={id:e.id,kind:e.kind,def:e,object:a,rest:LA(a),runners:[],animated:!1,topLevel:t===this.scene||t===this.camera&&!n,parentId:n,built:o,animator:s,particles:c,interactive:!!e.href};this.entries.set(e.id,p),this.attachBehaviours(p);for(let t of l){let n={id:t.id,kind:`text`,def:t.def,object:t.object,rest:LA(t.object),runners:[],animated:!0,topLevel:!1,parentId:e.id,interactive:!1};t.reveal&&n.runners.push(HC(t.reveal.def,t.reveal.impl,this.behaviourContext(n),{settled:()=>this.settleEntrances})),this.entries.set(t.id,n)}if(e.children?.length){let t=/* @__PURE__ */ new Map,n=e.children;await Promise.all(n.filter(e=>e.kind===`generator`&&e.generator===`terrain`).map(n=>this.addObject(n,a,e.id,t))),VA(t,n),await Promise.all(n.filter(e=>e.kind!==`generator`||e.generator!==`terrain`).map(n=>this.addObject(n,a,e.id,t)))}return p}removeEntry(e){let t=this.entries.get(e);if(t){t.object.traverse(t=>{let n=t.userData.a3dId;n&&n!==e&&this.entries.delete(n)}),t.object.removeFromParent();for(let e of t.runners)e.dispose();this.entries.delete(e)}}idsFor(e){let t=[];for(let n=e;n;n=n.parent){let e=n.userData?.a3dId;e&&this.entries.has(e)&&t.push(e)}return t}select(e){if(e.startsWith(`tag:`)){let t=e.slice(4),n=[],r=e=>{for(let i of e??[])i.tags?.includes(t)&&this.entries.has(i.id)&&n.push(i.id),r(i.children)};return r(this.def.objects),n}if(e.startsWith(`children:`)){let t=e.slice(9);return[...this.entries.values()].filter(e=>e.parentId===t).map(e=>e.id)}return Vw(e,{object:()=>null,camera:null,issue:()=>void 0}).filter(e=>e!==``)}objectPosition(e){let t=this.entries.get(e);return t?t.object.getWorldPosition(new B):null}interactiveRoots(){let e=[];for(let t of this.entries.values())t.interactive&&t.kind!==`light`&&e.push(t.object);return e}fitShadows(){let e=[];if(this.scene.traverse(t=>{t instanceof qu&&t.castShadow&&e.push(t)}),!e.length)return;let t=new Wa,n=new Wa;this.scene.updateMatrixWorld(!0);for(let e of this.entries.values())e.topLevel&&e.kind!==`particles`&&e.def.attach!==`camera`&&(n.setFromObject(e.object),n.isEmpty()||n.getSize(new B).length()>200||t.union(n));t.isEmpty()&&t.set(new B(-5,-1,-5),new B(5,5,5));let r=this.env?.ground?this.env.ground.position.y:t.min.y;t.expandByPoint(new B(t.min.x,r,t.min.z)),t.expandByPoint(new B(t.max.x,r,t.max.z)),t.expandByScalar(.3);for(let n of e)sE(n,t)}setViewport(e,t,n){this.viewportH=t*n;let r=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(this.def.target?.aspect??``),i=r?Number(r[1])/Number(r[2]):void 0;DT(this.camera,this.def.camera,e/Math.max(t,1),i&&Number.isFinite(i)&&i>0?i:void 0);for(let e of this.entries.values())e.particles?.setViewport(this.viewportH)}frame(e,t,n,r){this.input=n;for(let e of this.entries.values()){if(!e.animated)continue;let t=e.object;t.position.copy(e.rest.position),t.quaternion.copy(e.rest.quaternion),t.scale.copy(e.rest.scale),t.visible=e.rest.visible;let n=t;n.isLight&&e.rest.intensity!==void 0&&(n.intensity=e.rest.intensity,e.rest.color&&!this.timeline?.targets.has(e.id)&&n.color.copy(e.rest.color))}let i=this.def.timeline?n.timelineT??0:e;if(this.shots.length||this.timeline?.animatesCamera){let e=this.rig.rest;if(e.position.copy(this.cameraRest0.position),e.target.copy(this.cameraRest0.target),e.fov=this.cameraRest0.fov,e.zoom=this.cameraRest0.zoom,e.focus=this.cameraRest0.focus,this.shots.length){let t=Qw(this.shots,i,e,{objectPosition:e=>this.objectPosition(e)});e.position.copy(t.position),e.target.copy(t.target),e.fov=t.fov,e.focus=t.focus}}this.timeline&&n.timelineT!==null&&this.timeline.apply(n.timelineT),this.overrides?.apply(e),this.rig.rest.focus!==void 0&&(this.focusWritten||this.rig.rest.focus!==this.cameraRest0.focus)&&(this.postfxParam?.(`dof`,`focus`,this.rig.rest.focus),this.focusWritten=!0);for(let n of this.entries.values())for(let r of n.runners)r.late||r.step(e,t);for(let e of this.entries.values()){let t=e.object.userData.setPointer?e.object:e.object.children[0],r=t?.userData.setPointer;if(!r)continue;r(n.pointer.x,n.pointer.y);let i=t.userData.setPointerLocal;if(i&&this.camera){let e=this.pointerOnPlane(t,n.pointer.x,n.pointer.y);e&&i(e.x,e.z)}}for(let n of this.updaters)n(e,t);for(let e of this.entries.values())e.animator?.mixer.update(t);let a=this.def.camera?.lookAt;this.rig.update(e,t,{pointer:n.pointer,scroll:n.scroll,followTarget:r,lookAt:a?this.objectPosition(a):null}),this.camera.updateMatrixWorld();for(let n of this.entries.values())for(let r of n.runners)r.late&&r.step(e,t)}hasStatefulMotion(){if(this.def.camera?.controls===`follow`&&this.def.camera.follow)return!0;for(let e of this.entries.values())for(let t of e.runners)if(t.stateful)return!0;return!1}pointerRay=new of;pointerOnPlane(e,t,n){e.updateWorldMatrix(!0,!1),this.camera.updateMatrixWorld(),this.pointerRay.setFromCamera(new z(t,n),this.camera);let r=e.matrixWorld.clone().invert(),i=this.pointerRay.ray.clone().applyMatrix4(r);if(Math.abs(i.direction.y)<1e-6)return null;let a=-i.origin.y/i.direction.y;return a<0?null:i.origin.addScaledVector(i.direction,a)}dispose(){this.disposed=!0;for(let e of this.entries.values()){for(let t of e.runners)t.dispose();e.built?.dispose?.()}this.rig?.dispose(),this.env?.dispose(),PS(this.scene);let e=this.scene.environment;e&&e.dispose();let t=this.scene.background;t&&t.isTexture&&t.dispose(),this.scene.traverse(e=>e.shadow?.dispose?.()),this.entries.clear()}};function VA(e,t){let n=[...e.entries()],r=new Map(t.map((e,t)=>[e.id,t]));n.sort((e,t)=>(r.get(e[0])??1/0)-(r.get(t[0])??1/0)),e.clear();for(let[t,r]of n)e.set(t,r)}var HA=/* @__PURE__ */ new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Space`,`PageUp`,`PageDown`,`Home`,`End`]);function UA(){return{pointer:{x:0,y:0,inside:!1,down:!1,justPressed:!1},keys:/* @__PURE__ */ new Set,pressed:/* @__PURE__ */ new Set,swipe:null,clicks:[],scroll:0}}function WA(e){e.pressed.clear(),e.pointer.justPressed=!1,e.swipe=null,e.clicks.length=0}function GA(e,t,n){n?(e.keys.has(t)||e.pressed.add(t),e.keys.add(t)):e.keys.delete(t)}function KA(e,t,n){let r=e.ownerDocument.defaultView??window,i=!1,a=!1,o=null,s=t=>{let n=e.getBoundingClientRect();return{x:(t.clientX-n.left)/Math.max(n.width,1)*2-1,y:-((t.clientY-n.top)/Math.max(n.height,1)*2-1)}},c=e=>{let r=s(e);t.pointer.x=r.x,t.pointer.y=r.y,t.pointer.inside=!0,n.onPointerMove?.()},l=()=>{a=!0,t.pointer.inside=!0},u=()=>{a=!1,t.pointer.inside=!1,t.pointer.down=!1},d=e=>{i=!0;let n=s(e);t.pointer.x=n.x,t.pointer.y=n.y,t.pointer.down=!0,t.pointer.justPressed=!0,o={x:n.x,y:n.y,t:performance.now(),px:e.clientX,py:e.clientY}},f=e=>{if(t.pointer.down=!1,!o)return;let n=e.clientX-o.px,r=e.clientY-o.py,i=Math.hypot(n,r);i<8?t.clicks.push(s(e)):i>30&&performance.now()-o.t<600&&(t.swipe=Math.abs(n)>Math.abs(r)?n>0?`right`:`left`:r>0?`down`:`up`),o=null},p=()=>i||a||e.contains(e.ownerDocument.activeElement),m=e=>{if(!p())return;let r=e.target;(!r||r.tagName!==`INPUT`&&r.tagName!==`TEXTAREA`&&!r.isContentEditable)&&(GA(t,e.code,e.type===`keydown`),n.game&&HA.has(e.code)&&e.preventDefault())},h=()=>t.keys.clear(),g=t=>{e.contains(t.target)||(i=!1)};return e.addEventListener(`pointermove`,c),e.addEventListener(`pointerenter`,l),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointerdown`,d),r.addEventListener(`pointerup`,f),r.addEventListener(`keydown`,m,{passive:!1}),r.addEventListener(`keyup`,m),r.addEventListener(`blur`,h),r.document.addEventListener(`pointerdown`,g,!0),n.game&&(e.style.touchAction=`none`,e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`)),{dispose(){e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerenter`,l),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointerdown`,d),r.removeEventListener(`pointerup`,f),r.removeEventListener(`keydown`,m),r.removeEventListener(`keyup`,m),r.removeEventListener(`blur`,h),r.document.removeEventListener(`pointerdown`,g,!0)}}}function qA(e){let t=e.ownerDocument.defaultView;if(!t)return 0;let n=e.getBoundingClientRect(),r=t.innerHeight||1,i=(r-n.top)/(r+n.height);return i<0?0:i>1?1:i}var JA=(e,t,n)=>e<t?t:e>n?n:e;function YA(e,t,n){return typeof e==`number`&&Number.isFinite(e)?e:typeof e==`string`&&t&&typeof t[e]==`number`?t[e]:n}function XA(e,t){let n=Math.max(e.duration||0,.001);if(t===`timeline`)return{from:0,to:n,loop:e.loop,speed:1};let r=e.segments?.[t];if(!r)return null;let i=Array.isArray(r)?{from:r[0],to:r[1]}:r;return{from:JA(YA(i.from,e.markers,0),0,n),to:JA(YA(i.to,e.markers,n),0,n),loop:i.loop??!1,speed:typeof i.speed==`number`&&i.speed>0?i.speed:1}}function ZA(e,t,n){let r=Math.abs(e.to-e.from),i=e.to>=e.from?1:-1,a=n===void 0?0:Math.abs(n-e.from),o=r<=0?0:YS(Math.max(0,t*e.speed+a),r,e.loop);return e.from+i*o}function QA(e,t,n){let r=Math.max(e.duration||0,.001),i=n&&n!==`seek`&&n!==`timeline`&&e.segments?.[n]?n:``;if(!i)for(let n of Object.keys(e.segments??{})){let a=XA(e,n);if(!a)continue;let o=Math.min(a.from,a.to),s=Math.max(a.from,a.to);if(t>=o&&(t<s||s>=r-1e-6&&t<=s)){i=n;break}}let a=``,o=-1/0;for(let[n,r]of Object.entries(e.markers??{}))typeof r==`number`&&r<=t+1e-6&&r>=o&&(o=r,a=n);return{time:t,duration:r,progress:JA(t/r,0,1),segment:i,marker:a}}var $A=class{def;hoverClock=0;clickAt=-1;active=null;toggled=/* @__PURE__ */ new Map;prevLocal=null;lastLocal=0;lastT=0;pending=[];constructor(e){this.def=e}get duration(){return Math.max(this.def.duration||0,.001)}reset(){this.hoverClock=0,this.clickAt=-1,this.active=null,this.toggled.clear(),this.prevLocal=null,this.lastLocal=0,this.lastT=0,this.pending=[]}get local(){return this.lastLocal}play(e,t,n={}){let r=XA(this.def,e);if(!r)return!1;let i=n.reverse?{...r,from:r.to,to:r.from}:r;return this.active={...i,name:e,start:t},this.toggled.set(e,!n.reverse),!0}toggle(e,t){let n=XA(this.def,e);if(!n)return!1;let r=!this.toggled.get(e),i=r?n:{...n,from:n.to,to:n.from},a=this.active?.name===e?this.lastLocal:void 0,o=a!==void 0&&a>=Math.min(n.from,n.to)&&a<=Math.max(n.from,n.to);return this.active={...i,loop:!1,name:e,start:t,startLocal:o?a:void 0},this.toggled.set(e,r),!0}seek(e,t){let n=JA(YA(e,this.def.markers,0),0,this.duration);this.active={name:`seek`,from:n,to:n,loop:!1,speed:1,start:t}}autoRange(){let e=typeof this.def.autoplay==`string`?this.def.autoplay:null,t=e?XA(this.def,e):null,n=typeof this.def.speed==`number`&&this.def.speed>0?this.def.speed:1;return t?{...t,speed:t.speed*n}:{from:0,to:this.duration,loop:this.def.loop,speed:n}}autoLocal(e){let t=this.autoRange(),n=this.def.trigger??`visible`;if(e.staticMotion)return typeof this.def.autoplay==`string`?t.to:ZA({...t,speed:1},e.posterTime??0);if(n===`manual`||this.def.autoplay===!1)return t.from;if(n===`scroll`)return t.from+(t.to-t.from)*JA(e.scroll,0,1);if(e.deterministic)return ZA(t,e.t);switch(n){case`hover`:{this.hoverClock+=e.hovered?e.dt:t.loop?0:-e.dt;let n=Math.abs(t.to-t.from)/t.speed;return t.loop||(this.hoverClock=JA(this.hoverClock,0,n)),ZA(t,this.hoverClock)}case`click`:return e.clicked&&(this.clickAt=e.t),this.clickAt<0?t.from:ZA(t,e.t-this.clickAt);default:return ZA(t,e.t)}}update(e){let t;return t=this.active&&!e.staticMotion?ZA(this.active,Math.max(0,e.t-this.active.start),this.active.startLocal):this.autoLocal(e),t=JA(t,0,this.duration),this.collectMarkers(this.prevLocal,t,e.t<this.lastT),this.prevLocal=t,this.lastLocal=t,this.lastT=e.t,t}collectMarkers(e,t,n){let r=this.def.markers;if(r&&!n)for(let[n,i]of Object.entries(r)){if(typeof i!=`number`)continue;let r;r=e===null?i<=t:t>e?i>e&&i<=t:t<e?this.isLoopingForward()?i>e||i<=t:i<e&&i>=t:!1,r&&this.pending.push({name:n,time:i})}}isLoopingForward(){let e=this.active??this.autoRange();return!!e.loop&&e.loop!==`pingpong`&&e.to>=e.from}info(){return QA(this.def,this.lastLocal,this.active?.name)}drainMarkers(){let e=this.pending;return this.pending=[],e}};function ej(e,t){if(typeof e!=`string`||!e.trim())return null;try{let n=new URL(e.trim(),t);return n.protocol===`http:`||n.protocol===`https:`?n.href:null}catch{return null}}var tj=/* @__PURE__ */ new Set([`click`,`key`]),nj=class{defs;host;hoverPrev=/* @__PURE__ */ new Set;insidePrev=!1;scrollPrev=null;visibleFired=!1;fired=/* @__PURE__ */ new Set;queue=[];constructor(e,t){this.defs=e,this.host=t}targets(){let e=/* @__PURE__ */ new Set;for(let t of this.defs)t.target&&(t.on===`click`||t.on===`hover`||t.on===`hoverEnd`)&&e.add(t.target);return e}reset(){this.hoverPrev.clear(),this.insidePrev=!1,this.scrollPrev=null,this.visibleFired=!1,this.fired.clear(),this.queue=[]}event(e,t){this.queue.length<64&&this.queue.push({name:e,payload:t})}fire(e,t,n){let r=0;return this.defs.forEach((i,a)=>{if(i.on===e&&!(e===`key`?i.key!==t:e===`event`?i.event!==t:(i.target??void 0)!==t)&&!(i.once&&this.fired.has(a))){this.fired.add(a),r++;for(let t of i.do??[])this.run(t,n&&tj.has(e))}}),r}step(e){for(let t of this.targets()){let n=e.hovered.has(t),r=this.hoverPrev.has(t);n&&!r&&this.fire(`hover`,t,!1),!n&&r&&this.fire(`hoverEnd`,t,!1)}this.hoverPrev=new Set([...e.hovered].filter(e=>this.isTarget(e))),e.pointerInside!==this.insidePrev&&this.fire(e.pointerInside?`hover`:`hoverEnd`,void 0,!1),this.insidePrev=e.pointerInside;for(let t of e.clicked)this.fire(`click`,t,e.userGesture);e.canvasClicked&&this.fire(`click`,void 0,e.userGesture);for(let t of e.pressed)this.fire(`key`,t,e.userGesture);e.visible&&!this.visibleFired&&(this.visibleFired=!0,this.fire(`visible`,void 0,!1)),this.scrollPrev!==null&&e.scroll!==this.scrollPrev&&this.defs.forEach((t,n)=>{if(t.on===`scroll`&&typeof t.at==`number`&&!(!(this.scrollPrev<t.at&&e.scroll>=t.at)||t.once&&this.fired.has(n))){this.fired.add(n);for(let e of t.do??[])this.run(e,!1)}}),this.scrollPrev=e.scroll,this.flush()}flush(){for(let e=0;this.queue.length&&e<16;e++){let e=this.queue;this.queue=[];for(let t of e)this.fire(`event`,t.name,!1)}this.queue=[]}isTarget(e){return this.defs.some(t=>t.target===e)}run(e,t){let n=e;if(typeof n.play==`string`)this.host.play(n.play,n.reverse===!0);else if(typeof n.toggle==`string`)this.host.toggle(n.toggle);else if(typeof n.seek==`number`||typeof n.seek==`string`)this.host.seek(n.seek);else if(n.set&&typeof n.set==`object`){let e=n.set;typeof e.path==`string`&&e.value!==void 0&&this.host.set(e.path,e.value,typeof n.duration==`number`?n.duration:0,typeof n.ease==`string`?n.ease:void 0)}else typeof n.emit==`string`?this.host.emit(n.emit,n.payload):typeof n.openUrl==`string`?t?this.host.openUrl(n.openUrl,typeof n.newTab==`boolean`?n.newTab:void 0):this.host.emit(`openUrl`,{url:n.openUrl,blocked:!0}):n.playClip!==void 0&&typeof n.target==`string`&&this.host.playClip(n.target,n.playClip,{loop:n.loop,speed:n.speed,crossfade:n.crossfade})}},rj=`top bottom`,ij=`bottom top`;function aj(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:e.endsWith(`%`)?Number(e.slice(0,-1))/100*t:e.endsWith(`px`)?Number(e.slice(0,-2)):null}function oj(e,t,n){let r=e.trim().split(/\s+/);if(r.length!==2)return null;let i=aj(r[0],t),a=aj(r[1],n);return i===null||a===null?null:i-a}function sj(e,t,n,r=rj,i=ij){let a=oj(r,t,n)??-n,o=oj(i,t,n)??t,s=0-e;if(Math.abs(o-a)<1e-6)return+(s>=o);let c=(s-a)/(o-a);return c<0?0:c>1?1:c}J();var cj=8e3;function lj(e,t,n=cj){let r=[],i=0;if(e.traverseVisible(e=>{let t=e;if(!(t.isMesh||e.isLine)||e.isPoints)return;let n=t.geometry?.getAttribute(`position`);if(!n)return;let a=t.isInstancedMesh?t.count:1;a&&(r.push(t),i+=n.count*a)}),!r.length||!i)return null;let a=Math.max(1,Math.ceil(i/n)),o=new B,s=new V,c=new V,l=0,u=0;for(let e of r){let n=e.geometry.getAttribute(`position`),r=e,i=e.isSkinnedMesh?e:null,d=r.isInstancedMesh?r.count:1;for(let f=0;f<d;f++){r.isInstancedMesh?c.multiplyMatrices(e.matrixWorld,(r.getMatrixAt(f,s),s)):c.copy(e.matrixWorld);for(let e=f%a;e<n.count;e+=a)if(o.fromBufferAttribute(n,e),i&&i.applyBoneTransform(e,o),o.applyMatrix4(c),t.containsPoint(o)?l++:u++,l&&u)return`partial`}}return!l&&!u?null:u?`partial`:`full`}function uj(e,t,n){if(n!==`parts`){let r=e.worldToLocal(t.clone()),i=n.heightAt(r.x,r.z);return Number.isFinite(i)&&r.y<i}let r=new Wa,i=new V,a=!1;return e.traverseVisible(e=>{let n=e;if(a||!n.isMesh||!n.geometry)return;n.geometry.boundingBox||n.geometry.computeBoundingBox();let o=n.geometry.boundingBox,s=e;if(s.isInstancedMesh)for(let e=0;e<s.count&&!a;e++)s.getMatrixAt(e,i),r.copy(o).applyMatrix4(i.premultiply(s.matrixWorld)).containsPoint(t)&&(a=fj(n,t,r,e));else r.copy(o).applyMatrix4(n.matrixWorld).containsPoint(t)&&(a=fj(n,t,r))}),a}var dj=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)];function fj(e,t,n,r){let i=(Array.isArray(e.material)?e.material:[e.material]).filter(Boolean),a=i.map(e=>e.side);for(let e of i)e.side=2;try{let i=new of;return i.far=n.getSize(new B).length()+.001,dj.every(n=>(i.set(t,n),i.intersectObject(e,!1).some(e=>r===void 0||e.instanceId===r)))}finally{i.forEach((e,t)=>e.side=a[t])}}function pj(e,t,n){let r=e.createGain();return r.gain.value=Math.max(0,n),r.connect(t),{ctx:e,out:r,sources:[],timers:[],stopped:!1}}function mj(e,t=.06){if(e.stopped)return;e.stopped=!0;for(let t of e.timers)clearTimeout(t);let n=e.ctx.currentTime;try{e.out.gain.cancelScheduledValues(n),e.out.gain.setValueAtTime(e.out.gain.value,n),e.out.gain.linearRampToValueAtTime(0,n+t)}catch{}for(let r of e.sources)try{r.stop(n+t+.02)}catch{}setTimeout(()=>{try{e.out.disconnect()}catch{}},(t+.1)*1e3)}function hj(e,t){return e.timers.push(setTimeout(()=>mj(e,.01),(t+.2)*1e3)),{stop:()=>mj(e)}}function gj(e,t){let{ctx:n}=e,r=n.currentTime+(t.start??0),i=n.createOscillator();i.type=t.type??`square`,i.frequency.setValueAtTime(t.freq,r),t.to&&i.frequency.exponentialRampToValueAtTime(Math.max(1,t.to),r+t.dur),t.detune&&(i.detune.value=t.detune);let a=n.createGain(),o=t.gain??.3,s=t.attack??.005;a.gain.setValueAtTime(1e-4,r),a.gain.linearRampToValueAtTime(o,r+s);let c=Math.min(t.release??t.dur,t.dur);a.gain.setValueAtTime(o,r+Math.max(s,t.dur-c)),a.gain.exponentialRampToValueAtTime(1e-4,r+t.dur);let l=i;if(t.filter){let e=n.createBiquadFilter();e.type=t.filter.type,e.frequency.setValueAtTime(t.filter.freq,r),t.filter.to&&e.frequency.exponentialRampToValueAtTime(Math.max(10,t.filter.to),r+t.dur),e.Q.value=t.filter.q??1,i.connect(e),l=e}if(t.vibrato){let a=n.createOscillator();a.frequency.value=t.vibrato.rate;let o=n.createGain();o.gain.value=t.vibrato.depth,a.connect(o),o.connect(i.detune),a.start(r),a.stop(r+t.dur+.05),e.sources.push(a)}l.connect(a),a.connect(t.dest??e.out),i.start(r),i.stop(r+t.dur+.05),e.sources.push(i)}function _j(e){let t=bj.get(e);if(!t){t=e.createBuffer(1,Math.floor(e.sampleRate*2),e.sampleRate);let n=t.getChannelData(0),r=625341585;for(let e=0;e<n.length;e++)r^=r<<13,r^=r>>>17,r^=r<<5,n[e]=(r>>>0)/4294967296*2-1;bj.set(e,t)}return t}function vj(e,t){let{ctx:n}=e,r=n.currentTime+(t.start??0),i=n.createBufferSource();i.buffer=_j(n),i.loop=!0;let a=n.createGain(),o=t.gain??.3;a.gain.setValueAtTime(1e-4,r),a.gain.linearRampToValueAtTime(o,r+(t.attack??.003)),a.gain.exponentialRampToValueAtTime(1e-4,r+t.dur);let s=i;if(t.filter){let e=n.createBiquadFilter();e.type=t.filter.type,e.Q.value=t.filter.q??1,e.frequency.setValueAtTime(t.filter.freq,r),t.filter.mid&&e.frequency.exponentialRampToValueAtTime(t.filter.mid,r+t.dur*.45),t.filter.to&&e.frequency.exponentialRampToValueAtTime(t.filter.to,r+t.dur),i.connect(e),s=e}s.connect(a),a.connect(t.dest??e.out),i.start(r,r*.37%1.5),i.stop(r+t.dur+.05),e.sources.push(i)}function yj(e,t,n){let{ctx:r}=e,i=r.currentTime+.06,a=0,o=()=>{if(!e.stopped){for(;i<r.currentTime+.15;)n(a,i-r.currentTime),a++,i+=t;e.sources.length>400&&e.sources.splice(0,e.sources.length-200),e.timers.length=0,e.timers.push(setTimeout(o,40))}};o()}var bj,xj,Sj=t((()=>{bj=/* @__PURE__ */ new WeakMap,xj=e=>440*2**((e-69)/12)})),Cj=/* @__PURE__ */ n({SOUND_IMPLS:()=>Lj}),wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,Fj,Ij,Lj,Rj=t((()=>{Sj(),wj=(e,t)=>({play(n,r,i){let a=pj(n,r,i);return t(a),hj(a,e)}}),Tj=wj(.4,e=>{gj(e,{type:`square`,freq:xj(83),dur:.08,gain:.18,release:.02}),gj(e,{type:`square`,freq:xj(88),start:.075,dur:.32,gain:.18,release:.3}),gj(e,{type:`triangle`,freq:xj(100),start:.075,dur:.25,gain:.06,release:.24})}),Ej=wj(.3,e=>{gj(e,{type:`square`,freq:220,to:660,dur:.2,gain:.16,release:.12,filter:{type:`lowpass`,freq:2400}}),gj(e,{type:`triangle`,freq:330,to:990,dur:.18,gain:.12,release:.1})}),Dj=wj(.3,e=>{vj(e,{dur:.16,gain:.45,filter:{type:`lowpass`,freq:2200,to:300,q:.7}}),gj(e,{type:`sine`,freq:180,to:55,dur:.18,gain:.5,release:.15}),gj(e,{type:`square`,freq:120,to:60,dur:.08,gain:.12,release:.06})}),Oj=wj(1.6,e=>{vj(e,{dur:1.4,gain:.7,attack:.01,filter:{type:`lowpass`,freq:2600,to:90,q:.8}}),vj(e,{dur:.25,gain:.35,filter:{type:`highpass`,freq:1200,q:.5}}),gj(e,{type:`sine`,freq:90,to:28,dur:1.1,gain:.7,release:1}),gj(e,{type:`triangle`,freq:60,to:30,start:.05,dur:.8,gain:.3,release:.7})}),kj=wj(.1,e=>{gj(e,{type:`sine`,freq:1700,to:900,dur:.035,gain:.25,release:.03}),vj(e,{dur:.02,gain:.12,filter:{type:`highpass`,freq:4e3}})}),Aj=wj(.8,e=>{let t=[60,64,67,72,76,79,84];t.forEach((t,n)=>{gj(e,{type:`square`,freq:xj(t),start:n*.06,dur:.1,gain:.13,release:.06,filter:{type:`lowpass`,freq:3500}}),gj(e,{type:`triangle`,freq:xj(t+12),start:n*.06+.02,dur:.12,gain:.07,release:.1})}),gj(e,{type:`square`,freq:xj(84),start:t.length*.06,dur:.3,gain:.1,release:.28,vibrato:{rate:9,depth:35},filter:{type:`lowpass`,freq:3e3}})}),jj=wj(.35,e=>{gj(e,{type:`sawtooth`,freq:1800,to:160,dur:.24,gain:.16,release:.2,filter:{type:`bandpass`,freq:2400,to:400,q:2}}),gj(e,{type:`square`,freq:1200,to:120,dur:.18,gain:.07,release:.15})}),Mj=wj(1.6,e=>{let t=[72,76,79,84];t.forEach((t,n)=>{gj(e,{type:`square`,freq:xj(t),start:n*.12,dur:.14,gain:.12,release:.08,filter:{type:`lowpass`,freq:3200}}),gj(e,{type:`triangle`,freq:xj(t-12),start:n*.12,dur:.14,gain:.15,release:.1})});let n=t.length*.12+.04;for(let t of[79,84,88])gj(e,{type:`square`,freq:xj(t),start:n,dur:.9,gain:.08,attack:.01,release:.7,vibrato:{rate:6,depth:12},filter:{type:`lowpass`,freq:2800}});gj(e,{type:`triangle`,freq:xj(60),start:n,dur:.9,gain:.2,release:.6})}),Nj=wj(1.6,e=>{[67,66,65].forEach((t,n)=>gj(e,{type:`sawtooth`,freq:xj(t),start:n*.25,dur:.24,gain:.12,release:.1,filter:{type:`lowpass`,freq:1400}})),gj(e,{type:`sawtooth`,freq:xj(64),to:xj(52),start:.75,dur:.8,gain:.13,release:.5,vibrato:{rate:7,depth:40},filter:{type:`lowpass`,freq:1400,to:400}}),gj(e,{type:`triangle`,freq:xj(40),start:.75,dur:.8,gain:.18,release:.6})}),Pj=wj(.8,e=>{vj(e,{dur:.65,gain:.45,attack:.25,filter:{type:`bandpass`,freq:300,mid:2600,to:500,q:1.4}}),vj(e,{dur:.5,gain:.15,attack:.2,filter:{type:`lowpass`,freq:600,to:200}})}),Fj={play(e,t,n){let r=pj(e,t,n),i=e.createBiquadFilter();i.type=`lowpass`,i.frequency.value=900,i.Q.value=.6;let a=e.createOscillator();a.frequency.value=.07;let o=e.createGain();o.gain.value=450,a.connect(o),o.connect(i.frequency),a.start(),r.sources.push(a);let s=e.createDelay(1);s.delayTime.value=.42;let c=e.createGain();c.gain.value=.38,s.connect(c),c.connect(s),i.connect(r.out),i.connect(s),s.connect(r.out);let l=[[48,55,59,64],[45,52,55,60],[41,48,52,57],[43,50,55,59]];return yj(r,4,(e,t)=>{let n=l[e%l.length];for(let e of n)for(let n of[-7,7])gj(r,{type:`sawtooth`,freq:xj(e),start:t,dur:5.6,gain:.035,attack:1.4,release:1.8,detune:n,dest:i});gj(r,{type:`sine`,freq:xj(n[0]-12),start:t,dur:5.2,gain:.12,attack:1,release:1.5}),gj(r,{type:`triangle`,freq:xj(n[3]+24),start:t+1.3,dur:1.5,gain:.025,attack:.05,release:1.4,dest:s})}),{stop:()=>mj(r,.8)}}},Ij={play(e,t,n){let r=pj(e,t,n),i=[72,0,76,79,84,0,79,76,77,0,76,74,72,0,74,76,69,0,72,76,81,0,79,76,77,76,74,72,74,0,0,0,77,0,81,84,89,0,84,81,79,0,77,76,77,0,79,81,79,0,83,86,91,0,86,83,84,0,83,81,79,0,74,0],a=[48,45,41,43],o=60/140/4;return yj(r,o,(e,t)=>{let n=e%64,s=i[n];s&&gj(r,{type:`square`,freq:xj(s),start:t,dur:o*1.6,gain:.075,release:o*1.2,filter:{type:`lowpass`,freq:3800}});let c=a[Math.floor(n/16)];if(n%2==0){let e=c+(n/2%4==3?7:n/2%2?12:0);gj(r,{type:`triangle`,freq:xj(e-12),start:t,dur:o*1.8,gain:.22,release:o*1.2})}n%4==2&&gj(r,{type:`square`,freq:xj(c+24+(n/4%2?4:7)),start:t,dur:o*.8,gain:.03,release:o*.6}),n%4==0&&gj(r,{type:`sine`,freq:150,to:45,start:t,dur:.12,gain:.35,release:.1}),n%8==4&&vj(r,{start:t,dur:.12,gain:.16,filter:{type:`bandpass`,freq:1800,q:.8}}),n%2==1&&vj(r,{start:t,dur:.035,gain:.06,filter:{type:`highpass`,freq:7e3}})}),{stop:()=>mj(r,.1)}}},Lj={coin:Tj,jump:Ej,hit:Dj,explosion:Oj,click:kj,powerup:Aj,laser:jj,win:Mj,lose:Nj,whoosh:Pj,"ambient-pad":Fj,"chiptune-loop":Ij}}));function zj(e,t,n){let r=null,i=null,a=!!e?.muted,o=null,s=/* @__PURE__ */ new Map,c=null,l=!!e?.music,u=()=>Promise.resolve().then(()=>(Rj(),Cj)).then(e=>o=e.SOUND_IMPLS).catch(()=>o={}),d=e=>{let i=s.get(e);if(!i&&r){let a=r;i=fetch(t(e)).then(e=>e.arrayBuffer()).then(e=>a.decodeAudioData(e)).catch(t=>(n(t.message,e),null)),s.set(e,i)}return i??Promise.resolve(null)},f=(e,t=!1)=>{if(!r||!i)return null;let n=e.volume??1;if(e.preset){let t=o?.[e.preset];return t?t.play(r,i,n):null}if(e.src){let a=r,o=i,s=null,c=!1;return d(e.src).then(e=>{if(!e||c)return;s=a.createBufferSource(),s.buffer=e,s.loop=t;let r=a.createGain();r.gain.value=n,s.connect(r).connect(o),s.start()}),{stop(){c=!0;try{s?.stop()}catch{}}}}return null},p=()=>{!c&&e?.music&&!a&&r&&(c=f(e.music,e.music.loop!==!1))};return u(),{play(t){if(a||!r)return;let n=e?.sounds?.[t];n?f(n):o?.[t]&&o[t].play(r,i,1)},music(e){l=e,e?p():(c?.stop(),c=null)},muted:()=>a,setMuted(t){a=t,i&&r&&i.gain.setTargetAtTime(+!t,r.currentTime,.02),t?(c?.stop(),c=null):(l||e?.music)&&(l=!0,p())},unlock(){if(r){r.state===`suspended`&&r.resume();return}let e=globalThis.AudioContext??globalThis.webkitAudioContext;if(e)try{r=new e,i=r.createGain(),i.gain.value=+!a,i.connect(r.destination),l&&p()}catch(e){n(e.message)}},dispose(){c?.stop(),r?.close().catch(()=>void 0),r=null}}}var Bj=t((()=>{}));function Vj(e){if(!/^[0-9a-f]+$/i.test(e)||((e.length===3||e.length===4)&&(e=[...e].map(e=>e+e).join(``)),e.length!==6&&e.length!==8))return null;let t=t=>parseInt(e.slice(t,t+2),16);return{r:t(0),g:t(2),b:t(4),a:e.length===8?t(6)/255:1}}function Hj(e,t){let n=/^(-?\d*\.?\d+(?:e-?\d+)?)(%?)$/i.exec(e.trim());if(!n)return null;let r=Number(n[1]);return n[2]?r/100*t:r}function Uj(e){let t=/^(-?\d*\.?\d+)(deg|rad|turn|grad)?$/i.exec(e.trim());if(!t)return null;let n=Number(t[1]);switch((t[2]??`deg`).toLowerCase()){case`rad`:return n*180/Math.PI;case`turn`:return n*360;case`grad`:return n*.9;default:return n}}function Wj(e){let t=e.split(`/`);if(t.length>2)return null;let n=(t[0].includes(`,`)?t[0].split(`,`):t[0].trim().split(/\s+/)).map(e=>e.trim()).filter(e=>e!==``);return t.length===2&&n.push(t[1].trim()),n}function Gj(e,t,n){e=(e%360+360)%360;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r/2,[o,s,c]=e<60?[r,i,0]:e<120?[i,r,0]:e<180?[0,r,i]:e<240?[0,i,r]:e<300?[i,0,r]:[r,0,i];return[(o+a)*255,(s+a)*255,(c+a)*255]}function Kj(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();if(!t)return null;if(t.startsWith(`#`))return Vj(t.slice(1));if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=Xj[t];if(n)return Vj(n);let r=/^(rgba?|hsla?)\((.*)\)$/.exec(t);if(!r)return null;let i=Wj(r[2]);if(!i||i.length!==3&&i.length!==4)return null;let a=i.length===4?Hj(i[3],1):1;if(a===null)return null;if(r[1].startsWith(`rgb`)){let[e,t,n]=i.slice(0,3).map(e=>Hj(e,255));return e===null||t===null||n===null?null:{r:Zj(e,0,255),g:Zj(t,0,255),b:Zj(n,0,255),a:Zj(a,0,1)}}let o=Uj(i[0]),s=Hj(i[1],1),c=Hj(i[2],1);if(o===null||s===null||c===null||!i[1].trim().endsWith(`%`)||!i[2].trim().endsWith(`%`))return null;let[l,u,d]=Gj(o,Zj(s,0,1),Zj(c,0,1));return{r:l,g:u,b:d,a:Zj(a,0,1)}}function qj(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Jj(e,t){let n=qj(e),r=qj(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Yj(e){let t=Kj(e);return t?Jj(t,{r:255,g:255,b:255,a:1})>=Jj(t,{r:17,g:19,b:24,a:1})?`#ffffff`:`#111318`:`#ffffff`}var Xj,Zj,Qj=t((()=>{Xj={aliceblue:`f0f8ff`,antiquewhite:`faebd7`,aqua:`00ffff`,aquamarine:`7fffd4`,azure:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`000000`,blanchedalmond:`ffebcd`,blue:`0000ff`,blueviolet:`8a2be2`,brown:`a52a2a`,burlywood:`deb887`,cadetblue:`5f9ea0`,chartreuse:`7fff00`,chocolate:`d2691e`,coral:`ff7f50`,cornflowerblue:`6495ed`,cornsilk:`fff8dc`,crimson:`dc143c`,cyan:`00ffff`,darkblue:`00008b`,darkcyan:`008b8b`,darkgoldenrod:`b8860b`,darkgray:`a9a9a9`,darkgreen:`006400`,darkgrey:`a9a9a9`,darkkhaki:`bdb76b`,darkmagenta:`8b008b`,darkolivegreen:`556b2f`,darkorange:`ff8c00`,darkorchid:`9932cc`,darkred:`8b0000`,darksalmon:`e9967a`,darkseagreen:`8fbc8f`,darkslateblue:`483d8b`,darkslategray:`2f4f4f`,darkslategrey:`2f4f4f`,darkturquoise:`00ced1`,darkviolet:`9400d3`,deeppink:`ff1493`,deepskyblue:`00bfff`,dimgray:`696969`,dimgrey:`696969`,dodgerblue:`1e90ff`,firebrick:`b22222`,floralwhite:`fffaf0`,forestgreen:`228b22`,fuchsia:`ff00ff`,gainsboro:`dcdcdc`,ghostwhite:`f8f8ff`,gold:`ffd700`,goldenrod:`daa520`,gray:`808080`,green:`008000`,greenyellow:`adff2f`,grey:`808080`,honeydew:`f0fff0`,hotpink:`ff69b4`,indianred:`cd5c5c`,indigo:`4b0082`,ivory:`fffff0`,khaki:`f0e68c`,lavender:`e6e6fa`,lavenderblush:`fff0f5`,lawngreen:`7cfc00`,lemonchiffon:`fffacd`,lightblue:`add8e6`,lightcoral:`f08080`,lightcyan:`e0ffff`,lightgoldenrodyellow:`fafad2`,lightgray:`d3d3d3`,lightgreen:`90ee90`,lightgrey:`d3d3d3`,lightpink:`ffb6c1`,lightsalmon:`ffa07a`,lightseagreen:`20b2aa`,lightskyblue:`87cefa`,lightslategray:`778899`,lightslategrey:`778899`,lightsteelblue:`b0c4de`,lightyellow:`ffffe0`,lime:`00ff00`,limegreen:`32cd32`,linen:`faf0e6`,magenta:`ff00ff`,maroon:`800000`,mediumaquamarine:`66cdaa`,mediumblue:`0000cd`,mediumorchid:`ba55d3`,mediumpurple:`9370db`,mediumseagreen:`3cb371`,mediumslateblue:`7b68ee`,mediumspringgreen:`00fa9a`,mediumturquoise:`48d1cc`,mediumvioletred:`c71585`,midnightblue:`191970`,mintcream:`f5fffa`,mistyrose:`ffe4e1`,moccasin:`ffe4b5`,navajowhite:`ffdead`,navy:`000080`,oldlace:`fdf5e6`,olive:`808000`,olivedrab:`6b8e23`,orange:`ffa500`,orangered:`ff4500`,orchid:`da70d6`,palegoldenrod:`eee8aa`,palegreen:`98fb98`,paleturquoise:`afeeee`,palevioletred:`db7093`,papayawhip:`ffefd5`,peachpuff:`ffdab9`,peru:`cd853f`,pink:`ffc0cb`,plum:`dda0dd`,powderblue:`b0e0e6`,purple:`800080`,rebeccapurple:`663399`,red:`ff0000`,rosybrown:`bc8f8f`,royalblue:`4169e1`,saddlebrown:`8b4513`,salmon:`fa8072`,sandybrown:`f4a460`,seagreen:`2e8b57`,seashell:`fff5ee`,sienna:`a0522d`,silver:`c0c0c0`,skyblue:`87ceeb`,slateblue:`6a5acd`,slategray:`708090`,slategrey:`708090`,snow:`fffafa`,springgreen:`00ff7f`,steelblue:`4682b4`,tan:`d2b48c`,teal:`008080`,thistle:`d8bfd8`,tomato:`ff6347`,turquoise:`40e0d0`,violet:`ee82ee`,wheat:`f5deb3`,white:`ffffff`,whitesmoke:`f5f5f5`,yellow:`ffff00`,yellowgreen:`9acd32`},Zj=(e,t,n)=>Math.min(n,Math.max(t,e))}));function $j(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(/[0-9]/.test(r)||r===`-`&&/[0-9]/.test(e[n+1]??``)&&(t.length===0||t[t.length-1].t===`op`)){let r=n+1;for(;r<e.length&&/[0-9.]/.test(e[r]);)r++;t.push({t:`num`,v:Number(e.slice(n,r))}),n=r;continue}if(r===`'`||r===`"`){let i=n+1,a=``;for(;i<e.length&&e[i]!==r;)e[i]===`\\`&&i+1<e.length&&i++,a+=e[i++];if(i>=e.length)throw Error(`Unterminated string`);t.push({t:`str`,v:a}),n=i+1;continue}if(/[A-Za-z_$]/.test(r)){let r=n+1;for(;r<e.length&&/[A-Za-z0-9_$.]/.test(e[r]);)r++;t.push({t:`id`,v:e.slice(n,r)}),n=r;continue}let i=e.slice(n,n+3),a=e.slice(n,n+2);if(i===`===`||i===`!==`)t.push({t:`op`,v:i.slice(0,2)}),n+=3;else if([`==`,`!=`,`>=`,`<=`,`&&`,`||`].includes(a))t.push({t:`op`,v:a}),n+=2;else if(`!<>()`.includes(r))t.push({t:`op`,v:r}),n++;else throw Error(`Unexpected "${r}"`)}return t}function eM(e,t){let n=t.split(`.`);n[0]===`state`&&n.shift();let r=e;for(let e of n){if(iM.has(e)||typeof r!=`object`||!r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function tM(e,t){let n=$j(e),r=0,i=()=>n[r],a=e=>i()?.t===`op`&&i().v===e;function o(){let e=n[r++];if(!e)throw Error(`Unexpected end`);if(e.t===`num`||e.t===`str`)return e.v;if(e.t===`id`)return e.v===`true`?!0:e.v===`false`?!1:e.v===`null`||e.v===`undefined`?null:eM(t,e.v);if(e.v===`(`){let e=u();if(!a(`)`))throw Error(`Missing )`);return r++,e}throw Error(`Unexpected "${e.v}"`)}function s(){let e=o(),t=i();if(t?.t===`op`&&[`==`,`!=`,`>`,`<`,`>=`,`<=`].includes(t.v)){r++;let n=o(),i=e,a=n;switch(t.v){case`==`:return e==n||e==null&&n==null;case`!=`:return e!=n;case`>`:return i>a;case`<`:return i<a;case`>=`:return i>=a;default:return i<=a}}return e}function c(){return a(`!`)?(r++,!c()):s()}function l(){let e=c();for(;a(`&&`);){r++;let t=c();e&&=t}return e}function u(){let e=l();for(;a(`||`);){r++;let t=l();e||=t}return e}let d=u();if(r<n.length)throw Error(`Unexpected "${n[r].v}"`);return d}function nM(e,t){if(e===void 0)return!0;if(typeof e==`boolean`)return e;try{return!!tM(e,t)}catch{return!1}}function rM(e,t){return e.replace(/\{([^{}]+)\}/g,(e,n)=>{let r=n.trim(),i;try{i=/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(r)?eM(t,r):tM(r,t)}catch{i=void 0}return i==null?``:String(typeof i==`number`?Number.isInteger(i)?i:Math.round(i*100)/100:i)})}var iM,aM=t((()=>{iM=/* @__PURE__ */ new Set([`__proto__`,`prototype`,`constructor`])}));function oM(e,t,n){let r=e.ownerDocument,i=r.createElement(`div`);i.className=`a3d-hud`,i.setAttribute(`aria-live`,`polite`);let a=r.createElement(`style`),o=t?.accent??`#ff006e`;a.textContent=lM(t?.font??`system-ui,-apple-system,'Segoe UI',Roboto,sans-serif`,t?.color??`#ffffff`,o,t?.buttonText??Yj(o)),i.appendChild(a);let s=/* @__PURE__ */ new Map,c=e=>{let t=s.get(e);return t||(t=r.createElement(`div`),t.className=`a3d-zone`,t.style.cssText=sM[e]??sM[`top-left`],t.dataset.anchor=e,i.appendChild(t),s.set(e,t)),t},l=[[`top-left`,`top`,`top-right`],[`left`,`center`,`right`],[`bottom-left`,`bottom`,`bottom-right`]],u=()=>{for(let[e,t,n]of l){let r=s.get(t);r&&(r.style.gridColumn=s.has(e)||s.has(n)?`2`:`1 / -1`)}},d=/* @__PURE__ */ new Map;for(let e of t?.elements??[]){let t,i;if(e.type===`button`){let i=r.createElement(`button`);i.type=`button`,i.className=`a3d-btn`,i.addEventListener(`click`,t=>{t.stopPropagation(),e.action&&n(e.action)}),i.addEventListener(`pointerdown`,e=>e.stopPropagation()),t=i}else e.type===`bar`?(t=r.createElement(`div`),t.className=`a3d-bar`,i=r.createElement(`i`),t.appendChild(i)):(t=r.createElement(`div`),t.className=`a3d-el a3d-${e.style??`plain`}`);e.color&&(t.style.color=e.color,e.type===`bar`&&i&&(i.style.background=e.color)),e.background&&(t.style.background=e.background),e.type===`button`&&e.background&&!e.color&&(t.style.color=Yj(e.background)),t.dataset.id=e.id,c(e.anchor??`top-left`).appendChild(t),d.set(e.id,{def:e,node:t,fill:i,override:{},last:``})}u(),e.appendChild(i);let f=null,p=0,m=null,h=null,g=null;return{root:i,setTimeline(e){g=e},set(e,t){let n=d.get(e);n&&Object.assign(n.override,t)},toast(e,t=2){m={text:e,seconds:t}},update(e,t){let n=g&&!Object.prototype.hasOwnProperty.call(e,`timeline`)?{...e,timeline:g}:e;for(let e of d.values()){let t=e.override.visible??nM(e.def.visible,n);if(e.node.style.display=t?``:`none`,!t)continue;if(e.def.type===`bar`){let t=e.override.value??Number(e.def.value?eM(n,e.def.value):0),r=Math.max(0,Math.min(1,Number.isFinite(t)?t:0));e.fill.style.width=`${(r*100).toFixed(1)}%`;continue}let r=e.override.text??rM(e.def.text??``,n);r!==e.last&&(e.node.textContent=r,e.last=r)}m&&=(f||(f=r.createElement(`div`),f.className=`a3d-toast`,i.appendChild(f)),f.textContent=m.text,f.style.opacity=`1`,p=t+m.seconds,null),f&&t>p&&(f.style.opacity=`0`)},setMuteButton(e,t){e===null?(h?.remove(),h=null):(h||(h=r.createElement(`button`),h.type=`button`,h.className=`a3d-mute`,h.addEventListener(`pointerdown`,e=>e.stopPropagation()),h.addEventListener(`click`,e=>{e.stopPropagation(),t?.()}),c(`bottom-right`).appendChild(h),u()),h.innerHTML=e?dM:uM,h.setAttribute(`aria-label`,e?`Unmute sound`:`Mute sound`))},dispose(){i.remove()}}}var sM,cM,lM,uM,dM,fM=t((()=>{Qj(),aM(),sM={"top-left":`grid-row:1;grid-column:1;align-items:flex-start;align-self:start;`,top:`grid-row:1;grid-column:2;align-items:center;align-self:start;text-align:center;`,"top-right":`grid-row:1;grid-column:3;align-items:flex-end;align-self:start;text-align:right;`,left:`grid-row:2;grid-column:1;align-items:flex-start;align-self:center;`,center:`grid-row:2;grid-column:2;align-items:center;align-self:center;text-align:center;`,right:`grid-row:2;grid-column:3;align-items:flex-end;align-self:center;text-align:right;`,"bottom-left":`grid-row:3;grid-column:1;align-items:flex-start;align-self:end;`,bottom:`grid-row:3;grid-column:2;align-items:center;align-self:end;text-align:center;`,"bottom-right":`grid-row:3;grid-column:3;align-items:flex-end;align-self:end;text-align:right;`},cM=(e,t,n)=>`font-size:${n}px;font-size:clamp(${e}px,min(${t}cqw,${(t*1.6).toFixed(1)}cqh),${n}px)`,lM=(e,t,n,r)=>`
|
|
5797
6046
|
.a3d-hud{position:absolute;inset:0;pointer-events:none;font-family:${e};color:${t};z-index:2;overflow:hidden;user-select:none;-webkit-user-select:none;container-type:size;display:grid;grid-template-columns:minmax(min-content,1fr) fit-content(56%) minmax(min-content,1fr);grid-template-rows:auto minmax(0,1fr) auto}
|
|
5798
6047
|
.a3d-zone{display:flex;flex-direction:column;gap:8px;gap:clamp(4px,1.6cqw,8px);padding:14px;padding:clamp(8px,2.6cqw,14px);min-width:0;max-width:100%;box-sizing:border-box}
|
|
5799
6048
|
.a3d-el{line-height:1.2;text-shadow:0 1px 3px rgba(0,0,0,.45);white-space:pre-line;overflow-wrap:break-word}
|
|
5800
|
-
.a3d-plain{${
|
|
5801
|
-
.a3d-pill{${
|
|
5802
|
-
.a3d-title{${
|
|
5803
|
-
.a3d-subtitle{${
|
|
5804
|
-
.a3d-panel{${
|
|
6049
|
+
.a3d-plain{${cM(11,3.2,15)};font-weight:600}
|
|
6050
|
+
.a3d-pill{${cM(11,3,14)};font-weight:700;padding:.43em 1em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;box-sizing:border-box;flex:none;border-radius:999px;background:rgba(0,0,0,.42);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);text-shadow:none}
|
|
6051
|
+
.a3d-title{${cM(20,7,44)};font-weight:800;letter-spacing:-.01em}
|
|
6052
|
+
.a3d-subtitle{${cM(12,3.6,18)};font-weight:500;opacity:.9}
|
|
6053
|
+
.a3d-panel{${cM(13,3.6,18)};font-weight:600;line-height:1.45;padding:1.1em 1.6em;border-radius:18px;background:rgba(10,12,20,.72);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 10px 34px rgba(0,0,0,.35);text-shadow:none;max-width:100%;box-sizing:border-box}
|
|
5805
6054
|
.a3d-panel::first-line{font-size:1.45em;font-weight:800}
|
|
5806
|
-
.a3d-btn{pointer-events:auto;cursor:pointer;border:0;font:inherit;${
|
|
6055
|
+
.a3d-btn{pointer-events:auto;cursor:pointer;border:0;font:inherit;${cM(12,3.4,15)};font-weight:700;color:${r};background:${n};padding:.67em 1.47em;border-radius:999px;box-shadow:0 4px 14px rgba(0,0,0,.25);transition:transform .12s ease,filter .12s ease;text-shadow:none;min-height:36px}
|
|
5807
6056
|
.a3d-btn:hover{transform:translateY(-1px);filter:brightness(1.08)}.a3d-btn:active{transform:translateY(1px)}
|
|
5808
6057
|
.a3d-bar{width:160px;width:clamp(80px,30cqw,160px);height:10px;height:clamp(7px,2cqw,10px);border-radius:999px;background:rgba(0,0,0,.35);overflow:hidden}
|
|
5809
6058
|
.a3d-bar>i{display:block;height:100%;width:0;background:${n};border-radius:inherit}
|
|
5810
|
-
.a3d-toast{position:absolute;left:50%;bottom:18%;transform:translateX(-50%);max-width:86%;box-sizing:border-box;text-align:center;padding:.53em 1.2em;border-radius:999px;background:rgba(0,0,0,.6);color:#fff;font-weight:700;${
|
|
6059
|
+
.a3d-toast{position:absolute;left:50%;bottom:18%;transform:translateX(-50%);max-width:86%;box-sizing:border-box;text-align:center;padding:.53em 1.2em;border-radius:999px;background:rgba(0,0,0,.6);color:#fff;font-weight:700;${cM(12,3.4,15)};transition:opacity .25s ease;text-shadow:none}
|
|
5811
6060
|
.a3d-mute{pointer-events:auto;width:34px;height:34px;width:clamp(28px,8cqw,34px);height:clamp(28px,8cqw,34px);border-radius:50%;border:0;background:rgba(0,0,0,.4);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;flex:none}
|
|
5812
6061
|
.a3d-mute svg{width:55%;height:55%}
|
|
5813
|
-
`,Lj=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M19 5a10 10 0 0 1 0 14"/></svg>`,Rj=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="m23 9-6 6"/><path d="m17 9 6 6"/></svg>`}));function Bj(e,t,n){n.vsub(e,yN);let r=yN.dot(t);return t.scale(r,bN),bN.vadd(e,bN),n.distanceTo(bN)}function Vj(e,t,n,r,i,a,o,s,c){c.x=((a-s)*(e-o)+(o-i)*(t-s))/((a-s)*(n-o)+(o-i)*(r-s)),c.y=((s-r)*(e-o)+(n-o)*(t-s))/((a-s)*(n-o)+(o-i)*(r-s)),c.z=1-c.x-c.y}function Hj(e,t,n){let r=null,i=e.length;for(let a=0;a!==i;a++){let o=e[a],s=cF;e[(a+1)%i].vsub(o,s);let c=lF;s.cross(t,c);let l=uF;n.vsub(o,l);let u=c.dot(l);if(r===null||u>0&&r===!0||u<=0&&r===!1)r===null&&(r=u>0);else return!1}return!0}function Uj(e,t){e.push((t&4294901760)>>16,t&65535)}var Wj,Gj,$,Kj,qj,Jj,Yj,Xj,Zj,Qj,$j,eM,tM,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM,$M,eN,tN,nN,rN,iN,aN,oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,ON,kN,AN,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN,QN,$N,eP,tP,nP,rP,iP,aP,oP,sP,cP,lP,uP,dP,fP,pP,mP,hP,gP,_P,vP,yP,bP,xP,SP,CP,wP,TP,EP,DP,OP,kP,AP,jP,MP,NP,PP,FP,IP,LP,RP,zP,BP,VP,HP,UP,WP,GP,KP,qP,JP,YP,XP,ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF,sF,cF,lF,uF,dF,fF,pF,mF,hF,gF,_F,vF,yF,bF,xF,SF,CF,wF,TF,EF,DF,OF,kF,AF,jF,MF,NF,PF,FF,IF,LF,RF,zF,BF,VF,HF,UF,WF,GF,KF,qF,JF,YF,XF,ZF,QF,$F,eI,tI,nI,rI,iI,aI,oI,sI,cI,lI,uI,dI,fI,pI,mI,hI=t((()=>{if(Wj=class e{constructor(e){e===void 0&&(e=[0,0,0,0,0,0,0,0,0]),this.elements=e}identity(){let e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){let e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){let t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e){e===void 0&&(e=new $);let t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t){t===void 0&&(t=new $);let n=this.elements,r=e.x,i=e.y,a=e.z;return t.x=n[0]*r+n[1]*i+n[2]*a,t.y=n[3]*r+n[4]*i+n[5]*a,t.z=n[6]*r+n[7]*i+n[8]*a,t}smult(e){for(let t=0;t<this.elements.length;t++)this.elements[t]*=e}mmult(t,n){n===void 0&&(n=new e);let r=this.elements,i=t.elements,a=n.elements,o=r[0],s=r[1],c=r[2],l=r[3],u=r[4],d=r[5],f=r[6],p=r[7],m=r[8],h=i[0],g=i[1],_=i[2],v=i[3],y=i[4],b=i[5],x=i[6],S=i[7],C=i[8];return a[0]=o*h+s*v+c*x,a[1]=o*g+s*y+c*S,a[2]=o*_+s*b+c*C,a[3]=l*h+u*v+d*x,a[4]=l*g+u*y+d*S,a[5]=l*_+u*b+d*C,a[6]=f*h+p*v+m*x,a[7]=f*g+p*y+m*S,a[8]=f*_+p*b+m*C,n}scale(t,n){n===void 0&&(n=new e);let r=this.elements,i=n.elements;for(let e=0;e!==3;e++)i[3*e+0]=t.x*r[3*e+0],i[3*e+1]=t.y*r[3*e+1],i[3*e+2]=t.z*r[3*e+2];return n}solve(e,t){t===void 0&&(t=new $);let n=[],r,i;for(r=0;r<12;r++)n.push(0);for(r=0;r<3;r++)for(i=0;i<3;i++)n[r+4*i]=this.elements[r+3*i];n[3]=e.x,n[7]=e.y,n[11]=e.z;let a=3,o=a,s,c;do{if(r=o-a,n[r+4*r]===0){for(i=r+1;i<o;i++)if(n[r+4*i]!==0){s=4;do c=4-s,n[c+4*r]+=n[c+4*i];while(--s);break}}if(n[r+4*r]!==0)for(i=r+1;i<o;i++){let e=n[r+4*i]/n[r+4*r];s=4;do c=4-s,n[c+4*i]=c<=r?0:n[c+4*i]-n[c+4*r]*e;while(--s)}}while(--a);if(t.z=n[11]/n[10],t.y=(n[7]-n[6]*t.z)/n[5],t.x=(n[3]-n[2]*t.z-n[1]*t.y)/n[0],isNaN(t.x)||isNaN(t.y)||isNaN(t.z)||t.x===1/0||t.y===1/0||t.z===1/0)throw`Could not solve equation! Got x=[${t.toString()}], b=[${e.toString()}], A=[${this.toString()}]`;return t}e(e,t,n){if(n===void 0)return this.elements[t+3*e];this.elements[t+3*e]=n}copy(e){for(let t=0;t<e.elements.length;t++)this.elements[t]=e.elements[t];return this}toString(){let e=``;for(let t=0;t<9;t++)e+=this.elements[t]+`,`;return e}reverse(t){t===void 0&&(t=new e);let n=Gj,r,i;for(r=0;r<3;r++)for(i=0;i<3;i++)n[r+6*i]=this.elements[r+3*i];n[3]=1,n[9]=0,n[15]=0,n[4]=0,n[10]=1,n[16]=0,n[5]=0,n[11]=0,n[17]=1;let a=3,o=a,s,c;do{if(r=o-a,n[r+6*r]===0){for(i=r+1;i<o;i++)if(n[r+6*i]!==0){s=6;do c=6-s,n[c+6*r]+=n[c+6*i];while(--s);break}}if(n[r+6*r]!==0)for(i=r+1;i<o;i++){let e=n[r+6*i]/n[r+6*r];s=6;do c=6-s,n[c+6*i]=c<=r?0:n[c+6*i]-n[c+6*r]*e;while(--s)}}while(--a);r=2;do{i=r-1;do{let e=n[r+6*i]/n[r+6*r];s=6;do c=6-s,n[c+6*i]=n[c+6*i]-n[c+6*r]*e;while(--s)}while(i--)}while(--r);r=2;do{let e=1/n[r+6*r];s=6;do c=6-s,n[c+6*r]=n[c+6*r]*e;while(--s)}while(r--);r=2;do{i=2;do{if(c=n[3+i+6*r],isNaN(c)||c===1/0)throw`Could not reverse! A=[${this.toString()}]`;t.e(r,i,c)}while(i--)}while(r--);return t}setRotationFromQuaternion(e){let t=e.x,n=e.y,r=e.z,i=e.w,a=t+t,o=n+n,s=r+r,c=t*a,l=t*o,u=t*s,d=n*o,f=n*s,p=r*s,m=i*a,h=i*o,g=i*s,_=this.elements;return _[0]=1-(d+p),_[1]=l-g,_[2]=u+h,_[3]=l+g,_[4]=1-(c+p),_[5]=f-m,_[6]=u-h,_[7]=f+m,_[8]=1-(c+d),this}transpose(t){t===void 0&&(t=new e);let n=this.elements,r=t.elements,i;return r[0]=n[0],r[4]=n[4],r[8]=n[8],i=n[1],r[1]=n[3],r[3]=i,i=n[2],r[2]=n[6],r[6]=i,i=n[5],r[5]=n[7],r[7]=i,t}},Gj=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=class e{constructor(e,t,n){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),this.x=e,this.y=t,this.z=n}cross(t,n){n===void 0&&(n=new e);let r=t.x,i=t.y,a=t.z,o=this.x,s=this.y,c=this.z;return n.x=s*a-c*i,n.y=c*r-o*a,n.z=o*i-s*r,n}set(e,t,n){return this.x=e,this.y=t,this.z=n,this}setZero(){this.x=this.y=this.z=0}vadd(t,n){if(n)n.x=t.x+this.x,n.y=t.y+this.y,n.z=t.z+this.z;else return new e(this.x+t.x,this.y+t.y,this.z+t.z)}vsub(t,n){if(n)n.x=this.x-t.x,n.y=this.y-t.y,n.z=this.z-t.z;else return new e(this.x-t.x,this.y-t.y,this.z-t.z)}crossmat(){return new Wj([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])}normalize(){let e=this.x,t=this.y,n=this.z,r=Math.sqrt(e*e+t*t+n*n);if(r>0){let e=1/r;this.x*=e,this.y*=e,this.z*=e}else this.x=0,this.y=0,this.z=0;return r}unit(t){t===void 0&&(t=new e);let n=this.x,r=this.y,i=this.z,a=Math.sqrt(n*n+r*r+i*i);return a>0?(a=1/a,t.x=n*a,t.y=r*a,t.z=i*a):(t.x=1,t.y=0,t.z=0),t}length(){let e=this.x,t=this.y,n=this.z;return Math.sqrt(e*e+t*t+n*n)}lengthSquared(){return this.dot(this)}distanceTo(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z;return Math.sqrt((i-t)*(i-t)+(a-n)*(a-n)+(o-r)*(o-r))}distanceSquared(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z;return(i-t)*(i-t)+(a-n)*(a-n)+(o-r)*(o-r)}scale(t,n){n===void 0&&(n=new e);let r=this.x,i=this.y,a=this.z;return n.x=t*r,n.y=t*i,n.z=t*a,n}vmul(t,n){return n===void 0&&(n=new e),n.x=t.x*this.x,n.y=t.y*this.y,n.z=t.z*this.z,n}addScaledVector(t,n,r){return r===void 0&&(r=new e),r.x=this.x+t*n.x,r.y=this.y+t*n.y,r.z=this.z+t*n.z,r}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isZero(){return this.x===0&&this.y===0&&this.z===0}negate(t){return t===void 0&&(t=new e),t.x=-this.x,t.y=-this.y,t.z=-this.z,t}tangents(e,t){let n=this.length();if(n>0){let r=Kj,i=1/n;r.set(this.x*i,this.y*i,this.z*i);let a=qj;Math.abs(r.x)<.9?(a.set(1,0,0),r.cross(a,e)):(a.set(0,1,0),r.cross(a,e)),r.cross(e,t)}else e.set(1,0,0),t.set(0,1,0)}toString(){return`${this.x},${this.y},${this.z}`}toArray(){return[this.x,this.y,this.z]}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}lerp(e,t,n){let r=this.x,i=this.y,a=this.z;n.x=r+(e.x-r)*t,n.y=i+(e.y-i)*t,n.z=a+(e.z-a)*t}almostEquals(e,t){return t===void 0&&(t=1e-6),!(Math.abs(this.x-e.x)>t||Math.abs(this.y-e.y)>t||Math.abs(this.z-e.z)>t)}almostZero(e){return e===void 0&&(e=1e-6),!(Math.abs(this.x)>e||Math.abs(this.y)>e||Math.abs(this.z)>e)}isAntiparallelTo(e,t){return this.negate(Jj),Jj.almostEquals(e,t)}clone(){return new e(this.x,this.y,this.z)}},$.ZERO=new $(0,0,0),$.UNIT_X=new $(1,0,0),$.UNIT_Y=new $(0,1,0),$.UNIT_Z=new $(0,0,1),Kj=new $,qj=new $,Jj=new $,Yj=class e{constructor(e){e===void 0&&(e={}),this.lowerBound=new $,this.upperBound=new $,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,n,r){let i=this.lowerBound,a=this.upperBound,o=n;i.copy(e[0]),o&&o.vmult(i,i),a.copy(i);for(let t=1;t<e.length;t++){let n=e[t];o&&(o.vmult(n,Xj),n=Xj),n.x>a.x&&(a.x=n.x),n.x<i.x&&(i.x=n.x),n.y>a.y&&(a.y=n.y),n.y<i.y&&(i.y=n.y),n.z>a.z&&(a.z=n.z),n.z<i.z&&(i.z=n.z)}return t&&(t.vadd(i,i),t.vadd(a,a)),r&&(i.x-=r,i.y-=r,i.z-=r,a.x+=r,a.y+=r,a.z+=r),this}copy(e){return this.lowerBound.copy(e.lowerBound),this.upperBound.copy(e.upperBound),this}clone(){return new e().copy(this)}extend(e){this.lowerBound.x=Math.min(this.lowerBound.x,e.lowerBound.x),this.upperBound.x=Math.max(this.upperBound.x,e.upperBound.x),this.lowerBound.y=Math.min(this.lowerBound.y,e.lowerBound.y),this.upperBound.y=Math.max(this.upperBound.y,e.upperBound.y),this.lowerBound.z=Math.min(this.lowerBound.z,e.lowerBound.z),this.upperBound.z=Math.max(this.upperBound.z,e.upperBound.z)}overlaps(e){let t=this.lowerBound,n=this.upperBound,r=e.lowerBound,i=e.upperBound,a=r.x<=n.x&&n.x<=i.x||t.x<=i.x&&i.x<=n.x,o=r.y<=n.y&&n.y<=i.y||t.y<=i.y&&i.y<=n.y,s=r.z<=n.z&&n.z<=i.z||t.z<=i.z&&i.z<=n.z;return a&&o&&s}volume(){let e=this.lowerBound,t=this.upperBound;return(t.x-e.x)*(t.y-e.y)*(t.z-e.z)}contains(e){let t=this.lowerBound,n=this.upperBound,r=e.lowerBound,i=e.upperBound;return t.x<=r.x&&n.x>=i.x&&t.y<=r.y&&n.y>=i.y&&t.z<=r.z&&n.z>=i.z}getCorners(e,t,n,r,i,a,o,s){let c=this.lowerBound,l=this.upperBound;e.copy(c),t.set(l.x,c.y,c.z),n.set(l.x,l.y,c.z),r.set(c.x,l.y,l.z),i.set(l.x,c.y,l.z),a.set(c.x,l.y,c.z),o.set(c.x,c.y,l.z),s.copy(l)}toLocalFrame(e,t){let n=Zj,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7];this.getCorners(r,i,a,o,s,c,l,u);for(let t=0;t!==8;t++){let r=n[t];e.pointToLocal(r,r)}return t.setFromPoints(n)}toWorldFrame(e,t){let n=Zj,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7];this.getCorners(r,i,a,o,s,c,l,u);for(let t=0;t!==8;t++){let r=n[t];e.pointToWorld(r,r)}return t.setFromPoints(n)}overlapsRay(e){let{direction:t,from:n}=e,r=1/t.x,i=1/t.y,a=1/t.z,o=(this.lowerBound.x-n.x)*r,s=(this.upperBound.x-n.x)*r,c=(this.lowerBound.y-n.y)*i,l=(this.upperBound.y-n.y)*i,u=(this.lowerBound.z-n.z)*a,d=(this.upperBound.z-n.z)*a,f=Math.max(Math.max(Math.min(o,s),Math.min(c,l)),Math.min(u,d)),p=Math.min(Math.min(Math.max(o,s),Math.max(c,l)),Math.max(u,d));return!(p<0||f>p)}},Xj=new $,Zj=[new $,new $,new $,new $,new $,new $,new $,new $],Qj=class{constructor(){this.matrix=[]}get(e,t){let{index:n}=e,{index:r}=t;if(r>n){let e=r;r=n,n=e}return this.matrix[(n*(n+1)>>1)+r-1]}set(e,t,n){let{index:r}=e,{index:i}=t;if(i>r){let e=i;i=r,r=e}this.matrix[(r*(r+1)>>1)+i-1]=+!!n}reset(){for(let e=0,t=this.matrix.length;e!==t;e++)this.matrix[e]=0}setNumObjects(e){this.matrix.length=e*(e-1)>>1}},$j=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;return n[e]===void 0&&(n[e]=[]),n[e].includes(t)||n[e].push(t),this}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return!!(n[e]!==void 0&&n[e].includes(t))}hasAnyEventListener(e){return this._listeners!==void 0&&this._listeners[e]!==void 0}removeEventListener(e,t){if(this._listeners===void 0)return this;let n=this._listeners;if(n[e]===void 0)return this;let r=n[e].indexOf(t);return r!==-1&&n[e].splice(r,1),this}dispatchEvent(e){if(this._listeners===void 0)return this;let t=this._listeners[e.type];if(t!==void 0){e.target=this;for(let n=0,r=t.length;n<r;n++)t[n].call(this,e)}return this}},eM=class e{constructor(e,t,n,r){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=1),this.x=e,this.y=t,this.z=n,this.w=r}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(e,t){let n=Math.sin(t*.5);return this.x=e.x*n,this.y=e.y*n,this.z=e.z*n,this.w=Math.cos(t*.5),this}toAxisAngle(e){e===void 0&&(e=new $),this.normalize();let t=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(e.x=this.x,e.y=this.y,e.z=this.z):(e.x=this.x/n,e.y=this.y/n,e.z=this.z/n),[e,t]}setFromVectors(e,t){if(e.isAntiparallelTo(t)){let t=tM,n=nM;e.tangents(t,n),this.setFromAxisAngle(t,Math.PI)}else{let n=e.cross(t);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(e.length()**2*t.length()**2)+e.dot(t),this.normalize()}return this}mult(t,n){n===void 0&&(n=new e);let r=this.x,i=this.y,a=this.z,o=this.w,s=t.x,c=t.y,l=t.z,u=t.w;return n.x=r*u+o*s+i*l-a*c,n.y=i*u+o*c+a*s-r*l,n.z=a*u+o*l+r*c-i*s,n.w=o*u-r*s-i*c-a*l,n}inverse(t){t===void 0&&(t=new e);let n=this.x,r=this.y,i=this.z,a=this.w;this.conjugate(t);let o=1/(n*n+r*r+i*i+a*a);return t.x*=o,t.y*=o,t.z*=o,t.w*=o,t}conjugate(t){return t===void 0&&(t=new e),t.x=-this.x,t.y=-this.y,t.z=-this.z,t.w=this.w,t}normalize(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}normalizeFast(){let e=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}vmult(e,t){t===void 0&&(t=new $);let n=e.x,r=e.y,i=e.z,a=this.x,o=this.y,s=this.z,c=this.w,l=c*n+o*i-s*r,u=c*r+s*n-a*i,d=c*i+a*r-o*n,f=-a*n-o*r-s*i;return t.x=l*c+f*-a+u*-s-d*-o,t.y=u*c+f*-o+d*-a-l*-s,t.z=d*c+f*-s+l*-o-u*-a,t}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toEuler(e,t){t===void 0&&(t=`YZX`);let n,r,i,a=this.x,o=this.y,s=this.z,c=this.w;switch(t){case`YZX`:let e=a*o+s*c;if(e>.499&&(n=2*Math.atan2(a,c),r=Math.PI/2,i=0),e<-.499&&(n=-2*Math.atan2(a,c),r=-Math.PI/2,i=0),n===void 0){let t=a*a,l=o*o,u=s*s;n=Math.atan2(2*o*c-2*a*s,1-2*l-2*u),r=Math.asin(2*e),i=Math.atan2(2*a*c-2*o*s,1-2*t-2*u)}break;default:throw Error(`Euler order ${t} not supported yet.`)}e.y=n,e.z=r,e.x=i}setFromEuler(e,t,n,r){r===void 0&&(r=`XYZ`);let i=Math.cos(e/2),a=Math.cos(t/2),o=Math.cos(n/2),s=Math.sin(e/2),c=Math.sin(t/2),l=Math.sin(n/2);return r===`XYZ`?(this.x=s*a*o+i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o-s*c*l):r===`YXZ`?(this.x=s*a*o+i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o+s*c*l):r===`ZXY`?(this.x=s*a*o-i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o-s*c*l):r===`ZYX`?(this.x=s*a*o-i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o+s*c*l):r===`YZX`?(this.x=s*a*o+i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o-s*c*l):r===`XZY`&&(this.x=s*a*o-i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o+s*c*l),this}clone(){return new e(this.x,this.y,this.z,this.w)}slerp(t,n,r){r===void 0&&(r=new e);let i=this.x,a=this.y,o=this.z,s=this.w,c=t.x,l=t.y,u=t.z,d=t.w,f,p,m,h,g;return p=i*c+a*l+o*u+s*d,p<0&&(p=-p,c=-c,l=-l,u=-u,d=-d),1-p>1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-n)*f)/m,g=Math.sin(n*f)/m):(h=1-n,g=n),r.x=h*i+g*c,r.y=h*a+g*l,r.z=h*o+g*u,r.w=h*s+g*d,r}integrate(t,n,r,i){i===void 0&&(i=new e);let a=t.x*r.x,o=t.y*r.y,s=t.z*r.z,c=this.x,l=this.y,u=this.z,d=this.w,f=n*.5;return i.x+=f*(a*d+o*u-s*l),i.y+=f*(o*d+s*c-a*u),i.z+=f*(s*d+a*l-o*c),i.w+=f*(-a*c-o*l-s*u),i}},tM=new $,nM=new $,rM={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256},iM=class e{constructor(t){t===void 0&&(t={}),this.id=e.idCounter++,this.type=t.type||0,this.boundingSphereRadius=0,this.collisionResponse=!t.collisionResponse||t.collisionResponse,this.collisionFilterGroup=t.collisionFilterGroup===void 0?1:t.collisionFilterGroup,this.collisionFilterMask=t.collisionFilterMask===void 0?-1:t.collisionFilterMask,this.material=t.material?t.material:null,this.body=null}updateBoundingSphereRadius(){throw`computeBoundingSphereRadius() not implemented for shape type ${this.type}`}volume(){throw`volume() not implemented for shape type ${this.type}`}calculateLocalInertia(e,t){throw`calculateLocalInertia() not implemented for shape type ${this.type}`}calculateWorldAABB(e,t,n,r){throw`calculateWorldAABB() not implemented for shape type ${this.type}`}},iM.idCounter=0,iM.types=rM,aM=class e{constructor(e){e===void 0&&(e={}),this.position=new $,this.quaternion=new eM,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(t,n){return e.pointToLocalFrame(this.position,this.quaternion,t,n)}pointToWorld(t,n){return e.pointToWorldFrame(this.position,this.quaternion,t,n)}vectorToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,n,r){return r===void 0&&(r=new $),n.vsub(e,r),t.conjugate(oM),oM.vmult(r,r),r}static pointToWorldFrame(e,t,n,r){return r===void 0&&(r=new $),t.vmult(n,r),r.vadd(e,r),r}static vectorToWorldFrame(e,t,n){return n===void 0&&(n=new $),e.vmult(t,n),n}static vectorToLocalFrame(e,t,n,r){return r===void 0&&(r=new $),t.w*=-1,t.vmult(n,r),t.w*=-1,r}},oM=new eM,sM=class e extends iM{constructor(e){e===void 0&&(e={});let{vertices:t=[],faces:n=[],normals:r=[],axes:i,boundingSphereRadius:a}=e;super({type:iM.types.CONVEXPOLYHEDRON}),this.vertices=t,this.faces=n,this.faceNormals=r,this.faceNormals.length===0&&this.computeNormals(),a?this.boundingSphereRadius=a:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=i?i.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){let e=this.faces,t=this.vertices,n=this.uniqueEdges;n.length=0;let r=new $;for(let i=0;i!==e.length;i++){let a=e[i],o=a.length;for(let e=0;e!==o;e++){let i=(e+1)%o;t[a[e]].vsub(t[a[i]],r),r.normalize();let s=!1;for(let e=0;e!==n.length;e++)if(n[e].almostEquals(r)||n[e].almostEquals(r)){s=!0;break}s||n.push(r.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let e=0;e<this.faces.length;e++){for(let t=0;t<this.faces[e].length;t++)if(!this.vertices[this.faces[e][t]])throw Error(`Vertex ${this.faces[e][t]} not found!`);let t=this.faceNormals[e]||new $;this.getFaceNormal(e,t),t.negate(t),this.faceNormals[e]=t;let n=this.vertices[this.faces[e][0]];if(t.dot(n)<0){console.error(`.faceNormals[${e}] = Vec3(${t.toString()}) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.`);for(let t=0;t<this.faces[e].length;t++)console.warn(`.vertices[${this.faces[e][t]}] = Vec3(${this.vertices[this.faces[e][t]].toString()})`)}}}getFaceNormal(t,n){let r=this.faces[t],i=this.vertices[r[0]],a=this.vertices[r[1]],o=this.vertices[r[2]];e.computeNormal(i,a,o,n)}static computeNormal(e,t,n,r){let i=new $,a=new $;t.vsub(e,a),n.vsub(t,i),i.cross(a,r),r.isZero()||r.normalize()}clipAgainstHull(e,t,n,r,i,a,o,s,c){let l=new $,u=-1,d=-Number.MAX_VALUE;for(let e=0;e<n.faces.length;e++){l.copy(n.faceNormals[e]),i.vmult(l,l);let t=l.dot(a);t>d&&(d=t,u=e)}let f=[];for(let e=0;e<n.faces[u].length;e++){let t=n.vertices[n.faces[u][e]],a=new $;a.copy(t),i.vmult(a,a),r.vadd(a,a),f.push(a)}u>=0&&this.clipFaceAgainstHull(a,e,t,f,o,s,c)}findSeparatingAxis(e,t,n,r,i,a,o,s){let c=new $,l=new $,u=new $,d=new $,f=new $,p=new $,m=Number.MAX_VALUE,h=this;if(h.uniqueAxes)for(let o=0;o!==h.uniqueAxes.length;o++){n.vmult(h.uniqueAxes[o],c);let s=h.testSepAxis(c,e,t,n,r,i);if(s===!1)return!1;s<m&&(m=s,a.copy(c))}else{let s=o?o.length:h.faces.length;for(let l=0;l<s;l++){let s=o?o[l]:l;c.copy(h.faceNormals[s]),n.vmult(c,c);let u=h.testSepAxis(c,e,t,n,r,i);if(u===!1)return!1;u<m&&(m=u,a.copy(c))}}if(e.uniqueAxes)for(let o=0;o!==e.uniqueAxes.length;o++){i.vmult(e.uniqueAxes[o],l);let s=h.testSepAxis(l,e,t,n,r,i);if(s===!1)return!1;s<m&&(m=s,a.copy(l))}else{let o=s?s.length:e.faces.length;for(let c=0;c<o;c++){let o=s?s[c]:c;l.copy(e.faceNormals[o]),i.vmult(l,l);let u=h.testSepAxis(l,e,t,n,r,i);if(u===!1)return!1;u<m&&(m=u,a.copy(l))}}for(let o=0;o!==h.uniqueEdges.length;o++){n.vmult(h.uniqueEdges[o],d);for(let o=0;o!==e.uniqueEdges.length;o++)if(i.vmult(e.uniqueEdges[o],f),d.cross(f,p),!p.almostZero()){p.normalize();let o=h.testSepAxis(p,e,t,n,r,i);if(o===!1)return!1;o<m&&(m=o,a.copy(p))}}return r.vsub(t,u),u.dot(a)>0&&a.negate(a),!0}testSepAxis(t,n,r,i,a,o){let s=this;e.project(s,t,r,i,cM),e.project(n,t,a,o,lM);let c=cM[0],l=cM[1],u=lM[0],d=lM[1];if(c<d||u<l)return!1;let f=c-d,p=u-l;return f<p?f:p}calculateLocalInertia(e,t){let n=new $,r=new $;this.computeLocalAABB(r,n);let i=n.x-r.x,a=n.y-r.y,o=n.z-r.z;t.x=1/12*e*(2*a*2*a+2*o*2*o),t.y=1/12*e*(2*i*2*i+2*o*2*o),t.z=1/12*e*(2*a*2*a+2*i*2*i)}getPlaneConstantOfFace(e){let t=this.faces[e],n=this.faceNormals[e],r=this.vertices[t[0]];return-n.dot(r)}clipFaceAgainstHull(e,t,n,r,i,a,o){let s=new $,c=new $,l=new $,u=new $,d=new $,f=new $,p=new $,m=new $,h=this,g=[],_=r,v=g,y=-1,b=Number.MAX_VALUE;for(let t=0;t<h.faces.length;t++){s.copy(h.faceNormals[t]),n.vmult(s,s);let r=s.dot(e);r<b&&(b=r,y=t)}if(y<0)return;let x=h.faces[y];x.connectedFaces=[];for(let e=0;e<h.faces.length;e++)for(let t=0;t<h.faces[e].length;t++)x.indexOf(h.faces[e][t])!==-1&&e!==y&&x.connectedFaces.indexOf(e)===-1&&x.connectedFaces.push(e);let S=x.length;for(let e=0;e<S;e++){let r=h.vertices[x[e]],i=h.vertices[x[(e+1)%S]];r.vsub(i,c),l.copy(c),n.vmult(l,l),t.vadd(l,l),u.copy(this.faceNormals[y]),n.vmult(u,u),t.vadd(u,u),l.cross(u,d),d.negate(d),f.copy(r),n.vmult(f,f),t.vadd(f,f);let a=x.connectedFaces[e];p.copy(this.faceNormals[a]);let o=this.getPlaneConstantOfFace(a);m.copy(p),n.vmult(m,m);let s=o-m.dot(t);for(this.clipFaceAgainstPlane(_,v,m,s);_.length;)_.shift();for(;v.length;)_.push(v.shift())}p.copy(this.faceNormals[y]);let C=this.getPlaneConstantOfFace(y);m.copy(p),n.vmult(m,m);let w=C-m.dot(t);for(let e=0;e<_.length;e++){let t=m.dot(_[e])+w;if(t<=i&&(console.log(`clamped: depth=${t} to minDist=${i}`),t=i),t<=a){let n=_[e];if(t<=1e-6){let e={point:n,normal:m,depth:t};o.push(e)}}}}clipFaceAgainstPlane(e,t,n,r){let i,a,o=e.length;if(o<2)return t;let s=e[e.length-1],c=e[0];i=n.dot(s)+r;for(let l=0;l<o;l++){if(c=e[l],a=n.dot(c)+r,i<0){if(a<0){let e=new $;e.copy(c),t.push(e)}else{let e=new $;s.lerp(c,i/(i-a),e),t.push(e)}}else if(a<0){let e=new $;s.lerp(c,i/(i-a),e),t.push(e),t.push(c)}s=c,i=a}return t}computeWorldVertices(e,t){for(;this.worldVertices.length<this.vertices.length;)this.worldVertices.push(new $);let n=this.vertices,r=this.worldVertices;for(let i=0;i!==this.vertices.length;i++)t.vmult(n[i],r[i]),e.vadd(r[i],r[i]);this.worldVerticesNeedsUpdate=!1}computeLocalAABB(e,t){let n=this.vertices;e.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let r=0;r<this.vertices.length;r++){let i=n[r];i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y),i.z<e.z?e.z=i.z:i.z>t.z&&(t.z=i.z)}}computeWorldFaceNormals(e){let t=this.faceNormals.length;for(;this.worldFaceNormals.length<t;)this.worldFaceNormals.push(new $);let n=this.faceNormals,r=this.worldFaceNormals;for(let i=0;i!==t;i++)e.vmult(n[i],r[i]);this.worldFaceNormalsNeedsUpdate=!1}updateBoundingSphereRadius(){let e=0,t=this.vertices;for(let n=0;n!==t.length;n++){let r=t[n].lengthSquared();r>e&&(e=r)}this.boundingSphereRadius=Math.sqrt(e)}calculateWorldAABB(e,t,n,r){let i=this.vertices,a,o,s,c,l,u,d=new $;for(let n=0;n<i.length;n++){d.copy(i[n]),t.vmult(d,d),e.vadd(d,d);let r=d;(a===void 0||r.x<a)&&(a=r.x),(c===void 0||r.x>c)&&(c=r.x),(o===void 0||r.y<o)&&(o=r.y),(l===void 0||r.y>l)&&(l=r.y),(s===void 0||r.z<s)&&(s=r.z),(u===void 0||r.z>u)&&(u=r.z)}n.set(a,o,s),r.set(c,l,u)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}getAveragePointLocal(e){e===void 0&&(e=new $);let t=this.vertices;for(let n=0;n<t.length;n++)e.vadd(t[n],e);return e.scale(1/t.length,e),e}transformAllPoints(e,t){let n=this.vertices.length,r=this.vertices;if(t){for(let e=0;e<n;e++){let n=r[e];t.vmult(n,n)}for(let e=0;e<this.faceNormals.length;e++){let n=this.faceNormals[e];t.vmult(n,n)}}if(e)for(let t=0;t<n;t++){let n=r[t];n.vadd(e,n)}}pointIsInside(e){let t=this.vertices,n=this.faces,r=this.faceNormals,i=new $;this.getAveragePointLocal(i);for(let a=0;a<this.faces.length;a++){let o=r[a],s=t[n[a][0]],c=new $;e.vsub(s,c);let l=o.dot(c),u=new $;i.vsub(s,u);let d=o.dot(u);if(l<0&&d>0||l>0&&d<0)return!1}return-1}static project(e,t,n,r,i){let a=e.vertices.length,o=uM,s=0,c=0,l=dM,u=e.vertices;l.setZero(),aM.vectorToLocalFrame(n,r,t,o),aM.pointToLocalFrame(n,r,l,l);let d=l.dot(o);c=s=u[0].dot(o);for(let e=1;e<a;e++){let t=u[e].dot(o);t>s&&(s=t),t<c&&(c=t)}if(c-=d,s-=d,c>s){let e=c;c=s,s=e}i[0]=s,i[1]=c}},cM=[],lM=[],new $,uM=new $,dM=new $,fM=class e extends iM{constructor(e){super({type:iM.types.BOX}),this.halfExtents=e,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}updateConvexPolyhedronRepresentation(){let e=this.halfExtents.x,t=this.halfExtents.y,n=this.halfExtents.z,r=$,i=[new r(-e,-t,-n),new r(e,-t,-n),new r(e,t,-n),new r(-e,t,-n),new r(-e,-t,n),new r(e,-t,n),new r(e,t,n),new r(-e,t,n)],a=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],o=[new r(0,0,1),new r(0,1,0),new r(1,0,0)],s=new sM({vertices:i,faces:a,axes:o});this.convexPolyhedronRepresentation=s,s.material=this.material}calculateLocalInertia(t,n){return n===void 0&&(n=new $),e.calculateInertia(this.halfExtents,t,n),n}static calculateInertia(e,t,n){let r=e;n.x=1/12*t*(2*r.y*2*r.y+2*r.z*2*r.z),n.y=1/12*t*(2*r.x*2*r.x+2*r.z*2*r.z),n.z=1/12*t*(2*r.y*2*r.y+2*r.x*2*r.x)}getSideNormals(e,t){let n=e,r=this.halfExtents;if(n[0].set(r.x,0,0),n[1].set(0,r.y,0),n[2].set(0,0,r.z),n[3].set(-r.x,0,0),n[4].set(0,-r.y,0),n[5].set(0,0,-r.z),t!==void 0)for(let e=0;e!==n.length;e++)t.vmult(n[e],n[e]);return n}volume(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z}updateBoundingSphereRadius(){this.boundingSphereRadius=this.halfExtents.length()}forEachWorldCorner(e,t,n){let r=this.halfExtents,i=[[r.x,r.y,r.z],[-r.x,r.y,r.z],[-r.x,-r.y,r.z],[-r.x,-r.y,-r.z],[r.x,-r.y,-r.z],[r.x,r.y,-r.z],[-r.x,r.y,-r.z],[r.x,-r.y,r.z]];for(let r=0;r<i.length;r++)pM.set(i[r][0],i[r][1],i[r][2]),t.vmult(pM,pM),e.vadd(pM,pM),n(pM.x,pM.y,pM.z)}calculateWorldAABB(e,t,n,r){let i=this.halfExtents;mM[0].set(i.x,i.y,i.z),mM[1].set(-i.x,i.y,i.z),mM[2].set(-i.x,-i.y,i.z),mM[3].set(-i.x,-i.y,-i.z),mM[4].set(i.x,-i.y,-i.z),mM[5].set(i.x,i.y,-i.z),mM[6].set(-i.x,i.y,-i.z),mM[7].set(i.x,-i.y,i.z);let a=mM[0];t.vmult(a,a),e.vadd(a,a),r.copy(a),n.copy(a);for(let i=1;i<8;i++){let a=mM[i];t.vmult(a,a),e.vadd(a,a);let o=a.x,s=a.y,c=a.z;o>r.x&&(r.x=o),s>r.y&&(r.y=s),c>r.z&&(r.z=c),o<n.x&&(n.x=o),s<n.y&&(n.y=s),c<n.z&&(n.z=c)}}},pM=new $,mM=[new $,new $,new $,new $,new $,new $,new $,new $],hM={DYNAMIC:1,STATIC:2,KINEMATIC:4},gM={AWAKE:0,SLEEPY:1,SLEEPING:2},_M=class e extends $j{constructor(t){t===void 0&&(t={}),super(),this.id=e.idCounter++,this.index=-1,this.world=null,this.vlambda=new $,this.collisionFilterGroup=typeof t.collisionFilterGroup==`number`?t.collisionFilterGroup:1,this.collisionFilterMask=typeof t.collisionFilterMask==`number`?t.collisionFilterMask:-1,this.collisionResponse=typeof t.collisionResponse!=`boolean`||t.collisionResponse,this.position=new $,this.previousPosition=new $,this.interpolatedPosition=new $,this.initPosition=new $,t.position&&(this.position.copy(t.position),this.previousPosition.copy(t.position),this.interpolatedPosition.copy(t.position),this.initPosition.copy(t.position)),this.velocity=new $,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new $,this.force=new $;let n=typeof t.mass==`number`?t.mass:0;this.mass=n,this.invMass=n>0?1/n:0,this.material=t.material||null,this.linearDamping=typeof t.linearDamping==`number`?t.linearDamping:.01,this.type=n<=0?e.STATIC:e.DYNAMIC,typeof t.type==typeof e.STATIC&&(this.type=t.type),this.allowSleep=t.allowSleep===void 0||t.allowSleep,this.sleepState=e.AWAKE,this.sleepSpeedLimit=t.sleepSpeedLimit===void 0?.1:t.sleepSpeedLimit,this.sleepTimeLimit=t.sleepTimeLimit===void 0?1:t.sleepTimeLimit,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new $,this.quaternion=new eM,this.initQuaternion=new eM,this.previousQuaternion=new eM,this.interpolatedQuaternion=new eM,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new $,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new $,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new $,this.invInertia=new $,this.invInertiaWorld=new Wj,this.invMassSolve=0,this.invInertiaSolve=new $,this.invInertiaWorldSolve=new Wj,this.fixedRotation=t.fixedRotation!==void 0&&t.fixedRotation,this.angularDamping=t.angularDamping===void 0?.01:t.angularDamping,this.linearFactor=new $(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new $(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new Yj,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new $,this.isTrigger=!!t.isTrigger,t.shape&&this.addShape(t.shape),this.updateMassProperties()}wakeUp(){let t=this.sleepState;this.sleepState=e.AWAKE,this.wakeUpAfterNarrowphase=!1,t===e.SLEEPING&&this.dispatchEvent(e.wakeupEvent)}sleep(){this.sleepState=e.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1}sleepTick(t){if(this.allowSleep){let n=this.sleepState,r=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),i=this.sleepSpeedLimit**2;n===e.AWAKE&&r<i?(this.sleepState=e.SLEEPY,this.timeLastSleepy=t,this.dispatchEvent(e.sleepyEvent)):n===e.SLEEPY&&r>i?this.wakeUp():n===e.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(e.sleepEvent))}}updateSolveMassProperties(){this.sleepState===e.SLEEPING||this.type===e.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))}pointToLocalFrame(e,t){return t===void 0&&(t=new $),e.vsub(this.position,t),this.quaternion.conjugate().vmult(t,t),t}vectorToLocalFrame(e,t){return t===void 0&&(t=new $),this.quaternion.conjugate().vmult(e,t),t}pointToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t.vadd(this.position,t),t}vectorToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t}addShape(e,t,n){let r=new $,i=new eM;return t&&r.copy(t),n&&i.copy(n),this.shapes.push(e),this.shapeOffsets.push(r),this.shapeOrientations.push(i),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=this,this}removeShape(e){let t=this.shapes.indexOf(e);return t===-1?(console.warn(`Shape does not belong to the body`),this):(this.shapes.splice(t,1),this.shapeOffsets.splice(t,1),this.shapeOrientations.splice(t,1),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=null,this)}updateBoundingRadius(){let e=this.shapes,t=this.shapeOffsets,n=e.length,r=0;for(let i=0;i!==n;i++){let n=e[i];n.updateBoundingSphereRadius();let a=t[i].length(),o=n.boundingSphereRadius;a+o>r&&(r=a+o)}this.boundingRadius=r}updateAABB(){let e=this.shapes,t=this.shapeOffsets,n=this.shapeOrientations,r=e.length,i=vM,a=yM,o=this.quaternion,s=this.aabb,c=bM;for(let l=0;l!==r;l++){let r=e[l];o.vmult(t[l],i),i.vadd(this.position,i),o.mult(n[l],a),r.calculateWorldAABB(i,a,c.lowerBound,c.upperBound),l===0?s.copy(c):s.extend(c)}this.aabbNeedsUpdate=!1}updateInertiaWorld(e){let t=this.invInertia;if(t.x!==t.y||t.y!==t.z||e){let e=xM,n=SM;e.setRotationFromQuaternion(this.quaternion),e.transpose(n),e.scale(t,e),e.mmult(n,this.invInertiaWorld)}}applyForce(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;this.sleepState===e.SLEEPING&&this.wakeUp();let r=CM;n.cross(t,r),this.force.vadd(t,this.force),this.torque.vadd(r,this.torque)}applyLocalForce(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;let r=wM,i=TM;this.vectorToWorldFrame(t,r),this.vectorToWorldFrame(n,i),this.applyForce(r,i)}applyTorque(t){this.type===e.DYNAMIC&&(this.sleepState===e.SLEEPING&&this.wakeUp(),this.torque.vadd(t,this.torque))}applyImpulse(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;this.sleepState===e.SLEEPING&&this.wakeUp();let r=n,i=EM;i.copy(t),i.scale(this.invMass,i),this.velocity.vadd(i,this.velocity);let a=DM;r.cross(t,a),this.invInertiaWorld.vmult(a,a),this.angularVelocity.vadd(a,this.angularVelocity)}applyLocalImpulse(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;let r=OM,i=kM;this.vectorToWorldFrame(t,r),this.vectorToWorldFrame(n,i),this.applyImpulse(r,i)}updateMassProperties(){let e=AM;this.invMass=this.mass>0?1/this.mass:0;let t=this.inertia,n=this.fixedRotation;this.updateAABB(),e.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),fM.calculateInertia(e,this.mass,t),this.invInertia.set(t.x>0&&!n?1/t.x:0,t.y>0&&!n?1/t.y:0,t.z>0&&!n?1/t.z:0),this.updateInertiaWorld(!0)}getVelocityAtWorldPoint(e,t){let n=new $;return e.vsub(this.position,n),this.angularVelocity.cross(n,t),this.velocity.vadd(t,t),t}integrate(t,n,r){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),this.type!==e.DYNAMIC&&this.type!==e.KINEMATIC||this.sleepState===e.SLEEPING)return;let i=this.velocity,a=this.angularVelocity,o=this.position,s=this.force,c=this.torque,l=this.quaternion,u=this.invMass,d=this.invInertiaWorld,f=this.linearFactor,p=u*t;i.x+=s.x*p*f.x,i.y+=s.y*p*f.y,i.z+=s.z*p*f.z;let m=d.elements,h=this.angularFactor,g=c.x*h.x,_=c.y*h.y,v=c.z*h.z;a.x+=t*(m[0]*g+m[1]*_+m[2]*v),a.y+=t*(m[3]*g+m[4]*_+m[5]*v),a.z+=t*(m[6]*g+m[7]*_+m[8]*v),o.x+=i.x*t,o.y+=i.y*t,o.z+=i.z*t,l.integrate(this.angularVelocity,t,this.angularFactor,l),n&&(r?l.normalizeFast():l.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}},_M.idCounter=0,_M.COLLIDE_EVENT_NAME=`collide`,_M.DYNAMIC=hM.DYNAMIC,_M.STATIC=hM.STATIC,_M.KINEMATIC=hM.KINEMATIC,_M.AWAKE=gM.AWAKE,_M.SLEEPY=gM.SLEEPY,_M.SLEEPING=gM.SLEEPING,_M.wakeupEvent={type:`wakeup`},_M.sleepyEvent={type:`sleepy`},_M.sleepEvent={type:`sleep`},vM=new $,yM=new eM,bM=new Yj,xM=new Wj,SM=new Wj,new Wj,CM=new $,wM=new $,TM=new $,EM=new $,DM=new $,OM=new $,kM=new $,AM=new $,jM=class{constructor(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}collisionPairs(e,t,n){throw Error(`collisionPairs not implemented for this BroadPhase class!`)}needBroadphaseCollision(e,t){return(e.collisionFilterGroup&t.collisionFilterMask)!==0&&(t.collisionFilterGroup&e.collisionFilterMask)!==0&&((e.type&_M.STATIC)===0&&e.sleepState!==_M.SLEEPING||(t.type&_M.STATIC)===0&&t.sleepState!==_M.SLEEPING)}intersectionTest(e,t,n,r){this.useBoundingBoxes?this.doBoundingBoxBroadphase(e,t,n,r):this.doBoundingSphereBroadphase(e,t,n,r)}doBoundingSphereBroadphase(e,t,n,r){let i=MM;t.position.vsub(e.position,i);let a=(e.boundingRadius+t.boundingRadius)**2;i.lengthSquared()<a&&(n.push(e),r.push(t))}doBoundingBoxBroadphase(e,t,n,r){e.aabbNeedsUpdate&&e.updateAABB(),t.aabbNeedsUpdate&&t.updateAABB(),e.aabb.overlaps(t.aabb)&&(n.push(e),r.push(t))}makePairsUnique(e,t){let n=NM,r=PM,i=FM,a=e.length;for(let n=0;n!==a;n++)r[n]=e[n],i[n]=t[n];e.length=0,t.length=0;for(let e=0;e!==a;e++){let t=r[e].id,a=i[e].id,o=t<a?`${t},${a}`:`${a},${t}`;n[o]=e,n.keys.push(o)}for(let a=0;a!==n.keys.length;a++){let a=n.keys.pop(),o=n[a];e.push(r[o]),t.push(i[o]),delete n[a]}}setWorld(e){}static boundingSphereCheck(e,t){let n=new $;e.position.vsub(t.position,n);let r=e.shapes[0],i=t.shapes[0];return(r.boundingSphereRadius+i.boundingSphereRadius)**2>n.lengthSquared()}aabbQuery(e,t,n){return console.warn(`.aabbQuery is not implemented in this Broadphase subclass.`),[]}},MM=new $,new $,new eM,new $,NM={keys:[]},PM=[],FM=[],new $,new $,new $,IM=class extends jM{constructor(){super()}collisionPairs(e,t,n){let r=e.bodies,i=r.length,a,o;for(let e=0;e!==i;e++)for(let i=0;i!==e;i++)a=r[e],o=r[i],this.needBroadphaseCollision(a,o)&&this.intersectionTest(a,o,t,n)}aabbQuery(e,t,n){n===void 0&&(n=[]);for(let r=0;r<e.bodies.length;r++){let i=e.bodies[r];i.aabbNeedsUpdate&&i.updateAABB(),i.aabb.overlaps(t)&&n.push(i)}return n}},LM=class{constructor(){this.rayFromWorld=new $,this.rayToWorld=new $,this.hitNormalWorld=new $,this.hitPointWorld=new $,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(e,t,n,r,i,a,o){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(r),this.shape=i,this.body=a,this.distance=o}},GM={CLOSEST:1,ANY:2,ALL:4},RM=iM.types.SPHERE,zM=iM.types.PLANE,BM=iM.types.BOX,VM=iM.types.CYLINDER,HM=iM.types.CONVEXPOLYHEDRON,UM=iM.types.HEIGHTFIELD,WM=iM.types.TRIMESH,KM=class e{get[RM](){return this._intersectSphere}get[zM](){return this._intersectPlane}get[BM](){return this._intersectBox}get[VM](){return this._intersectConvex}get[HM](){return this._intersectConvex}get[UM](){return this._intersectHeightfield}get[WM](){return this._intersectTrimesh}constructor(t,n){t===void 0&&(t=new $),n===void 0&&(n=new $),this.from=t.clone(),this.to=n.clone(),this.direction=new $,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=e.ANY,this.result=new LM,this.hasHit=!1,this.callback=e=>{}}intersectWorld(t,n){return this.mode=n.mode||e.ANY,this.result=n.result||new LM,this.skipBackfaces=!!n.skipBackfaces,this.collisionFilterMask=n.collisionFilterMask===void 0?-1:n.collisionFilterMask,this.collisionFilterGroup=n.collisionFilterGroup===void 0?-1:n.collisionFilterGroup,this.checkCollisionResponse=n.checkCollisionResponse===void 0||n.checkCollisionResponse,n.from&&this.from.copy(n.from),n.to&&this.to.copy(n.to),this.callback=n.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(qM),JM.length=0,t.broadphase.aabbQuery(t,qM,JM),this.intersectBodies(JM),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());let n=this.checkCollisionResponse;if(n&&!e.collisionResponse||(this.collisionFilterGroup&e.collisionFilterMask)===0||(e.collisionFilterGroup&this.collisionFilterMask)===0)return;let r=ZM,i=QM;for(let t=0,a=e.shapes.length;t<a;t++){let a=e.shapes[t];if((!n||a.collisionResponse)&&(e.quaternion.mult(e.shapeOrientations[t],i),e.quaternion.vmult(e.shapeOffsets[t],r),r.vadd(e.position,r),this.intersectShape(a,i,r,e),this.result.shouldStop))break}}intersectBodies(e,t){t&&(this.result=t,this.updateDirection());for(let t=0,n=e.length;!this.result.shouldStop&&t<n;t++)this.intersectBody(e[t])}updateDirection(){this.to.vsub(this.from,this.direction),this.direction.normalize()}intersectShape(e,t,n,r){let i=this.from;if(Bj(i,this.direction,n)>e.boundingSphereRadius)return;let a=this[e.type];a&&a.call(this,e,t,n,r,e)}_intersectBox(e,t,n,r,i){return this._intersectConvex(e.convexPolyhedronRepresentation,t,n,r,i)}_intersectPlane(e,t,n,r,i){let a=this.from,o=this.to,s=this.direction,c=new $(0,0,1);t.vmult(c,c);let l=new $;a.vsub(n,l);let u=l.dot(c);if(o.vsub(n,l),u*l.dot(c)>0||a.distanceTo(o)<u)return;let d=c.dot(s);if(Math.abs(d)<this.precision)return;let f=new $,p=new $,m=new $;a.vsub(n,f);let h=-c.dot(f)/d;s.scale(h,p),a.vadd(p,m),this.reportIntersection(c,m,i,r,-1)}getAABB(e){let{lowerBound:t,upperBound:n}=e,r=this.to,i=this.from;t.x=Math.min(r.x,i.x),t.y=Math.min(r.y,i.y),t.z=Math.min(r.z,i.z),n.x=Math.max(r.x,i.x),n.y=Math.max(r.y,i.y),n.z=Math.max(r.z,i.z)}_intersectHeightfield(e,t,n,r,i){e.data,e.elementSize;let a=aN;a.from.copy(this.from),a.to.copy(this.to),aM.pointToLocalFrame(n,t,a.from,a.from),aM.pointToLocalFrame(n,t,a.to,a.to),a.updateDirection();let o=oN,s,c,l,u;s=c=0,l=u=e.data.length-1;let d=new Yj;a.getAABB(d),e.getIndexOfPosition(d.lowerBound.x,d.lowerBound.y,o,!0),s=Math.max(s,o[0]),c=Math.max(c,o[1]),e.getIndexOfPosition(d.upperBound.x,d.upperBound.y,o,!0),l=Math.min(l,o[0]+1),u=Math.min(u,o[1]+1);for(let o=s;o<l;o++)for(let s=c;s<u;s++){if(this.result.shouldStop)return;if(e.getAabbAtIndex(o,s,d),d.overlapsRay(a)){if(e.getConvexTrianglePillar(o,s,!1),aM.pointToWorldFrame(n,t,e.pillarOffset,iN),this._intersectConvex(e.pillarConvex,t,iN,r,i,rN),this.result.shouldStop)return;e.getConvexTrianglePillar(o,s,!0),aM.pointToWorldFrame(n,t,e.pillarOffset,iN),this._intersectConvex(e.pillarConvex,t,iN,r,i,rN)}}}_intersectSphere(e,t,n,r,i){let a=this.from,o=this.to,s=e.radius,c=(o.x-a.x)**2+(o.y-a.y)**2+(o.z-a.z)**2,l=2*((o.x-a.x)*(a.x-n.x)+(o.y-a.y)*(a.y-n.y)+(o.z-a.z)*(a.z-n.z)),u=(a.x-n.x)**2+(a.y-n.y)**2+(a.z-n.z)**2-s**2,d=l**2-4*c*u,f=sN,p=cN;if(!(d<0)){if(d===0)a.lerp(o,d,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1);else{let e=(-l-Math.sqrt(d))/(2*c),t=(-l+Math.sqrt(d))/(2*c);if(e>=0&&e<=1&&(a.lerp(o,e,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1)),this.result.shouldStop)return;t>=0&&t<=1&&(a.lerp(o,t,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1))}}}_intersectConvex(t,n,r,i,a,o){let s=lN,c=uN,l=o&&o.faceList||null,u=t.faces,d=t.vertices,f=t.faceNormals,p=this.direction,m=this.from,h=this.to,g=m.distanceTo(h),_=l?l.length:u.length,v=this.result;for(let t=0;!v.shouldStop&&t<_;t++){let o=l?l[t]:t,h=u[o],_=f[o],y=n,b=r;c.copy(d[h[0]]),y.vmult(c,c),c.vadd(b,c),c.vsub(m,c),y.vmult(_,s);let x=p.dot(s);if(Math.abs(x)<this.precision)continue;let S=s.dot(c)/x;if(!(S<0)){p.scale(S,$M),$M.vadd(m,$M),eN.copy(d[h[0]]),y.vmult(eN,eN),b.vadd(eN,eN);for(let t=1;!v.shouldStop&&t<h.length-1;t++){tN.copy(d[h[t]]),nN.copy(d[h[t+1]]),y.vmult(tN,tN),y.vmult(nN,nN),b.vadd(tN,tN),b.vadd(nN,nN);let n=$M.distanceTo(m);!(e.pointInTriangle($M,eN,tN,nN)||e.pointInTriangle($M,tN,eN,nN))||n>g||this.reportIntersection(s,$M,a,i,o)}}}}_intersectTrimesh(t,n,r,i,a,o){let s=dN,c=_N,l=vN,u=uN,d=fN,f=pN,p=mN,m=gN,h=hN,g=t.indices;t.vertices;let _=this.from,v=this.to,y=this.direction;l.position.copy(r),l.quaternion.copy(n),aM.vectorToLocalFrame(r,n,y,d),aM.pointToLocalFrame(r,n,_,f),aM.pointToLocalFrame(r,n,v,p),p.x*=t.scale.x,p.y*=t.scale.y,p.z*=t.scale.z,f.x*=t.scale.x,f.y*=t.scale.y,f.z*=t.scale.z,p.vsub(f,d),d.normalize();let b=f.distanceSquared(p);t.tree.rayQuery(this,l,c);for(let o=0,l=c.length;!this.result.shouldStop&&o!==l;o++){let l=c[o];t.getNormal(l,s),t.getVertex(g[l*3],eN),eN.vsub(f,u);let p=d.dot(s),_=s.dot(u)/p;if(_<0)continue;d.scale(_,$M),$M.vadd(f,$M),t.getVertex(g[l*3+1],tN),t.getVertex(g[l*3+2],nN);let v=$M.distanceSquared(f);!(e.pointInTriangle($M,tN,eN,nN)||e.pointInTriangle($M,eN,tN,nN))||v>b||(aM.vectorToWorldFrame(n,s,h),aM.pointToWorldFrame(r,n,$M,m),this.reportIntersection(h,m,a,i,l))}c.length=0}reportIntersection(t,n,r,i,a){let o=this.from,s=this.to,c=o.distanceTo(n),l=this.result;if(!(this.skipBackfaces&&t.dot(this.direction)>0))switch(l.hitFaceIndex=a===void 0?-1:a,this.mode){case e.ALL:this.hasHit=!0,l.set(o,s,t,n,r,i,c),l.hasHit=!0,this.callback(l);break;case e.CLOSEST:(c<l.distance||!l.hasHit)&&(this.hasHit=!0,l.hasHit=!0,l.set(o,s,t,n,r,i,c));break;case e.ANY:this.hasHit=!0,l.hasHit=!0,l.set(o,s,t,n,r,i,c),l.shouldStop=!0}}static pointInTriangle(e,t,n,r){r.vsub(t,yN),n.vsub(t,YM),e.vsub(t,XM);let i=yN.dot(yN),a=yN.dot(YM),o=yN.dot(XM),s=YM.dot(YM),c=YM.dot(XM),l,u;return(l=s*o-a*c)>=0&&(u=i*c-a*o)>=0&&l+u<i*s-a*a}},KM.CLOSEST=GM.CLOSEST,KM.ANY=GM.ANY,KM.ALL=GM.ALL,qM=new Yj,JM=[],YM=new $,XM=new $,ZM=new $,QM=new eM,$M=new $,eN=new $,tN=new $,nN=new $,new $,new LM,rN={faceList:[0]},iN=new $,aN=new KM,oN=[],sN=new $,cN=new $,lN=new $,new $,new $,uN=new $,dN=new $,fN=new $,pN=new $,mN=new $,hN=new $,gN=new $,new Yj,_N=[],vN=new aM,yN=new $,bN=new $,xN=class{static defaults(e,t){e===void 0&&(e={});for(let n in t)n in e||(e[n]=t[n]);return e}},SN=class e{constructor(t,n,r){r===void 0&&(r={}),r=xN.defaults(r,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=n,this.id=e.idCounter++,this.collideConnected=r.collideConnected,r.wakeUpBodies&&(t&&t.wakeUp(),n&&n.wakeUp())}update(){throw Error(`method update() not implmemented in this Constraint subclass!`)}enable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!0}disable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!1}},SN.idCounter=0,CN=class{constructor(){this.spatial=new $,this.rotational=new $}multiplyElement(e){return e.spatial.dot(this.spatial)+e.rotational.dot(this.rotational)}multiplyVectors(e,t){return e.dot(this.spatial)+t.dot(this.rotational)}},wN=class e{constructor(t,n,r,i){r===void 0&&(r=-1e6),i===void 0&&(i=1e6),this.id=e.idCounter++,this.minForce=r,this.maxForce=i,this.bi=t,this.bj=n,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new CN,this.jacobianElementB=new CN,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}setSpookParams(e,t,n){let r=t,i=e,a=n;this.a=4/(a*(1+4*r)),this.b=4*r/(1+4*r),this.eps=4/(a*a*i*(1+4*r))}computeB(e,t,n){let r=this.computeGW(),i=this.computeGq(),a=this.computeGiMf();return-i*e-r*t-a*n}computeGq(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.position,a=r.position;return e.spatial.dot(i)+t.spatial.dot(a)}computeGW(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.velocity,a=r.velocity,o=n.angularVelocity,s=r.angularVelocity;return e.multiplyVectors(i,o)+t.multiplyVectors(a,s)}computeGWlambda(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.vlambda,a=r.vlambda,o=n.wlambda,s=r.wlambda;return e.multiplyVectors(i,o)+t.multiplyVectors(a,s)}computeGiMf(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.force,a=n.torque,o=r.force,s=r.torque,c=n.invMassSolve,l=r.invMassSolve;return i.scale(c,TN),o.scale(l,EN),n.invInertiaWorldSolve.vmult(a,DN),r.invInertiaWorldSolve.vmult(s,ON),e.multiplyVectors(TN,DN)+t.multiplyVectors(EN,ON)}computeGiMGt(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.invMassSolve,a=r.invMassSolve,o=n.invInertiaWorldSolve,s=r.invInertiaWorldSolve,c=i+a;return o.vmult(e.rotational,kN),c+=kN.dot(e.rotational),s.vmult(t.rotational,kN),c+=kN.dot(t.rotational),c}addToWlambda(e){let t=this.jacobianElementA,n=this.jacobianElementB,r=this.bi,i=this.bj,a=AN;r.vlambda.addScaledVector(r.invMassSolve*e,t.spatial,r.vlambda),i.vlambda.addScaledVector(i.invMassSolve*e,n.spatial,i.vlambda),r.invInertiaWorldSolve.vmult(t.rotational,a),r.wlambda.addScaledVector(e,a,r.wlambda),i.invInertiaWorldSolve.vmult(n.rotational,a),i.wlambda.addScaledVector(e,a,i.wlambda)}computeC(){return this.computeGiMGt()+this.eps}},wN.idCounter=0,TN=new $,EN=new $,DN=new $,ON=new $,kN=new $,AN=new $,jN=class extends wN{constructor(e,t,n){n===void 0&&(n=1e6),super(e,t,0,n),this.restitution=0,this.ri=new $,this.rj=new $,this.ni=new $}computeB(e){let t=this.a,n=this.b,r=this.bi,i=this.bj,a=this.ri,o=this.rj,s=MN,c=NN,l=r.velocity,u=r.angularVelocity;r.force,r.torque;let d=i.velocity,f=i.angularVelocity;i.force,i.torque;let p=PN,m=this.jacobianElementA,h=this.jacobianElementB,g=this.ni;a.cross(g,s),o.cross(g,c),g.negate(m.spatial),s.negate(m.rotational),h.spatial.copy(g),h.rotational.copy(c),p.copy(i.position),p.vadd(o,p),p.vsub(r.position,p),p.vsub(a,p);let _=g.dot(p),v=this.restitution+1,y=v*d.dot(g)-v*l.dot(g)+f.dot(c)-u.dot(s),b=this.computeGiMf();return-_*t-y*n-e*b}getImpactVelocityAlongNormal(){let e=FN,t=IN,n=LN,r=RN,i=zN;return this.bi.position.vadd(this.ri,n),this.bj.position.vadd(this.rj,r),this.bi.getVelocityAtWorldPoint(n,e),this.bj.getVelocityAtWorldPoint(r,t),e.vsub(t,i),this.ni.dot(i)}},MN=new $,NN=new $,PN=new $,FN=new $,IN=new $,LN=new $,RN=new $,zN=new $,BN=class extends SN{constructor(e,t,n,r,i){t===void 0&&(t=new $),r===void 0&&(r=new $),i===void 0&&(i=1e6),super(e,n),this.pivotA=t.clone(),this.pivotB=r.clone();let a=this.equationX=new jN(e,n),o=this.equationY=new jN(e,n),s=this.equationZ=new jN(e,n);this.equations.push(a,o,s),a.minForce=o.minForce=s.minForce=-i,a.maxForce=o.maxForce=s.maxForce=i,a.ni.set(1,0,0),o.ni.set(0,1,0),s.ni.set(0,0,1)}update(){let e=this.bodyA,t=this.bodyB,n=this.equationX,r=this.equationY,i=this.equationZ;e.quaternion.vmult(this.pivotA,n.ri),t.quaternion.vmult(this.pivotB,n.rj),r.ri.copy(n.ri),r.rj.copy(n.rj),i.ri.copy(n.ri),i.rj.copy(n.rj)}},new $,new $,VN=class extends wN{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce;super(e,t,-r,r),this.axisA=n.axisA?n.axisA.clone():new $(1,0,0),this.axisB=n.axisB?n.axisB.clone():new $(0,1,0),this.maxAngle=Math.PI/2}computeB(e){let t=this.a,n=this.b,r=this.axisA,i=this.axisB,a=HN,o=UN,s=this.jacobianElementA,c=this.jacobianElementB;r.cross(i,a),i.cross(r,o),s.rotational.copy(o),c.rotational.copy(a);let l=Math.cos(this.maxAngle)-r.dot(i),u=this.computeGW(),d=this.computeGiMf();return-l*t-u*n-e*d}},HN=new $,UN=new $,new $,new $,WN=class extends SN{constructor(e,t,n,r){r===void 0&&(r=1e6),super(e,t),n===void 0&&(n=e.position.distanceTo(t.position)),this.distance=n;let i=this.distanceEquation=new jN(e,t);this.equations.push(i),i.minForce=-r,i.maxForce=r}update(){let e=this.bodyA,t=this.bodyB,n=this.distanceEquation,r=this.distance*.5,i=n.ni;t.position.vsub(e.position,i),i.normalize(),i.scale(r,n.ri),i.scale(-r,n.rj)}},GN=class extends BN{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce,i=new $,a=new $,o=new $;e.position.vadd(t.position,o),o.scale(.5,o),t.pointToLocalFrame(o,a),e.pointToLocalFrame(o,i),super(e,i,t,a,r),this.xA=e.vectorToLocalFrame($.UNIT_X),this.xB=t.vectorToLocalFrame($.UNIT_X),this.yA=e.vectorToLocalFrame($.UNIT_Y),this.yB=t.vectorToLocalFrame($.UNIT_Y),this.zA=e.vectorToLocalFrame($.UNIT_Z),this.zB=t.vectorToLocalFrame($.UNIT_Z);let s=this.rotationalEquation1=new VN(e,t,n),c=this.rotationalEquation2=new VN(e,t,n),l=this.rotationalEquation3=new VN(e,t,n);this.equations.push(s,c,l)}update(){let e=this.bodyA,t=this.bodyB;this.motorEquation;let n=this.rotationalEquation1,r=this.rotationalEquation2,i=this.rotationalEquation3;super.update(),e.vectorToWorldFrame(this.xA,n.axisA),t.vectorToWorldFrame(this.yB,n.axisB),e.vectorToWorldFrame(this.yA,r.axisA),t.vectorToWorldFrame(this.zB,r.axisB),e.vectorToWorldFrame(this.zA,i.axisA),t.vectorToWorldFrame(this.xB,i.axisB)}},new $,new $,KN=class extends wN{constructor(e,t,n){n===void 0&&(n=1e6),super(e,t,-n,n),this.axisA=new $,this.axisB=new $,this.targetVelocity=0}computeB(e){this.a;let t=this.b;this.bi,this.bj;let n=this.axisA,r=this.axisB,i=this.jacobianElementA,a=this.jacobianElementB;i.rotational.copy(n),r.negate(a.rotational);let o=this.computeGW()-this.targetVelocity,s=this.computeGiMf();return-o*t-e*s}},qN=class extends BN{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce,i=n.pivotA?n.pivotA.clone():new $,a=n.pivotB?n.pivotB.clone():new $;super(e,i,t,a,r),(this.axisA=n.axisA?n.axisA.clone():new $(1,0,0)).normalize(),(this.axisB=n.axisB?n.axisB.clone():new $(1,0,0)).normalize(),this.collideConnected=!!n.collideConnected;let o=this.rotationalEquation1=new VN(e,t,n),s=this.rotationalEquation2=new VN(e,t,n),c=this.motorEquation=new KN(e,t,r);c.enabled=!1,this.equations.push(o,s,c)}enableMotor(){this.motorEquation.enabled=!0}disableMotor(){this.motorEquation.enabled=!1}setMotorSpeed(e){this.motorEquation.targetVelocity=e}setMotorMaxForce(e){this.motorEquation.maxForce=e,this.motorEquation.minForce=-e}update(){let e=this.bodyA,t=this.bodyB,n=this.motorEquation,r=this.rotationalEquation1,i=this.rotationalEquation2,a=JN,o=YN,s=this.axisA,c=this.axisB;super.update(),e.quaternion.vmult(s,a),t.quaternion.vmult(c,o),a.tangents(r.axisA,i.axisA),r.axisB.copy(o),i.axisB.copy(o),this.motorEquation.enabled&&(e.quaternion.vmult(this.axisA,n.axisA),t.quaternion.vmult(this.axisB,n.axisB))}},JN=new $,YN=new $,XN=class extends wN{constructor(e,t,n){super(e,t,-n,n),this.ri=new $,this.rj=new $,this.t=new $}computeB(e){this.a;let t=this.b;this.bi,this.bj;let n=this.ri,r=this.rj,i=ZN,a=QN,o=this.t;n.cross(o,i),r.cross(o,a);let s=this.jacobianElementA,c=this.jacobianElementB;o.negate(s.spatial),i.negate(s.rotational),c.spatial.copy(o),c.rotational.copy(a);let l=this.computeGW(),u=this.computeGiMf();return-l*t-e*u}},ZN=new $,QN=new $,$N=class e{constructor(t,n,r){r=xN.defaults(r,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=e.idCounter++,this.materials=[t,n],this.friction=r.friction,this.restitution=r.restitution,this.contactEquationStiffness=r.contactEquationStiffness,this.contactEquationRelaxation=r.contactEquationRelaxation,this.frictionEquationStiffness=r.frictionEquationStiffness,this.frictionEquationRelaxation=r.frictionEquationRelaxation}},$N.idCounter=0,eP=class e{constructor(t){t===void 0&&(t={});let n=``;typeof t==`string`&&(n=t,t={}),this.name=n,this.id=e.idCounter++,this.friction=t.friction===void 0?-1:t.friction,this.restitution=t.restitution===void 0?-1:t.restitution}},eP.idCounter=0,tP=class{constructor(e,t,n){n===void 0&&(n={}),this.restLength=typeof n.restLength==`number`?n.restLength:1,this.stiffness=n.stiffness||100,this.damping=n.damping||1,this.bodyA=e,this.bodyB=t,this.localAnchorA=new $,this.localAnchorB=new $,n.localAnchorA&&this.localAnchorA.copy(n.localAnchorA),n.localAnchorB&&this.localAnchorB.copy(n.localAnchorB),n.worldAnchorA&&this.setWorldAnchorA(n.worldAnchorA),n.worldAnchorB&&this.setWorldAnchorB(n.worldAnchorB)}setWorldAnchorA(e){this.bodyA.pointToLocalFrame(e,this.localAnchorA)}setWorldAnchorB(e){this.bodyB.pointToLocalFrame(e,this.localAnchorB)}getWorldAnchorA(e){this.bodyA.pointToWorldFrame(this.localAnchorA,e)}getWorldAnchorB(e){this.bodyB.pointToWorldFrame(this.localAnchorB,e)}applyForce(){let e=this.stiffness,t=this.damping,n=this.restLength,r=this.bodyA,i=this.bodyB,a=nP,o=rP,s=iP,c=aP,l=fP,u=oP,d=sP,f=cP,p=lP,m=uP,h=dP;this.getWorldAnchorA(u),this.getWorldAnchorB(d),u.vsub(r.position,f),d.vsub(i.position,p),d.vsub(u,a);let g=a.length();o.copy(a),o.normalize(),i.velocity.vsub(r.velocity,s),i.angularVelocity.cross(p,l),s.vadd(l,s),r.angularVelocity.cross(f,l),s.vsub(l,s),o.scale(-e*(g-n)-t*s.dot(o),c),r.force.vsub(c,r.force),i.force.vadd(c,i.force),f.cross(c,m),p.cross(c,h),r.torque.vsub(m,r.torque),i.torque.vadd(h,i.torque)}},nP=new $,rP=new $,iP=new $,aP=new $,oP=new $,sP=new $,cP=new $,lP=new $,uP=new $,dP=new $,fP=new $,new $,new $,new $,new $,new $,new $,new $,new $,new KM,new $,new $,new $,new $(1,0,0),new $(0,1,0),new $(0,0,1),new $,new $,new $,new $,new $,new $,new $,new $,new $,new $,new $,pP=class extends iM{constructor(e){if(super({type:iM.types.SPHERE}),this.radius=e===void 0?1:e,this.radius<0)throw Error(`The sphere radius cannot be negative.`);this.updateBoundingSphereRadius()}calculateLocalInertia(e,t){t===void 0&&(t=new $);let n=2*e*this.radius*this.radius/5;return t.x=n,t.y=n,t.z=n,t}volume(){return 4*Math.PI*this.radius**3/3}updateBoundingSphereRadius(){this.boundingSphereRadius=this.radius}calculateWorldAABB(e,t,n,r){let i=this.radius,a=[`x`,`y`,`z`];for(let t=0;t<a.length;t++){let o=a[t];n[o]=e[o]-i,r[o]=e[o]+i}}},new $,new $,new $,new $,new $,new $,new $,new $,new $,mP=class extends sM{constructor(e,t,n,r){if(e===void 0&&(e=1),t===void 0&&(t=1),n===void 0&&(n=1),r===void 0&&(r=8),e<0)throw Error(`The cylinder radiusTop cannot be negative.`);if(t<0)throw Error(`The cylinder radiusBottom cannot be negative.`);let i=r,a=[],o=[],s=[],c=[],l=[],u=Math.cos,d=Math.sin;a.push(new $(-t*d(0),-n*.5,t*u(0))),c.push(0),a.push(new $(-e*d(0),n*.5,e*u(0))),l.push(1);for(let r=0;r<i;r++){let f=2*Math.PI/i*(r+1),p=2*Math.PI/i*(r+.5);r<i-1?(a.push(new $(-t*d(f),-n*.5,t*u(f))),c.push(2*r+2),a.push(new $(-e*d(f),n*.5,e*u(f))),l.push(2*r+3),s.push([2*r,2*r+1,2*r+3,2*r+2])):s.push([2*r,2*r+1,1,0]),(i%2==1||r<i/2)&&o.push(new $(-d(p),0,u(p)))}s.push(c),o.push(new $(0,1,0));let f=[];for(let e=0;e<l.length;e++)f.push(l[l.length-e-1]);s.push(f),super({vertices:a,faces:s,axes:o}),this.type=iM.types.CYLINDER,this.radiusTop=e,this.radiusBottom=t,this.height=n,this.numSegments=r}},new $,hP=class extends iM{constructor(e,t){t===void 0&&(t={}),t=xN.defaults(t,{maxValue:null,minValue:null,elementSize:1}),super({type:iM.types.HEIGHTFIELD}),this.data=e,this.maxValue=t.maxValue,this.minValue=t.minValue,this.elementSize=t.elementSize,t.minValue===null&&this.updateMinValue(),t.maxValue===null&&this.updateMaxValue(),this.cacheEnabled=!0,this.pillarConvex=new sM,this.pillarOffset=new $,this.updateBoundingSphereRadius(),this._cachedPillars={}}update(){this._cachedPillars={}}updateMinValue(){let e=this.data,t=e[0][0];for(let n=0;n!==e.length;n++)for(let r=0;r!==e[n].length;r++){let i=e[n][r];i<t&&(t=i)}this.minValue=t}updateMaxValue(){let e=this.data,t=e[0][0];for(let n=0;n!==e.length;n++)for(let r=0;r!==e[n].length;r++){let i=e[n][r];i>t&&(t=i)}this.maxValue=t}setHeightValueAtIndex(e,t,n){let r=this.data;r[e][t]=n,this.clearCachedConvexTrianglePillar(e,t,!1),e>0&&(this.clearCachedConvexTrianglePillar(e-1,t,!0),this.clearCachedConvexTrianglePillar(e-1,t,!1)),t>0&&(this.clearCachedConvexTrianglePillar(e,t-1,!0),this.clearCachedConvexTrianglePillar(e,t-1,!1)),t>0&&e>0&&this.clearCachedConvexTrianglePillar(e-1,t-1,!0)}getRectMinMax(e,t,n,r,i){i===void 0&&(i=[]);let a=this.data,o=this.minValue;for(let i=e;i<=n;i++)for(let e=t;e<=r;e++){let t=a[i][e];t>o&&(o=t)}i[0]=this.minValue,i[1]=o}getIndexOfPosition(e,t,n,r){let i=this.elementSize,a=this.data,o=Math.floor(e/i),s=Math.floor(t/i);return n[0]=o,n[1]=s,r&&(o<0&&(o=0),s<0&&(s=0),o>=a.length-1&&(o=a.length-1),s>=a[0].length-1&&(s=a[0].length-1)),!(o<0||s<0||o>=a.length-1||s>=a[0].length-1)}getTriangleAt(e,t,n,r,i,a){let o=gP;this.getIndexOfPosition(e,t,o,n);let s=o[0],c=o[1],l=this.data;n&&(s=Math.min(l.length-2,Math.max(0,s)),c=Math.min(l[0].length-2,Math.max(0,c)));let u=this.elementSize,d=(e/u-s)**2+(t/u-c)**2>(e/u-(s+1))**2+(t/u-(c+1))**2;return this.getTriangle(s,c,d,r,i,a),d}getNormalAt(e,t,n,r){let i=xP,a=SP,o=CP,s=wP,c=TP;this.getTriangleAt(e,t,n,i,a,o),a.vsub(i,s),o.vsub(i,c),s.cross(c,r),r.normalize()}getAabbAtIndex(e,t,n){let{lowerBound:r,upperBound:i}=n,a=this.data,o=this.elementSize;r.set(e*o,t*o,a[e][t]),i.set((e+1)*o,(t+1)*o,a[e+1][t+1])}getHeightAt(e,t,n){let r=this.data,i=vP,a=yP,o=bP,s=gP;this.getIndexOfPosition(e,t,s,n);let c=s[0],l=s[1];n&&(c=Math.min(r.length-2,Math.max(0,c)),l=Math.min(r[0].length-2,Math.max(0,l)));let u=this.getTriangleAt(e,t,n,i,a,o);Vj(e,t,i.x,i.y,a.x,a.y,o.x,o.y,_P);let d=_P;return u?r[c+1][l+1]*d.x+r[c][l+1]*d.y+r[c+1][l]*d.z:r[c][l]*d.x+r[c+1][l]*d.y+r[c][l+1]*d.z}getCacheConvexTrianglePillarKey(e,t,n){return`${e}_${t}_${+!!n}`}getCachedConvexTrianglePillar(e,t,n){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]}setCachedConvexTrianglePillar(e,t,n,r,i){this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]={convex:r,offset:i}}clearCachedConvexTrianglePillar(e,t,n){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]}getTriangle(e,t,n,r,i,a){let o=this.data,s=this.elementSize;n?(r.set((e+1)*s,(t+1)*s,o[e+1][t+1]),i.set(e*s,(t+1)*s,o[e][t+1]),a.set((e+1)*s,t*s,o[e+1][t])):(r.set(e*s,t*s,o[e][t]),i.set((e+1)*s,t*s,o[e+1][t]),a.set(e*s,(t+1)*s,o[e][t+1]))}getConvexTrianglePillar(e,t,n){let r=this.pillarConvex,i=this.pillarOffset;if(this.cacheEnabled){let a=this.getCachedConvexTrianglePillar(e,t,n);if(a){this.pillarConvex=a.convex,this.pillarOffset=a.offset;return}r=new sM,i=new $,this.pillarConvex=r,this.pillarOffset=i}let a=this.data,o=this.elementSize,s=r.faces;r.vertices.length=6;for(let e=0;e<6;e++)r.vertices[e]||(r.vertices[e]=new $);s.length=5;for(let e=0;e<5;e++)s[e]||(s[e]=[]);let c=r.vertices,l=(Math.min(a[e][t],a[e+1][t],a[e][t+1],a[e+1][t+1])-this.minValue)/2+this.minValue;n?(i.set((e+.75)*o,(t+.75)*o,l),c[0].set(.25*o,.25*o,a[e+1][t+1]-l),c[1].set(-.75*o,.25*o,a[e][t+1]-l),c[2].set(.25*o,-.75*o,a[e+1][t]-l),c[3].set(.25*o,.25*o,-Math.abs(l)-1),c[4].set(-.75*o,.25*o,-Math.abs(l)-1),c[5].set(.25*o,-.75*o,-Math.abs(l)-1),s[0][0]=0,s[0][1]=1,s[0][2]=2,s[1][0]=5,s[1][1]=4,s[1][2]=3,s[2][0]=2,s[2][1]=5,s[2][2]=3,s[2][3]=0,s[3][0]=3,s[3][1]=4,s[3][2]=1,s[3][3]=0,s[4][0]=1,s[4][1]=4,s[4][2]=5,s[4][3]=2):(i.set((e+.25)*o,(t+.25)*o,l),c[0].set(-.25*o,-.25*o,a[e][t]-l),c[1].set(.75*o,-.25*o,a[e+1][t]-l),c[2].set(-.25*o,.75*o,a[e][t+1]-l),c[3].set(-.25*o,-.25*o,-Math.abs(l)-1),c[4].set(.75*o,-.25*o,-Math.abs(l)-1),c[5].set(-.25*o,.75*o,-Math.abs(l)-1),s[0][0]=0,s[0][1]=1,s[0][2]=2,s[1][0]=5,s[1][1]=4,s[1][2]=3,s[2][0]=0,s[2][1]=2,s[2][2]=5,s[2][3]=3,s[3][0]=1,s[3][1]=0,s[3][2]=3,s[3][3]=4,s[4][0]=4,s[4][1]=5,s[4][2]=2,s[4][3]=1),r.computeNormals(),r.computeEdges(),r.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(e,t,n,r,i)}calculateLocalInertia(e,t){return t===void 0&&(t=new $),t.set(0,0,0),t}volume(){return Number.MAX_VALUE}calculateWorldAABB(e,t,n,r){n.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}updateBoundingSphereRadius(){let e=this.data,t=this.elementSize;this.boundingSphereRadius=new $(e.length*t,e[0].length*t,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).length()}setHeightsFromImage(e,t){let{x:n,z:r,y:i}=t,a=document.createElement(`canvas`);a.width=e.width,a.height=e.height;let o=a.getContext(`2d`);o.drawImage(e,0,0);let s=o.getImageData(0,0,e.width,e.height),c=this.data;c.length=0,this.elementSize=Math.abs(n)/s.width;for(let e=0;e<s.height;e++){let t=[];for(let i=0;i<s.width;i++){let a=s.data[(e*s.height+i)*4],o=s.data[(e*s.height+i)*4+1],c=s.data[(e*s.height+i)*4+2],l=(a+o+c)/4/255*r;n<0?t.push(l):t.unshift(l)}i<0?c.unshift(t):c.push(t)}this.updateMaxValue(),this.updateMinValue(),this.update()}},gP=[],_P=new $,vP=new $,yP=new $,bP=new $,xP=new $,SP=new $,CP=new $,wP=new $,TP=new $,new $,new Yj,new $,new Yj,new $,new $,new $,new $,new $,new $,new $,new Yj,new $,new aM,new Yj,EP=class{constructor(){this.equations=[]}solve(e,t){return 0}addEquation(e){e.enabled&&!e.bi.isTrigger&&!e.bj.isTrigger&&this.equations.push(e)}removeEquation(e){let t=this.equations,n=t.indexOf(e);n!==-1&&t.splice(n,1)}removeAllEquations(){this.equations.length=0}},DP=class extends EP{constructor(){super(),this.iterations=10,this.tolerance=1e-7}solve(e,t){let n=0,r=this.iterations,i=this.tolerance*this.tolerance,a=this.equations,o=a.length,s=t.bodies,c=s.length,l=e,u,d,f,p,m,h;if(o!==0)for(let e=0;e!==c;e++)s[e].updateSolveMassProperties();let g=kP,_=AP,v=OP;g.length=o,_.length=o,v.length=o;for(let e=0;e!==o;e++){let t=a[e];v[e]=0,_[e]=t.computeB(l),g[e]=1/t.computeC()}if(o!==0){for(let e=0;e!==c;e++){let t=s[e],n=t.vlambda,r=t.wlambda;n.set(0,0,0),r.set(0,0,0)}for(n=0;n!==r;n++){p=0;for(let e=0;e!==o;e++){let t=a[e];u=_[e],d=g[e],h=v[e],m=t.computeGWlambda(),f=d*(u-m-t.eps*h),h+f<t.minForce?f=t.minForce-h:h+f>t.maxForce&&(f=t.maxForce-h),v[e]+=f,p+=f>0?f:-f,t.addToWlambda(f)}if(p*p<i)break}for(let e=0;e!==c;e++){let t=s[e],n=t.velocity,r=t.angularVelocity;t.vlambda.vmul(t.linearFactor,t.vlambda),n.vadd(t.vlambda,n),t.wlambda.vmul(t.angularFactor,t.wlambda),r.vadd(t.wlambda,r)}let e=a.length,t=1/l;for(;e--;)a[e].multiplier=v[e]*t}return n}},OP=[],kP=[],AP=[],_M.STATIC,jP=class{constructor(){this.objects=[],this.type=Object}release(){let e=arguments.length;for(let t=0;t!==e;t++)this.objects.push(t<0||arguments.length<=t?void 0:arguments[t]);return this}get(){return this.objects.length===0?this.constructObject():this.objects.pop()}constructObject(){throw Error(`constructObject() not implemented in this Pool subclass yet!`)}resize(e){let t=this.objects;for(;t.length>e;)t.pop();for(;t.length<e;)t.push(this.constructObject());return this}},MP=class extends jP{constructor(){super(...arguments),this.type=$}constructObject(){return new $}},NP={sphereSphere:iM.types.SPHERE,spherePlane:iM.types.SPHERE|iM.types.PLANE,boxBox:iM.types.BOX|iM.types.BOX,sphereBox:iM.types.SPHERE|iM.types.BOX,planeBox:iM.types.PLANE|iM.types.BOX,convexConvex:iM.types.CONVEXPOLYHEDRON,sphereConvex:iM.types.SPHERE|iM.types.CONVEXPOLYHEDRON,planeConvex:iM.types.PLANE|iM.types.CONVEXPOLYHEDRON,boxConvex:iM.types.BOX|iM.types.CONVEXPOLYHEDRON,sphereHeightfield:iM.types.SPHERE|iM.types.HEIGHTFIELD,boxHeightfield:iM.types.BOX|iM.types.HEIGHTFIELD,convexHeightfield:iM.types.CONVEXPOLYHEDRON|iM.types.HEIGHTFIELD,sphereParticle:iM.types.PARTICLE|iM.types.SPHERE,planeParticle:iM.types.PLANE|iM.types.PARTICLE,boxParticle:iM.types.BOX|iM.types.PARTICLE,convexParticle:iM.types.PARTICLE|iM.types.CONVEXPOLYHEDRON,cylinderCylinder:iM.types.CYLINDER,sphereCylinder:iM.types.SPHERE|iM.types.CYLINDER,planeCylinder:iM.types.PLANE|iM.types.CYLINDER,boxCylinder:iM.types.BOX|iM.types.CYLINDER,convexCylinder:iM.types.CONVEXPOLYHEDRON|iM.types.CYLINDER,heightfieldCylinder:iM.types.HEIGHTFIELD|iM.types.CYLINDER,particleCylinder:iM.types.PARTICLE|iM.types.CYLINDER,sphereTrimesh:iM.types.SPHERE|iM.types.TRIMESH,planeTrimesh:iM.types.PLANE|iM.types.TRIMESH},PP=class{get[NP.sphereSphere](){return this.sphereSphere}get[NP.spherePlane](){return this.spherePlane}get[NP.boxBox](){return this.boxBox}get[NP.sphereBox](){return this.sphereBox}get[NP.planeBox](){return this.planeBox}get[NP.convexConvex](){return this.convexConvex}get[NP.sphereConvex](){return this.sphereConvex}get[NP.planeConvex](){return this.planeConvex}get[NP.boxConvex](){return this.boxConvex}get[NP.sphereHeightfield](){return this.sphereHeightfield}get[NP.boxHeightfield](){return this.boxHeightfield}get[NP.convexHeightfield](){return this.convexHeightfield}get[NP.sphereParticle](){return this.sphereParticle}get[NP.planeParticle](){return this.planeParticle}get[NP.boxParticle](){return this.boxParticle}get[NP.convexParticle](){return this.convexParticle}get[NP.cylinderCylinder](){return this.convexConvex}get[NP.sphereCylinder](){return this.sphereConvex}get[NP.planeCylinder](){return this.planeConvex}get[NP.boxCylinder](){return this.boxConvex}get[NP.convexCylinder](){return this.convexConvex}get[NP.heightfieldCylinder](){return this.heightfieldCylinder}get[NP.particleCylinder](){return this.particleCylinder}get[NP.sphereTrimesh](){return this.sphereTrimesh}get[NP.planeTrimesh](){return this.planeTrimesh}constructor(e){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new MP,this.world=e,this.currentContactMaterial=e.defaultContactMaterial,this.enableFrictionReduction=!1}createContactEquation(e,t,n,r,i,a){let o;this.contactPointPool.length?(o=this.contactPointPool.pop(),o.bi=e,o.bj=t):o=new jN(e,t),o.enabled=e.collisionResponse&&t.collisionResponse&&n.collisionResponse&&r.collisionResponse;let s=this.currentContactMaterial;o.restitution=s.restitution,o.setSpookParams(s.contactEquationStiffness,s.contactEquationRelaxation,this.world.dt);let c=n.material||e.material,l=r.material||t.material;return c&&l&&c.restitution>=0&&l.restitution>=0&&(o.restitution=c.restitution*l.restitution),o.si=i||n,o.sj=a||r,o}createFrictionEquationsFromContact(e,t){let n=e.bi,r=e.bj,i=e.si,a=e.sj,o=this.world,s=this.currentContactMaterial,c=s.friction,l=i.material||n.material,u=a.material||r.material;if(l&&u&&l.friction>=0&&u.friction>=0&&(c=l.friction*u.friction),c>0){let i=c*(o.frictionGravity||o.gravity).length(),a=n.invMass+r.invMass;a>0&&(a=1/a);let l=this.frictionEquationPool,u=l.length?l.pop():new XN(n,r,i*a),d=l.length?l.pop():new XN(n,r,i*a);return u.bi=d.bi=n,u.bj=d.bj=r,u.minForce=d.minForce=-i*a,u.maxForce=d.maxForce=i*a,u.ri.copy(e.ri),u.rj.copy(e.rj),d.ri.copy(e.ri),d.rj.copy(e.rj),e.ni.tangents(u.t,d.t),u.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,o.dt),d.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,o.dt),u.enabled=d.enabled=e.enabled,t.push(u,d),!0}return!1}createFrictionFromAverage(e){let t=this.result[this.result.length-1];if(!this.createFrictionEquationsFromContact(t,this.frictionResult)||e===1)return;let n=this.frictionResult[this.frictionResult.length-2],r=this.frictionResult[this.frictionResult.length-1];FP.setZero(),IP.setZero(),LP.setZero();let i=t.bi;t.bj;for(let n=0;n!==e;n++)t=this.result[this.result.length-1-n],t.bi===i?(FP.vsub(t.ni,FP),IP.vadd(t.rj,IP),LP.vadd(t.ri,LP)):(FP.vadd(t.ni,FP),IP.vadd(t.ri,IP),LP.vadd(t.rj,LP));let a=1/e;IP.scale(a,n.ri),LP.scale(a,n.rj),r.ri.copy(n.ri),r.rj.copy(n.rj),FP.normalize(),FP.tangents(n.t,r.t)}getContacts(e,t,n,r,i,a,o){this.contactPointPool=i,this.frictionEquationPool=o,this.result=r,this.frictionResult=a;let s=BP,c=VP,l=RP,u=zP;for(let r=0,i=e.length;r!==i;r++){let i=e[r],a=t[r],o=null;i.material&&a.material&&(o=n.getContactMaterial(i.material,a.material)||null);let d=i.type&_M.KINEMATIC&&a.type&_M.STATIC||i.type&_M.STATIC&&a.type&_M.KINEMATIC||i.type&_M.KINEMATIC&&a.type&_M.KINEMATIC;for(let e=0;e<i.shapes.length;e++){i.quaternion.mult(i.shapeOrientations[e],s),i.quaternion.vmult(i.shapeOffsets[e],l),l.vadd(i.position,l);let t=i.shapes[e];for(let e=0;e<a.shapes.length;e++){a.quaternion.mult(a.shapeOrientations[e],c),a.quaternion.vmult(a.shapeOffsets[e],u),u.vadd(a.position,u);let r=a.shapes[e];if(!(t.collisionFilterMask&r.collisionFilterGroup&&r.collisionFilterMask&t.collisionFilterGroup)||l.distanceTo(u)>t.boundingSphereRadius+r.boundingSphereRadius)continue;let f=null;t.material&&r.material&&(f=n.getContactMaterial(t.material,r.material)||null),this.currentContactMaterial=f||o||n.defaultContactMaterial;let p=t.type|r.type,m=this[p];if(m){let e=!1;e=t.type<r.type?m.call(this,t,r,l,u,s,c,i,a,t,r,d):m.call(this,r,t,u,l,c,s,a,i,t,r,d),e&&d&&(n.shapeOverlapKeeper.set(t.id,r.id),n.bodyOverlapKeeper.set(i.id,a.id))}}}}}sphereSphere(e,t,n,r,i,a,o,s,c,l,u){if(u)return n.distanceSquared(r)<(e.radius+t.radius)**2;let d=this.createContactEquation(o,s,e,t,c,l);r.vsub(n,d.ni),d.ni.normalize(),d.ri.copy(d.ni),d.rj.copy(d.ni),d.ri.scale(e.radius,d.ri),d.rj.scale(-t.radius,d.rj),d.ri.vadd(n,d.ri),d.ri.vsub(o.position,d.ri),d.rj.vadd(r,d.rj),d.rj.vsub(s.position,d.rj),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}spherePlane(e,t,n,r,i,a,o,s,c,l,u){let d=this.createContactEquation(o,s,e,t,c,l);if(d.ni.set(0,0,1),a.vmult(d.ni,d.ni),d.ni.negate(d.ni),d.ni.normalize(),d.ni.scale(e.radius,d.ri),n.vsub(r,oF),d.ni.scale(d.ni.dot(oF),sF),oF.vsub(sF,d.rj),-oF.dot(d.ni)<=e.radius){if(u)return!0;let e=d.ri,t=d.rj;e.vadd(n,e),e.vsub(o.position,e),t.vadd(r,t),t.vsub(s.position,t),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}}boxBox(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t.convexPolyhedronRepresentation,n,r,i,a,o,s,e,t,u)}sphereBox(e,t,n,r,i,a,o,s,c,l,u){let d=this.v3pool,f=hF;n.vsub(r,dF),t.getSideNormals(f,a);let p=e.radius,m=!1,h=_F,g=vF,_=yF,v=null,y=0,b=0,x=0,S=null;for(let e=0,t=f.length;e!==t&&m===!1;e++){let t=fF;t.copy(f[e]);let n=t.length();t.normalize();let r=dF.dot(t);if(r<n+p&&r>0){let i=pF,a=mF;i.copy(f[(e+1)%3]),a.copy(f[(e+2)%3]);let o=i.length(),s=a.length();i.normalize(),a.normalize();let c=dF.dot(i),l=dF.dot(a);if(c<o&&c>-o&&l<s&&l>-s){let e=Math.abs(r-n-p);if((S===null||e<S)&&(S=e,b=c,x=l,v=n,h.copy(t),g.copy(i),_.copy(a),y++,u))return!0}}}if(y){m=!0;let i=this.createContactEquation(o,s,e,t,c,l);h.scale(-p,i.ri),i.ni.copy(h),i.ni.negate(i.ni),h.scale(v,h),g.scale(b,g),h.vadd(g,h),_.scale(x,_),h.vadd(_,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}let C=d.get(),w=gF;for(let i=0;i!==2&&!m;i++)for(let a=0;a!==2&&!m;a++)for(let d=0;d!==2&&!m;d++)if(C.set(0,0,0),i?C.vadd(f[0],C):C.vsub(f[0],C),a?C.vadd(f[1],C):C.vsub(f[1],C),d?C.vadd(f[2],C):C.vsub(f[2],C),r.vadd(C,w),w.vsub(n,w),w.lengthSquared()<p*p){if(u)return!0;m=!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ri.copy(w),i.ri.normalize(),i.ni.copy(i.ri),i.ri.scale(p,i.ri),i.rj.copy(C),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}d.release(C),C=null;let T=d.get(),E=d.get(),D=d.get(),O=d.get(),k=d.get(),A=f.length;for(let i=0;i!==A&&!m;i++)for(let a=0;a!==A&&!m;a++)if(i%3!=a%3){f[a].cross(f[i],T),T.normalize(),f[i].vadd(f[a],E),D.copy(n),D.vsub(E,D),D.vsub(r,D);let d=D.dot(T);T.scale(d,O);let h=0;for(;h===i%3||h===a%3;)h++;k.copy(n),k.vsub(O,k),k.vsub(E,k),k.vsub(r,k);let g=Math.abs(d),_=k.length();if(g<f[h].length()&&_<p){if(u)return!0;m=!0;let i=this.createContactEquation(o,s,e,t,c,l);E.vadd(O,i.rj),i.rj.copy(i.rj),k.negate(i.ni),i.ni.normalize(),i.ri.copy(i.rj),i.ri.vadd(r,i.ri),i.ri.vsub(n,i.ri),i.ri.normalize(),i.ri.scale(p,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}d.release(T,E,D,O,k)}planeBox(e,t,n,r,i,a,o,s,c,l,u){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,t.convexPolyhedronRepresentation.id=t.id,this.planeConvex(e,t.convexPolyhedronRepresentation,n,r,i,a,o,s,e,t,u)}convexConvex(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=PF;if(!(n.distanceTo(r)>e.boundingSphereRadius+t.boundingSphereRadius)&&e.findSeparatingAxis(t,n,i,r,a,p,d,f)){let d=[],f=FF;e.clipAgainstHull(n,i,t,r,a,p,-100,100,d);let m=0;for(let i=0;i!==d.length;i++){if(u)return!0;let a=this.createContactEquation(o,s,e,t,c,l),h=a.ri,g=a.rj;p.negate(a.ni),d[i].normal.negate(f),f.scale(d[i].depth,f),d[i].point.vadd(f,h),g.copy(d[i].point),h.vsub(n,h),g.vsub(r,g),h.vadd(n,h),h.vsub(o.position,h),g.vadd(r,g),g.vsub(s.position,g),this.result.push(a),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(a,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}}sphereConvex(e,t,n,r,i,a,o,s,c,l,u){let d=this.v3pool;n.vsub(r,bF);let f=t.faceNormals,p=t.faces,m=t.vertices,h=e.radius,g=!1;for(let i=0;i!==m.length;i++){let d=m[i],f=wF;a.vmult(d,f),r.vadd(f,f);let p=CF;if(f.vsub(n,p),p.lengthSquared()<h*h){if(u)return!0;g=!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ri.copy(p),i.ri.normalize(),i.ni.copy(i.ri),i.ri.scale(h,i.ri),f.vsub(r,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult);return}}for(let i=0,_=p.length;i!==_&&g===!1;i++){let _=f[i],v=p[i],y=TF;a.vmult(_,y);let b=EF;a.vmult(m[v[0]],b),b.vadd(r,b);let x=DF;y.scale(-h,x),n.vadd(x,x);let S=OF;x.vsub(b,S);let C=S.dot(y),w=kF;if(n.vsub(b,w),C<0&&w.dot(y)>0){let i=[];for(let e=0,t=v.length;e!==t;e++){let t=d.get();a.vmult(m[v[e]],t),r.vadd(t,t),i.push(t)}if(Hj(i,y,n)){if(u)return!0;g=!0;let a=this.createContactEquation(o,s,e,t,c,l);y.scale(-h,a.ri),y.negate(a.ni);let f=d.get();y.scale(-C,f);let p=d.get();y.scale(-h,p),n.vsub(r,a.rj),a.rj.vadd(p,a.rj),a.rj.vadd(f,a.rj),a.rj.vadd(r,a.rj),a.rj.vsub(s.position,a.rj),a.ri.vadd(n,a.ri),a.ri.vsub(o.position,a.ri),d.release(f),d.release(p),this.result.push(a),this.createFrictionEquationsFromContact(a,this.frictionResult);for(let e=0,t=i.length;e!==t;e++)d.release(i[e]);return}for(let f=0;f!==v.length;f++){let p=d.get(),g=d.get();a.vmult(m[v[(f+1)%v.length]],p),a.vmult(m[v[(f+2)%v.length]],g),r.vadd(p,p),r.vadd(g,g);let _=xF;g.vsub(p,_);let y=SF;_.unit(y);let b=d.get(),x=d.get();n.vsub(p,x);let S=x.dot(y);y.scale(S,b),b.vadd(p,b);let C=d.get();if(b.vsub(n,C),S>0&&S*S<_.lengthSquared()&&C.lengthSquared()<h*h){if(u)return!0;let a=this.createContactEquation(o,s,e,t,c,l);b.vsub(r,a.rj),b.vsub(n,a.ni),a.ni.normalize(),a.ni.scale(h,a.ri),a.rj.vadd(r,a.rj),a.rj.vsub(s.position,a.rj),a.ri.vadd(n,a.ri),a.ri.vsub(o.position,a.ri),this.result.push(a),this.createFrictionEquationsFromContact(a,this.frictionResult);for(let e=0,t=i.length;e!==t;e++)d.release(i[e]);d.release(p),d.release(g),d.release(b),d.release(C),d.release(x);return}d.release(p),d.release(g),d.release(b),d.release(C),d.release(x)}for(let e=0,t=i.length;e!==t;e++)d.release(i[e])}}}planeConvex(e,t,n,r,i,a,o,s,c,l,u){let d=AF,f=jF;f.set(0,0,1),i.vmult(f,f);let p=0,m=MF;for(let i=0;i!==t.vertices.length;i++)if(d.copy(t.vertices[i]),a.vmult(d,d),r.vadd(d,d),d.vsub(n,m),f.dot(m)<=0){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l),a=NF;f.scale(f.dot(m),a),d.vsub(a,a),a.vsub(n,i.ri),i.ni.copy(f),d.vsub(r,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),p++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(i,this.frictionResult)}this.enableFrictionReduction&&p&&this.createFrictionFromAverage(p)}boxConvex(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}sphereHeightfield(e,t,n,r,i,a,o,s,c,l,u){let d=t.data,f=e.radius,p=t.elementSize,m=YF,h=JF;aM.pointToLocalFrame(r,a,n,h);let g=Math.floor((h.x-f)/p)-1,_=Math.ceil((h.x+f)/p)+1,v=Math.floor((h.y-f)/p)-1,y=Math.ceil((h.y+f)/p)+1;if(_<0||y<0||g>d.length||v>d[0].length)return;g<0&&(g=0),_<0&&(_=0),v<0&&(v=0),y<0&&(y=0),g>=d.length&&(g=d.length-1),_>=d.length&&(_=d.length-1),y>=d[0].length&&(y=d[0].length-1),v>=d[0].length&&(v=d[0].length-1);let b=[];t.getRectMinMax(g,v,_,y,b);let x=b[0],S=b[1];if(h.z-f>S||h.z+f<x)return;let C=this.result;for(let c=g;c<_;c++)for(let l=v;l<y;l++){let d=C.length,f=!1;if(t.getConvexTrianglePillar(c,l,!1),aM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(f=this.sphereConvex(e,t.pillarConvex,n,m,i,a,o,s,e,t,u)),u&&f||(t.getConvexTrianglePillar(c,l,!0),aM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(f=this.sphereConvex(e,t.pillarConvex,n,m,i,a,o,s,e,t,u)),u&&f))return!0;if(C.length-d>2)return}}boxHeightfield(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexHeightfield(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}convexHeightfield(e,t,n,r,i,a,o,s,c,l,u){let d=t.data,f=t.elementSize,p=e.boundingSphereRadius,m=KF,h=qF,g=GF;aM.pointToLocalFrame(r,a,n,g);let _=Math.floor((g.x-p)/f)-1,v=Math.ceil((g.x+p)/f)+1,y=Math.floor((g.y-p)/f)-1,b=Math.ceil((g.y+p)/f)+1;if(v<0||b<0||_>d.length||y>d[0].length)return;_<0&&(_=0),v<0&&(v=0),y<0&&(y=0),b<0&&(b=0),_>=d.length&&(_=d.length-1),v>=d.length&&(v=d.length-1),b>=d[0].length&&(b=d[0].length-1),y>=d[0].length&&(y=d[0].length-1);let x=[];t.getRectMinMax(_,y,v,b,x);let S=x[0],C=x[1];if(!(g.z-p>C||g.z+p<S))for(let c=_;c<v;c++)for(let l=y;l<b;l++){let d=!1;if(t.getConvexTrianglePillar(c,l,!1),aM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(d=this.convexConvex(e,t.pillarConvex,n,m,i,a,o,s,null,null,u,h,null)),u&&d||(t.getConvexTrianglePillar(c,l,!0),aM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(d=this.convexConvex(e,t.pillarConvex,n,m,i,a,o,s,null,null,u,h,null)),u&&d))return!0}}sphereParticle(e,t,n,r,i,a,o,s,c,l,u){let d=zF;if(d.set(0,0,1),r.vsub(n,d),d.lengthSquared()<=e.radius*e.radius){if(u)return!0;let n=this.createContactEquation(s,o,t,e,c,l);d.normalize(),n.rj.copy(d),n.rj.scale(e.radius,n.rj),n.ni.copy(d),n.ni.negate(n.ni),n.ri.set(0,0,0),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}planeParticle(e,t,n,r,i,a,o,s,c,l,u){let d=IF;d.set(0,0,1),o.quaternion.vmult(d,d);let f=LF;if(r.vsub(o.position,f),d.dot(f)<=0){if(u)return!0;let n=this.createContactEquation(s,o,t,e,c,l);n.ni.copy(d),n.ni.negate(n.ni),n.ri.set(0,0,0);let i=RF;d.scale(d.dot(r),i),r.vsub(i,i),n.rj.copy(i),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}boxParticle(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexParticle(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}convexParticle(e,t,n,r,i,a,o,s,c,l,u){let d=-1,f=HF,p=WF,m=null,h=VF;if(h.copy(r),h.vsub(n,h),i.conjugate(BF),BF.vmult(h,h),e.pointIsInside(h)){e.worldVerticesNeedsUpdate&&e.computeWorldVertices(n,i),e.worldFaceNormalsNeedsUpdate&&e.computeWorldFaceNormals(i);for(let t=0,n=e.faces.length;t!==n;t++){let n=[e.worldVertices[e.faces[t][0]]],i=e.worldFaceNormals[t];r.vsub(n[0],UF);let a=-i.dot(UF);if(m===null||Math.abs(a)<Math.abs(m)){if(u)return!0;m=a,d=t,f.copy(i)}}if(d!==-1){let i=this.createContactEquation(s,o,t,e,c,l);f.scale(m,p),p.vadd(r,p),p.vsub(n,p),i.rj.copy(p),f.negate(i.ni),i.ri.set(0,0,0);let a=i.ri,u=i.rj;a.vadd(r,a),a.vsub(s.position,a),u.vadd(n,u),u.vsub(o.position,u),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}else console.warn(`Point found inside convex, but did not find penetrating face!`)}}heightfieldCylinder(e,t,n,r,i,a,o,s,c,l,u){return this.convexHeightfield(t,e,r,n,a,i,s,o,c,l,u)}particleCylinder(e,t,n,r,i,a,o,s,c,l,u){return this.convexParticle(t,e,r,n,a,i,s,o,c,l,u)}sphereTrimesh(e,t,n,r,i,a,o,s,c,l,u){let d=YP,f=XP,p=ZP,m=QP,h=$P,g=eF,_=iF,v=JP,y=KP,b=aF;aM.pointToLocalFrame(r,a,n,h);let x=e.radius;_.lowerBound.set(h.x-x,h.y-x,h.z-x),_.upperBound.set(h.x+x,h.y+x,h.z+x),t.getTrianglesInAABB(_,b);let S=qP,C=e.radius*e.radius;for(let i=0;i<b.length;i++)for(let d=0;d<3;d++)if(t.getVertex(t.indices[b[i]*3+d],S),S.vsub(h,y),y.lengthSquared()<=C){if(v.copy(S),aM.pointToWorldFrame(r,a,v,S),S.vsub(n,y),u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ni.copy(y),i.ni.normalize(),i.ri.copy(i.ni),i.ri.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.copy(S),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}for(let i=0;i<b.length;i++)for(let _=0;_<3;_++){t.getVertex(t.indices[b[i]*3+_],d),t.getVertex(t.indices[b[i]*3+(_+1)%3],f),f.vsub(d,p),h.vsub(f,g);let v=g.dot(p);h.vsub(d,g);let y=g.dot(p);if(y>0&&v<0&&(h.vsub(d,g),m.copy(p),m.normalize(),y=g.dot(m),m.scale(y,g),g.vadd(d,g),g.distanceTo(h)<e.radius)){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);g.vsub(h,i.ni),i.ni.normalize(),i.ni.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),aM.pointToWorldFrame(r,a,g,g),g.vsub(s.position,i.rj),aM.vectorToWorldFrame(a,i.ni,i.ni),aM.vectorToWorldFrame(a,i.ri,i.ri),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}let w=tF,T=nF,E=rF,D=GP;for(let i=0,d=b.length;i!==d;i++){t.getTriangleVertices(b[i],w,T,E),t.getNormal(b[i],D),h.vsub(w,g);let d=g.dot(D);if(D.scale(d,g),h.vsub(g,g),d=g.distanceTo(h),KM.pointInTriangle(g,w,T,E)&&d<e.radius){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);g.vsub(h,i.ni),i.ni.normalize(),i.ni.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),aM.pointToWorldFrame(r,a,g,g),g.vsub(s.position,i.rj),aM.vectorToWorldFrame(a,i.ni,i.ni),aM.vectorToWorldFrame(a,i.ri,i.ri),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}b.length=0}planeTrimesh(e,t,n,r,i,a,o,s,c,l,u){let d=new $,f=HP;f.set(0,0,1),i.vmult(f,f);for(let i=0;i<t.vertices.length/3;i++){t.getVertex(i,d);let p=new $;p.copy(d),aM.pointToWorldFrame(r,a,p,d);let m=UP;if(d.vsub(n,m),f.dot(m)<=0){if(u)return!0;let n=this.createContactEquation(o,s,e,t,c,l);n.ni.copy(f);let r=WP;f.scale(m.dot(f),r),d.vsub(r,r),n.ri.copy(r),n.ri.vsub(o.position,n.ri),n.rj.copy(d),n.rj.vsub(s.position,n.rj),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}}},FP=new $,IP=new $,LP=new $,RP=new $,zP=new $,BP=new eM,VP=new eM,HP=new $,UP=new $,WP=new $,GP=new $,KP=new $,new $,qP=new $,JP=new $,YP=new $,XP=new $,ZP=new $,QP=new $,$P=new $,eF=new $,tF=new $,nF=new $,rF=new $,iF=new Yj,aF=[],oF=new $,sF=new $,cF=new $,lF=new $,uF=new $,dF=new $,fF=new $,pF=new $,mF=new $,hF=[new $,new $,new $,new $,new $,new $],gF=new $,_F=new $,vF=new $,yF=new $,bF=new $,xF=new $,SF=new $,CF=new $,wF=new $,TF=new $,EF=new $,DF=new $,OF=new $,kF=new $,new $,new $,AF=new $,jF=new $,MF=new $,NF=new $,PF=new $,FF=new $,IF=new $,LF=new $,RF=new $,zF=new $,BF=new eM,VF=new $,new $,HF=new $,UF=new $,WF=new $,GF=new $,KF=new $,qF=[0],JF=new $,YF=new $,XF=class{constructor(){this.current=[],this.previous=[]}getKey(e,t){if(t<e){let n=t;t=e,e=n}return e<<16|t}set(e,t){let n=this.getKey(e,t),r=this.current,i=0;for(;n>r[i];)i++;if(n!==r[i]){for(let e=r.length-1;e>=i;e--)r[e+1]=r[e];r[i]=n}}tick(){let e=this.current;this.current=this.previous,this.previous=e,this.current.length=0}getDiff(e,t){let n=this.current,r=this.previous,i=n.length,a=r.length,o=0;for(let t=0;t<i;t++){let i=!1,a=n[t];for(;a>r[o];)o++;i=a===r[o],i||Uj(e,a)}o=0;for(let e=0;e<a;e++){let i=!1,a=r[e];for(;a>n[o];)o++;i=n[o]===a,i||Uj(t,a)}}},ZF=(e,t)=>e<t?`${e}-${t}`:`${t}-${e}`,QF=class{constructor(){this.data={keys:[]}}get(e,t){let n=ZF(e,t);return this.data[n]}set(e,t,n){let r=ZF(e,t);this.get(e,t)||this.data.keys.push(r),this.data[r]=n}delete(e,t){let n=ZF(e,t),r=this.data.keys.indexOf(n);r!==-1&&this.data.keys.splice(r,1),delete this.data[n]}reset(){let e=this.data,t=e.keys;for(;t.length>0;){let n=t.pop();delete e[n]}}},$F=class extends $j{constructor(e){e===void 0&&(e={}),super(),this.dt=-1,this.allowSleep=!!e.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=e.quatNormalizeSkip===void 0?0:e.quatNormalizeSkip,this.quatNormalizeFast=e.quatNormalizeFast!==void 0&&e.quatNormalizeFast,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new $,e.gravity&&this.gravity.copy(e.gravity),e.frictionGravity&&(this.frictionGravity=new $,this.frictionGravity.copy(e.frictionGravity)),this.broadphase=e.broadphase===void 0?new IM:e.broadphase,this.bodies=[],this.hasActiveBodies=!1,this.solver=e.solver===void 0?new DP:e.solver,this.constraints=[],this.narrowphase=new PP(this),this.collisionMatrix=new Qj,this.collisionMatrixPrevious=new Qj,this.bodyOverlapKeeper=new XF,this.shapeOverlapKeeper=new XF,this.contactmaterials=[],this.contactMaterialTable=new QF,this.defaultMaterial=new eP(`default`),this.defaultContactMaterial=new $N(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:`addBody`,body:null},this.removeBodyEvent={type:`removeBody`,body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}getContactMaterial(e,t){return this.contactMaterialTable.get(e.id,t.id)}collisionMatrixTick(){let e=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=e,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()}addConstraint(e){this.constraints.push(e)}removeConstraint(e){let t=this.constraints.indexOf(e);t!==-1&&this.constraints.splice(t,1)}rayTest(e,t,n){n instanceof LM?this.raycastClosest(e,t,{skipBackfaces:!0},n):this.raycastAll(e,t,{skipBackfaces:!0},n)}raycastAll(e,t,n,r){return n===void 0&&(n={}),n.mode=KM.ALL,n.from=e,n.to=t,n.callback=r,eI.intersectWorld(this,n)}raycastAny(e,t,n,r){return n===void 0&&(n={}),n.mode=KM.ANY,n.from=e,n.to=t,n.result=r,eI.intersectWorld(this,n)}raycastClosest(e,t,n,r){return n===void 0&&(n={}),n.mode=KM.CLOSEST,n.from=e,n.to=t,n.result=r,eI.intersectWorld(this,n)}addBody(e){this.bodies.includes(e)||(e.index=this.bodies.length,this.bodies.push(e),e.world=this,e.initPosition.copy(e.position),e.initVelocity.copy(e.velocity),e.timeLastSleepy=this.time,e instanceof _M&&(e.initAngularVelocity.copy(e.angularVelocity),e.initQuaternion.copy(e.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=e,this.idToBodyMap[e.id]=e,this.dispatchEvent(this.addBodyEvent))}removeBody(e){e.world=null;let t=this.bodies.length-1,n=this.bodies,r=n.indexOf(e);if(r!==-1){n.splice(r,1);for(let e=0;e!==n.length;e++)n[e].index=e;this.collisionMatrix.setNumObjects(t),this.removeBodyEvent.body=e,delete this.idToBodyMap[e.id],this.dispatchEvent(this.removeBodyEvent)}}getBodyById(e){return this.idToBodyMap[e]}getShapeById(e){let t=this.bodies;for(let n=0;n<t.length;n++){let r=t[n].shapes;for(let t=0;t<r.length;t++){let n=r[t];if(n.id===e)return n}}return null}addContactMaterial(e){this.contactmaterials.push(e),this.contactMaterialTable.set(e.materials[0].id,e.materials[1].id,e)}removeContactMaterial(e){let t=this.contactmaterials.indexOf(e);t!==-1&&(this.contactmaterials.splice(t,1),this.contactMaterialTable.delete(e.materials[0].id,e.materials[1].id))}fixedStep(e,t){e===void 0&&(e=1/60),t===void 0&&(t=10);let n=tI.now()/1e3;if(!this.lastCallTime)this.step(e,void 0,t);else{let r=n-this.lastCallTime;this.step(e,r,t)}this.lastCallTime=n}step(e,t,n){if(n===void 0&&(n=10),t===void 0)this.internalStep(e),this.time+=e;else{this.accumulator+=t;let r=tI.now(),i=0;for(;this.accumulator>=e&&i<n&&(this.internalStep(e),this.accumulator-=e,i++,!(tI.now()-r>e*1e3)););this.accumulator%=e;let a=this.accumulator/e;for(let e=0;e!==this.bodies.length;e++){let t=this.bodies[e];t.previousPosition.lerp(t.position,a,t.interpolatedPosition),t.previousQuaternion.slerp(t.quaternion,a,t.interpolatedQuaternion),t.previousQuaternion.normalize()}this.time+=t}}internalStep(e){this.dt=e;let t=this.contacts,n=sI,r=cI,i=this.bodies.length,a=this.bodies,o=this.solver,s=this.gravity,c=this.doProfiling,l=this.profile,u=_M.DYNAMIC,d=-1/0,f=this.constraints,p=oI;s.length();let m=s.x,h=s.y,g=s.z,_=0;for(c&&(d=tI.now()),_=0;_!==i;_++){let e=a[_];if(e.type===u){let t=e.force,n=e.mass;t.x+=n*m,t.y+=n*h,t.z+=n*g}}for(let e=0,t=this.subsystems.length;e!==t;e++)this.subsystems[e].update();c&&(d=tI.now()),n.length=0,r.length=0,this.broadphase.collisionPairs(this,n,r),c&&(l.broadphase=tI.now()-d);let v=f.length;for(_=0;_!==v;_++){let e=f[_];if(!e.collideConnected)for(let t=n.length-1;t>=0;--t)(e.bodyA===n[t]&&e.bodyB===r[t]||e.bodyB===n[t]&&e.bodyA===r[t])&&(n.splice(t,1),r.splice(t,1))}this.collisionMatrixTick(),c&&(d=tI.now());let y=aI,b=t.length;for(_=0;_!==b;_++)y.push(t[_]);t.length=0;let x=this.frictionEquations.length;for(_=0;_!==x;_++)p.push(this.frictionEquations[_]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(n,r,this,t,y,this.frictionEquations,p),c&&(l.narrowphase=tI.now()-d),c&&(d=tI.now()),_=0;_<this.frictionEquations.length;_++)o.addEquation(this.frictionEquations[_]);let S=t.length;for(let e=0;e!==S;e++){let n=t[e],r=n.bi,i=n.bj,a=n.si,s=n.sj,c;c=r.material&&i.material&&this.getContactMaterial(r.material,i.material)||this.defaultContactMaterial,c.friction,r.material&&i.material&&(r.material.friction>=0&&i.material.friction>=0&&r.material.friction*i.material.friction,r.material.restitution>=0&&i.material.restitution>=0&&(n.restitution=r.material.restitution*i.material.restitution)),o.addEquation(n),r.allowSleep&&r.type===_M.DYNAMIC&&r.sleepState===_M.SLEEPING&&i.sleepState===_M.AWAKE&&i.type!==_M.STATIC&&i.velocity.lengthSquared()+i.angularVelocity.lengthSquared()>=i.sleepSpeedLimit**2*2&&(r.wakeUpAfterNarrowphase=!0),i.allowSleep&&i.type===_M.DYNAMIC&&i.sleepState===_M.SLEEPING&&r.sleepState===_M.AWAKE&&r.type!==_M.STATIC&&r.velocity.lengthSquared()+r.angularVelocity.lengthSquared()>=r.sleepSpeedLimit**2*2&&(i.wakeUpAfterNarrowphase=!0),this.collisionMatrix.set(r,i,!0),this.collisionMatrixPrevious.get(r,i)||(iI.body=i,iI.contact=n,r.dispatchEvent(iI),iI.body=r,i.dispatchEvent(iI)),this.bodyOverlapKeeper.set(r.id,i.id),this.shapeOverlapKeeper.set(a.id,s.id)}for(this.emitContactEvents(),c&&(l.makeContactConstraints=tI.now()-d,d=tI.now()),_=0;_!==i;_++){let e=a[_];e.wakeUpAfterNarrowphase&&=(e.wakeUp(),!1)}for(v=f.length,_=0;_!==v;_++){let e=f[_];e.update();for(let t=0,n=e.equations.length;t!==n;t++){let n=e.equations[t];o.addEquation(n)}}o.solve(e,this),c&&(l.solve=tI.now()-d),o.removeAllEquations();let C=Math.pow;for(_=0;_!==i;_++){let t=a[_];if(t.type&u){let n=C(1-t.linearDamping,e),r=t.velocity;r.scale(n,r);let i=t.angularVelocity;if(i){let n=C(1-t.angularDamping,e);i.scale(n,i)}}}this.dispatchEvent(rI),c&&(d=tI.now());let w=this.stepnumber%(this.quatNormalizeSkip+1)===0,T=this.quatNormalizeFast;for(_=0;_!==i;_++)a[_].integrate(e,w,T);this.clearForces(),this.broadphase.dirty=!0,c&&(l.integrate=tI.now()-d),this.stepnumber+=1,this.dispatchEvent(nI);let E=!0;if(this.allowSleep)for(E=!1,_=0;_!==i;_++){let e=a[_];e.sleepTick(this.time),e.sleepState!==_M.SLEEPING&&(E=!0)}this.hasActiveBodies=E}emitContactEvents(){let e=this.hasAnyEventListener(`beginContact`),t=this.hasAnyEventListener(`endContact`);if((e||t)&&this.bodyOverlapKeeper.getDiff(lI,uI),e){for(let e=0,t=lI.length;e<t;e+=2)dI.bodyA=this.getBodyById(lI[e]),dI.bodyB=this.getBodyById(lI[e+1]),this.dispatchEvent(dI);dI.bodyA=dI.bodyB=null}if(t){for(let e=0,t=uI.length;e<t;e+=2)fI.bodyA=this.getBodyById(uI[e]),fI.bodyB=this.getBodyById(uI[e+1]),this.dispatchEvent(fI);fI.bodyA=fI.bodyB=null}lI.length=uI.length=0;let n=this.hasAnyEventListener(`beginShapeContact`),r=this.hasAnyEventListener(`endShapeContact`);if((n||r)&&this.shapeOverlapKeeper.getDiff(lI,uI),n){for(let e=0,t=lI.length;e<t;e+=2){let t=this.getShapeById(lI[e]),n=this.getShapeById(lI[e+1]);pI.shapeA=t,pI.shapeB=n,t&&(pI.bodyA=t.body),n&&(pI.bodyB=n.body),this.dispatchEvent(pI)}pI.bodyA=pI.bodyB=pI.shapeA=pI.shapeB=null}if(r){for(let e=0,t=uI.length;e<t;e+=2){let t=this.getShapeById(uI[e]),n=this.getShapeById(uI[e+1]);mI.shapeA=t,mI.shapeB=n,t&&(mI.bodyA=t.body),n&&(mI.bodyB=n.body),this.dispatchEvent(mI)}mI.bodyA=mI.bodyB=mI.shapeA=mI.shapeB=null}}clearForces(){let e=this.bodies,t=e.length;for(let n=0;n!==t;n++){let t=e[n];t.force,t.torque,t.force.set(0,0,0),t.torque.set(0,0,0)}}},new Yj,eI=new KM,tI=globalThis.performance||{},!tI.now){let e=Date.now();tI.timing&&tI.timing.navigationStart&&(e=tI.timing.navigationStart),tI.now=()=>Date.now()-e}new $,nI={type:`postStep`},rI={type:`preStep`},iI={type:_M.COLLIDE_EVENT_NAME,body:null,contact:null},aI=[],oI=[],sI=[],cI=[],lI=[],uI=[],dI={type:`beginContact`,bodyA:null,bodyB:null},fI={type:`endContact`,bodyA:null,bodyB:null},pI={type:`beginShapeContact`,bodyA:null,bodyB:null,shapeA:null,shapeB:null},mI={type:`endShapeContact`,bodyA:null,bodyB:null,shapeA:null,shapeB:null}}));function gI(e){let t=e.B.quaternion.conjugate().mult(e.A.quaternion).mult(e.rel0.conjugate()),n=t.x*e.axisB.x+t.y*e.axisB.y+t.z*e.axisB.z,r=2*Math.atan2(n,t.w);return r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI),r}function _I(e){let t=gI(e),n=t>e.max?t-e.max:t<e.min?t-e.min:0;if(!n)return;let r=e.A.mass>0||e.B.mass<=0,i=r?e.A:e.B;if(i.mass<=0)return;let a=e.B.quaternion.vmult(e.axisB);a.normalize();let o=e.B.quaternion.vmult(e.pivotB).vadd(e.B.position),s=new eM().setFromAxisAngle(a,r?-n:n),c=i.position.vsub(o);i.position.copy(s.vmult(c).vadd(o)),i.quaternion.copy(s.mult(i.quaternion)),i.quaternion.normalize();let l=e.A.angularVelocity.vsub(e.B.angularVelocity).dot(a);if(l*n>0){let e=a.scale(r?l:-l);i.angularVelocity.vsub(e,i.angularVelocity);let t=i.position.vsub(o);i.velocity.vsub(e.cross(t),i.velocity)}i.aabbNeedsUpdate=!0}function vI(e,t){let n=[],r=t?t.length:e.length/3,i=n=>{let r=(t?t[n]:n)*3;return new $(e[r],e[r+1],e[r+2])};for(let e=0;e+2<r;e+=3){let t=i(e),r=i(e+1),a=i(e+2),o=r.vsub(t).cross(a.vsub(t)),s=o.length();if(s<1e-9)continue;o.scale(EI/s,o);let c=t.vadd(r).vadd(a).scale(1/3).vsub(o.scale(.5)),l=[t,r,a,t.vsub(o),r.vsub(o),a.vsub(o)].map(e=>e.vsub(c)),u=new sM({vertices:l,faces:[[0,1,2],[3,5,4],[0,3,4,1],[1,4,5,2],[2,5,3,0]]});n.push({shape:u,center:xI(c)})}return n}function yI(e,t){if(e.length<=t)return e.length?[e]:[];let n=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let t of e)for(let e=0;e<3;e++)n[e]=Math.min(n[e],t.center[e]),r[e]=Math.max(r[e],t.center[e]);let i=[0,1,2].reduce((e,t)=>r[t]-n[t]>r[e]-n[e]?t:e,0),a=[...e].sort((e,t)=>e.center[i]-t.center[i]),o=a.length>>1;return[...yI(a.slice(0,o),t),...yI(a.slice(o),t)]}function bI(e){let t=1/0;for(let n of e)if(n.type===`box`)t=Math.min(t,2*Math.min(...n.half));else if(n.type===`sphere`||n.type===`cylinder`||n.type===`capsule`)t=Math.min(t,2*n.radius);else if(n.type===`convex`){let e=[0,1,2].map(e=>Math.max(...n.vertices.map(t=>t[e]))-Math.min(...n.vertices.map(t=>t[e])));t=Math.min(t,...e)}return Number.isFinite(t)?Math.max(t,.01):1}var xI,SI,CI,wI,TI,EI,DI,OI,kI,AI,jI=t((()=>{hI(),xI=e=>[e.x,e.y,e.z],SI=(e,t=[0,0,0])=>new $(...e??t),CI=e=>e?new eM(e[0],e[1],e[2],e[3]):new eM,wI=.5,TI=.2,EI=.08,DI=.08,OI=.5,kI=48,AI=class{world;recs=[];byId=/* @__PURE__ */ new Map;byBody=/* @__PURE__ */ new Map;order=0;materials=/* @__PURE__ */ new Map;materialProps=/* @__PURE__ */ new Map;namedMaterials;pairOverrides=/* @__PURE__ */ new Map;layerBits=/* @__PURE__ */ new Map;joints=[];contactsNow=/* @__PURE__ */ new Map;contactsPrev=/* @__PURE__ */ new Map;beginHandlers=[];endHandlers=[];substeps;time=0;preVel=/* @__PURE__ */ new Map;stepDt=1/60;constructor(e={}){let t=Array.isArray(e)?{gravity:e}:e;this.world=new $F({gravity:SI(t.gravity,[0,-9.81,0]),allowSleep:t.sleep??!0}),this.world.broadphase.useBoundingBoxes=!0,this.world.solver.iterations=t.iterations??10,this.world.defaultContactMaterial.friction=wI,this.world.defaultContactMaterial.restitution=TI,this.substeps=Math.min(8,Math.max(1,Math.round(t.substeps??1))),this.namedMaterials=t.materials??{};for(let e of t.contacts??[])this.pairOverrides.set([e.a,e.b].sort().join(`|`),e);this.layerBits.set(`default`,1);for(let e of t.layers??[])this.layerBit(e)}get bodies(){return this.recs.map(e=>e.view)}get(e){return this.byId.get(e)?.view}layerBit(e){let t=this.layerBits.get(e);if(t===void 0){if(this.layerBits.size>=16)return 1;t=1<<this.layerBits.size,this.layerBits.set(e,t)}return t}layerMask(e){return e?e.reduce((e,t)=>e|this.layerBit(t),0):-1}material(e,t,n){let r=`${e??``}|${t}|${n}`,i=this.materials.get(r);if(i)return i;i=new eP({friction:-1,restitution:-1}),this.materialProps.set(i,{name:e,friction:t,restitution:n}),this.materials.set(r,i);for(let e of this.materials.values()){let t=this.materialProps.get(i),n=this.materialProps.get(e),r=t.name&&n.name?this.pairOverrides.get([t.name,n.name].sort().join(`|`)):void 0;this.world.addContactMaterial(new $N(i,e,{friction:r?.friction??Math.sqrt(t.friction*n.friction),restitution:r?.restitution??Math.max(t.restitution,n.restitution)}))}return i}add(e){let t=this.byId.get(e.id),n=t?[...this.contactsNow].filter(([,e])=>e.a===t||e.b===t):[],r=t?[...this.contactsPrev].filter(([,e])=>e.a===t||e.b===t):[];this.remove(e.id);let i=e.material?this.namedMaterials[e.material]:void 0,a=!!e.character,o=a?0:e.friction??i?.friction??wI,s=a?0:e.restitution??i?.restitution??TI,c=e.type,l=c===`dynamic`,u=l?Math.max(e.mass??1,1e-4):0,d=this.material(e.material,o,s),f=this.layerBit(e.layer??`default`),p=this.layerMask(e.collidesWith),m=()=>new _M({mass:u,type:l?_M.DYNAMIC:c===`static`?_M.STATIC:_M.KINEMATIC,position:SI(e.position),quaternion:CI(e.quaternion),material:d,isTrigger:c===`trigger`,linearDamping:e.linearDamping??.01,angularDamping:e.angularDamping??(a?1:.01),fixedRotation:a||!!e.fixedRotation,allowSleep:l&&!a&&e.sleep!==!1,sleepSpeedLimit:.12,sleepTimeLimit:.6,collisionFilterGroup:f,collisionFilterMask:p}),h=m(),g=[];for(let t of e.shapes)this.addShape(h,t,g,m);e.velocity&&h.velocity.set(...e.velocity),e.angularVelocity&&l&&h.angularVelocity.set(...e.angularVelocity),c===`kinematic`&&e.velocity&&h.velocity.set(...e.velocity),h.updateMassProperties(),this.world.addBody(h);for(let e of g)this.world.addBody(e);let _={id:e.id,type:c,shapes:e.shapes,main:h,extra:g,order:this.order++,gravityScale:e.gravityScale??1,ccd:!!e.ccd,character:a,minExtent:bI(e.shapes),userVel:c===`kinematic`||c===`trigger`?h.velocity.clone():new $,kinFrom:null,forces:[],torques:[],lastGrounded:-1/0,jumpedAt:-1/0,ground:null,onGround:!1,carry:null,view:null};_.view=this.viewOf(_),this.recs.push(_),this.byId.set(_.id,_),this.byBody.set(h,_);for(let e of g)this.byBody.set(e,_);if(t){_.order=t.order,_.lastGrounded=t.lastGrounded,_.jumpedAt=t.jumpedAt,_.ground=t.ground,_.onGround=t.onGround,t.character&&this.makeCharacter(_);let e=e=>({...e,a:e.a===t?_:e.a,b:e.b===t?_:e.b});for(let[t,r]of n)this.contactsNow.set(t,e(r));for(let[t,n]of r)this.contactsPrev.set(t,e(n));for(let e of this.recs)e.ground===t&&(e.ground=_)}return _.view}viewOf(e){let t=this;return{id:e.id,type:e.type,shapes:e.shapes,get position(){return xI(e.main.position)},get quaternion(){let t=e.main.quaternion;return[t.x,t.y,t.z,t.w]},get velocity(){return xI(e.main.velocity)},get angularVelocity(){return xI(e.main.angularVelocity)},get mass(){return e.main.mass},get sleeping(){return e.main.sleepState===_M.SLEEPING},get grounded(){return t.isGrounded(e)},character:e.character}}addShape(e,t,n,r){let i=SI(t.offset),a=CI(t.quat);switch(t.type){case`box`:e.addShape(new fM(new $(Math.max(t.half[0],.001),Math.max(t.half[1],.001),Math.max(t.half[2],.001))),i,a);break;case`sphere`:e.addShape(new pP(Math.max(t.radius,.001)),i,a);break;case`cylinder`:e.addShape(new mP(t.radius,t.radius,Math.max(t.height,.001),t.segments??16),i,a);break;case`capsule`:{let n=Math.max(t.radius,.001),r=Math.max(t.height-2*n,0);r>.001&&e.addShape(new mP(n,n,r,12),i,a);for(let t of r>.001?[1,-1]:[0]){let o=a.vmult(new $(0,t*r/2,0));e.addShape(new pP(n),i.vadd(o),a)}break}case`convex`:{let n=new sM({vertices:t.vertices.map(e=>new $(...e)),faces:t.faces});e.addShape(n,i,a);break}case`heightfield`:e.addShape(new hP(t.data,{elementSize:t.elementSize}),i,a);break;case`trimesh`:yI(vI(t.vertices,t.indices),kI).forEach((t,o)=>{let s=o===0?e:r();for(let e of t)s.addShape(e.shape,i.vadd(a.vmult(new $(...e.center))),a);o>0&&n.push(s)})}}remove(e){let t=this.byId.get(e);if(t){for(let t of this.joints.filter(t=>t.a===e||t.b===e))this.removeJoint(t.id);this.world.removeBody(t.main);for(let e of t.extra)this.world.removeBody(e);this.byId.delete(e),this.byBody.delete(t.main);for(let e of t.extra)this.byBody.delete(e);this.recs.splice(this.recs.indexOf(t),1);for(let[e,n]of this.contactsNow)(n.a===t||n.b===t)&&this.contactsNow.delete(e);for(let[e,n]of this.contactsPrev)(n.a===t||n.b===t)&&this.contactsPrev.delete(e);for(let e of this.recs)e.ground===t&&(e.ground=null)}}setPose(e,t,n){let r=this.byId.get(e);if(!r)return;let i=r.main;r.type!==`kinematic`&&r.type!==`trigger`||r.kinFrom||(r.kinFrom={p:i.position.clone(),q:i.quaternion.clone()}),r.character&&Math.hypot(t[0]-i.position.x,t[1]-i.position.y,t[2]-i.position.z)>OI&&(r.ground=null,r.onGround=!1,r.lastGrounded=-1/0);for(let e of[i,...r.extra])e.position.set(...t),n&&e.quaternion.set(...n),e.previousPosition.copy(e.position),e.interpolatedPosition.copy(e.position),e.previousQuaternion.copy(e.quaternion),e.interpolatedQuaternion.copy(e.quaternion),e.aabbNeedsUpdate=!0;r.type===`dynamic`?i.wakeUp():this.wakeAround(r)}wakeAround(e){let t=this.aabb(e);if(t)for(let e of this.recs){if(e.type!==`dynamic`||e.main.sleepState!==_M.SLEEPING)continue;let n=this.aabb(e);n&&n.overlaps(t)&&this.wakeIsland(e)}}aabb(e){let t=[e.main,...e.extra].filter(e=>e.shapes.length);if(!t.length)return null;let n=new Yj;return t.forEach((e,t)=>{e.aabbNeedsUpdate&&e.updateAABB(),t===0?n.copy(e.aabb):n.extend(e.aabb)}),n.lowerBound.vsub(new $(.001,.001,.001),n.lowerBound),n.upperBound.vadd(new $(.001,.001,.001),n.upperBound),n}setVelocity(e,t){let n=this.byId.get(e);n&&n.type!==`static`&&(n.main.velocity.set(...t),n.type!==`dynamic`&&n.userVel.set(...t),n.main.wakeUp())}setAngularVelocity(e,t){let n=this.byId.get(e);n&&n.type!==`static`&&(n.main.angularVelocity.set(...t),n.main.wakeUp())}applyImpulse(e,t,n){let r=this.byId.get(e);if(!r||r.type!==`dynamic`)return;let i=n?new $(...n).vsub(r.main.position):new $;r.main.applyImpulse(new $(...t),i),r.main.wakeUp()}applyForce(e,t,n){let r=this.byId.get(e);r&&r.type===`dynamic`&&(r.forces.push({f:new $(...t),p:n?new $(...n):null}),r.main.wakeUp())}applyTorque(e,t){let n=this.byId.get(e);n&&n.type===`dynamic`&&(n.torques.push(new $(...t)),n.main.wakeUp())}wake(e){this.byId.get(e)?.main.wakeUp()}addJoint(e){let t=this.byId.get(e.a),n=e.b?this.byId.get(e.b):void 0;if(!t||e.b&&!n)return null;let r=e.id??`joint-${this.joints.length+1}`,i=t.main,a=new $(...e.pivot??xI(n?n.main.position:i.position)),o,s;n?s=n.main:(o=new _M({mass:0,type:_M.STATIC,position:a.clone(),collisionFilterGroup:0,collisionFilterMask:0}),this.world.addBody(o),s=o);let c=(e,t)=>e.quaternion.conjugate().vmult(t.vsub(e.position)),l=(e,t)=>e.quaternion.conjugate().vmult(t),u=e.maxForce??1e6,d=e.collideConnected??!1,f,p,m;switch(e.type){case`hinge`:{let t=new $(...e.axis??[0,1,0]);t.length()<1e-9&&t.set(0,1,0),t.normalize();let r=new qN(i,s,{pivotA:c(i,a),pivotB:c(s,a),axisA:l(i,t),axisB:l(s,t),maxForce:u,collideConnected:d});e.limits&&(m={A:i,B:s,pivotB:c(s,a),axisB:l(s,t),rel0:s.quaternion.conjugate().mult(i.quaternion),min:Math.min(e.limits[0],e.limits[1]),max:Math.max(e.limits[0],e.limits[1])}),e.motor&&(r.enableMotor(),r.setMotorSpeed(n?e.motor.speed:-e.motor.speed),r.setMotorMaxForce(e.motor.maxForce??100)),f=r;break}case`point`:f=new BN(i,c(i,a),s,c(s,a),u),f.collideConnected=d;break;case`distance`:{let t=e.distance??i.position.distanceTo(s.position);f=new WN(i,s,t,u),f.collideConnected=d;break}case`lock`:f=new GN(i,s,{maxForce:u}),f.collideConnected=d;break;case`spring`:{let t=e.pivot&&n?c(i,a):new $,r=e.pivot?c(s,a):new $,o=i.quaternion.vmult(t).vadd(i.position),l=s.quaternion.vmult(r).vadd(s.position);p=new tP(i,s,{localAnchorA:t,localAnchorB:r,restLength:e.restLength??o.distanceTo(l),stiffness:e.stiffness??50,damping:e.damping??1});break}}return f&&this.world.addConstraint(f),this.joints.push({id:r,a:e.a,b:e.b,constraint:f,spring:p,anchor:o,limit:m}),r}removeJoint(e){let t=this.joints.findIndex(t=>t.id===e);if(t<0)return;let n=this.joints[t];n.constraint&&this.world.removeConstraint(n.constraint),n.anchor&&this.world.removeBody(n.anchor),this.joints.splice(t,1)}setMotorSpeed(e,t){let n=this.joints.find(t=>t.id===e);n?.constraint instanceof qN&&(n.constraint.enableMotor(),n.constraint.setMotorSpeed(n.b?t:-t),this.byId.get(n.a)?.main.wakeUp())}hasJoints(e){return this.joints.some(t=>t.a===e||t.b===e)}jointIds(){return this.joints.map(e=>e.id)}onCollision(e){this.beginHandlers.push(e)}onCollisionEnd(e){this.endHandlers.push(e)}isGrounded(e){return e.character?e.onGround:!!this.contactGround(e)}contactGround(e){let t=null;for(let n of this.contactsNow.values()){if(n.trigger)continue;let r=n.a===e&&-n.info.normal[1]>.5?n.b:n.b===e&&n.info.normal[1]>.5?n.a:null;if(r){if(r.type===`kinematic`)return r;t??=r}}return t}updateGround(e){let t=e.main,n=this.contactGround(e),r=this.time-e.jumpedAt<.15,i=t.velocity.y>1,a=r&&i?null:n;if(!a&&!i&&!r){let n=this.aabb(e);if(n){let r=[t.position.x,t.position.y,t.position.z],i=t.position.y-n.lowerBound.y+DI,o=this.raycast(r,[0,-1,0],i,{triggers:!1,mask:t.collisionFilterMask,ignore:t=>t.id===e.id});if(o&&o.normal[1]>.5&&(a=this.byId.get(o.body.id)??null,a)){let[t,n]=e.order<a.order?[e,a]:[a,e],r=`${t.id}|${n.id}`,i=o.normal;if(!this.contactsNow.has(r)){let a=t===e?[-i[0],-i[1],-i[2]]:[i[0],i[1],i[2]];this.contactsNow.set(r,{a:t,b:n,trigger:!1,info:{point:o.point,normal:a,impulse:0,speed:0}})}}}}e.ground=a,e.onGround=!!a}groundOf(e){let t=this.byId.get(e);if(!t)return null;let n=t.character?t.ground:this.contactGround(t);return n?n.view:null}grounded(e){let t=this.byId.get(e);return!!t&&this.isGrounded(t)}moveCharacter(e,t,n={}){let r=this.byId.get(e);if(!r||r.type===`static`)return;this.makeCharacter(r);let i=r.main,[a,o]=t,s=Math.hypot(a,o);s>1&&(a/=s,o/=s);let c=n.speed??5,l=(n.acceleration??40)*(this.isGrounded(r)||r.type!==`dynamic`?1:n.airControl??.35)*this.stepDt,u=(e,t)=>e+Math.max(-l,Math.min(l,t-e)),d=u(i.velocity.x,a*c),f=u(i.velocity.z,o*c);i.velocity.set(d,i.velocity.y,f),r.type!==`dynamic`&&r.userVel.set(d,i.velocity.y,f),i.wakeUp()}jump(e,t=6){let n=this.byId.get(e);return!n||n.type!==`dynamic`||(this.makeCharacter(n),!(this.isGrounded(n)||this.time-n.lastGrounded<=.12)||this.time-n.jumpedAt<.2)?!1:(n.jumpedAt=this.time,n.lastGrounded=-1/0,n.onGround=!1,n.main.velocity.y=t,n.main.wakeUp(),!0)}makeCharacter(e){if(e.character)return;e.character=!0,e.view.character=!0;let t=e.main;t.fixedRotation=!0,t.angularVelocity.set(0,0,0),t.allowSleep=!1,t.updateMassProperties();let n=t.material?this.materialProps.get(t.material):void 0;t.material=this.material(n?.name,0,0)}step(e){this.stepDt=e;let t=this.substeps;for(let n of this.recs){if(!n.ccd||n.main.sleepState===_M.SLEEPING)continue;let r=n.main.velocity.length()*e;t=Math.max(t,Math.min(8,Math.ceil(r/(.5*n.minExtent))))}let n=e/t;this.wakeAhead(e);let r=[];for(let t of this.recs){if(!t.kinFrom)continue;let n={p:t.main.position.clone(),q:t.main.quaternion.clone()},i=n.p.vsub(t.kinFrom.p);if(i.length()<2.5&&t.type===`kinematic`){for(let e of[t.main,...t.extra])e.position.copy(t.kinFrom.p),e.quaternion.copy(t.kinFrom.q);t.main.velocity.copy(i.scale(1/e).vadd(t.userVel));let a=n.q.mult(t.kinFrom.q.conjugate());a.w<0&&a.set(-a.x,-a.y,-a.z,-a.w);let o=Math.sqrt(Math.max(0,1-a.w*a.w)),s=2*Math.acos(Math.min(1,a.w));o>1e-6?t.main.angularVelocity.set(a.x/o*s/e,a.y/o*s/e,a.z/o*s/e):t.main.angularVelocity.set(0,0,0);for(let e of t.extra)e.velocity.copy(t.main.velocity),e.angularVelocity.copy(t.main.angularVelocity);r.push({rec:t,...n})}t.kinFrom=null}for(let e of this.recs){if(e.carry=null,!e.character||e.type!==`dynamic`||!e.onGround||e.ground?.type!==`kinematic`)continue;let t=e.ground.main,n=e.main.position.vsub(t.position),r=t.velocity.vadd(t.angularVelocity.cross(n));r.lengthSquared()<1e-10||(e.carry=r,e.main.velocity.vadd(r,e.main.velocity))}let i=/* @__PURE__ */ new Map,a=this.world.gravity;for(let e=0;e<t;e++){for(let e of this.recs){if(e.type!==`dynamic`)continue;let t=e.main;e.gravityScale!==1&&t.force.vadd(a.scale(t.mass*(e.gravityScale-1)),t.force);for(let n of e.forces)t.applyForce(n.f,n.p?n.p.vsub(t.position):new $);for(let n of e.torques)t.torque.vadd(n,t.torque)}for(let e of this.joints)e.spring?.applyForce();this.preVel.clear();for(let e of this.recs)e.type!==`static`&&this.preVel.set(e,e.main.velocity.clone());this.world.step(n);for(let e of this.joints)e.limit&&_I(e.limit);this.time+=n,this.collectContacts(i,n)}for(let e of this.recs)e.forces=[],e.torques=[];for(let e of this.recs)e.carry&&e.main.velocity.vsub(e.carry,e.main.velocity);for(let e of r)for(let t of[e.rec.main,...e.rec.extra])t.position.copy(e.p),t.quaternion.copy(e.q),t.velocity.copy(e.rec.userVel),t.angularVelocity.set(0,0,0),t.aabbNeedsUpdate=!0;for(let e of this.recs)if(e.type===`trigger`)for(let t of this.recs){if(t===e||t.type===`dynamic`||t.type===`trigger`||t.type===`static`||!this.filterOk(e,t))continue;let[n,r]=e.order<t.order?[e,t]:[t,e],a=`${n.id}|${r.id}`;if(i.has(a)||!this.overlapRecs(n,r))continue;let o=n.main.position,s=r.main.position,c=s.vsub(o),l=c.length()||1;i.set(a,{a:n,b:r,trigger:!0,info:{point:xI(o.vadd(s).scale(.5)),normal:[c.x/l,c.y/l,c.z/l],impulse:0,speed:0}})}let o=e=>e.type===`static`||e.main.sleepState===_M.SLEEPING;for(let[e,t]of this.contactsNow)!i.has(e)&&o(t.a)&&o(t.b)&&this.byId.has(t.a.id)&&this.byId.has(t.b.id)&&i.set(e,{...t,info:{...t.info,impulse:0,speed:0}});this.contactsPrev=this.contactsNow,this.contactsNow=i;for(let e of this.recs)e.character&&this.updateGround(e),this.isGrounded(e)&&(e.lastGrounded=this.time);for(let[e,t]of i)if(!this.contactsPrev.has(e))for(let e of this.beginHandlers)e(t.a.view,t.b.view,t.info);for(let[e,t]of this.contactsPrev)if(!i.has(e)&&this.byId.has(t.a.id)&&this.byId.has(t.b.id))for(let e of this.endHandlers)e(t.a.view,t.b.view)}wakeAhead(e){let t=null;for(let n of this.recs){if(n.type===`static`||n.type===`trigger`||n.main.sleepState===_M.SLEEPING)continue;let r=n.main.velocity;if(r.length()<.5)continue;let i=this.aabb(n);if(!i)continue;if(!t){t=[];for(let e of this.recs){if(e.type!==`dynamic`||e.main.sleepState!==_M.SLEEPING)continue;let n=this.aabb(e);n&&t.push({r:e,box:n})}}if(!t.length)return;let a=new $(Math.abs(r.x)*e*2+.05,Math.abs(r.y)*e*2+.05,Math.abs(r.z)*e*2+.05);i.lowerBound.vsub(a,i.lowerBound),i.upperBound.vadd(a,i.upperBound);for(let e of t)e.r.main.sleepState===_M.SLEEPING&&e.box.overlaps(i)&&this.wakeIsland(e.r)}}wakeIsland(e){let t=[e];for(e.main.wakeUp();t.length;){let e=t.pop();for(let n of this.contactsNow.values()){let r=n.a===e?n.b:n.b===e?n.a:null;r&&r.type===`dynamic`&&r.main.sleepState===_M.SLEEPING&&(r.main.wakeUp(),t.push(r))}}}filterOk(e,t){return(e.main.collisionFilterGroup&t.main.collisionFilterMask)!==0&&(t.main.collisionFilterGroup&e.main.collisionFilterMask)!==0}collectContacts(e,t){for(let n of this.world.contacts){let r=this.byBody.get(n.bi),i=this.byBody.get(n.bj);if(!r||!i||r===i)continue;let a=xI(n.ni),o=xI(n.bi.position.vadd(n.ri));i.order<r.order&&([r,i]=[i,r],a=[-a[0],-a[1],-a[2]],o=xI(n.bj.position.vadd(n.rj)));let s=`${r.id}|${i.id}`,c=Math.abs(n.multiplier)*t,l=e.get(s);if(l){c>l.info.impulse&&(l.info.impulse=c);continue}let u=new $,d=(this.preVel.get(i)??u).vsub(this.preVel.get(r)??u),f=Math.max(0,-(d.x*a[0]+d.y*a[1]+d.z*a[2]));e.set(s,{a:r,b:i,trigger:r.type===`trigger`||i.type===`trigger`,info:{point:o,normal:a,impulse:c,speed:this.contactsPrev.has(s)?0:f}})}}contacts(){return[...this.contactsNow.values()].map(e=>({a:e.a.view,b:e.b.view,info:e.info,trigger:e.trigger}))}contactsOf(e){let t=[];for(let n of this.contactsNow.values())n.a.id===e?t.push(n.b.view):n.b.id===e&&t.push(n.a.view);return t}overlaps(e,t){let n=this.byId.get(e),r=this.byId.get(t);return!n||!r||n===r?!1:this.overlapRecs(n,r)}overlapRecs(e,t){let n=this.aabb(e),r=this.aabb(t);if(!n||!r||!n.overlaps(r))return!1;for(let n of[e.main,...e.extra])for(let e of[t.main,...t.extra])if(this.bodiesOverlap(n,e))return!0;return!1}bodiesOverlap(e,t){let n=this.world.narrowphase,r=new eM,i=new eM,a=new $,o=new $;for(let s=0;s<e.shapes.length;s++){e.quaternion.mult(e.shapeOrientations[s],r),e.quaternion.vmult(e.shapeOffsets[s],a),a.vadd(e.position,a);let c=e.shapes[s];for(let s=0;s<t.shapes.length;s++){t.quaternion.mult(t.shapeOrientations[s],i),t.quaternion.vmult(t.shapeOffsets[s],o),o.vadd(t.position,o);let l=t.shapes[s];if(a.distanceTo(o)>c.boundingSphereRadius+l.boundingSphereRadius+.001)continue;let u=n[c.type|l.type];if(u&&(c.type<l.type?u.call(n,c,l,a,o,r,i,e,t,c,l,!0):u.call(n,l,c,o,a,i,r,t,e,c,l,!0)))return!0}}return!1}raycast(e,t,n=1/0,r={}){let i=Math.hypot(t[0],t[1],t[2]);if(i<1e-12)return null;let a=Number.isFinite(n)?n:1e4,o=[t[0]/i,t[1]/i,t[2]/i],s=new $(...e),c=new $(e[0]+o[0]*a,e[1]+o[1]*a,e[2]+o[2]*a),l=null;return this.world.raycastAll(s,c,{skipBackfaces:!0,collisionFilterMask:r.mask??-1,checkCollisionResponse:!1},e=>{let t=this.byBody.get(e.body);!t||r.triggers===!1&&t.type===`trigger`||r.ignore?.(t.view)||l&&e.distance>=l.distance||(l={body:t.view,distance:e.distance,point:xI(e.hitPointWorld),normal:xI(e.hitNormalWorld)})}),l}}}));function MI(e,t,n,r=0,i=24){for(let a=0;a<i;a++){let o=a/i*Math.PI*2,s=(a+1)/i*Math.PI*2,c=e=>n===`y`?[Math.cos(e)*t,r,Math.sin(e)*t]:n===`x`?[r,Math.cos(e)*t,Math.sin(e)*t]:[Math.cos(e)*t,Math.sin(e)*t,r];e.push(...c(o),...c(s))}}function NI(e){let t=[];switch(e.type){case`box`:{let[n,r,i]=e.half,a=[[-n,-r,-i],[n,-r,-i],[n,r,-i],[-n,r,-i],[-n,-r,i],[n,-r,i],[n,r,i],[-n,r,i]];for(let[e,n]of[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]])t.push(...a[e],...a[n]);break}case`sphere`:MI(t,e.radius,`x`),MI(t,e.radius,`y`),MI(t,e.radius,`z`);break;case`cylinder`:case`capsule`:{let n=e.radius,r=e.type===`capsule`?Math.max(e.height-2*n,0):e.height;MI(t,n,`y`,r/2),MI(t,n,`y`,-r/2);for(let e=0;e<8;e++){let i=e/8*Math.PI*2;t.push(Math.cos(i)*n,-r/2,Math.sin(i)*n,Math.cos(i)*n,r/2,Math.sin(i)*n)}if(e.type===`capsule`)for(let e of[1,-1])for(let i=0;i<12;i++){let a=i/12*(Math.PI/2),o=(i+1)/12*(Math.PI/2);for(let[i,s]of[[1,0],[0,1],[-1,0],[0,-1]])t.push(i*Math.cos(a)*n,e*(r/2+Math.sin(a)*n),s*Math.cos(a)*n,i*Math.cos(o)*n,e*(r/2+Math.sin(o)*n),s*Math.cos(o)*n)}break}case`convex`:for(let n of e.faces)for(let r=0;r<n.length;r++)t.push(...e.vertices[n[r]],...e.vertices[n[(r+1)%n.length]]);break;case`trimesh`:{let n=e.vertices,r=e.indices,i=r?r.length:n.length/3,a=e=>{let t=(r?r[e]:e)*3;return[n[t],n[t+1],n[t+2]]};for(let e=0;e+2<i;e+=3){let n=a(e),r=a(e+1),i=a(e+2);t.push(...n,...r,...r,...i,...i,...n)}break}case`heightfield`:{let n=e.data,r=e.elementSize,i=Math.max(1,Math.round(n.length/48));for(let e=0;e<n.length;e+=i)for(let a=0;a+i<n[e].length;a+=i)t.push(e*r,a*r,n[e][a],e*r,(a+i)*r,n[e][a+i]);for(let e=0;e<n[0].length;e+=i)for(let a=0;a+i<n.length;a+=i)t.push(a*r,e*r,n[a][e],(a+i)*r,e*r,n[a+i][e]);break}}if(e.offset||e.quat){let n=new V().compose(new B(...e.offset??[0,0,0]),new wi(...e.quat??[0,0,0,1]),new B(1,1,1)),r=new B;for(let e=0;e<t.length;e+=3)r.set(t[e],t[e+1],t[e+2]).applyMatrix4(n),t[e]=r.x,t[e+1]=r.y,t[e+2]=r.z}return t}var PI,FI,II=t((()=>{J(),PI={dynamic:4054148,static:5155071,kinematic:16755008,trigger:16732120,sleeping:10133670},FI=class{group=new ba;items=/* @__PURE__ */ new Map;constructor(e){this.group.name=`agent3d-physics-debug`,this.group.renderOrder=999,e.add(this.group)}sync(e){let t=/* @__PURE__ */ new Set;for(let n of e){t.add(n.id);let e=this.items.get(n.id);if(!e||e.body!==n){e&&this.drop(n.id);let t=n.shapes.flatMap(NI),r=new G;r.setAttribute(`position`,new W(t,3));let i=new uc({color:PI[n.type],depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9,toneMapped:!1}),a=new xc(r,i);a.renderOrder=999,a.frustumCulled=!1,this.group.add(a),e={lines:a,body:n},this.items.set(n.id,e)}let[r,i,a]=n.position,[o,s,c,l]=n.quaternion;e.lines.position.set(r,i,a),e.lines.quaternion.set(o,s,c,l),e.lines.material.color.setHex(n.sleeping?PI.sleeping:PI[n.type])}for(let e of[...this.items.keys()])t.has(e)||this.drop(e)}drop(e){let t=this.items.get(e);t&&(t.lines.removeFromParent(),t.lines.geometry.dispose(),t.lines.material.dispose(),this.items.delete(e))}dispose(){for(let e of[...this.items.keys()])this.drop(e);this.group.removeFromParent()}}})),LI,RI,zI,BI,VI,HI,UI,WI,GI,KI,qI,JI,YI=t((()=>{J(),LI=0,RI=1,zI=new B,BI=new bf,VI=new Fo,HI=new B,UI=new Ua,WI=class{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new JI,this.unassigned=new JI,this.vertices=[]}setFromPoints(e){if(e.length>=4){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.vertices.push(new qI(e[t]));this._compute()}return this}setFromObject(e){let t=[];return e.updateMatrixWorld(!0),e.traverse(function(e){let n=e.geometry;if(n!==void 0){let r=n.attributes.position;if(r!==void 0)for(let n=0,i=r.count;n<i;n++){let i=new B;i.fromBufferAttribute(r,n).applyMatrix4(e.matrixWorld),t.push(i)}}}),this.setFromPoints(t)}containsPoint(e){let t=this.faces;for(let n=0,r=t.length;n<r;n++)if(t[n].distanceToPoint(e)>this.tolerance)return!1;return!0}intersectRay(e,t){let n=this.faces,r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t],o=a.distanceToPoint(e.origin),s=a.normal.dot(e.direction);if(o>0&&s>=0)return null;let c=s===0?0:-o/s;if(!(c<=0)&&(s>0?i=Math.min(c,i):r=Math.max(c,r),r>i))return null}return r===-1/0?e.at(i,t):e.at(r,t),t}intersectsRay(e){return this.intersectRay(e,zI)!==null}makeEmpty(){return this.faces=[],this.vertices=[],this}_addVertexToFace(e,t){return e.face=t,t.outside===null?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this}_removeVertexFromFace(e,t){return e===t.outside&&(t.outside=e.next!==null&&e.next.face===t?e.next:null),this.assigned.remove(e),this}_removeAllVerticesFromFace(e){if(e.outside!==null){let t=e.outside,n=e.outside;for(;n.next!==null&&n.next.face===e;)n=n.next;return this.assigned.removeSubList(t,n),t.prev=n.next=null,e.outside=null,t}}_deleteFaceVertices(e,t){let n=this._removeAllVerticesFromFace(e);if(n!==void 0){if(t===void 0)this.unassigned.appendChain(n);else{let e=n;do{let n=e.next;t.distanceToPoint(e.point)>this.tolerance?this._addVertexToFace(e,t):this.unassigned.append(e),e=n}while(e!==null)}}return this}_resolveUnassignedPoints(e){if(this.unassigned.isEmpty()===!1){let t=this.unassigned.first();do{let n=t.next,r=this.tolerance,i=null;for(let n=0;n<e.length;n++){let a=e[n];if(a.mark===LI){let e=a.distanceToPoint(t.point);if(e>r&&(r=e,i=a),r>1e3*this.tolerance)break}}i!==null&&this._addVertexToFace(t,i),t=n}while(t!==null)}return this}_computeExtremes(){let e=new B,t=new B,n=[],r=[];for(let e=0;e<3;e++)n[e]=r[e]=this.vertices[0];e.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let i=0,a=this.vertices.length;i<a;i++){let a=this.vertices[i],o=a.point;for(let t=0;t<3;t++)o.getComponent(t)<e.getComponent(t)&&(e.setComponent(t,o.getComponent(t)),n[t]=a);for(let e=0;e<3;e++)o.getComponent(e)>t.getComponent(e)&&(t.setComponent(e,o.getComponent(e)),r[e]=a)}return this.tolerance=3*2**-52*(Math.max(Math.abs(e.x),Math.abs(t.x))+Math.max(Math.abs(e.y),Math.abs(t.y))+Math.max(Math.abs(e.z),Math.abs(t.z))),{min:n,max:r}}_computeInitialHull(){let e=this.vertices,t=this._computeExtremes(),n=t.min,r=t.max,i=0,a=0;for(let e=0;e<3;e++){let t=r[e].point.getComponent(e)-n[e].point.getComponent(e);t>i&&(i=t,a=e)}let o=n[a],s=r[a],c,l;i=0,BI.set(o.point,s.point);for(let t=0,n=this.vertices.length;t<n;t++){let n=e[t];if(n!==o&&n!==s){BI.closestPointToPoint(n.point,!0,HI);let e=HI.distanceToSquared(n.point);e>i&&(i=e,c=n)}}i=-1,VI.setFromCoplanarPoints(o.point,s.point,c.point);for(let t=0,n=this.vertices.length;t<n;t++){let n=e[t];if(n!==o&&n!==s&&n!==c){let e=Math.abs(VI.distanceToPoint(n.point));e>i&&(i=e,l=n)}}let u=[];if(VI.distanceToPoint(l.point)<0){u.push(GI.create(o,s,c),GI.create(l,s,o),GI.create(l,c,s),GI.create(l,o,c));for(let e=0;e<3;e++){let t=(e+1)%3;u[e+1].getEdge(2).setTwin(u[0].getEdge(t)),u[e+1].getEdge(1).setTwin(u[t+1].getEdge(0))}}else{u.push(GI.create(o,c,s),GI.create(l,o,s),GI.create(l,s,c),GI.create(l,c,o));for(let e=0;e<3;e++){let t=(e+1)%3;u[e+1].getEdge(2).setTwin(u[0].getEdge((3-e)%3)),u[e+1].getEdge(0).setTwin(u[t+1].getEdge(1))}}for(let e=0;e<4;e++)this.faces.push(u[e]);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n!==o&&n!==s&&n!==c&&n!==l){i=this.tolerance;let e=null;for(let t=0;t<4;t++){let r=this.faces[t].distanceToPoint(n.point);r>i&&(i=r,e=this.faces[t])}e!==null&&this._addVertexToFace(n,e)}}return this}_reindexFaces(){let e=[];for(let t=0;t<this.faces.length;t++){let n=this.faces[t];n.mark===LI&&e.push(n)}return this.faces=e,this}_nextVertexToAdd(){if(this.assigned.isEmpty()===!1){let e,t=0,n=this.assigned.first().face,r=n.outside;do{let i=n.distanceToPoint(r.point);i>t&&(t=i,e=r),r=r.next}while(r!==null&&r.face===n);return e}}_computeHorizon(e,t,n,r){this._deleteFaceVertices(n),n.mark=RI;let i;i=t===null?t=n.getEdge(0):t.next;do{let t=i.twin,n=t.face;n.mark===LI&&(n.distanceToPoint(e)>this.tolerance?this._computeHorizon(e,t,n,r):r.push(i)),i=i.next}while(i!==t);return this}_addAdjoiningFace(e,t){let n=GI.create(e,t.tail(),t.head());return this.faces.push(n),n.getEdge(-1).setTwin(t.twin),n.getEdge(0)}_addNewFaces(e,t){this.newFaces=[];let n=null,r=null;for(let i=0;i<t.length;i++){let a=t[i],o=this._addAdjoiningFace(e,a);n===null?n=o:o.next.setTwin(r),this.newFaces.push(o.face),r=o}return n.next.setTwin(r),this}_addVertexToHull(e){let t=[];return this.unassigned.clear(),this._removeVertexFromFace(e,e.face),this._computeHorizon(e.point,null,e.face,t),this._addNewFaces(e,t),this._resolveUnassignedPoints(this.newFaces),this}_cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}_compute(){let e;for(this._computeInitialHull();(e=this._nextVertexToAdd())!==void 0;)this._addVertexToHull(e);return this._reindexFaces(),this._cleanup(),this}},GI=class e{constructor(){this.normal=new B,this.midpoint=new B,this.area=0,this.constant=0,this.outside=null,this.mark=LI,this.edge=null}static create(t,n,r){let i=new e,a=new KI(t,i),o=new KI(n,i),s=new KI(r,i);return a.next=s.prev=o,o.next=a.prev=s,s.next=o.prev=a,i.edge=a,i.compute()}getEdge(e){let t=this.edge;for(;e>0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t}compute(){let e=this.edge.tail(),t=this.edge.head(),n=this.edge.next.head();return UI.set(e.point,t.point,n.point),UI.getNormal(this.normal),UI.getMidpoint(this.midpoint),this.area=UI.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(e){return this.normal.dot(e)-this.constant}},KI=class{constructor(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){let e=this.head(),t=this.tail();return t===null?-1:t.point.distanceTo(e.point)}lengthSquared(){let e=this.head(),t=this.tail();return t===null?-1:t.point.distanceToSquared(e.point)}setTwin(e){return this.twin=e,e.twin=this,this}},qI=class{constructor(e){this.point=e,this.prev=null,this.next=null,this.face=null}},JI=class{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(e,t){return t.prev=e.prev,t.next=e,t.prev===null?this.head=t:t.prev.next=t,e.prev=t,this}insertAfter(e,t){return t.prev=e,t.next=e.next,t.next===null?this.tail=t:t.next.prev=t,e.next=t,this}append(e){return this.head===null?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this}appendChain(e){for(this.head===null?this.head=e:this.tail.next=e,e.prev=this.tail;e.next!==null;)e=e.next;return this.tail=e,this}remove(e){return e.prev===null?this.head=e.next:e.prev.next=e.next,e.next===null?this.tail=e.prev:e.next.prev=e.prev,this}removeSubList(e,t){return e.prev===null?this.head=t.next:e.prev.next=t.next,t.next===null?this.tail=e.prev:t.next.prev=e.prev,this}isEmpty(){return this.head===null}}}));function XI(e){e.updateWorldMatrix(!0,!0);let t=new B,n=new wi,r=new B;return e.matrixWorld.decompose(t,n,r),{inv:new V().compose(t,n,new B(1,1,1)).invert(),scale:r}}function ZI(e,t){let n=e.userData?.a3dId;return!!n&&n!==t&&!n.includes(`/`)}function QI(e,t=`own`,n){let r=[],i=e.userData?.a3dId,a=o=>{if(o!==e&&(t===`own`&&ZI(o,i)||n?.(o)))return;let s=o;s.isMesh&&s.geometry?.getAttribute(`position`)&&!o.userData.noCollide&&r.push(s);for(let e of o.children)a(e)};return a(e),r}function $I(e){let t=QI(e.object);return t.length?t:QI(e.object,`tree`,eL(e.objectDef))}function eL(e){let t=/* @__PURE__ */ new Set,n=e=>{for(let r of e??[])r.body&&t.add(r.id),n(r.children)};return n(e?.children),e=>t.has(e.userData?.a3dId)}function tL(e,t){let n=new Wa,r=new Wa,i=new V;for(let a of e){let e=a;e.isInstancedMesh?(e.boundingBox||e.computeBoundingBox(),e.boundingBox&&r.copy(e.boundingBox)):(a.geometry.boundingBox||a.geometry.computeBoundingBox(),r.copy(a.geometry.boundingBox)),r.isEmpty()||n.union(r.applyMatrix4(i.multiplyMatrices(t,a.matrixWorld)))}return n}function nL(e,t){return tL($I({object:e,objectDef:t}),XI(e).inv)}function rL(e,t){let{inv:n}=XI(e),r=[tL(QI(e),n)],i=eL(t),a=e.userData?.a3dId,o=e=>{for(let t of e.children)i(t)||(ZI(t,a)?r.push(tL(QI(t,`tree`,i),n)):o(t))};return o(e),r.filter(e=>!e.isEmpty()).map(e=>({size:e.getSize(new B),center:e.getCenter(new B)}))}function iL(e,t){let{inv:n}=XI(e.object),r=new V,i=new B,a=[],o=0;for(let s of $I(e)){if(s.isInstancedMesh)continue;let e=s.geometry,c=e.getAttribute(`position`),l=e.getIndex(),u=l?l.count:c.count;if(o+=u/3,o>t)return null;r.multiplyMatrices(n,s.matrixWorld);let d=new Float32Array(u*3);for(let e=0;e<u;e++)i.fromBufferAttribute(c,l?l.getX(e):e).applyMatrix4(r),d[e*3]=i.x,d[e*3+1]=i.y,d[e*3+2]=i.z;a.push(d)}let s=new Float32Array(a.reduce((e,t)=>e+t.length,0)),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function aL(e,t){let{inv:n}=XI(e.object),r=new V,i=[],a=$I(e),o=a.reduce((e,t)=>e+t.geometry.getAttribute(`position`).count,0),s=Math.max(1,Math.ceil(o/t));for(let e of a){let t=e.geometry.getAttribute(`position`);r.multiplyMatrices(n,e.matrixWorld);for(let e=0;e<t.count;e+=s)i.push(new B().fromBufferAttribute(t,e).applyMatrix4(r))}let c=new Wa;for(let e of a){let t=e.geometry.getAttribute(`position`);r.multiplyMatrices(n,e.matrixWorld);let a=[];for(let e=0;e<t.count;e++){let n=new B().fromBufferAttribute(t,e).applyMatrix4(r);for(let e=0;e<3;e++)(!a[e*2]||n.getComponent(e)<a[e*2].getComponent(e))&&(a[e*2]=n),(!a[e*2+1]||n.getComponent(e)>a[e*2+1].getComponent(e))&&(a[e*2+1]=n)}for(let e of a)e&&(i.push(e),c.expandByPoint(e))}return i}function oL(e,t){if(e.length<4)return null;let n;try{n=new WI().setFromPoints(e)}catch{return null}let r=/* @__PURE__ */ new Map,i=[],a=[];for(let e of n.faces){let n=[],o=e.edge;do{let e=o.head().point,a=r.get(e);a===void 0&&(a=i.length,r.set(e,a),i.push([e.x-t.x,e.y-t.y,e.z-t.z])),n.push(a),o=o.next}while(o!==e.edge);n.length>=3&&a.push(n)}return a.length>=4?{vertices:i,faces:a}:null}function sL(e,t){let n=e.offset,r=hL(e.rotation),i=e.size?new B(...e.size):t;switch(e.shape){case`sphere`:return{type:`sphere`,radius:e.radius??Math.max(i.x,i.y,i.z)/2,offset:n,quat:r};case`cylinder`:return{type:`cylinder`,radius:e.radius??Math.max(i.x,i.z)/2,height:e.height??i.y,offset:n,quat:r};case`capsule`:return{type:`capsule`,radius:e.radius??Math.max(i.x,i.z)/2,height:e.height??i.y,offset:n,quat:r};default:return{type:`box`,half:[i.x/2,i.y/2,i.z/2],offset:n,quat:r}}}function cL(e){let t=e.objectDef,n=e.def.type===`static`||e.def.type===`kinematic`;if(e.built?.heightAt&&n&&typeof e.object.userData.size==`number`)return`heightfield`;if(t?.kind===`mesh`){let e=t.geometry?.type;return e===`sphere`||e===`icosahedron`||e===`dodecahedron`?`sphere`:e===`capsule`?`capsule`:e===`cylinder`?t.geometry.radiusTop===void 0||t.geometry.radiusTop===t.geometry.radiusBottom?`cylinder`:`convex`:e===`box`||e===`roundedBox`||e===`plane`?`box`:n?`trimesh`:`convex`}return t?.kind===`model`||t?.kind===`svg`?n?`trimesh`:`convex`:t?.kind===`generator`&&n?`trimesh`:`box`}function lL(e){let t=e.def,n=nL(e.object,e.objectDef),r=n.isEmpty(),i=r?new B(1,1,1):n.getSize(new B),a=r?new B:n.getCenter(new B);t.size&&i.set(t.size[0],t.size[1],t.size[2]);let o=t.offset?new B(...t.offset):a.clone(),s=t.shape??`box`;s===`auto`&&(s=cL(e));let c=()=>({type:`box`,half:[i.x/2,i.y/2,i.z/2]});switch(s){case`sphere`:return{shapes:[{type:`sphere`,radius:t.radius??Math.max(i.x,i.y,i.z)/2}],offset:o};case`cylinder`:return{shapes:[{type:`cylinder`,radius:t.radius??Math.max(i.x,i.z)/2,height:t.height??i.y}],offset:o};case`capsule`:return{shapes:[{type:`capsule`,radius:t.radius??Math.max(i.x,i.z)/2,height:t.height??i.y}],offset:o};case`compound`:{let n=t.offset?new B(...t.offset):new B;if(!t.shapes?.length){let t=rL(e.object,e.objectDef);if(t.length)return{shapes:t.map(e=>({type:`box`,half:[e.size.x/2,e.size.y/2,e.size.z/2],offset:[e.center.x-n.x,e.center.y-n.y,e.center.z-n.z]})),offset:n}}let r=(t.shapes??[]).map(e=>{let t=sL(e,i),r=e.offset??[0,0,0];return{...t,offset:[r[0]-n.x,r[1]-n.y,r[2]-n.z]}});return r.length?{shapes:r,offset:n}:{shapes:[c()],offset:o}}case`convex`:{let t=oL(aL(e,mL),o);return t?{shapes:[{type:`convex`,...t}],offset:o}:{shapes:[c()],offset:o,note:`convex hull failed (too few points): using the bounding box`}}case`heightfield`:return uL(e)||l(e,`heightfield needs a terrain generator (heightAt): using the triangles`);case`trimesh`:return l(e);default:return{shapes:[c()],offset:o}}function l(e,t){let n=iL(e,pL);if(!n||n.length===0)return{shapes:[c()],offset:o,note:n?`no triangles: using the bounding box`:`more than ${pL} triangles: using the bounding box (use a simpler collision mesh, "compound" or "box")`};for(let e=0;e<n.length;e+=3)n[e]-=o.x,n[e+1]-=o.y,n[e+2]-=o.z;return{shapes:[{type:`trimesh`,vertices:n}],offset:o,note:t}}}function uL(e){let t=e.built?.heightAt?.bind(e.built),n=e.object.userData.size;if(!t||typeof n!=`number`||!(n>0))return null;let{scale:r}=XI(e.object),i=0;for(let t of QI(e.object))if(t.userData.materialTarget||t.name===`terrain-ground`){let e=t.geometry;i=(e.getIndex()?.count??e.getAttribute(`position`).count)/3;break}let a=Math.min(160,Math.max(8,i?Math.round(Math.sqrt(i/2)):64)),o=a+1,s=n/a,c=[];for(let e=0;e<o;e++){let i=[];for(let a=0;a<o;a++)i.push(t(-n/2+e*s,n/2-a*s)*r.y);c.push(i)}let l=r.x,u=new B;return{shapes:[{type:`heightfield`,data:c,elementSize:s*l,offset:[-n/2*l,0,n/2*l],quat:[-Math.SQRT1_2,0,0,Math.SQRT1_2]}],offset:u}}function dL(e,t){e.updateWorldMatrix(!0,!1);let n=new B,r=new wi,i=new B;return e.matrixWorld.decompose(n,r,i),n.add(t.clone().applyQuaternion(r)),{position:[n.x,n.y,n.z],quaternion:[r.x,r.y,r.z,r.w]}}function fL(e,t){let{shapes:n,offset:r,note:i}=lL(t),a=dL(t.object,r),o=t.def,s=o.angularVelocity;return{init:{id:e,type:o.type,shapes:n,position:a.position,quaternion:a.quaternion,velocity:o.velocity,angularVelocity:s?[s[0]*LS,s[1]*LS,s[2]*LS]:void 0,mass:o.mass,friction:o.friction,restitution:o.restitution,material:o.material,linearDamping:o.linearDamping,angularDamping:o.angularDamping,gravityScale:o.gravityScale,fixedRotation:o.fixedRotation,character:o.character,sleep:o.sleep,ccd:o.ccd,layer:o.layer,collidesWith:o.collidesWith},offset:r,note:i}}var pL,mL,hL,gL=t((()=>{J(),YI(),zS(),pL=12e3,mL=600,hL=e=>{if(!e)return;let t=new wi().setFromEuler(new na(e[0]*LS,e[1]*LS,e[2]*LS));return[t.x,t.y,t.z,t.w]}})),_L=/* @__PURE__ */ n({PhysicsBridge:()=>vL,PhysicsWorld:()=>AI}),vL,yL=t((()=>{J(),zS(),jI(),II(),gL(),vL=class{def;issue;engine;offsets=/* @__PURE__ */ new Map;scales=/* @__PURE__ */ new Map;scaleWarned=/* @__PURE__ */ new Set;debug=null;world;constructor(e,t,n){this.def=e,this.issue=n,this.world=t;let r=e?.gravity??[0,-9.81,0];this.engine=new AI({gravity:[r[0],r[1],r[2]],iterations:e?.iterations,substeps:e?.substeps,sleep:e?.sleep,materials:e?.materials,contacts:e?.contacts,layers:e?.layers}),e?.debug&&(this.debug=new FI(t.scene))}attachAll(){this.world.scene.updateMatrixWorld(!0);for(let e of this.world.entries.values())this.addEntry(e),this.addGeneratorBodies(e);(this.def?.joints??[]).forEach((e,t)=>{this.engine.addJoint({id:e.id??`joint-${t+1}`,type:e.type,a:e.a,b:e.b,pivot:e.pivot,axis:e.axis,distance:e.distance,restLength:e.restLength,stiffness:e.stiffness,damping:e.damping,motor:e.motor?{speed:e.motor.speed*LS,maxForce:e.motor.maxForce}:void 0,limits:e.limits?[e.limits[0]*LS,e.limits[1]*LS]:void 0,maxForce:e.maxForce,collideConnected:e.collideConnected})||this.issue({code:`physics`,message:`physics.joints[${t}]: "${e.a}"${e.b?` or "${e.b}"`:``} has no body.`,path:`physics.joints[${t}]`})}),this.debug?.sync(this.engine.bodies)}addEntry(e,t){let n=t??e.def.body;if(!n||e.kind===`light`)return!1;let{init:r,offset:i,note:a}=fL(e.id,{object:e.object,def:n,objectDef:e.def,built:e.built});return a&&this.issue({code:`physics`,message:`objects#${e.id}.body: ${a}.`,path:`objects#${e.id}.body`}),this.offsets.set(e.id,i),this.scales.set(e.id,e.object.getWorldScale(new B)),this.engine.add(r),!0}addGeneratorBodies(e){if(e.kind===`light`||e.def.body)return;let t=e.object.userData.bodies;if(!Array.isArray(t)||!t.length)return;e.object.updateWorldMatrix(!0,!1);let n=new B,r=new wi,i=new B;e.object.matrixWorld.decompose(n,r,i);let a=t.map(e=>({type:`box`,half:[Math.abs(e.max[0]-e.min[0])*i.x/2,Math.abs(e.max[1]-e.min[1])*i.y/2,Math.abs(e.max[2]-e.min[2])*i.z/2],offset:[(e.min[0]+e.max[0])/2*i.x,(e.min[1]+e.max[1])/2*i.y,(e.min[2]+e.max[2])/2*i.z]}));this.offsets.set(e.id,new B),this.engine.add({id:e.id,type:`static`,shapes:a,position:[n.x,n.y,n.z],quaternion:[r.x,r.y,r.z,r.w]})}has(e){return!!this.engine.get(e)}moved(e){let t=this.world.entries.get(e),n=this.offsets.get(e),r=this.engine.get(e);if(!t||!n||!r)return;let i=this.scales.get(e);if(i&&t.def.body){let n=t.object.getWorldScale(new B);if(Math.abs(n.x-i.x)>1e-4*Math.abs(i.x)+1e-6||Math.abs(n.y-i.y)>1e-4*Math.abs(i.y)+1e-6||Math.abs(n.z-i.z)>1e-4*Math.abs(i.z)+1e-6){if(this.engine.hasJoints(e))this.scaleWarned.has(e)||(this.scaleWarned.add(e),this.issue({code:`physics`,message:`objects#${e}: its scale changed but its collider keeps the start size (the body is held by a joint).`,path:`objects#${e}.body`}));else{let n=[...r.velocity],i=[...r.angularVelocity];t.object.updateWorldMatrix(!0,!1),this.addEntry(t),this.engine.setVelocity(e,n),this.engine.setAngularVelocity(e,i),this.debug?.sync(this.engine.bodies);return}}}let a=dL(t.object,n);this.engine.setPose(e,a.position,a.quaternion)}remove(e){this.engine.remove(e),this.offsets.delete(e),this.scales.delete(e)}step(e){this.engine.step(e),this.syncObjects(),this.debug?.sync(this.engine.bodies)}syncObjects(){let e=new B,t=new wi,n=new wi;for(let r of this.engine.bodies){if(r.type!==`dynamic`&&r.type!==`kinematic`||r.sleeping)continue;if(r.type===`kinematic`){let e=r.velocity,t=r.angularVelocity;if(!e[0]&&!e[1]&&!e[2]&&!t[0]&&!t[1]&&!t[2])continue}let i=this.world.entries.get(r.id);if(!i)continue;let a=i.object;t.set(...r.quaternion),e.set(...r.position).sub((this.offsets.get(r.id)??new B).clone().applyQuaternion(t)),a.parent&&(a.parent.updateWorldMatrix(!0,!1),a.parent.worldToLocal(e),a.parent.getWorldQuaternion(n),t.premultiply(n.invert())),a.position.copy(e),a.quaternion.copy(t),i.animated&&(i.rest.position.copy(e),i.rest.quaternion.copy(t))}}dispose(){this.debug?.dispose(),this.debug=null}}})),bL=/* @__PURE__ */ n({GameHost:()=>TL});function xL(e,t=1,n){return{get x(){return e().x/t},set x(r){e().x=r*t,n?.()},get y(){return e().y/t},set y(r){e().y=r*t,n?.()},get z(){return e().z/t},set z(r){e().z=r*t,n?.()},set(r,i,a){e().set(r*t,i*t,a*t),n?.()}}}var SL,CL,wL,TL,EL=t((()=>{J(),Tv(),zS(),pj(),zj(),SL=null,CL=()=>SL??=Promise.resolve().then(()=>(yL(),_L)),wL=/* @__PURE__ */ new Map,TL=class e{opts;world;physics=null;state={};hud=null;audio;instances=[];factories=[];objCache=/* @__PURE__ */ new Map;handlers=/* @__PURE__ */ new Map;collisionHandlers=[];collisionEndHandlers=[];triggerEnterHandlers=[];triggerExitHandlers=[];rng;simTime=0;acc=0;stepDt;pendingPressed=/* @__PURE__ */ new Set;pendingJust=!1;pendingSwipe=null;stepPressed=/* @__PURE__ */ new Set;stepJust=!1;stepSwipe=null;shake={intensity:0,duration:0,until:0};restartRequested=!1;cloneCounter=0;unlockListeners=null;api;constructor(e){this.opts=e,this.stepDt=Math.min(Math.max(e.scene.physics?.step??1/60,1/480),1/10),this.rng=dv(e.scene.seed??1),this.audio=fj(e.scene.audio,e.resolveAsset,(t,n)=>e.issue({code:`asset-load`,message:t,path:n})),this.api=this.createApi()}static async create(t,n){let r=new e(t);if(r.hud=t.scene.ui?.elements?.length||t.scene.audio?Nj(t.container,t.scene.ui,e=>r.emit(e)):null,t.scene.audio&&r.hud){let e=()=>r.hud.setMuteButton(r.audio.muted(),()=>{r.audio.unlock(),r.audio.setMuted(!r.audio.muted()),e()});e()}if(!t.deterministic){let e=()=>r.audio.unlock();t.container.addEventListener(`pointerdown`,e),t.container.addEventListener(`keydown`,e),r.unlockListeners=()=>{t.container.removeEventListener(`pointerdown`,e),t.container.removeEventListener(`keydown`,e)}}return await r.loadScripts(),await r.attach(n),r}async loadScripts(){let{scene:e,scriptSources:t,resolveAsset:n,issue:r}=this.opts;for(let i of e.scripts??[]){let e=t?.[i],a=e===void 0?n(i):`src:${i}:${e.length}:${e.slice(0,64)}`,o=wL.get(a);o||(o=(async()=>{let t,r=null;e===void 0?t=n(i):(t=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),r=t);try{let e=await import(
|
|
6062
|
+
`,uM=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M19 5a10 10 0 0 1 0 14"/></svg>`,dM=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H2v6h4l5 4V5z"/><path d="m23 9-6 6"/><path d="m17 9 6 6"/></svg>`}));function pM(e,t,n){n.vsub(e,KN);let r=KN.dot(t);return t.scale(r,qN),qN.vadd(e,qN),n.distanceTo(qN)}function mM(e,t,n,r,i,a,o,s,c){c.x=((a-s)*(e-o)+(o-i)*(t-s))/((a-s)*(n-o)+(o-i)*(r-s)),c.y=((s-r)*(e-o)+(n-o)*(t-s))/((a-s)*(n-o)+(o-i)*(r-s)),c.z=1-c.x-c.y}function hM(e,t,n){let r=null,i=e.length;for(let a=0;a!==i;a++){let o=e[a],s=FF;e[(a+1)%i].vsub(o,s);let c=IF;s.cross(t,c);let l=LF;n.vsub(o,l);let u=c.dot(l);if(r===null||u>0&&r===!0||u<=0&&r===!1)r===null&&(r=u>0);else return!1}return!0}function gM(e,t){e.push((t&4294901760)>>16,t&65535)}var _M,vM,$,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM,$M,eN,tN,nN,rN,iN,aN,oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,ON,kN,AN,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN,qN,JN,YN,XN,ZN,QN,$N,eP,tP,nP,rP,iP,aP,oP,sP,cP,lP,uP,dP,fP,pP,mP,hP,gP,_P,vP,yP,bP,xP,SP,CP,wP,TP,EP,DP,OP,kP,AP,jP,MP,NP,PP,FP,IP,LP,RP,zP,BP,VP,HP,UP,WP,GP,KP,qP,JP,YP,XP,ZP,QP,$P,eF,tF,nF,rF,iF,aF,oF,sF,cF,lF,uF,dF,fF,pF,mF,hF,gF,_F,vF,yF,bF,xF,SF,CF,wF,TF,EF,DF,OF,kF,AF,jF,MF,NF,PF,FF,IF,LF,RF,zF,BF,VF,HF,UF,WF,GF,KF,qF,JF,YF,XF,ZF,QF,$F,eI,tI,nI,rI,iI,aI,oI,sI,cI,lI,uI,dI,fI,pI,mI,hI,gI,_I,vI,yI,bI,xI,SI,CI,wI,TI,EI,DI,OI,kI,AI,jI,MI,NI,PI,FI,II,LI,RI,zI,BI,VI,HI=t((()=>{if(_M=class e{constructor(e){e===void 0&&(e=[0,0,0,0,0,0,0,0,0]),this.elements=e}identity(){let e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){let e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){let t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e){e===void 0&&(e=new $);let t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t){t===void 0&&(t=new $);let n=this.elements,r=e.x,i=e.y,a=e.z;return t.x=n[0]*r+n[1]*i+n[2]*a,t.y=n[3]*r+n[4]*i+n[5]*a,t.z=n[6]*r+n[7]*i+n[8]*a,t}smult(e){for(let t=0;t<this.elements.length;t++)this.elements[t]*=e}mmult(t,n){n===void 0&&(n=new e);let r=this.elements,i=t.elements,a=n.elements,o=r[0],s=r[1],c=r[2],l=r[3],u=r[4],d=r[5],f=r[6],p=r[7],m=r[8],h=i[0],g=i[1],_=i[2],v=i[3],y=i[4],b=i[5],x=i[6],S=i[7],C=i[8];return a[0]=o*h+s*v+c*x,a[1]=o*g+s*y+c*S,a[2]=o*_+s*b+c*C,a[3]=l*h+u*v+d*x,a[4]=l*g+u*y+d*S,a[5]=l*_+u*b+d*C,a[6]=f*h+p*v+m*x,a[7]=f*g+p*y+m*S,a[8]=f*_+p*b+m*C,n}scale(t,n){n===void 0&&(n=new e);let r=this.elements,i=n.elements;for(let e=0;e!==3;e++)i[3*e+0]=t.x*r[3*e+0],i[3*e+1]=t.y*r[3*e+1],i[3*e+2]=t.z*r[3*e+2];return n}solve(e,t){t===void 0&&(t=new $);let n=[],r,i;for(r=0;r<12;r++)n.push(0);for(r=0;r<3;r++)for(i=0;i<3;i++)n[r+4*i]=this.elements[r+3*i];n[3]=e.x,n[7]=e.y,n[11]=e.z;let a=3,o=a,s,c;do{if(r=o-a,n[r+4*r]===0){for(i=r+1;i<o;i++)if(n[r+4*i]!==0){s=4;do c=4-s,n[c+4*r]+=n[c+4*i];while(--s);break}}if(n[r+4*r]!==0)for(i=r+1;i<o;i++){let e=n[r+4*i]/n[r+4*r];s=4;do c=4-s,n[c+4*i]=c<=r?0:n[c+4*i]-n[c+4*r]*e;while(--s)}}while(--a);if(t.z=n[11]/n[10],t.y=(n[7]-n[6]*t.z)/n[5],t.x=(n[3]-n[2]*t.z-n[1]*t.y)/n[0],isNaN(t.x)||isNaN(t.y)||isNaN(t.z)||t.x===1/0||t.y===1/0||t.z===1/0)throw`Could not solve equation! Got x=[${t.toString()}], b=[${e.toString()}], A=[${this.toString()}]`;return t}e(e,t,n){if(n===void 0)return this.elements[t+3*e];this.elements[t+3*e]=n}copy(e){for(let t=0;t<e.elements.length;t++)this.elements[t]=e.elements[t];return this}toString(){let e=``;for(let t=0;t<9;t++)e+=this.elements[t]+`,`;return e}reverse(t){t===void 0&&(t=new e);let n=vM,r,i;for(r=0;r<3;r++)for(i=0;i<3;i++)n[r+6*i]=this.elements[r+3*i];n[3]=1,n[9]=0,n[15]=0,n[4]=0,n[10]=1,n[16]=0,n[5]=0,n[11]=0,n[17]=1;let a=3,o=a,s,c;do{if(r=o-a,n[r+6*r]===0){for(i=r+1;i<o;i++)if(n[r+6*i]!==0){s=6;do c=6-s,n[c+6*r]+=n[c+6*i];while(--s);break}}if(n[r+6*r]!==0)for(i=r+1;i<o;i++){let e=n[r+6*i]/n[r+6*r];s=6;do c=6-s,n[c+6*i]=c<=r?0:n[c+6*i]-n[c+6*r]*e;while(--s)}}while(--a);r=2;do{i=r-1;do{let e=n[r+6*i]/n[r+6*r];s=6;do c=6-s,n[c+6*i]=n[c+6*i]-n[c+6*r]*e;while(--s)}while(i--)}while(--r);r=2;do{let e=1/n[r+6*r];s=6;do c=6-s,n[c+6*r]=n[c+6*r]*e;while(--s)}while(r--);r=2;do{i=2;do{if(c=n[3+i+6*r],isNaN(c)||c===1/0)throw`Could not reverse! A=[${this.toString()}]`;t.e(r,i,c)}while(i--)}while(r--);return t}setRotationFromQuaternion(e){let t=e.x,n=e.y,r=e.z,i=e.w,a=t+t,o=n+n,s=r+r,c=t*a,l=t*o,u=t*s,d=n*o,f=n*s,p=r*s,m=i*a,h=i*o,g=i*s,_=this.elements;return _[0]=1-(d+p),_[1]=l-g,_[2]=u+h,_[3]=l+g,_[4]=1-(c+p),_[5]=f-m,_[6]=u-h,_[7]=f+m,_[8]=1-(c+d),this}transpose(t){t===void 0&&(t=new e);let n=this.elements,r=t.elements,i;return r[0]=n[0],r[4]=n[4],r[8]=n[8],i=n[1],r[1]=n[3],r[3]=i,i=n[2],r[2]=n[6],r[6]=i,i=n[5],r[5]=n[7],r[7]=i,t}},vM=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=class e{constructor(e,t,n){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),this.x=e,this.y=t,this.z=n}cross(t,n){n===void 0&&(n=new e);let r=t.x,i=t.y,a=t.z,o=this.x,s=this.y,c=this.z;return n.x=s*a-c*i,n.y=c*r-o*a,n.z=o*i-s*r,n}set(e,t,n){return this.x=e,this.y=t,this.z=n,this}setZero(){this.x=this.y=this.z=0}vadd(t,n){if(n)n.x=t.x+this.x,n.y=t.y+this.y,n.z=t.z+this.z;else return new e(this.x+t.x,this.y+t.y,this.z+t.z)}vsub(t,n){if(n)n.x=this.x-t.x,n.y=this.y-t.y,n.z=this.z-t.z;else return new e(this.x-t.x,this.y-t.y,this.z-t.z)}crossmat(){return new _M([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])}normalize(){let e=this.x,t=this.y,n=this.z,r=Math.sqrt(e*e+t*t+n*n);if(r>0){let e=1/r;this.x*=e,this.y*=e,this.z*=e}else this.x=0,this.y=0,this.z=0;return r}unit(t){t===void 0&&(t=new e);let n=this.x,r=this.y,i=this.z,a=Math.sqrt(n*n+r*r+i*i);return a>0?(a=1/a,t.x=n*a,t.y=r*a,t.z=i*a):(t.x=1,t.y=0,t.z=0),t}length(){let e=this.x,t=this.y,n=this.z;return Math.sqrt(e*e+t*t+n*n)}lengthSquared(){return this.dot(this)}distanceTo(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z;return Math.sqrt((i-t)*(i-t)+(a-n)*(a-n)+(o-r)*(o-r))}distanceSquared(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z;return(i-t)*(i-t)+(a-n)*(a-n)+(o-r)*(o-r)}scale(t,n){n===void 0&&(n=new e);let r=this.x,i=this.y,a=this.z;return n.x=t*r,n.y=t*i,n.z=t*a,n}vmul(t,n){return n===void 0&&(n=new e),n.x=t.x*this.x,n.y=t.y*this.y,n.z=t.z*this.z,n}addScaledVector(t,n,r){return r===void 0&&(r=new e),r.x=this.x+t*n.x,r.y=this.y+t*n.y,r.z=this.z+t*n.z,r}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isZero(){return this.x===0&&this.y===0&&this.z===0}negate(t){return t===void 0&&(t=new e),t.x=-this.x,t.y=-this.y,t.z=-this.z,t}tangents(e,t){let n=this.length();if(n>0){let r=yM,i=1/n;r.set(this.x*i,this.y*i,this.z*i);let a=bM;Math.abs(r.x)<.9?(a.set(1,0,0),r.cross(a,e)):(a.set(0,1,0),r.cross(a,e)),r.cross(e,t)}else e.set(1,0,0),t.set(0,1,0)}toString(){return`${this.x},${this.y},${this.z}`}toArray(){return[this.x,this.y,this.z]}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}lerp(e,t,n){let r=this.x,i=this.y,a=this.z;n.x=r+(e.x-r)*t,n.y=i+(e.y-i)*t,n.z=a+(e.z-a)*t}almostEquals(e,t){return t===void 0&&(t=1e-6),!(Math.abs(this.x-e.x)>t||Math.abs(this.y-e.y)>t||Math.abs(this.z-e.z)>t)}almostZero(e){return e===void 0&&(e=1e-6),!(Math.abs(this.x)>e||Math.abs(this.y)>e||Math.abs(this.z)>e)}isAntiparallelTo(e,t){return this.negate(xM),xM.almostEquals(e,t)}clone(){return new e(this.x,this.y,this.z)}},$.ZERO=new $(0,0,0),$.UNIT_X=new $(1,0,0),$.UNIT_Y=new $(0,1,0),$.UNIT_Z=new $(0,0,1),yM=new $,bM=new $,xM=new $,SM=class e{constructor(e){e===void 0&&(e={}),this.lowerBound=new $,this.upperBound=new $,e.lowerBound&&this.lowerBound.copy(e.lowerBound),e.upperBound&&this.upperBound.copy(e.upperBound)}setFromPoints(e,t,n,r){let i=this.lowerBound,a=this.upperBound,o=n;i.copy(e[0]),o&&o.vmult(i,i),a.copy(i);for(let t=1;t<e.length;t++){let n=e[t];o&&(o.vmult(n,CM),n=CM),n.x>a.x&&(a.x=n.x),n.x<i.x&&(i.x=n.x),n.y>a.y&&(a.y=n.y),n.y<i.y&&(i.y=n.y),n.z>a.z&&(a.z=n.z),n.z<i.z&&(i.z=n.z)}return t&&(t.vadd(i,i),t.vadd(a,a)),r&&(i.x-=r,i.y-=r,i.z-=r,a.x+=r,a.y+=r,a.z+=r),this}copy(e){return this.lowerBound.copy(e.lowerBound),this.upperBound.copy(e.upperBound),this}clone(){return new e().copy(this)}extend(e){this.lowerBound.x=Math.min(this.lowerBound.x,e.lowerBound.x),this.upperBound.x=Math.max(this.upperBound.x,e.upperBound.x),this.lowerBound.y=Math.min(this.lowerBound.y,e.lowerBound.y),this.upperBound.y=Math.max(this.upperBound.y,e.upperBound.y),this.lowerBound.z=Math.min(this.lowerBound.z,e.lowerBound.z),this.upperBound.z=Math.max(this.upperBound.z,e.upperBound.z)}overlaps(e){let t=this.lowerBound,n=this.upperBound,r=e.lowerBound,i=e.upperBound,a=r.x<=n.x&&n.x<=i.x||t.x<=i.x&&i.x<=n.x,o=r.y<=n.y&&n.y<=i.y||t.y<=i.y&&i.y<=n.y,s=r.z<=n.z&&n.z<=i.z||t.z<=i.z&&i.z<=n.z;return a&&o&&s}volume(){let e=this.lowerBound,t=this.upperBound;return(t.x-e.x)*(t.y-e.y)*(t.z-e.z)}contains(e){let t=this.lowerBound,n=this.upperBound,r=e.lowerBound,i=e.upperBound;return t.x<=r.x&&n.x>=i.x&&t.y<=r.y&&n.y>=i.y&&t.z<=r.z&&n.z>=i.z}getCorners(e,t,n,r,i,a,o,s){let c=this.lowerBound,l=this.upperBound;e.copy(c),t.set(l.x,c.y,c.z),n.set(l.x,l.y,c.z),r.set(c.x,l.y,l.z),i.set(l.x,c.y,l.z),a.set(c.x,l.y,c.z),o.set(c.x,c.y,l.z),s.copy(l)}toLocalFrame(e,t){let n=wM,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7];this.getCorners(r,i,a,o,s,c,l,u);for(let t=0;t!==8;t++){let r=n[t];e.pointToLocal(r,r)}return t.setFromPoints(n)}toWorldFrame(e,t){let n=wM,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7];this.getCorners(r,i,a,o,s,c,l,u);for(let t=0;t!==8;t++){let r=n[t];e.pointToWorld(r,r)}return t.setFromPoints(n)}overlapsRay(e){let{direction:t,from:n}=e,r=1/t.x,i=1/t.y,a=1/t.z,o=(this.lowerBound.x-n.x)*r,s=(this.upperBound.x-n.x)*r,c=(this.lowerBound.y-n.y)*i,l=(this.upperBound.y-n.y)*i,u=(this.lowerBound.z-n.z)*a,d=(this.upperBound.z-n.z)*a,f=Math.max(Math.max(Math.min(o,s),Math.min(c,l)),Math.min(u,d)),p=Math.min(Math.min(Math.max(o,s),Math.max(c,l)),Math.max(u,d));return!(p<0||f>p)}},CM=new $,wM=[new $,new $,new $,new $,new $,new $,new $,new $],TM=class{constructor(){this.matrix=[]}get(e,t){let{index:n}=e,{index:r}=t;if(r>n){let e=r;r=n,n=e}return this.matrix[(n*(n+1)>>1)+r-1]}set(e,t,n){let{index:r}=e,{index:i}=t;if(i>r){let e=i;i=r,r=e}this.matrix[(r*(r+1)>>1)+i-1]=+!!n}reset(){for(let e=0,t=this.matrix.length;e!==t;e++)this.matrix[e]=0}setNumObjects(e){this.matrix.length=e*(e-1)>>1}},EM=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;return n[e]===void 0&&(n[e]=[]),n[e].includes(t)||n[e].push(t),this}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return!!(n[e]!==void 0&&n[e].includes(t))}hasAnyEventListener(e){return this._listeners!==void 0&&this._listeners[e]!==void 0}removeEventListener(e,t){if(this._listeners===void 0)return this;let n=this._listeners;if(n[e]===void 0)return this;let r=n[e].indexOf(t);return r!==-1&&n[e].splice(r,1),this}dispatchEvent(e){if(this._listeners===void 0)return this;let t=this._listeners[e.type];if(t!==void 0){e.target=this;for(let n=0,r=t.length;n<r;n++)t[n].call(this,e)}return this}},DM=class e{constructor(e,t,n,r){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=1),this.x=e,this.y=t,this.z=n,this.w=r}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}toArray(){return[this.x,this.y,this.z,this.w]}setFromAxisAngle(e,t){let n=Math.sin(t*.5);return this.x=e.x*n,this.y=e.y*n,this.z=e.z*n,this.w=Math.cos(t*.5),this}toAxisAngle(e){e===void 0&&(e=new $),this.normalize();let t=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(e.x=this.x,e.y=this.y,e.z=this.z):(e.x=this.x/n,e.y=this.y/n,e.z=this.z/n),[e,t]}setFromVectors(e,t){if(e.isAntiparallelTo(t)){let t=OM,n=kM;e.tangents(t,n),this.setFromAxisAngle(t,Math.PI)}else{let n=e.cross(t);this.x=n.x,this.y=n.y,this.z=n.z,this.w=Math.sqrt(e.length()**2*t.length()**2)+e.dot(t),this.normalize()}return this}mult(t,n){n===void 0&&(n=new e);let r=this.x,i=this.y,a=this.z,o=this.w,s=t.x,c=t.y,l=t.z,u=t.w;return n.x=r*u+o*s+i*l-a*c,n.y=i*u+o*c+a*s-r*l,n.z=a*u+o*l+r*c-i*s,n.w=o*u-r*s-i*c-a*l,n}inverse(t){t===void 0&&(t=new e);let n=this.x,r=this.y,i=this.z,a=this.w;this.conjugate(t);let o=1/(n*n+r*r+i*i+a*a);return t.x*=o,t.y*=o,t.z*=o,t.w*=o,t}conjugate(t){return t===void 0&&(t=new e),t.x=-this.x,t.y=-this.y,t.z=-this.z,t.w=this.w,t}normalize(){let e=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}normalizeFast(){let e=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;return e===0?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=e,this.y*=e,this.z*=e,this.w*=e),this}vmult(e,t){t===void 0&&(t=new $);let n=e.x,r=e.y,i=e.z,a=this.x,o=this.y,s=this.z,c=this.w,l=c*n+o*i-s*r,u=c*r+s*n-a*i,d=c*i+a*r-o*n,f=-a*n-o*r-s*i;return t.x=l*c+f*-a+u*-s-d*-o,t.y=u*c+f*-o+d*-a-l*-s,t.z=d*c+f*-s+l*-o-u*-a,t}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}toEuler(e,t){t===void 0&&(t=`YZX`);let n,r,i,a=this.x,o=this.y,s=this.z,c=this.w;switch(t){case`YZX`:let e=a*o+s*c;if(e>.499&&(n=2*Math.atan2(a,c),r=Math.PI/2,i=0),e<-.499&&(n=-2*Math.atan2(a,c),r=-Math.PI/2,i=0),n===void 0){let t=a*a,l=o*o,u=s*s;n=Math.atan2(2*o*c-2*a*s,1-2*l-2*u),r=Math.asin(2*e),i=Math.atan2(2*a*c-2*o*s,1-2*t-2*u)}break;default:throw Error(`Euler order ${t} not supported yet.`)}e.y=n,e.z=r,e.x=i}setFromEuler(e,t,n,r){r===void 0&&(r=`XYZ`);let i=Math.cos(e/2),a=Math.cos(t/2),o=Math.cos(n/2),s=Math.sin(e/2),c=Math.sin(t/2),l=Math.sin(n/2);return r===`XYZ`?(this.x=s*a*o+i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o-s*c*l):r===`YXZ`?(this.x=s*a*o+i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o+s*c*l):r===`ZXY`?(this.x=s*a*o-i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o-s*c*l):r===`ZYX`?(this.x=s*a*o-i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o+s*c*l):r===`YZX`?(this.x=s*a*o+i*c*l,this.y=i*c*o+s*a*l,this.z=i*a*l-s*c*o,this.w=i*a*o-s*c*l):r===`XZY`&&(this.x=s*a*o-i*c*l,this.y=i*c*o-s*a*l,this.z=i*a*l+s*c*o,this.w=i*a*o+s*c*l),this}clone(){return new e(this.x,this.y,this.z,this.w)}slerp(t,n,r){r===void 0&&(r=new e);let i=this.x,a=this.y,o=this.z,s=this.w,c=t.x,l=t.y,u=t.z,d=t.w,f,p,m,h,g;return p=i*c+a*l+o*u+s*d,p<0&&(p=-p,c=-c,l=-l,u=-u,d=-d),1-p>1e-6?(f=Math.acos(p),m=Math.sin(f),h=Math.sin((1-n)*f)/m,g=Math.sin(n*f)/m):(h=1-n,g=n),r.x=h*i+g*c,r.y=h*a+g*l,r.z=h*o+g*u,r.w=h*s+g*d,r}integrate(t,n,r,i){i===void 0&&(i=new e);let a=t.x*r.x,o=t.y*r.y,s=t.z*r.z,c=this.x,l=this.y,u=this.z,d=this.w,f=n*.5;return i.x+=f*(a*d+o*u-s*l),i.y+=f*(o*d+s*c-a*u),i.z+=f*(s*d+a*l-o*c),i.w+=f*(-a*c-o*l-s*u),i}},OM=new $,kM=new $,AM={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256},jM=class e{constructor(t){t===void 0&&(t={}),this.id=e.idCounter++,this.type=t.type||0,this.boundingSphereRadius=0,this.collisionResponse=!t.collisionResponse||t.collisionResponse,this.collisionFilterGroup=t.collisionFilterGroup===void 0?1:t.collisionFilterGroup,this.collisionFilterMask=t.collisionFilterMask===void 0?-1:t.collisionFilterMask,this.material=t.material?t.material:null,this.body=null}updateBoundingSphereRadius(){throw`computeBoundingSphereRadius() not implemented for shape type ${this.type}`}volume(){throw`volume() not implemented for shape type ${this.type}`}calculateLocalInertia(e,t){throw`calculateLocalInertia() not implemented for shape type ${this.type}`}calculateWorldAABB(e,t,n,r){throw`calculateWorldAABB() not implemented for shape type ${this.type}`}},jM.idCounter=0,jM.types=AM,MM=class e{constructor(e){e===void 0&&(e={}),this.position=new $,this.quaternion=new DM,e.position&&this.position.copy(e.position),e.quaternion&&this.quaternion.copy(e.quaternion)}pointToLocal(t,n){return e.pointToLocalFrame(this.position,this.quaternion,t,n)}pointToWorld(t,n){return e.pointToWorldFrame(this.position,this.quaternion,t,n)}vectorToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t}static pointToLocalFrame(e,t,n,r){return r===void 0&&(r=new $),n.vsub(e,r),t.conjugate(NM),NM.vmult(r,r),r}static pointToWorldFrame(e,t,n,r){return r===void 0&&(r=new $),t.vmult(n,r),r.vadd(e,r),r}static vectorToWorldFrame(e,t,n){return n===void 0&&(n=new $),e.vmult(t,n),n}static vectorToLocalFrame(e,t,n,r){return r===void 0&&(r=new $),t.w*=-1,t.vmult(n,r),t.w*=-1,r}},NM=new DM,PM=class e extends jM{constructor(e){e===void 0&&(e={});let{vertices:t=[],faces:n=[],normals:r=[],axes:i,boundingSphereRadius:a}=e;super({type:jM.types.CONVEXPOLYHEDRON}),this.vertices=t,this.faces=n,this.faceNormals=r,this.faceNormals.length===0&&this.computeNormals(),a?this.boundingSphereRadius=a:this.updateBoundingSphereRadius(),this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.worldFaceNormals=[],this.worldFaceNormalsNeedsUpdate=!0,this.uniqueAxes=i?i.slice():null,this.uniqueEdges=[],this.computeEdges()}computeEdges(){let e=this.faces,t=this.vertices,n=this.uniqueEdges;n.length=0;let r=new $;for(let i=0;i!==e.length;i++){let a=e[i],o=a.length;for(let e=0;e!==o;e++){let i=(e+1)%o;t[a[e]].vsub(t[a[i]],r),r.normalize();let s=!1;for(let e=0;e!==n.length;e++)if(n[e].almostEquals(r)||n[e].almostEquals(r)){s=!0;break}s||n.push(r.clone())}}}computeNormals(){this.faceNormals.length=this.faces.length;for(let e=0;e<this.faces.length;e++){for(let t=0;t<this.faces[e].length;t++)if(!this.vertices[this.faces[e][t]])throw Error(`Vertex ${this.faces[e][t]} not found!`);let t=this.faceNormals[e]||new $;this.getFaceNormal(e,t),t.negate(t),this.faceNormals[e]=t;let n=this.vertices[this.faces[e][0]];if(t.dot(n)<0){console.error(`.faceNormals[${e}] = Vec3(${t.toString()}) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.`);for(let t=0;t<this.faces[e].length;t++)console.warn(`.vertices[${this.faces[e][t]}] = Vec3(${this.vertices[this.faces[e][t]].toString()})`)}}}getFaceNormal(t,n){let r=this.faces[t],i=this.vertices[r[0]],a=this.vertices[r[1]],o=this.vertices[r[2]];e.computeNormal(i,a,o,n)}static computeNormal(e,t,n,r){let i=new $,a=new $;t.vsub(e,a),n.vsub(t,i),i.cross(a,r),r.isZero()||r.normalize()}clipAgainstHull(e,t,n,r,i,a,o,s,c){let l=new $,u=-1,d=-Number.MAX_VALUE;for(let e=0;e<n.faces.length;e++){l.copy(n.faceNormals[e]),i.vmult(l,l);let t=l.dot(a);t>d&&(d=t,u=e)}let f=[];for(let e=0;e<n.faces[u].length;e++){let t=n.vertices[n.faces[u][e]],a=new $;a.copy(t),i.vmult(a,a),r.vadd(a,a),f.push(a)}u>=0&&this.clipFaceAgainstHull(a,e,t,f,o,s,c)}findSeparatingAxis(e,t,n,r,i,a,o,s){let c=new $,l=new $,u=new $,d=new $,f=new $,p=new $,m=Number.MAX_VALUE,h=this;if(h.uniqueAxes)for(let o=0;o!==h.uniqueAxes.length;o++){n.vmult(h.uniqueAxes[o],c);let s=h.testSepAxis(c,e,t,n,r,i);if(s===!1)return!1;s<m&&(m=s,a.copy(c))}else{let s=o?o.length:h.faces.length;for(let l=0;l<s;l++){let s=o?o[l]:l;c.copy(h.faceNormals[s]),n.vmult(c,c);let u=h.testSepAxis(c,e,t,n,r,i);if(u===!1)return!1;u<m&&(m=u,a.copy(c))}}if(e.uniqueAxes)for(let o=0;o!==e.uniqueAxes.length;o++){i.vmult(e.uniqueAxes[o],l);let s=h.testSepAxis(l,e,t,n,r,i);if(s===!1)return!1;s<m&&(m=s,a.copy(l))}else{let o=s?s.length:e.faces.length;for(let c=0;c<o;c++){let o=s?s[c]:c;l.copy(e.faceNormals[o]),i.vmult(l,l);let u=h.testSepAxis(l,e,t,n,r,i);if(u===!1)return!1;u<m&&(m=u,a.copy(l))}}for(let o=0;o!==h.uniqueEdges.length;o++){n.vmult(h.uniqueEdges[o],d);for(let o=0;o!==e.uniqueEdges.length;o++)if(i.vmult(e.uniqueEdges[o],f),d.cross(f,p),!p.almostZero()){p.normalize();let o=h.testSepAxis(p,e,t,n,r,i);if(o===!1)return!1;o<m&&(m=o,a.copy(p))}}return r.vsub(t,u),u.dot(a)>0&&a.negate(a),!0}testSepAxis(t,n,r,i,a,o){let s=this;e.project(s,t,r,i,FM),e.project(n,t,a,o,IM);let c=FM[0],l=FM[1],u=IM[0],d=IM[1];if(c<d||u<l)return!1;let f=c-d,p=u-l;return f<p?f:p}calculateLocalInertia(e,t){let n=new $,r=new $;this.computeLocalAABB(r,n);let i=n.x-r.x,a=n.y-r.y,o=n.z-r.z;t.x=1/12*e*(2*a*2*a+2*o*2*o),t.y=1/12*e*(2*i*2*i+2*o*2*o),t.z=1/12*e*(2*a*2*a+2*i*2*i)}getPlaneConstantOfFace(e){let t=this.faces[e],n=this.faceNormals[e],r=this.vertices[t[0]];return-n.dot(r)}clipFaceAgainstHull(e,t,n,r,i,a,o){let s=new $,c=new $,l=new $,u=new $,d=new $,f=new $,p=new $,m=new $,h=this,g=[],_=r,v=g,y=-1,b=Number.MAX_VALUE;for(let t=0;t<h.faces.length;t++){s.copy(h.faceNormals[t]),n.vmult(s,s);let r=s.dot(e);r<b&&(b=r,y=t)}if(y<0)return;let x=h.faces[y];x.connectedFaces=[];for(let e=0;e<h.faces.length;e++)for(let t=0;t<h.faces[e].length;t++)x.indexOf(h.faces[e][t])!==-1&&e!==y&&x.connectedFaces.indexOf(e)===-1&&x.connectedFaces.push(e);let S=x.length;for(let e=0;e<S;e++){let r=h.vertices[x[e]],i=h.vertices[x[(e+1)%S]];r.vsub(i,c),l.copy(c),n.vmult(l,l),t.vadd(l,l),u.copy(this.faceNormals[y]),n.vmult(u,u),t.vadd(u,u),l.cross(u,d),d.negate(d),f.copy(r),n.vmult(f,f),t.vadd(f,f);let a=x.connectedFaces[e];p.copy(this.faceNormals[a]);let o=this.getPlaneConstantOfFace(a);m.copy(p),n.vmult(m,m);let s=o-m.dot(t);for(this.clipFaceAgainstPlane(_,v,m,s);_.length;)_.shift();for(;v.length;)_.push(v.shift())}p.copy(this.faceNormals[y]);let C=this.getPlaneConstantOfFace(y);m.copy(p),n.vmult(m,m);let w=C-m.dot(t);for(let e=0;e<_.length;e++){let t=m.dot(_[e])+w;if(t<=i&&(console.log(`clamped: depth=${t} to minDist=${i}`),t=i),t<=a){let n=_[e];if(t<=1e-6){let e={point:n,normal:m,depth:t};o.push(e)}}}}clipFaceAgainstPlane(e,t,n,r){let i,a,o=e.length;if(o<2)return t;let s=e[e.length-1],c=e[0];i=n.dot(s)+r;for(let l=0;l<o;l++){if(c=e[l],a=n.dot(c)+r,i<0){if(a<0){let e=new $;e.copy(c),t.push(e)}else{let e=new $;s.lerp(c,i/(i-a),e),t.push(e)}}else if(a<0){let e=new $;s.lerp(c,i/(i-a),e),t.push(e),t.push(c)}s=c,i=a}return t}computeWorldVertices(e,t){for(;this.worldVertices.length<this.vertices.length;)this.worldVertices.push(new $);let n=this.vertices,r=this.worldVertices;for(let i=0;i!==this.vertices.length;i++)t.vmult(n[i],r[i]),e.vadd(r[i],r[i]);this.worldVerticesNeedsUpdate=!1}computeLocalAABB(e,t){let n=this.vertices;e.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let r=0;r<this.vertices.length;r++){let i=n[r];i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y),i.z<e.z?e.z=i.z:i.z>t.z&&(t.z=i.z)}}computeWorldFaceNormals(e){let t=this.faceNormals.length;for(;this.worldFaceNormals.length<t;)this.worldFaceNormals.push(new $);let n=this.faceNormals,r=this.worldFaceNormals;for(let i=0;i!==t;i++)e.vmult(n[i],r[i]);this.worldFaceNormalsNeedsUpdate=!1}updateBoundingSphereRadius(){let e=0,t=this.vertices;for(let n=0;n!==t.length;n++){let r=t[n].lengthSquared();r>e&&(e=r)}this.boundingSphereRadius=Math.sqrt(e)}calculateWorldAABB(e,t,n,r){let i=this.vertices,a,o,s,c,l,u,d=new $;for(let n=0;n<i.length;n++){d.copy(i[n]),t.vmult(d,d),e.vadd(d,d);let r=d;(a===void 0||r.x<a)&&(a=r.x),(c===void 0||r.x>c)&&(c=r.x),(o===void 0||r.y<o)&&(o=r.y),(l===void 0||r.y>l)&&(l=r.y),(s===void 0||r.z<s)&&(s=r.z),(u===void 0||r.z>u)&&(u=r.z)}n.set(a,o,s),r.set(c,l,u)}volume(){return 4*Math.PI*this.boundingSphereRadius/3}getAveragePointLocal(e){e===void 0&&(e=new $);let t=this.vertices;for(let n=0;n<t.length;n++)e.vadd(t[n],e);return e.scale(1/t.length,e),e}transformAllPoints(e,t){let n=this.vertices.length,r=this.vertices;if(t){for(let e=0;e<n;e++){let n=r[e];t.vmult(n,n)}for(let e=0;e<this.faceNormals.length;e++){let n=this.faceNormals[e];t.vmult(n,n)}}if(e)for(let t=0;t<n;t++){let n=r[t];n.vadd(e,n)}}pointIsInside(e){let t=this.vertices,n=this.faces,r=this.faceNormals,i=new $;this.getAveragePointLocal(i);for(let a=0;a<this.faces.length;a++){let o=r[a],s=t[n[a][0]],c=new $;e.vsub(s,c);let l=o.dot(c),u=new $;i.vsub(s,u);let d=o.dot(u);if(l<0&&d>0||l>0&&d<0)return!1}return-1}static project(e,t,n,r,i){let a=e.vertices.length,o=LM,s=0,c=0,l=RM,u=e.vertices;l.setZero(),MM.vectorToLocalFrame(n,r,t,o),MM.pointToLocalFrame(n,r,l,l);let d=l.dot(o);c=s=u[0].dot(o);for(let e=1;e<a;e++){let t=u[e].dot(o);t>s&&(s=t),t<c&&(c=t)}if(c-=d,s-=d,c>s){let e=c;c=s,s=e}i[0]=s,i[1]=c}},FM=[],IM=[],new $,LM=new $,RM=new $,zM=class e extends jM{constructor(e){super({type:jM.types.BOX}),this.halfExtents=e,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}updateConvexPolyhedronRepresentation(){let e=this.halfExtents.x,t=this.halfExtents.y,n=this.halfExtents.z,r=$,i=[new r(-e,-t,-n),new r(e,-t,-n),new r(e,t,-n),new r(-e,t,-n),new r(-e,-t,n),new r(e,-t,n),new r(e,t,n),new r(-e,t,n)],a=[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]],o=[new r(0,0,1),new r(0,1,0),new r(1,0,0)],s=new PM({vertices:i,faces:a,axes:o});this.convexPolyhedronRepresentation=s,s.material=this.material}calculateLocalInertia(t,n){return n===void 0&&(n=new $),e.calculateInertia(this.halfExtents,t,n),n}static calculateInertia(e,t,n){let r=e;n.x=1/12*t*(2*r.y*2*r.y+2*r.z*2*r.z),n.y=1/12*t*(2*r.x*2*r.x+2*r.z*2*r.z),n.z=1/12*t*(2*r.y*2*r.y+2*r.x*2*r.x)}getSideNormals(e,t){let n=e,r=this.halfExtents;if(n[0].set(r.x,0,0),n[1].set(0,r.y,0),n[2].set(0,0,r.z),n[3].set(-r.x,0,0),n[4].set(0,-r.y,0),n[5].set(0,0,-r.z),t!==void 0)for(let e=0;e!==n.length;e++)t.vmult(n[e],n[e]);return n}volume(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z}updateBoundingSphereRadius(){this.boundingSphereRadius=this.halfExtents.length()}forEachWorldCorner(e,t,n){let r=this.halfExtents,i=[[r.x,r.y,r.z],[-r.x,r.y,r.z],[-r.x,-r.y,r.z],[-r.x,-r.y,-r.z],[r.x,-r.y,-r.z],[r.x,r.y,-r.z],[-r.x,r.y,-r.z],[r.x,-r.y,r.z]];for(let r=0;r<i.length;r++)BM.set(i[r][0],i[r][1],i[r][2]),t.vmult(BM,BM),e.vadd(BM,BM),n(BM.x,BM.y,BM.z)}calculateWorldAABB(e,t,n,r){let i=this.halfExtents;VM[0].set(i.x,i.y,i.z),VM[1].set(-i.x,i.y,i.z),VM[2].set(-i.x,-i.y,i.z),VM[3].set(-i.x,-i.y,-i.z),VM[4].set(i.x,-i.y,-i.z),VM[5].set(i.x,i.y,-i.z),VM[6].set(-i.x,i.y,-i.z),VM[7].set(i.x,-i.y,i.z);let a=VM[0];t.vmult(a,a),e.vadd(a,a),r.copy(a),n.copy(a);for(let i=1;i<8;i++){let a=VM[i];t.vmult(a,a),e.vadd(a,a);let o=a.x,s=a.y,c=a.z;o>r.x&&(r.x=o),s>r.y&&(r.y=s),c>r.z&&(r.z=c),o<n.x&&(n.x=o),s<n.y&&(n.y=s),c<n.z&&(n.z=c)}}},BM=new $,VM=[new $,new $,new $,new $,new $,new $,new $,new $],HM={DYNAMIC:1,STATIC:2,KINEMATIC:4},UM={AWAKE:0,SLEEPY:1,SLEEPING:2},WM=class e extends EM{constructor(t){t===void 0&&(t={}),super(),this.id=e.idCounter++,this.index=-1,this.world=null,this.vlambda=new $,this.collisionFilterGroup=typeof t.collisionFilterGroup==`number`?t.collisionFilterGroup:1,this.collisionFilterMask=typeof t.collisionFilterMask==`number`?t.collisionFilterMask:-1,this.collisionResponse=typeof t.collisionResponse!=`boolean`||t.collisionResponse,this.position=new $,this.previousPosition=new $,this.interpolatedPosition=new $,this.initPosition=new $,t.position&&(this.position.copy(t.position),this.previousPosition.copy(t.position),this.interpolatedPosition.copy(t.position),this.initPosition.copy(t.position)),this.velocity=new $,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new $,this.force=new $;let n=typeof t.mass==`number`?t.mass:0;this.mass=n,this.invMass=n>0?1/n:0,this.material=t.material||null,this.linearDamping=typeof t.linearDamping==`number`?t.linearDamping:.01,this.type=n<=0?e.STATIC:e.DYNAMIC,typeof t.type==typeof e.STATIC&&(this.type=t.type),this.allowSleep=t.allowSleep===void 0||t.allowSleep,this.sleepState=e.AWAKE,this.sleepSpeedLimit=t.sleepSpeedLimit===void 0?.1:t.sleepSpeedLimit,this.sleepTimeLimit=t.sleepTimeLimit===void 0?1:t.sleepTimeLimit,this.timeLastSleepy=0,this.wakeUpAfterNarrowphase=!1,this.torque=new $,this.quaternion=new DM,this.initQuaternion=new DM,this.previousQuaternion=new DM,this.interpolatedQuaternion=new DM,t.quaternion&&(this.quaternion.copy(t.quaternion),this.initQuaternion.copy(t.quaternion),this.previousQuaternion.copy(t.quaternion),this.interpolatedQuaternion.copy(t.quaternion)),this.angularVelocity=new $,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new $,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new $,this.invInertia=new $,this.invInertiaWorld=new _M,this.invMassSolve=0,this.invInertiaSolve=new $,this.invInertiaWorldSolve=new _M,this.fixedRotation=t.fixedRotation!==void 0&&t.fixedRotation,this.angularDamping=t.angularDamping===void 0?.01:t.angularDamping,this.linearFactor=new $(1,1,1),t.linearFactor&&this.linearFactor.copy(t.linearFactor),this.angularFactor=new $(1,1,1),t.angularFactor&&this.angularFactor.copy(t.angularFactor),this.aabb=new SM,this.aabbNeedsUpdate=!0,this.boundingRadius=0,this.wlambda=new $,this.isTrigger=!!t.isTrigger,t.shape&&this.addShape(t.shape),this.updateMassProperties()}wakeUp(){let t=this.sleepState;this.sleepState=e.AWAKE,this.wakeUpAfterNarrowphase=!1,t===e.SLEEPING&&this.dispatchEvent(e.wakeupEvent)}sleep(){this.sleepState=e.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0),this.wakeUpAfterNarrowphase=!1}sleepTick(t){if(this.allowSleep){let n=this.sleepState,r=this.velocity.lengthSquared()+this.angularVelocity.lengthSquared(),i=this.sleepSpeedLimit**2;n===e.AWAKE&&r<i?(this.sleepState=e.SLEEPY,this.timeLastSleepy=t,this.dispatchEvent(e.sleepyEvent)):n===e.SLEEPY&&r>i?this.wakeUp():n===e.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(e.sleepEvent))}}updateSolveMassProperties(){this.sleepState===e.SLEEPING||this.type===e.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))}pointToLocalFrame(e,t){return t===void 0&&(t=new $),e.vsub(this.position,t),this.quaternion.conjugate().vmult(t,t),t}vectorToLocalFrame(e,t){return t===void 0&&(t=new $),this.quaternion.conjugate().vmult(e,t),t}pointToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t.vadd(this.position,t),t}vectorToWorldFrame(e,t){return t===void 0&&(t=new $),this.quaternion.vmult(e,t),t}addShape(e,t,n){let r=new $,i=new DM;return t&&r.copy(t),n&&i.copy(n),this.shapes.push(e),this.shapeOffsets.push(r),this.shapeOrientations.push(i),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=this,this}removeShape(e){let t=this.shapes.indexOf(e);return t===-1?(console.warn(`Shape does not belong to the body`),this):(this.shapes.splice(t,1),this.shapeOffsets.splice(t,1),this.shapeOrientations.splice(t,1),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,e.body=null,this)}updateBoundingRadius(){let e=this.shapes,t=this.shapeOffsets,n=e.length,r=0;for(let i=0;i!==n;i++){let n=e[i];n.updateBoundingSphereRadius();let a=t[i].length(),o=n.boundingSphereRadius;a+o>r&&(r=a+o)}this.boundingRadius=r}updateAABB(){let e=this.shapes,t=this.shapeOffsets,n=this.shapeOrientations,r=e.length,i=GM,a=KM,o=this.quaternion,s=this.aabb,c=qM;for(let l=0;l!==r;l++){let r=e[l];o.vmult(t[l],i),i.vadd(this.position,i),o.mult(n[l],a),r.calculateWorldAABB(i,a,c.lowerBound,c.upperBound),l===0?s.copy(c):s.extend(c)}this.aabbNeedsUpdate=!1}updateInertiaWorld(e){let t=this.invInertia;if(t.x!==t.y||t.y!==t.z||e){let e=JM,n=YM;e.setRotationFromQuaternion(this.quaternion),e.transpose(n),e.scale(t,e),e.mmult(n,this.invInertiaWorld)}}applyForce(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;this.sleepState===e.SLEEPING&&this.wakeUp();let r=XM;n.cross(t,r),this.force.vadd(t,this.force),this.torque.vadd(r,this.torque)}applyLocalForce(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;let r=ZM,i=QM;this.vectorToWorldFrame(t,r),this.vectorToWorldFrame(n,i),this.applyForce(r,i)}applyTorque(t){this.type===e.DYNAMIC&&(this.sleepState===e.SLEEPING&&this.wakeUp(),this.torque.vadd(t,this.torque))}applyImpulse(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;this.sleepState===e.SLEEPING&&this.wakeUp();let r=n,i=$M;i.copy(t),i.scale(this.invMass,i),this.velocity.vadd(i,this.velocity);let a=eN;r.cross(t,a),this.invInertiaWorld.vmult(a,a),this.angularVelocity.vadd(a,this.angularVelocity)}applyLocalImpulse(t,n){if(n===void 0&&(n=new $),this.type!==e.DYNAMIC)return;let r=tN,i=nN;this.vectorToWorldFrame(t,r),this.vectorToWorldFrame(n,i),this.applyImpulse(r,i)}updateMassProperties(){let e=rN;this.invMass=this.mass>0?1/this.mass:0;let t=this.inertia,n=this.fixedRotation;this.updateAABB(),e.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),zM.calculateInertia(e,this.mass,t),this.invInertia.set(t.x>0&&!n?1/t.x:0,t.y>0&&!n?1/t.y:0,t.z>0&&!n?1/t.z:0),this.updateInertiaWorld(!0)}getVelocityAtWorldPoint(e,t){let n=new $;return e.vsub(this.position,n),this.angularVelocity.cross(n,t),this.velocity.vadd(t,t),t}integrate(t,n,r){if(this.previousPosition.copy(this.position),this.previousQuaternion.copy(this.quaternion),this.type!==e.DYNAMIC&&this.type!==e.KINEMATIC||this.sleepState===e.SLEEPING)return;let i=this.velocity,a=this.angularVelocity,o=this.position,s=this.force,c=this.torque,l=this.quaternion,u=this.invMass,d=this.invInertiaWorld,f=this.linearFactor,p=u*t;i.x+=s.x*p*f.x,i.y+=s.y*p*f.y,i.z+=s.z*p*f.z;let m=d.elements,h=this.angularFactor,g=c.x*h.x,_=c.y*h.y,v=c.z*h.z;a.x+=t*(m[0]*g+m[1]*_+m[2]*v),a.y+=t*(m[3]*g+m[4]*_+m[5]*v),a.z+=t*(m[6]*g+m[7]*_+m[8]*v),o.x+=i.x*t,o.y+=i.y*t,o.z+=i.z*t,l.integrate(this.angularVelocity,t,this.angularFactor,l),n&&(r?l.normalizeFast():l.normalize()),this.aabbNeedsUpdate=!0,this.updateInertiaWorld()}},WM.idCounter=0,WM.COLLIDE_EVENT_NAME=`collide`,WM.DYNAMIC=HM.DYNAMIC,WM.STATIC=HM.STATIC,WM.KINEMATIC=HM.KINEMATIC,WM.AWAKE=UM.AWAKE,WM.SLEEPY=UM.SLEEPY,WM.SLEEPING=UM.SLEEPING,WM.wakeupEvent={type:`wakeup`},WM.sleepyEvent={type:`sleepy`},WM.sleepEvent={type:`sleep`},GM=new $,KM=new DM,qM=new SM,JM=new _M,YM=new _M,new _M,XM=new $,ZM=new $,QM=new $,$M=new $,eN=new $,tN=new $,nN=new $,rN=new $,iN=class{constructor(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}collisionPairs(e,t,n){throw Error(`collisionPairs not implemented for this BroadPhase class!`)}needBroadphaseCollision(e,t){return(e.collisionFilterGroup&t.collisionFilterMask)!==0&&(t.collisionFilterGroup&e.collisionFilterMask)!==0&&((e.type&WM.STATIC)===0&&e.sleepState!==WM.SLEEPING||(t.type&WM.STATIC)===0&&t.sleepState!==WM.SLEEPING)}intersectionTest(e,t,n,r){this.useBoundingBoxes?this.doBoundingBoxBroadphase(e,t,n,r):this.doBoundingSphereBroadphase(e,t,n,r)}doBoundingSphereBroadphase(e,t,n,r){let i=aN;t.position.vsub(e.position,i);let a=(e.boundingRadius+t.boundingRadius)**2;i.lengthSquared()<a&&(n.push(e),r.push(t))}doBoundingBoxBroadphase(e,t,n,r){e.aabbNeedsUpdate&&e.updateAABB(),t.aabbNeedsUpdate&&t.updateAABB(),e.aabb.overlaps(t.aabb)&&(n.push(e),r.push(t))}makePairsUnique(e,t){let n=oN,r=sN,i=cN,a=e.length;for(let n=0;n!==a;n++)r[n]=e[n],i[n]=t[n];e.length=0,t.length=0;for(let e=0;e!==a;e++){let t=r[e].id,a=i[e].id,o=t<a?`${t},${a}`:`${a},${t}`;n[o]=e,n.keys.push(o)}for(let a=0;a!==n.keys.length;a++){let a=n.keys.pop(),o=n[a];e.push(r[o]),t.push(i[o]),delete n[a]}}setWorld(e){}static boundingSphereCheck(e,t){let n=new $;e.position.vsub(t.position,n);let r=e.shapes[0],i=t.shapes[0];return(r.boundingSphereRadius+i.boundingSphereRadius)**2>n.lengthSquared()}aabbQuery(e,t,n){return console.warn(`.aabbQuery is not implemented in this Broadphase subclass.`),[]}},aN=new $,new $,new DM,new $,oN={keys:[]},sN=[],cN=[],new $,new $,new $,lN=class extends iN{constructor(){super()}collisionPairs(e,t,n){let r=e.bodies,i=r.length,a,o;for(let e=0;e!==i;e++)for(let i=0;i!==e;i++)a=r[e],o=r[i],this.needBroadphaseCollision(a,o)&&this.intersectionTest(a,o,t,n)}aabbQuery(e,t,n){n===void 0&&(n=[]);for(let r=0;r<e.bodies.length;r++){let i=e.bodies[r];i.aabbNeedsUpdate&&i.updateAABB(),i.aabb.overlaps(t)&&n.push(i)}return n}},uN=class{constructor(){this.rayFromWorld=new $,this.rayToWorld=new $,this.hitNormalWorld=new $,this.hitPointWorld=new $,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}reset(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this.shouldStop=!1}abort(){this.shouldStop=!0}set(e,t,n,r,i,a,o){this.rayFromWorld.copy(e),this.rayToWorld.copy(t),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(r),this.shape=i,this.body=a,this.distance=o}},vN={CLOSEST:1,ANY:2,ALL:4},dN=jM.types.SPHERE,fN=jM.types.PLANE,pN=jM.types.BOX,mN=jM.types.CYLINDER,hN=jM.types.CONVEXPOLYHEDRON,gN=jM.types.HEIGHTFIELD,_N=jM.types.TRIMESH,yN=class e{get[dN](){return this._intersectSphere}get[fN](){return this._intersectPlane}get[pN](){return this._intersectBox}get[mN](){return this._intersectConvex}get[hN](){return this._intersectConvex}get[gN](){return this._intersectHeightfield}get[_N](){return this._intersectTrimesh}constructor(t,n){t===void 0&&(t=new $),n===void 0&&(n=new $),this.from=t.clone(),this.to=n.clone(),this.direction=new $,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=e.ANY,this.result=new uN,this.hasHit=!1,this.callback=e=>{}}intersectWorld(t,n){return this.mode=n.mode||e.ANY,this.result=n.result||new uN,this.skipBackfaces=!!n.skipBackfaces,this.collisionFilterMask=n.collisionFilterMask===void 0?-1:n.collisionFilterMask,this.collisionFilterGroup=n.collisionFilterGroup===void 0?-1:n.collisionFilterGroup,this.checkCollisionResponse=n.checkCollisionResponse===void 0||n.checkCollisionResponse,n.from&&this.from.copy(n.from),n.to&&this.to.copy(n.to),this.callback=n.callback||(()=>{}),this.hasHit=!1,this.result.reset(),this.updateDirection(),this.getAABB(bN),xN.length=0,t.broadphase.aabbQuery(t,bN,xN),this.intersectBodies(xN),this.hasHit}intersectBody(e,t){t&&(this.result=t,this.updateDirection());let n=this.checkCollisionResponse;if(n&&!e.collisionResponse||(this.collisionFilterGroup&e.collisionFilterMask)===0||(e.collisionFilterGroup&this.collisionFilterMask)===0)return;let r=wN,i=TN;for(let t=0,a=e.shapes.length;t<a;t++){let a=e.shapes[t];if((!n||a.collisionResponse)&&(e.quaternion.mult(e.shapeOrientations[t],i),e.quaternion.vmult(e.shapeOffsets[t],r),r.vadd(e.position,r),this.intersectShape(a,i,r,e),this.result.shouldStop))break}}intersectBodies(e,t){t&&(this.result=t,this.updateDirection());for(let t=0,n=e.length;!this.result.shouldStop&&t<n;t++)this.intersectBody(e[t])}updateDirection(){this.to.vsub(this.from,this.direction),this.direction.normalize()}intersectShape(e,t,n,r){let i=this.from;if(pM(i,this.direction,n)>e.boundingSphereRadius)return;let a=this[e.type];a&&a.call(this,e,t,n,r,e)}_intersectBox(e,t,n,r,i){return this._intersectConvex(e.convexPolyhedronRepresentation,t,n,r,i)}_intersectPlane(e,t,n,r,i){let a=this.from,o=this.to,s=this.direction,c=new $(0,0,1);t.vmult(c,c);let l=new $;a.vsub(n,l);let u=l.dot(c);if(o.vsub(n,l),u*l.dot(c)>0||a.distanceTo(o)<u)return;let d=c.dot(s);if(Math.abs(d)<this.precision)return;let f=new $,p=new $,m=new $;a.vsub(n,f);let h=-c.dot(f)/d;s.scale(h,p),a.vadd(p,m),this.reportIntersection(c,m,i,r,-1)}getAABB(e){let{lowerBound:t,upperBound:n}=e,r=this.to,i=this.from;t.x=Math.min(r.x,i.x),t.y=Math.min(r.y,i.y),t.z=Math.min(r.z,i.z),n.x=Math.max(r.x,i.x),n.y=Math.max(r.y,i.y),n.z=Math.max(r.z,i.z)}_intersectHeightfield(e,t,n,r,i){e.data,e.elementSize;let a=MN;a.from.copy(this.from),a.to.copy(this.to),MM.pointToLocalFrame(n,t,a.from,a.from),MM.pointToLocalFrame(n,t,a.to,a.to),a.updateDirection();let o=NN,s,c,l,u;s=c=0,l=u=e.data.length-1;let d=new SM;a.getAABB(d),e.getIndexOfPosition(d.lowerBound.x,d.lowerBound.y,o,!0),s=Math.max(s,o[0]),c=Math.max(c,o[1]),e.getIndexOfPosition(d.upperBound.x,d.upperBound.y,o,!0),l=Math.min(l,o[0]+1),u=Math.min(u,o[1]+1);for(let o=s;o<l;o++)for(let s=c;s<u;s++){if(this.result.shouldStop)return;if(e.getAabbAtIndex(o,s,d),d.overlapsRay(a)){if(e.getConvexTrianglePillar(o,s,!1),MM.pointToWorldFrame(n,t,e.pillarOffset,jN),this._intersectConvex(e.pillarConvex,t,jN,r,i,AN),this.result.shouldStop)return;e.getConvexTrianglePillar(o,s,!0),MM.pointToWorldFrame(n,t,e.pillarOffset,jN),this._intersectConvex(e.pillarConvex,t,jN,r,i,AN)}}}_intersectSphere(e,t,n,r,i){let a=this.from,o=this.to,s=e.radius,c=(o.x-a.x)**2+(o.y-a.y)**2+(o.z-a.z)**2,l=2*((o.x-a.x)*(a.x-n.x)+(o.y-a.y)*(a.y-n.y)+(o.z-a.z)*(a.z-n.z)),u=(a.x-n.x)**2+(a.y-n.y)**2+(a.z-n.z)**2-s**2,d=l**2-4*c*u,f=PN,p=FN;if(!(d<0)){if(d===0)a.lerp(o,d,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1);else{let e=(-l-Math.sqrt(d))/(2*c),t=(-l+Math.sqrt(d))/(2*c);if(e>=0&&e<=1&&(a.lerp(o,e,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1)),this.result.shouldStop)return;t>=0&&t<=1&&(a.lerp(o,t,f),f.vsub(n,p),p.normalize(),this.reportIntersection(p,f,i,r,-1))}}}_intersectConvex(t,n,r,i,a,o){let s=IN,c=LN,l=o&&o.faceList||null,u=t.faces,d=t.vertices,f=t.faceNormals,p=this.direction,m=this.from,h=this.to,g=m.distanceTo(h),_=l?l.length:u.length,v=this.result;for(let t=0;!v.shouldStop&&t<_;t++){let o=l?l[t]:t,h=u[o],_=f[o],y=n,b=r;c.copy(d[h[0]]),y.vmult(c,c),c.vadd(b,c),c.vsub(m,c),y.vmult(_,s);let x=p.dot(s);if(Math.abs(x)<this.precision)continue;let S=s.dot(c)/x;if(!(S<0)){p.scale(S,EN),EN.vadd(m,EN),DN.copy(d[h[0]]),y.vmult(DN,DN),b.vadd(DN,DN);for(let t=1;!v.shouldStop&&t<h.length-1;t++){ON.copy(d[h[t]]),kN.copy(d[h[t+1]]),y.vmult(ON,ON),y.vmult(kN,kN),b.vadd(ON,ON),b.vadd(kN,kN);let n=EN.distanceTo(m);!(e.pointInTriangle(EN,DN,ON,kN)||e.pointInTriangle(EN,ON,DN,kN))||n>g||this.reportIntersection(s,EN,a,i,o)}}}}_intersectTrimesh(t,n,r,i,a,o){let s=RN,c=WN,l=GN,u=LN,d=zN,f=BN,p=VN,m=UN,h=HN,g=t.indices;t.vertices;let _=this.from,v=this.to,y=this.direction;l.position.copy(r),l.quaternion.copy(n),MM.vectorToLocalFrame(r,n,y,d),MM.pointToLocalFrame(r,n,_,f),MM.pointToLocalFrame(r,n,v,p),p.x*=t.scale.x,p.y*=t.scale.y,p.z*=t.scale.z,f.x*=t.scale.x,f.y*=t.scale.y,f.z*=t.scale.z,p.vsub(f,d),d.normalize();let b=f.distanceSquared(p);t.tree.rayQuery(this,l,c);for(let o=0,l=c.length;!this.result.shouldStop&&o!==l;o++){let l=c[o];t.getNormal(l,s),t.getVertex(g[l*3],DN),DN.vsub(f,u);let p=d.dot(s),_=s.dot(u)/p;if(_<0)continue;d.scale(_,EN),EN.vadd(f,EN),t.getVertex(g[l*3+1],ON),t.getVertex(g[l*3+2],kN);let v=EN.distanceSquared(f);!(e.pointInTriangle(EN,ON,DN,kN)||e.pointInTriangle(EN,DN,ON,kN))||v>b||(MM.vectorToWorldFrame(n,s,h),MM.pointToWorldFrame(r,n,EN,m),this.reportIntersection(h,m,a,i,l))}c.length=0}reportIntersection(t,n,r,i,a){let o=this.from,s=this.to,c=o.distanceTo(n),l=this.result;if(!(this.skipBackfaces&&t.dot(this.direction)>0))switch(l.hitFaceIndex=a===void 0?-1:a,this.mode){case e.ALL:this.hasHit=!0,l.set(o,s,t,n,r,i,c),l.hasHit=!0,this.callback(l);break;case e.CLOSEST:(c<l.distance||!l.hasHit)&&(this.hasHit=!0,l.hasHit=!0,l.set(o,s,t,n,r,i,c));break;case e.ANY:this.hasHit=!0,l.hasHit=!0,l.set(o,s,t,n,r,i,c),l.shouldStop=!0}}static pointInTriangle(e,t,n,r){r.vsub(t,KN),n.vsub(t,SN),e.vsub(t,CN);let i=KN.dot(KN),a=KN.dot(SN),o=KN.dot(CN),s=SN.dot(SN),c=SN.dot(CN),l,u;return(l=s*o-a*c)>=0&&(u=i*c-a*o)>=0&&l+u<i*s-a*a}},yN.CLOSEST=vN.CLOSEST,yN.ANY=vN.ANY,yN.ALL=vN.ALL,bN=new SM,xN=[],SN=new $,CN=new $,wN=new $,TN=new DM,EN=new $,DN=new $,ON=new $,kN=new $,new $,new uN,AN={faceList:[0]},jN=new $,MN=new yN,NN=[],PN=new $,FN=new $,IN=new $,new $,new $,LN=new $,RN=new $,zN=new $,BN=new $,VN=new $,HN=new $,UN=new $,new SM,WN=[],GN=new MM,KN=new $,qN=new $,JN=class{static defaults(e,t){e===void 0&&(e={});for(let n in t)n in e||(e[n]=t[n]);return e}},YN=class e{constructor(t,n,r){r===void 0&&(r={}),r=JN.defaults(r,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=n,this.id=e.idCounter++,this.collideConnected=r.collideConnected,r.wakeUpBodies&&(t&&t.wakeUp(),n&&n.wakeUp())}update(){throw Error(`method update() not implmemented in this Constraint subclass!`)}enable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!0}disable(){let e=this.equations;for(let t=0;t<e.length;t++)e[t].enabled=!1}},YN.idCounter=0,XN=class{constructor(){this.spatial=new $,this.rotational=new $}multiplyElement(e){return e.spatial.dot(this.spatial)+e.rotational.dot(this.rotational)}multiplyVectors(e,t){return e.dot(this.spatial)+t.dot(this.rotational)}},ZN=class e{constructor(t,n,r,i){r===void 0&&(r=-1e6),i===void 0&&(i=1e6),this.id=e.idCounter++,this.minForce=r,this.maxForce=i,this.bi=t,this.bj=n,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new XN,this.jacobianElementB=new XN,this.enabled=!0,this.multiplier=0,this.setSpookParams(1e7,4,1/60)}setSpookParams(e,t,n){let r=t,i=e,a=n;this.a=4/(a*(1+4*r)),this.b=4*r/(1+4*r),this.eps=4/(a*a*i*(1+4*r))}computeB(e,t,n){let r=this.computeGW(),i=this.computeGq(),a=this.computeGiMf();return-i*e-r*t-a*n}computeGq(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.position,a=r.position;return e.spatial.dot(i)+t.spatial.dot(a)}computeGW(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.velocity,a=r.velocity,o=n.angularVelocity,s=r.angularVelocity;return e.multiplyVectors(i,o)+t.multiplyVectors(a,s)}computeGWlambda(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.vlambda,a=r.vlambda,o=n.wlambda,s=r.wlambda;return e.multiplyVectors(i,o)+t.multiplyVectors(a,s)}computeGiMf(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.force,a=n.torque,o=r.force,s=r.torque,c=n.invMassSolve,l=r.invMassSolve;return i.scale(c,QN),o.scale(l,$N),n.invInertiaWorldSolve.vmult(a,eP),r.invInertiaWorldSolve.vmult(s,tP),e.multiplyVectors(QN,eP)+t.multiplyVectors($N,tP)}computeGiMGt(){let e=this.jacobianElementA,t=this.jacobianElementB,n=this.bi,r=this.bj,i=n.invMassSolve,a=r.invMassSolve,o=n.invInertiaWorldSolve,s=r.invInertiaWorldSolve,c=i+a;return o.vmult(e.rotational,nP),c+=nP.dot(e.rotational),s.vmult(t.rotational,nP),c+=nP.dot(t.rotational),c}addToWlambda(e){let t=this.jacobianElementA,n=this.jacobianElementB,r=this.bi,i=this.bj,a=rP;r.vlambda.addScaledVector(r.invMassSolve*e,t.spatial,r.vlambda),i.vlambda.addScaledVector(i.invMassSolve*e,n.spatial,i.vlambda),r.invInertiaWorldSolve.vmult(t.rotational,a),r.wlambda.addScaledVector(e,a,r.wlambda),i.invInertiaWorldSolve.vmult(n.rotational,a),i.wlambda.addScaledVector(e,a,i.wlambda)}computeC(){return this.computeGiMGt()+this.eps}},ZN.idCounter=0,QN=new $,$N=new $,eP=new $,tP=new $,nP=new $,rP=new $,iP=class extends ZN{constructor(e,t,n){n===void 0&&(n=1e6),super(e,t,0,n),this.restitution=0,this.ri=new $,this.rj=new $,this.ni=new $}computeB(e){let t=this.a,n=this.b,r=this.bi,i=this.bj,a=this.ri,o=this.rj,s=aP,c=oP,l=r.velocity,u=r.angularVelocity;r.force,r.torque;let d=i.velocity,f=i.angularVelocity;i.force,i.torque;let p=sP,m=this.jacobianElementA,h=this.jacobianElementB,g=this.ni;a.cross(g,s),o.cross(g,c),g.negate(m.spatial),s.negate(m.rotational),h.spatial.copy(g),h.rotational.copy(c),p.copy(i.position),p.vadd(o,p),p.vsub(r.position,p),p.vsub(a,p);let _=g.dot(p),v=this.restitution+1,y=v*d.dot(g)-v*l.dot(g)+f.dot(c)-u.dot(s),b=this.computeGiMf();return-_*t-y*n-e*b}getImpactVelocityAlongNormal(){let e=cP,t=lP,n=uP,r=dP,i=fP;return this.bi.position.vadd(this.ri,n),this.bj.position.vadd(this.rj,r),this.bi.getVelocityAtWorldPoint(n,e),this.bj.getVelocityAtWorldPoint(r,t),e.vsub(t,i),this.ni.dot(i)}},aP=new $,oP=new $,sP=new $,cP=new $,lP=new $,uP=new $,dP=new $,fP=new $,pP=class extends YN{constructor(e,t,n,r,i){t===void 0&&(t=new $),r===void 0&&(r=new $),i===void 0&&(i=1e6),super(e,n),this.pivotA=t.clone(),this.pivotB=r.clone();let a=this.equationX=new iP(e,n),o=this.equationY=new iP(e,n),s=this.equationZ=new iP(e,n);this.equations.push(a,o,s),a.minForce=o.minForce=s.minForce=-i,a.maxForce=o.maxForce=s.maxForce=i,a.ni.set(1,0,0),o.ni.set(0,1,0),s.ni.set(0,0,1)}update(){let e=this.bodyA,t=this.bodyB,n=this.equationX,r=this.equationY,i=this.equationZ;e.quaternion.vmult(this.pivotA,n.ri),t.quaternion.vmult(this.pivotB,n.rj),r.ri.copy(n.ri),r.rj.copy(n.rj),i.ri.copy(n.ri),i.rj.copy(n.rj)}},new $,new $,mP=class extends ZN{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce;super(e,t,-r,r),this.axisA=n.axisA?n.axisA.clone():new $(1,0,0),this.axisB=n.axisB?n.axisB.clone():new $(0,1,0),this.maxAngle=Math.PI/2}computeB(e){let t=this.a,n=this.b,r=this.axisA,i=this.axisB,a=hP,o=gP,s=this.jacobianElementA,c=this.jacobianElementB;r.cross(i,a),i.cross(r,o),s.rotational.copy(o),c.rotational.copy(a);let l=Math.cos(this.maxAngle)-r.dot(i),u=this.computeGW(),d=this.computeGiMf();return-l*t-u*n-e*d}},hP=new $,gP=new $,new $,new $,_P=class extends YN{constructor(e,t,n,r){r===void 0&&(r=1e6),super(e,t),n===void 0&&(n=e.position.distanceTo(t.position)),this.distance=n;let i=this.distanceEquation=new iP(e,t);this.equations.push(i),i.minForce=-r,i.maxForce=r}update(){let e=this.bodyA,t=this.bodyB,n=this.distanceEquation,r=this.distance*.5,i=n.ni;t.position.vsub(e.position,i),i.normalize(),i.scale(r,n.ri),i.scale(-r,n.rj)}},vP=class extends pP{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce,i=new $,a=new $,o=new $;e.position.vadd(t.position,o),o.scale(.5,o),t.pointToLocalFrame(o,a),e.pointToLocalFrame(o,i),super(e,i,t,a,r),this.xA=e.vectorToLocalFrame($.UNIT_X),this.xB=t.vectorToLocalFrame($.UNIT_X),this.yA=e.vectorToLocalFrame($.UNIT_Y),this.yB=t.vectorToLocalFrame($.UNIT_Y),this.zA=e.vectorToLocalFrame($.UNIT_Z),this.zB=t.vectorToLocalFrame($.UNIT_Z);let s=this.rotationalEquation1=new mP(e,t,n),c=this.rotationalEquation2=new mP(e,t,n),l=this.rotationalEquation3=new mP(e,t,n);this.equations.push(s,c,l)}update(){let e=this.bodyA,t=this.bodyB;this.motorEquation;let n=this.rotationalEquation1,r=this.rotationalEquation2,i=this.rotationalEquation3;super.update(),e.vectorToWorldFrame(this.xA,n.axisA),t.vectorToWorldFrame(this.yB,n.axisB),e.vectorToWorldFrame(this.yA,r.axisA),t.vectorToWorldFrame(this.zB,r.axisB),e.vectorToWorldFrame(this.zA,i.axisA),t.vectorToWorldFrame(this.xB,i.axisB)}},new $,new $,yP=class extends ZN{constructor(e,t,n){n===void 0&&(n=1e6),super(e,t,-n,n),this.axisA=new $,this.axisB=new $,this.targetVelocity=0}computeB(e){this.a;let t=this.b;this.bi,this.bj;let n=this.axisA,r=this.axisB,i=this.jacobianElementA,a=this.jacobianElementB;i.rotational.copy(n),r.negate(a.rotational);let o=this.computeGW()-this.targetVelocity,s=this.computeGiMf();return-o*t-e*s}},bP=class extends pP{constructor(e,t,n){n===void 0&&(n={});let r=n.maxForce===void 0?1e6:n.maxForce,i=n.pivotA?n.pivotA.clone():new $,a=n.pivotB?n.pivotB.clone():new $;super(e,i,t,a,r),(this.axisA=n.axisA?n.axisA.clone():new $(1,0,0)).normalize(),(this.axisB=n.axisB?n.axisB.clone():new $(1,0,0)).normalize(),this.collideConnected=!!n.collideConnected;let o=this.rotationalEquation1=new mP(e,t,n),s=this.rotationalEquation2=new mP(e,t,n),c=this.motorEquation=new yP(e,t,r);c.enabled=!1,this.equations.push(o,s,c)}enableMotor(){this.motorEquation.enabled=!0}disableMotor(){this.motorEquation.enabled=!1}setMotorSpeed(e){this.motorEquation.targetVelocity=e}setMotorMaxForce(e){this.motorEquation.maxForce=e,this.motorEquation.minForce=-e}update(){let e=this.bodyA,t=this.bodyB,n=this.motorEquation,r=this.rotationalEquation1,i=this.rotationalEquation2,a=xP,o=SP,s=this.axisA,c=this.axisB;super.update(),e.quaternion.vmult(s,a),t.quaternion.vmult(c,o),a.tangents(r.axisA,i.axisA),r.axisB.copy(o),i.axisB.copy(o),this.motorEquation.enabled&&(e.quaternion.vmult(this.axisA,n.axisA),t.quaternion.vmult(this.axisB,n.axisB))}},xP=new $,SP=new $,CP=class extends ZN{constructor(e,t,n){super(e,t,-n,n),this.ri=new $,this.rj=new $,this.t=new $}computeB(e){this.a;let t=this.b;this.bi,this.bj;let n=this.ri,r=this.rj,i=wP,a=TP,o=this.t;n.cross(o,i),r.cross(o,a);let s=this.jacobianElementA,c=this.jacobianElementB;o.negate(s.spatial),i.negate(s.rotational),c.spatial.copy(o),c.rotational.copy(a);let l=this.computeGW(),u=this.computeGiMf();return-l*t-e*u}},wP=new $,TP=new $,EP=class e{constructor(t,n,r){r=JN.defaults(r,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=e.idCounter++,this.materials=[t,n],this.friction=r.friction,this.restitution=r.restitution,this.contactEquationStiffness=r.contactEquationStiffness,this.contactEquationRelaxation=r.contactEquationRelaxation,this.frictionEquationStiffness=r.frictionEquationStiffness,this.frictionEquationRelaxation=r.frictionEquationRelaxation}},EP.idCounter=0,DP=class e{constructor(t){t===void 0&&(t={});let n=``;typeof t==`string`&&(n=t,t={}),this.name=n,this.id=e.idCounter++,this.friction=t.friction===void 0?-1:t.friction,this.restitution=t.restitution===void 0?-1:t.restitution}},DP.idCounter=0,OP=class{constructor(e,t,n){n===void 0&&(n={}),this.restLength=typeof n.restLength==`number`?n.restLength:1,this.stiffness=n.stiffness||100,this.damping=n.damping||1,this.bodyA=e,this.bodyB=t,this.localAnchorA=new $,this.localAnchorB=new $,n.localAnchorA&&this.localAnchorA.copy(n.localAnchorA),n.localAnchorB&&this.localAnchorB.copy(n.localAnchorB),n.worldAnchorA&&this.setWorldAnchorA(n.worldAnchorA),n.worldAnchorB&&this.setWorldAnchorB(n.worldAnchorB)}setWorldAnchorA(e){this.bodyA.pointToLocalFrame(e,this.localAnchorA)}setWorldAnchorB(e){this.bodyB.pointToLocalFrame(e,this.localAnchorB)}getWorldAnchorA(e){this.bodyA.pointToWorldFrame(this.localAnchorA,e)}getWorldAnchorB(e){this.bodyB.pointToWorldFrame(this.localAnchorB,e)}applyForce(){let e=this.stiffness,t=this.damping,n=this.restLength,r=this.bodyA,i=this.bodyB,a=kP,o=AP,s=jP,c=MP,l=zP,u=NP,d=PP,f=FP,p=IP,m=LP,h=RP;this.getWorldAnchorA(u),this.getWorldAnchorB(d),u.vsub(r.position,f),d.vsub(i.position,p),d.vsub(u,a);let g=a.length();o.copy(a),o.normalize(),i.velocity.vsub(r.velocity,s),i.angularVelocity.cross(p,l),s.vadd(l,s),r.angularVelocity.cross(f,l),s.vsub(l,s),o.scale(-e*(g-n)-t*s.dot(o),c),r.force.vsub(c,r.force),i.force.vadd(c,i.force),f.cross(c,m),p.cross(c,h),r.torque.vsub(m,r.torque),i.torque.vadd(h,i.torque)}},kP=new $,AP=new $,jP=new $,MP=new $,NP=new $,PP=new $,FP=new $,IP=new $,LP=new $,RP=new $,zP=new $,new $,new $,new $,new $,new $,new $,new $,new $,new yN,new $,new $,new $,new $(1,0,0),new $(0,1,0),new $(0,0,1),new $,new $,new $,new $,new $,new $,new $,new $,new $,new $,new $,BP=class extends jM{constructor(e){if(super({type:jM.types.SPHERE}),this.radius=e===void 0?1:e,this.radius<0)throw Error(`The sphere radius cannot be negative.`);this.updateBoundingSphereRadius()}calculateLocalInertia(e,t){t===void 0&&(t=new $);let n=2*e*this.radius*this.radius/5;return t.x=n,t.y=n,t.z=n,t}volume(){return 4*Math.PI*this.radius**3/3}updateBoundingSphereRadius(){this.boundingSphereRadius=this.radius}calculateWorldAABB(e,t,n,r){let i=this.radius,a=[`x`,`y`,`z`];for(let t=0;t<a.length;t++){let o=a[t];n[o]=e[o]-i,r[o]=e[o]+i}}},new $,new $,new $,new $,new $,new $,new $,new $,new $,VP=class extends PM{constructor(e,t,n,r){if(e===void 0&&(e=1),t===void 0&&(t=1),n===void 0&&(n=1),r===void 0&&(r=8),e<0)throw Error(`The cylinder radiusTop cannot be negative.`);if(t<0)throw Error(`The cylinder radiusBottom cannot be negative.`);let i=r,a=[],o=[],s=[],c=[],l=[],u=Math.cos,d=Math.sin;a.push(new $(-t*d(0),-n*.5,t*u(0))),c.push(0),a.push(new $(-e*d(0),n*.5,e*u(0))),l.push(1);for(let r=0;r<i;r++){let f=2*Math.PI/i*(r+1),p=2*Math.PI/i*(r+.5);r<i-1?(a.push(new $(-t*d(f),-n*.5,t*u(f))),c.push(2*r+2),a.push(new $(-e*d(f),n*.5,e*u(f))),l.push(2*r+3),s.push([2*r,2*r+1,2*r+3,2*r+2])):s.push([2*r,2*r+1,1,0]),(i%2==1||r<i/2)&&o.push(new $(-d(p),0,u(p)))}s.push(c),o.push(new $(0,1,0));let f=[];for(let e=0;e<l.length;e++)f.push(l[l.length-e-1]);s.push(f),super({vertices:a,faces:s,axes:o}),this.type=jM.types.CYLINDER,this.radiusTop=e,this.radiusBottom=t,this.height=n,this.numSegments=r}},new $,HP=class extends jM{constructor(e,t){t===void 0&&(t={}),t=JN.defaults(t,{maxValue:null,minValue:null,elementSize:1}),super({type:jM.types.HEIGHTFIELD}),this.data=e,this.maxValue=t.maxValue,this.minValue=t.minValue,this.elementSize=t.elementSize,t.minValue===null&&this.updateMinValue(),t.maxValue===null&&this.updateMaxValue(),this.cacheEnabled=!0,this.pillarConvex=new PM,this.pillarOffset=new $,this.updateBoundingSphereRadius(),this._cachedPillars={}}update(){this._cachedPillars={}}updateMinValue(){let e=this.data,t=e[0][0];for(let n=0;n!==e.length;n++)for(let r=0;r!==e[n].length;r++){let i=e[n][r];i<t&&(t=i)}this.minValue=t}updateMaxValue(){let e=this.data,t=e[0][0];for(let n=0;n!==e.length;n++)for(let r=0;r!==e[n].length;r++){let i=e[n][r];i>t&&(t=i)}this.maxValue=t}setHeightValueAtIndex(e,t,n){let r=this.data;r[e][t]=n,this.clearCachedConvexTrianglePillar(e,t,!1),e>0&&(this.clearCachedConvexTrianglePillar(e-1,t,!0),this.clearCachedConvexTrianglePillar(e-1,t,!1)),t>0&&(this.clearCachedConvexTrianglePillar(e,t-1,!0),this.clearCachedConvexTrianglePillar(e,t-1,!1)),t>0&&e>0&&this.clearCachedConvexTrianglePillar(e-1,t-1,!0)}getRectMinMax(e,t,n,r,i){i===void 0&&(i=[]);let a=this.data,o=this.minValue;for(let i=e;i<=n;i++)for(let e=t;e<=r;e++){let t=a[i][e];t>o&&(o=t)}i[0]=this.minValue,i[1]=o}getIndexOfPosition(e,t,n,r){let i=this.elementSize,a=this.data,o=Math.floor(e/i),s=Math.floor(t/i);return n[0]=o,n[1]=s,r&&(o<0&&(o=0),s<0&&(s=0),o>=a.length-1&&(o=a.length-1),s>=a[0].length-1&&(s=a[0].length-1)),!(o<0||s<0||o>=a.length-1||s>=a[0].length-1)}getTriangleAt(e,t,n,r,i,a){let o=UP;this.getIndexOfPosition(e,t,o,n);let s=o[0],c=o[1],l=this.data;n&&(s=Math.min(l.length-2,Math.max(0,s)),c=Math.min(l[0].length-2,Math.max(0,c)));let u=this.elementSize,d=(e/u-s)**2+(t/u-c)**2>(e/u-(s+1))**2+(t/u-(c+1))**2;return this.getTriangle(s,c,d,r,i,a),d}getNormalAt(e,t,n,r){let i=JP,a=YP,o=XP,s=ZP,c=QP;this.getTriangleAt(e,t,n,i,a,o),a.vsub(i,s),o.vsub(i,c),s.cross(c,r),r.normalize()}getAabbAtIndex(e,t,n){let{lowerBound:r,upperBound:i}=n,a=this.data,o=this.elementSize;r.set(e*o,t*o,a[e][t]),i.set((e+1)*o,(t+1)*o,a[e+1][t+1])}getHeightAt(e,t,n){let r=this.data,i=GP,a=KP,o=qP,s=UP;this.getIndexOfPosition(e,t,s,n);let c=s[0],l=s[1];n&&(c=Math.min(r.length-2,Math.max(0,c)),l=Math.min(r[0].length-2,Math.max(0,l)));let u=this.getTriangleAt(e,t,n,i,a,o);mM(e,t,i.x,i.y,a.x,a.y,o.x,o.y,WP);let d=WP;return u?r[c+1][l+1]*d.x+r[c][l+1]*d.y+r[c+1][l]*d.z:r[c][l]*d.x+r[c+1][l]*d.y+r[c][l+1]*d.z}getCacheConvexTrianglePillarKey(e,t,n){return`${e}_${t}_${+!!n}`}getCachedConvexTrianglePillar(e,t,n){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]}setCachedConvexTrianglePillar(e,t,n,r,i){this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]={convex:r,offset:i}}clearCachedConvexTrianglePillar(e,t,n){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(e,t,n)]}getTriangle(e,t,n,r,i,a){let o=this.data,s=this.elementSize;n?(r.set((e+1)*s,(t+1)*s,o[e+1][t+1]),i.set(e*s,(t+1)*s,o[e][t+1]),a.set((e+1)*s,t*s,o[e+1][t])):(r.set(e*s,t*s,o[e][t]),i.set((e+1)*s,t*s,o[e+1][t]),a.set(e*s,(t+1)*s,o[e][t+1]))}getConvexTrianglePillar(e,t,n){let r=this.pillarConvex,i=this.pillarOffset;if(this.cacheEnabled){let a=this.getCachedConvexTrianglePillar(e,t,n);if(a){this.pillarConvex=a.convex,this.pillarOffset=a.offset;return}r=new PM,i=new $,this.pillarConvex=r,this.pillarOffset=i}let a=this.data,o=this.elementSize,s=r.faces;r.vertices.length=6;for(let e=0;e<6;e++)r.vertices[e]||(r.vertices[e]=new $);s.length=5;for(let e=0;e<5;e++)s[e]||(s[e]=[]);let c=r.vertices,l=(Math.min(a[e][t],a[e+1][t],a[e][t+1],a[e+1][t+1])-this.minValue)/2+this.minValue;n?(i.set((e+.75)*o,(t+.75)*o,l),c[0].set(.25*o,.25*o,a[e+1][t+1]-l),c[1].set(-.75*o,.25*o,a[e][t+1]-l),c[2].set(.25*o,-.75*o,a[e+1][t]-l),c[3].set(.25*o,.25*o,-Math.abs(l)-1),c[4].set(-.75*o,.25*o,-Math.abs(l)-1),c[5].set(.25*o,-.75*o,-Math.abs(l)-1),s[0][0]=0,s[0][1]=1,s[0][2]=2,s[1][0]=5,s[1][1]=4,s[1][2]=3,s[2][0]=2,s[2][1]=5,s[2][2]=3,s[2][3]=0,s[3][0]=3,s[3][1]=4,s[3][2]=1,s[3][3]=0,s[4][0]=1,s[4][1]=4,s[4][2]=5,s[4][3]=2):(i.set((e+.25)*o,(t+.25)*o,l),c[0].set(-.25*o,-.25*o,a[e][t]-l),c[1].set(.75*o,-.25*o,a[e+1][t]-l),c[2].set(-.25*o,.75*o,a[e][t+1]-l),c[3].set(-.25*o,-.25*o,-Math.abs(l)-1),c[4].set(.75*o,-.25*o,-Math.abs(l)-1),c[5].set(-.25*o,.75*o,-Math.abs(l)-1),s[0][0]=0,s[0][1]=1,s[0][2]=2,s[1][0]=5,s[1][1]=4,s[1][2]=3,s[2][0]=0,s[2][1]=2,s[2][2]=5,s[2][3]=3,s[3][0]=1,s[3][1]=0,s[3][2]=3,s[3][3]=4,s[4][0]=4,s[4][1]=5,s[4][2]=2,s[4][3]=1),r.computeNormals(),r.computeEdges(),r.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(e,t,n,r,i)}calculateLocalInertia(e,t){return t===void 0&&(t=new $),t.set(0,0,0),t}volume(){return Number.MAX_VALUE}calculateWorldAABB(e,t,n,r){n.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}updateBoundingSphereRadius(){let e=this.data,t=this.elementSize;this.boundingSphereRadius=new $(e.length*t,e[0].length*t,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).length()}setHeightsFromImage(e,t){let{x:n,z:r,y:i}=t,a=document.createElement(`canvas`);a.width=e.width,a.height=e.height;let o=a.getContext(`2d`);o.drawImage(e,0,0);let s=o.getImageData(0,0,e.width,e.height),c=this.data;c.length=0,this.elementSize=Math.abs(n)/s.width;for(let e=0;e<s.height;e++){let t=[];for(let i=0;i<s.width;i++){let a=s.data[(e*s.height+i)*4],o=s.data[(e*s.height+i)*4+1],c=s.data[(e*s.height+i)*4+2],l=(a+o+c)/4/255*r;n<0?t.push(l):t.unshift(l)}i<0?c.unshift(t):c.push(t)}this.updateMaxValue(),this.updateMinValue(),this.update()}},UP=[],WP=new $,GP=new $,KP=new $,qP=new $,JP=new $,YP=new $,XP=new $,ZP=new $,QP=new $,new $,new SM,new $,new SM,new $,new $,new $,new $,new $,new $,new $,new SM,new $,new MM,new SM,$P=class{constructor(){this.equations=[]}solve(e,t){return 0}addEquation(e){e.enabled&&!e.bi.isTrigger&&!e.bj.isTrigger&&this.equations.push(e)}removeEquation(e){let t=this.equations,n=t.indexOf(e);n!==-1&&t.splice(n,1)}removeAllEquations(){this.equations.length=0}},eF=class extends $P{constructor(){super(),this.iterations=10,this.tolerance=1e-7}solve(e,t){let n=0,r=this.iterations,i=this.tolerance*this.tolerance,a=this.equations,o=a.length,s=t.bodies,c=s.length,l=e,u,d,f,p,m,h;if(o!==0)for(let e=0;e!==c;e++)s[e].updateSolveMassProperties();let g=nF,_=rF,v=tF;g.length=o,_.length=o,v.length=o;for(let e=0;e!==o;e++){let t=a[e];v[e]=0,_[e]=t.computeB(l),g[e]=1/t.computeC()}if(o!==0){for(let e=0;e!==c;e++){let t=s[e],n=t.vlambda,r=t.wlambda;n.set(0,0,0),r.set(0,0,0)}for(n=0;n!==r;n++){p=0;for(let e=0;e!==o;e++){let t=a[e];u=_[e],d=g[e],h=v[e],m=t.computeGWlambda(),f=d*(u-m-t.eps*h),h+f<t.minForce?f=t.minForce-h:h+f>t.maxForce&&(f=t.maxForce-h),v[e]+=f,p+=f>0?f:-f,t.addToWlambda(f)}if(p*p<i)break}for(let e=0;e!==c;e++){let t=s[e],n=t.velocity,r=t.angularVelocity;t.vlambda.vmul(t.linearFactor,t.vlambda),n.vadd(t.vlambda,n),t.wlambda.vmul(t.angularFactor,t.wlambda),r.vadd(t.wlambda,r)}let e=a.length,t=1/l;for(;e--;)a[e].multiplier=v[e]*t}return n}},tF=[],nF=[],rF=[],WM.STATIC,iF=class{constructor(){this.objects=[],this.type=Object}release(){let e=arguments.length;for(let t=0;t!==e;t++)this.objects.push(t<0||arguments.length<=t?void 0:arguments[t]);return this}get(){return this.objects.length===0?this.constructObject():this.objects.pop()}constructObject(){throw Error(`constructObject() not implemented in this Pool subclass yet!`)}resize(e){let t=this.objects;for(;t.length>e;)t.pop();for(;t.length<e;)t.push(this.constructObject());return this}},aF=class extends iF{constructor(){super(...arguments),this.type=$}constructObject(){return new $}},oF={sphereSphere:jM.types.SPHERE,spherePlane:jM.types.SPHERE|jM.types.PLANE,boxBox:jM.types.BOX|jM.types.BOX,sphereBox:jM.types.SPHERE|jM.types.BOX,planeBox:jM.types.PLANE|jM.types.BOX,convexConvex:jM.types.CONVEXPOLYHEDRON,sphereConvex:jM.types.SPHERE|jM.types.CONVEXPOLYHEDRON,planeConvex:jM.types.PLANE|jM.types.CONVEXPOLYHEDRON,boxConvex:jM.types.BOX|jM.types.CONVEXPOLYHEDRON,sphereHeightfield:jM.types.SPHERE|jM.types.HEIGHTFIELD,boxHeightfield:jM.types.BOX|jM.types.HEIGHTFIELD,convexHeightfield:jM.types.CONVEXPOLYHEDRON|jM.types.HEIGHTFIELD,sphereParticle:jM.types.PARTICLE|jM.types.SPHERE,planeParticle:jM.types.PLANE|jM.types.PARTICLE,boxParticle:jM.types.BOX|jM.types.PARTICLE,convexParticle:jM.types.PARTICLE|jM.types.CONVEXPOLYHEDRON,cylinderCylinder:jM.types.CYLINDER,sphereCylinder:jM.types.SPHERE|jM.types.CYLINDER,planeCylinder:jM.types.PLANE|jM.types.CYLINDER,boxCylinder:jM.types.BOX|jM.types.CYLINDER,convexCylinder:jM.types.CONVEXPOLYHEDRON|jM.types.CYLINDER,heightfieldCylinder:jM.types.HEIGHTFIELD|jM.types.CYLINDER,particleCylinder:jM.types.PARTICLE|jM.types.CYLINDER,sphereTrimesh:jM.types.SPHERE|jM.types.TRIMESH,planeTrimesh:jM.types.PLANE|jM.types.TRIMESH},sF=class{get[oF.sphereSphere](){return this.sphereSphere}get[oF.spherePlane](){return this.spherePlane}get[oF.boxBox](){return this.boxBox}get[oF.sphereBox](){return this.sphereBox}get[oF.planeBox](){return this.planeBox}get[oF.convexConvex](){return this.convexConvex}get[oF.sphereConvex](){return this.sphereConvex}get[oF.planeConvex](){return this.planeConvex}get[oF.boxConvex](){return this.boxConvex}get[oF.sphereHeightfield](){return this.sphereHeightfield}get[oF.boxHeightfield](){return this.boxHeightfield}get[oF.convexHeightfield](){return this.convexHeightfield}get[oF.sphereParticle](){return this.sphereParticle}get[oF.planeParticle](){return this.planeParticle}get[oF.boxParticle](){return this.boxParticle}get[oF.convexParticle](){return this.convexParticle}get[oF.cylinderCylinder](){return this.convexConvex}get[oF.sphereCylinder](){return this.sphereConvex}get[oF.planeCylinder](){return this.planeConvex}get[oF.boxCylinder](){return this.boxConvex}get[oF.convexCylinder](){return this.convexConvex}get[oF.heightfieldCylinder](){return this.heightfieldCylinder}get[oF.particleCylinder](){return this.particleCylinder}get[oF.sphereTrimesh](){return this.sphereTrimesh}get[oF.planeTrimesh](){return this.planeTrimesh}constructor(e){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new aF,this.world=e,this.currentContactMaterial=e.defaultContactMaterial,this.enableFrictionReduction=!1}createContactEquation(e,t,n,r,i,a){let o;this.contactPointPool.length?(o=this.contactPointPool.pop(),o.bi=e,o.bj=t):o=new iP(e,t),o.enabled=e.collisionResponse&&t.collisionResponse&&n.collisionResponse&&r.collisionResponse;let s=this.currentContactMaterial;o.restitution=s.restitution,o.setSpookParams(s.contactEquationStiffness,s.contactEquationRelaxation,this.world.dt);let c=n.material||e.material,l=r.material||t.material;return c&&l&&c.restitution>=0&&l.restitution>=0&&(o.restitution=c.restitution*l.restitution),o.si=i||n,o.sj=a||r,o}createFrictionEquationsFromContact(e,t){let n=e.bi,r=e.bj,i=e.si,a=e.sj,o=this.world,s=this.currentContactMaterial,c=s.friction,l=i.material||n.material,u=a.material||r.material;if(l&&u&&l.friction>=0&&u.friction>=0&&(c=l.friction*u.friction),c>0){let i=c*(o.frictionGravity||o.gravity).length(),a=n.invMass+r.invMass;a>0&&(a=1/a);let l=this.frictionEquationPool,u=l.length?l.pop():new CP(n,r,i*a),d=l.length?l.pop():new CP(n,r,i*a);return u.bi=d.bi=n,u.bj=d.bj=r,u.minForce=d.minForce=-i*a,u.maxForce=d.maxForce=i*a,u.ri.copy(e.ri),u.rj.copy(e.rj),d.ri.copy(e.ri),d.rj.copy(e.rj),e.ni.tangents(u.t,d.t),u.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,o.dt),d.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,o.dt),u.enabled=d.enabled=e.enabled,t.push(u,d),!0}return!1}createFrictionFromAverage(e){let t=this.result[this.result.length-1];if(!this.createFrictionEquationsFromContact(t,this.frictionResult)||e===1)return;let n=this.frictionResult[this.frictionResult.length-2],r=this.frictionResult[this.frictionResult.length-1];cF.setZero(),lF.setZero(),uF.setZero();let i=t.bi;t.bj;for(let n=0;n!==e;n++)t=this.result[this.result.length-1-n],t.bi===i?(cF.vsub(t.ni,cF),lF.vadd(t.rj,lF),uF.vadd(t.ri,uF)):(cF.vadd(t.ni,cF),lF.vadd(t.ri,lF),uF.vadd(t.rj,uF));let a=1/e;lF.scale(a,n.ri),uF.scale(a,n.rj),r.ri.copy(n.ri),r.rj.copy(n.rj),cF.normalize(),cF.tangents(n.t,r.t)}getContacts(e,t,n,r,i,a,o){this.contactPointPool=i,this.frictionEquationPool=o,this.result=r,this.frictionResult=a;let s=pF,c=mF,l=dF,u=fF;for(let r=0,i=e.length;r!==i;r++){let i=e[r],a=t[r],o=null;i.material&&a.material&&(o=n.getContactMaterial(i.material,a.material)||null);let d=i.type&WM.KINEMATIC&&a.type&WM.STATIC||i.type&WM.STATIC&&a.type&WM.KINEMATIC||i.type&WM.KINEMATIC&&a.type&WM.KINEMATIC;for(let e=0;e<i.shapes.length;e++){i.quaternion.mult(i.shapeOrientations[e],s),i.quaternion.vmult(i.shapeOffsets[e],l),l.vadd(i.position,l);let t=i.shapes[e];for(let e=0;e<a.shapes.length;e++){a.quaternion.mult(a.shapeOrientations[e],c),a.quaternion.vmult(a.shapeOffsets[e],u),u.vadd(a.position,u);let r=a.shapes[e];if(!(t.collisionFilterMask&r.collisionFilterGroup&&r.collisionFilterMask&t.collisionFilterGroup)||l.distanceTo(u)>t.boundingSphereRadius+r.boundingSphereRadius)continue;let f=null;t.material&&r.material&&(f=n.getContactMaterial(t.material,r.material)||null),this.currentContactMaterial=f||o||n.defaultContactMaterial;let p=t.type|r.type,m=this[p];if(m){let e=!1;e=t.type<r.type?m.call(this,t,r,l,u,s,c,i,a,t,r,d):m.call(this,r,t,u,l,c,s,a,i,t,r,d),e&&d&&(n.shapeOverlapKeeper.set(t.id,r.id),n.bodyOverlapKeeper.set(i.id,a.id))}}}}}sphereSphere(e,t,n,r,i,a,o,s,c,l,u){if(u)return n.distanceSquared(r)<(e.radius+t.radius)**2;let d=this.createContactEquation(o,s,e,t,c,l);r.vsub(n,d.ni),d.ni.normalize(),d.ri.copy(d.ni),d.rj.copy(d.ni),d.ri.scale(e.radius,d.ri),d.rj.scale(-t.radius,d.rj),d.ri.vadd(n,d.ri),d.ri.vsub(o.position,d.ri),d.rj.vadd(r,d.rj),d.rj.vsub(s.position,d.rj),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}spherePlane(e,t,n,r,i,a,o,s,c,l,u){let d=this.createContactEquation(o,s,e,t,c,l);if(d.ni.set(0,0,1),a.vmult(d.ni,d.ni),d.ni.negate(d.ni),d.ni.normalize(),d.ni.scale(e.radius,d.ri),n.vsub(r,NF),d.ni.scale(d.ni.dot(NF),PF),NF.vsub(PF,d.rj),-NF.dot(d.ni)<=e.radius){if(u)return!0;let e=d.ri,t=d.rj;e.vadd(n,e),e.vsub(o.position,e),t.vadd(r,t),t.vsub(s.position,t),this.result.push(d),this.createFrictionEquationsFromContact(d,this.frictionResult)}}boxBox(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t.convexPolyhedronRepresentation,n,r,i,a,o,s,e,t,u)}sphereBox(e,t,n,r,i,a,o,s,c,l,u){let d=this.v3pool,f=HF;n.vsub(r,RF),t.getSideNormals(f,a);let p=e.radius,m=!1,h=WF,g=GF,_=KF,v=null,y=0,b=0,x=0,S=null;for(let e=0,t=f.length;e!==t&&m===!1;e++){let t=zF;t.copy(f[e]);let n=t.length();t.normalize();let r=RF.dot(t);if(r<n+p&&r>0){let i=BF,a=VF;i.copy(f[(e+1)%3]),a.copy(f[(e+2)%3]);let o=i.length(),s=a.length();i.normalize(),a.normalize();let c=RF.dot(i),l=RF.dot(a);if(c<o&&c>-o&&l<s&&l>-s){let e=Math.abs(r-n-p);if((S===null||e<S)&&(S=e,b=c,x=l,v=n,h.copy(t),g.copy(i),_.copy(a),y++,u))return!0}}}if(y){m=!0;let i=this.createContactEquation(o,s,e,t,c,l);h.scale(-p,i.ri),i.ni.copy(h),i.ni.negate(i.ni),h.scale(v,h),g.scale(b,g),h.vadd(g,h),_.scale(x,_),h.vadd(_,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}let C=d.get(),w=UF;for(let i=0;i!==2&&!m;i++)for(let a=0;a!==2&&!m;a++)for(let d=0;d!==2&&!m;d++)if(C.set(0,0,0),i?C.vadd(f[0],C):C.vsub(f[0],C),a?C.vadd(f[1],C):C.vsub(f[1],C),d?C.vadd(f[2],C):C.vsub(f[2],C),r.vadd(C,w),w.vsub(n,w),w.lengthSquared()<p*p){if(u)return!0;m=!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ri.copy(w),i.ri.normalize(),i.ni.copy(i.ri),i.ri.scale(p,i.ri),i.rj.copy(C),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}d.release(C),C=null;let T=d.get(),E=d.get(),D=d.get(),O=d.get(),k=d.get(),A=f.length;for(let i=0;i!==A&&!m;i++)for(let a=0;a!==A&&!m;a++)if(i%3!=a%3){f[a].cross(f[i],T),T.normalize(),f[i].vadd(f[a],E),D.copy(n),D.vsub(E,D),D.vsub(r,D);let d=D.dot(T);T.scale(d,O);let h=0;for(;h===i%3||h===a%3;)h++;k.copy(n),k.vsub(O,k),k.vsub(E,k),k.vsub(r,k);let g=Math.abs(d),_=k.length();if(g<f[h].length()&&_<p){if(u)return!0;m=!0;let i=this.createContactEquation(o,s,e,t,c,l);E.vadd(O,i.rj),i.rj.copy(i.rj),k.negate(i.ni),i.ni.normalize(),i.ri.copy(i.rj),i.ri.vadd(r,i.ri),i.ri.vsub(n,i.ri),i.ri.normalize(),i.ri.scale(p,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}d.release(T,E,D,O,k)}planeBox(e,t,n,r,i,a,o,s,c,l,u){return t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,t.convexPolyhedronRepresentation.id=t.id,this.planeConvex(e,t.convexPolyhedronRepresentation,n,r,i,a,o,s,e,t,u)}convexConvex(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=sI;if(!(n.distanceTo(r)>e.boundingSphereRadius+t.boundingSphereRadius)&&e.findSeparatingAxis(t,n,i,r,a,p,d,f)){let d=[],f=cI;e.clipAgainstHull(n,i,t,r,a,p,-100,100,d);let m=0;for(let i=0;i!==d.length;i++){if(u)return!0;let a=this.createContactEquation(o,s,e,t,c,l),h=a.ri,g=a.rj;p.negate(a.ni),d[i].normal.negate(f),f.scale(d[i].depth,f),d[i].point.vadd(f,h),g.copy(d[i].point),h.vsub(n,h),g.vsub(r,g),h.vadd(n,h),h.vsub(o.position,h),g.vadd(r,g),g.vsub(s.position,g),this.result.push(a),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(a,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}}sphereConvex(e,t,n,r,i,a,o,s,c,l,u){let d=this.v3pool;n.vsub(r,qF);let f=t.faceNormals,p=t.faces,m=t.vertices,h=e.radius,g=!1;for(let i=0;i!==m.length;i++){let d=m[i],f=ZF;a.vmult(d,f),r.vadd(f,f);let p=XF;if(f.vsub(n,p),p.lengthSquared()<h*h){if(u)return!0;g=!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ri.copy(p),i.ri.normalize(),i.ni.copy(i.ri),i.ri.scale(h,i.ri),f.vsub(r,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult);return}}for(let i=0,_=p.length;i!==_&&g===!1;i++){let _=f[i],v=p[i],y=QF;a.vmult(_,y);let b=$F;a.vmult(m[v[0]],b),b.vadd(r,b);let x=eI;y.scale(-h,x),n.vadd(x,x);let S=tI;x.vsub(b,S);let C=S.dot(y),w=nI;if(n.vsub(b,w),C<0&&w.dot(y)>0){let i=[];for(let e=0,t=v.length;e!==t;e++){let t=d.get();a.vmult(m[v[e]],t),r.vadd(t,t),i.push(t)}if(hM(i,y,n)){if(u)return!0;g=!0;let a=this.createContactEquation(o,s,e,t,c,l);y.scale(-h,a.ri),y.negate(a.ni);let f=d.get();y.scale(-C,f);let p=d.get();y.scale(-h,p),n.vsub(r,a.rj),a.rj.vadd(p,a.rj),a.rj.vadd(f,a.rj),a.rj.vadd(r,a.rj),a.rj.vsub(s.position,a.rj),a.ri.vadd(n,a.ri),a.ri.vsub(o.position,a.ri),d.release(f),d.release(p),this.result.push(a),this.createFrictionEquationsFromContact(a,this.frictionResult);for(let e=0,t=i.length;e!==t;e++)d.release(i[e]);return}for(let f=0;f!==v.length;f++){let p=d.get(),g=d.get();a.vmult(m[v[(f+1)%v.length]],p),a.vmult(m[v[(f+2)%v.length]],g),r.vadd(p,p),r.vadd(g,g);let _=JF;g.vsub(p,_);let y=YF;_.unit(y);let b=d.get(),x=d.get();n.vsub(p,x);let S=x.dot(y);y.scale(S,b),b.vadd(p,b);let C=d.get();if(b.vsub(n,C),S>0&&S*S<_.lengthSquared()&&C.lengthSquared()<h*h){if(u)return!0;let a=this.createContactEquation(o,s,e,t,c,l);b.vsub(r,a.rj),b.vsub(n,a.ni),a.ni.normalize(),a.ni.scale(h,a.ri),a.rj.vadd(r,a.rj),a.rj.vsub(s.position,a.rj),a.ri.vadd(n,a.ri),a.ri.vsub(o.position,a.ri),this.result.push(a),this.createFrictionEquationsFromContact(a,this.frictionResult);for(let e=0,t=i.length;e!==t;e++)d.release(i[e]);d.release(p),d.release(g),d.release(b),d.release(C),d.release(x);return}d.release(p),d.release(g),d.release(b),d.release(C),d.release(x)}for(let e=0,t=i.length;e!==t;e++)d.release(i[e])}}}planeConvex(e,t,n,r,i,a,o,s,c,l,u){let d=rI,f=iI;f.set(0,0,1),i.vmult(f,f);let p=0,m=aI;for(let i=0;i!==t.vertices.length;i++)if(d.copy(t.vertices[i]),a.vmult(d,d),r.vadd(d,d),d.vsub(n,m),f.dot(m)<=0){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l),a=oI;f.scale(f.dot(m),a),d.vsub(a,a),a.vsub(n,i.ri),i.ni.copy(f),d.vsub(r,i.rj),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.vadd(r,i.rj),i.rj.vsub(s.position,i.rj),this.result.push(i),p++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(i,this.frictionResult)}this.enableFrictionReduction&&p&&this.createFrictionFromAverage(p)}boxConvex(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}sphereHeightfield(e,t,n,r,i,a,o,s,c,l,u){let d=t.data,f=e.radius,p=t.elementSize,m=SI,h=xI;MM.pointToLocalFrame(r,a,n,h);let g=Math.floor((h.x-f)/p)-1,_=Math.ceil((h.x+f)/p)+1,v=Math.floor((h.y-f)/p)-1,y=Math.ceil((h.y+f)/p)+1;if(_<0||y<0||g>d.length||v>d[0].length)return;g<0&&(g=0),_<0&&(_=0),v<0&&(v=0),y<0&&(y=0),g>=d.length&&(g=d.length-1),_>=d.length&&(_=d.length-1),y>=d[0].length&&(y=d[0].length-1),v>=d[0].length&&(v=d[0].length-1);let b=[];t.getRectMinMax(g,v,_,y,b);let x=b[0],S=b[1];if(h.z-f>S||h.z+f<x)return;let C=this.result;for(let c=g;c<_;c++)for(let l=v;l<y;l++){let d=C.length,f=!1;if(t.getConvexTrianglePillar(c,l,!1),MM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(f=this.sphereConvex(e,t.pillarConvex,n,m,i,a,o,s,e,t,u)),u&&f||(t.getConvexTrianglePillar(c,l,!0),MM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(f=this.sphereConvex(e,t.pillarConvex,n,m,i,a,o,s,e,t,u)),u&&f))return!0;if(C.length-d>2)return}}boxHeightfield(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexHeightfield(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}convexHeightfield(e,t,n,r,i,a,o,s,c,l,u){let d=t.data,f=t.elementSize,p=e.boundingSphereRadius,m=yI,h=bI,g=vI;MM.pointToLocalFrame(r,a,n,g);let _=Math.floor((g.x-p)/f)-1,v=Math.ceil((g.x+p)/f)+1,y=Math.floor((g.y-p)/f)-1,b=Math.ceil((g.y+p)/f)+1;if(v<0||b<0||_>d.length||y>d[0].length)return;_<0&&(_=0),v<0&&(v=0),y<0&&(y=0),b<0&&(b=0),_>=d.length&&(_=d.length-1),v>=d.length&&(v=d.length-1),b>=d[0].length&&(b=d[0].length-1),y>=d[0].length&&(y=d[0].length-1);let x=[];t.getRectMinMax(_,y,v,b,x);let S=x[0],C=x[1];if(!(g.z-p>C||g.z+p<S))for(let c=_;c<v;c++)for(let l=y;l<b;l++){let d=!1;if(t.getConvexTrianglePillar(c,l,!1),MM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(d=this.convexConvex(e,t.pillarConvex,n,m,i,a,o,s,null,null,u,h,null)),u&&d||(t.getConvexTrianglePillar(c,l,!0),MM.pointToWorldFrame(r,a,t.pillarOffset,m),n.distanceTo(m)<t.pillarConvex.boundingSphereRadius+e.boundingSphereRadius&&(d=this.convexConvex(e,t.pillarConvex,n,m,i,a,o,s,null,null,u,h,null)),u&&d))return!0}}sphereParticle(e,t,n,r,i,a,o,s,c,l,u){let d=fI;if(d.set(0,0,1),r.vsub(n,d),d.lengthSquared()<=e.radius*e.radius){if(u)return!0;let n=this.createContactEquation(s,o,t,e,c,l);d.normalize(),n.rj.copy(d),n.rj.scale(e.radius,n.rj),n.ni.copy(d),n.ni.negate(n.ni),n.ri.set(0,0,0),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}planeParticle(e,t,n,r,i,a,o,s,c,l,u){let d=lI;d.set(0,0,1),o.quaternion.vmult(d,d);let f=uI;if(r.vsub(o.position,f),d.dot(f)<=0){if(u)return!0;let n=this.createContactEquation(s,o,t,e,c,l);n.ni.copy(d),n.ni.negate(n.ni),n.ri.set(0,0,0);let i=dI;d.scale(d.dot(r),i),r.vsub(i,i),n.rj.copy(i),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}boxParticle(e,t,n,r,i,a,o,s,c,l,u){return e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexParticle(e.convexPolyhedronRepresentation,t,n,r,i,a,o,s,e,t,u)}convexParticle(e,t,n,r,i,a,o,s,c,l,u){let d=-1,f=hI,p=_I,m=null,h=mI;if(h.copy(r),h.vsub(n,h),i.conjugate(pI),pI.vmult(h,h),e.pointIsInside(h)){e.worldVerticesNeedsUpdate&&e.computeWorldVertices(n,i),e.worldFaceNormalsNeedsUpdate&&e.computeWorldFaceNormals(i);for(let t=0,n=e.faces.length;t!==n;t++){let n=[e.worldVertices[e.faces[t][0]]],i=e.worldFaceNormals[t];r.vsub(n[0],gI);let a=-i.dot(gI);if(m===null||Math.abs(a)<Math.abs(m)){if(u)return!0;m=a,d=t,f.copy(i)}}if(d!==-1){let i=this.createContactEquation(s,o,t,e,c,l);f.scale(m,p),p.vadd(r,p),p.vsub(n,p),i.rj.copy(p),f.negate(i.ni),i.ri.set(0,0,0);let a=i.ri,u=i.rj;a.vadd(r,a),a.vsub(s.position,a),u.vadd(n,u),u.vsub(o.position,u),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}else console.warn(`Point found inside convex, but did not find penetrating face!`)}}heightfieldCylinder(e,t,n,r,i,a,o,s,c,l,u){return this.convexHeightfield(t,e,r,n,a,i,s,o,c,l,u)}particleCylinder(e,t,n,r,i,a,o,s,c,l,u){return this.convexParticle(t,e,r,n,a,i,s,o,c,l,u)}sphereTrimesh(e,t,n,r,i,a,o,s,c,l,u){let d=SF,f=CF,p=wF,m=TF,h=EF,g=DF,_=jF,v=xF,y=yF,b=MF;MM.pointToLocalFrame(r,a,n,h);let x=e.radius;_.lowerBound.set(h.x-x,h.y-x,h.z-x),_.upperBound.set(h.x+x,h.y+x,h.z+x),t.getTrianglesInAABB(_,b);let S=bF,C=e.radius*e.radius;for(let i=0;i<b.length;i++)for(let d=0;d<3;d++)if(t.getVertex(t.indices[b[i]*3+d],S),S.vsub(h,y),y.lengthSquared()<=C){if(v.copy(S),MM.pointToWorldFrame(r,a,v,S),S.vsub(n,y),u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);i.ni.copy(y),i.ni.normalize(),i.ri.copy(i.ni),i.ri.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),i.rj.copy(S),i.rj.vsub(s.position,i.rj),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}for(let i=0;i<b.length;i++)for(let _=0;_<3;_++){t.getVertex(t.indices[b[i]*3+_],d),t.getVertex(t.indices[b[i]*3+(_+1)%3],f),f.vsub(d,p),h.vsub(f,g);let v=g.dot(p);h.vsub(d,g);let y=g.dot(p);if(y>0&&v<0&&(h.vsub(d,g),m.copy(p),m.normalize(),y=g.dot(m),m.scale(y,g),g.vadd(d,g),g.distanceTo(h)<e.radius)){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);g.vsub(h,i.ni),i.ni.normalize(),i.ni.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),MM.pointToWorldFrame(r,a,g,g),g.vsub(s.position,i.rj),MM.vectorToWorldFrame(a,i.ni,i.ni),MM.vectorToWorldFrame(a,i.ri,i.ri),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}let w=OF,T=kF,E=AF,D=vF;for(let i=0,d=b.length;i!==d;i++){t.getTriangleVertices(b[i],w,T,E),t.getNormal(b[i],D),h.vsub(w,g);let d=g.dot(D);if(D.scale(d,g),h.vsub(g,g),d=g.distanceTo(h),yN.pointInTriangle(g,w,T,E)&&d<e.radius){if(u)return!0;let i=this.createContactEquation(o,s,e,t,c,l);g.vsub(h,i.ni),i.ni.normalize(),i.ni.scale(e.radius,i.ri),i.ri.vadd(n,i.ri),i.ri.vsub(o.position,i.ri),MM.pointToWorldFrame(r,a,g,g),g.vsub(s.position,i.rj),MM.vectorToWorldFrame(a,i.ni,i.ni),MM.vectorToWorldFrame(a,i.ri,i.ri),this.result.push(i),this.createFrictionEquationsFromContact(i,this.frictionResult)}}b.length=0}planeTrimesh(e,t,n,r,i,a,o,s,c,l,u){let d=new $,f=hF;f.set(0,0,1),i.vmult(f,f);for(let i=0;i<t.vertices.length/3;i++){t.getVertex(i,d);let p=new $;p.copy(d),MM.pointToWorldFrame(r,a,p,d);let m=gF;if(d.vsub(n,m),f.dot(m)<=0){if(u)return!0;let n=this.createContactEquation(o,s,e,t,c,l);n.ni.copy(f);let r=_F;f.scale(m.dot(f),r),d.vsub(r,r),n.ri.copy(r),n.ri.vsub(o.position,n.ri),n.rj.copy(d),n.rj.vsub(s.position,n.rj),this.result.push(n),this.createFrictionEquationsFromContact(n,this.frictionResult)}}}},cF=new $,lF=new $,uF=new $,dF=new $,fF=new $,pF=new DM,mF=new DM,hF=new $,gF=new $,_F=new $,vF=new $,yF=new $,new $,bF=new $,xF=new $,SF=new $,CF=new $,wF=new $,TF=new $,EF=new $,DF=new $,OF=new $,kF=new $,AF=new $,jF=new SM,MF=[],NF=new $,PF=new $,FF=new $,IF=new $,LF=new $,RF=new $,zF=new $,BF=new $,VF=new $,HF=[new $,new $,new $,new $,new $,new $],UF=new $,WF=new $,GF=new $,KF=new $,qF=new $,JF=new $,YF=new $,XF=new $,ZF=new $,QF=new $,$F=new $,eI=new $,tI=new $,nI=new $,new $,new $,rI=new $,iI=new $,aI=new $,oI=new $,sI=new $,cI=new $,lI=new $,uI=new $,dI=new $,fI=new $,pI=new DM,mI=new $,new $,hI=new $,gI=new $,_I=new $,vI=new $,yI=new $,bI=[0],xI=new $,SI=new $,CI=class{constructor(){this.current=[],this.previous=[]}getKey(e,t){if(t<e){let n=t;t=e,e=n}return e<<16|t}set(e,t){let n=this.getKey(e,t),r=this.current,i=0;for(;n>r[i];)i++;if(n!==r[i]){for(let e=r.length-1;e>=i;e--)r[e+1]=r[e];r[i]=n}}tick(){let e=this.current;this.current=this.previous,this.previous=e,this.current.length=0}getDiff(e,t){let n=this.current,r=this.previous,i=n.length,a=r.length,o=0;for(let t=0;t<i;t++){let i=!1,a=n[t];for(;a>r[o];)o++;i=a===r[o],i||gM(e,a)}o=0;for(let e=0;e<a;e++){let i=!1,a=r[e];for(;a>n[o];)o++;i=n[o]===a,i||gM(t,a)}}},wI=(e,t)=>e<t?`${e}-${t}`:`${t}-${e}`,TI=class{constructor(){this.data={keys:[]}}get(e,t){let n=wI(e,t);return this.data[n]}set(e,t,n){let r=wI(e,t);this.get(e,t)||this.data.keys.push(r),this.data[r]=n}delete(e,t){let n=wI(e,t),r=this.data.keys.indexOf(n);r!==-1&&this.data.keys.splice(r,1),delete this.data[n]}reset(){let e=this.data,t=e.keys;for(;t.length>0;){let n=t.pop();delete e[n]}}},EI=class extends EM{constructor(e){e===void 0&&(e={}),super(),this.dt=-1,this.allowSleep=!!e.allowSleep,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=e.quatNormalizeSkip===void 0?0:e.quatNormalizeSkip,this.quatNormalizeFast=e.quatNormalizeFast!==void 0&&e.quatNormalizeFast,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new $,e.gravity&&this.gravity.copy(e.gravity),e.frictionGravity&&(this.frictionGravity=new $,this.frictionGravity.copy(e.frictionGravity)),this.broadphase=e.broadphase===void 0?new lN:e.broadphase,this.bodies=[],this.hasActiveBodies=!1,this.solver=e.solver===void 0?new eF:e.solver,this.constraints=[],this.narrowphase=new sF(this),this.collisionMatrix=new TM,this.collisionMatrixPrevious=new TM,this.bodyOverlapKeeper=new CI,this.shapeOverlapKeeper=new CI,this.contactmaterials=[],this.contactMaterialTable=new TI,this.defaultMaterial=new DP(`default`),this.defaultContactMaterial=new EP(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.accumulator=0,this.subsystems=[],this.addBodyEvent={type:`addBody`,body:null},this.removeBodyEvent={type:`removeBody`,body:null},this.idToBodyMap={},this.broadphase.setWorld(this)}getContactMaterial(e,t){return this.contactMaterialTable.get(e.id,t.id)}collisionMatrixTick(){let e=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=e,this.collisionMatrix.reset(),this.bodyOverlapKeeper.tick(),this.shapeOverlapKeeper.tick()}addConstraint(e){this.constraints.push(e)}removeConstraint(e){let t=this.constraints.indexOf(e);t!==-1&&this.constraints.splice(t,1)}rayTest(e,t,n){n instanceof uN?this.raycastClosest(e,t,{skipBackfaces:!0},n):this.raycastAll(e,t,{skipBackfaces:!0},n)}raycastAll(e,t,n,r){return n===void 0&&(n={}),n.mode=yN.ALL,n.from=e,n.to=t,n.callback=r,DI.intersectWorld(this,n)}raycastAny(e,t,n,r){return n===void 0&&(n={}),n.mode=yN.ANY,n.from=e,n.to=t,n.result=r,DI.intersectWorld(this,n)}raycastClosest(e,t,n,r){return n===void 0&&(n={}),n.mode=yN.CLOSEST,n.from=e,n.to=t,n.result=r,DI.intersectWorld(this,n)}addBody(e){this.bodies.includes(e)||(e.index=this.bodies.length,this.bodies.push(e),e.world=this,e.initPosition.copy(e.position),e.initVelocity.copy(e.velocity),e.timeLastSleepy=this.time,e instanceof WM&&(e.initAngularVelocity.copy(e.angularVelocity),e.initQuaternion.copy(e.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=e,this.idToBodyMap[e.id]=e,this.dispatchEvent(this.addBodyEvent))}removeBody(e){e.world=null;let t=this.bodies.length-1,n=this.bodies,r=n.indexOf(e);if(r!==-1){n.splice(r,1);for(let e=0;e!==n.length;e++)n[e].index=e;this.collisionMatrix.setNumObjects(t),this.removeBodyEvent.body=e,delete this.idToBodyMap[e.id],this.dispatchEvent(this.removeBodyEvent)}}getBodyById(e){return this.idToBodyMap[e]}getShapeById(e){let t=this.bodies;for(let n=0;n<t.length;n++){let r=t[n].shapes;for(let t=0;t<r.length;t++){let n=r[t];if(n.id===e)return n}}return null}addContactMaterial(e){this.contactmaterials.push(e),this.contactMaterialTable.set(e.materials[0].id,e.materials[1].id,e)}removeContactMaterial(e){let t=this.contactmaterials.indexOf(e);t!==-1&&(this.contactmaterials.splice(t,1),this.contactMaterialTable.delete(e.materials[0].id,e.materials[1].id))}fixedStep(e,t){e===void 0&&(e=1/60),t===void 0&&(t=10);let n=OI.now()/1e3;if(!this.lastCallTime)this.step(e,void 0,t);else{let r=n-this.lastCallTime;this.step(e,r,t)}this.lastCallTime=n}step(e,t,n){if(n===void 0&&(n=10),t===void 0)this.internalStep(e),this.time+=e;else{this.accumulator+=t;let r=OI.now(),i=0;for(;this.accumulator>=e&&i<n&&(this.internalStep(e),this.accumulator-=e,i++,!(OI.now()-r>e*1e3)););this.accumulator%=e;let a=this.accumulator/e;for(let e=0;e!==this.bodies.length;e++){let t=this.bodies[e];t.previousPosition.lerp(t.position,a,t.interpolatedPosition),t.previousQuaternion.slerp(t.quaternion,a,t.interpolatedQuaternion),t.previousQuaternion.normalize()}this.time+=t}}internalStep(e){this.dt=e;let t=this.contacts,n=PI,r=FI,i=this.bodies.length,a=this.bodies,o=this.solver,s=this.gravity,c=this.doProfiling,l=this.profile,u=WM.DYNAMIC,d=-1/0,f=this.constraints,p=NI;s.length();let m=s.x,h=s.y,g=s.z,_=0;for(c&&(d=OI.now()),_=0;_!==i;_++){let e=a[_];if(e.type===u){let t=e.force,n=e.mass;t.x+=n*m,t.y+=n*h,t.z+=n*g}}for(let e=0,t=this.subsystems.length;e!==t;e++)this.subsystems[e].update();c&&(d=OI.now()),n.length=0,r.length=0,this.broadphase.collisionPairs(this,n,r),c&&(l.broadphase=OI.now()-d);let v=f.length;for(_=0;_!==v;_++){let e=f[_];if(!e.collideConnected)for(let t=n.length-1;t>=0;--t)(e.bodyA===n[t]&&e.bodyB===r[t]||e.bodyB===n[t]&&e.bodyA===r[t])&&(n.splice(t,1),r.splice(t,1))}this.collisionMatrixTick(),c&&(d=OI.now());let y=MI,b=t.length;for(_=0;_!==b;_++)y.push(t[_]);t.length=0;let x=this.frictionEquations.length;for(_=0;_!==x;_++)p.push(this.frictionEquations[_]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(n,r,this,t,y,this.frictionEquations,p),c&&(l.narrowphase=OI.now()-d),c&&(d=OI.now()),_=0;_<this.frictionEquations.length;_++)o.addEquation(this.frictionEquations[_]);let S=t.length;for(let e=0;e!==S;e++){let n=t[e],r=n.bi,i=n.bj,a=n.si,s=n.sj,c;c=r.material&&i.material&&this.getContactMaterial(r.material,i.material)||this.defaultContactMaterial,c.friction,r.material&&i.material&&(r.material.friction>=0&&i.material.friction>=0&&r.material.friction*i.material.friction,r.material.restitution>=0&&i.material.restitution>=0&&(n.restitution=r.material.restitution*i.material.restitution)),o.addEquation(n),r.allowSleep&&r.type===WM.DYNAMIC&&r.sleepState===WM.SLEEPING&&i.sleepState===WM.AWAKE&&i.type!==WM.STATIC&&i.velocity.lengthSquared()+i.angularVelocity.lengthSquared()>=i.sleepSpeedLimit**2*2&&(r.wakeUpAfterNarrowphase=!0),i.allowSleep&&i.type===WM.DYNAMIC&&i.sleepState===WM.SLEEPING&&r.sleepState===WM.AWAKE&&r.type!==WM.STATIC&&r.velocity.lengthSquared()+r.angularVelocity.lengthSquared()>=r.sleepSpeedLimit**2*2&&(i.wakeUpAfterNarrowphase=!0),this.collisionMatrix.set(r,i,!0),this.collisionMatrixPrevious.get(r,i)||(jI.body=i,jI.contact=n,r.dispatchEvent(jI),jI.body=r,i.dispatchEvent(jI)),this.bodyOverlapKeeper.set(r.id,i.id),this.shapeOverlapKeeper.set(a.id,s.id)}for(this.emitContactEvents(),c&&(l.makeContactConstraints=OI.now()-d,d=OI.now()),_=0;_!==i;_++){let e=a[_];e.wakeUpAfterNarrowphase&&=(e.wakeUp(),!1)}for(v=f.length,_=0;_!==v;_++){let e=f[_];e.update();for(let t=0,n=e.equations.length;t!==n;t++){let n=e.equations[t];o.addEquation(n)}}o.solve(e,this),c&&(l.solve=OI.now()-d),o.removeAllEquations();let C=Math.pow;for(_=0;_!==i;_++){let t=a[_];if(t.type&u){let n=C(1-t.linearDamping,e),r=t.velocity;r.scale(n,r);let i=t.angularVelocity;if(i){let n=C(1-t.angularDamping,e);i.scale(n,i)}}}this.dispatchEvent(AI),c&&(d=OI.now());let w=this.stepnumber%(this.quatNormalizeSkip+1)===0,T=this.quatNormalizeFast;for(_=0;_!==i;_++)a[_].integrate(e,w,T);this.clearForces(),this.broadphase.dirty=!0,c&&(l.integrate=OI.now()-d),this.stepnumber+=1,this.dispatchEvent(kI);let E=!0;if(this.allowSleep)for(E=!1,_=0;_!==i;_++){let e=a[_];e.sleepTick(this.time),e.sleepState!==WM.SLEEPING&&(E=!0)}this.hasActiveBodies=E}emitContactEvents(){let e=this.hasAnyEventListener(`beginContact`),t=this.hasAnyEventListener(`endContact`);if((e||t)&&this.bodyOverlapKeeper.getDiff(II,LI),e){for(let e=0,t=II.length;e<t;e+=2)RI.bodyA=this.getBodyById(II[e]),RI.bodyB=this.getBodyById(II[e+1]),this.dispatchEvent(RI);RI.bodyA=RI.bodyB=null}if(t){for(let e=0,t=LI.length;e<t;e+=2)zI.bodyA=this.getBodyById(LI[e]),zI.bodyB=this.getBodyById(LI[e+1]),this.dispatchEvent(zI);zI.bodyA=zI.bodyB=null}II.length=LI.length=0;let n=this.hasAnyEventListener(`beginShapeContact`),r=this.hasAnyEventListener(`endShapeContact`);if((n||r)&&this.shapeOverlapKeeper.getDiff(II,LI),n){for(let e=0,t=II.length;e<t;e+=2){let t=this.getShapeById(II[e]),n=this.getShapeById(II[e+1]);BI.shapeA=t,BI.shapeB=n,t&&(BI.bodyA=t.body),n&&(BI.bodyB=n.body),this.dispatchEvent(BI)}BI.bodyA=BI.bodyB=BI.shapeA=BI.shapeB=null}if(r){for(let e=0,t=LI.length;e<t;e+=2){let t=this.getShapeById(LI[e]),n=this.getShapeById(LI[e+1]);VI.shapeA=t,VI.shapeB=n,t&&(VI.bodyA=t.body),n&&(VI.bodyB=n.body),this.dispatchEvent(VI)}VI.bodyA=VI.bodyB=VI.shapeA=VI.shapeB=null}}clearForces(){let e=this.bodies,t=e.length;for(let n=0;n!==t;n++){let t=e[n];t.force,t.torque,t.force.set(0,0,0),t.torque.set(0,0,0)}}},new SM,DI=new yN,OI=globalThis.performance||{},!OI.now){let e=Date.now();OI.timing&&OI.timing.navigationStart&&(e=OI.timing.navigationStart),OI.now=()=>Date.now()-e}new $,kI={type:`postStep`},AI={type:`preStep`},jI={type:WM.COLLIDE_EVENT_NAME,body:null,contact:null},MI=[],NI=[],PI=[],FI=[],II=[],LI=[],RI={type:`beginContact`,bodyA:null,bodyB:null},zI={type:`endContact`,bodyA:null,bodyB:null},BI={type:`beginShapeContact`,bodyA:null,bodyB:null,shapeA:null,shapeB:null},VI={type:`endShapeContact`,bodyA:null,bodyB:null,shapeA:null,shapeB:null}}));function UI(e){let t=e.B.quaternion.conjugate().mult(e.A.quaternion).mult(e.rel0.conjugate()),n=t.x*e.axisB.x+t.y*e.axisB.y+t.z*e.axisB.z,r=2*Math.atan2(n,t.w);return r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI),r}function WI(e){let t=UI(e),n=t>e.max?t-e.max:t<e.min?t-e.min:0;if(!n)return;let r=e.A.mass>0||e.B.mass<=0,i=r?e.A:e.B;if(i.mass<=0)return;let a=e.B.quaternion.vmult(e.axisB);a.normalize();let o=e.B.quaternion.vmult(e.pivotB).vadd(e.B.position),s=new DM().setFromAxisAngle(a,r?-n:n),c=i.position.vsub(o);i.position.copy(s.vmult(c).vadd(o)),i.quaternion.copy(s.mult(i.quaternion)),i.quaternion.normalize();let l=e.A.angularVelocity.vsub(e.B.angularVelocity).dot(a);if(l*n>0){let e=a.scale(r?l:-l);i.angularVelocity.vsub(e,i.angularVelocity);let t=i.position.vsub(o);i.velocity.vsub(e.cross(t),i.velocity)}i.aabbNeedsUpdate=!0}function GI(e,t){let n=[],r=t?t.length:e.length/3,i=n=>{let r=(t?t[n]:n)*3;return new $(e[r],e[r+1],e[r+2])};for(let e=0;e+2<r;e+=3){let t=i(e),r=i(e+1),a=i(e+2),o=r.vsub(t).cross(a.vsub(t)),s=o.length();if(s<1e-9)continue;o.scale($I/s,o);let c=t.vadd(r).vadd(a).scale(1/3).vsub(o.scale(.5)),l=[t,r,a,t.vsub(o),r.vsub(o),a.vsub(o)].map(e=>e.vsub(c)),u=new PM({vertices:l,faces:[[0,1,2],[3,5,4],[0,3,4,1],[1,4,5,2],[2,5,3,0]]});n.push({shape:u,center:JI(c)})}return n}function KI(e,t){if(e.length<=t)return e.length?[e]:[];let n=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let t of e)for(let e=0;e<3;e++)n[e]=Math.min(n[e],t.center[e]),r[e]=Math.max(r[e],t.center[e]);let i=[0,1,2].reduce((e,t)=>r[t]-n[t]>r[e]-n[e]?t:e,0),a=[...e].sort((e,t)=>e.center[i]-t.center[i]),o=a.length>>1;return[...KI(a.slice(0,o),t),...KI(a.slice(o),t)]}function qI(e){let t=1/0;for(let n of e)if(n.type===`box`)t=Math.min(t,2*Math.min(...n.half));else if(n.type===`sphere`||n.type===`cylinder`||n.type===`capsule`)t=Math.min(t,2*n.radius);else if(n.type===`convex`){let e=[0,1,2].map(e=>Math.max(...n.vertices.map(t=>t[e]))-Math.min(...n.vertices.map(t=>t[e])));t=Math.min(t,...e)}return Number.isFinite(t)?Math.max(t,.01):1}var JI,YI,XI,ZI,QI,$I,eL,tL,nL,rL,iL=t((()=>{HI(),JI=e=>[e.x,e.y,e.z],YI=(e,t=[0,0,0])=>new $(...e??t),XI=e=>e?new DM(e[0],e[1],e[2],e[3]):new DM,ZI=.5,QI=.2,$I=.08,eL=.08,tL=.5,nL=48,rL=class{world;recs=[];byId=/* @__PURE__ */ new Map;byBody=/* @__PURE__ */ new Map;order=0;materials=/* @__PURE__ */ new Map;materialProps=/* @__PURE__ */ new Map;namedMaterials;pairOverrides=/* @__PURE__ */ new Map;layerBits=/* @__PURE__ */ new Map;joints=[];contactsNow=/* @__PURE__ */ new Map;contactsPrev=/* @__PURE__ */ new Map;beginHandlers=[];endHandlers=[];substeps;time=0;preVel=/* @__PURE__ */ new Map;stepDt=1/60;constructor(e={}){let t=Array.isArray(e)?{gravity:e}:e;this.world=new EI({gravity:YI(t.gravity,[0,-9.81,0]),allowSleep:t.sleep??!0}),this.world.broadphase.useBoundingBoxes=!0,this.world.solver.iterations=t.iterations??10,this.world.defaultContactMaterial.friction=ZI,this.world.defaultContactMaterial.restitution=QI,this.substeps=Math.min(8,Math.max(1,Math.round(t.substeps??1))),this.namedMaterials=t.materials??{};for(let e of t.contacts??[])this.pairOverrides.set([e.a,e.b].sort().join(`|`),e);this.layerBits.set(`default`,1);for(let e of t.layers??[])this.layerBit(e)}get bodies(){return this.recs.map(e=>e.view)}get(e){return this.byId.get(e)?.view}layerBit(e){let t=this.layerBits.get(e);if(t===void 0){if(this.layerBits.size>=16)return 1;t=1<<this.layerBits.size,this.layerBits.set(e,t)}return t}layerMask(e){return e?e.reduce((e,t)=>e|this.layerBit(t),0):-1}material(e,t,n){let r=`${e??``}|${t}|${n}`,i=this.materials.get(r);if(i)return i;i=new DP({friction:-1,restitution:-1}),this.materialProps.set(i,{name:e,friction:t,restitution:n}),this.materials.set(r,i);for(let e of this.materials.values()){let t=this.materialProps.get(i),n=this.materialProps.get(e),r=t.name&&n.name?this.pairOverrides.get([t.name,n.name].sort().join(`|`)):void 0;this.world.addContactMaterial(new EP(i,e,{friction:r?.friction??Math.sqrt(t.friction*n.friction),restitution:r?.restitution??Math.max(t.restitution,n.restitution)}))}return i}add(e){let t=this.byId.get(e.id),n=t?[...this.contactsNow].filter(([,e])=>e.a===t||e.b===t):[],r=t?[...this.contactsPrev].filter(([,e])=>e.a===t||e.b===t):[];this.remove(e.id);let i=e.material?this.namedMaterials[e.material]:void 0,a=!!e.character,o=a?0:e.friction??i?.friction??ZI,s=a?0:e.restitution??i?.restitution??QI,c=e.type,l=c===`dynamic`,u=l?Math.max(e.mass??1,1e-4):0,d=this.material(e.material,o,s),f=this.layerBit(e.layer??`default`),p=this.layerMask(e.collidesWith),m=()=>new WM({mass:u,type:l?WM.DYNAMIC:c===`static`?WM.STATIC:WM.KINEMATIC,position:YI(e.position),quaternion:XI(e.quaternion),material:d,isTrigger:c===`trigger`,linearDamping:e.linearDamping??.01,angularDamping:e.angularDamping??(a?1:.01),fixedRotation:a||!!e.fixedRotation,allowSleep:l&&!a&&e.sleep!==!1,sleepSpeedLimit:.12,sleepTimeLimit:.6,collisionFilterGroup:f,collisionFilterMask:p}),h=m(),g=[];for(let t of e.shapes)this.addShape(h,t,g,m);e.velocity&&h.velocity.set(...e.velocity),e.angularVelocity&&l&&h.angularVelocity.set(...e.angularVelocity),c===`kinematic`&&e.velocity&&h.velocity.set(...e.velocity),h.updateMassProperties(),this.world.addBody(h);for(let e of g)this.world.addBody(e);let _={id:e.id,type:c,shapes:e.shapes,main:h,extra:g,order:this.order++,gravityScale:e.gravityScale??1,ccd:!!e.ccd,character:a,minExtent:qI(e.shapes),userVel:c===`kinematic`||c===`trigger`?h.velocity.clone():new $,kinFrom:null,forces:[],torques:[],lastGrounded:-1/0,jumpedAt:-1/0,ground:null,onGround:!1,carry:null,view:null};_.view=this.viewOf(_),this.recs.push(_),this.byId.set(_.id,_),this.byBody.set(h,_);for(let e of g)this.byBody.set(e,_);if(t){_.order=t.order,_.lastGrounded=t.lastGrounded,_.jumpedAt=t.jumpedAt,_.ground=t.ground,_.onGround=t.onGround,t.character&&this.makeCharacter(_);let e=e=>({...e,a:e.a===t?_:e.a,b:e.b===t?_:e.b});for(let[t,r]of n)this.contactsNow.set(t,e(r));for(let[t,n]of r)this.contactsPrev.set(t,e(n));for(let e of this.recs)e.ground===t&&(e.ground=_)}return _.view}viewOf(e){let t=this;return{id:e.id,type:e.type,shapes:e.shapes,get position(){return JI(e.main.position)},get quaternion(){let t=e.main.quaternion;return[t.x,t.y,t.z,t.w]},get velocity(){return JI(e.main.velocity)},get angularVelocity(){return JI(e.main.angularVelocity)},get mass(){return e.main.mass},get sleeping(){return e.main.sleepState===WM.SLEEPING},get grounded(){return t.isGrounded(e)},character:e.character}}addShape(e,t,n,r){let i=YI(t.offset),a=XI(t.quat);switch(t.type){case`box`:e.addShape(new zM(new $(Math.max(t.half[0],.001),Math.max(t.half[1],.001),Math.max(t.half[2],.001))),i,a);break;case`sphere`:e.addShape(new BP(Math.max(t.radius,.001)),i,a);break;case`cylinder`:e.addShape(new VP(t.radius,t.radius,Math.max(t.height,.001),t.segments??16),i,a);break;case`capsule`:{let n=Math.max(t.radius,.001),r=Math.max(t.height-2*n,0);r>.001&&e.addShape(new VP(n,n,r,12),i,a);for(let t of r>.001?[1,-1]:[0]){let o=a.vmult(new $(0,t*r/2,0));e.addShape(new BP(n),i.vadd(o),a)}break}case`convex`:{let n=new PM({vertices:t.vertices.map(e=>new $(...e)),faces:t.faces});e.addShape(n,i,a);break}case`heightfield`:e.addShape(new HP(t.data,{elementSize:t.elementSize}),i,a);break;case`trimesh`:KI(GI(t.vertices,t.indices),nL).forEach((t,o)=>{let s=o===0?e:r();for(let e of t)s.addShape(e.shape,i.vadd(a.vmult(new $(...e.center))),a);o>0&&n.push(s)})}}remove(e){let t=this.byId.get(e);if(t){for(let t of this.joints.filter(t=>t.a===e||t.b===e))this.removeJoint(t.id);this.world.removeBody(t.main);for(let e of t.extra)this.world.removeBody(e);this.byId.delete(e),this.byBody.delete(t.main);for(let e of t.extra)this.byBody.delete(e);this.recs.splice(this.recs.indexOf(t),1);for(let[e,n]of this.contactsNow)(n.a===t||n.b===t)&&this.contactsNow.delete(e);for(let[e,n]of this.contactsPrev)(n.a===t||n.b===t)&&this.contactsPrev.delete(e);for(let e of this.recs)e.ground===t&&(e.ground=null)}}setPose(e,t,n){let r=this.byId.get(e);if(!r)return;let i=r.main;r.type!==`kinematic`&&r.type!==`trigger`||r.kinFrom||(r.kinFrom={p:i.position.clone(),q:i.quaternion.clone()}),r.character&&Math.hypot(t[0]-i.position.x,t[1]-i.position.y,t[2]-i.position.z)>tL&&(r.ground=null,r.onGround=!1,r.lastGrounded=-1/0);for(let e of[i,...r.extra])e.position.set(...t),n&&e.quaternion.set(...n),e.previousPosition.copy(e.position),e.interpolatedPosition.copy(e.position),e.previousQuaternion.copy(e.quaternion),e.interpolatedQuaternion.copy(e.quaternion),e.aabbNeedsUpdate=!0;r.type===`dynamic`?i.wakeUp():this.wakeAround(r)}wakeAround(e){let t=this.aabb(e);if(t)for(let e of this.recs){if(e.type!==`dynamic`||e.main.sleepState!==WM.SLEEPING)continue;let n=this.aabb(e);n&&n.overlaps(t)&&this.wakeIsland(e)}}aabb(e){let t=[e.main,...e.extra].filter(e=>e.shapes.length);if(!t.length)return null;let n=new SM;return t.forEach((e,t)=>{e.aabbNeedsUpdate&&e.updateAABB(),t===0?n.copy(e.aabb):n.extend(e.aabb)}),n.lowerBound.vsub(new $(.001,.001,.001),n.lowerBound),n.upperBound.vadd(new $(.001,.001,.001),n.upperBound),n}setVelocity(e,t){let n=this.byId.get(e);n&&n.type!==`static`&&(n.main.velocity.set(...t),n.type!==`dynamic`&&n.userVel.set(...t),n.main.wakeUp())}setAngularVelocity(e,t){let n=this.byId.get(e);n&&n.type!==`static`&&(n.main.angularVelocity.set(...t),n.main.wakeUp())}applyImpulse(e,t,n){let r=this.byId.get(e);if(!r||r.type!==`dynamic`)return;let i=n?new $(...n).vsub(r.main.position):new $;r.main.applyImpulse(new $(...t),i),r.main.wakeUp()}applyForce(e,t,n){let r=this.byId.get(e);r&&r.type===`dynamic`&&(r.forces.push({f:new $(...t),p:n?new $(...n):null}),r.main.wakeUp())}applyTorque(e,t){let n=this.byId.get(e);n&&n.type===`dynamic`&&(n.torques.push(new $(...t)),n.main.wakeUp())}wake(e){this.byId.get(e)?.main.wakeUp()}addJoint(e){let t=this.byId.get(e.a),n=e.b?this.byId.get(e.b):void 0;if(!t||e.b&&!n)return null;let r=e.id??`joint-${this.joints.length+1}`,i=t.main,a=new $(...e.pivot??JI(n?n.main.position:i.position)),o,s;n?s=n.main:(o=new WM({mass:0,type:WM.STATIC,position:a.clone(),collisionFilterGroup:0,collisionFilterMask:0}),this.world.addBody(o),s=o);let c=(e,t)=>e.quaternion.conjugate().vmult(t.vsub(e.position)),l=(e,t)=>e.quaternion.conjugate().vmult(t),u=e.maxForce??1e6,d=e.collideConnected??!1,f,p,m;switch(e.type){case`hinge`:{let t=new $(...e.axis??[0,1,0]);t.length()<1e-9&&t.set(0,1,0),t.normalize();let r=new bP(i,s,{pivotA:c(i,a),pivotB:c(s,a),axisA:l(i,t),axisB:l(s,t),maxForce:u,collideConnected:d});e.limits&&(m={A:i,B:s,pivotB:c(s,a),axisB:l(s,t),rel0:s.quaternion.conjugate().mult(i.quaternion),min:Math.min(e.limits[0],e.limits[1]),max:Math.max(e.limits[0],e.limits[1])}),e.motor&&(r.enableMotor(),r.setMotorSpeed(n?e.motor.speed:-e.motor.speed),r.setMotorMaxForce(e.motor.maxForce??100)),f=r;break}case`point`:f=new pP(i,c(i,a),s,c(s,a),u),f.collideConnected=d;break;case`distance`:{let t=e.distance??i.position.distanceTo(s.position);f=new _P(i,s,t,u),f.collideConnected=d;break}case`lock`:f=new vP(i,s,{maxForce:u}),f.collideConnected=d;break;case`spring`:{let t=e.pivot&&n?c(i,a):new $,r=e.pivot?c(s,a):new $,o=i.quaternion.vmult(t).vadd(i.position),l=s.quaternion.vmult(r).vadd(s.position);p=new OP(i,s,{localAnchorA:t,localAnchorB:r,restLength:e.restLength??o.distanceTo(l),stiffness:e.stiffness??50,damping:e.damping??1});break}}return f&&this.world.addConstraint(f),this.joints.push({id:r,a:e.a,b:e.b,constraint:f,spring:p,anchor:o,limit:m}),r}removeJoint(e){let t=this.joints.findIndex(t=>t.id===e);if(t<0)return;let n=this.joints[t];n.constraint&&this.world.removeConstraint(n.constraint),n.anchor&&this.world.removeBody(n.anchor),this.joints.splice(t,1)}setMotorSpeed(e,t){let n=this.joints.find(t=>t.id===e);n?.constraint instanceof bP&&(n.constraint.enableMotor(),n.constraint.setMotorSpeed(n.b?t:-t),this.byId.get(n.a)?.main.wakeUp())}hasJoints(e){return this.joints.some(t=>t.a===e||t.b===e)}jointIds(){return this.joints.map(e=>e.id)}onCollision(e){this.beginHandlers.push(e)}onCollisionEnd(e){this.endHandlers.push(e)}isGrounded(e){return e.character?e.onGround:!!this.contactGround(e)}contactGround(e){let t=null;for(let n of this.contactsNow.values()){if(n.trigger)continue;let r=n.a===e&&-n.info.normal[1]>.5?n.b:n.b===e&&n.info.normal[1]>.5?n.a:null;if(r){if(r.type===`kinematic`)return r;t??=r}}return t}updateGround(e){let t=e.main,n=this.contactGround(e),r=this.time-e.jumpedAt<.15,i=t.velocity.y>1,a=r&&i?null:n;if(!a&&!i&&!r){let n=this.aabb(e);if(n){let r=[t.position.x,t.position.y,t.position.z],i=t.position.y-n.lowerBound.y+eL,o=this.raycast(r,[0,-1,0],i,{triggers:!1,mask:t.collisionFilterMask,ignore:t=>t.id===e.id});if(o&&o.normal[1]>.5&&(a=this.byId.get(o.body.id)??null,a)){let[t,n]=e.order<a.order?[e,a]:[a,e],r=`${t.id}|${n.id}`,i=o.normal;if(!this.contactsNow.has(r)){let a=t===e?[-i[0],-i[1],-i[2]]:[i[0],i[1],i[2]];this.contactsNow.set(r,{a:t,b:n,trigger:!1,info:{point:o.point,normal:a,impulse:0,speed:0}})}}}}e.ground=a,e.onGround=!!a}groundOf(e){let t=this.byId.get(e);if(!t)return null;let n=t.character?t.ground:this.contactGround(t);return n?n.view:null}grounded(e){let t=this.byId.get(e);return!!t&&this.isGrounded(t)}moveCharacter(e,t,n={}){let r=this.byId.get(e);if(!r||r.type===`static`)return;this.makeCharacter(r);let i=r.main,[a,o]=t,s=Math.hypot(a,o);s>1&&(a/=s,o/=s);let c=n.speed??5,l=(n.acceleration??40)*(this.isGrounded(r)||r.type!==`dynamic`?1:n.airControl??.35)*this.stepDt,u=(e,t)=>e+Math.max(-l,Math.min(l,t-e)),d=u(i.velocity.x,a*c),f=u(i.velocity.z,o*c);i.velocity.set(d,i.velocity.y,f),r.type!==`dynamic`&&r.userVel.set(d,i.velocity.y,f),i.wakeUp()}jump(e,t=6){let n=this.byId.get(e);return!n||n.type!==`dynamic`||(this.makeCharacter(n),!(this.isGrounded(n)||this.time-n.lastGrounded<=.12)||this.time-n.jumpedAt<.2)?!1:(n.jumpedAt=this.time,n.lastGrounded=-1/0,n.onGround=!1,n.main.velocity.y=t,n.main.wakeUp(),!0)}makeCharacter(e){if(e.character)return;e.character=!0,e.view.character=!0;let t=e.main;t.fixedRotation=!0,t.angularVelocity.set(0,0,0),t.allowSleep=!1,t.updateMassProperties();let n=t.material?this.materialProps.get(t.material):void 0;t.material=this.material(n?.name,0,0)}step(e){this.stepDt=e;let t=this.substeps;for(let n of this.recs){if(!n.ccd||n.main.sleepState===WM.SLEEPING)continue;let r=n.main.velocity.length()*e;t=Math.max(t,Math.min(8,Math.ceil(r/(.5*n.minExtent))))}let n=e/t;this.wakeAhead(e);let r=[];for(let t of this.recs){if(!t.kinFrom)continue;let n={p:t.main.position.clone(),q:t.main.quaternion.clone()},i=n.p.vsub(t.kinFrom.p);if(i.length()<2.5&&t.type===`kinematic`){for(let e of[t.main,...t.extra])e.position.copy(t.kinFrom.p),e.quaternion.copy(t.kinFrom.q);t.main.velocity.copy(i.scale(1/e).vadd(t.userVel));let a=n.q.mult(t.kinFrom.q.conjugate());a.w<0&&a.set(-a.x,-a.y,-a.z,-a.w);let o=Math.sqrt(Math.max(0,1-a.w*a.w)),s=2*Math.acos(Math.min(1,a.w));o>1e-6?t.main.angularVelocity.set(a.x/o*s/e,a.y/o*s/e,a.z/o*s/e):t.main.angularVelocity.set(0,0,0);for(let e of t.extra)e.velocity.copy(t.main.velocity),e.angularVelocity.copy(t.main.angularVelocity);r.push({rec:t,...n})}t.kinFrom=null}for(let e of this.recs){if(e.carry=null,!e.character||e.type!==`dynamic`||!e.onGround||e.ground?.type!==`kinematic`)continue;let t=e.ground.main,n=e.main.position.vsub(t.position),r=t.velocity.vadd(t.angularVelocity.cross(n));r.lengthSquared()<1e-10||(e.carry=r,e.main.velocity.vadd(r,e.main.velocity))}let i=/* @__PURE__ */ new Map,a=this.world.gravity;for(let e=0;e<t;e++){for(let e of this.recs){if(e.type!==`dynamic`)continue;let t=e.main;e.gravityScale!==1&&t.force.vadd(a.scale(t.mass*(e.gravityScale-1)),t.force);for(let n of e.forces)t.applyForce(n.f,n.p?n.p.vsub(t.position):new $);for(let n of e.torques)t.torque.vadd(n,t.torque)}for(let e of this.joints)e.spring?.applyForce();this.preVel.clear();for(let e of this.recs)e.type!==`static`&&this.preVel.set(e,e.main.velocity.clone());this.world.step(n);for(let e of this.joints)e.limit&&WI(e.limit);this.time+=n,this.collectContacts(i,n)}for(let e of this.recs)e.forces=[],e.torques=[];for(let e of this.recs)e.carry&&e.main.velocity.vsub(e.carry,e.main.velocity);for(let e of r)for(let t of[e.rec.main,...e.rec.extra])t.position.copy(e.p),t.quaternion.copy(e.q),t.velocity.copy(e.rec.userVel),t.angularVelocity.set(0,0,0),t.aabbNeedsUpdate=!0;for(let e of this.recs)if(e.type===`trigger`)for(let t of this.recs){if(t===e||t.type===`dynamic`||t.type===`trigger`||t.type===`static`||!this.filterOk(e,t))continue;let[n,r]=e.order<t.order?[e,t]:[t,e],a=`${n.id}|${r.id}`;if(i.has(a)||!this.overlapRecs(n,r))continue;let o=n.main.position,s=r.main.position,c=s.vsub(o),l=c.length()||1;i.set(a,{a:n,b:r,trigger:!0,info:{point:JI(o.vadd(s).scale(.5)),normal:[c.x/l,c.y/l,c.z/l],impulse:0,speed:0}})}let o=e=>e.type===`static`||e.main.sleepState===WM.SLEEPING;for(let[e,t]of this.contactsNow)!i.has(e)&&o(t.a)&&o(t.b)&&this.byId.has(t.a.id)&&this.byId.has(t.b.id)&&i.set(e,{...t,info:{...t.info,impulse:0,speed:0}});this.contactsPrev=this.contactsNow,this.contactsNow=i;for(let e of this.recs)e.character&&this.updateGround(e),this.isGrounded(e)&&(e.lastGrounded=this.time);for(let[e,t]of i)if(!this.contactsPrev.has(e))for(let e of this.beginHandlers)e(t.a.view,t.b.view,t.info);for(let[e,t]of this.contactsPrev)if(!i.has(e)&&this.byId.has(t.a.id)&&this.byId.has(t.b.id))for(let e of this.endHandlers)e(t.a.view,t.b.view)}wakeAhead(e){let t=null;for(let n of this.recs){if(n.type===`static`||n.type===`trigger`||n.main.sleepState===WM.SLEEPING)continue;let r=n.main.velocity;if(r.length()<.5)continue;let i=this.aabb(n);if(!i)continue;if(!t){t=[];for(let e of this.recs){if(e.type!==`dynamic`||e.main.sleepState!==WM.SLEEPING)continue;let n=this.aabb(e);n&&t.push({r:e,box:n})}}if(!t.length)return;let a=new $(Math.abs(r.x)*e*2+.05,Math.abs(r.y)*e*2+.05,Math.abs(r.z)*e*2+.05);i.lowerBound.vsub(a,i.lowerBound),i.upperBound.vadd(a,i.upperBound);for(let e of t)e.r.main.sleepState===WM.SLEEPING&&e.box.overlaps(i)&&this.wakeIsland(e.r)}}wakeIsland(e){let t=[e];for(e.main.wakeUp();t.length;){let e=t.pop();for(let n of this.contactsNow.values()){let r=n.a===e?n.b:n.b===e?n.a:null;r&&r.type===`dynamic`&&r.main.sleepState===WM.SLEEPING&&(r.main.wakeUp(),t.push(r))}}}filterOk(e,t){return(e.main.collisionFilterGroup&t.main.collisionFilterMask)!==0&&(t.main.collisionFilterGroup&e.main.collisionFilterMask)!==0}collectContacts(e,t){for(let n of this.world.contacts){let r=this.byBody.get(n.bi),i=this.byBody.get(n.bj);if(!r||!i||r===i)continue;let a=JI(n.ni),o=JI(n.bi.position.vadd(n.ri));i.order<r.order&&([r,i]=[i,r],a=[-a[0],-a[1],-a[2]],o=JI(n.bj.position.vadd(n.rj)));let s=`${r.id}|${i.id}`,c=Math.abs(n.multiplier)*t,l=e.get(s);if(l){c>l.info.impulse&&(l.info.impulse=c);continue}let u=new $,d=(this.preVel.get(i)??u).vsub(this.preVel.get(r)??u),f=Math.max(0,-(d.x*a[0]+d.y*a[1]+d.z*a[2]));e.set(s,{a:r,b:i,trigger:r.type===`trigger`||i.type===`trigger`,info:{point:o,normal:a,impulse:c,speed:this.contactsPrev.has(s)?0:f}})}}contacts(){return[...this.contactsNow.values()].map(e=>({a:e.a.view,b:e.b.view,info:e.info,trigger:e.trigger}))}contactsOf(e){let t=[];for(let n of this.contactsNow.values())n.a.id===e?t.push(n.b.view):n.b.id===e&&t.push(n.a.view);return t}overlaps(e,t){let n=this.byId.get(e),r=this.byId.get(t);return!n||!r||n===r?!1:this.overlapRecs(n,r)}overlapRecs(e,t){let n=this.aabb(e),r=this.aabb(t);if(!n||!r||!n.overlaps(r))return!1;for(let n of[e.main,...e.extra])for(let e of[t.main,...t.extra])if(this.bodiesOverlap(n,e))return!0;return!1}bodiesOverlap(e,t){let n=this.world.narrowphase,r=new DM,i=new DM,a=new $,o=new $;for(let s=0;s<e.shapes.length;s++){e.quaternion.mult(e.shapeOrientations[s],r),e.quaternion.vmult(e.shapeOffsets[s],a),a.vadd(e.position,a);let c=e.shapes[s];for(let s=0;s<t.shapes.length;s++){t.quaternion.mult(t.shapeOrientations[s],i),t.quaternion.vmult(t.shapeOffsets[s],o),o.vadd(t.position,o);let l=t.shapes[s];if(a.distanceTo(o)>c.boundingSphereRadius+l.boundingSphereRadius+.001)continue;let u=n[c.type|l.type];if(u&&(c.type<l.type?u.call(n,c,l,a,o,r,i,e,t,c,l,!0):u.call(n,l,c,o,a,i,r,t,e,c,l,!0)))return!0}}return!1}raycast(e,t,n=1/0,r={}){let i=Math.hypot(t[0],t[1],t[2]);if(i<1e-12)return null;let a=Number.isFinite(n)?n:1e4,o=[t[0]/i,t[1]/i,t[2]/i],s=new $(...e),c=new $(e[0]+o[0]*a,e[1]+o[1]*a,e[2]+o[2]*a),l=null;return this.world.raycastAll(s,c,{skipBackfaces:!0,collisionFilterMask:r.mask??-1,checkCollisionResponse:!1},e=>{let t=this.byBody.get(e.body);!t||r.triggers===!1&&t.type===`trigger`||r.ignore?.(t.view)||l&&e.distance>=l.distance||(l={body:t.view,distance:e.distance,point:JI(e.hitPointWorld),normal:JI(e.hitNormalWorld)})}),l}}}));function aL(e,t,n,r=0,i=24){for(let a=0;a<i;a++){let o=a/i*Math.PI*2,s=(a+1)/i*Math.PI*2,c=e=>n===`y`?[Math.cos(e)*t,r,Math.sin(e)*t]:n===`x`?[r,Math.cos(e)*t,Math.sin(e)*t]:[Math.cos(e)*t,Math.sin(e)*t,r];e.push(...c(o),...c(s))}}function oL(e){let t=[];switch(e.type){case`box`:{let[n,r,i]=e.half,a=[[-n,-r,-i],[n,-r,-i],[n,r,-i],[-n,r,-i],[-n,-r,i],[n,-r,i],[n,r,i],[-n,r,i]];for(let[e,n]of[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]])t.push(...a[e],...a[n]);break}case`sphere`:aL(t,e.radius,`x`),aL(t,e.radius,`y`),aL(t,e.radius,`z`);break;case`cylinder`:case`capsule`:{let n=e.radius,r=e.type===`capsule`?Math.max(e.height-2*n,0):e.height;aL(t,n,`y`,r/2),aL(t,n,`y`,-r/2);for(let e=0;e<8;e++){let i=e/8*Math.PI*2;t.push(Math.cos(i)*n,-r/2,Math.sin(i)*n,Math.cos(i)*n,r/2,Math.sin(i)*n)}if(e.type===`capsule`)for(let e of[1,-1])for(let i=0;i<12;i++){let a=i/12*(Math.PI/2),o=(i+1)/12*(Math.PI/2);for(let[i,s]of[[1,0],[0,1],[-1,0],[0,-1]])t.push(i*Math.cos(a)*n,e*(r/2+Math.sin(a)*n),s*Math.cos(a)*n,i*Math.cos(o)*n,e*(r/2+Math.sin(o)*n),s*Math.cos(o)*n)}break}case`convex`:for(let n of e.faces)for(let r=0;r<n.length;r++)t.push(...e.vertices[n[r]],...e.vertices[n[(r+1)%n.length]]);break;case`trimesh`:{let n=e.vertices,r=e.indices,i=r?r.length:n.length/3,a=e=>{let t=(r?r[e]:e)*3;return[n[t],n[t+1],n[t+2]]};for(let e=0;e+2<i;e+=3){let n=a(e),r=a(e+1),i=a(e+2);t.push(...n,...r,...r,...i,...i,...n)}break}case`heightfield`:{let n=e.data,r=e.elementSize,i=Math.max(1,Math.round(n.length/48));for(let e=0;e<n.length;e+=i)for(let a=0;a+i<n[e].length;a+=i)t.push(e*r,a*r,n[e][a],e*r,(a+i)*r,n[e][a+i]);for(let e=0;e<n[0].length;e+=i)for(let a=0;a+i<n.length;a+=i)t.push(a*r,e*r,n[a][e],(a+i)*r,e*r,n[a+i][e]);break}}if(e.offset||e.quat){let n=new V().compose(new B(...e.offset??[0,0,0]),new wi(...e.quat??[0,0,0,1]),new B(1,1,1)),r=new B;for(let e=0;e<t.length;e+=3)r.set(t[e],t[e+1],t[e+2]).applyMatrix4(n),t[e]=r.x,t[e+1]=r.y,t[e+2]=r.z}return t}var sL,cL,lL=t((()=>{J(),sL={dynamic:4054148,static:5155071,kinematic:16755008,trigger:16732120,sleeping:10133670},cL=class{group=new ba;items=/* @__PURE__ */ new Map;constructor(e){this.group.name=`agent3d-physics-debug`,this.group.renderOrder=999,e.add(this.group)}sync(e){let t=/* @__PURE__ */ new Set;for(let n of e){t.add(n.id);let e=this.items.get(n.id);if(!e||e.body!==n){e&&this.drop(n.id);let t=n.shapes.flatMap(oL),r=new G;r.setAttribute(`position`,new W(t,3));let i=new uc({color:sL[n.type],depthTest:!1,depthWrite:!1,transparent:!0,opacity:.9,toneMapped:!1}),a=new xc(r,i);a.renderOrder=999,a.frustumCulled=!1,this.group.add(a),e={lines:a,body:n},this.items.set(n.id,e)}let[r,i,a]=n.position,[o,s,c,l]=n.quaternion;e.lines.position.set(r,i,a),e.lines.quaternion.set(o,s,c,l),e.lines.material.color.setHex(n.sleeping?sL.sleeping:sL[n.type])}for(let e of[...this.items.keys()])t.has(e)||this.drop(e)}drop(e){let t=this.items.get(e);t&&(t.lines.removeFromParent(),t.lines.geometry.dispose(),t.lines.material.dispose(),this.items.delete(e))}dispose(){for(let e of[...this.items.keys()])this.drop(e);this.group.removeFromParent()}}})),uL,dL,fL,pL,mL,hL,gL,_L,vL,yL,bL,xL,SL=t((()=>{J(),uL=0,dL=1,fL=new B,pL=new bf,mL=new Fo,hL=new B,gL=new Ua,_L=class{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new xL,this.unassigned=new xL,this.vertices=[]}setFromPoints(e){if(e.length>=4){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.vertices.push(new bL(e[t]));this._compute()}return this}setFromObject(e){let t=[];return e.updateMatrixWorld(!0),e.traverse(function(e){let n=e.geometry;if(n!==void 0){let r=n.attributes.position;if(r!==void 0)for(let n=0,i=r.count;n<i;n++){let i=new B;i.fromBufferAttribute(r,n).applyMatrix4(e.matrixWorld),t.push(i)}}}),this.setFromPoints(t)}containsPoint(e){let t=this.faces;for(let n=0,r=t.length;n<r;n++)if(t[n].distanceToPoint(e)>this.tolerance)return!1;return!0}intersectRay(e,t){let n=this.faces,r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t],o=a.distanceToPoint(e.origin),s=a.normal.dot(e.direction);if(o>0&&s>=0)return null;let c=s===0?0:-o/s;if(!(c<=0)&&(s>0?i=Math.min(c,i):r=Math.max(c,r),r>i))return null}return r===-1/0?e.at(i,t):e.at(r,t),t}intersectsRay(e){return this.intersectRay(e,fL)!==null}makeEmpty(){return this.faces=[],this.vertices=[],this}_addVertexToFace(e,t){return e.face=t,t.outside===null?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this}_removeVertexFromFace(e,t){return e===t.outside&&(t.outside=e.next!==null&&e.next.face===t?e.next:null),this.assigned.remove(e),this}_removeAllVerticesFromFace(e){if(e.outside!==null){let t=e.outside,n=e.outside;for(;n.next!==null&&n.next.face===e;)n=n.next;return this.assigned.removeSubList(t,n),t.prev=n.next=null,e.outside=null,t}}_deleteFaceVertices(e,t){let n=this._removeAllVerticesFromFace(e);if(n!==void 0){if(t===void 0)this.unassigned.appendChain(n);else{let e=n;do{let n=e.next;t.distanceToPoint(e.point)>this.tolerance?this._addVertexToFace(e,t):this.unassigned.append(e),e=n}while(e!==null)}}return this}_resolveUnassignedPoints(e){if(this.unassigned.isEmpty()===!1){let t=this.unassigned.first();do{let n=t.next,r=this.tolerance,i=null;for(let n=0;n<e.length;n++){let a=e[n];if(a.mark===uL){let e=a.distanceToPoint(t.point);if(e>r&&(r=e,i=a),r>1e3*this.tolerance)break}}i!==null&&this._addVertexToFace(t,i),t=n}while(t!==null)}return this}_computeExtremes(){let e=new B,t=new B,n=[],r=[];for(let e=0;e<3;e++)n[e]=r[e]=this.vertices[0];e.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let i=0,a=this.vertices.length;i<a;i++){let a=this.vertices[i],o=a.point;for(let t=0;t<3;t++)o.getComponent(t)<e.getComponent(t)&&(e.setComponent(t,o.getComponent(t)),n[t]=a);for(let e=0;e<3;e++)o.getComponent(e)>t.getComponent(e)&&(t.setComponent(e,o.getComponent(e)),r[e]=a)}return this.tolerance=3*2**-52*(Math.max(Math.abs(e.x),Math.abs(t.x))+Math.max(Math.abs(e.y),Math.abs(t.y))+Math.max(Math.abs(e.z),Math.abs(t.z))),{min:n,max:r}}_computeInitialHull(){let e=this.vertices,t=this._computeExtremes(),n=t.min,r=t.max,i=0,a=0;for(let e=0;e<3;e++){let t=r[e].point.getComponent(e)-n[e].point.getComponent(e);t>i&&(i=t,a=e)}let o=n[a],s=r[a],c,l;i=0,pL.set(o.point,s.point);for(let t=0,n=this.vertices.length;t<n;t++){let n=e[t];if(n!==o&&n!==s){pL.closestPointToPoint(n.point,!0,hL);let e=hL.distanceToSquared(n.point);e>i&&(i=e,c=n)}}i=-1,mL.setFromCoplanarPoints(o.point,s.point,c.point);for(let t=0,n=this.vertices.length;t<n;t++){let n=e[t];if(n!==o&&n!==s&&n!==c){let e=Math.abs(mL.distanceToPoint(n.point));e>i&&(i=e,l=n)}}let u=[];if(mL.distanceToPoint(l.point)<0){u.push(vL.create(o,s,c),vL.create(l,s,o),vL.create(l,c,s),vL.create(l,o,c));for(let e=0;e<3;e++){let t=(e+1)%3;u[e+1].getEdge(2).setTwin(u[0].getEdge(t)),u[e+1].getEdge(1).setTwin(u[t+1].getEdge(0))}}else{u.push(vL.create(o,c,s),vL.create(l,o,s),vL.create(l,s,c),vL.create(l,c,o));for(let e=0;e<3;e++){let t=(e+1)%3;u[e+1].getEdge(2).setTwin(u[0].getEdge((3-e)%3)),u[e+1].getEdge(0).setTwin(u[t+1].getEdge(1))}}for(let e=0;e<4;e++)this.faces.push(u[e]);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n!==o&&n!==s&&n!==c&&n!==l){i=this.tolerance;let e=null;for(let t=0;t<4;t++){let r=this.faces[t].distanceToPoint(n.point);r>i&&(i=r,e=this.faces[t])}e!==null&&this._addVertexToFace(n,e)}}return this}_reindexFaces(){let e=[];for(let t=0;t<this.faces.length;t++){let n=this.faces[t];n.mark===uL&&e.push(n)}return this.faces=e,this}_nextVertexToAdd(){if(this.assigned.isEmpty()===!1){let e,t=0,n=this.assigned.first().face,r=n.outside;do{let i=n.distanceToPoint(r.point);i>t&&(t=i,e=r),r=r.next}while(r!==null&&r.face===n);return e}}_computeHorizon(e,t,n,r){this._deleteFaceVertices(n),n.mark=dL;let i;i=t===null?t=n.getEdge(0):t.next;do{let t=i.twin,n=t.face;n.mark===uL&&(n.distanceToPoint(e)>this.tolerance?this._computeHorizon(e,t,n,r):r.push(i)),i=i.next}while(i!==t);return this}_addAdjoiningFace(e,t){let n=vL.create(e,t.tail(),t.head());return this.faces.push(n),n.getEdge(-1).setTwin(t.twin),n.getEdge(0)}_addNewFaces(e,t){this.newFaces=[];let n=null,r=null;for(let i=0;i<t.length;i++){let a=t[i],o=this._addAdjoiningFace(e,a);n===null?n=o:o.next.setTwin(r),this.newFaces.push(o.face),r=o}return n.next.setTwin(r),this}_addVertexToHull(e){let t=[];return this.unassigned.clear(),this._removeVertexFromFace(e,e.face),this._computeHorizon(e.point,null,e.face,t),this._addNewFaces(e,t),this._resolveUnassignedPoints(this.newFaces),this}_cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}_compute(){let e;for(this._computeInitialHull();(e=this._nextVertexToAdd())!==void 0;)this._addVertexToHull(e);return this._reindexFaces(),this._cleanup(),this}},vL=class e{constructor(){this.normal=new B,this.midpoint=new B,this.area=0,this.constant=0,this.outside=null,this.mark=uL,this.edge=null}static create(t,n,r){let i=new e,a=new yL(t,i),o=new yL(n,i),s=new yL(r,i);return a.next=s.prev=o,o.next=a.prev=s,s.next=o.prev=a,i.edge=a,i.compute()}getEdge(e){let t=this.edge;for(;e>0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t}compute(){let e=this.edge.tail(),t=this.edge.head(),n=this.edge.next.head();return gL.set(e.point,t.point,n.point),gL.getNormal(this.normal),gL.getMidpoint(this.midpoint),this.area=gL.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(e){return this.normal.dot(e)-this.constant}},yL=class{constructor(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){let e=this.head(),t=this.tail();return t===null?-1:t.point.distanceTo(e.point)}lengthSquared(){let e=this.head(),t=this.tail();return t===null?-1:t.point.distanceToSquared(e.point)}setTwin(e){return this.twin=e,e.twin=this,this}},bL=class{constructor(e){this.point=e,this.prev=null,this.next=null,this.face=null}},xL=class{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(e,t){return t.prev=e.prev,t.next=e,t.prev===null?this.head=t:t.prev.next=t,e.prev=t,this}insertAfter(e,t){return t.prev=e,t.next=e.next,t.next===null?this.tail=t:t.next.prev=t,e.next=t,this}append(e){return this.head===null?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this}appendChain(e){for(this.head===null?this.head=e:this.tail.next=e,e.prev=this.tail;e.next!==null;)e=e.next;return this.tail=e,this}remove(e){return e.prev===null?this.head=e.next:e.prev.next=e.next,e.next===null?this.tail=e.prev:e.next.prev=e.prev,this}removeSubList(e,t){return e.prev===null?this.head=t.next:e.prev.next=t.next,t.next===null?this.tail=e.prev:t.next.prev=e.prev,this}isEmpty(){return this.head===null}}}));function CL(e){e.updateWorldMatrix(!0,!0);let t=new B,n=new wi,r=new B;return e.matrixWorld.decompose(t,n,r),{inv:new V().compose(t,n,new B(1,1,1)).invert(),scale:r}}function wL(e,t){let n=e.userData?.a3dId;return!!n&&n!==t&&!n.includes(`/`)}function TL(e,t=`own`,n){let r=[],i=e.userData?.a3dId,a=o=>{if(o!==e&&(t===`own`&&wL(o,i)||n?.(o)))return;let s=o;s.isMesh&&s.geometry?.getAttribute(`position`)&&!o.userData.noCollide&&r.push(s);for(let e of o.children)a(e)};return a(e),r}function EL(e){let t=TL(e.object);return t.length?t:TL(e.object,`tree`,DL(e.objectDef))}function DL(e){let t=/* @__PURE__ */ new Set,n=e=>{for(let r of e??[])r.body&&t.add(r.id),n(r.children)};return n(e?.children),e=>t.has(e.userData?.a3dId)}function OL(e,t){let n=new Wa,r=new Wa,i=new V;for(let a of e){let e=a;e.isInstancedMesh?(e.boundingBox||e.computeBoundingBox(),e.boundingBox&&r.copy(e.boundingBox)):(a.geometry.boundingBox||a.geometry.computeBoundingBox(),r.copy(a.geometry.boundingBox)),r.isEmpty()||n.union(r.applyMatrix4(i.multiplyMatrices(t,a.matrixWorld)))}return n}function kL(e,t){return OL(EL({object:e,objectDef:t}),CL(e).inv)}function AL(e,t){let{inv:n}=CL(e),r=[OL(TL(e),n)],i=DL(t),a=e.userData?.a3dId,o=e=>{for(let t of e.children)i(t)||(wL(t,a)?r.push(OL(TL(t,`tree`,i),n)):o(t))};return o(e),r.filter(e=>!e.isEmpty()).map(e=>({size:e.getSize(new B),center:e.getCenter(new B)}))}function jL(e,t){let{inv:n}=CL(e.object),r=new V,i=new B,a=[],o=0;for(let s of EL(e)){if(s.isInstancedMesh)continue;let e=s.geometry,c=e.getAttribute(`position`),l=e.getIndex(),u=l?l.count:c.count;if(o+=u/3,o>t)return null;r.multiplyMatrices(n,s.matrixWorld);let d=new Float32Array(u*3);for(let e=0;e<u;e++)i.fromBufferAttribute(c,l?l.getX(e):e).applyMatrix4(r),d[e*3]=i.x,d[e*3+1]=i.y,d[e*3+2]=i.z;a.push(d)}let s=new Float32Array(a.reduce((e,t)=>e+t.length,0)),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function ML(e,t){let{inv:n}=CL(e.object),r=new V,i=[],a=EL(e),o=a.reduce((e,t)=>e+t.geometry.getAttribute(`position`).count,0),s=Math.max(1,Math.ceil(o/t));for(let e of a){let t=e.geometry.getAttribute(`position`);r.multiplyMatrices(n,e.matrixWorld);for(let e=0;e<t.count;e+=s)i.push(new B().fromBufferAttribute(t,e).applyMatrix4(r))}let c=new Wa;for(let e of a){let t=e.geometry.getAttribute(`position`);r.multiplyMatrices(n,e.matrixWorld);let a=[];for(let e=0;e<t.count;e++){let n=new B().fromBufferAttribute(t,e).applyMatrix4(r);for(let e=0;e<3;e++)(!a[e*2]||n.getComponent(e)<a[e*2].getComponent(e))&&(a[e*2]=n),(!a[e*2+1]||n.getComponent(e)>a[e*2+1].getComponent(e))&&(a[e*2+1]=n)}for(let e of a)e&&(i.push(e),c.expandByPoint(e))}return i}function NL(e,t){if(e.length<4)return null;let n;try{n=new _L().setFromPoints(e)}catch{return null}let r=/* @__PURE__ */ new Map,i=[],a=[];for(let e of n.faces){let n=[],o=e.edge;do{let e=o.head().point,a=r.get(e);a===void 0&&(a=i.length,r.set(e,a),i.push([e.x-t.x,e.y-t.y,e.z-t.z])),n.push(a),o=o.next}while(o!==e.edge);n.length>=3&&a.push(n)}return a.length>=4?{vertices:i,faces:a}:null}function PL(e,t){let n=e.offset,r=HL(e.rotation),i=e.size?new B(...e.size):t;switch(e.shape){case`sphere`:return{type:`sphere`,radius:e.radius??Math.max(i.x,i.y,i.z)/2,offset:n,quat:r};case`cylinder`:return{type:`cylinder`,radius:e.radius??Math.max(i.x,i.z)/2,height:e.height??i.y,offset:n,quat:r};case`capsule`:return{type:`capsule`,radius:e.radius??Math.max(i.x,i.z)/2,height:e.height??i.y,offset:n,quat:r};default:return{type:`box`,half:[i.x/2,i.y/2,i.z/2],offset:n,quat:r}}}function FL(e){let t=e.objectDef,n=e.def.type===`static`||e.def.type===`kinematic`;if(e.built?.heightAt&&n&&typeof e.object.userData.size==`number`)return`heightfield`;if(t?.kind===`mesh`){let e=t.geometry?.type;return e===`sphere`||e===`icosahedron`||e===`dodecahedron`?`sphere`:e===`capsule`?`capsule`:e===`cylinder`?t.geometry.radiusTop===void 0||t.geometry.radiusTop===t.geometry.radiusBottom?`cylinder`:`convex`:e===`box`||e===`roundedBox`||e===`plane`?`box`:n?`trimesh`:`convex`}return t?.kind===`model`||t?.kind===`svg`?n?`trimesh`:`convex`:t?.kind===`generator`&&n?`trimesh`:`box`}function IL(e){let t=e.def,n=kL(e.object,e.objectDef),r=n.isEmpty(),i=r?new B(1,1,1):n.getSize(new B),a=r?new B:n.getCenter(new B);t.size&&i.set(t.size[0],t.size[1],t.size[2]);let o=t.offset?new B(...t.offset):a.clone(),s=t.shape??`box`;s===`auto`&&(s=FL(e));let c=()=>({type:`box`,half:[i.x/2,i.y/2,i.z/2]});switch(s){case`sphere`:return{shapes:[{type:`sphere`,radius:t.radius??Math.max(i.x,i.y,i.z)/2}],offset:o};case`cylinder`:return{shapes:[{type:`cylinder`,radius:t.radius??Math.max(i.x,i.z)/2,height:t.height??i.y}],offset:o};case`capsule`:return{shapes:[{type:`capsule`,radius:t.radius??Math.max(i.x,i.z)/2,height:t.height??i.y}],offset:o};case`compound`:{let n=t.offset?new B(...t.offset):new B;if(!t.shapes?.length){let t=AL(e.object,e.objectDef);if(t.length)return{shapes:t.map(e=>({type:`box`,half:[e.size.x/2,e.size.y/2,e.size.z/2],offset:[e.center.x-n.x,e.center.y-n.y,e.center.z-n.z]})),offset:n}}let r=(t.shapes??[]).map(e=>{let t=PL(e,i),r=e.offset??[0,0,0];return{...t,offset:[r[0]-n.x,r[1]-n.y,r[2]-n.z]}});return r.length?{shapes:r,offset:n}:{shapes:[c()],offset:o}}case`convex`:{let t=NL(ML(e,VL),o);return t?{shapes:[{type:`convex`,...t}],offset:o}:{shapes:[c()],offset:o,note:`convex hull failed (too few points): using the bounding box`}}case`heightfield`:return LL(e)||l(e,`heightfield needs a terrain generator (heightAt): using the triangles`);case`trimesh`:return l(e);default:return{shapes:[c()],offset:o}}function l(e,t){let n=jL(e,BL);if(!n||n.length===0)return{shapes:[c()],offset:o,note:n?`no triangles: using the bounding box`:`more than ${BL} triangles: using the bounding box (use a simpler collision mesh, "compound" or "box")`};for(let e=0;e<n.length;e+=3)n[e]-=o.x,n[e+1]-=o.y,n[e+2]-=o.z;return{shapes:[{type:`trimesh`,vertices:n}],offset:o,note:t}}}function LL(e){let t=e.built?.heightAt?.bind(e.built),n=e.object.userData.size;if(!t||typeof n!=`number`||!(n>0))return null;let{scale:r}=CL(e.object),i=0;for(let t of TL(e.object))if(t.userData.materialTarget||t.name===`terrain-ground`){let e=t.geometry;i=(e.getIndex()?.count??e.getAttribute(`position`).count)/3;break}let a=Math.min(160,Math.max(8,i?Math.round(Math.sqrt(i/2)):64)),o=a+1,s=n/a,c=[];for(let e=0;e<o;e++){let i=[];for(let a=0;a<o;a++)i.push(t(-n/2+e*s,n/2-a*s)*r.y);c.push(i)}let l=r.x,u=new B;return{shapes:[{type:`heightfield`,data:c,elementSize:s*l,offset:[-n/2*l,0,n/2*l],quat:[-Math.SQRT1_2,0,0,Math.SQRT1_2]}],offset:u}}function RL(e,t){e.updateWorldMatrix(!0,!1);let n=new B,r=new wi,i=new B;return e.matrixWorld.decompose(n,r,i),n.add(t.clone().applyQuaternion(r)),{position:[n.x,n.y,n.z],quaternion:[r.x,r.y,r.z,r.w]}}function zL(e,t){let{shapes:n,offset:r,note:i}=IL(t),a=RL(t.object,r),o=t.def,s=o.angularVelocity;return{init:{id:e,type:o.type,shapes:n,position:a.position,quaternion:a.quaternion,velocity:o.velocity,angularVelocity:s?[s[0]*LS,s[1]*LS,s[2]*LS]:void 0,mass:o.mass,friction:o.friction,restitution:o.restitution,material:o.material,linearDamping:o.linearDamping,angularDamping:o.angularDamping,gravityScale:o.gravityScale,fixedRotation:o.fixedRotation,character:o.character,sleep:o.sleep,ccd:o.ccd,layer:o.layer,collidesWith:o.collidesWith},offset:r,note:i}}var BL,VL,HL,UL=t((()=>{J(),SL(),zS(),BL=12e3,VL=600,HL=e=>{if(!e)return;let t=new wi().setFromEuler(new na(e[0]*LS,e[1]*LS,e[2]*LS));return[t.x,t.y,t.z,t.w]}})),WL=/* @__PURE__ */ n({PhysicsBridge:()=>GL,PhysicsWorld:()=>rL}),GL,KL=t((()=>{J(),zS(),iL(),lL(),UL(),GL=class{def;issue;engine;offsets=/* @__PURE__ */ new Map;scales=/* @__PURE__ */ new Map;scaleWarned=/* @__PURE__ */ new Set;debug=null;world;constructor(e,t,n){this.def=e,this.issue=n,this.world=t;let r=e?.gravity??[0,-9.81,0];this.engine=new rL({gravity:[r[0],r[1],r[2]],iterations:e?.iterations,substeps:e?.substeps,sleep:e?.sleep,materials:e?.materials,contacts:e?.contacts,layers:e?.layers}),e?.debug&&(this.debug=new cL(t.scene))}attachAll(){this.world.scene.updateMatrixWorld(!0);for(let e of this.world.entries.values())this.addEntry(e),this.addGeneratorBodies(e);(this.def?.joints??[]).forEach((e,t)=>{this.engine.addJoint({id:e.id??`joint-${t+1}`,type:e.type,a:e.a,b:e.b,pivot:e.pivot,axis:e.axis,distance:e.distance,restLength:e.restLength,stiffness:e.stiffness,damping:e.damping,motor:e.motor?{speed:e.motor.speed*LS,maxForce:e.motor.maxForce}:void 0,limits:e.limits?[e.limits[0]*LS,e.limits[1]*LS]:void 0,maxForce:e.maxForce,collideConnected:e.collideConnected})||this.issue({code:`physics`,message:`physics.joints[${t}]: "${e.a}"${e.b?` or "${e.b}"`:``} has no body.`,path:`physics.joints[${t}]`})}),this.debug?.sync(this.engine.bodies)}addEntry(e,t){let n=t??e.def.body;if(!n||e.kind===`light`)return!1;let{init:r,offset:i,note:a}=zL(e.id,{object:e.object,def:n,objectDef:e.def,built:e.built});return a&&this.issue({code:`physics`,message:`objects#${e.id}.body: ${a}.`,path:`objects#${e.id}.body`}),this.offsets.set(e.id,i),this.scales.set(e.id,e.object.getWorldScale(new B)),this.engine.add(r),!0}addGeneratorBodies(e){if(e.kind===`light`||e.def.body)return;let t=e.object.userData.bodies;if(!Array.isArray(t)||!t.length)return;e.object.updateWorldMatrix(!0,!1);let n=new B,r=new wi,i=new B;e.object.matrixWorld.decompose(n,r,i);let a=t.map(e=>({type:`box`,half:[Math.abs(e.max[0]-e.min[0])*i.x/2,Math.abs(e.max[1]-e.min[1])*i.y/2,Math.abs(e.max[2]-e.min[2])*i.z/2],offset:[(e.min[0]+e.max[0])/2*i.x,(e.min[1]+e.max[1])/2*i.y,(e.min[2]+e.max[2])/2*i.z]}));this.offsets.set(e.id,new B),this.engine.add({id:e.id,type:`static`,shapes:a,position:[n.x,n.y,n.z],quaternion:[r.x,r.y,r.z,r.w]})}has(e){return!!this.engine.get(e)}moved(e){let t=this.world.entries.get(e),n=this.offsets.get(e),r=this.engine.get(e);if(!t||!n||!r)return;let i=this.scales.get(e);if(i&&t.def.body){let n=t.object.getWorldScale(new B);if(Math.abs(n.x-i.x)>1e-4*Math.abs(i.x)+1e-6||Math.abs(n.y-i.y)>1e-4*Math.abs(i.y)+1e-6||Math.abs(n.z-i.z)>1e-4*Math.abs(i.z)+1e-6){if(this.engine.hasJoints(e))this.scaleWarned.has(e)||(this.scaleWarned.add(e),this.issue({code:`physics`,message:`objects#${e}: its scale changed but its collider keeps the start size (the body is held by a joint).`,path:`objects#${e}.body`}));else{let n=[...r.velocity],i=[...r.angularVelocity];t.object.updateWorldMatrix(!0,!1),this.addEntry(t),this.engine.setVelocity(e,n),this.engine.setAngularVelocity(e,i),this.debug?.sync(this.engine.bodies);return}}}let a=RL(t.object,n);this.engine.setPose(e,a.position,a.quaternion)}remove(e){this.engine.remove(e),this.offsets.delete(e),this.scales.delete(e)}step(e){this.engine.step(e),this.syncObjects(),this.debug?.sync(this.engine.bodies)}syncObjects(){let e=new B,t=new wi,n=new wi;for(let r of this.engine.bodies){if(r.type!==`dynamic`&&r.type!==`kinematic`||r.sleeping)continue;if(r.type===`kinematic`){let e=r.velocity,t=r.angularVelocity;if(!e[0]&&!e[1]&&!e[2]&&!t[0]&&!t[1]&&!t[2])continue}let i=this.world.entries.get(r.id);if(!i)continue;let a=i.object;t.set(...r.quaternion),e.set(...r.position).sub((this.offsets.get(r.id)??new B).clone().applyQuaternion(t)),a.parent&&(a.parent.updateWorldMatrix(!0,!1),a.parent.worldToLocal(e),a.parent.getWorldQuaternion(n),t.premultiply(n.invert())),a.position.copy(e),a.quaternion.copy(t),i.animated&&(i.rest.position.copy(e),i.rest.quaternion.copy(t))}}dispose(){this.debug?.dispose(),this.debug=null}}})),qL=/* @__PURE__ */ n({GameHost:()=>QL});function JL(e,t=1,n){return{get x(){return e().x/t},set x(r){e().x=r*t,n?.()},get y(){return e().y/t},set y(r){e().y=r*t,n?.()},get z(){return e().z/t},set z(r){e().z=r*t,n?.()},set(r,i,a){e().set(r*t,i*t,a*t),n?.()}}}var YL,XL,ZL,QL,$L=t((()=>{J(),Tv(),zS(),Bj(),fM(),YL=null,XL=()=>YL??=Promise.resolve().then(()=>(KL(),WL)),ZL=/* @__PURE__ */ new Map,QL=class e{opts;world;physics=null;state={};hud=null;audio;instances=[];factories=[];objCache=/* @__PURE__ */ new Map;handlers=/* @__PURE__ */ new Map;collisionHandlers=[];collisionEndHandlers=[];triggerEnterHandlers=[];triggerExitHandlers=[];rng;simTime=0;acc=0;stepDt;pendingPressed=/* @__PURE__ */ new Set;pendingJust=!1;pendingSwipe=null;stepPressed=/* @__PURE__ */ new Set;stepJust=!1;stepSwipe=null;shake={intensity:0,duration:0,until:0};restartRequested=!1;cloneCounter=0;unlockListeners=null;api;constructor(e){this.opts=e,this.stepDt=Math.min(Math.max(e.scene.physics?.step??1/60,1/480),1/10),this.rng=dv(e.scene.seed??1),this.audio=zj(e.scene.audio,e.resolveAsset,(t,n)=>e.issue({code:`asset-load`,message:t,path:n})),this.api=this.createApi()}static async create(t,n){let r=new e(t);if(r.hud=t.scene.ui?.elements?.length||t.scene.audio?oM(t.container,t.scene.ui,e=>r.emit(e)):null,t.scene.audio&&r.hud){let e=()=>r.hud.setMuteButton(r.audio.muted(),()=>{r.audio.unlock(),r.audio.setMuted(!r.audio.muted()),e()});e()}if(!t.deterministic){let e=()=>r.audio.unlock();t.container.addEventListener(`pointerdown`,e),t.container.addEventListener(`keydown`,e),r.unlockListeners=()=>{t.container.removeEventListener(`pointerdown`,e),t.container.removeEventListener(`keydown`,e)}}return await r.loadScripts(),await r.attach(n),r}async loadScripts(){let{scene:e,scriptSources:t,resolveAsset:n,issue:r}=this.opts;for(let i of e.scripts??[]){let e=t?.[i],a=e===void 0?n(i):`src:${i}:${e.length}:${e.slice(0,64)}`,o=ZL.get(a);o||(o=(async()=>{let t,r=null;e===void 0?t=n(i):(t=URL.createObjectURL(new Blob([e],{type:`text/javascript`})),r=t);try{let e=await import(
|
|
5814
6063
|
/* @vite-ignore */
|
|
5815
|
-
t);if(typeof e.default!=`function`)throw Error(`the default export must be a function (api) => ({ start, update })`);return e.default}finally{r&&URL.revokeObjectURL(r)}})(),o.catch(()=>wL.delete(a)),wL.set(a,o));try{let e=await o;e&&this.factories.push({path:i,factory:e})}catch(e){r({code:`script-error`,message:`${i}: ${e.message}`,path:i})}}}async attach(e){this.world=e,this.objCache.clear(),this.physics?.dispose(),this.physics=null,e.scene.updateMatrixWorld(!0),this.needsPhysics(e)&&await this.ensurePhysics(),this.instances=[];for(let{path:e,factory:t}of this.factories)try{this.instances.push({path:e,inst:t(this.api)??{},failed:!1})}catch(t){this.opts.issue({code:`script-error`,message:`${e}: ${t.message}`,path:e})}for(let e of this.instances)try{await e.inst.start?.()}catch(t){e.failed=!0,this.opts.issue({code:`script-error`,message:`${e.path} start(): ${t.message}`,path:e.path})}this.hud?.update(this.state,0)}needsPhysics(e){if(this.opts.scene.physics?.joints?.length)return!0;for(let t of e.entries.values())if(t.kind!==`light`&&(t.def.body||Array.isArray(t.object.userData.bodies)))return!0;return!1}async ensurePhysics(){if(this.physics)return this.physics;let{PhysicsBridge:e}=await CL(),t=new e(this.opts.scene.physics,this.world,e=>this.opts.issue(e));return t.engine.onCollision((e,t,n)=>this.dispatchContact(e.id,t.id,n)),t.engine.onCollisionEnd((e,t)=>this.dispatchContact(e.id,t.id,null)),this.physics=t,t.attachAll(),t}dispatchContact(e,t,n){let r=this.api.get(e),i=this.api.get(t);if(!r||!i||!this.physics)return;let a=this.physics.engine.get(e)?.type===`trigger`,o=this.physics.engine.get(t)?.type===`trigger`;if(n){for(let e of this.collisionHandlers)this.safe(()=>e(r,i,n),`onCollision`);for(let e of this.triggerEnterHandlers)a&&this.safe(()=>e(r,i),`onTriggerEnter`),o&&this.safe(()=>e(i,r),`onTriggerEnter`)}else{for(let e of this.collisionEndHandlers)this.safe(()=>e(r,i),`onCollisionEnd`);for(let e of this.triggerExitHandlers)a&&this.safe(()=>e(r,i),`onTriggerExit`),o&&this.safe(()=>e(i,r),`onTriggerExit`)}}async addBodies(e,t){let n=[];e.object.traverse(e=>{let t=e.userData.a3dId;t&&!n.includes(t)&&n.push(t)});let r=n.map(e=>this.world.entries.get(e)).filter(e=>!!e).filter(n=>n===e&&t||n.def.body);if(!r.length)return;let i=await this.ensurePhysics();for(let n of r)i.has(n.id)||i.addEntry(n,n===e?t:void 0)}requestRestart(){this.restartRequested=!0}get pendingRestart(){return this.restartRequested}async restart(){this.restartRequested=!1;for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);for(let e of Object.keys(this.state))delete this.state[e];this.handlers.clear(),this.collisionHandlers=[],this.collisionEndHandlers=[],this.triggerEnterHandlers=[],this.triggerExitHandlers=[],this.rng=dv(this.opts.scene.seed??1),this.simTime=0,this.acc=0,this.shake={intensity:0,duration:0,until:0};let e=await this.opts.rebuild();return await this.attach(e),e}time(){return this.simTime}advance(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe),this.acc+=Math.min(e,.25);let n=0;for(;this.acc>=this.stepDt-1e-9&&n<30;)this.fixedStep(),this.acc-=this.stepDt,n++}advanceTo(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);for(t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe);this.simTime+this.stepDt<=e+1e-9;)this.fixedStep()}fixedStep(){this.stepPressed=this.pendingPressed,this.pendingPressed=/* @__PURE__ */ new Set,this.stepJust=this.pendingJust,this.pendingJust=!1,this.stepSwipe=this.pendingSwipe,this.pendingSwipe=null;let e=this.stepDt;this.simTime+=e;for(let t of this.instances)if(!t.failed&&t.inst.update)try{t.inst.update(e,this.simTime)}catch(e){t.failed=!0,this.opts.issue({code:`script-error`,message:`${t.path} update(): ${e.message}`,path:t.path})}this.physics?.step(e),this.stepPressed=/* @__PURE__ */ new Set,this.stepJust=!1,this.stepSwipe=null}afterFrame(){let e=this.world.rig,t=this.simTime;if(t<this.shake.until&&this.shake.duration>0){let n=(this.shake.until-t)/this.shake.duration*this.shake.intensity;e.shake.set((this.rng.next()-.5)*2*n,(this.rng.next()-.5)*2*n,(this.rng.next()-.5)*n)}else e.shake.set(0,0,0);this.hud?.update(this.state,t)}emit(e,t){for(let n of this.handlers.get(e)??[])this.safe(()=>n(t),`on(${e})`);for(let n of this.instances)!n.failed&&n.inst.onEvent&&this.safe(()=>n.inst.onEvent(e,t),`onEvent`)}safe(e,t){try{e()}catch(e){this.opts.issue({code:`script-error`,message:`${t}: ${e.message}`})}}dispose(){for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);this.instances=[],this.physics?.dispose(),this.hud?.dispose(),this.audio.dispose(),this.unlockListeners?.()}wrap(e){let t=this.objCache.get(e.id);if(t)return t;let n=this,r=e.id,i=()=>n.world.entries.get(r)??e,a=()=>{let e=i();e.animated&&(e.rest.position.copy(e.object.position),e.rest.quaternion.copy(e.object.quaternion),e.rest.scale.copy(e.object.scale)),n.physics?.moved(r)},o=()=>n.physics?.engine.get(r)?.velocity??[0,0,0],s=(e,t)=>{let i=o();i[e]=t,n.physics?.engine.setVelocity(r,i)},c={id:r,position:xL(()=>i().object.position,1,a),rotation:xL(()=>i().object.rotation,LS,a),scale:xL(()=>i().object.scale,1,a),get visible(){return i().object.visible},set visible(e){let t=i();t.object.visible=e,t.rest.visible=e},velocity:{get x(){return o()[0]},set x(e){s(0,e)},get y(){return o()[1]},set y(e){s(1,e)},get z(){return o()[2]},set z(e){s(2,e)},set(e,t,i){n.physics?.engine.setVelocity(r,[e,t,i])}},get userData(){return i().object.userData},get tags(){return i().object.userData.tags??[]},setColor(e){let t=AS(e);for(let e of IS(i().object))e.color?.copy(t)},setOpacity(e){for(let t of IS(i().object))t.opacity=e,e<1&&!t.transparent&&(t.transparent=!0,t.needsUpdate=!0)},playAnimation(e,t){i().animator?.play(e,t)},distanceTo(e){let t=i().object.getWorldPosition(new B),r=n.world.entries.get(e.id);return r?t.distanceTo(r.object.getWorldPosition(new B)):1/0},remove(){n.world.entries.get(r)?.object.traverse(e=>{let t=e.userData.a3dId;t&&n.physics?.remove(t)}),n.physics?.remove(r),n.world.removeEntry(r),n.objCache.delete(r)}};return this.objCache.set(r,c),c}idOf(e){return typeof e==`string`?e:e.id}createApi(){let e=this,t=()=>e.opts.input,n={id:`camera`,position:xL(()=>e.world.rig.rest.position),rotation:xL(()=>e.world.camera.rotation,LS),scale:xL(()=>e.world.camera.scale),visible:!0,velocity:xL(()=>new B),userData:{},tags:[],setColor(){},setOpacity(){},playAnimation(){},distanceTo(t){let n=e.world.entries.get(t.id);return n?e.world.camera.position.distanceTo(n.object.getWorldPosition(new B)):1/0},remove(){},lookAt(t,n,r){e.world.rig.rest.target.set(t,n,r)},shake(t,n){e.shake={intensity:t,duration:n,until:e.simTime+n}}},r=new of,i={get:t=>{let n=e.world.entries.get(t);return n&&n.kind!==`light`?e.wrap(n):null},findByTag:t=>{let n=[];for(let r of e.world.entries.values())r.kind!==`light`&&(r.object.userData.tags??[]).includes(t)&&n.push(e.wrap(r));return n},spawn:async(t,n)=>{let r=n?e.world.entries.get(n):void 0,i=await e.world.addObject(t,r?.object??e.world.scene,r?.id,/* @__PURE__ */ new Map);if(!i)throw Error(`spawn(${t.id}) failed`);return e.world.scene.updateMatrixWorld(!0),await e.addBodies(i),e.wrap(i)},clone:(t,n)=>{let r=e.world.entries.get(t);if(!r||r.kind===`light`)throw Error(`clone: unknown object "${t}"`);let i=n?.id;for(;!i||e.world.entries.has(i);)i=`${t}_${++e.cloneCounter}`;let a=r.object.clone(!0);a.traverse(e=>{let t=e;t.isMesh&&t.material&&(t.material=Array.isArray(t.material)?t.material.map(e=>e.clone()):t.material.clone()),e.userData.a3dId&&(e.userData={...e.userData})}),a.userData.a3dId=i,n?.position&&a.position.set(...n.position),(r.object.parent??e.world.scene).add(a);let o={...r.def,id:i,children:void 0},s={...r,id:i,def:o,object:a,rest:{position:a.position.clone(),quaternion:a.quaternion.clone(),scale:a.scale.clone(),visible:a.visible},runners:[],animator:void 0};return e.world.entries.set(i,s),e.world.scene.updateMatrixWorld(!0),o.body&&e.physics&&e.physics.addEntry(s),e.wrap(s)},camera:n,time:()=>e.simTime,random:()=>e.rng.next(),randomRange:(t,n)=>e.rng.range(t,n),input:{isDown:e=>t().keys.has(e),pressed:t=>e.stepPressed.has(t),get pointer(){let n=t().pointer;return{x:n.x,y:n.y,down:n.down,justPressed:e.stepJust}},swipe:()=>e.stepSwipe,pointerWorld:()=>{let n=t().pointer;r.setFromCamera(new z(n.x,n.y),e.world.camera);let i=[];for(let t of e.physics?.engine.bodies??[]){let n=e.world.entries.get(t.id);n&&i.push(n.object)}let a=i.length?r.intersectObjects(i,!0)[0]:void 0;if(a){let t=e.world.idsFor(a.object);return{x:a.point.x,y:a.point.y,z:a.point.z,objectId:t[0]}}let o=new B;return r.ray.intersectPlane(new Fo(new B(0,1,0),0),o)?{x:o.x,y:o.y,z:o.z}:null}},physics:{overlaps:(t,n)=>e.physics?.engine.overlaps(e.idOf(t),e.idOf(n))??!1,contacts:t=>(e.physics?.engine.contactsOf(e.idOf(t))??[]).map(e=>i.get(e.id)).filter(e=>!!e),raycast:(t,n,r,i)=>{let a=e.physics?.engine;if(!a)return null;let o=new Set((i?.ignore??[]).map(t=>e.idOf(t))),s=a.raycast(t,n,r??1/0,{ignore:o.size?e=>o.has(e.id):void 0,mask:i?.layers?a.layerMask(i.layers):void 0,triggers:i?.triggers});return s?{objectId:s.body.id,distance:s.distance,point:s.point,normal:s.normal}:null},applyImpulse:(t,n,r)=>e.physics?.engine.applyImpulse(e.idOf(t),n,r),applyForce:(t,n,r)=>e.physics?.engine.applyForce(e.idOf(t),n,r),applyTorque:(t,n)=>e.physics?.engine.applyTorque(e.idOf(t),n),setVelocity:(t,n)=>e.physics?.engine.setVelocity(e.idOf(t),n),getVelocity:t=>e.physics?.engine.get(e.idOf(t))?.velocity??[0,0,0],setAngularVelocity:(t,n)=>e.physics?.engine.setAngularVelocity(e.idOf(t),[n[0]*LS,n[1]*LS,n[2]*LS]),getAngularVelocity:t=>{let n=e.physics?.engine.get(e.idOf(t))?.angularVelocity??[0,0,0];return[n[0]/LS,n[1]/LS,n[2]/LS]},grounded:t=>e.physics?.engine.grounded(e.idOf(t))??!1,moveCharacter:(t,n,r)=>{let i=Array.isArray(n)?[n[0],n[1]]:[n.x,n.z];e.physics?.engine.moveCharacter(e.idOf(t),i,r)},jump:(t,n)=>e.physics?.engine.jump(e.idOf(t),n)??!1,wake:t=>e.physics?.engine.wake(e.idOf(t)),setMotorSpeed:(t,n)=>e.physics?.engine.setMotorSpeed(t,n*LS),onCollision:t=>void e.collisionHandlers.push(t),onCollisionEnd:t=>void e.collisionEndHandlers.push(t),onTriggerEnter:t=>void e.triggerEnterHandlers.push(t),onTriggerExit:t=>void e.triggerExitHandlers.push(t)},state:e.state,ui:{set:(t,n)=>e.hud?.set(t,n),toast:(t,n)=>e.hud?.toast(t,n)},audio:{play:t=>e.audio.play(t),music:t=>e.audio.music(t)},on:(t,n)=>{let r=e.handlers.get(t)??[];r.push(n),e.handlers.set(t,r)},emit:(t,n)=>e.emit(t,n),storage:{get(t){try{let n=globalThis.localStorage?.getItem(`agent3d:${e.opts.scene.id}:${t}`);return n==null?void 0:JSON.parse(n)}catch{return}},set(t,n){try{globalThis.localStorage?.setItem(`agent3d:${e.opts.scene.id}:${t}`,JSON.stringify(n))}catch{}}},data:e.opts.scene.data??{},restart:()=>e.requestRestart(),log:(...e)=>console.log(`[agent3d]`,...e)};return i}}})),DL,OL,kL,AL,jL,ML=t((()=>{J(),DL=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},OL=new Gu(-1,1,1,-1,0,1),kL=class extends G{constructor(){super(),this.setAttribute(`position`,new W([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new W([0,2,0,0,2,0],2))}},AL=new kL,jL=class{constructor(e){this._mesh=new K(AL,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,OL)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}}));function NL(e){let t=!1;return e.traverseVisible(e=>{if(t)return;let n=e.material;if(n)for(let e of Array.isArray(n)?n:[n])e.transmission>0&&(t=!0)}),t}var PL,FL,IL,LL,RL=t((()=>{J(),ML(),PL={1:`LINEAR_TONE_MAPPING`,2:`REINHARD_TONE_MAPPING`,3:`CINEON_TONE_MAPPING`,4:`ACES_FILMIC_TONE_MAPPING`,6:`AGX_TONE_MAPPING`,7:`NEUTRAL_TONE_MAPPING`,5:`CUSTOM_TONE_MAPPING`},FL=`
|
|
6064
|
+
t);if(typeof e.default!=`function`)throw Error(`the default export must be a function (api) => ({ start, update })`);return e.default}finally{r&&URL.revokeObjectURL(r)}})(),o.catch(()=>ZL.delete(a)),ZL.set(a,o));try{let e=await o;e&&this.factories.push({path:i,factory:e})}catch(e){r({code:`script-error`,message:`${i}: ${e.message}`,path:i})}}}async attach(e){this.world=e,this.objCache.clear(),this.physics?.dispose(),this.physics=null,e.scene.updateMatrixWorld(!0),this.needsPhysics(e)&&await this.ensurePhysics(),this.instances=[];for(let{path:e,factory:t}of this.factories)try{this.instances.push({path:e,inst:t(this.api)??{},failed:!1})}catch(t){this.opts.issue({code:`script-error`,message:`${e}: ${t.message}`,path:e})}for(let e of this.instances)try{await e.inst.start?.()}catch(t){e.failed=!0,this.opts.issue({code:`script-error`,message:`${e.path} start(): ${t.message}`,path:e.path})}this.hud?.update(this.state,0)}needsPhysics(e){if(this.opts.scene.physics?.joints?.length)return!0;for(let t of e.entries.values())if(t.kind!==`light`&&(t.def.body||Array.isArray(t.object.userData.bodies)))return!0;return!1}async ensurePhysics(){if(this.physics)return this.physics;let{PhysicsBridge:e}=await XL(),t=new e(this.opts.scene.physics,this.world,e=>this.opts.issue(e));return t.engine.onCollision((e,t,n)=>this.dispatchContact(e.id,t.id,n)),t.engine.onCollisionEnd((e,t)=>this.dispatchContact(e.id,t.id,null)),this.physics=t,t.attachAll(),t}dispatchContact(e,t,n){let r=this.api.get(e),i=this.api.get(t);if(!r||!i||!this.physics)return;let a=this.physics.engine.get(e)?.type===`trigger`,o=this.physics.engine.get(t)?.type===`trigger`;if(n){for(let e of this.collisionHandlers)this.safe(()=>e(r,i,n),`onCollision`);for(let e of this.triggerEnterHandlers)a&&this.safe(()=>e(r,i),`onTriggerEnter`),o&&this.safe(()=>e(i,r),`onTriggerEnter`)}else{for(let e of this.collisionEndHandlers)this.safe(()=>e(r,i),`onCollisionEnd`);for(let e of this.triggerExitHandlers)a&&this.safe(()=>e(r,i),`onTriggerExit`),o&&this.safe(()=>e(i,r),`onTriggerExit`)}}async addBodies(e,t){let n=[];e.object.traverse(e=>{let t=e.userData.a3dId;t&&!n.includes(t)&&n.push(t)});let r=n.map(e=>this.world.entries.get(e)).filter(e=>!!e).filter(n=>n===e&&t||n.def.body);if(!r.length)return;let i=await this.ensurePhysics();for(let n of r)i.has(n.id)||i.addEntry(n,n===e?t:void 0)}requestRestart(){this.restartRequested=!0}get pendingRestart(){return this.restartRequested}async restart(){this.restartRequested=!1;for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);for(let e of Object.keys(this.state))delete this.state[e];this.handlers.clear(),this.collisionHandlers=[],this.collisionEndHandlers=[],this.triggerEnterHandlers=[],this.triggerExitHandlers=[],this.rng=dv(this.opts.scene.seed??1),this.simTime=0,this.acc=0,this.shake={intensity:0,duration:0,until:0};let e=await this.opts.rebuild();return await this.attach(e),e}time(){return this.simTime}advance(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe),this.acc+=Math.min(e,.25);let n=0;for(;this.acc>=this.stepDt-1e-9&&n<30;)this.fixedStep(),this.acc-=this.stepDt,n++}advanceTo(e){let t=this.opts.input;for(let e of t.pressed)this.pendingPressed.add(e);for(t.pointer.justPressed&&(this.pendingJust=!0),t.swipe&&(this.pendingSwipe=t.swipe);this.simTime+this.stepDt<=e+1e-9;)this.fixedStep()}fixedStep(){this.stepPressed=this.pendingPressed,this.pendingPressed=/* @__PURE__ */ new Set,this.stepJust=this.pendingJust,this.pendingJust=!1,this.stepSwipe=this.pendingSwipe,this.pendingSwipe=null;let e=this.stepDt;this.simTime+=e;for(let t of this.instances)if(!t.failed&&t.inst.update)try{t.inst.update(e,this.simTime)}catch(e){t.failed=!0,this.opts.issue({code:`script-error`,message:`${t.path} update(): ${e.message}`,path:t.path})}this.physics?.step(e),this.stepPressed=/* @__PURE__ */ new Set,this.stepJust=!1,this.stepSwipe=null}afterFrame(){let e=this.world.rig,t=this.simTime;if(t<this.shake.until&&this.shake.duration>0){let n=(this.shake.until-t)/this.shake.duration*this.shake.intensity;e.shake.set((this.rng.next()-.5)*2*n,(this.rng.next()-.5)*2*n,(this.rng.next()-.5)*n)}else e.shake.set(0,0,0);this.hud?.update(this.state,t)}emit(e,t){for(let n of this.handlers.get(e)??[])this.safe(()=>n(t),`on(${e})`);for(let n of this.instances)!n.failed&&n.inst.onEvent&&this.safe(()=>n.inst.onEvent(e,t),`onEvent`)}safe(e,t){try{e()}catch(e){this.opts.issue({code:`script-error`,message:`${t}: ${e.message}`})}}dispose(){for(let e of this.instances)this.safe(()=>e.inst.dispose?.(),`dispose`);this.instances=[],this.physics?.dispose(),this.hud?.dispose(),this.audio.dispose(),this.unlockListeners?.()}wrap(e){let t=this.objCache.get(e.id);if(t)return t;let n=this,r=e.id,i=()=>n.world.entries.get(r)??e,a=()=>{let e=i();e.animated&&(e.rest.position.copy(e.object.position),e.rest.quaternion.copy(e.object.quaternion),e.rest.scale.copy(e.object.scale)),n.physics?.moved(r)},o=()=>n.physics?.engine.get(r)?.velocity??[0,0,0],s=(e,t)=>{let i=o();i[e]=t,n.physics?.engine.setVelocity(r,i)},c={id:r,position:JL(()=>i().object.position,1,a),rotation:JL(()=>i().object.rotation,LS,a),scale:JL(()=>i().object.scale,1,a),get visible(){return i().object.visible},set visible(e){let t=i();t.object.visible=e,t.rest.visible=e},velocity:{get x(){return o()[0]},set x(e){s(0,e)},get y(){return o()[1]},set y(e){s(1,e)},get z(){return o()[2]},set z(e){s(2,e)},set(e,t,i){n.physics?.engine.setVelocity(r,[e,t,i])}},get userData(){return i().object.userData},get tags(){return i().object.userData.tags??[]},setColor(e){let t=AS(e);for(let e of IS(i().object))e.color?.copy(t)},setOpacity(e){for(let t of IS(i().object))t.opacity=e,e<1&&!t.transparent&&(t.transparent=!0,t.needsUpdate=!0)},playAnimation(e,t){i().animator?.play(e,t)},distanceTo(e){let t=i().object.getWorldPosition(new B),r=n.world.entries.get(e.id);return r?t.distanceTo(r.object.getWorldPosition(new B)):1/0},remove(){n.world.entries.get(r)?.object.traverse(e=>{let t=e.userData.a3dId;t&&n.physics?.remove(t)}),n.physics?.remove(r),n.world.removeEntry(r),n.objCache.delete(r)}};return this.objCache.set(r,c),c}idOf(e){return typeof e==`string`?e:e.id}createApi(){let e=this,t=()=>e.opts.input,n={id:`camera`,position:JL(()=>e.world.rig.rest.position),rotation:JL(()=>e.world.camera.rotation,LS),scale:JL(()=>e.world.camera.scale),visible:!0,velocity:JL(()=>new B),userData:{},tags:[],setColor(){},setOpacity(){},playAnimation(){},distanceTo(t){let n=e.world.entries.get(t.id);return n?e.world.camera.position.distanceTo(n.object.getWorldPosition(new B)):1/0},remove(){},lookAt(t,n,r){e.world.rig.rest.target.set(t,n,r)},shake(t,n){e.shake={intensity:t,duration:n,until:e.simTime+n}}},r=new of,i={get:t=>{let n=e.world.entries.get(t);return n&&n.kind!==`light`?e.wrap(n):null},findByTag:t=>{let n=[];for(let r of e.world.entries.values())r.kind!==`light`&&(r.object.userData.tags??[]).includes(t)&&n.push(e.wrap(r));return n},spawn:async(t,n)=>{let r=n?e.world.entries.get(n):void 0,i=await e.world.addObject(t,r?.object??e.world.scene,r?.id,/* @__PURE__ */ new Map);if(!i)throw Error(`spawn(${t.id}) failed`);return e.world.scene.updateMatrixWorld(!0),await e.addBodies(i),e.wrap(i)},clone:(t,n)=>{let r=e.world.entries.get(t);if(!r||r.kind===`light`)throw Error(`clone: unknown object "${t}"`);let i=n?.id;for(;!i||e.world.entries.has(i);)i=`${t}_${++e.cloneCounter}`;let a=r.object.clone(!0);a.traverse(e=>{let t=e;t.isMesh&&t.material&&(t.material=Array.isArray(t.material)?t.material.map(e=>e.clone()):t.material.clone()),e.userData.a3dId&&(e.userData={...e.userData})}),a.userData.a3dId=i,n?.position&&a.position.set(...n.position),(r.object.parent??e.world.scene).add(a);let o={...r.def,id:i,children:void 0},s={...r,id:i,def:o,object:a,rest:{position:a.position.clone(),quaternion:a.quaternion.clone(),scale:a.scale.clone(),visible:a.visible},runners:[],animator:void 0};return e.world.entries.set(i,s),e.world.scene.updateMatrixWorld(!0),o.body&&e.physics&&e.physics.addEntry(s),e.wrap(s)},camera:n,time:()=>e.simTime,random:()=>e.rng.next(),randomRange:(t,n)=>e.rng.range(t,n),input:{isDown:e=>t().keys.has(e),pressed:t=>e.stepPressed.has(t),get pointer(){let n=t().pointer;return{x:n.x,y:n.y,down:n.down,justPressed:e.stepJust}},swipe:()=>e.stepSwipe,pointerWorld:()=>{let n=t().pointer;r.setFromCamera(new z(n.x,n.y),e.world.camera);let i=[];for(let t of e.physics?.engine.bodies??[]){let n=e.world.entries.get(t.id);n&&i.push(n.object)}let a=i.length?r.intersectObjects(i,!0)[0]:void 0;if(a){let t=e.world.idsFor(a.object);return{x:a.point.x,y:a.point.y,z:a.point.z,objectId:t[0]}}let o=new B;return r.ray.intersectPlane(new Fo(new B(0,1,0),0),o)?{x:o.x,y:o.y,z:o.z}:null}},physics:{overlaps:(t,n)=>e.physics?.engine.overlaps(e.idOf(t),e.idOf(n))??!1,contacts:t=>(e.physics?.engine.contactsOf(e.idOf(t))??[]).map(e=>i.get(e.id)).filter(e=>!!e),raycast:(t,n,r,i)=>{let a=e.physics?.engine;if(!a)return null;let o=new Set((i?.ignore??[]).map(t=>e.idOf(t))),s=a.raycast(t,n,r??1/0,{ignore:o.size?e=>o.has(e.id):void 0,mask:i?.layers?a.layerMask(i.layers):void 0,triggers:i?.triggers});return s?{objectId:s.body.id,distance:s.distance,point:s.point,normal:s.normal}:null},applyImpulse:(t,n,r)=>e.physics?.engine.applyImpulse(e.idOf(t),n,r),applyForce:(t,n,r)=>e.physics?.engine.applyForce(e.idOf(t),n,r),applyTorque:(t,n)=>e.physics?.engine.applyTorque(e.idOf(t),n),setVelocity:(t,n)=>e.physics?.engine.setVelocity(e.idOf(t),n),getVelocity:t=>e.physics?.engine.get(e.idOf(t))?.velocity??[0,0,0],setAngularVelocity:(t,n)=>e.physics?.engine.setAngularVelocity(e.idOf(t),[n[0]*LS,n[1]*LS,n[2]*LS]),getAngularVelocity:t=>{let n=e.physics?.engine.get(e.idOf(t))?.angularVelocity??[0,0,0];return[n[0]/LS,n[1]/LS,n[2]/LS]},grounded:t=>e.physics?.engine.grounded(e.idOf(t))??!1,moveCharacter:(t,n,r)=>{let i=Array.isArray(n)?[n[0],n[1]]:[n.x,n.z];e.physics?.engine.moveCharacter(e.idOf(t),i,r)},jump:(t,n)=>e.physics?.engine.jump(e.idOf(t),n)??!1,wake:t=>e.physics?.engine.wake(e.idOf(t)),setMotorSpeed:(t,n)=>e.physics?.engine.setMotorSpeed(t,n*LS),onCollision:t=>void e.collisionHandlers.push(t),onCollisionEnd:t=>void e.collisionEndHandlers.push(t),onTriggerEnter:t=>void e.triggerEnterHandlers.push(t),onTriggerExit:t=>void e.triggerExitHandlers.push(t)},state:e.state,ui:{set:(t,n)=>e.hud?.set(t,n),toast:(t,n)=>e.hud?.toast(t,n)},audio:{play:t=>e.audio.play(t),music:t=>e.audio.music(t)},on:(t,n)=>{let r=e.handlers.get(t)??[];r.push(n),e.handlers.set(t,r)},emit:(t,n)=>e.emit(t,n),storage:{get(t){try{let n=globalThis.localStorage?.getItem(`agent3d:${e.opts.scene.id}:${t}`);return n==null?void 0:JSON.parse(n)}catch{return}},set(t,n){try{globalThis.localStorage?.setItem(`agent3d:${e.opts.scene.id}:${t}`,JSON.stringify(n))}catch{}}},data:e.opts.scene.data??{},restart:()=>e.requestRestart(),log:(...e)=>console.log(`[agent3d]`,...e)};return i}}})),eR,tR,nR,rR,iR,aR=t((()=>{J(),eR=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}},tR=new Gu(-1,1,1,-1,0,1),nR=class extends G{constructor(){super(),this.setAttribute(`position`,new W([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new W([0,2,0,0,2,0],2))}},rR=new nR,iR=class{constructor(e){this._mesh=new K(rR,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,tR)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}}));function oR(e){let t=!1;return e.traverseVisible(e=>{if(t)return;let n=e.material;if(n)for(let e of Array.isArray(n)?n:[n])e.transmission>0&&(t=!0)}),t}var sR,cR,lR,uR,dR=t((()=>{J(),aR(),sR={1:`LINEAR_TONE_MAPPING`,2:`REINHARD_TONE_MAPPING`,3:`CINEON_TONE_MAPPING`,4:`ACES_FILMIC_TONE_MAPPING`,6:`AGX_TONE_MAPPING`,7:`NEUTRAL_TONE_MAPPING`,5:`CUSTOM_TONE_MAPPING`},cR=`
|
|
5816
6065
|
vec4 a3dSanitize(vec4 c) {
|
|
5817
6066
|
bvec4 bad = bvec4(isnan(c.r) || isinf(c.r), isnan(c.g) || isinf(c.g), isnan(c.b) || isinf(c.b), isnan(c.a) || isinf(c.a));
|
|
5818
6067
|
c = vec4(bad.r ? 0.0 : c.r, bad.g ? 0.0 : c.g, bad.b ? 0.0 : c.b, bad.a ? 1.0 : c.a);
|
|
5819
6068
|
return vec4(clamp(c.rgb, vec3(0.0), vec3(64.0)), clamp(c.a, 0.0, 1.0));
|
|
5820
|
-
}`,
|
|
6069
|
+
}`,lR=class extends eR{scene;camera;bgScene=new ka;target;quad;mat;toneMapping=null;clearColor=new H(0,0,0);clearAlpha=0;constructor(e,t,n,r){super(),this.scene=e,this.camera=t,this.target=new Hi(n,r,{type:Tn}),this.mat=new Vl({glslVersion:oi,uniforms:{tDiffuse:{value:null},tBackground:{value:this.target.texture},toneMappingExposure:{value:1},uToneBg:{value:0}},vertexShader:`precision highp float;
|
|
5821
6070
|
uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; in vec3 position; in vec2 uv; out vec2 vUv;
|
|
5822
6071
|
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,fragmentShader:`precision highp float;
|
|
5823
6072
|
uniform sampler2D tDiffuse; uniform sampler2D tBackground; uniform float uToneBg;
|
|
5824
6073
|
#include <tonemapping_pars_fragment>
|
|
5825
|
-
${
|
|
6074
|
+
${cR}
|
|
5826
6075
|
in vec2 vUv;
|
|
5827
6076
|
out vec4 fragColor;
|
|
5828
6077
|
vec3 tm(vec3 c) {
|
|
@@ -5863,18 +6112,18 @@ vec4 a3dSanitize(vec4 c) {
|
|
|
5863
6112
|
float outA = a + bg.a * (1.0 - a);
|
|
5864
6113
|
outA = max(outA, min(1.0, max(rgb.r, max(rgb.g, rgb.b))));
|
|
5865
6114
|
fragColor = vec4(rgb, outA);
|
|
5866
|
-
}`}),this.quad=new
|
|
5867
|
-
void main() { if (uShow < 0.5) discard; vec4 c = texture2D(tBg, vUv); gl_FragColor = vec4(c.rgb, 1.0); }`,depthTest:!1,depthWrite:!1,toneMapped:!1}),this.mesh=new K(new El(2,2),this.mat),this.mesh.name=`__a3dBackdrop`,this.mesh.frustumCulled=!1,this.mesh.renderOrder=-1e9,this.mesh.visible=!1,this.mesh.userData.a3dHelper=!0,this.mesh.onBeforeRender=(e,t)=>{this.mat.uniforms.uShow.value=e.getRenderTarget()===this.mainTarget||t.userData.a3dReflecting?0:1}}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mat.dispose()}}}));function
|
|
5868
|
-
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,
|
|
6115
|
+
}`}),this.quad=new iR(this.mat)}setSize(e,t){this.target.setSize(e,t)}fresh=!1;get texture(){return this.target.texture}prepare(e){this.drawBackground(e),this.fresh=!0}drawBackground(e){let t=this.scene.background,n=this.bgScene;n.background=t,n.backgroundBlurriness=this.scene.backgroundBlurriness,n.backgroundIntensity=this.scene.backgroundIntensity,n.backgroundRotation.copy(this.scene.backgroundRotation);let r=e.getClearColor(new H),i=e.getClearAlpha(),a=e.getRenderTarget();e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.target),e.clear(),t&&e.render(n,this.camera),e.setClearColor(r,i),e.setRenderTarget(a),n.background=null}render(e,t,n){if(this.toneMapping!==e.toneMapping){this.toneMapping=e.toneMapping;let t=sR[e.toneMapping];this.mat.defines=t?{[t]:``}:{},this.mat.needsUpdate=!0}this.fresh||this.drawBackground(e),this.fresh=!1;let r=this.scene.background,i=this.mat.uniforms;i.tDiffuse.value=n.texture,i.toneMappingExposure.value=e.toneMappingExposure,i.uToneBg.value=+(r instanceof zi&&ji.getTransfer(r.colorSpace)!==`srgb`),e.setRenderTarget(this.renderToScreen?null:t),this.quad.render(e)}dispose(){this.target.dispose(),this.mat.dispose(),this.quad.dispose()}},uR=class{mesh;mat;mainTarget=null;constructor(e){this.mat=new Bl({uniforms:{tBg:{value:e},uShow:{value:0}},vertexShader:`varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.99999, 1.0); }`,fragmentShader:`uniform sampler2D tBg; uniform float uShow; varying vec2 vUv;
|
|
6116
|
+
void main() { if (uShow < 0.5) discard; vec4 c = texture2D(tBg, vUv); gl_FragColor = vec4(c.rgb, 1.0); }`,depthTest:!1,depthWrite:!1,toneMapped:!1}),this.mesh=new K(new El(2,2),this.mat),this.mesh.name=`__a3dBackdrop`,this.mesh.frustumCulled=!1,this.mesh.renderOrder=-1e9,this.mesh.visible=!1,this.mesh.userData.a3dHelper=!0,this.mesh.onBeforeRender=(e,t)=>{this.mat.uniforms.uShow.value=e.getRenderTarget()===this.mainTarget||t.userData.a3dReflecting?0:1}}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mat.dispose()}}}));function fR(){return{uNear:{value:.1},uFar:{value:1e3},uOrtho:{value:0}}}function pR(e,t){e.uNear.value=t.near,e.uFar.value=t.far,e.uOrtho.value=+!!t.isOrthographicCamera}function mR(e,t,n={}){return new Bl({uniforms:t,vertexShader:vR,fragmentShader:e,defines:n,depthTest:!1,depthWrite:!1,blending:0})}function hR(e,t,n={}){return new Hi(Math.max(1,Math.round(e)),Math.max(1,Math.round(t)),{type:Tn,depthBuffer:!1,...n})}function gR(e,t,n=!1){let r=[];e.traverse(e=>{e.visible&&(e.userData.helper&&(n||!e.userData.ground)||e.isPoints||e.isSprite||e.isLine)&&(r.push(e),e.visible=!1)});let i=e.background;e.background=null;try{t()}finally{e.background=i;for(let e of r)e.visible=!0}}function _R(e=64,t=1){let n=t>>>0||1,r=()=>(n^=n<<13,n^=n>>>17,n^=n<<5,(n>>>0)/4294967296),i=new Uint8Array(e*e*4);for(let e=0;e<i.length;e++)i[e]=Math.floor(r()*256);let a=new As(i,e,e,Nn,vn);return a.wrapS=a.wrapT=an,a.needsUpdate=!0,a}var vR,yR,bR,xR,SR,CR=t((()=>{J(),aR(),vR=`varying vec2 vUv;
|
|
6117
|
+
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,yR=`
|
|
5869
6118
|
float a3dHash12(vec2 p) { vec3 p3 = fract(vec3(p.xyx) * 0.1031); p3 += dot(p3, p3.yzx + 33.33); return fract((p3.x + p3.y) * p3.z); }
|
|
5870
6119
|
float a3dLuma(vec3 c) { return dot(c, vec3(0.2126, 0.7152, 0.0722)); }
|
|
5871
|
-
`,
|
|
6120
|
+
`,bR=`
|
|
5872
6121
|
uniform float uNear; uniform float uFar; uniform float uOrtho;
|
|
5873
6122
|
float a3dViewZ(float d) {
|
|
5874
6123
|
if (uOrtho > 0.5) return uNear + d * (uFar - uNear);
|
|
5875
6124
|
return uNear * uFar / max(uFar - d * (uFar - uNear), 1e-6);
|
|
5876
6125
|
}
|
|
5877
|
-
`,
|
|
6126
|
+
`,xR=class extends eR{material;quad;constructor(e){super(),this.material=e,this.quad=new iR(e)}get uniforms(){return this.material.uniforms}render(e,t,n){this.material.uniforms.tDiffuse&&(this.material.uniforms.tDiffuse.value=n.texture),e.setRenderTarget(this.renderToScreen?null:t),this.quad.render(e)}dispose(){this.material.dispose(),this.quad.dispose()}},SR=class{target;normalMat=new Kl;groundMat=new Kl({transparent:!0,opacity:.5,blending:0});frame=-1;constructor(e,t){this.target=new Hi(Math.max(1,e),Math.max(1,t),{type:Tn,minFilter:cn,magFilter:cn,depthTexture:new Rc(Math.max(1,e),Math.max(1,t),Cn)}),this.normalMat.blending=0}get normalTexture(){return this.target.texture}get depthTexture(){return this.target.depthTexture}setSize(e,t){this.target.setSize(Math.max(1,e),Math.max(1,t)),this.frame=-1}ensure(e,t,n,r){if(this.frame===r)return;this.frame=r;let i=t.overrideMaterial,a=e.getClearColor(new H),o=e.getClearAlpha(),s=[],c=e.shadowMap,l={auto:c.autoUpdate,needs:c.needsUpdate};c.autoUpdate=!1,c.needsUpdate=!1,gR(t,()=>{if(t.traverse(e=>{e.userData.ground&&e.visible&&e.isMesh&&(s.push(e),e.visible=!1)}),t.overrideMaterial=this.normalMat,e.setRenderTarget(this.target),e.setClearColor(new H(.5,.5,1),0),e.clear(),e.render(t,n),s.length){let r=e.autoClear;e.autoClear=!1,t.overrideMaterial=this.groundMat;for(let e of s)e.visible=!0;let i=[];t.traverse(e=>{e.visible&&e.isMesh&&!e.userData.ground&&(i.push(e),e.visible=!1)}),e.render(t,n);for(let e of i)e.visible=!0;e.autoClear=r}});for(let e of s)e.visible=!0;c.autoUpdate=l.auto,c.needsUpdate=l.needs,t.overrideMaterial=i,e.setClearColor(a,o)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.normalMat.dispose(),this.groundMat.dispose()}}})),wR,TR,ER=t((()=>{J(),Rx(),zS(),CR(),wR=`
|
|
5878
6127
|
uniform sampler2D tDiffuse; uniform vec2 uRes; uniform float uTime; uniform float uPr;
|
|
5879
6128
|
uniform float uCA; uniform float uCARadial;
|
|
5880
6129
|
uniform float uSharpen;
|
|
@@ -5883,7 +6132,7 @@ uniform float uLift; uniform float uGamma; uniform float uGain; uniform vec3 uSh
|
|
|
5883
6132
|
uniform float uVigOffset; uniform float uVigDark; uniform vec3 uVigColor;
|
|
5884
6133
|
uniform float uGrain; uniform float uGrainSize; uniform float uScan; uniform float uGray;
|
|
5885
6134
|
varying vec2 vUv;
|
|
5886
|
-
${
|
|
6135
|
+
${yR}
|
|
5887
6136
|
vec3 toSRGB(vec3 c) { c = max(c, 0.0); return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c)); }
|
|
5888
6137
|
float scurve(float x, float k) {
|
|
5889
6138
|
x = clamp(x, 0.0, 1.0);
|
|
@@ -5941,7 +6190,7 @@ void main() {
|
|
|
5941
6190
|
float r1 = a3dHash12(gl_FragCoord.xy + 0.37), r2 = a3dHash12(gl_FragCoord.xy * 1.13 + 17.1);
|
|
5942
6191
|
g += (r1 + r2 - 1.0) / 255.0 * base.a;
|
|
5943
6192
|
gl_FragColor = vec4(g, base.a);
|
|
5944
|
-
}`,
|
|
6193
|
+
}`,TR=class extends xR{defines={};constructor(){super(mR(wR,{tDiffuse:{value:null},uRes:{value:new z(1,1)},uTime:{value:0},uPr:{value:1},uCA:{value:0},uCARadial:{value:1},uSharpen:{value:0},uExposure:{value:1},uWB:{value:new B(1,1,1)},uContrast:{value:1},uSat:{value:1},uVib:{value:0},uLift:{value:0},uGamma:{value:1},uGain:{value:1},uShadows:{value:new B(.5,.5,.5)},uHighlights:{value:new B(.5,.5,.5)},uToning:{value:0},uBleach:{value:0},uVigOffset:{value:1},uVigDark:{value:1.1},uVigColor:{value:new H(0,0,0)},uGrain:{value:0},uGrainSize:{value:1.5},uScan:{value:0},uGray:{value:0}}))}enable(e){e in this.defines||(this.defines[e]=``,this.material.defines={...this.defines},this.material.needsUpdate=!0)}configure(e){let t=this.uniforms;switch(e.type){case`chromatic`:t.uCA.value=Q(e.amount,.002),t.uCARadial.value=+!!ES(e.radial,!0),this.enable(`CA`);break;case`sharpen`:t.uSharpen.value=Q(e.amount,.3),this.enable(`SHARPEN`);break;case`vignette`:t.uVigOffset.value=Math.max(.01,Q(e.offset,1)),t.uVigDark.value=Q(e.darkness,1.1),t.uVigColor.value=AS(typeof e.color==`string`?e.color:`#000000`),this.enable(`VIGNETTE`);break;case`film`:t.uGrain.value=Q(e.intensity,.35),t.uGray.value=+!!ES(e.grayscale,!1),t.uScan.value=Q(e.scanlines,0),t.uGrainSize.value=Math.max(.5,Q(e.size,1.5)),this.enable(`FILM`);break;case`grading`:{let n=kx(e),r=(e,t)=>typeof n[e]==`number`?n[e]:t;t.uExposure.value=2**r(`exposure`,0);let i=r(`temperature`,0),a=r(`tint`,0),o=new B(1+.22*i+.04*a,1-.12*a,1-.22*i+.04*a),s=o.x*.2126+o.y*.7152+o.z*.0722;t.uWB.value.copy(o.multiplyScalar(1/s)),t.uContrast.value=Math.max(.05,r(`contrast`,1)),t.uSat.value=r(`saturation`,1),t.uVib.value=r(`vibrance`,0),t.uLift.value=r(`lift`,0),t.uGamma.value=Math.max(.05,r(`gamma`,1)),t.uGain.value=r(`gain`,1),t.uToning.value=r(`toning`,0),t.uBleach.value=r(`bleach`,0);let c=(e,t)=>{if(typeof e!=`string`)return t.set(.5,.5,.5);let n=AS(e).clone().convertLinearToSRGB();return t.set(n.r,n.g,n.b)};c(n.shadows,t.uShadows.value),c(n.highlights,t.uHighlights.value),this.enable(`GRADE`);break}}}setTime(e){this.uniforms.uTime.value=e}setSize(e,t){this.uniforms.uRes.value.set(e,t)}setPixelRatio(e){this.uniforms.uPr.value=e}}}));function DR(e=5){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=OR(t),r=n.length,i=new Uint8Array(r*4);for(let e=0;e<r;++e){let t=n[e],a=2*Math.PI*t/r,o=new B(Math.cos(a),Math.sin(a),0).normalize();i[e*4]=(o.x*.5+.5)*255,i[e*4+1]=(o.y*.5+.5)*255,i[e*4+2]=127,i[e*4+3]=255}let a=new As(i,t,t);return a.wrapS=an,a.wrapT=an,a.needsUpdate=!0,a}function OR(e){let t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,r=Array(n).fill(0),i=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)i===-1&&a===t?(a=t-2,i=0):(a===t&&(a=0),i<0&&(i=t-1)),r[i*t+a]===0?(r[i*t+a]=e++,a++,i--):(a-=2,i++);return r}var kR,AR,jR,MR=t((()=>{J(),kR={name:`GTAOShader`,defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new z},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new V},cameraProjectionMatrixInverse:{value:new V},cameraWorldMatrix:{value:new V},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new B(-1,-1,-1)},sceneBoxMax:{value:new B(1,1,1)}},vertexShader:`
|
|
5945
6194
|
|
|
5946
6195
|
varying vec2 vUv;
|
|
5947
6196
|
|
|
@@ -6141,7 +6390,7 @@ void main() {
|
|
|
6141
6390
|
ao = pow(ao, scale);
|
|
6142
6391
|
|
|
6143
6392
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
6144
|
-
}`},
|
|
6393
|
+
}`},AR={name:`GTAODepthShader`,defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
|
|
6145
6394
|
varying vec2 vUv;
|
|
6146
6395
|
|
|
6147
6396
|
void main() {
|
|
@@ -6169,7 +6418,7 @@ void main() {
|
|
|
6169
6418
|
float depth = getLinearDepth( vUv );
|
|
6170
6419
|
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
|
6171
6420
|
|
|
6172
|
-
}`},
|
|
6421
|
+
}`},jR={name:`GTAOBlendShader`,uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
|
|
6173
6422
|
varying vec2 vUv;
|
|
6174
6423
|
|
|
6175
6424
|
void main() {
|
|
@@ -6183,7 +6432,7 @@ void main() {
|
|
|
6183
6432
|
void main() {
|
|
6184
6433
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
6185
6434
|
gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
|
|
6186
|
-
}`}}));function
|
|
6435
|
+
}`}}));function NR(e,t,n){let r=PR(e,t,n),i=`vec3[SAMPLES](`;for(let t=0;t<e;t++){let n=r[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?`,`:`)`}`}return i}function PR(e,t,n){let r=[];for(let i=0;i<e;i++){let a=2*Math.PI*t*i/e,o=(i/(e-1))**n;r.push(new B(Math.cos(a),Math.sin(a),o))}return r}var FR,IR=t((()=>{J(),FR={name:`PoissonDenoiseShader`,defines:{SAMPLES:16,SAMPLE_VECTORS:NR(16,2,1),NORMAL_VECTOR_TYPE:1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new z},cameraProjectionMatrixInverse:{value:new V},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
|
|
6187
6436
|
|
|
6188
6437
|
varying vec2 vUv;
|
|
6189
6438
|
|
|
@@ -6324,7 +6573,7 @@ void main() {
|
|
|
6324
6573
|
denoised /= totalWeight;
|
|
6325
6574
|
}
|
|
6326
6575
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
6327
|
-
}`}})),
|
|
6576
|
+
}`}})),LR,RR=t((()=>{LR={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
6328
6577
|
|
|
6329
6578
|
varying vec2 vUv;
|
|
6330
6579
|
|
|
@@ -6347,9 +6596,9 @@ void main() {
|
|
|
6347
6596
|
gl_FragColor = opacity * texel;
|
|
6348
6597
|
|
|
6349
6598
|
|
|
6350
|
-
}`}})),fR,pR=t((()=>{fR=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,r,i,a=.5*(Math.sqrt(3)-1),o=(e+t)*a,s=Math.floor(e+o),c=Math.floor(t+o),l=(3-Math.sqrt(3))/6,u=(s+c)*l,d=s-u,f=c-u,p=e-d,m=t-f,h,g;p>m?(h=1,g=0):(h=0,g=1);let _=p-h+l,v=m-g+l,y=p-1+2*l,b=m-1+2*l,x=s&255,S=c&255,C=this.perm[x+this.perm[S]]%12,w=this.perm[x+h+this.perm[S+g]]%12,T=this.perm[x+1+this.perm[S+1]]%12,E=.5-p*p-m*m;E<0?n=0:(E*=E,n=E*E*this._dot(this.grad3[C],p,m));let D=.5-_*_-v*v;D<0?r=0:(D*=D,r=D*D*this._dot(this.grad3[w],_,v));let O=.5-y*y-b*b;return O<0?i=0:(O*=O,i=O*O*this._dot(this.grad3[T],y,b)),70*(n+r+i)}noise3d(e,t,n){let r,i,a,o,s=(e+t+n)*(1/3),c=Math.floor(e+s),l=Math.floor(t+s),u=Math.floor(n+s),d=1/6,f=(c+l+u)*d,p=c-f,m=l-f,h=u-f,g=e-p,_=t-m,v=n-h,y,b,x,S,C,w;g>=_?_>=v?(y=1,b=0,x=0,S=1,C=1,w=0):g>=v?(y=1,b=0,x=0,S=1,C=0,w=1):(y=0,b=0,x=1,S=1,C=0,w=1):_<v?(y=0,b=0,x=1,S=0,C=1,w=1):g<v?(y=0,b=1,x=0,S=0,C=1,w=1):(y=0,b=1,x=0,S=1,C=1,w=0);let T=g-y+d,E=_-b+d,D=v-x+d,O=g-S+2*d,k=_-C+2*d,A=v-w+2*d,j=g-1+3*d,M=_-1+3*d,N=v-1+3*d,P=c&255,F=l&255,ee=u&255,te=this.perm[P+this.perm[F+this.perm[ee]]]%12,ne=this.perm[P+y+this.perm[F+b+this.perm[ee+x]]]%12,re=this.perm[P+S+this.perm[F+C+this.perm[ee+w]]]%12,ie=this.perm[P+1+this.perm[F+1+this.perm[ee+1]]]%12,ae=.6-g*g-_*_-v*v;ae<0?r=0:(ae*=ae,r=ae*ae*this._dot3(this.grad3[te],g,_,v));let I=.6-T*T-E*E-D*D;I<0?i=0:(I*=I,i=I*I*this._dot3(this.grad3[ne],T,E,D));let oe=.6-O*O-k*k-A*A;oe<0?a=0:(oe*=oe,a=oe*oe*this._dot3(this.grad3[re],O,k,A));let se=.6-j*j-M*M-N*N;return se<0?o=0:(se*=se,o=se*se*this._dot3(this.grad3[ie],j,M,N)),32*(r+i+a+o)}noise4d(e,t,n,r){let i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20,l,u,d,f,p,m=(e+t+n+r)*s,h=Math.floor(e+m),g=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),y=(h+g+_+v)*c,b=h-y,x=g-y,S=_-y,C=v-y,w=e-b,T=t-x,E=n-S,D=r-C,O=w>T?32:0,k=w>E?16:0,A=T>E?8:0,j=w>D?4:0,M=T>D?2:0,N=+(E>D),P=O+k+A+j+M+N,F=+(a[P][0]>=3),ee=+(a[P][1]>=3),te=+(a[P][2]>=3),ne=+(a[P][3]>=3),re=+(a[P][0]>=2),ie=+(a[P][1]>=2),ae=+(a[P][2]>=2),I=+(a[P][3]>=2),oe=+(a[P][0]>=1),se=+(a[P][1]>=1),ce=+(a[P][2]>=1),le=+(a[P][3]>=1),ue=w-F+c,de=T-ee+c,fe=E-te+c,pe=D-ne+c,me=w-re+2*c,he=T-ie+2*c,ge=E-ae+2*c,_e=D-I+2*c,ve=w-oe+3*c,ye=T-se+3*c,be=E-ce+3*c,xe=D-le+3*c,Se=w-1+4*c,Ce=T-1+4*c,we=E-1+4*c,Te=D-1+4*c,Ee=h&255,L=g&255,De=_&255,Oe=v&255,ke=o[Ee+o[L+o[De+o[Oe]]]]%32,R=o[Ee+F+o[L+ee+o[De+te+o[Oe+ne]]]]%32,Ae=o[Ee+re+o[L+ie+o[De+ae+o[Oe+I]]]]%32,je=o[Ee+oe+o[L+se+o[De+ce+o[Oe+le]]]]%32,Me=o[Ee+1+o[L+1+o[De+1+o[Oe+1]]]]%32,Ne=.6-w*w-T*T-E*E-D*D;Ne<0?l=0:(Ne*=Ne,l=Ne*Ne*this._dot4(i[ke],w,T,E,D));let Pe=.6-ue*ue-de*de-fe*fe-pe*pe;Pe<0?u=0:(Pe*=Pe,u=Pe*Pe*this._dot4(i[R],ue,de,fe,pe));let Fe=.6-me*me-he*he-ge*ge-_e*_e;Fe<0?d=0:(Fe*=Fe,d=Fe*Fe*this._dot4(i[Ae],me,he,ge,_e));let Ie=.6-ve*ve-ye*ye-be*be-xe*xe;Ie<0?f=0:(Ie*=Ie,f=Ie*Ie*this._dot4(i[je],ve,ye,be,xe));let Le=.6-Se*Se-Ce*Ce-we*we-Te*Te;return Le<0?p=0:(Le*=Le,p=Le*Le*this._dot4(i[Me],Se,Ce,we,Te)),27*(l+u+d+f+p)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}_dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}}})),mR,hR=t((()=>{J(),ML(),aR(),lR(),dR(),pR(),mR=class e extends DL{constructor(e,t,n=512,r=512,i,a,o){super(),this.width=n,this.height=r,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=eR(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Hi(this.width,this.height,{type:Tn,depthBuffer:!1}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new Bl({defines:Object.assign({},nR.defines),uniforms:Ll.clone(nR.uniforms),vertexShader:nR.vertexShader,fragmentShader:nR.fragmentShader,blending:0,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=+!!this.camera.isPerspectiveCamera,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Kl,this.normalMaterial.blending=0,this.pdMaterial=new Bl({defines:Object.assign({},cR.defines),uniforms:Ll.clone(cR.uniforms),vertexShader:cR.vertexShader,fragmentShader:cR.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new Bl({defines:Object.assign({},rR.defines),uniforms:Ll.clone(rR.uniforms),vertexShader:rR.vertexShader,fragmentShader:rR.fragmentShader,blending:0}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new Bl({uniforms:Ll.clone(uR.uniforms),vertexShader:uR.vertexShader,fragmentShader:uR.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this.blendMaterial=new Bl({uniforms:Ll.clone(iR.uniforms),vertexShader:iR.vertexShader,fragmentShader:iR.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:5,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this._fsQuad=new jL(null),this._originalClearColor=new H,this.setGBuffer(i?i.depthTexture:void 0,i?i.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget&&this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){if(e!==void 0)this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1;else{if(this.normalRenderTarget===void 0){let e=new Rc;e.format=Fn,e.type=On,this.normalRenderTarget=new Hi(this.width,this.height,{minFilter:cn,magFilter:cn,type:Tn,depthTexture:e})}this.depthTexture=this.normalRenderTarget.depthTexture,this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0}let n=+!!this.normalTexture;this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.needsUpdate=!0,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.needsUpdate=!0,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&+!!e.screenSpaceRadius!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=+!!e.screenSpaceRadius,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=oR(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,n,r){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case e.OUTPUT.Off:break;case e.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalTexture||null,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(t,this.blendMaterial,this.renderToScreen?null:n);break;default:console.warn(`THREE.GTAOPass: Unknown output type.`)}}_renderPass(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(e){(e.isPoints||e.isLine||e.isLine2)&&e.visible&&(e.visible=!1,t.push(e))})}_restoreVisibility(){let e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){let t=new fR,n=e*e*4,r=new Uint8Array(n);for(let n=0;n<e;n++)for(let i=0;i<e;i++){let a=n,o=i;r[(n*e+i)*4]=(t.noise(a,o)*.5+.5)*255,r[(n*e+i)*4+1]=(t.noise(a+e,o)*.5+.5)*255,r[(n*e+i)*4+2]=(t.noise(a,o+e)*.5+.5)*255,r[(n*e+i)*4+3]=(t.noise(a+e,o+e)*.5+.5)*255}let i=new As(r,e,e,Nn,vn);return i.wrapS=an,i.wrapT=an,i.needsUpdate=!0,i}},mR.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5}}));function gR(e,t){let n=t.quality.effectScale,r=t.gbuffer(),i=()=>Math.max(1,Math.round(t.width*n)),a=()=>Math.max(1,Math.round(t.height*n)),o=new mR(t.scene,t.camera,i(),a(),{depthTexture:r.depthTexture,normalTexture:r.normalTexture});o.updateGtaoMaterial({radius:Q(e.radius,.6),thickness:Q(e.thickness,1),distanceExponent:1.5,distanceFallOff:Q(e.falloff,1),scale:1,samples:t.quality.aoSamples}),o.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:8,rings:2,samples:t.quality.tier===`low`?8:16}),o.output=mR.OUTPUT.Off;let s=o;s.pdNoiseTexture.dispose(),s.pdNoiseTexture=WL(64,7),s.pdMaterial.uniforms.tNoise.value=s.pdNoiseTexture;let c={tDiffuse:{value:null},tAo:{value:s.pdRenderTarget.texture},tDepth:{value:r.depthTexture},tNormal:{value:r.normalTexture},uAoRes:{value:new z(i(),a())},uIntensity:{value:Math.min(2,Q(e.intensity,1))},...zL()},l=new JL(VL(`uniform sampler2D tDiffuse; uniform sampler2D tAo; uniform sampler2D tDepth; uniform sampler2D tNormal; uniform vec2 uAoRes; uniform float uIntensity;
|
|
6599
|
+
}`}})),zR,BR=t((()=>{zR=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,r,i,a=.5*(Math.sqrt(3)-1),o=(e+t)*a,s=Math.floor(e+o),c=Math.floor(t+o),l=(3-Math.sqrt(3))/6,u=(s+c)*l,d=s-u,f=c-u,p=e-d,m=t-f,h,g;p>m?(h=1,g=0):(h=0,g=1);let _=p-h+l,v=m-g+l,y=p-1+2*l,b=m-1+2*l,x=s&255,S=c&255,C=this.perm[x+this.perm[S]]%12,w=this.perm[x+h+this.perm[S+g]]%12,T=this.perm[x+1+this.perm[S+1]]%12,E=.5-p*p-m*m;E<0?n=0:(E*=E,n=E*E*this._dot(this.grad3[C],p,m));let D=.5-_*_-v*v;D<0?r=0:(D*=D,r=D*D*this._dot(this.grad3[w],_,v));let O=.5-y*y-b*b;return O<0?i=0:(O*=O,i=O*O*this._dot(this.grad3[T],y,b)),70*(n+r+i)}noise3d(e,t,n){let r,i,a,o,s=(e+t+n)*(1/3),c=Math.floor(e+s),l=Math.floor(t+s),u=Math.floor(n+s),d=1/6,f=(c+l+u)*d,p=c-f,m=l-f,h=u-f,g=e-p,_=t-m,v=n-h,y,b,x,S,C,w;g>=_?_>=v?(y=1,b=0,x=0,S=1,C=1,w=0):g>=v?(y=1,b=0,x=0,S=1,C=0,w=1):(y=0,b=0,x=1,S=1,C=0,w=1):_<v?(y=0,b=0,x=1,S=0,C=1,w=1):g<v?(y=0,b=1,x=0,S=0,C=1,w=1):(y=0,b=1,x=0,S=1,C=1,w=0);let T=g-y+d,E=_-b+d,D=v-x+d,O=g-S+2*d,k=_-C+2*d,A=v-w+2*d,j=g-1+3*d,M=_-1+3*d,N=v-1+3*d,P=c&255,F=l&255,ee=u&255,te=this.perm[P+this.perm[F+this.perm[ee]]]%12,ne=this.perm[P+y+this.perm[F+b+this.perm[ee+x]]]%12,re=this.perm[P+S+this.perm[F+C+this.perm[ee+w]]]%12,ie=this.perm[P+1+this.perm[F+1+this.perm[ee+1]]]%12,ae=.6-g*g-_*_-v*v;ae<0?r=0:(ae*=ae,r=ae*ae*this._dot3(this.grad3[te],g,_,v));let I=.6-T*T-E*E-D*D;I<0?i=0:(I*=I,i=I*I*this._dot3(this.grad3[ne],T,E,D));let oe=.6-O*O-k*k-A*A;oe<0?a=0:(oe*=oe,a=oe*oe*this._dot3(this.grad3[re],O,k,A));let se=.6-j*j-M*M-N*N;return se<0?o=0:(se*=se,o=se*se*this._dot3(this.grad3[ie],j,M,N)),32*(r+i+a+o)}noise4d(e,t,n,r){let i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20,l,u,d,f,p,m=(e+t+n+r)*s,h=Math.floor(e+m),g=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),y=(h+g+_+v)*c,b=h-y,x=g-y,S=_-y,C=v-y,w=e-b,T=t-x,E=n-S,D=r-C,O=w>T?32:0,k=w>E?16:0,A=T>E?8:0,j=w>D?4:0,M=T>D?2:0,N=+(E>D),P=O+k+A+j+M+N,F=+(a[P][0]>=3),ee=+(a[P][1]>=3),te=+(a[P][2]>=3),ne=+(a[P][3]>=3),re=+(a[P][0]>=2),ie=+(a[P][1]>=2),ae=+(a[P][2]>=2),I=+(a[P][3]>=2),oe=+(a[P][0]>=1),se=+(a[P][1]>=1),ce=+(a[P][2]>=1),le=+(a[P][3]>=1),ue=w-F+c,de=T-ee+c,fe=E-te+c,pe=D-ne+c,me=w-re+2*c,he=T-ie+2*c,ge=E-ae+2*c,_e=D-I+2*c,ve=w-oe+3*c,ye=T-se+3*c,be=E-ce+3*c,xe=D-le+3*c,Se=w-1+4*c,Ce=T-1+4*c,we=E-1+4*c,Te=D-1+4*c,Ee=h&255,L=g&255,De=_&255,Oe=v&255,ke=o[Ee+o[L+o[De+o[Oe]]]]%32,R=o[Ee+F+o[L+ee+o[De+te+o[Oe+ne]]]]%32,Ae=o[Ee+re+o[L+ie+o[De+ae+o[Oe+I]]]]%32,je=o[Ee+oe+o[L+se+o[De+ce+o[Oe+le]]]]%32,Me=o[Ee+1+o[L+1+o[De+1+o[Oe+1]]]]%32,Ne=.6-w*w-T*T-E*E-D*D;Ne<0?l=0:(Ne*=Ne,l=Ne*Ne*this._dot4(i[ke],w,T,E,D));let Pe=.6-ue*ue-de*de-fe*fe-pe*pe;Pe<0?u=0:(Pe*=Pe,u=Pe*Pe*this._dot4(i[R],ue,de,fe,pe));let Fe=.6-me*me-he*he-ge*ge-_e*_e;Fe<0?d=0:(Fe*=Fe,d=Fe*Fe*this._dot4(i[Ae],me,he,ge,_e));let Ie=.6-ve*ve-ye*ye-be*be-xe*xe;Ie<0?f=0:(Ie*=Ie,f=Ie*Ie*this._dot4(i[je],ve,ye,be,xe));let Le=.6-Se*Se-Ce*Ce-we*we-Te*Te;return Le<0?p=0:(Le*=Le,p=Le*Le*this._dot4(i[Me],Se,Ce,we,Te)),27*(l+u+d+f+p)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}_dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}}})),VR,HR=t((()=>{J(),aR(),MR(),IR(),RR(),BR(),VR=class e extends eR{constructor(e,t,n=512,r=512,i,a,o){super(),this.width=n,this.height=r,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=DR(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Hi(this.width,this.height,{type:Tn,depthBuffer:!1}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new Bl({defines:Object.assign({},kR.defines),uniforms:Ll.clone(kR.uniforms),vertexShader:kR.vertexShader,fragmentShader:kR.fragmentShader,blending:0,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=+!!this.camera.isPerspectiveCamera,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Kl,this.normalMaterial.blending=0,this.pdMaterial=new Bl({defines:Object.assign({},FR.defines),uniforms:Ll.clone(FR.uniforms),vertexShader:FR.vertexShader,fragmentShader:FR.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new Bl({defines:Object.assign({},AR.defines),uniforms:Ll.clone(AR.uniforms),vertexShader:AR.vertexShader,fragmentShader:AR.fragmentShader,blending:0}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new Bl({uniforms:Ll.clone(LR.uniforms),vertexShader:LR.vertexShader,fragmentShader:LR.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this.blendMaterial=new Bl({uniforms:Ll.clone(jR.uniforms),vertexShader:jR.vertexShader,fragmentShader:jR.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:5,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this._fsQuad=new iR(null),this._originalClearColor=new H,this.setGBuffer(i?i.depthTexture:void 0,i?i.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget&&this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){if(e!==void 0)this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1;else{if(this.normalRenderTarget===void 0){let e=new Rc;e.format=Fn,e.type=On,this.normalRenderTarget=new Hi(this.width,this.height,{minFilter:cn,magFilter:cn,type:Tn,depthTexture:e})}this.depthTexture=this.normalRenderTarget.depthTexture,this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0}let n=+!!this.normalTexture;this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.needsUpdate=!0,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.needsUpdate=!0,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&+!!e.screenSpaceRadius!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=+!!e.screenSpaceRadius,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=NR(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,n,r){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case e.OUTPUT.Off:break;case e.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalTexture||null,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(t,this.blendMaterial,this.renderToScreen?null:n);break;default:console.warn(`THREE.GTAOPass: Unknown output type.`)}}_renderPass(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(e){(e.isPoints||e.isLine||e.isLine2)&&e.visible&&(e.visible=!1,t.push(e))})}_restoreVisibility(){let e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){let t=new zR,n=e*e*4,r=new Uint8Array(n);for(let n=0;n<e;n++)for(let i=0;i<e;i++){let a=n,o=i;r[(n*e+i)*4]=(t.noise(a,o)*.5+.5)*255,r[(n*e+i)*4+1]=(t.noise(a+e,o)*.5+.5)*255,r[(n*e+i)*4+2]=(t.noise(a,o+e)*.5+.5)*255,r[(n*e+i)*4+3]=(t.noise(a+e,o+e)*.5+.5)*255}let i=new As(r,e,e,Nn,vn);return i.wrapS=an,i.wrapT=an,i.needsUpdate=!0,i}},VR.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5}}));function UR(e,t){let n=t.quality.effectScale,r=t.gbuffer(),i=()=>Math.max(1,Math.round(t.width*n)),a=()=>Math.max(1,Math.round(t.height*n)),o=new VR(t.scene,t.camera,i(),a(),{depthTexture:r.depthTexture,normalTexture:r.normalTexture});o.updateGtaoMaterial({radius:Q(e.radius,.6),thickness:Q(e.thickness,1),distanceExponent:1.5,distanceFallOff:Q(e.falloff,1),scale:1,samples:t.quality.aoSamples}),o.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:8,rings:2,samples:t.quality.tier===`low`?8:16}),o.output=VR.OUTPUT.Off;let s=o;s.pdNoiseTexture.dispose(),s.pdNoiseTexture=_R(64,7),s.pdMaterial.uniforms.tNoise.value=s.pdNoiseTexture;let c={tDiffuse:{value:null},tAo:{value:s.pdRenderTarget.texture},tDepth:{value:r.depthTexture},tNormal:{value:r.normalTexture},uAoRes:{value:new z(i(),a())},uIntensity:{value:Math.min(2,Q(e.intensity,1))},...fR()},l=new xR(mR(`uniform sampler2D tDiffuse; uniform sampler2D tAo; uniform sampler2D tDepth; uniform sampler2D tNormal; uniform vec2 uAoRes; uniform float uIntensity;
|
|
6351
6600
|
varying vec2 vUv;
|
|
6352
|
-
${
|
|
6601
|
+
${bR}
|
|
6353
6602
|
void main() {
|
|
6354
6603
|
vec4 c = texture2D(tDiffuse, vUv);
|
|
6355
6604
|
float n = texture2D(tNormal, vUv).a;
|
|
@@ -6368,10 +6617,10 @@ void main() {
|
|
|
6368
6617
|
float ground = step(0.25, n) * (1.0 - step(0.75, n));
|
|
6369
6618
|
float cover = ground * (1.0 - c.a) * (1.0 - ao);
|
|
6370
6619
|
gl_FragColor = vec4(c.rgb * ao, c.a + cover);
|
|
6371
|
-
}`,c)),u=l,d=l.render.bind(l);u.render=(...e)=>{let n=e[0];t.gbuffer().ensure(n,t.scene,t.camera,t.frame()),
|
|
6620
|
+
}`,c)),u=l,d=l.render.bind(l);u.render=(...e)=>{let n=e[0];t.gbuffer().ensure(n,t.scene,t.camera,t.frame()),pR(c,t.camera),o.render(n,e[1],e[2],0,!1),d(...e)};let f=l.dispose.bind(l);return u.dispose=()=>{f(),o.dispose()},{pass:u,setSize:(e,t)=>{let r=Math.max(1,Math.round(e*n)),i=Math.max(1,Math.round(t*n));o.setSize(r,i),c.uAoRes.value.set(r,i)},set(e,t){typeof t==`number`&&(e===`intensity`?c.uIntensity.value=Math.min(2,t):e===`radius`?o.updateGtaoMaterial({radius:t}):e===`thickness`?o.updateGtaoMaterial({thickness:t}):e===`falloff`&&o.updateGtaoMaterial({distanceFallOff:t}))}}}function WR(e,t){let n={tDiffuse:{value:null},tNormal:{value:t.gbuffer().normalTexture},tDepth:{value:t.gbuffer().depthTexture},uResolution:{value:new z(t.width,t.height)},uColor:{value:AS(typeof e.color==`string`?e.color:`#000000`)},uThickness:{value:Q(e.thickness,1)*t.pixelRatio},...fR()},r=new xR(mR(`uniform sampler2D tDiffuse; uniform sampler2D tNormal; uniform sampler2D tDepth;
|
|
6372
6621
|
uniform vec2 uResolution; uniform vec3 uColor; uniform float uThickness;
|
|
6373
6622
|
varying vec2 vUv;
|
|
6374
|
-
${
|
|
6623
|
+
${bR}
|
|
6375
6624
|
float lin(vec2 uv) { return a3dViewZ(texture2D(tDepth, uv).x); }
|
|
6376
6625
|
void main() {
|
|
6377
6626
|
vec4 base = texture2D(tDiffuse, vUv);
|
|
@@ -6384,9 +6633,9 @@ void main() {
|
|
|
6384
6633
|
float nd = length(n1.xyz - n0.xyz) + length(n2.xyz - n0.xyz) + length(n3.xyz - n0.xyz) + length(n4.xyz - n0.xyz);
|
|
6385
6634
|
float edge = obj * max(smoothstep(0.04, 0.12, dd / max(d0, 1e-3)), smoothstep(0.5, 0.9, nd));
|
|
6386
6635
|
gl_FragColor = vec4(mix(base.rgb, uColor, edge), max(base.a, edge));
|
|
6387
|
-
}`,n)),i=r.render.bind(r);return r.render=(...e)=>{let r=e[0];t.gbuffer().ensure(r,t.scene,t.camera,t.frame()),
|
|
6636
|
+
}`,n)),i=r.render.bind(r);return r.render=(...e)=>{let r=e[0];t.gbuffer().ensure(r,t.scene,t.camera,t.frame()),pR(n,t.camera),i(...e)},{pass:r,setSize:(e,t)=>n.uResolution.value.set(e,t),set(e,r){e===`color`&&typeof r==`string`?n.uColor.value=AS(r):e===`thickness`&&typeof r==`number`&&(n.uThickness.value=r*t.pixelRatio)}}}function GR(e,t){let n=new XR(t,e);return{pass:n,update:()=>n.update(),set:(e,t)=>n.set(e,t)}}function KR(e,t){let n={tDiffuse:{value:null},tDepth:{value:t.gbuffer().depthTexture},uRes:{value:new z(t.width,t.height)},uFocus:{value:Q(e.focus,8)},uAperture:{value:Q(e.aperture,.002)},uMaxBlur:{value:Q(e.maxblur,.01)},...fR()},r=new xR(mR(`uniform sampler2D tDiffuse; uniform sampler2D tDepth; uniform vec2 uRes; uniform float uFocus; uniform float uAperture; uniform float uMaxBlur;
|
|
6388
6637
|
varying vec2 vUv;
|
|
6389
|
-
${
|
|
6638
|
+
${bR}
|
|
6390
6639
|
const float GOLDEN = 2.39996323;
|
|
6391
6640
|
float cocPx(float z) { return clamp(abs(z - uFocus) * uAperture, 0.0, uMaxBlur) * uRes.x; }
|
|
6392
6641
|
void main() {
|
|
@@ -6411,9 +6660,9 @@ void main() {
|
|
|
6411
6660
|
tot += 1.0;
|
|
6412
6661
|
}
|
|
6413
6662
|
gl_FragColor = acc / tot;
|
|
6414
|
-
}`,n,{SAMPLES:t.quality.dofSamples})),i=typeof e.focusOn==`string`?e.focusOn:null,a=new Wa,o=new B,s=new B,c=new B,l=r.render.bind(r);return r.render=(...e)=>{let r=e[0];if(t.gbuffer().ensure(r,t.scene,t.camera,t.frame()),
|
|
6663
|
+
}`,n,{SAMPLES:t.quality.dofSamples})),i=typeof e.focusOn==`string`?e.focusOn:null,a=new Wa,o=new B,s=new B,c=new B,l=r.render.bind(r);return r.render=(...e)=>{let r=e[0];if(t.gbuffer().ensure(r,t.scene,t.camera,t.frame()),pR(n,t.camera),i){let e=t.scene.getObjectByName(i);e&&(a.setFromObject(e),a.isEmpty()||(a.getCenter(o),t.camera.getWorldPosition(c),t.camera.getWorldDirection(s),n.uFocus.value=Math.max(t.camera.near,o.sub(c).dot(s))))}l(...e)},{pass:r,setSize:(e,t)=>n.uRes.value.set(e,t),set(e,t){e===`focusOn`&&(i=typeof t==`string`&&t?t:null),typeof t==`number`&&(e===`focus`?(n.uFocus.value=t,i=null):e===`aperture`?n.uAperture.value=t:e===`maxblur`&&(n.uMaxBlur.value=t))}}}function qR(e,t){let n=t.quality.tier===`low`||t.quality.tier===`medium`?.5:1,r=new $R(e,t.width,t.height,n);return{pass:r,setSize:(e,t)=>r.setSize(e,t),set(e,t){typeof t==`number`&&(e===`strength`?r.strength=t:e===`radius`?r.radius=t:e===`threshold`?r.threshold=t:e===`smoothing`&&(r.smoothing=t))}}}function JR(e,t){let n=new ez(e,t.width,t.height);return{pass:n,set:(e,t)=>n.set(e,t)}}var YR,XR,ZR,QR,$R,ez,tz=t((()=>{J(),HR(),aR(),zS(),CR(),YR=`float a3dIgn(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }`,XR=class extends eR{rt;mask;rays;rays2;maskMat;raysMat;fineMat;compMat;quad=new iR;srcColor=new H;visible=1;onScreen=0;d;constructor(e,t){super(),this.rt=e;let n=this.d={...t},r=e.quality.effectScale,i={minFilter:pn,magFilter:pn};this.mask=hR(e.width*r,e.height*r,i),this.rays=hR(e.width*r,e.height*r,i),this.rays2=hR(e.width*r,e.height*r,i);let a={value:new z(.5,1.1)},o={value:.85};this.maskMat=mR(`uniform sampler2D tDiffuse; uniform sampler2D tNormal; uniform vec2 uSrc; uniform vec3 uColor; uniform float uSize; uniform float uAspect;
|
|
6415
6664
|
varying vec2 vUv;
|
|
6416
|
-
${
|
|
6665
|
+
${yR}
|
|
6417
6666
|
void main() {
|
|
6418
6667
|
float far = 1.0 - step(0.25, texture2D(tNormal, vUv).a);
|
|
6419
6668
|
vec3 c = texture2D(tDiffuse, vUv).rgb;
|
|
@@ -6427,9 +6676,9 @@ void main() {
|
|
|
6427
6676
|
// Soft-compressed (≤ 2): a low sun's hot halo and bright fog must not flood the rays.
|
|
6428
6677
|
vec3 sky = c / max(l, 1e-3) * (l / (1.0 + l * 0.5)) * (0.35 + smoothstep(0.2, 1.5, l)) * wide;
|
|
6429
6678
|
gl_FragColor = vec4(far * (uColor * glow * 1.5 + sky), far * wide);
|
|
6430
|
-
}`,{tDiffuse:{value:null},tNormal:{value:e.gbuffer().normalTexture},uSrc:a,uColor:{value:new H},uSize:{value:.12},uAspect:{value:1}}),this.raysMat=
|
|
6679
|
+
}`,{tDiffuse:{value:null},tNormal:{value:e.gbuffer().normalTexture},uSrc:a,uColor:{value:new H},uSize:{value:.12},uAspect:{value:1}}),this.raysMat=mR(`uniform sampler2D tDiffuse; uniform vec2 uSrc; uniform float uLength; uniform float uDecay; uniform float uSize; uniform float uAspect;
|
|
6431
6680
|
varying vec2 vUv;
|
|
6432
|
-
${
|
|
6681
|
+
${YR}
|
|
6433
6682
|
void main() {
|
|
6434
6683
|
vec2 delta = (vUv - uSrc) * uLength / float(TAPS);
|
|
6435
6684
|
// Per-pixel start offset (interleaved gradient noise: deterministic,
|
|
@@ -6455,9 +6704,9 @@ void main() {
|
|
|
6455
6704
|
float open = acc.a / max(expect, 1e-4);
|
|
6456
6705
|
open = mix(1.0, clamp(open, 0.0, 1.0), smoothstep(0.0, 0.08, expect / max(tot, 1e-4)));
|
|
6457
6706
|
gl_FragColor = vec4(acc.rgb / max(tot, 1e-4), open);
|
|
6458
|
-
}`,{tDiffuse:{value:null},uSrc:a,uLength:o,uDecay:{value:.96},uSize:{value:.1},uAspect:{value:1}},{TAPS:Math.max(8,Math.round(e.quality.rays/2))}),this.fineMat=
|
|
6707
|
+
}`,{tDiffuse:{value:null},uSrc:a,uLength:o,uDecay:{value:.96},uSize:{value:.1},uAspect:{value:1}},{TAPS:Math.max(8,Math.round(e.quality.rays/2))}),this.fineMat=mR(`uniform sampler2D tDiffuse; uniform vec2 uSrc; uniform float uLength;
|
|
6459
6708
|
varying vec2 vUv;
|
|
6460
|
-
${
|
|
6709
|
+
${YR}
|
|
6461
6710
|
void main() {
|
|
6462
6711
|
vec2 delta = (vUv - uSrc) * uLength / float(COARSE * 8);
|
|
6463
6712
|
vec4 acc = vec4(0.0);
|
|
@@ -6471,7 +6720,7 @@ void main() {
|
|
|
6471
6720
|
acc += texture2D(tDiffuse, p + side * (mod(float(i), 2.0) - 0.5));
|
|
6472
6721
|
}
|
|
6473
6722
|
gl_FragColor = acc / 8.0;
|
|
6474
|
-
}`,{tDiffuse:{value:null},uSrc:a,uLength:o},{COARSE:Math.max(8,Math.round(e.quality.rays/2))}),this.compMat=
|
|
6723
|
+
}`,{tDiffuse:{value:null},uSrc:a,uLength:o},{COARSE:Math.max(8,Math.round(e.quality.rays/2))}),this.compMat=mR(`uniform sampler2D tDiffuse; uniform sampler2D tRays; uniform sampler2D tNormal; uniform float uIntensity; uniform float uShadow;
|
|
6475
6724
|
varying vec2 vUv;
|
|
6476
6725
|
void main() {
|
|
6477
6726
|
vec4 c = texture2D(tDiffuse, vUv);
|
|
@@ -6483,9 +6732,9 @@ void main() {
|
|
|
6483
6732
|
float sky = 1.0 - step(0.25, texture2D(tNormal, vUv).a);
|
|
6484
6733
|
float shade = mix(1.0, 0.55 + 0.45 * r.a, uShadow * mix(0.3, 1.0, sky));
|
|
6485
6734
|
gl_FragColor = vec4(c.rgb * shade + r.rgb * 1.8 * uIntensity, c.a);
|
|
6486
|
-
}`,{tDiffuse:{value:null},tRays:{value:this.rays2.texture},tNormal:{value:e.gbuffer().normalTexture},uIntensity:{value:.6},uShadow:{value:0}}),this.raysMat.uniforms.uDecay.value=Math.min(1,Math.max(.5,Q(n.decay,.96))),o.value=Math.min(1,Math.max(0,Q(n.length,.85))),this.maskMat.uniforms.uSize.value=Q(n.size,.1)}set(e,t){this.d[e]=t,typeof t==`number`&&(e===`decay`?this.raysMat.uniforms.uDecay.value=Math.min(1,Math.max(.5,t)):e===`length`?this.raysMat.uniforms.uLength.value=Math.min(1,Math.max(0,t)):e===`size`&&(this.maskMat.uniforms.uSize.value=t))}update(){let{scene:e,camera:t}=this.rt,n=typeof this.d.source==`string`?this.d.source:`auto`,r=null,i=null,a=null;if(n===`auto`||n===`sun`){let t=e.getObjectByName(`__sky`),n=t?.material?.uniforms;t?.userData.sunDir&&t.userData.sunUp?(r=t.userData.sunDir.clone(),a=t.userData.sunColor.clone()):n&&n.uSun?.value>0&&(r=n.uSunDir.value.clone(),a=n.uSunColor.value.clone())}if(!r&&n!==`sun`){let t;if(n===`auto`?e.traverse(e=>{!t&&(e.isDirectionalLight||e.isSpotLight)&&(t=e)}):t=e.getObjectByName(n),t){a=t.color.clone();let e=t.getWorldPosition(new B);if(t.isDirectionalLight){let n=t.target.getWorldPosition(new B);r=e.sub(n).normalize()}else i=e}}let o=this.maskMat.uniforms.uSrc.value,s=1;if(r||i){let e=i??t.getWorldPosition(new B).addScaledVector(r,t.far*.5),n=e.clone().applyMatrix4(t.matrixWorldInverse),a=e.clone().project(t);n.z>0&&!t.isOrthographicCamera&&(s=0),o.set(a.x*.5+.5,a.y*.5+.5);let c=Math.max(Math.abs(a.x),Math.abs(a.y));s*=Ci.clamp(2.2-c,0,1),this.onScreen=s*Ci.clamp((1.25-c)/.25,0,1)}else o.set(.5,1.15),this.onScreen=0;this.visible=s,this.srcColor.copy(typeof this.d.color==`string`?AS(this.d.color):a??new H(1,.95,.85))}setSize(e,t){let n=this.rt.quality.effectScale;for(let r of[this.mask,this.rays,this.rays2])r.setSize(Math.max(1,Math.round(e*n)),Math.max(1,Math.round(t*n)));this.maskMat.uniforms.uAspect.value=e/Math.max(1,t)}render(e,t,n){this.rt.gbuffer().ensure(e,this.rt.scene,this.rt.camera,this.rt.frame()),this.maskMat.uniforms.uAspect.value=this.raysMat.uniforms.uAspect.value=n.width/Math.max(1,n.height),this.raysMat.uniforms.uSize.value=this.maskMat.uniforms.uSize.value,this.maskMat.uniforms.tDiffuse.value=n.texture,this.maskMat.uniforms.uColor.value.copy(this.srcColor),this.quad.material=this.maskMat,e.setRenderTarget(this.mask),this.quad.render(e),this.raysMat.uniforms.tDiffuse.value=this.mask.texture,this.quad.material=this.raysMat,e.setRenderTarget(this.rays),this.quad.render(e),this.fineMat.uniforms.tDiffuse.value=this.rays.texture,this.quad.material=this.fineMat,e.setRenderTarget(this.rays2),this.quad.render(e),this.compMat.uniforms.tDiffuse.value=n.texture;let r=Q(this.d.intensity,.6);this.compMat.uniforms.uIntensity.value=r*this.visible,this.compMat.uniforms.uShadow.value=Math.min(1,r)*this.onScreen,this.quad.material=this.compMat,e.setRenderTarget(this.renderToScreen?null:t),this.quad.render(e)}dispose(){this.mask.dispose(),this.rays.dispose(),this.rays2.dispose(),this.maskMat.dispose(),this.raysMat.dispose(),this.fineMat.dispose(),this.compMat.dispose(),this.quad.dispose()}},
|
|
6735
|
+
}`,{tDiffuse:{value:null},tRays:{value:this.rays2.texture},tNormal:{value:e.gbuffer().normalTexture},uIntensity:{value:.6},uShadow:{value:0}}),this.raysMat.uniforms.uDecay.value=Math.min(1,Math.max(.5,Q(n.decay,.96))),o.value=Math.min(1,Math.max(0,Q(n.length,.85))),this.maskMat.uniforms.uSize.value=Q(n.size,.1)}set(e,t){this.d[e]=t,typeof t==`number`&&(e===`decay`?this.raysMat.uniforms.uDecay.value=Math.min(1,Math.max(.5,t)):e===`length`?this.raysMat.uniforms.uLength.value=Math.min(1,Math.max(0,t)):e===`size`&&(this.maskMat.uniforms.uSize.value=t))}update(){let{scene:e,camera:t}=this.rt,n=typeof this.d.source==`string`?this.d.source:`auto`,r=null,i=null,a=null;if(n===`auto`||n===`sun`){let t=e.getObjectByName(`__sky`),n=t?.material?.uniforms;t?.userData.sunDir&&t.userData.sunUp?(r=t.userData.sunDir.clone(),a=t.userData.sunColor.clone()):n&&n.uSun?.value>0&&(r=n.uSunDir.value.clone(),a=n.uSunColor.value.clone())}if(!r&&n!==`sun`){let t;if(n===`auto`?e.traverse(e=>{!t&&(e.isDirectionalLight||e.isSpotLight)&&(t=e)}):t=e.getObjectByName(n),t){a=t.color.clone();let e=t.getWorldPosition(new B);if(t.isDirectionalLight){let n=t.target.getWorldPosition(new B);r=e.sub(n).normalize()}else i=e}}let o=this.maskMat.uniforms.uSrc.value,s=1;if(r||i){let e=i??t.getWorldPosition(new B).addScaledVector(r,t.far*.5),n=e.clone().applyMatrix4(t.matrixWorldInverse),a=e.clone().project(t);n.z>0&&!t.isOrthographicCamera&&(s=0),o.set(a.x*.5+.5,a.y*.5+.5);let c=Math.max(Math.abs(a.x),Math.abs(a.y));s*=Ci.clamp(2.2-c,0,1),this.onScreen=s*Ci.clamp((1.25-c)/.25,0,1)}else o.set(.5,1.15),this.onScreen=0;this.visible=s,this.srcColor.copy(typeof this.d.color==`string`?AS(this.d.color):a??new H(1,.95,.85))}setSize(e,t){let n=this.rt.quality.effectScale;for(let r of[this.mask,this.rays,this.rays2])r.setSize(Math.max(1,Math.round(e*n)),Math.max(1,Math.round(t*n)));this.maskMat.uniforms.uAspect.value=e/Math.max(1,t)}render(e,t,n){this.rt.gbuffer().ensure(e,this.rt.scene,this.rt.camera,this.rt.frame()),this.maskMat.uniforms.uAspect.value=this.raysMat.uniforms.uAspect.value=n.width/Math.max(1,n.height),this.raysMat.uniforms.uSize.value=this.maskMat.uniforms.uSize.value,this.maskMat.uniforms.tDiffuse.value=n.texture,this.maskMat.uniforms.uColor.value.copy(this.srcColor),this.quad.material=this.maskMat,e.setRenderTarget(this.mask),this.quad.render(e),this.raysMat.uniforms.tDiffuse.value=this.mask.texture,this.quad.material=this.raysMat,e.setRenderTarget(this.rays),this.quad.render(e),this.fineMat.uniforms.tDiffuse.value=this.rays.texture,this.quad.material=this.fineMat,e.setRenderTarget(this.rays2),this.quad.render(e),this.compMat.uniforms.tDiffuse.value=n.texture;let r=Q(this.d.intensity,.6);this.compMat.uniforms.uIntensity.value=r*this.visible,this.compMat.uniforms.uShadow.value=Math.min(1,r)*this.onScreen,this.quad.material=this.compMat,e.setRenderTarget(this.renderToScreen?null:t),this.quad.render(e)}dispose(){this.mask.dispose(),this.rays.dispose(),this.rays2.dispose(),this.maskMat.dispose(),this.raysMat.dispose(),this.fineMat.dispose(),this.compMat.dispose(),this.quad.dispose()}},ZR=6,QR=5,$R=class extends eR{scale;down=[];up=[];preMat;downMat;upMat;compMat;quad=new iR;strength;radius;threshold;smoothing;constructor(e,t,n,r){super(),this.scale=r,this.needsSwap=!0,this.strength=Q(e.strength,.8),this.radius=Q(e.radius,.4),this.threshold=Q(e.threshold,.85),this.smoothing=Q(e.smoothing,.1);for(let e=0;e<ZR;e++)this.down.push(hR(1,1,{minFilter:pn,magFilter:pn})),e<5&&this.up.push(hR(1,1,{minFilter:pn,magFilter:pn}));this.preMat=mR(`uniform sampler2D tDiffuse; uniform vec2 uTexel; uniform float uThreshold; uniform float uKnee;
|
|
6487
6736
|
varying vec2 vUv;
|
|
6488
|
-
${
|
|
6737
|
+
${yR}
|
|
6489
6738
|
vec3 pick(vec2 uv) {
|
|
6490
6739
|
vec3 c = min(texture2D(tDiffuse, uv).rgb, vec3(64.0));
|
|
6491
6740
|
float l = a3dLuma(c);
|
|
@@ -6503,7 +6752,7 @@ void main() {
|
|
|
6503
6752
|
vec3 a = pick(vUv + vec2(-o.x, -o.y)), b = pick(vUv + vec2(o.x, -o.y)), c = pick(vUv + vec2(-o.x, o.y)), d = pick(vUv + vec2(o.x, o.y));
|
|
6504
6753
|
float wa = 1.0 / (1.0 + a3dLuma(a)), wb = 1.0 / (1.0 + a3dLuma(b)), wc = 1.0 / (1.0 + a3dLuma(c)), wd = 1.0 / (1.0 + a3dLuma(d));
|
|
6505
6754
|
gl_FragColor = vec4((a * wa + b * wb + c * wc + d * wd) / (wa + wb + wc + wd), 1.0);
|
|
6506
|
-
}`,{tDiffuse:{value:null},uTexel:{value:new z},uThreshold:{value:1},uKnee:{value:.1}}),this.downMat=
|
|
6755
|
+
}`,{tDiffuse:{value:null},uTexel:{value:new z},uThreshold:{value:1},uKnee:{value:.1}}),this.downMat=mR(`uniform sampler2D tDiffuse; uniform vec2 uTexel; varying vec2 vUv;
|
|
6507
6756
|
vec3 s(vec2 o) { return texture2D(tDiffuse, vUv + o * uTexel).rgb; }
|
|
6508
6757
|
void main() {
|
|
6509
6758
|
vec3 a = s(vec2(-2.0, 2.0)), b = s(vec2(0.0, 2.0)), c = s(vec2(2.0, 2.0));
|
|
@@ -6512,15 +6761,15 @@ void main() {
|
|
|
6512
6761
|
vec3 j = s(vec2(-1.0, 1.0)), k = s(vec2(1.0, 1.0)), l = s(vec2(-1.0, -1.0)), m = s(vec2(1.0, -1.0));
|
|
6513
6762
|
vec3 r = e * 0.125 + (a + c + g + i) * 0.03125 + (b + d + f + h) * 0.0625 + (j + k + l + m) * 0.125;
|
|
6514
6763
|
gl_FragColor = vec4(r, 1.0);
|
|
6515
|
-
}`,{tDiffuse:{value:null},uTexel:{value:new z}}),this.upMat=
|
|
6764
|
+
}`,{tDiffuse:{value:null},uTexel:{value:new z}}),this.upMat=mR(`uniform sampler2D tDiffuse; uniform sampler2D tLevel; uniform vec2 uTexel; uniform float uWeight; uniform float uCoarse; varying vec2 vUv;
|
|
6516
6765
|
vec3 s(vec2 o) { return texture2D(tDiffuse, vUv + o * uTexel).rgb; }
|
|
6517
6766
|
void main() {
|
|
6518
6767
|
vec3 t = s(vec2(0.0)) * 4.0 + (s(vec2(-1.0, 0.0)) + s(vec2(1.0, 0.0)) + s(vec2(0.0, -1.0)) + s(vec2(0.0, 1.0))) * 2.0
|
|
6519
6768
|
+ s(vec2(-1.0, -1.0)) + s(vec2(1.0, -1.0)) + s(vec2(-1.0, 1.0)) + s(vec2(1.0, 1.0));
|
|
6520
6769
|
gl_FragColor = vec4(t / 16.0 * uCoarse + texture2D(tLevel, vUv).rgb * uWeight, 1.0);
|
|
6521
|
-
}`,{tDiffuse:{value:null},tLevel:{value:null},uTexel:{value:new z},uWeight:{value:1},uCoarse:{value:1}}),this.compMat=
|
|
6522
|
-
void main() { vec4 c = texture2D(tDiffuse, vUv); gl_FragColor = vec4(c.rgb + texture2D(tBloom, vUv).rgb * uStrength, c.a); }`,{tDiffuse:{value:null},tBloom:{value:null},uStrength:{value:1}}),this.setSize(t,n)}levelWeights(){let e=Math.min(1,Math.max(0,this.radius)),t=Array.from({length:
|
|
6523
|
-
${
|
|
6770
|
+
}`,{tDiffuse:{value:null},tLevel:{value:null},uTexel:{value:new z},uWeight:{value:1},uCoarse:{value:1}}),this.compMat=mR(`uniform sampler2D tDiffuse; uniform sampler2D tBloom; uniform float uStrength; varying vec2 vUv;
|
|
6771
|
+
void main() { vec4 c = texture2D(tDiffuse, vUv); gl_FragColor = vec4(c.rgb + texture2D(tBloom, vUv).rgb * uStrength, c.a); }`,{tDiffuse:{value:null},tBloom:{value:null},uStrength:{value:1}}),this.setSize(t,n)}levelWeights(){let e=Math.min(1,Math.max(0,this.radius)),t=Array.from({length:ZR},(t,n)=>{let r=1-.8*n/5;return r*(1-e)+(1.2-r)*e}),n=t.reduce((e,t)=>e+t,0);return t.map(e=>e/n)}setSize(e,t){let n=Math.max(1,Math.round(e*this.scale*.5)),r=Math.max(1,Math.round(t*this.scale*.5));for(let e=0;e<ZR;e++)this.down[e].setSize(n,r),e<5&&this.up[e].setSize(n,r),n=Math.max(1,Math.round(n/2)),r=Math.max(1,Math.round(r/2))}draw(e,t,n){this.quad.material=t,e.setRenderTarget(n),this.quad.render(e)}render(e,t,n){let r=this.preMat.uniforms;r.tDiffuse.value=n.texture,r.uTexel.value.set(1/n.width,1/n.height),r.uThreshold.value=this.threshold,r.uKnee.value=Math.max(.001,this.smoothing*Math.max(this.threshold,.25)),this.draw(e,this.preMat,this.down[0]);let i=this.downMat.uniforms;for(let t=1;t<ZR;t++)i.tDiffuse.value=this.down[t-1].texture,i.uTexel.value.set(1/this.down[t-1].width,1/this.down[t-1].height),this.draw(e,this.downMat,this.down[t]);let a=this.levelWeights(),o=this.upMat.uniforms;for(let t=4;t>=0;t--){let n=t===4?this.down[5]:this.up[t+1];o.tDiffuse.value=n.texture,o.tLevel.value=this.down[t].texture,o.uTexel.value.set(1/n.width,1/n.height),o.uCoarse.value=t===4?a[5]:1,o.uWeight.value=a[t],this.draw(e,this.upMat,this.up[t])}let s=this.compMat.uniforms;s.tDiffuse.value=n.texture,s.tBloom.value=this.up[0].texture,s.uStrength.value=this.strength*QR,this.draw(e,this.compMat,this.renderToScreen?null:t)}dispose(){for(let e of[...this.down,...this.up])e.dispose();for(let e of[this.preMat,this.downMat,this.upMat,this.compMat])e.dispose();this.quad.dispose()}},ez=class extends eR{bright;a;b;g1;g2;brightMat;blurMat;compMat;quad=new iR;constructor(e,t,n){super();let r={minFilter:pn,magFilter:pn};this.g1=hR(Math.max(8,t/32),Math.max(8,n/32),r),this.g2=hR(Math.max(8,t/32),Math.max(8,n/32),r),this.bright=hR(t/4,n/2),this.a=hR(t/4,n/2),this.b=hR(t/4,n/2),this.brightMat=mR(`uniform sampler2D tDiffuse; uniform float uThreshold; varying vec2 vUv;
|
|
6772
|
+
${yR}
|
|
6524
6773
|
void main() {
|
|
6525
6774
|
vec3 c = texture2D(tDiffuse, vUv).rgb;
|
|
6526
6775
|
float l = a3dLuma(c);
|
|
@@ -6538,7 +6787,7 @@ void main() {
|
|
|
6538
6787
|
vec3 b = c * k;
|
|
6539
6788
|
b /= 1.0 + a3dLuma(b) / 1.5;
|
|
6540
6789
|
gl_FragColor = vec4(b * e.x * e.y, 1.0);
|
|
6541
|
-
}`,{tDiffuse:{value:null},uThreshold:{value:Q(e.threshold,1.2)}}),this.blurMat=
|
|
6790
|
+
}`,{tDiffuse:{value:null},uThreshold:{value:Q(e.threshold,1.2)}}),this.blurMat=mR(`uniform sampler2D tDiffuse; uniform vec2 uStep; uniform float uFalloff; varying vec2 vUv;
|
|
6542
6791
|
void main() {
|
|
6543
6792
|
// Exponential (not Gaussian) taps: a bright core with a long thin tail.
|
|
6544
6793
|
// Successive passes multiply the step by the tap count, so the taps of
|
|
@@ -6552,7 +6801,7 @@ void main() {
|
|
|
6552
6801
|
tot += w;
|
|
6553
6802
|
}
|
|
6554
6803
|
gl_FragColor = vec4(acc / tot, 1.0);
|
|
6555
|
-
}`,{tDiffuse:{value:null},uStep:{value:new z},uFalloff:{value:.35}}),this.compMat=
|
|
6804
|
+
}`,{tDiffuse:{value:null},uStep:{value:new z},uFalloff:{value:.35}}),this.compMat=mR(`uniform sampler2D tDiffuse; uniform sampler2D tBright; uniform sampler2D tStreak; uniform vec3 uTint;
|
|
6556
6805
|
uniform sampler2D tGhost;
|
|
6557
6806
|
uniform float uIntensity; uniform float uStreaks; uniform float uGhosts; uniform float uHalo; uniform float uAspect;
|
|
6558
6807
|
varying vec2 vUv;
|
|
@@ -6582,7 +6831,7 @@ void main() {
|
|
|
6582
6831
|
vec3 halo = vec3(texture2D(tGhost, 0.5 + hc * 0.98).r, texture2D(tGhost, huv).g, texture2D(tGhost, 0.5 + hc * 1.02).b) * hw * vec3(0.8, 0.9, 1.0);
|
|
6583
6832
|
fl += ghosts * uGhosts * 0.6 + halo * uHalo * 1.5;
|
|
6584
6833
|
gl_FragColor = vec4(c.rgb + fl * uIntensity, c.a);
|
|
6585
|
-
}`,{tDiffuse:{value:null},tBright:{value:this.bright.texture},tGhost:{value:this.g2.texture},tStreak:{value:this.a.texture},uTint:{value:AS(typeof e.tint==`string`?e.tint:`#9fc4ff`)},uIntensity:{value:Q(e.intensity,.5)},uStreaks:{value:Q(e.streaks,1)},uGhosts:{value:Q(e.ghosts,.5)},uHalo:{value:Q(e.halo,.3)},uAspect:{value:t/Math.max(1,n)}})}set(e,t){let n=this.compMat.uniforms;e===`tint`&&typeof t==`string`&&(n.uTint.value=AS(t)),typeof t==`number`&&(e===`threshold`?this.brightMat.uniforms.uThreshold.value=t:e===`intensity`?n.uIntensity.value=t:e===`streaks`?n.uStreaks.value=t:e===`ghosts`?n.uGhosts.value=t:e===`halo`&&(n.uHalo.value=t))}setSize(e,t){for(let n of[this.bright,this.a,this.b])n.setSize(Math.max(1,Math.round(e/4)),Math.max(1,Math.round(t/2)));for(let n of[this.g1,this.g2])n.setSize(Math.max(8,Math.round(e/32)),Math.max(8,Math.round(t/32)));this.compMat.uniforms.uAspect.value=e/Math.max(1,t)}draw(e,t,n){this.quad.material=t,e.setRenderTarget(n),this.quad.render(e)}render(e,t,n){this.brightMat.uniforms.tDiffuse.value=n.texture,this.draw(e,this.brightMat,this.bright);let r=1/this.bright.width,i=1/this.bright.height,a=this.bright,o=this.a;for(let[t,n,s]of[[1,0,.4],[4,0,.6],[13,0,1.2]])this.blurMat.uniforms.tDiffuse.value=a.texture,this.blurMat.uniforms.uFalloff.value=s,this.blurMat.uniforms.uStep.value.set(r*t,i*n),this.draw(e,this.blurMat,o),a=o,o=o===this.a?this.b:this.a;let s=this.blurMat.uniforms,c=1/this.g1.width,l=1/this.g1.height,u=[[this.bright,this.g1,r*4,0],[this.g1,this.g2,0,i*8],[this.g2,this.g1,c*1.5,0],[this.g1,this.g2,0,l*1.5]];for(let[t,n,r,i]of u)s.tDiffuse.value=t.texture,s.uFalloff.value=.25,s.uStep.value.set(r,i),this.draw(e,this.blurMat,n);this.compMat.uniforms.tStreak.value=a.texture,this.compMat.uniforms.tDiffuse.value=n.texture,this.draw(e,this.compMat,this.renderToScreen?null:t)}dispose(){for(let e of[this.bright,this.a,this.b,this.g1,this.g2])e.dispose();this.brightMat.dispose(),this.blurMat.dispose(),this.compMat.dispose(),this.quad.dispose()}}})),
|
|
6834
|
+
}`,{tDiffuse:{value:null},tBright:{value:this.bright.texture},tGhost:{value:this.g2.texture},tStreak:{value:this.a.texture},uTint:{value:AS(typeof e.tint==`string`?e.tint:`#9fc4ff`)},uIntensity:{value:Q(e.intensity,.5)},uStreaks:{value:Q(e.streaks,1)},uGhosts:{value:Q(e.ghosts,.5)},uHalo:{value:Q(e.halo,.3)},uAspect:{value:t/Math.max(1,n)}})}set(e,t){let n=this.compMat.uniforms;e===`tint`&&typeof t==`string`&&(n.uTint.value=AS(t)),typeof t==`number`&&(e===`threshold`?this.brightMat.uniforms.uThreshold.value=t:e===`intensity`?n.uIntensity.value=t:e===`streaks`?n.uStreaks.value=t:e===`ghosts`?n.uGhosts.value=t:e===`halo`&&(n.uHalo.value=t))}setSize(e,t){for(let n of[this.bright,this.a,this.b])n.setSize(Math.max(1,Math.round(e/4)),Math.max(1,Math.round(t/2)));for(let n of[this.g1,this.g2])n.setSize(Math.max(8,Math.round(e/32)),Math.max(8,Math.round(t/32)));this.compMat.uniforms.uAspect.value=e/Math.max(1,t)}draw(e,t,n){this.quad.material=t,e.setRenderTarget(n),this.quad.render(e)}render(e,t,n){this.brightMat.uniforms.tDiffuse.value=n.texture,this.draw(e,this.brightMat,this.bright);let r=1/this.bright.width,i=1/this.bright.height,a=this.bright,o=this.a;for(let[t,n,s]of[[1,0,.4],[4,0,.6],[13,0,1.2]])this.blurMat.uniforms.tDiffuse.value=a.texture,this.blurMat.uniforms.uFalloff.value=s,this.blurMat.uniforms.uStep.value.set(r*t,i*n),this.draw(e,this.blurMat,o),a=o,o=o===this.a?this.b:this.a;let s=this.blurMat.uniforms,c=1/this.g1.width,l=1/this.g1.height,u=[[this.bright,this.g1,r*4,0],[this.g1,this.g2,0,i*8],[this.g2,this.g1,c*1.5,0],[this.g1,this.g2,0,l*1.5]];for(let[t,n,r,i]of u)s.tDiffuse.value=t.texture,s.uFalloff.value=.25,s.uStep.value.set(r,i),this.draw(e,this.blurMat,n);this.compMat.uniforms.tStreak.value=a.texture,this.compMat.uniforms.tDiffuse.value=n.texture,this.draw(e,this.compMat,this.renderToScreen?null:t)}dispose(){for(let e of[this.bright,this.a,this.b,this.g1,this.g2])e.dispose();this.brightMat.dispose(),this.blurMat.dispose(),this.compMat.dispose(),this.quad.dispose()}}})),nz,rz,iz,az=t((()=>{J(),nz={name:`SMAAEdgesShader`,defines:{SMAA_THRESHOLD:`0.1`},uniforms:{tDiffuse:{value:null},resolution:{value:new z(1/1024,1/512)}},vertexShader:`
|
|
6586
6835
|
|
|
6587
6836
|
uniform vec2 resolution;
|
|
6588
6837
|
|
|
@@ -6666,7 +6915,7 @@ void main() {
|
|
|
6666
6915
|
|
|
6667
6916
|
gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );
|
|
6668
6917
|
|
|
6669
|
-
}`},
|
|
6918
|
+
}`},rz={name:`SMAAWeightsShader`,defines:{SMAA_MAX_SEARCH_STEPS:`8`,SMAA_AREATEX_MAX_DISTANCE:`16`,SMAA_AREATEX_PIXEL_SIZE:`( 1.0 / vec2( 160.0, 560.0 ) )`,SMAA_AREATEX_SUBTEX_SIZE:`( 1.0 / 7.0 )`},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new z(1/1024,1/512)}},vertexShader:`
|
|
6670
6919
|
|
|
6671
6920
|
uniform vec2 resolution;
|
|
6672
6921
|
|
|
@@ -6894,7 +7143,7 @@ void main() {
|
|
|
6894
7143
|
|
|
6895
7144
|
gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );
|
|
6896
7145
|
|
|
6897
|
-
}`},
|
|
7146
|
+
}`},iz={name:`SMAABlendShader`,uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new z(1/1024,1/512)}},vertexShader:`
|
|
6898
7147
|
|
|
6899
7148
|
uniform vec2 resolution;
|
|
6900
7149
|
|
|
@@ -6968,7 +7217,7 @@ void main() {
|
|
|
6968
7217
|
|
|
6969
7218
|
gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );
|
|
6970
7219
|
|
|
6971
|
-
}`}})),NR,PR=t((()=>{J(),ML(),MR(),NR=class extends DL{constructor(){super(),this._edgesRT=new Hi(1,1,{depthBuffer:!1,type:Tn}),this._edgesRT.texture.name=`SMAAPass.edges`,this._weightsRT=new Hi(1,1,{depthBuffer:!1,type:Tn}),this._weightsRT.texture.name=`SMAAPass.weights`;let e=this,t=new Image;t.src=this._getAreaTexture(),t.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new zi,this._areaTexture.name=`SMAAPass.area`,this._areaTexture.image=t,this._areaTexture.minFilter=pn,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let n=new Image;n.src=this._getSearchTexture(),n.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new zi,this._searchTexture.name=`SMAAPass.search`,this._searchTexture.image=n,this._searchTexture.magFilter=cn,this._searchTexture.minFilter=cn,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=Ll.clone(kR.uniforms),this._materialEdges=new Bl({defines:Object.assign({},kR.defines),uniforms:this._uniformsEdges,vertexShader:kR.vertexShader,fragmentShader:kR.fragmentShader}),this._uniformsWeights=Ll.clone(AR.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new Bl({defines:Object.assign({},AR.defines),uniforms:this._uniformsWeights,vertexShader:AR.vertexShader,fragmentShader:AR.fragmentShader}),this._uniformsBlend=Ll.clone(jR.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new Bl({uniforms:this._uniformsBlend,vertexShader:jR.vertexShader,fragmentShader:jR.fragmentShader}),this._fsQuad=new jL(null)}render(e,t,n){this._uniformsEdges.tDiffuse.value=n.texture,this._fsQuad.material=this._materialEdges,e.setRenderTarget(this._edgesRT),this.clear&&e.clear(),this._fsQuad.render(e),this._fsQuad.material=this._materialWeights,e.setRenderTarget(this._weightsRT),this.clear&&e.clear(),this._fsQuad.render(e),this._uniformsBlend.tColor.value=n.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this._fsQuad.render(e))}setSize(e,t){this._edgesRT.setSize(e,t),this._weightsRT.setSize(e,t),this._materialEdges.uniforms.resolution.value.set(1/e,1/t),this._materialWeights.uniforms.resolution.value.set(1/e,1/t),this._materialBlend.uniforms.resolution.value.set(1/e,1/t)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQES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tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII=`}_getSearchTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=`}}})),FR,IR=t((()=>{J(),FR={name:`FXAAShader`,uniforms:{tDiffuse:{value:null},resolution:{value:new z(1/1024,1/512)}},vertexShader:`
|
|
7220
|
+
}`}})),oz,sz=t((()=>{J(),aR(),az(),oz=class extends eR{constructor(){super(),this._edgesRT=new Hi(1,1,{depthBuffer:!1,type:Tn}),this._edgesRT.texture.name=`SMAAPass.edges`,this._weightsRT=new Hi(1,1,{depthBuffer:!1,type:Tn}),this._weightsRT.texture.name=`SMAAPass.weights`;let e=this,t=new Image;t.src=this._getAreaTexture(),t.onload=function(){e._areaTexture.needsUpdate=!0},this._areaTexture=new zi,this._areaTexture.name=`SMAAPass.area`,this._areaTexture.image=t,this._areaTexture.minFilter=pn,this._areaTexture.generateMipmaps=!1,this._areaTexture.flipY=!1;let n=new Image;n.src=this._getSearchTexture(),n.onload=function(){e._searchTexture.needsUpdate=!0},this._searchTexture=new zi,this._searchTexture.name=`SMAAPass.search`,this._searchTexture.image=n,this._searchTexture.magFilter=cn,this._searchTexture.minFilter=cn,this._searchTexture.generateMipmaps=!1,this._searchTexture.flipY=!1,this._uniformsEdges=Ll.clone(nz.uniforms),this._materialEdges=new Bl({defines:Object.assign({},nz.defines),uniforms:this._uniformsEdges,vertexShader:nz.vertexShader,fragmentShader:nz.fragmentShader}),this._uniformsWeights=Ll.clone(rz.uniforms),this._uniformsWeights.tDiffuse.value=this._edgesRT.texture,this._uniformsWeights.tArea.value=this._areaTexture,this._uniformsWeights.tSearch.value=this._searchTexture,this._materialWeights=new Bl({defines:Object.assign({},rz.defines),uniforms:this._uniformsWeights,vertexShader:rz.vertexShader,fragmentShader:rz.fragmentShader}),this._uniformsBlend=Ll.clone(iz.uniforms),this._uniformsBlend.tDiffuse.value=this._weightsRT.texture,this._materialBlend=new Bl({uniforms:this._uniformsBlend,vertexShader:iz.vertexShader,fragmentShader:iz.fragmentShader}),this._fsQuad=new iR(null)}render(e,t,n){this._uniformsEdges.tDiffuse.value=n.texture,this._fsQuad.material=this._materialEdges,e.setRenderTarget(this._edgesRT),this.clear&&e.clear(),this._fsQuad.render(e),this._fsQuad.material=this._materialWeights,e.setRenderTarget(this._weightsRT),this.clear&&e.clear(),this._fsQuad.render(e),this._uniformsBlend.tColor.value=n.texture,this._fsQuad.material=this._materialBlend,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this._fsQuad.render(e))}setSize(e,t){this._edgesRT.setSize(e,t),this._weightsRT.setSize(e,t),this._materialEdges.uniforms.resolution.value.set(1/e,1/t),this._materialWeights.uniforms.resolution.value.set(1/e,1/t),this._materialBlend.uniforms.resolution.value.set(1/e,1/t)}dispose(){this._edgesRT.dispose(),this._weightsRT.dispose(),this._areaTexture.dispose(),this._searchTexture.dispose(),this._materialEdges.dispose(),this._materialWeights.dispose(),this._materialBlend.dispose(),this._fsQuad.dispose()}_getAreaTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzM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beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII=`}_getSearchTexture(){return`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=`}}})),cz,lz=t((()=>{J(),cz={name:`FXAAShader`,uniforms:{tDiffuse:{value:null},resolution:{value:new z(1/1024,1/512)}},vertexShader:`
|
|
6972
7221
|
|
|
6973
7222
|
varying vec2 vUv;
|
|
6974
7223
|
|
|
@@ -7229,10 +7478,10 @@ void main() {
|
|
|
7229
7478
|
|
|
7230
7479
|
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
|
|
7231
7480
|
|
|
7232
|
-
}`}}));function
|
|
7233
|
-
void main() { vec2 cell = uPixel * uPr / uRes; vec2 uv = (floor(vUv / cell) + 0.5) * cell; gl_FragColor = texture2D(tDiffuse, uv); }`,{uPixel:{value:Math.max(1,Q(e.pixelSize,4))}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio()),set:
|
|
7481
|
+
}`}}));function uz(){return cz.fragmentShader.replace(`return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );`,`return dot( sqrt( max( Sample( tex2D, uv ).rgb, vec3( 0.0 ) ) ), vec3( 0.3, 0.59, 0.11 ) );`).replace(`float _SubpixelBlending = 1.0;`,`float _SubpixelBlending = 0.35;`)}function dz(e,t){let n=new Bl({...cz,fragmentShader:uz(),uniforms:Ll.clone(cz.uniforms),depthTest:!1,depthWrite:!1}),r=new xR(n),i=n.uniforms.resolution.value;return i.set(1/t.width,1/t.height),{pass:r,setSize:(e,t)=>i.set(1/e,1/t)}}function fz(e,t){let n=new oz;n.setSize(t.width,t.height);let r=[`_areaTexture`,`_searchTexture`].map(e=>n[e]?.image);return{pass:n,setSize:(e,t)=>n.setSize(e,t),ready:Promise.all(r.map(e=>e&&!e.complete&&typeof e.decode==`function`?e.decode().catch(()=>void 0):void 0)).then(()=>{for(let e of[`_areaTexture`,`_searchTexture`]){let t=n[e];t&&(t.needsUpdate=!0)}})}}function pz(e,t){let n=new bz(e,t);return{pass:n,set:(e,t)=>n.set(e,t)}}function mz(e,t){return(n,r)=>{let i=t[n];i&&typeof r==`number`&&(e.uniforms[i[0]].value=i[1](r))}}function hz(e,t,n){let r=new z(n.width,n.height);return{pass:new xR(mR(e,{tDiffuse:{value:null},uRes:{value:r},uPr:{value:n.pixelRatio},...t})),res:r}}function gz(e,t){let{pass:n,res:r}=hz(`uniform sampler2D tDiffuse; uniform vec2 uRes; uniform float uPr; uniform float uPixel; varying vec2 vUv;
|
|
7482
|
+
void main() { vec2 cell = uPixel * uPr / uRes; vec2 uv = (floor(vUv / cell) + 0.5) * cell; gl_FragColor = texture2D(tDiffuse, uv); }`,{uPixel:{value:Math.max(1,Q(e.pixelSize,4))}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio()),set:mz(n,{pixelSize:[`uPixel`,e=>Math.max(1,e)]})}}function _z(e,t){let{pass:n,res:r}=hz(`uniform sampler2D tDiffuse; uniform vec2 uRes; uniform float uPr; uniform float uSize; uniform float uAngle; uniform float uMono;
|
|
7234
7483
|
varying vec2 vUv;
|
|
7235
|
-
${
|
|
7484
|
+
${yR}
|
|
7236
7485
|
vec2 cellUv(vec2 frag, float ang) {
|
|
7237
7486
|
float s = uSize * uPr;
|
|
7238
7487
|
mat2 r = mat2(cos(ang), -sin(ang), sin(ang), cos(ang));
|
|
@@ -7269,9 +7518,9 @@ void main() {
|
|
|
7269
7518
|
vec3 outc = paper * (1.0 - dots(frag, ac, C) * vec3(0.95, 0.25, 0.0)) * (1.0 - dots(frag, am, M) * vec3(0.1, 0.9, 0.3)) * (1.0 - dots(frag, ay, Y) * vec3(0.0, 0.08, 0.9)) * (1.0 - dots(frag, ak, K * 0.9) * 0.92);
|
|
7270
7519
|
outc = pow(outc, vec3(2.2));
|
|
7271
7520
|
gl_FragColor = vec4(outc, base.a);
|
|
7272
|
-
}`,{uSize:{value:Math.max(2,Q(e.size,6))},uAngle:{value:Q(e.angle,45)*Math.PI/180},uMono:{value:+!!ES(e.mono,!1)}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio())}}function
|
|
7521
|
+
}`,{uSize:{value:Math.max(2,Q(e.size,6))},uAngle:{value:Q(e.angle,45)*Math.PI/180},uMono:{value:+!!ES(e.mono,!1)}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio())}}function vz(e,t){let{pass:n,res:r}=hz(`uniform sampler2D tDiffuse; uniform vec2 uRes; uniform float uPr; uniform float uSize; uniform float uMono; uniform vec3 uInk;
|
|
7273
7522
|
varying vec2 vUv;
|
|
7274
|
-
${
|
|
7523
|
+
${yR}
|
|
7275
7524
|
float glyph(int n, vec2 p) {
|
|
7276
7525
|
p = floor(p * vec2(-4.0, 4.0) + 2.5);
|
|
7277
7526
|
if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y) {
|
|
@@ -7300,9 +7549,9 @@ void main() {
|
|
|
7300
7549
|
float g = glyph(n, p * 1.15);
|
|
7301
7550
|
vec3 col = uMono > 0.5 ? uInk * (0.35 + 0.65 * l) : c.rgb / max(max(c.r, max(c.g, c.b)), 0.25);
|
|
7302
7551
|
gl_FragColor = vec4(col * g, texture2D(tDiffuse, vUv).a);
|
|
7303
|
-
}`,{uSize:{value:Math.max(4,Q(e.size,8))},uMono:{value:+!!ES(e.mono,!1)},uInk:{value:AS(typeof e.color==`string`?e.color:`#33ff88`)}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio())}}function
|
|
7552
|
+
}`,{uSize:{value:Math.max(4,Q(e.size,8))},uMono:{value:+!!ES(e.mono,!1)},uInk:{value:AS(typeof e.color==`string`?e.color:`#33ff88`)}},t);return{pass:n,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio())}}function yz(e,t){let{pass:n,res:r}=hz(`uniform sampler2D tDiffuse; uniform vec2 uRes; uniform float uPr; uniform float uTime; uniform float uAmount; uniform float uSpeed;
|
|
7304
7553
|
varying vec2 vUv;
|
|
7305
|
-
${
|
|
7554
|
+
${yR}
|
|
7306
7555
|
void main() {
|
|
7307
7556
|
float tb = floor(uTime * max(uSpeed, 0.001) * 6.0);
|
|
7308
7557
|
float burst = step(1.0 - uAmount * 0.55, a3dHash12(vec2(tb, 1.7)));
|
|
@@ -7320,7 +7569,7 @@ void main() {
|
|
|
7320
7569
|
float blk = step(0.93, a3dHash12(floor(vUv * vec2(10.0, rows)) + tb)) * burst * uAmount;
|
|
7321
7570
|
c.rgb = mix(c.rgb, vec3(1.0) - c.rgb.gbr, blk);
|
|
7322
7571
|
gl_FragColor = c;
|
|
7323
|
-
}`,{uTime:{value:0},uAmount:{value:Q(e.amount,.5)},uSpeed:{value:Q(e.speed,1)}},t);return{pass:n,update:e=>n.uniforms.uTime.value=e,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio()),set:
|
|
7572
|
+
}`,{uTime:{value:0},uAmount:{value:Q(e.amount,.5)},uSpeed:{value:Q(e.speed,1)}},t);return{pass:n,update:e=>n.uniforms.uTime.value=e,setSize:(e,i)=>(r.set(e,i),n.uniforms.uPr.value=t.renderer.getPixelRatio()),set:mz(n,{amount:[`uAmount`,xz],speed:[`uSpeed`,xz]})}}var bz,xz,Sz=t((()=>{J(),aR(),sz(),lz(),zS(),CR(),bz=class extends eR{rt;tmp;mat;quad;constructor(e,t){super(),this.rt=t,this.tmp=hR(t.width,t.height),this.mat=mR(`uniform sampler2D tDiffuse; uniform vec2 uDir; uniform float uFocus; uniform float uWidth; uniform float uBlur; uniform float uPr;
|
|
7324
7573
|
varying vec2 vUv;
|
|
7325
7574
|
void main() {
|
|
7326
7575
|
float k = smoothstep(uWidth, uWidth + 0.3, abs(vUv.y - uFocus));
|
|
@@ -7332,13 +7581,13 @@ void main() {
|
|
|
7332
7581
|
tot += w;
|
|
7333
7582
|
}
|
|
7334
7583
|
gl_FragColor = acc / tot;
|
|
7335
|
-
}`,{tDiffuse:{value:null},uDir:{value:new z},uFocus:{value:Q(e.focus,.5)},uWidth:{value:Q(e.width,.18)},uBlur:{value:Q(e.blur,1)},uPr:{value:t.pixelRatio}}),this.quad=new
|
|
7584
|
+
}`,{tDiffuse:{value:null},uDir:{value:new z},uFocus:{value:Q(e.focus,.5)},uWidth:{value:Q(e.width,.18)},uBlur:{value:Q(e.blur,1)},uPr:{value:t.pixelRatio}}),this.quad=new iR(this.mat)}set(e,t){let n={focus:`uFocus`,width:`uWidth`,blur:`uBlur`}[e];n&&typeof t==`number`&&(this.mat.uniforms[n].value=t)}setSize(e,t){this.tmp.setSize(e,t),this.mat.uniforms.uPr.value=this.rt.renderer.getPixelRatio()}render(e,t,n){let r=this.mat.uniforms;r.tDiffuse.value=n.texture,r.uDir.value.set(1/n.width,0),e.setRenderTarget(this.tmp),this.quad.render(e),r.tDiffuse.value=this.tmp.texture,r.uDir.value.set(0,1/n.height),e.setRenderTarget(this.renderToScreen?null:t),this.quad.render(e)}dispose(){this.tmp.dispose(),this.mat.dispose(),this.quad.dispose()}},xz=e=>e})),Cz=/* @__PURE__ */ n({POSTFX_IMPLS:()=>Dz,createPostFx:()=>Tz});function wz(e,t){let n=1,r=0;for(;e>0;)n/=t,r+=e%t*n,e=Math.floor(e/t);return r}function Tz(e,t,n){let{renderer:r,scene:i,camera:a}=t,o=t.quality??Ax(`high`),{active:s,dropped:c}=Px(e,o.tier),l=r.getPixelRatio(),u=Math.max(1,Math.floor(t.width*l)),d=Math.max(1,Math.floor(t.height*l)),f=t.antialias===!1?0:Math.min(o.msaa,r.capabilities.maxSamples??4),p=new Hi(u,d,{type:Tn,samples:f}),m=new Hi(u,d,{type:Tn,depthBuffer:!1}),h=m.clone(),g=0,_=null,v=new TR,y={renderer:r,scene:i,camera:a,quality:o,get width(){return u},get height(){return d},get pixelRatio(){return l},gbuffer:()=>_??=new SR(u,d),frame:()=>g,finish:v},b=[],x=/* @__PURE__ */ new Map,S=/* @__PURE__ */ new Map,C=[],w=e=>{let t=Dz[e.type];if(!t)return void n(e.type);if(t.stage===`finish`){S.set(e.type,{...e}),v.configure(e),C.push(e.type);return}if(t.stage===`meta`||!t.create)return;let r=t.create(e,y);r&&(b.push(r),x.set(e.type,r),C.push(e.type))};for(let e of Oz){let t=s.find(t=>t.type===e);t&&w(t)}let T=b.length,E=new lR(i,a,u,d),D=s.find(e=>e.type===`smaa`)??s.find(e=>e.type===`fxaa`);D&&w(D);for(let e of s)Dz[e.type]?.stage===`ldr`&&w(e);for(let e of s)Dz[e.type]?.stage===`finish`&&w(e);for(let e of s)Dz[e.type]||n(e.type);let O=T?new xR(mR(`uniform sampler2D tDiffuse; varying vec2 vUv;\n${cR}\nvoid main() { gl_FragColor = a3dSanitize(texture2D(tDiffuse, vUv)); }`,{tDiffuse:{value:null}})):null,k=[];O&&k.push(O);for(let e=0;e<T;e++)k.push(b[e].pass);k.push(E);for(let e=T;e<b.length;e++)k.push(b[e].pass);k.push(v),k.forEach((e,t)=>e.renderToScreen=t===k.length-1),v.setSize(u,d),v.setPixelRatio(l);let A=s.find(e=>e.type===`taa`),j=A?Math.max(2,Math.min(o.maxStillSamples,Math.round(Q(A.samples,8)))):0,M=null,N=null,P=null,F=new iR,ee=e=>{M??=[0,1].map(()=>new Hi(u,d,{type:Tn,depthBuffer:!1,minFilter:cn,magFilter:cn}));for(let e of M)(e.width!==u||e.height!==d)&&e.setSize(u,d);N??=mR(`uniform sampler2D tDiffuse; uniform sampler2D tPrev; uniform float uWeight; varying vec2 vUv;\n${cR}
|
|
7336
7585
|
void main() {
|
|
7337
7586
|
vec4 c = a3dSanitize(texture2D(tDiffuse, vUv));
|
|
7338
7587
|
float m = max(c.r, max(c.g, c.b));
|
|
7339
7588
|
gl_FragColor = mix(texture2D(tPrev, vUv), vec4(c.rgb / (1.0 + m), c.a), uWeight);
|
|
7340
|
-
}`,{tDiffuse:{value:null},tPrev:{value:null},uWeight:{value:1}}),P??=
|
|
7341
|
-
void main() { vec4 c = texture2D(tDiffuse, vUv); float m = max(c.r, max(c.g, c.b)); gl_FragColor = vec4(c.rgb / max(1.0 - m, 1e-3), c.a); }`,{tDiffuse:{value:null}});let t=a.isOrthographicCamera,[n,i]=M;for(let o=0;o<e;o++){let e=f>0?.5:1,s=(ZR(o+1,2)-.5)*e,c=(ZR(o+1,3)-.5)*e;(a.isPerspectiveCamera||t)&&a.setViewOffset(u,d,s,c,u,d),I(p),N.uniforms.tDiffuse.value=p.texture,N.uniforms.tPrev.value=n.texture,N.uniforms.uWeight.value=1/(o+1),F.material=N,r.setRenderTarget(i),F.render(r),[n,i]=[i,n]}a.clearViewOffset(),P.uniforms.tDiffuse.value=n.texture,F.material=P,r.setRenderTarget(m),F.render(r)},te=new H,ne=1,re=null,ie=!1,ae=!1;function I(e){if(i.getObjectByName(`__volumetric`)?.visible){let e=y.gbuffer();e.ensure(r,i,a,g),i.userData.a3dDepth={texture:e.depthTexture,width:u,height:d}}let t=i.background;t&&ie&&(re??=new LL(E.texture),ae||E.prepare(r),ae=!0,re.mainTarget=e,re.mesh.parent!==i&&i.add(re.mesh),re.mesh.visible=!0),i.background=null,i.userData.a3dBackground=t,r.setRenderTarget(e),r.setClearColor(0,0),r.clear();try{r.render(i,a)}finally{i.background=t,delete i.userData.a3dDepth,delete i.userData.a3dBackground,re&&(re.mesh.visible=!1)}}return{ready:Promise.all(b.map(e=>e.ready).filter(Boolean)).then(()=>void 0),stillSamples:j,effects:C,dropped:c,setParam(e,t,n){let r=S.get(e);r?(r[t]=n,v.configure(r)):x.get(e)?.set?.(t,n)},render(e,t){g++;for(let t of b)t.update?.(e);v.setTime(e),te=r.getClearColor(te),ne=r.getClearAlpha(),E.clearColor.copy(te),E.clearAlpha=ne;let n=r.autoClear;r.autoClear=!0;let a=Math.max(1,Math.floor(t?.samples??1));ie=NL(i),ae=!1;let o,s;try{a>1?(ee(a),o=m,s=h):(I(p),o=p,s=m),r.setClearColor(te,ne);for(let e of k)if(e.enabled&&(e.render(r,s,o,0,!1),e.needsSwap)){let e=o===p?h:o;o=s,s=e}}finally{r.setClearColor(te,ne),r.autoClear=n,r.setRenderTarget(null)}},setSize(e,t){l=r.getPixelRatio(),u=Math.max(1,Math.floor(e*l)),d=Math.max(1,Math.floor(t*l)),p.setSize(u,d),m.setSize(u,d),h.setSize(u,d),_?.setSize(u,d),E.setSize(u,d),v.setSize(u,d),v.setPixelRatio(l);for(let e of b)e.setSize?e.setSize(u,d):e.pass.setSize(u,d)},dispose(){for(let e of k)e.dispose();_?.dispose(),p.dispose(),m.dispose(),h.dispose();for(let e of M??[])e.dispose();N?.dispose(),P?.dispose(),F.dispose(),re?.dispose()}}}var $R,ez,tz,nz=t((()=>{J(),ML(),Rx(),zS(),RL(),XL(),$L(),OR(),YR(),$R={stage:`finish`},ez={look:{stage:`meta`},taa:{stage:`meta`},ao:{stage:`hdr`,create:gR},outline:{stage:`hdr`,create:_R},godrays:{stage:`hdr`,create:vR},dof:{stage:`hdr`,create:yR},bloom:{stage:`hdr`,create:bR},lensflare:{stage:`hdr`,create:xR},fxaa:{stage:`aa`,create:RR},smaa:{stage:`aa`,create:zR},tiltshift:{stage:`ldr`,create:BR},pixelate:{stage:`ldr`,create:UR},halftone:{stage:`ldr`,create:WR},ascii:{stage:`ldr`,create:GR},glitch:{stage:`ldr`,create:KR},chromatic:$R,sharpen:$R,grading:$R,vignette:$R,film:$R},tz=[`ao`,`outline`,`godrays`,`dof`,`bloom`,`lensflare`]}));J(),yg(),Rx(),Tv(),zS();var rz={none:0,aces:4,agx:6,neutral:7,reinhard:2};function iz(e){if(e.scripts?.length||e.ui?.elements?.length||e.physics||e.audio)return!0;let t=e=>!!e?.some(e=>!!e.body||t(e.children));return t(e.objects)}function az(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e.target?.aspect??``);return t&&Number(t[1])>0&&Number(t[2])>0?Number(t[1])/Number(t[2]):16/9}var oz=8,sz=2e4,cz=/* @__PURE__ */ new Set;function lz(e){for(;cz.size>=oz;){let t=null;for(let n of cz)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function uz(){return cz.size}var dz=class{container;options;scene;canvas;lastSeen=0;released=!1;releaseTimer=null;placeholder=null;readyCalled=!1;ready;issues=[];input;renderer=null;world=null;game=null;postfx=null;quality=Ax(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=gA();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=/* @__PURE__ */ new Map;scrollOverride=null;tlScroll=null;raf=0;playing=!1;visible=!0;started=!1;timeScale=1;staticMotion=!1;lastNow=0;fps=0;building=null;rebuilding=!1;disposed=!1;hovered=/* @__PURE__ */ new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new of;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=/* @__PURE__ */ new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=pg(n),this.ready=new Promise((e,t)=>{this.readyResolve=e,this.readyReject=t}),this.ready.catch(()=>void 0);let r=e.ownerDocument;this.canvas=r.createElement(`canvas`),this.canvas.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let i=r.defaultView?.getComputedStyle(e).position;i&&i!==`static`||(e.style.position=`relative`);let a=this;n.editor&&(this.editor={world:()=>a.world,renderer:()=>a.renderer,setOverlay:e=>{a.overlay=e},render:()=>a.render(),onWorld:e=>(a.worldListeners.add(e),()=>a.worldListeners.delete(e)),running:()=>!!a.raf}),this.input={pointer(e,t){a.inputState.pointer.x=e,a.inputState.pointer.y=t,a.inputState.pointer.inside=!0,a.inputInteractions()},key(e,t){vA(a.inputState,e,t),a.inputInteractions()},click(e,t){let n=e??a.inputState.pointer.x,r=t??a.inputState.pointer.y;a.inputState.pointer.x=n,a.inputState.pointer.y=r,a.inputState.pointer.inside=!0,a.inputState.pointer.justPressed=!0,a.inputState.clicks.push({x:n,y:r}),a.inputInteractions()},down(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.inside=!0,n.justPressed=!n.down,n.down=!0},up(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.down=!1},swipe(e){a.inputState.swipe=e},scroll(e){a.setScrollProgress(e),a.inputInteractions()}},e.appendChild(this.canvas),this.inputBinding=yA(e,this.inputState,{game:t.target?.kind===`game`}),this.measure(),typeof ResizeObserver<`u`&&(this.resizeObs=new ResizeObserver(()=>this.resize()),this.resizeObs.observe(e));let o=t.target??{},s=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),c=o.reducedMotion??(o.kind===`game`?`ignore`:`static`);s&&!this.deterministic&&(c===`static`?this.staticMotion=!0:c===`slow`&&(this.timeScale=.5)),this.deterministic||o.lazy===!1||typeof IntersectionObserver>`u`?this.start():(this.visible=!1,this.interObs=new IntersectionObserver(e=>{let t=e.some(e=>e.isIntersecting);this.visible=t,this.lastSeen=performance.now(),this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null,t?this.start():this.releasable()&&(this.releaseTimer=setTimeout(()=>this.release(),sz)),this.updateRunning()},{rootMargin:`200px 0px`}),this.interObs.observe(e),this.armStartFallback()),r.addEventListener(`visibilitychange`,this.onVisibility)}fallbackCleanup=null;armStartFallback(){let e=this.container.ownerDocument,t=e.defaultView;if(!t)return;let n=()=>{if(this.started||this.disposed)return a();if(e.visibilityState===`hidden`||!this.container.isConnected)return;let n=this.container.getBoundingClientRect(),r=t.innerHeight||e.documentElement.clientHeight,i=t.innerWidth||e.documentElement.clientWidth;n.bottom>=-200&&n.top<=r+200&&n.right>=0&&n.left<=i&&(n.width>0||n.height>0)&&(this.visible=!0,this.lastSeen=performance.now(),this.start(),this.updateRunning(),a())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=t.requestAnimationFrame(()=>i=t.requestAnimationFrame(n)),a=()=>{for(let e of r)clearTimeout(e);t.cancelAnimationFrame(i),t.removeEventListener(`load`,n),t.removeEventListener(`scroll`,n),e.removeEventListener(`visibilitychange`,n),this.fallbackCleanup=null};t.addEventListener(`load`,n),t.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`visibilitychange`,n),this.fallbackCleanup=a}createRenderer(){let e=this.scene.target??{},t=new dg({canvas:this.canvas,antialias:e.antialias!==!1,alpha:!!e.transparent,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:this.deterministic});if(!t.getContext())throw Error(`no context`);return this.configureRenderer(t),t.info.autoReset=!1,t}configureRenderer(e){let t=this.scene.target??{};e.outputColorSpace=Br,e.toneMapping=rz[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=Ax(jx(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let n=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(n);let r=eE(this.scene);if(e.shadowMap.enabled=r.enabled,e.shadowMap.type=r.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?AS(t):new H(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,lz(this),this.released){let e=this.container.ownerDocument.createElement(`canvas`);e.style.cssText=this.canvas.style.cssText,this.canvas.replaceWith(e),this.canvas=e,this.released=!1}try{this.renderer=this.createRenderer(),cz.add(this)}catch(e){this.report({code:`webgl-unavailable`,message:`WebGL is not available: ${e.message}`}),this.readyReject(/* @__PURE__ */ Error(`webgl-unavailable`));return}this.measure(),this.renderer.setSize(this.width,this.height,!1),this.building=this.buildAll().then(()=>{this.disposed||(this.deterministic?(this.t=0,this.frame(0)):this.staticMotion?(this.t=this.scene.target?.posterTime??0,this.game?.advanceTo(this.t),this.frame(0),this.renderStill()):(this.frame(0),this.playing=!0,this.updateRunning()),this.placeholder?.remove(),this.placeholder=null,this.readyResolve(),this.readyCalled||this.options.onReady?.(this),this.readyCalled=!0)}).catch(e=>{this.report({code:`build-error`,message:e.message}),this.readyReject(e)})}}makeContext(e){return{scene:this.scene,rng:dv(this.scene.seed??1),siblings:/* @__PURE__ */ new Map,color:e=>AS(e),resolveAsset:this.resolveAsset,renderer:this.renderer,deterministic:this.deterministic,quality:this.quality.tier,track:t=>(e.push(t.catch(()=>void 0)),this.trackProgress(t),t),onUpdate:()=>void 0,issue:(e,t,n)=>this.report({code:e,message:t,path:n}),shaders:Ex,generators:Dx}}async buildWorld(){let e=[],t=this.makeContext(e),n=await pA.create(u(this.scene),t,this.width/Math.max(this.height,1),this.canvas,!!this.options.editor);return await Promise.all(e),await Promise.all(e),n.setViewport(this.width,this.height,this.renderer.getPixelRatio()),n}async attachWorld(e){this.world=e,this.attachMotion(e),e.settleEntrances=this.staticMotion,await this.buildPostFx(e),this.renderer?.shadowMap&&(this.renderer.shadowMap.needsUpdate=!0);for(let e of this.worldListeners)try{e()}catch{}}async buildAll(){let e=await this.buildWorld();if(this.disposed)e.dispose();else{if(await this.attachWorld(e),iz(this.scene)){let{GameHost:t}=await Promise.resolve().then(()=>(EL(),bL));this.game=await t.create({scene:u(this.scene),container:this.container,input:this.inputState,resolveAsset:this.resolveAsset,scriptSources:this.options.scriptSources,deterministic:this.deterministic,issue:e=>this.report(e),rebuild:async()=>{let e=this.world,t=await this.buildWorld();return e?.dispose(),await this.attachWorld(t),t}},e);let n=this.game,r=n.emit.bind(n);n.emit=(e,t)=>{r(e,t),this.notify(e,t),this.dispatchMotionEvent(e,t)}}try{this.renderer?.compile(e.scene,e.camera)}catch{}}}loadTotal=0;loadDone=0;trackProgress(e){if(!this.options.onProgress)return;this.loadTotal++;let t=()=>{this.loadDone++;try{this.options.onProgress?.(this.loadDone,this.loadTotal)}catch{}};e.then(t,t)}notify(e,t){try{this.options.onEvent?.(e,t)}catch{}}emit(e,t){if(this.game)return this.game.emit(e,t);this.notify(e,t),this.dispatchMotionEvent(e,t)}dispatchMotionEvent(e,t){for(let n of this.eventListeners.get(e)??[])try{n(t)}catch{}this.interactions?.event(e,t)}report(e){this.issues.push(e);try{this.options.onError?.(e)}catch{}this.options.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)}updateRunning(){let e=this.container.ownerDocument.visibilityState===`hidden`,t=this.scene.target?.pauseOffscreen!==!1,n=this.playing&&!this.disposed&&!e&&(this.visible||!t)&&!!this.world;if(n&&!this.raf){this.lastNow=performance.now();let e=t=>{this.raf=requestAnimationFrame(e);let n=Math.min(Math.max((t-this.lastNow)/1e3,0),.1);this.lastNow=t,n>.002&&(this.fps=this.fps?this.fps*.9+1/n*.1:1/n),this.qualityAuto&&this.adaptQuality(n),this.tick(n*this.timeScale)};this.raf=requestAnimationFrame(e)}else!n&&this.raf&&(cancelAnimationFrame(this.raf),this.raf=0)}tick(e){this.world&&!this.rebuilding&&(this.game?.pendingRestart?(this.rebuilding=!0,this.game.restart().then(()=>{this.rebuilding=!1,this.t=0,this.resetMotion()})):(e=Math.max(e,0),this.t=Math.max(this.t+e,0),this.game?.advance(e),this.frame(e)))}attachMotion(e){this.tl=this.scene.timeline?new EA(this.scene.timeline):null,this.tlScroll=null,e.postfxParam=(e,t,n)=>this.postfx?.setParam?.(e,t,n);let t=this.scene.interactions??[];this.interactions=t.length?new kA(t,{play:(e,t)=>this.playSegment(e,{reverse:t}),toggle:e=>{this.tl?.toggle(e,this.t)||this.unknownSegment(e)},seek:e=>this.tl?.seek(e,this.t),set:(t,n,r,i)=>e.overrides.set(t,n,this.t,r,i),emit:(e,t)=>this.emit(e,t),openUrl:(e,t)=>this.openUrl(e,t),playClip:(t,n,r)=>{let i=e.entries.get(t)?.animator;i?i.play(n,r):this.report({code:`interaction`,message:`playClip: "${t}" is not a model with animation clips`,path:`interactions`})}}):null}handledClicks=0;handledKeys=/* @__PURE__ */ new Set;inputInteractions(){let e=this.world;if(!this.deterministic||!this.interactions||!e)return;let t=this.inputState,n=e.interactiveRoots(),r=new Set(t.pointer.inside?this.pickIds(t.pointer.x,t.pointer.y,n):[]),i=/* @__PURE__ */ new Set;for(let e of t.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,n))i.add(t);let a=new Set([...t.pressed].filter(e=>!this.handledKeys.has(e)));this.interactions.step({hovered:r,pointerInside:t.pointer.inside,clicked:i,canvasClicked:t.clicks.length>this.handledClicks,pressed:a,scroll:this.scrollValue(),visible:!0,userGesture:!1}),this.handledClicks=t.clicks.length;for(let e of a)this.handledKeys.add(e)}resetMotion(){this.tl?.reset(),this.interactions?.reset(),this.tlScroll=null}unknownSegment(e){this.report({code:`interaction`,message:`Unknown timeline segment "${e}"`,path:`timeline.segments`})}timelineLocal(e,t,n){let r=this.scene.timeline;return!r||!this.world?.timeline||!this.tl?null:this.tl.update({t:this.t,dt:e,deterministic:this.deterministic,staticMotion:this.staticMotion,posterTime:this.scene.target?.posterTime,hovered:t,clicked:n,scroll:r.trigger===`scroll`?this.timelineScroll(e):0})}timelineScroll(e){let t=this.scene.timeline;if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion)return this.scrollValue();let n=this.container.ownerDocument.defaultView,r=this.container.getBoundingClientRect(),i=PA(r.top,r.height,n?.innerHeight||1,t.scroll?.start,t.scroll?.end),a=Math.min(Math.max(t.scroll?.smoothing??.8,0),.99);return this.tlScroll===null||a<=0?this.tlScroll=i:this.tlScroll+=(i-this.tlScroll)*(1-a**(Math.max(e,0)*60)),Math.abs(i-this.tlScroll)<1e-4&&(this.tlScroll=i),this.tlScroll}scrollValue(){if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion){let e=this.scene.timeline,t=e?.trigger===`scroll`&&e.duration>0?e.duration:4;return Math.min(Math.max(this.t/t,0),1)}return bA(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?DA(e,n.location.href):null;if(this.emit(`openUrl`,{url:r??e,blocked:!r||this.deterministic}),!r||!n||this.deterministic)return;let i=new URL(r).origin!==n.location.origin;t??i?n.open(r,`_blank`,`noopener,noreferrer`):n.location.assign(r)}playSegment(e,t={}){this.tl?.play(e,this.t,t)||this.unknownSegment(e)}trigger(e,t){this.interactions?.fire(e,t,!this.deterministic),this.interactions?.flush()}on(e,t){let n=this.eventListeners.get(e);return n||this.eventListeners.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)}setScrollProgress(e){this.scrollOverride=e===null||!Number.isFinite(e)?null:Math.min(Math.max(e,0),1)}pickIds(e,t,n){if(!this.world||!n.length)return[];this.raycaster.setFromCamera(new z(e,t),this.world.camera);let r=this.raycaster.intersectObjects(n,!0).find(e=>e.object.visible&&!e.object.isPoints);return r?this.world.idsFor(r.object):[]}frame(e){let t=this.world;if(!t)return;let n=this.inputState,r=t.interactiveRoots();this.hovered=new Set(n.pointer.inside?this.pickIds(n.pointer.x,n.pointer.y,r):[]);let i=/* @__PURE__ */ new Set;for(let e of n.clicks){let n=this.pickIds(e.x,e.y,r);for(let e of n)i.add(e);if(this.options.onClick){let r=[...t.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object),i=n[0]??this.pickIds(e.x,e.y,r)[0]??null;try{this.options.onClick(i,{x:e.x,y:e.y})}catch{}}let a=n.map(e=>t.entries.get(e)?.def).find(e=>e&&`href`in e&&e.href);a?.href&&!this.deterministic&&this.navigate(a.href)}let a=[...this.hovered].some(e=>!!t.entries.get(e)?.def?.href)||[...this.hovered].some(e=>t.entries.get(e)?.interactive)?`pointer`:``;this.canvas.style.cursor!==a&&(this.canvas.style.cursor=a);let o=this.scrollValue(),s=i;if(this.handledClicks){s=/* @__PURE__ */ new Set;for(let e of n.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,r))s.add(t)}this.interactions?.step({hovered:this.hovered,pointerInside:n.pointer.inside,clicked:s,canvasClicked:n.clicks.length>this.handledClicks,pressed:this.handledKeys.size?new Set([...n.pressed].filter(e=>!this.handledKeys.has(e))):n.pressed,scroll:o,visible:!0,userGesture:!this.deterministic});let c={pointer:n.pointer,scroll:o,hovered:this.hovered,clicked:i,timelineT:this.timelineLocal(e,n.pointer.inside,n.clicks.length>0)};for(let e of this.tl?.drainMarkers()??[])this.emit(e.name,{marker:e.name,time:e.time});this.interactions?.flush();let l=this.scene.camera?.follow?.target;t.frame(this.t,e,c,l?t.entries.get(l)?.object:null),this.game?.hud?.setTimeline(this.tl&&c.timelineT!==null?this.tl.info():null),this.game?.afterFrame(),this.render(),_A(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=DA(e,t.location.href);if(!n)return;let r=new URL(n);r.origin===t.location.origin?t.location.assign(r.href):t.open(r.href,`_blank`,`noopener,noreferrer`)}render(e=!0){let t=this.renderer,n=this.world;if(!t||!n)return;let r=e?this.overlay:null,i=r?.viewCamera?.()??null,a=n.camera,o=i&&i!==a?{p:a.position.clone(),q:a.quaternion.clone(),proj:a.projectionMatrix.clone(),inv:a.projectionMatrixInverse.clone(),near:a.near,far:a.far}:null;if(i&&o){i.updateMatrixWorld(),i.matrixWorld.decompose(a.position,a.quaternion,new B),a.projectionMatrix.copy(i.projectionMatrix),a.projectionMatrixInverse.copy(i.projectionMatrixInverse);let e=i;typeof e.near==`number`&&(a.near=e.near,a.far=e.far),a.updateMatrixWorld(!0)}if(t.info.reset(),this.postfx?this.postfx.render(this.t,{samples:this.renderSamples}):t.render(n.scene,n.camera),this.renderSamples===1&&(this.lastStats={triangles:t.info.render.triangles,drawCalls:t.info.render.calls,geometries:t.info.memory.geometries,textures:t.info.memory.textures}),r)try{r.draw(t,a)}catch(e){this.report({code:`editor-overlay`,message:e.message}),this.overlay=null}o&&(a.position.copy(o.p),a.quaternion.copy(o.q),a.projectionMatrix.copy(o.proj),a.projectionMatrixInverse.copy(o.inv),a.near=o.near,a.far=o.far,a.updateMatrixWorld(!0))}releasable(){return!!this.renderer&&!!this.world&&!this.game&&!this.deterministic&&!this.options.editor&&!this.visible&&!this.disposed&&!this.released&&!iz(this.scene)}release(){if(!this.releasable())return;this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null;let e=``;try{this.render(),e=this.canvas.toDataURL(`image/webp`,.85)}catch{}if(e&&e.length>32){let t=this.container.ownerDocument.createElement(`img`);t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;`,t.src=e,this.placeholder?.remove(),this.placeholder=t,this.canvas.after(t)}this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.postfx?.dispose(),this.postfx=null,this.world?.dispose(),this.world=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,cz.delete(this),this.released=!0,this.started=!1,this.building=null}play(){this.playing=!0,this.start(),this.updateRunning()}pause(){this.playing=!1,this.updateRunning(),this.deterministic||this.renderStill()}async seek(e){if(this.started||this.start(),await this.building,!this.world)return;let t=Math.max(0,e);t<this.t-1e-9&&(this.game?await this.game.restart():this.world.resetBehaviours(),this.t=0,this.resetMotion(),this.world.frame(0,0,{pointer:this.inputState.pointer,scroll:0,hovered:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ new Set,timelineT:this.world.timeline?0:null})),this.advanceMotionGrid(t);let n=t-this.t;this.t=t,this.game?.advanceTo(t),this.frame(n)}advanceMotionGrid(e){let t=this.world;if(!t||!this.deterministic||this.game||!t.hasStatefulMotion())return;let n=this.scene.camera?.follow?.target,r=n?t.entries.get(n)?.object:null;for(let n of VC(this.t,e)){let e=n-this.t;this.t=n;let i=this.inputState,a=t.interactiveRoots(),o=new Set(i.pointer.inside?this.pickIds(i.pointer.x,i.pointer.y,a):[]);t.frame(this.t,e,{pointer:i.pointer,scroll:this.scrollValue(),hovered:o,clicked:/* @__PURE__ */ new Set,timelineT:this.timelineLocal(e,i.pointer.inside,!1)},r)}}time(){return this.t}async update(e){if(await this.building,this.scene=e,!this.renderer)return;this.renderer&&this.configureRenderer(this.renderer),this.game?.dispose(),this.game=null;let t=this.world;this.world=null,t?.dispose(),this.postfx?.dispose(),this.postfx=null,this.building=this.buildAll(),await this.building,this.frame(0)}measure(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||300),t=this.container.clientHeight;t||=Math.round(e/az(this.scene)),this.width=e,this.height=Math.max(1,t)}resize(){this.renderer&&(this.measure(),this.renderer.setSize(this.width,this.height,!1),this.world?.setViewport(this.width,this.height,this.renderer.getPixelRatio()),this.postfx?.setSize(this.width,this.height),this.world&&(!this.raf||this.deterministic)&&this.render())}stats(){return{...this.lastStats,fps:this.deterministic?void 0:Math.round(this.fps)||void 0}}inspect(){let e=this.world,t=e?.camera,n={objects:[],camera:{position:[0,0,0],target:[0,0,0]}};if(!e||!t)return n;e.scene.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let r=new Ks().setFromProjectionMatrix(new V().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new B),a=new Wa,o=new B,s;for(let c of e.entries.values()){if(!c.topLevel)continue;if(a.setFromObject(c.object),c.particles){let e=c.object.geometry;e.boundingBox&&a.copy(e.boundingBox).applyMatrix4(c.object.matrixWorld)}if(a.isEmpty())continue;let e=0,l=1/0,u=1/0,d=-1/0,f=-1/0;for(let n=0;n<8;n++)o.set(n&1?a.max.x:a.min.x,n&2?a.max.y:a.min.y,n&4?a.max.z:a.min.z),r.containsPoint(o)&&e++,o.project(t),l=Math.min(l,o.x),d=Math.max(d,o.x),u=Math.min(u,o.y),f=Math.max(f,o.y);let p=e===8?`full`:r.intersectsBox(a)?`partial`:`none`;p===`partial`&&!c.particles&&(p=IA(c.object,r)??p);let m=Math.max(-1,l),h=Math.min(1,d),g=Math.max(-1,u),_=Math.min(1,f),v=p===`none`||a.containsPoint(i)?+!!a.containsPoint(i):Math.max(0,h-m)*Math.max(0,_-g)/4;!s&&c.kind!==`particles`&&a.containsPoint(i)&&(c.kind!==`generator`||LA(c.object,i,c.def.generator===`terrain`&&c.built?.heightAt?{heightAt:c.built.heightAt}:`parts`))&&(s=c.id),n.objects.push({id:c.id,min:[a.min.x,a.min.y,a.min.z],max:[a.max.x,a.max.y,a.max.z],inView:p,screenCoverage:Math.round(Math.min(1,v)*1e3)/1e3})}let c=e.rig.orbit?e.rig.orbit.target:e.rig.rest.target;return n.camera={position:[i.x,i.y,i.z],target:[c.x,c.y,c.z]},s&&(n.camera.insideObject=s),n}snapshot(e=`image/png`,t){this.renderSamples=this.deterministic&&this.postfx?.stillSamples||1;try{this.render(!1)}finally{this.renderSamples=1}return this.canvas.toDataURL(e,t)}async snapshotHighQuality(e=16,t=`image/png`,n){this.started||this.start(),await this.building;let r=this.renderer,i=this.world;if(!r||!i)return this.canvas.toDataURL(t,n);let a=Math.max(1,Math.min(64,Math.round(e))),o=null;if(!this.postfx){let{createPostFx:e}=await Promise.resolve().then(()=>(nz(),XR));o=e([],{renderer:r,scene:i.scene,camera:i.camera,width:this.width,height:this.height,quality:Ax(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let s=this.postfx??o;try{return s.render(this.t,{samples:a}),this.canvas.toDataURL(t,n)}finally{o?.dispose()}}deviceHints(e){let t=globalThis.navigator??{},n;try{let t=e.getContext(),r=t.getExtension(`WEBGL_debug_renderer_info`);n=String(t.getParameter(r?r.UNMASKED_RENDERER_WEBGL:t.RENDERER)??``)}catch{}let r=t.userAgent??``;return{deterministic:this.deterministic,mobile:t.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r),cores:t.hardwareConcurrency,memoryGb:t.deviceMemory,gpu:n}}async buildPostFx(e,t=!1){if(t||(this.postfx?.dispose(),this.postfx=null),!this.scene.postfx?.length||!this.renderer)return;let{createPostFx:n}=await Promise.resolve().then(()=>(nz(),XR));if(this.world!==e||!this.renderer)return;let r=n(this.scene.postfx,{renderer:this.renderer,scene:e.scene,camera:e.camera,width:this.width,height:this.height,quality:this.quality,antialias:this.scene.target?.antialias!==!1},e=>this.report({code:`unknown-catalog-id`,message:`Unknown post effect "${e}"`,path:`postfx`}));if(await r.ready,this.world!==e)return r.dispose();this.postfx?.dispose(),this.postfx=r}renderStill(){let e=this.postfx?.stillSamples??0;if(!(e<2||!this.world)){this.renderSamples=e;try{this.render()}finally{this.renderSamples=1}}}adaptQuality(e){let t=this.renderer;if(!t||!this.world||this.rebuilding||(this.perfClock+=e,this.perfClock<2)||(this.fps<40?this.slowFor+=e:this.slowFor=Math.max(0,this.slowFor-e),this.slowFor<3))return;if(this.slowFor=0,this.perfClock=0,this.options.pixelRatio===void 0&&t.getPixelRatio()>1.01){t.setPixelRatio(Math.max(1,t.getPixelRatio()*.75)),this.resize();return}let n=Mx(this.quality.tier);n?(this.quality=Ax(n),this.scene.postfx?.length&&this.buildPostFx(this.world,!0)):this.qualityAuto=!1}pick(e,t){let n=this.world;if(!n)return null;let r=[...n.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object);return this.pickIds(e,t,r)[0]??null}state(){return this.game?.state??{}}dispose(){this.disposed||(this.disposed=!0,this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.resizeObs?.disconnect(),this.interObs?.disconnect(),this.fallbackCleanup?.(),this.container.ownerDocument.removeEventListener(`visibilitychange`,this.onVisibility),this.inputBinding?.dispose(),this.overlay=null,this.worldListeners.clear(),this.game?.dispose(),this.postfx?.dispose(),this.world?.dispose(),this.renderer?.dispose(),this.renderer?.forceContextLoss(),cz.delete(this),this.releaseTimer&&clearTimeout(this.releaseTimer),this.placeholder?.remove(),this.canvas.remove())}};function fz(e,t,n={}){let r=new dz(e,t,n);return r.canvas.isConnected&&r.resize(),r}var pz=typeof HTMLElement<`u`?HTMLElement:class{},mz=`
|
|
7589
|
+
}`,{tDiffuse:{value:null},tPrev:{value:null},uWeight:{value:1}}),P??=mR(`uniform sampler2D tDiffuse; varying vec2 vUv;
|
|
7590
|
+
void main() { vec4 c = texture2D(tDiffuse, vUv); float m = max(c.r, max(c.g, c.b)); gl_FragColor = vec4(c.rgb / max(1.0 - m, 1e-3), c.a); }`,{tDiffuse:{value:null}});let t=a.isOrthographicCamera,[n,i]=M;for(let o=0;o<e;o++){let e=f>0?.5:1,s=(wz(o+1,2)-.5)*e,c=(wz(o+1,3)-.5)*e;(a.isPerspectiveCamera||t)&&a.setViewOffset(u,d,s,c,u,d),I(p),N.uniforms.tDiffuse.value=p.texture,N.uniforms.tPrev.value=n.texture,N.uniforms.uWeight.value=1/(o+1),F.material=N,r.setRenderTarget(i),F.render(r),[n,i]=[i,n]}a.clearViewOffset(),P.uniforms.tDiffuse.value=n.texture,F.material=P,r.setRenderTarget(m),F.render(r)},te=new H,ne=1,re=null,ie=!1,ae=!1;function I(e){if(i.getObjectByName(`__volumetric`)?.visible){let e=y.gbuffer();e.ensure(r,i,a,g),i.userData.a3dDepth={texture:e.depthTexture,width:u,height:d}}let t=i.background;t&&ie&&(re??=new uR(E.texture),ae||E.prepare(r),ae=!0,re.mainTarget=e,re.mesh.parent!==i&&i.add(re.mesh),re.mesh.visible=!0),i.background=null,i.userData.a3dBackground=t,r.setRenderTarget(e),r.setClearColor(0,0),r.clear();try{r.render(i,a)}finally{i.background=t,delete i.userData.a3dDepth,delete i.userData.a3dBackground,re&&(re.mesh.visible=!1)}}return{ready:Promise.all(b.map(e=>e.ready).filter(Boolean)).then(()=>void 0),stillSamples:j,effects:C,dropped:c,setParam(e,t,n){let r=S.get(e);r?(r[t]=n,v.configure(r)):x.get(e)?.set?.(t,n)},render(e,t){g++;for(let t of b)t.update?.(e);v.setTime(e),te=r.getClearColor(te),ne=r.getClearAlpha(),E.clearColor.copy(te),E.clearAlpha=ne;let n=r.autoClear;r.autoClear=!0;let a=Math.max(1,Math.floor(t?.samples??1));ie=oR(i),ae=!1;let o,s;try{a>1?(ee(a),o=m,s=h):(I(p),o=p,s=m),r.setClearColor(te,ne);for(let e of k)if(e.enabled&&(e.render(r,s,o,0,!1),e.needsSwap)){let e=o===p?h:o;o=s,s=e}}finally{r.setClearColor(te,ne),r.autoClear=n,r.setRenderTarget(null)}},setSize(e,t){l=r.getPixelRatio(),u=Math.max(1,Math.floor(e*l)),d=Math.max(1,Math.floor(t*l)),p.setSize(u,d),m.setSize(u,d),h.setSize(u,d),_?.setSize(u,d),E.setSize(u,d),v.setSize(u,d),v.setPixelRatio(l);for(let e of b)e.setSize?e.setSize(u,d):e.pass.setSize(u,d)},dispose(){for(let e of k)e.dispose();_?.dispose(),p.dispose(),m.dispose(),h.dispose();for(let e of M??[])e.dispose();N?.dispose(),P?.dispose(),F.dispose(),re?.dispose()}}}var Ez,Dz,Oz,kz=t((()=>{J(),aR(),Rx(),zS(),dR(),CR(),ER(),tz(),Sz(),Ez={stage:`finish`},Dz={look:{stage:`meta`},taa:{stage:`meta`},ao:{stage:`hdr`,create:UR},outline:{stage:`hdr`,create:WR},godrays:{stage:`hdr`,create:GR},dof:{stage:`hdr`,create:KR},bloom:{stage:`hdr`,create:qR},lensflare:{stage:`hdr`,create:JR},fxaa:{stage:`aa`,create:dz},smaa:{stage:`aa`,create:fz},tiltshift:{stage:`ldr`,create:pz},pixelate:{stage:`ldr`,create:gz},halftone:{stage:`ldr`,create:_z},ascii:{stage:`ldr`,create:vz},glitch:{stage:`ldr`,create:yz},chromatic:Ez,sharpen:Ez,grading:Ez,vignette:Ez,film:Ez},Oz=[`ao`,`outline`,`godrays`,`dof`,`bloom`,`lensflare`]}));J(),yg(),Rx(),Tv(),zS();var Az={none:0,aces:4,agx:6,neutral:7,reinhard:2};function jz(e){if(e.scripts?.length||e.ui?.elements?.length||e.physics||e.audio)return!0;let t=e=>!!e?.some(e=>!!e.body||t(e.children));return t(e.objects)}function Mz(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e.target?.aspect??``);return t&&Number(t[1])>0&&Number(t[2])>0?Number(t[1])/Number(t[2]):16/9}var Nz=8,Pz=2e4,Fz=/* @__PURE__ */ new Set;function Iz(e){for(;Fz.size>=Nz;){let t=null;for(let n of Fz)n!==e&&n.releasable()&&(!t||n.lastSeen<t.lastSeen)&&(t=n);if(!t)return;t.release()}}function Lz(){return Fz.size}var Rz=class{container;options;scene;canvas;lastSeen=0;released=!1;releaseTimer=null;placeholder=null;readyCalled=!1;ready;issues=[];input;renderer=null;world=null;game=null;postfx=null;quality=Ax(`high`);qualityAuto=!1;perfClock=0;slowFor=0;renderSamples=1;inputState=UA();inputBinding=null;resolveAsset;deterministic;t=0;tl=null;interactions=null;eventListeners=/* @__PURE__ */ new Map;scrollOverride=null;tlScroll=null;raf=0;playing=!1;visible=!0;started=!1;timeScale=1;staticMotion=!1;lastNow=0;fps=0;building=null;rebuilding=!1;disposed=!1;hovered=/* @__PURE__ */ new Set;resizeObs=null;interObs=null;readyResolve;readyReject;raycaster=new of;width=1;height=1;lastStats={triangles:0,drawCalls:0,geometries:0,textures:0};onVisibility=()=>this.updateRunning();editor;overlay=null;worldListeners=/* @__PURE__ */ new Set;constructor(e,t,n){this.container=e,this.options=n,this.scene=t,this.deterministic=!!n.deterministic,this.resolveAsset=pg(n),this.ready=new Promise((e,t)=>{this.readyResolve=e,this.readyReject=t}),this.ready.catch(()=>void 0);let r=e.ownerDocument;this.canvas=r.createElement(`canvas`),this.canvas.style.cssText=`display:block;width:100%;height:100%;outline:none;touch-action:manipulation;`;let i=r.defaultView?.getComputedStyle(e).position;i&&i!==`static`||(e.style.position=`relative`);let a=this;n.editor&&(this.editor={world:()=>a.world,renderer:()=>a.renderer,setOverlay:e=>{a.overlay=e},render:()=>a.render(),onWorld:e=>(a.worldListeners.add(e),()=>a.worldListeners.delete(e)),running:()=>!!a.raf}),this.input={pointer(e,t){a.inputState.pointer.x=e,a.inputState.pointer.y=t,a.inputState.pointer.inside=!0,a.inputInteractions()},key(e,t){GA(a.inputState,e,t),a.inputInteractions()},click(e,t){let n=e??a.inputState.pointer.x,r=t??a.inputState.pointer.y;a.inputState.pointer.x=n,a.inputState.pointer.y=r,a.inputState.pointer.inside=!0,a.inputState.pointer.justPressed=!0,a.inputState.clicks.push({x:n,y:r}),a.inputInteractions()},down(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.inside=!0,n.justPressed=!n.down,n.down=!0},up(e,t){let n=a.inputState.pointer;e!==void 0&&t!==void 0&&(n.x=e,n.y=t),n.down=!1},swipe(e){a.inputState.swipe=e},scroll(e){a.setScrollProgress(e),a.inputInteractions()}},e.appendChild(this.canvas),this.inputBinding=KA(e,this.inputState,{game:t.target?.kind===`game`}),this.measure(),typeof ResizeObserver<`u`&&(this.resizeObs=new ResizeObserver(()=>this.resize()),this.resizeObs.observe(e));let o=t.target??{},s=n.reducedMotion??(typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches),c=o.reducedMotion??(o.kind===`game`?`ignore`:`static`);s&&!this.deterministic&&(c===`static`?this.staticMotion=!0:c===`slow`&&(this.timeScale=.5)),this.deterministic||o.lazy===!1||typeof IntersectionObserver>`u`?this.start():(this.visible=!1,this.interObs=new IntersectionObserver(e=>{let t=e.some(e=>e.isIntersecting);this.visible=t,this.lastSeen=performance.now(),this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null,t?this.start():this.releasable()&&(this.releaseTimer=setTimeout(()=>this.release(),Pz)),this.updateRunning()},{rootMargin:`200px 0px`}),this.interObs.observe(e),this.armStartFallback()),r.addEventListener(`visibilitychange`,this.onVisibility)}fallbackCleanup=null;armStartFallback(){let e=this.container.ownerDocument,t=e.defaultView;if(!t)return;let n=()=>{if(this.started||this.disposed)return a();if(e.visibilityState===`hidden`||!this.container.isConnected)return;let n=this.container.getBoundingClientRect(),r=t.innerHeight||e.documentElement.clientHeight,i=t.innerWidth||e.documentElement.clientWidth;n.bottom>=-200&&n.top<=r+200&&n.right>=0&&n.left<=i&&(n.width>0||n.height>0)&&(this.visible=!0,this.lastSeen=performance.now(),this.start(),this.updateRunning(),a())},r=[setTimeout(n,500),setTimeout(n,2e3)],i=t.requestAnimationFrame(()=>i=t.requestAnimationFrame(n)),a=()=>{for(let e of r)clearTimeout(e);t.cancelAnimationFrame(i),t.removeEventListener(`load`,n),t.removeEventListener(`scroll`,n),e.removeEventListener(`visibilitychange`,n),this.fallbackCleanup=null};t.addEventListener(`load`,n),t.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`visibilitychange`,n),this.fallbackCleanup=a}createRenderer(){let e=this.scene.target??{},t=new dg({canvas:this.canvas,antialias:e.antialias!==!1,alpha:!!e.transparent,premultipliedAlpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:this.deterministic});if(!t.getContext())throw Error(`no context`);return this.configureRenderer(t),t.info.autoReset=!1,t}configureRenderer(e){let t=this.scene.target??{};e.outputColorSpace=Br,e.toneMapping=Az[t.toneMapping??`aces`]??4,e.toneMappingExposure=t.exposure??1,this.quality=Ax(jx(t.quality,this.deviceHints(e))),this.qualityAuto=(t.quality??`auto`)===`auto`&&!this.deterministic&&!this.options.editor,this.perfClock=this.slowFor=0;let n=this.options.pixelRatio??Math.min(globalThis.devicePixelRatio||1,t.maxDpr??2,this.quality.dprCap);e.setPixelRatio(n);let r=eE(this.scene);if(e.shadowMap.enabled=r.enabled,e.shadowMap.type=r.type,t.transparent)e.setClearColor(0,0);else{let t=this.scene.environment?.background;e.setClearColor(typeof t==`string`&&t!==`transparent`?AS(t):new H(0),1)}}start(){if(!(this.started||this.disposed)){if(this.started=!0,Iz(this),this.released){let e=this.container.ownerDocument.createElement(`canvas`);e.style.cssText=this.canvas.style.cssText,this.canvas.replaceWith(e),this.canvas=e,this.released=!1}try{this.renderer=this.createRenderer(),Fz.add(this)}catch(e){this.report({code:`webgl-unavailable`,message:`WebGL is not available: ${e.message}`}),this.readyReject(/* @__PURE__ */ Error(`webgl-unavailable`));return}this.measure(),this.renderer.setSize(this.width,this.height,!1),this.building=this.buildAll().then(()=>{this.disposed||(this.deterministic?(this.t=0,this.frame(0)):this.staticMotion?(this.t=this.scene.target?.posterTime??0,this.game?.advanceTo(this.t),this.frame(0),this.renderStill()):(this.frame(0),this.playing=!0,this.updateRunning()),this.placeholder?.remove(),this.placeholder=null,this.readyResolve(),this.readyCalled||this.options.onReady?.(this),this.readyCalled=!0)}).catch(e=>{this.report({code:`build-error`,message:e.message}),this.readyReject(e)})}}makeContext(e){return{scene:this.scene,rng:dv(this.scene.seed??1),siblings:/* @__PURE__ */ new Map,color:e=>AS(e),resolveAsset:this.resolveAsset,renderer:this.renderer,deterministic:this.deterministic,quality:this.quality.tier,track:t=>(e.push(t.catch(()=>void 0)),this.trackProgress(t),t),onUpdate:()=>void 0,issue:(e,t,n)=>this.report({code:e,message:t,path:n}),shaders:Ex,generators:Dx}}async buildWorld(){let e=[],t=this.makeContext(e),n=await BA.create(u(this.scene),t,this.width/Math.max(this.height,1),this.canvas,!!this.options.editor);return await Promise.all(e),await Promise.all(e),n.setViewport(this.width,this.height,this.renderer.getPixelRatio()),n}async attachWorld(e){this.world=e,this.attachMotion(e),e.settleEntrances=this.staticMotion,await this.buildPostFx(e),this.renderer?.shadowMap&&(this.renderer.shadowMap.needsUpdate=!0);for(let e of this.worldListeners)try{e()}catch{}}async buildAll(){let e=await this.buildWorld();if(this.disposed)e.dispose();else{if(await this.attachWorld(e),jz(this.scene)){let{GameHost:t}=await Promise.resolve().then(()=>($L(),qL));this.game=await t.create({scene:u(this.scene),container:this.container,input:this.inputState,resolveAsset:this.resolveAsset,scriptSources:this.options.scriptSources,deterministic:this.deterministic,issue:e=>this.report(e),rebuild:async()=>{let e=this.world,t=await this.buildWorld();return e?.dispose(),await this.attachWorld(t),t}},e);let n=this.game,r=n.emit.bind(n);n.emit=(e,t)=>{r(e,t),this.notify(e,t),this.dispatchMotionEvent(e,t)}}try{this.renderer?.compile(e.scene,e.camera)}catch{}}}loadTotal=0;loadDone=0;trackProgress(e){if(!this.options.onProgress)return;this.loadTotal++;let t=()=>{this.loadDone++;try{this.options.onProgress?.(this.loadDone,this.loadTotal)}catch{}};e.then(t,t)}notify(e,t){try{this.options.onEvent?.(e,t)}catch{}}emit(e,t){if(this.game)return this.game.emit(e,t);this.notify(e,t),this.dispatchMotionEvent(e,t)}dispatchMotionEvent(e,t){for(let n of this.eventListeners.get(e)??[])try{n(t)}catch{}this.interactions?.event(e,t)}report(e){this.issues.push(e);try{this.options.onError?.(e)}catch{}this.options.onError||console.warn(`[agent3d] ${e.code}: ${e.message}`)}updateRunning(){let e=this.container.ownerDocument.visibilityState===`hidden`,t=this.scene.target?.pauseOffscreen!==!1,n=this.playing&&!this.disposed&&!e&&(this.visible||!t)&&!!this.world;if(n&&!this.raf){this.lastNow=performance.now();let e=t=>{this.raf=requestAnimationFrame(e);let n=Math.min(Math.max((t-this.lastNow)/1e3,0),.1);this.lastNow=t,n>.002&&(this.fps=this.fps?this.fps*.9+1/n*.1:1/n),this.qualityAuto&&this.adaptQuality(n),this.tick(n*this.timeScale)};this.raf=requestAnimationFrame(e)}else!n&&this.raf&&(cancelAnimationFrame(this.raf),this.raf=0)}tick(e){this.world&&!this.rebuilding&&(this.game?.pendingRestart?(this.rebuilding=!0,this.game.restart().then(()=>{this.rebuilding=!1,this.t=0,this.resetMotion()})):(e=Math.max(e,0),this.t=Math.max(this.t+e,0),this.game?.advance(e),this.frame(e)))}attachMotion(e){this.tl=this.scene.timeline?new $A(this.scene.timeline):null,this.tlScroll=null,e.postfxParam=(e,t,n)=>this.postfx?.setParam?.(e,t,n);let t=this.scene.interactions??[];this.interactions=t.length?new nj(t,{play:(e,t)=>this.playSegment(e,{reverse:t}),toggle:e=>{this.tl?.toggle(e,this.t)||this.unknownSegment(e)},seek:e=>this.tl?.seek(e,this.t),set:(t,n,r,i)=>e.overrides.set(t,n,this.t,r,i),emit:(e,t)=>this.emit(e,t),openUrl:(e,t)=>this.openUrl(e,t),playClip:(t,n,r)=>{let i=e.entries.get(t)?.animator;i?i.play(n,r):this.report({code:`interaction`,message:`playClip: "${t}" is not a model with animation clips`,path:`interactions`})}}):null}handledClicks=0;handledKeys=/* @__PURE__ */ new Set;inputInteractions(){let e=this.world;if(!this.deterministic||!this.interactions||!e)return;let t=this.inputState,n=e.interactiveRoots(),r=new Set(t.pointer.inside?this.pickIds(t.pointer.x,t.pointer.y,n):[]),i=/* @__PURE__ */ new Set;for(let e of t.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,n))i.add(t);let a=new Set([...t.pressed].filter(e=>!this.handledKeys.has(e)));this.interactions.step({hovered:r,pointerInside:t.pointer.inside,clicked:i,canvasClicked:t.clicks.length>this.handledClicks,pressed:a,scroll:this.scrollValue(),visible:!0,userGesture:!1}),this.handledClicks=t.clicks.length;for(let e of a)this.handledKeys.add(e)}resetMotion(){this.tl?.reset(),this.interactions?.reset(),this.tlScroll=null}unknownSegment(e){this.report({code:`interaction`,message:`Unknown timeline segment "${e}"`,path:`timeline.segments`})}timelineLocal(e,t,n){let r=this.scene.timeline;return!r||!this.world?.timeline||!this.tl?null:this.tl.update({t:this.t,dt:e,deterministic:this.deterministic,staticMotion:this.staticMotion,posterTime:this.scene.target?.posterTime,hovered:t,clicked:n,scroll:r.trigger===`scroll`?this.timelineScroll(e):0})}timelineScroll(e){let t=this.scene.timeline;if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion)return this.scrollValue();let n=this.container.ownerDocument.defaultView,r=this.container.getBoundingClientRect(),i=sj(r.top,r.height,n?.innerHeight||1,t.scroll?.start,t.scroll?.end),a=Math.min(Math.max(t.scroll?.smoothing??.8,0),.99);return this.tlScroll===null||a<=0?this.tlScroll=i:this.tlScroll+=(i-this.tlScroll)*(1-a**(Math.max(e,0)*60)),Math.abs(i-this.tlScroll)<1e-4&&(this.tlScroll=i),this.tlScroll}scrollValue(){if(this.scrollOverride!==null)return this.scrollOverride;if(this.deterministic||this.staticMotion){let e=this.scene.timeline,t=e?.trigger===`scroll`&&e.duration>0?e.duration:4;return Math.min(Math.max(this.t/t,0),1)}return qA(this.container)}openUrl(e,t){let n=this.container.ownerDocument.defaultView,r=n?ej(e,n.location.href):null;if(this.emit(`openUrl`,{url:r??e,blocked:!r||this.deterministic}),!r||!n||this.deterministic)return;let i=new URL(r).origin!==n.location.origin;t??i?n.open(r,`_blank`,`noopener,noreferrer`):n.location.assign(r)}playSegment(e,t={}){this.tl?.play(e,this.t,t)||this.unknownSegment(e)}trigger(e,t){this.interactions?.fire(e,t,!this.deterministic),this.interactions?.flush()}on(e,t){let n=this.eventListeners.get(e);return n||this.eventListeners.set(e,n=/* @__PURE__ */ new Set),n.add(t),()=>n.delete(t)}setScrollProgress(e){this.scrollOverride=e===null||!Number.isFinite(e)?null:Math.min(Math.max(e,0),1)}pickIds(e,t,n){if(!this.world||!n.length)return[];this.raycaster.setFromCamera(new z(e,t),this.world.camera);let r=this.raycaster.intersectObjects(n,!0).find(e=>e.object.visible&&!e.object.isPoints);return r?this.world.idsFor(r.object):[]}frame(e){let t=this.world;if(!t)return;let n=this.inputState,r=t.interactiveRoots();this.hovered=new Set(n.pointer.inside?this.pickIds(n.pointer.x,n.pointer.y,r):[]);let i=/* @__PURE__ */ new Set;for(let e of n.clicks){let n=this.pickIds(e.x,e.y,r);for(let e of n)i.add(e);if(this.options.onClick){let r=[...t.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object),i=n[0]??this.pickIds(e.x,e.y,r)[0]??null;try{this.options.onClick(i,{x:e.x,y:e.y})}catch{}}let a=n.map(e=>t.entries.get(e)?.def).find(e=>e&&`href`in e&&e.href);a?.href&&!this.deterministic&&this.navigate(a.href)}let a=[...this.hovered].some(e=>!!t.entries.get(e)?.def?.href)||[...this.hovered].some(e=>t.entries.get(e)?.interactive)?`pointer`:``;this.canvas.style.cursor!==a&&(this.canvas.style.cursor=a);let o=this.scrollValue(),s=i;if(this.handledClicks){s=/* @__PURE__ */ new Set;for(let e of n.clicks.slice(this.handledClicks))for(let t of this.pickIds(e.x,e.y,r))s.add(t)}this.interactions?.step({hovered:this.hovered,pointerInside:n.pointer.inside,clicked:s,canvasClicked:n.clicks.length>this.handledClicks,pressed:this.handledKeys.size?new Set([...n.pressed].filter(e=>!this.handledKeys.has(e))):n.pressed,scroll:o,visible:!0,userGesture:!this.deterministic});let c={pointer:n.pointer,scroll:o,hovered:this.hovered,clicked:i,timelineT:this.timelineLocal(e,n.pointer.inside,n.clicks.length>0)};for(let e of this.tl?.drainMarkers()??[])this.emit(e.name,{marker:e.name,time:e.time});this.interactions?.flush();let l=this.scene.camera?.follow?.target;t.frame(this.t,e,c,l?t.entries.get(l)?.object:null),this.game?.hud?.setTimeline(this.tl&&c.timelineT!==null?this.tl.info():null),this.game?.afterFrame(),this.render(),WA(n),this.handledClicks=0,this.handledKeys.clear()}navigate(e){let t=this.container.ownerDocument.defaultView;if(!t)return;let n=ej(e,t.location.href);if(!n)return;let r=new URL(n);r.origin===t.location.origin?t.location.assign(r.href):t.open(r.href,`_blank`,`noopener,noreferrer`)}render(e=!0){let t=this.renderer,n=this.world;if(!t||!n)return;let r=e?this.overlay:null,i=r?.viewCamera?.()??null,a=n.camera,o=i&&i!==a?{p:a.position.clone(),q:a.quaternion.clone(),proj:a.projectionMatrix.clone(),inv:a.projectionMatrixInverse.clone(),near:a.near,far:a.far}:null;if(i&&o){i.updateMatrixWorld(),i.matrixWorld.decompose(a.position,a.quaternion,new B),a.projectionMatrix.copy(i.projectionMatrix),a.projectionMatrixInverse.copy(i.projectionMatrixInverse);let e=i;typeof e.near==`number`&&(a.near=e.near,a.far=e.far),a.updateMatrixWorld(!0)}if(t.info.reset(),this.postfx?this.postfx.render(this.t,{samples:this.renderSamples}):t.render(n.scene,n.camera),this.renderSamples===1&&(this.lastStats={triangles:t.info.render.triangles,drawCalls:t.info.render.calls,geometries:t.info.memory.geometries,textures:t.info.memory.textures}),r)try{r.draw(t,a)}catch(e){this.report({code:`editor-overlay`,message:e.message}),this.overlay=null}o&&(a.position.copy(o.p),a.quaternion.copy(o.q),a.projectionMatrix.copy(o.proj),a.projectionMatrixInverse.copy(o.inv),a.near=o.near,a.far=o.far,a.updateMatrixWorld(!0))}releasable(){return!!this.renderer&&!!this.world&&!this.game&&!this.deterministic&&!this.options.editor&&!this.visible&&!this.disposed&&!this.released&&!jz(this.scene)}release(){if(!this.releasable())return;this.releaseTimer&&clearTimeout(this.releaseTimer),this.releaseTimer=null;let e=``;try{this.render(),e=this.canvas.toDataURL(`image/webp`,.85)}catch{}if(e&&e.length>32){let t=this.container.ownerDocument.createElement(`img`);t.alt=``,t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;pointer-events:none;`,t.src=e,this.placeholder?.remove(),this.placeholder=t,this.canvas.after(t)}this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.postfx?.dispose(),this.postfx=null,this.world?.dispose(),this.world=null,this.renderer?.dispose(),this.renderer?.forceContextLoss(),this.renderer=null,Fz.delete(this),this.released=!0,this.started=!1,this.building=null}play(){this.playing=!0,this.start(),this.updateRunning()}pause(){this.playing=!1,this.updateRunning(),this.deterministic||this.renderStill()}async seek(e){if(this.started||this.start(),await this.building,!this.world)return;let t=Math.max(0,e);t<this.t-1e-9&&(this.game?await this.game.restart():this.world.resetBehaviours(),this.t=0,this.resetMotion(),this.world.frame(0,0,{pointer:this.inputState.pointer,scroll:0,hovered:/* @__PURE__ */ new Set,clicked:/* @__PURE__ */ new Set,timelineT:this.world.timeline?0:null})),this.advanceMotionGrid(t);let n=t-this.t;this.t=t,this.game?.advanceTo(t),this.frame(n)}advanceMotionGrid(e){let t=this.world;if(!t||!this.deterministic||this.game||!t.hasStatefulMotion())return;let n=this.scene.camera?.follow?.target,r=n?t.entries.get(n)?.object:null;for(let n of VC(this.t,e)){let e=n-this.t;this.t=n;let i=this.inputState,a=t.interactiveRoots(),o=new Set(i.pointer.inside?this.pickIds(i.pointer.x,i.pointer.y,a):[]);t.frame(this.t,e,{pointer:i.pointer,scroll:this.scrollValue(),hovered:o,clicked:/* @__PURE__ */ new Set,timelineT:this.timelineLocal(e,i.pointer.inside,!1)},r)}}time(){return this.t}async update(e){if(await this.building,this.scene=e,!this.renderer)return;this.renderer&&this.configureRenderer(this.renderer),this.game?.dispose(),this.game=null;let t=this.world;this.world=null,t?.dispose(),this.postfx?.dispose(),this.postfx=null,this.building=this.buildAll(),await this.building,this.frame(0)}measure(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||300),t=this.container.clientHeight;t||=Math.round(e/Mz(this.scene)),this.width=e,this.height=Math.max(1,t)}resize(){this.renderer&&(this.measure(),this.renderer.setSize(this.width,this.height,!1),this.world?.setViewport(this.width,this.height,this.renderer.getPixelRatio()),this.postfx?.setSize(this.width,this.height),this.world&&(!this.raf||this.deterministic)&&this.render())}stats(){return{...this.lastStats,fps:this.deterministic?void 0:Math.round(this.fps)||void 0}}inspect(){let e=this.world,t=e?.camera,n={objects:[],camera:{position:[0,0,0],target:[0,0,0]}};if(!e||!t)return n;e.scene.updateMatrixWorld(!0),t.updateMatrixWorld(!0);let r=new Ks().setFromProjectionMatrix(new V().multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse)),i=t.getWorldPosition(new B),a=new Wa,o=new B,s;for(let c of e.entries.values()){if(!c.topLevel)continue;if(a.setFromObject(c.object),c.particles){let e=c.object.geometry;e.boundingBox&&a.copy(e.boundingBox).applyMatrix4(c.object.matrixWorld)}if(a.isEmpty())continue;let e=0,l=1/0,u=1/0,d=-1/0,f=-1/0;for(let n=0;n<8;n++)o.set(n&1?a.max.x:a.min.x,n&2?a.max.y:a.min.y,n&4?a.max.z:a.min.z),r.containsPoint(o)&&e++,o.project(t),l=Math.min(l,o.x),d=Math.max(d,o.x),u=Math.min(u,o.y),f=Math.max(f,o.y);let p=e===8?`full`:r.intersectsBox(a)?`partial`:`none`;p===`partial`&&!c.particles&&(p=lj(c.object,r)??p);let m=Math.max(-1,l),h=Math.min(1,d),g=Math.max(-1,u),_=Math.min(1,f),v=p===`none`||a.containsPoint(i)?+!!a.containsPoint(i):Math.max(0,h-m)*Math.max(0,_-g)/4;!s&&c.kind!==`particles`&&a.containsPoint(i)&&(c.kind!==`generator`||uj(c.object,i,c.def.generator===`terrain`&&c.built?.heightAt?{heightAt:c.built.heightAt}:`parts`))&&(s=c.id),n.objects.push({id:c.id,min:[a.min.x,a.min.y,a.min.z],max:[a.max.x,a.max.y,a.max.z],inView:p,screenCoverage:Math.round(Math.min(1,v)*1e3)/1e3})}let c=e.rig.orbit?e.rig.orbit.target:e.rig.rest.target;return n.camera={position:[i.x,i.y,i.z],target:[c.x,c.y,c.z]},s&&(n.camera.insideObject=s),n}snapshot(e=`image/png`,t){this.renderSamples=this.deterministic&&this.postfx?.stillSamples||1;try{this.render(!1)}finally{this.renderSamples=1}return this.canvas.toDataURL(e,t)}async snapshotHighQuality(e=16,t=`image/png`,n){this.started||this.start(),await this.building;let r=this.renderer,i=this.world;if(!r||!i)return this.canvas.toDataURL(t,n);let a=Math.max(1,Math.min(64,Math.round(e))),o=null;if(!this.postfx){let{createPostFx:e}=await Promise.resolve().then(()=>(kz(),Cz));o=e([],{renderer:r,scene:i.scene,camera:i.camera,width:this.width,height:this.height,quality:Ax(`ultra`),antialias:this.scene.target?.antialias!==!1},()=>void 0)}let s=this.postfx??o;try{return s.render(this.t,{samples:a}),this.canvas.toDataURL(t,n)}finally{o?.dispose()}}deviceHints(e){let t=globalThis.navigator??{},n;try{let t=e.getContext(),r=t.getExtension(`WEBGL_debug_renderer_info`);n=String(t.getParameter(r?r.UNMASKED_RENDERER_WEBGL:t.RENDERER)??``)}catch{}let r=t.userAgent??``;return{deterministic:this.deterministic,mobile:t.userAgentData?.mobile??/Mobi|Android|iPhone|iPad|iPod/i.test(r),cores:t.hardwareConcurrency,memoryGb:t.deviceMemory,gpu:n}}async buildPostFx(e,t=!1){if(t||(this.postfx?.dispose(),this.postfx=null),!this.scene.postfx?.length||!this.renderer)return;let{createPostFx:n}=await Promise.resolve().then(()=>(kz(),Cz));if(this.world!==e||!this.renderer)return;let r=n(this.scene.postfx,{renderer:this.renderer,scene:e.scene,camera:e.camera,width:this.width,height:this.height,quality:this.quality,antialias:this.scene.target?.antialias!==!1},e=>this.report({code:`unknown-catalog-id`,message:`Unknown post effect "${e}"`,path:`postfx`}));if(await r.ready,this.world!==e)return r.dispose();this.postfx?.dispose(),this.postfx=r}renderStill(){let e=this.postfx?.stillSamples??0;if(!(e<2||!this.world)){this.renderSamples=e;try{this.render()}finally{this.renderSamples=1}}}adaptQuality(e){let t=this.renderer;if(!t||!this.world||this.rebuilding||(this.perfClock+=e,this.perfClock<2)||(this.fps<40?this.slowFor+=e:this.slowFor=Math.max(0,this.slowFor-e),this.slowFor<3))return;if(this.slowFor=0,this.perfClock=0,this.options.pixelRatio===void 0&&t.getPixelRatio()>1.01){t.setPixelRatio(Math.max(1,t.getPixelRatio()*.75)),this.resize();return}let n=Mx(this.quality.tier);n?(this.quality=Ax(n),this.scene.postfx?.length&&this.buildPostFx(this.world,!0)):this.qualityAuto=!1}pick(e,t){let n=this.world;if(!n)return null;let r=[...n.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object);return this.pickIds(e,t,r)[0]??null}state(){return this.game?.state??{}}dispose(){this.disposed||(this.disposed=!0,this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.resizeObs?.disconnect(),this.interObs?.disconnect(),this.fallbackCleanup?.(),this.container.ownerDocument.removeEventListener(`visibilitychange`,this.onVisibility),this.inputBinding?.dispose(),this.overlay=null,this.worldListeners.clear(),this.game?.dispose(),this.postfx?.dispose(),this.world?.dispose(),this.renderer?.dispose(),this.renderer?.forceContextLoss(),Fz.delete(this),this.releaseTimer&&clearTimeout(this.releaseTimer),this.placeholder?.remove(),this.canvas.remove())}};function zz(e,t,n={}){let r=new Rz(e,t,n);return r.canvas.isConnected&&r.resize(),r}var Bz=typeof HTMLElement<`u`?HTMLElement:class{},Vz=`
|
|
7342
7591
|
:host{display:block;position:relative;width:100%;overflow:hidden;background:var(--agent3d-background,transparent);contain:layout paint;-webkit-tap-highlight-color:transparent}
|
|
7343
7592
|
:host([hidden]){display:none}
|
|
7344
7593
|
:host([interactive="false"]) ::slotted(*){pointer-events:none}
|
|
@@ -7357,4 +7606,4 @@ void main() {
|
|
|
7357
7606
|
:host([status="unsupported"]) .poster,:host([status="error"]) .poster{opacity:1}
|
|
7358
7607
|
@media (prefers-reduced-motion:reduce){.loading.indeterminate .bar{animation:none;width:100%;opacity:.3}.poster{transition:none}}
|
|
7359
7608
|
@media print{::slotted(canvas),::slotted(img){visibility:hidden}.print{display:block}.loading{display:none}.poster{opacity:1}}
|
|
7360
|
-
`,hz=null;function gz(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function _z(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function vz(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function yz(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?vz():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return u(n)}var bz=class extends pz{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(gz(this.root))hz||(hz=new CSSStyleSheet,hz.replaceSync(mz)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[hz,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=mz,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return d(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return yz(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=fz(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${_z(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=_z(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function xz(e=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(e)||customElements.define(e,bz))}xz();var Sz=globalThis;Sz.Agent3D||={mountScene:fz,version:r,bindSceneData:u,liveContexts:uz};export{bz as Agent3DSceneElement,u as bindSceneData,uz as liveContextCount,fz as mountScene,r as version};
|
|
7609
|
+
`,Hz=null;function Uz(e){try{return`adoptedStyleSheets`in e&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`}catch{return!1}}function Wz(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e??``);return!t||!(Number(t[1])>0)||!(Number(t[2])>0)?null:`${t[1]} / ${t[2]}`}function Gz(){let e=typeof navigator<`u`?navigator:{};if(e.connection?.saveData)return`low`;let t=e.hardwareConcurrency??8,n=e.deviceMemory??8;return t<=2||n<=2?`low`:t<=4||n<=4?`medium`:`high`}function Kz(e,t){let n=e;if(t.data&&Object.keys(t.data).length&&(n={...n,data:{...n.data??{},...t.data}}),t.loop!=null&&n.timeline){let e=t.loop.trim().toLowerCase(),r=e===`pingpong`?`pingpong`:e!==`false`&&e!==`0`&&e!==`no`;n={...n,timeline:{...n.timeline,loop:r}}}let r=t.quality?t.quality===`auto`?Gz():t.quality:null;if((t.quality===`low`||t.quality===`medium`||t.quality===`high`||t.quality===`ultra`)&&(n={...n,target:{...n.target,quality:t.quality}}),r===`low`||r===`medium`||r===`high`){let e=r===`low`?1:r===`medium`?1.5:2,t={...n.target,maxDpr:Math.min(n.target?.maxDpr??2,e)};r===`low`&&Object.assign(t,{antialias:!1,shadows:!1}),n={...n,target:t,...r===`low`?{postfx:void 0}:{}}}return u(n)}var qz=class extends Bz{static get observedAttributes(){return[`src`,`poster`,`aspect`,`alt`,`paused`,`loop`,`quality`,`library-base`]}player=null;ready;resolveReady;root=null;posterEl=null;posterBox=null;printEl=null;loadingEl=null;barEl=null;fallbackEl=null;sizeStyle=null;sizeSheet=null;sizeCssText=``;loadToken=0;connected=!1;source=null;dataOverrides={};dataObserver=null;interObs=null;inView=!0;lostTimer=null;wantPlay=null;autoAriaLabel=null;constructor(){super(),this.resetReady()}readySettled=!1;resetReady(){this.readySettled=!1,this.ready=new Promise(e=>this.resolveReady=e)}connectedCallback(){this.connected=!0,this.ensureShadow(),this.updatePoster(),this.applyAspect(null),this.ownerDocument.defaultView?.addEventListener(`beforeprint`,this.onBeforePrint),this.addEventListener(`webglcontextlost`,this.onContextLost,!0),this.addEventListener(`webglcontextrestored`,this.onContextRestored,!0),typeof MutationObserver<`u`&&(this.dataObserver=new MutationObserver(e=>{e.some(e=>e.attributeName?.startsWith(`data-`))&&this.refreshData()}),this.dataObserver.observe(this,{attributes:!0})),typeof IntersectionObserver<`u`&&(this.interObs=new IntersectionObserver(e=>this.inView=e.some(e=>e.isIntersecting)),this.interObs.observe(this)),this.load()}disconnectedCallback(){this.connected=!1,this.loadToken++,this.ownerDocument.defaultView?.removeEventListener(`beforeprint`,this.onBeforePrint),this.removeEventListener(`webglcontextlost`,this.onContextLost,!0),this.removeEventListener(`webglcontextrestored`,this.onContextRestored,!0),this.dataObserver?.disconnect(),this.dataObserver=null,this.interObs?.disconnect(),this.interObs=null,this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null,this.player?.dispose(),this.player=null,this.setStatus(`idle`)}attributeChangedCallback(e,t,n){this.connected&&t!==n&&(e===`poster`||e===`alt`?this.updatePoster():e===`aspect`?this.applyAspect(this.source):e===`paused`?n===null?this.getAttribute(`status`)===`ready`&&this.player?.play():this.player?.pause():e===`src`?(this.source=null,this.load()):this.rebuild())}play(){this.wantPlay=!0,this.hasAttribute(`paused`)&&this.removeAttribute(`paused`),this.player?.play()}pause(){this.wantPlay=!1,this.player?.pause()}async seek(e){await(this.player??await this.ready).seek(e)}get data(){return{...this.source?.data??{},...this.attrData(),...this.dataOverrides}}async setData(e,t={}){this.dataOverrides=t.replace?{...e}:{...this.dataOverrides,...e},await this.rebuild()}trigger(e,t){this.player?.emit?this.player.emit(e,t):this.ready.then(n=>n.emit?.(e,t))}reload(){return this.source=null,this.load()}ensureShadow(){if(this.root||typeof this.attachShadow!=`function`)return;let e=this.ownerDocument;this.root=this.shadowRoot??this.attachShadow({mode:`open`});let t=[];if(Uz(this.root))Hz||(Hz=new CSSStyleSheet,Hz.replaceSync(Vz)),this.sizeSheet=new CSSStyleSheet,this.root.adoptedStyleSheets=[Hz,this.sizeSheet];else{let n=e.createElement(`style`);n.textContent=Vz,this.sizeStyle=e.createElement(`style`),t=[n,this.sizeStyle]}let n=e.createElement(`slot`);this.posterBox=e.createElement(`div`),this.posterBox.className=`poster`,this.posterBox.setAttribute(`part`,`poster`);let r=e.createElement(`slot`);r.name=`poster`,this.posterEl=e.createElement(`img`),this.posterEl.setAttribute(`part`,`poster-image`),this.posterEl.decoding=`async`,r.appendChild(this.posterEl),this.posterBox.appendChild(r),this.printEl=e.createElement(`img`),this.printEl.className=`print`,this.printEl.alt=``,this.loadingEl=e.createElement(`div`),this.loadingEl.className=`loading indeterminate`,this.loadingEl.setAttribute(`part`,`loading`),this.loadingEl.setAttribute(`aria-hidden`,`true`),this.barEl=e.createElement(`div`),this.barEl.className=`bar`,this.barEl.setAttribute(`part`,`loading-bar`),this.loadingEl.appendChild(this.barEl),this.fallbackEl=e.createElement(`div`),this.fallbackEl.className=`fallback`,this.fallbackEl.setAttribute(`part`,`fallback`);let i=e.createElement(`slot`);i.name=`fallback`,this.fallbackEl.appendChild(i),this.root.append(...t,n,this.posterBox,this.printEl,this.loadingEl,this.fallbackEl)}updatePoster(){let e=this.posterEl;if(!e)return;let t=this.getAttribute(`poster`);e.alt=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``,t?e.getAttribute(`src`)!==t&&(e.src=t):e.removeAttribute(`src`),this.posterBox&&(this.posterBox.hidden=!this.posterSrc()),this.updateFallbackText()}posterSrc(){let e=this.querySelector(`[slot="poster"]`),t=e?.tagName===`IMG`?e:e?.querySelector(`img`);return t?.currentSrc||t?.getAttribute(`src`)||this.getAttribute(`poster`)}updateFallbackText(){let e=this.fallbackEl;if(!e)return;let t=e.querySelector(`slot`),n=!!this.querySelector(`[slot="fallback"]`),r=!!this.posterSrc();e.classList.toggle(`show`,n||!r),t&&!n&&(t.textContent=this.getAttribute(`alt`)??this.getAttribute(`aria-label`)??``)}setStatus(e){e===`idle`?this.removeAttribute(`status`):this.setAttribute(`status`,e),(e===`unsupported`||e===`error`)&&this.updateFallbackText()}progress(e,t){this.loadingEl&&this.barEl&&t>0&&(this.loadingEl.classList.remove(`indeterminate`),this.barEl.style.width=`${Math.round(Math.min(e,t)/t*100)}%`),this.emit(`agent3d:progress`,{loaded:e,total:t})}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}fail(e){this.emit(`agent3d:error`,e),this.emit(`agent3d-error`,e)}onBeforePrint=()=>{let e=this.printEl;if(!e)return;let t=``;try{this.player&&this.getAttribute(`status`)===`ready`&&(t=this.player.snapshot(`image/png`))}catch{}(!t||t.length<32)&&(t=this.posterSrc()??``),t?e.src=t:e.removeAttribute(`src`)};onContextLost=e=>{this.player&&this.inView&&this.getAttribute(`status`)===`ready`&&(e.preventDefault(),this.fail({code:`context-lost`,message:`The WebGL context was lost; restoring.`}),this.setStatus(`loading`),this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=setTimeout(()=>{this.lostTimer=null,this.rebuild(!0)},3e3))};onContextRestored=()=>{this.lostTimer&&clearTimeout(this.lostTimer),this.lostTimer=null;let e=this.player;e&&e.update(e.scene).then(()=>this.setStatus(`ready`),()=>void this.rebuild(!0))};childJson(e){let t=this.querySelector(e);if(t?.textContent)try{return JSON.parse(t.textContent)}catch(e){this.fail({code:`invalid-scene`,message:`Invalid inline JSON: ${e.message}`});return}}attrData(){return d(this.dataset??{})}refreshData(){this.source&&this.rebuild()}base(){let e=this.getAttribute(`src`);return e?new URL(`.`,new URL(e,this.ownerDocument.baseURI)).href:this.ownerDocument.baseURI}async fetchScene(){let e=this.childJson(`script[type="application/json"]:not([data-assets])`);if(e)return e;let t=this.getAttribute(`src`);if(!t)return;let n=new URL(t,this.ownerDocument.baseURI).href,r=await fetch(n);if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()}async load(){let e=++this.loadToken;if(!this.source){this.setStatus(`loading`);let t;try{if(t=await this.fetchScene(),!t&&this.ownerDocument.readyState===`loading`){if(await new Promise(e=>this.ownerDocument.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})),e!==this.loadToken)return;t=await this.fetchScene()}}catch(t){if(e!==this.loadToken)return;this.setStatus(`error`),this.fail({code:`scene-load`,message:`Cannot load ${this.getAttribute(`src`)}: ${t.message}`,path:this.getAttribute(`src`)??void 0});return}if(e!==this.loadToken)return;if(!t){this.setStatus(`idle`);return}this.source=t}await this.mount(e)}async rebuild(e=!1){if(!this.connected||!this.source)return;let t=this.player;if(t&&!e&&this.getAttribute(`status`)===`ready`&&this.getAttribute(`library-base`)===this.mountedLibraryBase){let e=this.sceneForMount();this.applySizing(e),await t.update(e)}else await this.mount(++this.loadToken)}sceneForMount(){return Kz(this.source,{data:{...this.attrData(),...this.dataOverrides},loop:this.getAttribute(`loop`),quality:this.getAttribute(`quality`)})}mountedLibraryBase=null;async mount(e){this.player?.dispose(),this.player=null,this.readySettled&&this.resetReady(),this.setStatus(`loading`);let t=this.sceneForMount();this.applySizing(t);let n=this.childJson(`script[data-assets]`),r={};this.querySelectorAll(`script[type="text/agent3d-script"][data-path]`).forEach(e=>{r[e.getAttribute(`data-path`)]=e.textContent??``});let i=this.getAttribute(`library-base`);this.mountedLibraryBase=i;let a=zz(this,t,{assetBase:this.base(),libraryBase:i?new URL(i,this.ownerDocument.baseURI).href:void 0,assetUrls:n,scriptSources:Object.keys(r).length?r:void 0,onError:t=>{e===this.loadToken&&(t.code===`webgl-unavailable`&&this.setStatus(`unsupported`),this.fail(t))},onEvent:(t,n)=>e===this.loadToken&&this.emit(`agent3d:event`,{name:t,payload:n}),onClick:(t,n)=>e===this.loadToken&&this.emit(`agent3d:click`,{id:t,x:n.x,y:n.y}),onProgress:(t,n)=>e===this.loadToken&&this.progress(t,n)});this.player=a;try{await a.ready}catch{e===this.loadToken&&this.getAttribute(`status`)!==`unsupported`&&this.setStatus(`error`);return}if(e!==this.loadToken)return;let o=(this.getAttribute(`autoplay`)??``).toLowerCase();(this.hasAttribute(`paused`)||this.wantPlay===!1||this.wantPlay!==!0&&(o===`false`||o===`0`||o===`no`))&&a.pause(),this.setStatus(`ready`),this.readySettled=!0,this.resolveReady(a),this.emit(`agent3d:ready`,{player:a}),this.emit(`agent3d-ready`,{player:a})}applyAspect(e){if(!this.sizeStyle&&!this.sizeSheet)return;let t=e?.target,n;n=t?.height?`:host{height:${t.height}}`:t?.kind===`fullscreen`?`:host{height:100vh;height:100dvh}`:`:host{aspect-ratio:${Wz(e?t?.aspect??this.getAttribute(`aspect`):this.getAttribute(`aspect`)??`16:9`)??`16 / 9`}}`,this.sizeCssText!==n&&(this.sizeCssText=n,this.sizeSheet?this.sizeSheet.replaceSync(n):this.sizeStyle&&(this.sizeStyle.textContent=n))}applySizing(e){if(this.sizeStyle||this.sizeSheet)this.applyAspect(e);else{this.style.display||(this.style.display=`block`),this.style.width||(this.style.width=`100%`),this.style.position||(this.style.position=`relative`);let t=Wz(e.target?.aspect)??`16 / 9`;e.target?.height?this.style.height=e.target.height:this.style.aspectRatio=t}let t=e.target?.kind===`game`;this.setAttribute(`role`,t?`application`:`img`);let n=this.getAttribute(`aria-label`);(n===null||n===this.autoAriaLabel)&&(this.autoAriaLabel=e.ariaLabel||e.title||`3D scene`,this.setAttribute(`aria-label`,this.autoAriaLabel)),t&&!this.hasAttribute(`tabindex`)&&(this.tabIndex=0),this.updatePoster()}};function Jz(e=`agent3d-scene`){typeof customElements<`u`&&(customElements.get(e)||customElements.define(e,qz))}Jz();var Yz=globalThis;Yz.Agent3D||={mountScene:zz,version:r,bindSceneData:u,liveContexts:Lz};export{qz as Agent3DSceneElement,u as bindSceneData,Lz as liveContextCount,zz as mountScene,r as version};
|