UNPKG

@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 • 3.55 MB
var M8=Object.defineProperty,T8=(n,e,i)=>e in n?M8(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,p=(n,e,i)=>(T8(n,typeof e!="symbol"?e+"":e,i),i),sT=(n,e,i)=>{if(!e.has(n))throw TypeError("Cannot "+i)},wi=(n,e,i)=>(sT(n,e,"read from private field"),i?i.call(n):e.get(n)),Pa=(n,e,i)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,i)},rc=(n,e,i,s)=>(sT(n,e,"write to private field"),s?s.call(n,i):e.set(n,i),i),Gg=(n,e,i)=>(sT(n,e,"access private method"),i);/** * @license * Copyright 2010-2023 Three.js Authors * SPDX-License-Identifier: MIT */const hh="162",Mp={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},qN=0,rT=1,$N=2,R8=3,B8=0,oT=1,aT=2,oc=3,Cn=0,pn=1,_i=2,mn=0,Ld=1,Rp=2,lT=3,cT=4,hT=5,kd=100,eF=101,tF=102,dT=103,zw=104,iF=200,nF=201,sF=202,rF=203,Qw=204,Vw=205,oF=206,aF=207,lF=208,cF=209,hF=210,dF=211,uF=212,pF=213,mF=214,uT=0,Xw=1,oy=2,Bp=3,Og=4,Ww=5,Hw=6,ay=7,ly=0,gF=1,fF=2,Yr=0,Ng=1,cy=2,AF=3,hy=4,yF=5,Fg=6,Lp=7,pT="attached",vF="detached",jw=300,dh=301,Pd=302,Kr=303,Ug=304,zg=306,Jr=1e3,ns=1001,uh=1002,Gt=1003,Qg=1004,L8=1004,ph=1005,k8=1005,kt=1006,kp=1007,P8=1007,qr=1008,D8=1008,vi=1009,Zw=1010,mT=1011,dy=1012,Pp=1013,Ir=1014,Bi=1015,Sn=1016,gT=1017,fT=1018,mh=1020,bF=1021,oi=1023,Yw=1024,xF=1025,Dd=1026,Gd=1027,Da=1028,Kw=1029,gh=1030,uy=1031,Vg=1033,py=33776,Jw=33777,qw=33778,my=33779,$w=35840,AT=35841,e1=35842,yT=35843,t1=36196,i1=37492,n1=37496,s1=37808,vT=37809,bT=37810,xT=37811,gy=37812,wT=37813,_T=37814,CT=37815,ST=37816,ET=37817,IT=37818,MT=37819,TT=37820,RT=37821,fy=36492,BT=36494,LT=36495,wF=36283,kT=36284,PT=36285,DT=36286,Ay=2200,GT=2201,_F=2202,Od=2300,ac=2301,r1=2302,Dp=2400,Gp=2401,yy=2402,o1=2500,OT=2501,CF=0,NT=1,a1=2,SF=3e3,FT=3001,qs=3200,l1=3201,Nd=0,EF=1,$r="",pt="srgb",Li="srgb-linear",vy="display-p3",Xg="display-p3-linear",by="linear",Ji="srgb",xy="rec709",wy="p3",IF=0,Fd=7680,MF=7681,TF=7682,RF=7683,BF=34055,LF=34056,kF=5386,UT=512,PF=513,DF=514,GF=515,OF=516,NF=517,FF=518,c1=519,UF=512,zF=513,QF=514,zT=515,VF=516,XF=517,WF=518,HF=519,_y=35044,Mr=35048,G8=35040,O8=35045,N8=35049,F8=35041,U8=35046,z8=35050,Q8=35042,V8="100",h1="300 es",d1=1035,lc=2e3,Cy=2001;let ks=class{addEventListener(n,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[n]===void 0&&(i[n]=[]),i[n].indexOf(e)===-1&&i[n].push(e)}hasEventListener(n,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[n]!==void 0&&i[n].indexOf(e)!==-1}removeEventListener(n,e){if(this._listeners===void 0)return;const i=this._listeners[n];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(n){if(this._listeners===void 0)return;const e=this._listeners[n.type];if(e!==void 0){n.target=this;const i=e.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,n);n.target=null}}};const Tr=["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 jF=1234567;const Op=Math.PI/180,Wg=180/Math.PI;function Ho(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(Tr[n&255]+Tr[n>>8&255]+Tr[n>>16&255]+Tr[n>>24&255]+"-"+Tr[e&255]+Tr[e>>8&255]+"-"+Tr[e>>16&15|64]+Tr[e>>24&255]+"-"+Tr[i&63|128]+Tr[i>>8&255]+"-"+Tr[i>>16&255]+Tr[i>>24&255]+Tr[s&255]+Tr[s>>8&255]+Tr[s>>16&255]+Tr[s>>24&255]).toLowerCase()}function Gn(n,e,i){return Math.max(e,Math.min(i,n))}function QT(n,e){return(n%e+e)%e}function X8(n,e,i,s,r){return s+(n-e)*(r-s)/(i-e)}function W8(n,e,i){return n!==e?(i-n)/(e-n):0}function Sy(n,e,i){return(1-i)*n+i*e}function H8(n,e,i,s){return Sy(n,e,1-Math.exp(-i*s))}function j8(n,e=1){return e-Math.abs(QT(n,e*2)-e)}function Z8(n,e,i){return n<=e?0:n>=i?1:(n=(n-e)/(i-e),n*n*(3-2*n))}function Y8(n,e,i){return n<=e?0:n>=i?1:(n=(n-e)/(i-e),n*n*n*(n*(n*6-15)+10))}function K8(n,e){return n+Math.floor(Math.random()*(e-n+1))}function J8(n,e){return n+Math.random()*(e-n)}function q8(n){return n*(.5-Math.random())}function $8(n){n!==void 0&&(jF=n);let e=jF+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function eJ(n){return n*Op}function tJ(n){return n*Wg}function VT(n){return(n&n-1)===0&&n!==0}function iJ(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function u1(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function nJ(n,e,i,s,r){const o=Math.cos,a=Math.sin,l=o(i/2),c=a(i/2),h=o((e+s)/2),d=a((e+s)/2),u=o((e-s)/2),m=a((e-s)/2),g=o((s-e)/2),f=a((s-e)/2);switch(r){case"XYX":n.set(l*d,c*u,c*m,l*h);break;case"YZY":n.set(c*m,l*d,c*u,l*h);break;case"ZXZ":n.set(c*u,c*m,l*d,l*h);break;case"XZX":n.set(l*d,c*f,c*g,l*h);break;case"YXY":n.set(c*g,l*d,c*f,l*h);break;case"ZYZ":n.set(c*f,c*g,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function eo(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Jt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const ai={DEG2RAD:Op,RAD2DEG:Wg,generateUUID:Ho,clamp:Gn,euclideanModulo:QT,mapLinear:X8,inverseLerp:W8,lerp:Sy,damp:H8,pingpong:j8,smoothstep:Z8,smootherstep:Y8,randInt:K8,randFloat:J8,randFloatSpread:q8,seededRandom:$8,degToRad:eJ,radToDeg:tJ,isPowerOfTwo:VT,ceilPowerOfTwo:iJ,floorPowerOfTwo:u1,setQuaternionFromProperEuler:nJ,normalize:Jt,denormalize:eo};let K=class y8{constructor(e=0,i=0){y8.prototype.isVector2=!0,this.x=e,this.y=i}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,i){return this.x=e,this.y=i,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,i){return this.x=e.x+i.x,this.y=e.y+i.y,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,i){return this.x=e.x-i.x,this.y=e.y-i.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const i=this.x,s=this.y,r=e.elements;return this.x=r[0]*i+r[3]*s+r[6],this.y=r[1]*i+r[4]*s+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,i){return this.x=Math.max(e.x,Math.min(i.x,this.x)),this.y=Math.max(e.y,Math.min(i.y,this.y)),this}clampScalar(e,i){return this.x=Math.max(e,Math.min(i,this.x)),this.y=Math.max(e,Math.min(i,this.y)),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(i,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const i=Math.sqrt(this.lengthSq()*e.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(e)/i;return Math.acos(Gn(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const i=this.x-e.x,s=this.y-e.y;return i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,i=0){return this.x=e[i],this.y=e[i+1],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this}rotateAround(e,i){const s=Math.cos(i),r=Math.sin(i),o=this.x-e.x,a=this.y-e.y;return this.x=o*s-a*r+e.x,this.y=o*r+a*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ot=class v8{constructor(e,i,s,r,o,a,l,c,h){v8.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,i,s,r,o,a,l,c,h)}set(e,i,s,r,o,a,l,c,h){const d=this.elements;return d[0]=e,d[1]=r,d[2]=l,d[3]=i,d[4]=o,d[5]=c,d[6]=s,d[7]=a,d[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const i=this.elements,s=e.elements;return i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=s[3],i[4]=s[4],i[5]=s[5],i[6]=s[6],i[7]=s[7],i[8]=s[8],this}extractBasis(e,i,s){return e.setFromMatrix3Column(this,0),i.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const i=e.elements;return this.set(i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,i){const s=e.elements,r=i.elements,o=this.elements,a=s[0],l=s[3],c=s[6],h=s[1],d=s[4],u=s[7],m=s[2],g=s[5],f=s[8],A=r[0],y=r[3],v=r[6],b=r[1],x=r[4],w=r[7],_=r[2],S=r[5],C=r[8];return o[0]=a*A+l*b+c*_,o[3]=a*y+l*x+c*S,o[6]=a*v+l*w+c*C,o[1]=h*A+d*b+u*_,o[4]=h*y+d*x+u*S,o[7]=h*v+d*w+u*C,o[2]=m*A+g*b+f*_,o[5]=m*y+g*x+f*S,o[8]=m*v+g*w+f*C,this}multiplyScalar(e){const i=this.elements;return i[0]*=e,i[3]*=e,i[6]*=e,i[1]*=e,i[4]*=e,i[7]*=e,i[2]*=e,i[5]*=e,i[8]*=e,this}determinant(){const e=this.elements,i=e[0],s=e[1],r=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],d=e[8];return i*a*d-i*l*h-s*o*d+s*l*c+r*o*h-r*a*c}invert(){const e=this.elements,i=e[0],s=e[1],r=e[2],o=e[3],a=e[4],l=e[5],c=e[6],h=e[7],d=e[8],u=d*a-l*h,m=l*c-d*o,g=h*o-a*c,f=i*u+s*m+r*g;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const A=1/f;return e[0]=u*A,e[1]=(r*h-d*s)*A,e[2]=(l*s-r*a)*A,e[3]=m*A,e[4]=(d*i-r*c)*A,e[5]=(r*o-l*i)*A,e[6]=g*A,e[7]=(s*c-h*i)*A,e[8]=(a*i-s*o)*A,this}transpose(){let e;const i=this.elements;return e=i[1],i[1]=i[3],i[3]=e,e=i[2],i[2]=i[6],i[6]=e,e=i[5],i[5]=i[7],i[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const i=this.elements;return e[0]=i[0],e[1]=i[3],e[2]=i[6],e[3]=i[1],e[4]=i[4],e[5]=i[7],e[6]=i[2],e[7]=i[5],e[8]=i[8],this}setUvTransform(e,i,s,r,o,a,l){const c=Math.cos(o),h=Math.sin(o);return this.set(s*c,s*h,-s*(c*a+h*l)+a+e,-r*h,r*c,-r*(-h*a+c*l)+l+i,0,0,1),this}scale(e,i){return this.premultiply(XT.makeScale(e,i)),this}rotate(e){return this.premultiply(XT.makeRotation(-e)),this}translate(e,i){return this.premultiply(XT.makeTranslation(e,i)),this}makeTranslation(e,i){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,i,0,0,1),this}makeRotation(e){const i=Math.cos(e),s=Math.sin(e);return this.set(i,-s,0,s,i,0,0,0,1),this}makeScale(e,i){return this.set(e,0,0,0,i,0,0,0,1),this}equals(e){const i=this.elements,s=e.elements;for(let r=0;r<9;r++)if(i[r]!==s[r])return!1;return!0}fromArray(e,i=0){for(let s=0;s<9;s++)this.elements[s]=e[s+i];return this}toArray(e=[],i=0){const s=this.elements;return e[i]=s[0],e[i+1]=s[1],e[i+2]=s[2],e[i+3]=s[3],e[i+4]=s[4],e[i+5]=s[5],e[i+6]=s[6],e[i+7]=s[7],e[i+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const XT=new Ot;function ZF(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const sJ={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Hg(n,e){return new sJ[n](e)}function Ey(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function YF(){const n=Ey("canvas");return n.style.display="block",n}const KF={};function JF(n){n in KF||(KF[n]=!0,console.warn(n))}const qF=new Ot().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),$F=new Ot().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),p1={[Li]:{transfer:by,primaries:xy,toReference:n=>n,fromReference:n=>n},[pt]:{transfer:Ji,primaries:xy,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[Xg]:{transfer:by,primaries:wy,toReference:n=>n.applyMatrix3($F),fromReference:n=>n.applyMatrix3(qF)},[vy]:{transfer:Ji,primaries:wy,toReference:n=>n.convertSRGBToLinear().applyMatrix3($F),fromReference:n=>n.applyMatrix3(qF).convertLinearToSRGB()}},rJ=new Set([Li,Xg]),Mi={enabled:!0,_workingColorSpace:Li,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!rJ.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,i){if(this.enabled===!1||e===i||!e||!i)return n;const s=p1[e].toReference,r=p1[i].fromReference;return r(s(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return p1[n].primaries},getTransfer:function(n){return n===$r?by:p1[n].transfer}};function jg(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function WT(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Zg,HT=class{static getDataURL(n){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement>"u")return n.src;let e;if(n instanceof HTMLCanvasElement)e=n;else{Zg===void 0&&(Zg=Ey("canvas")),Zg.width=n.width,Zg.height=n.height;const i=Zg.getContext("2d");n instanceof ImageData?i.putImageData(n,0,0):i.drawImage(n,0,0,n.width,n.height),e=Zg}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",n),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(n){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){const e=Ey("canvas");e.width=n.width,e.height=n.height;const i=e.getContext("2d");i.drawImage(n,0,0,n.width,n.height);const s=i.getImageData(0,0,n.width,n.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=jg(r[o]/255)*255;return i.putImageData(s,0,0),e}else if(n.data){const e=n.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(jg(e[i]/255)*255):e[i]=jg(e[i]);return{data:e,width:n.width,height:n.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),n}},oJ=0,fh=class{constructor(n=null){this.isSource=!0,Object.defineProperty(this,"id",{value:oJ++}),this.uuid=Ho(),this.data=n,this.dataReady=!0,this.version=0}set needsUpdate(n){n===!0&&this.version++}toJSON(n){const e=n===void 0||typeof n=="string";if(!e&&n.images[this.uuid]!==void 0)return n.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(jT(s[o].image)):r.push(jT(s[o]))}else r=jT(s);i.url=r}return e||(n.images[this.uuid]=i),i}};function jT(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?HT.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let aJ=0,Ut=class GM extends ks{constructor(e=GM.DEFAULT_IMAGE,i=GM.DEFAULT_MAPPING,s=ns,r=ns,o=kt,a=qr,l=oi,c=vi,h=GM.DEFAULT_ANISOTROPY,d=$r){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:aJ++}),this.uuid=Ho(),this.name="",this.source=new fh(e),this.mipmaps=[],this.mapping=i,this.channel=0,this.wrapS=s,this.wrapT=r,this.magFilter=o,this.minFilter=a,this.anisotropy=h,this.format=l,this.internalFormat=null,this.type=c,this.offset=new K(0,0),this.repeat=new K(1,1),this.center=new K(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ot,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const i=e===void 0||typeof e=="string";if(!i&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,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&&(s.userData=this.userData),i||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==jw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Jr:e.x=e.x-Math.floor(e.x);break;case ns:e.x=e.x<0?0:1;break;case uh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Jr:e.y=e.y-Math.floor(e.y);break;case ns:e.y=e.y<0?0:1;break;case uh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};Ut.DEFAULT_IMAGE=null,Ut.DEFAULT_MAPPING=jw,Ut.DEFAULT_ANISOTROPY=1;let Ze=class b8{constructor(e=0,i=0,s=0,r=1){b8.prototype.isVector4=!0,this.x=e,this.y=i,this.z=s,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,i,s,r){return this.x=e,this.y=i,this.z=s,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;case 3:this.w=i;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,i){return this.x=e.x+i.x,this.y=e.y+i.y,this.z=e.z+i.z,this.w=e.w+i.w,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this.z+=e.z*i,this.w+=e.w*i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,i){return this.x=e.x-i.x,this.y=e.y-i.y,this.z=e.z-i.z,this.w=e.w-i.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const i=this.x,s=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*i+a[4]*s+a[8]*r+a[12]*o,this.y=a[1]*i+a[5]*s+a[9]*r+a[13]*o,this.z=a[2]*i+a[6]*s+a[10]*r+a[14]*o,this.w=a[3]*i+a[7]*s+a[11]*r+a[15]*o,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const i=Math.sqrt(1-e.w*e.w);return i<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/i,this.y=e.y/i,this.z=e.z/i),this}setAxisAngleFromRotationMatrix(e){let i,s,r,o;const a=e.elements,l=a[0],c=a[4],h=a[8],d=a[1],u=a[5],m=a[9],g=a[2],f=a[6],A=a[10];if(Math.abs(c-d)<.01&&Math.abs(h-g)<.01&&Math.abs(m-f)<.01){if(Math.abs(c+d)<.1&&Math.abs(h+g)<.1&&Math.abs(m+f)<.1&&Math.abs(l+u+A-3)<.1)return this.set(1,0,0,0),this;i=Math.PI;const v=(l+1)/2,b=(u+1)/2,x=(A+1)/2,w=(c+d)/4,_=(h+g)/4,S=(m+f)/4;return v>b&&v>x?v<.01?(s=0,r=.707106781,o=.707106781):(s=Math.sqrt(v),r=w/s,o=_/s):b>x?b<.01?(s=.707106781,r=0,o=.707106781):(r=Math.sqrt(b),s=w/r,o=S/r):x<.01?(s=.707106781,r=.707106781,o=0):(o=Math.sqrt(x),s=_/o,r=S/o),this.set(s,r,o,i),this}let y=Math.sqrt((f-m)*(f-m)+(h-g)*(h-g)+(d-c)*(d-c));return Math.abs(y)<.001&&(y=1),this.x=(f-m)/y,this.y=(h-g)/y,this.z=(d-c)/y,this.w=Math.acos((l+u+A-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,i){return this.x=Math.max(e.x,Math.min(i.x,this.x)),this.y=Math.max(e.y,Math.min(i.y,this.y)),this.z=Math.max(e.z,Math.min(i.z,this.z)),this.w=Math.max(e.w,Math.min(i.w,this.w)),this}clampScalar(e,i){return this.x=Math.max(e,Math.min(i,this.x)),this.y=Math.max(e,Math.min(i,this.y)),this.z=Math.max(e,Math.min(i,this.z)),this.w=Math.max(e,Math.min(i,this.w)),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(i,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this.z+=(e.z-this.z)*i,this.w+=(e.w-this.w)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this.z=e.z+(i.z-e.z)*s,this.w=e.w+(i.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,i=0){return this.x=e[i],this.y=e[i+1],this.z=e[i+2],this.w=e[i+3],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e[i+2]=this.z,e[i+3]=this.w,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this.z=e.getZ(i),this.w=e.getW(i),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 e3 extends ks{constructor(e=1,i=1,s={}){super(),this.isRenderTarget=!0,this.width=e,this.height=i,this.depth=1,this.scissor=new Ze(0,0,e,i),this.scissorTest=!1,this.viewport=new Ze(0,0,e,i);const r={width:e,height:i,depth:1};s=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:kt,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},s);const o=new Ut(r,s.mapping,s.wrapS,s.wrapT,s.magFilter,s.minFilter,s.format,s.type,s.anisotropy,s.colorSpace);o.flipY=!1,o.generateMipmaps=s.generateMipmaps,o.internalFormat=s.internalFormat,this.textures=[];const a=s.count;for(let l=0;l<a;l++)this.textures[l]=o.clone(),this.textures[l].isRenderTargetTexture=!0;this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.depthTexture=s.depthTexture,this.samples=s.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,i,s=1){if(this.width!==e||this.height!==i||this.depth!==s){this.width=e,this.height=i,this.depth=s;for(let r=0,o=this.textures.length;r<o;r++)this.textures[r].image.width=e,this.textures[r].image.height=i,this.textures[r].image.depth=s;this.dispose()}this.viewport.set(0,0,e,i),this.scissor.set(0,0,e,i)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let s=0,r=e.textures.length;s<r;s++)this.textures[s]=e.textures[s].clone(),this.textures[s].isRenderTargetTexture=!0;const i=Object.assign({},e.texture.image);return this.texture.source=new fh(i),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Zt extends e3{constructor(e=1,i=1,s={}){super(e,i,s),this.isWebGLRenderTarget=!0}}class m1 extends Ut{constructor(e=null,i=1,s=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:i,height:s,depth:r},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=ns,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lJ extends Zt{constructor(e=1,i=1,s=1,r={}){super(e,i,r),this.isWebGLArrayRenderTarget=!0,this.depth=s,this.texture=new m1(null,e,i,s),this.texture.isRenderTargetTexture=!0}}let g1=class extends Ut{constructor(n=null,e=1,i=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:n,width:e,height:i,depth:s},this.magFilter=Gt,this.minFilter=Gt,this.wrapR=ns,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};class cJ extends Zt{constructor(e=1,i=1,s=1,r={}){super(e,i,r),this.isWebGL3DRenderTarget=!0,this.depth=s,this.texture=new g1(null,e,i,s),this.texture.isRenderTargetTexture=!0}}let Ce=class{constructor(n=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=n,this._y=e,this._z=i,this._w=s}static slerpFlat(n,e,i,s,r,o,a){let l=i[s+0],c=i[s+1],h=i[s+2],d=i[s+3];const u=r[o+0],m=r[o+1],g=r[o+2],f=r[o+3];if(a===0){n[e+0]=l,n[e+1]=c,n[e+2]=h,n[e+3]=d;return}if(a===1){n[e+0]=u,n[e+1]=m,n[e+2]=g,n[e+3]=f;return}if(d!==f||l!==u||c!==m||h!==g){let A=1-a;const y=l*u+c*m+h*g+d*f,v=y>=0?1:-1,b=1-y*y;if(b>Number.EPSILON){const w=Math.sqrt(b),_=Math.atan2(w,y*v);A=Math.sin(A*_)/w,a=Math.sin(a*_)/w}const x=a*v;if(l=l*A+u*x,c=c*A+m*x,h=h*A+g*x,d=d*A+f*x,A===1-a){const w=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=w,c*=w,h*=w,d*=w}}n[e]=l,n[e+1]=c,n[e+2]=h,n[e+3]=d}static multiplyQuaternionsFlat(n,e,i,s,r,o){const a=i[s],l=i[s+1],c=i[s+2],h=i[s+3],d=r[o],u=r[o+1],m=r[o+2],g=r[o+3];return n[e]=a*g+h*d+l*m-c*u,n[e+1]=l*g+h*u+c*d-a*m,n[e+2]=c*g+h*m+a*u-l*d,n[e+3]=h*g-a*d-l*u-c*m,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,e,i,s){return this._x=n,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(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,e=!0){const i=n._x,s=n._y,r=n._z,o=n._order,a=Math.cos,l=Math.sin,c=a(i/2),h=a(s/2),d=a(r/2),u=l(i/2),m=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*m*g,this._y=c*m*d-u*h*g,this._z=c*h*g+u*m*d,this._w=c*h*d-u*m*g;break;case"YXZ":this._x=u*h*d+c*m*g,this._y=c*m*d-u*h*g,this._z=c*h*g-u*m*d,this._w=c*h*d+u*m*g;break;case"ZXY":this._x=u*h*d-c*m*g,this._y=c*m*d+u*h*g,this._z=c*h*g+u*m*d,this._w=c*h*d-u*m*g;break;case"ZYX":this._x=u*h*d-c*m*g,this._y=c*m*d+u*h*g,this._z=c*h*g-u*m*d,this._w=c*h*d+u*m*g;break;case"YZX":this._x=u*h*d+c*m*g,this._y=c*m*d+u*h*g,this._z=c*h*g-u*m*d,this._w=c*h*d-u*m*g;break;case"XZY":this._x=u*h*d-c*m*g,this._y=c*m*d-u*h*g,this._z=c*h*g+u*m*d,this._w=c*h*d+u*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(n,e){const i=e/2,s=Math.sin(i);return this._x=n.x*s,this._y=n.y*s,this._z=n.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(n){const e=n.elements,i=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=i+a+d;if(u>0){const m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-l)*m,this._y=(r-c)*m,this._z=(o-s)*m}else if(i>a&&i>d){const m=2*Math.sqrt(1+i-a-d);this._w=(h-l)/m,this._x=.25*m,this._y=(s+o)/m,this._z=(r+c)/m}else if(a>d){const m=2*Math.sqrt(1+a-i-d);this._w=(r-c)/m,this._x=(s+o)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+d-i-a);this._w=(o-s)/m,this._x=(r+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(n,e){let i=n.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(n.x)>Math.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=i):(this._x=0,this._y=-n.z,this._z=n.y,this._w=i)):(this._x=n.y*e.z-n.z*e.y,this._y=n.z*e.x-n.x*e.z,this._z=n.x*e.y-n.y*e.x,this._w=i),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(Gn(this.dot(n),-1,1)))}rotateTowards(n,e){const i=this.angleTo(n);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(n,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(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._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 n=this.length();return n===0?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n){return this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,e){const i=n._x,s=n._y,r=n._z,o=n._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=i*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-i*c,this._z=r*h+o*c+i*l-s*a,this._w=o*h-i*a-s*l-r*c,this._onChangeCallback(),this}slerp(n,e){if(e===0)return this;if(e===1)return this.copy(n);const i=this._x,s=this._y,r=this._z,o=this._w;let a=o*n._w+i*n._x+s*n._y+r*n._z;if(a<0?(this._w=-n._w,this._x=-n._x,this._y=-n._y,this._z=-n._z,a=-a):this.copy(n),a>=1)return this._w=o,this._x=i,this._y=s,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-e;return this._w=m*o+e*this._w,this._x=m*i+e*this._x,this._y=m*s+e*this._y,this._z=m*r+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),d=Math.sin((1-e)*h)/c,u=Math.sin(e*h)/c;return this._w=o*d+this._w*u,this._x=i*d+this._x*u,this._y=s*d+this._y*u,this._z=r*d+this._z*u,this._onChangeCallback(),this}slerpQuaternions(n,e,i){return this.copy(n).slerp(e,i)}random(){const n=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(n),s*Math.cos(n),r*Math.sin(e),r*Math.cos(e))}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,e=0){return this._x=n[e],this._y=n[e+1],this._z=n[e+2],this._w=n[e+3],this._onChangeCallback(),this}toArray(n=[],e=0){return n[e]=this._x,n[e+1]=this._y,n[e+2]=this._z,n[e+3]=this._w,n}fromBufferAttribute(n,e){return this._x=n.getX(e),this._y=n.getY(e),this._z=n.getZ(e),this._w=n.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},E=class x8{constructor(e=0,i=0,s=0){x8.prototype.isVector3=!0,this.x=e,this.y=i,this.z=s}set(e,i,s){return s===void 0&&(s=this.z),this.x=e,this.y=i,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,i){switch(e){case 0:this.x=i;break;case 1:this.y=i;break;case 2:this.z=i;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,i){return this.x=e.x+i.x,this.y=e.y+i.y,this.z=e.z+i.z,this}addScaledVector(e,i){return this.x+=e.x*i,this.y+=e.y*i,this.z+=e.z*i,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,i){return this.x=e.x-i.x,this.y=e.y-i.y,this.z=e.z-i.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,i){return this.x=e.x*i.x,this.y=e.y*i.y,this.z=e.z*i.z,this}applyEuler(e){return this.applyQuaternion(t3.setFromEuler(e))}applyAxisAngle(e,i){return this.applyQuaternion(t3.setFromAxisAngle(e,i))}applyMatrix3(e){const i=this.x,s=this.y,r=this.z,o=e.elements;return this.x=o[0]*i+o[3]*s+o[6]*r,this.y=o[1]*i+o[4]*s+o[7]*r,this.z=o[2]*i+o[5]*s+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const i=this.x,s=this.y,r=this.z,o=e.elements,a=1/(o[3]*i+o[7]*s+o[11]*r+o[15]);return this.x=(o[0]*i+o[4]*s+o[8]*r+o[12])*a,this.y=(o[1]*i+o[5]*s+o[9]*r+o[13])*a,this.z=(o[2]*i+o[6]*s+o[10]*r+o[14])*a,this}applyQuaternion(e){const i=this.x,s=this.y,r=this.z,o=e.x,a=e.y,l=e.z,c=e.w,h=2*(a*r-l*s),d=2*(l*i-o*r),u=2*(o*s-a*i);return this.x=i+c*h+a*u-l*d,this.y=s+c*d+l*h-o*u,this.z=r+c*u+o*d-a*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const i=this.x,s=this.y,r=this.z,o=e.elements;return this.x=o[0]*i+o[4]*s+o[8]*r,this.y=o[1]*i+o[5]*s+o[9]*r,this.z=o[2]*i+o[6]*s+o[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,i){return this.x=Math.max(e.x,Math.min(i.x,this.x)),this.y=Math.max(e.y,Math.min(i.y,this.y)),this.z=Math.max(e.z,Math.min(i.z,this.z)),this}clampScalar(e,i){return this.x=Math.max(e,Math.min(i,this.x)),this.y=Math.max(e,Math.min(i,this.y)),this.z=Math.max(e,Math.min(i,this.z)),this}clampLength(e,i){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(i,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,i){return this.x+=(e.x-this.x)*i,this.y+=(e.y-this.y)*i,this.z+=(e.z-this.z)*i,this}lerpVectors(e,i,s){return this.x=e.x+(i.x-e.x)*s,this.y=e.y+(i.y-e.y)*s,this.z=e.z+(i.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,i){const s=e.x,r=e.y,o=e.z,a=i.x,l=i.y,c=i.z;return this.x=r*c-o*l,this.y=o*a-s*c,this.z=s*l-r*a,this}projectOnVector(e){const i=e.lengthSq();if(i===0)return this.set(0,0,0);const s=e.dot(this)/i;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return ZT.copy(this).projectOnVector(e),this.sub(ZT)}reflect(e){return this.sub(ZT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const i=Math.sqrt(this.lengthSq()*e.lengthSq());if(i===0)return Math.PI/2;const s=this.dot(e)/i;return Math.acos(Gn(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const i=this.x-e.x,s=this.y-e.y,r=this.z-e.z;return i*i+s*s+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,i,s){const r=Math.sin(i)*e;return this.x=r*Math.sin(s),this.y=Math.cos(i)*e,this.z=r*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,i,s){return this.x=e*Math.sin(i),this.y=s,this.z=e*Math.cos(i),this}setFromMatrixPosition(e){const i=e.elements;return this.x=i[12],this.y=i[13],this.z=i[14],this}setFromMatrixScale(e){const i=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=i,this.y=s,this.z=r,this}setFromMatrixColumn(e,i){return this.fromArray(e.elements,i*4)}setFromMatrix3Column(e,i){return this.fromArray(e.elements,i*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,i=0){return this.x=e[i],this.y=e[i+1],this.z=e[i+2],this}toArray(e=[],i=0){return e[i]=this.x,e[i+1]=this.y,e[i+2]=this.z,e}fromBufferAttribute(e,i){return this.x=e.getX(i),this.y=e.getY(i),this.z=e.getZ(i),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,i=Math.random()*2-1,s=Math.sqrt(1-i*i);return this.x=s*Math.cos(e),this.y=i,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const ZT=new E,t3=new Ce;let Wt=class{constructor(n=new E(1/0,1/0,1/0),e=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=n,this.max=e}set(n,e){return this.min.copy(n),this.max.copy(e),this}setFromArray(n){this.makeEmpty();for(let e=0,i=n.length;e<i;e+=3)this.expandByPoint(gl.fromArray(n,e));return this}setFromBufferAttribute(n){this.makeEmpty();for(let e=0,i=n.count;e<i;e++)this.expandByPoint(gl.fromBufferAttribute(n,e));return this}setFromPoints(n){this.makeEmpty();for(let e=0,i=n.length;e<i;e++)this.expandByPoint(n[e]);return this}setFromCenterAndSize(n,e){const i=gl.copy(e).multiplyScalar(.5);return this.min.copy(n).sub(i),this.max.copy(n).add(i),this}setFromObject(n,e=!1){return this.makeEmpty(),this.expandByObject(n,e)}clone(){return new this.constructor().copy(this)}copy(n){return this.min.copy(n.min),this.max.copy(n.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(n){return this.isEmpty()?n.set(0,0,0):n.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(n){return this.isEmpty()?n.set(0,0,0):n.subVectors(this.max,this.min)}expandByPoint(n){return this.min.min(n),this.max.max(n),this}expandByVector(n){return this.min.sub(n),this.max.add(n),this}expandByScalar(n){return this.min.addScalar(-n),this.max.addScalar(n),this}expandByObject(n,e=!1){n.updateWorldMatrix(!1,!1);const i=n.geometry;if(i!==void 0){const r=i.getAttribute("position");if(e===!0&&r!==void 0&&n.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)n.isMesh===!0?n.getVertexPosition(o,gl):gl.fromBufferAttribute(r,o),gl.applyMatrix4(n.matrixWorld),this.expandByPoint(gl);else n.boundingBox!==void 0?(n.boundingBox===null&&n.computeBoundingBox(),f1.copy(n.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),f1.copy(i.boundingBox)),f1.applyMatrix4(n.matrixWorld),this.union(f1)}const s=n.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],e);return this}containsPoint(n){return!(n.x<this.min.x||n.x>this.max.x||n.y<this.min.y||n.y>this.max.y||n.z<this.min.z||n.z>this.max.z)}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,e){return e.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return!(n.max.x<this.min.x||n.min.x>this.max.x||n.max.y<this.min.y||n.min.y>this.max.y||n.max.z<this.min.z||n.min.z>this.max.z)}intersectsSphere(n){return this.clampPoint(n.center,gl),gl.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let e,i;return n.normal.x>0?(e=n.normal.x*this.min.x,i=n.normal.x*this.max.x):(e=n.normal.x*this.max.x,i=n.normal.x*this.min.x),n.normal.y>0?(e+=n.normal.y*this.min.y,i+=n.normal.y*this.max.y):(e+=n.normal.y*this.max.y,i+=n.normal.y*this.min.y),n.normal.z>0?(e+=n.normal.z*this.min.z,i+=n.normal.z*this.max.z):(e+=n.normal.z*this.max.z,i+=n.normal.z*this.min.z),e<=-n.constant&&i>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(Iy),A1.subVectors(this.max,Iy),Yg.subVectors(n.a,Iy),Kg.subVectors(n.b,Iy),Jg.subVectors(n.c,Iy),Ud.subVectors(Kg,Yg),zd.subVectors(Jg,Kg),Np.subVectors(Yg,Jg);let e=[0,-Ud.z,Ud.y,0,-zd.z,zd.y,0,-Np.z,Np.y,Ud.z,0,-Ud.x,zd.z,0,-zd.x,Np.z,0,-Np.x,-Ud.y,Ud.x,0,-zd.y,zd.x,0,-Np.y,Np.x,0];return!YT(e,Yg,Kg,Jg,A1)||(e=[1,0,0,0,1,0,0,0,1],!YT(e,Yg,Kg,Jg,A1))?!1:(y1.crossVectors(Ud,zd),e=[y1.x,y1.y,y1.z],YT(e,Yg,Kg,Jg,A1))}clampPoint(n,e){return e.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,gl).distanceTo(n)}getBoundingSphere(n){return this.isEmpty()?n.makeEmpty():(this.getCenter(n.center),n.radius=this.getSize(gl).length()*.5),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()?this:(Ah[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),Ah[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),Ah[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),Ah[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),Ah[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),Ah[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),Ah[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),Ah[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(Ah),this)}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}};const Ah=[new E,new E,new E,new E,new E,new E,new E,new E],gl=new E,f1=new Wt,Yg=new E,Kg=new E,Jg=new E,Ud=new E,zd=new E,Np=new E,Iy=new E,A1=new E,y1=new E,Fp=new E;function YT(n,e,i,s,r){for(let o=0,a=n.length-3;o<=a;o+=3){Fp.fromArray(n,o);const l=r.x*Math.abs(Fp.x)+r.y*Math.abs(Fp.y)+r.z*Math.abs(Fp.z),c=e.dot(Fp),h=i.dot(Fp),d=s.dot(Fp);if(Math.max(-Math.max(c,h,d),Math.min(c,h,d))>l)return!1}return!0}const hJ=new Wt,My=new E,KT=new E;let sn=class{constructor(n=new E,e=-1){this.isSphere=!0,this.center=n,this.radius=e}set(n,e){return this.center.copy(n),this.radius=e,this}setFromPoints(n,e){const i=this.center;e!==void 0?i.copy(e):hJ.setFromPoints(n).getCenter(i);let s=0;for(let r=0,o=n.length;r<o;r++)s=Math.max(s,i.distanceToSquared(n[r]));return this.radius=Math.sqrt(s),this}copy(n){return this.center.copy(n.center),this.radius=n.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(n){return n.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(n){return n.distanceTo(this.center)-this.radius}intersectsSphere(n){const e=this.radius+n.radius;return n.center.distanceToSquared(this.center)<=e*e}intersectsBox(n){return n.intersectsSphere(this)}intersectsPlane(n){return Math.abs(n.distanceToPoint(this.center))<=this.radius}clampPoint(n,e){const i=this.center.distanceToSquared(n);return e.copy(n),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(n){return this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){if(this.isEmpty())return this.center.copy(n),this.radius=0,this;My.subVectors(n,this.center);const e=My.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(My,s/i),this.radius+=s}return this}union(n){return n.isEmpty()?this:this.isEmpty()?(this.copy(n),this):(this.center.equals(n.center)===!0?this.radius=Math.max(this.radius,n.radius):(KT.subVectors(n.center,this.center).setLength(n.radius),this.expandByPoint(My.copy(n.center).add(KT)),this.expandByPoint(My.copy(n.center).sub(KT))),this)}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return new this.constructor().copy(this)}};const yh=new E,JT=new E,v1=new E,Qd=new E,qT=new E,b1=new E,$T=new E;let to=class{constructor(n=new E,e=new E(0,0,-1)){this.origin=n,this.direction=e}set(n,e){return this.origin.copy(n),this.direction.copy(e),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,e){return e.copy(this.origin).addScaledVector(this.direction,n)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,yh)),this}closestPointToPoint(n,e){e.subVectors(n,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){const e=yh.subVectors(n,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(n):(yh.copy(this.origin).addScaledVector(this.direction,e),yh.distanceToSquared(n))}distanceSqToSegment(n,e,i,s){JT.copy(n).add(e).multiplyScalar(.5),v1.copy(e).sub(n).normalize(),Qd.copy(this.origin).sub(JT);const r=n.distanceTo(e)*.5,o=-this.direction.dot(v1),a=Qd.dot(this.direction),l=-Qd.dot(v1),c=Qd.lengthSq(),h=Math.abs(1-o*o);let d,u,m,g;if(h>0