@giro3d/piero 1.0.0-beta.2 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- "use strict";var ln=Object.defineProperty;var cn=(l,t,e)=>t in l?ln(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var N=(l,t,e)=>cn(l,typeof t!="symbol"?t+"":t,e);const M=require("vue"),un=require("@giro3d/giro3d/core/Instance"),dn=require("@giro3d/giro3d/utils/Fetcher"),pn=require("@loaders.gl/core"),mn=require("@giro3d/giro3d/core/ColorMap"),fn=require("@giro3d/giro3d/core/geographic/Coordinates"),yn=require("@giro3d/giro3d/core/geographic/Extent"),Hi=require("chroma-js"),Je=require("pinia");/**
1
+ "use strict";var ln=Object.defineProperty;var cn=(l,t,e)=>t in l?ln(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var N=(l,t,e)=>cn(l,typeof t!="symbol"?t+"":t,e);const M=require("vue"),un=require("@giro3d/giro3d/core/Instance"),dn=require("@giro3d/giro3d/utils/Fetcher"),pn=require("@loaders.gl/core"),mn=require("@giro3d/giro3d/core/ColorMap"),fn=require("@giro3d/giro3d/core/geographic/Coordinates"),yn=require("@giro3d/giro3d/core/geographic/Extent"),Wi=require("chroma-js"),Qe=require("pinia");/**
2
2
  * @license
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const Is="170",Ge=0,xn=1,Rs=2,qi=1,Ui=100,Xi=204,ji=205,Yi=3,Ds=0,Ls=300,Zi=1e3,Ae=1001,Gi=1002,gn=1006,wn=1008,bn=1009,Mn=1015,_n=1023,Sn=0,Ns="",ut="srgb",Os="srgb-linear",Vs="linear",vi="srgb",Zt=7680,$i=519,Qi=35044,Wt=2e3,Ci=2001;class Ut{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,t);t.target=null}}}const $=["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 Ji=1234567;const Ws=Math.PI/180,Hs=180/Math.PI;function he(){const l=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($[l&255]+$[l>>8&255]+$[l>>16&255]+$[l>>24&255]+"-"+$[t&255]+$[t>>8&255]+"-"+$[t>>16&15|64]+$[t>>24&255]+"-"+$[e&63|128]+$[e>>8&255]+"-"+$[e>>16&255]+$[e>>24&255]+$[i&255]+$[i>>8&255]+$[i>>16&255]+$[i>>24&255]).toLowerCase()}function et(l,t,e){return Math.max(t,Math.min(e,l))}function Pi(l,t){return(l%t+t)%t}function zn(l,t,e,i,s){return i+(l-t)*(s-i)/(e-t)}function An(l,t,e){return l!==t?(e-l)/(t-l):0}function we(l,t,e){return(1-e)*l+e*t}function En(l,t,e,i){return we(l,t,1-Math.exp(-e*i))}function vn(l,t=1){return t-Math.abs(Pi(l,t*2)-t)}function Cn(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*(3-2*l))}function Fn(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*l*(l*(l*6-15)+10))}function Bn(l,t){return l+Math.floor(Math.random()*(t-l+1))}function Pn(l,t){return l+Math.random()*(t-l)}function Tn(l){return l*(.5-Math.random())}function kn(l){l!==void 0&&(Ji=l);let t=Ji+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function In(l){return l*Ws}function Rn(l){return l*Hs}function Dn(l){return(l&l-1)===0&&l!==0}function Ln(l){return Math.pow(2,Math.ceil(Math.log(l)/Math.LN2))}function Nn(l){return Math.pow(2,Math.floor(Math.log(l)/Math.LN2))}function On(l,t,e,i,s){const n=Math.cos,r=Math.sin,o=n(e/2),a=r(e/2),h=n((t+i)/2),c=r((t+i)/2),u=n((t-i)/2),d=r((t-i)/2),p=n((i-t)/2),m=r((i-t)/2);switch(s){case"XYX":l.set(o*c,a*u,a*d,o*h);break;case"YZY":l.set(a*d,o*c,a*u,o*h);break;case"ZXZ":l.set(a*u,a*d,o*c,o*h);break;case"XZX":l.set(o*c,a*m,a*p,o*h);break;case"YXY":l.set(a*p,o*c,a*m,o*h);break;case"ZYZ":l.set(a*m,a*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function re(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return l/4294967295;case Uint16Array:return l/65535;case Uint8Array:return l/255;case Int32Array:return Math.max(l/2147483647,-1);case Int16Array:return Math.max(l/32767,-1);case Int8Array:return Math.max(l/127,-1);default:throw new Error("Invalid component type.")}}function st(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return Math.round(l*4294967295);case Uint16Array:return Math.round(l*65535);case Uint8Array:return Math.round(l*255);case Int32Array:return Math.round(l*2147483647);case Int16Array:return Math.round(l*32767);case Int8Array:return Math.round(l*127);default:throw new Error("Invalid component type.")}}const qs={DEG2RAD:Ws,RAD2DEG:Hs,generateUUID:he,clamp:et,euclideanModulo:Pi,mapLinear:zn,inverseLerp:An,lerp:we,damp:En,pingpong:vn,smoothstep:Cn,smootherstep:Fn,randInt:Bn,randFloat:Pn,randFloatSpread:Tn,seededRandom:kn,degToRad:In,radToDeg:Rn,isPowerOfTwo:Dn,ceilPowerOfTwo:Ln,floorPowerOfTwo:Nn,setQuaternionFromProperEuler:On,normalize:st,denormalize:re};class U{constructor(t=0,e=0){U.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(et(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*s+t.x,this.y=n*s+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vt{constructor(t,e,i,s,n,r,o,a,h){vt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,o,a,h)}set(t,e,i,s,n,r,o,a,h){const c=this.elements;return c[0]=t,c[1]=s,c[2]=o,c[3]=e,c[4]=n,c[5]=a,c[6]=i,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],o=i[3],a=i[6],h=i[1],c=i[4],u=i[7],d=i[2],p=i[5],m=i[8],y=s[0],w=s[3],g=s[6],_=s[1],b=s[4],f=s[7],z=s[2],S=s[5],A=s[8];return n[0]=r*y+o*_+a*z,n[3]=r*w+o*b+a*S,n[6]=r*g+o*f+a*A,n[1]=h*y+c*_+u*z,n[4]=h*w+c*b+u*S,n[7]=h*g+c*f+u*A,n[2]=d*y+p*_+m*z,n[5]=d*w+p*b+m*S,n[8]=d*g+p*f+m*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return e*r*c-e*o*h-i*n*c+i*o*a+s*n*h-s*r*a}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],u=c*r-o*h,d=o*a-c*n,p=h*n-r*a,m=e*u+i*d+s*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=u*y,t[1]=(s*h-c*i)*y,t[2]=(o*i-s*r)*y,t[3]=d*y,t[4]=(c*e-s*a)*y,t[5]=(s*n-o*e)*y,t[6]=p*y,t[7]=(i*a-h*e)*y,t[8]=(r*e-i*n)*y,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,n,r,o){const a=Math.cos(n),h=Math.sin(n);return this.set(i*a,i*h,-i*(a*r+h*o)+r+t,-s*h,s*a,-s*(-h*r+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(si.makeScale(t,e)),this}rotate(t){return this.premultiply(si.makeRotation(-t)),this}translate(t,e){return this.premultiply(si.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const si=new vt;function Vn(l){for(let t=l.length-1;t>=0;--t)if(l[t]>=65535)return!0;return!1}function Ki(l){return document.createElementNS("http://www.w3.org/1999/xhtml",l)}const ct={enabled:!0,workingColorSpace:Os,spaces:{},convert:function(l,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===vi&&(l.r=Et(l.r),l.g=Et(l.g),l.b=Et(l.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(l.applyMatrix3(this.spaces[t].toXYZ),l.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===vi&&(l.r=ae(l.r),l.g=ae(l.g),l.b=ae(l.b))),l},fromWorkingColorSpace:function(l,t){return this.convert(l,this.workingColorSpace,t)},toWorkingColorSpace:function(l,t){return this.convert(l,t,this.workingColorSpace)},getPrimaries:function(l){return this.spaces[l].primaries},getTransfer:function(l){return l===Ns?Vs:this.spaces[l].transfer},getLuminanceCoefficients:function(l,t=this.workingColorSpace){return l.fromArray(this.spaces[t].luminanceCoefficients)},define:function(l){Object.assign(this.spaces,l)},_getMatrix:function(l,t,e){return l.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(l){return this.spaces[l].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(l=this.workingColorSpace){return this.spaces[l].workingColorSpaceConfig.unpackColorSpace}};function Et(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function ae(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const ts=[.64,.33,.3,.6,.15,.06],es=[.2126,.7152,.0722],is=[.3127,.329],ss=new vt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ns=new vt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);ct.define({[Os]:{primaries:ts,whitePoint:is,transfer:Vs,toXYZ:ss,fromXYZ:ns,luminanceCoefficients:es,workingColorSpaceConfig:{unpackColorSpace:ut},outputColorSpaceConfig:{drawingBufferColorSpace:ut}},[ut]:{primaries:ts,whitePoint:is,transfer:vi,toXYZ:ss,fromXYZ:ns,luminanceCoefficients:es,outputColorSpaceConfig:{drawingBufferColorSpace:ut}}});let Gt;class Wn{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Gt===void 0&&(Gt=Ki("canvas")),Gt.width=t.width,Gt.height=t.height;const i=Gt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=Gt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Ki("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r<n.length;r++)n[r]=Et(n[r]/255)*255;return i.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Et(e[i]/255)*255):e[i]=Et(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Hn=0;class qn{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Hn++}),this.uuid=he(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let r=0,o=s.length;r<o;r++)s[r].isDataTexture?n.push(ni(s[r].image)):n.push(ni(s[r]))}else n=ni(s);i.url=n}return e||(t.images[this.uuid]=i),i}}function ni(l){return typeof HTMLImageElement<"u"&&l instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&l instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&l instanceof ImageBitmap?Wn.getDataURL(l):l.data?{data:Array.from(l.data),width:l.width,height:l.height,type:l.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Un=0;class Ht extends Ut{constructor(t=Ht.DEFAULT_IMAGE,e=Ht.DEFAULT_MAPPING,i=Ae,s=Ae,n=gn,r=wn,o=_n,a=bn,h=Ht.DEFAULT_ANISOTROPY,c=Ns){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Un++}),this.uuid=he(),this.name="",this.source=new qn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=r,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=a,this.offset=new U(0,0),this.repeat=new U(1,1),this.center=new U(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Ls)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Zi:t.x=t.x-Math.floor(t.x);break;case Ae:t.x=t.x<0?0:1;break;case Gi:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Zi:t.y=t.y-Math.floor(t.y);break;case Ae:t.y=t.y<0?0:1;break;case Gi:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Ht.DEFAULT_IMAGE=null;Ht.DEFAULT_MAPPING=Ls;Ht.DEFAULT_ANISOTROPY=1;class Xt{constructor(t=0,e=0,i=0,s=1){Xt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,n;const a=t.elements,h=a[0],c=a[4],u=a[8],d=a[1],p=a[5],m=a[9],y=a[2],w=a[6],g=a[10];if(Math.abs(c-d)<.01&&Math.abs(u-y)<.01&&Math.abs(m-w)<.01){if(Math.abs(c+d)<.1&&Math.abs(u+y)<.1&&Math.abs(m+w)<.1&&Math.abs(h+p+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const b=(h+1)/2,f=(p+1)/2,z=(g+1)/2,S=(c+d)/4,A=(u+y)/4,E=(m+w)/4;return b>f&&b>z?b<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(b),s=S/i,n=A/i):f>z?f<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(f),i=S/s,n=E/s):z<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(z),i=A/n,s=E/n),this.set(i,s,n,e),this}let _=Math.sqrt((w-m)*(w-m)+(u-y)*(u-y)+(d-c)*(d-c));return Math.abs(_)<.001&&(_=1),this.x=(w-m)/_,this.y=(u-y)/_,this.z=(d-c)/_,this.w=Math.acos((h+p+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tt{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,n,r,o){let a=i[s+0],h=i[s+1],c=i[s+2],u=i[s+3];const d=n[r+0],p=n[r+1],m=n[r+2],y=n[r+3];if(o===0){t[e+0]=a,t[e+1]=h,t[e+2]=c,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=m,t[e+3]=y;return}if(u!==y||a!==d||h!==p||c!==m){let w=1-o;const g=a*d+h*p+c*m+u*y,_=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){const z=Math.sqrt(b),S=Math.atan2(z,g*_);w=Math.sin(w*S)/z,o=Math.sin(o*S)/z}const f=o*_;if(a=a*w+d*f,h=h*w+p*f,c=c*w+m*f,u=u*w+y*f,w===1-o){const z=1/Math.sqrt(a*a+h*h+c*c+u*u);a*=z,h*=z,c*=z,u*=z}}t[e]=a,t[e+1]=h,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,n,r){const o=i[s],a=i[s+1],h=i[s+2],c=i[s+3],u=n[r],d=n[r+1],p=n[r+2],m=n[r+3];return t[e]=o*m+c*u+a*p-h*d,t[e+1]=a*m+c*d+h*u-o*p,t[e+2]=h*m+c*p+o*d-a*u,t[e+3]=c*m-o*u-a*d-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,o=Math.cos,a=Math.sin,h=o(i/2),c=o(s/2),u=o(n/2),d=a(i/2),p=a(s/2),m=a(n/2);switch(r){case"XYZ":this._x=d*c*u+h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u-d*p*m;break;case"YXZ":this._x=d*c*u+h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u+d*p*m;break;case"ZXY":this._x=d*c*u-h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u-d*p*m;break;case"ZYX":this._x=d*c*u-h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u+d*p*m;break;case"YZX":this._x=d*c*u+h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u-d*p*m;break;case"XZY":this._x=d*c*u-h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],n=e[8],r=e[1],o=e[5],a=e[9],h=e[2],c=e[6],u=e[10],d=i+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(c-a)*p,this._y=(n-h)*p,this._z=(r-s)*p}else if(i>o&&i>u){const p=2*Math.sqrt(1+i-o-u);this._w=(c-a)/p,this._x=.25*p,this._y=(s+r)/p,this._z=(n+h)/p}else if(o>u){const p=2*Math.sqrt(1+o-i-u);this._w=(n-h)/p,this._x=(s+r)/p,this._y=.25*p,this._z=(a+c)/p}else{const p=2*Math.sqrt(1+u-i-o);this._w=(r-s)/p,this._x=(n+h)/p,this._y=(a+c)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(et(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,o=e._x,a=e._y,h=e._z,c=e._w;return this._x=i*c+r*o+s*h-n*a,this._y=s*c+r*a+n*o-i*h,this._z=n*c+r*h+i*a-s*o,this._w=r*c-i*o-s*a-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let o=r*t._w+i*t._x+s*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=i,this._y=s,this._z=n,this;const a=1-o*o;if(a<=Number.EPSILON){const p=1-e;return this._w=p*r+e*this._w,this._x=p*i+e*this._x,this._y=p*s+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const h=Math.sqrt(a),c=Math.atan2(h,o),u=Math.sin((1-e)*c)/h,d=Math.sin(e*c)/h;return this._w=r*u+this._w*d,this._x=i*u+this._x*d,this._y=s*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class x{constructor(t=0,e=0,i=0){x.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(rs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(rs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=2*(r*s-o*i),c=2*(o*e-n*s),u=2*(n*i-r*e);return this.x=e+a*h+r*u-o*c,this.y=i+a*c+o*h-n*u,this.z=s+a*u+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s,this.y=n[1]*e+n[5]*i+n[9]*s,this.z=n[2]*e+n[6]*i+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,n=t.z,r=e.x,o=e.y,a=e.z;return this.x=s*a-n*o,this.y=n*r-i*a,this.z=i*o-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ri.copy(this).projectOnVector(t),this.sub(ri)}reflect(t){return this.sub(ri.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(et(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ri=new x,rs=new tt;class gt{constructor(t=new x(1/0,1/0,1/0),e=new x(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(pt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(pt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=pt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const n=i.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=n.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,pt):pt.fromBufferAttribute(n,r),pt.applyMatrix4(t.matrixWorld),this.expandByPoint(pt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ee.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ee.copy(i.boundingBox)),Ee.applyMatrix4(t.matrixWorld),this.union(Ee)}const s=t.children;for(let n=0,r=s.length;n<r;n++)this.expandByObject(s[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,pt),pt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ce),ve.subVectors(this.max,ce),$t.subVectors(t.a,ce),Qt.subVectors(t.b,ce),Jt.subVectors(t.c,ce),Ct.subVectors(Qt,$t),Ft.subVectors(Jt,Qt),It.subVectors($t,Jt);let e=[0,-Ct.z,Ct.y,0,-Ft.z,Ft.y,0,-It.z,It.y,Ct.z,0,-Ct.x,Ft.z,0,-Ft.x,It.z,0,-It.x,-Ct.y,Ct.x,0,-Ft.y,Ft.x,0,-It.y,It.x,0];return!oi(e,$t,Qt,Jt,ve)||(e=[1,0,0,0,1,0,0,0,1],!oi(e,$t,Qt,Jt,ve))?!1:(Ce.crossVectors(Ct,Ft),e=[Ce.x,Ce.y,Ce.z],oi(e,$t,Qt,Jt,ve))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,pt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(pt).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(wt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),wt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),wt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),wt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),wt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),wt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),wt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),wt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(wt),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const wt=[new x,new x,new x,new x,new x,new x,new x,new x],pt=new x,Ee=new gt,$t=new x,Qt=new x,Jt=new x,Ct=new x,Ft=new x,It=new x,ce=new x,ve=new x,Ce=new x,Rt=new x;function oi(l,t,e,i,s){for(let n=0,r=l.length-3;n<=r;n+=3){Rt.fromArray(l,n);const o=s.x*Math.abs(Rt.x)+s.y*Math.abs(Rt.y)+s.z*Math.abs(Rt.z),a=t.dot(Rt),h=e.dot(Rt),c=i.dot(Rt);if(Math.max(-Math.max(a,h,c),Math.min(a,h,c))>o)return!1}return!0}const Xn=new gt,ue=new x,ai=new x;class be{constructor(t=new x,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):Xn.setFromPoints(t).getCenter(i);let s=0;for(let n=0,r=t.length;n<r;n++)s=Math.max(s,i.distanceToSquared(t[n]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ue.subVectors(t,this.center);const e=ue.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(ue,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ai.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ue.copy(t.center).add(ai)),this.expandByPoint(ue.copy(t.center).sub(ai))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bt=new x,hi=new x,Fe=new x,Bt=new x,li=new x,Be=new x,ci=new x;class Ti{constructor(t=new x,e=new x(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,bt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=bt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(bt.copy(this.origin).addScaledVector(this.direction,e),bt.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){hi.copy(t).add(e).multiplyScalar(.5),Fe.copy(e).sub(t).normalize(),Bt.copy(this.origin).sub(hi);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Fe),o=Bt.dot(this.direction),a=-Bt.dot(Fe),h=Bt.lengthSq(),c=Math.abs(1-r*r);let u,d,p,m;if(c>0)if(u=r*a-o,d=r*o-a,m=n*c,u>=0)if(d>=-m)if(d<=m){const y=1/c;u*=y,d*=y,p=u*(u+r*d+2*o)+d*(r*u+d+2*a)+h}else d=n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;else d=-n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;else d<=-m?(u=Math.max(0,-(-r*n+o)),d=u>0?-n:Math.min(Math.max(-n,-a),n),p=-u*u+d*(d+2*a)+h):d<=m?(u=0,d=Math.min(Math.max(-n,-a),n),p=d*(d+2*a)+h):(u=Math.max(0,-(r*n+o)),d=u>0?n:Math.min(Math.max(-n,-a),n),p=-u*u+d*(d+2*a)+h);else d=r>0?-n:n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(hi).addScaledVector(Fe,d),p}intersectSphere(t,e){bt.subVectors(t.center,this.origin);const i=bt.dot(this.direction),s=bt.dot(bt)-i*i,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),o=i-r,a=i+r;return a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,n,r,o,a;const h=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,s=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,s=(t.min.x-d.x)*h),c>=0?(n=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c):(n=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c),i>r||n>s||((n>i||isNaN(i))&&(i=n),(r<s||isNaN(s))&&(s=r),u>=0?(o=(t.min.z-d.z)*u,a=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,a=(t.min.z-d.z)*u),i>a||o>s)||((o>i||i!==i)&&(i=o),(a<s||s!==s)&&(s=a),s<0)?null:this.at(i>=0?i:s,e)}intersectsBox(t){return this.intersectBox(t,bt)!==null}intersectTriangle(t,e,i,s,n){li.subVectors(e,t),Be.subVectors(i,t),ci.crossVectors(li,Be);let r=this.direction.dot(ci),o;if(r>0){if(s)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Bt.subVectors(this.origin,t);const a=o*this.direction.dot(Be.crossVectors(Bt,Be));if(a<0)return null;const h=o*this.direction.dot(li.cross(Bt));if(h<0||a+h>r)return null;const c=-o*Bt.dot(ci);return c<0?null:this.at(c/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class W{constructor(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w){W.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w)}set(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=n,g[5]=r,g[9]=o,g[13]=a,g[2]=h,g[6]=c,g[10]=u,g[14]=d,g[3]=p,g[7]=m,g[11]=y,g[15]=w,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new W().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/Kt.setFromMatrixColumn(t,0).length(),n=1/Kt.setFromMatrixColumn(t,1).length(),r=1/Kt.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),h=Math.sin(s),c=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=r*c,p=r*u,m=o*c,y=o*u;e[0]=a*c,e[4]=-a*u,e[8]=h,e[1]=p+m*h,e[5]=d-y*h,e[9]=-o*a,e[2]=y-d*h,e[6]=m+p*h,e[10]=r*a}else if(t.order==="YXZ"){const d=a*c,p=a*u,m=h*c,y=h*u;e[0]=d+y*o,e[4]=m*o-p,e[8]=r*h,e[1]=r*u,e[5]=r*c,e[9]=-o,e[2]=p*o-m,e[6]=y+d*o,e[10]=r*a}else if(t.order==="ZXY"){const d=a*c,p=a*u,m=h*c,y=h*u;e[0]=d-y*o,e[4]=-r*u,e[8]=m+p*o,e[1]=p+m*o,e[5]=r*c,e[9]=y-d*o,e[2]=-r*h,e[6]=o,e[10]=r*a}else if(t.order==="ZYX"){const d=r*c,p=r*u,m=o*c,y=o*u;e[0]=a*c,e[4]=m*h-p,e[8]=d*h+y,e[1]=a*u,e[5]=y*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*a,e[10]=r*a}else if(t.order==="YZX"){const d=r*a,p=r*h,m=o*a,y=o*h;e[0]=a*c,e[4]=y-d*u,e[8]=m*u+p,e[1]=u,e[5]=r*c,e[9]=-o*c,e[2]=-h*c,e[6]=p*u+m,e[10]=d-y*u}else if(t.order==="XZY"){const d=r*a,p=r*h,m=o*a,y=o*h;e[0]=a*c,e[4]=-u,e[8]=h*c,e[1]=d*u+y,e[5]=r*c,e[9]=p*u-m,e[2]=m*u-p,e[6]=o*c,e[10]=y*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(jn,t,Yn)}lookAt(t,e,i){const s=this.elements;return rt.subVectors(t,e),rt.lengthSq()===0&&(rt.z=1),rt.normalize(),Pt.crossVectors(i,rt),Pt.lengthSq()===0&&(Math.abs(i.z)===1?rt.x+=1e-4:rt.z+=1e-4,rt.normalize(),Pt.crossVectors(i,rt)),Pt.normalize(),Pe.crossVectors(rt,Pt),s[0]=Pt.x,s[4]=Pe.x,s[8]=rt.x,s[1]=Pt.y,s[5]=Pe.y,s[9]=rt.y,s[2]=Pt.z,s[6]=Pe.z,s[10]=rt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],o=i[4],a=i[8],h=i[12],c=i[1],u=i[5],d=i[9],p=i[13],m=i[2],y=i[6],w=i[10],g=i[14],_=i[3],b=i[7],f=i[11],z=i[15],S=s[0],A=s[4],E=s[8],v=s[12],F=s[1],P=s[5],B=s[9],T=s[13],k=s[2],R=s[6],G=s[10],q=s[14],it=s[3],I=s[7],V=s[11],j=s[15];return n[0]=r*S+o*F+a*k+h*it,n[4]=r*A+o*P+a*R+h*I,n[8]=r*E+o*B+a*G+h*V,n[12]=r*v+o*T+a*q+h*j,n[1]=c*S+u*F+d*k+p*it,n[5]=c*A+u*P+d*R+p*I,n[9]=c*E+u*B+d*G+p*V,n[13]=c*v+u*T+d*q+p*j,n[2]=m*S+y*F+w*k+g*it,n[6]=m*A+y*P+w*R+g*I,n[10]=m*E+y*B+w*G+g*V,n[14]=m*v+y*T+w*q+g*j,n[3]=_*S+b*F+f*k+z*it,n[7]=_*A+b*P+f*R+z*I,n[11]=_*E+b*B+f*G+z*V,n[15]=_*v+b*T+f*q+z*j,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],s=t[8],n=t[12],r=t[1],o=t[5],a=t[9],h=t[13],c=t[2],u=t[6],d=t[10],p=t[14],m=t[3],y=t[7],w=t[11],g=t[15];return m*(+n*a*u-s*h*u-n*o*d+i*h*d+s*o*p-i*a*p)+y*(+e*a*p-e*h*d+n*r*d-s*r*p+s*h*c-n*a*c)+w*(+e*h*u-e*o*p-n*r*u+i*r*p+n*o*c-i*h*c)+g*(-s*o*c-e*a*u+e*o*d+s*r*u-i*r*d+i*a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],u=t[9],d=t[10],p=t[11],m=t[12],y=t[13],w=t[14],g=t[15],_=u*w*h-y*d*h+y*a*p-o*w*p-u*a*g+o*d*g,b=m*d*h-c*w*h-m*a*p+r*w*p+c*a*g-r*d*g,f=c*y*h-m*u*h+m*o*p-r*y*p-c*o*g+r*u*g,z=m*u*a-c*y*a-m*o*d+r*y*d+c*o*w-r*u*w,S=e*_+i*b+s*f+n*z;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/S;return t[0]=_*A,t[1]=(y*d*n-u*w*n-y*s*p+i*w*p+u*s*g-i*d*g)*A,t[2]=(o*w*n-y*a*n+y*s*h-i*w*h-o*s*g+i*a*g)*A,t[3]=(u*a*n-o*d*n-u*s*h+i*d*h+o*s*p-i*a*p)*A,t[4]=b*A,t[5]=(c*w*n-m*d*n+m*s*p-e*w*p-c*s*g+e*d*g)*A,t[6]=(m*a*n-r*w*n-m*s*h+e*w*h+r*s*g-e*a*g)*A,t[7]=(r*d*n-c*a*n+c*s*h-e*d*h-r*s*p+e*a*p)*A,t[8]=f*A,t[9]=(m*u*n-c*y*n-m*i*p+e*y*p+c*i*g-e*u*g)*A,t[10]=(r*y*n-m*o*n+m*i*h-e*y*h-r*i*g+e*o*g)*A,t[11]=(c*o*n-r*u*n-c*i*h+e*u*h+r*i*p-e*o*p)*A,t[12]=z*A,t[13]=(c*y*s-m*u*s+m*i*d-e*y*d-c*i*w+e*u*w)*A,t[14]=(m*o*s-r*y*s-m*i*a+e*y*a+r*i*w-e*o*w)*A,t[15]=(r*u*s-c*o*s+c*i*a-e*u*a-r*i*d+e*o*d)*A,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,o=t.y,a=t.z,h=n*r,c=n*o;return this.set(h*r+i,h*o-s*a,h*a+s*o,0,h*o+s*a,c*o+i,c*a-s*r,0,h*a-s*o,c*a+s*r,n*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,o=e._z,a=e._w,h=n+n,c=r+r,u=o+o,d=n*h,p=n*c,m=n*u,y=r*c,w=r*u,g=o*u,_=a*h,b=a*c,f=a*u,z=i.x,S=i.y,A=i.z;return s[0]=(1-(y+g))*z,s[1]=(p+f)*z,s[2]=(m-b)*z,s[3]=0,s[4]=(p-f)*S,s[5]=(1-(d+g))*S,s[6]=(w+_)*S,s[7]=0,s[8]=(m+b)*A,s[9]=(w-_)*A,s[10]=(1-(d+y))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let n=Kt.set(s[0],s[1],s[2]).length();const r=Kt.set(s[4],s[5],s[6]).length(),o=Kt.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],mt.copy(this);const h=1/n,c=1/r,u=1/o;return mt.elements[0]*=h,mt.elements[1]*=h,mt.elements[2]*=h,mt.elements[4]*=c,mt.elements[5]*=c,mt.elements[6]*=c,mt.elements[8]*=u,mt.elements[9]*=u,mt.elements[10]*=u,e.setFromRotationMatrix(mt),i.x=n,i.y=r,i.z=o,this}makePerspective(t,e,i,s,n,r,o=Wt){const a=this.elements,h=2*n/(e-t),c=2*n/(i-s),u=(e+t)/(e-t),d=(i+s)/(i-s);let p,m;if(o===Wt)p=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(o===Ci)p=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return a[0]=h,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=d,a[13]=0,a[2]=0,a[6]=0,a[10]=p,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,s,n,r,o=Wt){const a=this.elements,h=1/(e-t),c=1/(i-s),u=1/(r-n),d=(e+t)*h,p=(i+s)*c;let m,y;if(o===Wt)m=(r+n)*u,y=-2*u;else if(o===Ci)m=n*u,y=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-d,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-p,a[2]=0,a[6]=0,a[10]=y,a[14]=-m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Kt=new x,mt=new W,jn=new x(0,0,0),Yn=new x(1,1,1),Pt=new x,Pe=new x,rt=new x,os=new W,as=new tt;class jt{constructor(t=0,e=0,i=0,s=jt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],o=s[8],a=s[1],h=s[5],c=s[9],u=s[2],d=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(et(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-et(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(et(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(a,n));break;case"ZYX":this._y=Math.asin(-et(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(a,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(et(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-et(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return os.makeRotationFromQuaternion(t),this.setFromRotationMatrix(os,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return as.setFromEuler(this),this.setFromQuaternion(as,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}jt.DEFAULT_ORDER="XYZ";class Us{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Zn=0;const hs=new x,te=new tt,Mt=new W,Te=new x,de=new x,Gn=new x,$n=new tt,ls=new x(1,0,0),cs=new x(0,1,0),us=new x(0,0,1),ds={type:"added"},Qn={type:"removed"},ee={type:"childadded",child:null},ui={type:"childremoved",child:null};class X extends Ut{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zn++}),this.uuid=he(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=X.DEFAULT_UP.clone();const t=new x,e=new jt,i=new tt,s=new x(1,1,1);function n(){i.setFromEuler(e,!1)}function r(){e.setFromQuaternion(i,void 0,!1)}e._onChange(n),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new W},normalMatrix:{value:new vt}}),this.matrix=new W,this.matrixWorld=new W,this.matrixAutoUpdate=X.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=X.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Us,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return te.setFromAxisAngle(t,e),this.quaternion.multiply(te),this}rotateOnWorldAxis(t,e){return te.setFromAxisAngle(t,e),this.quaternion.premultiply(te),this}rotateX(t){return this.rotateOnAxis(ls,t)}rotateY(t){return this.rotateOnAxis(cs,t)}rotateZ(t){return this.rotateOnAxis(us,t)}translateOnAxis(t,e){return hs.copy(t).applyQuaternion(this.quaternion),this.position.add(hs.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ls,t)}translateY(t){return this.translateOnAxis(cs,t)}translateZ(t){return this.translateOnAxis(us,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Mt.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Te.copy(t):Te.set(t,e,i);const s=this.parent;this.updateWorldMatrix(!0,!1),de.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mt.lookAt(de,Te,this.up):Mt.lookAt(Te,de,this.up),this.quaternion.setFromRotationMatrix(Mt),s&&(Mt.extractRotation(s.matrixWorld),te.setFromRotationMatrix(Mt),this.quaternion.premultiply(te.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(ds),ee.child=t,this.dispatchEvent(ee),ee.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Qn),ui.child=t,this.dispatchEvent(ui),ui.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Mt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Mt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Mt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(ds),ee.child=t,this.dispatchEvent(ee),ee.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,s=this.children.length;i<s;i++){const r=this.children[i].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(de,t,Gn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(de,$n,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(t)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const a=o.shapes;if(Array.isArray(a))for(let h=0,c=a.length;h<c;h++){const u=a[h];n(t.shapes,u)}else n(t.shapes,a)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let a=0,h=this.material.length;a<h;a++)o.push(n(t.materials,this.material[a]));s.material=o}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const a=this.animations[o];s.animations.push(n(t.animations,a))}}if(e){const o=r(t.geometries),a=r(t.materials),h=r(t.textures),c=r(t.images),u=r(t.shapes),d=r(t.skeletons),p=r(t.animations),m=r(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=s,i;function r(o){const a=[];for(const h in o){const c=o[h];delete c.metadata,a.push(c)}return a}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const s=t.children[i];this.add(s.clone())}return this}}X.DEFAULT_UP=new x(0,1,0);X.DEFAULT_MATRIX_AUTO_UPDATE=!0;X.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ft=new x,_t=new x,di=new x,St=new x,ie=new x,se=new x,ps=new x,pi=new x,mi=new x,fi=new x,yi=new Xt,xi=new Xt,gi=new Xt;class yt{constructor(t=new x,e=new x,i=new x){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,s){s.subVectors(i,e),ft.subVectors(t,e),s.cross(ft);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,e,i,s,n){ft.subVectors(s,e),_t.subVectors(i,e),di.subVectors(t,e);const r=ft.dot(ft),o=ft.dot(_t),a=ft.dot(di),h=_t.dot(_t),c=_t.dot(di),u=r*h-o*o;if(u===0)return n.set(0,0,0),null;const d=1/u,p=(h*a-o*c)*d,m=(r*c-o*a)*d;return n.set(1-p-m,m,p)}static containsPoint(t,e,i,s){return this.getBarycoord(t,e,i,s,St)===null?!1:St.x>=0&&St.y>=0&&St.x+St.y<=1}static getInterpolation(t,e,i,s,n,r,o,a){return this.getBarycoord(t,e,i,s,St)===null?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(n,St.x),a.addScaledVector(r,St.y),a.addScaledVector(o,St.z),a)}static getInterpolatedAttribute(t,e,i,s,n,r){return yi.setScalar(0),xi.setScalar(0),gi.setScalar(0),yi.fromBufferAttribute(t,e),xi.fromBufferAttribute(t,i),gi.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(yi,n.x),r.addScaledVector(xi,n.y),r.addScaledVector(gi,n.z),r}static isFrontFacing(t,e,i,s){return ft.subVectors(i,e),_t.subVectors(t,e),ft.cross(_t).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ft.subVectors(this.c,this.b),_t.subVectors(this.a,this.b),ft.cross(_t).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return yt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return yt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,n){return yt.getInterpolation(t,this.a,this.b,this.c,e,i,s,n)}containsPoint(t){return yt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return yt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,n=this.c;let r,o;ie.subVectors(s,i),se.subVectors(n,i),pi.subVectors(t,i);const a=ie.dot(pi),h=se.dot(pi);if(a<=0&&h<=0)return e.copy(i);mi.subVectors(t,s);const c=ie.dot(mi),u=se.dot(mi);if(c>=0&&u<=c)return e.copy(s);const d=a*u-c*h;if(d<=0&&a>=0&&c<=0)return r=a/(a-c),e.copy(i).addScaledVector(ie,r);fi.subVectors(t,n);const p=ie.dot(fi),m=se.dot(fi);if(m>=0&&p<=m)return e.copy(n);const y=p*h-a*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),e.copy(i).addScaledVector(se,o);const w=c*m-p*u;if(w<=0&&u-c>=0&&p-m>=0)return ps.subVectors(n,s),o=(u-c)/(u-c+(p-m)),e.copy(s).addScaledVector(ps,o);const g=1/(w+y+d);return r=y*g,o=d*g,e.copy(i).addScaledVector(ie,r).addScaledVector(se,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Xs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Tt={h:0,s:0,l:0},ke={h:0,s:0,l:0};function wi(l,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?l+(t-l)*6*e:e<1/2?t:e<2/3?l+(t-l)*6*(2/3-e):l}class ht{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ut){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ct.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=ct.workingColorSpace){return this.r=t,this.g=e,this.b=i,ct.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=ct.workingColorSpace){if(t=Pi(t,1),e=et(e,0,1),i=et(i,0,1),e===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=wi(r,n,t+1/3),this.g=wi(r,n,t),this.b=wi(r,n,t-1/3)}return ct.toWorkingColorSpace(this,s),this}setStyle(t,e=ut){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=s[1],o=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ut){const i=Xs[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Et(t.r),this.g=Et(t.g),this.b=Et(t.b),this}copyLinearToSRGB(t){return this.r=ae(t.r),this.g=ae(t.g),this.b=ae(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ut){return ct.fromWorkingColorSpace(Q.copy(this),t),Math.round(et(Q.r*255,0,255))*65536+Math.round(et(Q.g*255,0,255))*256+Math.round(et(Q.b*255,0,255))}getHexString(t=ut){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ct.workingColorSpace){ct.fromWorkingColorSpace(Q.copy(this),e);const i=Q.r,s=Q.g,n=Q.b,r=Math.max(i,s,n),o=Math.min(i,s,n);let a,h;const c=(o+r)/2;if(o===r)a=0,h=0;else{const u=r-o;switch(h=c<=.5?u/(r+o):u/(2-r-o),r){case i:a=(s-n)/u+(s<n?6:0);break;case s:a=(n-i)/u+2;break;case n:a=(i-s)/u+4;break}a/=6}return t.h=a,t.s=h,t.l=c,t}getRGB(t,e=ct.workingColorSpace){return ct.fromWorkingColorSpace(Q.copy(this),e),t.r=Q.r,t.g=Q.g,t.b=Q.b,t}getStyle(t=ut){ct.fromWorkingColorSpace(Q.copy(this),t);const e=Q.r,i=Q.g,s=Q.b;return t!==ut?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(t,e,i){return this.getHSL(Tt),this.setHSL(Tt.h+t,Tt.s+e,Tt.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Tt),t.getHSL(ke);const i=we(Tt.h,ke.h,e),s=we(Tt.s,ke.s,e),n=we(Tt.l,ke.l,e);return this.setHSL(i,s,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,s=this.b,n=t.elements;return this.r=n[0]*e+n[3]*i+n[6]*s,this.g=n[1]*e+n[4]*i+n[7]*s,this.b=n[2]*e+n[5]*i+n[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Q=new ht;ht.NAMES=Xs;let Jn=0;class ki extends Ut{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jn++}),this.uuid=he(),this.name="",this.blending=qi,this.side=Ge,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xi,this.blendDst=ji,this.blendEquation=Ui,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ht(0,0,0),this.blendAlpha=0,this.depthFunc=Yi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$i,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zt,this.stencilZFail=Zt,this.stencilZPass=Zt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==qi&&(i.blending=this.blending),this.side!==Ge&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Xi&&(i.blendSrc=this.blendSrc),this.blendDst!==ji&&(i.blendDst=this.blendDst),this.blendEquation!==Ui&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Yi&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==$i&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Zt&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Zt&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Zt&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const r=[];for(const o in n){const a=n[o];delete a.metadata,r.push(a)}return r}if(e){const n=s(t.textures),r=s(t.images);n.length>0&&(i.textures=n),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(e!==null){const s=e.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Me extends ki{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.combine=Ds,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const H=new x,Ie=new U;class qt{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Qi,this.updateRanges=[],this.gpuType=Mn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[t+s]=e.array[i+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)Ie.fromBufferAttribute(this,e),Ie.applyMatrix3(t),this.setXY(e,Ie.x,Ie.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyMatrix3(t),this.setXYZ(e,H.x,H.y,H.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyMatrix4(t),this.setXYZ(e,H.x,H.y,H.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyNormalMatrix(t),this.setXYZ(e,H.x,H.y,H.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.transformDirection(t),this.setXYZ(e,H.x,H.y,H.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=re(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=st(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=re(e,this.array)),e}setX(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=re(e,this.array)),e}setY(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=re(e,this.array)),e}setZ(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=re(e,this.array)),e}setW(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,s){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array),s=st(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this}setXYZW(t,e,i,s,n){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array),s=st(s,this.array),n=st(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Qi&&(t.usage=this.usage),t}}class Kn extends qt{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class tr extends qt{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class L extends qt{constructor(t,e,i){super(new Float32Array(t),e,i)}}let er=0;const lt=new W,bi=new X,ne=new x,ot=new gt,pe=new gt,Y=new x;class nt extends Ut{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:er++}),this.uuid=he(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Vn(t)?tr:Kn)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new vt().getNormalMatrix(t);i.applyNormalMatrix(n),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return lt.makeRotationFromQuaternion(t),this.applyMatrix4(lt),this}rotateX(t){return lt.makeRotationX(t),this.applyMatrix4(lt),this}rotateY(t){return lt.makeRotationY(t),this.applyMatrix4(lt),this}rotateZ(t){return lt.makeRotationZ(t),this.applyMatrix4(lt),this}translate(t,e,i){return lt.makeTranslation(t,e,i),this.applyMatrix4(lt),this}scale(t,e,i){return lt.makeScale(t,e,i),this.applyMatrix4(lt),this}lookAt(t){return bi.lookAt(t),bi.updateMatrix(),this.applyMatrix4(bi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ne).negate(),this.translate(ne.x,ne.y,ne.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let s=0,n=t.length;s<n;s++){const r=t[s];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new L(i,3))}else{for(let i=0,s=e.count;i<s;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new x(-1/0,-1/0,-1/0),new x(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,s=e.length;i<s;i++){const n=e[i];ot.setFromBufferAttribute(n),this.morphTargetsRelative?(Y.addVectors(this.boundingBox.min,ot.min),this.boundingBox.expandByPoint(Y),Y.addVectors(this.boundingBox.max,ot.max),this.boundingBox.expandByPoint(Y)):(this.boundingBox.expandByPoint(ot.min),this.boundingBox.expandByPoint(ot.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new be);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new x,1/0);return}if(t){const i=this.boundingSphere.center;if(ot.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const o=e[n];pe.setFromBufferAttribute(o),this.morphTargetsRelative?(Y.addVectors(ot.min,pe.min),ot.expandByPoint(Y),Y.addVectors(ot.max,pe.max),ot.expandByPoint(Y)):(ot.expandByPoint(pe.min),ot.expandByPoint(pe.max))}ot.getCenter(i);let s=0;for(let n=0,r=t.count;n<r;n++)Y.fromBufferAttribute(t,n),s=Math.max(s,i.distanceToSquared(Y));if(e)for(let n=0,r=e.length;n<r;n++){const o=e[n],a=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)Y.fromBufferAttribute(o,h),a&&(ne.fromBufferAttribute(t,h),Y.add(ne)),s=Math.max(s,i.distanceToSquared(Y))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,s=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new qt(new Float32Array(4*i.count),4));const r=this.getAttribute("tangent"),o=[],a=[];for(let E=0;E<i.count;E++)o[E]=new x,a[E]=new x;const h=new x,c=new x,u=new x,d=new U,p=new U,m=new U,y=new x,w=new x;function g(E,v,F){h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,v),u.fromBufferAttribute(i,F),d.fromBufferAttribute(n,E),p.fromBufferAttribute(n,v),m.fromBufferAttribute(n,F),c.sub(h),u.sub(h),p.sub(d),m.sub(d);const P=1/(p.x*m.y-m.x*p.y);isFinite(P)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(u,-p.y).multiplyScalar(P),w.copy(u).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(P),o[E].add(y),o[v].add(y),o[F].add(y),a[E].add(w),a[v].add(w),a[F].add(w))}let _=this.groups;_.length===0&&(_=[{start:0,count:t.count}]);for(let E=0,v=_.length;E<v;++E){const F=_[E],P=F.start,B=F.count;for(let T=P,k=P+B;T<k;T+=3)g(t.getX(T+0),t.getX(T+1),t.getX(T+2))}const b=new x,f=new x,z=new x,S=new x;function A(E){z.fromBufferAttribute(s,E),S.copy(z);const v=o[E];b.copy(v),b.sub(z.multiplyScalar(z.dot(v))).normalize(),f.crossVectors(S,v);const P=f.dot(a[E])<0?-1:1;r.setXYZW(E,b.x,b.y,b.z,P)}for(let E=0,v=_.length;E<v;++E){const F=_[E],P=F.start,B=F.count;for(let T=P,k=P+B;T<k;T+=3)A(t.getX(T+0)),A(t.getX(T+1)),A(t.getX(T+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new qt(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const s=new x,n=new x,r=new x,o=new x,a=new x,h=new x,c=new x,u=new x;if(t)for(let d=0,p=t.count;d<p;d+=3){const m=t.getX(d+0),y=t.getX(d+1),w=t.getX(d+2);s.fromBufferAttribute(e,m),n.fromBufferAttribute(e,y),r.fromBufferAttribute(e,w),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),o.fromBufferAttribute(i,m),a.fromBufferAttribute(i,y),h.fromBufferAttribute(i,w),o.add(c),a.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,a.x,a.y,a.z),i.setXYZ(w,h.x,h.y,h.z)}else for(let d=0,p=e.count;d<p;d+=3)s.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),i.setXYZ(d+0,c.x,c.y,c.z),i.setXYZ(d+1,c.x,c.y,c.z),i.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Y.fromBufferAttribute(t,e),Y.normalize(),t.setXYZ(e,Y.x,Y.y,Y.z)}toNonIndexed(){function t(o,a){const h=o.array,c=o.itemSize,u=o.normalized,d=new h.constructor(a.length*c);let p=0,m=0;for(let y=0,w=a.length;y<w;y++){o.isInterleavedBufferAttribute?p=a[y]*o.data.stride+o.offset:p=a[y]*c;for(let g=0;g<c;g++)d[m++]=h[p++]}return new qt(d,c,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new nt,i=this.index.array,s=this.attributes;for(const o in s){const a=s[o],h=t(a,i);e.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const a=[],h=n[o];for(let c=0,u=h.length;c<u;c++){const d=h[c],p=t(d,i);a.push(p)}e.morphAttributes[o]=a}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,a=r.length;o<a;o++){const h=r[o];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const h in a)a[h]!==void 0&&(t[h]=a[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const a in i){const h=i[a];t.data.attributes[a]=h.toJSON(t.data)}const s={};let n=!1;for(const a in this.morphAttributes){const h=this.morphAttributes[a],c=[];for(let u=0,d=h.length;u<d;u++){const p=h[u];c.push(p.toJSON(t.data))}c.length>0&&(s[a]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const h in s){const c=s[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],u=n[h];for(let d=0,p=u.length;d<p;d++)c.push(u[d].clone(e));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let h=0,c=r.length;h<c;h++){const u=r[h];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const a=t.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ms=new W,Dt=new Ti,Re=new be,fs=new x,De=new x,Le=new x,Ne=new x,Mi=new x,Oe=new x,ys=new x,Ve=new x;class C extends X{constructor(t=new nt,e=new Me){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(t,e){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(n&&o){Oe.set(0,0,0);for(let a=0,h=n.length;a<h;a++){const c=o[a],u=n[a];c!==0&&(Mi.fromBufferAttribute(u,t),r?Oe.addScaledVector(Mi,c):Oe.addScaledVector(Mi.sub(e),c))}e.add(Oe)}return e}raycast(t,e){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Re.copy(i.boundingSphere),Re.applyMatrix4(n),Dt.copy(t.ray).recast(t.near),!(Re.containsPoint(Dt.origin)===!1&&(Dt.intersectSphere(Re,fs)===null||Dt.origin.distanceToSquared(fs)>(t.far-t.near)**2))&&(ms.copy(n).invert(),Dt.copy(t.ray).applyMatrix4(ms),!(i.boundingBox!==null&&Dt.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,Dt)))}_computeIntersections(t,e,i){let s;const n=this.geometry,r=this.material,o=n.index,a=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,u=n.attributes.normal,d=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(r))for(let m=0,y=d.length;m<y;m++){const w=d[m],g=r[w.materialIndex],_=Math.max(w.start,p.start),b=Math.min(o.count,Math.min(w.start+w.count,p.start+p.count));for(let f=_,z=b;f<z;f+=3){const S=o.getX(f),A=o.getX(f+1),E=o.getX(f+2);s=We(this,g,t,i,h,c,u,S,A,E),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=w.materialIndex,e.push(s))}}else{const m=Math.max(0,p.start),y=Math.min(o.count,p.start+p.count);for(let w=m,g=y;w<g;w+=3){const _=o.getX(w),b=o.getX(w+1),f=o.getX(w+2);s=We(this,r,t,i,h,c,u,_,b,f),s&&(s.faceIndex=Math.floor(w/3),e.push(s))}}else if(a!==void 0)if(Array.isArray(r))for(let m=0,y=d.length;m<y;m++){const w=d[m],g=r[w.materialIndex],_=Math.max(w.start,p.start),b=Math.min(a.count,Math.min(w.start+w.count,p.start+p.count));for(let f=_,z=b;f<z;f+=3){const S=f,A=f+1,E=f+2;s=We(this,g,t,i,h,c,u,S,A,E),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=w.materialIndex,e.push(s))}}else{const m=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let w=m,g=y;w<g;w+=3){const _=w,b=w+1,f=w+2;s=We(this,r,t,i,h,c,u,_,b,f),s&&(s.faceIndex=Math.floor(w/3),e.push(s))}}}}function ir(l,t,e,i,s,n,r,o){let a;if(t.side===xn?a=i.intersectTriangle(r,n,s,!0,o):a=i.intersectTriangle(s,n,r,t.side===Ge,o),a===null)return null;Ve.copy(o),Ve.applyMatrix4(l.matrixWorld);const h=e.ray.origin.distanceTo(Ve);return h<e.near||h>e.far?null:{distance:h,point:Ve.clone(),object:l}}function We(l,t,e,i,s,n,r,o,a,h){l.getVertexPosition(o,De),l.getVertexPosition(a,Le),l.getVertexPosition(h,Ne);const c=ir(l,t,e,i,De,Le,Ne,ys);if(c){const u=new x;yt.getBarycoord(ys,De,Le,Ne,u),s&&(c.uv=yt.getInterpolatedAttribute(s,o,a,h,u,new U)),n&&(c.uv1=yt.getInterpolatedAttribute(n,o,a,h,u,new U)),r&&(c.normal=yt.getInterpolatedAttribute(r,o,a,h,u,new x),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const d={a:o,b:a,c:h,normal:new x,materialIndex:0};yt.getNormal(De,Le,Ne,d.normal),c.face=d,c.barycoord=u}return c}class Z extends nt{constructor(t=1,e=1,i=1,s=1,n=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:n,depthSegments:r};const o=this;s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);const a=[],h=[],c=[],u=[];let d=0,p=0;m("z","y","x",-1,-1,i,e,t,r,n,0),m("z","y","x",1,-1,i,e,-t,r,n,1),m("x","z","y",1,1,t,i,e,s,r,2),m("x","z","y",1,-1,t,i,-e,s,r,3),m("x","y","z",1,-1,t,e,i,s,n,4),m("x","y","z",-1,-1,t,e,-i,s,n,5),this.setIndex(a),this.setAttribute("position",new L(h,3)),this.setAttribute("normal",new L(c,3)),this.setAttribute("uv",new L(u,2));function m(y,w,g,_,b,f,z,S,A,E,v){const F=f/A,P=z/E,B=f/2,T=z/2,k=S/2,R=A+1,G=E+1;let q=0,it=0;const I=new x;for(let V=0;V<G;V++){const j=V*P-T;for(let dt=0;dt<R;dt++){const Yt=dt*F-B;I[y]=Yt*_,I[w]=j*b,I[g]=k,h.push(I.x,I.y,I.z),I[y]=0,I[w]=0,I[g]=S>0?1:-1,c.push(I.x,I.y,I.z),u.push(dt/A),u.push(1-V/E),q+=1}}for(let V=0;V<E;V++)for(let j=0;j<A;j++){const dt=d+j+R*V,Yt=d+j+R*(V+1),ze=d+(j+1)+R*(V+1),Wi=d+(j+1)+R*V;a.push(dt,Yt,Wi),a.push(Yt,ze,Wi),it+=6}o.addGroup(p,it,v),p+=it,d+=q}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Z(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class sr extends X{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new W,this.projectionMatrix=new W,this.projectionMatrixInverse=new W,this.coordinateSystem=Wt}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const _i=new x,nr=new x,rr=new vt;class at{constructor(t=new x(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,s){return this.normal.set(t,e,i),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const s=_i.subVectors(i,e).cross(nr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(_i),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/s;return n<0||n>1?null:e.copy(t.start).addScaledVector(i,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||rr.getNormalMatrix(t),s=this.coplanarPoint(_i).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Lt=new be,He=new x;class or{constructor(t=new at,e=new at,i=new at,s=new at,n=new at,r=new at){this.planes=[t,e,i,s,n,r]}set(t,e,i,s,n,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(s),o[4].copy(n),o[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Wt){const i=this.planes,s=t.elements,n=s[0],r=s[1],o=s[2],a=s[3],h=s[4],c=s[5],u=s[6],d=s[7],p=s[8],m=s[9],y=s[10],w=s[11],g=s[12],_=s[13],b=s[14],f=s[15];if(i[0].setComponents(a-n,d-h,w-p,f-g).normalize(),i[1].setComponents(a+n,d+h,w+p,f+g).normalize(),i[2].setComponents(a+r,d+c,w+m,f+_).normalize(),i[3].setComponents(a-r,d-c,w-m,f-_).normalize(),i[4].setComponents(a-o,d-u,w-y,f-b).normalize(),e===Wt)i[5].setComponents(a+o,d+u,w+y,f+b).normalize();else if(e===Ci)i[5].setComponents(o,u,y,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Lt.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Lt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Lt)}intersectsSprite(t){return Lt.center.set(0,0,0),Lt.radius=.7071067811865476,Lt.applyMatrix4(t.matrixWorld),this.intersectsSphere(Lt)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let n=0;n<6;n++)if(e[n].distanceToPoint(i)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const s=e[i];if(He.x=s.normal.x>0?t.max.x:t.min.x,He.y=s.normal.y>0?t.max.y:t.min.y,He.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(He)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Ke extends nt{constructor(t=1,e=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:s};const n=t/2,r=e/2,o=Math.floor(i),a=Math.floor(s),h=o+1,c=a+1,u=t/o,d=e/a,p=[],m=[],y=[],w=[];for(let g=0;g<c;g++){const _=g*d-r;for(let b=0;b<h;b++){const f=b*u-n;m.push(f,-_,0),y.push(0,0,1),w.push(b/o),w.push(1-g/a)}}for(let g=0;g<a;g++)for(let _=0;_<o;_++){const b=_+h*g,f=_+h*(g+1),z=_+1+h*(g+1),S=_+1+h*g;p.push(b,f,S),p.push(f,z,S)}this.setIndex(p),this.setAttribute("position",new L(m,3)),this.setAttribute("normal",new L(y,3)),this.setAttribute("uv",new L(w,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ke(t.width,t.height,t.widthSegments,t.heightSegments)}}class ar extends sr{constructor(t=-1,e=1,i=1,s=-1,n=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=s,this.near=n,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,s,n,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-t,r=i+t,o=s+e,a=s-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,r=n+h*this.view.width,o-=c*this.view.offsetY,a=o-c*this.view.height}this.projectionMatrix.makeOrthographic(n,r,o,a,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class js extends X{constructor(){super(),this.isGroup=!0,this.type="Group"}}class _e extends ki{static get type(){return"LineBasicMaterial"}constructor(t){super(),this.isLineBasicMaterial=!0,this.color=new ht(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const $e=new x,Qe=new x,xs=new W,me=new Ti,qe=new be,Si=new x,gs=new x;class At extends X{constructor(t=new nt,e=new _e){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let s=1,n=e.count;s<n;s++)$e.fromBufferAttribute(e,s-1),Qe.fromBufferAttribute(e,s),i[s]=i[s-1],i[s]+=$e.distanceTo(Qe);t.setAttribute("lineDistance",new L(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,s=this.matrixWorld,n=t.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),qe.copy(i.boundingSphere),qe.applyMatrix4(s),qe.radius+=n,t.ray.intersectsSphere(qe)===!1)return;xs.copy(s).invert(),me.copy(t.ray).applyMatrix4(xs);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,h=this.isLineSegments?2:1,c=i.index,d=i.attributes.position;if(c!==null){const p=Math.max(0,r.start),m=Math.min(c.count,r.start+r.count);for(let y=p,w=m-1;y<w;y+=h){const g=c.getX(y),_=c.getX(y+1),b=Ue(this,t,me,a,g,_);b&&e.push(b)}if(this.isLineLoop){const y=c.getX(m-1),w=c.getX(p),g=Ue(this,t,me,a,y,w);g&&e.push(g)}}else{const p=Math.max(0,r.start),m=Math.min(d.count,r.start+r.count);for(let y=p,w=m-1;y<w;y+=h){const g=Ue(this,t,me,a,y,y+1);g&&e.push(g)}if(this.isLineLoop){const y=Ue(this,t,me,a,m-1,p);y&&e.push(y)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}}function Ue(l,t,e,i,s,n){const r=l.geometry.attributes.position;if($e.fromBufferAttribute(r,s),Qe.fromBufferAttribute(r,n),e.distanceSqToSegment($e,Qe,Si,gs)>i)return;Si.applyMatrix4(l.matrixWorld);const a=t.ray.origin.distanceTo(Si);if(!(a<t.near||a>t.far))return{distance:a,point:gs.clone().applyMatrix4(l.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:l}}const ws=new x,bs=new x;class Ii extends At{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let s=0,n=e.count;s<n;s+=2)ws.fromBufferAttribute(e,s),bs.fromBufferAttribute(e,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+ws.distanceTo(bs);t.setAttribute("lineDistance",new L(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class J extends nt{constructor(t=1,e=1,i=1,s=32,n=1,r=!1,o=0,a=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:s,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:a};const h=this;s=Math.floor(s),n=Math.floor(n);const c=[],u=[],d=[],p=[];let m=0;const y=[],w=i/2;let g=0;_(),r===!1&&(t>0&&b(!0),e>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new L(u,3)),this.setAttribute("normal",new L(d,3)),this.setAttribute("uv",new L(p,2));function _(){const f=new x,z=new x;let S=0;const A=(e-t)/i;for(let E=0;E<=n;E++){const v=[],F=E/n,P=F*(e-t)+t;for(let B=0;B<=s;B++){const T=B/s,k=T*a+o,R=Math.sin(k),G=Math.cos(k);z.x=P*R,z.y=-F*i+w,z.z=P*G,u.push(z.x,z.y,z.z),f.set(R,A,G).normalize(),d.push(f.x,f.y,f.z),p.push(T,1-F),v.push(m++)}y.push(v)}for(let E=0;E<s;E++)for(let v=0;v<n;v++){const F=y[v][E],P=y[v+1][E],B=y[v+1][E+1],T=y[v][E+1];(t>0||v!==0)&&(c.push(F,P,T),S+=3),(e>0||v!==n-1)&&(c.push(P,B,T),S+=3)}h.addGroup(g,S,0),g+=S}function b(f){const z=m,S=new U,A=new x;let E=0;const v=f===!0?t:e,F=f===!0?1:-1;for(let B=1;B<=s;B++)u.push(0,w*F,0),d.push(0,F,0),p.push(.5,.5),m++;const P=m;for(let B=0;B<=s;B++){const k=B/s*a+o,R=Math.cos(k),G=Math.sin(k);A.x=v*G,A.y=w*F,A.z=v*R,u.push(A.x,A.y,A.z),d.push(0,F,0),S.x=R*.5+.5,S.y=G*.5*F+.5,p.push(S.x,S.y),m++}for(let B=0;B<s;B++){const T=z+B,k=P+B;f===!0?c.push(k,k+1,T):c.push(k+1,k,T),E+=3}h.addGroup(g,E,f===!0?1:2),g+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new J(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ri extends nt{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const n=[],r=[];o(s),h(i),c(),this.setAttribute("position",new L(n,3)),this.setAttribute("normal",new L(n.slice(),3)),this.setAttribute("uv",new L(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(_){const b=new x,f=new x,z=new x;for(let S=0;S<e.length;S+=3)p(e[S+0],b),p(e[S+1],f),p(e[S+2],z),a(b,f,z,_)}function a(_,b,f,z){const S=z+1,A=[];for(let E=0;E<=S;E++){A[E]=[];const v=_.clone().lerp(f,E/S),F=b.clone().lerp(f,E/S),P=S-E;for(let B=0;B<=P;B++)B===0&&E===S?A[E][B]=v:A[E][B]=v.clone().lerp(F,B/P)}for(let E=0;E<S;E++)for(let v=0;v<2*(S-E)-1;v++){const F=Math.floor(v/2);v%2===0?(d(A[E][F+1]),d(A[E+1][F]),d(A[E][F])):(d(A[E][F+1]),d(A[E+1][F+1]),d(A[E+1][F]))}}function h(_){const b=new x;for(let f=0;f<n.length;f+=3)b.x=n[f+0],b.y=n[f+1],b.z=n[f+2],b.normalize().multiplyScalar(_),n[f+0]=b.x,n[f+1]=b.y,n[f+2]=b.z}function c(){const _=new x;for(let b=0;b<n.length;b+=3){_.x=n[b+0],_.y=n[b+1],_.z=n[b+2];const f=w(_)/2/Math.PI+.5,z=g(_)/Math.PI+.5;r.push(f,1-z)}m(),u()}function u(){for(let _=0;_<r.length;_+=6){const b=r[_+0],f=r[_+2],z=r[_+4],S=Math.max(b,f,z),A=Math.min(b,f,z);S>.9&&A<.1&&(b<.2&&(r[_+0]+=1),f<.2&&(r[_+2]+=1),z<.2&&(r[_+4]+=1))}}function d(_){n.push(_.x,_.y,_.z)}function p(_,b){const f=_*3;b.x=t[f+0],b.y=t[f+1],b.z=t[f+2]}function m(){const _=new x,b=new x,f=new x,z=new x,S=new U,A=new U,E=new U;for(let v=0,F=0;v<n.length;v+=9,F+=6){_.set(n[v+0],n[v+1],n[v+2]),b.set(n[v+3],n[v+4],n[v+5]),f.set(n[v+6],n[v+7],n[v+8]),S.set(r[F+0],r[F+1]),A.set(r[F+2],r[F+3]),E.set(r[F+4],r[F+5]),z.copy(_).add(b).add(f).divideScalar(3);const P=w(z);y(S,F+0,_,P),y(A,F+2,b,P),y(E,F+4,f,P)}}function y(_,b,f,z){z<0&&_.x===1&&(r[b]=_.x-1),f.x===0&&f.z===0&&(r[b]=z/2/Math.PI+.5)}function w(_){return Math.atan2(_.z,-_.x)}function g(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ri(t.vertices,t.indices,t.radius,t.details)}}class oe extends Ri{constructor(t=1,e=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],s=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,s,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new oe(t.radius,t.detail)}}class Di extends nt{constructor(t=1,e=32,i=16,s=0,n=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:s,phiLength:n,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(r+o,Math.PI);let h=0;const c=[],u=new x,d=new x,p=[],m=[],y=[],w=[];for(let g=0;g<=i;g++){const _=[],b=g/i;let f=0;g===0&&r===0?f=.5/e:g===i&&a===Math.PI&&(f=-.5/e);for(let z=0;z<=e;z++){const S=z/e;u.x=-t*Math.cos(s+S*n)*Math.sin(r+b*o),u.y=t*Math.cos(r+b*o),u.z=t*Math.sin(s+S*n)*Math.sin(r+b*o),m.push(u.x,u.y,u.z),d.copy(u).normalize(),y.push(d.x,d.y,d.z),w.push(S+f,1-b),_.push(h++)}c.push(_)}for(let g=0;g<i;g++)for(let _=0;_<e;_++){const b=c[g][_+1],f=c[g][_],z=c[g+1][_],S=c[g+1][_+1];(g!==0||r>0)&&p.push(b,f,S),(g!==i-1||a<Math.PI)&&p.push(f,z,S)}this.setIndex(p),this.setAttribute("position",new L(m,3)),this.setAttribute("normal",new L(y,3)),this.setAttribute("uv",new L(w,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Di(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Vt extends nt{constructor(t=1,e=.4,i=12,s=48,n=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:s,arc:n},i=Math.floor(i),s=Math.floor(s);const r=[],o=[],a=[],h=[],c=new x,u=new x,d=new x;for(let p=0;p<=i;p++)for(let m=0;m<=s;m++){const y=m/s*n,w=p/i*Math.PI*2;u.x=(t+e*Math.cos(w))*Math.cos(y),u.y=(t+e*Math.cos(w))*Math.sin(y),u.z=e*Math.sin(w),o.push(u.x,u.y,u.z),c.x=t*Math.cos(y),c.y=t*Math.sin(y),d.subVectors(u,c).normalize(),a.push(d.x,d.y,d.z),h.push(m/s),h.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=s;m++){const y=(s+1)*p+m-1,w=(s+1)*(p-1)+m-1,g=(s+1)*(p-1)+m,_=(s+1)*p+m;r.push(y,w,_),r.push(w,g,_)}this.setIndex(r),this.setAttribute("position",new L(o,3)),this.setAttribute("normal",new L(a,3)),this.setAttribute("uv",new L(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vt(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class hr extends ki{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sn,this.normalScale=new U(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.combine=Ds,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const Ms={enabled:!1,files:{},add:function(l,t){this.enabled!==!1&&(this.files[l]=t)},get:function(l){if(this.enabled!==!1)return this.files[l]},remove:function(l){delete this.files[l]},clear:function(){this.files={}}};class lr{constructor(t,e,i){const s=this;let n=!1,r=0,o=0,a;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(c){o++,n===!1&&s.onStart!==void 0&&s.onStart(c,r,o),n=!0},this.itemEnd=function(c){r++,s.onProgress!==void 0&&s.onProgress(c,r,o),r===o&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(c){s.onError!==void 0&&s.onError(c)},this.resolveURL=function(c){return a?a(c):c},this.setURLModifier=function(c){return a=c,this},this.addHandler=function(c,u){return h.push(c,u),this},this.removeHandler=function(c){const u=h.indexOf(c);return u!==-1&&h.splice(u,2),this},this.getHandler=function(c){for(let u=0,d=h.length;u<d;u+=2){const p=h[u],m=h[u+1];if(p.global&&(p.lastIndex=0),p.test(c))return m}return null}}}const cr=new lr;class Li{constructor(t){this.manager=t!==void 0?t:cr,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(s,n){i.load(t,s,e,n)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Li.DEFAULT_MATERIAL_NAME="__DEFAULT";const zt={};class ur extends Error{constructor(t,e){super(t),this.response=e}}class dr extends Li{constructor(t){super(t)}load(t,e,i,s){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=Ms.get(t);if(n!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(n),this.manager.itemEnd(t)},0),n;if(zt[t]!==void 0){zt[t].push({onLoad:e,onProgress:i,onError:s});return}zt[t]=[],zt[t].push({onLoad:e,onProgress:i,onError:s});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=zt[t],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let y=0;const w=new ReadableStream({start(g){_();function _(){u.read().then(({done:b,value:f})=>{if(b)g.close();else{y+=f.byteLength;const z=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let S=0,A=c.length;S<A;S++){const E=c[S];E.onProgress&&E.onProgress(z)}g.enqueue(f),_()}},b=>{g.error(b)})}}});return new Response(w)}else throw new ur(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(a){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,o));case"json":return h.json();default:if(o===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return h.arrayBuffer().then(m=>p.decode(m))}}}).then(h=>{Ms.add(t,h);const c=zt[t];delete zt[t];for(let u=0,d=c.length;u<d;u++){const p=c[u];p.onLoad&&p.onLoad(h)}}).catch(h=>{const c=zt[t];if(c===void 0)throw this.manager.itemError(t),h;delete zt[t];for(let u=0,d=c.length;u<d;u++){const p=c[u];p.onError&&p.onError(h)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Ys extends X{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ht(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}const zi=new W,_s=new x,Ss=new x;class pr{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new W,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Xt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;_s.setFromMatrixPosition(t.matrixWorld),e.position.copy(_s),Ss.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Ss),e.updateMatrixWorld(),zi.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zi),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(zi)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class mr extends pr{constructor(){super(new ar(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class fr extends Ys{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(X.DEFAULT_UP),this.updateMatrix(),this.target=new X,this.shadow=new mr}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class yr extends Ys{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class xr{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=zs(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=zs();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function zs(){return performance.now()}const As=new W;class Zs{constructor(t,e,i=0,s=1/0){this.ray=new Ti(t,e),this.near=i,this.far=s,this.camera=null,this.layers=new Us,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return As.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(As),this}intersectObject(t,e=!0,i=[]){return Fi(t,this,i,e),i.sort(Es),i}intersectObjects(t,e=!0,i=[]){for(let s=0,n=t.length;s<n;s++)Fi(t[s],this,i,e);return i.sort(Es),i}}function Es(l,t){return l.distance-t.distance}function Fi(l,t,e,i){let s=!0;if(l.layers.test(t.layers)&&l.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const n=l.children;for(let r=0,o=n.length;r<o;r++)Fi(n[r],t,e,!0)}}class gr{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(et(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class wr extends Ii{constructor(t=10,e=10,i=4473924,s=8947848){i=new ht(i),s=new ht(s);const n=e/2,r=t/e,o=t/2,a=[],h=[];for(let d=0,p=0,m=-o;d<=e;d++,m+=r){a.push(-o,0,m,o,0,m),a.push(m,0,-o,m,0,o);const y=d===n?i:s;y.toArray(h,p),p+=3,y.toArray(h,p),p+=3,y.toArray(h,p),p+=3,y.toArray(h,p),p+=3}const c=new nt;c.setAttribute("position",new L(a,3)),c.setAttribute("color",new L(h,3));const u=new _e({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class br extends Ii{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],n=new nt;n.setIndex(new qt(i,1)),n.setAttribute("position",new L(s,3)),super(n,new _e({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Mr extends Ut{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Is}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Is);function _r(l){return URL.canParse(l)&&(l.startsWith("http://")||l.startsWith("https://"))}async function Sr(l,t){return(await ti(l,t)).arrayBuffer()}function ti(l,t){if(typeof l=="string"){const e=ei(l);return dn.fetch(e,t)}return pn.fetchFile(l,t)}async function zr(l,t){return await(await ti(l,t)).json()}async function Ar(l,t){return(await ti(l,t)).text()}function Er(l){let t,e;if(l instanceof Response){const r=new URL(l.url);t=`${r.origin}${r.pathname}`,e=r.search}else if(l instanceof File)t=l.name;else if(l instanceof Blob)t="";else if(typeof l=="string"){const r=ei(l),o=new URL(r);t=`${o.origin}${o.pathname}`,e=o.search}else return l;const i=t.split("/"),s=i.pop(),n=i.join("/");return{baseUrl:t,dirname:n,fileext:s==null?void 0:s.split(".").at(-1),filename:s,queryString:e}}async function vr(l){return new Promise((t,e)=>{if(typeof l=="string")return ei(l);{const i=new FileReader;i.addEventListener("load",()=>t(i.result),!1),i.addEventListener("error",()=>e(i.error)),i.readAsDataURL(l)}})}const Gs={checkAbsoluteHost:_r,fetch:ti,fetchArrayBuffer:Sr,fetchJson:zr,fetchText:Ar,getContext:Er,toDataURL:vr};let Bi=null,$s={};function le(){if(!Bi)throw new Error("No configuration loaded");return Bi}function Cr(){return $s}async function Fr(l){return await Gs.fetchJson(l)}async function Br(l){l.crs_definitions||(console.warn("Configuration is not specifying CRS definitions. You should define the projections you use. See https://gitlab.com/giro3d/piero/-/issues/78 for more information."),l.crs_definitions={"EPSG:2154":"+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs","EPSG:3857":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs","EPSG:3946":"+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs","EPSG:3948":"+proj=lcc +lat_0=48 +lon_0=3 +lat_1=47.25 +lat_2=48.75 +x_0=1700000 +y_0=7200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs","EPSG:4171":"+proj=longlat +ellps=GRS80 +no_defs +type=crs","EPSG:4326":"+proj=longlat +datum=WGS84 +no_defs +type=crs","IGNF:WGS84G":'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'});for(const[t,e]of Object.entries(l.crs_definitions))try{un.registerCRS(t,e)}catch(i){throw console.error(`Failed to register CRS "${t}" as "${e}".`),i}return Bi=l,Promise.resolve()}function Pr(l){$s=l}function Tr(l,t){const e=JSON.stringify(l,null,2),i=new Blob([e],{type:"application/json"});Qs(i,t)}function Qs(l,t){const e=URL.createObjectURL(l),i=document.createElement("a");i.href=e,i.download=t,i.innerHTML="Click here to download the file",document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(e)}let Js="/";function kr(l="http://localhost:8080/"){const t=Js??l;return t.at(-1)==="/"?t:t+"/"}function Ir(l){Js=l}const Ks={downloadAsJson:Tr,downloadBlob:Qs,getBaseUrl:kr,setBaseUrl:Ir};function Rr(l){const t=Hi.scale(l.ramp).mode("lab").colors(256).map(e=>{const i=Hi(e).gl();return new ht().setRGB(i[0],i[1],i[2],"srgb")});return new mn({colors:t,...l})}function Dr(l){const t=le();return l?new fn(l.crs??t.default_crs,l.x,l.y,l.z??0).as(t.default_crs):void 0}function Lr(l){const t=le();return l?new yn(l.crs??t.default_crs,l).as(t.default_crs):void 0}function ei(l){return l.startsWith("http://")||l.startsWith("https://")?l:new URL(l,Ks.getBaseUrl()).toString()}function Nr(l){var e;return((e=le().enabled_features)==null?void 0:e.includes(l))??!1}function Or(l,t){const e=l.isEntity3D?l.object3d:l;"dataset"in e.userData||(e.userData.dataset={});for(const[i,s]of Object.entries(t))e.userData.dataset[i]=s}const Se=l=>l!=null&&typeof l=="object",Vr=l=>Se(l)&&"href"in l,Wr=l=>Se(l)&&l.isColor,Hr=l=>Se(l)&&l.isVector3;class tn extends Ut{constructor(e){super();N(this,"config");N(this,"name");N(this,"onObjectPreloaded");N(this,"type");N(this,"uuid");N(this,"_isPreloaded");N(this,"_isPreloading");N(this,"_opacity");N(this,"_parent");N(this,"_visible");this.type=e.type,this.uuid=qs.generateUUID(),this.name=e.name,this.onObjectPreloaded=e.onObjectPreloaded,this._parent=null,this._visible=e.visible??!1,this._opacity=e.opacity??1,this._isPreloading=!1,this._isPreloaded=!1,this.config=e}get isPreloaded(){return this._isPreloaded}set isPreloaded(e){this._isPreloaded=e,this.dispatchEvent({type:"isPreloaded"})}get isPreloading(){return this._isPreloading}set isPreloading(e){this._isPreloading=e,this.dispatchEvent({type:"isPreloading"})}get opacity(){return this._opacity}set opacity(e){this._opacity=e,this.dispatchEvent({type:"opacity"})}get parent(){return this._parent}set parent(e){this._parent=e}get visible(){return this._visible}set visible(e){this._visible=e,this.dispatchEvent({type:"visible"})}delete(){this.dispatchEvent({type:"delete"})}get(e){var i;return e in this.config&&this.config[e]!=null?this.config[e]:(i=this.parent)==null?void 0:i.get(e)}}class Ni extends tn{constructor(e){super(e);N(this,"_children");this._children=sn(e.children,this),this._isPreloaded=!0}get children(){return this._children}set children(e){this._children.forEach(i=>i.parent=null),this._children=e,this._children.forEach(i=>{i.parent=this,i.visible=i.visible||this._visible})}leafs(){return this._children.map(e=>e.leafs()).flat()}traverse(e){var i;e(this),(i=this._children)==null||i.forEach(s=>s.traverse(e))}}N(Ni,"isGroup",e=>Se(e)&&e.type==="group");class en extends tn{constructor(t){super(t)}leafs(){return[this]}traverse(t){t(this)}}function sn(l,t){return l.map(e=>{let i;return e.type==="group"?i=new Ni(e):i=new en(e),t&&(i.parent=t,i.visible=i.visible||t.visible),i})}const Oi=Je.defineStore("camera",()=>{const l=M.ref(),t=M.ref(new x),e=M.ref("orbit"),i=M.ref(!1);function s(){if(l.value===void 0)throw new Error("Cannot get cameraPosition");return l.value}function n(){return t.value}function r(m){l.value=m}function o(m,y){l.value=m,t.value.copy(y)}function a(){return e.value}function h(){return e}function c(m){e.value=m}function u(){return i.value}function d(m){i.value=m}function p(m){}return{getCamera3dPosition:n,getCameraPosition:s,getNavigationMode:a,getNavigationModeRef:h,isUserInteracting:u,lookTopDownAt:p,setCameraPosition:r,setCurrentPosition:o,setIsUserInteracting:d,setNavigationMode:c}}),Vi=Je.defineStore("clippingBox",()=>{const l=M.ref(0),t=M.ref(new x(0,0,0)),e=M.ref(new x(0,0,0)),i=M.ref(!1),s=M.ref(!1),n=M.ref(!1),r=M.ref(new gt().setFromCenterAndSize(t.value,e.value));function o(){r.value=new gt().setFromCenterAndSize(t.value,e.value)}function a(y){i.value=y}function h(y){s.value=y}function c(y){l.value=y}function u(y){t.value=y,o()}function d(y){e.value=y,o()}function p(y){n.value=y}function m(y){r.value=y.clone();const w=new x,g=new x;y.getCenter(w),y.getSize(g),t.value=w,e.value=g}return{center:t,clippingBox:r,displayHelper:n,enable:i,invert:s,orientation:l,setCenter:u,setClippingBox:m,setDisplayHelper:p,setEnabled:a,setInverted:h,setOrientation:c,setSize:d,size:e}}),qr={class:"input-group"},Ur={class:"form-check form-switch"},Xr=["checked"],jr={class:"input-group"},Yr={class:"form-check form-switch"},Zr=["checked"],Gr={class:"input-group"},$r={class:"form-check form-switch"},Qr=["checked"],Jr={class:"accordion mt-3"},Kr={class:"accordion-item"},to={id:"clippingbox-size",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},eo={class:"accordion-body"},io={class:"d-flex justify-content-between align-items-end w-100"},so={class:"input-group mb-3"},no=["value"],ro=["value"],oo=["value"],ao={class:"input-group mb-3"},ho=["value"],lo=["value"],co=["value"],uo={class:"accordion-item"},po={id:"clippingbox-floorpreset",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},mo={class:"accordion-body"},fo={class:"row w-100"},yo={class:"col-sm-6"},xo={class:"input-group input-group-sm"},go={class:"row w-100"},wo={class:"col-sm-6"},bo={class:"input-group input-group-sm"},Mo={class:"row w-100"},_o={class:"col-sm-6"},So={class:"input-group input-group-sm"},zo=M.defineComponent({__name:"ClippingBox",setup(l){const t=le(),e=Vi(),i=Oi(),s=b=>Number.parseFloat(b.target.value);function n(){const{target:b}=i.getCameraPosition();e.setCenter(b.clone())}function r(b){const f=e.size.clone();f.setX(b),e.setSize(f)}function o(b){const f=e.size.clone();f.setY(b),e.setSize(f)}function a(b){const f=e.size.clone();f.setZ(b),e.setSize(f)}function h(b){const f=e.center.clone();f.setX(b),e.setCenter(f)}function c(b){const f=e.center.clone();f.setY(b),e.setCenter(f)}function u(b){const f=e.center.clone();f.setZ(b),e.setCenter(f)}const d=M.ref(t.analysis.clipping_box.floor_preset.altitude),p=M.ref(t.analysis.clipping_box.floor_preset.size),m=M.ref(t.analysis.clipping_box.floor_preset.floor);function y(){m.value-=1;const b=e.center.clone();b.setZ(g()),e.setCenter(b)}function w(){m.value+=1;const b=e.center.clone();b.setZ(g()),e.setCenter(b)}function g(){return d.value+(m.value+.5)*p.value}function _(){const{target:b}=i.getCameraPosition(),f=b.clone();f.z=g();const z=new x(1e3,1e3,p.value);e.setSize(z),e.setCenter(f)}return(b,f)=>(M.openBlock(),M.createElementBlock("div",null,[M.createElementVNode("div",qr,[M.createElementVNode("div",Ur,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).enable,type:"checkbox",role:"switch",id:"enable-clippingbox",onInput:f[0]||(f[0]=z=>M.unref(e).setEnabled(!M.unref(e).enable))},null,40,Xr),f[14]||(f[14]=M.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox"},"Enable clipping box",-1))])]),M.createElementVNode("div",jr,[M.createElementVNode("div",Yr,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).invert,type:"checkbox",role:"switch",id:"invert-clippingbox",onInput:f[1]||(f[1]=z=>M.unref(e).setInverted(!M.unref(e).invert))},null,40,Zr),f[15]||(f[15]=M.createElementVNode("label",{class:"form-check-label",for:"invert-clippingbox"},"Invert clipping box",-1))])]),M.createElementVNode("div",Gr,[M.createElementVNode("div",$r,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).displayHelper,type:"checkbox",role:"switch",id:"enable-clippingbox-helper",onInput:f[2]||(f[2]=z=>M.unref(e).setDisplayHelper(!M.unref(e).displayHelper))},null,40,Qr),f[16]||(f[16]=M.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox-helper"},"Show 3D helper",-1))])]),M.createElementVNode("div",Jr,[M.createElementVNode("div",Kr,[f[19]||(f[19]=M.createElementVNode("h2",{class:"accordion-header"},[M.createElementVNode("button",{class:"accordion-button",type:"button","data-bs-toggle":"collapse","data-bs-target":"#clippingbox-size","aria-expanded":"true","aria-controls":"clippingbox-size"}," Clipping box size ")],-1)),M.createElementVNode("div",to,[M.createElementVNode("div",eo,[M.createElementVNode("div",io,[f[17]||(f[17]=M.createElementVNode("label",{class:"form-label flex-grow"},"Center (x, y, z)",-1)),M.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[3]||(f[3]=z=>n())}," Set from view ")]),M.createElementVNode("div",so,[M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-x",value:M.unref(e).center.x,onInput:f[4]||(f[4]=z=>h(s(z)))},null,40,no),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-y",value:M.unref(e).center.y,onInput:f[5]||(f[5]=z=>c(s(z)))},null,40,ro),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-z",value:M.unref(e).center.z,onInput:f[6]||(f[6]=z=>u(s(z)))},null,40,oo)]),f[18]||(f[18]=M.createElementVNode("label",{class:"form-label"},"Size (x, y, z)",-1)),M.createElementVNode("div",ao,[M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-x",min:"1",value:M.unref(e).size.x,onInput:f[7]||(f[7]=z=>r(s(z)))},null,40,ho),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-y",min:"1",value:M.unref(e).size.y,onInput:f[8]||(f[8]=z=>o(s(z)))},null,40,lo),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-z",min:"1",value:M.unref(e).size.z,onInput:f[9]||(f[9]=z=>a(s(z)))},null,40,co)])])])]),M.createElementVNode("div",uo,[f[27]||(f[27]=M.createElementVNode("h2",{class:"accordion-header"},[M.createElementVNode("button",{class:"accordion-button",type:"button","data-bs-toggle":"collapse","data-bs-target":"#clippingbox-floorpreset","aria-expanded":"true","aria-controls":"clippingbox-floorpreset"}," Floor preset ")],-1)),M.createElementVNode("div",po,[M.createElementVNode("div",mo,[M.createElementVNode("div",fo,[f[21]||(f[21]=M.createElementVNode("label",{for:"floor-reference-altitude",class:"col-sm-6 col-form-label col-form-label-sm"},"Reference altitude",-1)),M.createElementVNode("div",yo,[M.createElementVNode("div",xo,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-reference-altitude","onUpdate:modelValue":f[10]||(f[10]=z=>d.value=z)},null,512),[[M.vModelText,d.value]]),f[20]||(f[20]=M.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),M.createElementVNode("div",go,[f[23]||(f[23]=M.createElementVNode("label",{for:"floor-size",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor size",-1)),M.createElementVNode("div",wo,[M.createElementVNode("div",bo,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-size","onUpdate:modelValue":f[11]||(f[11]=z=>p.value=z)},null,512),[[M.vModelText,p.value]]),f[22]||(f[22]=M.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),M.createElementVNode("div",Mo,[f[26]||(f[26]=M.createElementVNode("label",{for:"floor-number",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor number",-1)),M.createElementVNode("div",_o,[M.createElementVNode("div",So,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-number","onUpdate:modelValue":f[12]||(f[12]=z=>m.value=z)},null,512),[[M.vModelText,m.value]]),M.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:w},[...f[24]||(f[24]=[M.createElementVNode("i",{class:"bi bi-arrow-up-short"},null,-1)])]),M.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:y},[...f[25]||(f[25]=[M.createElementVNode("i",{class:"bi bi-arrow-down-short"},null,-1)])])])])]),M.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[13]||(f[13]=z=>_())}," Set ")])])])])]))}}),ii=(l,t)=>{const e=l.__vccOpts||l;for(const[i,s]of t)e[i]=s;return e},Ao=ii(zo,[["__scopeId","data-v-803bbe4b"]]),Nt=new Zs,K=new x,kt=new x,O=new tt,vs={X:new x(1,0,0),Y:new x(0,1,0),Z:new x(0,0,1)},Ai={type:"change"},Cs={type:"mouseDown",mode:null},Fs={type:"mouseUp",mode:null},Bs={type:"objectChange"};class Eo extends Mr{constructor(t,e=null){super(void 0,e);const i=new To(this);this._root=i;const s=new ko;this._gizmo=s,i.add(s);const n=new Io;this._plane=n,i.add(n);const r=this;function o(b,f){let z=f;Object.defineProperty(r,b,{get:function(){return z!==void 0?z:f},set:function(S){z!==S&&(z=S,n[b]=S,s[b]=S,r.dispatchEvent({type:b+"-changed",value:S}),r.dispatchEvent(Ai))}}),r[b]=f,n[b]=f,s[b]=f}o("camera",t),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const a=new x,h=new x,c=new tt,u=new tt,d=new x,p=new tt,m=new x,y=new x,w=new x,g=0,_=new x;o("worldPosition",a),o("worldPositionStart",h),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",m),o("pointEnd",y),o("rotationAxis",w),o("rotationAngle",g),o("eye",_),this._offset=new x,this._startNorm=new x,this._endNorm=new x,this._cameraScale=new x,this._parentPosition=new x,this._parentQuaternion=new tt,this._parentQuaternionInv=new tt,this._parentScale=new x,this._worldScaleStart=new x,this._worldQuaternionInv=new tt,this._worldScale=new x,this._positionStart=new x,this._quaternionStart=new tt,this._scaleStart=new x,this._getPointer=vo.bind(this),this._onPointerDown=Fo.bind(this),this._onPointerHover=Co.bind(this),this._onPointerMove=Bo.bind(this),this._onPointerUp=Po.bind(this),e!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(this.object===void 0||this.dragging===!0)return;t!==null&&Nt.setFromCamera(t,this.camera);const e=Ei(this._gizmo.picker[this.mode],Nt);e?this.axis=e.object.name:this.axis=null}pointerDown(t){if(!(this.object===void 0||this.dragging===!0||t!=null&&t.button!==0)&&this.axis!==null){t!==null&&Nt.setFromCamera(t,this.camera);const e=Ei(this._plane,Nt,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,Cs.mode=this.mode,this.dispatchEvent(Cs)}}pointerMove(t){const e=this.axis,i=this.mode,s=this.object;let n=this.space;if(i==="scale"?n="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(n="world"),s===void 0||e===null||this.dragging===!1||t!==null&&t.button!==-1)return;t!==null&&Nt.setFromCamera(t,this.camera);const r=Ei(this._plane,Nt,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(s.position.applyQuaternion(O.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),n==="world"&&(s.parent&&s.position.add(K.setFromMatrixPosition(s.parent.matrixWorld)),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(K.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if(i==="scale"){if(e.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),kt.set(o,o,o)}else K.copy(this.pointStart),kt.copy(this.pointEnd),K.applyQuaternion(this._worldQuaternionInv),kt.applyQuaternion(this._worldQuaternionInv),kt.divide(K),e.search("X")===-1&&(kt.x=1),e.search("Y")===-1&&(kt.y=1),e.search("Z")===-1&&(kt.z=1);s.scale.copy(this._scaleStart).multiply(kt),this.scaleSnap&&(e.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(K.setFromMatrixPosition(this.camera.matrixWorld));let a=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(K.copy(this.rotationAxis).cross(this.eye))*o):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(vs[e]),K.copy(vs[e]),n==="local"&&K.applyQuaternion(this.worldQuaternion),K.cross(this.eye),K.length()===0?a=!0:this.rotationAngle=this._offset.dot(K.normalize())*o),(e==="E"||a)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&e!=="E"&&e!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(O.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(O.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ai),this.dispatchEvent(Bs)}}pointerUp(t){t!==null&&t.button!==0||(this.dragging&&this.axis!==null&&(Fs.mode=this.mode,this.dispatchEvent(Fs)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ai),this.dispatchEvent(Bs),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Nt}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function vo(l){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:l.button};{const t=this.domElement.getBoundingClientRect();return{x:(l.clientX-t.left)/t.width*2-1,y:-(l.clientY-t.top)/t.height*2+1,button:l.button}}}function Co(l){if(this.enabled)switch(l.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(l));break}}function Fo(l){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(l)),this.pointerDown(this._getPointer(l)))}function Bo(l){this.enabled&&this.pointerMove(this._getPointer(l))}function Po(l){this.enabled&&(this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(l)))}function Ei(l,t,e){const i=t.intersectObject(l,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||e)return i[s];return!1}const Xe=new jt,D=new x(0,1,0),Ps=new x(0,0,0),Ts=new W,je=new tt,Ze=new tt,xt=new x,ks=new W,xe=new x(1,0,0),Ot=new x(0,1,0),ge=new x(0,0,1),Ye=new x,fe=new x,ye=new x;class To extends X{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;e.object!==void 0&&(e.object.updateMatrixWorld(),e.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class ko extends X{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new Me({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new _e({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const s=e.clone();s.opacity=.5;const n=t.clone();n.color.setHex(16711680);const r=t.clone();r.color.setHex(65280);const o=t.clone();o.color.setHex(255);const a=t.clone();a.color.setHex(16711680),a.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const c=t.clone();c.color.setHex(255),c.opacity=.5;const u=t.clone();u.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25,t.clone().color.setHex(16776960);const m=t.clone();m.color.setHex(7895160);const y=new J(0,.04,.1,12);y.translate(0,.05,0);const w=new Z(.08,.08,.08);w.translate(0,.04,0);const g=new nt;g.setAttribute("position",new L([0,0,0,1,0,0],3));const _=new J(.0075,.0075,.5,3);_.translate(0,.25,0);function b(R,G){const q=new Vt(R,.0075,3,64,G*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function f(){const R=new nt;return R.setAttribute("position",new L([0,0,0,1,1,1],3)),R}const z={X:[[new C(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new C(y,n),[-.5,0,0],[0,0,Math.PI/2]],[new C(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new C(y,r),[0,.5,0]],[new C(y,r),[0,-.5,0],[Math.PI,0,0]],[new C(_,r)]],Z:[[new C(y,o),[0,0,.5],[Math.PI/2,0,0]],[new C(y,o),[0,0,-.5],[-Math.PI/2,0,0]],[new C(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new C(new oe(.1,0),u.clone()),[0,0,0]]],XY:[[new C(new Z(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new C(new Z(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new C(new J(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new C(new J(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C(new J(.2,0,.6,4),i),[0,.3,0]],[new C(new J(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C(new J(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new C(new J(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new C(new oe(.2,0),i)]],XY:[[new C(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new C(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new C(new oe(.01,2),s),null,null,null,"helper"]],END:[[new C(new oe(.01,2),s),null,null,null,"helper"]],DELTA:[[new At(f(),s),null,null,null,"helper"]],X:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new At(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new At(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},E={XYZE:[[new C(b(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new C(b(.5,.5),n)]],Y:[[new C(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new C(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new C(b(.75,1),d),null,[0,Math.PI/2,0]]]},v={AXIS:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},F={XYZE:[[new C(new Di(.25,10,8),i)]],X:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new C(new Vt(.75,.1,2,24),i)]]},P={X:[[new C(w,n),[.5,0,0],[0,0,-Math.PI/2]],[new C(_,n),[0,0,0],[0,0,-Math.PI/2]],[new C(w,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new C(w,r),[0,.5,0]],[new C(_,r)],[new C(w,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new C(w,o),[0,0,.5],[Math.PI/2,0,0]],[new C(_,o),[0,0,0],[Math.PI/2,0,0]],[new C(w,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new C(new Z(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new C(new Z(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C(new Z(.1,.1,.1),u.clone())]]},B={X:[[new C(new J(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new C(new J(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C(new J(.2,0,.6,4),i),[0,.3,0]],[new C(new J(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C(new J(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new C(new J(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new C(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new C(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C(new Z(.2,.2,.2),i),[0,0,0]]]},T={X:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new At(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new At(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function k(R){const G=new X;for(const q in R)for(let it=R[q].length;it--;){const I=R[q][it][0].clone(),V=R[q][it][1],j=R[q][it][2],dt=R[q][it][3],Yt=R[q][it][4];I.name=q,I.tag=Yt,V&&I.position.set(V[0],V[1],V[2]),j&&I.rotation.set(j[0],j[1],j[2]),dt&&I.scale.set(dt[0],dt[1],dt[2]),I.updateMatrix();const ze=I.geometry.clone();ze.applyMatrix4(I.matrix),I.geometry=ze,I.renderOrder=1/0,I.position.set(0,0,0),I.rotation.set(0,0,0),I.scale.set(1,1,1),G.add(I)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=k(z)),this.add(this.gizmo.rotate=k(E)),this.add(this.gizmo.scale=k(P)),this.add(this.picker.translate=k(S)),this.add(this.picker.rotate=k(F)),this.add(this.picker.scale=k(B)),this.add(this.helper.translate=k(A)),this.add(this.helper.rotate=k(v)),this.add(this.helper.scale=k(T)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ze;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let n=0;n<s.length;n++){const r=s[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(O.setFromEuler(Xe.set(0,0,0)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(O.setFromEuler(Xe.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(O.setFromEuler(Xe.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(O.setFromEuler(Xe.set(0,Math.PI/2,0)),D.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Ts.lookAt(Ps,D,Ot)),r.quaternion.multiply(O),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),K.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),K.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(K),r.visible=this.dragging):(r.quaternion.copy(i),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(je.copy(i),D.copy(this.eye).applyQuaternion(O.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Ts.lookAt(this.eye,Ps,Ot)),r.name==="X"&&(O.setFromAxisAngle(xe,Math.atan2(-D.y,D.z)),O.multiplyQuaternions(je,O),r.quaternion.copy(O)),r.name==="Y"&&(O.setFromAxisAngle(Ot,Math.atan2(D.x,D.z)),O.multiplyQuaternions(je,O),r.quaternion.copy(O)),r.name==="Z"&&(O.setFromAxisAngle(ge,Math.atan2(D.y,D.x)),O.multiplyQuaternions(je,O),r.quaternion.copy(O))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(a){return r.name===a}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(t)}}class Io extends C{constructor(){super(new Ke(1e5,1e5,2,2),new Me({visible:!1,wireframe:!0,side:Rs,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),Ye.copy(xe).applyQuaternion(e==="local"?this.worldQuaternion:Ze),fe.copy(Ot).applyQuaternion(e==="local"?this.worldQuaternion:Ze),ye.copy(ge).applyQuaternion(e==="local"?this.worldQuaternion:Ze),D.copy(fe),this.mode){case"translate":case"scale":switch(this.axis){case"X":D.copy(this.eye).cross(Ye),xt.copy(Ye).cross(D);break;case"Y":D.copy(this.eye).cross(fe),xt.copy(fe).cross(D);break;case"Z":D.copy(this.eye).cross(ye),xt.copy(ye).cross(D);break;case"XY":xt.copy(ye);break;case"YZ":xt.copy(Ye);break;case"XZ":D.copy(ye),xt.copy(fe);break;case"XYZ":case"E":xt.set(0,0,0);break}break;case"rotate":default:xt.set(0,0,0)}xt.length()===0?this.quaternion.copy(this.cameraQuaternion):(ks.lookAt(K.set(0,0,0),xt,D),this.quaternion.setFromRotationMatrix(ks)),super.updateMatrixWorld(t)}}function nn(l){const t=M.shallowReactive(l);return t.type==="group"&&(t.children=M.shallowReactive(t.children.map(e=>nn(e)))),t}const rn=Je.defineStore("datasets",()=>{const l=le(),t=M.shallowReactive(sn(l.datasets).map(S=>nn(S))),e=M.computed(()=>t.map(S=>S.leafs()).flat()),i=M.computed(()=>e.value.length),s=new Map,n=new Map,r=M.ref([]);function o(S){r.value=[...r.value,{...S,mustBePreloaded:S.mustBePreloaded??!1,mustBeVisible:S.mustBeVisible??!1}]}function a(){return t}function h(){return e.value}function c(S){const A=M.shallowReactive(S);return t.push(A),A}function u(S,A){s.set(S.uuid,A)}function d(S,A){n.set(S.uuid,A)}function p(S){const A=S.parent!=null?S.parent.children:t;A.splice(A.indexOf(S),1)}function m(S){const A=new gt;return S.traverse(E=>{var T;const v=s.get(E.uuid),F=v==null?void 0:v.getBoundingBox();if(F&&!F.isEmpty()){A.union(F);return}const P=n.get(E.uuid),B=(T=P==null?void 0:P.getExtent())==null?void 0:T.as(l.default_crs);if(B&&B.isValid()){const k=B.toBox3(0,0);A.union(k);return}}),A}function y(S){return s.get(S.uuid)}function w(S){return n.get(S.uuid)}function g(S){}function _(S,A){}function b(S){}function f(S){}function z(S,A){return r.value.filter(v=>!(v.predicate!=null&&!v.predicate(S)||v.mustBeVisible&&!A.isVisible||v.mustBePreloaded&&!A.isPreloaded))}return{add:c,attachEntity:u,attachLayer:d,count:i,getBoundingBox:m,getCustomActions:z,getDatasets:h,getEntity:y,getLayer:w,getTree:a,importFromFile:g,registerCustomAction:o,remove:p,setVisible:_,toggleGrid:b,toggleMask:f}}),Ro=new Me({color:"yellow",opacity:.1,transparent:!0});class Do{constructor(t){N(this,"_cameraStore",Oi());N(this,"_clippingBox",null);N(this,"_clippingBoxHelper",null);N(this,"_clippingBoxMesh",null);N(this,"_datasetStore",rn());N(this,"_previousTransformControls",this._cameraStore.getNavigationMode());N(this,"_store",Vi());N(this,"_transformControls",null);N(this,"_volumeHelpers",new js);this.context=t,t.events.addEventListener("ready",this.initialize.bind(this))}clipToDataset(t){const e=this._datasetStore.getBoundingBox(t);e!=null&&e.isEmpty()||this.setClippingBox(e)}dispose(){this.context.view.getInstance().scene.remove(this._volumeHelpers),this.disposeClippingBox()}isClippingBoxEnabled(){return this._store.enable}setClippingBox(t){t.isEmpty()||(this._store.setClippingBox(t),this._store.setEnabled(!0))}applyClippingPlanes(){const t=this._store.enable?this.getPlanesFromBoxSides():[];for(const e of this._datasetStore.getDatasets()){const i=this._datasetStore.getEntity(e);i&&(i.clippingPlanes=t,i.traverseMaterials(s=>{s.clipIntersection=this._store.invert}),this.context.view.getInstance().notifyChange(i))}}createClippingBox(t,e){this._clippingBox=new gt,this._clippingBox.setFromCenterAndSize(t,e);const i=this.context.view.getInstance();if(this._store.displayHelper){const s=new Z(e.x,e.y,e.z);this._clippingBoxMesh=new C(s,Ro),this._clippingBoxHelper=new br(this._clippingBox,new ht("yellow")),this._clippingBoxMesh.renderOrder=2,this._clippingBoxMesh.position.copy(t),this._clippingBoxMesh.updateMatrixWorld(),this._clippingBoxHelper.updateMatrixWorld(),this._transformControls=new Eo(i.view.camera,i.domElement),this._transformControls.addEventListener("change",()=>{this._cameraStore.getNavigationMode()!=="disabled"||this._clippingBoxMesh===null||(this._store.center.copy(this._clippingBoxMesh.position),this.moveClippingBox())}),this._transformControls.addEventListener("dragging-changed",n=>{n.value!=null?(this._previousTransformControls=this._cameraStore.getNavigationMode(),this._cameraStore.setNavigationMode("disabled"),this._cameraStore.setIsUserInteracting(!0)):(this._cameraStore.setNavigationMode(this._previousTransformControls),setTimeout(()=>this._cameraStore.setIsUserInteracting(!1),0))}),this._volumeHelpers.add(this._clippingBoxHelper),this._volumeHelpers.add(this._clippingBoxMesh),this._transformControls.attach(this._clippingBoxMesh),this._transformControls.getHelper().updateMatrixWorld(),i.scene.add(this._transformControls.getHelper()),i.notifyChange()}}disposeClippingBox(){var t,e,i,s,n,r,o,a;(t=this._transformControls)==null||t.detach(),(e=this._transformControls)==null||e.getHelper().removeFromParent(),(i=this._transformControls)==null||i.dispose(),(n=(s=this._clippingBoxMesh)==null?void 0:s.geometry)==null||n.dispose(),(r=this._clippingBoxMesh)==null||r.removeFromParent(),(o=this._clippingBoxHelper)==null||o.removeFromParent(),(a=this._clippingBoxHelper)==null||a.dispose(),this.context.view.getInstance().notifyChange()}getPlanesFromBoxSides(){if(this._clippingBox===null)throw new Error("No clippingBox defined");const t=[];return t.push(new at(new x(0,0,1),-this._clippingBox.min.z)),t.push(new at(new x(0,0,-1),+this._clippingBox.max.z)),t.push(new at(new x(1,0,0),-this._clippingBox.min.x)),t.push(new at(new x(-1,0,0),+this._clippingBox.max.x)),t.push(new at(new x(0,1,0),-this._clippingBox.min.y)),t.push(new at(new x(0,-1,0),+this._clippingBox.max.y)),this._store.invert&&t.forEach(e=>e.negate()),t}initialize(){this.context.view.getInstance().scene.add(this._volumeHelpers),this._clippingBox=null,this._clippingBoxHelper=null,this._clippingBoxMesh=null,this._transformControls=null,this._previousTransformControls=this._cameraStore.getNavigationMode(),this._store.$onAction(({after:e,name:i})=>{e(()=>{switch(i){case"setCenter":this.moveClippingBox();break;case"setClippingBox":case"setDisplayHelper":case"setEnabled":case"setSize":this.updateClippingBox();break;case"setInverted":this.applyClippingPlanes();break}})}),this._datasetStore.$onAction(({after:e,name:i})=>{e(()=>{switch(i){case"attachEntity":this.applyClippingPlanes();break}})})}moveClippingBox(){var e,i,s,n,r;const t=this.context.view.getInstance();this._store.enable&&(this._clippingBox===null&&this.createClippingBox(this._store.center,this._store.size),(e=this._clippingBox)==null||e.setFromCenterAndSize(this._store.center,this._store.size),this._store.displayHelper&&((i=this._clippingBoxMesh)==null||i.position.copy(this._store.center),(s=this._clippingBoxMesh)==null||s.updateMatrixWorld(),(n=this._clippingBoxHelper)==null||n.updateMatrixWorld(),(r=this._transformControls)==null||r.getHelper().updateMatrixWorld(),t.notifyChange(this._volumeHelpers),t.notifyChange(this._transformControls))),this.applyClippingPlanes()}updateClippingBox(){this.disposeClippingBox(),this._store.enable&&this.createClippingBox(this._store.center,this._store.size),this.applyClippingPlanes()}}const on="builtin-clipping-box-analysis";class Lo{constructor(){N(this,"id",on);N(this,"name","Clipping box");N(this,"_manager",null);N(this,"_store",null)}getClippingBox(){if(this._store==null)throw new Error("module is not initialized");return this._store.clippingBox}initialize(t){t.analysis.registerTool({component:Ao,icon:"bi-bounding-box",name:"Clipping box"}),this._store=Vi();const e=new Do(t);t.datasets.registerDatasetAction({action:i=>e.clipToDataset(i),icon:"bi-bounding-box",mustBePreloaded:!0,title:"Clip to"}),this._manager=e}isClippingBoxEnabled(){if(this._store==null)throw new Error("module is not initialized");return this._store.enable}isClippingBoxInverted(){if(this._store==null)throw new Error("module is not initialized");return this._store.invert}setClippingBox(t){if(this._manager==null)throw new Error("module is not initialized");this._manager.setClippingBox(t)}}const No=Je.defineStore("modules",()=>{const l=M.shallowRef([]);function t(s){l.value=s}function e(){return l.value}function i(s){for(const n of l.value)if(n.id===s)return n;return null}return{getLoadedModules:e,getModule:i,setLoadedModules:t}}),Oo={class:"form-check form-switch"},Vo=["checked"],Wo=M.defineComponent({__name:"SwitchToggle",props:["modelValue"],emits:["update:modelValue"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("div",Oo,[M.createElementVNode("input",{class:"form-check-input",type:"checkbox",role:"switch",checked:l.modelValue,onInput:e[0]||(e[0]=i=>t.$emit("update:modelValue",i.target.checked))},null,40,Vo),M.renderSlot(t.$slots,"default")]))}}),Ho=["title"],qo=["title"],an=M.defineComponent({__name:"Icon",props:{icon:{},title:{}},setup(l){return(t,e)=>t.icon.startsWith("bi-")?(M.openBlock(),M.createElementBlock("i",{key:0,class:M.normalizeClass(["bi",t.icon]),title:t.title},null,10,Ho)):(M.openBlock(),M.createElementBlock("i",{key:1,class:M.normalizeClass(t.icon),title:t.title},null,10,qo))}}),Uo=["title"],hn=M.defineComponent({__name:"ButtonWithIcon",props:{icon:{},text:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("button",{title:t.title,class:"btn",type:"button",onClick:e[0]||(e[0]=i=>t.$emit("click",i))},[t.icon?(M.openBlock(),M.createBlock(an,{key:0,icon:t.icon},null,8,["icon"])):M.createCommentVNode("",!0),M.createTextVNode(" "+M.toDisplayString(t.text),1)],8,Uo))}}),Xo={},jo={class:"icons text-nowrap d-flex justify-content-evenly"};function Yo(l,t){return M.openBlock(),M.createElementBlock("div",jo,[M.renderSlot(l.$slots,"default")])}const Zo=ii(Xo,[["render",Yo]]),Go=M.defineComponent({__name:"IconListButton",props:{icon:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createBlock(hn,{title:t.title,icon:t.icon,onClick:e[0]||(e[0]=i=>t.$emit("click",i)),class:"btn-link link-secondary link-opacity-75 link-opacity-100-hover p-0 border-0"},null,8,["title","icon"]))}}),$o=ii(Go,[["__scopeId","data-v-10315937"]]),Qo=["title","disabled"],Jo=M.defineComponent({__name:"ListLabelButton",props:{disabled:{type:Boolean},text:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("button",{class:M.normalizeClass(["btn btn-link d-inline-block flex-fill text-start text-nowrap text-truncate overflow-hidden px-1 py-0 link-underline link-underline-opacity-0 link-underline-opacity-75-hover",t.$attrs.class]),title:t.title??t.text,disabled:!!t.disabled,type:"button",onClick:e[0]||(e[0]=i=>t.$emit("click",i))},M.toDisplayString(t.text),11,Qo))}});function Ko(l,t){const e=M.ref(l[t]);return M.watch(()=>l[t],i=>{e.value=i}),e}exports.AmbientLight=yr;exports.Box3=gt;exports.BufferGeometry=nt;exports.ClippingBoxAnalysis=Lo;exports.Clock=xr;exports.Color=ht;exports.Datagroup=Ni;exports.Dataset=en;exports.DirectionalLight=fr;exports.DoubleSide=Rs;exports.Download=Ks;exports.EventDispatcher=Ut;exports.Fetcher=Gs;exports.FileLoader=dr;exports.Float32BufferAttribute=L;exports.FrontSide=Ge;exports.GridHelper=wr;exports.Group=js;exports.IconList=Zo;exports.IconListButton=$o;exports.LineBasicMaterial=_e;exports.LineSegments=Ii;exports.Loader=Li;exports.MathUtils=qs;exports.Matrix4=W;exports.Mesh=C;exports.MeshBasicMaterial=Me;exports.MeshLambertMaterial=hr;exports.Object3D=X;exports.Plane=at;exports.PlaneGeometry=Ke;exports.Quaternion=tt;exports.Raycaster=Zs;exports.SRGBColorSpace=ut;exports.Sphere=be;exports.Spherical=gr;exports.Vector2=U;exports.Vector3=x;exports.Vector4=Xt;exports._export_sfc=ii;exports._sfc_main=Wo;exports._sfc_main$1=hn;exports._sfc_main$2=an;exports._sfc_main$3=Jo;exports.fillObject3DUserData=Or;exports.getColorMap=Rr;exports.getConfig=le;exports.getCoordinates=Dr;exports.getDynamicStyles=Cr;exports.getExtent=Lr;exports.getPublicFolderUrl=ei;exports.hasExperimentalFeature=Nr;exports.isColor=Wr;exports.isLink=Vr;exports.isObject=Se;exports.isVector3=Hr;exports.loadRemoteConfiguration=Fr;exports.moduleId=on;exports.refAndWatch=Ko;exports.setConfiguration=Br;exports.setDynamicStyles=Pr;exports.useCameraStore=Oi;exports.useDatasetStore=rn;exports.useModuleStore=No;
5
+ */const ks="170",Ze=0,xn=1,Is=2,Hi=1,qi=100,Ui=204,Xi=205,ji=3,Rs=0,Ds=300,Yi=1e3,ze=1001,Zi=1002,gn=1006,wn=1008,bn=1009,Mn=1015,_n=1023,Sn=0,Ls="",ut="srgb",Ns="srgb-linear",Os="linear",vi="srgb",Zt=7680,Gi=519,$i=35044,Wt=2e3,Ci=2001;class Ut{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,t);t.target=null}}}const $=["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 Qi=1234567;const Vs=Math.PI/180,Ws=180/Math.PI;function he(){const l=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return($[l&255]+$[l>>8&255]+$[l>>16&255]+$[l>>24&255]+"-"+$[t&255]+$[t>>8&255]+"-"+$[t>>16&15|64]+$[t>>24&255]+"-"+$[e&63|128]+$[e>>8&255]+"-"+$[e>>16&255]+$[e>>24&255]+$[i&255]+$[i>>8&255]+$[i>>16&255]+$[i>>24&255]).toLowerCase()}function et(l,t,e){return Math.max(t,Math.min(e,l))}function Pi(l,t){return(l%t+t)%t}function zn(l,t,e,i,s){return i+(l-t)*(s-i)/(e-t)}function An(l,t,e){return l!==t?(e-l)/(t-l):0}function we(l,t,e){return(1-e)*l+e*t}function En(l,t,e,i){return we(l,t,1-Math.exp(-e*i))}function vn(l,t=1){return t-Math.abs(Pi(l,t*2)-t)}function Cn(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*(3-2*l))}function Fn(l,t,e){return l<=t?0:l>=e?1:(l=(l-t)/(e-t),l*l*l*(l*(l*6-15)+10))}function Bn(l,t){return l+Math.floor(Math.random()*(t-l+1))}function Pn(l,t){return l+Math.random()*(t-l)}function Tn(l){return l*(.5-Math.random())}function kn(l){l!==void 0&&(Qi=l);let t=Qi+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function In(l){return l*Vs}function Rn(l){return l*Ws}function Dn(l){return(l&l-1)===0&&l!==0}function Ln(l){return Math.pow(2,Math.ceil(Math.log(l)/Math.LN2))}function Nn(l){return Math.pow(2,Math.floor(Math.log(l)/Math.LN2))}function On(l,t,e,i,s){const n=Math.cos,r=Math.sin,o=n(e/2),a=r(e/2),h=n((t+i)/2),c=r((t+i)/2),u=n((t-i)/2),d=r((t-i)/2),p=n((i-t)/2),m=r((i-t)/2);switch(s){case"XYX":l.set(o*c,a*u,a*d,o*h);break;case"YZY":l.set(a*d,o*c,a*u,o*h);break;case"ZXZ":l.set(a*u,a*d,o*c,o*h);break;case"XZX":l.set(o*c,a*m,a*p,o*h);break;case"YXY":l.set(a*p,o*c,a*m,o*h);break;case"ZYZ":l.set(a*m,a*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function re(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return l/4294967295;case Uint16Array:return l/65535;case Uint8Array:return l/255;case Int32Array:return Math.max(l/2147483647,-1);case Int16Array:return Math.max(l/32767,-1);case Int8Array:return Math.max(l/127,-1);default:throw new Error("Invalid component type.")}}function st(l,t){switch(t.constructor){case Float32Array:return l;case Uint32Array:return Math.round(l*4294967295);case Uint16Array:return Math.round(l*65535);case Uint8Array:return Math.round(l*255);case Int32Array:return Math.round(l*2147483647);case Int16Array:return Math.round(l*32767);case Int8Array:return Math.round(l*127);default:throw new Error("Invalid component type.")}}const Hs={DEG2RAD:Vs,RAD2DEG:Ws,generateUUID:he,clamp:et,euclideanModulo:Pi,mapLinear:zn,inverseLerp:An,lerp:we,damp:En,pingpong:vn,smoothstep:Cn,smootherstep:Fn,randInt:Bn,randFloat:Pn,randFloatSpread:Tn,seededRandom:kn,degToRad:In,radToDeg:Rn,isPowerOfTwo:Dn,ceilPowerOfTwo:Ln,floorPowerOfTwo:Nn,setQuaternionFromProperEuler:On,normalize:st,denormalize:re};class U{constructor(t=0,e=0){U.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(et(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),s=Math.sin(e),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*s+t.x,this.y=n*s+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class vt{constructor(t,e,i,s,n,r,o,a,h){vt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,o,a,h)}set(t,e,i,s,n,r,o,a,h){const c=this.elements;return c[0]=t,c[1]=s,c[2]=o,c[3]=e,c[4]=n,c[5]=a,c[6]=i,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],o=i[3],a=i[6],h=i[1],c=i[4],u=i[7],d=i[2],p=i[5],m=i[8],y=s[0],w=s[3],g=s[6],_=s[1],b=s[4],f=s[7],z=s[2],S=s[5],A=s[8];return n[0]=r*y+o*_+a*z,n[3]=r*w+o*b+a*S,n[6]=r*g+o*f+a*A,n[1]=h*y+c*_+u*z,n[4]=h*w+c*b+u*S,n[7]=h*g+c*f+u*A,n[2]=d*y+p*_+m*z,n[5]=d*w+p*b+m*S,n[8]=d*g+p*f+m*A,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return e*r*c-e*o*h-i*n*c+i*o*a+s*n*h-s*r*a}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],u=c*r-o*h,d=o*a-c*n,p=h*n-r*a,m=e*u+i*d+s*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=u*y,t[1]=(s*h-c*i)*y,t[2]=(o*i-s*r)*y,t[3]=d*y,t[4]=(c*e-s*a)*y,t[5]=(s*n-o*e)*y,t[6]=p*y,t[7]=(i*a-h*e)*y,t[8]=(r*e-i*n)*y,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,n,r,o){const a=Math.cos(n),h=Math.sin(n);return this.set(i*a,i*h,-i*(a*r+h*o)+r+t,-s*h,s*a,-s*(-h*r+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(si.makeScale(t,e)),this}rotate(t){return this.premultiply(si.makeRotation(-t)),this}translate(t,e){return this.premultiply(si.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<9;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const si=new vt;function Vn(l){for(let t=l.length-1;t>=0;--t)if(l[t]>=65535)return!0;return!1}function Ji(l){return document.createElementNS("http://www.w3.org/1999/xhtml",l)}const ct={enabled:!0,workingColorSpace:Ns,spaces:{},convert:function(l,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===vi&&(l.r=Et(l.r),l.g=Et(l.g),l.b=Et(l.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(l.applyMatrix3(this.spaces[t].toXYZ),l.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===vi&&(l.r=ae(l.r),l.g=ae(l.g),l.b=ae(l.b))),l},fromWorkingColorSpace:function(l,t){return this.convert(l,this.workingColorSpace,t)},toWorkingColorSpace:function(l,t){return this.convert(l,t,this.workingColorSpace)},getPrimaries:function(l){return this.spaces[l].primaries},getTransfer:function(l){return l===Ls?Os:this.spaces[l].transfer},getLuminanceCoefficients:function(l,t=this.workingColorSpace){return l.fromArray(this.spaces[t].luminanceCoefficients)},define:function(l){Object.assign(this.spaces,l)},_getMatrix:function(l,t,e){return l.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(l){return this.spaces[l].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(l=this.workingColorSpace){return this.spaces[l].workingColorSpaceConfig.unpackColorSpace}};function Et(l){return l<.04045?l*.0773993808:Math.pow(l*.9478672986+.0521327014,2.4)}function ae(l){return l<.0031308?l*12.92:1.055*Math.pow(l,.41666)-.055}const Ki=[.64,.33,.3,.6,.15,.06],ts=[.2126,.7152,.0722],es=[.3127,.329],is=new vt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ss=new vt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);ct.define({[Ns]:{primaries:Ki,whitePoint:es,transfer:Os,toXYZ:is,fromXYZ:ss,luminanceCoefficients:ts,workingColorSpaceConfig:{unpackColorSpace:ut},outputColorSpaceConfig:{drawingBufferColorSpace:ut}},[ut]:{primaries:Ki,whitePoint:es,transfer:vi,toXYZ:is,fromXYZ:ss,luminanceCoefficients:ts,outputColorSpaceConfig:{drawingBufferColorSpace:ut}}});let Gt;class Wn{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Gt===void 0&&(Gt=Ji("canvas")),Gt.width=t.width,Gt.height=t.height;const i=Gt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=Gt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Ji("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const s=i.getImageData(0,0,t.width,t.height),n=s.data;for(let r=0;r<n.length;r++)n[r]=Et(n[r]/255)*255;return i.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(Et(e[i]/255)*255):e[i]=Et(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Hn=0;class qn{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Hn++}),this.uuid=he(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let r=0,o=s.length;r<o;r++)s[r].isDataTexture?n.push(ni(s[r].image)):n.push(ni(s[r]))}else n=ni(s);i.url=n}return e||(t.images[this.uuid]=i),i}}function ni(l){return typeof HTMLImageElement<"u"&&l instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&l instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&l instanceof ImageBitmap?Wn.getDataURL(l):l.data?{data:Array.from(l.data),width:l.width,height:l.height,type:l.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Un=0;class Ht extends Ut{constructor(t=Ht.DEFAULT_IMAGE,e=Ht.DEFAULT_MAPPING,i=ze,s=ze,n=gn,r=wn,o=_n,a=bn,h=Ht.DEFAULT_ANISOTROPY,c=Ls){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Un++}),this.uuid=he(),this.name="",this.source=new qn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=r,this.anisotropy=h,this.format=o,this.internalFormat=null,this.type=a,this.offset=new U(0,0),this.repeat=new U(1,1),this.center=new U(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Ds)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Yi:t.x=t.x-Math.floor(t.x);break;case ze:t.x=t.x<0?0:1;break;case Zi:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Yi:t.y=t.y-Math.floor(t.y);break;case ze:t.y=t.y<0?0:1;break;case Zi:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Ht.DEFAULT_IMAGE=null;Ht.DEFAULT_MAPPING=Ds;Ht.DEFAULT_ANISOTROPY=1;class Xt{constructor(t=0,e=0,i=0,s=1){Xt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s+r[12]*n,this.y=r[1]*e+r[5]*i+r[9]*s+r[13]*n,this.z=r[2]*e+r[6]*i+r[10]*s+r[14]*n,this.w=r[3]*e+r[7]*i+r[11]*s+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,n;const a=t.elements,h=a[0],c=a[4],u=a[8],d=a[1],p=a[5],m=a[9],y=a[2],w=a[6],g=a[10];if(Math.abs(c-d)<.01&&Math.abs(u-y)<.01&&Math.abs(m-w)<.01){if(Math.abs(c+d)<.1&&Math.abs(u+y)<.1&&Math.abs(m+w)<.1&&Math.abs(h+p+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const b=(h+1)/2,f=(p+1)/2,z=(g+1)/2,S=(c+d)/4,A=(u+y)/4,E=(m+w)/4;return b>f&&b>z?b<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(b),s=S/i,n=A/i):f>z?f<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(f),i=S/s,n=E/s):z<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(z),i=A/n,s=E/n),this.set(i,s,n,e),this}let _=Math.sqrt((w-m)*(w-m)+(u-y)*(u-y)+(d-c)*(d-c));return Math.abs(_)<.001&&(_=1),this.x=(w-m)/_,this.y=(u-y)/_,this.z=(d-c)/_,this.w=Math.acos((h+p+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tt{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,n,r,o){let a=i[s+0],h=i[s+1],c=i[s+2],u=i[s+3];const d=n[r+0],p=n[r+1],m=n[r+2],y=n[r+3];if(o===0){t[e+0]=a,t[e+1]=h,t[e+2]=c,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=m,t[e+3]=y;return}if(u!==y||a!==d||h!==p||c!==m){let w=1-o;const g=a*d+h*p+c*m+u*y,_=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){const z=Math.sqrt(b),S=Math.atan2(z,g*_);w=Math.sin(w*S)/z,o=Math.sin(o*S)/z}const f=o*_;if(a=a*w+d*f,h=h*w+p*f,c=c*w+m*f,u=u*w+y*f,w===1-o){const z=1/Math.sqrt(a*a+h*h+c*c+u*u);a*=z,h*=z,c*=z,u*=z}}t[e]=a,t[e+1]=h,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,n,r){const o=i[s],a=i[s+1],h=i[s+2],c=i[s+3],u=n[r],d=n[r+1],p=n[r+2],m=n[r+3];return t[e]=o*m+c*u+a*p-h*d,t[e+1]=a*m+c*d+h*u-o*p,t[e+2]=h*m+c*p+o*d-a*u,t[e+3]=c*m-o*u-a*d-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,o=Math.cos,a=Math.sin,h=o(i/2),c=o(s/2),u=o(n/2),d=a(i/2),p=a(s/2),m=a(n/2);switch(r){case"XYZ":this._x=d*c*u+h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u-d*p*m;break;case"YXZ":this._x=d*c*u+h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u+d*p*m;break;case"ZXY":this._x=d*c*u-h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u-d*p*m;break;case"ZYX":this._x=d*c*u-h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u+d*p*m;break;case"YZX":this._x=d*c*u+h*p*m,this._y=h*p*u+d*c*m,this._z=h*c*m-d*p*u,this._w=h*c*u-d*p*m;break;case"XZY":this._x=d*c*u-h*p*m,this._y=h*p*u-d*c*m,this._z=h*c*m+d*p*u,this._w=h*c*u+d*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],n=e[8],r=e[1],o=e[5],a=e[9],h=e[2],c=e[6],u=e[10],d=i+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(c-a)*p,this._y=(n-h)*p,this._z=(r-s)*p}else if(i>o&&i>u){const p=2*Math.sqrt(1+i-o-u);this._w=(c-a)/p,this._x=.25*p,this._y=(s+r)/p,this._z=(n+h)/p}else if(o>u){const p=2*Math.sqrt(1+o-i-u);this._w=(n-h)/p,this._x=(s+r)/p,this._y=.25*p,this._z=(a+c)/p}else{const p=2*Math.sqrt(1+u-i-o);this._w=(r-s)/p,this._x=(n+h)/p,this._y=(a+c)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(et(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,o=e._x,a=e._y,h=e._z,c=e._w;return this._x=i*c+r*o+s*h-n*a,this._y=s*c+r*a+n*o-i*h,this._z=n*c+r*h+i*a-s*o,this._w=r*c-i*o-s*a-n*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let o=r*t._w+i*t._x+s*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=i,this._y=s,this._z=n,this;const a=1-o*o;if(a<=Number.EPSILON){const p=1-e;return this._w=p*r+e*this._w,this._x=p*i+e*this._x,this._y=p*s+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const h=Math.sqrt(a),c=Math.atan2(h,o),u=Math.sin((1-e)*c)/h,d=Math.sin(e*c)/h;return this._w=r*u+this._w*d,this._x=i*u+this._x*d,this._y=s*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class x{constructor(t=0,e=0,i=0){x.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ns.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ns.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,o=t.z,a=t.w,h=2*(r*s-o*i),c=2*(o*e-n*s),u=2*(n*i-r*e);return this.x=e+a*h+r*u-o*c,this.y=i+a*c+o*h-n*u,this.z=s+a*u+n*c-r*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s,this.y=n[1]*e+n[5]*i+n[9]*s,this.z=n[2]*e+n[6]*i+n[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,s=t.y,n=t.z,r=e.x,o=e.y,a=e.z;return this.x=s*a-n*o,this.y=n*r-i*a,this.z=i*o-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return ri.copy(this).projectOnVector(t),this.sub(ri)}reflect(t){return this.sub(ri.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(et(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ri=new x,ns=new tt;class gt{constructor(t=new x(1/0,1/0,1/0),e=new x(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(pt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(pt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=pt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const n=i.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=n.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,pt):pt.fromBufferAttribute(n,r),pt.applyMatrix4(t.matrixWorld),this.expandByPoint(pt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ae.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ae.copy(i.boundingBox)),Ae.applyMatrix4(t.matrixWorld),this.union(Ae)}const s=t.children;for(let n=0,r=s.length;n<r;n++)this.expandByObject(s[n],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,pt),pt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ce),Ee.subVectors(this.max,ce),$t.subVectors(t.a,ce),Qt.subVectors(t.b,ce),Jt.subVectors(t.c,ce),Ct.subVectors(Qt,$t),Ft.subVectors(Jt,Qt),It.subVectors($t,Jt);let e=[0,-Ct.z,Ct.y,0,-Ft.z,Ft.y,0,-It.z,It.y,Ct.z,0,-Ct.x,Ft.z,0,-Ft.x,It.z,0,-It.x,-Ct.y,Ct.x,0,-Ft.y,Ft.x,0,-It.y,It.x,0];return!oi(e,$t,Qt,Jt,Ee)||(e=[1,0,0,0,1,0,0,0,1],!oi(e,$t,Qt,Jt,Ee))?!1:(ve.crossVectors(Ct,Ft),e=[ve.x,ve.y,ve.z],oi(e,$t,Qt,Jt,Ee))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,pt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(pt).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(wt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),wt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),wt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),wt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),wt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),wt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),wt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),wt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(wt),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const wt=[new x,new x,new x,new x,new x,new x,new x,new x],pt=new x,Ae=new gt,$t=new x,Qt=new x,Jt=new x,Ct=new x,Ft=new x,It=new x,ce=new x,Ee=new x,ve=new x,Rt=new x;function oi(l,t,e,i,s){for(let n=0,r=l.length-3;n<=r;n+=3){Rt.fromArray(l,n);const o=s.x*Math.abs(Rt.x)+s.y*Math.abs(Rt.y)+s.z*Math.abs(Rt.z),a=t.dot(Rt),h=e.dot(Rt),c=i.dot(Rt);if(Math.max(-Math.max(a,h,c),Math.min(a,h,c))>o)return!1}return!0}const Xn=new gt,ue=new x,ai=new x;class be{constructor(t=new x,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):Xn.setFromPoints(t).getCenter(i);let s=0;for(let n=0,r=t.length;n<r;n++)s=Math.max(s,i.distanceToSquared(t[n]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ue.subVectors(t,this.center);const e=ue.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(ue,s/i),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ai.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ue.copy(t.center).add(ai)),this.expandByPoint(ue.copy(t.center).sub(ai))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const bt=new x,hi=new x,Ce=new x,Bt=new x,li=new x,Fe=new x,ci=new x;class Ti{constructor(t=new x,e=new x(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,bt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=bt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(bt.copy(this.origin).addScaledVector(this.direction,e),bt.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){hi.copy(t).add(e).multiplyScalar(.5),Ce.copy(e).sub(t).normalize(),Bt.copy(this.origin).sub(hi);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Ce),o=Bt.dot(this.direction),a=-Bt.dot(Ce),h=Bt.lengthSq(),c=Math.abs(1-r*r);let u,d,p,m;if(c>0)if(u=r*a-o,d=r*o-a,m=n*c,u>=0)if(d>=-m)if(d<=m){const y=1/c;u*=y,d*=y,p=u*(u+r*d+2*o)+d*(r*u+d+2*a)+h}else d=n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;else d=-n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;else d<=-m?(u=Math.max(0,-(-r*n+o)),d=u>0?-n:Math.min(Math.max(-n,-a),n),p=-u*u+d*(d+2*a)+h):d<=m?(u=0,d=Math.min(Math.max(-n,-a),n),p=d*(d+2*a)+h):(u=Math.max(0,-(r*n+o)),d=u>0?n:Math.min(Math.max(-n,-a),n),p=-u*u+d*(d+2*a)+h);else d=r>0?-n:n,u=Math.max(0,-(r*d+o)),p=-u*u+d*(d+2*a)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(hi).addScaledVector(Ce,d),p}intersectSphere(t,e){bt.subVectors(t.center,this.origin);const i=bt.dot(this.direction),s=bt.dot(bt)-i*i,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),o=i-r,a=i+r;return a<0?null:o<0?this.at(a,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,n,r,o,a;const h=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,s=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,s=(t.min.x-d.x)*h),c>=0?(n=(t.min.y-d.y)*c,r=(t.max.y-d.y)*c):(n=(t.max.y-d.y)*c,r=(t.min.y-d.y)*c),i>r||n>s||((n>i||isNaN(i))&&(i=n),(r<s||isNaN(s))&&(s=r),u>=0?(o=(t.min.z-d.z)*u,a=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,a=(t.min.z-d.z)*u),i>a||o>s)||((o>i||i!==i)&&(i=o),(a<s||s!==s)&&(s=a),s<0)?null:this.at(i>=0?i:s,e)}intersectsBox(t){return this.intersectBox(t,bt)!==null}intersectTriangle(t,e,i,s,n){li.subVectors(e,t),Fe.subVectors(i,t),ci.crossVectors(li,Fe);let r=this.direction.dot(ci),o;if(r>0){if(s)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Bt.subVectors(this.origin,t);const a=o*this.direction.dot(Fe.crossVectors(Bt,Fe));if(a<0)return null;const h=o*this.direction.dot(li.cross(Bt));if(h<0||a+h>r)return null;const c=-o*Bt.dot(ci);return c<0?null:this.at(c/r,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class W{constructor(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w){W.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w)}set(t,e,i,s,n,r,o,a,h,c,u,d,p,m,y,w){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=n,g[5]=r,g[9]=o,g[13]=a,g[2]=h,g[6]=c,g[10]=u,g[14]=d,g[3]=p,g[7]=m,g[11]=y,g[15]=w,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new W().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,s=1/Kt.setFromMatrixColumn(t,0).length(),n=1/Kt.setFromMatrixColumn(t,1).length(),r=1/Kt.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),h=Math.sin(s),c=Math.cos(n),u=Math.sin(n);if(t.order==="XYZ"){const d=r*c,p=r*u,m=o*c,y=o*u;e[0]=a*c,e[4]=-a*u,e[8]=h,e[1]=p+m*h,e[5]=d-y*h,e[9]=-o*a,e[2]=y-d*h,e[6]=m+p*h,e[10]=r*a}else if(t.order==="YXZ"){const d=a*c,p=a*u,m=h*c,y=h*u;e[0]=d+y*o,e[4]=m*o-p,e[8]=r*h,e[1]=r*u,e[5]=r*c,e[9]=-o,e[2]=p*o-m,e[6]=y+d*o,e[10]=r*a}else if(t.order==="ZXY"){const d=a*c,p=a*u,m=h*c,y=h*u;e[0]=d-y*o,e[4]=-r*u,e[8]=m+p*o,e[1]=p+m*o,e[5]=r*c,e[9]=y-d*o,e[2]=-r*h,e[6]=o,e[10]=r*a}else if(t.order==="ZYX"){const d=r*c,p=r*u,m=o*c,y=o*u;e[0]=a*c,e[4]=m*h-p,e[8]=d*h+y,e[1]=a*u,e[5]=y*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*a,e[10]=r*a}else if(t.order==="YZX"){const d=r*a,p=r*h,m=o*a,y=o*h;e[0]=a*c,e[4]=y-d*u,e[8]=m*u+p,e[1]=u,e[5]=r*c,e[9]=-o*c,e[2]=-h*c,e[6]=p*u+m,e[10]=d-y*u}else if(t.order==="XZY"){const d=r*a,p=r*h,m=o*a,y=o*h;e[0]=a*c,e[4]=-u,e[8]=h*c,e[1]=d*u+y,e[5]=r*c,e[9]=p*u-m,e[2]=m*u-p,e[6]=o*c,e[10]=y*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(jn,t,Yn)}lookAt(t,e,i){const s=this.elements;return rt.subVectors(t,e),rt.lengthSq()===0&&(rt.z=1),rt.normalize(),Pt.crossVectors(i,rt),Pt.lengthSq()===0&&(Math.abs(i.z)===1?rt.x+=1e-4:rt.z+=1e-4,rt.normalize(),Pt.crossVectors(i,rt)),Pt.normalize(),Be.crossVectors(rt,Pt),s[0]=Pt.x,s[4]=Be.x,s[8]=rt.x,s[1]=Pt.y,s[5]=Be.y,s[9]=rt.y,s[2]=Pt.z,s[6]=Be.z,s[10]=rt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],o=i[4],a=i[8],h=i[12],c=i[1],u=i[5],d=i[9],p=i[13],m=i[2],y=i[6],w=i[10],g=i[14],_=i[3],b=i[7],f=i[11],z=i[15],S=s[0],A=s[4],E=s[8],v=s[12],F=s[1],P=s[5],B=s[9],T=s[13],k=s[2],R=s[6],G=s[10],q=s[14],it=s[3],I=s[7],V=s[11],j=s[15];return n[0]=r*S+o*F+a*k+h*it,n[4]=r*A+o*P+a*R+h*I,n[8]=r*E+o*B+a*G+h*V,n[12]=r*v+o*T+a*q+h*j,n[1]=c*S+u*F+d*k+p*it,n[5]=c*A+u*P+d*R+p*I,n[9]=c*E+u*B+d*G+p*V,n[13]=c*v+u*T+d*q+p*j,n[2]=m*S+y*F+w*k+g*it,n[6]=m*A+y*P+w*R+g*I,n[10]=m*E+y*B+w*G+g*V,n[14]=m*v+y*T+w*q+g*j,n[3]=_*S+b*F+f*k+z*it,n[7]=_*A+b*P+f*R+z*I,n[11]=_*E+b*B+f*G+z*V,n[15]=_*v+b*T+f*q+z*j,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],s=t[8],n=t[12],r=t[1],o=t[5],a=t[9],h=t[13],c=t[2],u=t[6],d=t[10],p=t[14],m=t[3],y=t[7],w=t[11],g=t[15];return m*(+n*a*u-s*h*u-n*o*d+i*h*d+s*o*p-i*a*p)+y*(+e*a*p-e*h*d+n*r*d-s*r*p+s*h*c-n*a*c)+w*(+e*h*u-e*o*p-n*r*u+i*r*p+n*o*c-i*h*c)+g*(-s*o*c-e*a*u+e*o*d+s*r*u-i*r*d+i*a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],u=t[9],d=t[10],p=t[11],m=t[12],y=t[13],w=t[14],g=t[15],_=u*w*h-y*d*h+y*a*p-o*w*p-u*a*g+o*d*g,b=m*d*h-c*w*h-m*a*p+r*w*p+c*a*g-r*d*g,f=c*y*h-m*u*h+m*o*p-r*y*p-c*o*g+r*u*g,z=m*u*a-c*y*a-m*o*d+r*y*d+c*o*w-r*u*w,S=e*_+i*b+s*f+n*z;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/S;return t[0]=_*A,t[1]=(y*d*n-u*w*n-y*s*p+i*w*p+u*s*g-i*d*g)*A,t[2]=(o*w*n-y*a*n+y*s*h-i*w*h-o*s*g+i*a*g)*A,t[3]=(u*a*n-o*d*n-u*s*h+i*d*h+o*s*p-i*a*p)*A,t[4]=b*A,t[5]=(c*w*n-m*d*n+m*s*p-e*w*p-c*s*g+e*d*g)*A,t[6]=(m*a*n-r*w*n-m*s*h+e*w*h+r*s*g-e*a*g)*A,t[7]=(r*d*n-c*a*n+c*s*h-e*d*h-r*s*p+e*a*p)*A,t[8]=f*A,t[9]=(m*u*n-c*y*n-m*i*p+e*y*p+c*i*g-e*u*g)*A,t[10]=(r*y*n-m*o*n+m*i*h-e*y*h-r*i*g+e*o*g)*A,t[11]=(c*o*n-r*u*n-c*i*h+e*u*h+r*i*p-e*o*p)*A,t[12]=z*A,t[13]=(c*y*s-m*u*s+m*i*d-e*y*d-c*i*w+e*u*w)*A,t[14]=(m*o*s-r*y*s-m*i*a+e*y*a+r*i*w-e*o*w)*A,t[15]=(r*u*s-c*o*s+c*i*a-e*u*a-r*i*d+e*o*d)*A,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,o=t.y,a=t.z,h=n*r,c=n*o;return this.set(h*r+i,h*o-s*a,h*a+s*o,0,h*o+s*a,c*o+i,c*a-s*r,0,h*a-s*o,c*a+s*r,n*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,o=e._z,a=e._w,h=n+n,c=r+r,u=o+o,d=n*h,p=n*c,m=n*u,y=r*c,w=r*u,g=o*u,_=a*h,b=a*c,f=a*u,z=i.x,S=i.y,A=i.z;return s[0]=(1-(y+g))*z,s[1]=(p+f)*z,s[2]=(m-b)*z,s[3]=0,s[4]=(p-f)*S,s[5]=(1-(d+g))*S,s[6]=(w+_)*S,s[7]=0,s[8]=(m+b)*A,s[9]=(w-_)*A,s[10]=(1-(d+y))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let n=Kt.set(s[0],s[1],s[2]).length();const r=Kt.set(s[4],s[5],s[6]).length(),o=Kt.set(s[8],s[9],s[10]).length();this.determinant()<0&&(n=-n),t.x=s[12],t.y=s[13],t.z=s[14],mt.copy(this);const h=1/n,c=1/r,u=1/o;return mt.elements[0]*=h,mt.elements[1]*=h,mt.elements[2]*=h,mt.elements[4]*=c,mt.elements[5]*=c,mt.elements[6]*=c,mt.elements[8]*=u,mt.elements[9]*=u,mt.elements[10]*=u,e.setFromRotationMatrix(mt),i.x=n,i.y=r,i.z=o,this}makePerspective(t,e,i,s,n,r,o=Wt){const a=this.elements,h=2*n/(e-t),c=2*n/(i-s),u=(e+t)/(e-t),d=(i+s)/(i-s);let p,m;if(o===Wt)p=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(o===Ci)p=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return a[0]=h,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=c,a[9]=d,a[13]=0,a[2]=0,a[6]=0,a[10]=p,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,s,n,r,o=Wt){const a=this.elements,h=1/(e-t),c=1/(i-s),u=1/(r-n),d=(e+t)*h,p=(i+s)*c;let m,y;if(o===Wt)m=(r+n)*u,y=-2*u;else if(o===Ci)m=n*u,y=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-d,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-p,a[2]=0,a[6]=0,a[10]=y,a[14]=-m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let s=0;s<16;s++)if(e[s]!==i[s])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Kt=new x,mt=new W,jn=new x(0,0,0),Yn=new x(1,1,1),Pt=new x,Be=new x,rt=new x,rs=new W,os=new tt;class jt{constructor(t=0,e=0,i=0,s=jt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],o=s[8],a=s[1],h=s[5],c=s[9],u=s[2],d=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(et(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-et(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(et(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(a,n));break;case"ZYX":this._y=Math.asin(-et(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(a,n)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(et(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-et(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return rs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(rs,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return os.setFromEuler(this),this.setFromQuaternion(os,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}jt.DEFAULT_ORDER="XYZ";class qs{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Zn=0;const as=new x,te=new tt,Mt=new W,Pe=new x,de=new x,Gn=new x,$n=new tt,hs=new x(1,0,0),ls=new x(0,1,0),cs=new x(0,0,1),us={type:"added"},Qn={type:"removed"},ee={type:"childadded",child:null},ui={type:"childremoved",child:null};class X extends Ut{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zn++}),this.uuid=he(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=X.DEFAULT_UP.clone();const t=new x,e=new jt,i=new tt,s=new x(1,1,1);function n(){i.setFromEuler(e,!1)}function r(){e.setFromQuaternion(i,void 0,!1)}e._onChange(n),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new W},normalMatrix:{value:new vt}}),this.matrix=new W,this.matrixWorld=new W,this.matrixAutoUpdate=X.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=X.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qs,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return te.setFromAxisAngle(t,e),this.quaternion.multiply(te),this}rotateOnWorldAxis(t,e){return te.setFromAxisAngle(t,e),this.quaternion.premultiply(te),this}rotateX(t){return this.rotateOnAxis(hs,t)}rotateY(t){return this.rotateOnAxis(ls,t)}rotateZ(t){return this.rotateOnAxis(cs,t)}translateOnAxis(t,e){return as.copy(t).applyQuaternion(this.quaternion),this.position.add(as.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(hs,t)}translateY(t){return this.translateOnAxis(ls,t)}translateZ(t){return this.translateOnAxis(cs,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Mt.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Pe.copy(t):Pe.set(t,e,i);const s=this.parent;this.updateWorldMatrix(!0,!1),de.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mt.lookAt(de,Pe,this.up):Mt.lookAt(Pe,de,this.up),this.quaternion.setFromRotationMatrix(Mt),s&&(Mt.extractRotation(s.matrixWorld),te.setFromRotationMatrix(Mt),this.quaternion.premultiply(te.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(us),ee.child=t,this.dispatchEvent(ee),ee.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Qn),ui.child=t,this.dispatchEvent(ui),ui.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Mt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Mt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Mt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(us),ee.child=t,this.dispatchEvent(ee),ee.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,s=this.children.length;i<s;i++){const r=this.children[i].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(de,t,Gn),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(de,$n,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(t)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const a=o.shapes;if(Array.isArray(a))for(let h=0,c=a.length;h<c;h++){const u=a[h];n(t.shapes,u)}else n(t.shapes,a)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let a=0,h=this.material.length;a<h;a++)o.push(n(t.materials,this.material[a]));s.material=o}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const a=this.animations[o];s.animations.push(n(t.animations,a))}}if(e){const o=r(t.geometries),a=r(t.materials),h=r(t.textures),c=r(t.images),u=r(t.shapes),d=r(t.skeletons),p=r(t.animations),m=r(t.nodes);o.length>0&&(i.geometries=o),a.length>0&&(i.materials=a),h.length>0&&(i.textures=h),c.length>0&&(i.images=c),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),m.length>0&&(i.nodes=m)}return i.object=s,i;function r(o){const a=[];for(const h in o){const c=o[h];delete c.metadata,a.push(c)}return a}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const s=t.children[i];this.add(s.clone())}return this}}X.DEFAULT_UP=new x(0,1,0);X.DEFAULT_MATRIX_AUTO_UPDATE=!0;X.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ft=new x,_t=new x,di=new x,St=new x,ie=new x,se=new x,ds=new x,pi=new x,mi=new x,fi=new x,yi=new Xt,xi=new Xt,gi=new Xt;class yt{constructor(t=new x,e=new x,i=new x){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,s){s.subVectors(i,e),ft.subVectors(t,e),s.cross(ft);const n=s.lengthSq();return n>0?s.multiplyScalar(1/Math.sqrt(n)):s.set(0,0,0)}static getBarycoord(t,e,i,s,n){ft.subVectors(s,e),_t.subVectors(i,e),di.subVectors(t,e);const r=ft.dot(ft),o=ft.dot(_t),a=ft.dot(di),h=_t.dot(_t),c=_t.dot(di),u=r*h-o*o;if(u===0)return n.set(0,0,0),null;const d=1/u,p=(h*a-o*c)*d,m=(r*c-o*a)*d;return n.set(1-p-m,m,p)}static containsPoint(t,e,i,s){return this.getBarycoord(t,e,i,s,St)===null?!1:St.x>=0&&St.y>=0&&St.x+St.y<=1}static getInterpolation(t,e,i,s,n,r,o,a){return this.getBarycoord(t,e,i,s,St)===null?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(n,St.x),a.addScaledVector(r,St.y),a.addScaledVector(o,St.z),a)}static getInterpolatedAttribute(t,e,i,s,n,r){return yi.setScalar(0),xi.setScalar(0),gi.setScalar(0),yi.fromBufferAttribute(t,e),xi.fromBufferAttribute(t,i),gi.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(yi,n.x),r.addScaledVector(xi,n.y),r.addScaledVector(gi,n.z),r}static isFrontFacing(t,e,i,s){return ft.subVectors(i,e),_t.subVectors(t,e),ft.cross(_t).dot(s)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ft.subVectors(this.c,this.b),_t.subVectors(this.a,this.b),ft.cross(_t).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return yt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return yt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,n){return yt.getInterpolation(t,this.a,this.b,this.c,e,i,s,n)}containsPoint(t){return yt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return yt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,n=this.c;let r,o;ie.subVectors(s,i),se.subVectors(n,i),pi.subVectors(t,i);const a=ie.dot(pi),h=se.dot(pi);if(a<=0&&h<=0)return e.copy(i);mi.subVectors(t,s);const c=ie.dot(mi),u=se.dot(mi);if(c>=0&&u<=c)return e.copy(s);const d=a*u-c*h;if(d<=0&&a>=0&&c<=0)return r=a/(a-c),e.copy(i).addScaledVector(ie,r);fi.subVectors(t,n);const p=ie.dot(fi),m=se.dot(fi);if(m>=0&&p<=m)return e.copy(n);const y=p*h-a*m;if(y<=0&&h>=0&&m<=0)return o=h/(h-m),e.copy(i).addScaledVector(se,o);const w=c*m-p*u;if(w<=0&&u-c>=0&&p-m>=0)return ds.subVectors(n,s),o=(u-c)/(u-c+(p-m)),e.copy(s).addScaledVector(ds,o);const g=1/(w+y+d);return r=y*g,o=d*g,e.copy(i).addScaledVector(ie,r).addScaledVector(se,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Us={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Tt={h:0,s:0,l:0},Te={h:0,s:0,l:0};function wi(l,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?l+(t-l)*6*e:e<1/2?t:e<2/3?l+(t-l)*6*(2/3-e):l}class ht{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ut){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ct.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=ct.workingColorSpace){return this.r=t,this.g=e,this.b=i,ct.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=ct.workingColorSpace){if(t=Pi(t,1),e=et(e,0,1),i=et(i,0,1),e===0)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=wi(r,n,t+1/3),this.g=wi(r,n,t),this.b=wi(r,n,t-1/3)}return ct.toWorkingColorSpace(this,s),this}setStyle(t,e=ut){function i(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let n;const r=s[1],o=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ut){const i=Us[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Et(t.r),this.g=Et(t.g),this.b=Et(t.b),this}copyLinearToSRGB(t){return this.r=ae(t.r),this.g=ae(t.g),this.b=ae(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ut){return ct.fromWorkingColorSpace(Q.copy(this),t),Math.round(et(Q.r*255,0,255))*65536+Math.round(et(Q.g*255,0,255))*256+Math.round(et(Q.b*255,0,255))}getHexString(t=ut){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ct.workingColorSpace){ct.fromWorkingColorSpace(Q.copy(this),e);const i=Q.r,s=Q.g,n=Q.b,r=Math.max(i,s,n),o=Math.min(i,s,n);let a,h;const c=(o+r)/2;if(o===r)a=0,h=0;else{const u=r-o;switch(h=c<=.5?u/(r+o):u/(2-r-o),r){case i:a=(s-n)/u+(s<n?6:0);break;case s:a=(n-i)/u+2;break;case n:a=(i-s)/u+4;break}a/=6}return t.h=a,t.s=h,t.l=c,t}getRGB(t,e=ct.workingColorSpace){return ct.fromWorkingColorSpace(Q.copy(this),e),t.r=Q.r,t.g=Q.g,t.b=Q.b,t}getStyle(t=ut){ct.fromWorkingColorSpace(Q.copy(this),t);const e=Q.r,i=Q.g,s=Q.b;return t!==ut?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(t,e,i){return this.getHSL(Tt),this.setHSL(Tt.h+t,Tt.s+e,Tt.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Tt),t.getHSL(Te);const i=we(Tt.h,Te.h,e),s=we(Tt.s,Te.s,e),n=we(Tt.l,Te.l,e);return this.setHSL(i,s,n),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,s=this.b,n=t.elements;return this.r=n[0]*e+n[3]*i+n[6]*s,this.g=n[1]*e+n[4]*i+n[7]*s,this.b=n[2]*e+n[5]*i+n[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Q=new ht;ht.NAMES=Us;let Jn=0;class ki extends Ut{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jn++}),this.uuid=he(),this.name="",this.blending=Hi,this.side=Ze,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ui,this.blendDst=Xi,this.blendEquation=qi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ht(0,0,0),this.blendAlpha=0,this.depthFunc=ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Gi,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zt,this.stencilZFail=Zt,this.stencilZPass=Zt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Hi&&(i.blending=this.blending),this.side!==Ze&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Ui&&(i.blendSrc=this.blendSrc),this.blendDst!==Xi&&(i.blendDst=this.blendDst),this.blendEquation!==qi&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==ji&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Gi&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Zt&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Zt&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Zt&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const r=[];for(const o in n){const a=n[o];delete a.metadata,r.push(a)}return r}if(e){const n=s(t.textures),r=s(t.images);n.length>0&&(i.textures=n),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(e!==null){const s=e.length;i=new Array(s);for(let n=0;n!==s;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Me extends ki{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.combine=Rs,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const H=new x,ke=new U;class qt{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=$i,this.updateRanges=[],this.gpuType=Mn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,n=this.itemSize;s<n;s++)this.array[t+s]=e.array[i+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)ke.fromBufferAttribute(this,e),ke.applyMatrix3(t),this.setXY(e,ke.x,ke.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyMatrix3(t),this.setXYZ(e,H.x,H.y,H.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyMatrix4(t),this.setXYZ(e,H.x,H.y,H.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.applyNormalMatrix(t),this.setXYZ(e,H.x,H.y,H.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)H.fromBufferAttribute(this,e),H.transformDirection(t),this.setXYZ(e,H.x,H.y,H.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=re(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=st(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=re(e,this.array)),e}setX(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=re(e,this.array)),e}setY(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=re(e,this.array)),e}setZ(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=re(e,this.array)),e}setW(t,e){return this.normalized&&(e=st(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,s){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array),s=st(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this}setXYZW(t,e,i,s,n){return t*=this.itemSize,this.normalized&&(e=st(e,this.array),i=st(i,this.array),s=st(s,this.array),n=st(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=s,this.array[t+3]=n,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==$i&&(t.usage=this.usage),t}}class Kn extends qt{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class tr extends qt{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class L extends qt{constructor(t,e,i){super(new Float32Array(t),e,i)}}let er=0;const lt=new W,bi=new X,ne=new x,ot=new gt,pe=new gt,Y=new x;class nt extends Ut{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:er++}),this.uuid=he(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Vn(t)?tr:Kn)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const n=new vt().getNormalMatrix(t);i.applyNormalMatrix(n),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return lt.makeRotationFromQuaternion(t),this.applyMatrix4(lt),this}rotateX(t){return lt.makeRotationX(t),this.applyMatrix4(lt),this}rotateY(t){return lt.makeRotationY(t),this.applyMatrix4(lt),this}rotateZ(t){return lt.makeRotationZ(t),this.applyMatrix4(lt),this}translate(t,e,i){return lt.makeTranslation(t,e,i),this.applyMatrix4(lt),this}scale(t,e,i){return lt.makeScale(t,e,i),this.applyMatrix4(lt),this}lookAt(t){return bi.lookAt(t),bi.updateMatrix(),this.applyMatrix4(bi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ne).negate(),this.translate(ne.x,ne.y,ne.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let s=0,n=t.length;s<n;s++){const r=t[s];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new L(i,3))}else{for(let i=0,s=e.count;i<s;i++){const n=t[i];e.setXYZ(i,n.x,n.y,n.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new gt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new x(-1/0,-1/0,-1/0),new x(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,s=e.length;i<s;i++){const n=e[i];ot.setFromBufferAttribute(n),this.morphTargetsRelative?(Y.addVectors(this.boundingBox.min,ot.min),this.boundingBox.expandByPoint(Y),Y.addVectors(this.boundingBox.max,ot.max),this.boundingBox.expandByPoint(Y)):(this.boundingBox.expandByPoint(ot.min),this.boundingBox.expandByPoint(ot.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new be);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new x,1/0);return}if(t){const i=this.boundingSphere.center;if(ot.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const o=e[n];pe.setFromBufferAttribute(o),this.morphTargetsRelative?(Y.addVectors(ot.min,pe.min),ot.expandByPoint(Y),Y.addVectors(ot.max,pe.max),ot.expandByPoint(Y)):(ot.expandByPoint(pe.min),ot.expandByPoint(pe.max))}ot.getCenter(i);let s=0;for(let n=0,r=t.count;n<r;n++)Y.fromBufferAttribute(t,n),s=Math.max(s,i.distanceToSquared(Y));if(e)for(let n=0,r=e.length;n<r;n++){const o=e[n],a=this.morphTargetsRelative;for(let h=0,c=o.count;h<c;h++)Y.fromBufferAttribute(o,h),a&&(ne.fromBufferAttribute(t,h),Y.add(ne)),s=Math.max(s,i.distanceToSquared(Y))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,s=e.normal,n=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new qt(new Float32Array(4*i.count),4));const r=this.getAttribute("tangent"),o=[],a=[];for(let E=0;E<i.count;E++)o[E]=new x,a[E]=new x;const h=new x,c=new x,u=new x,d=new U,p=new U,m=new U,y=new x,w=new x;function g(E,v,F){h.fromBufferAttribute(i,E),c.fromBufferAttribute(i,v),u.fromBufferAttribute(i,F),d.fromBufferAttribute(n,E),p.fromBufferAttribute(n,v),m.fromBufferAttribute(n,F),c.sub(h),u.sub(h),p.sub(d),m.sub(d);const P=1/(p.x*m.y-m.x*p.y);isFinite(P)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(u,-p.y).multiplyScalar(P),w.copy(u).multiplyScalar(p.x).addScaledVector(c,-m.x).multiplyScalar(P),o[E].add(y),o[v].add(y),o[F].add(y),a[E].add(w),a[v].add(w),a[F].add(w))}let _=this.groups;_.length===0&&(_=[{start:0,count:t.count}]);for(let E=0,v=_.length;E<v;++E){const F=_[E],P=F.start,B=F.count;for(let T=P,k=P+B;T<k;T+=3)g(t.getX(T+0),t.getX(T+1),t.getX(T+2))}const b=new x,f=new x,z=new x,S=new x;function A(E){z.fromBufferAttribute(s,E),S.copy(z);const v=o[E];b.copy(v),b.sub(z.multiplyScalar(z.dot(v))).normalize(),f.crossVectors(S,v);const P=f.dot(a[E])<0?-1:1;r.setXYZW(E,b.x,b.y,b.z,P)}for(let E=0,v=_.length;E<v;++E){const F=_[E],P=F.start,B=F.count;for(let T=P,k=P+B;T<k;T+=3)A(t.getX(T+0)),A(t.getX(T+1)),A(t.getX(T+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new qt(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const s=new x,n=new x,r=new x,o=new x,a=new x,h=new x,c=new x,u=new x;if(t)for(let d=0,p=t.count;d<p;d+=3){const m=t.getX(d+0),y=t.getX(d+1),w=t.getX(d+2);s.fromBufferAttribute(e,m),n.fromBufferAttribute(e,y),r.fromBufferAttribute(e,w),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),o.fromBufferAttribute(i,m),a.fromBufferAttribute(i,y),h.fromBufferAttribute(i,w),o.add(c),a.add(c),h.add(c),i.setXYZ(m,o.x,o.y,o.z),i.setXYZ(y,a.x,a.y,a.z),i.setXYZ(w,h.x,h.y,h.z)}else for(let d=0,p=e.count;d<p;d+=3)s.fromBufferAttribute(e,d+0),n.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),c.subVectors(r,n),u.subVectors(s,n),c.cross(u),i.setXYZ(d+0,c.x,c.y,c.z),i.setXYZ(d+1,c.x,c.y,c.z),i.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)Y.fromBufferAttribute(t,e),Y.normalize(),t.setXYZ(e,Y.x,Y.y,Y.z)}toNonIndexed(){function t(o,a){const h=o.array,c=o.itemSize,u=o.normalized,d=new h.constructor(a.length*c);let p=0,m=0;for(let y=0,w=a.length;y<w;y++){o.isInterleavedBufferAttribute?p=a[y]*o.data.stride+o.offset:p=a[y]*c;for(let g=0;g<c;g++)d[m++]=h[p++]}return new qt(d,c,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new nt,i=this.index.array,s=this.attributes;for(const o in s){const a=s[o],h=t(a,i);e.setAttribute(o,h)}const n=this.morphAttributes;for(const o in n){const a=[],h=n[o];for(let c=0,u=h.length;c<u;c++){const d=h[c],p=t(d,i);a.push(p)}e.morphAttributes[o]=a}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,a=r.length;o<a;o++){const h=r[o];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const h in a)a[h]!==void 0&&(t[h]=a[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const a in i){const h=i[a];t.data.attributes[a]=h.toJSON(t.data)}const s={};let n=!1;for(const a in this.morphAttributes){const h=this.morphAttributes[a],c=[];for(let u=0,d=h.length;u<d;u++){const p=h[u];c.push(p.toJSON(t.data))}c.length>0&&(s[a]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const h in s){const c=s[h];this.setAttribute(h,c.clone(e))}const n=t.morphAttributes;for(const h in n){const c=[],u=n[h];for(let d=0,p=u.length;d<p;d++)c.push(u[d].clone(e));this.morphAttributes[h]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let h=0,c=r.length;h<c;h++){const u=r[h];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const a=t.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ps=new W,Dt=new Ti,Ie=new be,ms=new x,Re=new x,De=new x,Le=new x,Mi=new x,Ne=new x,fs=new x,Oe=new x;class C extends X{constructor(t=new nt,e=new Me){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}getVertexPosition(t,e){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(n&&o){Ne.set(0,0,0);for(let a=0,h=n.length;a<h;a++){const c=o[a],u=n[a];c!==0&&(Mi.fromBufferAttribute(u,t),r?Ne.addScaledVector(Mi,c):Ne.addScaledVector(Mi.sub(e),c))}e.add(Ne)}return e}raycast(t,e){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ie.copy(i.boundingSphere),Ie.applyMatrix4(n),Dt.copy(t.ray).recast(t.near),!(Ie.containsPoint(Dt.origin)===!1&&(Dt.intersectSphere(Ie,ms)===null||Dt.origin.distanceToSquared(ms)>(t.far-t.near)**2))&&(ps.copy(n).invert(),Dt.copy(t.ray).applyMatrix4(ps),!(i.boundingBox!==null&&Dt.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,Dt)))}_computeIntersections(t,e,i){let s;const n=this.geometry,r=this.material,o=n.index,a=n.attributes.position,h=n.attributes.uv,c=n.attributes.uv1,u=n.attributes.normal,d=n.groups,p=n.drawRange;if(o!==null)if(Array.isArray(r))for(let m=0,y=d.length;m<y;m++){const w=d[m],g=r[w.materialIndex],_=Math.max(w.start,p.start),b=Math.min(o.count,Math.min(w.start+w.count,p.start+p.count));for(let f=_,z=b;f<z;f+=3){const S=o.getX(f),A=o.getX(f+1),E=o.getX(f+2);s=Ve(this,g,t,i,h,c,u,S,A,E),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=w.materialIndex,e.push(s))}}else{const m=Math.max(0,p.start),y=Math.min(o.count,p.start+p.count);for(let w=m,g=y;w<g;w+=3){const _=o.getX(w),b=o.getX(w+1),f=o.getX(w+2);s=Ve(this,r,t,i,h,c,u,_,b,f),s&&(s.faceIndex=Math.floor(w/3),e.push(s))}}else if(a!==void 0)if(Array.isArray(r))for(let m=0,y=d.length;m<y;m++){const w=d[m],g=r[w.materialIndex],_=Math.max(w.start,p.start),b=Math.min(a.count,Math.min(w.start+w.count,p.start+p.count));for(let f=_,z=b;f<z;f+=3){const S=f,A=f+1,E=f+2;s=Ve(this,g,t,i,h,c,u,S,A,E),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=w.materialIndex,e.push(s))}}else{const m=Math.max(0,p.start),y=Math.min(a.count,p.start+p.count);for(let w=m,g=y;w<g;w+=3){const _=w,b=w+1,f=w+2;s=Ve(this,r,t,i,h,c,u,_,b,f),s&&(s.faceIndex=Math.floor(w/3),e.push(s))}}}}function ir(l,t,e,i,s,n,r,o){let a;if(t.side===xn?a=i.intersectTriangle(r,n,s,!0,o):a=i.intersectTriangle(s,n,r,t.side===Ze,o),a===null)return null;Oe.copy(o),Oe.applyMatrix4(l.matrixWorld);const h=e.ray.origin.distanceTo(Oe);return h<e.near||h>e.far?null:{distance:h,point:Oe.clone(),object:l}}function Ve(l,t,e,i,s,n,r,o,a,h){l.getVertexPosition(o,Re),l.getVertexPosition(a,De),l.getVertexPosition(h,Le);const c=ir(l,t,e,i,Re,De,Le,fs);if(c){const u=new x;yt.getBarycoord(fs,Re,De,Le,u),s&&(c.uv=yt.getInterpolatedAttribute(s,o,a,h,u,new U)),n&&(c.uv1=yt.getInterpolatedAttribute(n,o,a,h,u,new U)),r&&(c.normal=yt.getInterpolatedAttribute(r,o,a,h,u,new x),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const d={a:o,b:a,c:h,normal:new x,materialIndex:0};yt.getNormal(Re,De,Le,d.normal),c.face=d,c.barycoord=u}return c}class Z extends nt{constructor(t=1,e=1,i=1,s=1,n=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:n,depthSegments:r};const o=this;s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);const a=[],h=[],c=[],u=[];let d=0,p=0;m("z","y","x",-1,-1,i,e,t,r,n,0),m("z","y","x",1,-1,i,e,-t,r,n,1),m("x","z","y",1,1,t,i,e,s,r,2),m("x","z","y",1,-1,t,i,-e,s,r,3),m("x","y","z",1,-1,t,e,i,s,n,4),m("x","y","z",-1,-1,t,e,-i,s,n,5),this.setIndex(a),this.setAttribute("position",new L(h,3)),this.setAttribute("normal",new L(c,3)),this.setAttribute("uv",new L(u,2));function m(y,w,g,_,b,f,z,S,A,E,v){const F=f/A,P=z/E,B=f/2,T=z/2,k=S/2,R=A+1,G=E+1;let q=0,it=0;const I=new x;for(let V=0;V<G;V++){const j=V*P-T;for(let dt=0;dt<R;dt++){const Yt=dt*F-B;I[y]=Yt*_,I[w]=j*b,I[g]=k,h.push(I.x,I.y,I.z),I[y]=0,I[w]=0,I[g]=S>0?1:-1,c.push(I.x,I.y,I.z),u.push(dt/A),u.push(1-V/E),q+=1}}for(let V=0;V<E;V++)for(let j=0;j<A;j++){const dt=d+j+R*V,Yt=d+j+R*(V+1),Se=d+(j+1)+R*(V+1),Vi=d+(j+1)+R*V;a.push(dt,Yt,Vi),a.push(Yt,Se,Vi),it+=6}o.addGroup(p,it,v),p+=it,d+=q}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Z(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class sr extends X{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new W,this.projectionMatrix=new W,this.projectionMatrixInverse=new W,this.coordinateSystem=Wt}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const _i=new x,nr=new x,rr=new vt;class at{constructor(t=new x(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,s){return this.normal.set(t,e,i),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const s=_i.subVectors(i,e).cross(nr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(_i),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const n=-(t.start.dot(this.normal)+this.constant)/s;return n<0||n>1?null:e.copy(t.start).addScaledVector(i,n)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||rr.getNormalMatrix(t),s=this.coplanarPoint(_i).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(n),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Lt=new be,We=new x;class or{constructor(t=new at,e=new at,i=new at,s=new at,n=new at,r=new at){this.planes=[t,e,i,s,n,r]}set(t,e,i,s,n,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(s),o[4].copy(n),o[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Wt){const i=this.planes,s=t.elements,n=s[0],r=s[1],o=s[2],a=s[3],h=s[4],c=s[5],u=s[6],d=s[7],p=s[8],m=s[9],y=s[10],w=s[11],g=s[12],_=s[13],b=s[14],f=s[15];if(i[0].setComponents(a-n,d-h,w-p,f-g).normalize(),i[1].setComponents(a+n,d+h,w+p,f+g).normalize(),i[2].setComponents(a+r,d+c,w+m,f+_).normalize(),i[3].setComponents(a-r,d-c,w-m,f-_).normalize(),i[4].setComponents(a-o,d-u,w-y,f-b).normalize(),e===Wt)i[5].setComponents(a+o,d+u,w+y,f+b).normalize();else if(e===Ci)i[5].setComponents(o,u,y,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Lt.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Lt.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Lt)}intersectsSprite(t){return Lt.center.set(0,0,0),Lt.radius=.7071067811865476,Lt.applyMatrix4(t.matrixWorld),this.intersectsSphere(Lt)}intersectsSphere(t){const e=this.planes,i=t.center,s=-t.radius;for(let n=0;n<6;n++)if(e[n].distanceToPoint(i)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const s=e[i];if(We.x=s.normal.x>0?t.max.x:t.min.x,We.y=s.normal.y>0?t.max.y:t.min.y,We.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(We)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Je extends nt{constructor(t=1,e=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:s};const n=t/2,r=e/2,o=Math.floor(i),a=Math.floor(s),h=o+1,c=a+1,u=t/o,d=e/a,p=[],m=[],y=[],w=[];for(let g=0;g<c;g++){const _=g*d-r;for(let b=0;b<h;b++){const f=b*u-n;m.push(f,-_,0),y.push(0,0,1),w.push(b/o),w.push(1-g/a)}}for(let g=0;g<a;g++)for(let _=0;_<o;_++){const b=_+h*g,f=_+h*(g+1),z=_+1+h*(g+1),S=_+1+h*g;p.push(b,f,S),p.push(f,z,S)}this.setIndex(p),this.setAttribute("position",new L(m,3)),this.setAttribute("normal",new L(y,3)),this.setAttribute("uv",new L(w,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Je(t.width,t.height,t.widthSegments,t.heightSegments)}}class ar extends sr{constructor(t=-1,e=1,i=1,s=-1,n=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=s,this.near=n,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,s,n,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-t,r=i+t,o=s+e,a=s-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=h*this.view.offsetX,r=n+h*this.view.width,o-=c*this.view.offsetY,a=o-c*this.view.height}this.projectionMatrix.makeOrthographic(n,r,o,a,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class Xs extends X{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Ke extends ki{static get type(){return"LineBasicMaterial"}constructor(t){super(),this.isLineBasicMaterial=!0,this.color=new ht(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ge=new x,$e=new x,ys=new W,me=new Ti,He=new be,Si=new x,xs=new x;class At extends X{constructor(t=new nt,e=new Ke){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let s=1,n=e.count;s<n;s++)Ge.fromBufferAttribute(e,s-1),$e.fromBufferAttribute(e,s),i[s]=i[s-1],i[s]+=Ge.distanceTo($e);t.setAttribute("lineDistance",new L(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,s=this.matrixWorld,n=t.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),He.copy(i.boundingSphere),He.applyMatrix4(s),He.radius+=n,t.ray.intersectsSphere(He)===!1)return;ys.copy(s).invert(),me.copy(t.ray).applyMatrix4(ys);const o=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=o*o,h=this.isLineSegments?2:1,c=i.index,d=i.attributes.position;if(c!==null){const p=Math.max(0,r.start),m=Math.min(c.count,r.start+r.count);for(let y=p,w=m-1;y<w;y+=h){const g=c.getX(y),_=c.getX(y+1),b=qe(this,t,me,a,g,_);b&&e.push(b)}if(this.isLineLoop){const y=c.getX(m-1),w=c.getX(p),g=qe(this,t,me,a,y,w);g&&e.push(g)}}else{const p=Math.max(0,r.start),m=Math.min(d.count,r.start+r.count);for(let y=p,w=m-1;y<w;y+=h){const g=qe(this,t,me,a,y,y+1);g&&e.push(g)}if(this.isLineLoop){const y=qe(this,t,me,a,m-1,p);y&&e.push(y)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const o=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=n}}}}}function qe(l,t,e,i,s,n){const r=l.geometry.attributes.position;if(Ge.fromBufferAttribute(r,s),$e.fromBufferAttribute(r,n),e.distanceSqToSegment(Ge,$e,Si,xs)>i)return;Si.applyMatrix4(l.matrixWorld);const a=t.ray.origin.distanceTo(Si);if(!(a<t.near||a>t.far))return{distance:a,point:xs.clone().applyMatrix4(l.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:l}}const gs=new x,ws=new x;class js extends At{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let s=0,n=e.count;s<n;s+=2)gs.fromBufferAttribute(e,s),ws.fromBufferAttribute(e,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+gs.distanceTo(ws);t.setAttribute("lineDistance",new L(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class J extends nt{constructor(t=1,e=1,i=1,s=32,n=1,r=!1,o=0,a=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:s,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:a};const h=this;s=Math.floor(s),n=Math.floor(n);const c=[],u=[],d=[],p=[];let m=0;const y=[],w=i/2;let g=0;_(),r===!1&&(t>0&&b(!0),e>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new L(u,3)),this.setAttribute("normal",new L(d,3)),this.setAttribute("uv",new L(p,2));function _(){const f=new x,z=new x;let S=0;const A=(e-t)/i;for(let E=0;E<=n;E++){const v=[],F=E/n,P=F*(e-t)+t;for(let B=0;B<=s;B++){const T=B/s,k=T*a+o,R=Math.sin(k),G=Math.cos(k);z.x=P*R,z.y=-F*i+w,z.z=P*G,u.push(z.x,z.y,z.z),f.set(R,A,G).normalize(),d.push(f.x,f.y,f.z),p.push(T,1-F),v.push(m++)}y.push(v)}for(let E=0;E<s;E++)for(let v=0;v<n;v++){const F=y[v][E],P=y[v+1][E],B=y[v+1][E+1],T=y[v][E+1];(t>0||v!==0)&&(c.push(F,P,T),S+=3),(e>0||v!==n-1)&&(c.push(P,B,T),S+=3)}h.addGroup(g,S,0),g+=S}function b(f){const z=m,S=new U,A=new x;let E=0;const v=f===!0?t:e,F=f===!0?1:-1;for(let B=1;B<=s;B++)u.push(0,w*F,0),d.push(0,F,0),p.push(.5,.5),m++;const P=m;for(let B=0;B<=s;B++){const k=B/s*a+o,R=Math.cos(k),G=Math.sin(k);A.x=v*G,A.y=w*F,A.z=v*R,u.push(A.x,A.y,A.z),d.push(0,F,0),S.x=R*.5+.5,S.y=G*.5*F+.5,p.push(S.x,S.y),m++}for(let B=0;B<s;B++){const T=z+B,k=P+B;f===!0?c.push(k,k+1,T):c.push(k+1,k,T),E+=3}h.addGroup(g,E,f===!0?1:2),g+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new J(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ii extends nt{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const n=[],r=[];o(s),h(i),c(),this.setAttribute("position",new L(n,3)),this.setAttribute("normal",new L(n.slice(),3)),this.setAttribute("uv",new L(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(_){const b=new x,f=new x,z=new x;for(let S=0;S<e.length;S+=3)p(e[S+0],b),p(e[S+1],f),p(e[S+2],z),a(b,f,z,_)}function a(_,b,f,z){const S=z+1,A=[];for(let E=0;E<=S;E++){A[E]=[];const v=_.clone().lerp(f,E/S),F=b.clone().lerp(f,E/S),P=S-E;for(let B=0;B<=P;B++)B===0&&E===S?A[E][B]=v:A[E][B]=v.clone().lerp(F,B/P)}for(let E=0;E<S;E++)for(let v=0;v<2*(S-E)-1;v++){const F=Math.floor(v/2);v%2===0?(d(A[E][F+1]),d(A[E+1][F]),d(A[E][F])):(d(A[E][F+1]),d(A[E+1][F+1]),d(A[E+1][F]))}}function h(_){const b=new x;for(let f=0;f<n.length;f+=3)b.x=n[f+0],b.y=n[f+1],b.z=n[f+2],b.normalize().multiplyScalar(_),n[f+0]=b.x,n[f+1]=b.y,n[f+2]=b.z}function c(){const _=new x;for(let b=0;b<n.length;b+=3){_.x=n[b+0],_.y=n[b+1],_.z=n[b+2];const f=w(_)/2/Math.PI+.5,z=g(_)/Math.PI+.5;r.push(f,1-z)}m(),u()}function u(){for(let _=0;_<r.length;_+=6){const b=r[_+0],f=r[_+2],z=r[_+4],S=Math.max(b,f,z),A=Math.min(b,f,z);S>.9&&A<.1&&(b<.2&&(r[_+0]+=1),f<.2&&(r[_+2]+=1),z<.2&&(r[_+4]+=1))}}function d(_){n.push(_.x,_.y,_.z)}function p(_,b){const f=_*3;b.x=t[f+0],b.y=t[f+1],b.z=t[f+2]}function m(){const _=new x,b=new x,f=new x,z=new x,S=new U,A=new U,E=new U;for(let v=0,F=0;v<n.length;v+=9,F+=6){_.set(n[v+0],n[v+1],n[v+2]),b.set(n[v+3],n[v+4],n[v+5]),f.set(n[v+6],n[v+7],n[v+8]),S.set(r[F+0],r[F+1]),A.set(r[F+2],r[F+3]),E.set(r[F+4],r[F+5]),z.copy(_).add(b).add(f).divideScalar(3);const P=w(z);y(S,F+0,_,P),y(A,F+2,b,P),y(E,F+4,f,P)}}function y(_,b,f,z){z<0&&_.x===1&&(r[b]=_.x-1),f.x===0&&f.z===0&&(r[b]=z/2/Math.PI+.5)}function w(_){return Math.atan2(_.z,-_.x)}function g(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ii(t.vertices,t.indices,t.radius,t.details)}}class oe extends Ii{constructor(t=1,e=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],s=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,s,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new oe(t.radius,t.detail)}}class Ri extends nt{constructor(t=1,e=32,i=16,s=0,n=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:s,phiLength:n,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(r+o,Math.PI);let h=0;const c=[],u=new x,d=new x,p=[],m=[],y=[],w=[];for(let g=0;g<=i;g++){const _=[],b=g/i;let f=0;g===0&&r===0?f=.5/e:g===i&&a===Math.PI&&(f=-.5/e);for(let z=0;z<=e;z++){const S=z/e;u.x=-t*Math.cos(s+S*n)*Math.sin(r+b*o),u.y=t*Math.cos(r+b*o),u.z=t*Math.sin(s+S*n)*Math.sin(r+b*o),m.push(u.x,u.y,u.z),d.copy(u).normalize(),y.push(d.x,d.y,d.z),w.push(S+f,1-b),_.push(h++)}c.push(_)}for(let g=0;g<i;g++)for(let _=0;_<e;_++){const b=c[g][_+1],f=c[g][_],z=c[g+1][_],S=c[g+1][_+1];(g!==0||r>0)&&p.push(b,f,S),(g!==i-1||a<Math.PI)&&p.push(f,z,S)}this.setIndex(p),this.setAttribute("position",new L(m,3)),this.setAttribute("normal",new L(y,3)),this.setAttribute("uv",new L(w,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ri(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Vt extends nt{constructor(t=1,e=.4,i=12,s=48,n=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:s,arc:n},i=Math.floor(i),s=Math.floor(s);const r=[],o=[],a=[],h=[],c=new x,u=new x,d=new x;for(let p=0;p<=i;p++)for(let m=0;m<=s;m++){const y=m/s*n,w=p/i*Math.PI*2;u.x=(t+e*Math.cos(w))*Math.cos(y),u.y=(t+e*Math.cos(w))*Math.sin(y),u.z=e*Math.sin(w),o.push(u.x,u.y,u.z),c.x=t*Math.cos(y),c.y=t*Math.sin(y),d.subVectors(u,c).normalize(),a.push(d.x,d.y,d.z),h.push(m/s),h.push(p/i)}for(let p=1;p<=i;p++)for(let m=1;m<=s;m++){const y=(s+1)*p+m-1,w=(s+1)*(p-1)+m-1,g=(s+1)*(p-1)+m,_=(s+1)*p+m;r.push(y,w,_),r.push(w,g,_)}this.setIndex(r),this.setAttribute("position",new L(o,3)),this.setAttribute("normal",new L(a,3)),this.setAttribute("uv",new L(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vt(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class hr extends ki{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new ht(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sn,this.normalScale=new U(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jt,this.combine=Rs,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const bs={enabled:!1,files:{},add:function(l,t){this.enabled!==!1&&(this.files[l]=t)},get:function(l){if(this.enabled!==!1)return this.files[l]},remove:function(l){delete this.files[l]},clear:function(){this.files={}}};class lr{constructor(t,e,i){const s=this;let n=!1,r=0,o=0,a;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(c){o++,n===!1&&s.onStart!==void 0&&s.onStart(c,r,o),n=!0},this.itemEnd=function(c){r++,s.onProgress!==void 0&&s.onProgress(c,r,o),r===o&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(c){s.onError!==void 0&&s.onError(c)},this.resolveURL=function(c){return a?a(c):c},this.setURLModifier=function(c){return a=c,this},this.addHandler=function(c,u){return h.push(c,u),this},this.removeHandler=function(c){const u=h.indexOf(c);return u!==-1&&h.splice(u,2),this},this.getHandler=function(c){for(let u=0,d=h.length;u<d;u+=2){const p=h[u],m=h[u+1];if(p.global&&(p.lastIndex=0),p.test(c))return m}return null}}}const cr=new lr;class Di{constructor(t){this.manager=t!==void 0?t:cr,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(s,n){i.load(t,s,e,n)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Di.DEFAULT_MATERIAL_NAME="__DEFAULT";const zt={};class ur extends Error{constructor(t,e){super(t),this.response=e}}class dr extends Di{constructor(t){super(t)}load(t,e,i,s){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const n=bs.get(t);if(n!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(n),this.manager.itemEnd(t)},0),n;if(zt[t]!==void 0){zt[t].push({onLoad:e,onProgress:i,onError:s});return}zt[t]=[],zt[t].push({onLoad:e,onProgress:i,onError:s});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(r).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const c=zt[t],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=d?parseInt(d):0,m=p!==0;let y=0;const w=new ReadableStream({start(g){_();function _(){u.read().then(({done:b,value:f})=>{if(b)g.close();else{y+=f.byteLength;const z=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:p});for(let S=0,A=c.length;S<A;S++){const E=c[S];E.onProgress&&E.onProgress(z)}g.enqueue(f),_()}},b=>{g.error(b)})}}});return new Response(w)}else throw new ur(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(a){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(c=>new DOMParser().parseFromString(c,o));case"json":return h.json();default:if(o===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return h.arrayBuffer().then(m=>p.decode(m))}}}).then(h=>{bs.add(t,h);const c=zt[t];delete zt[t];for(let u=0,d=c.length;u<d;u++){const p=c[u];p.onLoad&&p.onLoad(h)}}).catch(h=>{const c=zt[t];if(c===void 0)throw this.manager.itemError(t),h;delete zt[t];for(let u=0,d=c.length;u<d;u++){const p=c[u];p.onError&&p.onError(h)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Ys extends X{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ht(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}const zi=new W,Ms=new x,_s=new x;class pr{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new U(512,512),this.map=null,this.mapPass=null,this.matrix=new W,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new U(1,1),this._viewportCount=1,this._viewports=[new Xt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Ms.setFromMatrixPosition(t.matrixWorld),e.position.copy(Ms),_s.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(_s),e.updateMatrixWorld(),zi.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(zi),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(zi)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class mr extends pr{constructor(){super(new ar(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class fr extends Ys{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(X.DEFAULT_UP),this.updateMatrix(),this.target=new X,this.shadow=new mr}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class yr extends Ys{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class xr{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ss(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Ss();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Ss(){return performance.now()}const zs=new W;class Zs{constructor(t,e,i=0,s=1/0){this.ray=new Ti(t,e),this.near=i,this.far=s,this.camera=null,this.layers=new qs,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return zs.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(zs),this}intersectObject(t,e=!0,i=[]){return Fi(t,this,i,e),i.sort(As),i}intersectObjects(t,e=!0,i=[]){for(let s=0,n=t.length;s<n;s++)Fi(t[s],this,i,e);return i.sort(As),i}}function As(l,t){return l.distance-t.distance}function Fi(l,t,e,i){let s=!0;if(l.layers.test(t.layers)&&l.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const n=l.children;for(let r=0,o=n.length;r<o;r++)Fi(n[r],t,e,!0)}}class gr{constructor(t=1,e=0,i=0){return this.radius=t,this.phi=e,this.theta=i,this}set(t,e,i){return this.radius=t,this.phi=e,this.theta=i,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,i){return this.radius=Math.sqrt(t*t+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,i),this.phi=Math.acos(et(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class wr extends js{constructor(t=10,e=10,i=4473924,s=8947848){i=new ht(i),s=new ht(s);const n=e/2,r=t/e,o=t/2,a=[],h=[];for(let d=0,p=0,m=-o;d<=e;d++,m+=r){a.push(-o,0,m,o,0,m),a.push(m,0,-o,m,0,o);const y=d===n?i:s;y.toArray(h,p),p+=3,y.toArray(h,p),p+=3,y.toArray(h,p),p+=3,y.toArray(h,p),p+=3}const c=new nt;c.setAttribute("position",new L(a,3)),c.setAttribute("color",new L(h,3));const u=new Ke({vertexColors:!0,toneMapped:!1});super(c,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class br extends js{constructor(t,e=16776960){const i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),s=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],n=new nt;n.setIndex(new qt(i,1)),n.setAttribute("position",new L(s,3)),super(n,new Ke({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){const e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}}class Mr extends Ut{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ks}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ks);function _r(l){return URL.canParse(l)&&(l.startsWith("http://")||l.startsWith("https://"))}async function Sr(l,t){return(await ti(l,t)).arrayBuffer()}function ti(l,t){if(typeof l=="string"){const e=ei(l);return dn.fetch(e,t)}return pn.fetchFile(l,t)}async function zr(l,t){return await(await ti(l,t)).json()}async function Ar(l,t){return(await ti(l,t)).text()}function Er(l){let t,e;if(l instanceof Response){const r=new URL(l.url);t=`${r.origin}${r.pathname}`,e=r.search}else if(l instanceof File)t=l.name;else if(l instanceof Blob)t="";else if(typeof l=="string"){const r=ei(l),o=new URL(r);t=`${o.origin}${o.pathname}`,e=o.search}else return l;const i=t.split("/"),s=i.pop(),n=i.join("/");return{baseUrl:t,dirname:n,fileext:s==null?void 0:s.split(".").at(-1),filename:s,queryString:e}}async function vr(l){return new Promise((t,e)=>{if(typeof l=="string")return ei(l);{const i=new FileReader;i.addEventListener("load",()=>t(i.result),!1),i.addEventListener("error",()=>e(i.error)),i.readAsDataURL(l)}})}const Gs={checkAbsoluteHost:_r,fetch:ti,fetchArrayBuffer:Sr,fetchJson:zr,fetchText:Ar,getContext:Er,toDataURL:vr};let Bi=null,$s={};function le(){if(!Bi)throw new Error("No configuration loaded");return Bi}function Cr(){return $s}async function Fr(l){return await Gs.fetchJson(l)}async function Br(l){l.crs_definitions||(console.warn("Configuration is not specifying CRS definitions. You should define the projections you use. See https://gitlab.com/giro3d/piero/-/issues/78 for more information."),l.crs_definitions={"EPSG:2154":"+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs","EPSG:3857":"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs","EPSG:3946":"+proj=lcc +lat_1=45.25 +lat_2=46.75 +lat_0=46 +lon_0=3 +x_0=1700000 +y_0=5200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs","EPSG:3948":"+proj=lcc +lat_0=48 +lon_0=3 +lat_1=47.25 +lat_2=48.75 +x_0=1700000 +y_0=7200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs","EPSG:4171":"+proj=longlat +ellps=GRS80 +no_defs +type=crs","EPSG:4326":"+proj=longlat +datum=WGS84 +no_defs +type=crs","IGNF:WGS84G":'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'});for(const[t,e]of Object.entries(l.crs_definitions))try{un.registerCRS(t,e)}catch(i){throw console.error(`Failed to register CRS "${t}" as "${e}".`),i}return Bi=l,Promise.resolve()}function Pr(l){$s=l}function Tr(l,t){const e=JSON.stringify(l,null,2),i=new Blob([e],{type:"application/json"});Qs(i,t)}function Qs(l,t){const e=URL.createObjectURL(l),i=document.createElement("a");i.href=e,i.download=t,i.innerHTML="Click here to download the file",document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(e)}let Js;function kr(l="http://localhost:8080/"){const t=Js??l;return t.at(-1)==="/"?t:t+"/"}function Ir(l){Js=l}const Ks={downloadAsJson:Tr,downloadBlob:Qs,getBaseUrl:kr,setBaseUrl:Ir};function Rr(l){const t=Wi.scale(l.ramp).mode("lab").colors(256).map(e=>{const i=Wi(e).gl();return new ht().setRGB(i[0],i[1],i[2],"srgb")});return new mn({colors:t,...l})}function Dr(l){const t=le();return l?new fn(l.crs??t.default_crs,l.x,l.y,l.z??0).as(t.default_crs):void 0}function Lr(l){const t=le();return l?new yn(l.crs??t.default_crs,l).as(t.default_crs):void 0}function ei(l){return l.startsWith("http://")||l.startsWith("https://")?l:new URL(l,Ks.getBaseUrl()).toString()}function Nr(l){var e;return((e=le().enabled_features)==null?void 0:e.includes(l))??!1}function Or(l,t){const e=l.isEntity3D?l.object3d:l;"dataset"in e.userData||(e.userData.dataset={});for(const[i,s]of Object.entries(t))e.userData.dataset[i]=s}const _e=l=>l!=null&&typeof l=="object",Vr=l=>_e(l)&&"href"in l,Wr=l=>_e(l)&&l.isColor,Hr=l=>_e(l)&&l.isVector3;class tn extends Ut{constructor(e){super();N(this,"config");N(this,"name");N(this,"onObjectPreloaded");N(this,"type");N(this,"uuid");N(this,"_isPreloaded");N(this,"_isPreloading");N(this,"_opacity");N(this,"_parent");N(this,"_visible");this.type=e.type,this.uuid=Hs.generateUUID(),this.name=e.name,this.onObjectPreloaded=e.onObjectPreloaded,this._parent=null,this._visible=e.visible??!1,this._opacity=e.opacity??1,this._isPreloading=!1,this._isPreloaded=!1,this.config=e}get isPreloaded(){return this._isPreloaded}set isPreloaded(e){this._isPreloaded=e,this.dispatchEvent({type:"isPreloaded"})}get isPreloading(){return this._isPreloading}set isPreloading(e){this._isPreloading=e,this.dispatchEvent({type:"isPreloading"})}get opacity(){return this._opacity}set opacity(e){this._opacity=e,this.dispatchEvent({type:"opacity"})}get parent(){return this._parent}set parent(e){this._parent=e}get visible(){return this._visible}set visible(e){this._visible=e,this.dispatchEvent({type:"visible"})}delete(){this.dispatchEvent({type:"delete"})}get(e){var i;return e in this.config&&this.config[e]!=null?this.config[e]:(i=this.parent)==null?void 0:i.get(e)}}class Li extends tn{constructor(e){super(e);N(this,"_children");this._children=sn(e.children,this),this._isPreloaded=!0}get children(){return this._children}set children(e){this._children.forEach(i=>i.parent=null),this._children=e,this._children.forEach(i=>{i.parent=this,i.visible=i.visible||this._visible})}leafs(){return this._children.map(e=>e.leafs()).flat()}traverse(e){var i;e(this),(i=this._children)==null||i.forEach(s=>s.traverse(e))}}N(Li,"isGroup",e=>_e(e)&&e.type==="group");class en extends tn{constructor(t){super(t)}leafs(){return[this]}traverse(t){t(this)}}function sn(l,t){return l.map(e=>{let i;return e.type==="group"?i=new Li(e):i=new en(e),t&&(i.parent=t,i.visible=i.visible||t.visible),i})}const Ni=Qe.defineStore("camera",()=>{const l=M.ref(),t=M.ref(new x),e=M.ref("orbit"),i=M.ref(!1);function s(){if(l.value===void 0)throw new Error("Cannot get cameraPosition");return l.value}function n(){return t.value}function r(m){l.value=m}function o(m,y){l.value=m,t.value.copy(y)}function a(){return e.value}function h(){return e}function c(m){e.value=m}function u(){return i.value}function d(m){i.value=m}function p(m){}return{getCamera3dPosition:n,getCameraPosition:s,getNavigationMode:a,getNavigationModeRef:h,isUserInteracting:u,lookTopDownAt:p,setCameraPosition:r,setCurrentPosition:o,setIsUserInteracting:d,setNavigationMode:c}}),Oi=Qe.defineStore("clippingBox",()=>{const l=M.ref(0),t=M.ref(new x(0,0,0)),e=M.ref(new x(0,0,0)),i=M.ref(!1),s=M.ref(!1),n=M.ref(!1),r=M.ref(new gt().setFromCenterAndSize(t.value,e.value));function o(){r.value=new gt().setFromCenterAndSize(t.value,e.value)}function a(y){i.value=y}function h(y){s.value=y}function c(y){l.value=y}function u(y){t.value=y,o()}function d(y){e.value=y,o()}function p(y){n.value=y}function m(y){r.value=y.clone();const w=new x,g=new x;y.getCenter(w),y.getSize(g),t.value=w,e.value=g}return{center:t,clippingBox:r,displayHelper:n,enable:i,invert:s,orientation:l,setCenter:u,setClippingBox:m,setDisplayHelper:p,setEnabled:a,setInverted:h,setOrientation:c,setSize:d,size:e}}),qr={class:"input-group"},Ur={class:"form-check form-switch"},Xr=["checked"],jr={class:"input-group"},Yr={class:"form-check form-switch"},Zr=["checked"],Gr={class:"input-group"},$r={class:"form-check form-switch"},Qr=["checked"],Jr={class:"accordion mt-3"},Kr={class:"accordion-item"},to={id:"clippingbox-size",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},eo={class:"accordion-body"},io={class:"d-flex justify-content-between align-items-end w-100"},so={class:"input-group mb-3"},no=["value"],ro=["value"],oo=["value"],ao={class:"input-group mb-3"},ho=["value"],lo=["value"],co=["value"],uo={class:"accordion-item"},po={id:"clippingbox-floorpreset",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},mo={class:"accordion-body"},fo={class:"row w-100"},yo={class:"col-sm-6"},xo={class:"input-group input-group-sm"},go={class:"row w-100"},wo={class:"col-sm-6"},bo={class:"input-group input-group-sm"},Mo={class:"row w-100"},_o={class:"col-sm-6"},So={class:"input-group input-group-sm"},zo=M.defineComponent({__name:"ClippingBox",setup(l){const t=le(),e=Oi(),i=Ni(),s=b=>Number.parseFloat(b.target.value);function n(){const{target:b}=i.getCameraPosition();e.setCenter(b.clone())}function r(b){const f=e.size.clone();f.setX(b),e.setSize(f)}function o(b){const f=e.size.clone();f.setY(b),e.setSize(f)}function a(b){const f=e.size.clone();f.setZ(b),e.setSize(f)}function h(b){const f=e.center.clone();f.setX(b),e.setCenter(f)}function c(b){const f=e.center.clone();f.setY(b),e.setCenter(f)}function u(b){const f=e.center.clone();f.setZ(b),e.setCenter(f)}const d=M.ref(t.analysis.clipping_box.floor_preset.altitude),p=M.ref(t.analysis.clipping_box.floor_preset.size),m=M.ref(t.analysis.clipping_box.floor_preset.floor);function y(){m.value-=1;const b=e.center.clone();b.setZ(g()),e.setCenter(b)}function w(){m.value+=1;const b=e.center.clone();b.setZ(g()),e.setCenter(b)}function g(){return d.value+(m.value+.5)*p.value}function _(){const{target:b}=i.getCameraPosition(),f=b.clone();f.z=g();const z=new x(1e3,1e3,p.value);e.setSize(z),e.setCenter(f)}return(b,f)=>(M.openBlock(),M.createElementBlock("div",null,[M.createElementVNode("div",qr,[M.createElementVNode("div",Ur,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).enable,type:"checkbox",role:"switch",id:"enable-clippingbox",onInput:f[0]||(f[0]=z=>M.unref(e).setEnabled(!M.unref(e).enable))},null,40,Xr),f[14]||(f[14]=M.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox"},"Enable clipping box",-1))])]),M.createElementVNode("div",jr,[M.createElementVNode("div",Yr,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).invert,type:"checkbox",role:"switch",id:"invert-clippingbox",onInput:f[1]||(f[1]=z=>M.unref(e).setInverted(!M.unref(e).invert))},null,40,Zr),f[15]||(f[15]=M.createElementVNode("label",{class:"form-check-label",for:"invert-clippingbox"},"Invert clipping box",-1))])]),M.createElementVNode("div",Gr,[M.createElementVNode("div",$r,[M.createElementVNode("input",{class:"form-check-input",checked:M.unref(e).displayHelper,type:"checkbox",role:"switch",id:"enable-clippingbox-helper",onInput:f[2]||(f[2]=z=>M.unref(e).setDisplayHelper(!M.unref(e).displayHelper))},null,40,Qr),f[16]||(f[16]=M.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox-helper"},"Show 3D helper",-1))])]),M.createElementVNode("div",Jr,[M.createElementVNode("div",Kr,[f[19]||(f[19]=M.createElementVNode("h2",{class:"accordion-header"},[M.createElementVNode("button",{class:"accordion-button",type:"button","data-bs-toggle":"collapse","data-bs-target":"#clippingbox-size","aria-expanded":"true","aria-controls":"clippingbox-size"}," Clipping box size ")],-1)),M.createElementVNode("div",to,[M.createElementVNode("div",eo,[M.createElementVNode("div",io,[f[17]||(f[17]=M.createElementVNode("label",{class:"form-label flex-grow"},"Center (x, y, z)",-1)),M.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[3]||(f[3]=z=>n())}," Set from view ")]),M.createElementVNode("div",so,[M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-x",value:M.unref(e).center.x,onInput:f[4]||(f[4]=z=>h(s(z)))},null,40,no),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-y",value:M.unref(e).center.y,onInput:f[5]||(f[5]=z=>c(s(z)))},null,40,ro),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-z",value:M.unref(e).center.z,onInput:f[6]||(f[6]=z=>u(s(z)))},null,40,oo)]),f[18]||(f[18]=M.createElementVNode("label",{class:"form-label"},"Size (x, y, z)",-1)),M.createElementVNode("div",ao,[M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-x",min:"1",value:M.unref(e).size.x,onInput:f[7]||(f[7]=z=>r(s(z)))},null,40,ho),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-y",min:"1",value:M.unref(e).size.y,onInput:f[8]||(f[8]=z=>o(s(z)))},null,40,lo),M.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-z",min:"1",value:M.unref(e).size.z,onInput:f[9]||(f[9]=z=>a(s(z)))},null,40,co)])])])]),M.createElementVNode("div",uo,[f[27]||(f[27]=M.createElementVNode("h2",{class:"accordion-header"},[M.createElementVNode("button",{class:"accordion-button",type:"button","data-bs-toggle":"collapse","data-bs-target":"#clippingbox-floorpreset","aria-expanded":"true","aria-controls":"clippingbox-floorpreset"}," Floor preset ")],-1)),M.createElementVNode("div",po,[M.createElementVNode("div",mo,[M.createElementVNode("div",fo,[f[21]||(f[21]=M.createElementVNode("label",{for:"floor-reference-altitude",class:"col-sm-6 col-form-label col-form-label-sm"},"Reference altitude",-1)),M.createElementVNode("div",yo,[M.createElementVNode("div",xo,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-reference-altitude","onUpdate:modelValue":f[10]||(f[10]=z=>d.value=z)},null,512),[[M.vModelText,d.value]]),f[20]||(f[20]=M.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),M.createElementVNode("div",go,[f[23]||(f[23]=M.createElementVNode("label",{for:"floor-size",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor size",-1)),M.createElementVNode("div",wo,[M.createElementVNode("div",bo,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-size","onUpdate:modelValue":f[11]||(f[11]=z=>p.value=z)},null,512),[[M.vModelText,p.value]]),f[22]||(f[22]=M.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),M.createElementVNode("div",Mo,[f[26]||(f[26]=M.createElementVNode("label",{for:"floor-number",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor number",-1)),M.createElementVNode("div",_o,[M.createElementVNode("div",So,[M.withDirectives(M.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-number","onUpdate:modelValue":f[12]||(f[12]=z=>m.value=z)},null,512),[[M.vModelText,m.value]]),M.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:w},[...f[24]||(f[24]=[M.createElementVNode("i",{class:"bi bi-arrow-up-short"},null,-1)])]),M.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:y},[...f[25]||(f[25]=[M.createElementVNode("i",{class:"bi bi-arrow-down-short"},null,-1)])])])])]),M.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[13]||(f[13]=z=>_())}," Set ")])])])])]))}}),ii=(l,t)=>{const e=l.__vccOpts||l;for(const[i,s]of t)e[i]=s;return e},Ao=ii(zo,[["__scopeId","data-v-803bbe4b"]]),Nt=new Zs,K=new x,kt=new x,O=new tt,Es={X:new x(1,0,0),Y:new x(0,1,0),Z:new x(0,0,1)},Ai={type:"change"},vs={type:"mouseDown",mode:null},Cs={type:"mouseUp",mode:null},Fs={type:"objectChange"};class Eo extends Mr{constructor(t,e=null){super(void 0,e);const i=new To(this);this._root=i;const s=new ko;this._gizmo=s,i.add(s);const n=new Io;this._plane=n,i.add(n);const r=this;function o(b,f){let z=f;Object.defineProperty(r,b,{get:function(){return z!==void 0?z:f},set:function(S){z!==S&&(z=S,n[b]=S,s[b]=S,r.dispatchEvent({type:b+"-changed",value:S}),r.dispatchEvent(Ai))}}),r[b]=f,n[b]=f,s[b]=f}o("camera",t),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const a=new x,h=new x,c=new tt,u=new tt,d=new x,p=new tt,m=new x,y=new x,w=new x,g=0,_=new x;o("worldPosition",a),o("worldPositionStart",h),o("worldQuaternion",c),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",m),o("pointEnd",y),o("rotationAxis",w),o("rotationAngle",g),o("eye",_),this._offset=new x,this._startNorm=new x,this._endNorm=new x,this._cameraScale=new x,this._parentPosition=new x,this._parentQuaternion=new tt,this._parentQuaternionInv=new tt,this._parentScale=new x,this._worldScaleStart=new x,this._worldQuaternionInv=new tt,this._worldScale=new x,this._positionStart=new x,this._quaternionStart=new tt,this._scaleStart=new x,this._getPointer=vo.bind(this),this._onPointerDown=Fo.bind(this),this._onPointerHover=Co.bind(this),this._onPointerMove=Bo.bind(this),this._onPointerUp=Po.bind(this),e!==null&&this.connect()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(t){if(this.object===void 0||this.dragging===!0)return;t!==null&&Nt.setFromCamera(t,this.camera);const e=Ei(this._gizmo.picker[this.mode],Nt);e?this.axis=e.object.name:this.axis=null}pointerDown(t){if(!(this.object===void 0||this.dragging===!0||t!=null&&t.button!==0)&&this.axis!==null){t!==null&&Nt.setFromCamera(t,this.camera);const e=Ei(this._plane,Nt,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,vs.mode=this.mode,this.dispatchEvent(vs)}}pointerMove(t){const e=this.axis,i=this.mode,s=this.object;let n=this.space;if(i==="scale"?n="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(n="world"),s===void 0||e===null||this.dragging===!1||t!==null&&t.button!==-1)return;t!==null&&Nt.setFromCamera(t,this.camera);const r=Ei(this._plane,Nt,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(n==="local"&&(s.position.applyQuaternion(O.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),n==="world"&&(s.parent&&s.position.add(K.setFromMatrixPosition(s.parent.matrixWorld)),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(K.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if(i==="scale"){if(e.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),kt.set(o,o,o)}else K.copy(this.pointStart),kt.copy(this.pointEnd),K.applyQuaternion(this._worldQuaternionInv),kt.applyQuaternion(this._worldQuaternionInv),kt.divide(K),e.search("X")===-1&&(kt.x=1),e.search("Y")===-1&&(kt.y=1),e.search("Z")===-1&&(kt.z=1);s.scale.copy(this._scaleStart).multiply(kt),this.scaleSnap&&(e.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(K.setFromMatrixPosition(this.camera.matrixWorld));let a=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(K.copy(this.rotationAxis).cross(this.eye))*o):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(Es[e]),K.copy(Es[e]),n==="local"&&K.applyQuaternion(this.worldQuaternion),K.cross(this.eye),K.length()===0?a=!0:this.rotationAngle=this._offset.dot(K.normalize())*o),(e==="E"||a)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&e!=="E"&&e!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(O.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(O.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ai),this.dispatchEvent(Fs)}}pointerUp(t){t!==null&&t.button!==0||(this.dragging&&this.axis!==null&&(Cs.mode=this.mode,this.dispatchEvent(Cs)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ai),this.dispatchEvent(Fs),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Nt}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function vo(l){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:l.button};{const t=this.domElement.getBoundingClientRect();return{x:(l.clientX-t.left)/t.width*2-1,y:-(l.clientY-t.top)/t.height*2+1,button:l.button}}}function Co(l){if(this.enabled)switch(l.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(l));break}}function Fo(l){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(l)),this.pointerDown(this._getPointer(l)))}function Bo(l){this.enabled&&this.pointerMove(this._getPointer(l))}function Po(l){this.enabled&&(this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(l)))}function Ei(l,t,e){const i=t.intersectObject(l,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||e)return i[s];return!1}const Ue=new jt,D=new x(0,1,0),Bs=new x(0,0,0),Ps=new W,Xe=new tt,Ye=new tt,xt=new x,Ts=new W,xe=new x(1,0,0),Ot=new x(0,1,0),ge=new x(0,0,1),je=new x,fe=new x,ye=new x;class To extends X{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;e.object!==void 0&&(e.object.updateMatrixWorld(),e.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class ko extends X{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new Me({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Ke({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const s=e.clone();s.opacity=.5;const n=t.clone();n.color.setHex(16711680);const r=t.clone();r.color.setHex(65280);const o=t.clone();o.color.setHex(255);const a=t.clone();a.color.setHex(16711680),a.opacity=.5;const h=t.clone();h.color.setHex(65280),h.opacity=.5;const c=t.clone();c.color.setHex(255),c.opacity=.5;const u=t.clone();u.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25,t.clone().color.setHex(16776960);const m=t.clone();m.color.setHex(7895160);const y=new J(0,.04,.1,12);y.translate(0,.05,0);const w=new Z(.08,.08,.08);w.translate(0,.04,0);const g=new nt;g.setAttribute("position",new L([0,0,0,1,0,0],3));const _=new J(.0075,.0075,.5,3);_.translate(0,.25,0);function b(R,G){const q=new Vt(R,.0075,3,64,G*Math.PI*2);return q.rotateY(Math.PI/2),q.rotateX(Math.PI/2),q}function f(){const R=new nt;return R.setAttribute("position",new L([0,0,0,1,1,1],3)),R}const z={X:[[new C(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new C(y,n),[-.5,0,0],[0,0,Math.PI/2]],[new C(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new C(y,r),[0,.5,0]],[new C(y,r),[0,-.5,0],[Math.PI,0,0]],[new C(_,r)]],Z:[[new C(y,o),[0,0,.5],[Math.PI/2,0,0]],[new C(y,o),[0,0,-.5],[-Math.PI/2,0,0]],[new C(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new C(new oe(.1,0),u.clone()),[0,0,0]]],XY:[[new C(new Z(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new C(new Z(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new C(new J(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new C(new J(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C(new J(.2,0,.6,4),i),[0,.3,0]],[new C(new J(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C(new J(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new C(new J(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new C(new oe(.2,0),i)]],XY:[[new C(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new C(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new C(new oe(.01,2),s),null,null,null,"helper"]],END:[[new C(new oe(.01,2),s),null,null,null,"helper"]],DELTA:[[new At(f(),s),null,null,null,"helper"]],X:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new At(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new At(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},E={XYZE:[[new C(b(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new C(b(.5,.5),n)]],Y:[[new C(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new C(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new C(b(.75,1),d),null,[0,Math.PI/2,0]]]},v={AXIS:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},F={XYZE:[[new C(new Ri(.25,10,8),i)]],X:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new C(new Vt(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new C(new Vt(.75,.1,2,24),i)]]},P={X:[[new C(w,n),[.5,0,0],[0,0,-Math.PI/2]],[new C(_,n),[0,0,0],[0,0,-Math.PI/2]],[new C(w,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new C(w,r),[0,.5,0]],[new C(_,r)],[new C(w,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new C(w,o),[0,0,.5],[Math.PI/2,0,0]],[new C(_,o),[0,0,0],[Math.PI/2,0,0]],[new C(w,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new C(new Z(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new C(new Z(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C(new Z(.1,.1,.1),u.clone())]]},B={X:[[new C(new J(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new C(new J(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new C(new J(.2,0,.6,4),i),[0,.3,0]],[new C(new J(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new C(new J(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new C(new J(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new C(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new C(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new C(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new C(new Z(.2,.2,.2),i),[0,0,0]]]},T={X:[[new At(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new At(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new At(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function k(R){const G=new X;for(const q in R)for(let it=R[q].length;it--;){const I=R[q][it][0].clone(),V=R[q][it][1],j=R[q][it][2],dt=R[q][it][3],Yt=R[q][it][4];I.name=q,I.tag=Yt,V&&I.position.set(V[0],V[1],V[2]),j&&I.rotation.set(j[0],j[1],j[2]),dt&&I.scale.set(dt[0],dt[1],dt[2]),I.updateMatrix();const Se=I.geometry.clone();Se.applyMatrix4(I.matrix),I.geometry=Se,I.renderOrder=1/0,I.position.set(0,0,0),I.rotation.set(0,0,0),I.scale.set(1,1,1),G.add(I)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=k(z)),this.add(this.gizmo.rotate=k(E)),this.add(this.gizmo.scale=k(P)),this.add(this.picker.translate=k(S)),this.add(this.picker.rotate=k(F)),this.add(this.picker.scale=k(B)),this.add(this.helper.translate=k(A)),this.add(this.helper.rotate=k(v)),this.add(this.helper.scale=k(T)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Ye;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let n=0;n<s.length;n++){const r=s[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(O.setFromEuler(Ue.set(0,0,0)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(O.setFromEuler(Ue.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(O.setFromEuler(Ue.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(O),Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(O.setFromEuler(Ue.set(0,Math.PI/2,0)),D.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Ps.lookAt(Bs,D,Ot)),r.quaternion.multiply(O),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),K.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),K.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(K),r.visible=this.dragging):(r.quaternion.copy(i),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(D.copy(ge).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(D.copy(xe).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(D.copy(Ot).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(Xe.copy(i),D.copy(this.eye).applyQuaternion(O.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Ps.lookAt(this.eye,Bs,Ot)),r.name==="X"&&(O.setFromAxisAngle(xe,Math.atan2(-D.y,D.z)),O.multiplyQuaternions(Xe,O),r.quaternion.copy(O)),r.name==="Y"&&(O.setFromAxisAngle(Ot,Math.atan2(D.x,D.z)),O.multiplyQuaternions(Xe,O),r.quaternion.copy(O)),r.name==="Z"&&(O.setFromAxisAngle(ge,Math.atan2(D.y,D.x)),O.multiplyQuaternions(Xe,O),r.quaternion.copy(O))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(a){return r.name===a}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(t)}}class Io extends C{constructor(){super(new Je(1e5,1e5,2,2),new Me({visible:!1,wireframe:!0,side:Is,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),je.copy(xe).applyQuaternion(e==="local"?this.worldQuaternion:Ye),fe.copy(Ot).applyQuaternion(e==="local"?this.worldQuaternion:Ye),ye.copy(ge).applyQuaternion(e==="local"?this.worldQuaternion:Ye),D.copy(fe),this.mode){case"translate":case"scale":switch(this.axis){case"X":D.copy(this.eye).cross(je),xt.copy(je).cross(D);break;case"Y":D.copy(this.eye).cross(fe),xt.copy(fe).cross(D);break;case"Z":D.copy(this.eye).cross(ye),xt.copy(ye).cross(D);break;case"XY":xt.copy(ye);break;case"YZ":xt.copy(je);break;case"XZ":D.copy(ye),xt.copy(fe);break;case"XYZ":case"E":xt.set(0,0,0);break}break;case"rotate":default:xt.set(0,0,0)}xt.length()===0?this.quaternion.copy(this.cameraQuaternion):(Ts.lookAt(K.set(0,0,0),xt,D),this.quaternion.setFromRotationMatrix(Ts)),super.updateMatrixWorld(t)}}function nn(l){const t=M.shallowReactive(l);return t.type==="group"&&(t.children=M.shallowReactive(t.children.map(e=>nn(e)))),t}const rn=Qe.defineStore("datasets",()=>{const l=le(),t=M.shallowReactive(sn(l.datasets).map(S=>nn(S))),e=M.computed(()=>t.map(S=>S.leafs()).flat()),i=M.computed(()=>e.value.length),s=new Map,n=new Map,r=M.ref([]);function o(S){r.value=[...r.value,{...S,mustBePreloaded:S.mustBePreloaded??!1,mustBeVisible:S.mustBeVisible??!1}]}function a(){return t}function h(){return e.value}function c(S){const A=M.shallowReactive(S);return t.push(A),A}function u(S,A){s.set(S.uuid,A)}function d(S,A){n.set(S.uuid,A)}function p(S){const A=S.parent!=null?S.parent.children:t;A.splice(A.indexOf(S),1)}function m(S){const A=new gt;return S.traverse(E=>{var T;const v=s.get(E.uuid),F=v==null?void 0:v.getBoundingBox();if(F&&!F.isEmpty()){A.union(F);return}const P=n.get(E.uuid),B=(T=P==null?void 0:P.getExtent())==null?void 0:T.as(l.default_crs);if(B&&B.isValid()){const k=B.toBox3(0,0);A.union(k);return}}),A}function y(S){return s.get(S.uuid)}function w(S){return n.get(S.uuid)}function g(S){}function _(S,A){}function b(S){}function f(S){}function z(S,A){return r.value.filter(v=>!(v.predicate!=null&&!v.predicate(S)||v.mustBeVisible&&!A.isVisible||v.mustBePreloaded&&!A.isPreloaded))}return{add:c,attachEntity:u,attachLayer:d,count:i,getBoundingBox:m,getCustomActions:z,getDatasets:h,getEntity:y,getLayer:w,getTree:a,importFromFile:g,registerCustomAction:o,remove:p,setVisible:_,toggleGrid:b,toggleMask:f}}),Ro=new Me({color:"yellow",opacity:.1,transparent:!0});class Do{constructor(t){N(this,"_cameraStore",Ni());N(this,"_clippingBox",null);N(this,"_clippingBoxHelper",null);N(this,"_clippingBoxMesh",null);N(this,"_datasetStore",rn());N(this,"_previousTransformControls",this._cameraStore.getNavigationMode());N(this,"_store",Oi());N(this,"_transformControls",null);N(this,"_volumeHelpers",new Xs);this.context=t,t.events.addEventListener("ready",this.initialize.bind(this))}clipToDataset(t){const e=this._datasetStore.getBoundingBox(t);e!=null&&e.isEmpty()||this.setClippingBox(e)}dispose(){this.context.view.getInstance().scene.remove(this._volumeHelpers),this.disposeClippingBox()}isClippingBoxEnabled(){return this._store.enable}setClippingBox(t){t.isEmpty()||(this._store.setClippingBox(t),this._store.setEnabled(!0))}applyClippingPlanes(){const t=this._store.enable?this.getPlanesFromBoxSides():[];for(const e of this._datasetStore.getDatasets()){const i=this._datasetStore.getEntity(e);i&&(i.clippingPlanes=t,i.traverseMaterials(s=>{s.clipIntersection=this._store.invert}),this.context.view.getInstance().notifyChange(i))}}createClippingBox(t,e){this._clippingBox=new gt,this._clippingBox.setFromCenterAndSize(t,e);const i=this.context.view.getInstance();if(this._store.displayHelper){const s=new Z(e.x,e.y,e.z);this._clippingBoxMesh=new C(s,Ro),this._clippingBoxHelper=new br(this._clippingBox,new ht("yellow")),this._clippingBoxMesh.renderOrder=2,this._clippingBoxMesh.position.copy(t),this._clippingBoxMesh.updateMatrixWorld(),this._clippingBoxHelper.updateMatrixWorld(),this._transformControls=new Eo(i.view.camera,i.domElement),this._transformControls.addEventListener("change",()=>{this._cameraStore.getNavigationMode()!=="disabled"||this._clippingBoxMesh===null||(this._store.center.copy(this._clippingBoxMesh.position),this.moveClippingBox())}),this._transformControls.addEventListener("dragging-changed",n=>{n.value!=null?(this._previousTransformControls=this._cameraStore.getNavigationMode(),this._cameraStore.setNavigationMode("disabled"),this._cameraStore.setIsUserInteracting(!0)):(this._cameraStore.setNavigationMode(this._previousTransformControls),setTimeout(()=>this._cameraStore.setIsUserInteracting(!1),0))}),this._volumeHelpers.add(this._clippingBoxHelper),this._volumeHelpers.add(this._clippingBoxMesh),this._transformControls.attach(this._clippingBoxMesh),this._transformControls.getHelper().updateMatrixWorld(),i.scene.add(this._transformControls.getHelper()),i.notifyChange()}}disposeClippingBox(){var t,e,i,s,n,r,o,a;(t=this._transformControls)==null||t.detach(),(e=this._transformControls)==null||e.getHelper().removeFromParent(),(i=this._transformControls)==null||i.dispose(),(n=(s=this._clippingBoxMesh)==null?void 0:s.geometry)==null||n.dispose(),(r=this._clippingBoxMesh)==null||r.removeFromParent(),(o=this._clippingBoxHelper)==null||o.removeFromParent(),(a=this._clippingBoxHelper)==null||a.dispose(),this.context.view.getInstance().notifyChange()}getPlanesFromBoxSides(){if(this._clippingBox===null)throw new Error("No clippingBox defined");const t=[];return t.push(new at(new x(0,0,1),-this._clippingBox.min.z)),t.push(new at(new x(0,0,-1),+this._clippingBox.max.z)),t.push(new at(new x(1,0,0),-this._clippingBox.min.x)),t.push(new at(new x(-1,0,0),+this._clippingBox.max.x)),t.push(new at(new x(0,1,0),-this._clippingBox.min.y)),t.push(new at(new x(0,-1,0),+this._clippingBox.max.y)),this._store.invert&&t.forEach(e=>e.negate()),t}initialize(){this.context.view.getInstance().scene.add(this._volumeHelpers),this._clippingBox=null,this._clippingBoxHelper=null,this._clippingBoxMesh=null,this._transformControls=null,this._previousTransformControls=this._cameraStore.getNavigationMode(),this._store.$onAction(({after:e,name:i})=>{e(()=>{switch(i){case"setCenter":this.moveClippingBox();break;case"setClippingBox":case"setDisplayHelper":case"setEnabled":case"setSize":this.updateClippingBox();break;case"setInverted":this.applyClippingPlanes();break}})}),this._datasetStore.$onAction(({after:e,name:i})=>{e(()=>{switch(i){case"attachEntity":this.applyClippingPlanes();break}})})}moveClippingBox(){var e,i,s,n,r;const t=this.context.view.getInstance();this._store.enable&&(this._clippingBox===null&&this.createClippingBox(this._store.center,this._store.size),(e=this._clippingBox)==null||e.setFromCenterAndSize(this._store.center,this._store.size),this._store.displayHelper&&((i=this._clippingBoxMesh)==null||i.position.copy(this._store.center),(s=this._clippingBoxMesh)==null||s.updateMatrixWorld(),(n=this._clippingBoxHelper)==null||n.updateMatrixWorld(),(r=this._transformControls)==null||r.getHelper().updateMatrixWorld(),t.notifyChange(this._volumeHelpers),t.notifyChange(this._transformControls))),this.applyClippingPlanes()}updateClippingBox(){this.disposeClippingBox(),this._store.enable&&this.createClippingBox(this._store.center,this._store.size),this.applyClippingPlanes()}}const on="builtin-clipping-box-analysis";class Lo{constructor(){N(this,"id",on);N(this,"name","Clipping box");N(this,"_manager",null);N(this,"_store",null)}getClippingBox(){if(this._store==null)throw new Error("module is not initialized");return this._store.clippingBox}initialize(t){t.analysis.registerTool({component:Ao,icon:"bi-bounding-box",name:"Clipping box"}),this._store=Oi();const e=new Do(t);t.datasets.registerDatasetAction({action:i=>e.clipToDataset(i),icon:"bi-bounding-box",mustBePreloaded:!0,title:"Clip to"}),this._manager=e}isClippingBoxEnabled(){if(this._store==null)throw new Error("module is not initialized");return this._store.enable}isClippingBoxInverted(){if(this._store==null)throw new Error("module is not initialized");return this._store.invert}setClippingBox(t){if(this._manager==null)throw new Error("module is not initialized");this._manager.setClippingBox(t)}}const No=Qe.defineStore("modules",()=>{const l=M.shallowRef([]);function t(s){l.value=s}function e(){return l.value}function i(s){for(const n of l.value)if(n.id===s)return n;return null}return{getLoadedModules:e,getModule:i,setLoadedModules:t}}),Oo={class:"form-check form-switch"},Vo=["checked"],Wo=M.defineComponent({__name:"SwitchToggle",props:["modelValue"],emits:["update:modelValue"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("div",Oo,[M.createElementVNode("input",{class:"form-check-input",type:"checkbox",role:"switch",checked:l.modelValue,onInput:e[0]||(e[0]=i=>t.$emit("update:modelValue",i.target.checked))},null,40,Vo),M.renderSlot(t.$slots,"default")]))}}),Ho=["title"],qo=["title"],an=M.defineComponent({__name:"Icon",props:{icon:{},title:{}},setup(l){return(t,e)=>t.icon.startsWith("bi-")?(M.openBlock(),M.createElementBlock("i",{key:0,class:M.normalizeClass(["bi",t.icon]),title:t.title},null,10,Ho)):(M.openBlock(),M.createElementBlock("i",{key:1,class:M.normalizeClass(t.icon),title:t.title},null,10,qo))}}),Uo=["title"],hn=M.defineComponent({__name:"ButtonWithIcon",props:{icon:{},text:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("button",{title:t.title,class:"btn",type:"button",onClick:e[0]||(e[0]=i=>t.$emit("click",i))},[t.icon?(M.openBlock(),M.createBlock(an,{key:0,icon:t.icon},null,8,["icon"])):M.createCommentVNode("",!0),M.createTextVNode(" "+M.toDisplayString(t.text),1)],8,Uo))}}),Xo={},jo={class:"icons text-nowrap d-flex justify-content-evenly"};function Yo(l,t){return M.openBlock(),M.createElementBlock("div",jo,[M.renderSlot(l.$slots,"default")])}const Zo=ii(Xo,[["render",Yo]]),Go=M.defineComponent({__name:"IconListButton",props:{icon:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createBlock(hn,{title:t.title,icon:t.icon,onClick:e[0]||(e[0]=i=>t.$emit("click",i)),class:"btn-link link-secondary link-opacity-75 link-opacity-100-hover p-0 border-0"},null,8,["title","icon"]))}}),$o=ii(Go,[["__scopeId","data-v-10315937"]]),Qo=["title","disabled"],Jo=M.defineComponent({__name:"ListLabelButton",props:{disabled:{type:Boolean},text:{},title:{}},emits:["click"],setup(l){return(t,e)=>(M.openBlock(),M.createElementBlock("button",{class:M.normalizeClass(["btn btn-link d-inline-block flex-fill text-start text-nowrap text-truncate overflow-hidden px-1 py-0 link-underline link-underline-opacity-0 link-underline-opacity-75-hover",t.$attrs.class]),title:t.title??t.text,disabled:!!t.disabled,type:"button",onClick:e[0]||(e[0]=i=>t.$emit("click",i))},M.toDisplayString(t.text),11,Qo))}});function Ko(l,t){const e=M.ref(l[t]);return M.watch(()=>l[t],i=>{e.value=i}),e}exports.AmbientLight=yr;exports.Box3=gt;exports.BufferGeometry=nt;exports.ClippingBoxAnalysis=Lo;exports.Clock=xr;exports.Color=ht;exports.Datagroup=Li;exports.Dataset=en;exports.DirectionalLight=fr;exports.DoubleSide=Is;exports.Download=Ks;exports.EventDispatcher=Ut;exports.Fetcher=Gs;exports.FileLoader=dr;exports.Float32BufferAttribute=L;exports.FrontSide=Ze;exports.GridHelper=wr;exports.Group=Xs;exports.IconList=Zo;exports.IconListButton=$o;exports.Loader=Di;exports.MathUtils=Hs;exports.Matrix4=W;exports.Mesh=C;exports.MeshBasicMaterial=Me;exports.MeshLambertMaterial=hr;exports.Object3D=X;exports.Plane=at;exports.PlaneGeometry=Je;exports.Quaternion=tt;exports.Raycaster=Zs;exports.SRGBColorSpace=ut;exports.Sphere=be;exports.Spherical=gr;exports.Vector2=U;exports.Vector3=x;exports.Vector4=Xt;exports._export_sfc=ii;exports._sfc_main=Wo;exports._sfc_main$1=hn;exports._sfc_main$2=an;exports._sfc_main$3=Jo;exports.fillObject3DUserData=Or;exports.getColorMap=Rr;exports.getConfig=le;exports.getCoordinates=Dr;exports.getDynamicStyles=Cr;exports.getExtent=Lr;exports.getPublicFolderUrl=ei;exports.hasExperimentalFeature=Nr;exports.isColor=Wr;exports.isLink=Vr;exports.isObject=_e;exports.isVector3=Hr;exports.loadRemoteConfiguration=Fr;exports.moduleId=on;exports.refAndWatch=Ko;exports.setConfiguration=Br;exports.setDynamicStyles=Pr;exports.useCameraStore=Ni;exports.useDatasetStore=rn;exports.useModuleStore=No;
6
6
  //# sourceMappingURL=Components.cjs.js.map