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

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.
Files changed (43) hide show
  1. package/dist/Components.cjs.js +3 -2
  2. package/dist/Components.cjs.js.map +1 -1
  3. package/dist/Components.es.js +3193 -1778
  4. package/dist/Components.es.js.map +1 -1
  5. package/dist/assets/piero.css +2 -2
  6. package/dist/index.cjs.js +7 -7
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.es.js +3192 -4319
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/modules.cjs.js +1 -2
  11. package/dist/modules.cjs.js.map +1 -1
  12. package/dist/modules.es.js +981 -965
  13. package/dist/modules.es.js.map +1 -1
  14. package/dist/src/api/SearchApi.d.ts +34 -0
  15. package/dist/src/api/ViewApi.d.ts +2 -0
  16. package/dist/src/api/WidgetApi.d.ts +17 -0
  17. package/dist/src/api/index.d.ts +2 -1
  18. package/dist/src/components/CoordinateInput.vue.d.ts +31 -0
  19. package/dist/src/components/SearchOverlay.vue.d.ts +4 -5
  20. package/dist/src/context.d.ts +10 -0
  21. package/dist/src/events.d.ts +7 -1
  22. package/dist/src/modules/OpenLayersMinimap.d.ts +7 -0
  23. package/dist/src/modules/PostProcessEntities.d.ts +16 -0
  24. package/dist/src/modules/crossSectionAnalysis/CrossSection.vue.d.ts +1 -1
  25. package/dist/src/modules/crossSectionAnalysis/CrossSectionHelper.d.ts +4 -0
  26. package/dist/src/modules/crossSectionAnalysis/CrossSectionManager.d.ts +7 -0
  27. package/dist/src/modules/crossSectionAnalysis/store.d.ts +22 -2
  28. package/dist/src/modules/geocoding/CoordinatesSearch.d.ts +7 -0
  29. package/dist/src/modules/geocoding/FrenchBanGeocoder.d.ts +10 -0
  30. package/dist/src/modules/index.d.ts +5 -1
  31. package/dist/src/modules/minimap/OpenLayersMinimapComponent.vue.d.ts +8 -0
  32. package/dist/src/services/CameraController.d.ts +3 -3
  33. package/dist/src/services/Giro3DManager.d.ts +2 -0
  34. package/dist/src/services/SceneCursorManager.d.ts +19 -0
  35. package/dist/src/stores/giro3d.d.ts +1 -7
  36. package/dist/src/stores/search.d.ts +12 -0
  37. package/dist/src/stores/widgets.d.ts +12 -0
  38. package/dist/src/utils/Types.d.ts +1 -0
  39. package/package.json +2 -2
  40. package/dist/src/components/MinimapView.vue.d.ts +0 -4
  41. package/dist/src/providers/BanProvider.d.ts +0 -11
  42. package/dist/src/providers/Geocoding.d.ts +0 -7
  43. package/dist/src/services/MinimapController.d.ts +0 -19
@@ -1,6 +1,7 @@
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 jn=Object.defineProperty;var Yn=(o,t,e)=>t in o?jn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var F=(o,t,e)=>Yn(o,typeof t!="symbol"?t+"":t,e);const Zn=require("@giro3d/giro3d/core/picking/PickPointsAt"),Gn=require("@giro3d/giro3d/core/picking/PickTilesAt"),ln=require("@giro3d/giro3d/entities/Map"),ci=require("@giro3d/giro3d/entities/Shape"),v=require("vue"),$n=require("@giro3d/giro3d/core/Instance"),Qn=require("@giro3d/giro3d/utils/Fetcher"),Jn=require("@loaders.gl/core"),Kn=require("@giro3d/giro3d/core/ColorMap"),ue=require("@giro3d/giro3d/core/geographic/Coordinates"),cn=require("@giro3d/giro3d/core/geographic/Extent"),ps=require("chroma-js"),ye=require("pinia"),ke=require("@giro3d/giro3d/core/layer/ColorLayer"),Fe=require("@giro3d/giro3d/core/layer/ElevationLayer"),tr=require("@giro3d/giro3d/core/layer/Interpretation"),un=require("@giro3d/giro3d/core/layer/MaskLayer"),ds=require("@giro3d/giro3d/formats/BilFormat"),er=require("@giro3d/giro3d/formats/GeoTIFFFormat"),ir=require("@giro3d/giro3d/formats/MapboxTerrainFormat"),sr=require("@giro3d/giro3d/sources/GeoTIFFSource"),Kt=require("@giro3d/giro3d/sources/TiledImageSource"),De=require("@giro3d/giro3d/sources/VectorSource"),ms=require("@giro3d/giro3d/sources/VectorTileSource"),Ae=require("ol/format"),pe=require("ol/source"),nr=require("ol/source/WMTS"),tt=require("ol/style");/**
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 pn="170",ui=0,rr=1,dn=2,fs=1,ys=100,xs=204,gs=205,ws=3,mn=0,fn=300,bs=1e3,Re=1001,Ms=1002,or=1006,ar=1008,hr=1009,lr=1015,cr=1023,ur=0,yn="",ut="srgb",xn="srgb-linear",gn="linear",Yi="srgb",te=7680,_s=519,Ss=35044,Xt=2e3,Zi=2001;class St{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 Q=["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 vs=1234567;const wn=Math.PI/180,bn=180/Math.PI;function xe(){const o=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Q[o&255]+Q[o>>8&255]+Q[o>>16&255]+Q[o>>24&255]+"-"+Q[t&255]+Q[t>>8&255]+"-"+Q[t>>16&15|64]+Q[t>>24&255]+"-"+Q[e&63|128]+Q[e>>8&255]+"-"+Q[e>>16&255]+Q[e>>24&255]+Q[i&255]+Q[i>>8&255]+Q[i>>16&255]+Q[i>>24&255]).toLowerCase()}function it(o,t,e){return Math.max(t,Math.min(e,o))}function ts(o,t){return(o%t+t)%t}function pr(o,t,e,i,s){return i+(o-t)*(s-i)/(e-t)}function dr(o,t,e){return o!==t?(e-o)/(t-o):0}function Be(o,t,e){return(1-e)*o+e*t}function mr(o,t,e,i){return Be(o,t,1-Math.exp(-e*i))}function fr(o,t=1){return t-Math.abs(ts(o,t*2)-t)}function yr(o,t,e){return o<=t?0:o>=e?1:(o=(o-t)/(e-t),o*o*(3-2*o))}function xr(o,t,e){return o<=t?0:o>=e?1:(o=(o-t)/(e-t),o*o*o*(o*(o*6-15)+10))}function gr(o,t){return o+Math.floor(Math.random()*(t-o+1))}function wr(o,t){return o+Math.random()*(t-o)}function br(o){return o*(.5-Math.random())}function Mr(o){o!==void 0&&(vs=o);let t=vs+=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 _r(o){return o*wn}function Sr(o){return o*bn}function vr(o){return(o&o-1)===0&&o!==0}function zr(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function Ar(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function Cr(o,t,e,i,s){const n=Math.cos,r=Math.sin,a=n(e/2),h=r(e/2),l=n((t+i)/2),c=r((t+i)/2),p=n((t-i)/2),u=r((t-i)/2),d=n((i-t)/2),m=r((i-t)/2);switch(s){case"XYX":o.set(a*c,h*p,h*u,a*l);break;case"YZY":o.set(h*u,a*c,h*p,a*l);break;case"ZXZ":o.set(h*p,h*u,a*c,a*l);break;case"XZX":o.set(a*c,h*m,h*d,a*l);break;case"YXY":o.set(h*d,a*c,h*m,a*l);break;case"ZYZ":o.set(h*m,h*d,a*c,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function de(o,t){switch(t.constructor){case Float32Array:return o;case Uint32Array:return o/4294967295;case Uint16Array:return o/65535;case Uint8Array:return o/255;case Int32Array:return Math.max(o/2147483647,-1);case Int16Array:return Math.max(o/32767,-1);case Int8Array:return Math.max(o/127,-1);default:throw new Error("Invalid component type.")}}function rt(o,t){switch(t.constructor){case Float32Array:return o;case Uint32Array:return Math.round(o*4294967295);case Uint16Array:return Math.round(o*65535);case Uint8Array:return Math.round(o*255);case Int32Array:return Math.round(o*2147483647);case Int16Array:return Math.round(o*32767);case Int8Array:return Math.round(o*127);default:throw new Error("Invalid component type.")}}const es={DEG2RAD:wn,RAD2DEG:bn,generateUUID:xe,clamp:it,euclideanModulo:ts,mapLinear:pr,inverseLerp:dr,lerp:Be,damp:mr,pingpong:fr,smoothstep:yr,smootherstep:xr,randInt:gr,randFloat:wr,randFloatSpread:br,seededRandom:Mr,degToRad:_r,radToDeg:Sr,isPowerOfTwo:vr,ceilPowerOfTwo:zr,floorPowerOfTwo:Ar,setQuaternionFromProperEuler:Cr,normalize:rt,denormalize:de};class X{constructor(t=0,e=0){X.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(it(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 kt{constructor(t,e,i,s,n,r,a,h,l){kt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,h,l)}set(t,e,i,s,n,r,a,h,l){const c=this.elements;return c[0]=t,c[1]=s,c[2]=a,c[3]=e,c[4]=n,c[5]=h,c[6]=i,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[3],h=i[6],l=i[1],c=i[4],p=i[7],u=i[2],d=i[5],m=i[8],y=s[0],x=s[3],w=s[6],b=s[1],g=s[4],f=s[7],_=s[2],S=s[5],z=s[8];return n[0]=r*y+a*b+h*_,n[3]=r*x+a*g+h*S,n[6]=r*w+a*f+h*z,n[1]=l*y+c*b+p*_,n[4]=l*x+c*g+p*S,n[7]=l*w+c*f+p*z,n[2]=u*y+d*b+m*_,n[5]=u*x+d*g+m*S,n[8]=u*w+d*f+m*z,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],h=t[6],l=t[7],c=t[8];return e*r*c-e*a*l-i*n*c+i*a*h+s*n*l-s*r*h}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],h=t[6],l=t[7],c=t[8],p=c*r-a*l,u=a*h-c*n,d=l*n-r*h,m=e*p+i*u+s*d;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=p*y,t[1]=(s*l-c*i)*y,t[2]=(a*i-s*r)*y,t[3]=u*y,t[4]=(c*e-s*h)*y,t[5]=(s*n-a*e)*y,t[6]=d*y,t[7]=(i*h-l*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,a){const h=Math.cos(n),l=Math.sin(n);return this.set(i*h,i*l,-i*(h*r+l*a)+r+t,-s*l,s*h,-s*(-l*r+h*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Mi.makeScale(t,e)),this}rotate(t){return this.premultiply(Mi.makeRotation(-t)),this}translate(t,e){return this.premultiply(Mi.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 Mi=new kt;function Er(o){for(let t=o.length-1;t>=0;--t)if(o[t]>=65535)return!0;return!1}function zs(o){return document.createElementNS("http://www.w3.org/1999/xhtml",o)}const mt={enabled:!0,workingColorSpace:xn,spaces:{},convert:function(o,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===Yi&&(o.r=Bt(o.r),o.g=Bt(o.g),o.b=Bt(o.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(o.applyMatrix3(this.spaces[t].toXYZ),o.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===Yi&&(o.r=fe(o.r),o.g=fe(o.g),o.b=fe(o.b))),o},fromWorkingColorSpace:function(o,t){return this.convert(o,this.workingColorSpace,t)},toWorkingColorSpace:function(o,t){return this.convert(o,t,this.workingColorSpace)},getPrimaries:function(o){return this.spaces[o].primaries},getTransfer:function(o){return o===yn?gn:this.spaces[o].transfer},getLuminanceCoefficients:function(o,t=this.workingColorSpace){return o.fromArray(this.spaces[t].luminanceCoefficients)},define:function(o){Object.assign(this.spaces,o)},_getMatrix:function(o,t,e){return o.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(o){return this.spaces[o].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(o=this.workingColorSpace){return this.spaces[o].workingColorSpaceConfig.unpackColorSpace}};function Bt(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function fe(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}const As=[.64,.33,.3,.6,.15,.06],Cs=[.2126,.7152,.0722],Es=[.3127,.329],Fs=new kt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Bs=new kt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);mt.define({[xn]:{primaries:As,whitePoint:Es,transfer:gn,toXYZ:Fs,fromXYZ:Bs,luminanceCoefficients:Cs,workingColorSpaceConfig:{unpackColorSpace:ut},outputColorSpaceConfig:{drawingBufferColorSpace:ut}},[ut]:{primaries:As,whitePoint:Es,transfer:Yi,toXYZ:Fs,fromXYZ:Bs,luminanceCoefficients:Cs,outputColorSpaceConfig:{drawingBufferColorSpace:ut}}});let ee;class Fr{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{ee===void 0&&(ee=zs("canvas")),ee.width=t.width,ee.height=t.height;const i=ee.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=ee}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=zs("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]=Bt(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(Bt(e[i]/255)*255):e[i]=Bt(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 Br=0;class kr{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Br++}),this.uuid=xe(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},s=this.data;if(s!==null){let n;if(Array.isArray(s)){n=[];for(let r=0,a=s.length;r<a;r++)s[r].isDataTexture?n.push(_i(s[r].image)):n.push(_i(s[r]))}else n=_i(s);i.url=n}return e||(t.images[this.uuid]=i),i}}function _i(o){return typeof HTMLImageElement<"u"&&o instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&o instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&o instanceof ImageBitmap?Fr.getDataURL(o):o.data?{data:Array.from(o.data),width:o.width,height:o.height,type:o.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Pr=0;class jt extends St{constructor(t=jt.DEFAULT_IMAGE,e=jt.DEFAULT_MAPPING,i=Re,s=Re,n=or,r=ar,a=cr,h=hr,l=jt.DEFAULT_ANISOTROPY,c=yn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pr++}),this.uuid=xe(),this.name="",this.source=new kr(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=n,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=h,this.offset=new X(0,0),this.repeat=new X(1,1),this.center=new X(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kt,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!==fn)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case bs:t.x=t.x-Math.floor(t.x);break;case Re:t.x=t.x<0?0:1;break;case Ms: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 bs:t.y=t.y-Math.floor(t.y);break;case Re:t.y=t.y<0?0:1;break;case Ms: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++}}jt.DEFAULT_IMAGE=null;jt.DEFAULT_MAPPING=fn;jt.DEFAULT_ANISOTROPY=1;class Zt{constructor(t=0,e=0,i=0,s=1){Zt.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 h=t.elements,l=h[0],c=h[4],p=h[8],u=h[1],d=h[5],m=h[9],y=h[2],x=h[6],w=h[10];if(Math.abs(c-u)<.01&&Math.abs(p-y)<.01&&Math.abs(m-x)<.01){if(Math.abs(c+u)<.1&&Math.abs(p+y)<.1&&Math.abs(m+x)<.1&&Math.abs(l+d+w-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const g=(l+1)/2,f=(d+1)/2,_=(w+1)/2,S=(c+u)/4,z=(p+y)/4,A=(m+x)/4;return g>f&&g>_?g<.01?(i=0,s=.707106781,n=.707106781):(i=Math.sqrt(g),s=S/i,n=z/i):f>_?f<.01?(i=.707106781,s=0,n=.707106781):(s=Math.sqrt(f),i=S/s,n=A/s):_<.01?(i=.707106781,s=.707106781,n=0):(n=Math.sqrt(_),i=z/n,s=A/n),this.set(i,s,n,e),this}let b=Math.sqrt((x-m)*(x-m)+(p-y)*(p-y)+(u-c)*(u-c));return Math.abs(b)<.001&&(b=1),this.x=(x-m)/b,this.y=(p-y)/b,this.z=(u-c)/b,this.w=Math.acos((l+d+w-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 et{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,n,r,a){let h=i[s+0],l=i[s+1],c=i[s+2],p=i[s+3];const u=n[r+0],d=n[r+1],m=n[r+2],y=n[r+3];if(a===0){t[e+0]=h,t[e+1]=l,t[e+2]=c,t[e+3]=p;return}if(a===1){t[e+0]=u,t[e+1]=d,t[e+2]=m,t[e+3]=y;return}if(p!==y||h!==u||l!==d||c!==m){let x=1-a;const w=h*u+l*d+c*m+p*y,b=w>=0?1:-1,g=1-w*w;if(g>Number.EPSILON){const _=Math.sqrt(g),S=Math.atan2(_,w*b);x=Math.sin(x*S)/_,a=Math.sin(a*S)/_}const f=a*b;if(h=h*x+u*f,l=l*x+d*f,c=c*x+m*f,p=p*x+y*f,x===1-a){const _=1/Math.sqrt(h*h+l*l+c*c+p*p);h*=_,l*=_,c*=_,p*=_}}t[e]=h,t[e+1]=l,t[e+2]=c,t[e+3]=p}static multiplyQuaternionsFlat(t,e,i,s,n,r){const a=i[s],h=i[s+1],l=i[s+2],c=i[s+3],p=n[r],u=n[r+1],d=n[r+2],m=n[r+3];return t[e]=a*m+c*p+h*d-l*u,t[e+1]=h*m+c*u+l*p-a*d,t[e+2]=l*m+c*d+a*u-h*p,t[e+3]=c*m-a*p-h*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,s=t._y,n=t._z,r=t._order,a=Math.cos,h=Math.sin,l=a(i/2),c=a(s/2),p=a(n/2),u=h(i/2),d=h(s/2),m=h(n/2);switch(r){case"XYZ":this._x=u*c*p+l*d*m,this._y=l*d*p-u*c*m,this._z=l*c*m+u*d*p,this._w=l*c*p-u*d*m;break;case"YXZ":this._x=u*c*p+l*d*m,this._y=l*d*p-u*c*m,this._z=l*c*m-u*d*p,this._w=l*c*p+u*d*m;break;case"ZXY":this._x=u*c*p-l*d*m,this._y=l*d*p+u*c*m,this._z=l*c*m+u*d*p,this._w=l*c*p-u*d*m;break;case"ZYX":this._x=u*c*p-l*d*m,this._y=l*d*p+u*c*m,this._z=l*c*m-u*d*p,this._w=l*c*p+u*d*m;break;case"YZX":this._x=u*c*p+l*d*m,this._y=l*d*p+u*c*m,this._z=l*c*m-u*d*p,this._w=l*c*p-u*d*m;break;case"XZY":this._x=u*c*p-l*d*m,this._y=l*d*p-u*c*m,this._z=l*c*m+u*d*p,this._w=l*c*p+u*d*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],a=e[5],h=e[9],l=e[2],c=e[6],p=e[10],u=i+a+p;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(c-h)*d,this._y=(n-l)*d,this._z=(r-s)*d}else if(i>a&&i>p){const d=2*Math.sqrt(1+i-a-p);this._w=(c-h)/d,this._x=.25*d,this._y=(s+r)/d,this._z=(n+l)/d}else if(a>p){const d=2*Math.sqrt(1+a-i-p);this._w=(n-l)/d,this._x=(s+r)/d,this._y=.25*d,this._z=(h+c)/d}else{const d=2*Math.sqrt(1+p-i-a);this._w=(r-s)/d,this._x=(n+l)/d,this._y=(h+c)/d,this._z=.25*d}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(it(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,s=t._y,n=t._z,r=t._w,a=e._x,h=e._y,l=e._z,c=e._w;return this._x=i*c+r*a+s*l-n*h,this._y=s*c+r*h+n*a-i*l,this._z=n*c+r*l+i*h-s*a,this._w=r*c-i*a-s*h-n*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,s=this._y,n=this._z,r=this._w;let a=r*t._w+i*t._x+s*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=r,this._x=i,this._y=s,this._z=n,this;const h=1-a*a;if(h<=Number.EPSILON){const d=1-e;return this._w=d*r+e*this._w,this._x=d*i+e*this._x,this._y=d*s+e*this._y,this._z=d*n+e*this._z,this.normalize(),this}const l=Math.sqrt(h),c=Math.atan2(l,a),p=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=r*p+this._w*u,this._x=i*p+this._x*u,this._y=s*p+this._y*u,this._z=n*p+this._z*u,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 M{constructor(t=0,e=0,i=0){M.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(ks.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ks.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*s,this.y=n[1]*e+n[4]*i+n[7]*s,this.z=n[2]*e+n[5]*i+n[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,n=t.elements,r=1/(n[3]*e+n[7]*i+n[11]*s+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*s+n[12])*r,this.y=(n[1]*e+n[5]*i+n[9]*s+n[13])*r,this.z=(n[2]*e+n[6]*i+n[10]*s+n[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,n=t.x,r=t.y,a=t.z,h=t.w,l=2*(r*s-a*i),c=2*(a*e-n*s),p=2*(n*i-r*e);return this.x=e+h*l+r*p-a*c,this.y=i+h*c+a*l-n*p,this.z=s+h*p+n*c-r*l,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,a=e.y,h=e.z;return this.x=s*h-n*a,this.y=n*r-i*h,this.z=i*a-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Si.copy(this).projectOnVector(t),this.sub(Si)}reflect(t){return this.sub(Si.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(it(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 Si=new M,ks=new et;class bt{constructor(t=new M(1/0,1/0,1/0),e=new M(-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(yt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(yt.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=yt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const n=i.getAttribute("position");if(e===!0&&n!==void 0&&t.isInstancedMesh!==!0)for(let r=0,a=n.count;r<a;r++)t.isMesh===!0?t.getVertexPosition(r,yt):yt.fromBufferAttribute(n,r),yt.applyMatrix4(t.matrixWorld),this.expandByPoint(yt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Oe.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Oe.copy(i.boundingBox)),Oe.applyMatrix4(t.matrixWorld),this.union(Oe)}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,yt),yt.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(we),Ne.subVectors(this.max,we),ie.subVectors(t.a,we),se.subVectors(t.b,we),ne.subVectors(t.c,we),Pt.subVectors(se,ie),Tt.subVectors(ne,se),Ot.subVectors(ie,ne);let e=[0,-Pt.z,Pt.y,0,-Tt.z,Tt.y,0,-Ot.z,Ot.y,Pt.z,0,-Pt.x,Tt.z,0,-Tt.x,Ot.z,0,-Ot.x,-Pt.y,Pt.x,0,-Tt.y,Tt.x,0,-Ot.y,Ot.x,0];return!vi(e,ie,se,ne,Ne)||(e=[1,0,0,0,1,0,0,0,1],!vi(e,ie,se,ne,Ne))?!1:(Ve.crossVectors(Pt,Tt),e=[Ve.x,Ve.y,Ve.z],vi(e,ie,se,ne,Ne))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,yt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(yt).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:(vt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),vt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),vt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),vt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),vt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),vt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),vt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),vt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(vt),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 vt=[new M,new M,new M,new M,new M,new M,new M,new M],yt=new M,Oe=new bt,ie=new M,se=new M,ne=new M,Pt=new M,Tt=new M,Ot=new M,we=new M,Ne=new M,Ve=new M,Nt=new M;function vi(o,t,e,i,s){for(let n=0,r=o.length-3;n<=r;n+=3){Nt.fromArray(o,n);const a=s.x*Math.abs(Nt.x)+s.y*Math.abs(Nt.y)+s.z*Math.abs(Nt.z),h=t.dot(Nt),l=e.dot(Nt),c=i.dot(Nt);if(Math.max(-Math.max(h,l,c),Math.min(h,l,c))>a)return!1}return!0}const Tr=new bt,be=new M,zi=new M;class Pe{constructor(t=new M,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):Tr.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;be.subVectors(t,this.center);const e=be.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),s=(i-this.radius)*.5;this.center.addScaledVector(be,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):(zi.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(be.copy(t.center).add(zi)),this.expandByPoint(be.copy(t.center).sub(zi))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const zt=new M,Ai=new M,Ue=new M,It=new M,Ci=new M,He=new M,Ei=new M;class is{constructor(t=new M,e=new M(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,zt)),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=zt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(zt.copy(this.origin).addScaledVector(this.direction,e),zt.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){Ai.copy(t).add(e).multiplyScalar(.5),Ue.copy(e).sub(t).normalize(),It.copy(this.origin).sub(Ai);const n=t.distanceTo(e)*.5,r=-this.direction.dot(Ue),a=It.dot(this.direction),h=-It.dot(Ue),l=It.lengthSq(),c=Math.abs(1-r*r);let p,u,d,m;if(c>0)if(p=r*h-a,u=r*a-h,m=n*c,p>=0)if(u>=-m)if(u<=m){const y=1/c;p*=y,u*=y,d=p*(p+r*u+2*a)+u*(r*p+u+2*h)+l}else u=n,p=Math.max(0,-(r*u+a)),d=-p*p+u*(u+2*h)+l;else u=-n,p=Math.max(0,-(r*u+a)),d=-p*p+u*(u+2*h)+l;else u<=-m?(p=Math.max(0,-(-r*n+a)),u=p>0?-n:Math.min(Math.max(-n,-h),n),d=-p*p+u*(u+2*h)+l):u<=m?(p=0,u=Math.min(Math.max(-n,-h),n),d=u*(u+2*h)+l):(p=Math.max(0,-(r*n+a)),u=p>0?n:Math.min(Math.max(-n,-h),n),d=-p*p+u*(u+2*h)+l);else u=r>0?-n:n,p=Math.max(0,-(r*u+a)),d=-p*p+u*(u+2*h)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,p),s&&s.copy(Ai).addScaledVector(Ue,u),d}intersectSphere(t,e){zt.subVectors(t.center,this.origin);const i=zt.dot(this.direction),s=zt.dot(zt)-i*i,n=t.radius*t.radius;if(s>n)return null;const r=Math.sqrt(n-s),a=i-r,h=i+r;return h<0?null:a<0?this.at(h,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,s,n,r,a,h;const l=1/this.direction.x,c=1/this.direction.y,p=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),c>=0?(n=(t.min.y-u.y)*c,r=(t.max.y-u.y)*c):(n=(t.max.y-u.y)*c,r=(t.min.y-u.y)*c),i>r||n>s||((n>i||isNaN(i))&&(i=n),(r<s||isNaN(s))&&(s=r),p>=0?(a=(t.min.z-u.z)*p,h=(t.max.z-u.z)*p):(a=(t.max.z-u.z)*p,h=(t.min.z-u.z)*p),i>h||a>s)||((a>i||i!==i)&&(i=a),(h<s||s!==s)&&(s=h),s<0)?null:this.at(i>=0?i:s,e)}intersectsBox(t){return this.intersectBox(t,zt)!==null}intersectTriangle(t,e,i,s,n){Ci.subVectors(e,t),He.subVectors(i,t),Ei.crossVectors(Ci,He);let r=this.direction.dot(Ei),a;if(r>0){if(s)return null;a=1}else if(r<0)a=-1,r=-r;else return null;It.subVectors(this.origin,t);const h=a*this.direction.dot(He.crossVectors(It,He));if(h<0)return null;const l=a*this.direction.dot(Ci.cross(It));if(l<0||h+l>r)return null;const c=-a*It.dot(Ei);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 U{constructor(t,e,i,s,n,r,a,h,l,c,p,u,d,m,y,x){U.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,s,n,r,a,h,l,c,p,u,d,m,y,x)}set(t,e,i,s,n,r,a,h,l,c,p,u,d,m,y,x){const w=this.elements;return w[0]=t,w[4]=e,w[8]=i,w[12]=s,w[1]=n,w[5]=r,w[9]=a,w[13]=h,w[2]=l,w[6]=c,w[10]=p,w[14]=u,w[3]=d,w[7]=m,w[11]=y,w[15]=x,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 U().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/re.setFromMatrixColumn(t,0).length(),n=1/re.setFromMatrixColumn(t,1).length(),r=1/re.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,s=t.y,n=t.z,r=Math.cos(i),a=Math.sin(i),h=Math.cos(s),l=Math.sin(s),c=Math.cos(n),p=Math.sin(n);if(t.order==="XYZ"){const u=r*c,d=r*p,m=a*c,y=a*p;e[0]=h*c,e[4]=-h*p,e[8]=l,e[1]=d+m*l,e[5]=u-y*l,e[9]=-a*h,e[2]=y-u*l,e[6]=m+d*l,e[10]=r*h}else if(t.order==="YXZ"){const u=h*c,d=h*p,m=l*c,y=l*p;e[0]=u+y*a,e[4]=m*a-d,e[8]=r*l,e[1]=r*p,e[5]=r*c,e[9]=-a,e[2]=d*a-m,e[6]=y+u*a,e[10]=r*h}else if(t.order==="ZXY"){const u=h*c,d=h*p,m=l*c,y=l*p;e[0]=u-y*a,e[4]=-r*p,e[8]=m+d*a,e[1]=d+m*a,e[5]=r*c,e[9]=y-u*a,e[2]=-r*l,e[6]=a,e[10]=r*h}else if(t.order==="ZYX"){const u=r*c,d=r*p,m=a*c,y=a*p;e[0]=h*c,e[4]=m*l-d,e[8]=u*l+y,e[1]=h*p,e[5]=y*l+u,e[9]=d*l-m,e[2]=-l,e[6]=a*h,e[10]=r*h}else if(t.order==="YZX"){const u=r*h,d=r*l,m=a*h,y=a*l;e[0]=h*c,e[4]=y-u*p,e[8]=m*p+d,e[1]=p,e[5]=r*c,e[9]=-a*c,e[2]=-l*c,e[6]=d*p+m,e[10]=u-y*p}else if(t.order==="XZY"){const u=r*h,d=r*l,m=a*h,y=a*l;e[0]=h*c,e[4]=-p,e[8]=l*c,e[1]=u*p+y,e[5]=r*c,e[9]=d*p-m,e[2]=m*p-d,e[6]=a*c,e[10]=y*p+u}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(Ir,t,Lr)}lookAt(t,e,i){const s=this.elements;return lt.subVectors(t,e),lt.lengthSq()===0&&(lt.z=1),lt.normalize(),Lt.crossVectors(i,lt),Lt.lengthSq()===0&&(Math.abs(i.z)===1?lt.x+=1e-4:lt.z+=1e-4,lt.normalize(),Lt.crossVectors(i,lt)),Lt.normalize(),qe.crossVectors(lt,Lt),s[0]=Lt.x,s[4]=qe.x,s[8]=lt.x,s[1]=Lt.y,s[5]=qe.y,s[9]=lt.y,s[2]=Lt.z,s[6]=qe.z,s[10]=lt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,n=this.elements,r=i[0],a=i[4],h=i[8],l=i[12],c=i[1],p=i[5],u=i[9],d=i[13],m=i[2],y=i[6],x=i[10],w=i[14],b=i[3],g=i[7],f=i[11],_=i[15],S=s[0],z=s[4],A=s[8],C=s[12],E=s[1],B=s[5],P=s[9],I=s[13],L=s[2],R=s[6],G=s[10],W=s[14],nt=s[3],D=s[7],V=s[11],j=s[15];return n[0]=r*S+a*E+h*L+l*nt,n[4]=r*z+a*B+h*R+l*D,n[8]=r*A+a*P+h*G+l*V,n[12]=r*C+a*I+h*W+l*j,n[1]=c*S+p*E+u*L+d*nt,n[5]=c*z+p*B+u*R+d*D,n[9]=c*A+p*P+u*G+d*V,n[13]=c*C+p*I+u*W+d*j,n[2]=m*S+y*E+x*L+w*nt,n[6]=m*z+y*B+x*R+w*D,n[10]=m*A+y*P+x*G+w*V,n[14]=m*C+y*I+x*W+w*j,n[3]=b*S+g*E+f*L+_*nt,n[7]=b*z+g*B+f*R+_*D,n[11]=b*A+g*P+f*G+_*V,n[15]=b*C+g*I+f*W+_*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],a=t[5],h=t[9],l=t[13],c=t[2],p=t[6],u=t[10],d=t[14],m=t[3],y=t[7],x=t[11],w=t[15];return m*(+n*h*p-s*l*p-n*a*u+i*l*u+s*a*d-i*h*d)+y*(+e*h*d-e*l*u+n*r*u-s*r*d+s*l*c-n*h*c)+x*(+e*l*p-e*a*d-n*r*p+i*r*d+n*a*c-i*l*c)+w*(-s*a*c-e*h*p+e*a*u+s*r*p-i*r*u+i*h*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],h=t[6],l=t[7],c=t[8],p=t[9],u=t[10],d=t[11],m=t[12],y=t[13],x=t[14],w=t[15],b=p*x*l-y*u*l+y*h*d-a*x*d-p*h*w+a*u*w,g=m*u*l-c*x*l-m*h*d+r*x*d+c*h*w-r*u*w,f=c*y*l-m*p*l+m*a*d-r*y*d-c*a*w+r*p*w,_=m*p*h-c*y*h-m*a*u+r*y*u+c*a*x-r*p*x,S=e*b+i*g+s*f+n*_;if(S===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const z=1/S;return t[0]=b*z,t[1]=(y*u*n-p*x*n-y*s*d+i*x*d+p*s*w-i*u*w)*z,t[2]=(a*x*n-y*h*n+y*s*l-i*x*l-a*s*w+i*h*w)*z,t[3]=(p*h*n-a*u*n-p*s*l+i*u*l+a*s*d-i*h*d)*z,t[4]=g*z,t[5]=(c*x*n-m*u*n+m*s*d-e*x*d-c*s*w+e*u*w)*z,t[6]=(m*h*n-r*x*n-m*s*l+e*x*l+r*s*w-e*h*w)*z,t[7]=(r*u*n-c*h*n+c*s*l-e*u*l-r*s*d+e*h*d)*z,t[8]=f*z,t[9]=(m*p*n-c*y*n-m*i*d+e*y*d+c*i*w-e*p*w)*z,t[10]=(r*y*n-m*a*n+m*i*l-e*y*l-r*i*w+e*a*w)*z,t[11]=(c*a*n-r*p*n-c*i*l+e*p*l+r*i*d-e*a*d)*z,t[12]=_*z,t[13]=(c*y*s-m*p*s+m*i*u-e*y*u-c*i*x+e*p*x)*z,t[14]=(m*a*s-r*y*s-m*i*h+e*y*h+r*i*x-e*a*x)*z,t[15]=(r*p*s-c*a*s+c*i*h-e*p*h-r*i*u+e*a*u)*z,this}scale(t){const e=this.elements,i=t.x,s=t.y,n=t.z;return e[0]*=i,e[4]*=s,e[8]*=n,e[1]*=i,e[5]*=s,e[9]*=n,e[2]*=i,e[6]*=s,e[10]*=n,e[3]*=i,e[7]*=s,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),s=Math.sin(e),n=1-i,r=t.x,a=t.y,h=t.z,l=n*r,c=n*a;return this.set(l*r+i,l*a-s*h,l*h+s*a,0,l*a+s*h,c*a+i,c*h-s*r,0,l*h-s*a,c*h+s*r,n*h*h+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,n,r){return this.set(1,i,n,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,n=e._x,r=e._y,a=e._z,h=e._w,l=n+n,c=r+r,p=a+a,u=n*l,d=n*c,m=n*p,y=r*c,x=r*p,w=a*p,b=h*l,g=h*c,f=h*p,_=i.x,S=i.y,z=i.z;return s[0]=(1-(y+w))*_,s[1]=(d+f)*_,s[2]=(m-g)*_,s[3]=0,s[4]=(d-f)*S,s[5]=(1-(u+w))*S,s[6]=(x+b)*S,s[7]=0,s[8]=(m+g)*z,s[9]=(x-b)*z,s[10]=(1-(u+y))*z,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=re.set(s[0],s[1],s[2]).length();const r=re.set(s[4],s[5],s[6]).length(),a=re.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],xt.copy(this);const l=1/n,c=1/r,p=1/a;return xt.elements[0]*=l,xt.elements[1]*=l,xt.elements[2]*=l,xt.elements[4]*=c,xt.elements[5]*=c,xt.elements[6]*=c,xt.elements[8]*=p,xt.elements[9]*=p,xt.elements[10]*=p,e.setFromRotationMatrix(xt),i.x=n,i.y=r,i.z=a,this}makePerspective(t,e,i,s,n,r,a=Xt){const h=this.elements,l=2*n/(e-t),c=2*n/(i-s),p=(e+t)/(e-t),u=(i+s)/(i-s);let d,m;if(a===Xt)d=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(a===Zi)d=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return h[0]=l,h[4]=0,h[8]=p,h[12]=0,h[1]=0,h[5]=c,h[9]=u,h[13]=0,h[2]=0,h[6]=0,h[10]=d,h[14]=m,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(t,e,i,s,n,r,a=Xt){const h=this.elements,l=1/(e-t),c=1/(i-s),p=1/(r-n),u=(e+t)*l,d=(i+s)*c;let m,y;if(a===Xt)m=(r+n)*p,y=-2*p;else if(a===Zi)m=n*p,y=-1*p;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return h[0]=2*l,h[4]=0,h[8]=0,h[12]=-u,h[1]=0,h[5]=2*c,h[9]=0,h[13]=-d,h[2]=0,h[6]=0,h[10]=y,h[14]=-m,h[3]=0,h[7]=0,h[11]=0,h[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 re=new M,xt=new U,Ir=new M(0,0,0),Lr=new M(1,1,1),Lt=new M,qe=new M,lt=new M,Ps=new U,Ts=new et;class Gt{constructor(t=0,e=0,i=0,s=Gt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const s=t.elements,n=s[0],r=s[4],a=s[8],h=s[1],l=s[5],c=s[9],p=s[2],u=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(it(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-it(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-p,n),this._z=0);break;case"ZXY":this._x=Math.asin(it(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-p,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(h,n));break;case"ZYX":this._y=Math.asin(-it(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(h,n)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(it(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-p,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-it(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-c,d),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 Ps.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ps,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ts.setFromEuler(this),this.setFromQuaternion(Ts,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}}Gt.DEFAULT_ORDER="XYZ";class Mn{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 Dr=0;const Is=new M,oe=new et,At=new U,We=new M,Me=new M,Rr=new M,Or=new et,Ls=new M(1,0,0),Ds=new M(0,1,0),Rs=new M(0,0,1),Os={type:"added"},Nr={type:"removed"},ae={type:"childadded",child:null},Fi={type:"childremoved",child:null};class q extends St{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Dr++}),this.uuid=xe(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=q.DEFAULT_UP.clone();const t=new M,e=new Gt,i=new et,s=new M(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 U},normalMatrix:{value:new kt}}),this.matrix=new U,this.matrixWorld=new U,this.matrixAutoUpdate=q.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=q.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Mn,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 oe.setFromAxisAngle(t,e),this.quaternion.multiply(oe),this}rotateOnWorldAxis(t,e){return oe.setFromAxisAngle(t,e),this.quaternion.premultiply(oe),this}rotateX(t){return this.rotateOnAxis(Ls,t)}rotateY(t){return this.rotateOnAxis(Ds,t)}rotateZ(t){return this.rotateOnAxis(Rs,t)}translateOnAxis(t,e){return Is.copy(t).applyQuaternion(this.quaternion),this.position.add(Is.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ls,t)}translateY(t){return this.translateOnAxis(Ds,t)}translateZ(t){return this.translateOnAxis(Rs,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(At.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?We.copy(t):We.set(t,e,i);const s=this.parent;this.updateWorldMatrix(!0,!1),Me.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?At.lookAt(Me,We,this.up):At.lookAt(We,Me,this.up),this.quaternion.setFromRotationMatrix(At),s&&(At.extractRotation(s.matrixWorld),oe.setFromRotationMatrix(At),this.quaternion.premultiply(oe.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(Os),ae.child=t,this.dispatchEvent(ae),ae.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(Nr),Fi.child=t,this.dispatchEvent(Fi),Fi.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),At.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),At.multiply(t.parent.matrixWorld)),t.applyMatrix4(At),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Os),ae.child=t,this.dispatchEvent(ae),ae.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(Me,t,Rr),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Me,Or,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,s=e.length;i<s;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let n=0,r=s.length;n<r;n++)s[n].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function n(a,h){return a[h.uuid]===void 0&&(a[h.uuid]=h.toJSON(t)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=n(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const h=a.shapes;if(Array.isArray(h))for(let l=0,c=h.length;l<c;l++){const p=h[l];n(t.shapes,p)}else n(t.shapes,h)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let h=0,l=this.material.length;h<l;h++)a.push(n(t.materials,this.material[h]));s.material=a}else s.material=n(t.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){const h=this.animations[a];s.animations.push(n(t.animations,h))}}if(e){const a=r(t.geometries),h=r(t.materials),l=r(t.textures),c=r(t.images),p=r(t.shapes),u=r(t.skeletons),d=r(t.animations),m=r(t.nodes);a.length>0&&(i.geometries=a),h.length>0&&(i.materials=h),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),p.length>0&&(i.shapes=p),u.length>0&&(i.skeletons=u),d.length>0&&(i.animations=d),m.length>0&&(i.nodes=m)}return i.object=s,i;function r(a){const h=[];for(const l in a){const c=a[l];delete c.metadata,h.push(c)}return h}}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}}q.DEFAULT_UP=new M(0,1,0);q.DEFAULT_MATRIX_AUTO_UPDATE=!0;q.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gt=new M,Ct=new M,Bi=new M,Et=new M,he=new M,le=new M,Ns=new M,ki=new M,Pi=new M,Ti=new M,Ii=new Zt,Li=new Zt,Di=new Zt;class wt{constructor(t=new M,e=new M,i=new M){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,s){s.subVectors(i,e),gt.subVectors(t,e),s.cross(gt);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){gt.subVectors(s,e),Ct.subVectors(i,e),Bi.subVectors(t,e);const r=gt.dot(gt),a=gt.dot(Ct),h=gt.dot(Bi),l=Ct.dot(Ct),c=Ct.dot(Bi),p=r*l-a*a;if(p===0)return n.set(0,0,0),null;const u=1/p,d=(l*h-a*c)*u,m=(r*c-a*h)*u;return n.set(1-d-m,m,d)}static containsPoint(t,e,i,s){return this.getBarycoord(t,e,i,s,Et)===null?!1:Et.x>=0&&Et.y>=0&&Et.x+Et.y<=1}static getInterpolation(t,e,i,s,n,r,a,h){return this.getBarycoord(t,e,i,s,Et)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(n,Et.x),h.addScaledVector(r,Et.y),h.addScaledVector(a,Et.z),h)}static getInterpolatedAttribute(t,e,i,s,n,r){return Ii.setScalar(0),Li.setScalar(0),Di.setScalar(0),Ii.fromBufferAttribute(t,e),Li.fromBufferAttribute(t,i),Di.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(Ii,n.x),r.addScaledVector(Li,n.y),r.addScaledVector(Di,n.z),r}static isFrontFacing(t,e,i,s){return gt.subVectors(i,e),Ct.subVectors(t,e),gt.cross(Ct).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 gt.subVectors(this.c,this.b),Ct.subVectors(this.a,this.b),gt.cross(Ct).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return wt.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return wt.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,n){return wt.getInterpolation(t,this.a,this.b,this.c,e,i,s,n)}containsPoint(t){return wt.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return wt.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,s=this.b,n=this.c;let r,a;he.subVectors(s,i),le.subVectors(n,i),ki.subVectors(t,i);const h=he.dot(ki),l=le.dot(ki);if(h<=0&&l<=0)return e.copy(i);Pi.subVectors(t,s);const c=he.dot(Pi),p=le.dot(Pi);if(c>=0&&p<=c)return e.copy(s);const u=h*p-c*l;if(u<=0&&h>=0&&c<=0)return r=h/(h-c),e.copy(i).addScaledVector(he,r);Ti.subVectors(t,n);const d=he.dot(Ti),m=le.dot(Ti);if(m>=0&&d<=m)return e.copy(n);const y=d*l-h*m;if(y<=0&&l>=0&&m<=0)return a=l/(l-m),e.copy(i).addScaledVector(le,a);const x=c*m-d*p;if(x<=0&&p-c>=0&&d-m>=0)return Ns.subVectors(n,s),a=(p-c)/(p-c+(d-m)),e.copy(s).addScaledVector(Ns,a);const w=1/(x+y+u);return r=y*w,a=u*w,e.copy(i).addScaledVector(he,r).addScaledVector(le,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const _n={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},Dt={h:0,s:0,l:0},Xe={h:0,s:0,l:0};function Ri(o,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?o+(t-o)*6*e:e<1/2?t:e<2/3?o+(t-o)*6*(2/3-e):o}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,mt.toWorkingColorSpace(this,e),this}setRGB(t,e,i,s=mt.workingColorSpace){return this.r=t,this.g=e,this.b=i,mt.toWorkingColorSpace(this,s),this}setHSL(t,e,i,s=mt.workingColorSpace){if(t=ts(t,1),e=it(e,0,1),i=it(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=Ri(r,n,t+1/3),this.g=Ri(r,n,t),this.b=Ri(r,n,t-1/3)}return mt.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],a=s[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,e);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,e);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=s[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ut){const i=_n[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=Bt(t.r),this.g=Bt(t.g),this.b=Bt(t.b),this}copyLinearToSRGB(t){return this.r=fe(t.r),this.g=fe(t.g),this.b=fe(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ut){return mt.fromWorkingColorSpace(J.copy(this),t),Math.round(it(J.r*255,0,255))*65536+Math.round(it(J.g*255,0,255))*256+Math.round(it(J.b*255,0,255))}getHexString(t=ut){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=mt.workingColorSpace){mt.fromWorkingColorSpace(J.copy(this),e);const i=J.r,s=J.g,n=J.b,r=Math.max(i,s,n),a=Math.min(i,s,n);let h,l;const c=(a+r)/2;if(a===r)h=0,l=0;else{const p=r-a;switch(l=c<=.5?p/(r+a):p/(2-r-a),r){case i:h=(s-n)/p+(s<n?6:0);break;case s:h=(n-i)/p+2;break;case n:h=(i-s)/p+4;break}h/=6}return t.h=h,t.s=l,t.l=c,t}getRGB(t,e=mt.workingColorSpace){return mt.fromWorkingColorSpace(J.copy(this),e),t.r=J.r,t.g=J.g,t.b=J.b,t}getStyle(t=ut){mt.fromWorkingColorSpace(J.copy(this),t);const e=J.r,i=J.g,s=J.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(Dt),this.setHSL(Dt.h+t,Dt.s+e,Dt.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(Dt),t.getHSL(Xe);const i=Be(Dt.h,Xe.h,e),s=Be(Dt.s,Xe.s,e),n=Be(Dt.l,Xe.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 J=new ht;ht.NAMES=_n;let Vr=0;class ss extends St{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vr++}),this.uuid=xe(),this.name="",this.blending=fs,this.side=ui,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=xs,this.blendDst=gs,this.blendEquation=ys,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ht(0,0,0),this.blendAlpha=0,this.depthFunc=ws,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=_s,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=te,this.stencilZFail=te,this.stencilZPass=te,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!==fs&&(i.blending=this.blending),this.side!==ui&&(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!==xs&&(i.blendSrc=this.blendSrc),this.blendDst!==gs&&(i.blendDst=this.blendDst),this.blendEquation!==ys&&(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!==ws&&(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!==_s&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==te&&(i.stencilFail=this.stencilFail),this.stencilZFail!==te&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==te&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(n){const r=[];for(const a in n){const h=n[a];delete h.metadata,r.push(h)}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 $t extends ss{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 Gt,this.combine=mn,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 M,je=new X;class Yt{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=Ss,this.updateRanges=[],this.gpuType=lr,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++)je.fromBufferAttribute(this,e),je.applyMatrix3(t),this.setXY(e,je.x,je.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=de(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=rt(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=de(e,this.array)),e}setX(t,e){return this.normalized&&(e=rt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=de(e,this.array)),e}setY(t,e){return this.normalized&&(e=rt(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=de(e,this.array)),e}setZ(t,e){return this.normalized&&(e=rt(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=de(e,this.array)),e}setW(t,e){return this.normalized&&(e=rt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=rt(e,this.array),i=rt(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=rt(e,this.array),i=rt(i,this.array),s=rt(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=rt(e,this.array),i=rt(i,this.array),s=rt(s,this.array),n=rt(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!==Ss&&(t.usage=this.usage),t}}class Ur extends Yt{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class Hr extends Yt{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class T extends Yt{constructor(t,e,i){super(new Float32Array(t),e,i)}}let qr=0;const dt=new U,Oi=new q,ce=new M,ct=new bt,_e=new bt,Y=new M;class st extends St{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:qr++}),this.uuid=xe(),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(Er(t)?Hr:Ur)(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 kt().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 dt.makeRotationFromQuaternion(t),this.applyMatrix4(dt),this}rotateX(t){return dt.makeRotationX(t),this.applyMatrix4(dt),this}rotateY(t){return dt.makeRotationY(t),this.applyMatrix4(dt),this}rotateZ(t){return dt.makeRotationZ(t),this.applyMatrix4(dt),this}translate(t,e,i){return dt.makeTranslation(t,e,i),this.applyMatrix4(dt),this}scale(t,e,i){return dt.makeScale(t,e,i),this.applyMatrix4(dt),this}lookAt(t){return Oi.lookAt(t),Oi.updateMatrix(),this.applyMatrix4(Oi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ce).negate(),this.translate(ce.x,ce.y,ce.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 T(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 bt);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 M(-1/0,-1/0,-1/0),new M(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];ct.setFromBufferAttribute(n),this.morphTargetsRelative?(Y.addVectors(this.boundingBox.min,ct.min),this.boundingBox.expandByPoint(Y),Y.addVectors(this.boundingBox.max,ct.max),this.boundingBox.expandByPoint(Y)):(this.boundingBox.expandByPoint(ct.min),this.boundingBox.expandByPoint(ct.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 Pe);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 M,1/0);return}if(t){const i=this.boundingSphere.center;if(ct.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const a=e[n];_e.setFromBufferAttribute(a),this.morphTargetsRelative?(Y.addVectors(ct.min,_e.min),ct.expandByPoint(Y),Y.addVectors(ct.max,_e.max),ct.expandByPoint(Y)):(ct.expandByPoint(_e.min),ct.expandByPoint(_e.max))}ct.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 a=e[n],h=this.morphTargetsRelative;for(let l=0,c=a.count;l<c;l++)Y.fromBufferAttribute(a,l),h&&(ce.fromBufferAttribute(t,l),Y.add(ce)),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 Yt(new Float32Array(4*i.count),4));const r=this.getAttribute("tangent"),a=[],h=[];for(let A=0;A<i.count;A++)a[A]=new M,h[A]=new M;const l=new M,c=new M,p=new M,u=new X,d=new X,m=new X,y=new M,x=new M;function w(A,C,E){l.fromBufferAttribute(i,A),c.fromBufferAttribute(i,C),p.fromBufferAttribute(i,E),u.fromBufferAttribute(n,A),d.fromBufferAttribute(n,C),m.fromBufferAttribute(n,E),c.sub(l),p.sub(l),d.sub(u),m.sub(u);const B=1/(d.x*m.y-m.x*d.y);isFinite(B)&&(y.copy(c).multiplyScalar(m.y).addScaledVector(p,-d.y).multiplyScalar(B),x.copy(p).multiplyScalar(d.x).addScaledVector(c,-m.x).multiplyScalar(B),a[A].add(y),a[C].add(y),a[E].add(y),h[A].add(x),h[C].add(x),h[E].add(x))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let A=0,C=b.length;A<C;++A){const E=b[A],B=E.start,P=E.count;for(let I=B,L=B+P;I<L;I+=3)w(t.getX(I+0),t.getX(I+1),t.getX(I+2))}const g=new M,f=new M,_=new M,S=new M;function z(A){_.fromBufferAttribute(s,A),S.copy(_);const C=a[A];g.copy(C),g.sub(_.multiplyScalar(_.dot(C))).normalize(),f.crossVectors(S,C);const B=f.dot(h[A])<0?-1:1;r.setXYZW(A,g.x,g.y,g.z,B)}for(let A=0,C=b.length;A<C;++A){const E=b[A],B=E.start,P=E.count;for(let I=B,L=B+P;I<L;I+=3)z(t.getX(I+0)),z(t.getX(I+1)),z(t.getX(I+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 Yt(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let u=0,d=i.count;u<d;u++)i.setXYZ(u,0,0,0);const s=new M,n=new M,r=new M,a=new M,h=new M,l=new M,c=new M,p=new M;if(t)for(let u=0,d=t.count;u<d;u+=3){const m=t.getX(u+0),y=t.getX(u+1),x=t.getX(u+2);s.fromBufferAttribute(e,m),n.fromBufferAttribute(e,y),r.fromBufferAttribute(e,x),c.subVectors(r,n),p.subVectors(s,n),c.cross(p),a.fromBufferAttribute(i,m),h.fromBufferAttribute(i,y),l.fromBufferAttribute(i,x),a.add(c),h.add(c),l.add(c),i.setXYZ(m,a.x,a.y,a.z),i.setXYZ(y,h.x,h.y,h.z),i.setXYZ(x,l.x,l.y,l.z)}else for(let u=0,d=e.count;u<d;u+=3)s.fromBufferAttribute(e,u+0),n.fromBufferAttribute(e,u+1),r.fromBufferAttribute(e,u+2),c.subVectors(r,n),p.subVectors(s,n),c.cross(p),i.setXYZ(u+0,c.x,c.y,c.z),i.setXYZ(u+1,c.x,c.y,c.z),i.setXYZ(u+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(a,h){const l=a.array,c=a.itemSize,p=a.normalized,u=new l.constructor(h.length*c);let d=0,m=0;for(let y=0,x=h.length;y<x;y++){a.isInterleavedBufferAttribute?d=h[y]*a.data.stride+a.offset:d=h[y]*c;for(let w=0;w<c;w++)u[m++]=l[d++]}return new Yt(u,c,p)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new st,i=this.index.array,s=this.attributes;for(const a in s){const h=s[a],l=t(h,i);e.setAttribute(a,l)}const n=this.morphAttributes;for(const a in n){const h=[],l=n[a];for(let c=0,p=l.length;c<p;c++){const u=l[c],d=t(u,i);h.push(d)}e.morphAttributes[a]=h}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let a=0,h=r.length;a<h;a++){const l=r[a];e.addGroup(l.start,l.count,l.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 h=this.parameters;for(const l in h)h[l]!==void 0&&(t[l]=h[l]);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 h in i){const l=i[h];t.data.attributes[h]=l.toJSON(t.data)}const s={};let n=!1;for(const h in this.morphAttributes){const l=this.morphAttributes[h],c=[];for(let p=0,u=l.length;p<u;p++){const d=l[p];c.push(d.toJSON(t.data))}c.length>0&&(s[h]=c,n=!0)}n&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const s=t.attributes;for(const l in s){const c=s[l];this.setAttribute(l,c.clone(e))}const n=t.morphAttributes;for(const l in n){const c=[],p=n[l];for(let u=0,d=p.length;u<d;u++)c.push(p[u].clone(e));this.morphAttributes[l]=c}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let l=0,c=r.length;l<c;l++){const p=r[l];this.addGroup(p.start,p.count,p.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const h=t.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Vs=new U,Vt=new is,Ye=new Pe,Us=new M,Ze=new M,Ge=new M,$e=new M,Ni=new M,Qe=new M,Hs=new M,Je=new M;class k extends q{constructor(t=new st,e=new $t){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const s=e[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,r=s.length;n<r;n++){const a=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}getVertexPosition(t,e){const i=this.geometry,s=i.attributes.position,n=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(s,t);const a=this.morphTargetInfluences;if(n&&a){Qe.set(0,0,0);for(let h=0,l=n.length;h<l;h++){const c=a[h],p=n[h];c!==0&&(Ni.fromBufferAttribute(p,t),r?Qe.addScaledVector(Ni,c):Qe.addScaledVector(Ni.sub(e),c))}e.add(Qe)}return e}raycast(t,e){const i=this.geometry,s=this.material,n=this.matrixWorld;s!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Ye.copy(i.boundingSphere),Ye.applyMatrix4(n),Vt.copy(t.ray).recast(t.near),!(Ye.containsPoint(Vt.origin)===!1&&(Vt.intersectSphere(Ye,Us)===null||Vt.origin.distanceToSquared(Us)>(t.far-t.near)**2))&&(Vs.copy(n).invert(),Vt.copy(t.ray).applyMatrix4(Vs),!(i.boundingBox!==null&&Vt.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,Vt)))}_computeIntersections(t,e,i){let s;const n=this.geometry,r=this.material,a=n.index,h=n.attributes.position,l=n.attributes.uv,c=n.attributes.uv1,p=n.attributes.normal,u=n.groups,d=n.drawRange;if(a!==null)if(Array.isArray(r))for(let m=0,y=u.length;m<y;m++){const x=u[m],w=r[x.materialIndex],b=Math.max(x.start,d.start),g=Math.min(a.count,Math.min(x.start+x.count,d.start+d.count));for(let f=b,_=g;f<_;f+=3){const S=a.getX(f),z=a.getX(f+1),A=a.getX(f+2);s=Ke(this,w,t,i,l,c,p,S,z,A),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=x.materialIndex,e.push(s))}}else{const m=Math.max(0,d.start),y=Math.min(a.count,d.start+d.count);for(let x=m,w=y;x<w;x+=3){const b=a.getX(x),g=a.getX(x+1),f=a.getX(x+2);s=Ke(this,r,t,i,l,c,p,b,g,f),s&&(s.faceIndex=Math.floor(x/3),e.push(s))}}else if(h!==void 0)if(Array.isArray(r))for(let m=0,y=u.length;m<y;m++){const x=u[m],w=r[x.materialIndex],b=Math.max(x.start,d.start),g=Math.min(h.count,Math.min(x.start+x.count,d.start+d.count));for(let f=b,_=g;f<_;f+=3){const S=f,z=f+1,A=f+2;s=Ke(this,w,t,i,l,c,p,S,z,A),s&&(s.faceIndex=Math.floor(f/3),s.face.materialIndex=x.materialIndex,e.push(s))}}else{const m=Math.max(0,d.start),y=Math.min(h.count,d.start+d.count);for(let x=m,w=y;x<w;x+=3){const b=x,g=x+1,f=x+2;s=Ke(this,r,t,i,l,c,p,b,g,f),s&&(s.faceIndex=Math.floor(x/3),e.push(s))}}}}function Wr(o,t,e,i,s,n,r,a){let h;if(t.side===rr?h=i.intersectTriangle(r,n,s,!0,a):h=i.intersectTriangle(s,n,r,t.side===ui,a),h===null)return null;Je.copy(a),Je.applyMatrix4(o.matrixWorld);const l=e.ray.origin.distanceTo(Je);return l<e.near||l>e.far?null:{distance:l,point:Je.clone(),object:o}}function Ke(o,t,e,i,s,n,r,a,h,l){o.getVertexPosition(a,Ze),o.getVertexPosition(h,Ge),o.getVertexPosition(l,$e);const c=Wr(o,t,e,i,Ze,Ge,$e,Hs);if(c){const p=new M;wt.getBarycoord(Hs,Ze,Ge,$e,p),s&&(c.uv=wt.getInterpolatedAttribute(s,a,h,l,p,new X)),n&&(c.uv1=wt.getInterpolatedAttribute(n,a,h,l,p,new X)),r&&(c.normal=wt.getInterpolatedAttribute(r,a,h,l,p,new M),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));const u={a,b:h,c:l,normal:new M,materialIndex:0};wt.getNormal(Ze,Ge,$e,u.normal),c.face=u,c.barycoord=p}return c}class Z extends st{constructor(t=1,e=1,i=1,s=1,n=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:n,depthSegments:r};const a=this;s=Math.floor(s),n=Math.floor(n),r=Math.floor(r);const h=[],l=[],c=[],p=[];let u=0,d=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(h),this.setAttribute("position",new T(l,3)),this.setAttribute("normal",new T(c,3)),this.setAttribute("uv",new T(p,2));function m(y,x,w,b,g,f,_,S,z,A,C){const E=f/z,B=_/A,P=f/2,I=_/2,L=S/2,R=z+1,G=A+1;let W=0,nt=0;const D=new M;for(let V=0;V<G;V++){const j=V*B-I;for(let ft=0;ft<R;ft++){const Jt=ft*E-P;D[y]=Jt*b,D[x]=j*g,D[w]=L,l.push(D.x,D.y,D.z),D[y]=0,D[x]=0,D[w]=S>0?1:-1,c.push(D.x,D.y,D.z),p.push(ft/z),p.push(1-V/A),W+=1}}for(let V=0;V<A;V++)for(let j=0;j<z;j++){const ft=u+j+R*V,Jt=u+j+R*(V+1),Le=u+(j+1)+R*(V+1),us=u+(j+1)+R*V;h.push(ft,Jt,us),h.push(Jt,Le,us),nt+=6}a.addGroup(d,nt,C),d+=nt,u+=W}}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 Xr extends q{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new U,this.projectionMatrix=new U,this.projectionMatrixInverse=new U,this.coordinateSystem=Xt}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 Vi=new M,jr=new M,Yr=new kt;let pt=class{constructor(t=new M(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=Vi.subVectors(i,e).cross(jr.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(Vi),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||Yr.getNormalMatrix(t),s=this.coplanarPoint(Vi).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 Ut=new Pe,ti=new M;class Zr{constructor(t=new pt,e=new pt,i=new pt,s=new pt,n=new pt,r=new pt){this.planes=[t,e,i,s,n,r]}set(t,e,i,s,n,r){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(n),a[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Xt){const i=this.planes,s=t.elements,n=s[0],r=s[1],a=s[2],h=s[3],l=s[4],c=s[5],p=s[6],u=s[7],d=s[8],m=s[9],y=s[10],x=s[11],w=s[12],b=s[13],g=s[14],f=s[15];if(i[0].setComponents(h-n,u-l,x-d,f-w).normalize(),i[1].setComponents(h+n,u+l,x+d,f+w).normalize(),i[2].setComponents(h+r,u+c,x+m,f+b).normalize(),i[3].setComponents(h-r,u-c,x-m,f-b).normalize(),i[4].setComponents(h-a,u-p,x-y,f-g).normalize(),e===Xt)i[5].setComponents(h+a,u+p,x+y,f+g).normalize();else if(e===Zi)i[5].setComponents(a,p,y,g).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(),Ut.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Ut.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ut)}intersectsSprite(t){return Ut.center.set(0,0,0),Ut.radius=.7071067811865476,Ut.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ut)}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(ti.x=s.normal.x>0?t.max.x:t.min.x,ti.y=s.normal.y>0?t.max.y:t.min.y,ti.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ti)<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 Te extends st{constructor(t=1,e=1,i=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:s};const n=t/2,r=e/2,a=Math.floor(i),h=Math.floor(s),l=a+1,c=h+1,p=t/a,u=e/h,d=[],m=[],y=[],x=[];for(let w=0;w<c;w++){const b=w*u-r;for(let g=0;g<l;g++){const f=g*p-n;m.push(f,-b,0),y.push(0,0,1),x.push(g/a),x.push(1-w/h)}}for(let w=0;w<h;w++)for(let b=0;b<a;b++){const g=b+l*w,f=b+l*(w+1),_=b+1+l*(w+1),S=b+1+l*w;d.push(g,f,S),d.push(f,_,S)}this.setIndex(d),this.setAttribute("position",new T(m,3)),this.setAttribute("normal",new T(y,3)),this.setAttribute("uv",new T(x,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Te(t.width,t.height,t.widthSegments,t.heightSegments)}}class Gr extends Xr{constructor(t=-1,e=1,i=1,s=-1,n=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=s,this.near=n,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,s,n,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=n,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let n=i-t,r=i+t,a=s+e,h=s-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=l*this.view.offsetX,r=n+l*this.view.width,a-=c*this.view.offsetY,h=a-c*this.view.height}this.projectionMatrix.makeOrthographic(n,r,a,h,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 Sn extends q{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Ie extends ss{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 pi=new M,di=new M,qs=new U,Se=new is,ei=new Pe,Ui=new M,Ws=new M;class _t extends q{constructor(t=new st,e=new Ie){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++)pi.fromBufferAttribute(e,s-1),di.fromBufferAttribute(e,s),i[s]=i[s-1],i[s]+=pi.distanceTo(di);t.setAttribute("lineDistance",new T(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(),ei.copy(i.boundingSphere),ei.applyMatrix4(s),ei.radius+=n,t.ray.intersectsSphere(ei)===!1)return;qs.copy(s).invert(),Se.copy(t.ray).applyMatrix4(qs);const a=n/((this.scale.x+this.scale.y+this.scale.z)/3),h=a*a,l=this.isLineSegments?2:1,c=i.index,u=i.attributes.position;if(c!==null){const d=Math.max(0,r.start),m=Math.min(c.count,r.start+r.count);for(let y=d,x=m-1;y<x;y+=l){const w=c.getX(y),b=c.getX(y+1),g=ii(this,t,Se,h,w,b);g&&e.push(g)}if(this.isLineLoop){const y=c.getX(m-1),x=c.getX(d),w=ii(this,t,Se,h,y,x);w&&e.push(w)}}else{const d=Math.max(0,r.start),m=Math.min(u.count,r.start+r.count);for(let y=d,x=m-1;y<x;y+=l){const w=ii(this,t,Se,h,y,y+1);w&&e.push(w)}if(this.isLineLoop){const y=ii(this,t,Se,h,m-1,d);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 a=s[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}}function ii(o,t,e,i,s,n){const r=o.geometry.attributes.position;if(pi.fromBufferAttribute(r,s),di.fromBufferAttribute(r,n),e.distanceSqToSegment(pi,di,Ui,Ws)>i)return;Ui.applyMatrix4(o.matrixWorld);const h=t.ray.origin.distanceTo(Ui);if(!(h<t.near||h>t.far))return{distance:h,point:Ws.clone().applyMatrix4(o.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:o}}const Xs=new M,js=new M;class vn extends _t{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)Xs.fromBufferAttribute(e,s),js.fromBufferAttribute(e,s+1),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+Xs.distanceTo(js);t.setAttribute("lineDistance",new T(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class $ extends st{constructor(t=1,e=1,i=1,s=32,n=1,r=!1,a=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:s,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:h};const l=this;s=Math.floor(s),n=Math.floor(n);const c=[],p=[],u=[],d=[];let m=0;const y=[],x=i/2;let w=0;b(),r===!1&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(c),this.setAttribute("position",new T(p,3)),this.setAttribute("normal",new T(u,3)),this.setAttribute("uv",new T(d,2));function b(){const f=new M,_=new M;let S=0;const z=(e-t)/i;for(let A=0;A<=n;A++){const C=[],E=A/n,B=E*(e-t)+t;for(let P=0;P<=s;P++){const I=P/s,L=I*h+a,R=Math.sin(L),G=Math.cos(L);_.x=B*R,_.y=-E*i+x,_.z=B*G,p.push(_.x,_.y,_.z),f.set(R,z,G).normalize(),u.push(f.x,f.y,f.z),d.push(I,1-E),C.push(m++)}y.push(C)}for(let A=0;A<s;A++)for(let C=0;C<n;C++){const E=y[C][A],B=y[C+1][A],P=y[C+1][A+1],I=y[C][A+1];(t>0||C!==0)&&(c.push(E,B,I),S+=3),(e>0||C!==n-1)&&(c.push(B,P,I),S+=3)}l.addGroup(w,S,0),w+=S}function g(f){const _=m,S=new X,z=new M;let A=0;const C=f===!0?t:e,E=f===!0?1:-1;for(let P=1;P<=s;P++)p.push(0,x*E,0),u.push(0,E,0),d.push(.5,.5),m++;const B=m;for(let P=0;P<=s;P++){const L=P/s*h+a,R=Math.cos(L),G=Math.sin(L);z.x=C*G,z.y=x*E,z.z=C*R,p.push(z.x,z.y,z.z),u.push(0,E,0),S.x=R*.5+.5,S.y=G*.5*E+.5,d.push(S.x,S.y),m++}for(let P=0;P<s;P++){const I=_+P,L=B+P;f===!0?c.push(L,L+1,I):c.push(L+1,L,I),A+=3}l.addGroup(w,A,f===!0?1:2),w+=A}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new $(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ns extends st{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const n=[],r=[];a(s),l(i),c(),this.setAttribute("position",new T(n,3)),this.setAttribute("normal",new T(n.slice(),3)),this.setAttribute("uv",new T(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function a(b){const g=new M,f=new M,_=new M;for(let S=0;S<e.length;S+=3)d(e[S+0],g),d(e[S+1],f),d(e[S+2],_),h(g,f,_,b)}function h(b,g,f,_){const S=_+1,z=[];for(let A=0;A<=S;A++){z[A]=[];const C=b.clone().lerp(f,A/S),E=g.clone().lerp(f,A/S),B=S-A;for(let P=0;P<=B;P++)P===0&&A===S?z[A][P]=C:z[A][P]=C.clone().lerp(E,P/B)}for(let A=0;A<S;A++)for(let C=0;C<2*(S-A)-1;C++){const E=Math.floor(C/2);C%2===0?(u(z[A][E+1]),u(z[A+1][E]),u(z[A][E])):(u(z[A][E+1]),u(z[A+1][E+1]),u(z[A+1][E]))}}function l(b){const g=new M;for(let f=0;f<n.length;f+=3)g.x=n[f+0],g.y=n[f+1],g.z=n[f+2],g.normalize().multiplyScalar(b),n[f+0]=g.x,n[f+1]=g.y,n[f+2]=g.z}function c(){const b=new M;for(let g=0;g<n.length;g+=3){b.x=n[g+0],b.y=n[g+1],b.z=n[g+2];const f=x(b)/2/Math.PI+.5,_=w(b)/Math.PI+.5;r.push(f,1-_)}m(),p()}function p(){for(let b=0;b<r.length;b+=6){const g=r[b+0],f=r[b+2],_=r[b+4],S=Math.max(g,f,_),z=Math.min(g,f,_);S>.9&&z<.1&&(g<.2&&(r[b+0]+=1),f<.2&&(r[b+2]+=1),_<.2&&(r[b+4]+=1))}}function u(b){n.push(b.x,b.y,b.z)}function d(b,g){const f=b*3;g.x=t[f+0],g.y=t[f+1],g.z=t[f+2]}function m(){const b=new M,g=new M,f=new M,_=new M,S=new X,z=new X,A=new X;for(let C=0,E=0;C<n.length;C+=9,E+=6){b.set(n[C+0],n[C+1],n[C+2]),g.set(n[C+3],n[C+4],n[C+5]),f.set(n[C+6],n[C+7],n[C+8]),S.set(r[E+0],r[E+1]),z.set(r[E+2],r[E+3]),A.set(r[E+4],r[E+5]),_.copy(b).add(g).add(f).divideScalar(3);const B=x(_);y(S,E+0,b,B),y(z,E+2,g,B),y(A,E+4,f,B)}}function y(b,g,f,_){_<0&&b.x===1&&(r[g]=b.x-1),f.x===0&&f.z===0&&(r[g]=_/2/Math.PI+.5)}function x(b){return Math.atan2(b.z,-b.x)}function w(b){return Math.atan2(-b.y,Math.sqrt(b.x*b.x+b.z*b.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ns(t.vertices,t.indices,t.radius,t.details)}}class me extends ns{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 me(t.radius,t.detail)}}class rs extends st{constructor(t=1,e=32,i=16,s=0,n=Math.PI*2,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:s,phiLength:n,thetaStart:r,thetaLength:a},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const h=Math.min(r+a,Math.PI);let l=0;const c=[],p=new M,u=new M,d=[],m=[],y=[],x=[];for(let w=0;w<=i;w++){const b=[],g=w/i;let f=0;w===0&&r===0?f=.5/e:w===i&&h===Math.PI&&(f=-.5/e);for(let _=0;_<=e;_++){const S=_/e;p.x=-t*Math.cos(s+S*n)*Math.sin(r+g*a),p.y=t*Math.cos(r+g*a),p.z=t*Math.sin(s+S*n)*Math.sin(r+g*a),m.push(p.x,p.y,p.z),u.copy(p).normalize(),y.push(u.x,u.y,u.z),x.push(S+f,1-g),b.push(l++)}c.push(b)}for(let w=0;w<i;w++)for(let b=0;b<e;b++){const g=c[w][b+1],f=c[w][b],_=c[w+1][b],S=c[w+1][b+1];(w!==0||r>0)&&d.push(g,f,S),(w!==i-1||h<Math.PI)&&d.push(f,_,S)}this.setIndex(d),this.setAttribute("position",new T(m,3)),this.setAttribute("normal",new T(y,3)),this.setAttribute("uv",new T(x,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rs(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Wt extends st{constructor(t=1,e=.4,i=12,s=48,n=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:s,arc:n},i=Math.floor(i),s=Math.floor(s);const r=[],a=[],h=[],l=[],c=new M,p=new M,u=new M;for(let d=0;d<=i;d++)for(let m=0;m<=s;m++){const y=m/s*n,x=d/i*Math.PI*2;p.x=(t+e*Math.cos(x))*Math.cos(y),p.y=(t+e*Math.cos(x))*Math.sin(y),p.z=e*Math.sin(x),a.push(p.x,p.y,p.z),c.x=t*Math.cos(y),c.y=t*Math.sin(y),u.subVectors(p,c).normalize(),h.push(u.x,u.y,u.z),l.push(m/s),l.push(d/i)}for(let d=1;d<=i;d++)for(let m=1;m<=s;m++){const y=(s+1)*d+m-1,x=(s+1)*(d-1)+m-1,w=(s+1)*(d-1)+m,b=(s+1)*d+m;r.push(y,x,b),r.push(x,w,b)}this.setIndex(r),this.setAttribute("position",new T(a,3)),this.setAttribute("normal",new T(h,3)),this.setAttribute("uv",new T(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wt(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class $r extends ss{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=ur,this.normalScale=new X(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gt,this.combine=mn,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 Ys={enabled:!1,files:{},add:function(o,t){this.enabled!==!1&&(this.files[o]=t)},get:function(o){if(this.enabled!==!1)return this.files[o]},remove:function(o){delete this.files[o]},clear:function(){this.files={}}};class Qr{constructor(t,e,i){const s=this;let n=!1,r=0,a=0,h;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(c){a++,n===!1&&s.onStart!==void 0&&s.onStart(c,r,a),n=!0},this.itemEnd=function(c){r++,s.onProgress!==void 0&&s.onProgress(c,r,a),r===a&&(n=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(c){s.onError!==void 0&&s.onError(c)},this.resolveURL=function(c){return h?h(c):c},this.setURLModifier=function(c){return h=c,this},this.addHandler=function(c,p){return l.push(c,p),this},this.removeHandler=function(c){const p=l.indexOf(c);return p!==-1&&l.splice(p,2),this},this.getHandler=function(c){for(let p=0,u=l.length;p<u;p+=2){const d=l[p],m=l[p+1];if(d.global&&(d.lastIndex=0),d.test(c))return m}return null}}}const Jr=new Qr;class os{constructor(t){this.manager=t!==void 0?t:Jr,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}}os.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ft={};class Kr extends Error{constructor(t,e){super(t),this.response=e}}class to extends os{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=Ys.get(t);if(n!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(n),this.manager.itemEnd(t)},0),n;if(Ft[t]!==void 0){Ft[t].push({onLoad:e,onProgress:i,onError:s});return}Ft[t]=[],Ft[t].push({onLoad:e,onProgress:i,onError:s});const r=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,h=this.responseType;fetch(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const c=Ft[t],p=l.body.getReader(),u=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),d=u?parseInt(u):0,m=d!==0;let y=0;const x=new ReadableStream({start(w){b();function b(){p.read().then(({done:g,value:f})=>{if(g)w.close();else{y+=f.byteLength;const _=new ProgressEvent("progress",{lengthComputable:m,loaded:y,total:d});for(let S=0,z=c.length;S<z;S++){const A=c[S];A.onProgress&&A.onProgress(_)}w.enqueue(f),b()}},g=>{w.error(g)})}}});return new Response(x)}else throw new Kr(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(h){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return l.json();default:if(a===void 0)return l.text();{const p=/charset="?([^;"\s]*)"?/i.exec(a),u=p&&p[1]?p[1].toLowerCase():void 0,d=new TextDecoder(u);return l.arrayBuffer().then(m=>d.decode(m))}}}).then(l=>{Ys.add(t,l);const c=Ft[t];delete Ft[t];for(let p=0,u=c.length;p<u;p++){const d=c[p];d.onLoad&&d.onLoad(l)}}).catch(l=>{const c=Ft[t];if(c===void 0)throw this.manager.itemError(t),l;delete Ft[t];for(let p=0,u=c.length;p<u;p++){const d=c[p];d.onError&&d.onError(l)}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 zn extends q{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 Hi=new U,Zs=new M,Gs=new M;class eo{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new X(512,512),this.map=null,this.mapPass=null,this.matrix=new U,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zr,this._frameExtents=new X(1,1),this._viewportCount=1,this._viewports=[new Zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Zs.setFromMatrixPosition(t.matrixWorld),e.position.copy(Zs),Gs.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Gs),e.updateMatrixWorld(),Hi.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hi),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Hi)}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 io extends eo{constructor(){super(new Gr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class so extends zn{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(q.DEFAULT_UP),this.updateMatrix(),this.target=new q,this.shadow=new io}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class no extends zn{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class ro{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=$s(),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=$s();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function $s(){return performance.now()}const Qs=new U;class An{constructor(t,e,i=0,s=1/0){this.ray=new is(t,e),this.near=i,this.far=s,this.camera=null,this.layers=new Mn,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 Qs.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Qs),this}intersectObject(t,e=!0,i=[]){return Gi(t,this,i,e),i.sort(Js),i}intersectObjects(t,e=!0,i=[]){for(let s=0,n=t.length;s<n;s++)Gi(t[s],this,i,e);return i.sort(Js),i}}function Js(o,t){return o.distance-t.distance}function Gi(o,t,e,i){let s=!0;if(o.layers.test(t.layers)&&o.raycast(t,e)===!1&&(s=!1),s===!0&&i===!0){const n=o.children;for(let r=0,a=n.length;r<a;r++)Gi(n[r],t,e,!0)}}class oo{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(it(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class ao extends vn{constructor(t=10,e=10,i=4473924,s=8947848){i=new ht(i),s=new ht(s);const n=e/2,r=t/e,a=t/2,h=[],l=[];for(let u=0,d=0,m=-a;u<=e;u++,m+=r){h.push(-a,0,m,a,0,m),h.push(m,0,-a,m,0,a);const y=u===n?i:s;y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3,y.toArray(l,d),d+=3}const c=new st;c.setAttribute("position",new T(h,3)),c.setAttribute("color",new T(l,3));const p=new Ie({vertexColors:!0,toneMapped:!1});super(c,p),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ho extends vn{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 st;n.setIndex(new Yt(i,1)),n.setAttribute("position",new T(s,3)),super(n,new Ie({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()}}const Ks=new M;let si,qi;class lo extends q{constructor(t=new M(0,0,1),e=new M(0,0,0),i=1,s=16776960,n=i*.2,r=n*.2){super(),this.type="ArrowHelper",si===void 0&&(si=new st,si.setAttribute("position",new T([0,0,0,0,1,0],3)),qi=new $(0,.5,1,5,1),qi.translate(0,-.5,0)),this.position.copy(e),this.line=new _t(si,new Ie({color:s,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new k(qi,new $t({color:s,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(i,n,r)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Ks.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Ks,e)}}setLength(t,e=t*.2,i=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class co extends St{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:pn}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pn);function uo(o){return URL.canParse(o)&&(o.startsWith("http://")||o.startsWith("https://"))}async function po(o,t){return(await yi(o,t)).arrayBuffer()}function yi(o,t){if(typeof o=="string"){const e=Qt(o);return Qn.fetch(e,t)}return Jn.fetchFile(o,t)}async function mo(o,t){return await(await yi(o,t)).json()}async function fo(o,t){return(await yi(o,t)).text()}function yo(o){let t,e;if(o instanceof Response){const r=new URL(o.url);t=`${r.origin}${r.pathname}`,e=r.search}else if(o instanceof File)t=o.name;else if(o instanceof Blob)t="";else if(typeof o=="string"){const r=Qt(o),a=new URL(r);t=`${a.origin}${a.pathname}`,e=a.search}else return o;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 xo(o){return new Promise((t,e)=>{if(typeof o=="string")return Qt(o);{const i=new FileReader;i.addEventListener("load",()=>t(i.result),!1),i.addEventListener("error",()=>e(i.error)),i.readAsDataURL(o)}})}const xi={checkAbsoluteHost:uo,fetch:yi,fetchArrayBuffer:po,fetchJson:mo,fetchText:fo,getContext:yo,toDataURL:xo};let $i=null,Cn={};function ot(){if(!$i)throw new Error("No configuration loaded");return $i}function go(){return Cn}async function wo(o){return await xi.fetchJson(o)}async function bo(o){o.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."),o.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(o.crs_definitions))try{$n.registerCRS(t,e)}catch(i){throw console.error(`Failed to register CRS "${t}" as "${e}".`),i}return $i=o,Promise.resolve()}function Mo(o){Cn=o}function _o(o,t){const e=JSON.stringify(o,null,2),i=new Blob([e],{type:"application/json"});En(i,t)}function En(o,t){const e=URL.createObjectURL(o),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 Fn;function So(o="http://localhost:8080/"){const t=Fn??o;return t.at(-1)==="/"?t:t+"/"}function vo(o){Fn=o}const Bn={downloadAsJson:_o,downloadBlob:En,getBaseUrl:So,setBaseUrl:vo};function kn(o){const t=ps.scale(o.ramp).mode("lab").colors(256).map(e=>{const i=ps(e).gl();return new ht().setRGB(i[0],i[1],i[2],"srgb")});return new Kn({colors:t,...o})}function zo(o){const t=ot();return o?new ue(o.crs??t.default_crs,o.x,o.y,o.z??0).as(t.default_crs):void 0}function as(o){const t=ot();return o?new cn(o.crs??t.default_crs,o).as(t.default_crs):void 0}function Qt(o){return o.startsWith("http://")||o.startsWith("https://")?o:new URL(o,Bn.getBaseUrl()).toString()}function Ao(o){var e;return((e=ot().enabled_features)==null?void 0:e.includes(o))??!1}function Co(o,t){const e=o.isEntity3D?o.object3d:o;"dataset"in e.userData||(e.userData.dataset={});for(const[i,s]of Object.entries(t))e.userData.dataset[i]=s}const Eo="#377c5f",Fo="yellow",Bo="#ffd500",ko="#73d1bd",Po=5;function To(o){if(o==null)throw new Error("non null assertion failed");return o}const ge=o=>o!=null&&typeof o=="object",Io=o=>ge(o)&&"href"in o,Lo=o=>ge(o)&&o.isColor,Do=o=>ge(o)&&o.isVector3;class Pn extends St{constructor(e){super();F(this,"config");F(this,"name");F(this,"onObjectPreloaded");F(this,"type");F(this,"uuid");F(this,"_isPreloaded");F(this,"_isPreloading");F(this,"_opacity");F(this,"_parent");F(this,"_visible");this.type=e.type,this.uuid=es.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 hs extends Pn{constructor(e){super(e);F(this,"_children");this._children=In(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))}}F(hs,"isGroup",e=>ge(e)&&e.type==="group");class Tn extends Pn{constructor(t){super(t)}leafs(){return[this]}traverse(t){t(this)}}function In(o,t){return o.map(e=>{let i;return e.type==="group"?i=new hs(e):i=new Tn(e),t&&(i.parent=t,i.visible=i.visible||t.visible),i})}const Ro=new Intl.NumberFormat(void 0,{maximumFractionDigits:2,style:"unit",unit:"meter",unitDisplay:"short"}),Oo=o=>`${Ro.format(o.length)}`,fi=class fi extends ci{constructor(){super({color:Fo,lineLabelFormatter:Oo,showLineLabel:!0});F(this,"isMeasure3D",!0);this.userData.highlightable=!0,this.userData.highlightColor=Bo,this.depthTest=!0}get from(){return this.points[0]}get length(){return this.getLength()}get to(){return this.points[1]}clone(){return new fi().copy(this)}copy(e){return this.setPoints([e.from,e.to]),this}};F(fi,"isMeasure3D",e=>ge(e)&&e.isMeasure3D);let mi=fi;const gi=ye.defineStore("camera",()=>{const o=v.ref(),t=v.ref(new M),e=v.ref("orbit"),i=v.ref(!1);function s(){if(o.value===void 0)throw new Error("Cannot get cameraPosition");return o.value}function n(){return t.value}function r(m){o.value=m}function a(m,y){o.value=m,t.value.copy(y)}function h(){return e.value}function l(){return e}function c(m){e.value=m}function p(){return i.value}function u(m){i.value=m}function d(m){}return{getCamera3dPosition:n,getCameraPosition:s,getNavigationMode:h,getNavigationModeRef:l,isUserInteracting:p,lookTopDownAt:d,setCameraPosition:r,setCurrentPosition:a,setIsUserInteracting:u,setNavigationMode:c}}),ls=ye.defineStore("clippingBox",()=>{const o=v.ref(0),t=v.ref(new M(0,0,0)),e=v.ref(new M(0,0,0)),i=v.ref(!1),s=v.ref(!1),n=v.ref(!1),r=v.ref(new bt().setFromCenterAndSize(t.value,e.value));function a(){r.value=new bt().setFromCenterAndSize(t.value,e.value)}function h(y){i.value=y}function l(y){s.value=y}function c(y){o.value=y}function p(y){t.value=y,a()}function u(y){e.value=y,a()}function d(y){n.value=y}function m(y){r.value=y.clone();const x=new M,w=new M;y.getCenter(x),y.getSize(w),t.value=x,e.value=w}return{center:t,clippingBox:r,displayHelper:n,enable:i,invert:s,orientation:o,setCenter:p,setClippingBox:m,setDisplayHelper:d,setEnabled:h,setInverted:l,setOrientation:c,setSize:u,size:e}}),No={class:"input-group"},Vo={class:"form-check form-switch"},Uo=["checked"],Ho={class:"input-group"},qo={class:"form-check form-switch"},Wo=["checked"],Xo={class:"input-group"},jo={class:"form-check form-switch"},Yo=["checked"],Zo={class:"accordion mt-3"},Go={class:"accordion-item"},$o={id:"clippingbox-size",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},Qo={class:"accordion-body"},Jo={class:"d-flex justify-content-between align-items-end w-100"},Ko={class:"input-group mb-3"},ta=["value"],ea=["value"],ia=["value"],sa={class:"input-group mb-3"},na=["value"],ra=["value"],oa=["value"],aa={class:"accordion-item"},ha={id:"clippingbox-floorpreset",class:"accordion-collapse collapse show","data-bs-parent":"#accordionExample"},la={class:"accordion-body"},ca={class:"row w-100"},ua={class:"col-sm-6"},pa={class:"input-group input-group-sm"},da={class:"row w-100"},ma={class:"col-sm-6"},fa={class:"input-group input-group-sm"},ya={class:"row w-100"},xa={class:"col-sm-6"},ga={class:"input-group input-group-sm"},wa=v.defineComponent({__name:"ClippingBox",setup(o){const t=ot(),e=ls(),i=gi(),s=g=>Number.parseFloat(g.target.value);function n(){const{target:g}=i.getCameraPosition();e.setCenter(g.clone())}function r(g){const f=e.size.clone();f.setX(g),e.setSize(f)}function a(g){const f=e.size.clone();f.setY(g),e.setSize(f)}function h(g){const f=e.size.clone();f.setZ(g),e.setSize(f)}function l(g){const f=e.center.clone();f.setX(g),e.setCenter(f)}function c(g){const f=e.center.clone();f.setY(g),e.setCenter(f)}function p(g){const f=e.center.clone();f.setZ(g),e.setCenter(f)}const u=v.ref(t.analysis.clipping_box.floor_preset.altitude),d=v.ref(t.analysis.clipping_box.floor_preset.size),m=v.ref(t.analysis.clipping_box.floor_preset.floor);function y(){m.value-=1;const g=e.center.clone();g.setZ(w()),e.setCenter(g)}function x(){m.value+=1;const g=e.center.clone();g.setZ(w()),e.setCenter(g)}function w(){return u.value+(m.value+.5)*d.value}function b(){const{target:g}=i.getCameraPosition(),f=g.clone();f.z=w();const _=new M(1e3,1e3,d.value);e.setSize(_),e.setCenter(f)}return(g,f)=>(v.openBlock(),v.createElementBlock("div",null,[v.createElementVNode("div",No,[v.createElementVNode("div",Vo,[v.createElementVNode("input",{class:"form-check-input",checked:v.unref(e).enable,type:"checkbox",role:"switch",id:"enable-clippingbox",onInput:f[0]||(f[0]=_=>v.unref(e).setEnabled(!v.unref(e).enable))},null,40,Uo),f[14]||(f[14]=v.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox"},"Enable clipping box",-1))])]),v.createElementVNode("div",Ho,[v.createElementVNode("div",qo,[v.createElementVNode("input",{class:"form-check-input",checked:v.unref(e).invert,type:"checkbox",role:"switch",id:"invert-clippingbox",onInput:f[1]||(f[1]=_=>v.unref(e).setInverted(!v.unref(e).invert))},null,40,Wo),f[15]||(f[15]=v.createElementVNode("label",{class:"form-check-label",for:"invert-clippingbox"},"Invert clipping box",-1))])]),v.createElementVNode("div",Xo,[v.createElementVNode("div",jo,[v.createElementVNode("input",{class:"form-check-input",checked:v.unref(e).displayHelper,type:"checkbox",role:"switch",id:"enable-clippingbox-helper",onInput:f[2]||(f[2]=_=>v.unref(e).setDisplayHelper(!v.unref(e).displayHelper))},null,40,Yo),f[16]||(f[16]=v.createElementVNode("label",{class:"form-check-label",for:"enable-clippingbox-helper"},"Show 3D helper",-1))])]),v.createElementVNode("div",Zo,[v.createElementVNode("div",Go,[f[19]||(f[19]=v.createElementVNode("h2",{class:"accordion-header"},[v.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)),v.createElementVNode("div",$o,[v.createElementVNode("div",Qo,[v.createElementVNode("div",Jo,[f[17]||(f[17]=v.createElementVNode("label",{class:"form-label flex-grow"},"Center (x, y, z)",-1)),v.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[3]||(f[3]=_=>n())}," Set from view ")]),v.createElementVNode("div",Ko,[v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-x",value:v.unref(e).center.x,onInput:f[4]||(f[4]=_=>l(s(_)))},null,40,ta),v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-y",value:v.unref(e).center.y,onInput:f[5]||(f[5]=_=>c(s(_)))},null,40,ea),v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-center-z",value:v.unref(e).center.z,onInput:f[6]||(f[6]=_=>p(s(_)))},null,40,ia)]),f[18]||(f[18]=v.createElementVNode("label",{class:"form-label"},"Size (x, y, z)",-1)),v.createElementVNode("div",sa,[v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-x",min:"1",value:v.unref(e).size.x,onInput:f[7]||(f[7]=_=>r(s(_)))},null,40,na),v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-y",min:"1",value:v.unref(e).size.y,onInput:f[8]||(f[8]=_=>a(s(_)))},null,40,ra),v.createElementVNode("input",{type:"number",class:"form-control",id:"plane-size-z",min:"1",value:v.unref(e).size.z,onInput:f[9]||(f[9]=_=>h(s(_)))},null,40,oa)])])])]),v.createElementVNode("div",aa,[f[27]||(f[27]=v.createElementVNode("h2",{class:"accordion-header"},[v.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)),v.createElementVNode("div",ha,[v.createElementVNode("div",la,[v.createElementVNode("div",ca,[f[21]||(f[21]=v.createElementVNode("label",{for:"floor-reference-altitude",class:"col-sm-6 col-form-label col-form-label-sm"},"Reference altitude",-1)),v.createElementVNode("div",ua,[v.createElementVNode("div",pa,[v.withDirectives(v.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-reference-altitude","onUpdate:modelValue":f[10]||(f[10]=_=>u.value=_)},null,512),[[v.vModelText,u.value]]),f[20]||(f[20]=v.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),v.createElementVNode("div",da,[f[23]||(f[23]=v.createElementVNode("label",{for:"floor-size",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor size",-1)),v.createElementVNode("div",ma,[v.createElementVNode("div",fa,[v.withDirectives(v.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-size","onUpdate:modelValue":f[11]||(f[11]=_=>d.value=_)},null,512),[[v.vModelText,d.value]]),f[22]||(f[22]=v.createElementVNode("span",{class:"input-group-text"},"m",-1))])])]),v.createElementVNode("div",ya,[f[26]||(f[26]=v.createElementVNode("label",{for:"floor-number",class:"col-sm-6 col-form-label col-form-label-sm"},"Floor number",-1)),v.createElementVNode("div",xa,[v.createElementVNode("div",ga,[v.withDirectives(v.createElementVNode("input",{type:"number",class:"form-control form-control-sm",id:"floor-number","onUpdate:modelValue":f[12]||(f[12]=_=>m.value=_)},null,512),[[v.vModelText,m.value]]),v.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:x},[...f[24]||(f[24]=[v.createElementVNode("i",{class:"bi bi-arrow-up-short"},null,-1)])]),v.createElementVNode("button",{class:"btn btn-outline-secondary btn-sm px-0",type:"button",onClick:y},[...f[25]||(f[25]=[v.createElementVNode("i",{class:"bi bi-arrow-down-short"},null,-1)])])])])]),v.createElementVNode("button",{type:"button",class:"btn btn-outline-secondary btn-sm",onClick:f[13]||(f[13]=_=>b())}," Set ")])])])])]))}}),wi=(o,t)=>{const e=o.__vccOpts||o;for(const[i,s]of t)e[i]=s;return e},ba=wi(wa,[["__scopeId","data-v-803bbe4b"]]),Ht=new An,K=new M,Rt=new M,N=new et,tn={X:new M(1,0,0),Y:new M(0,1,0),Z:new M(0,0,1)},Wi={type:"change"},en={type:"mouseDown",mode:null},sn={type:"mouseUp",mode:null},nn={type:"objectChange"};class Ma extends co{constructor(t,e=null){super(void 0,e);const i=new Ca(this);this._root=i;const s=new Ea;this._gizmo=s,i.add(s);const n=new Fa;this._plane=n,i.add(n);const r=this;function a(g,f){let _=f;Object.defineProperty(r,g,{get:function(){return _!==void 0?_:f},set:function(S){_!==S&&(_=S,n[g]=S,s[g]=S,r.dispatchEvent({type:g+"-changed",value:S}),r.dispatchEvent(Wi))}}),r[g]=f,n[g]=f,s[g]=f}a("camera",t),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const h=new M,l=new M,c=new et,p=new et,u=new M,d=new et,m=new M,y=new M,x=new M,w=0,b=new M;a("worldPosition",h),a("worldPositionStart",l),a("worldQuaternion",c),a("worldQuaternionStart",p),a("cameraPosition",u),a("cameraQuaternion",d),a("pointStart",m),a("pointEnd",y),a("rotationAxis",x),a("rotationAngle",w),a("eye",b),this._offset=new M,this._startNorm=new M,this._endNorm=new M,this._cameraScale=new M,this._parentPosition=new M,this._parentQuaternion=new et,this._parentQuaternionInv=new et,this._parentScale=new M,this._worldScaleStart=new M,this._worldQuaternionInv=new et,this._worldScale=new M,this._positionStart=new M,this._quaternionStart=new et,this._scaleStart=new M,this._getPointer=_a.bind(this),this._onPointerDown=va.bind(this),this._onPointerHover=Sa.bind(this),this._onPointerMove=za.bind(this),this._onPointerUp=Aa.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&&Ht.setFromCamera(t,this.camera);const e=Xi(this._gizmo.picker[this.mode],Ht);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&&Ht.setFromCamera(t,this.camera);const e=Xi(this._plane,Ht,!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,en.mode=this.mode,this.dispatchEvent(en)}}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&&Ht.setFromCamera(t,this.camera);const r=Xi(this._plane,Ht,!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(N.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 a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Rt.set(a,a,a)}else K.copy(this.pointStart),Rt.copy(this.pointEnd),K.applyQuaternion(this._worldQuaternionInv),Rt.applyQuaternion(this._worldQuaternionInv),Rt.divide(K),e.search("X")===-1&&(Rt.x=1),e.search("Y")===-1&&(Rt.y=1),e.search("Z")===-1&&(Rt.z=1);s.scale.copy(this._scaleStart).multiply(Rt),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 a=20/this.worldPosition.distanceTo(K.setFromMatrixPosition(this.camera.matrixWorld));let h=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(K.copy(this.rotationAxis).cross(this.eye))*a):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(tn[e]),K.copy(tn[e]),n==="local"&&K.applyQuaternion(this.worldQuaternion),K.cross(this.eye),K.length()===0?h=!0:this.rotationAngle=this._offset.dot(K.normalize())*a),(e==="E"||h)&&(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(N.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(N.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Wi),this.dispatchEvent(nn)}}pointerUp(t){t!==null&&t.button!==0||(this.dragging&&this.axis!==null&&(sn.mode=this.mode,this.dispatchEvent(sn)),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(Wi),this.dispatchEvent(nn),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ht}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 _a(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const t=this.domElement.getBoundingClientRect();return{x:(o.clientX-t.left)/t.width*2-1,y:-(o.clientY-t.top)/t.height*2+1,button:o.button}}}function Sa(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o));break}}function va(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function za(o){this.enabled&&this.pointerMove(this._getPointer(o))}function Aa(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function Xi(o,t,e){const i=t.intersectObject(o,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||e)return i[s];return!1}const ni=new Gt,O=new M(0,1,0),rn=new M(0,0,0),on=new U,ri=new et,hi=new et,Mt=new M,an=new U,Ce=new M(1,0,0),qt=new M(0,1,0),Ee=new M(0,0,1),oi=new M,ve=new M,ze=new M;class Ca extends q{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 Ea extends q{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new $t({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new Ie({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 a=t.clone();a.color.setHex(255);const h=t.clone();h.color.setHex(16711680),h.opacity=.5;const l=t.clone();l.color.setHex(65280),l.opacity=.5;const c=t.clone();c.color.setHex(255),c.opacity=.5;const p=t.clone();p.opacity=.25;const u=t.clone();u.color.setHex(16776960),u.opacity=.25,t.clone().color.setHex(16776960);const m=t.clone();m.color.setHex(7895160);const y=new $(0,.04,.1,12);y.translate(0,.05,0);const x=new Z(.08,.08,.08);x.translate(0,.04,0);const w=new st;w.setAttribute("position",new T([0,0,0,1,0,0],3));const b=new $(.0075,.0075,.5,3);b.translate(0,.25,0);function g(R,G){const W=new Wt(R,.0075,3,64,G*Math.PI*2);return W.rotateY(Math.PI/2),W.rotateX(Math.PI/2),W}function f(){const R=new st;return R.setAttribute("position",new T([0,0,0,1,1,1],3)),R}const _={X:[[new k(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new k(y,n),[-.5,0,0],[0,0,Math.PI/2]],[new k(b,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new k(y,r),[0,.5,0]],[new k(y,r),[0,-.5,0],[Math.PI,0,0]],[new k(b,r)]],Z:[[new k(y,a),[0,0,.5],[Math.PI/2,0,0]],[new k(y,a),[0,0,-.5],[-Math.PI/2,0,0]],[new k(b,a),null,[Math.PI/2,0,0]]],XYZ:[[new k(new me(.1,0),p.clone()),[0,0,0]]],XY:[[new k(new Z(.15,.15,.01),c.clone()),[.15,.15,0]]],YZ:[[new k(new Z(.15,.15,.01),h.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new k(new Z(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new k(new $(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new k(new $(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new k(new $(.2,0,.6,4),i),[0,.3,0]],[new k(new $(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new k(new $(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new k(new $(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new k(new me(.2,0),i)]],XY:[[new k(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new k(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new k(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},z={START:[[new k(new me(.01,2),s),null,null,null,"helper"]],END:[[new k(new me(.01,2),s),null,null,null,"helper"]],DELTA:[[new _t(f(),s),null,null,null,"helper"]],X:[[new _t(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new _t(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new _t(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},A={XYZE:[[new k(g(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new k(g(.5,.5),n)]],Y:[[new k(g(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new k(g(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new k(g(.75,1),u),null,[0,Math.PI/2,0]]]},C={AXIS:[[new _t(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},E={XYZE:[[new k(new rs(.25,10,8),i)]],X:[[new k(new Wt(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new k(new Wt(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new k(new Wt(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new k(new Wt(.75,.1,2,24),i)]]},B={X:[[new k(x,n),[.5,0,0],[0,0,-Math.PI/2]],[new k(b,n),[0,0,0],[0,0,-Math.PI/2]],[new k(x,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new k(x,r),[0,.5,0]],[new k(b,r)],[new k(x,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new k(x,a),[0,0,.5],[Math.PI/2,0,0]],[new k(b,a),[0,0,0],[Math.PI/2,0,0]],[new k(x,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new k(new Z(.15,.15,.01),c),[.15,.15,0]]],YZ:[[new k(new Z(.15,.15,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new k(new Z(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new k(new Z(.1,.1,.1),p.clone())]]},P={X:[[new k(new $(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new k(new $(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new k(new $(.2,0,.6,4),i),[0,.3,0]],[new k(new $(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new k(new $(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new k(new $(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new k(new Z(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new k(new Z(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new k(new Z(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new k(new Z(.2,.2,.2),i),[0,0,0]]]},I={X:[[new _t(w,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new _t(w,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new _t(w,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function L(R){const G=new q;for(const W in R)for(let nt=R[W].length;nt--;){const D=R[W][nt][0].clone(),V=R[W][nt][1],j=R[W][nt][2],ft=R[W][nt][3],Jt=R[W][nt][4];D.name=W,D.tag=Jt,V&&D.position.set(V[0],V[1],V[2]),j&&D.rotation.set(j[0],j[1],j[2]),ft&&D.scale.set(ft[0],ft[1],ft[2]),D.updateMatrix();const Le=D.geometry.clone();Le.applyMatrix4(D.matrix),D.geometry=Le,D.renderOrder=1/0,D.position.set(0,0,0),D.rotation.set(0,0,0),D.scale.set(1,1,1),G.add(D)}return G}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=L(_)),this.add(this.gizmo.rotate=L(A)),this.add(this.gizmo.scale=L(B)),this.add(this.picker.translate=L(S)),this.add(this.picker.rotate=L(E)),this.add(this.picker.scale=L(P)),this.add(this.helper.translate=L(z)),this.add(this.helper.rotate=L(C)),this.add(this.helper.scale=L(I)),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:hi;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 a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=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(a*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(N.setFromEuler(ni.set(0,0,0)),r.quaternion.copy(i).multiply(N),Math.abs(O.copy(Ce).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(N.setFromEuler(ni.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(N),Math.abs(O.copy(qt).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(N.setFromEuler(ni.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(N),Math.abs(O.copy(Ee).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(N.setFromEuler(ni.set(0,Math.PI/2,0)),O.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(on.lookAt(rn,O,qt)),r.quaternion.multiply(N),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(O.copy(Ce).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(O.copy(qt).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(O.copy(Ee).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(O.copy(Ee).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(O.copy(Ce).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(O.copy(qt).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(ri.copy(i),O.copy(this.eye).applyQuaternion(N.copy(i).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(on.lookAt(this.eye,rn,qt)),r.name==="X"&&(N.setFromAxisAngle(Ce,Math.atan2(-O.y,O.z)),N.multiplyQuaternions(ri,N),r.quaternion.copy(N)),r.name==="Y"&&(N.setFromAxisAngle(qt,Math.atan2(O.x,O.z)),N.multiplyQuaternions(ri,N),r.quaternion.copy(N)),r.name==="Z"&&(N.setFromAxisAngle(Ee,Math.atan2(O.y,O.x)),N.multiplyQuaternions(ri,N),r.quaternion.copy(N))),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(h){return r.name===h}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(t)}}class Fa extends k{constructor(){super(new Te(1e5,1e5,2,2),new $t({visible:!1,wireframe:!0,side:dn,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"),oi.copy(Ce).applyQuaternion(e==="local"?this.worldQuaternion:hi),ve.copy(qt).applyQuaternion(e==="local"?this.worldQuaternion:hi),ze.copy(Ee).applyQuaternion(e==="local"?this.worldQuaternion:hi),O.copy(ve),this.mode){case"translate":case"scale":switch(this.axis){case"X":O.copy(this.eye).cross(oi),Mt.copy(oi).cross(O);break;case"Y":O.copy(this.eye).cross(ve),Mt.copy(ve).cross(O);break;case"Z":O.copy(this.eye).cross(ze),Mt.copy(ze).cross(O);break;case"XY":Mt.copy(ze);break;case"YZ":Mt.copy(oi);break;case"XZ":O.copy(ze),Mt.copy(ve);break;case"XYZ":case"E":Mt.set(0,0,0);break}break;case"rotate":default:Mt.set(0,0,0)}Mt.length()===0?this.quaternion.copy(this.cameraQuaternion):(an.lookAt(K.set(0,0,0),Mt,O),this.quaternion.setFromRotationMatrix(an)),super.updateMatrixWorld(t)}}function Ln(o){const t=v.shallowReactive(o);return t.type==="group"&&(t.children=v.shallowReactive(t.children.map(e=>Ln(e)))),t}const Dn=ye.defineStore("datasets",()=>{const o=ot(),t=v.shallowReactive(In(o.datasets).map(S=>Ln(S))),e=v.computed(()=>t.map(S=>S.leafs()).flat()),i=v.computed(()=>e.value.length),s=new Map,n=new Map,r=v.ref([]);function a(S){r.value=[...r.value,{...S,mustBePreloaded:S.mustBePreloaded??!1,mustBeVisible:S.mustBeVisible??!1}]}function h(){return t}function l(){return e.value}function c(S){const z=v.shallowReactive(S);return t.push(z),z}function p(S,z){s.set(S.uuid,z)}function u(S,z){n.set(S.uuid,z)}function d(S){const z=S.parent!=null?S.parent.children:t;z.splice(z.indexOf(S),1)}function m(S){const z=new bt;return S.traverse(A=>{var I;const C=s.get(A.uuid),E=C==null?void 0:C.getBoundingBox();if(E&&!E.isEmpty()){z.union(E);return}const B=n.get(A.uuid),P=(I=B==null?void 0:B.getExtent())==null?void 0:I.as(o.default_crs);if(P&&P.isValid()){const L=P.toBox3(0,0);z.union(L);return}}),z}function y(S){return s.get(S.uuid)}function x(S){return n.get(S.uuid)}function w(S){}function b(S,z){}function g(S){}function f(S){}function _(S,z){return r.value.filter(C=>!(C.predicate!=null&&!C.predicate(S)||C.mustBeVisible&&!z.isVisible||C.mustBePreloaded&&!z.isPreloaded))}return{add:c,attachEntity:p,attachLayer:u,count:i,getBoundingBox:m,getCustomActions:_,getDatasets:l,getEntity:y,getLayer:x,getTree:h,importFromFile:w,registerCustomAction:a,remove:d,setVisible:b,toggleGrid:g,toggleMask:f}}),Ba=new $t({color:"yellow",opacity:.1,transparent:!0});class ka{constructor(t){F(this,"_cameraStore",gi());F(this,"_clippingBox",null);F(this,"_clippingBoxHelper",null);F(this,"_clippingBoxMesh",null);F(this,"_datasetStore",Dn());F(this,"_previousTransformControls",this._cameraStore.getNavigationMode());F(this,"_store",ls());F(this,"_transformControls",null);F(this,"_volumeHelpers",new Sn);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 bt,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 k(s,Ba),this._clippingBoxHelper=new ho(this._clippingBox,new ht("yellow")),this._clippingBoxMesh.renderOrder=2,this._clippingBoxMesh.position.copy(t),this._clippingBoxMesh.updateMatrixWorld(),this._clippingBoxHelper.updateMatrixWorld(),this._transformControls=new Ma(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,a,h;(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(),(a=this._clippingBoxHelper)==null||a.removeFromParent(),(h=this._clippingBoxHelper)==null||h.dispose(),this.context.view.getInstance().notifyChange()}getPlanesFromBoxSides(){if(this._clippingBox===null)throw new Error("No clippingBox defined");const t=[];return t.push(new pt(new M(0,0,1),-this._clippingBox.min.z)),t.push(new pt(new M(0,0,-1),+this._clippingBox.max.z)),t.push(new pt(new M(1,0,0),-this._clippingBox.min.x)),t.push(new pt(new M(-1,0,0),+this._clippingBox.max.x)),t.push(new pt(new M(0,1,0),-this._clippingBox.min.y)),t.push(new pt(new M(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._store.enable&&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 cs="builtin-clipping-box-analysis";class Pa{constructor(){F(this,"id",cs);F(this,"name","Clipping box");F(this,"_manager",null);F(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:ba,icon:"bi-bounding-box",name:"Clipping box"}),this._store=ls();const e=new ka(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 Rn=ye.defineStore("modules",()=>{const o=v.shallowRef([]);function t(s){o.value=s}function e(){return o.value}function i(s){for(const n of o.value)if(n.id===s)return n;return null}return{getLoadedModules:e,getModule:i,setLoadedModules:t}});class Ta{constructor(t,e,i,s){F(this,"attributes");F(this,"name");F(this,"parent");F(this,"point");this.name=t,this.parent=e,this.attributes=i,this.point=s.clone()}}class Ia{constructor(t,e,i){F(this,"_grid");F(this,"_instance");this._instance=t;const s=e.dimensions(),n=e.center();this._grid=new ao(1,100),this._grid.name=i,this._grid.scale.set(s.x,1,s.y),this._grid.visible=!0,this._grid.position.set(n.x,n.y,-100),this._grid.rotateOnAxis(new M(1,0,0),Math.PI/2);const r=this._grid.material;r.opacity=.5,r.transparent=!0,this._grid.updateMatrixWorld(),this._instance.add(this._grid)}get visible(){return this._grid.visible}set visible(t){this._grid.visible=t,this._instance.notifyChange(this._grid)}dispose(){this._instance.remove(this._grid),this._grid.geometry.dispose(),this._grid.material.dispose()}}async function La(o,t,e,i){const s=new Ae.WMTSCapabilities,n=await xi.fetchText(t),r=s.read(n),a=nr.optionsFromCapabilities(r,{layer:o});if(a===null)throw new Error("Cannot resolve WMTS source from capabilities");return new pe.WMTS(a)}async function Da(o,t){const e=await bi(t.config);switch(t.type){case"colorLayer":{const i=t.config;return new ke({...e,elevationRange:i.elevationRange,magFilter:i.magFilter,minFilter:i.minFilter})}case"elevationLayer":{const i=t.config;return new Fe({...e,minmax:i.minmax})}case"maskLayer":{const i=t.config;return new un({...e,maskMode:i.maskMode})}default:return t.type}}function Ra(o){if(o==null)return new tt.Style;switch(o){case"LineString":case"MultiLineString":return new tt.Style({stroke:new tt.Stroke({color:"yellow",width:1})});case"MultiPoint":case"Point":return new tt.Style({image:new tt.Circle({fill:new tt.Fill({color:"yellow"}),radius:3,stroke:new tt.Stroke({color:"black"})})});case"MultiPolygon":case"Polygon":return new tt.Style({fill:new tt.Fill({color:"rgba(50, 50, 200, 0.4)"}),stroke:new tt.Stroke({color:"black",width:1})});default:return console.warn(`Geometry ${o} not supported`),new tt.Style}}function Oa(o){if(o.imageFormat)switch(o.imageFormat){case"Bil":return new ds;case"GeoTIFF":return new er;case"MapboxTerrain":return new ir;default:return o.imageFormat}switch(o.format){case"image/x-bil;bits=32":return new ds;default:return}}function Na(o){return{colorSpace:o.colorSpace,flipY:o.flipY,is8bit:o.is8bit}}async function Va(o){const t=await bi(o);switch(o.type){case"color":{const e=o.options;return new ke({...t,elevationRange:e.elevationRange})}case"elevation":{const e=o.options;return new Fe({...t,magFilter:e.magFilter,minFilter:e.minFilter,minmax:e.minmax??{max:5e3,min:0},noDataOptions:{replaceNoData:!1}})}case"mask":{const e=o.options;return new un({...t,maskMode:e.maskMode})}default:return o.type}}async function bi(o){const t=ot(),e=await On(o.source),i="options"in o?o.options:o,s=as(i.extent),n=i.interpretation?new tr(i.interpretation.mode,i.interpretation):void 0,r=i.colorMap??("type"in o&&o.type==="elevation"?t.basemap.colormap:void 0),a=r?kn(r):void 0,h="resolution"in o.source?o.source.resolution:void 0;let l,c;return"type"in o&&o.type==="color"&&(l=o.options.minFilter,c=o.options.magFilter),{backgroundColor:i.backgroundColor,colorMap:a,extent:s,interpretation:n,magFilter:c,minFilter:l,name:o.name,noDataOptions:i.noDataOptions,preloadImages:i.preloadImages,resolutionFactor:h,showEmptyTextures:i.showEmptyTextures,showTileBorders:i.showTileBorders,source:e}}async function Ua(o,t){const e=await bi(o),i=o.options;return new ke({extent:t,...e,elevationRange:i.elevationRange,magFilter:i.magFilter,minFilter:i.minFilter})}async function On(o){const t=Na(o);switch(o.type){case"bingmaps":return new Kt({...t,source:new pe.BingMaps(o)});case"cog":return new sr({...t,crs:li(o,o.projection),url:Qt(o.url)});case"geojson":return new De({...t,...await ai(o,new Ae.GeoJSON)});case"gpx":return new De({...t,...await ai(o,new Ae.GPX)});case"kml":return new De({...t,...await ai(o,new Ae.KML)});case"mvt":return new ms({...t,...hn(o),format:new Ae.MVT});case"osm":return new Kt({...t,source:new pe.OSM(o)});case"stadiamaps":return new Kt({...t,source:new pe.StadiaMaps(o)});case"vector":return new De({...t,...await ai(o,o.format)});case"vector-tile":return new ms({...t,...hn(o),format:o.format});case"wms":{const e=new pe.TileWMS({crossOrigin:"anonymous",params:{FORMAT:o.format,LAYERS:Array.isArray(o.layer)?o.layer:[o.layer]},projection:li(o),url:o.url});return new Kt({...t,...ji(o,e)})}case"wmts":{const e=await La(o.layer,o.url,o.format,li(o));return new Kt({...t,...ji(o,e)})}case"xyz":return new Kt({...t,...ji(o,new pe.XYZ(o))});default:return o}}async function Ha(o){return o.url instanceof Blob?xi.toDataURL(o.url):Qt(o.url)}function li(o,t){return o.dataProjection??("projection"in o?o.projection:void 0)??t}function Nn(o){if(typeof o=="string"){if(o==="default")return e=>{var i;return Ra((i=e.getGeometry())==null?void 0:i.getType())};const t=go();return t[o]==null?(console.warn(`Could not find style ${o} in configuration`),new tt.Style({})):t[o]}return qa(o)}function ji(o,t){return{extent:as(o.extent),format:Oa(o),httpTimeout:o.httpTimeout,noDataValue:o.noDataValue??o.nodata,retries:o.retries,source:t}}async function ai(o,t){const e=await Ha(o);return{data:{format:t,url:e},dataProjection:li(o,"EPSG:4326"),style:Nn(o.style)}}function hn(o){return{backgroundColor:o.backgroundColor,style:Nn(o.style),url:Qt(o.url)}}function qa(o){function t(s){if(s)return new tt.Stroke({color:s.color,width:s.width})}function e(s){if(s)return new tt.Fill({color:s.color})}function i(s){if(s)return new tt.Circle({fill:e(s.fill),radius:s.radius,stroke:t(s.stroke)})}return new tt.Style({fill:e(o.fill),image:i(o.point),stroke:t(o.stroke)})}const Qi={getDatasetLayer:Da,getLayer:Va,getLayerOptions:bi,getOverlay:Ua,getSource:On};class Wa{constructor(t,e,i){F(this,"_instance");F(this,"_plane");this._instance=t;const s=e.dimensions(),n=e.center();this._plane=new k(new Te(s.x,s.y,1,1),new $t({color:"black"})),this._plane.name=i,this._plane.position.set(n.x,n.y,-101),this._plane.updateMatrixWorld(),this._instance.add(this._plane)}get visible(){return this._plane.visible}set visible(t){this._plane.visible=t,this._instance.notifyChange(this._plane)}dispose(){this._instance.remove(this._plane),this._plane.geometry.dispose(),this._plane.material.dispose()}}const Vn=ye.defineStore("giro3d",()=>{const o=v.shallowRef(null),t=v.shallowRef(null);function e(){return o.value}function i(u){o.value=u}function s(){return t.value}function n(u){t.value=u}function r(){const u=ot(),d=u.camera;return Array.isArray(d.position)?(console.warn("Configuration is using an array for camera.position, you should switch to an object; see https://gitlab.com/giro3d/piero/-/issues/24 for more information. This will be removed in release v24.7."),new ue("EPSG:4326",d.position[0],d.position[1],d.altitude).as(u.default_crs)):("z"in d.position||console.warn("Configuration is using a 2D object for camera.position, you should switch to a 3D object; see https://gitlab.com/giro3d/piero/-/issues/38 for more information. This will be removed in release v24.7."),new ue(d.position.crs??u.default_crs,d.position.x,d.position.y,"z"in d.position?d.position.z:d.altitude).as(u.default_crs))}function a(){const u=ot();return"lookAt"in u.camera&&u.camera.lookAt?new ue(u.camera.lookAt.crs??u.default_crs,u.camera.lookAt.x,u.camera.lookAt.y,u.camera.lookAt.z).as(u.default_crs):l().center()}function h(){const u=ot();return{backgroundColor:u.basemap.backgroundColor??"white",backgroundOpacity:u.basemap.backgroundOpacity,colorimetry:u.basemap.colorimetry,contourLines:u.basemap.contourLines,elevationRange:u.basemap.elevationRange,graticule:u.basemap.graticule,lighting:u.basemap.lighting??{elevationLayersOnly:!0,enabled:!0},showOutline:u.basemap.showOutline,side:u.basemap.side??ui,terrain:u.basemap.terrain}}function l(){const u=ot();if(u.basemap.extent)return as(u.basemap.extent);console.warn("Configuration is using basemap.center/basemap.size, you should switch to extent. This will be removed in release v24.10.");const d=u.basemap.size,m=u.basemap.center;if(d==null||m==null)throw new Error("basemap.center and basemap.size need to be defined");let y;return Array.isArray(m)?(console.warn("Configuration is using an array for basemap.center, you should switch to an object; see https://gitlab.com/giro3d/piero/-/issues/24 for more information. This will be removed in release v24.7."),y=new ue("EPSG:4326",m[0],m[1],0)):y=new ue(m.crs??u.default_crs,m.x,m.y,0),y=y.as(u.default_crs),cn.fromCenterAndSize(u.default_crs,{x:y.x,y:y.y},d[0],d[1])}function c(){return ot().default_crs}function p(){var u;(u=o.value)==null||u.notifyChange()}return{getCRS:c,getDefaultBasemapExtent:l,getDefaultBasemapOptions:h,getDefaultCameraLookAt:a,getDefaultCameraPosition:r,getInspector:s,getMainView:e,notifyChange:p,setInspector:n,setMainView:i}});class Xa extends St{constructor(){super(...arguments);F(this,"canSetOpacity",!1);F(this,"name","Graticule");F(this,"uuid","graticule");F(this,"_enabled",!1);F(this,"_instance");F(this,"_map");F(this,"_visible",!1)}get displayed(){return this.enabled&&this.visible}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._updateVisible()}set instance(e){this._instance=e}set map(e){this._map=e}get visible(){return this._visible}set visible(e){this._visible=e,this._updateVisible()}_updateVisible(){this._map&&this._instance&&(this._map.graticule.enabled=this.displayed,this._instance.notifyChange(this._map))}}class Un extends St{constructor(e){super();F(this,"name");F(this,"uuid");F(this,"_opacity",1);F(this,"_visible",!1);this.name=e,this.uuid=es.generateUUID()}get opacity(){return this._opacity}set opacity(e){this._opacity=e,this.dispatchEvent({type:"opacity"})}get visible(){return this._visible}set visible(e){this._visible=e,this.dispatchEvent({type:"visible"})}delete(){this.dispatchEvent({type:"delete"})}}class ja extends Un{constructor({name:e,source:i,type:s,...n}){super(e);F(this,"options");F(this,"source");F(this,"type");F(this,"_loading");this._loading=!1,this.type=s,this.source=i,this.options=n}get isLoading(){return this._loading}set isLoading(e){this._loading=e}}class Ya extends Un{constructor({name:e,source:i,...s}){super(e);F(this,"options");F(this,"source");F(this,"_loading");this._loading=!1,this.source=i,this.options=s}get isLoading(){return this._loading}set isLoading(e){this._loading=e}}function Za(){const o=ot(),t=[],e=o.basemap.layers;for(const i of e){const s=new ja(i);s.visible=i.visible,t.push(s)}return t}function Ga(){const o=ot();if("graticule"in o.basemap&&o.basemap.graticule!==void 0){const t=new Xa;return typeof o.basemap.graticule=="boolean"?t.visible=o.basemap.graticule:t.visible=o.basemap.graticule.enabled??!0,v.shallowReactive(t)}}function $a(){const o=ot(),t=[];for(const e of o.overlays){let i;"source"in e?i=e:(console.warn(`Configuration for ${e.name} is deprecated. This will be removed in release v24.7.`),i={name:e.name,source:{...e},visible:e.visible});const s=new Ya(i);s.visible=e.visible,t.push(s)}return t}const Hn=ye.defineStore("layers",()=>{const o=v.shallowReactive(Za().map(m=>v.shallowReactive(m))),t=v.computed(()=>o.length),e=v.shallowReactive($a().map(m=>v.shallowReactive(m))),i=v.computed(()=>e.length),s=Ga();function n(){return o}function r(){return s}function a(m,y){m.visible=y}function h(m,y){m.opacity=y}function l(){return e}function c(m,y){m.visible=y}function p(m,y){m.opacity=y}function u(m){const y=e.indexOf(m);if(y>0){const x=e[y-1];e[y-1]=m,e[y]=x}}function d(m){const y=e.indexOf(m);if(y<e.length-1){const x=e[y+1];e[y+1]=m,e[y]=x}}return{basemapCount:t,getBasemaps:n,getGraticuleLayer:r,getOverlays:l,moveOverlayDown:d,moveOverlayUp:u,overlayCount:i,setBasemapOpacity:h,setBasemapVisibility:a,setOverlayOpacity:p,setOverlayVisibility:c}}),Qa=3e3,Ji="grid",Ki="plane",Ja=5e3;class Ka extends St{constructor(e){super();F(this,"_baseLayers");F(this,"_basemap");F(this,"_boundOnAfterCameraUpdate");F(this,"_cameraStore",gi());F(this,"_datasetLayers");F(this,"_giro3dStore",Vn());F(this,"_grid");F(this,"_instance");F(this,"_layerStore",Hn());F(this,"_overlays");F(this,"_plane");this._instance=e,this._baseLayers=new Map,this._overlays=new Map,this._datasetLayers=new Set;const i=this._giro3dStore.getDefaultBasemapExtent(),s=this._giro3dStore.getDefaultBasemapOptions();this._basemap=new ln({extent:i,...s}),this._basemap.terrain.segments=32,this._basemap.name="basemaps",this._instance.add(this._basemap),this._grid=new Ia(this._instance,i,Ji),this._plane=new Wa(this._instance,i,Ki),this._boundOnAfterCameraUpdate=this.onAfterCameraUpdate.bind(this),this._instance.addEventListener("after-camera-update",this._boundOnAfterCameraUpdate);for(const r of this._layerStore.getOverlays())r.visible&&this.loadOverlay(r);for(const r of this._layerStore.getBasemaps())r.visible&&this.loadBasemap(r);const n=this._layerStore.getGraticuleLayer();n&&(n.instance=this._instance,n.map=this._basemap),this._layerStore.$onAction(({after:r,args:a,name:h})=>{r(()=>{switch(h){case"moveOverlayDown":case"moveOverlayUp":this.onOverlayReordered(a[0]);break;case"setBasemapOpacity":this.onLayerOpacityChanged(a[0],a[1]);break;case"setBasemapVisibility":this.onLayerVisibilityChanged(a[0],a[1]);break;case"setOverlayOpacity":this.onOverlayOpacityChanged(a[0],a[1]);break;case"setOverlayVisibility":this.onOverlayVisibilityChanged(a[0],a[1]);break}})})}get extent(){return this._basemap.extent}async addDatasetLayer(e){this._datasetLayers.add(e.id),await this._basemap.addLayer(e),this.updateLayerOrdering()}dispose(){this._instance.removeEventListener("after-camera-update",this._boundOnAfterCameraUpdate),this._instance.remove(this._basemap),this._plane.dispose(),this._grid.dispose(),this._basemap.dispose({disposeLayers:!0})}notify(e){this._instance.notifyChange(e)}removeBasemapLayer(e){this._datasetLayers.delete(e.id),this._basemap.removeLayer(e,{disposeLayer:!0}),this._instance.notifyChange(this._basemap)}setMapOpacity(e){this._basemap.opacity=e,this._instance.notifyChange(this._basemap)}async getLayer(e,i=!0){const s=this._baseLayers.get(e.uuid);return!s&&i?this.loadBasemap(e):s}async getOverlay(e,i=!0){const s=this._overlays.get(e.uuid);return!s&&i?this.loadOverlay(e):s}async loadBasemap(e){const i=await Qi.getLayer(e);return this._baseLayers.set(e.uuid,i),await this._basemap.addLayer(i),this.updateLayerOrdering(),i.visible=e.visible,ke.isColorLayer(i)&&(i.opacity=e.opacity),Fe.isElevationLayer(i)&&(i.addEventListener("visible-property-changed",()=>{this._basemap.visible=i.visible,this._instance.notifyChange(this._basemap)}),this._basemap.visible=i.visible),this._instance.notifyChange(this._basemap),i}async loadOverlay(e){const i=await Qi.getOverlay(e,this.extent);return this._overlays.set(e.uuid,i),await this._basemap.addLayer(i),this.updateLayerOrdering(),i.visible=e.visible,i.opacity=e.opacity,this._instance.notifyChange(this._basemap),i}onAfterCameraUpdate(){const e=this._cameraStore.getCamera3dPosition(),i=this._grid.visible,s=e.z<Qa;i!==s&&(this._grid.visible=s,this._plane.visible=s);const n=this._layerStore.getGraticuleLayer();if(n){const r=n.enabled,a=e.z<Ja;r!==a&&(n.enabled=a)}}async onLayerOpacityChanged(e,i){const s=await this.getLayer(e);s&&ke.isColorLayer(s)&&(s.opacity=i,this.notify(s)),s&&Fe.isElevationLayer(s)&&this.setMapOpacity(e.opacity)}async onLayerVisibilityChanged(e,i){e.type==="elevation"&&i&&[...this._baseLayers.keys()].forEach(r=>{if(r===e.uuid)return;const a=this._baseLayers.get(r);if(a&&Fe.isElevationLayer(a)){this._baseLayers.delete(r),this.removeBasemapLayer(a);const h=this._layerStore.getBasemaps().find(l=>l.uuid===r);h&&this._layerStore.setBasemapVisibility(h,!1)}});const s=await this.getLayer(e,i);s&&(s.visible=i,i||(this._baseLayers.delete(e.uuid),this.removeBasemapLayer(s)),this.notify(s))}async onOverlayOpacityChanged(e,i){const s=await this.getOverlay(e);s&&(s.opacity=i,this.notify(s))}onOverlayReordered(e){e.visible&&this.updateLayerOrdering()}async onOverlayVisibilityChanged(e,i){const s=await this.getOverlay(e,i);s&&(s.visible=i,i||(this._overlays.delete(e.uuid),this.removeBasemapLayer(s)),this.notify(s))}updateLayerOrdering(){const e=[...this._layerStore.getBasemaps().map(i=>{var s;return(s=this._baseLayers.get(i.uuid))==null?void 0:s.id}).reverse(),...this._layerStore.getOverlays().map(i=>{var s;return(s=this._overlays.get(i.uuid))==null?void 0:s.id}).reverse(),...[...this._datasetLayers.values()].reverse()];this._basemap.sortColorLayers((i,s)=>{const n=e.indexOf(i.id),r=e.indexOf(s.id);return n>=0&&r>=0?n-r:0})}}const qn=[];function th(o,t){return ci.isShapePickResult(o)?-1:ci.isShapePickResult(t)?1:o.distance-t.distance}class eh{constructor(){F(this,"_moduleStore",Rn())}getFeatureFromPickedObject(t){var c,p;const{entity:e,features:i,object:s}=t,n=(e==null?void 0:e.object3d)??s;let r=(p=(c=n.userData)==null?void 0:c.dataset)==null?void 0:p.name;const a=(e==null?void 0:e.id)??n.uuid,h=[],l=new Map;if(l.set("Dataset",h),e){if(Gn.isMapPickResult(t)){if(i==null||i.length===0)return null;const u=i.at(0);r=this.getNameFromOLFeature(u.feature)??r,this.getAttributesFromOLFeature(u.feature,l),h.push({key:"Layer",value:u.layer.name})}else if(Zn.isPointsPickResult(t))this.getAttributesFromPointCloud(t,l);else if(!e.isFeatureCollection){if(ci.isShapePickResult(t)){const u=t.entity;if(mi.isMeasure3D(u)){const d=u.userData.measure;r=(d==null?void 0:d.title)??r,this.getAttributesFromMeasure(t,l)}else{const d=u.userData.annotation;r=(d==null?void 0:d.title)??r,this.getAttributesFromAnnotation(t,l)}}}for(const u of qn)u(t,l)}return e!=null&&e.userData&&this.getAttributesFromEntity(e,l),(s==null?void 0:s.userData)!=null&&this.getAttributesFromPickedObject3D(t,l),s!=null&&this.getDatasetAttributes(s,h),new Ta(r,a,l,t.point)}getFirstFeatureAt(t,e,i=1,s){const n=this.getObjectsAt(t,e,i,s);if(n!=null&&n.length>0)return n;const r=this.getMapAt(t,e,i);return r?[r]:null}getGeometryAttributes(t,e){const i=new bt,s=new M,n=new M;i.setFromObject(t),i.getCenter(n),i.getSize(s),e.push({key:"Center",value:[n.x.toFixed(2),n.y.toFixed(2),n.z.toFixed(2)]});const r="m";e.push({key:"Size",value:[`${s.x.toFixed(2)}${r}`,`${s.y.toFixed(2)}${r}`,`${s.z.toFixed(2)}${r}`]})}getMapAt(t,e,i=1){const s=t.getObjects(r=>r.isMap);return t.pickObjectsAt(e,{limit:1,pickFeatures:!0,radius:i,sortByDistance:!0,where:s}).at(0)??null}getMouseCoordinate(t,e){const i=t.getObjects(n=>n.isMap),s=t.pickObjectsAt(e,{limit:1,radius:0,where:i}).at(0);return(s==null?void 0:s.point)??null}getObjectsAt(t,e,i=1,s){let n=t.getObjects(a=>ln.isMap(a)!==!0&&a.name!==Ki&&a.name!==Ji);s&&(n=n.filter(s));const r=t.pickObjectsAt(e,{filter:a=>this.filterPick(t,a),pickFeatures:!0,radius:i,where:n});return r.sort(th),r??null}hasFeature(t,e){const i=t.getObjects(n=>n.isMap!==!0&&n.name!==Ki&&n.name!==Ji);return t.pickObjectsAt(e,{limit:1,radius:0,where:i}).at(0)!=null}pick(t,e){var s;const i=(s=this.getFirstFeatureAt(t,e))==null?void 0:s.at(0);if(i){const n=this.getFeatureFromPickedObject(i);if(n)return{feature:n,pickResult:i,point:i.point}}return null}filterPick(t,e){const i=this._moduleStore.getModule(cs);if(i!=null&&i.isClippingBoxEnabled()){const s=i.getClippingBox().containsPoint(e.point);if(i.isClippingBoxInverted()){if(s)return!1}else if(!s)return!1}return!(e.distance<t.view.camera.near||e.distance>t.view.camera.far)}getAttributesFromAnnotation(t,e){e.has("GeoJSON")||e.set("GeoJSON",[]);const i=e.get("GeoJSON"),s=t.entity,n=s.userData,{annotation:r,measurements:a,type:h}=n;if(r!=null)for(const[p,u]of Object.entries(r.properties))p==="geometry"||p==="geometryProperty"||p==="metadata"||p==="entity"||i.push({key:p,value:u});e.has("Measurement")||e.set("Measurement",[]);const l=e.get("Measurement");h==="MultiPoint"&&l.push({key:"Number of points",value:s.points.length});const c="m";a.area!=null&&l.push({key:"Area",value:`${a.area.toFixed(2)}${c}²`}),a.perimeter!=null&&l.push({key:h==="Polygon"?"Perimeter":"Length",value:`${a.perimeter.toFixed(2)}${c}`}),a.minmax!=null&&(l.push({key:"Min altitude",value:`${a.minmax[0].toFixed(2)}${c}`}),l.push({key:"Max altitude",value:`${a.minmax[1].toFixed(2)}${c}`}))}getAttributesFromEntity(t,e){e.has("Feature")||e.set("Feature",[]);const i=e.get("Feature");(t==null?void 0:t.userData)!=null&&this.getAttributesFromUserData(t.userData,i)}getAttributesFromMeasure(t,e){e.has("GeoJSON")||e.set("GeoJSON",[]);const i=e.get("GeoJSON"),s=t.entity;for(const[r,a]of Object.entries(s.userData.measure.properties))r==="geometry"||r==="geometryProperty"||r==="metadata"||r==="entity"||i.push({key:r,value:a});e.has("Measurement")||e.set("Measurement",[]);const n=e.get("Measurement");n.push({key:"From",value:s.from}),n.push({key:"To",value:s.to}),n.push({key:"Length",value:`${s.length.toFixed(2)}m`})}getAttributesFromObject3D(t,e){if((t==null?void 0:t.userData)!=null&&this.getAttributesFromUserData(t.userData,e),t!=null&&t.parent){if("isFeatureTile"in t.parent&&t.parent.isFeatureTile===!0)return;this.getAttributesFromObject3D(t.parent,e)}}getAttributesFromOLFeature(t,e){e.has("Feature")||e.set("Feature",[]);const i=e.get("Feature");t.getId()!==void 0&&i.push({key:"fid",value:t.getId()});for(const[s,n]of Object.entries(t.getProperties()))s==="geometry"||s==="geometryProperty"||i.push({key:s,value:n})}getAttributesFromPickedObject3D(t,e){e.has("Feature")||e.set("Feature",[]);const i=e.get("Feature");this.getAttributesFromObject3D(t.object,i)}getAttributesFromPointCloud(t,e){var i;(i=e.get("Dataset"))==null||i.push({key:"Tile",value:t.object.name})}getAttributesFromUserData(t,e){for(const[i,s]of Object.entries(t))if(!(i==="geometry"||i==="geometryProperty"||i==="metadata"||i==="entity"||i==="dataset"||i==="bbox"||i==="hover")){if(i==="feature"&&typeof s=="object"&&"ol_uid"in s){this.getAttributesFromUserData(s.getProperties(),e);continue}if(i==="properties"){this.getAttributesFromUserData(s,e);continue}if(typeof s!="object"){if(i==="id"){e.push({key:"fid",value:s});continue}e.push({key:i,value:s})}}}getDatasetAttributes(t,e){var i,s,n,r;((s=(i=t==null?void 0:t.userData)==null?void 0:i.dataset)==null?void 0:s.name)!=null&&e.push({key:"Dataset",value:t.userData.dataset.name}),((r=(n=t==null?void 0:t.userData)==null?void 0:n.dataset)==null?void 0:r.filename)!=null&&e.push({key:"File",value:t.userData.dataset.filename}),t.parent&&this.getDatasetAttributes(t.parent,e)}getNameFromOLFeature(t){return t.get("nom")??t.get("name")??t.getId()}}const at=new ht;class ih extends os{constructor(t){super(t),this.propertyNameMapping={},this.customPropertyMapping={}}load(t,e,i,s){const n=this,r=new to(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,function(a){try{e(n.parse(a))}catch(h){s?s(h):console.error(h),n.manager.itemError(t)}},i,s)}setPropertyNameMapping(t){this.propertyNameMapping=t}setCustomPropertyNameMapping(t){this.customPropertyMapping=t}parse(t){function e(x,w=0){const b=/^ply([\s\S]*)end_header(\r\n|\r|\n)/;let g="";const f=b.exec(x);f!==null&&(g=f[1]);const _={comments:[],elements:[],headerLength:w,objInfo:""},S=g.split(/\r\n|\r|\n/);let z;function A(C,E){const B={type:C[0]};return B.type==="list"?(B.name=C[3],B.countType=C[1],B.itemType=C[2]):B.name=C[1],B.name in E&&(B.name=E[B.name]),B}for(let C=0;C<S.length;C++){let E=S[C];if(E=E.trim(),E==="")continue;const B=E.split(/\s+/),P=B.shift();switch(E=B.join(" "),P){case"format":_.format=B[0],_.version=B[1];break;case"comment":_.comments.push(E);break;case"element":z!==void 0&&_.elements.push(z),z={},z.name=B[0],z.count=parseInt(B[1]),z.properties=[];break;case"property":z.properties.push(A(B,y.propertyNameMapping));break;case"obj_info":_.objInfo=E;break;default:console.log("unhandled",P,B)}}return z!==void 0&&_.elements.push(z),_}function i(x,w){switch(w){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(x);case"float":case"double":case"float32":case"float64":return parseFloat(x)}}function s(x,w){const b={};for(let g=0;g<x.length;g++){if(w.empty())return null;if(x[g].type==="list"){const f=[],_=i(w.next(),x[g].countType);for(let S=0;S<_;S++){if(w.empty())return null;f.push(i(w.next(),x[g].itemType))}b[x[g].name]=f}else b[x[g].name]=i(w.next(),x[g].type)}return b}function n(){const x={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[],faceVertexColors:[]};for(const w of Object.keys(y.customPropertyMapping))x[w]=[];return x}function r(x){const w=x.map(g=>g.name);function b(g){for(let f=0,_=g.length;f<_;f++){const S=g[f];if(w.includes(S))return S}return null}return{attrX:b(["x","px","posx"])||"x",attrY:b(["y","py","posy"])||"y",attrZ:b(["z","pz","posz"])||"z",attrNX:b(["nx","normalx"]),attrNY:b(["ny","normaly"]),attrNZ:b(["nz","normalz"]),attrS:b(["s","u","texture_u","tx"]),attrT:b(["t","v","texture_v","ty"]),attrR:b(["red","diffuse_red","r","diffuse_r"]),attrG:b(["green","diffuse_green","g","diffuse_g"]),attrB:b(["blue","diffuse_blue","b","diffuse_b"])}}function a(x,w){const b=n(),g=/end_header\s+(\S[\s\S]*\S|\S)\s*$/;let f,_;(_=g.exec(x))!==null?f=_[1].split(/\s+/):f=[];const S=new sh(f);t:for(let z=0;z<w.elements.length;z++){const A=w.elements[z],C=r(A.properties);for(let E=0;E<A.count;E++){const B=s(A.properties,S);if(!B)break t;l(b,A.name,B,C)}}return h(b)}function h(x){let w=new st;x.indices.length>0&&w.setIndex(x.indices),w.setAttribute("position",new T(x.vertices,3)),x.normals.length>0&&w.setAttribute("normal",new T(x.normals,3)),x.uvs.length>0&&w.setAttribute("uv",new T(x.uvs,2)),x.colors.length>0&&w.setAttribute("color",new T(x.colors,3)),(x.faceVertexUvs.length>0||x.faceVertexColors.length>0)&&(w=w.toNonIndexed(),x.faceVertexUvs.length>0&&w.setAttribute("uv",new T(x.faceVertexUvs,2)),x.faceVertexColors.length>0&&w.setAttribute("color",new T(x.faceVertexColors,3)));for(const b of Object.keys(y.customPropertyMapping))x[b].length>0&&w.setAttribute(b,new T(x[b],y.customPropertyMapping[b].length));return w.computeBoundingSphere(),w}function l(x,w,b,g){if(w==="vertex"){x.vertices.push(b[g.attrX],b[g.attrY],b[g.attrZ]),g.attrNX!==null&&g.attrNY!==null&&g.attrNZ!==null&&x.normals.push(b[g.attrNX],b[g.attrNY],b[g.attrNZ]),g.attrS!==null&&g.attrT!==null&&x.uvs.push(b[g.attrS],b[g.attrT]),g.attrR!==null&&g.attrG!==null&&g.attrB!==null&&(at.setRGB(b[g.attrR]/255,b[g.attrG]/255,b[g.attrB]/255,ut),x.colors.push(at.r,at.g,at.b));for(const f of Object.keys(y.customPropertyMapping))for(const _ of y.customPropertyMapping[f])x[f].push(b[_])}else if(w==="face"){const f=b.vertex_indices||b.vertex_index,_=b.texcoord;f.length===3?(x.indices.push(f[0],f[1],f[2]),_&&_.length===6&&(x.faceVertexUvs.push(_[0],_[1]),x.faceVertexUvs.push(_[2],_[3]),x.faceVertexUvs.push(_[4],_[5]))):f.length===4&&(x.indices.push(f[0],f[1],f[3]),x.indices.push(f[1],f[2],f[3])),g.attrR!==null&&g.attrG!==null&&g.attrB!==null&&(at.setRGB(b[g.attrR]/255,b[g.attrG]/255,b[g.attrB]/255,ut),x.faceVertexColors.push(at.r,at.g,at.b),x.faceVertexColors.push(at.r,at.g,at.b),x.faceVertexColors.push(at.r,at.g,at.b))}}function c(x,w){const b={};let g=0;for(let f=0;f<w.length;f++){const _=w[f],S=_.valueReader;if(_.type==="list"){const z=[],A=_.countReader.read(x+g);g+=_.countReader.size;for(let C=0;C<A;C++)z.push(S.read(x+g)),g+=S.size;b[_.name]=z}else b[_.name]=S.read(x+g),g+=S.size}return[b,g]}function p(x,w,b){function g(f,_,S){switch(_){case"int8":case"char":return{read:z=>f.getInt8(z),size:1};case"uint8":case"uchar":return{read:z=>f.getUint8(z),size:1};case"int16":case"short":return{read:z=>f.getInt16(z,S),size:2};case"uint16":case"ushort":return{read:z=>f.getUint16(z,S),size:2};case"int32":case"int":return{read:z=>f.getInt32(z,S),size:4};case"uint32":case"uint":return{read:z=>f.getUint32(z,S),size:4};case"float32":case"float":return{read:z=>f.getFloat32(z,S),size:4};case"float64":case"double":return{read:z=>f.getFloat64(z,S),size:8}}}for(let f=0,_=x.length;f<_;f++){const S=x[f];S.type==="list"?(S.countReader=g(w,S.countType,b),S.valueReader=g(w,S.itemType,b)):S.valueReader=g(w,S.type,b)}}function u(x,w){const b=n(),g=w.format==="binary_little_endian",f=new DataView(x,w.headerLength);let _,S=0;for(let z=0;z<w.elements.length;z++){const A=w.elements[z],C=A.properties,E=r(C);p(C,f,g);for(let B=0;B<A.count;B++){_=c(S,C),S+=_[1];const P=_[0];l(b,A.name,P,E)}}return h(b)}function d(x){let w=0,b=!0,g="";const f=[],_=new TextDecoder().decode(x.subarray(0,5)),S=/^ply\r\n/.test(_);do{const z=String.fromCharCode(x[w++]);z!==`
6
+ `&&z!=="\r"?g+=z:(g==="end_header"&&(b=!1),g!==""&&(f.push(g),g=""))}while(b&&w<x.length);return S===!0&&w++,{headerText:f.join("\r")+"\r",headerLength:w}}let m;const y=this;if(t instanceof ArrayBuffer){const x=new Uint8Array(t),{headerText:w,headerLength:b}=d(x),g=e(w,b);if(g.format==="ascii"){const f=new TextDecoder().decode(x);m=a(f,g)}else m=u(t,g)}else m=a(t,e(t));return m}}class sh{constructor(t){this.arr=t,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}}const nh={class:"form-check form-switch"},rh=["checked"],oh=v.defineComponent({__name:"SwitchToggle",props:["modelValue"],emits:["update:modelValue"],setup(o){return(t,e)=>(v.openBlock(),v.createElementBlock("div",nh,[v.createElementVNode("input",{class:"form-check-input",type:"checkbox",role:"switch",checked:o.modelValue,onInput:e[0]||(e[0]=i=>t.$emit("update:modelValue",i.target.checked))},null,40,rh),v.renderSlot(t.$slots,"default")]))}}),ah=["title"],hh=["title"],Wn=v.defineComponent({__name:"Icon",props:{icon:{},title:{}},setup(o){return(t,e)=>t.icon.startsWith("bi-")?(v.openBlock(),v.createElementBlock("i",{key:0,class:v.normalizeClass(["bi",t.icon]),title:t.title},null,10,ah)):(v.openBlock(),v.createElementBlock("i",{key:1,class:v.normalizeClass(t.icon),title:t.title},null,10,hh))}}),lh=["title"],Xn=v.defineComponent({__name:"ButtonWithIcon",props:{icon:{},text:{},title:{}},emits:["click"],setup(o){return(t,e)=>(v.openBlock(),v.createElementBlock("button",{title:t.title,class:"btn",type:"button",onClick:e[0]||(e[0]=i=>t.$emit("click",i))},[t.icon?(v.openBlock(),v.createBlock(Wn,{key:0,icon:t.icon},null,8,["icon"])):v.createCommentVNode("",!0),v.createTextVNode(" "+v.toDisplayString(t.text),1)],8,lh))}}),ch={},uh={class:"icons text-nowrap d-flex justify-content-evenly"};function ph(o,t){return v.openBlock(),v.createElementBlock("div",uh,[v.renderSlot(o.$slots,"default")])}const dh=wi(ch,[["render",ph]]),mh=v.defineComponent({__name:"IconListButton",props:{icon:{},title:{}},emits:["click"],setup(o){return(t,e)=>(v.openBlock(),v.createBlock(Xn,{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"]))}}),fh=wi(mh,[["__scopeId","data-v-10315937"]]),yh=["title","disabled"],xh=v.defineComponent({__name:"ListLabelButton",props:{disabled:{type:Boolean},text:{},title:{}},emits:["click"],setup(o){return(t,e)=>(v.openBlock(),v.createElementBlock("button",{class:v.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))},v.toDisplayString(t.text),11,yh))}});function gh(o,t){const e=v.ref(o[t]);return v.watch(()=>o[t],i=>{e.value=i}),e}exports.AmbientLight=no;exports.ArrowHelper=lo;exports.Box3=bt;exports.ClippingBoxAnalysis=Pa;exports.Clock=ro;exports.Color=ht;exports.DEFAULT_SHAPE_COLOR=Eo;exports.Datagroup=hs;exports.Dataset=Tn;exports.DirectionalLight=so;exports.DoubleSide=dn;exports.Download=Bn;exports.EDIT_SHAPE_COLOR=ko;exports.EventDispatcher=St;exports.Fetcher=xi;exports.Float32BufferAttribute=T;exports.Group=Sn;exports.IconList=dh;exports.IconListButton=fh;exports.LayerBuilder=Qi;exports.LayerManager=Ka;exports.MathUtils=es;exports.Matrix4=U;exports.Measure3D=mi;exports.Mesh=k;exports.MeshBasicMaterial=$t;exports.MeshLambertMaterial=$r;exports.Object3D=q;exports.PLYLoader=ih;exports.Picker=eh;exports.Plane=pt;exports.PlaneGeometry=Te;exports.Quaternion=et;exports.Raycaster=An;exports.SHAPE_POINT_RADIUS=Po;exports.Sphere=Pe;exports.Spherical=oo;exports.Vector2=X;exports.Vector3=M;exports.Vector4=Zt;exports._export_sfc=wi;exports._sfc_main=oh;exports._sfc_main$1=Xn;exports._sfc_main$2=Wn;exports._sfc_main$3=xh;exports.customAttributeExtractors=qn;exports.fillObject3DUserData=Co;exports.getColorMap=kn;exports.getConfig=ot;exports.getCoordinates=zo;exports.getPublicFolderUrl=Qt;exports.hasExperimentalFeature=Ao;exports.isColor=Lo;exports.isLink=Io;exports.isObject=ge;exports.isVector3=Do;exports.loadRemoteConfiguration=wo;exports.moduleId=cs;exports.nonNull=To;exports.refAndWatch=gh;exports.setConfiguration=bo;exports.setDynamicStyles=Mo;exports.useCameraStore=gi;exports.useDatasetStore=Dn;exports.useGiro3dStore=Vn;exports.useLayerStore=Hn;exports.useModuleStore=Rn;
6
7
  //# sourceMappingURL=Components.cjs.js.map