mirror of
https://github.com/samvallad33/vestige.git
synced 2026-07-24 23:41:01 +02:00
Turn all 17 sparse organs from text-on-black voids into full-bleed, moving, bioluminescent WebGPU fields. Each cell maps to a real backend fact; verified live on the real brain with a decoded fill% + motion + zero-error probe. Foundation: one reusable LivingFieldPass (src/lib/observatory/field/) does splat -> separable-blur (render passes) -> membrane base coat -> HDR cells with orbital drift and a CPU pick-mirror. Each organ writes a ~20-line data->cells mapper (cell-layout.ts: layoutGalaxy / layoutRings / FIELD_HUE). Organs brought alive (fill% before -> after, all zero WebGPU errors): stats 0.8->80.9, observatory 10.8->81.4, graph 12.3->82.4, memories ->78.4, blackbox 18.2->83.3, contradictions 1.6->69.6, dreams 0.3->64.5, settings 2.7->76.4, reasoning 2.7->39.2, patterns 7.1->45.6, activation 10->64.9, feed ->89, explore ->83.3, intentions ->66.6, importance ->73.7, memory-prs ->74.4, schedule ->37.1. Backend surfaces: add api.memoryChangelog() + ChangelogResponse; surface suppress/unsuppress on the memories field (shift/alt-click -> scar). Tests: palace-launch-gate now asserts fillPct>30 + isAnimating (not just non-black), with a longer settle for reasoning's deep_reference and a raised timeout for the curated tour. all-routes-smoke treats settings as the WebGPU field it now is. Gates green: check 0/0, build ok, palace-launch-gate 22/22 + tour, all-routes-smoke 20/20. Protected work untouched: MemoryCinema, graph/cinema, observatory scene shaders, node-renderer, palace-map. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1331 lines
458 KiB
JavaScript
1331 lines
458 KiB
JavaScript
var Ol=Object.defineProperty;var Dl=(l,t,e)=>t in l?Ol(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var z=(l,t,e)=>Dl(l,typeof t!="symbol"?t+"":t,e);import{bf as Ll,i as Nl,w as Ul,ai as Vl,p as Wn,c as ot,r as at,X as ct,Y as jt,a as mt,b as Hn,f as vt,aS as Ph,aH as Fh,g as F,u as Bn,j as ji,d as xt,e as Gl,s as rt,bg as Wl,af as Hl}from"./CGq8RnJq.js";import{B as ql}from"./W8qDZJD6.js";import"./Bzak7iHL.js";import{d as Rh,s as Ot,b as Ri,o as Xl,e as Yl}from"./DAau0uzT.js";import{i as _t,b as Jl}from"./Ccqjq5DS.js";import{e as Eh,s as Cn,r as Zl}from"./DqfV0sZu.js";import{s as vs}from"./uCQU803Y.js";import{b as $l}from"./DGM4cicq.js";import{p as ut,a as jl,s as Kl}from"./DV6OI5iy.js";import{a as Ql}from"./D35IQVqe.js";import{e as tc}from"./Ch9vNiEl.js";import{b as ec}from"./DY7cP31Q.js";import{s as Hr}from"./HFGAk8XQ.js";import{t as ic,d as Oh,N as me,U as ir,F as Mt,b as Ki,P as ze,c as Qi,f as ea,L as At,g as zt,O as sc,D as nc}from"./BMB5u1EX.js";import{o as Ya}from"./BKh9s_e0.js";import{N as Ja}from"./CcUbQ_Wl.js";const rc=Symbol("NaN");function g0(l,t,e){Ul&&Vl();var i=new ql(l),s=!Ll();Nl(()=>{var n=t();n!==n&&(n=rc),s&&n!==null&&typeof n=="object"&&(n={}),i.ensure(n,e)})}/**
|
||
* @license
|
||
* Copyright 2010-2024 Three.js Authors
|
||
* SPDX-License-Identifier: MIT
|
||
*/const Dh="172",y0={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},x0={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},b0=0,v0=1,w0=2,_0=3,M0=0,S0=1,A0=2,I0=3,qr=0,Lh=1,T0=2,ac=0,Za=1,oc=2,C0=3,B0=4,z0=5,$a=100,k0=101,P0=102,F0=103,R0=104,E0=200,O0=201,D0=202,L0=203,ja=204,Ka=205,N0=206,U0=207,V0=208,G0=209,W0=210,H0=211,q0=212,X0=213,Y0=214,J0=0,Z0=1,$0=2,Qa=3,j0=4,K0=5,Q0=6,tg=7,ia=0,eg=1,ig=2,sg=0,ng=1,rg=2,ag=3,og=4,hg=5,lg=6,cg=7,to="attached",hc="detached",sa=300,na=301,lc=302,cc=303,uc=304,dc=306,Xr=1e3,ge=1001,Yr=1002,pe=1003,fc=1004,ug=1004,pc=1005,dg=1005,ae=1006,mc=1007,fg=1007,qn=1008,pg=1008,Nh=1009,gc=1010,yc=1011,xc=1012,bc=1013,ra=1014,Gi=1015,vc=1016,wc=1017,_c=1018,Mc=1020,Sc=35902,Ac=1021,Ic=1022,As=1023,Tc=1024,Cc=1025,sr=1026,eo=1027,Uh=1028,Vh=1029,Bc=1030,zc=1031,mg=1032,kc=1033,Pc=33776,Fc=33777,Rc=33778,Ec=33779,Oc=35840,Dc=35841,Lc=35842,Nc=35843,Uc=36196,Vc=37492,Gc=37496,Wc=37808,Hc=37809,qc=37810,Xc=37811,Yc=37812,Jc=37813,Zc=37814,$c=37815,jc=37816,Kc=37817,Qc=37818,tu=37819,eu=37820,iu=37821,su=36492,nu=36494,ru=36495,au=36283,ou=36284,hu=36285,lu=36286,cu=2200,uu=2201,du=2202,zn=2300,Jr=2301,nr=2302,Ei=2400,Oi=2401,kn=2402,aa=2500,Gh=2501,gg=0,yg=1,xg=2,fu=3200,bg=3201,vg=3202,wg=3203,Hi=0,_g=1,Wh="",ne="srgb",io="srgb-linear",so="linear",rr="srgb",Mg=0,pi=7680,Sg=7681,Ag=7682,Ig=7683,Tg=34055,Cg=34056,Bg=5386,zg=512,kg=513,Pg=514,Fg=515,Rg=516,Eg=517,Og=518,no=519,Dg=512,Lg=513,Ng=514,Ug=515,Vg=516,Gg=517,Wg=518,Hg=519,Pn=35044,qg=35048,Xg=35040,Yg=35045,Jg=35049,Zg=35041,$g=35046,jg=35050,Kg=35042,Qg="100",ty="300 es",Be=2e3,Fn=2001;class Xe{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,t);t.target=null}}}const kt=["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"];let ro=1234567;const ai=Math.PI/180,Is=180/Math.PI;function Qt(){const l=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(kt[l&255]+kt[l>>8&255]+kt[l>>16&255]+kt[l>>24&255]+"-"+kt[t&255]+kt[t>>8&255]+"-"+kt[t>>16&15|64]+kt[t>>24&255]+"-"+kt[e&63|128]+kt[e>>8&255]+"-"+kt[e>>16&255]+kt[e>>24&255]+kt[i&255]+kt[i>>8&255]+kt[i>>16&255]+kt[i>>24&255]).toLowerCase()}function X(l,t,e){return Math.max(t,Math.min(e,l))}function oa(l,t){return(l%t+t)%t}function pu(l,t,e,i,s){return i+(l-t)*(s-i)/(e-t)}function mu(l,t,e){return l!==t?(e-l)/(t-l):0}function ws(l,t,e){return(1-e)*l+e*t}function gu(l,t,e,i){return ws(l,t,1-Math.exp(-e*i))}function yu(l,t=1){return t-Math.abs(oa(l,t*2)-t)}function xu(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*(3-2*l))}function bu(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*l*(l*(l*6-15)+10))}function vu(l,t){return l+Math.floor(Math.random()*(t-l+1))}function wu(l,t){return l+Math.random()*(t-l)}function _u(l){return l*(.5-Math.random())}function Mu(l){l!==void 0&&(ro=l);let t=ro+=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 Su(l){return l*ai}function Au(l){return l*Is}function Iu(l){return(l&l-1)===0&&l!==0}function Tu(l){return Math.pow(2,Math.ceil(Math.log(l)/Math.LN2))}function Cu(l){return Math.pow(2,Math.floor(Math.log(l)/Math.LN2))}function Bu(l,t,e,i,s){const n=Math.cos,r=Math.sin,a=n(e/2),o=r(e/2),h=n((t+i)/2),c=r((t+i)/2),u=n((t-i)/2),d=r((t-i)/2),f=n((i-t)/2),p=r((i-t)/2);switch(s){case"XYX":l.set(a*c,o*u,o*d,a*h);break;case"YZY":l.set(o*d,a*c,o*u,a*h);break;case"ZXZ":l.set(o*u,o*d,a*c,a*h);break;case"XZX":l.set(a*c,o*p,o*f,a*h);break;case"YXY":l.set(o*f,a*c,o*p,a*h);break;case"ZYZ":l.set(o*p,o*f,a*c,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Dt(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return l/4294967295;case Uint16Array:return l/65535;case Uint8Array:return l/255;case Int32Array:return Math.max(l/2147483647,-1);case Int16Array:return Math.max(l/32767,-1);case Int8Array:return Math.max(l/127,-1);default:throw new Error("Invalid component type.")}}function Y(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return Math.round(l*4294967295);case Uint16Array:return Math.round(l*65535);case Uint8Array:return Math.round(l*255);case Int32Array:return Math.round(l*2147483647);case Int16Array:return Math.round(l*32767);case Int8Array:return Math.round(l*127);default:throw new Error("Invalid component type.")}}const ey={DEG2RAD:ai,RAD2DEG:Is,generateUUID:Qt,clamp:X,euclideanModulo:oa,mapLinear:pu,inverseLerp:mu,lerp:ws,damp:gu,pingpong:yu,smoothstep:xu,smootherstep:bu,randInt:vu,randFloat:wu,randFloatSpread:_u,seededRandom:Mu,degToRad:Su,radToDeg:Au,isPowerOfTwo:Iu,ceilPowerOfTwo:Tu,floorPowerOfTwo:Cu,setQuaternionFromProperEuler:Bu,normalize:Y,denormalize:Dt};class B{constructor(t=0,e=0){B.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(X(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*s+t.x,this.y=n*s+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class be{constructor(t,e,i,s,n,r,a,o,h){be.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,o,h)}set(t,e,i,s,n,r,a,o,h){const c=this.elements;return c[0]=t,c[1]=s,c[2]=a,c[3]=e,c[4]=n,c[5]=o,c[6]=i,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[3],o=i[6],h=i[1],c=i[4],u=i[7],d=i[2],f=i[5],p=i[8],m=s[0],g=s[3],x=s[6],y=s[1],b=s[4],v=s[7],_=s[2],M=s[5],A=s[8];return n[0]=r*m+a*y+o*_,n[3]=r*g+a*b+o*M,n[6]=r*x+a*v+o*A,n[1]=h*m+c*y+u*_,n[4]=h*g+c*b+u*M,n[7]=h*x+c*v+u*A,n[2]=d*m+f*y+p*_,n[5]=d*g+f*b+p*M,n[8]=d*x+f*v+p*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8];return e*r*c-e*a*h-i*n*c+i*a*o+s*n*h-s*r*o}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],u=c*r-a*h,d=a*o-c*n,f=h*n-r*o,p=e*u+i*d+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return t[0]=u*m,t[1]=(s*h-c*i)*m,t[2]=(a*i-s*r)*m,t[3]=d*m,t[4]=(c*e-s*o)*m,t[5]=(s*n-a*e)*m,t[6]=f*m,t[7]=(i*o-h*e)*m,t[8]=(r*e-i*n)*m,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,n,r,a){const o=Math.cos(n),h=Math.sin(n);return this.set(i*o,i*h,-i*(o*r+h*a)+r+t,-s*h,s*o,-s*(-h*r+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(ar.makeScale(t,e)),this}rotate(t){return this.premultiply(ar.makeRotation(-t)),this}translate(t,e){return this.premultiply(ar.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ar=new be;function zu(l){for(let t=l.length-1;t>=0;--t)if(l[t]>=65535)return!0;return!1}const ku={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Di(l,t){return new ku[l](t)}function Rn(l){return document.createElementNS("http://www.w3.org/1999/xhtml",l)}function iy(){const l=Rn("canvas");return l.style.display="block",l}const ao={};function sy(l){l in ao||(ao[l]=!0,console.warn(l))}function ny(l,t,e){return new Promise(function(i,s){function n(){switch(l.clientWaitSync(t,l.SYNC_FLUSH_COMMANDS_BIT,0)){case l.WAIT_FAILED:s();break;case l.TIMEOUT_EXPIRED:setTimeout(n,e);break;default:i()}}setTimeout(n,e)})}function ry(l){const t=l.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function ay(l){const t=l.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const oo=new be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ho=new be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pu(){const l={enabled:!0,workingColorSpace:io,spaces:{},convert:function(s,n,r){return this.enabled===!1||n===r||!n||!r||(this.spaces[n].transfer===rr&&(s.r=ke(s.r),s.g=ke(s.g),s.b=ke(s.b)),this.spaces[n].primaries!==this.spaces[r].primaries&&(s.applyMatrix3(this.spaces[n].toXYZ),s.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===rr&&(s.r=Ui(s.r),s.g=Ui(s.g),s.b=Ui(s.b))),s},fromWorkingColorSpace:function(s,n){return this.convert(s,this.workingColorSpace,n)},toWorkingColorSpace:function(s,n){return this.convert(s,n,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Wh?so:this.spaces[s].transfer},getLuminanceCoefficients:function(s,n=this.workingColorSpace){return s.fromArray(this.spaces[n].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,n,r){return s.copy(this.spaces[n].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return l.define({[io]:{primaries:t,whitePoint:i,transfer:so,toXYZ:oo,fromXYZ:ho,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:ne},outputColorSpaceConfig:{drawingBufferColorSpace:ne}},[ne]:{primaries:t,whitePoint:i,transfer:rr,toXYZ:oo,fromXYZ:ho,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:ne}}}),l}const $t=Pu();function ke(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function Ui(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}let mi;class Fu{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{mi===void 0&&(mi=Rn("canvas")),mi.width=t.width,mi.height=t.height;const i=mi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=mi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Rn("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r<n.length;r++)n[r]=ke(n[r]/255)*255;return i.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(ke(e[i]/255)*255):e[i]=ke(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Ru=0;class Li{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Ru++}),this.uuid=Qt(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let r=0,a=s.length;r<a;r++)s[r].isDataTexture?n.push(or(s[r].image)):n.push(or(s[r]))}else n=or(s);i.url=n}return e||(t.images[this.uuid]=i),i}}function or(l){return typeof HTMLImageElement<"u"&&l instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&l instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&l instanceof ImageBitmap?Fu.getDataURL(l):l.data?{data:Array.from(l.data),width:l.width,height:l.height,type:l.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Eu=0;class yt extends Xe{constructor(t=yt.DEFAULT_IMAGE,e=yt.DEFAULT_MAPPING,i=ge,s=ge,n=ae,r=qn,a=As,o=Nh,h=yt.DEFAULT_ANISOTROPY,c=Wh){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Eu++}),this.uuid=Qt(),this.name="",this.source=new Li(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=r,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new B(0,0),this.repeat=new B(1,1),this.center=new B(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new be,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==sa)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Xr:t.x=t.x-Math.floor(t.x);break;case ge:t.x=t.x<0?0:1;break;case Yr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Xr:t.y=t.y-Math.floor(t.y);break;case ge:t.y=t.y<0?0:1;break;case Yr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}yt.DEFAULT_IMAGE=null;yt.DEFAULT_MAPPING=sa;yt.DEFAULT_ANISOTROPY=1;class It{constructor(t=0,e=0,i=0,s=1){It.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,n;const o=t.elements,h=o[0],c=o[4],u=o[8],d=o[1],f=o[5],p=o[9],m=o[2],g=o[6],x=o[10];if(Math.abs(c-d)<.01&&Math.abs(u-m)<.01&&Math.abs(p-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(u+m)<.1&&Math.abs(p+g)<.1&&Math.abs(h+f+x-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const b=(h+1)/2,v=(f+1)/2,_=(x+1)/2,M=(c+d)/4,A=(u+m)/4,S=(p+g)/4;return b>v&&b>_?b<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(b),s=M/i,n=A/i):v>_?v<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(v),i=M/s,n=S/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=A/n,s=S/n),this.set(i,s,n,e),this}let y=Math.sqrt((g-p)*(g-p)+(u-m)*(u-m)+(d-c)*(d-c));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-m)/y,this.z=(d-c)/y,this.w=Math.acos((h+f+x-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this.z=X(this.z,t.z,e.z),this.w=X(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this.z=X(this.z,t,e),this.w=X(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}}class ha extends Xe{constructor(t=1,e=1,i={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new It(0,0,t,e),this.scissorTest=!1,this.viewport=new It(0,0,t,e);const s={width:t,height:e,depth:1};i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ae,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},i);const n=new yt(s,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace);n.flipY=!1,n.generateMipmaps=i.generateMipmaps,n.internalFormat=i.internalFormat,this.textures=[];const r=i.count;for(let a=0;a<r;a++)this.textures[a]=n.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let s=0,n=this.textures.length;s<n;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=i;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let i=0,s=t.textures.length;i<s;i++)this.textures[i]=t.textures[i].clone(),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;const e=Object.assign({},t.texture.image);return this.texture.source=new Li(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class la extends ha{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class Hh extends yt{constructor(t=null,e=1,i=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=ge,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class oy extends la{constructor(t=1,e=1,i=1,s={}){super(t,e,s),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new Hh(null,t,e,i),this.texture.isRenderTargetTexture=!0}}class qh extends yt{constructor(t=null,e=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=ge,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hy extends la{constructor(t=1,e=1,i=1,s={}){super(t,e,s),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new qh(null,t,e,i),this.texture.isRenderTargetTexture=!0}}class te{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,n,r,a){let o=i[s+0],h=i[s+1],c=i[s+2],u=i[s+3];const d=n[r+0],f=n[r+1],p=n[r+2],m=n[r+3];if(a===0){t[e+0]=o,t[e+1]=h,t[e+2]=c,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=f,t[e+2]=p,t[e+3]=m;return}if(u!==m||o!==d||h!==f||c!==p){let g=1-a;const x=o*d+h*f+c*p+u*m,y=x>=0?1:-1,b=1-x*x;if(b>Number.EPSILON){const _=Math.sqrt(b),M=Math.atan2(_,x*y);g=Math.sin(g*M)/_,a=Math.sin(a*M)/_}const v=a*y;if(o=o*g+d*v,h=h*g+f*v,c=c*g+p*v,u=u*g+m*v,g===1-a){const _=1/Math.sqrt(o*o+h*h+c*c+u*u);o*=_,h*=_,c*=_,u*=_}}t[e]=o,t[e+1]=h,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,n,r){const a=i[s],o=i[s+1],h=i[s+2],c=i[s+3],u=n[r],d=n[r+1],f=n[r+2],p=n[r+3];return t[e]=a*p+c*u+o*f-h*d,t[e+1]=o*p+c*d+h*u-a*f,t[e+2]=h*p+c*f+a*d-o*u,t[e+3]=c*p-a*u-o*d-h*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,a=Math.cos,o=Math.sin,h=a(i/2),c=a(s/2),u=a(n/2),d=o(i/2),f=o(s/2),p=o(n/2);switch(r){case"XYZ":this._x=d*c*u+h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u-d*f*p;break;case"YXZ":this._x=d*c*u+h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u+d*f*p;break;case"ZXY":this._x=d*c*u-h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u-d*f*p;break;case"ZYX":this._x=d*c*u-h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u+d*f*p;break;case"YZX":this._x=d*c*u+h*f*p,this._y=h*f*u+d*c*p,this._z=h*c*p-d*f*u,this._w=h*c*u-d*f*p;break;case"XZY":this._x=d*c*u-h*f*p,this._y=h*f*u-d*c*p,this._z=h*c*p+d*f*u,this._w=h*c*u+d*f*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],n=e[8],r=e[1],a=e[5],o=e[9],h=e[2],c=e[6],u=e[10],d=i+a+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(c-o)*f,this._y=(n-h)*f,this._z=(r-s)*f}else if(i>a&&i>u){const f=2*Math.sqrt(1+i-a-u);this._w=(c-o)/f,this._x=.25*f,this._y=(s+r)/f,this._z=(n+h)/f}else if(a>u){const f=2*Math.sqrt(1+a-i-u);this._w=(n-h)/f,this._x=(s+r)/f,this._y=.25*f,this._z=(o+c)/f}else{const f=2*Math.sqrt(1+u-i-a);this._w=(r-s)/f,this._x=(n+h)/f,this._y=(o+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(X(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,a=e._x,o=e._y,h=e._z,c=e._w;return this._x=i*c+r*a+s*h-n*o,this._y=s*c+r*o+n*a-i*h,this._z=n*c+r*h+i*o-s*a,this._w=r*c-i*a-s*o-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let a=r*t._w+i*t._x+s*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=i,this._y=s,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const f=1-e;return this._w=f*r+e*this._w,this._x=f*i+e*this._x,this._y=f*s+e*this._y,this._z=f*n+e*this._z,this.normalize(),this}const h=Math.sqrt(o),c=Math.atan2(h,a),u=Math.sin((1-e)*c)/h,d=Math.sin(e*c)/h;return this._w=r*u+this._w*d,this._x=i*u+this._x*d,this._y=s*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class w{constructor(t=0,e=0,i=0){w.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(lo.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(lo.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,a=t.z,o=t.w,h=2*(r*s-a*i),c=2*(a*e-n*s),u=2*(n*i-r*e);return this.x=e+o*h+r*u-a*c,this.y=i+o*c+a*h-n*u,this.z=s+o*u+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s,this.y=n[1]*e+n[5]*i+n[9]*s,this.z=n[2]*e+n[6]*i+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=X(this.x,t.x,e.x),this.y=X(this.y,t.y,e.y),this.z=X(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=X(this.x,t,e),this.y=X(this.y,t,e),this.z=X(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(X(i,t,e))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,n=t.z,r=e.x,a=e.y,o=e.z;return this.x=s*o-n*a,this.y=n*r-i*o,this.z=i*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return hr.copy(this).projectOnVector(t),this.sub(hr)}reflect(t){return this.sub(hr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(X(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const hr=new w,lo=new te;class Ht{constructor(t=new w(1/0,1/0,1/0),e=new w(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(ue.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(ue.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=ue.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const n=i.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,a=n.count;r<a;r++)t.isMesh===!0?t.getVertexPosition(r,ue):ue.fromBufferAttribute(n,r),ue.applyMatrix4(t.matrixWorld),this.expandByPoint(ue);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ds.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ds.copy(i.boundingBox)),Ds.applyMatrix4(t.matrixWorld),this.union(Ds)}const s=t.children;for(let n=0,r=s.length;n<r;n++)this.expandByObject(s[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ue),ue.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ts),Ls.subVectors(this.max,ts),gi.subVectors(t.a,ts),yi.subVectors(t.b,ts),xi.subVectors(t.c,ts),De.subVectors(yi,gi),Le.subVectors(xi,yi),Je.subVectors(gi,xi);let e=[0,-De.z,De.y,0,-Le.z,Le.y,0,-Je.z,Je.y,De.z,0,-De.x,Le.z,0,-Le.x,Je.z,0,-Je.x,-De.y,De.x,0,-Le.y,Le.x,0,-Je.y,Je.x,0];return!lr(e,gi,yi,xi,Ls)||(e=[1,0,0,0,1,0,0,0,1],!lr(e,gi,yi,xi,Ls))?!1:(Ns.crossVectors(De,Le),e=[Ns.x,Ns.y,Ns.z],lr(e,gi,yi,xi,Ls))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ue).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ue).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(_e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_e),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const _e=[new w,new w,new w,new w,new w,new w,new w,new w],ue=new w,Ds=new Ht,gi=new w,yi=new w,xi=new w,De=new w,Le=new w,Je=new w,ts=new w,Ls=new w,Ns=new w,Ze=new w;function lr(l,t,e,i,s){for(let n=0,r=l.length-3;n<=r;n+=3){Ze.fromArray(l,n);const a=s.x*Math.abs(Ze.x)+s.y*Math.abs(Ze.y)+s.z*Math.abs(Ze.z),o=t.dot(Ze),h=e.dot(Ze),c=i.dot(Ze);if(Math.max(-Math.max(o,h,c),Math.min(o,h,c))>a)return!1}return!0}const Ou=new Ht,es=new w,cr=new w;class Lt{constructor(t=new w,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):Ou.setFromPoints(t).getCenter(i);let s=0;for(let n=0,r=t.length;n<r;n++)s=Math.max(s,i.distanceToSquared(t[n]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;es.subVectors(t,this.center);const e=es.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(es,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(cr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(es.copy(t.center).add(cr)),this.expandByPoint(es.copy(t.center).sub(cr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Me=new w,ur=new w,Us=new w,Ne=new w,dr=new w,Vs=new w,fr=new w;class ks{constructor(t=new w,e=new w(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Me)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Me.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Me.copy(this.origin).addScaledVector(this.direction,e),Me.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){ur.copy(t).add(e).multiplyScalar(.5),Us.copy(e).sub(t).normalize(),Ne.copy(this.origin).sub(ur);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Us),a=Ne.dot(this.direction),o=-Ne.dot(Us),h=Ne.lengthSq(),c=Math.abs(1-r*r);let u,d,f,p;if(c>0)if(u=r*o-a,d=r*a-o,p=n*c,u>=0)if(d>=-p)if(d<=p){const m=1/c;u*=m,d*=m,f=u*(u+r*d+2*a)+d*(r*u+d+2*o)+h}else d=n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;else d=-n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;else d<=-p?(u=Math.max(0,-(-r*n+a)),d=u>0?-n:Math.min(Math.max(-n,-o),n),f=-u*u+d*(d+2*o)+h):d<=p?(u=0,d=Math.min(Math.max(-n,-o),n),f=d*(d+2*o)+h):(u=Math.max(0,-(r*n+a)),d=u>0?n:Math.min(Math.max(-n,-o),n),f=-u*u+d*(d+2*o)+h);else d=r>0?-n:n,u=Math.max(0,-(r*d+a)),f=-u*u+d*(d+2*o)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(ur).addScaledVector(Us,d),f}intersectSphere(t,e){Me.subVectors(t.center,this.origin);const i=Me.dot(this.direction),s=Me.dot(Me)-i*i,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),a=i-r,o=i+r;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,n,r,a,o;const h=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,s=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,s=(t.min.x-d.x)*h),c>=0?(n=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c):(n=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c),i>r||n>s||((n>i||isNaN(i))&&(i=n),(r<s||isNaN(s))&&(s=r),u>=0?(a=(t.min.z-d.z)*u,o=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,o=(t.min.z-d.z)*u),i>o||a>s)||((a>i||i!==i)&&(i=a),(o<s||s!==s)&&(s=o),s<0)?null:this.at(i>=0?i:s,e)}intersectsBox(t){return this.intersectBox(t,Me)!==null}intersectTriangle(t,e,i,s,n){dr.subVectors(e,t),Vs.subVectors(i,t),fr.crossVectors(dr,Vs);let r=this.direction.dot(fr),a;if(r>0){if(s)return null;a=1}else if(r<0)a=-1,r=-r;else return null;Ne.subVectors(this.origin,t);const o=a*this.direction.dot(Vs.crossVectors(Ne,Vs));if(o<0)return null;const h=a*this.direction.dot(dr.cross(Ne));if(h<0||o+h>r)return null;const c=-a*Ne.dot(fr);return c<0?null:this.at(c/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Z{constructor(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g){Z.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g)}set(t,e,i,s,n,r,a,o,h,c,u,d,f,p,m,g){const x=this.elements;return x[0]=t,x[4]=e,x[8]=i,x[12]=s,x[1]=n,x[5]=r,x[9]=a,x[13]=o,x[2]=h,x[6]=c,x[10]=u,x[14]=d,x[3]=f,x[7]=p,x[11]=m,x[15]=g,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 Z().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/bi.setFromMatrixColumn(t,0).length(),n=1/bi.setFromMatrixColumn(t,1).length(),r=1/bi.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),c=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=r*c,f=r*u,p=a*c,m=a*u;e[0]=o*c,e[4]=-o*u,e[8]=h,e[1]=f+p*h,e[5]=d-m*h,e[9]=-a*o,e[2]=m-d*h,e[6]=p+f*h,e[10]=r*o}else if(t.order==="YXZ"){const d=o*c,f=o*u,p=h*c,m=h*u;e[0]=d+m*a,e[4]=p*a-f,e[8]=r*h,e[1]=r*u,e[5]=r*c,e[9]=-a,e[2]=f*a-p,e[6]=m+d*a,e[10]=r*o}else if(t.order==="ZXY"){const d=o*c,f=o*u,p=h*c,m=h*u;e[0]=d-m*a,e[4]=-r*u,e[8]=p+f*a,e[1]=f+p*a,e[5]=r*c,e[9]=m-d*a,e[2]=-r*h,e[6]=a,e[10]=r*o}else if(t.order==="ZYX"){const d=r*c,f=r*u,p=a*c,m=a*u;e[0]=o*c,e[4]=p*h-f,e[8]=d*h+m,e[1]=o*u,e[5]=m*h+d,e[9]=f*h-p,e[2]=-h,e[6]=a*o,e[10]=r*o}else if(t.order==="YZX"){const d=r*o,f=r*h,p=a*o,m=a*h;e[0]=o*c,e[4]=m-d*u,e[8]=p*u+f,e[1]=u,e[5]=r*c,e[9]=-a*c,e[2]=-h*c,e[6]=f*u+p,e[10]=d-m*u}else if(t.order==="XZY"){const d=r*o,f=r*h,p=a*o,m=a*h;e[0]=o*c,e[4]=-u,e[8]=h*c,e[1]=d*u+m,e[5]=r*c,e[9]=f*u-p,e[2]=p*u-f,e[6]=a*c,e[10]=m*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Du,t,Lu)}lookAt(t,e,i){const s=this.elements;return Jt.subVectors(t,e),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),Ue.crossVectors(i,Jt),Ue.lengthSq()===0&&(Math.abs(i.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),Ue.crossVectors(i,Jt)),Ue.normalize(),Gs.crossVectors(Jt,Ue),s[0]=Ue.x,s[4]=Gs.x,s[8]=Jt.x,s[1]=Ue.y,s[5]=Gs.y,s[9]=Jt.y,s[2]=Ue.z,s[6]=Gs.z,s[10]=Jt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[4],o=i[8],h=i[12],c=i[1],u=i[5],d=i[9],f=i[13],p=i[2],m=i[6],g=i[10],x=i[14],y=i[3],b=i[7],v=i[11],_=i[15],M=s[0],A=s[4],S=s[8],T=s[12],C=s[1],P=s[5],V=s[9],q=s[13],L=s[2],I=s[6],U=s[10],wt=s[14],Ct=s[3],tt=s[7],J=s[11],ht=s[15];return n[0]=r*M+a*C+o*L+h*Ct,n[4]=r*A+a*P+o*I+h*tt,n[8]=r*S+a*V+o*U+h*J,n[12]=r*T+a*q+o*wt+h*ht,n[1]=c*M+u*C+d*L+f*Ct,n[5]=c*A+u*P+d*I+f*tt,n[9]=c*S+u*V+d*U+f*J,n[13]=c*T+u*q+d*wt+f*ht,n[2]=p*M+m*C+g*L+x*Ct,n[6]=p*A+m*P+g*I+x*tt,n[10]=p*S+m*V+g*U+x*J,n[14]=p*T+m*q+g*wt+x*ht,n[3]=y*M+b*C+v*L+_*Ct,n[7]=y*A+b*P+v*I+_*tt,n[11]=y*S+b*V+v*U+_*J,n[15]=y*T+b*q+v*wt+_*ht,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],s=t[8],n=t[12],r=t[1],a=t[5],o=t[9],h=t[13],c=t[2],u=t[6],d=t[10],f=t[14],p=t[3],m=t[7],g=t[11],x=t[15];return p*(+n*o*u-s*h*u-n*a*d+i*h*d+s*a*f-i*o*f)+m*(+e*o*f-e*h*d+n*r*d-s*r*f+s*h*c-n*o*c)+g*(+e*h*u-e*a*f-n*r*u+i*r*f+n*a*c-i*h*c)+x*(-s*a*c-e*o*u+e*a*d+s*r*u-i*r*d+i*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=t[6],h=t[7],c=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],x=t[15],y=u*g*h-m*d*h+m*o*f-a*g*f-u*o*x+a*d*x,b=p*d*h-c*g*h-p*o*f+r*g*f+c*o*x-r*d*x,v=c*m*h-p*u*h+p*a*f-r*m*f-c*a*x+r*u*x,_=p*u*o-c*m*o-p*a*d+r*m*d+c*a*g-r*u*g,M=e*y+i*b+s*v+n*_;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/M;return t[0]=y*A,t[1]=(m*d*n-u*g*n-m*s*f+i*g*f+u*s*x-i*d*x)*A,t[2]=(a*g*n-m*o*n+m*s*h-i*g*h-a*s*x+i*o*x)*A,t[3]=(u*o*n-a*d*n-u*s*h+i*d*h+a*s*f-i*o*f)*A,t[4]=b*A,t[5]=(c*g*n-p*d*n+p*s*f-e*g*f-c*s*x+e*d*x)*A,t[6]=(p*o*n-r*g*n-p*s*h+e*g*h+r*s*x-e*o*x)*A,t[7]=(r*d*n-c*o*n+c*s*h-e*d*h-r*s*f+e*o*f)*A,t[8]=v*A,t[9]=(p*u*n-c*m*n-p*i*f+e*m*f+c*i*x-e*u*x)*A,t[10]=(r*m*n-p*a*n+p*i*h-e*m*h-r*i*x+e*a*x)*A,t[11]=(c*a*n-r*u*n-c*i*h+e*u*h+r*i*f-e*a*f)*A,t[12]=_*A,t[13]=(c*m*s-p*u*s+p*i*d-e*m*d-c*i*g+e*u*g)*A,t[14]=(p*a*s-r*m*s-p*i*o+e*m*o+r*i*g-e*a*g)*A,t[15]=(r*u*s-c*a*s+c*i*o-e*u*o-r*i*d+e*a*d)*A,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,a=t.y,o=t.z,h=n*r,c=n*a;return this.set(h*r+i,h*a-s*o,h*o+s*a,0,h*a+s*o,c*a+i,c*o-s*r,0,h*o-s*a,c*o+s*r,n*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,a=e._z,o=e._w,h=n+n,c=r+r,u=a+a,d=n*h,f=n*c,p=n*u,m=r*c,g=r*u,x=a*u,y=o*h,b=o*c,v=o*u,_=i.x,M=i.y,A=i.z;return s[0]=(1-(m+x))*_,s[1]=(f+v)*_,s[2]=(p-b)*_,s[3]=0,s[4]=(f-v)*M,s[5]=(1-(d+x))*M,s[6]=(g+y)*M,s[7]=0,s[8]=(p+b)*A,s[9]=(g-y)*A,s[10]=(1-(d+m))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let n=bi.set(s[0],s[1],s[2]).length();const r=bi.set(s[4],s[5],s[6]).length(),a=bi.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],de.copy(this);const h=1/n,c=1/r,u=1/a;return de.elements[0]*=h,de.elements[1]*=h,de.elements[2]*=h,de.elements[4]*=c,de.elements[5]*=c,de.elements[6]*=c,de.elements[8]*=u,de.elements[9]*=u,de.elements[10]*=u,e.setFromRotationMatrix(de),i.x=n,i.y=r,i.z=a,this}makePerspective(t,e,i,s,n,r,a=Be){const o=this.elements,h=2*n/(e-t),c=2*n/(i-s),u=(e+t)/(e-t),d=(i+s)/(i-s);let f,p;if(a===Be)f=-(r+n)/(r-n),p=-2*r*n/(r-n);else if(a===Fn)f=-r/(r-n),p=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return o[0]=h,o[4]=0,o[8]=u,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=f,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,s,n,r,a=Be){const o=this.elements,h=1/(e-t),c=1/(i-s),u=1/(r-n),d=(e+t)*h,f=(i+s)*c;let p,m;if(a===Be)p=(r+n)*u,m=-2*u;else if(a===Fn)p=n*u,m=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-f,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const bi=new w,de=new Z,Du=new w(0,0,0),Lu=new w(1,1,1),Ue=new w,Gs=new w,Jt=new w,co=new Z,uo=new te;class xe{constructor(t=0,e=0,i=0,s=xe.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],a=s[8],o=s[1],h=s[5],c=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(X(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-X(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(X(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-X(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(X(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-X(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return co.makeRotationFromQuaternion(t),this.setFromRotationMatrix(co,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return uo.setFromEuler(this),this.setFromQuaternion(uo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xe.DEFAULT_ORDER="XYZ";class Xh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Nu=0;const fo=new w,vi=new te,Se=new Z,Ws=new w,is=new w,Uu=new w,Vu=new te,po=new w(1,0,0),mo=new w(0,1,0),go=new w(0,0,1),yo={type:"added"},Gu={type:"removed"},wi={type:"childadded",child:null},pr={type:"childremoved",child:null};class st extends Xe{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Nu++}),this.uuid=Qt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=st.DEFAULT_UP.clone();const t=new w,e=new xe,i=new te,s=new w(1,1,1);function n(){i.setFromEuler(e,!1)}function r(){e.setFromQuaternion(i,void 0,!1)}e._onChange(n),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new Z},normalMatrix:{value:new be}}),this.matrix=new Z,this.matrixWorld=new Z,this.matrixAutoUpdate=st.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=st.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Xh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return vi.setFromAxisAngle(t,e),this.quaternion.multiply(vi),this}rotateOnWorldAxis(t,e){return vi.setFromAxisAngle(t,e),this.quaternion.premultiply(vi),this}rotateX(t){return this.rotateOnAxis(po,t)}rotateY(t){return this.rotateOnAxis(mo,t)}rotateZ(t){return this.rotateOnAxis(go,t)}translateOnAxis(t,e){return fo.copy(t).applyQuaternion(this.quaternion),this.position.add(fo.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(po,t)}translateY(t){return this.translateOnAxis(mo,t)}translateZ(t){return this.translateOnAxis(go,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Se.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Ws.copy(t):Ws.set(t,e,i);const s=this.parent;this.updateWorldMatrix(!0,!1),is.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Se.lookAt(is,Ws,this.up):Se.lookAt(Ws,is,this.up),this.quaternion.setFromRotationMatrix(Se),s&&(Se.extractRotation(s.matrixWorld),vi.setFromRotationMatrix(Se),this.quaternion.premultiply(vi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(yo),wi.child=t,this.dispatchEvent(wi),wi.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Gu),pr.child=t,this.dispatchEvent(pr),pr.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Se.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Se.multiply(t.parent.matrixWorld)),t.applyMatrix4(Se),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(yo),wi.child=t,this.dispatchEvent(wi),wi.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,s=this.children.length;i<s;i++){const r=this.children[i].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(is,t,Uu),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(is,Vu,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(a,o){return a[o.uuid]===void 0&&(a[o.uuid]=o.toJSON(t)),o.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const o=a.shapes;if(Array.isArray(o))for(let h=0,c=o.length;h<c;h++){const u=o[h];n(t.shapes,u)}else n(t.shapes,o)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let o=0,h=this.material.length;o<h;o++)a.push(n(t.materials,this.material[o]));s.material=a}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){const o=this.animations[a];s.animations.push(n(t.animations,o))}}if(e){const a=r(t.geometries),o=r(t.materials),h=r(t.textures),c=r(t.images),u=r(t.shapes),d=r(t.skeletons),f=r(t.animations),p=r(t.nodes);a.length>0&&(i.geometries=a),o.length>0&&(i.materials=o),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function r(a){const o=[];for(const h in a){const c=a[h];delete c.metadata,o.push(c)}return o}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const s=t.children[i];this.add(s.clone())}return this}}st.DEFAULT_UP=new w(0,1,0);st.DEFAULT_MATRIX_AUTO_UPDATE=!0;st.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const fe=new w,Ae=new w,mr=new w,Ie=new w,_i=new w,Mi=new w,xo=new w,gr=new w,yr=new w,xr=new w,br=new It,vr=new It,wr=new It;class Kt{constructor(t=new w,e=new w,i=new w){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,s){s.subVectors(i,e),fe.subVectors(t,e),s.cross(fe);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,e,i,s,n){fe.subVectors(s,e),Ae.subVectors(i,e),mr.subVectors(t,e);const r=fe.dot(fe),a=fe.dot(Ae),o=fe.dot(mr),h=Ae.dot(Ae),c=Ae.dot(mr),u=r*h-a*a;if(u===0)return n.set(0,0,0),null;const d=1/u,f=(h*o-a*c)*d,p=(r*c-a*o)*d;return n.set(1-f-p,p,f)}static containsPoint(t,e,i,s){return this.getBarycoord(t,e,i,s,Ie)===null?!1:Ie.x>=0&&Ie.y>=0&&Ie.x+Ie.y<=1}static getInterpolation(t,e,i,s,n,r,a,o){return this.getBarycoord(t,e,i,s,Ie)===null?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(n,Ie.x),o.addScaledVector(r,Ie.y),o.addScaledVector(a,Ie.z),o)}static getInterpolatedAttribute(t,e,i,s,n,r){return br.setScalar(0),vr.setScalar(0),wr.setScalar(0),br.fromBufferAttribute(t,e),vr.fromBufferAttribute(t,i),wr.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(br,n.x),r.addScaledVector(vr,n.y),r.addScaledVector(wr,n.z),r}static isFrontFacing(t,e,i,s){return fe.subVectors(i,e),Ae.subVectors(t,e),fe.cross(Ae).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return fe.subVectors(this.c,this.b),Ae.subVectors(this.a,this.b),fe.cross(Ae).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Kt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Kt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,n){return Kt.getInterpolation(t,this.a,this.b,this.c,e,i,s,n)}containsPoint(t){return Kt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Kt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,n=this.c;let r,a;_i.subVectors(s,i),Mi.subVectors(n,i),gr.subVectors(t,i);const o=_i.dot(gr),h=Mi.dot(gr);if(o<=0&&h<=0)return e.copy(i);yr.subVectors(t,s);const c=_i.dot(yr),u=Mi.dot(yr);if(c>=0&&u<=c)return e.copy(s);const d=o*u-c*h;if(d<=0&&o>=0&&c<=0)return r=o/(o-c),e.copy(i).addScaledVector(_i,r);xr.subVectors(t,n);const f=_i.dot(xr),p=Mi.dot(xr);if(p>=0&&f<=p)return e.copy(n);const m=f*h-o*p;if(m<=0&&h>=0&&p<=0)return a=h/(h-p),e.copy(i).addScaledVector(Mi,a);const g=c*p-f*u;if(g<=0&&u-c>=0&&f-p>=0)return xo.subVectors(n,s),a=(u-c)/(u-c+(f-p)),e.copy(s).addScaledVector(xo,a);const x=1/(g+m+d);return r=m*x,a=d*x,e.copy(i).addScaledVector(_i,r).addScaledVector(Mi,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Yh={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},Ve={h:0,s:0,l:0},Hs={h:0,s:0,l:0};function _r(l,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?l+(t-l)*6*e:e<1/2?t:e<2/3?l+(t-l)*6*(2/3-e):l}class G{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ne){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,$t.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=$t.workingColorSpace){return this.r=t,this.g=e,this.b=i,$t.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=$t.workingColorSpace){if(t=oa(t,1),e=X(e,0,1),i=X(i,0,1),e===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=_r(r,n,t+1/3),this.g=_r(r,n,t),this.b=_r(r,n,t-1/3)}return $t.toWorkingColorSpace(this,s),this}setStyle(t,e=ne){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=s[1],a=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ne){const i=Yh[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ke(t.r),this.g=ke(t.g),this.b=ke(t.b),this}copyLinearToSRGB(t){return this.r=Ui(t.r),this.g=Ui(t.g),this.b=Ui(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ne){return $t.fromWorkingColorSpace(Pt.copy(this),t),Math.round(X(Pt.r*255,0,255))*65536+Math.round(X(Pt.g*255,0,255))*256+Math.round(X(Pt.b*255,0,255))}getHexString(t=ne){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=$t.workingColorSpace){$t.fromWorkingColorSpace(Pt.copy(this),e);const i=Pt.r,s=Pt.g,n=Pt.b,r=Math.max(i,s,n),a=Math.min(i,s,n);let o,h;const c=(a+r)/2;if(a===r)o=0,h=0;else{const u=r-a;switch(h=c<=.5?u/(r+a):u/(2-r-a),r){case i:o=(s-n)/u+(s<n?6:0);break;case s:o=(n-i)/u+2;break;case n:o=(i-s)/u+4;break}o/=6}return t.h=o,t.s=h,t.l=c,t}getRGB(t,e=$t.workingColorSpace){return $t.fromWorkingColorSpace(Pt.copy(this),e),t.r=Pt.r,t.g=Pt.g,t.b=Pt.b,t}getStyle(t=ne){$t.fromWorkingColorSpace(Pt.copy(this),t);const e=Pt.r,i=Pt.g,s=Pt.b;return t!==ne?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(t,e,i){return this.getHSL(Ve),this.setHSL(Ve.h+t,Ve.s+e,Ve.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Ve),t.getHSL(Hs);const i=ws(Ve.h,Hs.h,e),s=ws(Ve.s,Hs.s,e),n=ws(Ve.l,Hs.l,e);return this.setHSL(i,s,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,s=this.b,n=t.elements;return this.r=n[0]*e+n[3]*i+n[6]*s,this.g=n[1]*e+n[4]*i+n[7]*s,this.b=n[2]*e+n[5]*i+n[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Pt=new G;G.NAMES=Yh;let Wu=0;class Nt extends Xe{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Wu++}),this.uuid=Qt(),this.name="",this.type="Material",this.blending=Za,this.side=qr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ja,this.blendDst=Ka,this.blendEquation=$a,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new G(0,0,0),this.blendAlpha=0,this.depthFunc=Qa,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=no,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pi,this.stencilZFail=pi,this.stencilZPass=pi,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Za&&(i.blending=this.blending),this.side!==qr&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==ja&&(i.blendSrc=this.blendSrc),this.blendDst!==Ka&&(i.blendDst=this.blendDst),this.blendEquation!==$a&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Qa&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==no&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pi&&(i.stencilFail=this.stencilFail),this.stencilZFail!==pi&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==pi&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const r=[];for(const a in n){const o=n[a];delete o.metadata,r.push(o)}return r}if(e){const n=s(t.textures),r=s(t.images);n.length>0&&(i.textures=n),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(e!==null){const s=e.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class qi extends Nt{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new G(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 xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ce=Hu();function Hu(){const l=new ArrayBuffer(4),t=new Float32Array(l),e=new Uint32Array(l),i=new Uint32Array(512),s=new Uint32Array(512);for(let o=0;o<256;++o){const h=o-127;h<-27?(i[o]=0,i[o|256]=32768,s[o]=24,s[o|256]=24):h<-14?(i[o]=1024>>-h-14,i[o|256]=1024>>-h-14|32768,s[o]=-h-1,s[o|256]=-h-1):h<=15?(i[o]=h+15<<10,i[o|256]=h+15<<10|32768,s[o]=13,s[o|256]=13):h<128?(i[o]=31744,i[o|256]=64512,s[o]=24,s[o|256]=24):(i[o]=31744,i[o|256]=64512,s[o]=13,s[o|256]=13)}const n=new Uint32Array(2048),r=new Uint32Array(64),a=new Uint32Array(64);for(let o=1;o<1024;++o){let h=o<<13,c=0;for(;(h&8388608)===0;)h<<=1,c-=8388608;h&=-8388609,c+=947912704,n[o]=h|c}for(let o=1024;o<2048;++o)n[o]=939524096+(o-1024<<13);for(let o=1;o<31;++o)r[o]=o<<23;r[31]=1199570944,r[32]=2147483648;for(let o=33;o<63;++o)r[o]=2147483648+(o-32<<23);r[63]=3347054592;for(let o=1;o<64;++o)o!==32&&(a[o]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:s,mantissaTable:n,exponentTable:r,offsetTable:a}}function Wt(l){Math.abs(l)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),l=X(l,-65504,65504),Ce.floatView[0]=l;const t=Ce.uint32View[0],e=t>>23&511;return Ce.baseTable[e]+((t&8388607)>>Ce.shiftTable[e])}function xs(l){const t=l>>10;return Ce.uint32View[0]=Ce.mantissaTable[Ce.offsetTable[t]+(l&1023)]+Ce.exponentTable[t],Ce.floatView[0]}const ly={toHalfFloat:Wt,fromHalfFloat:xs},bt=new w,qs=new B;class ft{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Pn,this.updateRanges=[],this.gpuType=Gi,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[t+s]=e.array[i+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)qs.fromBufferAttribute(this,e),qs.applyMatrix3(t),this.setXY(e,qs.x,qs.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)bt.fromBufferAttribute(this,e),bt.applyMatrix3(t),this.setXYZ(e,bt.x,bt.y,bt.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)bt.fromBufferAttribute(this,e),bt.applyMatrix4(t),this.setXYZ(e,bt.x,bt.y,bt.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)bt.fromBufferAttribute(this,e),bt.applyNormalMatrix(t),this.setXYZ(e,bt.x,bt.y,bt.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)bt.fromBufferAttribute(this,e),bt.transformDirection(t),this.setXYZ(e,bt.x,bt.y,bt.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Dt(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Y(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Dt(e,this.array)),e}setX(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Dt(e,this.array)),e}setY(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Dt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Dt(e,this.array)),e}setW(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,s){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this}setXYZW(t,e,i,s,n){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array),n=Y(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Pn&&(t.usage=this.usage),t}}class cy extends ft{constructor(t,e,i){super(new Int8Array(t),e,i)}}class uy extends ft{constructor(t,e,i){super(new Uint8Array(t),e,i)}}class dy extends ft{constructor(t,e,i){super(new Uint8ClampedArray(t),e,i)}}class fy extends ft{constructor(t,e,i){super(new Int16Array(t),e,i)}}class qu extends ft{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class py extends ft{constructor(t,e,i){super(new Int32Array(t),e,i)}}class Xu extends ft{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class my extends ft{constructor(t,e,i){super(new Uint16Array(t),e,i),this.isFloat16BufferAttribute=!0}getX(t){let e=xs(this.array[t*this.itemSize]);return this.normalized&&(e=Dt(e,this.array)),e}setX(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize]=Wt(e),this}getY(t){let e=xs(this.array[t*this.itemSize+1]);return this.normalized&&(e=Dt(e,this.array)),e}setY(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+1]=Wt(e),this}getZ(t){let e=xs(this.array[t*this.itemSize+2]);return this.normalized&&(e=Dt(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+2]=Wt(e),this}getW(t){let e=xs(this.array[t*this.itemSize+3]);return this.normalized&&(e=Dt(e,this.array)),e}setW(t,e){return this.normalized&&(e=Y(e,this.array)),this.array[t*this.itemSize+3]=Wt(e),this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array)),this.array[t+0]=Wt(e),this.array[t+1]=Wt(i),this}setXYZ(t,e,i,s){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array)),this.array[t+0]=Wt(e),this.array[t+1]=Wt(i),this.array[t+2]=Wt(s),this}setXYZW(t,e,i,s,n){return t*=this.itemSize,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array),n=Y(n,this.array)),this.array[t+0]=Wt(e),this.array[t+1]=Wt(i),this.array[t+2]=Wt(s),this.array[t+3]=Wt(n),this}}class D extends ft{constructor(t,e,i){super(new Float32Array(t),e,i)}}let Yu=0;const se=new Z,Mr=new st,Si=new w,Zt=new Ht,ss=new Ht,St=new w;class j extends Xe{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yu++}),this.uuid=Qt(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(zu(t)?Xu:qu)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new be().getNormalMatrix(t);i.applyNormalMatrix(n),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return se.makeRotationFromQuaternion(t),this.applyMatrix4(se),this}rotateX(t){return se.makeRotationX(t),this.applyMatrix4(se),this}rotateY(t){return se.makeRotationY(t),this.applyMatrix4(se),this}rotateZ(t){return se.makeRotationZ(t),this.applyMatrix4(se),this}translate(t,e,i){return se.makeTranslation(t,e,i),this.applyMatrix4(se),this}scale(t,e,i){return se.makeScale(t,e,i),this.applyMatrix4(se),this}lookAt(t){return Mr.lookAt(t),Mr.updateMatrix(),this.applyMatrix4(Mr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Si).negate(),this.translate(Si.x,Si.y,Si.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let s=0,n=t.length;s<n;s++){const r=t[s];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new D(i,3))}else{const i=Math.min(t.length,e.count);for(let s=0;s<i;s++){const n=t[s];e.setXYZ(s,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,s=e.length;i<s;i++){const n=e[i];Zt.setFromBufferAttribute(n),this.morphTargetsRelative?(St.addVectors(this.boundingBox.min,Zt.min),this.boundingBox.expandByPoint(St),St.addVectors(this.boundingBox.max,Zt.max),this.boundingBox.expandByPoint(St)):(this.boundingBox.expandByPoint(Zt.min),this.boundingBox.expandByPoint(Zt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 Lt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new w,1/0);return}if(t){const i=this.boundingSphere.center;if(Zt.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const a=e[n];ss.setFromBufferAttribute(a),this.morphTargetsRelative?(St.addVectors(Zt.min,ss.min),Zt.expandByPoint(St),St.addVectors(Zt.max,ss.max),Zt.expandByPoint(St)):(Zt.expandByPoint(ss.min),Zt.expandByPoint(ss.max))}Zt.getCenter(i);let s=0;for(let n=0,r=t.count;n<r;n++)St.fromBufferAttribute(t,n),s=Math.max(s,i.distanceToSquared(St));if(e)for(let n=0,r=e.length;n<r;n++){const a=e[n],o=this.morphTargetsRelative;for(let h=0,c=a.count;h<c;h++)St.fromBufferAttribute(a,h),o&&(Si.fromBufferAttribute(t,h),St.add(Si)),s=Math.max(s,i.distanceToSquared(St))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,s=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ft(new Float32Array(4*i.count),4));const r=this.getAttribute("tangent"),a=[],o=[];for(let S=0;S<i.count;S++)a[S]=new w,o[S]=new w;const h=new w,c=new w,u=new w,d=new B,f=new B,p=new B,m=new w,g=new w;function x(S,T,C){h.fromBufferAttribute(i,S),c.fromBufferAttribute(i,T),u.fromBufferAttribute(i,C),d.fromBufferAttribute(n,S),f.fromBufferAttribute(n,T),p.fromBufferAttribute(n,C),c.sub(h),u.sub(h),f.sub(d),p.sub(d);const P=1/(f.x*p.y-p.x*f.y);isFinite(P)&&(m.copy(c).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(P),g.copy(u).multiplyScalar(f.x).addScaledVector(c,-p.x).multiplyScalar(P),a[S].add(m),a[T].add(m),a[C].add(m),o[S].add(g),o[T].add(g),o[C].add(g))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let S=0,T=y.length;S<T;++S){const C=y[S],P=C.start,V=C.count;for(let q=P,L=P+V;q<L;q+=3)x(t.getX(q+0),t.getX(q+1),t.getX(q+2))}const b=new w,v=new w,_=new w,M=new w;function A(S){_.fromBufferAttribute(s,S),M.copy(_);const T=a[S];b.copy(T),b.sub(_.multiplyScalar(_.dot(T))).normalize(),v.crossVectors(M,T);const P=v.dot(o[S])<0?-1:1;r.setXYZW(S,b.x,b.y,b.z,P)}for(let S=0,T=y.length;S<T;++S){const C=y[S],P=C.start,V=C.count;for(let q=P,L=P+V;q<L;q+=3)A(t.getX(q+0)),A(t.getX(q+1)),A(t.getX(q+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new ft(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const s=new w,n=new w,r=new w,a=new w,o=new w,h=new w,c=new w,u=new w;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),m=t.getX(d+1),g=t.getX(d+2);s.fromBufferAttribute(e,p),n.fromBufferAttribute(e,m),r.fromBufferAttribute(e,g),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),a.fromBufferAttribute(i,p),o.fromBufferAttribute(i,m),h.fromBufferAttribute(i,g),a.add(c),o.add(c),h.add(c),i.setXYZ(p,a.x,a.y,a.z),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(g,h.x,h.y,h.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),i.setXYZ(d+0,c.x,c.y,c.z),i.setXYZ(d+1,c.x,c.y,c.z),i.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)St.fromBufferAttribute(t,e),St.normalize(),t.setXYZ(e,St.x,St.y,St.z)}toNonIndexed(){function t(a,o){const h=a.array,c=a.itemSize,u=a.normalized,d=new h.constructor(o.length*c);let f=0,p=0;for(let m=0,g=o.length;m<g;m++){a.isInterleavedBufferAttribute?f=o[m]*a.data.stride+a.offset:f=o[m]*c;for(let x=0;x<c;x++)d[p++]=h[f++]}return new ft(d,c,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new j,i=this.index.array,s=this.attributes;for(const a in s){const o=s[a],h=t(o,i);e.setAttribute(a,h)}const n=this.morphAttributes;for(const a in n){const o=[],h=n[a];for(let c=0,u=h.length;c<u;c++){const d=h[c],f=t(d,i);o.push(f)}e.morphAttributes[a]=o}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let a=0,o=r.length;a<o;a++){const h=r[a];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const o=this.parameters;for(const h in o)o[h]!==void 0&&(t[h]=o[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const o in i){const h=i[o];t.data.attributes[o]=h.toJSON(t.data)}const s={};let n=!1;for(const o in this.morphAttributes){const h=this.morphAttributes[o],c=[];for(let u=0,d=h.length;u<d;u++){const f=h[u];c.push(f.toJSON(t.data))}c.length>0&&(s[o]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const h in s){const c=s[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],u=n[h];for(let d=0,f=u.length;d<f;d++)c.push(u[d].clone(e));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let h=0,c=r.length;h<c;h++){const u=r[h];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const o=t.boundingSphere;return o!==null&&(this.boundingSphere=o.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const bo=new Z,$e=new ks,Xs=new Lt,vo=new w,Ys=new w,Js=new w,Zs=new w,Sr=new w,$s=new w,wo=new w,js=new w;class qt extends st{constructor(t=new j,e=new qi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const a=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}getVertexPosition(t,e){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(s,t);const a=this.morphTargetInfluences;if(n&&a){$s.set(0,0,0);for(let o=0,h=n.length;o<h;o++){const c=a[o],u=n[o];c!==0&&(Sr.fromBufferAttribute(u,t),r?$s.addScaledVector(Sr,c):$s.addScaledVector(Sr.sub(e),c))}e.add($s)}return e}raycast(t,e){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Xs.copy(i.boundingSphere),Xs.applyMatrix4(n),$e.copy(t.ray).recast(t.near),!(Xs.containsPoint($e.origin)===!1&&($e.intersectSphere(Xs,vo)===null||$e.origin.distanceToSquared(vo)>(t.far-t.near)**2))&&(bo.copy(n).invert(),$e.copy(t.ray).applyMatrix4(bo),!(i.boundingBox!==null&&$e.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,$e)))}_computeIntersections(t,e,i){let s;const n=this.geometry,r=this.material,a=n.index,o=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,u=n.attributes.normal,d=n.groups,f=n.drawRange;if(a!==null)if(Array.isArray(r))for(let p=0,m=d.length;p<m;p++){const g=d[p],x=r[g.materialIndex],y=Math.max(g.start,f.start),b=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let v=y,_=b;v<_;v+=3){const M=a.getX(v),A=a.getX(v+1),S=a.getX(v+2);s=Ks(this,x,t,i,h,c,u,M,A,S),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{const p=Math.max(0,f.start),m=Math.min(a.count,f.start+f.count);for(let g=p,x=m;g<x;g+=3){const y=a.getX(g),b=a.getX(g+1),v=a.getX(g+2);s=Ks(this,r,t,i,h,c,u,y,b,v),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}else if(o!==void 0)if(Array.isArray(r))for(let p=0,m=d.length;p<m;p++){const g=d[p],x=r[g.materialIndex],y=Math.max(g.start,f.start),b=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let v=y,_=b;v<_;v+=3){const M=v,A=v+1,S=v+2;s=Ks(this,x,t,i,h,c,u,M,A,S),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{const p=Math.max(0,f.start),m=Math.min(o.count,f.start+f.count);for(let g=p,x=m;g<x;g+=3){const y=g,b=g+1,v=g+2;s=Ks(this,r,t,i,h,c,u,y,b,v),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}}}function Ju(l,t,e,i,s,n,r,a){let o;if(t.side===Lh?o=i.intersectTriangle(r,n,s,!0,a):o=i.intersectTriangle(s,n,r,t.side===qr,a),o===null)return null;js.copy(a),js.applyMatrix4(l.matrixWorld);const h=e.ray.origin.distanceTo(js);return h<e.near||h>e.far?null:{distance:h,point:js.clone(),object:l}}function Ks(l,t,e,i,s,n,r,a,o,h){l.getVertexPosition(a,Ys),l.getVertexPosition(o,Js),l.getVertexPosition(h,Zs);const c=Ju(l,t,e,i,Ys,Js,Zs,wo);if(c){const u=new w;Kt.getBarycoord(wo,Ys,Js,Zs,u),s&&(c.uv=Kt.getInterpolatedAttribute(s,a,o,h,u,new B)),n&&(c.uv1=Kt.getInterpolatedAttribute(n,a,o,h,u,new B)),r&&(c.normal=Kt.getInterpolatedAttribute(r,a,o,h,u,new w),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const d={a,b:o,c:h,normal:new w,materialIndex:0};Kt.getNormal(Ys,Js,Zs,d.normal),c.face=d,c.barycoord=u}return c}class Xn extends j{constructor(t=1,e=1,i=1,s=1,n=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:n,depthSegments:r};const a=this;s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);const o=[],h=[],c=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,r,n,0),p("z","y","x",1,-1,i,e,-t,r,n,1),p("x","z","y",1,1,t,i,e,s,r,2),p("x","z","y",1,-1,t,i,-e,s,r,3),p("x","y","z",1,-1,t,e,i,s,n,4),p("x","y","z",-1,-1,t,e,-i,s,n,5),this.setIndex(o),this.setAttribute("position",new D(h,3)),this.setAttribute("normal",new D(c,3)),this.setAttribute("uv",new D(u,2));function p(m,g,x,y,b,v,_,M,A,S,T){const C=v/A,P=_/S,V=v/2,q=_/2,L=M/2,I=A+1,U=S+1;let wt=0,Ct=0;const tt=new w;for(let J=0;J<U;J++){const ht=J*P-q;for(let Ut=0;Ut<I;Ut++){const oe=Ut*C-V;tt[m]=oe*y,tt[g]=ht*b,tt[x]=L,h.push(tt.x,tt.y,tt.z),tt[m]=0,tt[g]=0,tt[x]=M>0?1:-1,c.push(tt.x,tt.y,tt.z),u.push(Ut/A),u.push(1-J/S),wt+=1}}for(let J=0;J<S;J++)for(let ht=0;ht<A;ht++){const Ut=d+ht+I*J,oe=d+ht+I*(J+1),di=d+(ht+1)+I*(J+1),Ye=d+(ht+1)+I*J;o.push(Ut,oe,Ye),o.push(oe,di,Ye),Ct+=6}a.addGroup(f,Ct,T),f+=Ct,d+=wt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Yn(l){const t={};for(const e in l){t[e]={};for(const i in l[e]){const s=l[e][i];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=s.clone():Array.isArray(s)?t[e][i]=s.slice():t[e][i]=s}}return t}function Zu(l){const t={};for(let e=0;e<l.length;e++){const i=Yn(l[e]);for(const s in i)t[s]=i[s]}return t}function $u(l){const t=[];for(let e=0;e<l.length;e++)t.push(l[e].clone());return t}function gy(l){const t=l.getRenderTarget();return t===null?l.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:$t.workingColorSpace}const yy={clone:Yn,merge:Zu};var ju=`void main() {
|
||
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
||
}`,Ku=`void main() {
|
||
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
||
}`;class ca extends Nt{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ju,this.fragmentShader=Ku,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Yn(t.uniforms),this.uniformsGroups=$u(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const r=this.uniforms[s].value;r&&r.isTexture?e.uniforms[s]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[s]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[s]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[s]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[s]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[s]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[s]={type:"m4",value:r.toArray()}:e.uniforms[s]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class ua extends st{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Z,this.projectionMatrix=new Z,this.projectionMatrixInverse=new Z,this.coordinateSystem=Be}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ge=new w,_o=new B,Mo=new B;class re extends ua{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Is*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ai*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Is*2*Math.atan(Math.tan(ai*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){Ge.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ge.x,Ge.y).multiplyScalar(-t/Ge.z),Ge.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ge.x,Ge.y).multiplyScalar(-t/Ge.z)}getViewSize(t,e){return this.getViewBounds(t,_o,Mo),e.subVectors(Mo,_o)}setViewOffset(t,e,i,s,n,r){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ai*.5*this.fov)/this.zoom,i=2*e,s=this.aspect*i,n=-.5*s;const r=this.view;if(this.view!==null&&this.view.enabled){const o=r.fullWidth,h=r.fullHeight;n+=r.offsetX*s/o,e-=r.offsetY*i/h,s*=r.width/o,i*=r.height/h}const a=this.filmOffset;a!==0&&(n+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+s,e,e-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Ai=-90,Ii=1;class Qu extends st{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new re(Ai,Ii,t,e);s.layers=this.layers,this.add(s);const n=new re(Ai,Ii,t,e);n.layers=this.layers,this.add(n);const r=new re(Ai,Ii,t,e);r.layers=this.layers,this.add(r);const a=new re(Ai,Ii,t,e);a.layers=this.layers,this.add(a);const o=new re(Ai,Ii,t,e);o.layers=this.layers,this.add(o);const h=new re(Ai,Ii,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,s,n,r,a,o]=e;for(const h of e)this.remove(h);if(t===Be)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),n.up.set(0,0,-1),n.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(t===Fn)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),n.up.set(0,0,1),n.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const h of e)this.add(h),h.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[n,r,a,o,h,c]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,n),t.setRenderTarget(i,1,s),t.render(e,r),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,c),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class da extends yt{constructor(t,e,i,s,n,r,a,o,h,c){t=t!==void 0?t:[],e=e!==void 0?e:na,super(t,e,i,s,n,r,a,o,h,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class xy extends la{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},s=[i,i,i,i,i,i];this.texture=new da(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:ae}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
||
|
||
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
||
|
||
}
|
||
|
||
void main() {
|
||
|
||
vWorldDirection = transformDirection( position, modelMatrix );
|
||
|
||
#include <begin_vertex>
|
||
#include <project_vertex>
|
||
|
||
}
|
||
`,fragmentShader:`
|
||
|
||
uniform sampler2D tEquirect;
|
||
|
||
varying vec3 vWorldDirection;
|
||
|
||
#include <common>
|
||
|
||
void main() {
|
||
|
||
vec3 direction = normalize( vWorldDirection );
|
||
|
||
vec2 sampleUV = equirectUv( direction );
|
||
|
||
gl_FragColor = texture2D( tEquirect, sampleUV );
|
||
|
||
}
|
||
`},s=new Xn(5,5,5),n=new ca({name:"CubemapFromEquirect",uniforms:Yn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Lh,blending:ac});n.uniforms.tEquirect.value=e;const r=new qt(s,n),a=e.minFilter;return e.minFilter===qn&&(e.minFilter=ae),new Qu(1,10,this).update(t,r),e.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(t,e,i,s){const n=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(n)}}class fa{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new G(t),this.density=e}clone(){return new fa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class pa{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new G(t),this.near=e,this.far=i}clone(){return new pa(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class td extends st{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 xe,this.environmentIntensity=1,this.environmentRotation=new xe,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ma{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Pn,this.updateRanges=[],this.version=0,this.uuid=Qt()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let s=0,n=this.stride;s<n;s++)this.array[t+s]=e.array[i+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Qt()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Qt()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Et=new w;class Wi{constructor(t,e,i,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,i=this.data.count;e<i;e++)Et.fromBufferAttribute(this,e),Et.applyMatrix4(t),this.setXYZ(e,Et.x,Et.y,Et.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Et.fromBufferAttribute(this,e),Et.applyNormalMatrix(t),this.setXYZ(e,Et.x,Et.y,Et.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Et.fromBufferAttribute(this,e),Et.transformDirection(t),this.setXYZ(e,Et.x,Et.y,Et.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Dt(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Y(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=Y(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Y(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Y(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Y(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Dt(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Dt(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Dt(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Dt(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=s,this}setXYZW(t,e,i,s,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Y(e,this.array),i=Y(i,this.array),s=Y(s,this.array),n=Y(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=s,this.data.array[t+3]=n,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[s+n])}return new ft(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Wi(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const s=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[s+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class _s extends Nt{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new G(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Ti;const ns=new w,Ci=new w,Bi=new w,zi=new B,rs=new B,Jh=new Z,Qs=new w,as=new w,tn=new w,So=new B,Ar=new B,Ao=new B;class bs extends st{constructor(t=new _s){if(super(),this.isSprite=!0,this.type="Sprite",Ti===void 0){Ti=new j;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new ma(e,5);Ti.setIndex([0,1,2,0,2,3]),Ti.setAttribute("position",new Wi(i,3,0,!1)),Ti.setAttribute("uv",new Wi(i,2,3,!1))}this.geometry=Ti,this.material=t,this.center=new B(.5,.5)}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ci.setFromMatrixScale(this.matrixWorld),Jh.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Bi.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ci.multiplyScalar(-Bi.z);const i=this.material.rotation;let s,n;i!==0&&(n=Math.cos(i),s=Math.sin(i));const r=this.center;en(Qs.set(-.5,-.5,0),Bi,r,Ci,s,n),en(as.set(.5,-.5,0),Bi,r,Ci,s,n),en(tn.set(.5,.5,0),Bi,r,Ci,s,n),So.set(0,0),Ar.set(1,0),Ao.set(1,1);let a=t.ray.intersectTriangle(Qs,as,tn,!1,ns);if(a===null&&(en(as.set(-.5,.5,0),Bi,r,Ci,s,n),Ar.set(0,1),a=t.ray.intersectTriangle(Qs,tn,as,!1,ns),a===null))return;const o=t.ray.origin.distanceTo(ns);o<t.near||o>t.far||e.push({distance:o,point:ns.clone(),uv:Kt.getInterpolation(ns,Qs,as,tn,So,Ar,Ao,new B),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function en(l,t,e,i,s,n){zi.subVectors(l,e).addScalar(.5).multiply(i),s!==void 0?(rs.x=n*zi.x-s*zi.y,rs.y=s*zi.x+n*zi.y):rs.copy(zi),l.copy(t),l.x+=rs.x,l.y+=rs.y,l.applyMatrix4(Jh)}const sn=new w,Io=new w;class ed extends st{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let i=0,s=e.length;i<s;i++){const n=e[i];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,i=0){e=Math.abs(e);const s=this.levels;let n;for(n=0;n<s.length&&!(e<s[n].distance);n++);return s.splice(n,0,{distance:e,hysteresis:i,object:t}),this.add(t),this}removeLevel(t){const e=this.levels;for(let i=0;i<e.length;i++)if(e[i].distance===t){const s=e.splice(i,1);return this.remove(s[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){const e=this.levels;if(e.length>0){let i,s;for(i=1,s=e.length;i<s;i++){let n=e[i].distance;if(e[i].object.visible&&(n-=n*e[i].hysteresis),t<n)break}return e[i-1].object}return null}raycast(t,e){if(this.levels.length>0){sn.setFromMatrixPosition(this.matrixWorld);const s=t.ray.origin.distanceTo(sn);this.getObjectForDistance(s).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){sn.setFromMatrixPosition(t.matrixWorld),Io.setFromMatrixPosition(this.matrixWorld);const i=sn.distanceTo(Io)/t.zoom;e[0].object.visible=!0;let s,n;for(s=1,n=e.length;s<n;s++){let r=e[s].distance;if(e[s].object.visible&&(r-=r*e[s].hysteresis),i>=r)e[s-1].object.visible=!1,e[s].object.visible=!0;else break}for(this._currentLevel=s-1;s<n;s++)e[s].object.visible=!1}}toJSON(t){const e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];const i=this.levels;for(let s=0,n=i.length;s<n;s++){const r=i[s];e.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return e}}const To=new w,Co=new It,Bo=new It,id=new w,zo=new Z,nn=new w,Ir=new Lt,ko=new Z,Tr=new ks;class sd extends qt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=to,this.bindMatrix=new Z,this.bindMatrixInverse=new Z,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ht),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,nn),this.boundingBox.expandByPoint(nn)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Lt),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,nn),this.boundingSphere.expandByPoint(nn)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,s=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ir.copy(this.boundingSphere),Ir.applyMatrix4(s),t.ray.intersectsSphere(Ir)!==!1&&(ko.copy(s).invert(),Tr.copy(t.ray).applyMatrix4(ko),!(this.boundingBox!==null&&Tr.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Tr)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new It,e=this.geometry.attributes.skinWeight;for(let i=0,s=e.count;i<s;i++){t.fromBufferAttribute(e,i);const n=1/t.manhattanLength();n!==1/0?t.multiplyScalar(n):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===to?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===hc?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,s=this.geometry;Co.fromBufferAttribute(s.attributes.skinIndex,t),Bo.fromBufferAttribute(s.attributes.skinWeight,t),To.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let n=0;n<4;n++){const r=Bo.getComponent(n);if(r!==0){const a=Co.getComponent(n);zo.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(id.copy(To).applyMatrix4(zo),r)}}return e.applyMatrix4(this.bindMatrixInverse)}}class Zh extends st{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Pe extends yt{constructor(t=null,e=1,i=1,s,n,r,a,o,h=pe,c=pe,u,d){super(null,r,a,o,h,c,s,n,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Po=new Z,nd=new Z;class ga{constructor(t=[],e=[]){this.uuid=Qt(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,s=this.bones.length;i<s;i++)this.boneInverses.push(new Z)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new Z;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,s=this.boneTexture;for(let n=0,r=t.length;n<r;n++){const a=t[n]?t[n].matrixWorld:nd;Po.multiplyMatrices(a,e[n]),Po.toArray(i,n*16)}s!==null&&(s.needsUpdate=!0)}clone(){return new ga(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new Pe(e,t,t,As,Gi);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const s=this.bones[e];if(s.name===t)return s}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,s=t.bones.length;i<s;i++){const n=t.bones[i];let r=e[n];r===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Zh),this.bones.push(r),this.boneInverses.push(new Z().fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let s=0,n=e.length;s<n;s++){const r=e[s];t.bones.push(r.uuid);const a=i[s];t.boneInverses.push(a.toArray())}return t}}class Ts extends ft{constructor(t,e,i,s=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=s}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const ki=new Z,Fo=new Z,rn=[],Ro=new Ht,rd=new Z,os=new qt,hs=new Lt;class ad extends qt{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Ts(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let s=0;s<i;s++)this.setMatrixAt(s,rd)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Ht),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,ki),Ro.copy(t.boundingBox).applyMatrix4(ki),this.boundingBox.union(Ro)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Lt),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,ki),hs.copy(t.boundingSphere).applyMatrix4(ki),this.boundingSphere.union(hs)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const i=e.morphTargetInfluences,s=this.morphTexture.source.data.data,n=i.length+1,r=t*n+1;for(let a=0;a<i.length;a++)i[a]=s[r+a]}raycast(t,e){const i=this.matrixWorld,s=this.count;if(os.geometry=this.geometry,os.material=this.material,os.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hs.copy(this.boundingSphere),hs.applyMatrix4(i),t.ray.intersectsSphere(hs)!==!1))for(let n=0;n<s;n++){this.getMatrixAt(n,ki),Fo.multiplyMatrices(i,ki),os.matrixWorld=Fo,os.raycast(t,rn);for(let r=0,a=rn.length;r<a;r++){const o=rn[r];o.instanceId=n,o.object=this,e.push(o)}rn.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new Ts(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const i=e.morphTargetInfluences,s=i.length+1;this.morphTexture===null&&(this.morphTexture=new Pe(new Float32Array(s*this.count),s,this.count,Uh,Gi));const n=this.morphTexture.source.data.data;let r=0;for(let h=0;h<i.length;h++)r+=i[h];const a=this.geometry.morphTargetsRelative?1:1-r,o=s*t;n[o]=a,n.set(i,o+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}const Cr=new w,od=new w,hd=new be;class Pi{constructor(t=new w(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,s){return this.normal.set(t,e,i),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const s=Cr.subVectors(i,e).cross(od.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(Cr),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/s;return n<0||n>1?null:e.copy(t.start).addScaledVector(i,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||hd.getNormalMatrix(t),s=this.coplanarPoint(Cr).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const je=new Lt,an=new w;class $h{constructor(t=new Pi,e=new Pi,i=new Pi,s=new Pi,n=new Pi,r=new Pi){this.planes=[t,e,i,s,n,r]}set(t,e,i,s,n,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(n),a[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Be){const i=this.planes,s=t.elements,n=s[0],r=s[1],a=s[2],o=s[3],h=s[4],c=s[5],u=s[6],d=s[7],f=s[8],p=s[9],m=s[10],g=s[11],x=s[12],y=s[13],b=s[14],v=s[15];if(i[0].setComponents(o-n,d-h,g-f,v-x).normalize(),i[1].setComponents(o+n,d+h,g+f,v+x).normalize(),i[2].setComponents(o+r,d+c,g+p,v+y).normalize(),i[3].setComponents(o-r,d-c,g-p,v-y).normalize(),i[4].setComponents(o-a,d-u,g-m,v-b).normalize(),e===Be)i[5].setComponents(o+a,d+u,g+m,v+b).normalize();else if(e===Fn)i[5].setComponents(a,u,m,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),je.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),je.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(je)}intersectsSprite(t){return je.center.set(0,0,0),je.radius=.7071067811865476,je.applyMatrix4(t.matrixWorld),this.intersectsSphere(je)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let n=0;n<6;n++)if(e[n].distanceToPoint(i)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const s=e[i];if(an.x=s.normal.x>0?t.max.x:t.min.x,an.y=s.normal.y>0?t.max.y:t.min.y,an.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(an)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Br(l,t){return l-t}function ld(l,t){return l.z-t.z}function cd(l,t){return t.z-l.z}class ud{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,i,s){const n=this.pool,r=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1,index:-1});const a=n[this.index];r.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}}const Gt=new Z,dd=new G(1,1,1),zr=new $h,on=new Ht,Ke=new Lt,ls=new w,Eo=new w,fd=new w,kr=new ud,Ft=new qt,hn=[];function pd(l,t,e=0){const i=t.itemSize;if(l.isInterleavedBufferAttribute||l.array.constructor!==t.array.constructor){const s=l.count;for(let n=0;n<s;n++)for(let r=0;r<i;r++)t.setComponent(n+e,r,l.getComponent(n,r))}else t.array.set(l.array,e*i);t.needsUpdate=!0}function Qe(l,t){if(l.constructor!==t.constructor){const e=Math.min(l.length,t.length);for(let i=0;i<e;i++)t[i]=l[i]}else{const e=Math.min(l.length,t.length);t.set(new l.constructor(l.buffer,0,e))}}class md extends qt{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}constructor(t,e,i=e*2,s){super(new j,s),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=t,this._maxVertexCount=e,this._maxIndexCount=i,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4),i=new Pe(e,t,t,As,Gi);this._matricesTexture=i}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Uint32Array(t*t),i=new Pe(e,t,t,Vh,ra);this._indirectTexture=i}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);const e=new Float32Array(t*t*4).fill(1),i=new Pe(e,t,t,As,Gi);i.colorSpace=$t.workingColorSpace,this._colorsTexture=i}_initializeGeometry(t){const e=this.geometry,i=this._maxVertexCount,s=this._maxIndexCount;if(this._geometryInitialized===!1){for(const n in t.attributes){const r=t.getAttribute(n),{array:a,itemSize:o,normalized:h}=r,c=new a.constructor(i*o),u=new ft(c,o,h);e.setAttribute(n,u)}if(t.getIndex()!==null){const n=i>65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new ft(n,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const i in e.attributes){if(!t.hasAttribute(i))throw new Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const s=t.getAttribute(i),n=e.getAttribute(i);if(s.itemSize!==n.itemSize||s.normalized!==n.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){const e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){const e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);const t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i<s;i++){if(e[i].active===!1)continue;const n=e[i].geometryIndex;this.getMatrixAt(i,Gt),this.getBoundingBoxAt(n,on).applyMatrix4(Gt),t.union(on)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Lt);const t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i<s;i++){if(e[i].active===!1)continue;const n=e[i].geometryIndex;this.getMatrixAt(i,Gt),this.getBoundingSphereAt(n,Ke).applyMatrix4(Gt),t.union(Ke)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const i={visible:!0,active:!0,geometryIndex:t};let s=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Br),s=this._availableInstanceIds.shift(),this._instanceInfo[s]=i):(s=this._instanceInfo.length,this._instanceInfo.push(i));const n=this._matricesTexture;Gt.identity().toArray(n.image.data,s*16),n.needsUpdate=!0;const r=this._colorsTexture;return r&&(dd.toArray(r.image.data,s*4),r.needsUpdate=!0),this._visibilityChanged=!0,s}addGeometry(t,e=-1,i=-1){this._initializeGeometry(t),this._validateGeometry(t);const s={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;s.vertexStart=this._nextVertexStart,s.reservedVertexCount=e===-1?t.getAttribute("position").count:e;const r=t.getIndex();if(r!==null&&(s.indexStart=this._nextIndexStart,s.reservedIndexCount=i===-1?r.count:i),s.indexStart!==-1&&s.indexStart+s.reservedIndexCount>this._maxIndexCount||s.vertexStart+s.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let o;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Br),o=this._availableGeometryIds.shift(),n[o]=s):(o=this._geometryCount,this._geometryCount++,n.push(s)),this.setGeometryAt(o,t),this._nextIndexStart=s.indexStart+s.reservedIndexCount,this._nextVertexStart=s.vertexStart+s.reservedVertexCount,o}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const i=this.geometry,s=i.getIndex()!==null,n=i.getIndex(),r=e.getIndex(),a=this._geometryInfo[t];if(s&&r.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const o=a.vertexStart,h=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(const c in i.attributes){const u=e.getAttribute(c),d=i.getAttribute(c);pd(u,d,o);const f=u.itemSize;for(let p=u.count,m=h;p<m;p++){const g=o+p;for(let x=0;x<f;x++)d.setComponent(g,x,0)}d.needsUpdate=!0,d.addUpdateRange(o*f,h*f)}if(s){const c=a.indexStart,u=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let d=0;d<r.count;d++)n.setX(c+d,o+r.getX(d));for(let d=r.count,f=u;d<f;d++)n.setX(c+d,o);n.needsUpdate=!0,n.addUpdateRange(c,a.reservedIndexCount)}return a.start=s?a.indexStart:a.vertexStart,a.count=s?a.indexCount:a.vertexCount,a.boundingBox=null,e.boundingBox!==null&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,e.boundingSphere!==null&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){const e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;const i=this._instanceInfo;for(let s=0,n=i.length;s<n;s++)i[s].geometryIndex===t&&this.deleteInstance(s);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0;const i=this._geometryInfo,s=i.map((r,a)=>a).sort((r,a)=>i[r].vertexStart-i[a].vertexStart),n=this.geometry;for(let r=0,a=i.length;r<a;r++){const o=s[r],h=i[o];if(h.active!==!1){if(n.index!==null){if(h.indexStart!==e){const{indexStart:c,vertexStart:u,reservedIndexCount:d}=h,f=n.index,p=f.array,m=t-u;for(let g=c;g<c+d;g++)p[g]=p[g]+m;f.array.copyWithin(e,c,c+d),f.addUpdateRange(e,d),h.indexStart=e}e+=h.reservedIndexCount}if(h.vertexStart!==t){const{vertexStart:c,reservedVertexCount:u}=h,d=n.attributes;for(const f in d){const p=d[f],{array:m,itemSize:g}=p;m.copyWithin(t*g,c*g,(c+u)*g),p.addUpdateRange(t*g,u*g)}h.vertexStart=t}t+=h.reservedVertexCount,h.start=n.index?h.indexStart:h.vertexStart,this._nextIndexStart=n.index?h.indexStart+h.reservedIndexCount:0,this._nextVertexStart=h.vertexStart+h.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(s.boundingBox===null){const n=new Ht,r=i.index,a=i.attributes.position;for(let o=s.start,h=s.start+s.count;o<h;o++){let c=o;r&&(c=r.getX(c)),n.expandByPoint(ls.fromBufferAttribute(a,c))}s.boundingBox=n}return e.copy(s.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;const i=this.geometry,s=this._geometryInfo[t];if(s.boundingSphere===null){const n=new Lt;this.getBoundingBoxAt(t,on),on.getCenter(n.center);const r=i.index,a=i.attributes.position;let o=0;for(let h=s.start,c=s.start+s.count;h<c;h++){let u=h;r&&(u=r.getX(u)),ls.fromBufferAttribute(a,u),o=Math.max(o,n.center.distanceToSquared(ls))}n.radius=Math.sqrt(o),s.boundingSphere=n}return e.copy(s.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);const i=this._matricesTexture,s=this._matricesTexture.image.data;return e.toArray(s,t*16),i.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);const i=this._geometryInfo[t];return e.vertexStart=i.vertexStart,e.vertexCount=i.vertexCount,e.reservedVertexCount=i.reservedVertexCount,e.indexStart=i.indexStart,e.indexCount=i.indexCount,e.reservedIndexCount=i.reservedIndexCount,e.start=i.start,e.count=i.count,e}setInstanceCount(t){const e=this._availableInstanceIds,i=this._instanceInfo;for(e.sort(Br);e[e.length-1]===i.length;)i.pop(),e.pop();if(t<i.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);const s=new Int32Array(t),n=new Int32Array(t);Qe(this._multiDrawCounts,s),Qe(this._multiDrawStarts,n),this._multiDrawCounts=s,this._multiDrawStarts=n,this._maxInstanceCount=t;const r=this._indirectTexture,a=this._matricesTexture,o=this._colorsTexture;r.dispose(),this._initIndirectTexture(),Qe(r.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Qe(a.image.data,this._matricesTexture.image.data),o&&(o.dispose(),this._initColorsTexture(),Qe(o.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){const i=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...i.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(o=>o.indexStart+o.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);const n=this.geometry;n.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new j,this._initializeGeometry(n));const r=this.geometry;n.index&&Qe(n.index.array,r.index.array);for(const a in n.attributes)Qe(n.attributes[a].array,r.attributes[a].array)}raycast(t,e){const i=this._instanceInfo,s=this._geometryInfo,n=this.matrixWorld,r=this.geometry;Ft.material=this.material,Ft.geometry.index=r.index,Ft.geometry.attributes=r.attributes,Ft.geometry.boundingBox===null&&(Ft.geometry.boundingBox=new Ht),Ft.geometry.boundingSphere===null&&(Ft.geometry.boundingSphere=new Lt);for(let a=0,o=i.length;a<o;a++){if(!i[a].visible||!i[a].active)continue;const h=i[a].geometryIndex,c=s[h];Ft.geometry.setDrawRange(c.start,c.count),this.getMatrixAt(a,Ft.matrixWorld).premultiply(n),this.getBoundingBoxAt(h,Ft.geometry.boundingBox),this.getBoundingSphereAt(h,Ft.geometry.boundingSphere),Ft.raycast(t,hn);for(let u=0,d=hn.length;u<d;u++){const f=hn[u];f.object=this,f.batchId=a,e.push(f)}hn.length=0}Ft.material=null,Ft.geometry.index=null,Ft.geometry.attributes={},Ft.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return 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}onBeforeRender(t,e,i,s,n){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const r=s.getIndex(),a=r===null?1:r.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,c=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,p=f.image.data;d&&(Gt.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),zr.setFromProjectionMatrix(Gt,t.coordinateSystem));let m=0;if(this.sortObjects){Gt.copy(this.matrixWorld).invert(),ls.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Gt),Eo.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(Gt);for(let y=0,b=o.length;y<b;y++)if(o[y].visible&&o[y].active){const v=o[y].geometryIndex;this.getMatrixAt(y,Gt),this.getBoundingSphereAt(v,Ke).applyMatrix4(Gt);let _=!1;if(d&&(_=!zr.intersectsSphere(Ke)),!_){const M=u[v],A=fd.subVectors(Ke.center,ls).dot(Eo);kr.push(M.start,M.count,A,y)}}const g=kr.list,x=this.customSort;x===null?g.sort(n.transparent?cd:ld):x.call(this,g,i);for(let y=0,b=g.length;y<b;y++){const v=g[y];h[m]=v.start*a,c[m]=v.count,p[m]=v.index,m++}kr.reset()}else for(let g=0,x=o.length;g<x;g++)if(o[g].visible&&o[g].active){const y=o[g].geometryIndex;let b=!1;if(d&&(this.getMatrixAt(g,Gt),this.getBoundingSphereAt(y,Ke).applyMatrix4(Gt),b=!zr.intersectsSphere(Ke)),!b){const v=u[y];h[m]=v.start*a,c[m]=v.count,p[m]=g,m++}}f.needsUpdate=!0,this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(t,e,i,s,n,r){this.onBeforeRender(t,null,s,n,r)}}class Xt extends Nt{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new G(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const En=new w,On=new w,Oo=new Z,cs=new ks,ln=new Lt,Pr=new w,Do=new w;class hi extends st{constructor(t=new j,e=new Xt){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let s=1,n=e.count;s<n;s++)En.fromBufferAttribute(e,s-1),On.fromBufferAttribute(e,s),i[s]=i[s-1],i[s]+=En.distanceTo(On);t.setAttribute("lineDistance",new D(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,s=this.matrixWorld,n=t.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ln.copy(i.boundingSphere),ln.applyMatrix4(s),ln.radius+=n,t.ray.intersectsSphere(ln)===!1)return;Oo.copy(s).invert(),cs.copy(t.ray).applyMatrix4(Oo);const a=n/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=this.isLineSegments?2:1,c=i.index,d=i.attributes.position;if(c!==null){const f=Math.max(0,r.start),p=Math.min(c.count,r.start+r.count);for(let m=f,g=p-1;m<g;m+=h){const x=c.getX(m),y=c.getX(m+1),b=cn(this,t,cs,o,x,y);b&&e.push(b)}if(this.isLineLoop){const m=c.getX(p-1),g=c.getX(f),x=cn(this,t,cs,o,m,g);x&&e.push(x)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let m=f,g=p-1;m<g;m+=h){const x=cn(this,t,cs,o,m,m+1);x&&e.push(x)}if(this.isLineLoop){const m=cn(this,t,cs,o,p-1,f);m&&e.push(m)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const a=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}}function cn(l,t,e,i,s,n){const r=l.geometry.attributes.position;if(En.fromBufferAttribute(r,s),On.fromBufferAttribute(r,n),e.distanceSqToSegment(En,On,Pr,Do)>i)return;Pr.applyMatrix4(l.matrixWorld);const o=t.ray.origin.distanceTo(Pr);if(!(o<t.near||o>t.far))return{distance:o,point:Do.clone().applyMatrix4(l.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:l}}const Lo=new w,No=new w;class Re extends hi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let s=0,n=e.count;s<n;s+=2)Lo.fromBufferAttribute(e,s),No.fromBufferAttribute(e,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+Lo.distanceTo(No);t.setAttribute("lineDistance",new D(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gd extends hi{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class jh extends Nt{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new G(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const Uo=new Z,Zr=new ks,un=new Lt,dn=new w;class yd extends st{constructor(t=new j,e=new jh){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const i=this.geometry,s=this.matrixWorld,n=t.params.Points.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),un.copy(i.boundingSphere),un.applyMatrix4(s),un.radius+=n,t.ray.intersectsSphere(un)===!1)return;Uo.copy(s).invert(),Zr.copy(t.ray).applyMatrix4(Uo);const a=n/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,h=i.index,u=i.attributes.position;if(h!==null){const d=Math.max(0,r.start),f=Math.min(h.count,r.start+r.count);for(let p=d,m=f;p<m;p++){const g=h.getX(p);dn.fromBufferAttribute(u,g),Vo(dn,g,o,s,t,e,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,m=f;p<m;p++)dn.fromBufferAttribute(u,p),Vo(dn,p,o,s,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const a=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}}function Vo(l,t,e,i,s,n,r){const a=Zr.distanceSqToPoint(l);if(a<e){const o=new w;Zr.closestPointToPoint(l,o),o.applyMatrix4(i);const h=s.ray.origin.distanceTo(o);if(h<s.near||h>s.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:o,index:t,face:null,faceIndex:null,barycoord:null,object:r})}}class Kh extends st{constructor(){super(),this.isGroup=!0,this.type="Group"}}class by extends yt{constructor(t,e,i,s,n,r,a,o,h){super(t,e,i,s,n,r,a,o,h),this.isVideoTexture=!0,this.minFilter=r!==void 0?r:ae,this.magFilter=n!==void 0?n:ae,this.generateMipmaps=!1;const c=this;function u(){c.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class vy extends yt{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=pe,this.minFilter=pe,this.generateMipmaps=!1,this.needsUpdate=!0}}class ya extends yt{constructor(t,e,i,s,n,r,a,o,h,c,u,d){super(null,r,a,o,h,c,s,n,u,d),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class wy extends ya{constructor(t,e,i,s,n,r){super(t,e,i,n,r),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=ge,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class _y extends ya{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,na),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Qh extends yt{constructor(t,e,i,s,n,r,a,o,h){super(t,e,i,s,n,r,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class My extends yt{constructor(t,e,i,s,n,r,a,o,h,c=sr){if(c!==sr&&c!==eo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&c===sr&&(i=ra),i===void 0&&c===eo&&(i=Mc),super(null,s,n,r,a,o,c,i,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:pe,this.minFilter=o!==void 0?o:pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class ve{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,s=this.getPoint(0),n=0;e.push(0);for(let r=1;r<=t;r++)i=this.getPoint(r/t),n+=i.distanceTo(s),e.push(n),s=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let s=0;const n=i.length;let r;e?r=e:r=t*i[n-1];let a=0,o=n-1,h;for(;a<=o;)if(s=Math.floor(a+(o-a)/2),h=i[s]-r,h<0)a=s+1;else if(h>0)o=s-1;else{o=s;break}if(s=o,i[s]===r)return s/(n-1);const c=i[s],d=i[s+1]-c,f=(r-c)/d;return(s+f)/(n-1)}getTangent(t,e){let s=t-1e-4,n=t+1e-4;s<0&&(s=0),n>1&&(n=1);const r=this.getPoint(s),a=this.getPoint(n),o=e||(r.isVector2?new B:new w);return o.copy(a).sub(r).normalize(),o}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new w,s=[],n=[],r=[],a=new w,o=new Z;for(let f=0;f<=t;f++){const p=f/t;s[f]=this.getTangentAt(p,new w)}n[0]=new w,r[0]=new w;let h=Number.MAX_VALUE;const c=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);c<=h&&(h=c,i.set(1,0,0)),u<=h&&(h=u,i.set(0,1,0)),d<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),n[0].crossVectors(s[0],a),r[0].crossVectors(s[0],n[0]);for(let f=1;f<=t;f++){if(n[f]=n[f-1].clone(),r[f]=r[f-1].clone(),a.crossVectors(s[f-1],s[f]),a.length()>Number.EPSILON){a.normalize();const p=Math.acos(X(s[f-1].dot(s[f]),-1,1));n[f].applyMatrix4(o.makeRotationAxis(a,p))}r[f].crossVectors(s[f],n[f])}if(e===!0){let f=Math.acos(X(n[0].dot(n[t]),-1,1));f/=t,s[0].dot(a.crossVectors(n[0],n[t]))>0&&(f=-f);for(let p=1;p<=t;p++)n[p].applyMatrix4(o.makeRotationAxis(s[p],f*p)),r[p].crossVectors(s[p],n[p])}return{tangents:s,normals:n,binormals:r}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class xa extends ve{constructor(t=0,e=0,i=1,s=1,n=0,r=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=n,this.aEndAngle=r,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new B){const i=e,s=Math.PI*2;let n=this.aEndAngle-this.aStartAngle;const r=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(r?n=0:n=s),this.aClockwise===!0&&!r&&(n===s?n=-s:n=n-s);const a=this.aStartAngle+t*n;let o=this.aX+this.xRadius*Math.cos(a),h=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const c=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=o-this.aX,f=h-this.aY;o=d*c-f*u+this.aX,h=d*u+f*c+this.aY}return i.set(o,h)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class xd extends xa{constructor(t,e,i,s,n,r){super(t,e,i,i,s,n,r),this.isArcCurve=!0,this.type="ArcCurve"}}function ba(){let l=0,t=0,e=0,i=0;function s(n,r,a,o){l=n,t=a,e=-3*n+3*r-2*a-o,i=2*n-2*r+a+o}return{initCatmullRom:function(n,r,a,o,h){s(r,a,h*(a-n),h*(o-r))},initNonuniformCatmullRom:function(n,r,a,o,h,c,u){let d=(r-n)/h-(a-n)/(h+c)+(a-r)/c,f=(a-r)/c-(o-r)/(c+u)+(o-a)/u;d*=c,f*=c,s(r,a,d,f)},calc:function(n){const r=n*n,a=r*n;return l+t*n+e*r+i*a}}}const fn=new w,Fr=new ba,Rr=new ba,Er=new ba;class bd extends ve{constructor(t=[],e=!1,i="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=i,this.tension=s}getPoint(t,e=new w){const i=e,s=this.points,n=s.length,r=(n-(this.closed?0:1))*t;let a=Math.floor(r),o=r-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/n)+1)*n:o===0&&a===n-1&&(a=n-2,o=1);let h,c;this.closed||a>0?h=s[(a-1)%n]:(fn.subVectors(s[0],s[1]).add(s[0]),h=fn);const u=s[a%n],d=s[(a+1)%n];if(this.closed||a+2<n?c=s[(a+2)%n]:(fn.subVectors(s[n-1],s[n-2]).add(s[n-1]),c=fn),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let p=Math.pow(h.distanceToSquared(u),f),m=Math.pow(u.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);m<1e-4&&(m=1),p<1e-4&&(p=m),g<1e-4&&(g=m),Fr.initNonuniformCatmullRom(h.x,u.x,d.x,c.x,p,m,g),Rr.initNonuniformCatmullRom(h.y,u.y,d.y,c.y,p,m,g),Er.initNonuniformCatmullRom(h.z,u.z,d.z,c.z,p,m,g)}else this.curveType==="catmullrom"&&(Fr.initCatmullRom(h.x,u.x,d.x,c.x,this.tension),Rr.initCatmullRom(h.y,u.y,d.y,c.y,this.tension),Er.initCatmullRom(h.z,u.z,d.z,c.z,this.tension));return i.set(Fr.calc(o),Rr.calc(o),Er.calc(o)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const s=t.points[e];this.points.push(new w().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Go(l,t,e,i,s){const n=(i-t)*.5,r=(s-e)*.5,a=l*l,o=l*a;return(2*e-2*i+n+r)*o+(-3*e+3*i-2*n-r)*a+n*l+e}function vd(l,t){const e=1-l;return e*e*t}function wd(l,t){return 2*(1-l)*l*t}function _d(l,t){return l*l*t}function Ms(l,t,e,i){return vd(l,t)+wd(l,e)+_d(l,i)}function Md(l,t){const e=1-l;return e*e*e*t}function Sd(l,t){const e=1-l;return 3*e*e*l*t}function Ad(l,t){return 3*(1-l)*l*l*t}function Id(l,t){return l*l*l*t}function Ss(l,t,e,i,s){return Md(l,t)+Sd(l,e)+Ad(l,i)+Id(l,s)}class tl extends ve{constructor(t=new B,e=new B,i=new B,s=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=i,this.v3=s}getPoint(t,e=new B){const i=e,s=this.v0,n=this.v1,r=this.v2,a=this.v3;return i.set(Ss(t,s.x,n.x,r.x,a.x),Ss(t,s.y,n.y,r.y,a.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Td extends ve{constructor(t=new w,e=new w,i=new w,s=new w){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=i,this.v3=s}getPoint(t,e=new w){const i=e,s=this.v0,n=this.v1,r=this.v2,a=this.v3;return i.set(Ss(t,s.x,n.x,r.x,a.x),Ss(t,s.y,n.y,r.y,a.y),Ss(t,s.z,n.z,r.z,a.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class el extends ve{constructor(t=new B,e=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new B){const i=e;return t===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new B){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Cd extends ve{constructor(t=new w,e=new w){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new w){const i=e;return t===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(t).add(this.v1)),i}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new w){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class il extends ve{constructor(t=new B,e=new B,i=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new B){const i=e,s=this.v0,n=this.v1,r=this.v2;return i.set(Ms(t,s.x,n.x,r.x),Ms(t,s.y,n.y,r.y)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class sl extends ve{constructor(t=new w,e=new w,i=new w){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=i}getPoint(t,e=new w){const i=e,s=this.v0,n=this.v1,r=this.v2;return i.set(Ms(t,s.x,n.x,r.x),Ms(t,s.y,n.y,r.y),Ms(t,s.z,n.z,r.z)),i}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class nl extends ve{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new B){const i=e,s=this.points,n=(s.length-1)*t,r=Math.floor(n),a=n-r,o=s[r===0?r:r-1],h=s[r],c=s[r>s.length-2?s.length-1:r+1],u=s[r>s.length-3?s.length-1:r+2];return i.set(Go(a,o.x,h.x,c.x,u.x),Go(a,o.y,h.y,c.y,u.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,i=this.points.length;e<i;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,i=t.points.length;e<i;e++){const s=t.points[e];this.points.push(new B().fromArray(s))}return this}}var Dn=Object.freeze({__proto__:null,ArcCurve:xd,CatmullRomCurve3:bd,CubicBezierCurve:tl,CubicBezierCurve3:Td,EllipseCurve:xa,LineCurve:el,LineCurve3:Cd,QuadraticBezierCurve:il,QuadraticBezierCurve3:sl,SplineCurve:nl});class Bd extends ve{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const i=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Dn[i](e,t))}return this}getPoint(t,e){const i=t*this.getLength(),s=this.getCurveLengths();let n=0;for(;n<s.length;){if(s[n]>=i){const r=s[n]-i,a=this.curves[n],o=a.getLength(),h=o===0?0:1-r/o;return a.getPointAt(h,e)}n++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,s=this.curves.length;i<s;i++)e+=this.curves[i].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let i;for(let s=0,n=this.curves;s<n.length;s++){const r=n[s],a=r.isEllipseCurve?t*2:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,o=r.getPoints(a);for(let h=0;h<o.length;h++){const c=o[h];i&&i.equals(c)||(e.push(c),i=c)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,i=this.curves.length;e<i;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,i=t.curves.length;e<i;e++){const s=t.curves[e];this.curves.push(new Dn[s.type]().fromJSON(s))}return this}}class Ln extends Bd{constructor(t){super(),this.type="Path",this.currentPoint=new B,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,i=t.length;e<i;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const i=new el(this.currentPoint.clone(),new B(t,e));return this.curves.push(i),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,i,s){const n=new il(this.currentPoint.clone(),new B(t,e),new B(i,s));return this.curves.push(n),this.currentPoint.set(i,s),this}bezierCurveTo(t,e,i,s,n,r){const a=new tl(this.currentPoint.clone(),new B(t,e),new B(i,s),new B(n,r));return this.curves.push(a),this.currentPoint.set(n,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),i=new nl(e);return this.curves.push(i),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,i,s,n,r){const a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(t+a,e+o,i,s,n,r),this}absarc(t,e,i,s,n,r){return this.absellipse(t,e,i,i,s,n,r),this}ellipse(t,e,i,s,n,r,a,o){const h=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(t+h,e+c,i,s,n,r,a,o),this}absellipse(t,e,i,s,n,r,a,o){const h=new xa(t,e,i,s,n,r,a,o);if(this.curves.length>0){const u=h.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(h);const c=h.getPoint(1);return this.currentPoint.copy(c),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Jn extends j{constructor(t=[new B(0,-.5),new B(.5,0),new B(0,.5)],e=12,i=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:s},e=Math.floor(e),s=X(s,0,Math.PI*2);const n=[],r=[],a=[],o=[],h=[],c=1/e,u=new w,d=new B,f=new w,p=new w,m=new w;let g=0,x=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,x=t[y+1].y-t[y].y,f.x=x*1,f.y=-g,f.z=x*0,m.copy(f),f.normalize(),o.push(f.x,f.y,f.z);break;case t.length-1:o.push(m.x,m.y,m.z);break;default:g=t[y+1].x-t[y].x,x=t[y+1].y-t[y].y,f.x=x*1,f.y=-g,f.z=x*0,p.copy(f),f.x+=m.x,f.y+=m.y,f.z+=m.z,f.normalize(),o.push(f.x,f.y,f.z),m.copy(p)}for(let y=0;y<=e;y++){const b=i+y*c*s,v=Math.sin(b),_=Math.cos(b);for(let M=0;M<=t.length-1;M++){u.x=t[M].x*v,u.y=t[M].y,u.z=t[M].x*_,r.push(u.x,u.y,u.z),d.x=y/e,d.y=M/(t.length-1),a.push(d.x,d.y);const A=o[3*M+0]*v,S=o[3*M+1],T=o[3*M+0]*_;h.push(A,S,T)}}for(let y=0;y<e;y++)for(let b=0;b<t.length-1;b++){const v=b+y*t.length,_=v,M=v+t.length,A=v+t.length+1,S=v+1;n.push(_,M,S),n.push(A,S,M)}this.setIndex(n),this.setAttribute("position",new D(r,3)),this.setAttribute("uv",new D(a,2)),this.setAttribute("normal",new D(h,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jn(t.points,t.segments,t.phiStart,t.phiLength)}}class va extends Jn{constructor(t=1,e=1,i=4,s=8){const n=new Ln;n.absarc(0,-e/2,t,Math.PI*1.5,0),n.absarc(0,e/2,t,0,Math.PI*.5),super(n.getPoints(i),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:i,radialSegments:s}}static fromJSON(t){return new va(t.radius,t.length,t.capSegments,t.radialSegments)}}class wa extends j{constructor(t=1,e=32,i=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:s},e=Math.max(3,e);const n=[],r=[],a=[],o=[],h=new w,c=new B;r.push(0,0,0),a.push(0,0,1),o.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=i+u/e*s;h.x=t*Math.cos(f),h.y=t*Math.sin(f),r.push(h.x,h.y,h.z),a.push(0,0,1),c.x=(r[d]/t+1)/2,c.y=(r[d+1]/t+1)/2,o.push(c.x,c.y)}for(let u=1;u<=e;u++)n.push(u,u+1,0);this.setIndex(n),this.setAttribute("position",new D(r,3)),this.setAttribute("normal",new D(a,3)),this.setAttribute("uv",new D(o,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new wa(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Ps extends j{constructor(t=1,e=1,i=1,s=32,n=1,r=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:s,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:o};const h=this;s=Math.floor(s),n=Math.floor(n);const c=[],u=[],d=[],f=[];let p=0;const m=[],g=i/2;let x=0;y(),r===!1&&(t>0&&b(!0),e>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new D(u,3)),this.setAttribute("normal",new D(d,3)),this.setAttribute("uv",new D(f,2));function y(){const v=new w,_=new w;let M=0;const A=(e-t)/i;for(let S=0;S<=n;S++){const T=[],C=S/n,P=C*(e-t)+t;for(let V=0;V<=s;V++){const q=V/s,L=q*o+a,I=Math.sin(L),U=Math.cos(L);_.x=P*I,_.y=-C*i+g,_.z=P*U,u.push(_.x,_.y,_.z),v.set(I,A,U).normalize(),d.push(v.x,v.y,v.z),f.push(q,1-C),T.push(p++)}m.push(T)}for(let S=0;S<s;S++)for(let T=0;T<n;T++){const C=m[T][S],P=m[T+1][S],V=m[T+1][S+1],q=m[T][S+1];(t>0||T!==0)&&(c.push(C,P,q),M+=3),(e>0||T!==n-1)&&(c.push(P,V,q),M+=3)}h.addGroup(x,M,0),x+=M}function b(v){const _=p,M=new B,A=new w;let S=0;const T=v===!0?t:e,C=v===!0?1:-1;for(let V=1;V<=s;V++)u.push(0,g*C,0),d.push(0,C,0),f.push(.5,.5),p++;const P=p;for(let V=0;V<=s;V++){const L=V/s*o+a,I=Math.cos(L),U=Math.sin(L);A.x=T*U,A.y=g*C,A.z=T*I,u.push(A.x,A.y,A.z),d.push(0,C,0),M.x=I*.5+.5,M.y=U*.5*C+.5,f.push(M.x,M.y),p++}for(let V=0;V<s;V++){const q=_+V,L=P+V;v===!0?c.push(L,L+1,q):c.push(L+1,L,q),S+=3}h.addGroup(x,S,v===!0?1:2),x+=S}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ps(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class _a extends Ps{constructor(t=1,e=1,i=32,s=1,n=!1,r=0,a=Math.PI*2){super(0,t,e,i,s,n,r,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:s,openEnded:n,thetaStart:r,thetaLength:a}}static fromJSON(t){return new _a(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ci extends j{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const n=[],r=[];a(s),h(i),c(),this.setAttribute("position",new D(n,3)),this.setAttribute("normal",new D(n.slice(),3)),this.setAttribute("uv",new D(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const b=new w,v=new w,_=new w;for(let M=0;M<e.length;M+=3)f(e[M+0],b),f(e[M+1],v),f(e[M+2],_),o(b,v,_,y)}function o(y,b,v,_){const M=_+1,A=[];for(let S=0;S<=M;S++){A[S]=[];const T=y.clone().lerp(v,S/M),C=b.clone().lerp(v,S/M),P=M-S;for(let V=0;V<=P;V++)V===0&&S===M?A[S][V]=T:A[S][V]=T.clone().lerp(C,V/P)}for(let S=0;S<M;S++)for(let T=0;T<2*(M-S)-1;T++){const C=Math.floor(T/2);T%2===0?(d(A[S][C+1]),d(A[S+1][C]),d(A[S][C])):(d(A[S][C+1]),d(A[S+1][C+1]),d(A[S+1][C]))}}function h(y){const b=new w;for(let v=0;v<n.length;v+=3)b.x=n[v+0],b.y=n[v+1],b.z=n[v+2],b.normalize().multiplyScalar(y),n[v+0]=b.x,n[v+1]=b.y,n[v+2]=b.z}function c(){const y=new w;for(let b=0;b<n.length;b+=3){y.x=n[b+0],y.y=n[b+1],y.z=n[b+2];const v=g(y)/2/Math.PI+.5,_=x(y)/Math.PI+.5;r.push(v,1-_)}p(),u()}function u(){for(let y=0;y<r.length;y+=6){const b=r[y+0],v=r[y+2],_=r[y+4],M=Math.max(b,v,_),A=Math.min(b,v,_);M>.9&&A<.1&&(b<.2&&(r[y+0]+=1),v<.2&&(r[y+2]+=1),_<.2&&(r[y+4]+=1))}}function d(y){n.push(y.x,y.y,y.z)}function f(y,b){const v=y*3;b.x=t[v+0],b.y=t[v+1],b.z=t[v+2]}function p(){const y=new w,b=new w,v=new w,_=new w,M=new B,A=new B,S=new B;for(let T=0,C=0;T<n.length;T+=9,C+=6){y.set(n[T+0],n[T+1],n[T+2]),b.set(n[T+3],n[T+4],n[T+5]),v.set(n[T+6],n[T+7],n[T+8]),M.set(r[C+0],r[C+1]),A.set(r[C+2],r[C+3]),S.set(r[C+4],r[C+5]),_.copy(y).add(b).add(v).divideScalar(3);const P=g(_);m(M,C+0,y,P),m(A,C+2,b,P),m(S,C+4,v,P)}}function m(y,b,v,_){_<0&&y.x===1&&(r[b]=y.x-1),v.x===0&&v.z===0&&(r[b]=_/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function x(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ci(t.vertices,t.indices,t.radius,t.details)}}class Ma extends ci{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=1/i,n=[-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,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],r=[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];super(n,r,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ma(t.radius,t.detail)}}const pn=new w,mn=new w,Or=new w,gn=new Kt;class zd extends j{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){const s=Math.pow(10,4),n=Math.cos(ai*e),r=t.getIndex(),a=t.getAttribute("position"),o=r?r.count:a.count,h=[0,0,0],c=["a","b","c"],u=new Array(3),d={},f=[];for(let p=0;p<o;p+=3){r?(h[0]=r.getX(p),h[1]=r.getX(p+1),h[2]=r.getX(p+2)):(h[0]=p,h[1]=p+1,h[2]=p+2);const{a:m,b:g,c:x}=gn;if(m.fromBufferAttribute(a,h[0]),g.fromBufferAttribute(a,h[1]),x.fromBufferAttribute(a,h[2]),gn.getNormal(Or),u[0]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,u[1]=`${Math.round(g.x*s)},${Math.round(g.y*s)},${Math.round(g.z*s)}`,u[2]=`${Math.round(x.x*s)},${Math.round(x.y*s)},${Math.round(x.z*s)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const b=(y+1)%3,v=u[y],_=u[b],M=gn[c[y]],A=gn[c[b]],S=`${v}_${_}`,T=`${_}_${v}`;T in d&&d[T]?(Or.dot(d[T].normal)<=n&&(f.push(M.x,M.y,M.z),f.push(A.x,A.y,A.z)),d[T]=null):S in d||(d[S]={index0:h[y],index1:h[b],normal:Or.clone()})}}for(const p in d)if(d[p]){const{index0:m,index1:g}=d[p];pn.fromBufferAttribute(a,m),mn.fromBufferAttribute(a,g),f.push(pn.x,pn.y,pn.z),f.push(mn.x,mn.y,mn.z)}this.setAttribute("position",new D(f,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}class Vi extends Ln{constructor(t){super(t),this.uuid=Qt(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,s=this.holes.length;i<s;i++)e[i]=this.holes[i].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const s=t.holes[e];this.holes.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,i=this.holes.length;e<i;e++){const s=this.holes[e];t.holes.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,i=t.holes.length;e<i;e++){const s=t.holes[e];this.holes.push(new Ln().fromJSON(s))}return this}}const kd={triangulate:function(l,t,e=2){const i=t&&t.length,s=i?t[0]*e:l.length;let n=rl(l,0,s,e,!0);const r=[];if(!n||n.next===n.prev)return r;let a,o,h,c,u,d,f;if(i&&(n=Od(l,t,n,e)),l.length>80*e){a=h=l[0],o=c=l[1];for(let p=e;p<s;p+=e)u=l[p],d=l[p+1],u<a&&(a=u),d<o&&(o=d),u>h&&(h=u),d>c&&(c=d);f=Math.max(h-a,c-o),f=f!==0?32767/f:0}return Cs(n,r,e,a,o,f,0),r}};function rl(l,t,e,i,s){let n,r;if(s===Yd(l,t,e,i)>0)for(n=t;n<e;n+=i)r=Wo(n,l[n],l[n+1],r);else for(n=e-i;n>=t;n-=i)r=Wo(n,l[n],l[n+1],r);return r&&Zn(r,r.next)&&(zs(r),r=r.next),r}function li(l,t){if(!l)return l;t||(t=l);let e=l,i;do if(i=!1,!e.steiner&&(Zn(e,e.next)||dt(e.prev,e,e.next)===0)){if(zs(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Cs(l,t,e,i,s,n,r){if(!l)return;!r&&n&&Vd(l,i,s,n);let a=l,o,h;for(;l.prev!==l.next;){if(o=l.prev,h=l.next,n?Fd(l,i,s,n):Pd(l)){t.push(o.i/e|0),t.push(l.i/e|0),t.push(h.i/e|0),zs(l),l=h.next,a=h.next;continue}if(l=h,l===a){r?r===1?(l=Rd(li(l),t,e),Cs(l,t,e,i,s,n,2)):r===2&&Ed(l,t,e,i,s,n):Cs(li(l),t,e,i,s,n,1);break}}}function Pd(l){const t=l.prev,e=l,i=l.next;if(dt(t,e,i)>=0)return!1;const s=t.x,n=e.x,r=i.x,a=t.y,o=e.y,h=i.y,c=s<n?s<r?s:r:n<r?n:r,u=a<o?a<h?a:h:o<h?o:h,d=s>n?s>r?s:r:n>r?n:r,f=a>o?a>h?a:h:o>h?o:h;let p=i.next;for(;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=u&&p.y<=f&&Ni(s,a,n,o,r,h,p.x,p.y)&&dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Fd(l,t,e,i){const s=l.prev,n=l,r=l.next;if(dt(s,n,r)>=0)return!1;const a=s.x,o=n.x,h=r.x,c=s.y,u=n.y,d=r.y,f=a<o?a<h?a:h:o<h?o:h,p=c<u?c<d?c:d:u<d?u:d,m=a>o?a>h?a:h:o>h?o:h,g=c>u?c>d?c:d:u>d?u:d,x=$r(f,p,t,e,i),y=$r(m,g,t,e,i);let b=l.prevZ,v=l.nextZ;for(;b&&b.z>=x&&v&&v.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==r&&Ni(a,c,o,u,h,d,b.x,b.y)&&dt(b.prev,b,b.next)>=0||(b=b.prevZ,v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==r&&Ni(a,c,o,u,h,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;b&&b.z>=x;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==s&&b!==r&&Ni(a,c,o,u,h,d,b.x,b.y)&&dt(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==s&&v!==r&&Ni(a,c,o,u,h,d,v.x,v.y)&&dt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Rd(l,t,e){let i=l;do{const s=i.prev,n=i.next.next;!Zn(s,n)&&al(s,i,i.next,n)&&Bs(s,n)&&Bs(n,s)&&(t.push(s.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),zs(i),zs(i.next),i=l=n),i=i.next}while(i!==l);return li(i)}function Ed(l,t,e,i,s,n){let r=l;do{let a=r.next.next;for(;a!==r.prev;){if(r.i!==a.i&&Hd(r,a)){let o=ol(r,a);r=li(r,r.next),o=li(o,o.next),Cs(r,t,e,i,s,n,0),Cs(o,t,e,i,s,n,0);return}a=a.next}r=r.next}while(r!==l)}function Od(l,t,e,i){const s=[];let n,r,a,o,h;for(n=0,r=t.length;n<r;n++)a=t[n]*i,o=n<r-1?t[n+1]*i:l.length,h=rl(l,a,o,i,!1),h===h.next&&(h.steiner=!0),s.push(Wd(h));for(s.sort(Dd),n=0;n<s.length;n++)e=Ld(s[n],e);return e}function Dd(l,t){return l.x-t.x}function Ld(l,t){const e=Nd(l,t);if(!e)return t;const i=ol(e,l);return li(i,i.next),li(e,e.next)}function Nd(l,t){let e=t,i=-1/0,s;const n=l.x,r=l.y;do{if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const d=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>i&&(i=d,s=e.x<e.next.x?e:e.next,d===n))return s}e=e.next}while(e!==t);if(!s)return null;const a=s,o=s.x,h=s.y;let c=1/0,u;e=s;do n>=e.x&&e.x>=o&&n!==e.x&&Ni(r<h?n:i,r,o,h,r<h?i:n,r,e.x,e.y)&&(u=Math.abs(r-e.y)/(n-e.x),Bs(e,l)&&(u<c||u===c&&(e.x>s.x||e.x===s.x&&Ud(s,e)))&&(s=e,c=u)),e=e.next;while(e!==a);return s}function Ud(l,t){return dt(l.prev,l,t.prev)<0&&dt(t.next,l,l.next)<0}function Vd(l,t,e,i){let s=l;do s.z===0&&(s.z=$r(s.x,s.y,t,e,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==l);s.prevZ.nextZ=null,s.prevZ=null,Gd(s)}function Gd(l){let t,e,i,s,n,r,a,o,h=1;do{for(e=l,l=null,n=null,r=0;e;){for(r++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(o=h;a>0||o>0&&i;)a!==0&&(o===0||!i||e.z<=i.z)?(s=e,e=e.nextZ,a--):(s=i,i=i.nextZ,o--),n?n.nextZ=s:l=s,s.prevZ=n,n=s;e=i}n.nextZ=null,h*=2}while(r>1);return l}function $r(l,t,e,i,s){return l=(l-e)*s|0,t=(t-i)*s|0,l=(l|l<<8)&16711935,l=(l|l<<4)&252645135,l=(l|l<<2)&858993459,l=(l|l<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,l|t<<1}function Wd(l){let t=l,e=l;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==l);return e}function Ni(l,t,e,i,s,n,r,a){return(s-r)*(t-a)>=(l-r)*(n-a)&&(l-r)*(i-a)>=(e-r)*(t-a)&&(e-r)*(n-a)>=(s-r)*(i-a)}function Hd(l,t){return l.next.i!==t.i&&l.prev.i!==t.i&&!qd(l,t)&&(Bs(l,t)&&Bs(t,l)&&Xd(l,t)&&(dt(l.prev,l,t.prev)||dt(l,t.prev,t))||Zn(l,t)&&dt(l.prev,l,l.next)>0&&dt(t.prev,t,t.next)>0)}function dt(l,t,e){return(t.y-l.y)*(e.x-t.x)-(t.x-l.x)*(e.y-t.y)}function Zn(l,t){return l.x===t.x&&l.y===t.y}function al(l,t,e,i){const s=xn(dt(l,t,e)),n=xn(dt(l,t,i)),r=xn(dt(e,i,l)),a=xn(dt(e,i,t));return!!(s!==n&&r!==a||s===0&&yn(l,e,t)||n===0&&yn(l,i,t)||r===0&&yn(e,l,i)||a===0&&yn(e,t,i))}function yn(l,t,e){return t.x<=Math.max(l.x,e.x)&&t.x>=Math.min(l.x,e.x)&&t.y<=Math.max(l.y,e.y)&&t.y>=Math.min(l.y,e.y)}function xn(l){return l>0?1:l<0?-1:0}function qd(l,t){let e=l;do{if(e.i!==l.i&&e.next.i!==l.i&&e.i!==t.i&&e.next.i!==t.i&&al(e,e.next,l,t))return!0;e=e.next}while(e!==l);return!1}function Bs(l,t){return dt(l.prev,l,l.next)<0?dt(l,t,l.next)>=0&&dt(l,l.prev,t)>=0:dt(l,t,l.prev)<0||dt(l,l.next,t)<0}function Xd(l,t){let e=l,i=!1;const s=(l.x+t.x)/2,n=(l.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&s<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==l);return i}function ol(l,t){const e=new jr(l.i,l.x,l.y),i=new jr(t.i,t.x,t.y),s=l.next,n=t.prev;return l.next=t,t.prev=l,e.next=s,s.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Wo(l,t,e,i){const s=new jr(l,t,e);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function zs(l){l.next.prev=l.prev,l.prev.next=l.next,l.prevZ&&(l.prevZ.nextZ=l.nextZ),l.nextZ&&(l.nextZ.prevZ=l.prevZ)}function jr(l,t,e){this.i=l,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Yd(l,t,e,i){let s=0;for(let n=t,r=e-i;n<e;n+=i)s+=(l[r]-l[n])*(l[n+1]+l[r+1]),r=n;return s}class Fe{static area(t){const e=t.length;let i=0;for(let s=e-1,n=0;n<e;s=n++)i+=t[s].x*t[n].y-t[n].x*t[s].y;return i*.5}static isClockWise(t){return Fe.area(t)<0}static triangulateShape(t,e){const i=[],s=[],n=[];Ho(t),qo(i,t);let r=t.length;e.forEach(Ho);for(let o=0;o<e.length;o++)s.push(r),r+=e[o].length,qo(i,e[o]);const a=kd.triangulate(i,s);for(let o=0;o<a.length;o+=3)n.push(a.slice(o,o+3));return n}}function Ho(l){const t=l.length;t>2&&l[t-1].equals(l[0])&&l.pop()}function qo(l,t){for(let e=0;e<t.length;e++)l.push(t[e].x),l.push(t[e].y)}class Sa extends j{constructor(t=new Vi([new B(.5,.5),new B(-.5,.5),new B(-.5,-.5),new B(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const i=this,s=[],n=[];for(let a=0,o=t.length;a<o;a++){const h=t[a];r(h)}this.setAttribute("position",new D(s,3)),this.setAttribute("uv",new D(n,2)),this.computeVertexNormals();function r(a){const o=[],h=e.curveSegments!==void 0?e.curveSegments:12,c=e.steps!==void 0?e.steps:1,u=e.depth!==void 0?e.depth:1;let d=e.bevelEnabled!==void 0?e.bevelEnabled:!0,f=e.bevelThickness!==void 0?e.bevelThickness:.2,p=e.bevelSize!==void 0?e.bevelSize:f-.1,m=e.bevelOffset!==void 0?e.bevelOffset:0,g=e.bevelSegments!==void 0?e.bevelSegments:3;const x=e.extrudePath,y=e.UVGenerator!==void 0?e.UVGenerator:Jd;let b,v=!1,_,M,A,S;x&&(b=x.getSpacedPoints(c),v=!0,d=!1,_=x.computeFrenetFrames(c,!1),M=new w,A=new w,S=new w),d||(g=0,f=0,p=0,m=0);const T=a.extractPoints(h);let C=T.shape;const P=T.holes;if(!Fe.isClockWise(C)){C=C.reverse();for(let k=0,E=P.length;k<E;k++){const R=P[k];Fe.isClockWise(R)&&(P[k]=R.reverse())}}const q=Fe.triangulateShape(C,P),L=C;for(let k=0,E=P.length;k<E;k++){const R=P[k];C=C.concat(R)}function I(k,E,R){return E||console.error("THREE.ExtrudeGeometry: vec does not exist"),k.clone().addScaledVector(E,R)}const U=C.length,wt=q.length;function Ct(k,E,R){let W,N,et;const nt=k.x-E.x,O=k.y-E.y,K=R.x-k.x,lt=R.y-k.y,ie=nt*nt+O*O,$=nt*lt-O*K;if(Math.abs($)>Number.EPSILON){const Vt=Math.sqrt(ie),Bt=Math.sqrt(K*K+lt*lt),fi=E.x-O/Vt,Ji=E.y+nt/Vt,tr=R.x-lt/Bt,Rs=R.y+K/Bt,Es=((tr-fi)*lt-(Rs-Ji)*K)/(nt*lt-O*K);W=fi+nt*Es-k.x,N=Ji+O*Es-k.y;const Zi=W*W+N*N;if(Zi<=2)return new B(W,N);et=Math.sqrt(Zi/2)}else{let Vt=!1;nt>Number.EPSILON?K>Number.EPSILON&&(Vt=!0):nt<-Number.EPSILON?K<-Number.EPSILON&&(Vt=!0):Math.sign(O)===Math.sign(lt)&&(Vt=!0),Vt?(W=-O,N=nt,et=Math.sqrt(ie)):(W=nt,N=O,et=Math.sqrt(ie/2))}return new B(W/et,N/et)}const tt=[];for(let k=0,E=L.length,R=E-1,W=k+1;k<E;k++,R++,W++)R===E&&(R=0),W===E&&(W=0),tt[k]=Ct(L[k],L[R],L[W]);const J=[];let ht,Ut=tt.concat();for(let k=0,E=P.length;k<E;k++){const R=P[k];ht=[];for(let W=0,N=R.length,et=N-1,nt=W+1;W<N;W++,et++,nt++)et===N&&(et=0),nt===N&&(nt=0),ht[W]=Ct(R[W],R[et],R[nt]);J.push(ht),Ut=Ut.concat(ht)}for(let k=0;k<g;k++){const E=k/g,R=f*Math.cos(E*Math.PI/2),W=p*Math.sin(E*Math.PI/2)+m;for(let N=0,et=L.length;N<et;N++){const nt=I(L[N],tt[N],W);Yt(nt.x,nt.y,-R)}for(let N=0,et=P.length;N<et;N++){const nt=P[N];ht=J[N];for(let O=0,K=nt.length;O<K;O++){const lt=I(nt[O],ht[O],W);Yt(lt.x,lt.y,-R)}}}const oe=p+m;for(let k=0;k<U;k++){const E=d?I(C[k],Ut[k],oe):C[k];v?(A.copy(_.normals[0]).multiplyScalar(E.x),M.copy(_.binormals[0]).multiplyScalar(E.y),S.copy(b[0]).add(A).add(M),Yt(S.x,S.y,S.z)):Yt(E.x,E.y,0)}for(let k=1;k<=c;k++)for(let E=0;E<U;E++){const R=d?I(C[E],Ut[E],oe):C[E];v?(A.copy(_.normals[k]).multiplyScalar(R.x),M.copy(_.binormals[k]).multiplyScalar(R.y),S.copy(b[k]).add(A).add(M),Yt(S.x,S.y,S.z)):Yt(R.x,R.y,u/c*k)}for(let k=g-1;k>=0;k--){const E=k/g,R=f*Math.cos(E*Math.PI/2),W=p*Math.sin(E*Math.PI/2)+m;for(let N=0,et=L.length;N<et;N++){const nt=I(L[N],tt[N],W);Yt(nt.x,nt.y,u+R)}for(let N=0,et=P.length;N<et;N++){const nt=P[N];ht=J[N];for(let O=0,K=nt.length;O<K;O++){const lt=I(nt[O],ht[O],W);v?Yt(lt.x,lt.y+b[c-1].y,b[c-1].x+R):Yt(lt.x,lt.y,u+R)}}}di(),Ye();function di(){const k=s.length/3;if(d){let E=0,R=U*E;for(let W=0;W<wt;W++){const N=q[W];he(N[2]+R,N[1]+R,N[0]+R)}E=c+g*2,R=U*E;for(let W=0;W<wt;W++){const N=q[W];he(N[0]+R,N[1]+R,N[2]+R)}}else{for(let E=0;E<wt;E++){const R=q[E];he(R[2],R[1],R[0])}for(let E=0;E<wt;E++){const R=q[E];he(R[0]+U*c,R[1]+U*c,R[2]+U*c)}}i.addGroup(k,s.length/3-k,0)}function Ye(){const k=s.length/3;let E=0;Ee(L,E),E+=L.length;for(let R=0,W=P.length;R<W;R++){const N=P[R];Ee(N,E),E+=N.length}i.addGroup(k,s.length/3-k,1)}function Ee(k,E){let R=k.length;for(;--R>=0;){const W=R;let N=R-1;N<0&&(N=k.length-1);for(let et=0,nt=c+g*2;et<nt;et++){const O=U*et,K=U*(et+1),lt=E+W+O,ie=E+N+O,$=E+N+K,Vt=E+W+K;Qn(lt,ie,$,Vt)}}}function Yt(k,E,R){o.push(k),o.push(E),o.push(R)}function he(k,E,R){le(k),le(E),le(R);const W=s.length/3,N=y.generateTopUV(i,s,W-3,W-2,W-1);ce(N[0]),ce(N[1]),ce(N[2])}function Qn(k,E,R,W){le(k),le(E),le(W),le(E),le(R),le(W);const N=s.length/3,et=y.generateSideWallUV(i,s,N-6,N-3,N-2,N-1);ce(et[0]),ce(et[1]),ce(et[3]),ce(et[1]),ce(et[2]),ce(et[3])}function le(k){s.push(o[k*3+0]),s.push(o[k*3+1]),s.push(o[k*3+2])}function ce(k){n.push(k.x),n.push(k.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes,i=this.parameters.options;return Zd(e,i,t)}static fromJSON(t,e){const i=[];for(let n=0,r=t.shapes.length;n<r;n++){const a=e[t.shapes[n]];i.push(a)}const s=t.options.extrudePath;return s!==void 0&&(t.options.extrudePath=new Dn[s.type]().fromJSON(s)),new Sa(i,t.options)}}const Jd={generateTopUV:function(l,t,e,i,s){const n=t[e*3],r=t[e*3+1],a=t[i*3],o=t[i*3+1],h=t[s*3],c=t[s*3+1];return[new B(n,r),new B(a,o),new B(h,c)]},generateSideWallUV:function(l,t,e,i,s,n){const r=t[e*3],a=t[e*3+1],o=t[e*3+2],h=t[i*3],c=t[i*3+1],u=t[i*3+2],d=t[s*3],f=t[s*3+1],p=t[s*3+2],m=t[n*3],g=t[n*3+1],x=t[n*3+2];return Math.abs(a-c)<Math.abs(r-h)?[new B(r,1-o),new B(h,1-u),new B(d,1-p),new B(m,1-x)]:[new B(a,1-o),new B(c,1-u),new B(f,1-p),new B(g,1-x)]}};function Zd(l,t,e){if(e.shapes=[],Array.isArray(l))for(let i=0,s=l.length;i<s;i++){const n=l[i];e.shapes.push(n.uuid)}else e.shapes.push(l.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}class Aa extends ci{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],n=[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];super(s,n,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Aa(t.radius,t.detail)}}class $n extends ci{constructor(t=1,e=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],s=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,s,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new $n(t.radius,t.detail)}}class Ia extends j{constructor(t=1,e=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:s};const n=t/2,r=e/2,a=Math.floor(i),o=Math.floor(s),h=a+1,c=o+1,u=t/a,d=e/o,f=[],p=[],m=[],g=[];for(let x=0;x<c;x++){const y=x*d-r;for(let b=0;b<h;b++){const v=b*u-n;p.push(v,-y,0),m.push(0,0,1),g.push(b/a),g.push(1-x/o)}}for(let x=0;x<o;x++)for(let y=0;y<a;y++){const b=y+h*x,v=y+h*(x+1),_=y+1+h*(x+1),M=y+1+h*x;f.push(b,v,M),f.push(v,_,M)}this.setIndex(f),this.setAttribute("position",new D(p,3)),this.setAttribute("normal",new D(m,3)),this.setAttribute("uv",new D(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ia(t.width,t.height,t.widthSegments,t.heightSegments)}}class Ta extends j{constructor(t=.5,e=1,i=32,s=1,n=0,r=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:i,phiSegments:s,thetaStart:n,thetaLength:r},i=Math.max(3,i),s=Math.max(1,s);const a=[],o=[],h=[],c=[];let u=t;const d=(e-t)/s,f=new w,p=new B;for(let m=0;m<=s;m++){for(let g=0;g<=i;g++){const x=n+g/i*r;f.x=u*Math.cos(x),f.y=u*Math.sin(x),o.push(f.x,f.y,f.z),h.push(0,0,1),p.x=(f.x/e+1)/2,p.y=(f.y/e+1)/2,c.push(p.x,p.y)}u+=d}for(let m=0;m<s;m++){const g=m*(i+1);for(let x=0;x<i;x++){const y=x+g,b=y,v=y+i+1,_=y+i+2,M=y+1;a.push(b,v,M),a.push(v,_,M)}}this.setIndex(a),this.setAttribute("position",new D(o,3)),this.setAttribute("normal",new D(h,3)),this.setAttribute("uv",new D(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ta(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class Ca extends j{constructor(t=new Vi([new B(0,.5),new B(-.5,-.5),new B(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const i=[],s=[],n=[],r=[];let a=0,o=0;if(Array.isArray(t)===!1)h(t);else for(let c=0;c<t.length;c++)h(t[c]),this.addGroup(a,o,c),a+=o,o=0;this.setIndex(i),this.setAttribute("position",new D(s,3)),this.setAttribute("normal",new D(n,3)),this.setAttribute("uv",new D(r,2));function h(c){const u=s.length/3,d=c.extractPoints(e);let f=d.shape;const p=d.holes;Fe.isClockWise(f)===!1&&(f=f.reverse());for(let g=0,x=p.length;g<x;g++){const y=p[g];Fe.isClockWise(y)===!0&&(p[g]=y.reverse())}const m=Fe.triangulateShape(f,p);for(let g=0,x=p.length;g<x;g++){const y=p[g];f=f.concat(y)}for(let g=0,x=f.length;g<x;g++){const y=f[g];s.push(y.x,y.y,0),n.push(0,0,1),r.push(y.x,y.y)}for(let g=0,x=m.length;g<x;g++){const y=m[g],b=y[0]+u,v=y[1]+u,_=y[2]+u;i.push(b,v,_),o+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return $d(e,t)}static fromJSON(t,e){const i=[];for(let s=0,n=t.shapes.length;s<n;s++){const r=e[t.shapes[s]];i.push(r)}return new Ca(i,t.curveSegments)}}function $d(l,t){if(t.shapes=[],Array.isArray(l))for(let e=0,i=l.length;e<i;e++){const s=l[e];t.shapes.push(s.uuid)}else t.shapes.push(l.uuid);return t}class Fs extends j{constructor(t=1,e=32,i=16,s=0,n=Math.PI*2,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:s,phiLength:n,thetaStart:r,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const o=Math.min(r+a,Math.PI);let h=0;const c=[],u=new w,d=new w,f=[],p=[],m=[],g=[];for(let x=0;x<=i;x++){const y=[],b=x/i;let v=0;x===0&&r===0?v=.5/e:x===i&&o===Math.PI&&(v=-.5/e);for(let _=0;_<=e;_++){const M=_/e;u.x=-t*Math.cos(s+M*n)*Math.sin(r+b*a),u.y=t*Math.cos(r+b*a),u.z=t*Math.sin(s+M*n)*Math.sin(r+b*a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),m.push(d.x,d.y,d.z),g.push(M+v,1-b),y.push(h++)}c.push(y)}for(let x=0;x<i;x++)for(let y=0;y<e;y++){const b=c[x][y+1],v=c[x][y],_=c[x+1][y],M=c[x+1][y+1];(x!==0||r>0)&&f.push(b,v,M),(x!==i-1||o<Math.PI)&&f.push(v,_,M)}this.setIndex(f),this.setAttribute("position",new D(p,3)),this.setAttribute("normal",new D(m,3)),this.setAttribute("uv",new D(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Fs(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Ba extends ci{constructor(t=1,e=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],s=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,s,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ba(t.radius,t.detail)}}class za extends j{constructor(t=1,e=.4,i=12,s=48,n=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:s,arc:n},i=Math.floor(i),s=Math.floor(s);const r=[],a=[],o=[],h=[],c=new w,u=new w,d=new w;for(let f=0;f<=i;f++)for(let p=0;p<=s;p++){const m=p/s*n,g=f/i*Math.PI*2;u.x=(t+e*Math.cos(g))*Math.cos(m),u.y=(t+e*Math.cos(g))*Math.sin(m),u.z=e*Math.sin(g),a.push(u.x,u.y,u.z),c.x=t*Math.cos(m),c.y=t*Math.sin(m),d.subVectors(u,c).normalize(),o.push(d.x,d.y,d.z),h.push(p/s),h.push(f/i)}for(let f=1;f<=i;f++)for(let p=1;p<=s;p++){const m=(s+1)*f+p-1,g=(s+1)*(f-1)+p-1,x=(s+1)*(f-1)+p,y=(s+1)*f+p;r.push(m,g,y),r.push(g,x,y)}this.setIndex(r),this.setAttribute("position",new D(a,3)),this.setAttribute("normal",new D(o,3)),this.setAttribute("uv",new D(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new za(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class ka extends j{constructor(t=1,e=.4,i=64,s=8,n=2,r=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:i,radialSegments:s,p:n,q:r},i=Math.floor(i),s=Math.floor(s);const a=[],o=[],h=[],c=[],u=new w,d=new w,f=new w,p=new w,m=new w,g=new w,x=new w;for(let b=0;b<=i;++b){const v=b/i*n*Math.PI*2;y(v,n,r,t,f),y(v+.01,n,r,t,p),g.subVectors(p,f),x.addVectors(p,f),m.crossVectors(g,x),x.crossVectors(m,g),m.normalize(),x.normalize();for(let _=0;_<=s;++_){const M=_/s*Math.PI*2,A=-e*Math.cos(M),S=e*Math.sin(M);u.x=f.x+(A*x.x+S*m.x),u.y=f.y+(A*x.y+S*m.y),u.z=f.z+(A*x.z+S*m.z),o.push(u.x,u.y,u.z),d.subVectors(u,f).normalize(),h.push(d.x,d.y,d.z),c.push(b/i),c.push(_/s)}}for(let b=1;b<=i;b++)for(let v=1;v<=s;v++){const _=(s+1)*(b-1)+(v-1),M=(s+1)*b+(v-1),A=(s+1)*b+v,S=(s+1)*(b-1)+v;a.push(_,M,S),a.push(M,A,S)}this.setIndex(a),this.setAttribute("position",new D(o,3)),this.setAttribute("normal",new D(h,3)),this.setAttribute("uv",new D(c,2));function y(b,v,_,M,A){const S=Math.cos(b),T=Math.sin(b),C=_/v*b,P=Math.cos(C);A.x=M*(2+P)*.5*S,A.y=M*(2+P)*T*.5,A.z=M*Math.sin(C)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ka(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}}class Pa extends j{constructor(t=new sl(new w(-1,-1,0),new w(-1,1,0),new w(1,1,0)),e=64,i=1,s=8,n=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:i,radialSegments:s,closed:n};const r=t.computeFrenetFrames(e,n);this.tangents=r.tangents,this.normals=r.normals,this.binormals=r.binormals;const a=new w,o=new w,h=new B;let c=new w;const u=[],d=[],f=[],p=[];m(),this.setIndex(p),this.setAttribute("position",new D(u,3)),this.setAttribute("normal",new D(d,3)),this.setAttribute("uv",new D(f,2));function m(){for(let b=0;b<e;b++)g(b);g(n===!1?e:0),y(),x()}function g(b){c=t.getPointAt(b/e,c);const v=r.normals[b],_=r.binormals[b];for(let M=0;M<=s;M++){const A=M/s*Math.PI*2,S=Math.sin(A),T=-Math.cos(A);o.x=T*v.x+S*_.x,o.y=T*v.y+S*_.y,o.z=T*v.z+S*_.z,o.normalize(),d.push(o.x,o.y,o.z),a.x=c.x+i*o.x,a.y=c.y+i*o.y,a.z=c.z+i*o.z,u.push(a.x,a.y,a.z)}}function x(){for(let b=1;b<=e;b++)for(let v=1;v<=s;v++){const _=(s+1)*(b-1)+(v-1),M=(s+1)*b+(v-1),A=(s+1)*b+v,S=(s+1)*(b-1)+v;p.push(_,M,S),p.push(M,A,S)}}function y(){for(let b=0;b<=e;b++)for(let v=0;v<=s;v++)h.x=b/e,h.y=v/s,f.push(h.x,h.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Pa(new Dn[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}class jd extends j{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){const e=[],i=new Set,s=new w,n=new w;if(t.index!==null){const r=t.attributes.position,a=t.index;let o=t.groups;o.length===0&&(o=[{start:0,count:a.count,materialIndex:0}]);for(let h=0,c=o.length;h<c;++h){const u=o[h],d=u.start,f=u.count;for(let p=d,m=d+f;p<m;p+=3)for(let g=0;g<3;g++){const x=a.getX(p+g),y=a.getX(p+(g+1)%3);s.fromBufferAttribute(r,x),n.fromBufferAttribute(r,y),Xo(s,n,i)===!0&&(e.push(s.x,s.y,s.z),e.push(n.x,n.y,n.z))}}}else{const r=t.attributes.position;for(let a=0,o=r.count/3;a<o;a++)for(let h=0;h<3;h++){const c=3*a+h,u=3*a+(h+1)%3;s.fromBufferAttribute(r,c),n.fromBufferAttribute(r,u),Xo(s,n,i)===!0&&(e.push(s.x,s.y,s.z),e.push(n.x,n.y,n.z))}}this.setAttribute("position",new D(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Xo(l,t,e){const i=`${l.x},${l.y},${l.z}-${t.x},${t.y},${t.z}`,s=`${t.x},${t.y},${t.z}-${l.x},${l.y},${l.z}`;return e.has(i)===!0||e.has(s)===!0?!1:(e.add(i),e.add(s),!0)}var Yo=Object.freeze({__proto__:null,BoxGeometry:Xn,CapsuleGeometry:va,CircleGeometry:wa,ConeGeometry:_a,CylinderGeometry:Ps,DodecahedronGeometry:Ma,EdgesGeometry:zd,ExtrudeGeometry:Sa,IcosahedronGeometry:Aa,LatheGeometry:Jn,OctahedronGeometry:$n,PlaneGeometry:Ia,PolyhedronGeometry:ci,RingGeometry:Ta,ShapeGeometry:Ca,SphereGeometry:Fs,TetrahedronGeometry:Ba,TorusGeometry:za,TorusKnotGeometry:ka,TubeGeometry:Pa,WireframeGeometry:jd});class Kd extends Nt{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new G(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class Qd extends ca{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Fa extends Nt{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new G(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xe,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class tf extends Fa{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new B(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return X(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new G(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new G(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new G(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class ef extends Nt{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new G(16777215),this.specular=new G(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class sf extends Nt{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new G(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class nf extends Nt{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class rf extends Nt{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new G(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new G(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xe,this.combine=ia,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class af extends Nt{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=fu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class of extends Nt{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class hf extends Nt{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new G(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Hi,this.normalScale=new B(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class lf extends Xt{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function ri(l,t,e){return!l||!e&&l.constructor===t?l:typeof t.BYTES_PER_ELEMENT=="number"?new t(l):Array.prototype.slice.call(l)}function hl(l){return ArrayBuffer.isView(l)&&!(l instanceof DataView)}function ll(l){function t(s,n){return l[s]-l[n]}const e=l.length,i=new Array(e);for(let s=0;s!==e;++s)i[s]=s;return i.sort(t),i}function Kr(l,t,e){const i=l.length,s=new l.constructor(i);for(let n=0,r=0;r!==i;++n){const a=e[n]*t;for(let o=0;o!==t;++o)s[r++]=l[a+o]}return s}function Ra(l,t,e,i){let s=1,n=l[0];for(;n!==void 0&&n[i]===void 0;)n=l[s++];if(n===void 0)return;let r=n[i];if(r!==void 0)if(Array.isArray(r))do r=n[i],r!==void 0&&(t.push(n.time),e.push.apply(e,r)),n=l[s++];while(n!==void 0);else if(r.toArray!==void 0)do r=n[i],r!==void 0&&(t.push(n.time),r.toArray(e,e.length)),n=l[s++];while(n!==void 0);else do r=n[i],r!==void 0&&(t.push(n.time),e.push(r)),n=l[s++];while(n!==void 0)}function cf(l,t,e,i,s=30){const n=l.clone();n.name=t;const r=[];for(let o=0;o<n.tracks.length;++o){const h=n.tracks[o],c=h.getValueSize(),u=[],d=[];for(let f=0;f<h.times.length;++f){const p=h.times[f]*s;if(!(p<e||p>=i)){u.push(h.times[f]);for(let m=0;m<c;++m)d.push(h.values[f*c+m])}}u.length!==0&&(h.times=ri(u,h.times.constructor),h.values=ri(d,h.values.constructor),r.push(h))}n.tracks=r;let a=1/0;for(let o=0;o<n.tracks.length;++o)a>n.tracks[o].times[0]&&(a=n.tracks[o].times[0]);for(let o=0;o<n.tracks.length;++o)n.tracks[o].shift(-1*a);return n.resetDuration(),n}function uf(l,t=0,e=l,i=30){i<=0&&(i=30);const s=e.tracks.length,n=t/i;for(let r=0;r<s;++r){const a=e.tracks[r],o=a.ValueTypeName;if(o==="bool"||o==="string")continue;const h=l.tracks.find(function(x){return x.name===a.name&&x.ValueTypeName===o});if(h===void 0)continue;let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);let d=0;const f=h.getValueSize();h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);const p=a.times.length-1;let m;if(n<=a.times[0]){const x=c,y=u-c;m=a.values.slice(x,y)}else if(n>=a.times[p]){const x=p*u+c,y=x+u-c;m=a.values.slice(x,y)}else{const x=a.createInterpolant(),y=c,b=u-c;x.evaluate(n),m=x.resultBuffer.slice(y,b)}o==="quaternion"&&new te().fromArray(m).normalize().conjugate().toArray(m);const g=h.times.length;for(let x=0;x<g;++x){const y=x*f+d;if(o==="quaternion")te.multiplyQuaternionsFlat(h.values,y,m,0,h.values,y);else{const b=f-d*2;for(let v=0;v<b;++v)h.values[y+v]-=m[v]}}}return l.blendMode=Gh,l}const Sy={convertArray:ri,isTypedArray:hl,getKeyframeOrder:ll,sortedArray:Kr,flattenJSON:Ra,subclip:cf,makeClipAdditive:uf};class jn{constructor(t,e,i,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,s=e[i],n=e[i-1];t:{e:{let r;i:{s:if(!(t<s)){for(let a=i+2;;){if(s===void 0){if(t<n)break s;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(n=s,s=e[++i],t<s)break e}r=e.length;break i}if(!(t>=n)){const a=e[1];t<a&&(i=2,n=a);for(let o=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(s=n,n=e[--i-1],t>=n)break e}r=i,i=0;break i}break t}for(;i<r;){const a=i+r>>>1;t<e[a]?r=a:i=a+1}if(s=e[i],n=e[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,s)}return this.interpolate_(i,n,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,s=this.valueSize,n=t*s;for(let r=0;r!==s;++r)e[r]=i[n+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class df extends jn{constructor(t,e,i,s){super(t,e,i,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ei,endingEnd:Ei}}intervalChanged_(t,e,i){const s=this.parameterPositions;let n=t-2,r=t+1,a=s[n],o=s[r];if(a===void 0)switch(this.getSettings_().endingStart){case Oi:n=t,a=2*e-i;break;case kn:n=s.length-2,a=e+s[n]-s[n+1];break;default:n=t,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case Oi:r=t,o=2*i-e;break;case kn:r=1,o=i+s[1]-s[0];break;default:r=t-1,o=e}const h=(i-e)*.5,c=this.valueSize;this._weightPrev=h/(e-a),this._weightNext=h/(o-i),this._offsetPrev=n*c,this._offsetNext=r*c}interpolate_(t,e,i,s){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,h=o-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-e)/(s-e),m=p*p,g=m*p,x=-d*g+2*d*m-d*p,y=(1+d)*g+(-1.5-2*d)*m+(-.5+d)*p+1,b=(-1-f)*g+(1.5+f)*m+.5*p,v=f*g-f*m;for(let _=0;_!==a;++_)n[_]=x*r[c+_]+y*r[h+_]+b*r[o+_]+v*r[u+_];return n}}class cl extends jn{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=t*a,h=o-a,c=(i-e)/(s-e),u=1-c;for(let d=0;d!==a;++d)n[d]=r[h+d]*u+r[o+d]*c;return n}}class ff extends jn{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t){return this.copySampleValue_(t-1)}}class we{constructor(t,e,i,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ri(e,this.TimeBufferType),this.values=ri(i,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:ri(t.times,Array),values:ri(t.values,Array)};const s=t.getInterpolation();s!==t.DefaultInterpolation&&(i.interpolation=s)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new ff(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new cl(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new df(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case zn:e=this.InterpolantFactoryMethodDiscrete;break;case Jr:e=this.InterpolantFactoryMethodLinear;break;case nr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return zn;case this.InterpolantFactoryMethodLinear:return Jr;case this.InterpolantFactoryMethodSmooth:return nr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,s=e.length;i!==s;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,s=e.length;i!==s;++i)e[i]*=t}return this}trim(t,e){const i=this.times,s=i.length;let n=0,r=s-1;for(;n!==s&&i[n]<t;)++n;for(;r!==-1&&i[r]>e;)--r;if(++r,n!==0||r!==s){n>=r&&(r=Math.max(r,1),n=r-1);const a=this.getValueSize();this.times=i.slice(n,r),this.values=this.values.slice(n*a,r*a)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,s=this.values,n=i.length;n===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let a=0;a!==n;a++){const o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),t=!1;break}if(r!==null&&r>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,r),t=!1;break}r=o}if(s!==void 0&&hl(s))for(let a=0,o=s.length;a!==o;++a){const h=s[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=this.getInterpolation()===nr,n=t.length-1;let r=1;for(let a=1;a<n;++a){let o=!1;const h=t[a],c=t[a+1];if(h!==c&&(a!==1||h!==t[0]))if(s)o=!0;else{const u=a*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const m=e[u+p];if(m!==e[d+p]||m!==e[f+p]){o=!0;break}}}if(o){if(a!==r){t[r]=t[a];const u=a*i,d=r*i;for(let f=0;f!==i;++f)e[d+f]=e[u+f]}++r}}if(n>0){t[r]=t[n];for(let a=n*i,o=r*i,h=0;h!==i;++h)e[o+h]=e[a+h];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,s=new i(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}}we.prototype.TimeBufferType=Float32Array;we.prototype.ValueBufferType=Float32Array;we.prototype.DefaultInterpolation=Jr;class Xi extends we{constructor(t,e,i){super(t,e,i)}}Xi.prototype.ValueTypeName="bool";Xi.prototype.ValueBufferType=Array;Xi.prototype.DefaultInterpolation=zn;Xi.prototype.InterpolantFactoryMethodLinear=void 0;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;class ul extends we{}ul.prototype.ValueTypeName="color";class Nn extends we{}Nn.prototype.ValueTypeName="number";class pf extends jn{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){const n=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e);let h=t*a;for(let c=h+a;h!==c;h+=4)te.slerpFlat(n,0,r,h-a,r,h,o);return n}}class Kn extends we{InterpolantFactoryMethodLinear(t){return new pf(this.times,this.values,this.getValueSize(),t)}}Kn.prototype.ValueTypeName="quaternion";Kn.prototype.InterpolantFactoryMethodSmooth=void 0;class Yi extends we{constructor(t,e,i){super(t,e,i)}}Yi.prototype.ValueTypeName="string";Yi.prototype.ValueBufferType=Array;Yi.prototype.DefaultInterpolation=zn;Yi.prototype.InterpolantFactoryMethodLinear=void 0;Yi.prototype.InterpolantFactoryMethodSmooth=void 0;class Un extends we{}Un.prototype.ValueTypeName="vector";class Vn{constructor(t="",e=-1,i=[],s=aa){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=Qt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,s=1/(t.fps||1);for(let r=0,a=i.length;r!==a;++r)e.push(gf(i[r]).scale(s));const n=new this(t.name,t.duration,e,t.blendMode);return n.uuid=t.uuid,n}static toJSON(t){const e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let n=0,r=i.length;n!==r;++n)e.push(we.toJSON(i[n]));return s}static CreateFromMorphTargetSequence(t,e,i,s){const n=e.length,r=[];for(let a=0;a<n;a++){let o=[],h=[];o.push((a+n-1)%n,a,(a+1)%n),h.push(0,1,0);const c=ll(o);o=Kr(o,1,c),h=Kr(h,1,c),!s&&o[0]===0&&(o.push(n),h.push(h[0])),r.push(new Nn(".morphTargetInfluences["+e[a].name+"]",o,h).scale(1/i))}return new this(t,-1,r)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const s=t;i=s.geometry&&s.geometry.animations||s.animations}for(let s=0;s<i.length;s++)if(i[s].name===e)return i[s];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const s={},n=/^([\w-]*?)([\d]+)$/;for(let a=0,o=t.length;a<o;a++){const h=t[a],c=h.name.match(n);if(c&&c.length>1){const u=c[1];let d=s[u];d||(s[u]=d=[]),d.push(h)}}const r=[];for(const a in s)r.push(this.CreateFromMorphTargetSequence(a,s[a],e,i));return r}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,d,f,p,m){if(f.length!==0){const g=[],x=[];Ra(f,g,x,p),g.length!==0&&m.push(new u(d,g,x))}},s=[],n=t.name||"default",r=t.fps||30,a=t.blendMode;let o=t.length||-1;const h=t.hierarchy||[];for(let u=0;u<h.length;u++){const d=h[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const f={};let p;for(p=0;p<d.length;p++)if(d[p].morphTargets)for(let m=0;m<d[p].morphTargets.length;m++)f[d[p].morphTargets[m]]=-1;for(const m in f){const g=[],x=[];for(let y=0;y!==d[p].morphTargets.length;++y){const b=d[p];g.push(b.time),x.push(b.morphTarget===m?1:0)}s.push(new Nn(".morphTargetInfluence["+m+"]",g,x))}o=f.length*r}else{const f=".bones["+e[u].name+"]";i(Un,f+".position",d,"pos",s),i(Kn,f+".quaternion",d,"rot",s),i(Un,f+".scale",d,"scl",s)}}return s.length===0?null:new this(n,o,s,a)}resetDuration(){const t=this.tracks;let e=0;for(let i=0,s=t.length;i!==s;++i){const n=this.tracks[i];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function mf(l){switch(l.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Nn;case"vector":case"vector2":case"vector3":case"vector4":return Un;case"color":return ul;case"quaternion":return Kn;case"bool":case"boolean":return Xi;case"string":return Yi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+l)}function gf(l){if(l.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=mf(l.type);if(l.times===void 0){const e=[],i=[];Ra(l.keys,e,i,"value"),l.times=e,l.values=i}return t.parse!==void 0?t.parse(l):new t(l.name,l.times,l.values,l.interpolation)}const He={enabled:!1,files:{},add:function(l,t){this.enabled!==!1&&(this.files[l]=t)},get:function(l){if(this.enabled!==!1)return this.files[l]},remove:function(l){delete this.files[l]},clear:function(){this.files={}}};class dl{constructor(t,e,i){const s=this;let n=!1,r=0,a=0,o;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(c){a++,n===!1&&s.onStart!==void 0&&s.onStart(c,r,a),n=!0},this.itemEnd=function(c){r++,s.onProgress!==void 0&&s.onProgress(c,r,a),r===a&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(c){s.onError!==void 0&&s.onError(c)},this.resolveURL=function(c){return o?o(c):c},this.setURLModifier=function(c){return o=c,this},this.addHandler=function(c,u){return h.push(c,u),this},this.removeHandler=function(c){const u=h.indexOf(c);return u!==-1&&h.splice(u,2),this},this.getHandler=function(c){for(let u=0,d=h.length;u<d;u+=2){const f=h[u],p=h[u+1];if(f.global&&(f.lastIndex=0),f.test(c))return p}return null}}}const yf=new dl;class ee{constructor(t){this.manager=t!==void 0?t:yf,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(s,n){i.load(t,s,e,n)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}ee.DEFAULT_MATERIAL_NAME="__DEFAULT";const Te={};class xf extends Error{constructor(t,e){super(t),this.response=e}}class qe extends ee{constructor(t){super(t)}load(t,e,i,s){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=He.get(t);if(n!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(n),this.manager.itemEnd(t)},0),n;if(Te[t]!==void 0){Te[t].push({onLoad:e,onProgress:i,onError:s});return}Te[t]=[],Te[t].push({onLoad:e,onProgress:i,onError:s});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=Te[t],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let m=0;const g=new ReadableStream({start(x){y();function y(){u.read().then(({done:b,value:v})=>{if(b)x.close();else{m+=v.byteLength;const _=new ProgressEvent("progress",{lengthComputable:p,loaded:m,total:f});for(let M=0,A=c.length;M<A;M++){const S=c[M];S.onProgress&&S.onProgress(_)}x.enqueue(v),y()}},b=>{x.error(b)})}}});return new Response(g)}else throw new xf(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(o){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return h.json();default:if(a===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return h.arrayBuffer().then(p=>f.decode(p))}}}).then(h=>{He.add(t,h);const c=Te[t];delete Te[t];for(let u=0,d=c.length;u<d;u++){const f=c[u];f.onLoad&&f.onLoad(h)}}).catch(h=>{const c=Te[t];if(c===void 0)throw this.manager.itemError(t),h;delete Te[t];for(let u=0,d=c.length;u<d;u++){const f=c[u];f.onError&&f.onError(h)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Ay extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new qe(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(a){try{e(n.parse(JSON.parse(a)))}catch(o){s?s(o):console.error(o),n.manager.itemError(t)}},i,s)}parse(t){const e=[];for(let i=0;i<t.length;i++){const s=Vn.parse(t[i]);e.push(s)}return e}}class Iy extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=[],a=new ya,o=new qe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(n.withCredentials);let h=0;function c(u){o.load(t[u],function(d){const f=n.parse(d,!0);r[u]={width:f.width,height:f.height,format:f.format,mipmaps:f.mipmaps},h+=1,h===6&&(f.mipmapCount===1&&(a.minFilter=ae),a.image=r,a.format=f.format,a.needsUpdate=!0,e&&e(a))},i,s)}if(Array.isArray(t))for(let u=0,d=t.length;u<d;++u)c(u);else o.load(t,function(u){const d=n.parse(u,!0);if(d.isCubemap){const f=d.mipmaps.length/d.mipmapCount;for(let p=0;p<f;p++){r[p]={mipmaps:[]};for(let m=0;m<d.mipmapCount;m++)r[p].mipmaps.push(d.mipmaps[p*d.mipmapCount+m]),r[p].format=d.format,r[p].width=d.width,r[p].height=d.height}a.image=r}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=ae),a.format=d.format,a.needsUpdate=!0,e&&e(a)},i,s);return a}}class Gn extends ee{constructor(t){super(t)}load(t,e,i,s){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,r=He.get(t);if(r!==void 0)return n.manager.itemStart(t),setTimeout(function(){e&&e(r),n.manager.itemEnd(t)},0),r;const a=Rn("img");function o(){c(),He.add(t,this),e&&e(this),n.manager.itemEnd(t)}function h(u){c(),s&&s(u),n.manager.itemError(t),n.manager.itemEnd(t)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",h,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",h,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(t),a.src=t,a}}class Ty extends ee{constructor(t){super(t)}load(t,e,i,s){const n=new da;n.colorSpace=ne;const r=new Gn(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function o(h){r.load(t[h],function(c){n.images[h]=c,a++,a===6&&(n.needsUpdate=!0,e&&e(n))},void 0,s)}for(let h=0;h<t.length;++h)o(h);return n}}class Cy extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new Pe,a=new qe(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(n.withCredentials),a.load(t,function(o){let h;try{h=n.parse(o)}catch(c){if(s!==void 0)s(c);else{console.error(c);return}}h.image!==void 0?r.image=h.image:h.data!==void 0&&(r.image.width=h.width,r.image.height=h.height,r.image.data=h.data),r.wrapS=h.wrapS!==void 0?h.wrapS:ge,r.wrapT=h.wrapT!==void 0?h.wrapT:ge,r.magFilter=h.magFilter!==void 0?h.magFilter:ae,r.minFilter=h.minFilter!==void 0?h.minFilter:ae,r.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(r.colorSpace=h.colorSpace),h.flipY!==void 0&&(r.flipY=h.flipY),h.format!==void 0&&(r.format=h.format),h.type!==void 0&&(r.type=h.type),h.mipmaps!==void 0&&(r.mipmaps=h.mipmaps,r.minFilter=qn),h.mipmapCount===1&&(r.minFilter=ae),h.generateMipmaps!==void 0&&(r.generateMipmaps=h.generateMipmaps),r.needsUpdate=!0,e&&e(r,h)},i,s),r}}class By extends ee{constructor(t){super(t)}load(t,e,i,s){const n=new yt,r=new Gn(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(a){n.image=a,n.needsUpdate=!0,e!==void 0&&e(n)},i,s),n}}class ui extends st{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new G(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class bf extends ui{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(st.DEFAULT_UP),this.updateMatrix(),this.groundColor=new G(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Dr=new Z,Jo=new w,Zo=new w;class Ea{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new Z,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $h,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new It(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Jo.setFromMatrixPosition(t.matrixWorld),e.position.copy(Jo),Zo.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Zo),e.updateMatrixWorld(),Dr.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dr),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Dr)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class vf extends Ea{constructor(){super(new re(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=Is*2*t.angle*this.focus,s=this.mapSize.width/this.mapSize.height,n=t.distance||e.far;(i!==e.fov||s!==e.aspect||n!==e.far)&&(e.fov=i,e.aspect=s,e.far=n,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class wf extends ui{constructor(t,e,i=0,s=Math.PI/3,n=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(st.DEFAULT_UP),this.updateMatrix(),this.target=new st,this.distance=i,this.angle=s,this.penumbra=n,this.decay=r,this.map=null,this.shadow=new vf}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const $o=new Z,us=new w,Lr=new w;class _f extends Ea{constructor(){super(new re(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new It(2,1,1,1),new It(0,1,1,1),new It(3,1,1,1),new It(1,1,1,1),new It(3,0,1,1),new It(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,s=this.matrix,n=t.distance||i.far;n!==i.far&&(i.far=n,i.updateProjectionMatrix()),us.setFromMatrixPosition(t.matrixWorld),i.position.copy(us),Lr.copy(i.position),Lr.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(Lr),i.updateMatrixWorld(),s.makeTranslation(-us.x,-us.y,-us.z),$o.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix($o)}}class Mf extends ui{constructor(t,e,i=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=s,this.shadow=new _f}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class fl extends ua{constructor(t=-1,e=1,i=1,s=-1,n=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=s,this.near=n,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,s,n,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-t,r=i+t,a=s+e,o=s-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,r=n+h*this.view.width,a-=c*this.view.offsetY,o=a-c*this.view.height}this.projectionMatrix.makeOrthographic(n,r,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class Sf extends Ea{constructor(){super(new fl(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Af extends ui{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(st.DEFAULT_UP),this.updateMatrix(),this.target=new st,this.shadow=new Sf}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class If extends ui{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Tf extends ui{constructor(t,e,i=10,s=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=s}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){const e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}}class Cf{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new w)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,s=t.y,n=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.282095),e.addScaledVector(r[1],.488603*s),e.addScaledVector(r[2],.488603*n),e.addScaledVector(r[3],.488603*i),e.addScaledVector(r[4],1.092548*(i*s)),e.addScaledVector(r[5],1.092548*(s*n)),e.addScaledVector(r[6],.315392*(3*n*n-1)),e.addScaledVector(r[7],1.092548*(i*n)),e.addScaledVector(r[8],.546274*(i*i-s*s)),e}getIrradianceAt(t,e){const i=t.x,s=t.y,n=t.z,r=this.coefficients;return e.copy(r[0]).multiplyScalar(.886227),e.addScaledVector(r[1],2*.511664*s),e.addScaledVector(r[2],2*.511664*n),e.addScaledVector(r[3],2*.511664*i),e.addScaledVector(r[4],2*.429043*i*s),e.addScaledVector(r[5],2*.429043*s*n),e.addScaledVector(r[6],.743125*n*n-.247708),e.addScaledVector(r[7],2*.429043*i*n),e.addScaledVector(r[8],.429043*(i*i-s*s)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let s=0;s<9;s++)i[s].fromArray(t,e+s*3);return this}toArray(t=[],e=0){const i=this.coefficients;for(let s=0;s<9;s++)i[s].toArray(t,e+s*3);return t}static getBasisAt(t,e){const i=t.x,s=t.y,n=t.z;e[0]=.282095,e[1]=.488603*s,e[2]=.488603*n,e[3]=.488603*i,e[4]=1.092548*i*s,e[5]=1.092548*s*n,e[6]=.315392*(3*n*n-1),e[7]=1.092548*i*n,e[8]=.546274*(i*i-s*s)}}class Bf extends ui{constructor(t=new Cf,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class Oa extends ee{constructor(t){super(t),this.textures={}}load(t,e,i,s){const n=this,r=new qe(n.manager);r.setPath(n.path),r.setRequestHeader(n.requestHeader),r.setWithCredentials(n.withCredentials),r.load(t,function(a){try{e(n.parse(JSON.parse(a)))}catch(o){s?s(o):console.error(o),n.manager.itemError(t)}},i,s)}parse(t){const e=this.textures;function i(n){return e[n]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",n),e[n]}const s=this.createMaterialFromType(t.type);if(t.uuid!==void 0&&(s.uuid=t.uuid),t.name!==void 0&&(s.name=t.name),t.color!==void 0&&s.color!==void 0&&s.color.setHex(t.color),t.roughness!==void 0&&(s.roughness=t.roughness),t.metalness!==void 0&&(s.metalness=t.metalness),t.sheen!==void 0&&(s.sheen=t.sheen),t.sheenColor!==void 0&&(s.sheenColor=new G().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(s.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&s.emissive!==void 0&&s.emissive.setHex(t.emissive),t.specular!==void 0&&s.specular!==void 0&&s.specular.setHex(t.specular),t.specularIntensity!==void 0&&(s.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&s.specularColor!==void 0&&s.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(s.shininess=t.shininess),t.clearcoat!==void 0&&(s.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(s.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(s.dispersion=t.dispersion),t.iridescence!==void 0&&(s.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(s.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(s.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(s.transmission=t.transmission),t.thickness!==void 0&&(s.thickness=t.thickness),t.attenuationDistance!==void 0&&(s.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&s.attenuationColor!==void 0&&s.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(s.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(s.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(s.fog=t.fog),t.flatShading!==void 0&&(s.flatShading=t.flatShading),t.blending!==void 0&&(s.blending=t.blending),t.combine!==void 0&&(s.combine=t.combine),t.side!==void 0&&(s.side=t.side),t.shadowSide!==void 0&&(s.shadowSide=t.shadowSide),t.opacity!==void 0&&(s.opacity=t.opacity),t.transparent!==void 0&&(s.transparent=t.transparent),t.alphaTest!==void 0&&(s.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(s.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(s.depthFunc=t.depthFunc),t.depthTest!==void 0&&(s.depthTest=t.depthTest),t.depthWrite!==void 0&&(s.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(s.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(s.blendSrc=t.blendSrc),t.blendDst!==void 0&&(s.blendDst=t.blendDst),t.blendEquation!==void 0&&(s.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(s.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(s.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(s.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&s.blendColor!==void 0&&s.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(s.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(s.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(s.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(s.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(s.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(s.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(s.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(s.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(s.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(s.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(s.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(s.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(s.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(s.rotation=t.rotation),t.linewidth!==void 0&&(s.linewidth=t.linewidth),t.dashSize!==void 0&&(s.dashSize=t.dashSize),t.gapSize!==void 0&&(s.gapSize=t.gapSize),t.scale!==void 0&&(s.scale=t.scale),t.polygonOffset!==void 0&&(s.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(s.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(s.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(s.dithering=t.dithering),t.alphaToCoverage!==void 0&&(s.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(s.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(s.forceSinglePass=t.forceSinglePass),t.visible!==void 0&&(s.visible=t.visible),t.toneMapped!==void 0&&(s.toneMapped=t.toneMapped),t.userData!==void 0&&(s.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?s.vertexColors=t.vertexColors>0:s.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const n in t.uniforms){const r=t.uniforms[n];switch(s.uniforms[n]={},r.type){case"t":s.uniforms[n].value=i(r.value);break;case"c":s.uniforms[n].value=new G().setHex(r.value);break;case"v2":s.uniforms[n].value=new B().fromArray(r.value);break;case"v3":s.uniforms[n].value=new w().fromArray(r.value);break;case"v4":s.uniforms[n].value=new It().fromArray(r.value);break;case"m3":s.uniforms[n].value=new be().fromArray(r.value);break;case"m4":s.uniforms[n].value=new Z().fromArray(r.value);break;default:s.uniforms[n].value=r.value}}if(t.defines!==void 0&&(s.defines=t.defines),t.vertexShader!==void 0&&(s.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(s.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(s.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)s.extensions[n]=t.extensions[n];if(t.lights!==void 0&&(s.lights=t.lights),t.clipping!==void 0&&(s.clipping=t.clipping),t.size!==void 0&&(s.size=t.size),t.sizeAttenuation!==void 0&&(s.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(s.map=i(t.map)),t.matcap!==void 0&&(s.matcap=i(t.matcap)),t.alphaMap!==void 0&&(s.alphaMap=i(t.alphaMap)),t.bumpMap!==void 0&&(s.bumpMap=i(t.bumpMap)),t.bumpScale!==void 0&&(s.bumpScale=t.bumpScale),t.normalMap!==void 0&&(s.normalMap=i(t.normalMap)),t.normalMapType!==void 0&&(s.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),s.normalScale=new B().fromArray(n)}return t.displacementMap!==void 0&&(s.displacementMap=i(t.displacementMap)),t.displacementScale!==void 0&&(s.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(s.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(s.roughnessMap=i(t.roughnessMap)),t.metalnessMap!==void 0&&(s.metalnessMap=i(t.metalnessMap)),t.emissiveMap!==void 0&&(s.emissiveMap=i(t.emissiveMap)),t.emissiveIntensity!==void 0&&(s.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(s.specularMap=i(t.specularMap)),t.specularIntensityMap!==void 0&&(s.specularIntensityMap=i(t.specularIntensityMap)),t.specularColorMap!==void 0&&(s.specularColorMap=i(t.specularColorMap)),t.envMap!==void 0&&(s.envMap=i(t.envMap)),t.envMapRotation!==void 0&&s.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(s.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(s.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(s.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(s.lightMap=i(t.lightMap)),t.lightMapIntensity!==void 0&&(s.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(s.aoMap=i(t.aoMap)),t.aoMapIntensity!==void 0&&(s.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(s.gradientMap=i(t.gradientMap)),t.clearcoatMap!==void 0&&(s.clearcoatMap=i(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(s.clearcoatNormalScale=new B().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(s.iridescenceMap=i(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(s.transmissionMap=i(t.transmissionMap)),t.thicknessMap!==void 0&&(s.thicknessMap=i(t.thicknessMap)),t.anisotropyMap!==void 0&&(s.anisotropyMap=i(t.anisotropyMap)),t.sheenColorMap!==void 0&&(s.sheenColorMap=i(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return Oa.createMaterialFromType(t)}static createMaterialFromType(t){const e={ShadowMaterial:Kd,SpriteMaterial:_s,RawShaderMaterial:Qd,ShaderMaterial:ca,PointsMaterial:jh,MeshPhysicalMaterial:tf,MeshStandardMaterial:Fa,MeshPhongMaterial:ef,MeshToonMaterial:sf,MeshNormalMaterial:nf,MeshLambertMaterial:rf,MeshDepthMaterial:af,MeshDistanceMaterial:of,MeshBasicMaterial:qi,MeshMatcapMaterial:hf,LineDashedMaterial:lf,LineBasicMaterial:Xt,Material:Nt};return new e[t]}}class jo{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let i=0,s=t.length;i<s;i++)e+=String.fromCharCode(t[i]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class zf extends j{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class kf extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new qe(n.manager);r.setPath(n.path),r.setRequestHeader(n.requestHeader),r.setWithCredentials(n.withCredentials),r.load(t,function(a){try{e(n.parse(JSON.parse(a)))}catch(o){s?s(o):console.error(o),n.manager.itemError(t)}},i,s)}parse(t){const e={},i={};function s(f,p){if(e[p]!==void 0)return e[p];const g=f.interleavedBuffers[p],x=n(f,g.buffer),y=Di(g.type,x),b=new ma(y,g.stride);return b.uuid=g.uuid,e[p]=b,b}function n(f,p){if(i[p]!==void 0)return i[p];const g=f.arrayBuffers[p],x=new Uint32Array(g).buffer;return i[p]=x,x}const r=t.isInstancedBufferGeometry?new zf:new j,a=t.data.index;if(a!==void 0){const f=Di(a.type,a.array);r.setIndex(new ft(f,1))}const o=t.data.attributes;for(const f in o){const p=o[f];let m;if(p.isInterleavedBufferAttribute){const g=s(t.data,p.data);m=new Wi(g,p.itemSize,p.offset,p.normalized)}else{const g=Di(p.type,p.array),x=p.isInstancedBufferAttribute?Ts:ft;m=new x(g,p.itemSize,p.normalized)}p.name!==void 0&&(m.name=p.name),p.usage!==void 0&&m.setUsage(p.usage),r.setAttribute(f,m)}const h=t.data.morphAttributes;if(h)for(const f in h){const p=h[f],m=[];for(let g=0,x=p.length;g<x;g++){const y=p[g];let b;if(y.isInterleavedBufferAttribute){const v=s(t.data,y.data);b=new Wi(v,y.itemSize,y.offset,y.normalized)}else{const v=Di(y.type,y.array);b=new ft(v,y.itemSize,y.normalized)}y.name!==void 0&&(b.name=y.name),m.push(b)}r.morphAttributes[f]=m}t.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);const u=t.data.groups||t.data.drawcalls||t.data.offsets;if(u!==void 0)for(let f=0,p=u.length;f!==p;++f){const m=u[f];r.addGroup(m.start,m.count,m.materialIndex)}const d=t.data.boundingSphere;if(d!==void 0){const f=new w;d.center!==void 0&&f.fromArray(d.center),r.boundingSphere=new Lt(f,d.radius)}return t.name&&(r.name=t.name),t.userData&&(r.userData=t.userData),r}}class zy extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=this.path===""?jo.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||r;const a=new qe(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){let h=null;try{h=JSON.parse(o)}catch(u){s!==void 0&&s(u),console.error("THREE:ObjectLoader: Can't parse "+t+".",u.message);return}const c=h.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry"){s!==void 0&&s(new Error("THREE.ObjectLoader: Can't load "+t)),console.error("THREE.ObjectLoader: Can't load "+t);return}n.parse(h,e)},i,s)}async loadAsync(t,e){const i=this,s=this.path===""?jo.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||s;const n=new qe(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);const r=await n.loadAsync(t,e),a=JSON.parse(r),o=a.metadata;if(o===void 0||o.type===void 0||o.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await i.parseAsync(a)}parse(t,e){const i=this.parseAnimations(t.animations),s=this.parseShapes(t.shapes),n=this.parseGeometries(t.geometries,s),r=this.parseImages(t.images,function(){e!==void 0&&e(h)}),a=this.parseTextures(t.textures,r),o=this.parseMaterials(t.materials,a),h=this.parseObject(t.object,n,o,a,i),c=this.parseSkeletons(t.skeletons,h);if(this.bindSkeletons(h,c),this.bindLightTargets(h),e!==void 0){let u=!1;for(const d in r)if(r[d].data instanceof HTMLImageElement){u=!0;break}u===!1&&e(h)}return h}async parseAsync(t){const e=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),s=this.parseGeometries(t.geometries,i),n=await this.parseImagesAsync(t.images),r=this.parseTextures(t.textures,n),a=this.parseMaterials(t.materials,r),o=this.parseObject(t.object,s,a,r,e),h=this.parseSkeletons(t.skeletons,o);return this.bindSkeletons(o,h),this.bindLightTargets(o),o}parseShapes(t){const e={};if(t!==void 0)for(let i=0,s=t.length;i<s;i++){const n=new Vi().fromJSON(t[i]);e[n.uuid]=n}return e}parseSkeletons(t,e){const i={},s={};if(e.traverse(function(n){n.isBone&&(s[n.uuid]=n)}),t!==void 0)for(let n=0,r=t.length;n<r;n++){const a=new ga().fromJSON(t[n],s);i[a.uuid]=a}return i}parseGeometries(t,e){const i={};if(t!==void 0){const s=new kf;for(let n=0,r=t.length;n<r;n++){let a;const o=t[n];switch(o.type){case"BufferGeometry":case"InstancedBufferGeometry":a=s.parse(o);break;default:o.type in Yo?a=Yo[o.type].fromJSON(o,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${o.type}"`)}a.uuid=o.uuid,o.name!==void 0&&(a.name=o.name),o.userData!==void 0&&(a.userData=o.userData),i[o.uuid]=a}}return i}parseMaterials(t,e){const i={},s={};if(t!==void 0){const n=new Oa;n.setTextures(e);for(let r=0,a=t.length;r<a;r++){const o=t[r];i[o.uuid]===void 0&&(i[o.uuid]=n.parse(o)),s[o.uuid]=i[o.uuid]}}return s}parseAnimations(t){const e={};if(t!==void 0)for(let i=0;i<t.length;i++){const s=t[i],n=Vn.parse(s);e[n.uuid]=n}return e}parseImages(t,e){const i=this,s={};let n;function r(o){return i.manager.itemStart(o),n.load(o,function(){i.manager.itemEnd(o)},void 0,function(){i.manager.itemError(o),i.manager.itemEnd(o)})}function a(o){if(typeof o=="string"){const h=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h)?h:i.resourcePath+h;return r(c)}else return o.data?{data:Di(o.type,o.data),width:o.width,height:o.height}:null}if(t!==void 0&&t.length>0){const o=new dl(e);n=new Gn(o),n.setCrossOrigin(this.crossOrigin);for(let h=0,c=t.length;h<c;h++){const u=t[h],d=u.url;if(Array.isArray(d)){const f=[];for(let p=0,m=d.length;p<m;p++){const g=d[p],x=a(g);x!==null&&(x instanceof HTMLImageElement?f.push(x):f.push(new Pe(x.data,x.width,x.height)))}s[u.uuid]=new Li(f)}else{const f=a(u.url);s[u.uuid]=new Li(f)}}}return s}async parseImagesAsync(t){const e=this,i={};let s;async function n(r){if(typeof r=="string"){const a=r,o=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:e.resourcePath+a;return await s.loadAsync(o)}else return r.data?{data:Di(r.type,r.data),width:r.width,height:r.height}:null}if(t!==void 0&&t.length>0){s=new Gn(this.manager),s.setCrossOrigin(this.crossOrigin);for(let r=0,a=t.length;r<a;r++){const o=t[r],h=o.url;if(Array.isArray(h)){const c=[];for(let u=0,d=h.length;u<d;u++){const f=h[u],p=await n(f);p!==null&&(p instanceof HTMLImageElement?c.push(p):c.push(new Pe(p.data,p.width,p.height)))}i[o.uuid]=new Li(c)}else{const c=await n(o.url);i[o.uuid]=new Li(c)}}}return i}parseTextures(t,e){function i(n,r){return typeof n=="number"?n:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",n),r[n])}const s={};if(t!==void 0)for(let n=0,r=t.length;n<r;n++){const a=t[n];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),e[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const o=e[a.image],h=o.data;let c;Array.isArray(h)?(c=new da,h.length===6&&(c.needsUpdate=!0)):(h&&h.data?c=new Pe:c=new yt,h&&(c.needsUpdate=!0)),c.source=o,c.uuid=a.uuid,a.name!==void 0&&(c.name=a.name),a.mapping!==void 0&&(c.mapping=i(a.mapping,Pf)),a.channel!==void 0&&(c.channel=a.channel),a.offset!==void 0&&c.offset.fromArray(a.offset),a.repeat!==void 0&&c.repeat.fromArray(a.repeat),a.center!==void 0&&c.center.fromArray(a.center),a.rotation!==void 0&&(c.rotation=a.rotation),a.wrap!==void 0&&(c.wrapS=i(a.wrap[0],Ko),c.wrapT=i(a.wrap[1],Ko)),a.format!==void 0&&(c.format=a.format),a.internalFormat!==void 0&&(c.internalFormat=a.internalFormat),a.type!==void 0&&(c.type=a.type),a.colorSpace!==void 0&&(c.colorSpace=a.colorSpace),a.minFilter!==void 0&&(c.minFilter=i(a.minFilter,Qo)),a.magFilter!==void 0&&(c.magFilter=i(a.magFilter,Qo)),a.anisotropy!==void 0&&(c.anisotropy=a.anisotropy),a.flipY!==void 0&&(c.flipY=a.flipY),a.generateMipmaps!==void 0&&(c.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(c.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(c.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(c.compareFunction=a.compareFunction),a.userData!==void 0&&(c.userData=a.userData),s[a.uuid]=c}return s}parseObject(t,e,i,s,n){let r;function a(d){return e[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),e[d]}function o(d){if(d!==void 0){if(Array.isArray(d)){const f=[];for(let p=0,m=d.length;p<m;p++){const g=d[p];i[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),f.push(i[g])}return f}return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),i[d]}}function h(d){return s[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),s[d]}let c,u;switch(t.type){case"Scene":r=new td,t.background!==void 0&&(Number.isInteger(t.background)?r.background=new G(t.background):r.background=h(t.background)),t.environment!==void 0&&(r.environment=h(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?r.fog=new pa(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(r.fog=new fa(t.fog.color,t.fog.density)),t.fog.name!==""&&(r.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(r.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(r.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&r.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(r.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&r.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":r=new re(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(r.focus=t.focus),t.zoom!==void 0&&(r.zoom=t.zoom),t.filmGauge!==void 0&&(r.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(r.filmOffset=t.filmOffset),t.view!==void 0&&(r.view=Object.assign({},t.view));break;case"OrthographicCamera":r=new fl(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(r.zoom=t.zoom),t.view!==void 0&&(r.view=Object.assign({},t.view));break;case"AmbientLight":r=new If(t.color,t.intensity);break;case"DirectionalLight":r=new Af(t.color,t.intensity),r.target=t.target||"";break;case"PointLight":r=new Mf(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":r=new Tf(t.color,t.intensity,t.width,t.height);break;case"SpotLight":r=new wf(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),r.target=t.target||"";break;case"HemisphereLight":r=new bf(t.color,t.groundColor,t.intensity);break;case"LightProbe":r=new Bf().fromJSON(t);break;case"SkinnedMesh":c=a(t.geometry),u=o(t.material),r=new sd(c,u),t.bindMode!==void 0&&(r.bindMode=t.bindMode),t.bindMatrix!==void 0&&r.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(r.skeleton=t.skeleton);break;case"Mesh":c=a(t.geometry),u=o(t.material),r=new qt(c,u);break;case"InstancedMesh":c=a(t.geometry),u=o(t.material);const d=t.count,f=t.instanceMatrix,p=t.instanceColor;r=new ad(c,u,d),r.instanceMatrix=new Ts(new Float32Array(f.array),16),p!==void 0&&(r.instanceColor=new Ts(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":c=a(t.geometry),u=o(t.material),r=new md(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,u),r.geometry=c,r.perObjectFrustumCulled=t.perObjectFrustumCulled,r.sortObjects=t.sortObjects,r._drawRanges=t.drawRanges,r._reservedRanges=t.reservedRanges,r._visibility=t.visibility,r._active=t.active,r._bounds=t.bounds.map(m=>{const g=new Ht;g.min.fromArray(m.boxMin),g.max.fromArray(m.boxMax);const x=new Lt;return x.radius=m.sphereRadius,x.center.fromArray(m.sphereCenter),{boxInitialized:m.boxInitialized,box:g,sphereInitialized:m.sphereInitialized,sphere:x}}),r._maxInstanceCount=t.maxInstanceCount,r._maxVertexCount=t.maxVertexCount,r._maxIndexCount=t.maxIndexCount,r._geometryInitialized=t.geometryInitialized,r._geometryCount=t.geometryCount,r._matricesTexture=h(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(r._colorsTexture=h(t.colorsTexture.uuid));break;case"LOD":r=new ed;break;case"Line":r=new hi(a(t.geometry),o(t.material));break;case"LineLoop":r=new gd(a(t.geometry),o(t.material));break;case"LineSegments":r=new Re(a(t.geometry),o(t.material));break;case"PointCloud":case"Points":r=new yd(a(t.geometry),o(t.material));break;case"Sprite":r=new bs(o(t.material));break;case"Group":r=new Kh;break;case"Bone":r=new Zh;break;default:r=new st}if(r.uuid=t.uuid,t.name!==void 0&&(r.name=t.name),t.matrix!==void 0?(r.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(t.position!==void 0&&r.position.fromArray(t.position),t.rotation!==void 0&&r.rotation.fromArray(t.rotation),t.quaternion!==void 0&&r.quaternion.fromArray(t.quaternion),t.scale!==void 0&&r.scale.fromArray(t.scale)),t.up!==void 0&&r.up.fromArray(t.up),t.castShadow!==void 0&&(r.castShadow=t.castShadow),t.receiveShadow!==void 0&&(r.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(r.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(r.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(r.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(r.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&r.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(r.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(r.visible=t.visible),t.frustumCulled!==void 0&&(r.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(r.renderOrder=t.renderOrder),t.userData!==void 0&&(r.userData=t.userData),t.layers!==void 0&&(r.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f<d.length;f++)r.add(this.parseObject(d[f],e,i,s,n))}if(t.animations!==void 0){const d=t.animations;for(let f=0;f<d.length;f++){const p=d[f];r.animations.push(n[p])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(r.autoUpdate=t.autoUpdate);const d=t.levels;for(let f=0;f<d.length;f++){const p=d[f],m=r.getObjectByProperty("uuid",p.object);m!==void 0&&r.addLevel(m,p.distance,p.hysteresis)}}return r}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const s=e[i.skeleton];s===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(s,i.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){const i=e.target,s=t.getObjectByProperty("uuid",i);s!==void 0?e.target=s:e.target=new st}})}}const Pf={UVMapping:sa,CubeReflectionMapping:na,CubeRefractionMapping:lc,EquirectangularReflectionMapping:cc,EquirectangularRefractionMapping:uc,CubeUVReflectionMapping:dc},Ko={RepeatWrapping:Xr,ClampToEdgeWrapping:ge,MirroredRepeatWrapping:Yr},Qo={NearestFilter:pe,NearestMipmapNearestFilter:fc,NearestMipmapLinearFilter:pc,LinearFilter:ae,LinearMipmapNearestFilter:mc,LinearMipmapLinearFilter:qn};class ky extends ee{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,i,s){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,r=He.get(t);if(r!==void 0){if(n.manager.itemStart(t),r.then){r.then(h=>{e&&e(h),n.manager.itemEnd(t)}).catch(h=>{s&&s(h)});return}return setTimeout(function(){e&&e(r),n.manager.itemEnd(t)},0),r}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const o=fetch(t,a).then(function(h){return h.blob()}).then(function(h){return createImageBitmap(h,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(h){return He.add(t,h),e&&e(h),n.manager.itemEnd(t),h}).catch(function(h){s&&s(h),He.remove(t),n.manager.itemError(t),n.manager.itemEnd(t)});He.add(t,o),n.manager.itemStart(t)}}let bn;class pl{static getContext(){return bn===void 0&&(bn=new(window.AudioContext||window.webkitAudioContext)),bn}static setContext(t){bn=t}}class Py extends ee{constructor(t){super(t)}load(t,e,i,s){const n=this,r=new qe(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(o){try{const h=o.slice(0);pl.getContext().decodeAudioData(h,function(u){e(u)}).catch(a)}catch(h){a(h)}},i,s);function a(o){s?s(o):console.error(o),n.manager.itemError(t)}}}const th=new Z,eh=new Z,ti=new Z;class Fy{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new re,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new re,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,ti.copy(t.projectionMatrix);const s=e.eyeSep/2,n=s*e.near/e.focus,r=e.near*Math.tan(ai*e.fov*.5)/e.zoom;let a,o;eh.elements[12]=-s,th.elements[12]=s,a=-r*e.aspect+n,o=r*e.aspect+n,ti.elements[0]=2*e.near/(o-a),ti.elements[8]=(o+a)/(o-a),this.cameraL.projectionMatrix.copy(ti),a=-r*e.aspect-n,o=r*e.aspect-n,ti.elements[0]=2*e.near/(o-a),ti.elements[8]=(o+a)/(o-a),this.cameraR.projectionMatrix.copy(ti)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(eh),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(th)}}class Ry extends re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ff{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ih(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=ih();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function ih(){return performance.now()}const ei=new w,sh=new te,Rf=new w,ii=new w;class Ey extends st{constructor(){super(),this.type="AudioListener",this.context=pl.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ff}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ei,sh,Rf),ii.set(0,0,-1).applyQuaternion(sh),e.positionX){const s=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(ei.x,s),e.positionY.linearRampToValueAtTime(ei.y,s),e.positionZ.linearRampToValueAtTime(ei.z,s),e.forwardX.linearRampToValueAtTime(ii.x,s),e.forwardY.linearRampToValueAtTime(ii.y,s),e.forwardZ.linearRampToValueAtTime(ii.z,s),e.upX.linearRampToValueAtTime(i.x,s),e.upY.linearRampToValueAtTime(i.y,s),e.upZ.linearRampToValueAtTime(i.z,s)}else e.setPosition(ei.x,ei.y,ei.z),e.setOrientation(ii.x,ii.y,ii.z,i.x,i.y,i.z)}}class Ef extends st{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),t.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}}const si=new w,nh=new te,Of=new w,ni=new w;class Oy extends Ef{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,i){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=i,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(si,nh,Of),ni.set(0,0,1).applyQuaternion(nh);const e=this.panner;if(e.positionX){const i=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(si.x,i),e.positionY.linearRampToValueAtTime(si.y,i),e.positionZ.linearRampToValueAtTime(si.z,i),e.orientationX.linearRampToValueAtTime(ni.x,i),e.orientationY.linearRampToValueAtTime(ni.y,i),e.orientationZ.linearRampToValueAtTime(ni.z,i)}else e.setPosition(si.x,si.y,si.z),e.setOrientation(ni.x,ni.y,ni.z)}}class Dy{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0;const e=this.getFrequencyData();for(let i=0;i<e.length;i++)t+=e[i];return t/e.length}}class Df{constructor(t,e,i){this.binding=t,this.valueSize=i;let s,n,r;switch(e){case"quaternion":s=this._slerp,n=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":s=this._select,n=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:s=this._lerp,n=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=s,this._mixBufferRegionAdditive=n,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,s=this.valueSize,n=t*s+s;let r=this.cumulativeWeight;if(r===0){for(let a=0;a!==s;++a)i[n+a]=i[a];r=e}else{r+=e;const a=e/r;this._mixBufferRegion(i,n,0,a,s)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,s=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,s,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,s=t*e+e,n=this.cumulativeWeight,r=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,n<1){const o=e*this._origIndex;this._mixBufferRegion(i,s,o,1-n,e)}r>0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let o=e,h=e+e;o!==h;++o)if(i[o]!==i[o+e]){a.setValue(i,s);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let n=i,r=s;n!==r;++n)e[n]=e[s+n%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,s,n){if(s>=.5)for(let r=0;r!==n;++r)t[e+r]=t[i+r]}_slerp(t,e,i,s){te.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,n){const r=this._workIndex*n;te.multiplyQuaternionsFlat(t,r,t,e,t,i),te.slerpFlat(t,e,t,e,t,r,s)}_lerp(t,e,i,s,n){const r=1-s;for(let a=0;a!==n;++a){const o=e+a;t[o]=t[o]*r+t[i+a]*s}}_lerpAdditive(t,e,i,s,n){for(let r=0;r!==n;++r){const a=e+r;t[a]=t[a]+t[i+r]*s}}}const Da="\\[\\]\\.:\\/",Lf=new RegExp("["+Da+"]","g"),La="[^"+Da+"]",Nf="[^"+Da.replace("\\.","")+"]",Uf=/((?:WC+[\/:])*)/.source.replace("WC",La),Vf=/(WCOD+)?/.source.replace("WCOD",Nf),Gf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",La),Wf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",La),Hf=new RegExp("^"+Uf+Vf+Gf+Wf+"$"),qf=["material","materials","bones","map"];class Xf{constructor(t,e,i){const s=i||it.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,s=this._bindings[i];s!==void 0&&s.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let s=this._targetGroup.nCachedObjects_,n=i.length;s!==n;++s)i[s].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class it{constructor(t,e,i){this.path=e,this.parsedPath=i||it.parseTrackName(e),this.node=it.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new it.Composite(t,e,i):new it(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Lf,"")}static parseTrackName(t){const e=Hf.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){const n=i.nodeName.substring(s+1);qf.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(n){for(let r=0;r<n.length;r++){const a=n[r];if(a.name===e||a.uuid===e)return a;const o=i(a.children);if(o)return o}return null},s=i(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let s=0,n=i.length;s!==n;++s)t[e++]=i[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let s=0,n=i.length;s!==n;++s)i[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let s=0,n=i.length;s!==n;++s)i[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let s=0,n=i.length;s!==n;++s)i[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,s=e.propertyName;let n=e.propertyIndex;if(t||(t=it.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=e.objectIndex;switch(i){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let c=0;c<t.length;c++)if(t[c].name===h){h=c;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(h!==void 0){if(t[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[h]}}const r=t[s];if(r===void 0){const h=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+s+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(n!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[n]!==void 0&&(n=t.morphTargetDictionary[n])}o=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=n}else r.fromArray!==void 0&&r.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(o=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=s;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}it.Composite=Xf;it.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};it.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};it.prototype.GetterByBindingType=[it.prototype._getValue_direct,it.prototype._getValue_array,it.prototype._getValue_arrayElement,it.prototype._getValue_toArray];it.prototype.SetterByBindingTypeAndVersioning=[[it.prototype._setValue_direct,it.prototype._setValue_direct_setNeedsUpdate,it.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[it.prototype._setValue_array,it.prototype._setValue_array_setNeedsUpdate,it.prototype._setValue_array_setMatrixWorldNeedsUpdate],[it.prototype._setValue_arrayElement,it.prototype._setValue_arrayElement_setNeedsUpdate,it.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[it.prototype._setValue_fromArray,it.prototype._setValue_fromArray_setNeedsUpdate,it.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ly{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Qt(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const t={};this._indicesByUUID=t;for(let i=0,s=arguments.length;i!==s;++i)t[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const t=this._objects,e=this._indicesByUUID,i=this._paths,s=this._parsedPaths,n=this._bindings,r=n.length;let a,o=t.length,h=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const d=arguments[c],f=d.uuid;let p=e[f];if(p===void 0){p=o++,e[f]=p,t.push(d);for(let m=0,g=r;m!==g;++m)n[m].push(new it(d,i[m],s[m]))}else if(p<h){a=t[p];const m=--h,g=t[m];e[g.uuid]=p,t[p]=g,e[f]=m,t[m]=d;for(let x=0,y=r;x!==y;++x){const b=n[x],v=b[m];let _=b[p];b[p]=v,_===void 0&&(_=new it(d,i[x],s[x])),b[m]=_}}else t[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=h}remove(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length;let n=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const o=arguments[r],h=o.uuid,c=e[h];if(c!==void 0&&c>=n){const u=n++,d=t[u];e[d.uuid]=c,t[c]=d,e[h]=u,t[u]=o;for(let f=0,p=s;f!==p;++f){const m=i[f],g=m[u],x=m[c];m[c]=g,m[u]=x}}}this.nCachedObjects_=n}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length;let n=this.nCachedObjects_,r=t.length;for(let a=0,o=arguments.length;a!==o;++a){const h=arguments[a],c=h.uuid,u=e[c];if(u!==void 0)if(delete e[c],u<n){const d=--n,f=t[d],p=--r,m=t[p];e[f.uuid]=u,t[u]=f,e[m.uuid]=d,t[d]=m,t.pop();for(let g=0,x=s;g!==x;++g){const y=i[g],b=y[d],v=y[p];y[u]=b,y[d]=v,y.pop()}}else{const d=--r,f=t[d];d>0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let p=0,m=s;p!==m;++p){const g=i[p];g[u]=g[d],g.pop()}}}this.nCachedObjects_=n}subscribe_(t,e){const i=this._bindingsIndicesByPath;let s=i[t];const n=this._bindings;if(s!==void 0)return n[s];const r=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,c=this.nCachedObjects_,u=new Array(h);s=n.length,i[t]=s,r.push(t),a.push(e),n.push(u);for(let d=c,f=o.length;d!==f;++d){const p=o[d];u[d]=new it(p,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(i!==void 0){const s=this._paths,n=this._parsedPaths,r=this._bindings,a=r.length-1,o=r[a],h=t[a];e[h]=i,r[i]=o,r.pop(),n[i]=n[a],n.pop(),s[i]=s[a],s.pop()}}}class Yf{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const n=e.tracks,r=n.length,a=new Array(r),o={endingStart:Ei,endingEnd:Ei};for(let h=0;h!==r;++h){const c=n[h].createInterpolant(null);a[h]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=uu,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i){if(t.fadeOut(e),this.fadeIn(e),i){const s=this._clip.duration,n=t._clip.duration,r=n/s,a=s/n;t.warp(1,r,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const s=this._mixer,n=s.time,r=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);const o=a.parameterPositions,h=a.sampleValues;return o[0]=n,o[1]=n+i,h[0]=t/r,h[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled){this._updateWeight(t);return}const n=this._startTime;if(n!==null){const o=(t-n)*i;o<0||i===0?e=0:(this._startTime=null,e=i*o)}e*=this._updateTimeScale(t);const r=this._updateTime(e),a=this._updateWeight(t);if(a>0){const o=this._interpolants,h=this._propertyBindings;switch(this.blendMode){case Gh:for(let c=0,u=o.length;c!==u;++c)o[c].evaluate(r),h[c].accumulateAdditive(a);break;case aa:default:for(let c=0,u=o.length;c!==u;++c)o[c].evaluate(r),h[c].accumulate(s,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),s===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let s=this.time+t,n=this._loopCount;const r=i===du;if(t===0)return n===-1?s:r&&(n&1)===1?e-s:s;if(i===cu){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(s>=e)s=e;else if(s<0)s=0;else{this.time=s;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(n===-1&&(t>=0?(n=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),s>=e||s<0){const a=Math.floor(s/e);s-=e*a,n+=Math.abs(a);const o=this.repetitions-n;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(o===1){const h=t<0;this._setEndings(h,!h,r)}else this._setEndings(!1,!1,r);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=s;if(r&&(n&1)===1)return e-s}return s}_setEndings(t,e,i){const s=this._interpolantSettings;i?(s.endingStart=Oi,s.endingEnd=Oi):(t?s.endingStart=this.zeroSlopeAtStart?Oi:Ei:s.endingStart=kn,e?s.endingEnd=this.zeroSlopeAtEnd?Oi:Ei:s.endingEnd=kn)}_scheduleFading(t,e,i){const s=this._mixer,n=s.time;let r=this._weightInterpolant;r===null&&(r=s._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,o=r.sampleValues;return a[0]=n,o[0]=e,a[1]=n+t,o[1]=i,this}}const Jf=new Float32Array(1);class Ny extends Xe{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,s=t._clip.tracks,n=s.length,r=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName;let c=h[o];c===void 0&&(c={},h[o]=c);for(let u=0;u!==n;++u){const d=s[u],f=d.name;let p=c[f];if(p!==void 0)++p.referenceCount,r[u]=p;else{if(p=r[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,f));continue}const m=e&&e._propertyBindings[u].binding.parsedPath;p=new Df(it.create(i,f,m),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,f),r[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,s=t._clip.uuid,n=this._actionsByClip[s];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,s,i)}const e=t._propertyBindings;for(let i=0,s=e.length;i!==s;++i){const n=e[i];n.useCount++===0&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,s=e.length;i!==s;++i){const n=e[i];--n.useCount===0&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,i){const s=this._actions,n=this._actionsByClip;let r=n[e];if(r===void 0)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,n[e]=r;else{const a=r.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=s.length,s.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],s=t._cacheIndex;i._cacheIndex=s,e[s]=i,e.pop(),t._cacheIndex=null;const n=t._clip.uuid,r=this._actionsByClip,a=r[n],o=a.knownActions,h=o[o.length-1],c=t._byClipCacheIndex;h._byClipCacheIndex=c,o[c]=h,o.pop(),t._byClipCacheIndex=null;const u=a.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],o.length===0&&delete r[n],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,s=e.length;i!==s;++i){const n=e[i];--n.referenceCount===0&&this._removeInactiveBinding(n)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,s=this._nActiveActions++,n=e[s];t._cacheIndex=s,e[s]=t,n._cacheIndex=i,e[i]=n}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,s=--this._nActiveActions,n=e[s];t._cacheIndex=s,e[s]=t,n._cacheIndex=i,e[i]=n}_addInactiveBinding(t,e,i){const s=this._bindingsByRootAndName,n=this._bindings;let r=s[e];r===void 0&&(r={},s[e]=r),r[i]=t,t._cacheIndex=n.length,n.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,s=i.rootNode.uuid,n=i.path,r=this._bindingsByRootAndName,a=r[s],o=e[e.length-1],h=t._cacheIndex;o._cacheIndex=h,e[h]=o,e.pop(),delete a[n],Object.keys(a).length===0&&delete r[s]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,s=this._nActiveBindings++,n=e[s];t._cacheIndex=s,e[s]=t,n._cacheIndex=i,e[i]=n}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,s=--this._nActiveBindings,n=e[s];t._cacheIndex=s,e[s]=t,n._cacheIndex=i,e[i]=n}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return i===void 0&&(i=new cl(new Float32Array(2),new Float32Array(2),1,Jf),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,s=--this._nActiveControlInterpolants,n=e[s];t.__cacheIndex=s,e[s]=t,n.__cacheIndex=i,e[i]=n}clipAction(t,e,i){const s=e||this._root,n=s.uuid;let r=typeof t=="string"?Vn.findByName(s,t):t;const a=r!==null?r.uuid:t,o=this._actionsByClip[a];let h=null;if(i===void 0&&(r!==null?i=r.blendMode:i=aa),o!==void 0){const u=o.actionByRoot[n];if(u!==void 0&&u.blendMode===i)return u;h=o.knownActions[0],r===null&&(r=h._clip)}if(r===null)return null;const c=new Yf(this,r,e,i);return this._bindAction(c,h),this._addInactiveAction(c,a,n),c}existingAction(t,e){const i=e||this._root,s=i.uuid,n=typeof t=="string"?Vn.findByName(i,t):t,r=n?n.uuid:t,a=this._actionsByClip[r];return a!==void 0&&a.actionByRoot[s]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let i=e-1;i>=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,s=this.time+=t,n=Math.sign(t),r=this._accuIndex^=1;for(let h=0;h!==i;++h)e[h]._update(s,t,n,r);const a=this._bindings,o=this._nActiveBindings;for(let h=0;h!==o;++h)a[h].apply(r);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,s=this._actionsByClip,n=s[i];if(n!==void 0){const r=n.knownActions;for(let a=0,o=r.length;a!==o;++a){const h=r[a];this._deactivateAction(h);const c=h._cacheIndex,u=e[e.length-1];h._cacheIndex=null,h._byClipCacheIndex=null,u._cacheIndex=c,e[c]=u,e.pop(),this._removeInactiveBindingsForAction(h)}delete s[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const r in i){const a=i[r].actionByRoot,o=a[e];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}const s=this._bindingsByRootAndName,n=s[e];if(n!==void 0)for(const r in n){const a=n[r];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){const i=this.existingAction(t,e);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class Uy extends ha{constructor(t=1,e=1,i=1,s={}){super(t,e,s),this.isRenderTarget3D=!0,this.depth=i,this.texture=new qh(null,t,e,i),this.texture.isRenderTargetTexture=!0}}class Vy extends ha{constructor(t=1,e=1,i=1,s={}){super(t,e,s),this.isRenderTargetArray=!0,this.depth=i,this.texture=new Hh(null,t,e,i),this.texture.isRenderTargetTexture=!0}}class ml{constructor(t){this.value=t}clone(){return new ml(this.value.clone===void 0?this.value:this.value.clone())}}let Zf=0;class Gy extends Xe{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Zf++}),this.name="",this.usage=Pn,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){const e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(t){this.name=t.name,this.usage=t.usage;const e=t.uniforms;this.uniforms.length=0;for(let i=0,s=e.length;i<s;i++){const n=Array.isArray(e[i])?e[i]:[e[i]];for(let r=0;r<n.length;r++)this.uniforms.push(n[r].clone())}return this}clone(){return new this.constructor().copy(this)}}class Wy extends ma{constructor(t,e,i=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class Hy{constructor(t,e,i,s,n){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=i,this.elementSize=s,this.count=n,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}}const rh=new Z;class qy{constructor(t,e,i=0,s=1/0){this.ray=new ks(t,e),this.near=i,this.far=s,this.camera=null,this.layers=new Xh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return rh.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(rh),this}intersectObject(t,e=!0,i=[]){return Qr(t,this,i,e),i.sort(ah),i}intersectObjects(t,e=!0,i=[]){for(let s=0,n=t.length;s<n;s++)Qr(t[s],this,i,e);return i.sort(ah),i}}function ah(l,t){return l.distance-t.distance}function Qr(l,t,e,i){let s=!0;if(l.layers.test(t.layers)&&l.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const n=l.children;for(let r=0,a=n.length;r<a;r++)Qr(n[r],t,e,!0)}}class Xy{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=X(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(X(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Yy{constructor(t=1,e=0,i=0){return this.radius=t,this.theta=e,this.y=i,this}set(t,e,i){return this.radius=t,this.theta=e,this.y=i,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+i*i),this.theta=Math.atan2(t,i),this.y=e,this}clone(){return new this.constructor().copy(this)}}class gl{constructor(t,e,i,s){gl.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,s){const n=this.elements;return n[0]=t,n[2]=e,n[1]=i,n[3]=s,this}}const oh=new B;class Jy{constructor(t=new B(1/0,1/0),e=new B(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=oh.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,oh).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const hh=new w,vn=new w;class Zy{constructor(t=new w,e=new w){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){hh.subVectors(t,this.start),vn.subVectors(this.end,this.start);const i=vn.dot(vn);let n=vn.dot(hh)/i;return e&&(n=X(n,0,1)),n}closestPointToPoint(t,e,i){const s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const lh=new w;class $y extends st{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new j,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let r=0,a=1,o=32;r<o;r++,a++){const h=r/o*Math.PI*2,c=a/o*Math.PI*2;s.push(Math.cos(h),Math.sin(h),1,Math.cos(c),Math.sin(c),1)}i.setAttribute("position",new D(s,3));const n=new Xt({fog:!1,toneMapped:!1});this.cone=new Re(i,n),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),lh.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(lh),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const We=new w,wn=new Z,Nr=new Z;class jy extends Re{constructor(t){const e=yl(t),i=new j,s=[],n=[],r=new G(0,0,1),a=new G(0,1,0);for(let h=0;h<e.length;h++){const c=e[h];c.parent&&c.parent.isBone&&(s.push(0,0,0),s.push(0,0,0),n.push(r.r,r.g,r.b),n.push(a.r,a.g,a.b))}i.setAttribute("position",new D(s,3)),i.setAttribute("color",new D(n,3));const o=new Xt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,o),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(t){const e=this.bones,i=this.geometry,s=i.getAttribute("position");Nr.copy(this.root.matrixWorld).invert();for(let n=0,r=0;n<e.length;n++){const a=e[n];a.parent&&a.parent.isBone&&(wn.multiplyMatrices(Nr,a.matrixWorld),We.setFromMatrixPosition(wn),s.setXYZ(r,We.x,We.y,We.z),wn.multiplyMatrices(Nr,a.parent.matrixWorld),We.setFromMatrixPosition(wn),s.setXYZ(r+1,We.x,We.y,We.z),r+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose()}}function yl(l){const t=[];l.isBone===!0&&t.push(l);for(let e=0;e<l.children.length;e++)t.push.apply(t,yl(l.children[e]));return t}class Ky extends qt{constructor(t,e,i){const s=new Fs(e,4,2),n=new qi({wireframe:!0,fog:!1,toneMapped:!1});super(s,n),this.light=t,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const $f=new w,ch=new G,uh=new G;class Qy extends st{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";const s=new $n(e);s.rotateY(Math.PI*.5),this.material=new qi({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const n=s.getAttribute("position"),r=new Float32Array(n.count*3);s.setAttribute("color",new ft(r,3)),this.add(new qt(s,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const e=t.geometry.getAttribute("color");ch.copy(this.light.color),uh.copy(this.light.groundColor);for(let i=0,s=e.count;i<s;i++){const n=i<s/2?ch:uh;e.setXYZ(i,n.r,n.g,n.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt($f.setFromMatrixPosition(this.light.matrixWorld).negate())}}class tx extends Re{constructor(t=10,e=10,i=4473924,s=8947848){i=new G(i),s=new G(s);const n=e/2,r=t/e,a=t/2,o=[],h=[];for(let d=0,f=0,p=-a;d<=e;d++,p+=r){o.push(-a,0,p,a,0,p),o.push(p,0,-a,p,0,a);const m=d===n?i:s;m.toArray(h,f),f+=3,m.toArray(h,f),f+=3,m.toArray(h,f),f+=3,m.toArray(h,f),f+=3}const c=new j;c.setAttribute("position",new D(o,3)),c.setAttribute("color",new D(h,3));const u=new Xt({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ex extends Re{constructor(t=10,e=16,i=8,s=64,n=4473924,r=8947848){n=new G(n),r=new G(r);const a=[],o=[];if(e>1)for(let u=0;u<e;u++){const d=u/e*(Math.PI*2),f=Math.sin(d)*t,p=Math.cos(d)*t;a.push(0,0,0),a.push(f,0,p);const m=u&1?n:r;o.push(m.r,m.g,m.b),o.push(m.r,m.g,m.b)}for(let u=0;u<i;u++){const d=u&1?n:r,f=t-t/i*u;for(let p=0;p<s;p++){let m=p/s*(Math.PI*2),g=Math.sin(m)*f,x=Math.cos(m)*f;a.push(g,0,x),o.push(d.r,d.g,d.b),m=(p+1)/s*(Math.PI*2),g=Math.sin(m)*f,x=Math.cos(m)*f,a.push(g,0,x),o.push(d.r,d.g,d.b)}}const h=new j;h.setAttribute("position",new D(a,3)),h.setAttribute("color",new D(o,3));const c=new Xt({vertexColors:!0,toneMapped:!1});super(h,c),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const dh=new w,_n=new w,fh=new w;class ix extends st{constructor(t,e,i){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",e===void 0&&(e=1);let s=new j;s.setAttribute("position",new D([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const n=new Xt({fog:!1,toneMapped:!1});this.lightPlane=new hi(s,n),this.add(this.lightPlane),s=new j,s.setAttribute("position",new D([0,0,0,0,0,1],3)),this.targetLine=new hi(s,n),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),dh.setFromMatrixPosition(this.light.matrixWorld),_n.setFromMatrixPosition(this.light.target.matrixWorld),fh.subVectors(_n,dh),this.lightPlane.lookAt(_n),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(_n),this.targetLine.scale.z=fh.length()}}const Mn=new w,pt=new ua;class sx extends Re{constructor(t){const e=new j,i=new Xt({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],n=[],r={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,m){o(p),o(m)}function o(p){s.push(0,0,0),n.push(0,0,0),r[p]===void 0&&(r[p]=[]),r[p].push(s.length/3-1)}e.setAttribute("position",new D(s,3)),e.setAttribute("color",new D(n,3)),super(e,i),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update();const h=new G(16755200),c=new G(16711680),u=new G(43775),d=new G(16777215),f=new G(3355443);this.setColors(h,c,u,d,f)}setColors(t,e,i,s,n){const a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,s.r,s.g,s.b),a.setXYZ(39,s.r,s.g,s.b),a.setXYZ(40,n.r,n.g,n.b),a.setXYZ(41,n.r,n.g,n.b),a.setXYZ(42,n.r,n.g,n.b),a.setXYZ(43,n.r,n.g,n.b),a.setXYZ(44,n.r,n.g,n.b),a.setXYZ(45,n.r,n.g,n.b),a.setXYZ(46,n.r,n.g,n.b),a.setXYZ(47,n.r,n.g,n.b),a.setXYZ(48,n.r,n.g,n.b),a.setXYZ(49,n.r,n.g,n.b),a.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap,i=1,s=1;pt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);const n=this.camera.coordinateSystem===Be?-1:0;gt("c",e,t,pt,0,0,n),gt("t",e,t,pt,0,0,1),gt("n1",e,t,pt,-i,-s,n),gt("n2",e,t,pt,i,-s,n),gt("n3",e,t,pt,-i,s,n),gt("n4",e,t,pt,i,s,n),gt("f1",e,t,pt,-i,-s,1),gt("f2",e,t,pt,i,-s,1),gt("f3",e,t,pt,-i,s,1),gt("f4",e,t,pt,i,s,1),gt("u1",e,t,pt,i*.7,s*1.1,n),gt("u2",e,t,pt,-i*.7,s*1.1,n),gt("u3",e,t,pt,0,s*2,n),gt("cf1",e,t,pt,-i,0,1),gt("cf2",e,t,pt,i,0,1),gt("cf3",e,t,pt,0,-s,1),gt("cf4",e,t,pt,0,s,1),gt("cn1",e,t,pt,-i,0,n),gt("cn2",e,t,pt,i,0,n),gt("cn3",e,t,pt,0,-s,n),gt("cn4",e,t,pt,0,s,n),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function gt(l,t,e,i,s,n,r){Mn.set(s,n,r).unproject(i);const a=t[l];if(a!==void 0){const o=e.getAttribute("position");for(let h=0,c=a.length;h<c;h++)o.setXYZ(a[h],Mn.x,Mn.y,Mn.z)}}const Sn=new Ht;class nx extends Re{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=new Float32Array(24),n=new j;n.setIndex(new ft(i,1)),n.setAttribute("position",new ft(s,3)),super(n,new Xt({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(t){if(t!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&Sn.setFromObject(this.object),Sn.isEmpty())return;const e=Sn.min,i=Sn.max,s=this.geometry.attributes.position,n=s.array;n[0]=i.x,n[1]=i.y,n[2]=i.z,n[3]=e.x,n[4]=i.y,n[5]=i.z,n[6]=e.x,n[7]=e.y,n[8]=i.z,n[9]=i.x,n[10]=e.y,n[11]=i.z,n[12]=i.x,n[13]=i.y,n[14]=e.z,n[15]=e.x,n[16]=i.y,n[17]=e.z,n[18]=e.x,n[19]=e.y,n[20]=e.z,n[21]=i.x,n[22]=e.y,n[23]=e.z,s.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class rx extends Re{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],n=new j;n.setIndex(new ft(i,1)),n.setAttribute("position",new D(s,3)),super(n,new Xt({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class ax extends hi{constructor(t,e=1,i=16776960){const s=i,n=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],r=new j;r.setAttribute("position",new D(n,3)),r.computeBoundingSphere(),super(r,new Xt({color:s,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],o=new j;o.setAttribute("position",new D(a,3)),o.computeBoundingSphere(),this.add(new qt(o,new qi({color:s,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const ph=new w;let An,Ur;class ox extends st{constructor(t=new w(0,0,1),e=new w(0,0,0),i=1,s=16776960,n=i*.2,r=n*.2){super(),this.type="ArrowHelper",An===void 0&&(An=new j,An.setAttribute("position",new D([0,0,0,0,1,0],3)),Ur=new Ps(0,.5,1,5,1),Ur.translate(0,-.5,0)),this.position.copy(e),this.line=new hi(An,new Xt({color:s,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new qt(Ur,new qi({color:s,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,n,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{ph.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(ph,e)}}setLength(t,e=t*.2,i=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class hx extends Re{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],s=new j;s.setAttribute("position",new D(e,3)),s.setAttribute("color",new D(i,3));const n=new Xt({vertexColors:!0,toneMapped:!1});super(s,n),this.type="AxesHelper"}setColors(t,e,i){const s=new G,n=this.geometry.attributes.color.array;return s.set(t),s.toArray(n,0),s.toArray(n,3),s.set(e),s.toArray(n,6),s.toArray(n,9),s.set(i),s.toArray(n,12),s.toArray(n,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class lx{constructor(){this.type="ShapePath",this.color=new G,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Ln,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,n,r){return this.currentPath.bezierCurveTo(t,e,i,s,n,r),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(x){const y=[];for(let b=0,v=x.length;b<v;b++){const _=x[b],M=new Vi;M.curves=_.curves,y.push(M)}return y}function i(x,y){const b=y.length;let v=!1;for(let _=b-1,M=0;M<b;_=M++){let A=y[_],S=y[M],T=S.x-A.x,C=S.y-A.y;if(Math.abs(C)>Number.EPSILON){if(C<0&&(A=y[M],T=-T,S=y[_],C=-C),x.y<A.y||x.y>S.y)continue;if(x.y===A.y){if(x.x===A.x)return!0}else{const P=C*(x.x-A.x)-T*(x.y-A.y);if(P===0)return!0;if(P<0)continue;v=!v}}else{if(x.y!==A.y)continue;if(S.x<=x.x&&x.x<=A.x||A.x<=x.x&&x.x<=S.x)return!0}}return v}const s=Fe.isClockWise,n=this.subPaths;if(n.length===0)return[];let r,a,o;const h=[];if(n.length===1)return a=n[0],o=new Vi,o.curves=a.curves,h.push(o),h;let c=!s(n[0].getPoints());c=t?!c:c;const u=[],d=[];let f=[],p=0,m;d[p]=void 0,f[p]=[];for(let x=0,y=n.length;x<y;x++)a=n[x],m=a.getPoints(),r=s(m),r=t?!r:r,r?(!c&&d[p]&&p++,d[p]={s:new Vi,p:m},d[p].s.curves=a.curves,c&&p++,f[p]=[]):f[p].push({h:a,p:m[0]});if(!d[0])return e(n);if(d.length>1){let x=!1,y=0;for(let b=0,v=d.length;b<v;b++)u[b]=[];for(let b=0,v=d.length;b<v;b++){const _=f[b];for(let M=0;M<_.length;M++){const A=_[M];let S=!0;for(let T=0;T<d.length;T++)i(A.p,d[T].p)&&(b!==T&&y++,S?(S=!1,u[T].push(A)):x=!0);S&&u[b].push(A)}}y>0&&x===!1&&(f=u)}let g;for(let x=0,y=d.length;x<y;x++){o=d[x].s,h.push(o),g=f[x];for(let b=0,v=g.length;b<v;b++)o.holes.push(g[b].h)}return h}}class cx extends Xe{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}function jf(l,t){const e=l.image&&l.image.width?l.image.width/l.image.height:1;return e>t?(l.repeat.x=1,l.repeat.y=e/t,l.offset.x=0,l.offset.y=(1-l.repeat.y)/2):(l.repeat.x=t/e,l.repeat.y=1,l.offset.x=(1-l.repeat.x)/2,l.offset.y=0),l}function Kf(l,t){const e=l.image&&l.image.width?l.image.width/l.image.height:1;return e>t?(l.repeat.x=t/e,l.repeat.y=1,l.offset.x=(1-l.repeat.x)/2,l.offset.y=0):(l.repeat.x=1,l.repeat.y=e/t,l.offset.x=0,l.offset.y=(1-l.repeat.y)/2),l}function Qf(l){return l.repeat.x=1,l.repeat.y=1,l.offset.x=0,l.offset.y=0,l}function tp(l,t,e,i){const s=ep(i);switch(e){case Ac:return l*t;case Tc:return l*t;case Cc:return l*t*2;case Uh:return l*t/s.components*s.byteLength;case Vh:return l*t/s.components*s.byteLength;case Bc:return l*t*2/s.components*s.byteLength;case zc:return l*t*2/s.components*s.byteLength;case Ic:return l*t*3/s.components*s.byteLength;case As:return l*t*4/s.components*s.byteLength;case kc:return l*t*4/s.components*s.byteLength;case Pc:case Fc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*8;case Rc:case Ec:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Dc:case Nc:return Math.max(l,16)*Math.max(t,8)/4;case Oc:case Lc:return Math.max(l,8)*Math.max(t,8)/2;case Uc:case Vc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*8;case Gc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Wc:return Math.floor((l+3)/4)*Math.floor((t+3)/4)*16;case Hc:return Math.floor((l+4)/5)*Math.floor((t+3)/4)*16;case qc:return Math.floor((l+4)/5)*Math.floor((t+4)/5)*16;case Xc:return Math.floor((l+5)/6)*Math.floor((t+4)/5)*16;case Yc:return Math.floor((l+5)/6)*Math.floor((t+5)/6)*16;case Jc:return Math.floor((l+7)/8)*Math.floor((t+4)/5)*16;case Zc:return Math.floor((l+7)/8)*Math.floor((t+5)/6)*16;case $c:return Math.floor((l+7)/8)*Math.floor((t+7)/8)*16;case jc:return Math.floor((l+9)/10)*Math.floor((t+4)/5)*16;case Kc:return Math.floor((l+9)/10)*Math.floor((t+5)/6)*16;case Qc:return Math.floor((l+9)/10)*Math.floor((t+7)/8)*16;case tu:return Math.floor((l+9)/10)*Math.floor((t+9)/10)*16;case eu:return Math.floor((l+11)/12)*Math.floor((t+9)/10)*16;case iu:return Math.floor((l+11)/12)*Math.floor((t+11)/12)*16;case su:case nu:case ru:return Math.ceil(l/4)*Math.ceil(t/4)*16;case au:case ou:return Math.ceil(l/4)*Math.ceil(t/4)*8;case hu:case lu:return Math.ceil(l/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ep(l){switch(l){case Nh:case gc:return{byteLength:1,components:1};case xc:case yc:case vc:return{byteLength:2,components:1};case wc:case _c:return{byteLength:2,components:4};case ra:case bc:case Gi:return{byteLength:4,components:1};case Sc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${l}.`)}const ux={contain:jf,cover:Kf,fill:Qf,getByteLength:tp};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dh);function xl(l){return l>=.7?"active":l>=.4?"dormant":l>=.1?"silent":"unavailable"}const bl={active:"#10b981",dormant:"#f59e0b",silent:"#8b5cf6",unavailable:"#6b7280"},dx={active:"Easily retrievable (retention ≥ 70%)",dormant:"Retrievable with effort (40–70%)",silent:"Difficult, needs cues (10–40%)",unavailable:"Needs reinforcement (< 10%)"},Vr={aha:"#FFD700",confusion:"#EF4444",failure:"#9CA3AF"},fx={aha:"Aha moments and breakthroughs",confusion:"Confusions and weak spots",failure:"Failures and guardrails"};function mh(l,t){return t==="state"?bl[xl(l.retention)]:t==="ahagraph"?vl(l)??Ja[l.type]??"#8B95A5":Ja[l.type]||"#8B95A5"}function vl(l){const t=new Set((l.tags??[]).map(e=>e.toLowerCase()));return t.has("aha")?Vr.aha:t.has("confusion")||t.has("weak-spot")?Vr.confusion:t.has("failure")||t.has("guardrail")?Vr.failure:null}let ds=null;function ip(){if(ds)return ds;const l=128,t=document.createElement("canvas");t.width=l,t.height=l;const e=t.getContext("2d");if(!e)return ds=new yt,ds;const i=e.createRadialGradient(l/2,l/2,0,l/2,l/2,l/2);i.addColorStop(0,"rgba(255, 255, 255, 1.0)"),i.addColorStop(.25,"rgba(255, 255, 255, 0.7)"),i.addColorStop(.55,"rgba(255, 255, 255, 0.2)"),i.addColorStop(1,"rgba(255, 255, 255, 0.0)"),e.fillStyle=i,e.fillRect(0,0,l,l);const s=new Qh(t);return s.needsUpdate=!0,ds=s,s}function gh(l){if(l===0||l===1)return l;const t=.3;return Math.pow(2,-10*l)*Math.sin((l-t/4)*(2*Math.PI)/t)+1}function sp(l){return l*l*((1.70158+1)*l-1.70158)}class px{constructor(){z(this,"group");z(this,"meshMap",new Map);z(this,"glowMap",new Map);z(this,"positions",new Map);z(this,"labelSprites",new Map);z(this,"hoveredNode",null);z(this,"selectedNode",null);z(this,"colorMode","type");z(this,"materializingNodes",[]);z(this,"dissolvingNodes",[]);z(this,"growingNodes",[]);this.group=new Kh}setColorMode(t){if(this.colorMode!==t){this.colorMode=t;for(const[e,i]of this.meshMap){const s=i.userData.retention??0,n=i.userData.type??"fact",r=Array.isArray(i.userData.tags)?i.userData.tags:[],o=mh({type:n,retention:s,tags:r},t),h=new G(o),c=i.material;c.color.copy(h),c.emissive.copy(h);const u=this.glowMap.get(e);u&&u.material.color.copy(h)}}}createNodes(t){const e=(1+Math.sqrt(5))/2,i=t.length;for(let s=0;s<i;s++){const n=t[s],r=1-2*s/(i-1||1),a=Math.sqrt(1-r*r),o=2*Math.PI*s/e,h=30+i*.5,c=new w(a*Math.cos(o)*h,r*h,a*Math.sin(o)*h);n.isCenter&&c.set(0,0,0),this.positions.set(n.id,c),this.createNodeMeshes(n,c,1)}return this.positions}createNodeMeshes(t,e,i){const s=.5+t.retention*2,n=mh(t,this.colorMode),r=(t.suppression_count??0)>0,a=new Fs(s,16,16),o=new Fa({color:new G(n),emissive:new G(n),emissiveIntensity:r?0:.3+t.retention*.5,roughness:.3,metalness:.1,transparent:!0,opacity:r?.2:.3+t.retention*.7}),h=new qt(a,o);h.position.copy(e),h.scale.setScalar(i),h.userData={nodeId:t.id,type:t.type,retention:t.retention,tags:t.tags},this.meshMap.set(t.id,h),this.group.add(h);const c=new _s({map:ip(),color:new G(n),transparent:!0,opacity:i>0?r?.1:.3+t.retention*.35:0,blending:oc,depthWrite:!1}),u=new bs(c);u.scale.set(s*6*i,s*6*i,1),u.position.copy(e),u.userData={isGlow:!0,nodeId:t.id},this.glowMap.set(t.id,u),this.group.add(u);const d=t.label||t.type,f=this.createTextSprite(d,"#94a3b8");return f.position.copy(e),f.position.y+=s*2+1.5,f.userData={isLabel:!0,nodeId:t.id,offset:s*2+1.5},this.group.add(f),this.labelSprites.set(t.id,f),{mesh:h,glow:u,label:f,size:s}}addNode(t,e,i={}){const s=(e==null?void 0:e.clone())??new w((Math.random()-.5)*40,(Math.random()-.5)*40,(Math.random()-.5)*40);this.positions.set(t.id,s);const{mesh:n,glow:r,label:a}=this.createNodeMeshes(t,s,0);return n.scale.setScalar(.001),r.scale.set(.001,.001,1),r.material.opacity=0,a.material.opacity=0,i.isBirthRitual?(n.visible=!1,r.visible=!1,a.visible=!1,n.userData.birthRitualPending={totalFrames:30,targetScale:.5+t.retention*2}):this.materializingNodes.push({id:t.id,frame:0,totalFrames:30,mesh:n,glow:r,label:a,targetScale:.5+t.retention*2}),s}igniteNode(t){const e=this.meshMap.get(t),i=this.glowMap.get(t),s=this.labelSprites.get(t);if(!e||!i||!s)return;const n=e.userData.birthRitualPending;n&&(e.visible=!0,i.visible=!0,s.visible=!0,delete e.userData.birthRitualPending,this.materializingNodes.push({id:t,frame:0,totalFrames:n.totalFrames,mesh:e,glow:i,label:s,targetScale:n.targetScale}))}removeNode(t){const e=this.meshMap.get(t),i=this.glowMap.get(t),s=this.labelSprites.get(t);!e||!i||!s||(this.materializingNodes=this.materializingNodes.filter(n=>n.id!==t),this.dissolvingNodes.push({id:t,frame:0,totalFrames:60,mesh:e,glow:i,label:s,originalScale:e.scale.x}))}growNode(t,e){const i=this.meshMap.get(t);if(!i)return;const s=i.scale.x,n=.5+e*2;i.userData.retention=e,this.growingNodes.push({id:t,frame:0,totalFrames:30,startScale:s,targetScale:n})}createTextSprite(t,e){const i=document.createElement("canvas"),s=i.getContext("2d");if(!s){const x=new yt;return new bs(new _s({map:x,transparent:!0,opacity:0}))}i.width=512,i.height=64;const n=t.length>40?t.slice(0,37)+"...":t;s.clearRect(0,0,i.width,i.height),s.font='600 22px -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif';const a=s.measureText(n).width,h=Math.min(a+14*2,i.width-4),c=40,u=(i.width-h)/2,d=(i.height-c)/2,f=c/2;s.fillStyle="rgba(10, 16, 28, 0.82)",s.beginPath(),s.moveTo(u+f,d),s.lineTo(u+h-f,d),s.quadraticCurveTo(u+h,d,u+h,d+f),s.lineTo(u+h,d+c-f),s.quadraticCurveTo(u+h,d+c,u+h-f,d+c),s.lineTo(u+f,d+c),s.quadraticCurveTo(u,d+c,u,d+c-f),s.lineTo(u,d+f),s.quadraticCurveTo(u,d,u+f,d),s.closePath(),s.fill(),s.strokeStyle="rgba(148, 163, 184, 0.18)",s.lineWidth=1,s.stroke(),s.textAlign="center",s.textBaseline="middle",s.fillStyle=e,s.fillText(n,i.width/2,i.height/2+1);const p=new Qh(i);p.needsUpdate=!0;const m=new _s({map:p,transparent:!0,opacity:0,depthTest:!1,sizeAttenuation:!0}),g=new bs(m);return g.scale.set(9,1.2,1),g}updatePositions(){this.group.children.forEach(t=>{if(t.userData.nodeId){const e=this.positions.get(t.userData.nodeId);if(!e)return;t.userData.isGlow?t.position.copy(e):t.userData.isLabel?(t.position.copy(e),t.position.y+=t.userData.offset):t instanceof qt&&t.position.copy(e)}})}animate(t,e,i,s=1){var r,a;for(let o=this.materializingNodes.length-1;o>=0;o--){const h=this.materializingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=gh(c);if(h.mesh.scale.setScalar(Math.max(.001,u)),h.frame>=5){const d=Math.min((h.frame-5)/5,1),f=h.glow.material;f.opacity=d*.4;const p=h.targetScale*6*u;h.glow.scale.set(p,p,1)}if(h.frame>=40){const d=Math.min((h.frame-40)/20,1);h.label.material.opacity=d*.9}h.frame>=60&&this.materializingNodes.splice(o,1)}for(let o=this.dissolvingNodes.length-1;o>=0;o--){const h=this.dissolvingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=1-sp(c),d=Math.max(.001,h.originalScale*u);h.mesh.scale.setScalar(d);const f=d*6;h.glow.scale.set(f,f,1);const p=h.mesh.material;p.opacity*=.97,h.glow.material.opacity*=.95,h.label.material.opacity*=.93,h.frame>=h.totalFrames&&(this.group.remove(h.mesh),this.group.remove(h.glow),this.group.remove(h.label),h.mesh.geometry.dispose(),h.mesh.material.dispose(),(r=h.glow.material.map)==null||r.dispose(),h.glow.material.dispose(),(a=h.label.material.map)==null||a.dispose(),h.label.material.dispose(),this.meshMap.delete(h.id),this.glowMap.delete(h.id),this.labelSprites.delete(h.id),this.positions.delete(h.id),this.dissolvingNodes.splice(o,1))}for(let o=this.growingNodes.length-1;o>=0;o--){const h=this.growingNodes[o];h.frame++;const c=Math.min(h.frame/h.totalFrames,1),u=h.startScale+(h.targetScale-h.startScale)*gh(c),d=this.meshMap.get(h.id);d&&d.scale.setScalar(u);const f=this.glowMap.get(h.id);if(f){const p=u*6;f.scale.set(p,p,1)}h.frame>=h.totalFrames&&this.growingNodes.splice(o,1)}const n=new Set([...this.materializingNodes.map(o=>o.id),...this.dissolvingNodes.map(o=>o.id),...this.growingNodes.map(o=>o.id)]);this.meshMap.forEach((o,h)=>{if(n.has(h))return;const c=e.find(y=>y.id===h);if(!c)return;const u=1+Math.sin(t*1.5+e.indexOf(c)*.5)*.15*c.retention;o.scale.setScalar(u);const d=this.positions.get(h),f=d?i.position.distanceTo(d):0,p=1+Math.min(1.4,Math.max(0,(f-60)/100)),m=o.material;if(h===this.hoveredNode)m.emissiveIntensity=1*s;else if(h===this.selectedNode)m.emissiveIntensity=.8*s;else{const b=.3+c.retention*.5+Math.sin(t*(.8+c.retention*.7))*.1*c.retention;m.emissiveIntensity=b*s*p}const g=.3+c.retention*.7;m.opacity=Math.min(1,g*s*p);const x=this.glowMap.get(h);if(x){const y=x.material,b=.3+c.retention*.35;y.opacity=Math.min(.95,b*s*p)}}),this.labelSprites.forEach((o,h)=>{if(n.has(h))return;const c=this.positions.get(h);if(!c)return;const u=i.position.distanceTo(c),d=o.material,f=h===this.hoveredNode||h===this.selectedNode?1:u<40?.9:u<80?.9*(1-(u-40)/40):0;d.opacity+=(f-d.opacity)*.1})}getMeshes(){return Array.from(this.meshMap.values())}dispose(){this.group.traverse(t=>{var e,i,s,n,r;t instanceof qt?((e=t.geometry)==null||e.dispose(),(i=t.material)==null||i.dispose()):t instanceof bs&&((n=(s=t.material)==null?void 0:s.map)==null||n.dispose(),(r=t.material)==null||r.dispose())}),this.materializingNodes=[],this.dissolvingNodes=[],this.growingNodes=[]}}function np(l){var e,i;const t={};for(const s of l)(t[e=s.source]??(t[e]=[])).push({edge:s,otherId:s.target}),(t[i=s.target]??(t[i]=[])).push({edge:s,otherId:s.source});for(const s of Object.keys(t))t[s].sort((n,r)=>(r.edge.weight??0)-(n.edge.weight??0));return t}function Gr(l){const t=(l.type??"").toLowerCase();return t.includes("contradict")||t.includes("conflict")||t.includes("supersede")}function yh(l){const t=(l.type??"").toLowerCase();return t==="causal"||t.includes("causal")||t.includes("cause")}function In(l){const t=Date.parse(l.updatedAt||l.createdAt||"");return Number.isFinite(t)?t:0}function rp(l,t,e,i=7,s={}){var y;const n=s.preferCausal??!1,r=new Map(l.map(b=>[b.id,b])),a={beats:[],centerId:e,pivoted:!1,flowEdges:[]};if(l.length===0)return a;const o=np(t),h=r.has(e);let c=h?e:"";c||(c=((y=l.find(b=>b.isCenter))==null?void 0:y.id)??""),c||(c=l.map(b=>{var v;return{id:b.id,deg:((v=o[b.id])==null?void 0:v.length)??0}}).sort((b,v)=>v.deg-b.deg)[0].id);const u=r.get(c);if(!u)return a;const d=!h,f=new Set([c]),p=[{nodeId:c,node:u,viaEdge:null,kind:"origin",intensity:1}],m=[];let g=c,x=!1;for(;p.length<i;){const b=o[g]??[];let v;if(n&&(v=b.find(A=>!f.has(A.otherId)&&yh(A.edge))),!v&&!x&&(v=b.find(A=>!f.has(A.otherId)&&Gr(A.edge)),v&&(x=!0)),v||(v=b.find(A=>!f.has(A.otherId))),!v){const A=l.filter(T=>!f.has(T.id)).sort((T,C)=>In(C)-In(T));if(A.length===0)break;const S=A[0];f.add(S.id),p.push({nodeId:S.id,node:S,viaEdge:null,kind:"bridge",intensity:.6}),g=S.id;continue}const _=r.get(v.otherId);if(!_){f.add(v.otherId);continue}f.add(_.id),m.push(v.edge);const M=n&&yh(v.edge);p.push({nodeId:_.id,node:_,viaEdge:v.edge,kind:Gr(v.edge)?"contradiction":"connection",intensity:Gr(v.edge)||M?1:Math.min(1,.55+(v.edge.weight??0)*.45)}),g=_.id}if(p.length<i){const b=p[p.length-1].nodeId,v=l.filter(_=>_.id!==b).sort((_,M)=>In(M)-In(_))[0];v&&!p.some(_=>_.nodeId===v.id)&&p.push({nodeId:v.id,node:v,viaEdge:null,kind:"recent",intensity:.8})}return{beats:p,centerId:c,pivoted:d,flowEdges:m}}var ap=vt('<span class="hidden lg:inline text-[#ffffff]/[0.5] whitespace-nowrap"> </span>'),op=vt('<span class="text-[#a6dcff] tracking-widest whitespace-nowrap">CAPTURE</span>'),hp=vt('<span class="text-[#5dcaa5] whitespace-nowrap w-[6ch] text-right"> </span>'),lp=vt('<div class="absolute top-0 left-0 right-0 z-20 pointer-events-none" style="padding-top: env(safe-area-inset-top);"><div class="flex items-center justify-between gap-3 px-4 py-2 bg-gradient-to-b from-[#05060a]/85 to-transparent font-mono text-xs [font-variant-numeric:tabular-nums]"><div class="flex items-center gap-3 min-w-0 flex-1 overflow-hidden"><span class="text-[#5dcaa5] tracking-widest uppercase truncate"> </span> <span class="hidden md:inline text-[#ffffff]/[0.5] whitespace-nowrap"> </span></div> <div class="hidden sm:flex items-center gap-4"><span class="text-[#ffffff]/[0.55] whitespace-nowrap"> </span> <!></div> <div class="flex items-center gap-3"><span class="text-[#ffffff]/[0.55] whitespace-nowrap"> </span> <!> <button class="text-[#ffffff]/[0.5] hover:text-[#5dcaa5] transition-colors cursor-pointer pointer-events-auto whitespace-nowrap" title="Copy shareable demo URL">[url]</button></div></div></div>');function cp(l,t){Wn(t,!0);let e=ut(t,"demoMode",3,"recall-path"),i=ut(t,"seed",3,"vestige-observatory-v1"),s=ut(t,"nodeCount",3,0),n=ut(t,"edgeCount",3,0),r=ut(t,"centerId",3,""),a=ut(t,"frameCount",3,0),o=ut(t,"fpsEstimate",3,0),h=ut(t,"freezeFrame",3,null);ut(t,"loading",3,!1),ut(t,"error",3,"");function c(){const L=new URLSearchParams({demo:e(),seed:i()});h()!==null&&L.set("frame",String(h()));const I=`${window.location.origin}${ec}/observatory?${L.toString()}`;navigator.clipboard.writeText(I).catch(()=>{})}var u=lp(),d=ot(u),f=ot(d),p=ot(f),m=ot(p,!0);at(p);var g=ct(p,2),x=ot(g);at(g),at(f);var y=ct(f,2),b=ot(y),v=ot(b);at(b);var _=ct(b,2);{var M=L=>{var I=ap(),U=ot(I);at(I),jt(wt=>Ot(U,`center=${wt??""}`),[()=>r().slice(0,8)]),mt(L,I)};_t(_,L=>{r()&&L(M)})}at(y);var A=ct(y,2),S=ot(A),T=ot(S);at(S);var C=ct(S,2);{var P=L=>{var I=op();mt(L,I)},V=L=>{var I=hp(),U=ot(I);at(I),jt(()=>Ot(U,`${o()??""}fps`)),mt(L,I)};_t(C,L=>{h()!==null?L(P):o()>0&&L(V,1)})}var q=ct(C,2);at(A),at(d),at(u),jt((L,I)=>{Ot(m,e()),Ot(x,`seed=${L??""}${i().length>12?"…":""}`),Ot(v,`${s()??""} nodes · ${n()??""} edges`),Ot(T,`frame: ${I??""}`)},[()=>i().slice(0,12),()=>String(a()).padStart(3," ")]),Ri("click",q,c),mt(l,u),Hn()}Rh(["click"]);var up=vt('<div class="active-label svelte-8n8iia"> </div>'),dp=vt("<div></div>"),fp=vt('<div class="spine svelte-8n8iia"><!> <div class="track svelte-8n8iia"><!> <div class="playhead svelte-8n8iia"></div></div></div>');function pp(l,t){Wn(t,!0);let e=ut(t,"steps",19,()=>[]),i=ut(t,"frame",3,0),s=ut(t,"loopFrames",3,720);const n=u=>u/s()*100;function r(u,d){const f=d-u;return f<-14||f>90?0:f<0?1+f/14:1-f/90}let a=Bn(()=>{let u="",d=.15;for(const f of e()){const p=r(f.beatFrame,i());p>d&&(d=p,u=f.label)}return u});var o=Ph(),h=Fh(o);{var c=u=>{var d=fp(),f=ot(d);{var p=y=>{var b=up(),v=ot(b,!0);at(b),jt(()=>Ot(v,F(a))),mt(y,b)};_t(f,y=>{F(a)&&y(p)})}var m=ct(f,2),g=ot(m);Eh(g,17,e,y=>y.beatFrame,(y,b)=>{var v=dp();let _;jt((M,A,S)=>{_=vs(v,1,"tick svelte-8n8iia",null,_,M),Hr(v,`left: ${A??""}%; opacity: ${S??""}`),Cn(v,"title",F(b).label)},[()=>({hot:r(F(b).beatFrame,i())>0,backward:F(b).kind===1}),()=>n(F(b).beatFrame),()=>.45+.55*r(F(b).beatFrame,i())]),mt(y,v)});var x=ct(g,2);at(m),at(d),jt(y=>Hr(x,`left: ${y??""}%`),[()=>n(i())]),mt(u,d)};_t(h,u=>{e().length>0&&u(c)})}mt(l,o),Hn()}var mp=vt('<div><div class="k svelte-ssd7yu"> </div> <div class="v svelte-ssd7yu"> </div> <div class="s svelte-ssd7yu"> </div></div>');function xh(l,t){Wn(t,!0);let e=ut(t,"frame",3,0),i=ut(t,"fadeWindow",19,()=>[600,620,705,719]),s=ut(t,"tone",3,"triumph");const n=(c,u,d)=>{const f=Math.min(1,Math.max(0,(d-c)/(u-c)));return f*f*(3-2*f)};let r=Bn(()=>n(i()[0],i()[1],e())*(1-n(i()[2],i()[3],e())));var a=Ph(),o=Fh(a);{var h=c=>{var u=mp();let d;var f=ot(u),p=ot(f,!0);at(f);var m=ct(f,2),g=ot(m,!0);at(m);var x=ct(m,2),y=ot(x,!0);at(x),at(u),jt(()=>{d=vs(u,1,"verdict svelte-ssd7yu",null,d,{quarantine:s()==="quarantine"}),Hr(u,`opacity: ${F(r)??""}`),Ot(p,t.verdict.headline),Ot(g,t.verdict.causeLabel),Ot(y,t.verdict.receipt)}),mt(c,u)};_t(o,c=>{F(r)>.001&&c(h)})}mt(l,a),Hn()}function bh(l){const t=/^#?([0-9a-fA-F]{6})$/.exec(l.trim());if(!t)return[107/255,114/255,128/255];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function gp(l){const t=vl({tags:l.tags});return bh(t||bl[xl(l.retention)])}function yp(l){const e=[...l.nodes].sort((r,a)=>r.isCenter!==a.isCenter?r.isCenter?-1:1:r.id<a.id?-1:r.id>a.id?1:0).map((r,a)=>ic(r,a)),i=new Map;for(const r of e)i.set(r.id,r.index);const s=[];for(const r of l.edges){const a=i.get(r.source),o=i.get(r.target);a===void 0||o===void 0||a===o||s.push({sourceIndex:a,targetIndex:o,weight:r.weight,type:r.type})}const n=e.findIndex(r=>r.isCenter);return{nodes:e,edges:s,indexById:i,centerIndex:n<0?0:n}}function wl(l,t,e=120){const i=l.nodes.length,s=new Float32Array(i*Mt);for(let n=0;n<i;n++){const r=l.nodes[n],a=n*Mt,[o,h,c]=r.isCenter&&l.centerIndex===n?[0,0,0]:Oh(n,i,e,t),u=r.isCenter?4.2:1.4+r.retention*1.8;s[a+me.posRadius+0]=o,s[a+me.posRadius+1]=h,s[a+me.posRadius+2]=c,s[a+me.posRadius+3]=u,s[a+me.velRetention+3]=r.retention;const[d,f,p]=gp(r);let m=0;r.isCenter&&(m|=Ki.isCenter),r.suppressed&&(m|=Ki.suppressed);const g=new Set(r.tags.map(x=>x.toLowerCase()));g.has("aha")&&(m|=Ki.isAha),(g.has("failure")||g.has("guardrail"))&&(m|=Ki.isFailure),(g.has("confusion")||g.has("weak-spot"))&&(m|=Ki.isConfusion),s[a+me.colorFlags+0]=d,s[a+me.colorFlags+1]=f,s[a+me.colorFlags+2]=p,s[a+me.colorFlags+3]=m}return{data:s,nodeCount:i}}function vh(l){const t=new Uint32Array(Math.max(1,l.edges.length)*ir);return l.edges.forEach((e,i)=>{t[i*ir]=e.sourceIndex,t[i*ir+1]=e.targetIndex}),t}const xp=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Camera {
|
||
view_proj: mat4x4<f32>,
|
||
right: vec4<f32>,
|
||
up: vec4<f32>,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<uniform> camera: Camera;
|
||
@group(0) @binding(2) var<storage, read> nodes: array<Node>;
|
||
|
||
// Iridescent thin-film band — ported EXACTLY from causal-brain-demo.html
|
||
// spectral(w) (visual DNA §7.1): indigo → cyan-teal → mint → magenta rim,
|
||
// wrapping. Activation glow rides this band; base color stays FSRS state.
|
||
fn spectral(w_in: f32) -> vec3<f32> {
|
||
let w = fract(w_in);
|
||
// var, not let: WGSL only allows dynamic indexing through a reference.
|
||
var stops = array<vec3<f32>, 4>(
|
||
vec3<f32>(0.20, 0.28, 0.95), // indigo
|
||
vec3<f32>(0.20, 0.85, 0.90), // cyan-teal
|
||
vec3<f32>(0.45, 1.00, 0.72), // mint
|
||
vec3<f32>(0.85, 0.45, 1.00) // magenta rim
|
||
);
|
||
let f = w * 4.0;
|
||
let i = u32(floor(f)) % 4u;
|
||
let frac = f - floor(f);
|
||
let a = stops[i];
|
||
let b = stops[(i + 1u) % 4u];
|
||
return mix(a, b, frac);
|
||
}
|
||
|
||
struct VSOut {
|
||
@builtin(position) clip: vec4<f32>,
|
||
@location(0) uv: vec2<f32>,
|
||
// Per-instance constants: flat interpolation guarantees the flag bit
|
||
// field survives the raster stage bit-exact (no barycentric rounding).
|
||
@location(1) @interpolate(flat) color: vec3<f32>,
|
||
// x retention, y flags (bit field as f32), z recall intensity, w radius
|
||
@location(2) @interpolate(flat) misc: vec4<f32>,
|
||
// Per-demo choreography lanes (demo.y, demo.z, demo.w), gated by demo_id:
|
||
// rescue (2) searchlight/wave/shock, forgetting-horizon (3) fade-and-fall,
|
||
// firewall (4) flare-membrane/shock. Each demo's choreography pass is the
|
||
// ONLY writer of its lanes, and every gated term below is an exact no-op
|
||
// when its lane is 0.0 — other demos stay pixel-identical.
|
||
@location(3) @interpolate(flat) demo_yzw: vec3<f32>,
|
||
};
|
||
|
||
// Quad corners for two triangles (vertex_index 0..5).
|
||
const CORNERS = array<vec2<f32>, 6>(
|
||
vec2<f32>(-1.0, -1.0),
|
||
vec2<f32>( 1.0, -1.0),
|
||
vec2<f32>( 1.0, 1.0),
|
||
vec2<f32>(-1.0, -1.0),
|
||
vec2<f32>( 1.0, 1.0),
|
||
vec2<f32>(-1.0, 1.0)
|
||
);
|
||
|
||
@vertex
|
||
fn vs_main(
|
||
@builtin(vertex_index) vi: u32,
|
||
@builtin(instance_index) ii: u32
|
||
) -> VSOut {
|
||
var out: VSOut;
|
||
if (ii >= u32(params.node_count)) {
|
||
// degenerate — clipped away
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
return out;
|
||
}
|
||
|
||
let node = nodes[ii];
|
||
let corner = CORNERS[vi];
|
||
|
||
// Breath: halo geometry swells ~6% on the global pulse (§7.2), and the
|
||
// center memory breathes a touch deeper — a heartbeat, not a strobe.
|
||
let flags = u32(node.color_flags.w);
|
||
let is_center = (flags & 1u) != 0u;
|
||
var breath = 1.0 + 0.06 * params.pulse;
|
||
if (is_center) {
|
||
breath = 1.0 + 0.12 * params.pulse;
|
||
}
|
||
|
||
// Sprite spans ~3.2× the core radius so the halo has room to feather out.
|
||
// Recall activation swells the sprite — the wavefront physically blooms.
|
||
// Per-demo choreography lanes swell it too, gated by demo_id so each
|
||
// demo's grammar can never leak into another (lanes are 0.0 elsewhere,
|
||
// and the gate makes the no-op structural, not just numerical).
|
||
let recall = node.demo.x;
|
||
let dy = node.demo.y;
|
||
let dz = node.demo.z;
|
||
let dw = node.demo.w;
|
||
// The firewall grammar fires for the deterministic demo (demo_id==4) AND for
|
||
// a LIVE contradiction/suppression event (live_kind==1). Both write the same
|
||
// demo lanes (firewall.wgsl), so the visual reads identically either way.
|
||
let firewall_active = params.demo_id == 4.0 || params.live_kind == 1.0;
|
||
var lane_swell = 0.0;
|
||
if (params.demo_id == 2.0) {
|
||
// salience-rescue: searchlight pop, wave shiver, shock bloom.
|
||
lane_swell = 0.5 * dy + 0.25 * dz + 0.9 * dw;
|
||
} else if (firewall_active) {
|
||
// firewall: intrusion flare pop (band (0..1]), membrane presence
|
||
// (band [2.6..2.9] via the range gate), crimson shock bloom.
|
||
lane_swell = 0.35 * min(dy, 1.0) + 0.3 * smoothstep(1.5, 2.2, dy) + 0.55 * dw;
|
||
}
|
||
// forgetting-horizon (demo 3): VISUAL displacement toward the horizon —
|
||
// down and away from the field axis, ~40.5 units at dz = 1 — plus a
|
||
// shrink. pos_radius is NEVER written (the force sim owns positions);
|
||
// drift is pure of demo.z, so ?frame=N capture stays exact. CPU mirror:
|
||
// forgetting-plan.ts horizonDrift().
|
||
var horizon_scale = 1.0;
|
||
var drift = vec3<f32>(0.0);
|
||
if (params.demo_id == 3.0) {
|
||
let dzc = clamp(dz, 0.0, 1.0);
|
||
horizon_scale = 1.0 - 0.35 * dzc;
|
||
if (dz > 0.0) {
|
||
let p = node.pos_radius.xyz;
|
||
let r_xz = max(length(p.xz), 0.001);
|
||
let away = vec3<f32>(p.x / r_xz, 0.0, p.z / r_xz);
|
||
drift = dzc * (vec3<f32>(0.0, -34.0, 0.0) + away * 22.0);
|
||
}
|
||
}
|
||
let half_size = node.pos_radius.w * 3.2 * breath * (1.0 + 0.9 * recall)
|
||
* (1.0 + lane_swell) * horizon_scale;
|
||
let world = node.pos_radius.xyz + drift
|
||
+ camera.right.xyz * corner.x * half_size
|
||
+ camera.up.xyz * corner.y * half_size;
|
||
|
||
out.clip = camera.view_proj * vec4<f32>(world, 1.0);
|
||
out.uv = corner;
|
||
out.color = node.color_flags.rgb;
|
||
out.misc = vec4<f32>(node.vel_retention.w, node.color_flags.w, node.demo.x, node.pos_radius.w);
|
||
out.demo_yzw = vec3<f32>(dy, dz, dw);
|
||
return out;
|
||
}
|
||
|
||
@fragment
|
||
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
||
let d = length(in.uv);
|
||
if (d > 1.0) {
|
||
discard;
|
||
}
|
||
|
||
let retention = in.misc.x;
|
||
let flags = u32(in.misc.y);
|
||
let suppressed = (flags & 2u) != 0u;
|
||
let is_center = (flags & 1u) != 0u;
|
||
|
||
// Soft sprite: hot core + feathered halo. The halo rides the breath pulse.
|
||
let core = smoothstep(0.22, 0.0, d);
|
||
let halo = pow(max(1.0 - d, 0.0), 2.4);
|
||
var intensity = core * 1.35 + halo * (0.42 + 0.18 * params.pulse);
|
||
|
||
// Meaning layer: low-retention memories glow dimmer (drifting toward the
|
||
// horizon), the center anchor reads brightest.
|
||
intensity = intensity * (0.45 + 0.55 * retention);
|
||
if (is_center) {
|
||
intensity = intensity * 1.6;
|
||
}
|
||
if (suppressed) {
|
||
intensity = intensity * 0.28;
|
||
}
|
||
|
||
var color = in.color * intensity;
|
||
|
||
// Forgetting-horizon (demo 3): multiplicative dim toward near-black as
|
||
// demo.z rises. Floor 0.06 — never fully gone, always retrievable. Sits
|
||
// BEFORE the recall block so a rescued memory's ignition burns through
|
||
// the fade. demo_yzw.y carries demo.z (vec3 = y/z/w lanes).
|
||
if (params.demo_id == 3.0) {
|
||
color = color * mix(1.0, 0.06, clamp(in.demo_yzw.y, 0.0, 1.0));
|
||
}
|
||
|
||
// Recall activation (§7.1): the thin-film band takes over as the wave
|
||
// lands. Hue drifts exactly ONE full spectral cycle per 720-frame loop
|
||
// (loop_phase wraps 0→1 and spectral() fract-wraps) — oil-slick shimmer
|
||
// with a mathematically invisible loop seam.
|
||
let recall = in.misc.z;
|
||
if (recall > 0.001) {
|
||
let band = spectral(0.1 + params.loop_phase + d * 0.35);
|
||
let activation = band * recall * (core * 1.7 + halo * 0.9);
|
||
// white-hot pinpoint at full ignition
|
||
let flash = vec3<f32>(1.0, 1.0, 1.0) * core * recall * 0.55;
|
||
color = color + activation + flash;
|
||
}
|
||
|
||
// Per-demo choreography lanes — gated by demo_id AND on nonzero values so
|
||
// every other demo is pixel-unchanged (each demo's pass is the only
|
||
// writer of its lanes, and lanes are exactly 0.0 everywhere else).
|
||
if (params.demo_id == 2.0) {
|
||
if (in.demo_yzw.x > 0.001) {
|
||
// Searchlight: cold clinical white — unmistakably NOT the spectral grammar.
|
||
color = color + vec3<f32>(0.82, 0.90, 1.00) * in.demo_yzw.x * (core * 1.8 + halo * 0.7);
|
||
}
|
||
if (in.demo_yzw.y > 0.001) {
|
||
// Interrogation shimmer: icy spectral strobe as the wave scrubs the past.
|
||
color = color + spectral(0.55 + params.loop_phase) * in.demo_yzw.y * (core * 0.9 + halo * 0.5)
|
||
+ vec3<f32>(1.0) * core * in.demo_yzw.y * 0.2;
|
||
}
|
||
if (in.demo_yzw.z > 0.001) {
|
||
// Detonation: crimson blaze + warm-white pinpoint.
|
||
color = color + vec3<f32>(1.00, 0.16, 0.10) * in.demo_yzw.z * (core * 1.9 + halo * 1.1)
|
||
+ vec3<f32>(1.0, 0.85, 0.8) * core * in.demo_yzw.z * 0.4;
|
||
}
|
||
} else if (params.demo_id == 4.0 || params.live_kind == 1.0) {
|
||
// firewall: demo.y carries TWO value bands — intrusion flare (0..1]
|
||
// and membrane [2.6..2.9] — separated by range, one lane. demo.w is
|
||
// the crimson shock rim / sever blink. (demo_yzw = y/z/w lanes.)
|
||
let fy = in.demo_yzw.x;
|
||
let fw = in.demo_yzw.z;
|
||
// Intrusion flare: sickly green-white — a hue deliberately OUTSIDE
|
||
// both the FSRS palette and the thin-film band. Continuous across the
|
||
// band boundary (fades out as fy climbs toward the membrane band).
|
||
let flare = min(fy, 1.0) * (1.0 - smoothstep(1.0, 1.8, fy));
|
||
if (flare > 0.001) {
|
||
color = color + vec3<f32>(0.62, 1.00, 0.55) * flare * (core * 1.7 + halo * 0.9)
|
||
+ vec3<f32>(0.90, 1.00, 0.85) * core * flare * 0.5;
|
||
}
|
||
// Membrane: quarantine ring at d ≈ 0.75 with fresnel-ish falloff —
|
||
// green body, crimson edge. exp(-q·q) squares by multiplication and
|
||
// the pow base is clamped ≥ 0 (no pow(neg) anywhere).
|
||
let mw = smoothstep(1.5, 2.2, fy);
|
||
if (mw > 0.001) {
|
||
let q = (d - 0.75) * 9.0;
|
||
let ring = exp(-q * q);
|
||
let fresnel = pow(clamp(d / 0.75, 0.0, 1.0), 3.0);
|
||
let ring_col = mix(vec3<f32>(0.55, 1.00, 0.60), vec3<f32>(1.00, 0.20, 0.16),
|
||
smoothstep(0.72, 0.92, d));
|
||
color = color + ring_col * ring * fresnel * mw * 1.4;
|
||
}
|
||
// Shockwave: crimson RIM as the front passes (a rim, not a blaze).
|
||
if (fw > 0.001) {
|
||
let rim = smoothstep(0.45, 0.8, d) * (1.0 - smoothstep(0.85, 1.0, d));
|
||
color = color + vec3<f32>(1.00, 0.14, 0.10) * rim * fw * 1.5
|
||
+ vec3<f32>(1.00, 0.60, 0.50) * core * fw * 0.15;
|
||
}
|
||
}
|
||
|
||
// Additive target (src=one, dst=one): alpha is ignored, light accumulates.
|
||
return vec4<f32>(color * params.brightness, 1.0);
|
||
}
|
||
`,bp=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage, read_write> nodes: array<Node>;
|
||
// x source index, y target index, z beat frame, w kind (0 recall, 1 backward)
|
||
@group(0) @binding(2) var<storage, read> path: array<vec4<u32>>;
|
||
// x source index, y target node index (Increment 7: force simulation edges)
|
||
@group(0) @binding(3) var<storage, read> edges: array<vec2<u32>>;
|
||
// v2.3 living field — per-node LIVE retrievability (real FSRS curve, recomputed
|
||
// on the CPU by the LiveBridge). One f32 per node. read to overwrite
|
||
// vel_retention.w so render-nodes dims each memory on its true forgetting curve.
|
||
@group(0) @binding(4) var<storage, read> live_retention: array<f32>;
|
||
|
||
// --- Force-simulation helpers (Increment 7) ---
|
||
|
||
fn safe_normalize(v: vec3<f32>) -> vec3<f32> {
|
||
let l = length(v);
|
||
if (l < 0.0001) { return vec3<f32>(0.0); }
|
||
return v / l;
|
||
}
|
||
|
||
fn clamp_len(v: vec3<f32>, hi: f32) -> vec3<f32> {
|
||
let l = length(v);
|
||
if (l > hi && l > 0.0001) { return v * (hi / l); }
|
||
return v;
|
||
}
|
||
|
||
@compute @workgroup_size(64)
|
||
fn recall_sim(@builtin(global_invocation_id) id: vec3<u32>) {
|
||
let i = id.x;
|
||
if (i >= u32(params.node_count)) {
|
||
return;
|
||
}
|
||
|
||
let frame = params.frame;
|
||
var intensity = 0.0;
|
||
|
||
let steps = u32(params.path_count);
|
||
for (var s = 0u; s < steps; s = s + 1u) {
|
||
let step = path[s];
|
||
let bf = f32(step.z);
|
||
|
||
if (step.y == i) {
|
||
// Arrival: sharp attack as the wavefront lands, slow afterglow.
|
||
let attack = smoothstep(bf - 14.0, bf + 4.0, frame);
|
||
let decay = 1.0 - smoothstep(bf + 40.0, bf + 200.0, frame);
|
||
intensity = max(intensity, attack * decay);
|
||
}
|
||
if (step.x == i && step.x != step.y) {
|
||
// Departure: the source shimmers as the wave leaves it.
|
||
let rise = smoothstep(bf - 55.0, bf - 30.0, frame);
|
||
let fall = 1.0 - smoothstep(bf + 10.0, bf + 70.0, frame);
|
||
intensity = max(intensity, rise * fall * 0.45);
|
||
}
|
||
}
|
||
|
||
var node = nodes[i];
|
||
let flags = u32(node.color_flags.w);
|
||
let is_center = (flags & 1u) != 0u;
|
||
|
||
// Write recall intensity (existing behavior preserved).
|
||
node.demo.x = intensity;
|
||
|
||
// v2.3 LIVE FSRS decay — overwrite retention with the real forgetting-curve
|
||
// value the LiveBridge computed for this node on the CPU. This is the #1
|
||
// moat: render-nodes already dims by vel_retention.w (line ~183), so writing
|
||
// the true retrievability here makes every memory visibly forget on its own
|
||
// curve. Guarded so a graph with no live-decay data (all zeros) keeps its
|
||
// static snapshot instead of collapsing to black.
|
||
if (i < arrayLength(&live_retention)) {
|
||
let lr = live_retention[i];
|
||
if (lr > 0.0) {
|
||
node.vel_retention = vec4<f32>(node.vel_retention.xyz, lr);
|
||
}
|
||
}
|
||
|
||
// --- Increment 7: force simulation ---
|
||
|
||
// Capture mode (params.capture_mode == 1.0): skip physics integration
|
||
// entirely. The storage-buffer state stays frozen at initial upload
|
||
// values, making same URL + frame → identical pixels (spec §4 Inc 9).
|
||
if (params.capture_mode == 0.0) {
|
||
// 7B: center anchor — center node never moves.
|
||
// (WGSL forbids swizzle stores — reconstruct the vec4, preserving .w.)
|
||
if (is_center) {
|
||
node.pos_radius = vec4<f32>(0.0, 0.0, 0.0, node.pos_radius.w);
|
||
node.vel_retention = vec4<f32>(0.0, 0.0, 0.0, node.vel_retention.w);
|
||
nodes[i] = node;
|
||
return;
|
||
}
|
||
|
||
let pos = node.pos_radius.xyz;
|
||
var force = vec3<f32>(0.0);
|
||
|
||
// 7C: edge springs — scan existing edgeBuffer, no atomics.
|
||
for (var e = 0u; e < u32(params.edge_count); e = e + 1u) {
|
||
let edge = edges[e];
|
||
var other_idx = 0xffffffffu;
|
||
if (edge.x == i) { other_idx = edge.y; }
|
||
if (edge.y == i) { other_idx = edge.x; }
|
||
if (other_idx != 0xffffffffu && other_idx < u32(params.node_count)) {
|
||
let other = nodes[other_idx].pos_radius.xyz;
|
||
let delta = other - pos;
|
||
let dist = max(length(delta), 0.001);
|
||
let dir = delta / dist;
|
||
let stretch = dist - 34.0;
|
||
force = force + dir * stretch * 0.00055;
|
||
}
|
||
}
|
||
|
||
// 7D: soft repulsion (only ≤ 500 nodes for performance).
|
||
if (u32(params.node_count) <= 500u) {
|
||
for (var j = 0u; j < u32(params.node_count); j = j + 1u) {
|
||
if (j == i) { continue; }
|
||
let other = nodes[j].pos_radius.xyz;
|
||
let delta = pos - other;
|
||
let d2 = max(dot(delta, delta), 9.0);
|
||
force = force + safe_normalize(delta) * (7.5 / d2);
|
||
}
|
||
}
|
||
|
||
// Gentle centering: keeps the field in frame without crushing it.
|
||
force = force + (-pos) * 0.0008;
|
||
|
||
// v2.3 DREAM STORM — while the real dream pipeline streams (live_kind ==
|
||
// 2 == LIVE_KIND.dreamStorm), the field enters a metabolic consolidation
|
||
// storm: damping loosens (springs overshoot, clusters slosh together as
|
||
// new ConnectionDiscovered edges are appended) and a deterministic
|
||
// turbulence rides live_energy. Pure of node index + live_frame, so no
|
||
// wall clock — the storm is a function of the real event envelope. At
|
||
// rest (energy 0) both terms vanish → the field is byte-identical.
|
||
var damping = 0.88;
|
||
if (params.live_kind == 2.0) {
|
||
let e = clamp(params.live_energy, 0.0, 1.4);
|
||
damping = 0.88 + 0.09 * e; // up to ~0.97 — longer, sloshier settling
|
||
// Curl-free deterministic jitter: phase from node index + live_frame.
|
||
let ph = f32(i) * 0.61803 + params.live_frame * 0.05;
|
||
let jitter = vec3<f32>(sin(ph * 6.2831), sin(ph * 4.7123 + 1.3), sin(ph * 5.318 + 2.1));
|
||
force = force + jitter * (0.006 * e);
|
||
}
|
||
|
||
// 7B: velocity damping + cap, then position integration.
|
||
var vel = node.vel_retention.xyz;
|
||
vel = (vel + force) * damping;
|
||
vel = clamp_len(vel, 0.42);
|
||
node.vel_retention = vec4<f32>(vel, node.vel_retention.w);
|
||
node.pos_radius = vec4<f32>(pos + vel, node.pos_radius.w);
|
||
}
|
||
// When capture_mode (params.capture_mode == 1.0), node is NOT written back —
|
||
// the storage buffer retains its initial upload values, guaranteeing
|
||
// deterministic pixels for the same frame index.
|
||
nodes[i] = node;
|
||
}
|
||
`,_l=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Camera {
|
||
view_proj: mat4x4<f32>,
|
||
right: vec4<f32>,
|
||
up: vec4<f32>,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<uniform> camera: Camera;
|
||
@group(0) @binding(2) var<storage, read> nodes: array<Node>;
|
||
// x source index, y target index, z beat frame, w kind (0 recall, 1 backward)
|
||
@group(0) @binding(3) var<storage, read> path: array<vec4<u32>>;
|
||
|
||
// Same thin-film band as the node shader (§7.1).
|
||
fn spectral(w_in: f32) -> vec3<f32> {
|
||
let w = fract(w_in);
|
||
// var, not let: WGSL only allows dynamic indexing through a reference.
|
||
var stops = array<vec3<f32>, 4>(
|
||
vec3<f32>(0.20, 0.28, 0.95),
|
||
vec3<f32>(0.20, 0.85, 0.90),
|
||
vec3<f32>(0.45, 1.00, 0.72),
|
||
vec3<f32>(0.85, 0.45, 1.00)
|
||
);
|
||
let f = w * 4.0;
|
||
let i = u32(floor(f)) % 4u;
|
||
let frac = f - floor(f);
|
||
let a = stops[i];
|
||
let b = stops[(i + 1u) % 4u];
|
||
return mix(a, b, frac);
|
||
}
|
||
|
||
struct VSOut {
|
||
@builtin(position) clip: vec4<f32>,
|
||
// x: t along segment (0 source → 1 target), y: side (-1..1)
|
||
@location(0) uv: vec2<f32>,
|
||
// x: beat frame, y: kind, z: segment visible (0 skips degenerate steps)
|
||
// Per-instance constant — flat keeps it bit-exact through the raster.
|
||
@location(1) @interpolate(flat) beat: vec3<f32>,
|
||
};
|
||
|
||
// (t, side) corners for two triangles of the ribbon.
|
||
const RIBBON = array<vec2<f32>, 6>(
|
||
vec2<f32>(0.0, -1.0),
|
||
vec2<f32>(1.0, -1.0),
|
||
vec2<f32>(1.0, 1.0),
|
||
vec2<f32>(0.0, -1.0),
|
||
vec2<f32>(1.0, 1.0),
|
||
vec2<f32>(0.0, 1.0)
|
||
);
|
||
|
||
@vertex
|
||
fn vs_main(
|
||
@builtin(vertex_index) vi: u32,
|
||
@builtin(instance_index) ii: u32
|
||
) -> VSOut {
|
||
var out: VSOut;
|
||
if (ii >= u32(params.path_count)) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
out.beat = vec3<f32>(0.0);
|
||
return out;
|
||
}
|
||
|
||
let step = path[ii];
|
||
let src = nodes[step.x];
|
||
let dst = nodes[step.y];
|
||
let corner = RIBBON[vi];
|
||
|
||
// Degenerate (origin beat: source == target) — emit nothing visible.
|
||
if (step.x == step.y) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
out.beat = vec3<f32>(0.0);
|
||
return out;
|
||
}
|
||
|
||
let a = camera.view_proj * vec4<f32>(src.pos_radius.xyz, 1.0);
|
||
let b = camera.view_proj * vec4<f32>(dst.pos_radius.xyz, 1.0);
|
||
|
||
// NDC-space perpendicular for constant screen width.
|
||
let ndc_a = a.xy / max(a.w, 0.0001);
|
||
let ndc_b = b.xy / max(b.w, 0.0001);
|
||
var dir = ndc_b - ndc_a;
|
||
let dlen = max(length(dir), 0.0001);
|
||
dir = dir / dlen;
|
||
let perp = vec2<f32>(-dir.y, dir.x);
|
||
|
||
// Ribbon half-width in NDC (aspect-corrected), ~2.5 px on a 900px-tall view.
|
||
let px = 2.5 / max(params.viewport_h, 1.0) * 2.0;
|
||
let width = vec2<f32>(px * (params.viewport_h / max(params.viewport_w, 1.0)), px);
|
||
|
||
let base = mix(a, b, corner.x);
|
||
let offset = perp * width * corner.y * base.w;
|
||
out.clip = vec4<f32>(base.xy + offset, base.zw);
|
||
out.uv = vec2<f32>(corner.x, corner.y);
|
||
out.beat = vec3<f32>(f32(step.z), f32(step.w), 1.0);
|
||
return out;
|
||
}
|
||
|
||
@fragment
|
||
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
||
if (in.beat.z < 0.5) {
|
||
discard;
|
||
}
|
||
|
||
let frame = params.frame;
|
||
let bf = in.beat.x;
|
||
let t = in.uv.x;
|
||
|
||
// Wave departs 45 frames before the beat and lands exactly on it.
|
||
let progress = clamp((frame - (bf - 45.0)) / 45.0, 0.0, 1.0);
|
||
// Nothing before departure; trail lingers ~90 frames after arrival.
|
||
let live = smoothstep(bf - 46.0, bf - 44.0, frame)
|
||
* (1.0 - smoothstep(bf + 40.0, bf + 90.0, frame));
|
||
if (live <= 0.001) {
|
||
discard;
|
||
}
|
||
|
||
// The light packet: gaussian around the wavefront position.
|
||
let dwave = (t - progress) * 14.0;
|
||
let packet = exp(-dwave * dwave);
|
||
|
||
// Fading trail behind the packet — provenance stays visible a beat.
|
||
var trail = 0.0;
|
||
if (t < progress) {
|
||
trail = (1.0 - (progress - t)) * 0.22;
|
||
}
|
||
|
||
// Feather across the ribbon width.
|
||
let across = 1.0 - abs(in.uv.y);
|
||
let profile = across * across;
|
||
|
||
// Backward/contradiction hops burn hotter into the magenta rim (§7.4).
|
||
// Hue drifts one full spectral cycle per loop (seamless at the wrap).
|
||
// Kind 2 (salience-rescue probe): a gray failing beam — vector search
|
||
// visibly probing lookalikes and coming back empty. Kinds 0/1 unchanged.
|
||
var band = spectral(0.15 + t * 0.35 + params.loop_phase);
|
||
var packet_white = 0.35;
|
||
if (in.beat.y > 1.5) {
|
||
band = vec3<f32>(0.62, 0.66, 0.72);
|
||
packet_white = 0.18;
|
||
} else if (in.beat.y > 0.5) {
|
||
band = mix(band, vec3<f32>(1.0, 0.25, 0.45), 0.55);
|
||
}
|
||
|
||
let energy = (packet * 1.6 + trail) * profile * live;
|
||
let color = band * energy + vec3<f32>(1.0) * packet * profile * live * packet_white;
|
||
return vec4<f32>(color * params.brightness, 1.0);
|
||
}
|
||
`;function vp(l){return 60+l*60}function Ml(l,t,e=8,i={}){var c;const s=[...l.nodes].sort((u,d)=>u.id<d.id?-1:u.id>d.id?1:0),n=[...l.edges].sort((u,d)=>{const f=`${u.source}\0${u.target}\0${u.type}`,p=`${d.source}\0${d.target}\0${d.type}`;return f<p?-1:f>p?1:0}),r=i.centerId??l.center_id,a=rp(s,n,r,e,{preferCausal:i.preferCausal}),o=[];for(let u=0;u<a.beats.length;u++){const d=a.beats[u],f=t.indexById.get(d.nodeId);if(f===void 0)continue;const p=u>0?a.beats[u-1].nodeId:d.nodeId,m=t.indexById.get(p)??f,g=(((c=d.viaEdge)==null?void 0:c.type)??"").toLowerCase(),x=g==="causal"||g.includes("causal"),y=d.kind==="contradiction"||x;o.push({sourceIndex:m,targetIndex:f,beatFrame:vp(u),kind:y?ze.backwardCause:ze.recall,beatKind:d.kind,nodeId:d.nodeId,label:d.node.label})}const h=new Uint32Array(Math.max(1,o.length)*Qi);return o.forEach((u,d)=>{h[d*Qi]=u.sourceIndex,h[d*Qi+1]=u.targetIndex,h[d*Qi+2]=u.beatFrame,h[d*Qi+3]=u.kind}),{data:h,steps:o,path:a}}const wp=24,wh=300;class _p{constructor(t){z(this,"engine");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"cameraBuffer",null);z(this,"nodeBuffer",null);z(this,"edgeBuffer",null);z(this,"cameraData",new Float32Array(wp));z(this,"nodeCount",0);z(this,"simPipeline",null);z(this,"simBindGroup",null);z(this,"pathBuffer",null);z(this,"liveRetentionBuffer",null);z(this,"pathPipeline",null);z(this,"pathBindGroup",null);z(this,"pathStepCount",0);z(this,"graph",null);z(this,"pathSteps",[]);this.engine=t,t.addPass(this)}upload(t,e,i){var f,p,m,g;const s=this.engine.gpuDevice;if(!s)return;const n=(i==null?void 0:i.recallPath)??!0,r=yp(t);this.graph=r;const a=new ea({seed:e}),{data:o,nodeCount:h}=wl(r,a.state.rng);this.nodeCount=h,(f=this.nodeBuffer)==null||f.destroy(),this.nodeBuffer=s.createBuffer({label:"observatory-node-state",size:Math.max(o.byteLength,64),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC|GPUBufferUsage.VERTEX}),s.queue.writeBuffer(this.nodeBuffer,0,o.buffer);const c=vh(r);(p=this.edgeBuffer)==null||p.destroy(),this.edgeBuffer=s.createBuffer({label:"observatory-edge-index",size:c.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),s.queue.writeBuffer(this.edgeBuffer,0,c.buffer);const u=new Float32Array(Math.max(h,4));for(let x=0;x<h;x++)u[x]=r.nodes[x].retention;(m=this.liveRetentionBuffer)==null||m.destroy(),this.liveRetentionBuffer=s.createBuffer({label:"observatory-live-retention",size:u.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),s.queue.writeBuffer(this.liveRetentionBuffer,0,u.buffer);const d=n?Ml(t,r):{steps:[],data:new Uint32Array(4)};this.pathSteps=d.steps,(g=this.pathBuffer)==null||g.destroy(),this.pathBuffer=s.createBuffer({label:"observatory-path-steps",size:d.data.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),s.queue.writeBuffer(this.pathBuffer,0,d.data.buffer),this.pathStepCount=this.pathSteps.length,this.engine.params[2]=h,this.engine.params[3]=r.edges.length,this.engine.params[4]=this.pathSteps.length,this.cameraBuffer||(this.cameraBuffer=s.createBuffer({label:"observatory-camera",size:this.cameraData.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})),this.createPipeline(s)}setPathSteps(t,e){var s;const i=this.engine.gpuDevice;i&&(this.pathSteps=e,this.pathStepCount=e.length,(s=this.pathBuffer)==null||s.destroy(),this.pathBuffer=i.createBuffer({label:"observatory-path-steps",size:Math.max(t.byteLength,16),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),i.queue.writeBuffer(this.pathBuffer,0,t.buffer),this.engine.params[4]=e.length,this.createPipeline(i))}setEdges(t){var s;const e=this.engine.gpuDevice;if(!e||!this.graph)return;this.graph.edges=t;const i=vh(this.graph);(s=this.edgeBuffer)==null||s.destroy(),this.edgeBuffer=e.createBuffer({label:"observatory-edge-index",size:Math.max(i.byteLength,8),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.edgeBuffer,0,i.buffer),this.engine.params[3]=t.length,this.createPipeline(e)}uploadLiveRetention(t){const e=this.engine.gpuDevice;if(!e||!this.liveRetentionBuffer)return;const i=Math.min(t.length,this.nodeCount);i<=0||e.queue.writeBuffer(this.liveRetentionBuffer,0,t.buffer,0,i*4)}createPipeline(t){if(!this.engine.paramsBuffer||!this.cameraBuffer||!this.nodeBuffer)return;if(this.pathBuffer){const i=t.createShaderModule({label:"observatory-simulate",code:bp});this.simPipeline=t.createComputePipeline({label:"observatory-recall-sim",layout:"auto",compute:{module:i,entryPoint:"recall_sim"}});const s=[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeBuffer}},{binding:2,resource:{buffer:this.pathBuffer}}];this.edgeBuffer&&s.push({binding:3,resource:{buffer:this.edgeBuffer}}),this.liveRetentionBuffer&&s.push({binding:4,resource:{buffer:this.liveRetentionBuffer}}),this.simBindGroup=t.createBindGroup({label:"observatory-recall-sim-bind",layout:this.simPipeline.getBindGroupLayout(0),entries:s})}const e=t.createShaderModule({label:"observatory-render-nodes",code:xp});if(this.pipeline=t.createRenderPipeline({label:"observatory-nodes",layout:"auto",vertex:{module:e,entryPoint:"vs_main"},fragment:{module:e,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.bindGroup=t.createBindGroup({label:"observatory-nodes-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.cameraBuffer}},{binding:2,resource:{buffer:this.nodeBuffer}}]}),this.pathBuffer){const i=t.createShaderModule({label:"observatory-render-path",code:_l});this.pathPipeline=t.createRenderPipeline({label:"observatory-path",layout:"auto",vertex:{module:i,entryPoint:"vs_main"},fragment:{module:i,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.pathBindGroup=t.createBindGroup({label:"observatory-path-bind",layout:this.pathPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.cameraBuffer}},{binding:2,resource:{buffer:this.nodeBuffer}},{binding:3,resource:{buffer:this.pathBuffer}}]})}}compute(t){const e=this.engine.gpuDevice;if(!e||!this.cameraBuffer)return;const i=this.engine.params[6]||1,s=this.engine.params[7]||1,n=this.engine.params[1],r=Ya(n,i/s,wh);if(this.cameraData.set(r.viewProj,0),this.cameraData[16]=r.right[0],this.cameraData[17]=r.right[1],this.cameraData[18]=r.right[2],this.cameraData[19]=0,this.cameraData[20]=r.up[0],this.cameraData[21]=r.up[1],this.cameraData[22]=r.up[2],this.cameraData[23]=0,e.queue.writeBuffer(this.cameraBuffer,0,this.cameraData),this.simPipeline&&this.simBindGroup&&this.nodeCount>0){const a=t.beginComputePass({label:"observatory-recall-sim"});a.setPipeline(this.simPipeline),a.setBindGroup(0,this.simBindGroup),a.dispatchWorkgroups(Math.ceil(this.nodeCount/64)),a.end()}}render(t){!this.pipeline||!this.bindGroup||this.nodeCount===0||(t.setPipeline(this.pipeline),t.setBindGroup(0,this.bindGroup),t.draw(6,this.nodeCount),this.pathPipeline&&this.pathBindGroup&&this.pathStepCount>0&&(t.setPipeline(this.pathPipeline),t.setBindGroup(0,this.pathBindGroup),t.draw(6,this.pathStepCount)))}get nodeStateBuffer(){return this.nodeBuffer}get cameraUniformBuffer(){return this.cameraBuffer}get nodeCountValue(){return this.nodeCount}get pathStepMeta(){return this.pathSteps}async pickAt(t,e){const i=this.engine.gpuDevice;if(!i||!this.nodeBuffer||!this.graph||this.nodeCount===0)return null;const s=this.nodeCount*Mt*4,n=i.createBuffer({label:"observatory-pick-staging",size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),r=i.createCommandEncoder({label:"observatory-pick-copy"});r.copyBufferToBuffer(this.nodeBuffer,0,n,0,s),i.queue.submit([r.finish()]);let a;try{await n.mapAsync(GPUMapMode.READ),a=new Float32Array(n.getMappedRange().slice(0))}catch{return n.destroy(),null}n.unmap(),n.destroy();const o=this.engine.params[6]||1,h=this.engine.params[7]||1,c=this.engine.params[1],u=Ya(c,o/h,wh).viewProj,d=1/Math.tan(50*Math.PI/360);let f=-1,p=1/0;for(let m=0;m<this.nodeCount;m++){const g=m*Mt+me.posRadius,x=a[g],y=a[g+1],b=a[g+2],v=a[g+3],_=u[3]*x+u[7]*y+u[11]*b+u[15];if(_<=0)continue;const M=(u[0]*x+u[4]*y+u[8]*b+u[12])/_,A=(u[1]*x+u[5]*y+u[9]*b+u[13])/_,S=Math.max(v*d/_,.012),T=Math.hypot(M-t,A-e)/S;T<1.6&&T<p&&(p=T,f=m)}return f<0?null:{index:f,id:this.graph.nodes[f].id}}dispose(){var t,e,i,s,n;(t=this.nodeBuffer)==null||t.destroy(),(e=this.edgeBuffer)==null||e.destroy(),(i=this.cameraBuffer)==null||i.destroy(),(s=this.pathBuffer)==null||s.destroy(),(n=this.liveRetentionBuffer)==null||n.destroy(),this.nodeBuffer=null,this.edgeBuffer=null,this.cameraBuffer=null,this.pathBuffer=null,this.liveRetentionBuffer=null,this.pipeline=null,this.bindGroup=null,this.simPipeline=null,this.simBindGroup=null,this.pathPipeline=null,this.pathBindGroup=null}}const Tn=16,fs=4,_h=110,Mp=180,Sp=.7,Ap=.2,Ip=360,Tp=18;function Cp(l){if(l.edges.length>0){const t=l.centerIndex,e=l.edges.filter(i=>i.sourceIndex===t||i.targetIndex===t);if(e.length>0){let i=-1,s=-1;for(const n of e){const r=n.sourceIndex===t?n.targetIndex:n.sourceIndex,a=l.nodes[r];a&&a.retention>s&&(s=a.retention,i=r)}if(i>=0)return i}}for(let t=0;t<l.nodes.length;t++)if(t!==l.centerIndex)return t;return l.centerIndex}function Bp(l,t,e=8192){const i=Cp(l),n=l.nodes[i].id,r=Mh(l,i),o=new ea({seed:t+":birth:"+n}).state.rng,h=new Float32Array(e*Tn),c=Math.floor(e*Sp),u=Math.floor(e*Ap),d=e-c-u;for(let x=0;x<c;x++){const y=x*Tn,[b,v,_]=Oh(x,c,_h+o()*(Mp-_h),o);h[y+0]=r[0]+b,h[y+1]=r[1]+v,h[y+2]=r[2]+_,h[y+3]=o(),h[y+4]=r[0],h[y+5]=r[1],h[y+6]=r[2],h[y+7]=1+o()*1.8,h[y+8]=.55,h[y+9]=.32,h[y+10]=1,h[y+11]=o(),h[y+12]=0,h[y+13]=0,h[y+14]=0,h[y+15]=0}const f=l.edges.filter(x=>x.sourceIndex===i||x.targetIndex===i);for(let x=0;x<u;x++){const y=(c+x)*Tn;if(f.length===0)continue;const b=x%f.length,v=f[b],_=v.sourceIndex===i?v.targetIndex:v.sourceIndex,M=Mh(l,_),A=M[0]-r[0],S=M[1]-r[1],T=M[2]-r[2],C=Math.sqrt(A*A+S*S+T*T)||1,P=x/Math.max(1,u)*2+.5,V=o()*30,q=-S*V/C,L=A*V/C,I=0;h[y+0]=r[0]+A/C*P*80+q,h[y+1]=r[1]+S/C*P*80+L,h[y+2]=r[2]+T/C*P*80+I,h[y+3]=o(),h[y+4]=r[0],h[y+5]=r[1],h[y+6]=r[2],h[y+7]=1+o()*1.8,h[y+8]=.55,h[y+9]=.32,h[y+10]=1,h[y+11]=o(),h[y+12]=0,h[y+13]=0,h[y+14]=0,h[y+15]=0}const p=300;for(let x=0;x<d;x++){const y=(c+u+x)*Tn,b=o()*Math.PI*2,v=o()*120;h[y+0]=r[0]+Math.cos(b)*v,h[y+1]=r[1]+Math.sin(b)*v,h[y+2]=r[2]+p*.6+o()*40,h[y+3]=o(),h[y+4]=r[0],h[y+5]=r[1],h[y+6]=r[2],h[y+7]=1+o()*1.8,h[y+8]=.55,h[y+9]=.32,h[y+10]=1,h[y+11]=o(),h[y+12]=0,h[y+13]=0,h[y+14]=0,h[y+15]=0}const m=zp(l,i),g=kp();return{targetIndex:i,targetNodeId:n,particles:h,edgeSteps:m,timeline:g}}function Mh(l,t){const e=l.nodes[t],i=l.nodes.length;if(e.isCenter&&l.centerIndex===t)return[0,0,0];const s=Math.PI*(3-Math.sqrt(5)),n=1-t/(i-1||1)*2,r=Math.sqrt(1-n*n),a=s*t,o=120,h=(t*7+3)%100/100*.1*o-.05*o,c=(t*13+7)%100/100*.1*o-.05*o,u=(t*17+11)%100/100*.1*o-.05*o;return[Math.cos(a)*r*o+h,n*o+c,Math.sin(a)*r*o+u]}function zp(l,t){const e=l.edges.filter(n=>n.sourceIndex===t||n.targetIndex===t),i=e.length;if(i===0)return new Uint32Array(0);const s=new Uint32Array(i*fs);for(let n=0;n<i;n++){const r=e[n],a=r.sourceIndex===t?r.targetIndex:r.sourceIndex,o=Ip+n*Tp;s[n*fs+0]=t,s[n*fs+1]=a,s[n*fs+2]=o,s[n*fs+3]=0}return s}function kp(){return[{label:"latent trace condensing",startFrame:60,endFrame:239},{label:"engram coalescence",startFrame:240,endFrame:329},{label:"memory ignition",startFrame:330,endFrame:359},{label:"associations engrave",startFrame:360,endFrame:509},{label:"stabilization",startFrame:510,endFrame:659}]}const Pp=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
// 16 floats / 64 bytes per particle (matches birth-plan.ts layout).
|
||
struct BirthParticle {
|
||
start_life: vec4<f32>,
|
||
target_size: vec4<f32>,
|
||
color_phase: vec4<f32>,
|
||
state: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage, read_write> particles: array<BirthParticle>;
|
||
|
||
@compute @workgroup_size(64)
|
||
fn birth_compute(@builtin(global_invocation_id) id: vec3<u32>) {
|
||
let i = id.x;
|
||
if (i >= arrayLength(&particles)) {
|
||
return;
|
||
}
|
||
|
||
// Capture mode (params.capture_mode == 1.0): skip physics integration.
|
||
// The storage-buffer state stays frozen at initial upload values.
|
||
if (params.capture_mode == 1.0) {
|
||
return;
|
||
}
|
||
|
||
var particle = particles[i];
|
||
let frame = params.frame;
|
||
let phase = params.loop_phase;
|
||
|
||
// --- Convergence choreography (integer cycles per 720-frame loop) ---
|
||
|
||
// Phase offset (stagger) from start_life.w: 0..1 → delays convergence.
|
||
let stagger = particle.start_life.w;
|
||
|
||
// Effective frame: staggered loop frame (wraps at 720).
|
||
let effFrame = fract(phase + stagger * 0.15) * 720.0;
|
||
|
||
// --- Phase 1: latent trace condensing (frames 0–239) ---
|
||
// Slow drift toward target.
|
||
var t: f32;
|
||
if (effFrame < 240.0) {
|
||
// Smooth ease-in: 0 → 1 over 240 frames.
|
||
t = effFrame / 240.0;
|
||
t = t * t * (3.0 - 2.0 * t); // smoothstep
|
||
}
|
||
// --- Phase 2: engram coalescence (frames 240–329) ---
|
||
// Accelerated convergence to target.
|
||
else if (effFrame < 330.0) {
|
||
let localFrame = effFrame - 240.0;
|
||
// 0 → 1 over 90 frames, with slight overshoot then settle.
|
||
t = localFrame / 90.0;
|
||
t = t * t * (3.0 - 2.0 * t);
|
||
// Add a small overshoot (1.05) then settle back to 1.0.
|
||
t = 1.0 - 0.05 * (1.0 - t);
|
||
}
|
||
// --- Phase 3: memory ignition (frames 330–359) ---
|
||
// Hold at target (flash handled in render).
|
||
else if (effFrame < 360.0) {
|
||
t = 1.0;
|
||
}
|
||
// --- Phase 4: associations engrave (frames 360–509) ---
|
||
// Hold at target.
|
||
else if (effFrame < 510.0) {
|
||
t = 1.0;
|
||
}
|
||
// --- Phase 5: stabilization (frames 510–719) ---
|
||
// Hold at target, then fade alpha for reset.
|
||
else {
|
||
let localFrame = effFrame - 510.0;
|
||
// Fade alpha to 0 for seamless reset at frame 0.
|
||
t = 1.0;
|
||
particle.state.w = 1.0 - smoothstep(0.0, 150.0, localFrame);
|
||
}
|
||
|
||
// Interpolate from start to target.
|
||
let startPos = particle.start_life.xyz;
|
||
let targetPos = particle.target_size.xyz;
|
||
// (WGSL forbids swizzle stores - reconstruct, preserving alpha in .w)
|
||
particle.state = vec4<f32>(mix(startPos, targetPos, t), particle.state.w);
|
||
|
||
// Alpha: particles fade in during convergence, fade out during reset.
|
||
let fadeIn = smoothstep(0.0, 60.0, effFrame);
|
||
particle.state.w = max(particle.state.w, fadeIn * 0.8);
|
||
|
||
particles[i] = particle;
|
||
}
|
||
`,Fp=16,Rp=6,Ep=330,Op=359,Dp=360;class Lp{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"active");z(this,"computePipeline",null);z(this,"computeBindGroup",null);z(this,"particleBuffer",null);z(this,"particleCount",0);z(this,"renderPipeline",null);z(this,"renderBindGroup",null);z(this,"haloPipeline",null);z(this,"haloBindGroup",null);z(this,"haloIndexBuffer",null);z(this,"engravePipeline",null);z(this,"engraveBindGroup",null);z(this,"engraveBuffer",null);z(this,"engraveStepCount",0);z(this,"timeline",[]);z(this,"birthPlan",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.active=!1,this.engine.addPass(this)}get engraveSteps(){var t;return((t=this.birthPlan)==null?void 0:t.edgeSteps)??new Uint32Array(0)}upload(t){var n,r;const e=this.engine.gpuDevice;if(!e||!this.nodeRenderer.nodeStateBuffer)return;const i=this.nodeRenderer.graph;if(!i)return;this.birthPlan=Bp(i,t),this.timeline=this.birthPlan.timeline;const s=this.birthPlan.particles.length/Fp;this.particleCount=s,(n=this.particleBuffer)==null||n.destroy(),this.particleBuffer=e.createBuffer({label:"observatory-birth-particles",size:this.birthPlan.particles.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.particleBuffer,0,this.birthPlan.particles.buffer),(r=this.engraveBuffer)==null||r.destroy(),this.engraveStepCount=this.birthPlan.edgeSteps.length/4,this.engraveStepCount>0&&(this.engraveBuffer=e.createBuffer({label:"observatory-birth-engrave",size:this.birthPlan.edgeSteps.byteLength,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),e.queue.writeBuffer(this.engraveBuffer,0,this.birthPlan.edgeSteps.buffer)),this.createComputePipeline(e),this.createRenderPipeline(e),this.createHaloPipeline(e),this.createEngravePipeline(e)}createComputePipeline(t){const e=t.createShaderModule({label:"observatory-birth-compute",code:Pp});this.computePipeline=t.createComputePipeline({label:"observatory-birth-compute-pipeline",layout:"auto",compute:{module:e,entryPoint:"birth_compute"}});const i=[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.particleBuffer}}];this.computeBindGroup=t.createBindGroup({label:"observatory-birth-compute-bind",layout:this.computePipeline.getBindGroupLayout(0),entries:i})}createRenderPipeline(t){const i=t.createShaderModule({label:"observatory-birth-render",code:`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
_pad: f32,
|
||
};
|
||
|
||
struct Camera {
|
||
view_proj: mat4x4<f32>,
|
||
right: vec4<f32>,
|
||
up: vec4<f32>,
|
||
};
|
||
|
||
struct BirthParticle {
|
||
start_life: vec4<f32>,
|
||
target_size: vec4<f32>,
|
||
color_phase: vec4<f32>,
|
||
state: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<uniform> camera: Camera;
|
||
@group(0) @binding(2) var<storage, read> particles: array<BirthParticle>;
|
||
|
||
struct VSOut {
|
||
@builtin(position) clip: vec4<f32>,
|
||
@location(0) uv: vec2<f32>,
|
||
@location(1) @interpolate(flat) color: vec3<f32>,
|
||
@location(2) @interpolate(flat) misc: vec4<f32>,
|
||
};
|
||
|
||
const CORNERS = array<vec2<f32>, 6>(
|
||
vec2<f32>(-1.0, -1.0),
|
||
vec2<f32>( 1.0, -1.0),
|
||
vec2<f32>( 1.0, 1.0),
|
||
vec2<f32>(-1.0, -1.0),
|
||
vec2<f32>( 1.0, 1.0),
|
||
vec2<f32>(-1.0, 1.0)
|
||
);
|
||
|
||
@vertex
|
||
fn vs_main(
|
||
@builtin(vertex_index) vi: u32,
|
||
@builtin(instance_index) ii: u32
|
||
) -> VSOut {
|
||
var out: VSOut;
|
||
if (ii >= arrayLength(&particles)) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
return out;
|
||
}
|
||
|
||
let particle = particles[ii];
|
||
let corner = CORNERS[vi];
|
||
|
||
// Current position from state.xyz.
|
||
let pos = particle.state.xyz;
|
||
|
||
// Base size from target_size.w.
|
||
let baseSize = particle.target_size.w;
|
||
|
||
// Flash boost during ignition (frames 330–359).
|
||
let frame = params.frame;
|
||
var flashBoost = 1.0;
|
||
if (frame >= 330.0 && frame <= 359.0) {
|
||
let flashT = (frame - 330.0) / 29.0; // 0..1 over flash frames
|
||
// Sharp flash: peaks at frame 345, fades by 359.
|
||
flashBoost = 1.0 + 3.0 * (1.0 - smoothstep(330.0, 345.0, frame))
|
||
+ 2.0 * smoothstep(345.0, 359.0, frame);
|
||
}
|
||
|
||
// Size: base + flash boost + pulse breathing.
|
||
let breath = 1.0 + 0.06 * params.pulse;
|
||
let halfSize = baseSize * 4.0 * breath * flashBoost;
|
||
|
||
let world = pos
|
||
+ camera.right.xyz * corner.x * halfSize
|
||
+ camera.up.xyz * corner.y * halfSize;
|
||
|
||
out.clip = camera.view_proj * vec4<f32>(world, 1.0);
|
||
out.uv = corner;
|
||
|
||
// Color: violet dust (0.55, 0.32, 1.00) with spectral rim.
|
||
let phase = particle.color_phase.w;
|
||
let spectralW = fract(params.loop_phase + phase);
|
||
var spectralColor: vec3<f32>;
|
||
var stops = array<vec3<f32>, 4>(
|
||
vec3<f32>(0.55, 0.32, 1.00), // violet base
|
||
vec3<f32>(0.40, 0.60, 1.00), // blue-violet
|
||
vec3<f32>(0.70, 0.45, 1.00), // magenta-violet
|
||
vec3<f32>(0.55, 0.32, 1.00) // wrap
|
||
);
|
||
let f = spectralW * 4.0;
|
||
let i = u32(floor(f)) % 4u;
|
||
let frac = f - floor(f);
|
||
spectralColor = mix(stops[i], stops[(i + 1u) % 4u], frac);
|
||
|
||
// Alpha from state.w (convergence progress + fade).
|
||
let alpha = particle.state.w;
|
||
|
||
out.color = spectralColor;
|
||
out.misc = vec4<f32>(baseSize, 0.0, 0.0, alpha);
|
||
return out;
|
||
}
|
||
|
||
@fragment
|
||
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
||
let d = length(in.uv);
|
||
if (d > 1.0) {
|
||
discard;
|
||
}
|
||
|
||
let alpha = in.misc.w;
|
||
let core = smoothstep(0.25, 0.0, d);
|
||
let halo = pow(max(1.0 - d, 0.0), 2.0);
|
||
|
||
// Additive glow: core + halo.
|
||
let intensity = core * 1.5 + halo * 0.6;
|
||
|
||
// Flash boost during ignition.
|
||
let frame = params.frame;
|
||
var flash = 0.0;
|
||
if (frame >= 330.0 && frame <= 359.0) {
|
||
flash = smoothstep(330.0, 345.0, frame) * 2.0;
|
||
}
|
||
|
||
let color = in.color * (intensity + flash);
|
||
|
||
return vec4<f32>(color * params.brightness, 1.0);
|
||
}
|
||
`});this.renderPipeline=t.createRenderPipeline({label:"observatory-birth-render",layout:"auto",vertex:{module:i,entryPoint:"vs_main"},fragment:{module:i,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}});const s=this.nodeRenderer.cameraUniformBuffer;this.renderBindGroup=t.createBindGroup({label:"observatory-birth-render-bind",layout:this.renderPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:s}},{binding:2,resource:{buffer:this.particleBuffer}}]})}createHaloPipeline(t){const i=t.createShaderModule({label:"observatory-birth-halo",code:`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
_pad: f32,
|
||
};
|
||
|
||
struct Camera {
|
||
view_proj: mat4x4<f32>,
|
||
right: vec4<f32>,
|
||
up: vec4<f32>,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<uniform> camera: Camera;
|
||
@group(0) @binding(2) var<storage, read> nodes: array<Node>;
|
||
|
||
struct VSOut {
|
||
@builtin(position) clip: vec4<f32>,
|
||
@location(0) uv: vec2<f32>,
|
||
};
|
||
|
||
@vertex
|
||
fn vs_main(
|
||
@builtin(vertex_index) vi: u32,
|
||
@builtin(instance_index) ii: u32
|
||
) -> VSOut {
|
||
var out: VSOut;
|
||
if (ii >= u32(params.node_count)) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
return out;
|
||
}
|
||
|
||
let node = nodes[ii];
|
||
let flags = u32(node.color_flags.w);
|
||
let is_target = (flags & 4u) != 0u; // flag 2: is birth target
|
||
|
||
if (!is_target) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
return out;
|
||
}
|
||
|
||
// Flash halo: only visible during ignition (frames 330–359).
|
||
let frame = params.frame;
|
||
if (frame < 330.0 || frame > 359.0) {
|
||
out.clip = vec4<f32>(0.0, 0.0, 2.0, 1.0);
|
||
return out;
|
||
}
|
||
|
||
// Halo ring: expands during flash, fades by frame 359.
|
||
let flashT = (frame - 330.0) / 29.0; // 0..1
|
||
let ringRadius = 0.3 + flashT * 0.5; // expands 0.3 → 0.8
|
||
|
||
// Quad centered on target position.
|
||
let pos = node.pos_radius.xyz;
|
||
let cornerX = (f32(vi) / 3.0 - 1.0); // -1, 0, 1 (3 unique x)
|
||
let cornerY = (f32(vi % 3) / 1.5 - 1.0); // -1, 0, 1
|
||
|
||
// We use 4 vertices for a simple quad (vi 0..3).
|
||
let cx = cornerX * ringRadius;
|
||
let cy = cornerY * ringRadius;
|
||
|
||
let world = pos
|
||
+ camera.right.xyz * cx
|
||
+ camera.up.xyz * cy;
|
||
|
||
out.clip = camera.view_proj * vec4<f32>(world, 1.0);
|
||
|
||
// UV for radial fade.
|
||
out.uv = vec2<f32>(cx / ringRadius, cy / ringRadius);
|
||
|
||
return out;
|
||
}
|
||
|
||
@fragment
|
||
fn fs_main(in: VSOut) -> @location(0) vec4<f32> {
|
||
let d = length(in.uv);
|
||
if (d > 0.7) {
|
||
discard;
|
||
}
|
||
|
||
// Flash: white-hot core, violet rim.
|
||
let flashIntensity = 1.0 - smoothstep(0.0, 0.7, d);
|
||
let color = vec3<f32>(0.7, 0.4, 1.0) * flashIntensity * 2.0;
|
||
|
||
// Fade out as flash ends.
|
||
let frame = params.frame;
|
||
let fadeOut = 1.0 - smoothstep(345.0, 359.0, frame);
|
||
|
||
return vec4<f32>(color * params.brightness * fadeOut, 1.0);
|
||
}
|
||
`});this.haloPipeline=t.createRenderPipeline({label:"observatory-birth-halo",layout:"auto",vertex:{module:i,entryPoint:"vs_main"},fragment:{module:i,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}});const s=this.nodeRenderer.cameraUniformBuffer;this.haloBindGroup=t.createBindGroup({label:"observatory-birth-halo-bind",layout:this.haloPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:s}},{binding:2,resource:{buffer:this.nodeRenderer.nodeStateBuffer}}]})}createEngravePipeline(t){if(this.engraveStepCount===0||!this.engraveBuffer)return;const e=t.createShaderModule({label:"observatory-birth-engrave",code:_l});this.engravePipeline=t.createRenderPipeline({label:"observatory-birth-engrave-pipeline",layout:"auto",vertex:{module:e,entryPoint:"vs_main"},fragment:{module:e,entryPoint:"fs_main",targets:[{format:this.engine.sceneFormat,blend:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"}}),this.engraveBindGroup=t.createBindGroup({label:"observatory-birth-engrave-bind",layout:this.engravePipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.cameraUniformBuffer}},{binding:2,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:3,resource:{buffer:this.engraveBuffer}}]})}compute(t,e){const i=this.engine.params[9];if(this.active=i===1,!this.active||!this.computePipeline||!this.computeBindGroup)return;const s=t.beginComputePass({label:"observatory-birth-compute"});s.setPipeline(this.computePipeline),s.setBindGroup(0,this.computeBindGroup),s.dispatchWorkgroups(Math.ceil(this.particleCount/64)),s.end()}render(t,e){this.active&&(this.renderPipeline&&this.renderBindGroup&&this.particleCount>0&&(t.setPipeline(this.renderPipeline),t.setBindGroup(0,this.renderBindGroup),t.draw(Rp,this.particleCount)),this.haloPipeline&&this.haloBindGroup&&e>=Ep&&e<=Op&&(t.setPipeline(this.haloPipeline),t.setBindGroup(0,this.haloBindGroup),t.draw(4,this.nodeRenderer.nodeCountValue)),this.engravePipeline&&this.engraveBindGroup&&this.engraveStepCount>0&&e>=Dp&&(t.setPipeline(this.engravePipeline),t.setBindGroup(0,this.engraveBindGroup),t.draw(6,this.engraveStepCount)))}dispose(){var t,e,i,s,n,r,a,o,h,c,u;(t=this.particleBuffer)==null||t.destroy(),this.particleBuffer=null,(i=(e=this.computePipeline)==null?void 0:e.destroy)==null||i.call(e),this.computePipeline=null,this.computeBindGroup=null,(n=(s=this.renderPipeline)==null?void 0:s.destroy)==null||n.call(s),this.renderPipeline=null,this.renderBindGroup=null,(a=(r=this.haloPipeline)==null?void 0:r.destroy)==null||a.call(r),this.haloPipeline=null,this.haloBindGroup=null,(o=this.haloIndexBuffer)==null||o.destroy(),this.haloIndexBuffer=null,(c=(h=this.engravePipeline)==null?void 0:h.destroy)==null||c.call(h),this.engravePipeline=null,this.engraveBindGroup=null,(u=this.engraveBuffer)==null||u.destroy(),this.engraveBuffer=null}}function Np(l){const t=l.hopSlot.toFixed(1),e=l.causeDepth.toFixed(1);return`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage, read_write> nodes: array<Node>;
|
||
// 1 u32/node: bits 0-15 hopDepth (0xffff unreached), 16 failure, 17 cause,
|
||
// 18 lookalike, 19-21 lookalike k (rescue-plan.ts packing).
|
||
@group(0) @binding(2) var<storage, read> wave: array<u32>;
|
||
|
||
const HOP_SLOT: f32 = ${t};
|
||
const CAUSE_DEPTH: f32 = ${e};
|
||
const TAU: f32 = 6.28318530717958647;
|
||
|
||
fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 {
|
||
return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f));
|
||
}
|
||
|
||
fn arrival(d: f32) -> f32 {
|
||
return min(260.0 + HOP_SLOT * d, 514.0);
|
||
}
|
||
|
||
@compute @workgroup_size(64)
|
||
fn rescue_choreo(@builtin(global_invocation_id) id: vec3<u32>) {
|
||
let i = id.x;
|
||
if (i >= u32(params.node_count)) {
|
||
return;
|
||
}
|
||
if (i >= arrayLength(&wave)) {
|
||
return;
|
||
}
|
||
// Belt-and-braces atop the TS gate: salience-rescue is demo index 2.
|
||
if (params.demo_id != 2.0) {
|
||
return;
|
||
}
|
||
|
||
let packed = wave[i];
|
||
let depth_u = packed & 0xffffu;
|
||
let d = f32(depth_u);
|
||
let is_failure = (packed & 0x10000u) != 0u;
|
||
let is_cause = (packed & 0x20000u) != 0u;
|
||
let is_look = (packed & 0x40000u) != 0u;
|
||
let look_k = f32((packed >> 19u) & 0x7u);
|
||
|
||
let f = params.frame;
|
||
|
||
var dx = 0.0;
|
||
var dy = 0.0;
|
||
var dz = 0.0;
|
||
var dw = 0.0;
|
||
|
||
if (is_failure) {
|
||
// Detonation spike, wound simmer, recognition flare as the arc lands.
|
||
dw = dw + env(f, 90.0, 96.0, 120.0, 168.0);
|
||
dw = dw + 0.35 * env(f, 100.0, 130.0, 600.0, 656.0);
|
||
dw = dw + 0.35 * env(f, 552.0, 562.0, 580.0, 640.0);
|
||
// Symptom backlight while the cause burns.
|
||
dx = dx + 0.4 * env(f, 556.0, 566.0, 620.0, 668.0);
|
||
}
|
||
if (!is_failure && depth_u >= 1u && depth_u <= 12u) {
|
||
// Shockwave blink: crimson concussion, 3 frames/hop of REAL graph distance.
|
||
dw = dw + 0.75 * exp(-0.3 * d)
|
||
* env(f, 92.0 + 3.0 * d, 96.0 + 3.0 * d, 96.0 + 3.0 * d, 122.0 + 3.0 * d);
|
||
}
|
||
if (is_look) {
|
||
let fk = 138.0 + 28.0 * look_k;
|
||
// Searchlight flare — cold pop, sequential, on camera.
|
||
dy = dy + env(f, fk - 6.0, fk, fk + 10.0, fk + 26.0);
|
||
// Ash residue — the struck-through lookalike stays in frame until the verdict.
|
||
dy = dy + 0.15 * smoothstep(fk + 10.0, fk + 26.0, f) * (1.0 - smoothstep(600.0, 656.0, f));
|
||
}
|
||
if (!is_failure && depth_u >= 1u && d <= CAUSE_DEPTH) {
|
||
let wd = arrival(d);
|
||
// Interrogation flicker: 24 integer sine cycles per loop, per-depth phase.
|
||
let flicker = 0.75 + 0.25 * sin(TAU * 24.0 * params.loop_phase + 1.7 * d);
|
||
dz = dz + env(f, wd - 10.0, wd, wd + 28.0, wd + 64.0) * flicker;
|
||
// Scanned ember.
|
||
dz = dz + 0.08 * smoothstep(wd + 28.0, wd + 64.0, f) * (1.0 - smoothstep(580.0, 640.0, f));
|
||
}
|
||
if (is_cause) {
|
||
// Cause ignition rides the EXISTING recall response (render-nodes.wgsl):
|
||
// spectral() thin-film band + white-hot core + sprite swell at full intensity.
|
||
dx = dx + env(f, 520.0, 546.0, 640.0, 700.0);
|
||
}
|
||
|
||
// WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color
|
||
// lanes pass through untouched (the force sim owns them).
|
||
var node = nodes[i];
|
||
node.demo = vec4<f32>(dx, dy, dz, dw);
|
||
nodes[i] = node;
|
||
}
|
||
`}const Up=2;class Vp{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"waveBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.waveBuffer)==null||i.destroy(),this.waveBuffer=t.createBuffer({label:"observatory-rescue-wave",size:Math.max(4,this.plan.waveData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.waveBuffer,0,this.plan.waveData.buffer);const e=t.createShaderModule({label:"observatory-rescue-choreo",code:Np(this.plan.consts)});this.pipeline=t.createComputePipeline({label:"observatory-rescue-choreo",layout:"auto",compute:{module:e,entryPoint:"rescue_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-rescue-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.waveBuffer}}]})}compute(t){if(this.engine.params[9]!==Up||!this.pipeline||!this.bindGroup)return;const e=this.nodeRenderer.nodeCountValue;if(e===0)return;const i=t.beginComputePass({label:"observatory-rescue-choreo"});i.setPipeline(this.pipeline),i.setBindGroup(0,this.bindGroup),i.dispatchWorkgroups(Math.ceil(e/64)),i.end()}dispose(){var t;(t=this.waveBuffer)==null||t.destroy(),this.waveBuffer=null,this.pipeline=null,this.bindGroup=null}}const Gp=4,Wp=90,Hp=138,qp=28,Xp=260,Yp=514,Sh=560,Jp=600,oi=65535,Zp=48,$p={causal:0,temporal:1,shared_concepts:2,complementary:3,semantic:4};function Sl(l,t){const e=new ea({seed:t});return wl(l,e.state.rng).data}function jp(l){const t=new Uint32Array(l.nodes.length);for(const e of l.edges)t[e.sourceIndex]++,t[e.targetIndex]++;return t}function Kp(l,t){const e=l.nodes.length;if(e===0)return-1;const i=jp(l),s=r=>{const a=l.nodes[r],o=new Set(a.tags.map(f=>f.toLowerCase()));let h=0;(o.has("failure")||o.has("guardrail"))&&(h+=3),(o.has("confusion")||o.has("weak-spot"))&&(h+=2),h+=Math.min(i[r],8)/8;const c=t[r*Mt+0],u=t[r*Mt+1],d=t[r*Mt+2];return Math.sqrt(c*c+u*u+d*d)>=54&&(h+=.5),h},n=[r=>r!==l.centerIndex&&!l.nodes[r].suppressed&&i[r]>=2,r=>r!==l.centerIndex&&!l.nodes[r].suppressed,r=>r!==l.centerIndex,()=>!0];for(const r of n){let a=-1,o=-1/0;for(let h=0;h<e;h++){if(!r(h))continue;const c=s(h);c>o&&(o=c,a=h)}if(a>=0)return a}return-1}function Qp(l,t){const e=l.nodes.length,i=new Uint16Array(e).fill(oi),s=new Int32Array(e).fill(-1);if(t<0||t>=e)return{depths:i,parents:s};const n=Array.from({length:e},()=>[]);for(const a of l.edges){const o=$p[a.type]??5;n[a.sourceIndex].push({nbr:a.targetIndex,rank:o}),n[a.targetIndex].push({nbr:a.sourceIndex,rank:o})}for(const a of n)a.sort((o,h)=>o.rank-h.rank||o.nbr-h.nbr);i[t]=0;const r=[t];for(let a=0;a<r.length;a++){const o=r[a];for(const{nbr:h}of n[o])i[h]===oi&&(i[h]=i[o]+1,r.push(h))}for(let a=0;a<e;a++)if(!(i[a]===oi||i[a]===0)){for(const{nbr:o}of n[a])if(i[o]===i[a]-1){s[a]=o;break}}return{depths:i,parents:s}}function tm(l,t,e,i){const s=new Map;for(const n of l.nodes)s.set(n.id,n.createdAt);for(const n of[3,2,1]){const r=[];for(let f=0;f<t.nodes.length;f++){if(f===t.centerIndex||f===i)continue;const p=e[f];p===oi||p<n||r.push(f)}if(r.length===0)continue;let a=r.filter(f=>t.nodes[f].retention<=.45);a.length===0&&(a=r);const o=new Map;let h=1/0,c=-1/0;for(const f of a){const p=s.get(t.nodes[f].id),m=p?Date.parse(p):NaN;Number.isFinite(m)&&(o.set(f,m),m<h&&(h=m),m>c&&(c=m))}const u=f=>{const p=o.get(f);return p===void 0?0:c===h?1:(c-p)/(c-h)},d=f=>2*(1-t.nodes[f].retention)+.5*Math.min(e[f],6)/6+.5*u(f);return a.sort((f,p)=>{const m=d(f),g=d(p);return g!==m?g-m:e[p]!==e[f]?e[p]-e[f]:f-p}),{index:a[0],depth:e[a[0]]}}return{index:-1,depth:0}}function em(l,t,e,i,s){const n=l[e*Mt+0],r=l[e*Mt+1],a=l[e*Mt+2],o=[];for(let h=0;h<t;h++){if(h===e||h===i||h===s)continue;const c=l[h*Mt+0]-n,u=l[h*Mt+1]-r,d=l[h*Mt+2]-a;o.push({i:h,d2:c*c+u*u+d*d})}return o.sort((h,c)=>h.d2-c.d2||h.i-c.i),o.slice(0,Gp).map(h=>h.i)}function ta(l){const t=Math.max(1,l);return Math.min(84,Math.max(14,Math.floor(252/t)))}function im(l,t){return Math.min(Xp+t*l,Yp)}function Ah(l){return Hp+qp*l}function ye(l){return l.length>64?l.slice(0,64)+"…":l}const ps=4;function Wr(l){const t=new Uint32Array(l);return t.fill(oi),{viable:!1,failureIndex:-1,causeIndex:-1,lookalikeIndices:[],hopDepths:new Uint16Array(l).fill(oi),causeDepth:0,hopSlot:ta(3),waveData:t,pathData:new Uint32Array(4),pathMetas:[],spineBeats:[],verdict:{headline:"root cause found",causeLabel:"",failureLabel:"",causeDate:"",hops:0,k:0,receipt:""},consts:{hopSlot:ta(3),causeDepth:3}}}function sm(l,t,e){var L;const i=t.nodes.length;if(i===0)return Wr(0);const s=Sl(t,e),n=Kp(t,s);if(n<0)return Wr(i);const{depths:r,parents:a}=Qp(t,n),o=tm(l,t,r,n);if(o.index<0){const I=Wr(i);return I.failureIndex=n,I.hopDepths=r,I}const h=o.index,c=Math.max(1,o.depth),u=ta(c),d=I=>im(I,u),f=em(s,i,n,h,t.centerIndex),p=f.length,m=new Uint32Array(i);for(let I=0;I<i;I++){let U=r[I]&65535;I===n&&(U|=65536),I===h&&(U|=1<<17),m[I]=U}f.forEach((I,U)=>{m[I]|=1<<18|U<<19});const g=[];f.forEach((I,U)=>{g.push({src:n,dst:I,bf:Ah(U),kind:ze.probe,beatKind:"probe"})});const x=[];{let I=h;for(;I!==n&&I>=0&&a[I]>=0;)x.push(I),I=a[I]}const y=new Set(x),b=[];for(let I=0;I<i;I++){if(I===n||y.has(I))continue;const U=r[I];U===oi||U<1||U>c||a[I]<0||b.push(I)}b.sort((I,U)=>r[I]-r[U]||I-U);const v=[...x.slice().reverse(),...b].slice(0,Zp);v.sort((I,U)=>r[I]-r[U]||I-U);for(const I of v)g.push({src:a[I],dst:I,bf:d(r[I]),kind:ze.backwardCause,beatKind:"wave"});g.push({src:h,dst:n,bf:Sh,kind:ze.backwardCause,beatKind:"arc"});const _=new Uint32Array(Math.max(1,g.length)*ps),M=[];g.forEach((I,U)=>{_[U*ps+0]=I.src,_[U*ps+1]=I.dst,_[U*ps+2]=I.bf,_[U*ps+3]=I.kind,M.push({sourceIndex:I.src,targetIndex:I.dst,beatFrame:I.bf,kind:I.kind,beatKind:I.beatKind,nodeId:t.nodes[I.dst].id,label:ye(t.nodes[I.dst].label)})});const A=ye(t.nodes[n].label),S=ye(t.nodes[h].label),T=[],C=(I,U,wt,Ct)=>{T.push({sourceIndex:n,targetIndex:n,beatFrame:I,kind:U,beatKind:"rescue",nodeId:Ct,label:wt})};C(Wp,1,`failure: ${A}`,t.nodes[n].id),f.forEach((I,U)=>{C(Ah(U),0,`lookalike ✗ · ${ye(t.nodes[I].label)}`,t.nodes[I].id)}),C(d(1),1,"reaching backward through time","rescue-wave-start"),c>=2&&d(c)!==d(1)&&C(d(c),1,`scrubbing past · ${c} hops`,"rescue-wave-deep"),C(Sh,1,`causal arc · ${S}`,t.nodes[h].id),C(Jp,1,"root cause found","rescue-verdict");const P=((L=l.nodes.find(I=>I.id===t.nodes[h].id))==null?void 0:L.createdAt)??"",V=P?P.slice(0,10):"",q={headline:"root cause found",causeLabel:S,failureLabel:A,causeDate:V,hops:c,k:p,receipt:`${c} hops back · ${V} · vector search: 0 for ${p}`};return{viable:!0,failureIndex:n,causeIndex:h,lookalikeIndices:f,hopDepths:r,causeDepth:c,hopSlot:u,waveData:m,pathData:_,pathMetas:M,spineBeats:T,verdict:q,consts:{hopSlot:u,causeDepth:c}}}const nm=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage, read_write> nodes: array<Node>;
|
||
// 1 u32/node: bits 0-7 rank, 8 isDrifting, 9 isRescued, 10-11 rescue slot k
|
||
// (forgetting-plan.ts packing). Non-drifting nodes are exactly 0.
|
||
@group(0) @binding(2) var<storage, read> horizon: array<u32>;
|
||
|
||
fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 {
|
||
return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f));
|
||
}
|
||
|
||
@compute @workgroup_size(64)
|
||
fn forgetting_choreo(@builtin(global_invocation_id) id: vec3<u32>) {
|
||
let i = id.x;
|
||
if (i >= u32(params.node_count)) {
|
||
return;
|
||
}
|
||
if (i >= arrayLength(&horizon)) {
|
||
return;
|
||
}
|
||
// Belt-and-braces atop the TS gate: forgetting-horizon is demo index 3.
|
||
if (params.demo_id != 3.0) {
|
||
return;
|
||
}
|
||
|
||
let packed = horizon[i];
|
||
let is_drifting = (packed & 0x100u) != 0u;
|
||
let is_rescued = (packed & 0x200u) != 0u;
|
||
let rank01 = f32(packed & 0xffu) / 255.0;
|
||
let k = f32((packed >> 10u) & 0x3u);
|
||
|
||
let f = params.frame;
|
||
// Master release: every lane is exactly 0.0 by frame 712 — the seam wall.
|
||
let master = 1.0 - smoothstep(660.0, 712.0, f);
|
||
|
||
var dx = 0.0;
|
||
var dz = 0.0;
|
||
|
||
if (is_drifting) {
|
||
let onset = 90.0 + 42.0 * rank01;
|
||
// Phase 1 — the drift: dim + fall to the 0.55 plateau, retention-staggered.
|
||
let phase1 = 0.55 * smoothstep(onset, onset + 210.0, f);
|
||
if (is_rescued) {
|
||
let rk = 318.0 + 60.0 * k;
|
||
// Snap-back begins 22 frames before the recall ribbon lands at rk.
|
||
dz = master * phase1 * (1.0 - smoothstep(rk - 22.0, rk + 6.0, f));
|
||
// Ignition rides the EXISTING recall response (render-nodes.wgsl):
|
||
// spectral() thin-film band + white-hot core + sprite swell for free.
|
||
dx = master * env(f, rk - 26.0, rk, rk + 60.0, rk + 130.0);
|
||
} else {
|
||
// Phase 2 — the sink: to exactly 1.0 over 640..660 (the ~6% floor era).
|
||
let phase2 = 0.45 * smoothstep(480.0 + 24.0 * rank01, 640.0, f);
|
||
dz = master * (phase1 + phase2);
|
||
}
|
||
}
|
||
|
||
// WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color
|
||
// lanes pass through untouched (the force sim owns them). demo.y and
|
||
// demo.w are hard 0.0: the rescue/firewall grammars can never fire here.
|
||
var node = nodes[i];
|
||
node.demo = vec4<f32>(dx, 0.0, dz, 0.0);
|
||
nodes[i] = node;
|
||
}
|
||
`,rm=3;class am{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"horizonBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.horizonBuffer)==null||i.destroy(),this.horizonBuffer=t.createBuffer({label:"observatory-forgetting-horizon",size:Math.max(4,this.plan.horizonData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.horizonBuffer,0,this.plan.horizonData.buffer);const e=t.createShaderModule({label:"observatory-forgetting-choreo",code:nm});this.pipeline=t.createComputePipeline({label:"observatory-forgetting-choreo",layout:"auto",compute:{module:e,entryPoint:"forgetting_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-forgetting-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.horizonBuffer}}]})}compute(t){if(this.engine.params[9]!==rm||!this.pipeline||!this.bindGroup)return;const e=this.nodeRenderer.nodeCountValue;if(e===0)return;const i=t.beginComputePass({label:"observatory-forgetting-choreo"});i.setPipeline(this.pipeline),i.setBindGroup(0,this.bindGroup),i.dispatchWorkgroups(Math.ceil(e/64)),i.end()}dispose(){var t;(t=this.horizonBuffer)==null||t.destroy(),this.horizonBuffer=null,this.pipeline=null,this.bindGroup=null}}const om=318,hm=60,Al=3,lm=132,cm=60,um=540,dm=660;function fm(l){const t=[];for(let s=0;s<l.nodes.length;s++)s!==l.centerIndex&&t.push(s);t.sort((s,n)=>l.nodes[s].retention-l.nodes[n].retention||s-n);const e=t.length;if(e===0)return[];const i=Math.min(e,Math.max(Math.min(Al,e),Math.round(.25*e)));return t.slice(0,i)}function pm(l,t){const e=new Uint32Array(l.nodes.length);for(const n of l.edges)e[n.sourceIndex]++,e[n.targetIndex]++;const i=n=>2*l.nodes[n].retention+Math.min(e[n],8)/8;return t.slice().sort((n,r)=>i(r)-i(n)||n-r).slice(0,Math.min(Al,t.length))}function Ih(l){return om+hm*l}const ms=4;function mm(l){return{viable:!1,driftingIndices:[],rescuedIndices:[],horizonData:new Uint32Array(l),pathData:new Uint32Array(4),pathMetas:[],spineBeats:[]}}function gm(l){const t=l.nodes.length,e=fm(l);if(t<2||e.length<1)return mm(t);const i=pm(l,e),s=e.length,n=new Uint32Array(t);e.forEach((d,f)=>{const p=Math.round(255*f/Math.max(1,s-1));n[d]=p&255|256}),i.forEach((d,f)=>{n[d]|=512|f<<10});const r=new Uint32Array(Math.max(1,i.length)*ms),a=[];i.forEach((d,f)=>{const p=Ih(f);r[f*ms+0]=l.centerIndex,r[f*ms+1]=d,r[f*ms+2]=p,r[f*ms+3]=ze.recall,a.push({sourceIndex:l.centerIndex,targetIndex:d,beatFrame:p,kind:ze.recall,beatKind:"recall",nodeId:l.nodes[d].id,label:ye(l.nodes[d].label)})});const o=[],h=(d,f,p,m)=>{o.push({sourceIndex:l.centerIndex,targetIndex:l.centerIndex,beatFrame:d,kind:f,beatKind:"horizon",nodeId:m,label:p})},c=new Set(i),u=e.filter(d=>!c.has(d)).slice(0,3);return u.forEach((d,f)=>{const p=Math.round(l.nodes[d].retention*100);h(lm+cm*f,1,`fading: ${ye(l.nodes[d].label)} · retention ${p}%`,l.nodes[d].id)}),i.forEach((d,f)=>{h(Ih(f),0,`recalled: ${ye(l.nodes[d].label)}`,l.nodes[d].id)}),u.length>0&&h(um,1,"the unrecalled sink · nothing is deleted","horizon-sink"),h(dm,0,"every memory still retrievable","horizon-retrievable"),{viable:!0,driftingIndices:e,rescuedIndices:i,horizonData:n,pathData:r,pathMetas:a,spineBeats:o}}const ym=`
|
||
struct Params {
|
||
frame: f32,
|
||
loop_phase: f32,
|
||
node_count: f32,
|
||
edge_count: f32,
|
||
path_count: f32,
|
||
pulse: f32,
|
||
viewport_w: f32,
|
||
viewport_h: f32,
|
||
brightness: f32,
|
||
demo_id: f32,
|
||
time: f32,
|
||
capture_mode: f32,
|
||
live_kind: f32,
|
||
live_frame: f32,
|
||
live_energy: f32,
|
||
projection_days: f32,
|
||
};
|
||
|
||
struct Node {
|
||
pos_radius: vec4<f32>,
|
||
vel_retention: vec4<f32>,
|
||
color_flags: vec4<f32>,
|
||
demo: vec4<f32>,
|
||
};
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage, read_write> nodes: array<Node>;
|
||
// 1 u32/node: bits 0-7 shockDelay, 8 isIntruder, 9 isSeverNeighbor,
|
||
// 10-13 sever slot k (firewall-plan.ts packing). Every node carries a delay.
|
||
@group(0) @binding(2) var<storage, read> fire: array<u32>;
|
||
|
||
const TAU: f32 = 6.28318530717958647;
|
||
|
||
fn env(f: f32, a0: f32, a1: f32, r0: f32, r1: f32) -> f32 {
|
||
return smoothstep(a0, a1, f) * (1.0 - smoothstep(r0, r1, f));
|
||
}
|
||
|
||
@compute @workgroup_size(64)
|
||
fn firewall_choreo(@builtin(global_invocation_id) id: vec3<u32>) {
|
||
let i = id.x;
|
||
if (i >= u32(params.node_count)) {
|
||
return;
|
||
}
|
||
if (i >= arrayLength(&fire)) {
|
||
return;
|
||
}
|
||
// Fire in TWO modes: the deterministic demo (demo_id == 4, wrapped loop
|
||
// frame) OR a LIVE event (live_kind == 1, driven by live_frame = frames
|
||
// since a real MemorySuppressed / contradiction fired). Anything else →
|
||
// no-op, and other grammars own the lanes.
|
||
let is_demo = params.demo_id == 4.0;
|
||
let is_live = params.live_kind == 1.0;
|
||
if (!is_demo && !is_live) {
|
||
return;
|
||
}
|
||
|
||
let packed = fire[i];
|
||
let delay = f32(packed & 0xffu);
|
||
let is_intruder = (packed & 0x100u) != 0u;
|
||
let is_sever = (packed & 0x200u) != 0u;
|
||
let k = f32((packed >> 10u) & 0xfu);
|
||
|
||
// Live mode replays the SAME 720-frame beat map from the event: f =
|
||
// live_frame (clamped to the loop window), loop_phase derived from it so the
|
||
// integer-cycle sines still resolve. Demo mode reads the wrapped loop clock.
|
||
var f = params.frame;
|
||
var lp = params.loop_phase;
|
||
if (is_live) {
|
||
f = clamp(params.live_frame, 0.0, 719.0);
|
||
lp = f / 720.0;
|
||
}
|
||
|
||
var fy = 0.0;
|
||
var fw = 0.0;
|
||
|
||
if (is_intruder) {
|
||
// Intrusion flare: sickly strobe, band (0..1], 36 integer cycles/loop.
|
||
// C¹ handoff into the membrane over 330-332 (the rise sweeps the flare
|
||
// band exactly once — the condensation read is intentional).
|
||
fy = env(f, 90.0, 96.0, 310.0, 332.0)
|
||
* (0.55 + 0.45 * sin(TAU * 36.0 * lp));
|
||
// Membrane: sustained ring band [2.60..2.90], 12 integer cycles/loop.
|
||
fy = fy + env(f, 330.0, 352.0, 620.0, 680.0)
|
||
* (2.75 + 0.15 * sin(TAU * 12.0 * lp));
|
||
// Source detonation as the front leaves.
|
||
fw = env(f, 148.0, 153.0, 162.0, 196.0);
|
||
} else {
|
||
// Crimson rim as the radial front passes: arrival A = 150 + delay,
|
||
// amplitude fades with distance; A ∈ [150, 294] ⇒ all rims dead by 320.
|
||
let a = 150.0 + delay;
|
||
let amp = 0.9 - 0.45 * (delay / 144.0);
|
||
fw = amp * env(f, a - 2.0, a + 3.0, a + 8.0, a + 26.0);
|
||
if (is_sever) {
|
||
// Node-side receipt of the severed edge; last release 474.
|
||
let sk = 345.0 + 21.0 * k;
|
||
fw = fw + 0.6 * env(f, sk - 4.0, sk, sk + 6.0, sk + 24.0);
|
||
}
|
||
}
|
||
|
||
// WGSL forbids swizzle stores — reconstruct the FULL vec4; pos/vel/color
|
||
// lanes pass through untouched (the force sim owns them). demo.x and
|
||
// demo.z are hard 0.0: the recall and horizon grammars can never fire here.
|
||
var node = nodes[i];
|
||
node.demo = vec4<f32>(0.0, fy, 0.0, fw);
|
||
nodes[i] = node;
|
||
}
|
||
`,xm=4;class Il{constructor(t){z(this,"engine");z(this,"nodeRenderer");z(this,"plan");z(this,"pipeline",null);z(this,"bindGroup",null);z(this,"fireBuffer",null);this.engine=t.engine,this.nodeRenderer=t.nodeRenderer,this.plan=t.plan,this.engine.addPass(this)}upload(){var i;const t=this.engine.gpuDevice;if(!t||!this.engine.paramsBuffer||!this.plan.viable||!this.nodeRenderer.nodeStateBuffer||this.nodeRenderer.nodeCountValue===0)return;(i=this.fireBuffer)==null||i.destroy(),this.fireBuffer=t.createBuffer({label:"observatory-firewall-fire",size:Math.max(4,this.plan.fireData.byteLength),usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),t.queue.writeBuffer(this.fireBuffer,0,this.plan.fireData.buffer);const e=t.createShaderModule({label:"observatory-firewall-choreo",code:ym});this.pipeline=t.createComputePipeline({label:"observatory-firewall-choreo",layout:"auto",compute:{module:e,entryPoint:"firewall_choreo"}}),this.bindGroup=t.createBindGroup({label:"observatory-firewall-bind",layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.engine.paramsBuffer}},{binding:1,resource:{buffer:this.nodeRenderer.nodeStateBuffer}},{binding:2,resource:{buffer:this.fireBuffer}}]})}rearm(t){if(this.plan=t,!!this.engine.gpuDevice){if(!t.viable){this.pipeline=null,this.bindGroup=null;return}this.upload()}}get armed(){return this.plan.viable&&!!this.pipeline&&!!this.bindGroup}compute(t){const e=this.engine.params[9]===xm,i=this.engine.params[12]===1;if(!e&&!i||!this.pipeline||!this.bindGroup)return;const s=this.nodeRenderer.nodeCountValue;if(s===0)return;const n=t.beginComputePass({label:"observatory-firewall-choreo"});n.setPipeline(this.pipeline),n.setBindGroup(0,this.bindGroup),n.dispatchWorkgroups(Math.ceil(s/64)),n.end()}dispose(){var t;(t=this.fireBuffer)==null||t.destroy(),this.fireBuffer=null,this.pipeline=null,this.bindGroup=null}}const bm=90,vm=150,wm=144,_m=330,Mm=345,Sm=21,Am=6,Im=480,Tm=["failure","guardrail","confusion"];function Cm(l){const t=l.nodes.length;if(t===0)return-1;const e=new Uint32Array(t);for(const n of l.edges)e[n.sourceIndex]++,e[n.targetIndex]++;const i=n=>l.nodes[n].tags.some(r=>Tm.includes(r.toLowerCase())),s=[n=>n!==l.centerIndex&&!l.nodes[n].suppressed&&i(n),n=>n!==l.centerIndex&&!l.nodes[n].suppressed&&e[n]<=1,n=>n!==l.centerIndex&&!l.nodes[n].suppressed,n=>n!==l.centerIndex];for(const n of s){let r=-1;for(let a=0;a<t;a++)n(a)&&(r<0||l.nodes[a].retention<l.nodes[r].retention)&&(r=a);if(r>=0)return r}return-1}function Bm(l,t,e){const i=l[e*Mt+0],s=l[e*Mt+1],n=l[e*Mt+2],r=new Array(t);let a=0;for(let h=0;h<t;h++){const c=l[h*Mt+0]-i,u=l[h*Mt+1]-s,d=l[h*Mt+2]-n,f=Math.sqrt(c*c+u*u+d*d);r[h]=f,f>a&&(a=f)}a<1e-6&&(a=1);const o=new Array(t);for(let h=0;h<t;h++)o[h]=Math.min(255,Math.max(0,Math.round(wm*r[h]/a)));return o[e]=0,o}function zm(l,t){const e=new Set;for(const i of l.edges)i.sourceIndex===t&&i.targetIndex!==t&&e.add(i.targetIndex),i.targetIndex===t&&i.sourceIndex!==t&&e.add(i.sourceIndex);return Array.from(e).sort((i,s)=>i-s).slice(0,Am)}function Th(l){return Mm+Sm*l}const gs=4;function km(l){return Na(l)}function Na(l){return{viable:!1,intruderIndex:-1,severedNeighborIndices:[],shockDelays:[],fireData:new Uint32Array(l),pathData:new Uint32Array(4),pathMetas:[],spineBeats:[],verdict:{headline:"threat quarantined",intruderLabel:"",receipt:"memory held in review · Memory PR opened"}}}function Pm(l,t){return Tl(l,t,Cm(l))}function Fm(l,t,e){return e<0||e>=l.nodes.length?Na(l.nodes.length):Tl(l,t,e)}function Tl(l,t,e){const i=l.nodes.length;if(i===0||e<0)return Na(i);const s=Sl(l,t),n=Bm(s,i,e),r=zm(l,e),a=new Uint32Array(i);for(let p=0;p<i;p++)a[p]=n[p]&255;a[e]=256,r.forEach((p,m)=>{a[p]|=512|m<<10});const o=new Uint32Array(Math.max(1,r.length)*gs),h=[];r.forEach((p,m)=>{const g=Th(m);o[m*gs+0]=e,o[m*gs+1]=p,o[m*gs+2]=g,o[m*gs+3]=ze.probe,h.push({sourceIndex:e,targetIndex:p,beatFrame:g,kind:ze.probe,beatKind:"sever",nodeId:l.nodes[p].id,label:ye(l.nodes[p].label)})});const c=ye(l.nodes[e].label),u=[],d=(p,m,g)=>{u.push({sourceIndex:e,targetIndex:e,beatFrame:p,kind:1,beatKind:"firewall",nodeId:g,label:m})};return d(bm,`intrusion · ${c}`,l.nodes[e].id),d(vm,"immune response · shockwave","firewall-shock"),d(_m,"membrane forming","firewall-membrane"),r.forEach((p,m)=>{d(Th(m),`edge severed ✗ · ${ye(l.nodes[p].label)}`,l.nodes[p].id)}),d(Im,"threat quarantined","firewall-verdict"),{viable:!0,intruderIndex:e,severedNeighborIndices:r,shockDelays:n,fireData:a,pathData:o,pathMetas:h,spineBeats:u,verdict:{headline:"threat quarantined",intruderLabel:c,receipt:"memory held in review · Memory PR opened"}}}const Ua=.1542;function Rm(l=Ua){return Math.pow(.9,-1/l)-1}function Em(l,t,e=Ua){if(!(l>0))return 0;if(!(t>0))return 1;const i=Rm(e),s=Math.pow(1+i*t/l,-e);return s<0?0:s>1?1:s}const Om=864e5;function Dm(l,t,e=0){if(!l)return e>0?e:0;const i=Date.parse(l);if(!Number.isFinite(i))return e>0?e:0;const s=(t-i)/Om;return Math.max(0,s)+Math.max(0,e)}function Lm(l,t,e,i=0,s=Ua){return l===void 0||!Number.isFinite(l)?1:Em(l,Dm(t,e,i),s)}const Ch={[At.firewall]:620,[At.dreamStorm]:360,[At.causalRecall]:260,[At.birth]:180};class Nm{constructor(t){z(this,"engine");z(this,"renderer");z(this,"graph");z(this,"response");z(this,"seed");z(this,"projectionDays");z(this,"onApply");z(this,"onFirewall");z(this,"firewall",null);z(this,"liveEdges",[]);z(this,"liveEdgeKeys",new Set);z(this,"edgesDirty",!1);z(this,"indexById");z(this,"active",null);z(this,"dreamOpen",!1);z(this,"retention");z(this,"hasLiveDecay",!1);z(this,"eventsSeen",0);z(this,"lastDecayFrame",-1e3);z(this,"lastAppliedMs",0);z(this,"seeded",!1);z(this,"lastProj",-1);this.engine=t.engine,this.renderer=t.renderer,this.graph=t.graph,this.response=t.response,this.seed=t.seed,this.projectionDays=t.projectionDays??(()=>0),this.onApply=t.onApply,this.onFirewall=t.onFirewall,this.indexById=t.graph.indexById;const e=t.graph.nodes.length;this.retention=new Float32Array(e);for(let s=0;s<e;s++){const n=t.graph.nodes[s];this.retention[s]=n.retention,n.stability!==void 0&&n.lastAccessed&&(this.hasLiveDecay=!0)}this.liveEdges=t.graph.edges.slice();for(const s of this.liveEdges)this.liveEdgeKeys.add(Bh(s.sourceIndex,s.targetIndex));this.lastAppliedMs=0;const i=this.engine.params;i[zt.liveKind]=At.none,i[zt.liveFrame]=0,i[zt.liveEnergy]=0,i[zt.projectionDays]=0}get liveDecayAvailable(){return this.hasLiveDecay}seedWatermark(t){let e=0;for(const i of t){const s=zh(i);s>e&&(e=s)}this.lastAppliedMs=e,this.seeded=!0}ingest(t){if(t.length===0)return;if(!this.seeded){this.seedWatermark(t);return}let e=this.lastAppliedMs;for(let i=t.length-1;i>=0;i--){const s=t[i],n=zh(s);n>this.lastAppliedMs&&(this.decodeAndArm(s,this.engine.totalFrames),n>e&&(e=n))}this.lastAppliedMs=e}decodeAndArm(t,e){var s;const i=t.data??{};switch(t.type){case"MemorySuppressed":{const n=Fi(i.id);if(!n||!this.indexById.has(n))return;this.arm({kind:At.firewall,startFrame:e,targetId:n,relatedIds:this.neighborsOf(n),pairs:[],scalar:ys(i.estimated_cascade)});break}case"DeepReferenceCompleted":{const r=Um(i.contradiction_pairs).filter(([h,c])=>this.indexById.has(h)&&this.indexById.has(c));if(r.length>0){const h=r[0][0];this.arm({kind:At.firewall,startFrame:e,targetId:h,relatedIds:r.flatMap(c=>c).filter(c=>c!==h),pairs:r,scalar:r.length});return}const a=Fi(i.primary_id),o=kh(i.supporting_ids).filter(h=>this.indexById.has(h));a&&this.indexById.has(a)&&this.arm({kind:At.causalRecall,startFrame:e,targetId:a,relatedIds:o,pairs:[],scalar:ys(i.confidence)});break}case"BackfillFired":case"CausalReceipt":{const n=kh(i.path_ids??i.causal_path).filter(a=>this.indexById.has(a)),r=Fi(i.target_id??i.effect_id)||n[0];r&&this.indexById.has(r)&&this.arm({kind:At.causalRecall,startFrame:e,targetId:r,relatedIds:n.filter(a=>a!==r),pairs:[],scalar:n.length});break}case"DreamStarted":{this.dreamOpen=!0,this.arm({kind:At.dreamStorm,startFrame:e,targetId:"",relatedIds:[],pairs:[],scalar:ys(i.memory_count)});break}case"DreamCompleted":{this.dreamOpen=!1;const n=ys(i.connections_found);this.active&&this.active.kind===At.dreamStorm?this.active.scalar=Math.max(this.active.scalar,n):this.arm({kind:At.dreamStorm,startFrame:e,targetId:"",relatedIds:[],pairs:[],scalar:n});break}case"ConnectionDiscovered":{const n=this.indexById.get(Fi(i.source_id)),r=this.indexById.get(Fi(i.target_id));if(n===void 0||r===void 0||n===r)break;const a=Bh(n,r);if(this.liveEdgeKeys.has(a))break;this.liveEdgeKeys.add(a),this.liveEdges.push({sourceIndex:n,targetIndex:r,weight:ys(i.weight)||.5,type:Fi(i.connection_type)||"semantic"}),this.edgesDirty=!0,this.dreamOpen&&((s=this.active)==null?void 0:s.kind)===At.dreamStorm&&(this.active.scalar+=1);break}}}arm(t){var e;if(this.active=t,this.eventsSeen++,t.kind===At.firewall){const i=this.indexById.get(t.targetId);if(i===void 0)return;const s=Fm(this.graph,this.seed,i);if(!s.viable)return;this.firewall||(this.firewall=new Il({engine:this.engine,nodeRenderer:this.renderer,plan:km(this.graph.nodes.length)})),this.firewall.rearm(s),(e=this.onFirewall)==null||e.call(this,{intruderLabel:s.verdict.intruderLabel,startFrame:t.startFrame})}if(t.kind===At.causalRecall&&this.indexById.has(t.targetId)){const i=Ml(this.response,this.graph,8,{preferCausal:!0,centerId:t.targetId});i.steps.length>0&&this.renderer.setPathSteps(i.data,i.steps)}}neighborsOf(t){const e=this.indexById.get(t);if(e===void 0)return[];const i=[];for(const s of this.graph.edges)if(s.sourceIndex===e?i.push(this.graph.nodes[s.targetIndex].id):s.targetIndex===e&&i.push(this.graph.nodes[s.sourceIndex].id),i.length>=12)break;return i}drain(t){var s;const e=this.engine.params;this.edgesDirty&&(this.renderer.setEdges(this.liveEdges),this.edgesDirty=!1);const i=this.projectionDays();if(e[zt.projectionDays]=i,this.hasLiveDecay&&(t-this.lastDecayFrame>=6||i!==this.lastProj)&&(this.recomputeDecay(i),this.lastDecayFrame=t,this.lastProj=i),this.active){const n=Ch[this.active.kind]??300,r=t-this.active.startFrame;r>n+140?(this.active=null,e[zt.liveKind]=At.none,e[zt.liveEnergy]=0):(e[zt.liveKind]=this.active.kind,e[zt.liveFrame]=Math.max(0,r),e[zt.liveEnergy]=this.energyEnvelope(this.active,r,!1))}else e[zt.liveKind]=At.none,e[zt.liveEnergy]=0;(s=this.onApply)==null||s.call(this,{simFrame:t,activeKind:e[zt.liveKind],eventsSeen:this.eventsSeen})}debugState(){const t=this.engine.params;return{activeKind:t[zt.liveKind],liveEnergy:t[zt.liveEnergy],liveFrame:t[zt.liveFrame],edgeCount:this.liveEdges.length,eventsSeen:this.eventsSeen}}energyEnvelope(t,e,i){if(e<0)return 0;const s=Ch[t.kind]??300;if(t.kind===At.dreamStorm){const a=Math.min(1,e/45),o=1-Math.max(0,(e-(s-90))/90),h=Math.min(1.4,.7+t.scalar*.02);return Math.max(0,a*Math.min(1,o)*h)}const n=Math.min(1,e/24),r=1-Math.max(0,(e-s)/140);return Math.max(0,n*Math.min(1,r))}recomputeDecay(t){const e=this.engine.wallNowMs,i=this.graph.nodes;for(let s=0;s<i.length;s++){const n=i[s];this.retention[s]=n.stability!==void 0&&n.lastAccessed?Lm(n.stability,n.lastAccessed,e,t):n.retention}this.renderer.uploadLiveRetention(this.retention)}refreshDecay(){this.hasLiveDecay&&this.recomputeDecay(this.projectionDays())}}function Bh(l,t){return l<t?`${l}-${t}`:`${t}-${l}`}function zh(l){var i;const t=(i=l.data)==null?void 0:i.timestamp;if(typeof t!="string")return 0;const e=Date.parse(t);return Number.isFinite(e)?e:0}function Fi(l){return typeof l=="string"?l:""}function ys(l){return typeof l=="number"&&Number.isFinite(l)?l:0}function kh(l){return Array.isArray(l)?l.filter(t=>typeof t=="string"):[]}function Um(l){if(!Array.isArray(l))return[];const t=[];for(const e of l)Array.isArray(e)&&e.length>=2&&typeof e[0]=="string"&&typeof e[1]=="string"&&t.push([e[0],e[1]]);return t}var Vm=vt(`<div class="absolute top-20 left-1/2 -translate-x-1/2 pointer-events-none
|
||
flex flex-col items-center gap-1 px-5 py-3 rounded-xl border border-[#ff2d55]/40
|
||
bg-[#1a0508]/85 backdrop-blur-sm text-center enter"><div class="font-mono text-[11px] tracking-[0.2em] text-[#ff5c78] uppercase">⬤ threat quarantined</div> <div class="font-mono text-[13px] text-[#ffd0d8] max-w-sm truncate"> </div> <div class="font-mono text-[10px] tracking-wide text-[#ff5c78]/70">memory held in review · Memory PR opened</div></div>`),Gm=vt(`<button class="absolute bottom-4 right-4 pointer-events-auto flex items-center gap-2 px-3 py-1.5
|
||
rounded-xl border border-[#22C7DE]/25 bg-[#05060a]/80 backdrop-blur-sm
|
||
font-mono text-[11px] tracking-wide text-[#22C7DE]/80 hover:text-[#22C7DE]
|
||
hover:border-[#22C7DE]/50 transition-colors"> </button>`),Wm=vt('<button class="text-[#22C7DE]/60 hover:text-[#22C7DE] transition-colors" title="Return to now">reset</button>'),Hm=vt(`<div class="absolute bottom-4 left-1/2 -translate-x-1/2 pointer-events-auto
|
||
flex items-center gap-3 px-4 py-2.5 rounded-xl border border-[#22C7DE]/25
|
||
bg-[#05060a]/80 backdrop-blur-sm font-mono text-[11px] tracking-wide"><span class="text-[#22C7DE]/80 uppercase">Forgetting horizon</span> <input type="range" min="0" max="365" step="1" class="w-40 sm:w-56 accent-[#22C7DE] cursor-pointer" aria-label="Project the forgetting curve forward N days" title="Project every memory forward on its real FSRS curve"/> <span class="text-[#7fe6c0] w-16 text-right tabular-nums"> </span> <!></div>`),qm=vt(`<button class="absolute top-10 right-4 pointer-events-auto font-mono text-xs tracking-widest
|
||
text-[#5dcaa5]/70 hover:text-[#5dcaa5] border border-[#5dcaa5]/25 hover:border-[#5dcaa5]/60
|
||
bg-[#05060a]/70 rounded px-3 py-1.5 transition-colors" title="Exit Observatory (Esc)">× EXIT</button>`),Xm=vt("<button> </button>"),Ym=vt('<div class="absolute top-10 left-4 pointer-events-auto flex flex-col gap-1.5"></div>'),Jm=vt('<div class="absolute inset-0 flex items-center justify-center pointer-events-auto"><div class="text-[#5dcaa5] font-mono text-sm tracking-widest animate-pulse">LOADING MEMORY FIELD...</div></div>'),Zm=vt('<div class="absolute inset-0 flex items-center justify-center pointer-events-auto"><div class="text-red-400 font-mono text-sm border border-red-900/50 bg-red-950/30 px-4 py-2 rounded"> </div></div>'),$m=vt('<div class="absolute inset-0 flex items-center justify-center pointer-events-auto"><div class="text-[#5dcaa5] font-mono text-sm tracking-widest">NO MEMORIES IN FIELD</div></div>'),jm=vt('<div class="absolute inset-0 z-10 pointer-events-none"><!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!></div>'),Km=vt("<div><div><!></div> <!></div>");function mx(l,t){Wn(t,!0);const e=()=>jl(tc,"$eventFeed",i),[i,s]=Kl();let n=ut(t,"seed",3,"vestige-observatory-v1"),r=ut(t,"freezeFrame",3,null),a=ut(t,"capture",3,!1),o=ut(t,"showSwitcher",3,!0),h=ut(t,"embedded",3,!1),c=ut(t,"chrome",3,"full"),u=ut(t,"live",3,!1),d=xt(0),f=null,p=xt(!1),m=xt(!1),g=xt(!1);function x(){if(typeof window>"u")return;const O=window.matchMedia("(prefers-reduced-motion: reduce)");O.matches&&!F(g)&&rt(m,!0);const K=lt=>{F(g)||rt(m,lt.matches,!0)};return O.addEventListener("change",K),()=>O.removeEventListener("change",K)}function y(){rt(g,!0),rt(m,!F(m))}ji(()=>{var O;(O=F(tt))==null||O.setPaused(F(m))});let b=xt(""),v=xt(0),_=Bn(()=>F(b)!==""&&F(v)>0),M=xt(null);async function A(O){if(!t.onpick||!J||!F(M))return;const K=F(M).getBoundingClientRect();if(K.width===0||K.height===0)return;const lt=(O.clientX-K.left)/K.width*2-1,ie=-((O.clientY-K.top)/K.height*2-1),$=await J.pickAt(lt,ie);$&&t.onpick($.id)}const S={"recall-path":"RECALL","engram-birth":"BIRTH","salience-rescue":"RESCUE","forgetting-horizon":"HORIZON",firewall:"FIREWALL"};let T=xt(!a());function C(O){(O.key==="h"||O.key==="H")&&rt(T,!F(T)),O.key==="Escape"&&t.onexit&&t.onexit()}let P=xt(null),V=xt(!0),q=xt(""),L=xt(0),I=xt(0),U=xt(0),wt=xt(0),Ct=xt(""),tt=xt(null),J=null,ht=null,Ut=null,oe=xt(null),di=null,Ye=null,Ee=xt(null),Yt=!1,he=xt(Gl([]));async function Qn(){rt(V,!0),rt(q,"");try{const O=await Ql.graph({max_nodes:200,depth:3,sort:"connected"});rt(P,O,!0),rt(U,O.nodeCount,!0),rt(wt,O.edgeCount,!0),rt(Ct,O.center_id,!0)}catch(O){rt(q,O instanceof Error?O.message:"Failed to load graph data",!0)}finally{rt(V,!1)}}function le(O,K){rt(L,O,!0),rt(I,K,!0)}function ce(O){var K;Yt=!1,rt(tt,O,!0),J=new _p(O),(K=t.onready)==null||K.call(t,O)}ji(()=>{if(F(tt)&&J&&F(P)&&!Yt){Yt=!0;const O=t.demo==="engram-birth",K=t.demo==="salience-rescue",lt=t.demo==="forgetting-horizon",ie=t.demo==="firewall";if(J.upload(F(P),n(),{recallPath:!O&&!K&&!lt&&!ie}),O){ht=new Lp({engine:F(tt),nodeRenderer:J,seed:n()}),ht.upload(n());const $=ht.engraveSteps,Vt=[];for(let Bt=0;Bt<$.length/4;Bt++)Vt.push({sourceIndex:$[Bt*4],targetIndex:$[Bt*4+1],beatFrame:$[Bt*4+2],kind:$[Bt*4+3],beatKind:"engrave",nodeId:`engrave-${Bt}`,label:"edge engraved"});J.setPathSteps($,Vt),rt(he,ht.timeline.map((Bt,fi)=>({sourceIndex:0,targetIndex:0,beatFrame:Bt.startFrame,kind:0,beatKind:"birth",nodeId:`birth-${fi}`,label:Bt.label})),!0)}else if(K){const $=sm(F(P),J.graph,n());rt(oe,$,!0),$.viable&&(Ut=new Vp({engine:F(tt),nodeRenderer:J,plan:$}),Ut.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else if(lt){const $=gm(J.graph);$.viable&&(di=new am({engine:F(tt),nodeRenderer:J,plan:$}),di.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else if(ie){const $=Pm(J.graph,n());rt(Ee,$,!0),$.viable&&(Ye=new Il({engine:F(tt),nodeRenderer:J,plan:$}),Ye.upload(),J.setPathSteps($.pathData,$.pathMetas)),rt(he,$.spineBeats,!0)}else rt(he,J.pathSteps,!0);u()&&J.graph&&F(P)&&(f=new Nm({engine:F(tt),renderer:J,graph:J.graph,response:F(P),seed:n(),projectionDays:()=>F(d),onFirewall:$=>{rt(b,$.intruderLabel,!0),rt(v,Date.now(),!0)}}),rt(p,f.liveDecayAvailable,!0),F(tt).setPreFrameHook($=>f==null?void 0:f.drain($)),typeof window<"u"&&(window.__vestigeLiveBridge=f)),F(tt).demoClock.reset()}}),ji(()=>{const O=e();f&&f.ingest(O)}),ji(()=>{F(d),f==null||f.refreshDecay()}),ji(()=>{if(!F(v))return;const O=setTimeout(()=>{rt(b,""),rt(v,0)},7e3);return()=>clearTimeout(O)}),Xl(()=>(Qn(),x()));var k=Km();Yl("keydown",Wl,C);let E;var R=ot(k);let W;var N=ot(R);sc(N,{get demo(){return t.demo},get seed(){return n()},get freezeFrame(){return r()},onframe:le,onready:ce}),at(R),Jl(R,O=>rt(M,O),()=>F(M));var et=ct(R,2);{var nt=O=>{var K=jm(),lt=ot(K);{var ie=H=>{var Q=Vm(),Tt=ct(ot(Q),2),Rt=ot(Tt,!0);at(Tt),Hl(2),at(Q),jt(()=>Ot(Rt,F(b))),mt(H,Q)};_t(lt,H=>{u()&&F(_)&&H(ie)})}var $=ct(lt,2);{var Vt=H=>{var Q=Gm(),Tt=ot(Q,!0);at(Q),jt(()=>{Cn(Q,"title",F(m)?"Resume field motion":"Pause field motion (event pulses stay live)"),Cn(Q,"aria-pressed",F(m)),Ot(Tt,F(m)?"▶ RESUME":"❚❚ PAUSE")}),Ri("click",Q,y),mt(H,Q)};_t($,H=>{u()&&H(Vt)})}var Bt=ct($,2);{var fi=H=>{var Q=Hm(),Tt=ct(ot(Q),2);Zl(Tt);var Rt=ct(Tt,2),Oe=ot(Rt,!0);at(Rt);var er=ct(Rt,2);{var Os=$i=>{var Xa=Wm();Ri("click",Xa,()=>rt(d,0)),mt($i,Xa)};_t(er,$i=>{F(d)!==0&&$i(Os)})}at(Q),jt(()=>Ot(Oe,F(d)===0?"now":`+${F(d)}d`)),$l(Tt,()=>F(d),$i=>rt(d,$i)),mt(H,Q)};_t(Bt,H=>{u()&&F(p)&&H(fi)})}var Ji=ct(Bt,2);{var tr=H=>{cp(H,{get demoMode(){return t.demo},get seed(){return n()},get nodeCount(){return F(U)},get edgeCount(){return F(wt)},get centerId(){return F(Ct)},get frameCount(){return F(L)},get fpsEstimate(){return F(I)},get freezeFrame(){return r()},get loading(){return F(V)},get error(){return F(q)}})};_t(Ji,H=>{c()==="full"&&H(tr)})}var Rs=ct(Ji,2);{var Es=H=>{var Q=qm();Ri("click",Q,function(...Tt){var Rt;(Rt=t.onexit)==null||Rt.apply(this,Tt)}),mt(H,Q)};_t(Rs,H=>{c()==="full"&&t.onexit&&H(Es)})}var Zi=ct(Rs,2);{var Cl=H=>{var Q=Ym();Eh(Q,20,()=>nc,Tt=>Tt,(Tt,Rt)=>{var Oe=Xm(),er=ot(Oe,!0);at(Oe),jt(()=>{vs(Oe,1,`font-mono text-[11px] tracking-widest text-left rounded px-3 py-1.5 border transition-colors
|
||
${Rt===t.demo?"text-[#05060a] bg-[#5dcaa5] border-[#5dcaa5]":"text-[#5dcaa5]/60 hover:text-[#5dcaa5] bg-[#05060a]/70 border-[#5dcaa5]/20 hover:border-[#5dcaa5]/50"}`),Cn(Oe,"title",`Play the ${S[Rt]??""} moment`),Ot(er,S[Rt])}),Ri("click",Oe,()=>{var Os;return(Os=t.ondemochange)==null?void 0:Os.call(t,Rt)}),mt(Tt,Oe)}),at(Q),mt(H,Q)};_t(Zi,H=>{c()==="full"&&o()&&H(Cl)})}var Va=ct(Zi,2);{var Bl=H=>{var Q=Jm();mt(H,Q)};_t(Va,H=>{F(V)&&H(Bl)})}var Ga=ct(Va,2);{var zl=H=>{var Q=Zm(),Tt=ot(Q),Rt=ot(Tt,!0);at(Tt),at(Q),jt(()=>Ot(Rt,F(q))),mt(H,Q)};_t(Ga,H=>{F(q)&&!F(V)&&H(zl)})}var Wa=ct(Ga,2);{var kl=H=>{pp(H,{get steps(){return F(he)},get frame(){return F(L)}})};_t(Wa,H=>{c()==="full"&&H(kl)})}var Ha=ct(Wa,2);{var Pl=H=>{xh(H,{get frame(){return F(L)},get verdict(){return F(oe).verdict}})};_t(Ha,H=>{var Q;c()==="full"&&t.demo==="salience-rescue"&&((Q=F(oe))!=null&&Q.viable)&&H(Pl)})}var qa=ct(Ha,2);{var Fl=H=>{{let Q=Bn(()=>({headline:F(Ee).verdict.headline,causeLabel:F(Ee).verdict.intruderLabel,receipt:F(Ee).verdict.receipt}));xh(H,{get frame(){return F(L)},tone:"quarantine",fadeWindow:[480,495,605,620],get verdict(){return F(Q)}})}};_t(qa,H=>{var Q;c()==="full"&&t.demo==="firewall"&&((Q=F(Ee))!=null&&Q.viable)&&H(Fl)})}var Rl=ct(qa,2);{var El=H=>{var Q=$m();mt(H,Q)};_t(Rl,H=>{!F(V)&&F(P)&&F(P).nodeCount===0&&H(El)})}at(K),mt(O,K)};_t(et,O=>{F(T)&&O(nt)})}at(k),jt(()=>{E=vs(k,1,`${h()?"absolute":"fixed"} inset-0 overflow-hidden bg-[#05060a]`,null,E,{"cursor-none":a()}),W=vs(R,1,"absolute inset-0 z-0",null,W,{"cursor-crosshair":!!t.onpick&&!a()})}),Ri("click",R,A),mt(l,k),Hn(),s()}Rh(["click"]);export{fl as $,Dh as A,Lh as B,G as C,qg as D,Xe as E,my as F,Kh as G,vc as H,ma as I,ee as J,qe as K,lf as L,ey as M,ac as N,Nt as O,jh as P,Za as Q,ha as R,Pn as S,Oa as T,ra as U,w as V,Fn as W,zy as X,Hi as Y,_g as Z,qt as _,be as a,pe as a$,re as a0,Xn as a1,yt as a2,My as a3,sg as a4,io as a5,Z as a6,Wh as a7,sa as a8,xe as a9,T0 as aA,sy as aB,Mf as aC,Af as aD,Tf as aE,If as aF,bf as aG,Bf as aH,ng as aI,rg as aJ,ag as aK,og as aL,lg as aM,cg as aN,M0 as aO,cc as aP,uc as aQ,Fs as aR,eo as aS,sr as aT,Mc as aU,Nh as aV,iy as aW,Yr as aX,ge as aY,Xr as aZ,fc as a_,Lg as aa,I0 as ab,Bc as ac,Kd as ad,_s as ae,ft as af,vy as ag,ig as ah,eg as ai,ia as aj,Hh as ak,Gi as al,xy as am,td as an,Qu as ao,dc as ap,j as aq,As as ar,D as as,st as at,pg as au,Pi as av,ne as aw,S0 as ax,$h as ay,qr as az,B as b,qc as b$,Gg as b0,Vg as b1,Wg as b2,Ng as b3,Ug as b4,Hg as b5,Dg as b6,P0 as b7,k0 as b8,$a as b9,wc as bA,_c as bB,Sc as bC,gc as bD,yc as bE,xc as bF,Ac as bG,Ic as bH,Tc as bI,Cc as bJ,Uh as bK,Vh as bL,zc as bM,kc as bN,Pc as bO,Fc as bP,Rc as bQ,Ec as bR,Oc as bS,Dc as bT,Lc as bU,Nc as bV,Uc as bW,Vc as bX,Gc as bY,Wc as bZ,Hc as b_,U0 as ba,G0 as bb,Ka as bc,L0 as bd,N0 as be,V0 as bf,W0 as bg,ja as bh,D0 as bi,O0 as bj,E0 as bk,b0 as bl,v0 as bm,w0 as bn,z0 as bo,B0 as bp,C0 as bq,oc as br,tg as bs,Q0 as bt,K0 as bu,j0 as bv,Qa as bw,$0 as bx,Z0 as by,J0 as bz,Wi as c,nx as c$,Xc as c0,Yc as c1,Jc as c2,Zc as c3,$c as c4,jc as c5,Kc as c6,Qc as c7,tu as c8,eu as c9,F0 as cA,da as cB,mg as cC,Gh as cD,Yf as cE,Vn as cF,Ay as cG,Ny as cH,Ly as cI,Sy as cJ,xd as cK,Ry as cL,ox as cM,to as cN,Ef as cO,Dy as cP,pl as cQ,Ey as cR,Py as cS,hx as cT,fu as cU,md as cV,Zh as cW,Xi as cX,Jy as cY,Ht as cZ,rx as c_,iu as ca,su as cb,au as cc,ou as cd,hu as ce,lu as cf,Pe as cg,Xu as ch,qu as ci,Eg as cj,Rg as ck,Og as cl,Pg as cm,Fg as cn,kg as co,no as cp,zg as cq,Cg as cr,Tg as cs,Ig as ct,Ag as cu,Bg as cv,Sg as cw,Mg as cx,pi as cy,R0 as cz,$t as d,ed as d$,kf as d0,He as d1,ua as d2,sx as d3,Qh as d4,va as d5,bd as d6,wa as d7,Ff as d8,ul as d9,Ma as dA,jg as dB,Jg as dC,zd as dD,xa as dE,Sa as dF,pa as dG,fa as dH,Hy as dI,Qg as dJ,ty as dK,tx as dL,Qy as dM,Aa as dN,ky as dO,Gn as dP,Fu as dQ,zf as dR,ad as dS,fy as dT,py as dU,cy as dV,jn as dW,zn as dX,Jr as dY,nr as dZ,we as d_,wy as da,_y as db,ya as dc,Iy as dd,_a as de,X0 as df,H0 as dg,cx as dh,Ty as di,tl as dj,Td as dk,df as dl,_0 as dm,ve as dn,Bd as dp,hg as dq,Ps as dr,Yy as ds,qh as dt,Cy as du,ly as dv,yf as dw,hc as dx,ix as dy,ff as dz,rr as e,Li as e$,Jn as e0,Xh as e1,ui as e2,hi as e3,Zy as e4,el as e5,Cd as e6,gd as e7,Re as e8,cl as e9,Oy as eA,it as eB,Df as eC,il as eD,sl as eE,te as eF,Kn as eG,pf as eH,bg as eI,vg as eJ,nu as eK,ru as eL,wg as eM,Qd as eN,ks as eO,qy as eP,Uy as eQ,Vy as eR,Ta as eS,ca as eT,Vi as eU,Ca as eV,lx as eW,Fe as eX,ga as eY,jy as eZ,sd as e_,fg as ea,so as eb,jo as ec,dl as ed,cu as ee,du as ef,uu as eg,y0 as eh,gl as ei,af as ej,of as ek,dg as el,ug as em,aa as en,Nn as eo,$n as ep,Y0 as eq,q0 as er,A0 as es,Ln as et,Ia as eu,ax as ev,Ky as ew,yd as ex,ex as ey,ci as ez,na as f,Lt as f0,Xy as f1,Cf as f2,nl as f3,$y as f4,bs as f5,$g as f6,Yg as f7,Fy as f8,Kg as f9,Oi as fA,g0 as fB,mx as fC,ry as fD,ay as fE,ny as fF,Is as fG,yy as fH,gy as fI,Yn as fJ,tp as fK,zu as fL,Zu as fM,Rn as fN,ip as fO,px as fP,dx as fQ,bl as fR,np as fS,In as fT,Gr as fU,rp as fV,fx as fW,Vr as fX,Xg as fa,Zg as fb,Yi as fc,x0 as fd,Ba as fe,By as ff,ux as fg,za as fh,ka as fi,Kt as fj,xg as fk,yg as fl,gg as fm,Pa as fn,uy as fo,dy as fp,ml as fq,Gy as fr,Un as fs,by as ft,hy as fu,oy as fv,la as fw,jd as fx,kn as fy,Ei as fz,lc as g,Be as h,wf as i,Wy as j,Ts as k,Xt as l,qi as m,rf as n,hf as o,nf as p,ef as q,tf as r,Fa as s,sf as t,ae as u,mc as v,pc as w,qn as x,It as y,bc as z};
|