@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.57 MB
JavaScript
"use strict";var e6=Object.defineProperty;var t6=(g,A,e)=>A in g?e6(g,A,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[A]=e;var c=(g,A,e)=>(t6(g,typeof A!="symbol"?A+"":A,e),e),GU=(g,A,e)=>{if(!A.has(g))throw TypeError("Cannot "+e)};var yt=(g,A,e)=>(GU(g,A,"read from private field"),e?e.call(g):A.get(g)),Cs=(g,A,e)=>{if(A.has(g))throw TypeError("Cannot add the same private member more than once");A instanceof WeakSet?A.add(g):A.set(g,e)},Nn=(g,A,e,t)=>(GU(g,A,"write to private field"),t?t.call(g,e):A.set(g,e),e);var oQ=(g,A,e)=>(GU(g,A,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var kU=typeof document<"u"?document.currentScript:null;/**
* @license
* Copyright 2010-2023 Three.js Authors
* SPDX-License-Identifier: MIT
*/const KC="162",vQ={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},qQ={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},G4=0,yK=1,k4=2,i6=3,g6=0,oL=1,IL=2,Ja=3,Oi=0,Fi=1,Mt=2,bi=0,ic=1,ml=2,wK=3,mK=4,sL=5,OB=100,M4=101,R4=102,SK=103,SG=104,U4=200,N4=201,F4=202,b4=203,GG=204,kG=205,K4=206,x4=207,J4=208,L4=209,v4=210,q4=211,T4=212,_4=213,H4=214,nL=0,jk=1,mD=2,Sl=3,Gd=4,$k=5,AM=6,Ry=7,Uy=0,Y4=1,O4=2,NI=0,eu=1,Ny=2,P4=3,Fy=4,Z4=5,tu=6,Gl=7,GK="attached",W4="detached",eM=300,xC=301,uc=302,FI=303,kd=304,iu=306,KI=1e3,wg=1001,JC=1002,Te=1003,Md=1004,o6=1004,cC=1005,I6=1005,Je=1006,sl=1007,s6=1007,MI=1008,n6=1008,St=1009,MG=1010,aL=1011,by=1012,nl=1013,eI=1014,qt=1015,Hi=1016,rL=1017,CL=1018,kC=1020,V4=1021,Qt=1023,tM=1024,X4=1025,gc=1026,pc=1027,dn=1028,iM=1029,fC=1030,Ky=1031,Rd=1033,Tf=33776,TS=33777,_S=33778,_f=33779,RG=35840,kK=35841,UG=35842,MK=35843,gM=36196,NG=37492,FG=37496,bG=37808,RK=37809,UK=37810,NK=37811,SD=37812,FK=37813,bK=37814,KK=37815,xK=37816,JK=37817,LK=37818,vK=37819,qK=37820,TK=37821,Hf=36492,_K=36494,HK=36495,z4=36283,YK=36284,OK=36285,PK=36286,GD=2200,BL=2201,j4=2202,fc=2300,cr=2301,HS=2302,zQ=2400,jQ=2401,kD=2402,oM=2500,cL=2501,$4=0,QL=1,KG=2,AZ=3e3,ZK=3001,bo=3200,IM=3201,Nc=0,eZ=1,AI="",pe="srgb",Ht="srgb-linear",xy="display-p3",gu="display-p3-linear",MD="linear",ai="srgb",RD="rec709",UD="p3",tZ=0,LB=7680,iZ=7681,gZ=7682,oZ=7683,IZ=34055,sZ=34056,nZ=5386,WK=512,aZ=513,rZ=514,CZ=515,BZ=516,cZ=517,QZ=518,xG=519,lZ=512,hZ=513,EZ=514,lL=515,dZ=516,uZ=517,pZ=518,fZ=519,ND=35044,$o=35048,a6=35040,r6=35045,C6=35049,B6=35041,c6=35046,Q6=35050,l6=35042,h6="100",JG="300 es",LG=1035,ja=2e3,FD=2001;let ro=class{addEventListener(A,e){this._listeners===void 0&&(this._listeners={});const t=this._listeners;t[A]===void 0&&(t[A]=[]),t[A].indexOf(e)===-1&&t[A].push(e)}hasEventListener(A,e){if(this._listeners===void 0)return!1;const t=this._listeners;return t[A]!==void 0&&t[A].indexOf(e)!==-1}removeEventListener(A,e){if(this._listeners===void 0)return;const i=this._listeners[A];if(i!==void 0){const o=i.indexOf(e);o!==-1&&i.splice(o,1)}}dispatchEvent(A){if(this._listeners===void 0)return;const t=this._listeners[A.type];if(t!==void 0){A.target=this;const i=t.slice(0);for(let o=0,I=i.length;o<I;o++)i[o].call(this,A);A.target=null}}};const Ho=["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 X_=1234567;const al=Math.PI/180,Ud=180/Math.PI;function Ks(){const g=Math.random()*4294967295|0,A=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0;return(Ho[g&255]+Ho[g>>8&255]+Ho[g>>16&255]+Ho[g>>24&255]+"-"+Ho[A&255]+Ho[A>>8&255]+"-"+Ho[A>>16&15|64]+Ho[A>>24&255]+"-"+Ho[e&63|128]+Ho[e>>8&255]+"-"+Ho[e>>16&255]+Ho[e>>24&255]+Ho[t&255]+Ho[t>>8&255]+Ho[t>>16&255]+Ho[t>>24&255]).toLowerCase()}function og(g,A,e){return Math.max(A,Math.min(e,g))}function hL(g,A){return(g%A+A)%A}function E6(g,A,e,t,i){return t+(g-A)*(i-t)/(e-A)}function d6(g,A,e){return g!==A?(e-g)/(A-g):0}function Yf(g,A,e){return(1-e)*g+e*A}function u6(g,A,e,t){return Yf(g,A,1-Math.exp(-e*t))}function p6(g,A=1){return A-Math.abs(hL(g,A*2)-A)}function f6(g,A,e){return g<=A?0:g>=e?1:(g=(g-A)/(e-A),g*g*(3-2*g))}function D6(g,A,e){return g<=A?0:g>=e?1:(g=(g-A)/(e-A),g*g*g*(g*(g*6-15)+10))}function y6(g,A){return g+Math.floor(Math.random()*(A-g+1))}function w6(g,A){return g+Math.random()*(A-g)}function m6(g){return g*(.5-Math.random())}function S6(g){g!==void 0&&(X_=g);let A=X_+=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 G6(g){return g*al}function k6(g){return g*Ud}function VK(g){return(g&g-1)===0&&g!==0}function M6(g){return Math.pow(2,Math.ceil(Math.log(g)/Math.LN2))}function vG(g){return Math.pow(2,Math.floor(Math.log(g)/Math.LN2))}function R6(g,A,e,t,i){const o=Math.cos,I=Math.sin,s=o(e/2),n=I(e/2),a=o((A+t)/2),r=I((A+t)/2),C=o((A-t)/2),B=I((A-t)/2),Q=o((t-A)/2),l=I((t-A)/2);switch(i){case"XYX":g.set(s*r,n*C,n*B,s*a);break;case"YZY":g.set(n*B,s*r,n*C,s*a);break;case"ZXZ":g.set(n*C,n*B,s*r,s*a);break;case"XZX":g.set(s*r,n*l,n*Q,s*a);break;case"YXY":g.set(n*Q,s*r,n*l,s*a);break;case"ZYZ":g.set(n*l,n*Q,s*r,s*a);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function GI(g,A){switch(A.constructor){case Float32Array:return g;case Uint32Array:return g/4294967295;case Uint16Array:return g/65535;case Uint8Array:return g/255;case Int32Array:return Math.max(g/2147483647,-1);case Int16Array:return Math.max(g/32767,-1);case Int8Array:return Math.max(g/127,-1);default:throw new Error("Invalid component type.")}}function tt(g,A){switch(A.constructor){case Float32Array:return g;case Uint32Array:return Math.round(g*4294967295);case Uint16Array:return Math.round(g*65535);case Uint8Array:return Math.round(g*255);case Int32Array:return Math.round(g*2147483647);case Int16Array:return Math.round(g*32767);case Int8Array:return Math.round(g*127);default:throw new Error("Invalid component type.")}}const ct={DEG2RAD:al,RAD2DEG:Ud,generateUUID:Ks,clamp:og,euclideanModulo:hL,mapLinear:E6,inverseLerp:d6,lerp:Yf,damp:u6,pingpong:p6,smoothstep:f6,smootherstep:D6,randInt:y6,randFloat:w6,randFloatSpread:m6,seededRandom:S6,degToRad:G6,radToDeg:k6,isPowerOfTwo:VK,ceilPowerOfTwo:M6,floorPowerOfTwo:vG,setQuaternionFromProperEuler:R6,normalize:tt,denormalize:GI};let eA=class DZ{constructor(A=0,e=0){DZ.prototype.isVector2=!0,this.x=A,this.y=e}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}set(A,e){return this.x=A,this.y=e,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,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;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,e){return this.x=A.x+e.x,this.y=A.y+e.y,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,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,e){return this.x=A.x-e.x,this.y=A.y-e.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 e=this.x,t=this.y,i=A.elements;return this.x=i[0]*e+i[3]*t+i[6],this.y=i[1]*e+i[4]*t+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,e){return this.x=Math.max(A.x,Math.min(e.x,this.x)),this.y=Math.max(A.y,Math.min(e.y,this.y)),this}clampScalar(A,e){return this.x=Math.max(A,Math.min(e,this.x)),this.y=Math.max(A,Math.min(e,this.y)),this}clampLength(A,e){const t=this.length();return this.divideScalar(t||1).multiplyScalar(Math.max(A,Math.min(e,t)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(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 e=Math.sqrt(this.lengthSq()*A.lengthSq());if(e===0)return Math.PI/2;const t=this.dot(A)/e;return Math.acos(og(t,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){const e=this.x-A.x,t=this.y-A.y;return e*e+t*t}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this}equals(A){return A.x===this.x&&A.y===this.y}fromArray(A,e=0){return this.x=A[e],this.y=A[e+1],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this}rotateAround(A,e){const t=Math.cos(e),i=Math.sin(e),o=this.x-A.x,I=this.y-A.y;return this.x=o*t-I*i+A.x,this.y=o*i+I*t+A.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},qe=class yZ{constructor(A,e,t,i,o,I,s,n,a){yZ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],A!==void 0&&this.set(A,e,t,i,o,I,s,n,a)}set(A,e,t,i,o,I,s,n,a){const r=this.elements;return r[0]=A,r[1]=i,r[2]=s,r[3]=e,r[4]=o,r[5]=n,r[6]=t,r[7]=I,r[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){const e=this.elements,t=A.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}extractBasis(A,e,t){return A.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),t.setFromMatrix3Column(this,2),this}setFromMatrix4(A){const e=A.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,e){const t=A.elements,i=e.elements,o=this.elements,I=t[0],s=t[3],n=t[6],a=t[1],r=t[4],C=t[7],B=t[2],Q=t[5],l=t[8],h=i[0],E=i[3],d=i[6],p=i[1],u=i[4],f=i[7],D=i[2],y=i[5],m=i[8];return o[0]=I*h+s*p+n*D,o[3]=I*E+s*u+n*y,o[6]=I*d+s*f+n*m,o[1]=a*h+r*p+C*D,o[4]=a*E+r*u+C*y,o[7]=a*d+r*f+C*m,o[2]=B*h+Q*p+l*D,o[5]=B*E+Q*u+l*y,o[8]=B*d+Q*f+l*m,this}multiplyScalar(A){const e=this.elements;return e[0]*=A,e[3]*=A,e[6]*=A,e[1]*=A,e[4]*=A,e[7]*=A,e[2]*=A,e[5]*=A,e[8]*=A,this}determinant(){const A=this.elements,e=A[0],t=A[1],i=A[2],o=A[3],I=A[4],s=A[5],n=A[6],a=A[7],r=A[8];return e*I*r-e*s*a-t*o*r+t*s*n+i*o*a-i*I*n}invert(){const A=this.elements,e=A[0],t=A[1],i=A[2],o=A[3],I=A[4],s=A[5],n=A[6],a=A[7],r=A[8],C=r*I-s*a,B=s*n-r*o,Q=a*o-I*n,l=e*C+t*B+i*Q;if(l===0)return this.set(0,0,0,0,0,0,0,0,0);const h=1/l;return A[0]=C*h,A[1]=(i*a-r*t)*h,A[2]=(s*t-i*I)*h,A[3]=B*h,A[4]=(r*e-i*n)*h,A[5]=(i*o-s*e)*h,A[6]=Q*h,A[7]=(t*n-a*e)*h,A[8]=(I*e-t*o)*h,this}transpose(){let A;const e=this.elements;return A=e[1],e[1]=e[3],e[3]=A,A=e[2],e[2]=e[6],e[6]=A,A=e[5],e[5]=e[7],e[7]=A,this}getNormalMatrix(A){return this.setFromMatrix4(A).invert().transpose()}transposeIntoArray(A){const e=this.elements;return A[0]=e[0],A[1]=e[3],A[2]=e[6],A[3]=e[1],A[4]=e[4],A[5]=e[7],A[6]=e[2],A[7]=e[5],A[8]=e[8],this}setUvTransform(A,e,t,i,o,I,s){const n=Math.cos(o),a=Math.sin(o);return this.set(t*n,t*a,-t*(n*I+a*s)+I+A,-i*a,i*n,-i*(-a*I+n*s)+s+e,0,0,1),this}scale(A,e){return this.premultiply(MU.makeScale(A,e)),this}rotate(A){return this.premultiply(MU.makeRotation(-A)),this}translate(A,e){return this.premultiply(MU.makeTranslation(A,e)),this}makeTranslation(A,e){return A.isVector2?this.set(1,0,A.x,0,1,A.y,0,0,1):this.set(1,0,A,0,1,e,0,0,1),this}makeRotation(A){const e=Math.cos(A),t=Math.sin(A);return this.set(e,-t,0,t,e,0,0,0,1),this}makeScale(A,e){return this.set(A,0,0,0,e,0,0,0,1),this}equals(A){const e=this.elements,t=A.elements;for(let i=0;i<9;i++)if(e[i]!==t[i])return!1;return!0}fromArray(A,e=0){for(let t=0;t<9;t++)this.elements[t]=A[t+e];return this}toArray(A=[],e=0){const t=this.elements;return A[e]=t[0],A[e+1]=t[1],A[e+2]=t[2],A[e+3]=t[3],A[e+4]=t[4],A[e+5]=t[5],A[e+6]=t[6],A[e+7]=t[7],A[e+8]=t[8],A}clone(){return new this.constructor().fromArray(this.elements)}};const MU=new qe;function wZ(g){for(let A=g.length-1;A>=0;--A)if(g[A]>=65535)return!0;return!1}const U6={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function PE(g,A){return new U6[g](A)}function bD(g){return document.createElementNS("http://www.w3.org/1999/xhtml",g)}function mZ(){const g=bD("canvas");return g.style.display="block",g}const z_={};function SZ(g){g in z_||(z_[g]=!0,console.warn(g))}const j_=new qe().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),$_=new qe().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),jw={[Ht]:{transfer:MD,primaries:RD,toReference:g=>g,fromReference:g=>g},[pe]:{transfer:ai,primaries:RD,toReference:g=>g.convertSRGBToLinear(),fromReference:g=>g.convertLinearToSRGB()},[gu]:{transfer:MD,primaries:UD,toReference:g=>g.applyMatrix3($_),fromReference:g=>g.applyMatrix3(j_)},[xy]:{transfer:ai,primaries:UD,toReference:g=>g.convertSRGBToLinear().applyMatrix3($_),fromReference:g=>g.applyMatrix3(j_).convertLinearToSRGB()}},N6=new Set([Ht,gu]),xt={enabled:!0,_workingColorSpace:Ht,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(g){if(!N6.has(g))throw new Error(`Unsupported working color space, "${g}".`);this._workingColorSpace=g},convert:function(g,A,e){if(this.enabled===!1||A===e||!A||!e)return g;const t=jw[A].toReference,i=jw[e].fromReference;return i(t(g))},fromWorkingColorSpace:function(g,A){return this.convert(g,this._workingColorSpace,A)},toWorkingColorSpace:function(g,A){return this.convert(g,A,this._workingColorSpace)},getPrimaries:function(g){return jw[g].primaries},getTransfer:function(g){return g===AI?MD:jw[g].transfer}};function rd(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}function RU(g){return g<.0031308?g*12.92:1.055*Math.pow(g,.41666)-.055}let yh,EL=class{static getDataURL(A){if(/^data:/i.test(A.src)||typeof HTMLCanvasElement>"u")return A.src;let e;if(A instanceof HTMLCanvasElement)e=A;else{yh===void 0&&(yh=bD("canvas")),yh.width=A.width,yh.height=A.height;const t=yh.getContext("2d");A instanceof ImageData?t.putImageData(A,0,0):t.drawImage(A,0,0,A.width,A.height),e=yh}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",A),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap){const e=bD("canvas");e.width=A.width,e.height=A.height;const t=e.getContext("2d");t.drawImage(A,0,0,A.width,A.height);const i=t.getImageData(0,0,A.width,A.height),o=i.data;for(let I=0;I<o.length;I++)o[I]=rd(o[I]/255)*255;return t.putImageData(i,0,0),e}else if(A.data){const e=A.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(rd(e[t]/255)*255):e[t]=rd(e[t]);return{data:e,width:A.width,height:A.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),A}},F6=0,DC=class{constructor(A=null){this.isSource=!0,Object.defineProperty(this,"id",{value:F6++}),this.uuid=Ks(),this.data=A,this.dataReady=!0,this.version=0}set needsUpdate(A){A===!0&&this.version++}toJSON(A){const e=A===void 0||typeof A=="string";if(!e&&A.images[this.uuid]!==void 0)return A.images[this.uuid];const t={uuid:this.uuid,url:""},i=this.data;if(i!==null){let o;if(Array.isArray(i)){o=[];for(let I=0,s=i.length;I<s;I++)i[I].isDataTexture?o.push(UU(i[I].image)):o.push(UU(i[I]))}else o=UU(i);t.url=o}return e||(A.images[this.uuid]=t),t}};function UU(g){return typeof HTMLImageElement<"u"&&g instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&g instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&g instanceof ImageBitmap?EL.getDataURL(g):g.data?{data:Array.from(g.data),width:g.width,height:g.height,type:g.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let b6=0,Pe=class YS extends ro{constructor(A=YS.DEFAULT_IMAGE,e=YS.DEFAULT_MAPPING,t=wg,i=wg,o=Je,I=MI,s=Qt,n=St,a=YS.DEFAULT_ANISOTROPY,r=AI){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:b6++}),this.uuid=Ks(),this.name="",this.source=new DC(A),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=t,this.wrapT=i,this.magFilter=o,this.minFilter=I,this.anisotropy=a,this.format=s,this.internalFormat=null,this.type=n,this.offset=new eA(0,0),this.repeat=new eA(1,1),this.center=new eA(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new qe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=r,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 e=A===void 0||typeof A=="string";if(!e&&A.textures[this.uuid]!==void 0)return A.textures[this.uuid];const t={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&&(t.userData=this.userData),e||(A.textures[this.uuid]=t),t}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(A){if(this.mapping!==eM)return A;if(A.applyMatrix3(this.matrix),A.x<0||A.x>1)switch(this.wrapS){case KI:A.x=A.x-Math.floor(A.x);break;case wg:A.x=A.x<0?0:1;break;case JC: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 KI:A.y=A.y-Math.floor(A.y);break;case wg:A.y=A.y<0?0:1;break;case JC: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)}};Pe.DEFAULT_IMAGE=null;Pe.DEFAULT_MAPPING=eM;Pe.DEFAULT_ANISOTROPY=1;let $A=class GZ{constructor(A=0,e=0,t=0,i=1){GZ.prototype.isVector4=!0,this.x=A,this.y=e,this.z=t,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,e,t,i){return this.x=A,this.y=e,this.z=t,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,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+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,e){return this.x=A.x+e.x,this.y=A.y+e.y,this.z=A.z+e.z,this.w=A.w+e.w,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,this.z+=A.z*e,this.w+=A.w*e,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,e){return this.x=A.x-e.x,this.y=A.y-e.y,this.z=A.z-e.z,this.w=A.w-e.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 e=this.x,t=this.y,i=this.z,o=this.w,I=A.elements;return this.x=I[0]*e+I[4]*t+I[8]*i+I[12]*o,this.y=I[1]*e+I[5]*t+I[9]*i+I[13]*o,this.z=I[2]*e+I[6]*t+I[10]*i+I[14]*o,this.w=I[3]*e+I[7]*t+I[11]*i+I[15]*o,this}divideScalar(A){return this.multiplyScalar(1/A)}setAxisAngleFromQuaternion(A){this.w=2*Math.acos(A.w);const e=Math.sqrt(1-A.w*A.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=A.x/e,this.y=A.y/e,this.z=A.z/e),this}setAxisAngleFromRotationMatrix(A){let e,t,i,o;const n=A.elements,a=n[0],r=n[4],C=n[8],B=n[1],Q=n[5],l=n[9],h=n[2],E=n[6],d=n[10];if(Math.abs(r-B)<.01&&Math.abs(C-h)<.01&&Math.abs(l-E)<.01){if(Math.abs(r+B)<.1&&Math.abs(C+h)<.1&&Math.abs(l+E)<.1&&Math.abs(a+Q+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const u=(a+1)/2,f=(Q+1)/2,D=(d+1)/2,y=(r+B)/4,m=(C+h)/4,k=(l+E)/4;return u>f&&u>D?u<.01?(t=0,i=.707106781,o=.707106781):(t=Math.sqrt(u),i=y/t,o=m/t):f>D?f<.01?(t=.707106781,i=0,o=.707106781):(i=Math.sqrt(f),t=y/i,o=k/i):D<.01?(t=.707106781,i=.707106781,o=0):(o=Math.sqrt(D),t=m/o,i=k/o),this.set(t,i,o,e),this}let p=Math.sqrt((E-l)*(E-l)+(C-h)*(C-h)+(B-r)*(B-r));return Math.abs(p)<.001&&(p=1),this.x=(E-l)/p,this.y=(C-h)/p,this.z=(B-r)/p,this.w=Math.acos((a+Q+d-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,e){return this.x=Math.max(A.x,Math.min(e.x,this.x)),this.y=Math.max(A.y,Math.min(e.y,this.y)),this.z=Math.max(A.z,Math.min(e.z,this.z)),this.w=Math.max(A.w,Math.min(e.w,this.w)),this}clampScalar(A,e){return this.x=Math.max(A,Math.min(e,this.x)),this.y=Math.max(A,Math.min(e,this.y)),this.z=Math.max(A,Math.min(e,this.z)),this.w=Math.max(A,Math.min(e,this.w)),this}clampLength(A,e){const t=this.length();return this.divideScalar(t||1).multiplyScalar(Math.max(A,Math.min(e,t)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(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,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this.z+=(A.z-this.z)*e,this.w+=(A.w-this.w)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this.z=A.z+(e.z-A.z)*t,this.w=A.w+(e.w-A.w)*t,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z&&A.w===this.w}fromArray(A,e=0){return this.x=A[e],this.y=A[e+1],this.z=A[e+2],this.w=A[e+3],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A[e+2]=this.z,A[e+3]=this.w,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this.z=A.getZ(e),this.w=A.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};class kZ extends ro{constructor(A=1,e=1,t={}){super(),this.isRenderTarget=!0,this.width=A,this.height=e,this.depth=1,this.scissor=new $A(0,0,A,e),this.scissorTest=!1,this.viewport=new $A(0,0,A,e);const i={width:A,height:e,depth:1};t=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Je,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0,count:1},t);const o=new Pe(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace);o.flipY=!1,o.generateMipmaps=t.generateMipmaps,o.internalFormat=t.internalFormat,this.textures=[];const I=t.count;for(let s=0;s<I;s++)this.textures[s]=o.clone(),this.textures[s].isRenderTargetTexture=!0;this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this.samples=t.samples}get texture(){return this.textures[0]}set texture(A){this.textures[0]=A}setSize(A,e,t=1){if(this.width!==A||this.height!==e||this.depth!==t){this.width=A,this.height=e,this.depth=t;for(let i=0,o=this.textures.length;i<o;i++)this.textures[i].image.width=A,this.textures[i].image.height=e,this.textures[i].image.depth=t;this.dispose()}this.viewport.set(0,0,A,e),this.scissor.set(0,0,A,e)}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 t=0,i=A.textures.length;t<i;t++)this.textures[t]=A.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0;const e=Object.assign({},A.texture.image);return this.texture.source=new DC(e),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 At extends kZ{constructor(A=1,e=1,t={}){super(A,e,t),this.isWebGLRenderTarget=!0}}class sM extends Pe{constructor(A=null,e=1,t=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:A,width:e,height:t,depth:i},this.magFilter=Te,this.minFilter=Te,this.wrapR=wg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class K6 extends At{constructor(A=1,e=1,t=1,i={}){super(A,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=t,this.texture=new sM(null,A,e,t),this.texture.isRenderTargetTexture=!0}}let nM=class extends Pe{constructor(A=null,e=1,t=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:A,width:e,height:t,depth:i},this.magFilter=Te,this.minFilter=Te,this.wrapR=wg,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};class x6 extends At{constructor(A=1,e=1,t=1,i={}){super(A,e,i),this.isWebGL3DRenderTarget=!0,this.depth=t,this.texture=new nM(null,A,e,t),this.texture.isRenderTargetTexture=!0}}let GA=class{constructor(A=0,e=0,t=0,i=1){this.isQuaternion=!0,this._x=A,this._y=e,this._z=t,this._w=i}static slerpFlat(A,e,t,i,o,I,s){let n=t[i+0],a=t[i+1],r=t[i+2],C=t[i+3];const B=o[I+0],Q=o[I+1],l=o[I+2],h=o[I+3];if(s===0){A[e+0]=n,A[e+1]=a,A[e+2]=r,A[e+3]=C;return}if(s===1){A[e+0]=B,A[e+1]=Q,A[e+2]=l,A[e+3]=h;return}if(C!==h||n!==B||a!==Q||r!==l){let E=1-s;const d=n*B+a*Q+r*l+C*h,p=d>=0?1:-1,u=1-d*d;if(u>Number.EPSILON){const D=Math.sqrt(u),y=Math.atan2(D,d*p);E=Math.sin(E*y)/D,s=Math.sin(s*y)/D}const f=s*p;if(n=n*E+B*f,a=a*E+Q*f,r=r*E+l*f,C=C*E+h*f,E===1-s){const D=1/Math.sqrt(n*n+a*a+r*r+C*C);n*=D,a*=D,r*=D,C*=D}}A[e]=n,A[e+1]=a,A[e+2]=r,A[e+3]=C}static multiplyQuaternionsFlat(A,e,t,i,o,I){const s=t[i],n=t[i+1],a=t[i+2],r=t[i+3],C=o[I],B=o[I+1],Q=o[I+2],l=o[I+3];return A[e]=s*l+r*C+n*Q-a*B,A[e+1]=n*l+r*B+a*C-s*Q,A[e+2]=a*l+r*Q+s*B-n*C,A[e+3]=r*l-s*C-n*B-a*Q,A}get x(){return this._x}set x(A){this._x=A,this._onChangeCallback()}get y(){return this._y}set y(A){this._y=A,this._onChangeCallback()}get z(){return this._z}set z(A){this._z=A,this._onChangeCallback()}get w(){return this._w}set w(A){this._w=A,this._onChangeCallback()}set(A,e,t,i){return this._x=A,this._y=e,this._z=t,this._w=i,this._onChangeCallback(),this}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,this._onChangeCallback(),this}setFromEuler(A,e=!0){const t=A._x,i=A._y,o=A._z,I=A._order,s=Math.cos,n=Math.sin,a=s(t/2),r=s(i/2),C=s(o/2),B=n(t/2),Q=n(i/2),l=n(o/2);switch(I){case"XYZ":this._x=B*r*C+a*Q*l,this._y=a*Q*C-B*r*l,this._z=a*r*l+B*Q*C,this._w=a*r*C-B*Q*l;break;case"YXZ":this._x=B*r*C+a*Q*l,this._y=a*Q*C-B*r*l,this._z=a*r*l-B*Q*C,this._w=a*r*C+B*Q*l;break;case"ZXY":this._x=B*r*C-a*Q*l,this._y=a*Q*C+B*r*l,this._z=a*r*l+B*Q*C,this._w=a*r*C-B*Q*l;break;case"ZYX":this._x=B*r*C-a*Q*l,this._y=a*Q*C+B*r*l,this._z=a*r*l-B*Q*C,this._w=a*r*C+B*Q*l;break;case"YZX":this._x=B*r*C+a*Q*l,this._y=a*Q*C+B*r*l,this._z=a*r*l-B*Q*C,this._w=a*r*C-B*Q*l;break;case"XZY":this._x=B*r*C-a*Q*l,this._y=a*Q*C-B*r*l,this._z=a*r*l+B*Q*C,this._w=a*r*C+B*Q*l;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+I)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(A,e){const t=e/2,i=Math.sin(t);return this._x=A.x*i,this._y=A.y*i,this._z=A.z*i,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(A){const e=A.elements,t=e[0],i=e[4],o=e[8],I=e[1],s=e[5],n=e[9],a=e[2],r=e[6],C=e[10],B=t+s+C;if(B>0){const Q=.5/Math.sqrt(B+1);this._w=.25/Q,this._x=(r-n)*Q,this._y=(o-a)*Q,this._z=(I-i)*Q}else if(t>s&&t>C){const Q=2*Math.sqrt(1+t-s-C);this._w=(r-n)/Q,this._x=.25*Q,this._y=(i+I)/Q,this._z=(o+a)/Q}else if(s>C){const Q=2*Math.sqrt(1+s-t-C);this._w=(o-a)/Q,this._x=(i+I)/Q,this._y=.25*Q,this._z=(n+r)/Q}else{const Q=2*Math.sqrt(1+C-t-s);this._w=(I-i)/Q,this._x=(o+a)/Q,this._y=(n+r)/Q,this._z=.25*Q}return this._onChangeCallback(),this}setFromUnitVectors(A,e){let t=A.dot(e)+1;return t<Number.EPSILON?(t=0,Math.abs(A.x)>Math.abs(A.z)?(this._x=-A.y,this._y=A.x,this._z=0,this._w=t):(this._x=0,this._y=-A.z,this._z=A.y,this._w=t)):(this._x=A.y*e.z-A.z*e.y,this._y=A.z*e.x-A.x*e.z,this._z=A.x*e.y-A.y*e.x,this._w=t),this.normalize()}angleTo(A){return 2*Math.acos(Math.abs(og(this.dot(A),-1,1)))}rotateTowards(A,e){const t=this.angleTo(A);if(t===0)return this;const i=Math.min(1,e/t);return this.slerp(A,i),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(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)}normalize(){let A=this.length();return A===0?(this._x=0,this._y=0,this._z=0,this._w=1):(A=1/A,this._x=this._x*A,this._y=this._y*A,this._z=this._z*A,this._w=this._w*A),this._onChangeCallback(),this}multiply(A){return this.multiplyQuaternions(this,A)}premultiply(A){return this.multiplyQuaternions(A,this)}multiplyQuaternions(A,e){const t=A._x,i=A._y,o=A._z,I=A._w,s=e._x,n=e._y,a=e._z,r=e._w;return this._x=t*r+I*s+i*a-o*n,this._y=i*r+I*n+o*s-t*a,this._z=o*r+I*a+t*n-i*s,this._w=I*r-t*s-i*n-o*a,this._onChangeCallback(),this}slerp(A,e){if(e===0)return this;if(e===1)return this.copy(A);const t=this._x,i=this._y,o=this._z,I=this._w;let s=I*A._w+t*A._x+i*A._y+o*A._z;if(s<0?(this._w=-A._w,this._x=-A._x,this._y=-A._y,this._z=-A._z,s=-s):this.copy(A),s>=1)return this._w=I,this._x=t,this._y=i,this._z=o,this;const n=1-s*s;if(n<=Number.EPSILON){const Q=1-e;return this._w=Q*I+e*this._w,this._x=Q*t+e*this._x,this._y=Q*i+e*this._y,this._z=Q*o+e*this._z,this.normalize(),this}const a=Math.sqrt(n),r=Math.atan2(a,s),C=Math.sin((1-e)*r)/a,B=Math.sin(e*r)/a;return this._w=I*C+this._w*B,this._x=t*C+this._x*B,this._y=i*C+this._y*B,this._z=o*C+this._z*B,this._onChangeCallback(),this}slerpQuaternions(A,e,t){return this.copy(A).slerp(e,t)}random(){const A=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),t=Math.random(),i=Math.sqrt(1-t),o=Math.sqrt(t);return this.set(i*Math.sin(A),i*Math.cos(A),o*Math.sin(e),o*Math.cos(e))}equals(A){return A._x===this._x&&A._y===this._y&&A._z===this._z&&A._w===this._w}fromArray(A,e=0){return this._x=A[e],this._y=A[e+1],this._z=A[e+2],this._w=A[e+3],this._onChangeCallback(),this}toArray(A=[],e=0){return A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w,A}fromBufferAttribute(A,e){return this._x=A.getX(e),this._y=A.getY(e),this._z=A.getZ(e),this._w=A.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(A){return this._onChangeCallback=A,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},S=class MZ{constructor(A=0,e=0,t=0){MZ.prototype.isVector3=!0,this.x=A,this.y=e,this.z=t}set(A,e,t){return t===void 0&&(t=this.z),this.x=A,this.y=e,this.z=t,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,e){switch(A){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+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,e){return this.x=A.x+e.x,this.y=A.y+e.y,this.z=A.z+e.z,this}addScaledVector(A,e){return this.x+=A.x*e,this.y+=A.y*e,this.z+=A.z*e,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,e){return this.x=A.x-e.x,this.y=A.y-e.y,this.z=A.z-e.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,e){return this.x=A.x*e.x,this.y=A.y*e.y,this.z=A.z*e.z,this}applyEuler(A){return this.applyQuaternion(AH.setFromEuler(A))}applyAxisAngle(A,e){return this.applyQuaternion(AH.setFromAxisAngle(A,e))}applyMatrix3(A){const e=this.x,t=this.y,i=this.z,o=A.elements;return this.x=o[0]*e+o[3]*t+o[6]*i,this.y=o[1]*e+o[4]*t+o[7]*i,this.z=o[2]*e+o[5]*t+o[8]*i,this}applyNormalMatrix(A){return this.applyMatrix3(A).normalize()}applyMatrix4(A){const e=this.x,t=this.y,i=this.z,o=A.elements,I=1/(o[3]*e+o[7]*t+o[11]*i+o[15]);return this.x=(o[0]*e+o[4]*t+o[8]*i+o[12])*I,this.y=(o[1]*e+o[5]*t+o[9]*i+o[13])*I,this.z=(o[2]*e+o[6]*t+o[10]*i+o[14])*I,this}applyQuaternion(A){const e=this.x,t=this.y,i=this.z,o=A.x,I=A.y,s=A.z,n=A.w,a=2*(I*i-s*t),r=2*(s*e-o*i),C=2*(o*t-I*e);return this.x=e+n*a+I*C-s*r,this.y=t+n*r+s*a-o*C,this.z=i+n*C+o*r-I*a,this}project(A){return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix)}unproject(A){return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld)}transformDirection(A){const e=this.x,t=this.y,i=this.z,o=A.elements;return this.x=o[0]*e+o[4]*t+o[8]*i,this.y=o[1]*e+o[5]*t+o[9]*i,this.z=o[2]*e+o[6]*t+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,e){return this.x=Math.max(A.x,Math.min(e.x,this.x)),this.y=Math.max(A.y,Math.min(e.y,this.y)),this.z=Math.max(A.z,Math.min(e.z,this.z)),this}clampScalar(A,e){return this.x=Math.max(A,Math.min(e,this.x)),this.y=Math.max(A,Math.min(e,this.y)),this.z=Math.max(A,Math.min(e,this.z)),this}clampLength(A,e){const t=this.length();return this.divideScalar(t||1).multiplyScalar(Math.max(A,Math.min(e,t)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(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,e){return this.x+=(A.x-this.x)*e,this.y+=(A.y-this.y)*e,this.z+=(A.z-this.z)*e,this}lerpVectors(A,e,t){return this.x=A.x+(e.x-A.x)*t,this.y=A.y+(e.y-A.y)*t,this.z=A.z+(e.z-A.z)*t,this}cross(A){return this.crossVectors(this,A)}crossVectors(A,e){const t=A.x,i=A.y,o=A.z,I=e.x,s=e.y,n=e.z;return this.x=i*n-o*s,this.y=o*I-t*n,this.z=t*s-i*I,this}projectOnVector(A){const e=A.lengthSq();if(e===0)return this.set(0,0,0);const t=A.dot(this)/e;return this.copy(A).multiplyScalar(t)}projectOnPlane(A){return NU.copy(this).projectOnVector(A),this.sub(NU)}reflect(A){return this.sub(NU.copy(A).multiplyScalar(2*this.dot(A)))}angleTo(A){const e=Math.sqrt(this.lengthSq()*A.lengthSq());if(e===0)return Math.PI/2;const t=this.dot(A)/e;return Math.acos(og(t,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){const e=this.x-A.x,t=this.y-A.y,i=this.z-A.z;return e*e+t*t+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,e,t){const i=Math.sin(e)*A;return this.x=i*Math.sin(t),this.y=Math.cos(e)*A,this.z=i*Math.cos(t),this}setFromCylindrical(A){return this.setFromCylindricalCoords(A.radius,A.theta,A.y)}setFromCylindricalCoords(A,e,t){return this.x=A*Math.sin(e),this.y=t,this.z=A*Math.cos(e),this}setFromMatrixPosition(A){const e=A.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(A){const e=this.setFromMatrixColumn(A,0).length(),t=this.setFromMatrixColumn(A,1).length(),i=this.setFromMatrixColumn(A,2).length();return this.x=e,this.y=t,this.z=i,this}setFromMatrixColumn(A,e){return this.fromArray(A.elements,e*4)}setFromMatrix3Column(A,e){return this.fromArray(A.elements,e*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,e=0){return this.x=A[e],this.y=A[e+1],this.z=A[e+2],this}toArray(A=[],e=0){return A[e]=this.x,A[e+1]=this.y,A[e+2]=this.z,A}fromBufferAttribute(A,e){return this.x=A.getX(e),this.y=A.getY(e),this.z=A.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const A=Math.random()*Math.PI*2,e=Math.random()*2-1,t=Math.sqrt(1-e*e);return this.x=t*Math.cos(A),this.y=e,this.z=t*Math.sin(A),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const NU=new S,AH=new GA;let Xe=class{constructor(A=new S(1/0,1/0,1/0),e=new S(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=A,this.max=e}set(A,e){return this.min.copy(A),this.max.copy(e),this}setFromArray(A){this.makeEmpty();for(let e=0,t=A.length;e<t;e+=3)this.expandByPoint(Fn.fromArray(A,e));return this}setFromBufferAttribute(A){this.makeEmpty();for(let e=0,t=A.count;e<t;e++)this.expandByPoint(Fn.fromBufferAttribute(A,e));return this}setFromPoints(A){this.makeEmpty();for(let e=0,t=A.length;e<t;e++)this.expandByPoint(A[e]);return this}setFromCenterAndSize(A,e){const t=Fn.copy(e).multiplyScalar(.5);return this.min.copy(A).sub(t),this.max.copy(A).add(t),this}setFromObject(A,e=!1){return this.makeEmpty(),this.expandByObject(A,e)}clone(){return new this.constructor().copy(this)}copy(A){return this.min.copy(A.min),this.max.copy(A.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(A){return this.isEmpty()?A.set(0,0,0):A.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(A){return this.isEmpty()?A.set(0,0,0):A.subVectors(this.max,this.min)}expandByPoint(A){return this.min.min(A),this.max.max(A),this}expandByVector(A){return this.min.sub(A),this.max.add(A),this}expandByScalar(A){return this.min.addScalar(-A),this.max.addScalar(A),this}expandByObject(A,e=!1){A.updateWorldMatrix(!1,!1);const t=A.geometry;if(t!==void 0){const o=t.getAttribute("position");if(e===!0&&o!==void 0&&A.isInstancedMesh!==!0)for(let I=0,s=o.count;I<s;I++)A.isMesh===!0?A.getVertexPosition(I,Fn):Fn.fromBufferAttribute(o,I),Fn.applyMatrix4(A.matrixWorld),this.expandByPoint(Fn);else A.boundingBox!==void 0?(A.boundingBox===null&&A.computeBoundingBox(),$w.copy(A.boundingBox)):(t.boundingBox===null&&t.computeBoundingBox(),$w.copy(t.boundingBox)),$w.applyMatrix4(A.matrixWorld),this.union($w)}const i=A.children;for(let o=0,I=i.length;o<I;o++)this.expandByObject(i[o],e);return this}containsPoint(A){return!(A.x<this.min.x||A.x>this.max.x||A.y<this.min.y||A.y>this.max.y||A.z<this.min.z||A.z>this.max.z)}containsBox(A){return this.min.x<=A.min.x&&A.max.x<=this.max.x&&this.min.y<=A.min.y&&A.max.y<=this.max.y&&this.min.z<=A.min.z&&A.max.z<=this.max.z}getParameter(A,e){return e.set((A.x-this.min.x)/(this.max.x-this.min.x),(A.y-this.min.y)/(this.max.y-this.min.y),(A.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(A){return!(A.max.x<this.min.x||A.min.x>this.max.x||A.max.y<this.min.y||A.min.y>this.max.y||A.max.z<this.min.z||A.min.z>this.max.z)}intersectsSphere(A){return this.clampPoint(A.center,Fn),Fn.distanceToSquared(A.center)<=A.radius*A.radius}intersectsPlane(A){let e,t;return A.normal.x>0?(e=A.normal.x*this.min.x,t=A.normal.x*this.max.x):(e=A.normal.x*this.max.x,t=A.normal.x*this.min.x),A.normal.y>0?(e+=A.normal.y*this.min.y,t+=A.normal.y*this.max.y):(e+=A.normal.y*this.max.y,t+=A.normal.y*this.min.y),A.normal.z>0?(e+=A.normal.z*this.min.z,t+=A.normal.z*this.max.z):(e+=A.normal.z*this.max.z,t+=A.normal.z*this.min.z),e<=-A.constant&&t>=-A.constant}intersectsTriangle(A){if(this.isEmpty())return!1;this.getCenter($u),A0.subVectors(this.max,$u),wh.subVectors(A.a,$u),mh.subVectors(A.b,$u),Sh.subVectors(A.c,$u),sB.subVectors(mh,wh),nB.subVectors(Sh,mh),IQ.subVectors(wh,Sh);let e=[0,-sB.z,sB.y,0,-nB.z,nB.y,0,-IQ.z,IQ.y,sB.z,0,-sB.x,nB.z,0,-nB.x,IQ.z,0,-IQ.x,-sB.y,sB.x,0,-nB.y,nB.x,0,-IQ.y,IQ.x,0];return!FU(e,wh,mh,Sh,A0)||(e=[1,0,0,0,1,0,0,0,1],!FU(e,wh,mh,Sh,A0))?!1:(e0.crossVectors(sB,nB),e=[e0.x,e0.y,e0.z],FU(e,wh,mh,Sh,A0))}clampPoint(A,e){return e.copy(A).clamp(this.min,this.max)}distanceToPoint(A){return this.clampPoint(A,Fn).distanceTo(A)}getBoundingSphere(A){return this.isEmpty()?A.makeEmpty():(this.getCenter(A.center),A.radius=this.getSize(Fn).length()*.5),A}intersect(A){return this.min.max(A.min),this.max.min(A.max),this.isEmpty()&&this.makeEmpty(),this}union(A){return this.min.min(A.min),this.max.max(A.max),this}applyMatrix4(A){return this.isEmpty()?this:(Nr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(A),Nr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(A),Nr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(A),Nr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(A),Nr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(A),Nr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(A),Nr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(A),Nr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(A),this.setFromPoints(Nr),this)}translate(A){return this.min.add(A),this.max.add(A),this}equals(A){return A.min.equals(this.min)&&A.max.equals(this.max)}};const Nr=[new S,new S,new S,new S,new S,new S,new S,new S],Fn=new S,$w=new Xe,wh=new S,mh=new S,Sh=new S,sB=new S,nB=new S,IQ=new S,$u=new S,A0=new S,e0=new S,sQ=new S;function FU(g,A,e,t,i){for(let o=0,I=g.length-3;o<=I;o+=3){sQ.fromArray(g,o);const s=i.x*Math.abs(sQ.x)+i.y*Math.abs(sQ.y)+i.z*Math.abs(sQ.z),n=A.dot(sQ),a=e.dot(sQ),r=t.dot(sQ);if(Math.max(-Math.max(n,a,r),Math.min(n,a,r))>s)return!1}return!0}const J6=new Xe,Ap=new S,bU=new S;let fi=class{constructor(A=new S,e=-1){this.isSphere=!0,this.center=A,this.radius=e}set(A,e){return this.center.copy(A),this.radius=e,this}setFromPoints(A,e){const t=this.center;e!==void 0?t.copy(e):J6.setFromPoints(A).getCenter(t);let i=0;for(let o=0,I=A.length;o<I;o++)i=Math.max(i,t.distanceToSquared(A[o]));return this.radius=Math.sqrt(i),this}copy(A){return this.center.copy(A.center),this.radius=A.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(A){return A.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(A){return A.distanceTo(this.center)-this.radius}intersectsSphere(A){const e=this.radius+A.radius;return A.center.distanceToSquared(this.center)<=e*e}intersectsBox(A){return A.intersectsSphere(this)}intersectsPlane(A){return Math.abs(A.distanceToPoint(this.center))<=this.radius}clampPoint(A,e){const t=this.center.distanceToSquared(A);return e.copy(A),t>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(A){return this.isEmpty()?(A.makeEmpty(),A):(A.set(this.center,this.center),A.expandByScalar(this.radius),A)}applyMatrix4(A){return this.center.applyMatrix4(A),this.radius=this.radius*A.getMaxScaleOnAxis(),this}translate(A){return this.center.add(A),this}expandByPoint(A){if(this.isEmpty())return this.center.copy(A),this.radius=0,this;Ap.subVectors(A,this.center);const e=Ap.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=(t-this.radius)*.5;this.center.addScaledVector(Ap,i/t),this.radius+=i}return this}union(A){return A.isEmpty()?this:this.isEmpty()?(this.copy(A),this):(this.center.equals(A.center)===!0?this.radius=Math.max(this.radius,A.radius):(bU.subVectors(A.center,this.center).setLength(A.radius),this.expandByPoint(Ap.copy(A.center).add(bU)),this.expandByPoint(Ap.copy(A.center).sub(bU))),this)}equals(A){return A.center.equals(this.center)&&A.radius===this.radius}clone(){return new this.constructor().copy(this)}};const Fr=new S,KU=new S,t0=new S,aB=new S,xU=new S,i0=new S,JU=new S;let vI=class{constructor(A=new S,e=new S(0,0,-1)){this.origin=A,this.direction=e}set(A,e){return this.origin.copy(A),this.direction.copy(e),this}copy(A){return this.origin.copy(A.origin),this.direction.copy(A.direction),this}at(A,e){return e.copy(this.origin).addScaledVector(this.direction,A)}lookAt(A){return this.direction.copy(A).sub(this.origin).normalize(),this}recast(A){return this.origin.copy(this.at(A,Fr)),this}closestPointToPoint(A,e){e.subVectors(A,this.origin);const t=e.dot(this.direction);return t<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,t)}distanceToPoint(A){return Math.sqrt(this.distanceSqToPoint(A))}distanceSqToPoint(A){const e=Fr.subVectors(A,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(A):(Fr.copy(this.origin).addScaledVector(this.direction,e),Fr.distanceToSquared(A))}distanceSqToSegment(A,e,t,i){KU.copy(A).add(e).multiplyScalar(.5),t0.copy(e).sub(A).normalize(),aB.copy(this.origi