@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
5 lines • 5.56 MB
JavaScript
var I6=Object.defineProperty,o6=(i,A,t)=>A in i?I6(i,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[A]=t,Q=(i,A,t)=>(o6(i,typeof A!="symbol"?A+"":A,t),t),EU=(i,A,t)=>{if(!A.has(i))throw TypeError("Cannot "+t)},Gt=(i,A,t)=>(EU(i,A,"read from private field"),t?t.call(i):A.get(i)),_s=(i,A,t)=>{if(A.has(i))throw TypeError("Cannot add the same private member more than once");A instanceof WeakSet?A.add(i):A.set(i,t)},pa=(i,A,t,g)=>(EU(i,A,"write to private field"),g?g.call(i,t):A.set(i,t),t),sc=(i,A,t)=>(EU(i,A,"access private method"),t);/**
* @license
* Copyright 2010-2023 Three.js Authors
* SPDX-License-Identifier: MIT
*/const Sr="162",XQ={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},VQ={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},H2=0,dU=1,_2=2,s6=3,n6=0,uU=1,pU=2,Da=3,Ui=0,pi=1,kt=2,Di=0,jC=1,jQ=2,DU=3,yU=4,mU=5,zC=100,O2=101,P2=102,wU=103,Mm=104,Z2=200,W2=201,X2=202,V2=203,Rm=204,Um=205,j2=206,z2=207,$2=208,AY=209,eY=210,tY=211,iY=212,gY=213,IY=214,SU=0,Nm=1,qu=2,zQ=3,nc=4,bm=5,Fm=6,Tu=7,Yu=0,oY=1,sY=2,go=0,ac=1,Hu=2,nY=3,_u=4,aY=5,rc=6,$Q=7,fU="attached",rY="detached",Km=300,fr=301,$C=302,Io=303,Cc=304,Bc=306,oo=1e3,lg=1001,Gr=1002,xe=1003,Qc=1004,a6=1004,kr=1005,r6=1005,Fe=1006,Al=1007,C6=1007,so=1008,B6=1008,mt=1009,vm=1010,GU=1011,Ou=1012,el=1013,JI=1014,vt=1015,Ni=1016,kU=1017,MU=1018,Mr=1020,CY=1021,at=1023,xm=1024,BY=1025,AB=1026,eB=1027,Os=1028,Jm=1029,Rr=1030,Pu=1031,lc=1033,Zu=33776,Lm=33777,qm=33778,Wu=33779,Tm=35840,RU=35841,Ym=35842,UU=35843,Hm=36196,_m=37492,Om=37496,Pm=37808,NU=37809,bU=37810,FU=37811,Xu=37812,KU=37813,vU=37814,xU=37815,JU=37816,LU=37817,qU=37818,TU=37819,YU=37820,HU=37821,Vu=36492,_U=36494,OU=36495,QY=36283,PU=36284,ZU=36285,WU=36286,ju=2200,XU=2201,lY=2202,tB=2300,ya=2301,Zm=2302,tl=2400,il=2401,zu=2402,Wm=2500,VU=2501,hY=0,jU=1,Xm=2,cY=3e3,zU=3001,CI=3200,Vm=3201,iB=0,EY=1,no="",le="srgb",xt="srgb-linear",$u="display-p3",hc="display-p3-linear",Ap="linear",gi="srgb",ep="rec709",tp="p3",dY=0,gB=7680,uY=7681,pY=7682,DY=7683,yY=34055,mY=34056,wY=5386,$U=512,SY=513,fY=514,GY=515,kY=516,MY=517,RY=518,jm=519,UY=512,NY=513,bY=514,AN=515,FY=516,KY=517,vY=518,xY=519,ip=35044,LI=35048,Q6=35040,l6=35045,h6=35049,c6=35041,E6=35046,d6=35050,u6=35042,p6="100",zm="300 es",$m=1035,ma=2e3,gp=2001;let Og=class{addEventListener(i,A){this._listeners===void 0&&(this._listeners={});const t=this._listeners;t[i]===void 0&&(t[i]=[]),t[i].indexOf(A)===-1&&t[i].push(A)}hasEventListener(i,A){if(this._listeners===void 0)return!1;const t=this._listeners;return t[i]!==void 0&&t[i].indexOf(A)!==-1}removeEventListener(i,A){if(this._listeners===void 0)return;const t=this._listeners[i];if(t!==void 0){const g=t.indexOf(A);g!==-1&&t.splice(g,1)}}dispatchEvent(i){if(this._listeners===void 0)return;const A=this._listeners[i.type];if(A!==void 0){i.target=this;const t=A.slice(0);for(let g=0,I=t.length;g<I;g++)t[g].call(this,i);i.target=null}}};const qI=["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 JY=1234567;const gl=Math.PI/180,cc=180/Math.PI;function ts(){const i=Math.random()*4294967295|0,A=Math.random()*4294967295|0,t=Math.random()*4294967295|0,g=Math.random()*4294967295|0;return(qI[i&255]+qI[i>>8&255]+qI[i>>16&255]+qI[i>>24&255]+"-"+qI[A&255]+qI[A>>8&255]+"-"+qI[A>>16&15|64]+qI[A>>24&255]+"-"+qI[t&63|128]+qI[t>>8&255]+"-"+qI[t>>16&255]+qI[t>>24&255]+qI[g&255]+qI[g>>8&255]+qI[g>>16&255]+qI[g>>24&255]).toLowerCase()}function Oi(i,A,t){return Math.max(A,Math.min(t,i))}function eN(i,A){return(i%A+A)%A}function D6(i,A,t,g,I){return g+(i-A)*(I-g)/(t-A)}function y6(i,A,t){return i!==A?(t-i)/(A-i):0}function Ip(i,A,t){return(1-t)*i+t*A}function m6(i,A,t,g){return Ip(i,A,1-Math.exp(-t*g))}function w6(i,A=1){return A-Math.abs(eN(i,A*2)-A)}function S6(i,A,t){return i<=A?0:i>=t?1:(i=(i-A)/(t-A),i*i*(3-2*i))}function f6(i,A,t){return i<=A?0:i>=t?1:(i=(i-A)/(t-A),i*i*i*(i*(i*6-15)+10))}function G6(i,A){return i+Math.floor(Math.random()*(A-i+1))}function k6(i,A){return i+Math.random()*(A-i)}function M6(i){return i*(.5-Math.random())}function R6(i){i!==void 0&&(JY=i);let A=JY+=1831565813;return A=Math.imul(A^A>>>15,A|1),A^=A+Math.imul(A^A>>>7,A|61),((A^A>>>14)>>>0)/4294967296}function U6(i){return i*gl}function N6(i){return i*cc}function tN(i){return(i&i-1)===0&&i!==0}function b6(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Aw(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function F6(i,A,t,g,I){const o=Math.cos,s=Math.sin,n=o(t/2),a=s(t/2),r=o((A+g)/2),C=s((A+g)/2),B=o((A-g)/2),l=s((A-g)/2),h=o((g-A)/2),c=s((g-A)/2);switch(I){case"XYX":i.set(n*C,a*B,a*l,n*r);break;case"YZY":i.set(a*l,n*C,a*B,n*r);break;case"ZXZ":i.set(a*B,a*l,n*C,n*r);break;case"XZX":i.set(n*C,a*c,a*h,n*r);break;case"YXY":i.set(a*h,n*C,a*c,n*r);break;case"ZYZ":i.set(a*c,a*h,n*C,n*r);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+I)}}function ao(i,A){switch(A.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function $e(i,A){switch(A.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const rt={DEG2RAD:gl,RAD2DEG:cc,generateUUID:ts,clamp:Oi,euclideanModulo:eN,mapLinear:D6,inverseLerp:y6,lerp:Ip,damp:m6,pingpong:w6,smoothstep:S6,smootherstep:f6,randInt:G6,randFloat:k6,randFloatSpread:M6,seededRandom:R6,degToRad:U6,radToDeg:N6,isPowerOfTwo:tN,ceilPowerOfTwo:b6,floorPowerOfTwo:Aw,setQuaternionFromProperEuler:F6,normalize:$e,denormalize:ao};let j=class X9{constructor(A=0,t=0){X9.prototype.isVector2=!0,this.x=A,this.y=t}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}set(A,t){return this.x=A,this.y=t,this}setScalar(A){return this.x=A,this.y=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setComponent(A,t){switch(A){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y)}copy(A){return this.x=A.x,this.y=A.y,this}add(A){return this.x+=A.x,this.y+=A.y,this}addScalar(A){return this.x+=A,this.y+=A,this}addVectors(A,t){return this.x=A.x+t.x,this.y=A.y+t.y,this}addScaledVector(A,t){return this.x+=A.x*t,this.y+=A.y*t,this}sub(A){return this.x-=A.x,this.y-=A.y,this}subScalar(A){return this.x-=A,this.y-=A,this}subVectors(A,t){return this.x=A.x-t.x,this.y=A.y-t.y,this}multiply(A){return this.x*=A.x,this.y*=A.y,this}multiplyScalar(A){return this.x*=A,this.y*=A,this}divide(A){return this.x/=A.x,this.y/=A.y,this}divideScalar(A){return this.multiplyScalar(1/A)}applyMatrix3(A){const t=this.x,g=this.y,I=A.elements;return this.x=I[0]*t+I[3]*g+I[6],this.y=I[1]*t+I[4]*g+I[7],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this}clamp(A,t){return this.x=Math.max(A.x,Math.min(t.x,this.x)),this.y=Math.max(A.y,Math.min(t.y,this.y)),this}clampScalar(A,t){return this.x=Math.max(A,Math.min(t,this.x)),this.y=Math.max(A,Math.min(t,this.y)),this}clampLength(A,t){const g=this.length();return this.divideScalar(g||1).multiplyScalar(Math.max(A,Math.min(t,g)))}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(A){return this.x*A.x+this.y*A.y}cross(A){return this.x*A.y-this.y*A.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(A){const t=Math.sqrt(this.lengthSq()*A.lengthSq());if(t===0)return Math.PI/2;const g=this.dot(A)/t;return Math.acos(Oi(g,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){const t=this.x-A.x,g=this.y-A.y;return t*t+g*g}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,t){return this.x+=(A.x-this.x)*t,this.y+=(A.y-this.y)*t,this}lerpVectors(A,t,g){return this.x=A.x+(t.x-A.x)*g,this.y=A.y+(t.y-A.y)*g,this}equals(A){return A.x===this.x&&A.y===this.y}fromArray(A,t=0){return this.x=A[t],this.y=A[t+1],this}toArray(A=[],t=0){return A[t]=this.x,A[t+1]=this.y,A}fromBufferAttribute(A,t){return this.x=A.getX(t),this.y=A.getY(t),this}rotateAround(A,t){const g=Math.cos(t),I=Math.sin(t),o=this.x-A.x,s=this.y-A.y;return this.x=o*g-s*I+A.x,this.y=o*I+s*g+A.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Je=class V9{constructor(A,t,g,I,o,s,n,a,r){V9.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],A!==void 0&&this.set(A,t,g,I,o,s,n,a,r)}set(A,t,g,I,o,s,n,a,r){const C=this.elements;return C[0]=A,C[1]=I,C[2]=n,C[3]=t,C[4]=o,C[5]=a,C[6]=g,C[7]=s,C[8]=r,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){const t=this.elements,g=A.elements;return t[0]=g[0],t[1]=g[1],t[2]=g[2],t[3]=g[3],t[4]=g[4],t[5]=g[5],t[6]=g[6],t[7]=g[7],t[8]=g[8],this}extractBasis(A,t,g){return A.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),g.setFromMatrix3Column(this,2),this}setFromMatrix4(A){const t=A.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,t){const g=A.elements,I=t.elements,o=this.elements,s=g[0],n=g[3],a=g[6],r=g[1],C=g[4],B=g[7],l=g[2],h=g[5],c=g[8],E=I[0],d=I[3],u=I[6],p=I[1],D=I[4],y=I[7],m=I[2],S=I[5],w=I[8];return o[0]=s*E+n*p+a*m,o[3]=s*d+n*D+a*S,o[6]=s*u+n*y+a*w,o[1]=r*E+C*p+B*m,o[4]=r*d+C*D+B*S,o[7]=r*u+C*y+B*w,o[2]=l*E+h*p+c*m,o[5]=l*d+h*D+c*S,o[8]=l*u+h*y+c*w,this}multiplyScalar(A){const t=this.elements;return t[0]*=A,t[3]*=A,t[6]*=A,t[1]*=A,t[4]*=A,t[7]*=A,t[2]*=A,t[5]*=A,t[8]*=A,this}determinant(){const A=this.elements,t=A[0],g=A[1],I=A[2],o=A[3],s=A[4],n=A[5],a=A[6],r=A[7],C=A[8];return t*s*C-t*n*r-g*o*C+g*n*a+I*o*r-I*s*a}invert(){const A=this.elements,t=A[0],g=A[1],I=A[2],o=A[3],s=A[4],n=A[5],a=A[6],r=A[7],C=A[8],B=C*s-n*r,l=n*a-C*o,h=r*o-s*a,c=t*B+g*l+I*h;if(c===0)return this.set(0,0,0,0,0,0,0,0,0);const E=1/c;return A[0]=B*E,A[1]=(I*r-C*g)*E,A[2]=(n*g-I*s)*E,A[3]=l*E,A[4]=(C*t-I*a)*E,A[5]=(I*o-n*t)*E,A[6]=h*E,A[7]=(g*a-r*t)*E,A[8]=(s*t-g*o)*E,this}transpose(){let A;const t=this.elements;return A=t[1],t[1]=t[3],t[3]=A,A=t[2],t[2]=t[6],t[6]=A,A=t[5],t[5]=t[7],t[7]=A,this}getNormalMatrix(A){return this.setFromMatrix4(A).invert().transpose()}transposeIntoArray(A){const t=this.elements;return A[0]=t[0],A[1]=t[3],A[2]=t[6],A[3]=t[1],A[4]=t[4],A[5]=t[7],A[6]=t[2],A[7]=t[5],A[8]=t[8],this}setUvTransform(A,t,g,I,o,s,n){const a=Math.cos(o),r=Math.sin(o);return this.set(g*a,g*r,-g*(a*s+r*n)+s+A,-I*r,I*a,-I*(-r*s+a*n)+n+t,0,0,1),this}scale(A,t){return this.premultiply(iN.makeScale(A,t)),this}rotate(A){return this.premultiply(iN.makeRotation(-A)),this}translate(A,t){return this.premultiply(iN.makeTranslation(A,t)),this}makeTranslation(A,t){return A.isVector2?this.set(1,0,A.x,0,1,A.y,0,0,1):this.set(1,0,A,0,1,t,0,0,1),this}makeRotation(A){const t=Math.cos(A),g=Math.sin(A);return this.set(t,-g,0,g,t,0,0,0,1),this}makeScale(A,t){return this.set(A,0,0,0,t,0,0,0,1),this}equals(A){const t=this.elements,g=A.elements;for(let I=0;I<9;I++)if(t[I]!==g[I])return!1;return!0}fromArray(A,t=0){for(let g=0;g<9;g++)this.elements[g]=A[g+t];return this}toArray(A=[],t=0){const g=this.elements;return A[t]=g[0],A[t+1]=g[1],A[t+2]=g[2],A[t+3]=g[3],A[t+4]=g[4],A[t+5]=g[5],A[t+6]=g[6],A[t+7]=g[7],A[t+8]=g[8],A}clone(){return new this.constructor().fromArray(this.elements)}};const iN=new Je;function LY(i){for(let A=i.length-1;A>=0;--A)if(i[A]>=65535)return!0;return!1}const K6={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ec(i,A){return new K6[i](A)}function op(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function qY(){const i=op("canvas");return i.style.display="block",i}const TY={};function YY(i){i in TY||(TY[i]=!0,console.warn(i))}const HY=new Je().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),_Y=new Je().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ew={[xt]:{transfer:Ap,primaries:ep,toReference:i=>i,fromReference:i=>i},[le]:{transfer:gi,primaries:ep,toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[hc]:{transfer:Ap,primaries:tp,toReference:i=>i.applyMatrix3(_Y),fromReference:i=>i.applyMatrix3(HY)},[$u]:{transfer:gi,primaries:tp,toReference:i=>i.convertSRGBToLinear().applyMatrix3(_Y),fromReference:i=>i.applyMatrix3(HY).convertLinearToSRGB()}},v6=new Set([xt,hc]),bt={enabled:!0,_workingColorSpace:xt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!v6.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,A,t){if(this.enabled===!1||A===t||!A||!t)return i;const g=ew[A].toReference,I=ew[t].fromReference;return I(g(i))},fromWorkingColorSpace:function(i,A){return this.convert(i,this._workingColorSpace,A)},toWorkingColorSpace:function(i,A){return this.convert(i,A,this._workingColorSpace)},getPrimaries:function(i){return ew[i].primaries},getTransfer:function(i){return i===no?Ap:ew[i].transfer}};function dc(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function gN(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let uc,IN=class{static getDataURL(i){if(/^data:/i.test(i.src)||typeof HTMLCanvasElement>"u")return i.src;let A;if(i instanceof HTMLCanvasElement)A=i;else{uc===void 0&&(uc=op("canvas")),uc.width=i.width,uc.height=i.height;const t=uc.getContext("2d");i instanceof ImageData?t.putImageData(i,0,0):t.drawImage(i,0,0,i.width,i.height),A=uc}return A.width>2048||A.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",i),A.toDataURL("image/jpeg",.6)):A.toDataURL("image/png")}static sRGBToLinear(i){if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap){const A=op("canvas");A.width=i.width,A.height=i.height;const t=A.getContext("2d");t.drawImage(i,0,0,i.width,i.height);const g=t.getImageData(0,0,i.width,i.height),I=g.data;for(let o=0;o<I.length;o++)I[o]=dc(I[o]/255)*255;return t.putImageData(g,0,0),A}else if(i.data){const A=i.data.slice(0);for(let t=0;t<A.length;t++)A instanceof Uint8Array||A instanceof Uint8ClampedArray?A[t]=Math.floor(dc(A[t]/255)*255):A[t]=dc(A[t]);return{data:A,width:i.width,height:i.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),i}},x6=0,Ur=class{constructor(i=null){this.isSource=!0,Object.defineProperty(this,"id",{value:x6++}),this.uuid=ts(),this.data=i,this.dataReady=!0,this.version=0}set needsUpdate(i){i===!0&&this.version++}toJSON(i){const A=i===void 0||typeof i=="string";if(!A&&i.images[this.uuid]!==void 0)return i.images[this.uuid];const t={uuid:this.uuid,url:""},g=this.data;if(g!==null){let I;if(Array.isArray(g)){I=[];for(let o=0,s=g.length;o<s;o++)g[o].isDataTexture?I.push(oN(g[o].image)):I.push(oN(g[o]))}else I=oN(g);t.url=I}return A||(i.images[this.uuid]=t),t}};function oN(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?IN.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let J6=0,Ye=class _R extends Og{constructor(A=_R.DEFAULT_IMAGE,t=_R.DEFAULT_MAPPING,g=lg,I=lg,o=Fe,s=so,n=at,a=mt,r=_R.DEFAULT_ANISOTROPY,C=no){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:J6++}),this.uuid=ts(),this.name="",this.source=new Ur(A),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=g,this.wrapT=I,this.magFilter=o,this.minFilter=s,this.anisotropy=r,this.format=n,this.internalFormat=null,this.type=a,this.offset=new j(0,0),this.repeat=new j(1,1),this.center=new j(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Je,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=C,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(A=null){this.source.data=A}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(A){return this.name=A.name,this.source=A.source,this.mipmaps=A.mipmaps.slice(0),this.mapping=A.mapping,this.channel=A.channel,this.wrapS=A.wrapS,this.wrapT=A.wrapT,this.magFilter=A.magFilter,this.minFilter=A.minFilter,this.anisotropy=A.anisotropy,this.format=A.format,this.internalFormat=A.internalFormat,this.type=A.type,this.offset.copy(A.offset),this.repeat.copy(A.repeat),this.center.copy(A.center),this.rotation=A.rotation,this.matrixAutoUpdate=A.matrixAutoUpdate,this.matrix.copy(A.matrix),this.generateMipmaps=A.generateMipmaps,this.premultiplyAlpha=A.premultiplyAlpha,this.flipY=A.flipY,this.unpackAlignment=A.unpackAlignment,this.colorSpace=A.colorSpace,this.userData=JSON.parse(JSON.stringify(A.userData)),this.needsUpdate=!0,this}toJSON(A){const t=A===void 0||typeof A=="string";if(!t&&A.textures[this.uuid]!==void 0)return A.textures[this.uuid];const g={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(A).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&&(g.userData=this.userData),t||(A.textures[this.uuid]=g),g}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(A){if(this.mapping!==Km)return A;if(A.applyMatrix3(this.matrix),A.x<0||A.x>1)switch(this.wrapS){case oo:A.x=A.x-Math.floor(A.x);break;case lg:A.x=A.x<0?0:1;break;case Gr:Math.abs(Math.floor(A.x)%2)===1?A.x=Math.ceil(A.x)-A.x:A.x=A.x-Math.floor(A.x);break}if(A.y<0||A.y>1)switch(this.wrapT){case oo:A.y=A.y-Math.floor(A.y);break;case lg:A.y=A.y<0?0:1;break;case Gr:Math.abs(Math.floor(A.y)%2)===1?A.y=Math.ceil(A.y)-A.y:A.y=A.y-Math.floor(A.y);break}return this.flipY&&(A.y=1-A.y),A}set needsUpdate(A){A===!0&&(this.version++,this.source.needsUpdate=!0)}};Ye.DEFAULT_IMAGE=null,Ye.DEFAULT_MAPPING=Km,Ye.DEFAULT_ANISOTROPY=1;let VA=class j9{constructor(A=0,t=0,g=0,I=1){j9.prototype.isVector4=!0,this.x=A,this.y=t,this.z=g,this.w=I}get width(){return this.z}set width(A){this.z=A}get height(){return this.w}set height(A){this.w=A}set(A,t,g,I){return this.x=A,this.y=t,this.z=g,this.w=I,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this.w=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setW(A){return this.w=A,this}setComponent(A,t){switch(A){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){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: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this.w=A.w!==void 0?A.w:1,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this.w+=A.w,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this.w+=A,this}addVectors(A,t){return this.x=A.x+t.x,this.y=A.y+t.y,this.z=A.z+t.z,this.w=A.w+t.w,this}addScaledVector(A,t){return this.x+=A.x*t,this.y+=A.y*t,this.z+=A.z*t,this.w+=A.w*t,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this.w-=A.w,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this.w-=A,this}subVectors(A,t){return this.x=A.x-t.x,this.y=A.y-t.y,this.z=A.z-t.z,this.w=A.w-t.w,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this.w*=A.w,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this.w*=A,this}applyMatrix4(A){const t=this.x,g=this.y,I=this.z,o=this.w,s=A.elements;return this.x=s[0]*t+s[4]*g+s[8]*I+s[12]*o,this.y=s[1]*t+s[5]*g+s[9]*I+s[13]*o,this.z=s[2]*t+s[6]*g+s[10]*I+s[14]*o,this.w=s[3]*t+s[7]*g+s[11]*I+s[15]*o,this}divideScalar(A){return this.multiplyScalar(1/A)}setAxisAngleFromQuaternion(A){this.w=2*Math.acos(A.w);const t=Math.sqrt(1-A.w*A.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=A.x/t,this.y=A.y/t,this.z=A.z/t),this}setAxisAngleFromRotationMatrix(A){let t,g,I,o;const s=A.elements,n=s[0],a=s[4],r=s[8],C=s[1],B=s[5],l=s[9],h=s[2],c=s[6],E=s[10];if(Math.abs(a-C)<.01&&Math.abs(r-h)<.01&&Math.abs(l-c)<.01){if(Math.abs(a+C)<.1&&Math.abs(r+h)<.1&&Math.abs(l+c)<.1&&Math.abs(n+B+E-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const u=(n+1)/2,p=(B+1)/2,D=(E+1)/2,y=(a+C)/4,m=(r+h)/4,S=(l+c)/4;return u>p&&u>D?u<.01?(g=0,I=.707106781,o=.707106781):(g=Math.sqrt(u),I=y/g,o=m/g):p>D?p<.01?(g=.707106781,I=0,o=.707106781):(I=Math.sqrt(p),g=y/I,o=S/I):D<.01?(g=.707106781,I=.707106781,o=0):(o=Math.sqrt(D),g=m/o,I=S/o),this.set(g,I,o,t),this}let d=Math.sqrt((c-l)*(c-l)+(r-h)*(r-h)+(C-a)*(C-a));return Math.abs(d)<.001&&(d=1),this.x=(c-l)/d,this.y=(r-h)/d,this.z=(C-a)/d,this.w=Math.acos((n+B+E-1)/2),this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this.w=Math.min(this.w,A.w),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this.w=Math.max(this.w,A.w),this}clamp(A,t){return this.x=Math.max(A.x,Math.min(t.x,this.x)),this.y=Math.max(A.y,Math.min(t.y,this.y)),this.z=Math.max(A.z,Math.min(t.z,this.z)),this.w=Math.max(A.w,Math.min(t.w,this.w)),this}clampScalar(A,t){return this.x=Math.max(A,Math.min(t,this.x)),this.y=Math.max(A,Math.min(t,this.y)),this.z=Math.max(A,Math.min(t,this.z)),this.w=Math.max(A,Math.min(t,this.w)),this}clampLength(A,t){const g=this.length();return this.divideScalar(g||1).multiplyScalar(Math.max(A,Math.min(t,g)))}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(A){return this.x*A.x+this.y*A.y+this.z*A.z+this.w*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,t){return this.x+=(A.x-this.x)*t,this.y+=(A.y-this.y)*t,this.z+=(A.z-this.z)*t,this.w+=(A.w-this.w)*t,this}lerpVectors(A,t,g){return this.x=A.x+(t.x-A.x)*g,this.y=A.y+(t.y-A.y)*g,this.z=A.z+(t.z-A.z)*g,this.w=A.w+(t.w-A.w)*g,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z&&A.w===this.w}fromArray(A,t=0){return this.x=A[t],this.y=A[t+1],this.z=A[t+2],this.w=A[t+3],this}toArray(A=[],t=0){return A[t]=this.x,A[t+1]=this.y,A[t+2]=this.z,A[t+3]=this.w,A}fromBufferAttribute(A,t){return this.x=A.getX(t),this.y=A.getY(t),this.z=A.getZ(t),this.w=A.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};class OY extends Og{constructor(A=1,t=1,g={}){super(),this.isRenderTarget=!0,this.width=A,this.height=t,this.depth=1,this.scissor=new VA(0,0,A,t),this.scissorTest=!1,this.viewport=new VA(0,0,A,t);const I={width:A,height:t,depth:1};g=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Fe,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},g);const o=new Ye(I,g.mapping,g.wrapS,g.wrapT,g.magFilter,g.minFilter,g.format,g.type,g.anisotropy,g.colorSpace);o.flipY=!1,o.generateMipmaps=g.generateMipmaps,o.internalFormat=g.internalFormat,this.textures=[];const s=g.count;for(let n=0;n<s;n++)this.textures[n]=o.clone(),this.textures[n].isRenderTargetTexture=!0;this.depthBuffer=g.depthBuffer,this.stencilBuffer=g.stencilBuffer,this.depthTexture=g.depthTexture,this.samples=g.samples}get texture(){return this.textures[0]}set texture(A){this.textures[0]=A}setSize(A,t,g=1){if(this.width!==A||this.height!==t||this.depth!==g){this.width=A,this.height=t,this.depth=g;for(let I=0,o=this.textures.length;I<o;I++)this.textures[I].image.width=A,this.textures[I].image.height=t,this.textures[I].image.depth=g;this.dispose()}this.viewport.set(0,0,A,t),this.scissor.set(0,0,A,t)}clone(){return new this.constructor().copy(this)}copy(A){this.width=A.width,this.height=A.height,this.depth=A.depth,this.scissor.copy(A.scissor),this.scissorTest=A.scissorTest,this.viewport.copy(A.viewport),this.textures.length=0;for(let g=0,I=A.textures.length;g<I;g++)this.textures[g]=A.textures[g].clone(),this.textures[g].isRenderTargetTexture=!0;const t=Object.assign({},A.texture.image);return this.texture.source=new Ur(t),this.depthBuffer=A.depthBuffer,this.stencilBuffer=A.stencilBuffer,A.depthTexture!==null&&(this.depthTexture=A.depthTexture.clone()),this.samples=A.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class je extends OY{constructor(A=1,t=1,g={}){super(A,t,g),this.isWebGLRenderTarget=!0}}class tw extends Ye{constructor(A=null,t=1,g=1,I=1){super(null),this.isDataArrayTexture=!0,this.image={data:A,width:t,height:g,depth:I},this.magFilter=xe,this.minFilter=xe,this.wrapR=lg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class L6 extends je{constructor(A=1,t=1,g=1,I={}){super(A,t,I),this.isWebGLArrayRenderTarget=!0,this.depth=g,this.texture=new tw(null,A,t,g),this.texture.isRenderTargetTexture=!0}}let iw=class extends Ye{constructor(i=null,A=1,t=1,g=1){super(null),this.isData3DTexture=!0,this.image={data:i,width:A,height:t,depth:g},this.magFilter=xe,this.minFilter=xe,this.wrapR=lg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};class q6 extends je{constructor(A=1,t=1,g=1,I={}){super(A,t,I),this.isWebGL3DRenderTarget=!0,this.depth=g,this.texture=new iw(null,A,t,g),this.texture.isRenderTargetTexture=!0}}let kA=class{constructor(i=0,A=0,t=0,g=1){this.isQuaternion=!0,this._x=i,this._y=A,this._z=t,this._w=g}static slerpFlat(i,A,t,g,I,o,s){let n=t[g+0],a=t[g+1],r=t[g+2],C=t[g+3];const B=I[o+0],l=I[o+1],h=I[o+2],c=I[o+3];if(s===0){i[A+0]=n,i[A+1]=a,i[A+2]=r,i[A+3]=C;return}if(s===1){i[A+0]=B,i[A+1]=l,i[A+2]=h,i[A+3]=c;return}if(C!==c||n!==B||a!==l||r!==h){let E=1-s;const d=n*B+a*l+r*h+C*c,u=d>=0?1:-1,p=1-d*d;if(p>Number.EPSILON){const y=Math.sqrt(p),m=Math.atan2(y,d*u);E=Math.sin(E*m)/y,s=Math.sin(s*m)/y}const D=s*u;if(n=n*E+B*D,a=a*E+l*D,r=r*E+h*D,C=C*E+c*D,E===1-s){const y=1/Math.sqrt(n*n+a*a+r*r+C*C);n*=y,a*=y,r*=y,C*=y}}i[A]=n,i[A+1]=a,i[A+2]=r,i[A+3]=C}static multiplyQuaternionsFlat(i,A,t,g,I,o){const s=t[g],n=t[g+1],a=t[g+2],r=t[g+3],C=I[o],B=I[o+1],l=I[o+2],h=I[o+3];return i[A]=s*h+r*C+n*l-a*B,i[A+1]=n*h+r*B+a*C-s*l,i[A+2]=a*h+r*l+s*B-n*C,i[A+3]=r*h-s*C-n*B-a*l,i}get x(){return this._x}set x(i){this._x=i,this._onChangeCallback()}get y(){return this._y}set y(i){this._y=i,this._onChangeCallback()}get z(){return this._z}set z(i){this._z=i,this._onChangeCallback()}get w(){return this._w}set w(i){this._w=i,this._onChangeCallback()}set(i,A,t,g){return this._x=i,this._y=A,this._z=t,this._w=g,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(i){return this._x=i.x,this._y=i.y,this._z=i.z,this._w=i.w,this._onChangeCallback(),this}setFromEuler(i,A=!0){const t=i._x,g=i._y,I=i._z,o=i._order,s=Math.cos,n=Math.sin,a=s(t/2),r=s(g/2),C=s(I/2),B=n(t/2),l=n(g/2),h=n(I/2);switch(o){case"XYZ":this._x=B*r*C+a*l*h,this._y=a*l*C-B*r*h,this._z=a*r*h+B*l*C,this._w=a*r*C-B*l*h;break;case"YXZ":this._x=B*r*C+a*l*h,this._y=a*l*C-B*r*h,this._z=a*r*h-B*l*C,this._w=a*r*C+B*l*h;break;case"ZXY":this._x=B*r*C-a*l*h,this._y=a*l*C+B*r*h,this._z=a*r*h+B*l*C,this._w=a*r*C-B*l*h;break;case"ZYX":this._x=B*r*C-a*l*h,this._y=a*l*C+B*r*h,this._z=a*r*h-B*l*C,this._w=a*r*C+B*l*h;break;case"YZX":this._x=B*r*C+a*l*h,this._y=a*l*C+B*r*h,this._z=a*r*h-B*l*C,this._w=a*r*C-B*l*h;break;case"XZY":this._x=B*r*C-a*l*h,this._y=a*l*C-B*r*h,this._z=a*r*h+B*l*C,this._w=a*r*C+B*l*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return A===!0&&this._onChangeCallback(),this}setFromAxisAngle(i,A){const t=A/2,g=Math.sin(t);return this._x=i.x*g,this._y=i.y*g,this._z=i.z*g,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(i){const A=i.elements,t=A[0],g=A[4],I=A[8],o=A[1],s=A[5],n=A[9],a=A[2],r=A[6],C=A[10],B=t+s+C;if(B>0){const l=.5/Math.sqrt(B+1);this._w=.25/l,this._x=(r-n)*l,this._y=(I-a)*l,this._z=(o-g)*l}else if(t>s&&t>C){const l=2*Math.sqrt(1+t-s-C);this._w=(r-n)/l,this._x=.25*l,this._y=(g+o)/l,this._z=(I+a)/l}else if(s>C){const l=2*Math.sqrt(1+s-t-C);this._w=(I-a)/l,this._x=(g+o)/l,this._y=.25*l,this._z=(n+r)/l}else{const l=2*Math.sqrt(1+C-t-s);this._w=(o-g)/l,this._x=(I+a)/l,this._y=(n+r)/l,this._z=.25*l}return this._onChangeCallback(),this}setFromUnitVectors(i,A){let t=i.dot(A)+1;return t<Number.EPSILON?(t=0,Math.abs(i.x)>Math.abs(i.z)?(this._x=-i.y,this._y=i.x,this._z=0,this._w=t):(this._x=0,this._y=-i.z,this._z=i.y,this._w=t)):(this._x=i.y*A.z-i.z*A.y,this._y=i.z*A.x-i.x*A.z,this._z=i.x*A.y-i.y*A.x,this._w=t),this.normalize()}angleTo(i){return 2*Math.acos(Math.abs(Oi(this.dot(i),-1,1)))}rotateTowards(i,A){const t=this.angleTo(i);if(t===0)return this;const g=Math.min(1,A/t);return this.slerp(i,g),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(i){return this._x*i._x+this._y*i._y+this._z*i._z+this._w*i._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 i=this.length();return i===0?(this._x=0,this._y=0,this._z=0,this._w=1):(i=1/i,this._x=this._x*i,this._y=this._y*i,this._z=this._z*i,this._w=this._w*i),this._onChangeCallback(),this}multiply(i){return this.multiplyQuaternions(this,i)}premultiply(i){return this.multiplyQuaternions(i,this)}multiplyQuaternions(i,A){const t=i._x,g=i._y,I=i._z,o=i._w,s=A._x,n=A._y,a=A._z,r=A._w;return this._x=t*r+o*s+g*a-I*n,this._y=g*r+o*n+I*s-t*a,this._z=I*r+o*a+t*n-g*s,this._w=o*r-t*s-g*n-I*a,this._onChangeCallback(),this}slerp(i,A){if(A===0)return this;if(A===1)return this.copy(i);const t=this._x,g=this._y,I=this._z,o=this._w;let s=o*i._w+t*i._x+g*i._y+I*i._z;if(s<0?(this._w=-i._w,this._x=-i._x,this._y=-i._y,this._z=-i._z,s=-s):this.copy(i),s>=1)return this._w=o,this._x=t,this._y=g,this._z=I,this;const n=1-s*s;if(n<=Number.EPSILON){const l=1-A;return this._w=l*o+A*this._w,this._x=l*t+A*this._x,this._y=l*g+A*this._y,this._z=l*I+A*this._z,this.normalize(),this}const a=Math.sqrt(n),r=Math.atan2(a,s),C=Math.sin((1-A)*r)/a,B=Math.sin(A*r)/a;return this._w=o*C+this._w*B,this._x=t*C+this._x*B,this._y=g*C+this._y*B,this._z=I*C+this._z*B,this._onChangeCallback(),this}slerpQuaternions(i,A,t){return this.copy(i).slerp(A,t)}random(){const i=2*Math.PI*Math.random(),A=2*Math.PI*Math.random(),t=Math.random(),g=Math.sqrt(1-t),I=Math.sqrt(t);return this.set(g*Math.sin(i),g*Math.cos(i),I*Math.sin(A),I*Math.cos(A))}equals(i){return i._x===this._x&&i._y===this._y&&i._z===this._z&&i._w===this._w}fromArray(i,A=0){return this._x=i[A],this._y=i[A+1],this._z=i[A+2],this._w=i[A+3],this._onChangeCallback(),this}toArray(i=[],A=0){return i[A]=this._x,i[A+1]=this._y,i[A+2]=this._z,i[A+3]=this._w,i}fromBufferAttribute(i,A){return this._x=i.getX(A),this._y=i.getY(A),this._z=i.getZ(A),this._w=i.getW(A),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(i){return this._onChangeCallback=i,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},f=class z9{constructor(A=0,t=0,g=0){z9.prototype.isVector3=!0,this.x=A,this.y=t,this.z=g}set(A,t,g){return g===void 0&&(g=this.z),this.x=A,this.y=t,this.z=g,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setComponent(A,t){switch(A){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this}addVectors(A,t){return this.x=A.x+t.x,this.y=A.y+t.y,this.z=A.z+t.z,this}addScaledVector(A,t){return this.x+=A.x*t,this.y+=A.y*t,this.z+=A.z*t,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this}subVectors(A,t){return this.x=A.x-t.x,this.y=A.y-t.y,this.z=A.z-t.z,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this}multiplyVectors(A,t){return this.x=A.x*t.x,this.y=A.y*t.y,this.z=A.z*t.z,this}applyEuler(A){return this.applyQuaternion(PY.setFromEuler(A))}applyAxisAngle(A,t){return this.applyQuaternion(PY.setFromAxisAngle(A,t))}applyMatrix3(A){const t=this.x,g=this.y,I=this.z,o=A.elements;return this.x=o[0]*t+o[3]*g+o[6]*I,this.y=o[1]*t+o[4]*g+o[7]*I,this.z=o[2]*t+o[5]*g+o[8]*I,this}applyNormalMatrix(A){return this.applyMatrix3(A).normalize()}applyMatrix4(A){const t=this.x,g=this.y,I=this.z,o=A.elements,s=1/(o[3]*t+o[7]*g+o[11]*I+o[15]);return this.x=(o[0]*t+o[4]*g+o[8]*I+o[12])*s,this.y=(o[1]*t+o[5]*g+o[9]*I+o[13])*s,this.z=(o[2]*t+o[6]*g+o[10]*I+o[14])*s,this}applyQuaternion(A){const t=this.x,g=this.y,I=this.z,o=A.x,s=A.y,n=A.z,a=A.w,r=2*(s*I-n*g),C=2*(n*t-o*I),B=2*(o*g-s*t);return this.x=t+a*r+s*B-n*C,this.y=g+a*C+n*r-o*B,this.z=I+a*B+o*C-s*r,this}project(A){return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix)}unproject(A){return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld)}transformDirection(A){const t=this.x,g=this.y,I=this.z,o=A.elements;return this.x=o[0]*t+o[4]*g+o[8]*I,this.y=o[1]*t+o[5]*g+o[9]*I,this.z=o[2]*t+o[6]*g+o[10]*I,this.normalize()}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this}divideScalar(A){return this.multiplyScalar(1/A)}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this}clamp(A,t){return this.x=Math.max(A.x,Math.min(t.x,this.x)),this.y=Math.max(A.y,Math.min(t.y,this.y)),this.z=Math.max(A.z,Math.min(t.z,this.z)),this}clampScalar(A,t){return this.x=Math.max(A,Math.min(t,this.x)),this.y=Math.max(A,Math.min(t,this.y)),this.z=Math.max(A,Math.min(t,this.z)),this}clampLength(A,t){const g=this.length();return this.divideScalar(g||1).multiplyScalar(Math.max(A,Math.min(t,g)))}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(A){return this.x*A.x+this.y*A.y+this.z*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,t){return this.x+=(A.x-this.x)*t,this.y+=(A.y-this.y)*t,this.z+=(A.z-this.z)*t,this}lerpVectors(A,t,g){return this.x=A.x+(t.x-A.x)*g,this.y=A.y+(t.y-A.y)*g,this.z=A.z+(t.z-A.z)*g,this}cross(A){return this.crossVectors(this,A)}crossVectors(A,t){const g=A.x,I=A.y,o=A.z,s=t.x,n=t.y,a=t.z;return this.x=I*a-o*n,this.y=o*s-g*a,this.z=g*n-I*s,this}projectOnVector(A){const t=A.lengthSq();if(t===0)return this.set(0,0,0);const g=A.dot(this)/t;return this.copy(A).multiplyScalar(g)}projectOnPlane(A){return sN.copy(this).projectOnVector(A),this.sub(sN)}reflect(A){return this.sub(sN.copy(A).multiplyScalar(2*this.dot(A)))}angleTo(A){const t=Math.sqrt(this.lengthSq()*A.lengthSq());if(t===0)return Math.PI/2;const g=this.dot(A)/t;return Math.acos(Oi(g,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){const t=this.x-A.x,g=this.y-A.y,I=this.z-A.z;return t*t+g*g+I*I}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)+Math.abs(this.z-A.z)}setFromSpherical(A){return this.setFromSphericalCoords(A.radius,A.phi,A.theta)}setFromSphericalCoords(A,t,g){const I=Math.sin(t)*A;return this.x=I*Math.sin(g),this.y=Math.cos(t)*A,this.z=I*Math.cos(g),this}setFromCylindrical(A){return this.setFromCylindricalCoords(A.radius,A.theta,A.y)}setFromCylindricalCoords(A,t,g){return this.x=A*Math.sin(t),this.y=g,this.z=A*Math.cos(t),this}setFromMatrixPosition(A){const t=A.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(A){const t=this.setFromMatrixColumn(A,0).length(),g=this.setFromMatrixColumn(A,1).length(),I=this.setFromMatrixColumn(A,2).length();return this.x=t,this.y=g,this.z=I,this}setFromMatrixColumn(A,t){return this.fromArray(A.elements,t*4)}setFromMatrix3Column(A,t){return this.fromArray(A.elements,t*3)}setFromEuler(A){return this.x=A._x,this.y=A._y,this.z=A._z,this}setFromColor(A){return this.x=A.r,this.y=A.g,this.z=A.b,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z}fromArray(A,t=0){return this.x=A[t],this.y=A[t+1],this.z=A[t+2],this}toArray(A=[],t=0){return A[t]=this.x,A[t+1]=this.y,A[t+2]=this.z,A}fromBufferAttribute(A,t){return this.x=A.getX(t),this.y=A.getY(t),this.z=A.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const A=Math.random()*Math.PI*2,t=Math.random()*2-1,g=Math.sqrt(1-t*t);return this.x=g*Math.cos(A),this.y=t,this.z=g*Math.sin(A),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const sN=new f,PY=new kA;let Ze=class{constructor(i=new f(1/0,1/0,1/0),A=new f(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=i,this.max=A}set(i,A){return this.min.copy(i),this.max.copy(A),this}setFromArray(i){this.makeEmpty();for(let A=0,t=i.length;A<t;A+=3)this.expandByPoint(Gn.fromArray(i,A));return this}setFromBufferAttribute(i){this.makeEmpty();for(let A=0,t=i.count;A<t;A++)this.expandByPoint(Gn.fromBufferAttribute(i,A));return this}setFromPoints(i){this.makeEmpty();for(let A=0,t=i.length;A<t;A++)this.expandByPoint(i[A]);return this}setFromCenterAndSize(i,A){const t=Gn.copy(A).multiplyScalar(.5);return this.min.copy(i).sub(t),this.max.copy(i).add(t),this}setFromObject(i,A=!1){return this.makeEmpty(),this.expandByObject(i,A)}clone(){return new this.constructor().copy(this)}copy(i){return this.min.copy(i.min),this.max.copy(i.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(i){return this.isEmpty()?i.set(0,0,0):i.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(i){return this.isEmpty()?i.set(0,0,0):i.subVectors(this.max,this.min)}expandByPoint(i){return this.min.min(i),this.max.max(i),this}expandByVector(i){return this.min.sub(i),this.max.add(i),this}expandByScalar(i){return this.min.addScalar(-i),this.max.addScalar(i),this}expandByObject(i,A=!1){i.updateWorldMatrix(!1,!1);const t=i.geometry;if(t!==void 0){const I=t.getAttribute("position");if(A===!0&&I!==void 0&&i.isInstancedMesh!==!0)for(let o=0,s=I.count;o<s;o++)i.isMesh===!0?i.getVertexPosition(o,Gn):Gn.fromBufferAttribute(I,o),Gn.applyMatrix4(i.matrixWorld),this.expandByPoint(Gn);else i.boundingBox!==void 0?(i.boundingBox===null&&i.computeBoundingBox(),gw.copy(i.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),gw.copy(t.boundingBox)),gw.applyMatrix4(i.matrixWorld),this.union(gw)}const g=i.children;for(let I=0,o=g.length;I<o;I++)this.expandByObject(g[I],A);return this}containsPoint(i){return!(i.x<this.min.x||i.x>this.max.x||i.y<this.min.y||i.y>this.max.y||i.z<this.min.z||i.z>this.max.z)}containsBox(i){return this.min.x<=i.min.x&&i.max.x<=this.max.x&&this.min.y<=i.min.y&&i.max.y<=this.max.y&&this.min.z<=i.min.z&&i.max.z<=this.max.z}getParameter(i,A){return A.set((i.x-this.min.x)/(this.max.x-this.min.x),(i.y-this.min.y)/(this.max.y-this.min.y),(i.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(i){return!(i.max.x<this.min.x||i.min.x>this.max.x||i.max.y<this.min.y||i.min.y>this.max.y||i.max.z<this.min.z||i.min.z>this.max.z)}intersectsSphere(i){return this.clampPoint(i.center,Gn),Gn.distanceToSquared(i.center)<=i.radius*i.radius}intersectsPlane(i){let A,t;return i.normal.x>0?(A=i.normal.x*this.min.x,t=i.normal.x*this.max.x):(A=i.normal.x*this.max.x,t=i.normal.x*this.min.x),i.normal.y>0?(A+=i.normal.y*this.min.y,t+=i.normal.y*this.max.y):(A+=i.normal.y*this.max.y,t+=i.normal.y*this.min.y),i.normal.z>0?(A+=i.normal.z*this.min.z,t+=i.normal.z*this.max.z):(A+=i.normal.z*this.max.z,t+=i.normal.z*this.min.z),A<=-i.constant&&t>=-i.constant}intersectsTriangle(i){if(this.isEmpty())return!1;this.getCenter(sp),Iw.subVectors(this.max,sp),pc.subVectors(i.a,sp),Dc.subVectors(i.b,sp),yc.subVectors(i.c,sp),IB.subVectors(Dc,pc),oB.subVectors(yc,Dc),Il.subVectors(pc,yc);let A=[0,-IB.z,IB.y,0,-oB.z,oB.y,0,-Il.z,Il.y,IB.z,0,-IB.x,oB.z,0,-oB.x,Il.z,0,-Il.x,-IB.y,IB.x,0,-oB.y,oB.x,0,-Il.y,Il.x,0];return!nN(A,pc,Dc,yc,Iw)||(A=[1,0,0,0,1,0,0,0,1],!nN(A,pc,Dc,yc,Iw))?!1:(ow.crossVectors(IB,oB),A=[ow.x,ow.y,ow.z],nN(A,pc,Dc,yc,Iw))}clampPoint(i,A){return A.copy(i).clamp(this.min,this.max)}distanceToPoint(i){return this.clampPoint(i,Gn).distanceTo(i)}getBoundingSphere(i){return this.isEmpty()?i.makeEmpty():(this.getCenter(i.center),i.radius=this.getSize(Gn).length()*.5),i}intersect(i){return this.min.max(i.min),this.max.min(i.max),this.isEmpty()&&this.makeEmpty(),this}union(i){return this.min.min(i.min),this.max.max(i.max),this}applyMatrix4(i){return this.isEmpty()?this:(Nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(i),Nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(i),Nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(i),Nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(i),Nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(i),Nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(i),Nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(i),Nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(i),this.setFromPoints(Nr),this)}translate(i){return this.min.add(i),this.max.add(i),this}equals(i){return i.min.equals(this.min)&&i.max.equals(this.max)}};const Nr=[new f,new f,new f,new f,new f,new f,new f,new f],Gn=new f,gw=new Ze,pc=new f,Dc=new f,yc=new f,IB=new f,oB=new f,Il=new f,sp=new f,Iw=new f,ow=new f,ol=new f;function nN(i,A,t,g,I){for(let o=0,s=i.length-3;o<=s;o+=3){ol.fromArray(i,o);const n=I.x*Math.abs(ol.x)+I.y*Math.abs(ol.y)+I.z*Math.abs(ol.z),a=A.dot(ol),r=t.dot(ol),C=g.dot(ol);if(Math.max(-Math.max(a,r,C),Math.min(a,r,C))>n)return!1}return!0}const T6=new Ze,np=new f,aN=new f;let ri=class{constructor(i=new f,A=-1){this.isSphere=!0,this.center=i,this.radius=A}set(i,A){return this.center.copy(i),this.radius=A,this}setFromPoints(i,A){const t=this.center;A!==void 0?t.copy(A):T6.setFromPoints(i).getCenter(t);let g=0;for(let I=0,o=i.length;I<o;I++)g=Math.max(g,t.distanceToSquared(i[I]));return this.radius=Math.sqrt(g),this}copy(i){return this.center.copy(i.center),this.radius=i.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(i){return i.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(i){return i.distanceTo(this.center)-this.radius}intersectsSphere(i){const A=this.radius+i.radius;return i.center.distanceToSquared(this.center)<=A*A}intersectsBox(i){return i.intersectsSphere(this)}intersectsPlane(i){return Math.abs(i.distanceToPoint(this.center))<=this.radius}clampPoint(i,A){const t=this.center.distanceToSquared(i);return A.copy(i),t>this.radius*this.radius&&(A.sub(this.center).normalize(),A.multiplyScalar(this.radius).add(this.center)),A}getBoundingBox(i){return this.isEmpty()?(i.makeEmpty(),i):(i.set(this.center,this.center),i.expandByScalar(this.radius),i)}applyMatrix4(i){return this.center.applyMatrix4(i),this.radius=this.radius*i.getMaxScaleOnAxis(),this}translate(i){return this.center.add(i),this}expandByPoint(i){if(this.isEmpty())return this.center.copy(i),this.radius=0,this;np.subVectors(i,this.center);const A=np.lengthSq();if(A>this.radius*this.radius){const t=Math.sqrt(A),g=(t-this.radius)*.5;this.center.addScaledVector(np,g/t),this.radius+=g}return this}union(i){return i.isEmpty()?this:this.isEmpty()?(this.copy(i),this):(this.center.equals(i.center)===!0?this.radius=Math.max(this.radius,i.radius):(aN.subVectors(i.center,this.center).setLength(i.radius),this.expandByPoint(np.copy(i.center).add(aN)),this.expandByPoint(np.copy(i.center).sub(aN))),this)}equals(i){return i.center.equals(this.center)&&i.radius===this.radius}clone(){return new this.constructor().copy(this)}};const br=new f,rN=new f,sw=new f,sB=new f,CN=new f,nw=new f,BN=new f;let ro=class{constructor(i=new f,A=new f(0,0,-1)){this.origin=i,this.direction=A}set(i,A){return this.origin.copy(i),this.direction.copy(A),this}copy(i){return this.origin.copy(i.origin),this.direction.copy(i.direction),this}at(i,A){return A.copy(this.origin).addScaledVector(this.direction,i)}lookAt(i){return this.direction.copy(i).sub(this.origin).normalize(),this}recast(i){return this.origin.copy(this.at(i,br)),this}closestPointToPoint(i,A){A.subVectors(i,this.origin);const t=A.dot(this.direction);return t<0?A.copy(this.origin):A.copy(this.origin).addScaledVector(this.direction,t)}distanceToPoint(i){return Math.sqrt(this.distanceSqToPoint(i))}distanceSqToPoint(i){const A=br.subVectors(i,this.origin).dot(this.direction);return A<0?this.origin.distanceToSquared(i):(br.copy(this.origin).addScaledVector(this.direction,A),br.distanceToSquared(i))}distanceSqToSegment(i,A,t,g){rN.copy(i).add(A).multiplyScalar(.5),sw.copy(A).sub(i).normalize(),sB.copy(this.origin).sub(rN);const I=i.distanceTo(A)*.5,o=-this.direction.dot(sw),s=sB.dot(this.direction),n=-sB.dot(sw),a=sB.lengthSq(),r=Math.abs(1-o*o);let C,B,l,h;if(r>0