@liveroom-tech/react-immersive 5.1.0 → 5.2.0

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 (44) hide show
  1. package/README.md +486 -57
  2. package/dist/binding-builder.css +1 -1
  3. package/dist/binding-builder.js +17 -13
  4. package/dist/binding-builder.mjs +1 -1
  5. package/dist/chunk-4NLJSD3S.mjs +1 -0
  6. package/dist/chunk-B7REIGDG.mjs +1 -0
  7. package/dist/{chunk-WN6GMMHF.mjs → chunk-HYFJ5DYJ.mjs} +1 -1
  8. package/dist/chunk-QC3NT76G.mjs +3 -0
  9. package/dist/chunk-T3M3BQ7H.mjs +32 -0
  10. package/dist/chunk-ZPK67UG7.mjs +1 -0
  11. package/dist/hosted.css +1 -1
  12. package/dist/hosted.d.mts +4 -3
  13. package/dist/hosted.d.ts +4 -3
  14. package/dist/hosted.js +16 -12
  15. package/dist/hosted.mjs +1 -1
  16. package/dist/index.css +1 -1
  17. package/dist/index.d.mts +39 -8
  18. package/dist/index.d.ts +39 -8
  19. package/dist/index.js +14 -10
  20. package/dist/index.mjs +1 -1
  21. package/dist/materialVariants-DnZe9eMC.d.mts +309 -0
  22. package/dist/materialVariants-DnZe9eMC.d.ts +309 -0
  23. package/dist/modelInfo-BYebMPdZ.d.mts +43 -0
  24. package/dist/modelInfo-XfUQO7C_.d.ts +43 -0
  25. package/dist/{ModelViewer-Bj-KjiDL.d.mts → modelViewerProps-CIZ2R_Fv.d.ts} +82 -10
  26. package/dist/{ModelViewer-BkQ73y6N.d.ts → modelViewerProps-DoRiTZMn.d.mts} +82 -10
  27. package/dist/{objectCatalog-BIeXURoq.d.ts → rendererBackend-QwMzISTn.d.mts} +32 -4
  28. package/dist/{objectCatalog-BIeXURoq.d.mts → rendererBackend-QwMzISTn.d.ts} +32 -4
  29. package/dist/simple-model-viewer.css +1 -1
  30. package/dist/simple-model-viewer.d.mts +32 -4
  31. package/dist/simple-model-viewer.d.ts +32 -4
  32. package/dist/simple-model-viewer.js +3 -3
  33. package/dist/simple-model-viewer.mjs +1 -1
  34. package/dist/utils.d.mts +5 -4
  35. package/dist/utils.d.ts +5 -4
  36. package/dist/utils.js +1 -1
  37. package/dist/utils.mjs +1 -1
  38. package/package.json +2 -1
  39. package/dist/chunk-32WCLPTZ.mjs +0 -1
  40. package/dist/chunk-CSGNL4XU.mjs +0 -3
  41. package/dist/chunk-F2ILTIPG.mjs +0 -28
  42. package/dist/chunk-V6GALFL5.mjs +0 -1
  43. package/dist/modelInfo-DnkmTGMd.d.mts +0 -23
  44. package/dist/modelInfo-DnkmTGMd.d.ts +0 -23
@@ -1,4 +1,4 @@
1
- "use strict";"use client";var At=Object.defineProperty;var gn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var _n=Object.prototype.hasOwnProperty;var xn=(t,e)=>()=>(t&&(e=t(t=0)),e);var Kt=(t,e)=>{for(var n in e)At(t,n,{get:e[n],enumerable:!0})},yn=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of vn(e))!_n.call(t,r)&&r!==n&&At(t,r,{get:()=>e[r],enumerable:!(i=gn(e,r))||i.enumerable});return t};var bn=t=>yn(At({},"__esModule",{value:!0}),t);var Pe={};Kt(Pe,{bvhWorkerCode:()=>Yn});var Yn,Ne=xn(()=>{"use strict";Yn=`(()=>{var Ls=1;var Ds=3,wn=0,Ui=1,Fi=2;var di=0,pi=1,mi=2,gi=3,_i=4,xi=5,yi=6,vi=7,Ns=0,Us=1,Fs=2;var Bi=1,Oi=2,zi=3,Vi=4,ki=5,Gi=6,Hi=7;var Wi=300,Bs=301,Xi=302;var Os=306,Mi=1e3,Ie=1001,Si=1002;var zs=1006;var Vs=1008;var ks=1009;var Gs=1015;var Hs=1023;var De=2300,ln=2301,an=2302,bi=2303,Ti=2400,Ai=2401,Ei=2402;var qi="",_t="srgb",wi="srgb-linear",Ci="linear",cn="srgb";var Ri=35044;var Le=2e3,Pi=2001;function Fr(c){for(let t=c.length-1;t>=0;--t)if(c[t]>=65535)return!0;return!1}function Br(c){return ArrayBuffer.isView(c)&&!(c instanceof DataView)}function Ii(c){return document.createElementNS("http://www.w3.org/1999/xhtml",c)}var xs={},un=null;function Ws(c){let t=c[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=c[1];e&&e.isStackTrace?c[0]+=" "+e.getLocation():c[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return c}function Q(...c){c=Ws(c);let t="THREE."+c.shift();if(un)un("warn",t,...c);else{let e=c[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...c)}}function G(...c){c=Ws(c);let t="THREE."+c.shift();if(un)un("error",t,...c);else{let e=c[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...c)}}function Li(...c){let t=c.join(" ");t in xs||(xs[t]=!0,Q(...c))}var Or={[di]:pi,[mi]:yi,[_i]:vi,[gi]:xi,[pi]:di,[yi]:mi,[vi]:_i,[xi]:gi},Yt=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,t);t.target=null}}},st=["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"];var yl=Math.PI/180,zr=180/Math.PI;function Cn(){let c=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(st[c&255]+st[c>>8&255]+st[c>>16&255]+st[c>>24&255]+"-"+st[t&255]+st[t>>8&255]+"-"+st[t>>16&15|64]+st[t>>24&255]+"-"+st[e&63|128]+st[e>>8&255]+"-"+st[e>>16&255]+st[e>>24&255]+st[n&255]+st[n>>8&255]+st[n>>16&255]+st[n>>24&255]).toLowerCase()}function U(c,t,e){return Math.max(t,Math.min(e,c))}function Vr(c,t){return(c%t+t)%t}function Zn(c,t,e){return(1-e)*c+e*t}function Ee(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return c/4294967295;case Uint16Array:return c/65535;case Uint8Array:return c/255;case Int32Array:return Math.max(c/2147483647,-1);case Int16Array:return Math.max(c/32767,-1);case Int8Array:return Math.max(c/127,-1);default:throw new Error("Invalid component type.")}}function ut(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return Math.round(c*4294967295);case Uint16Array:return Math.round(c*65535);case Uint8Array:return Math.round(c*255);case Int32Array:return Math.round(c*2147483647);case Int16Array:return Math.round(c*32767);case Int8Array:return Math.round(c*127);default:throw new Error("Invalid component type.")}}var H=class c{static{c.prototype.isVector2=!0}constructor(t=0,e=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){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(U(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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){let n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*n-r*i+t.x,this.y=s*i+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Lt=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,r,o){let a=n[i+0],l=n[i+1],u=n[i+2],f=n[i+3],h=s[r+0],d=s[r+1],p=s[r+2],m=s[r+3];if(f!==m||a!==h||l!==d||u!==p){let _=a*h+l*d+u*p+f*m;_<0&&(h=-h,d=-d,p=-p,m=-m,_=-_);let g=1-o;if(_<.9995){let x=Math.acos(_),y=Math.sin(x);g=Math.sin(g*x)/y,o=Math.sin(o*x)/y,a=a*g+h*o,l=l*g+d*o,u=u*g+p*o,f=f*g+m*o}else{a=a*g+h*o,l=l*g+d*o,u=u*g+p*o,f=f*g+m*o;let x=1/Math.sqrt(a*a+l*l+u*u+f*f);a*=x,l*=x,u*=x,f*=x}}t[e]=a,t[e+1]=l,t[e+2]=u,t[e+3]=f}static multiplyQuaternionsFlat(t,e,n,i,s,r){let o=n[i],a=n[i+1],l=n[i+2],u=n[i+3],f=s[r],h=s[r+1],d=s[r+2],p=s[r+3];return t[e]=o*p+u*f+a*d-l*h,t[e+1]=a*p+u*h+l*f-o*d,t[e+2]=l*p+u*d+o*h-a*f,t[e+3]=u*p-o*f-a*h-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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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){let n=t._x,i=t._y,s=t._z,r=t._order,o=Math.cos,a=Math.sin,l=o(n/2),u=o(i/2),f=o(s/2),h=a(n/2),d=a(i/2),p=a(s/2);switch(r){case"XYZ":this._x=h*u*f+l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f-h*d*p;break;case"YXZ":this._x=h*u*f+l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f+h*d*p;break;case"ZXY":this._x=h*u*f-l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f-h*d*p;break;case"ZYX":this._x=h*u*f-l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f+h*d*p;break;case"YZX":this._x=h*u*f+l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f-h*d*p;break;case"XZY":this._x=h*u*f-l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f+h*d*p;break;default:Q("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],s=e[8],r=e[1],o=e[5],a=e[9],l=e[2],u=e[6],f=e[10],h=n+o+f;if(h>0){let d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-a)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>f){let d=2*Math.sqrt(1+n-o-f);this._w=(u-a)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>f){let d=2*Math.sqrt(1+o-n-f);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(a+u)/d}else{let d=2*Math.sqrt(1+f-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(a+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(U(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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){let n=t._x,i=t._y,s=t._z,r=t._w,o=e._x,a=e._y,l=e._z,u=e._w;return this._x=n*u+r*o+i*l-s*a,this._y=i*u+r*a+s*o-n*l,this._z=s*u+r*l+n*a-i*o,this._w=r*u-n*o-i*a-s*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,r=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,s=-s,r=-r,o=-o);let a=1-e;if(o<.9995){let l=Math.acos(o),u=Math.sin(l);a=Math.sin(a*l)/u,e=Math.sin(e*l)/u,this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+s*e,this._w=this._w*a+r*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+s*e,this._w=this._w*a+r*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*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}},M=class c{static{c.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(ys.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ys.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=t.elements,r=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,s=t.x,r=t.y,o=t.z,a=t.w,l=2*(r*i-o*n),u=2*(o*e-s*i),f=2*(s*n-r*e);return this.x=e+a*l+r*f-o*u,this.y=n+a*u+o*l-s*f,this.z=i+a*f+s*u-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){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this.z=U(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this.z=U(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=i*a-s*o,this.y=s*r-n*a,this.z=n*o-i*r,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Jn.copy(this).projectOnVector(t),this.sub(Jn)}reflect(t){return this.sub(Jn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(U(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Jn=new M,ys=new Lt,N=class c{static{c.prototype.isMatrix3=!0}constructor(t,e,n,i,s,r,o,a,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,r,o,a,l)}set(t,e,n,i,s,r,o,a,l){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=s,u[5]=a,u[6]=n,u[7]=r,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let 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){let n=t.elements,i=e.elements,s=this.elements,r=n[0],o=n[3],a=n[6],l=n[1],u=n[4],f=n[7],h=n[2],d=n[5],p=n[8],m=i[0],_=i[3],g=i[6],x=i[1],y=i[4],S=i[7],v=i[2],b=i[5],T=i[8];return s[0]=r*m+o*x+a*v,s[3]=r*_+o*y+a*b,s[6]=r*g+o*S+a*T,s[1]=l*m+u*x+f*v,s[4]=l*_+u*y+f*b,s[7]=l*g+u*S+f*T,s[2]=h*m+d*x+p*v,s[5]=h*_+d*y+p*b,s[8]=h*g+d*S+p*T,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8];return e*r*u-e*o*l-n*s*u+n*o*a+i*s*l-i*r*a}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8],f=u*r-o*l,h=o*a-u*s,d=l*s-r*a,p=e*f+n*h+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return t[0]=f*m,t[1]=(i*l-u*n)*m,t[2]=(o*n-i*r)*m,t[3]=h*m,t[4]=(u*e-i*a)*m,t[5]=(i*s-o*e)*m,t[6]=d*m,t[7]=(n*a-l*e)*m,t[8]=(r*e-n*s)*m,this}transpose(){let t,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){let 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,n,i,s,r,o){let a=Math.cos(s),l=Math.sin(s);return this.set(n*a,n*l,-n*(a*r+l*o)+r+t,-i*l,i*a,-i*(-l*r+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply($n.makeScale(t,e)),this}rotate(t){return this.premultiply($n.makeRotation(-t)),this}translate(t,e){return this.premultiply($n.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){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},$n=new N,vs=new N().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ms=new N().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function kr(){let c={enabled:!0,workingColorSpace:wi,spaces:{},convert:function(i,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===cn&&(i.r=It(i.r),i.g=It(i.g),i.b=It(i.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===cn&&(i.r=he(i.r),i.g=he(i.g),i.b=he(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===qi?Ci:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,r){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return Li("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),c.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return Li("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),c.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return c.define({[wi]:{primaries:t,whitePoint:n,transfer:Ci,toXYZ:vs,fromXYZ:Ms,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:_t},outputColorSpaceConfig:{drawingBufferColorSpace:_t}},[_t]:{primaries:t,whitePoint:n,transfer:cn,toXYZ:vs,fromXYZ:Ms,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:_t}}}),c}var gt=kr();function It(c){return c<.04045?c*.0773993808:Math.pow(c*.9478672986+.0521327014,2.4)}function he(c){return c<.0031308?c*12.92:1.055*Math.pow(c,.41666)-.055}var jt,hn=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{jt===void 0&&(jt=Ii("canvas")),jt.width=t.width,jt.height=t.height;let i=jt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=jt}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=Ii("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=It(s[r]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(It(e[n]/255)*255):e[n]=It(e[n]);return{data:e,width:t.width,height:t.height}}else return Q("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Gr=0,fn=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gr++}),this.uuid=Cn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?s.push(Kn(i[r].image)):s.push(Kn(i[r]))}else s=Kn(i);n.url=s}return e||(t.images[this.uuid]=n),n}};function Kn(c){return typeof HTMLImageElement<"u"&&c instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&c instanceof ImageBitmap?hn.getDataURL(c):c.data?{data:Array.from(c.data),width:c.width,height:c.height,type:c.data.constructor.name}:(Q("Texture: Unable to serialize Texture."),{})}var Hr=0,Qn=new M,fe=class c extends Yt{constructor(t=c.DEFAULT_IMAGE,e=c.DEFAULT_MAPPING,n=Ie,i=Ie,s=zs,r=Vs,o=Hs,a=ks,l=c.DEFAULT_ANISOTROPY,u=qi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hr++}),this.uuid=Cn(),this.name="",this.source=new fn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=a,this.offset=new H(0,0),this.repeat=new H(1,1),this.center=new H(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new N,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Qn).x}get height(){return this.source.getSize(Qn).y}get depth(){return this.source.getSize(Qn).z}get image(){return this.source.data}set image(t){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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.normalized=t.normalized,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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Q(\`Texture.setValues(): parameter '\${e}' has value of undefined.\`);continue}let i=this[e];if(i===void 0){Q(\`Texture.setValues(): property '\${e}' does not exist.\`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,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,normalized:this.normalized,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&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Wi)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Mi:t.x=t.x-Math.floor(t.x);break;case Ie:t.x=t.x<0?0:1;break;case Si: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 Mi:t.y=t.y-Math.floor(t.y);break;case Ie:t.y=t.y<0?0:1;break;case Si: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++}};fe.DEFAULT_IMAGE=null;fe.DEFAULT_MAPPING=Wi;fe.DEFAULT_ANISOTROPY=1;var de=class c{static{c.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}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,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,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){let e=this.x,n=this.y,i=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*e+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*e+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*e+r[7]*n+r[11]*i+r[15]*s,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);let 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,n,i,s,a=t.elements,l=a[0],u=a[4],f=a[8],h=a[1],d=a[5],p=a[9],m=a[2],_=a[6],g=a[10];if(Math.abs(u-h)<.01&&Math.abs(f-m)<.01&&Math.abs(p-_)<.01){if(Math.abs(u+h)<.1&&Math.abs(f+m)<.1&&Math.abs(p+_)<.1&&Math.abs(l+d+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let y=(l+1)/2,S=(d+1)/2,v=(g+1)/2,b=(u+h)/4,T=(f+m)/4,A=(p+_)/4;return y>S&&y>v?y<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(y),i=b/n,s=T/n):S>v?S<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),n=b/i,s=A/i):v<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(v),n=T/s,i=A/s),this.set(n,i,s,e),this}let x=Math.sqrt((_-p)*(_-p)+(f-m)*(f-m)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(_-p)/x,this.y=(f-m)/x,this.z=(h-u)/x,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(t){let 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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this.z=U(this.z,t.z,e.z),this.w=U(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this.z=U(this.z,t,e),this.w=U(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,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}};var W=class c{static{c.prototype.isMatrix4=!0}constructor(t,e,n,i,s,r,o,a,l,u,f,h,d,p,m,_){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,n,i,s,r,o,a,l,u,f,h,d,p,m,_)}set(t,e,n,i,s,r,o,a,l,u,f,h,d,p,m,_){let g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=s,g[5]=r,g[9]=o,g[13]=a,g[2]=l,g[6]=u,g[10]=f,g[14]=h,g[3]=d,g[7]=p,g[11]=m,g[15]=_,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 c().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let 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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();let e=this.elements,n=t.elements,i=1/te.setFromMatrixColumn(t,0).length(),s=1/te.setFromMatrixColumn(t,1).length(),r=1/te.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,s=t.z,r=Math.cos(n),o=Math.sin(n),a=Math.cos(i),l=Math.sin(i),u=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){let h=r*u,d=r*f,p=o*u,m=o*f;e[0]=a*u,e[4]=-a*f,e[8]=l,e[1]=d+p*l,e[5]=h-m*l,e[9]=-o*a,e[2]=m-h*l,e[6]=p+d*l,e[10]=r*a}else if(t.order==="YXZ"){let h=a*u,d=a*f,p=l*u,m=l*f;e[0]=h+m*o,e[4]=p*o-d,e[8]=r*l,e[1]=r*f,e[5]=r*u,e[9]=-o,e[2]=d*o-p,e[6]=m+h*o,e[10]=r*a}else if(t.order==="ZXY"){let h=a*u,d=a*f,p=l*u,m=l*f;e[0]=h-m*o,e[4]=-r*f,e[8]=p+d*o,e[1]=d+p*o,e[5]=r*u,e[9]=m-h*o,e[2]=-r*l,e[6]=o,e[10]=r*a}else if(t.order==="ZYX"){let h=r*u,d=r*f,p=o*u,m=o*f;e[0]=a*u,e[4]=p*l-d,e[8]=h*l+m,e[1]=a*f,e[5]=m*l+h,e[9]=d*l-p,e[2]=-l,e[6]=o*a,e[10]=r*a}else if(t.order==="YZX"){let h=r*a,d=r*l,p=o*a,m=o*l;e[0]=a*u,e[4]=m-h*f,e[8]=p*f+d,e[1]=f,e[5]=r*u,e[9]=-o*u,e[2]=-l*u,e[6]=d*f+p,e[10]=h-m*f}else if(t.order==="XZY"){let h=r*a,d=r*l,p=o*a,m=o*l;e[0]=a*u,e[4]=-f,e[8]=l*u,e[1]=h*f+m,e[5]=r*u,e[9]=d*f-p,e[2]=p*f-d,e[6]=o*u,e[10]=m*f+h}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(Wr,t,Xr)}lookAt(t,e,n){let i=this.elements;return ft.subVectors(t,e),ft.lengthSq()===0&&(ft.z=1),ft.normalize(),Nt.crossVectors(n,ft),Nt.lengthSq()===0&&(Math.abs(n.z)===1?ft.x+=1e-4:ft.z+=1e-4,ft.normalize(),Nt.crossVectors(n,ft)),Nt.normalize(),Ke.crossVectors(ft,Nt),i[0]=Nt.x,i[4]=Ke.x,i[8]=ft.x,i[1]=Nt.y,i[5]=Ke.y,i[9]=ft.y,i[2]=Nt.z,i[6]=Ke.z,i[10]=ft.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],o=n[4],a=n[8],l=n[12],u=n[1],f=n[5],h=n[9],d=n[13],p=n[2],m=n[6],_=n[10],g=n[14],x=n[3],y=n[7],S=n[11],v=n[15],b=i[0],T=i[4],A=i[8],E=i[12],C=i[1],R=i[5],w=i[9],P=i[13],L=i[2],D=i[6],O=i[10],it=i[14],Tt=i[3],At=i[7],Je=i[11],$e=i[15];return s[0]=r*b+o*C+a*L+l*Tt,s[4]=r*T+o*R+a*D+l*At,s[8]=r*A+o*w+a*O+l*Je,s[12]=r*E+o*P+a*it+l*$e,s[1]=u*b+f*C+h*L+d*Tt,s[5]=u*T+f*R+h*D+d*At,s[9]=u*A+f*w+h*O+d*Je,s[13]=u*E+f*P+h*it+d*$e,s[2]=p*b+m*C+_*L+g*Tt,s[6]=p*T+m*R+_*D+g*At,s[10]=p*A+m*w+_*O+g*Je,s[14]=p*E+m*P+_*it+g*$e,s[3]=x*b+y*C+S*L+v*Tt,s[7]=x*T+y*R+S*D+v*At,s[11]=x*A+y*w+S*O+v*Je,s[15]=x*E+y*P+S*it+v*$e,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],r=t[1],o=t[5],a=t[9],l=t[13],u=t[2],f=t[6],h=t[10],d=t[14],p=t[3],m=t[7],_=t[11],g=t[15],x=a*d-l*h,y=o*d-l*f,S=o*h-a*f,v=r*d-l*u,b=r*h-a*u,T=r*f-o*u;return e*(m*x-_*y+g*S)-n*(p*x-_*v+g*b)+i*(p*y-m*v+g*T)-s*(p*S-m*b+_*T)}transpose(){let t=this.elements,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,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],m=t[13],_=t[14],g=t[15],x=e*o-n*r,y=e*a-i*r,S=e*l-s*r,v=n*a-i*o,b=n*l-s*o,T=i*l-s*a,A=u*m-f*p,E=u*_-h*p,C=u*g-d*p,R=f*_-h*m,w=f*g-d*m,P=h*g-d*_,L=x*P-y*w+S*R+v*C-b*E+T*A;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let D=1/L;return t[0]=(o*P-a*w+l*R)*D,t[1]=(i*w-n*P-s*R)*D,t[2]=(m*T-_*b+g*v)*D,t[3]=(h*b-f*T-d*v)*D,t[4]=(a*C-r*P-l*E)*D,t[5]=(e*P-i*C+s*E)*D,t[6]=(_*S-p*T-g*y)*D,t[7]=(u*T-h*S+d*y)*D,t[8]=(r*w-o*C+l*A)*D,t[9]=(n*C-e*w-s*A)*D,t[10]=(p*b-m*S+g*x)*D,t[11]=(f*S-u*b-d*x)*D,t[12]=(o*E-r*R-a*A)*D,t[13]=(e*R-n*E+i*A)*D,t[14]=(m*y-p*v-_*x)*D,t[15]=(u*v-f*y+h*x)*D,this}scale(t){let e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),s=1-n,r=t.x,o=t.y,a=t.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*a,l*a+i*o,0,l*o+i*a,u*o+n,u*a-i*r,0,l*a-i*o,u*a+i*r,s*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,r){return this.set(1,n,s,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,s=e._x,r=e._y,o=e._z,a=e._w,l=s+s,u=r+r,f=o+o,h=s*l,d=s*u,p=s*f,m=r*u,_=r*f,g=o*f,x=a*l,y=a*u,S=a*f,v=n.x,b=n.y,T=n.z;return i[0]=(1-(m+g))*v,i[1]=(d+S)*v,i[2]=(p-y)*v,i[3]=0,i[4]=(d-S)*b,i[5]=(1-(h+g))*b,i[6]=(_+x)*b,i[7]=0,i[8]=(p+y)*T,i[9]=(_-x)*T,i[10]=(1-(h+m))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];let s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let r=te.set(i[0],i[1],i[2]).length(),o=te.set(i[4],i[5],i[6]).length(),a=te.set(i[8],i[9],i[10]).length();s<0&&(r=-r),yt.copy(this);let l=1/r,u=1/o,f=1/a;return yt.elements[0]*=l,yt.elements[1]*=l,yt.elements[2]*=l,yt.elements[4]*=u,yt.elements[5]*=u,yt.elements[6]*=u,yt.elements[8]*=f,yt.elements[9]*=f,yt.elements[10]*=f,e.setFromRotationMatrix(yt),n.x=r,n.y=o,n.z=a,this}makePerspective(t,e,n,i,s,r,o=Le,a=!1){let l=this.elements,u=2*s/(e-t),f=2*s/(n-i),h=(e+t)/(e-t),d=(n+i)/(n-i),p,m;if(a)p=s/(r-s),m=r*s/(r-s);else if(o===Le)p=-(r+s)/(r-s),m=-2*r*s/(r-s);else if(o===Pi)p=-r/(r-s),m=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,r,o=Le,a=!1){let l=this.elements,u=2/(e-t),f=2/(n-i),h=-(e+t)/(e-t),d=-(n+i)/(n-i),p,m;if(a)p=1/(r-s),m=r/(r-s);else if(o===Le)p=-2/(r-s),m=-(r+s)/(r-s);else if(o===Pi)p=-1/(r-s),m=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},te=new M,yt=new W,Wr=new M(0,0,0),Xr=new M(1,1,1),Nt=new M,Ke=new M,ft=new M,Ss=new W,bs=new Lt,Ne=class c{constructor(t=0,e=0,n=0,i=c.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){let i=t.elements,s=i[0],r=i[4],o=i[8],a=i[1],l=i[5],u=i[9],f=i[2],h=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(U(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-U(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(U(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(a,s));break;case"ZYX":this._y=Math.asin(-U(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(a,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(U(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-U(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:Q("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ss.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ss,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return bs.setFromEuler(this),this.setFromQuaternion(bs,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}};Ne.DEFAULT_ORDER="XYZ";var dn=class{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}},qr=0,Ts=new M,ee=new Lt,wt=new W,Qe=new M,we=new M,Yr=new M,Zr=new Lt,As=new M(1,0,0),Es=new M(0,1,0),ws=new M(0,0,1),Cs={type:"added"},Jr={type:"removed"},ne={type:"childadded",child:null},jn={type:"childremoved",child:null},Zt=class c extends Yt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qr++}),this.uuid=Cn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DEFAULT_UP.clone();let t=new M,e=new Ne,n=new Lt,i=new M(1,1,1);function s(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new W},normalMatrix:{value:new N}}),this.matrix=new W,this.matrixWorld=new W,this.matrixAutoUpdate=c.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=c.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}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 ee.setFromAxisAngle(t,e),this.quaternion.multiply(ee),this}rotateOnWorldAxis(t,e){return ee.setFromAxisAngle(t,e),this.quaternion.premultiply(ee),this}rotateX(t){return this.rotateOnAxis(As,t)}rotateY(t){return this.rotateOnAxis(Es,t)}rotateZ(t){return this.rotateOnAxis(ws,t)}translateOnAxis(t,e){return Ts.copy(t).applyQuaternion(this.quaternion),this.position.add(Ts.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(As,t)}translateY(t){return this.translateOnAxis(Es,t)}translateZ(t){return this.translateOnAxis(ws,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(wt.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Qe.copy(t):Qe.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),we.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wt.lookAt(we,Qe,this.up):wt.lookAt(Qe,we,this.up),this.quaternion.setFromRotationMatrix(wt),i&&(wt.extractRotation(i.matrixWorld),ee.setFromRotationMatrix(wt),this.quaternion.premultiply(ee.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(G("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(Cs),ne.child=t,this.dispatchEvent(ne),ne.child=null):G("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Jr),jn.child=t,this.dispatchEvent(jn),jn.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),wt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),wt.multiply(t.parent.matrixWorld)),t.applyMatrix4(wt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Cs),ne.child=t,this.dispatchEvent(ne),ne.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 n=0,i=this.children.length;n<i;n++){let r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,t,Yr),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,Zr,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}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);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.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){let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(t)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let l=0,u=a.length;l<u;l++){let f=a[l];s(t.shapes,f)}else s(t.shapes,a)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,l=this.material.length;a<l;a++)o.push(s(t.materials,this.material[a]));i.material=o}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(s(t.animations,a))}}if(e){let o=r(t.geometries),a=r(t.materials),l=r(t.textures),u=r(t.images),f=r(t.shapes),h=r(t.skeletons),d=r(t.animations),p=r(t.nodes);o.length>0&&(n.geometries=o),a.length>0&&(n.materials=a),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),h.length>0&&(n.skeletons=h),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){let a=[];for(let l in o){let u=o[l];delete u.metadata,a.push(u)}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.pivot=t.pivot!==null?t.pivot.clone():null,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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};Zt.DEFAULT_UP=new M(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var 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},Ut={h:0,s:0,l:0},je={h:0,s:0,l:0};function ti(c,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?c+(t-c)*6*e:e<1/2?t:e<2/3?c+(t-c)*6*(2/3-e):c}var j=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=_t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,gt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=gt.workingColorSpace){return this.r=t,this.g=e,this.b=n,gt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=gt.workingColorSpace){if(t=Vr(t,1),e=U(e,0,1),n=U(n,0,1),e===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+e):n+e-n*e,r=2*n-s;this.r=ti(r,s,t+1/3),this.g=ti(r,s,t),this.b=ti(r,s,t-1/3)}return gt.colorSpaceToWorking(this,i),this}setStyle(t,e=_t){function n(s){s!==void 0&&parseFloat(s)<1&&Q("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\\w+)\\(([^\\)]*)\\)/.exec(t)){let s,r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(s=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Q("Color: Unknown color model "+t)}}else if(i=/^\\#([A-Fa-f\\d]+)$/.exec(t)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(s,16),e);Q("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=_t){let n=Xs[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Q("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=It(t.r),this.g=It(t.g),this.b=It(t.b),this}copyLinearToSRGB(t){return this.r=he(t.r),this.g=he(t.g),this.b=he(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=_t){return gt.workingToColorSpace(rt.copy(this),t),Math.round(U(rt.r*255,0,255))*65536+Math.round(U(rt.g*255,0,255))*256+Math.round(U(rt.b*255,0,255))}getHexString(t=_t){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=gt.workingColorSpace){gt.workingToColorSpace(rt.copy(this),e);let n=rt.r,i=rt.g,s=rt.b,r=Math.max(n,i,s),o=Math.min(n,i,s),a,l,u=(o+r)/2;if(o===r)a=0,l=0;else{let f=r-o;switch(l=u<=.5?f/(r+o):f/(2-r-o),r){case n:a=(i-s)/f+(i<s?6:0);break;case i:a=(s-n)/f+2;break;case s:a=(n-i)/f+4;break}a/=6}return t.h=a,t.s=l,t.l=u,t}getRGB(t,e=gt.workingColorSpace){return gt.workingToColorSpace(rt.copy(this),e),t.r=rt.r,t.g=rt.g,t.b=rt.b,t}getStyle(t=_t){gt.workingToColorSpace(rt.copy(this),t);let e=rt.r,n=rt.g,i=rt.b;return t!==_t?\`color(\${t} \${e.toFixed(3)} \${n.toFixed(3)} \${i.toFixed(3)})\`:\`rgb(\${Math.round(e*255)},\${Math.round(n*255)},\${Math.round(i*255)})\`}offsetHSL(t,e,n){return this.getHSL(Ut),this.setHSL(Ut.h+t,Ut.s+e,Ut.l+n)}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,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Ut),t.getHSL(je);let n=Zn(Ut.h,je.h,e),i=Zn(Ut.s,je.s,e),s=Zn(Ut.l,je.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,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}},rt=new j;j.NAMES=Xs;var vt=new M,Ct=new M,ei=new M,Rt=new M,ie=new M,se=new M,Rs=new M,ni=new M,ii=new M,si=new M,ri=new de,oi=new de,ai=new de,St=class c{constructor(t=new M,e=new M,n=new M){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),vt.subVectors(t,e),i.cross(vt);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){vt.subVectors(i,e),Ct.subVectors(n,e),ei.subVectors(t,e);let r=vt.dot(vt),o=vt.dot(Ct),a=vt.dot(ei),l=Ct.dot(Ct),u=Ct.dot(ei),f=r*l-o*o;if(f===0)return s.set(0,0,0),null;let h=1/f,d=(l*a-o*u)*h,p=(r*u-o*a)*h;return s.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Rt)===null?!1:Rt.x>=0&&Rt.y>=0&&Rt.x+Rt.y<=1}static getInterpolation(t,e,n,i,s,r,o,a){return this.getBarycoord(t,e,n,i,Rt)===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(s,Rt.x),a.addScaledVector(r,Rt.y),a.addScaledVector(o,Rt.z),a)}static getInterpolatedAttribute(t,e,n,i,s,r){return ri.setScalar(0),oi.setScalar(0),ai.setScalar(0),ri.fromBufferAttribute(t,e),oi.fromBufferAttribute(t,n),ai.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(ri,s.x),r.addScaledVector(oi,s.y),r.addScaledVector(ai,s.z),r}static isFrontFacing(t,e,n,i){return vt.subVectors(n,e),Ct.subVectors(t,e),vt.cross(Ct).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 vt.subVectors(this.c,this.b),Ct.subVectors(this.a,this.b),vt.cross(Ct).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return c.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return c.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return c.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return c.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return c.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,s=this.c,r,o;ie.subVectors(i,n),se.subVectors(s,n),ni.subVectors(t,n);let a=ie.dot(ni),l=se.dot(ni);if(a<=0&&l<=0)return e.copy(n);ii.subVectors(t,i);let u=ie.dot(ii),f=se.dot(ii);if(u>=0&&f<=u)return e.copy(i);let h=a*f-u*l;if(h<=0&&a>=0&&u<=0)return r=a/(a-u),e.copy(n).addScaledVector(ie,r);si.subVectors(t,s);let d=ie.dot(si),p=se.dot(si);if(p>=0&&d<=p)return e.copy(s);let m=d*l-a*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(n).addScaledVector(se,o);let _=u*p-d*f;if(_<=0&&f-u>=0&&d-p>=0)return Rs.subVectors(s,i),o=(f-u)/(f-u+(d-p)),e.copy(i).addScaledVector(Rs,o);let g=1/(_+m+h);return r=m*g,o=h*g,e.copy(n).addScaledVector(ie,r).addScaledVector(se,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},X=class{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,n=t.length;e<n;e+=3)this.expandByPoint(Mt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Mt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Mt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),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);let n=t.geometry;if(n!==void 0){let s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,Mt):Mt.fromBufferAttribute(s,r),Mt.applyMatrix4(t.matrixWorld),this.expandByPoint(Mt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),tn.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),tn.copy(n.boundingBox)),tn.applyMatrix4(t.matrixWorld),this.union(tn)}let i=t.children;for(let s=0,r=i.length;s<r;s++)this.expandByObject(i[s],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,Mt),Mt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ce),en.subVectors(this.max,Ce),re.subVectors(t.a,Ce),oe.subVectors(t.b,Ce),ae.subVectors(t.c,Ce),Ft.subVectors(oe,re),Bt.subVectors(ae,oe),Xt.subVectors(re,ae);let e=[0,-Ft.z,Ft.y,0,-Bt.z,Bt.y,0,-Xt.z,Xt.y,Ft.z,0,-Ft.x,Bt.z,0,-Bt.x,Xt.z,0,-Xt.x,-Ft.y,Ft.x,0,-Bt.y,Bt.x,0,-Xt.y,Xt.x,0];return!ci(e,re,oe,ae,en)||(e=[1,0,0,0,1,0,0,0,1],!ci(e,re,oe,ae,en))?!1:(nn.crossVectors(Ft,Bt),e=[nn.x,nn.y,nn.z],ci(e,re,oe,ae,en))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Mt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Mt).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:(Pt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pt),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Pt=[new M,new M,new M,new M,new M,new M,new M,new M],Mt=new M,tn=new X,re=new M,oe=new M,ae=new M,Ft=new M,Bt=new M,Xt=new M,Ce=new M,en=new M,nn=new M,qt=new M;function ci(c,t,e,n,i){for(let s=0,r=c.length-3;s<=r;s+=3){qt.fromArray(c,s);let o=i.x*Math.abs(qt.x)+i.y*Math.abs(qt.y)+i.z*Math.abs(qt.z),a=t.dot(qt),l=e.dot(qt),u=n.dot(qt);if(Math.max(-Math.max(a,l,u),Math.min(a,l,u))>o)return!1}return!0}var J=new M,sn=new H,$r=0,ot=class extends Yt{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$r++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Ri,this.updateRanges=[],this.gpuType=Gs,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,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyMatrix3(t),this.setXY(e,sn.x,sn.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyMatrix3(t),this.setXYZ(e,J.x,J.y,J.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyMatrix4(t),this.setXYZ(e,J.x,J.y,J.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyNormalMatrix(t),this.setXYZ(e,J.x,J.y,J.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.transformDirection(t),this.setXYZ(e,J.x,J.y,J.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ee(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ut(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ee(e,this.array)),e}setX(t,e){return this.normalized&&(e=ut(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ee(e,this.array)),e}setY(t,e){return this.normalized&&(e=ut(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=Ee(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ut(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=Ee(e,this.array)),e}setW(t,e){return this.normalized&&(e=ut(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array),i=ut(i,this.array),s=ut(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==Ri&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}};var pn=class extends ot{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var mn=class extends ot{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var gn=class extends ot{constructor(t,e,n){super(new Float32Array(t),e,n)}},Kr=new X,Re=new M,li=new M,pe=class{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){let n=this.center;e!==void 0?n.copy(e):Kr.setFromPoints(t).getCenter(n);let i=0;for(let s=0,r=t.length;s<r;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),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){let 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){let n=this.center.distanceToSquared(t);return e.copy(t),n>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;Re.subVectors(t,this.center);let e=Re.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Re,i/n),this.radius+=i}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):(li.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Re.copy(t.center).add(li)),this.expandByPoint(Re.copy(t.center).sub(li))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Qr=0,mt=new W,ui=new Zt,ce=new M,dt=new X,Pe=new X,K=new M,Ue=class c extends Yt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qr++}),this.uuid=Cn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(Fr(t)?mn:pn)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,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,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new N().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return mt.makeRotationFromQuaternion(t),this.applyMatrix4(mt),this}rotateX(t){return mt.makeRotationX(t),this.applyMatrix4(mt),this}rotateY(t){return mt.makeRotationY(t),this.applyMatrix4(mt),this}rotateZ(t){return mt.makeRotationZ(t),this.applyMatrix4(mt),this}translate(t,e,n){return mt.makeTranslation(t,e,n),this.applyMatrix4(mt),this}scale(t,e,n){return mt.makeScale(t,e,n),this.applyMatrix4(mt),this}lookAt(t){return ui.lookAt(t),ui.updateMatrix(),this.applyMatrix4(ui.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ce).negate(),this.translate(ce.x,ce.y,ce.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,s=t.length;i<s;i++){let r=t[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new gn(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&Q("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 X);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){G("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 n=0,i=e.length;n<i;n++){let s=e[n];dt.setFromBufferAttribute(s),this.morphTargetsRelative?(K.addVectors(this.boundingBox.min,dt.min),this.boundingBox.expandByPoint(K),K.addVectors(this.boundingBox.max,dt.max),this.boundingBox.expandByPoint(K)):(this.boundingBox.expandByPoint(dt.min),this.boundingBox.expandByPoint(dt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&G('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);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){G("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new M,1/0);return}if(t){let n=this.boundingSphere.center;if(dt.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){let o=e[s];Pe.setFromBufferAttribute(o),this.morphTargetsRelative?(K.addVectors(dt.min,Pe.min),dt.expandByPoint(K),K.addVectors(dt.max,Pe.max),dt.expandByPoint(K)):(dt.expandByPoint(Pe.min),dt.expandByPoint(Pe.max))}dt.getCenter(n);let i=0;for(let s=0,r=t.count;s<r;s++)K.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(K));if(e)for(let s=0,r=e.length;s<r;s++){let o=e[s],a=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)K.fromBufferAttribute(o,l),a&&(ce.fromBufferAttribute(t,l),K.add(ce)),i=Math.max(i,n.distanceToSquared(K))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&G('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){G("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ot(new Float32Array(4*n.count),4));let r=this.getAttribute("tangent"),o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new M,a[A]=new M;let l=new M,u=new M,f=new M,h=new H,d=new H,p=new H,m=new M,_=new M;function g(A,E,C){l.fromBufferAttribute(n,A),u.fromBufferAttribute(n,E),f.fromBufferAttribute(n,C),h.fromBufferAttribute(s,A),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,C),u.sub(l),f.sub(l),d.sub(h),p.sub(h);let R=1/(d.x*p.y-p.x*d.y);isFinite(R)&&(m.copy(u).multiplyScalar(p.y).addScaledVector(f,-d.y).multiplyScalar(R),_.copy(f).multiplyScalar(d.x).addScaledVector(u,-p.x).multiplyScalar(R),o[A].add(m),o[E].add(m),o[C].add(m),a[A].add(_),a[E].add(_),a[C].add(_))}let x=this.groups;x.length===0&&(x=[{start:0,count:t.count}]);for(let A=0,E=x.length;A<E;++A){let C=x[A],R=C.start,w=C.count;for(let P=R,L=R+w;P<L;P+=3)g(t.getX(P+0),t.getX(P+1),t.getX(P+2))}let y=new M,S=new M,v=new M,b=new M;function T(A){v.fromBufferAttribute(i,A),b.copy(v);let E=o[A];y.copy(E),y.sub(v.multiplyScalar(v.dot(E))).normalize(),S.crossVectors(b,E);let R=S.dot(a[A])<0?-1:1;r.setXYZW(A,y.x,y.y,y.z,R)}for(let A=0,E=x.length;A<E;++A){let C=x[A],R=C.start,w=C.count;for(let P=R,L=R+w;P<L;P+=3)T(t.getX(P+0)),T(t.getX(P+1)),T(t.getX(P+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ot(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new M,s=new M,r=new M,o=new M,a=new M,l=new M,u=new M,f=new M;if(t)for(let h=0,d=t.count;h<d;h+=3){let p=t.getX(h+0),m=t.getX(h+1),_=t.getX(h+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),r.fromBufferAttribute(e,_),u.subVectors(r,s),f.subVectors(i,s),u.cross(f),o.fromBufferAttribute(n,p),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,_),o.add(u),a.add(u),l.add(u),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let h=0,d=e.count;h<d;h+=3)i.fromBufferAttribute(e,h+0),s.fromBufferAttribute(e,h+1),r.fromBufferAttribute(e,h+2),u.subVectors(r,s),f.subVectors(i,s),u.cross(f),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)K.fromBufferAttribute(t,e),K.normalize(),t.setXYZ(e,K.x,K.y,K.z)}toNonIndexed(){function t(o,a){let l=o.array,u=o.itemSize,f=o.normalized,h=new l.constructor(a.length*u),d=0,p=0;for(let m=0,_=a.length;m<_;m++){o.isInterleavedBufferAttribute?d=a[m]*o.data.stride+o.offset:d=a[m]*u;for(let g=0;g<u;g++)h[p++]=l[d++]}return new ot(h,u,f)}if(this.index===null)return Q("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new c,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],l=t(a,n);e.setAttribute(o,l)}let s=this.morphAttributes;for(let o in s){let a=[],l=s[o];for(let u=0,f=l.length;u<f;u++){let h=l[u],d=t(h,n);a.push(d)}e.morphAttributes[o]=a}e.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let o=0,a=r.length;o<a;o++){let l=r[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,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){let a=this.parameters;for(let l in a)a[l]!==void 0&&(t[l]=a[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let a in n){let l=n[a];t.data.attributes[a]=l.toJSON(t.data)}let i={},s=!1;for(let a in this.morphAttributes){let l=this.morphAttributes[a],u=[];for(let f=0,h=l.length;f<h;f++){let d=l[f];u.push(d.toJSON(t.data))}u.length>0&&(i[a]=u,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let i=t.attributes;for(let l in i){let u=i[l];this.setAttribute(l,u.clone(e))}let s=t.morphAttributes;for(let l in s){let u=[],f=s[l];for(let h=0,d=f.length;h<d;h++)u.push(f[h].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;let r=t.groups;for(let l=0,u=r.length;l<u;l++){let f=r[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let 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"})}};var hi=new M,jr=new M,to=new N,Jt=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,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=hi.subVectors(n,e).cross(jr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let 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,n=!0){let i=t.delta(hi),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return n===!0&&(r<0||r>1)?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<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){let n=e||to.getNormalMatrix(t),i=this.coplanarPoint(hi).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),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)}};function qs(c){let t={};for(let e in c){t[e]={};for(let n in c[e]){let i=c[e][n];if(Ps(i))i.isRenderTargetTexture?(Q("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(Ps(i[0])){let s=[];for(let r=0,o=i.length;r<o;r++)s[r]=i[r].clone();t[e][n]=s}else t[e][n]=i.slice();else t[e][n]=i}}return t}function ct(c){let t={};for(let e=0;e<c.length;e++){let n=qs(c[e]);for(let i in n)t[i]=n[i]}return t}function Ps(c){return c&&(c.isColor||c.isMatrix3||c.isMatrix4||c.isVector2||c.isVector3||c.isVector4||c.isTexture||c.isQuaternion)}function rn(c,t){return!c||c.constructor===t?c:typeof t.BYTES_PER_ELEMENT=="number"?new t(c):Array.prototype.slice.call(c)}var Ot=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{t:{let r;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=e[++n],t<i)break t}r=e.length;break e}if(!(t>=s)){let o=e[1];t<o&&(n=2,s=o);for(let a=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=s,s=e[--n-1],t>=s)break t}r=n,n=0;break e}break n}for(;n<r;){let o=n+r>>>1;t<e[o]?r=o:n=o+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let r=0;r!==i;++r)e[r]=n[s+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},_n=class extends Ot{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ti,endingEnd:Ti}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,r=t+1,o=i[s],a=i[r];if(o===void 0)switch(this.getSettings_().endingStart){case Ai:s=t,o=2*e-n;break;case Ei:s=i.length-2,o=e+i[s]-i[s+1];break;default:s=t,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case Ai:r=t,a=2*n-e;break;case Ei:r=1,a=n+i[1]-i[0];break;default:r=t-1,a=e}let l=(n-e)*.5,u=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(a-n),this._offsetPrev=s*u,this._offsetNext=r*u}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),m=p*p,_=m*p,g=-h*_+2*h*m-h*p,x=(1+h)*_+(-1.5-2*h)*m+(-.5+h)*p+1,y=(-1-d)*_+(1.5+d)*m+.5*p,S=d*_-d*m;for(let v=0;v!==o;++v)s[v]=g*r[u+v]+x*r[l+v]+y*r[a+v]+S*r[f+v];return s}},xn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=(n-e)/(i-e),f=1-u;for(let h=0;h!==o;++h)s[h]=r[l+h]*f+r[a+h]*u;return s}},yn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},vn=class extends Ot{interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=this.settings||this.DefaultSettings_,f=u.inTangents,h=u.outTangents;if(!f||!h){let m=(n-e)/(i-e),_=1-m;for(let g=0;g!==o;++g)s[g]=r[l+g]*_+r[a+g]*m;return s}let d=o*2,p=t-1;for(let m=0;m!==o;++m){let _=r[l+m],g=r[a+m],x=p*d+m*2,y=h[x],S=h[x+1],v=t*d+m*2,b=f[v],T=f[v+1],A=(n-e)/(i-e),E,C,R,w,P;for(let L=0;L<8;L++){E=A*A,C=E*A,R=1-A,w=R*R,P=w*R;let O=P*e+3*w*A*y+3*R*E*b+C*i-n;if(Math.abs(O)<1e-10)break;let it=3*w*(y-e)+6*R*A*(b-y)+3*E*(i-b);if(Math.abs(it)<1e-10)break;A=A-O/it,A=Math.max(0,Math.min(1,A))}s[m]=P*_+3*w*A*S+3*R*E*T+C*g}return s}},pt=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=rn(e,this.TimeBufferType),this.values=rn(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:rn(t.times,Array),values:rn(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new yn(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new xn(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new _n(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new vn(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case De:e=this.InterpolantFactoryMethodDiscrete;break;case ln:e=this.InterpolantFactoryMethodLinear;break;case an:e=this.InterpolantFactoryMethodSmooth;break;case bi:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Q("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return De;case this.InterpolantFactoryMethodLinear:return ln;case this.InterpolantFactoryMethodSmooth:return an;case this.InterpolantFactoryMethodBezier:return bi}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,r=i-1;for(;s!==i&&n[s]<t;)++s;for(;r!==-1&&n[r]>e;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);let o=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(G("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,s=n.length;s===0&&(G("KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let o=0;o!==s;o++){let a=n[o];if(typeof a=="number"&&isNaN(a)){G("KeyframeTrack: Time is not a valid number.",this,o,a),t=!1;break}if(r!==null&&r>a){G("KeyframeTrack: Out of order keys.",this,o,a,r),t=!1;break}r=a}if(i!==void 0&&Br(i))for(let o=0,a=i.length;o!==a;++o){let l=i[o];if(isNaN(l)){G("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===an,s=t.length-1,r=1;for(let o=1;o<s;++o){let a=!1,l=t[o],u=t[o+1];if(l!==u&&(o!==1||l!==t[0]))if(i)a=!0;else{let f=o*n,h=f-n,d=f+n;for(let p=0;p!==n;++p){let m=e[f+p];if(m!==e[h+p]||m!==e[d+p]){a=!0;break}}}if(a){if(o!==r){t[r]=t[o];let f=o*n,h=r*n;for(let d=0;d!==n;++d)e[h+d]=e[f+d]}++r}}if(s>0){t[r]=t[s];for(let o=s*n,a=r*n,l=0;l!==n;++l)e[a+l]=e[o+l];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};pt.prototype.ValueTypeName="";pt.prototype.TimeBufferType=Float32Array;pt.prototype.ValueBufferType=Float32Array;pt.prototype.DefaultInterpolation=ln;var zt=class extends pt{constructor(t,e,n){super(t,e,n)}};zt.prototype.ValueTypeName="bool";zt.prototype.ValueBufferType=Array;zt.prototype.DefaultInterpolation=De;zt.prototype.InterpolantFactoryMethodLinear=void 0;zt.prototype.InterpolantFactoryMethodSmooth=void 0;var Mn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Mn.prototype.ValueTypeName="color";var Sn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Sn.prototype.ValueTypeName="number";var bn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=(n-e)/(i-e),l=t*o;for(let u=l+o;l!==u;l+=4)Lt.slerpFlat(s,0,r,l-o,r,l,a);return s}},Fe=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new bn(this.times,this.values,this.getValueSize(),t)}};Fe.prototype.ValueTypeName="quaternion";Fe.prototype.InterpolantFactoryMethodSmooth=void 0;var Vt=class extends pt{constructor(t,e,n){super(t,e,n)}};Vt.prototype.ValueTypeName="string";Vt.prototype.ValueBufferType=Array;Vt.prototype.DefaultInterpolation=De;Vt.prototype.InterpolantFactoryMethodLinear=void 0;Vt.prototype.InterpolantFactoryMethodSmooth=void 0;var Tn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Tn.prototype.ValueTypeName="vector";var An=class{constructor(t,e,n){let i=this,s=!1,r=0,o=0,a,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(u){o++,s===!1&&i.onStart!==void 0&&i.onStart(u,r,o),s=!0},this.itemEnd=function(u){r++,i.onProgress!==void 0&&i.onProgress(u,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return a?a(u):u},this.setURLModifier=function(u){return a=u,this},this.addHandler=function(u,f){return l.push(u,f),this},this.removeHandler=function(u){let f=l.indexOf(u);return f!==-1&&l.splice(f,2),this},this.getHandler=function(u){for(let f=0,h=l.length;f<h;f+=2){let d=l[f],p=l[f+1];if(d.global&&(d.lastIndex=0),d.test(u))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Ys=new An,En=class{constructor(t){this.manager=t!==void 0?t:Ys,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}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}abort(){return this}};En.DEFAULT_MATERIAL_NAME="__DEFAULT";var Yi="\\\\[\\\\]\\\\.:\\\\/",eo=new RegExp("["+Yi+"]","g"),Zi="[^"+Yi+"]",no="[^"+Yi.replace("\\\\.","")+"]",io=/((?:WC+[\\/:])*)/.source.replace("WC",Zi),so=/(WCOD+)?/.source.replace("WCOD",no),ro=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Zi),oo=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Zi),ao=new RegExp("^"+io+so+ro+oo+"$"),co=["material","materials","bones","map"],Di=class{constructor(t,e,n){let i=n||k.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},k=class c{constructor(t,e,n){this.path=e,this.parsedPath=n||c.parseTrackName(e),this.node=c.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new c.Composite(t,e,n):new c(t,e,n)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(eo,"")}static parseTrackName(t){let e=ao.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);co.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let r=0;r<s.length;r++){let o=s[r];if(o.name===e||o.uuid===e)return o;let a=n(o.children);if(a)return a}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=c.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Q("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){G("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){G("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){G("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===l){l=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){G("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){G("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){G("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){G("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let r=t[i];if(r===void 0){let l=e.nodeName;G("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){G("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){G("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}a=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(a=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};k.Composite=Di;k.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};k.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};k.prototype.GetterByBindingType=[k.prototype._getValue_direct,k.prototype._getValue_array,k.prototype._getValue_arrayElement,k.prototype._getValue_toArray];k.prototype.SetterByBindingTypeAndVersioning=[[k.prototype._setValue_direct,k.prototype._setValue_direct_setNeedsUpdate,k.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[k.prototype._setValue_array,k.prototype._setValue_array_setNeedsUpdate,k.prototype._setValue_array_setMatrixWorldNeedsUpdate],[k.prototype._setValue_arrayElement,k.prototype._setValue_arrayElement_setNeedsUpdate,k.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[k.prototype._setValue_fromArray,k.prototype._setValue_fromArray_setNeedsUpdate,k.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var vl=new Float32Array(1);var Ni=class c{static{c.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}};var Is=new M,on=new M,le=new M,ue=new M,fi=new M,lo=new M,uo=new M,at=class{constructor(t=new M,e=new M){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Is.subVectors(t,this.start),on.subVectors(this.end,this.start);let n=on.dot(on);if(n===0)return 0;let s=on.dot(Is)/n;return e&&(s=U(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=lo,n=uo){let i=10000000000000001e-32,s,r,o=this.start,a=t.start,l=this.end,u=t.end;le.subVectors(l,o),ue.subVectors(u,a),fi.subVectors(o,a);let f=le.dot(le),h=ue.dot(ue),d=ue.dot(fi);if(f<=i&&h<=i)return e.copy(o),n.copy(a),e.sub(n),e.dot(e);if(f<=i)s=0,r=d/h,r=U(r,0,1);else{let p=le.dot(fi);if(h<=i)r=0,s=U(-p/f,0,1);else{let m=le.dot(ue),_=f*h-m*m;_!==0?s=U((m*d-p*h)/_,0,1):s=0,r=(m*s+d)/h,r<0?(r=0,s=U(-p/f,0,1)):r>1&&(r=1,s=U((m-p)/f,0,1))}}return e.copy(o).addScaledVector(le,s),n.copy(a).addScaledVector(ue,r),e.distanceToSquared(n)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"184"}}));typeof window<"u"&&(window.__THREE__?Q("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="184");var ho=\`#ifdef USE_ALPHAHASH
1
+ "use strict";"use client";var jt=Object.defineProperty;var Ei=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Ci=Object.prototype.hasOwnProperty;var Li=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pe=(t,e)=>{for(var n in e)jt(t,n,{get:e[n],enumerable:!0})},Ni=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Pi(e))!Ci.call(t,r)&&r!==n&&jt(t,r,{get:()=>e[r],enumerable:!(i=Ei(e,r))||i.enumerable});return t};var Ri=t=>Ni(jt({},"__esModule",{value:!0}),t);var kn={};Pe(kn,{bvhWorkerCode:()=>Mr});var Mr,Vn=Li(()=>{"use strict";Mr=`(()=>{var Ls=1;var Ds=3,wn=0,Ui=1,Fi=2;var di=0,pi=1,mi=2,gi=3,_i=4,xi=5,yi=6,vi=7,Ns=0,Us=1,Fs=2;var Bi=1,Oi=2,zi=3,Vi=4,ki=5,Gi=6,Hi=7;var Wi=300,Bs=301,Xi=302;var Os=306,Mi=1e3,Ie=1001,Si=1002;var zs=1006;var Vs=1008;var ks=1009;var Gs=1015;var Hs=1023;var De=2300,ln=2301,an=2302,bi=2303,Ti=2400,Ai=2401,Ei=2402;var qi="",_t="srgb",wi="srgb-linear",Ci="linear",cn="srgb";var Ri=35044;var Le=2e3,Pi=2001;function Fr(c){for(let t=c.length-1;t>=0;--t)if(c[t]>=65535)return!0;return!1}function Br(c){return ArrayBuffer.isView(c)&&!(c instanceof DataView)}function Ii(c){return document.createElementNS("http://www.w3.org/1999/xhtml",c)}var xs={},un=null;function Ws(c){let t=c[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=c[1];e&&e.isStackTrace?c[0]+=" "+e.getLocation():c[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return c}function Q(...c){c=Ws(c);let t="THREE."+c.shift();if(un)un("warn",t,...c);else{let e=c[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...c)}}function G(...c){c=Ws(c);let t="THREE."+c.shift();if(un)un("error",t,...c);else{let e=c[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...c)}}function Li(...c){let t=c.join(" ");t in xs||(xs[t]=!0,Q(...c))}var Or={[di]:pi,[mi]:yi,[_i]:vi,[gi]:xi,[pi]:di,[yi]:mi,[vi]:_i,[xi]:gi},Yt=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,t);t.target=null}}},st=["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"];var yl=Math.PI/180,zr=180/Math.PI;function Cn(){let c=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(st[c&255]+st[c>>8&255]+st[c>>16&255]+st[c>>24&255]+"-"+st[t&255]+st[t>>8&255]+"-"+st[t>>16&15|64]+st[t>>24&255]+"-"+st[e&63|128]+st[e>>8&255]+"-"+st[e>>16&255]+st[e>>24&255]+st[n&255]+st[n>>8&255]+st[n>>16&255]+st[n>>24&255]).toLowerCase()}function U(c,t,e){return Math.max(t,Math.min(e,c))}function Vr(c,t){return(c%t+t)%t}function Zn(c,t,e){return(1-e)*c+e*t}function Ee(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return c/4294967295;case Uint16Array:return c/65535;case Uint8Array:return c/255;case Int32Array:return Math.max(c/2147483647,-1);case Int16Array:return Math.max(c/32767,-1);case Int8Array:return Math.max(c/127,-1);default:throw new Error("Invalid component type.")}}function ut(c,t){switch(t.constructor){case Float32Array:return c;case Uint32Array:return Math.round(c*4294967295);case Uint16Array:return Math.round(c*65535);case Uint8Array:return Math.round(c*255);case Int32Array:return Math.round(c*2147483647);case Int16Array:return Math.round(c*32767);case Int8Array:return Math.round(c*127);default:throw new Error("Invalid component type.")}}var H=class c{static{c.prototype.isVector2=!0}constructor(t=0,e=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){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(U(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,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){let n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*n-r*i+t.x,this.y=s*i+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Lt=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,s,r,o){let a=n[i+0],l=n[i+1],u=n[i+2],f=n[i+3],h=s[r+0],d=s[r+1],p=s[r+2],m=s[r+3];if(f!==m||a!==h||l!==d||u!==p){let _=a*h+l*d+u*p+f*m;_<0&&(h=-h,d=-d,p=-p,m=-m,_=-_);let g=1-o;if(_<.9995){let x=Math.acos(_),y=Math.sin(x);g=Math.sin(g*x)/y,o=Math.sin(o*x)/y,a=a*g+h*o,l=l*g+d*o,u=u*g+p*o,f=f*g+m*o}else{a=a*g+h*o,l=l*g+d*o,u=u*g+p*o,f=f*g+m*o;let x=1/Math.sqrt(a*a+l*l+u*u+f*f);a*=x,l*=x,u*=x,f*=x}}t[e]=a,t[e+1]=l,t[e+2]=u,t[e+3]=f}static multiplyQuaternionsFlat(t,e,n,i,s,r){let o=n[i],a=n[i+1],l=n[i+2],u=n[i+3],f=s[r],h=s[r+1],d=s[r+2],p=s[r+3];return t[e]=o*p+u*f+a*d-l*h,t[e+1]=a*p+u*h+l*f-o*d,t[e+2]=l*p+u*d+o*h-a*f,t[e+3]=u*p-o*f-a*h-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,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,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){let n=t._x,i=t._y,s=t._z,r=t._order,o=Math.cos,a=Math.sin,l=o(n/2),u=o(i/2),f=o(s/2),h=a(n/2),d=a(i/2),p=a(s/2);switch(r){case"XYZ":this._x=h*u*f+l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f-h*d*p;break;case"YXZ":this._x=h*u*f+l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f+h*d*p;break;case"ZXY":this._x=h*u*f-l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f-h*d*p;break;case"ZYX":this._x=h*u*f-l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f+h*d*p;break;case"YZX":this._x=h*u*f+l*d*p,this._y=l*d*f+h*u*p,this._z=l*u*p-h*d*f,this._w=l*u*f-h*d*p;break;case"XZY":this._x=h*u*f-l*d*p,this._y=l*d*f-h*u*p,this._z=l*u*p+h*d*f,this._w=l*u*f+h*d*p;break;default:Q("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],s=e[8],r=e[1],o=e[5],a=e[9],l=e[2],u=e[6],f=e[10],h=n+o+f;if(h>0){let d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-a)*d,this._y=(s-l)*d,this._z=(r-i)*d}else if(n>o&&n>f){let d=2*Math.sqrt(1+n-o-f);this._w=(u-a)/d,this._x=.25*d,this._y=(i+r)/d,this._z=(s+l)/d}else if(o>f){let d=2*Math.sqrt(1+o-n-f);this._w=(s-l)/d,this._x=(i+r)/d,this._y=.25*d,this._z=(a+u)/d}else{let d=2*Math.sqrt(1+f-n-o);this._w=(r-i)/d,this._x=(s+l)/d,this._y=(a+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(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=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(U(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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){let n=t._x,i=t._y,s=t._z,r=t._w,o=e._x,a=e._y,l=e._z,u=e._w;return this._x=n*u+r*o+i*l-s*a,this._y=i*u+r*a+s*o-n*l,this._z=s*u+r*l+n*a-i*o,this._w=r*u-n*o-i*a-s*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,s=t._z,r=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,s=-s,r=-r,o=-o);let a=1-e;if(o<.9995){let l=Math.acos(o),u=Math.sin(l);a=Math.sin(a*l)/u,e=Math.sin(e*l)/u,this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+s*e,this._w=this._w*a+r*e,this._onChangeCallback()}else this._x=this._x*a+n*e,this._y=this._y*a+i*e,this._z=this._z*a+s*e,this._w=this._w*a+r*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*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}},M=class c{static{c.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,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(ys.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ys.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,s=t.elements,r=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*r,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*r,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*r,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,s=t.x,r=t.y,o=t.z,a=t.w,l=2*(r*i-o*n),u=2*(o*e-s*i),f=2*(s*n-r*e);return this.x=e+a*l+r*f-o*u,this.y=n+a*u+o*l-s*f,this.z=i+a*f+s*u-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){let e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this.z=U(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this.z=U(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=i*a-s*o,this.y=s*r-n*a,this.z=n*o-i*r,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Jn.copy(this).projectOnVector(t),this.sub(Jn)}reflect(t){return this.sub(Jn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(U(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Jn=new M,ys=new Lt,N=class c{static{c.prototype.isMatrix3=!0}constructor(t,e,n,i,s,r,o,a,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,r,o,a,l)}set(t,e,n,i,s,r,o,a,l){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=s,u[5]=a,u[6]=n,u[7]=r,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let 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){let n=t.elements,i=e.elements,s=this.elements,r=n[0],o=n[3],a=n[6],l=n[1],u=n[4],f=n[7],h=n[2],d=n[5],p=n[8],m=i[0],_=i[3],g=i[6],x=i[1],y=i[4],S=i[7],v=i[2],b=i[5],T=i[8];return s[0]=r*m+o*x+a*v,s[3]=r*_+o*y+a*b,s[6]=r*g+o*S+a*T,s[1]=l*m+u*x+f*v,s[4]=l*_+u*y+f*b,s[7]=l*g+u*S+f*T,s[2]=h*m+d*x+p*v,s[5]=h*_+d*y+p*b,s[8]=h*g+d*S+p*T,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8];return e*r*u-e*o*l-n*s*u+n*o*a+i*s*l-i*r*a}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8],f=u*r-o*l,h=o*a-u*s,d=l*s-r*a,p=e*f+n*h+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return t[0]=f*m,t[1]=(i*l-u*n)*m,t[2]=(o*n-i*r)*m,t[3]=h*m,t[4]=(u*e-i*a)*m,t[5]=(i*s-o*e)*m,t[6]=d*m,t[7]=(n*a-l*e)*m,t[8]=(r*e-n*s)*m,this}transpose(){let t,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){let 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,n,i,s,r,o){let a=Math.cos(s),l=Math.sin(s);return this.set(n*a,n*l,-n*(a*r+l*o)+r+t,-i*l,i*a,-i*(-l*r+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply($n.makeScale(t,e)),this}rotate(t){return this.premultiply($n.makeRotation(-t)),this}translate(t,e){return this.premultiply($n.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){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},$n=new N,vs=new N().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ms=new N().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function kr(){let c={enabled:!0,workingColorSpace:wi,spaces:{},convert:function(i,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===cn&&(i.r=It(i.r),i.g=It(i.g),i.b=It(i.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===cn&&(i.r=he(i.r),i.g=he(i.g),i.b=he(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===qi?Ci:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,r){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return Li("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),c.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return Li("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),c.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return c.define({[wi]:{primaries:t,whitePoint:n,transfer:Ci,toXYZ:vs,fromXYZ:Ms,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:_t},outputColorSpaceConfig:{drawingBufferColorSpace:_t}},[_t]:{primaries:t,whitePoint:n,transfer:cn,toXYZ:vs,fromXYZ:Ms,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:_t}}}),c}var gt=kr();function It(c){return c<.04045?c*.0773993808:Math.pow(c*.9478672986+.0521327014,2.4)}function he(c){return c<.0031308?c*12.92:1.055*Math.pow(c,.41666)-.055}var jt,hn=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{jt===void 0&&(jt=Ii("canvas")),jt.width=t.width,jt.height=t.height;let i=jt.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=jt}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=Ii("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let r=0;r<s.length;r++)s[r]=It(s[r]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(It(e[n]/255)*255):e[n]=It(e[n]);return{data:e,width:t.width,height:t.height}}else return Q("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Gr=0,fn=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gr++}),this.uuid=Cn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?s.push(Kn(i[r].image)):s.push(Kn(i[r]))}else s=Kn(i);n.url=s}return e||(t.images[this.uuid]=n),n}};function Kn(c){return typeof HTMLImageElement<"u"&&c instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&c instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&c instanceof ImageBitmap?hn.getDataURL(c):c.data?{data:Array.from(c.data),width:c.width,height:c.height,type:c.data.constructor.name}:(Q("Texture: Unable to serialize Texture."),{})}var Hr=0,Qn=new M,fe=class c extends Yt{constructor(t=c.DEFAULT_IMAGE,e=c.DEFAULT_MAPPING,n=Ie,i=Ie,s=zs,r=Vs,o=Hs,a=ks,l=c.DEFAULT_ANISOTROPY,u=qi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hr++}),this.uuid=Cn(),this.name="",this.source=new fn(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=a,this.offset=new H(0,0),this.repeat=new H(1,1),this.center=new H(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new N,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Qn).x}get height(){return this.source.getSize(Qn).y}get depth(){return this.source.getSize(Qn).z}get image(){return this.source.data}set image(t){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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.normalized=t.normalized,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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){Q(\`Texture.setValues(): parameter '\${e}' has value of undefined.\`);continue}let i=this[e];if(i===void 0){Q(\`Texture.setValues(): property '\${e}' does not exist.\`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,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,normalized:this.normalized,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&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Wi)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Mi:t.x=t.x-Math.floor(t.x);break;case Ie:t.x=t.x<0?0:1;break;case Si: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 Mi:t.y=t.y-Math.floor(t.y);break;case Ie:t.y=t.y<0?0:1;break;case Si: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++}};fe.DEFAULT_IMAGE=null;fe.DEFAULT_MAPPING=Wi;fe.DEFAULT_ANISOTROPY=1;var de=class c{static{c.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}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,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,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){let e=this.x,n=this.y,i=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i+r[12]*s,this.y=r[1]*e+r[5]*n+r[9]*i+r[13]*s,this.z=r[2]*e+r[6]*n+r[10]*i+r[14]*s,this.w=r[3]*e+r[7]*n+r[11]*i+r[15]*s,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);let 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,n,i,s,a=t.elements,l=a[0],u=a[4],f=a[8],h=a[1],d=a[5],p=a[9],m=a[2],_=a[6],g=a[10];if(Math.abs(u-h)<.01&&Math.abs(f-m)<.01&&Math.abs(p-_)<.01){if(Math.abs(u+h)<.1&&Math.abs(f+m)<.1&&Math.abs(p+_)<.1&&Math.abs(l+d+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let y=(l+1)/2,S=(d+1)/2,v=(g+1)/2,b=(u+h)/4,T=(f+m)/4,A=(p+_)/4;return y>S&&y>v?y<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(y),i=b/n,s=T/n):S>v?S<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(S),n=b/i,s=A/i):v<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(v),n=T/s,i=A/s),this.set(n,i,s,e),this}let x=Math.sqrt((_-p)*(_-p)+(f-m)*(f-m)+(h-u)*(h-u));return Math.abs(x)<.001&&(x=1),this.x=(_-p)/x,this.y=(f-m)/x,this.z=(h-u)/x,this.w=Math.acos((l+d+g-1)/2),this}setFromMatrixPosition(t){let 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=U(this.x,t.x,e.x),this.y=U(this.y,t.y,e.y),this.z=U(this.z,t.z,e.z),this.w=U(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=U(this.x,t,e),this.y=U(this.y,t,e),this.z=U(this.z,t,e),this.w=U(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(U(n,t,e))}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,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,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}};var W=class c{static{c.prototype.isMatrix4=!0}constructor(t,e,n,i,s,r,o,a,l,u,f,h,d,p,m,_){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,n,i,s,r,o,a,l,u,f,h,d,p,m,_)}set(t,e,n,i,s,r,o,a,l,u,f,h,d,p,m,_){let g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=s,g[5]=r,g[9]=o,g[13]=a,g[2]=l,g[6]=u,g[10]=f,g[14]=h,g[3]=d,g[7]=p,g[11]=m,g[15]=_,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 c().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let 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,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();let e=this.elements,n=t.elements,i=1/te.setFromMatrixColumn(t,0).length(),s=1/te.setFromMatrixColumn(t,1).length(),r=1/te.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,s=t.z,r=Math.cos(n),o=Math.sin(n),a=Math.cos(i),l=Math.sin(i),u=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){let h=r*u,d=r*f,p=o*u,m=o*f;e[0]=a*u,e[4]=-a*f,e[8]=l,e[1]=d+p*l,e[5]=h-m*l,e[9]=-o*a,e[2]=m-h*l,e[6]=p+d*l,e[10]=r*a}else if(t.order==="YXZ"){let h=a*u,d=a*f,p=l*u,m=l*f;e[0]=h+m*o,e[4]=p*o-d,e[8]=r*l,e[1]=r*f,e[5]=r*u,e[9]=-o,e[2]=d*o-p,e[6]=m+h*o,e[10]=r*a}else if(t.order==="ZXY"){let h=a*u,d=a*f,p=l*u,m=l*f;e[0]=h-m*o,e[4]=-r*f,e[8]=p+d*o,e[1]=d+p*o,e[5]=r*u,e[9]=m-h*o,e[2]=-r*l,e[6]=o,e[10]=r*a}else if(t.order==="ZYX"){let h=r*u,d=r*f,p=o*u,m=o*f;e[0]=a*u,e[4]=p*l-d,e[8]=h*l+m,e[1]=a*f,e[5]=m*l+h,e[9]=d*l-p,e[2]=-l,e[6]=o*a,e[10]=r*a}else if(t.order==="YZX"){let h=r*a,d=r*l,p=o*a,m=o*l;e[0]=a*u,e[4]=m-h*f,e[8]=p*f+d,e[1]=f,e[5]=r*u,e[9]=-o*u,e[2]=-l*u,e[6]=d*f+p,e[10]=h-m*f}else if(t.order==="XZY"){let h=r*a,d=r*l,p=o*a,m=o*l;e[0]=a*u,e[4]=-f,e[8]=l*u,e[1]=h*f+m,e[5]=r*u,e[9]=d*f-p,e[2]=p*f-d,e[6]=o*u,e[10]=m*f+h}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(Wr,t,Xr)}lookAt(t,e,n){let i=this.elements;return ft.subVectors(t,e),ft.lengthSq()===0&&(ft.z=1),ft.normalize(),Nt.crossVectors(n,ft),Nt.lengthSq()===0&&(Math.abs(n.z)===1?ft.x+=1e-4:ft.z+=1e-4,ft.normalize(),Nt.crossVectors(n,ft)),Nt.normalize(),Ke.crossVectors(ft,Nt),i[0]=Nt.x,i[4]=Ke.x,i[8]=ft.x,i[1]=Nt.y,i[5]=Ke.y,i[9]=ft.y,i[2]=Nt.z,i[6]=Ke.z,i[10]=ft.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,s=this.elements,r=n[0],o=n[4],a=n[8],l=n[12],u=n[1],f=n[5],h=n[9],d=n[13],p=n[2],m=n[6],_=n[10],g=n[14],x=n[3],y=n[7],S=n[11],v=n[15],b=i[0],T=i[4],A=i[8],E=i[12],C=i[1],R=i[5],w=i[9],P=i[13],L=i[2],D=i[6],O=i[10],it=i[14],Tt=i[3],At=i[7],Je=i[11],$e=i[15];return s[0]=r*b+o*C+a*L+l*Tt,s[4]=r*T+o*R+a*D+l*At,s[8]=r*A+o*w+a*O+l*Je,s[12]=r*E+o*P+a*it+l*$e,s[1]=u*b+f*C+h*L+d*Tt,s[5]=u*T+f*R+h*D+d*At,s[9]=u*A+f*w+h*O+d*Je,s[13]=u*E+f*P+h*it+d*$e,s[2]=p*b+m*C+_*L+g*Tt,s[6]=p*T+m*R+_*D+g*At,s[10]=p*A+m*w+_*O+g*Je,s[14]=p*E+m*P+_*it+g*$e,s[3]=x*b+y*C+S*L+v*Tt,s[7]=x*T+y*R+S*D+v*At,s[11]=x*A+y*w+S*O+v*Je,s[15]=x*E+y*P+S*it+v*$e,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],r=t[1],o=t[5],a=t[9],l=t[13],u=t[2],f=t[6],h=t[10],d=t[14],p=t[3],m=t[7],_=t[11],g=t[15],x=a*d-l*h,y=o*d-l*f,S=o*h-a*f,v=r*d-l*u,b=r*h-a*u,T=r*f-o*u;return e*(m*x-_*y+g*S)-n*(p*x-_*v+g*b)+i*(p*y-m*v+g*T)-s*(p*S-m*b+_*T)}transpose(){let t=this.elements,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,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],r=t[4],o=t[5],a=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],m=t[13],_=t[14],g=t[15],x=e*o-n*r,y=e*a-i*r,S=e*l-s*r,v=n*a-i*o,b=n*l-s*o,T=i*l-s*a,A=u*m-f*p,E=u*_-h*p,C=u*g-d*p,R=f*_-h*m,w=f*g-d*m,P=h*g-d*_,L=x*P-y*w+S*R+v*C-b*E+T*A;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let D=1/L;return t[0]=(o*P-a*w+l*R)*D,t[1]=(i*w-n*P-s*R)*D,t[2]=(m*T-_*b+g*v)*D,t[3]=(h*b-f*T-d*v)*D,t[4]=(a*C-r*P-l*E)*D,t[5]=(e*P-i*C+s*E)*D,t[6]=(_*S-p*T-g*y)*D,t[7]=(u*T-h*S+d*y)*D,t[8]=(r*w-o*C+l*A)*D,t[9]=(n*C-e*w-s*A)*D,t[10]=(p*b-m*S+g*x)*D,t[11]=(f*S-u*b-d*x)*D,t[12]=(o*E-r*R-a*A)*D,t[13]=(e*R-n*E+i*A)*D,t[14]=(m*y-p*v-_*x)*D,t[15]=(u*v-f*y+h*x)*D,this}scale(t){let e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){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,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),s=1-n,r=t.x,o=t.y,a=t.z,l=s*r,u=s*o;return this.set(l*r+n,l*o-i*a,l*a+i*o,0,l*o+i*a,u*o+n,u*a-i*r,0,l*a-i*o,u*a+i*r,s*a*a+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,r){return this.set(1,n,s,0,t,1,r,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,s=e._x,r=e._y,o=e._z,a=e._w,l=s+s,u=r+r,f=o+o,h=s*l,d=s*u,p=s*f,m=r*u,_=r*f,g=o*f,x=a*l,y=a*u,S=a*f,v=n.x,b=n.y,T=n.z;return i[0]=(1-(m+g))*v,i[1]=(d+S)*v,i[2]=(p-y)*v,i[3]=0,i[4]=(d-S)*b,i[5]=(1-(h+g))*b,i[6]=(_+x)*b,i[7]=0,i[8]=(p+y)*T,i[9]=(_-x)*T,i[10]=(1-(h+m))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];let s=this.determinant();if(s===0)return n.set(1,1,1),e.identity(),this;let r=te.set(i[0],i[1],i[2]).length(),o=te.set(i[4],i[5],i[6]).length(),a=te.set(i[8],i[9],i[10]).length();s<0&&(r=-r),yt.copy(this);let l=1/r,u=1/o,f=1/a;return yt.elements[0]*=l,yt.elements[1]*=l,yt.elements[2]*=l,yt.elements[4]*=u,yt.elements[5]*=u,yt.elements[6]*=u,yt.elements[8]*=f,yt.elements[9]*=f,yt.elements[10]*=f,e.setFromRotationMatrix(yt),n.x=r,n.y=o,n.z=a,this}makePerspective(t,e,n,i,s,r,o=Le,a=!1){let l=this.elements,u=2*s/(e-t),f=2*s/(n-i),h=(e+t)/(e-t),d=(n+i)/(n-i),p,m;if(a)p=s/(r-s),m=r*s/(r-s);else if(o===Le)p=-(r+s)/(r-s),m=-2*r*s/(r-s);else if(o===Pi)p=-r/(r-s),m=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=f,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,r,o=Le,a=!1){let l=this.elements,u=2/(e-t),f=2/(n-i),h=-(e+t)/(e-t),d=-(n+i)/(n-i),p,m;if(a)p=1/(r-s),m=r/(r-s);else if(o===Le)p=-2/(r-s),m=-(r+s)/(r-s);else if(o===Pi)p=-1/(r-s),m=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=f,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},te=new M,yt=new W,Wr=new M(0,0,0),Xr=new M(1,1,1),Nt=new M,Ke=new M,ft=new M,Ss=new W,bs=new Lt,Ne=class c{constructor(t=0,e=0,n=0,i=c.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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,n=!0){let i=t.elements,s=i[0],r=i[4],o=i[8],a=i[1],l=i[5],u=i[9],f=i[2],h=i[6],d=i[10];switch(e){case"XYZ":this._y=Math.asin(U(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-U(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(U(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-f,d),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(a,s));break;case"ZYX":this._y=Math.asin(-U(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(a,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(U(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-U(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:Q("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ss.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ss,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return bs.setFromEuler(this),this.setFromQuaternion(bs,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}};Ne.DEFAULT_ORDER="XYZ";var dn=class{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}},qr=0,Ts=new M,ee=new Lt,wt=new W,Qe=new M,we=new M,Yr=new M,Zr=new Lt,As=new M(1,0,0),Es=new M(0,1,0),ws=new M(0,0,1),Cs={type:"added"},Jr={type:"removed"},ne={type:"childadded",child:null},jn={type:"childremoved",child:null},Zt=class c extends Yt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qr++}),this.uuid=Cn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DEFAULT_UP.clone();let t=new M,e=new Ne,n=new Lt,i=new M(1,1,1);function s(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._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:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new W},normalMatrix:{value:new N}}),this.matrix=new W,this.matrixWorld=new W,this.matrixAutoUpdate=c.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=c.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}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 ee.setFromAxisAngle(t,e),this.quaternion.multiply(ee),this}rotateOnWorldAxis(t,e){return ee.setFromAxisAngle(t,e),this.quaternion.premultiply(ee),this}rotateX(t){return this.rotateOnAxis(As,t)}rotateY(t){return this.rotateOnAxis(Es,t)}rotateZ(t){return this.rotateOnAxis(ws,t)}translateOnAxis(t,e){return Ts.copy(t).applyQuaternion(this.quaternion),this.position.add(Ts.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(As,t)}translateY(t){return this.translateOnAxis(Es,t)}translateZ(t){return this.translateOnAxis(ws,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(wt.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Qe.copy(t):Qe.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),we.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?wt.lookAt(we,Qe,this.up):wt.lookAt(Qe,we,this.up),this.quaternion.setFromRotationMatrix(wt),i&&(wt.extractRotation(i.matrixWorld),ee.setFromRotationMatrix(wt),this.quaternion.premultiply(ee.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(G("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(Cs),ne.child=t,this.dispatchEvent(ne),ne.child=null):G("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Jr),jn.child=t,this.dispatchEvent(jn),jn.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),wt.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),wt.multiply(t.parent.matrixWorld)),t.applyMatrix4(wt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Cs),ne.child=t,this.dispatchEvent(ne),ne.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 n=0,i=this.children.length;n<i;n++){let r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,t,Yr),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(we,Zr,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let e=t.x,n=t.y,i=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*i,s[13]+=n-s[1]*e-s[5]*n-s[9]*i,s[14]+=i-s[2]*e-s[6]*n-s[10]*i}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);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.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){let i=this.children;for(let s=0,r=i.length;s<r;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,a){return o[a.uuid]===void 0&&(o[a.uuid]=a.toJSON(t)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let a=o.shapes;if(Array.isArray(a))for(let l=0,u=a.length;l<u;l++){let f=a[l];s(t.shapes,f)}else s(t.shapes,a)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let a=0,l=this.material.length;a<l;a++)o.push(s(t.materials,this.material[a]));i.material=o}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){let a=this.animations[o];i.animations.push(s(t.animations,a))}}if(e){let o=r(t.geometries),a=r(t.materials),l=r(t.textures),u=r(t.images),f=r(t.shapes),h=r(t.skeletons),d=r(t.animations),p=r(t.nodes);o.length>0&&(n.geometries=o),a.length>0&&(n.materials=a),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),h.length>0&&(n.skeletons=h),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function r(o){let a=[];for(let l in o){let u=o[l];delete u.metadata,a.push(u)}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.pivot=t.pivot!==null?t.pivot.clone():null,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.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};Zt.DEFAULT_UP=new M(0,1,0);Zt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Zt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var 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},Ut={h:0,s:0,l:0},je={h:0,s:0,l:0};function ti(c,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?c+(t-c)*6*e:e<1/2?t:e<2/3?c+(t-c)*6*(2/3-e):c}var j=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=_t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,gt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=gt.workingColorSpace){return this.r=t,this.g=e,this.b=n,gt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=gt.workingColorSpace){if(t=Vr(t,1),e=U(e,0,1),n=U(n,0,1),e===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+e):n+e-n*e,r=2*n-s;this.r=ti(r,s,t+1/3),this.g=ti(r,s,t),this.b=ti(r,s,t-1/3)}return gt.colorSpaceToWorking(this,i),this}setStyle(t,e=_t){function n(s){s!==void 0&&parseFloat(s)<1&&Q("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\\w+)\\(([^\\)]*)\\)/.exec(t)){let s,r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(s=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Q("Color: Unknown color model "+t)}}else if(i=/^\\#([A-Fa-f\\d]+)$/.exec(t)){let s=i[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(s,16),e);Q("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=_t){let n=Xs[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Q("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=It(t.r),this.g=It(t.g),this.b=It(t.b),this}copyLinearToSRGB(t){return this.r=he(t.r),this.g=he(t.g),this.b=he(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=_t){return gt.workingToColorSpace(rt.copy(this),t),Math.round(U(rt.r*255,0,255))*65536+Math.round(U(rt.g*255,0,255))*256+Math.round(U(rt.b*255,0,255))}getHexString(t=_t){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=gt.workingColorSpace){gt.workingToColorSpace(rt.copy(this),e);let n=rt.r,i=rt.g,s=rt.b,r=Math.max(n,i,s),o=Math.min(n,i,s),a,l,u=(o+r)/2;if(o===r)a=0,l=0;else{let f=r-o;switch(l=u<=.5?f/(r+o):f/(2-r-o),r){case n:a=(i-s)/f+(i<s?6:0);break;case i:a=(s-n)/f+2;break;case s:a=(n-i)/f+4;break}a/=6}return t.h=a,t.s=l,t.l=u,t}getRGB(t,e=gt.workingColorSpace){return gt.workingToColorSpace(rt.copy(this),e),t.r=rt.r,t.g=rt.g,t.b=rt.b,t}getStyle(t=_t){gt.workingToColorSpace(rt.copy(this),t);let e=rt.r,n=rt.g,i=rt.b;return t!==_t?\`color(\${t} \${e.toFixed(3)} \${n.toFixed(3)} \${i.toFixed(3)})\`:\`rgb(\${Math.round(e*255)},\${Math.round(n*255)},\${Math.round(i*255)})\`}offsetHSL(t,e,n){return this.getHSL(Ut),this.setHSL(Ut.h+t,Ut.s+e,Ut.l+n)}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,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Ut),t.getHSL(je);let n=Zn(Ut.h,je.h,e),i=Zn(Ut.s,je.s,e),s=Zn(Ut.l,je.l,e);return this.setHSL(n,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*i,this.g=s[1]*e+s[4]*n+s[7]*i,this.b=s[2]*e+s[5]*n+s[8]*i,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}},rt=new j;j.NAMES=Xs;var vt=new M,Ct=new M,ei=new M,Rt=new M,ie=new M,se=new M,Rs=new M,ni=new M,ii=new M,si=new M,ri=new de,oi=new de,ai=new de,St=class c{constructor(t=new M,e=new M,n=new M){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),vt.subVectors(t,e),i.cross(vt);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){vt.subVectors(i,e),Ct.subVectors(n,e),ei.subVectors(t,e);let r=vt.dot(vt),o=vt.dot(Ct),a=vt.dot(ei),l=Ct.dot(Ct),u=Ct.dot(ei),f=r*l-o*o;if(f===0)return s.set(0,0,0),null;let h=1/f,d=(l*a-o*u)*h,p=(r*u-o*a)*h;return s.set(1-d-p,p,d)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Rt)===null?!1:Rt.x>=0&&Rt.y>=0&&Rt.x+Rt.y<=1}static getInterpolation(t,e,n,i,s,r,o,a){return this.getBarycoord(t,e,n,i,Rt)===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(s,Rt.x),a.addScaledVector(r,Rt.y),a.addScaledVector(o,Rt.z),a)}static getInterpolatedAttribute(t,e,n,i,s,r){return ri.setScalar(0),oi.setScalar(0),ai.setScalar(0),ri.fromBufferAttribute(t,e),oi.fromBufferAttribute(t,n),ai.fromBufferAttribute(t,i),r.setScalar(0),r.addScaledVector(ri,s.x),r.addScaledVector(oi,s.y),r.addScaledVector(ai,s.z),r}static isFrontFacing(t,e,n,i){return vt.subVectors(n,e),Ct.subVectors(t,e),vt.cross(Ct).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 vt.subVectors(this.c,this.b),Ct.subVectors(this.a,this.b),vt.cross(Ct).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return c.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return c.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return c.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return c.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return c.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,s=this.c,r,o;ie.subVectors(i,n),se.subVectors(s,n),ni.subVectors(t,n);let a=ie.dot(ni),l=se.dot(ni);if(a<=0&&l<=0)return e.copy(n);ii.subVectors(t,i);let u=ie.dot(ii),f=se.dot(ii);if(u>=0&&f<=u)return e.copy(i);let h=a*f-u*l;if(h<=0&&a>=0&&u<=0)return r=a/(a-u),e.copy(n).addScaledVector(ie,r);si.subVectors(t,s);let d=ie.dot(si),p=se.dot(si);if(p>=0&&d<=p)return e.copy(s);let m=d*l-a*p;if(m<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(n).addScaledVector(se,o);let _=u*p-d*f;if(_<=0&&f-u>=0&&d-p>=0)return Rs.subVectors(s,i),o=(f-u)/(f-u+(d-p)),e.copy(i).addScaledVector(Rs,o);let g=1/(_+m+h);return r=m*g,o=h*g,e.copy(n).addScaledVector(ie,r).addScaledVector(se,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},X=class{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,n=t.length;e<n;e+=3)this.expandByPoint(Mt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Mt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=Mt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),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);let n=t.geometry;if(n!==void 0){let s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,Mt):Mt.fromBufferAttribute(s,r),Mt.applyMatrix4(t.matrixWorld),this.expandByPoint(Mt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),tn.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),tn.copy(n.boundingBox)),tn.applyMatrix4(t.matrixWorld),this.union(tn)}let i=t.children;for(let s=0,r=i.length;s<r;s++)this.expandByObject(i[s],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,Mt),Mt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ce),en.subVectors(this.max,Ce),re.subVectors(t.a,Ce),oe.subVectors(t.b,Ce),ae.subVectors(t.c,Ce),Ft.subVectors(oe,re),Bt.subVectors(ae,oe),Xt.subVectors(re,ae);let e=[0,-Ft.z,Ft.y,0,-Bt.z,Bt.y,0,-Xt.z,Xt.y,Ft.z,0,-Ft.x,Bt.z,0,-Bt.x,Xt.z,0,-Xt.x,-Ft.y,Ft.x,0,-Bt.y,Bt.x,0,-Xt.y,Xt.x,0];return!ci(e,re,oe,ae,en)||(e=[1,0,0,0,1,0,0,0,1],!ci(e,re,oe,ae,en))?!1:(nn.crossVectors(Ft,Bt),e=[nn.x,nn.y,nn.z],ci(e,re,oe,ae,en))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Mt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Mt).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:(Pt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pt),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Pt=[new M,new M,new M,new M,new M,new M,new M,new M],Mt=new M,tn=new X,re=new M,oe=new M,ae=new M,Ft=new M,Bt=new M,Xt=new M,Ce=new M,en=new M,nn=new M,qt=new M;function ci(c,t,e,n,i){for(let s=0,r=c.length-3;s<=r;s+=3){qt.fromArray(c,s);let o=i.x*Math.abs(qt.x)+i.y*Math.abs(qt.y)+i.z*Math.abs(qt.z),a=t.dot(qt),l=e.dot(qt),u=n.dot(qt);if(Math.max(-Math.max(a,l,u),Math.min(a,l,u))>o)return!1}return!0}var J=new M,sn=new H,$r=0,ot=class extends Yt{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$r++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Ri,this.updateRanges=[],this.gpuType=Gs,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,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyMatrix3(t),this.setXY(e,sn.x,sn.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyMatrix3(t),this.setXYZ(e,J.x,J.y,J.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyMatrix4(t),this.setXYZ(e,J.x,J.y,J.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.applyNormalMatrix(t),this.setXYZ(e,J.x,J.y,J.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)J.fromBufferAttribute(this,e),J.transformDirection(t),this.setXYZ(e,J.x,J.y,J.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ee(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ut(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ee(e,this.array)),e}setX(t,e){return this.normalized&&(e=ut(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ee(e,this.array)),e}setY(t,e){return this.normalized&&(e=ut(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=Ee(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ut(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=Ee(e,this.array)),e}setW(t,e){return this.normalized&&(e=ut(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,s){return t*=this.itemSize,this.normalized&&(e=ut(e,this.array),n=ut(n,this.array),i=ut(i,this.array),s=ut(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==Ri&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}};var pn=class extends ot{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var mn=class extends ot{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var gn=class extends ot{constructor(t,e,n){super(new Float32Array(t),e,n)}},Kr=new X,Re=new M,li=new M,pe=class{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){let n=this.center;e!==void 0?n.copy(e):Kr.setFromPoints(t).getCenter(n);let i=0;for(let s=0,r=t.length;s<r;s++)i=Math.max(i,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),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){let 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){let n=this.center.distanceToSquared(t);return e.copy(t),n>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;Re.subVectors(t,this.center);let e=Re.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Re,i/n),this.radius+=i}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):(li.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Re.copy(t.center).add(li)),this.expandByPoint(Re.copy(t.center).sub(li))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},Qr=0,mt=new W,ui=new Zt,ce=new M,dt=new X,Pe=new X,K=new M,Ue=class c extends Yt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qr++}),this.uuid=Cn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(Fr(t)?mn:pn)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,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,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new N().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return mt.makeRotationFromQuaternion(t),this.applyMatrix4(mt),this}rotateX(t){return mt.makeRotationX(t),this.applyMatrix4(mt),this}rotateY(t){return mt.makeRotationY(t),this.applyMatrix4(mt),this}rotateZ(t){return mt.makeRotationZ(t),this.applyMatrix4(mt),this}translate(t,e,n){return mt.makeTranslation(t,e,n),this.applyMatrix4(mt),this}scale(t,e,n){return mt.makeScale(t,e,n),this.applyMatrix4(mt),this}lookAt(t){return ui.lookAt(t),ui.updateMatrix(),this.applyMatrix4(ui.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ce).negate(),this.translate(ce.x,ce.y,ce.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,s=t.length;i<s;i++){let r=t[i];n.push(r.x,r.y,r.z||0)}this.setAttribute("position",new gn(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&Q("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 X);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){G("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 n=0,i=e.length;n<i;n++){let s=e[n];dt.setFromBufferAttribute(s),this.morphTargetsRelative?(K.addVectors(this.boundingBox.min,dt.min),this.boundingBox.expandByPoint(K),K.addVectors(this.boundingBox.max,dt.max),this.boundingBox.expandByPoint(K)):(this.boundingBox.expandByPoint(dt.min),this.boundingBox.expandByPoint(dt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&G('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);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){G("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new M,1/0);return}if(t){let n=this.boundingSphere.center;if(dt.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){let o=e[s];Pe.setFromBufferAttribute(o),this.morphTargetsRelative?(K.addVectors(dt.min,Pe.min),dt.expandByPoint(K),K.addVectors(dt.max,Pe.max),dt.expandByPoint(K)):(dt.expandByPoint(Pe.min),dt.expandByPoint(Pe.max))}dt.getCenter(n);let i=0;for(let s=0,r=t.count;s<r;s++)K.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(K));if(e)for(let s=0,r=e.length;s<r;s++){let o=e[s],a=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)K.fromBufferAttribute(o,l),a&&(ce.fromBufferAttribute(t,l),K.add(ce)),i=Math.max(i,n.distanceToSquared(K))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&G('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){G("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ot(new Float32Array(4*n.count),4));let r=this.getAttribute("tangent"),o=[],a=[];for(let A=0;A<n.count;A++)o[A]=new M,a[A]=new M;let l=new M,u=new M,f=new M,h=new H,d=new H,p=new H,m=new M,_=new M;function g(A,E,C){l.fromBufferAttribute(n,A),u.fromBufferAttribute(n,E),f.fromBufferAttribute(n,C),h.fromBufferAttribute(s,A),d.fromBufferAttribute(s,E),p.fromBufferAttribute(s,C),u.sub(l),f.sub(l),d.sub(h),p.sub(h);let R=1/(d.x*p.y-p.x*d.y);isFinite(R)&&(m.copy(u).multiplyScalar(p.y).addScaledVector(f,-d.y).multiplyScalar(R),_.copy(f).multiplyScalar(d.x).addScaledVector(u,-p.x).multiplyScalar(R),o[A].add(m),o[E].add(m),o[C].add(m),a[A].add(_),a[E].add(_),a[C].add(_))}let x=this.groups;x.length===0&&(x=[{start:0,count:t.count}]);for(let A=0,E=x.length;A<E;++A){let C=x[A],R=C.start,w=C.count;for(let P=R,L=R+w;P<L;P+=3)g(t.getX(P+0),t.getX(P+1),t.getX(P+2))}let y=new M,S=new M,v=new M,b=new M;function T(A){v.fromBufferAttribute(i,A),b.copy(v);let E=o[A];y.copy(E),y.sub(v.multiplyScalar(v.dot(E))).normalize(),S.crossVectors(b,E);let R=S.dot(a[A])<0?-1:1;r.setXYZW(A,y.x,y.y,y.z,R)}for(let A=0,E=x.length;A<E;++A){let C=x[A],R=C.start,w=C.count;for(let P=R,L=R+w;P<L;P+=3)T(t.getX(P+0)),T(t.getX(P+1)),T(t.getX(P+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ot(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);let i=new M,s=new M,r=new M,o=new M,a=new M,l=new M,u=new M,f=new M;if(t)for(let h=0,d=t.count;h<d;h+=3){let p=t.getX(h+0),m=t.getX(h+1),_=t.getX(h+2);i.fromBufferAttribute(e,p),s.fromBufferAttribute(e,m),r.fromBufferAttribute(e,_),u.subVectors(r,s),f.subVectors(i,s),u.cross(f),o.fromBufferAttribute(n,p),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,_),o.add(u),a.add(u),l.add(u),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let h=0,d=e.count;h<d;h+=3)i.fromBufferAttribute(e,h+0),s.fromBufferAttribute(e,h+1),r.fromBufferAttribute(e,h+2),u.subVectors(r,s),f.subVectors(i,s),u.cross(f),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)K.fromBufferAttribute(t,e),K.normalize(),t.setXYZ(e,K.x,K.y,K.z)}toNonIndexed(){function t(o,a){let l=o.array,u=o.itemSize,f=o.normalized,h=new l.constructor(a.length*u),d=0,p=0;for(let m=0,_=a.length;m<_;m++){o.isInterleavedBufferAttribute?d=a[m]*o.data.stride+o.offset:d=a[m]*u;for(let g=0;g<u;g++)h[p++]=l[d++]}return new ot(h,u,f)}if(this.index===null)return Q("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new c,n=this.index.array,i=this.attributes;for(let o in i){let a=i[o],l=t(a,n);e.setAttribute(o,l)}let s=this.morphAttributes;for(let o in s){let a=[],l=s[o];for(let u=0,f=l.length;u<f;u++){let h=l[u],d=t(h,n);a.push(d)}e.morphAttributes[o]=a}e.morphTargetsRelative=this.morphTargetsRelative;let r=this.groups;for(let o=0,a=r.length;o<a;o++){let l=r[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,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){let a=this.parameters;for(let l in a)a[l]!==void 0&&(t[l]=a[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let a in n){let l=n[a];t.data.attributes[a]=l.toJSON(t.data)}let i={},s=!1;for(let a in this.morphAttributes){let l=this.morphAttributes[a],u=[];for(let f=0,h=l.length;f<h;f++){let d=l[f];u.push(d.toJSON(t.data))}u.length>0&&(i[a]=u,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let i=t.attributes;for(let l in i){let u=i[l];this.setAttribute(l,u.clone(e))}let s=t.morphAttributes;for(let l in s){let u=[],f=s[l];for(let h=0,d=f.length;h<d;h++)u.push(f[h].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;let r=t.groups;for(let l=0,u=r.length;l<u;l++){let f=r[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let 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"})}};var hi=new M,jr=new M,to=new N,Jt=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,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=hi.subVectors(n,e).cross(jr.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let 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,n=!0){let i=t.delta(hi),s=this.normal.dot(i);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return n===!0&&(r<0||r>1)?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<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){let n=e||to.getNormalMatrix(t),i=this.coplanarPoint(hi).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),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)}};function qs(c){let t={};for(let e in c){t[e]={};for(let n in c[e]){let i=c[e][n];if(Ps(i))i.isRenderTargetTexture?(Q("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(Ps(i[0])){let s=[];for(let r=0,o=i.length;r<o;r++)s[r]=i[r].clone();t[e][n]=s}else t[e][n]=i.slice();else t[e][n]=i}}return t}function ct(c){let t={};for(let e=0;e<c.length;e++){let n=qs(c[e]);for(let i in n)t[i]=n[i]}return t}function Ps(c){return c&&(c.isColor||c.isMatrix3||c.isMatrix4||c.isVector2||c.isVector3||c.isVector4||c.isTexture||c.isQuaternion)}function rn(c,t){return!c||c.constructor===t?c:typeof t.BYTES_PER_ELEMENT=="number"?new t(c):Array.prototype.slice.call(c)}var Ot=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],s=e[n-1];n:{t:{let r;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=i,i=e[++n],t<i)break t}r=e.length;break e}if(!(t>=s)){let o=e[1];t<o&&(n=2,s=o);for(let a=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(i=s,s=e[--n-1],t>=s)break t}r=n,n=0;break e}break n}for(;n<r;){let o=n+r>>>1;t<e[o]?r=o:n=o+1}if(i=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=t*i;for(let r=0;r!==i;++r)e[r]=n[s+r];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},_n=class extends Ot{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ti,endingEnd:Ti}}intervalChanged_(t,e,n){let i=this.parameterPositions,s=t-2,r=t+1,o=i[s],a=i[r];if(o===void 0)switch(this.getSettings_().endingStart){case Ai:s=t,o=2*e-n;break;case Ei:s=i.length-2,o=e+i[s]-i[s+1];break;default:s=t,o=n}if(a===void 0)switch(this.getSettings_().endingEnd){case Ai:r=t,a=2*n-e;break;case Ei:r=1,a=n+i[1]-i[0];break;default:r=t-1,a=e}let l=(n-e)*.5,u=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(a-n),this._offsetPrev=s*u,this._offsetNext=r*u}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=this._offsetPrev,f=this._offsetNext,h=this._weightPrev,d=this._weightNext,p=(n-e)/(i-e),m=p*p,_=m*p,g=-h*_+2*h*m-h*p,x=(1+h)*_+(-1.5-2*h)*m+(-.5+h)*p+1,y=(-1-d)*_+(1.5+d)*m+.5*p,S=d*_-d*m;for(let v=0;v!==o;++v)s[v]=g*r[u+v]+x*r[l+v]+y*r[a+v]+S*r[f+v];return s}},xn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=(n-e)/(i-e),f=1-u;for(let h=0;h!==o;++h)s[h]=r[l+h]*f+r[a+h]*u;return s}},yn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},vn=class extends Ot{interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=t*o,l=a-o,u=this.settings||this.DefaultSettings_,f=u.inTangents,h=u.outTangents;if(!f||!h){let m=(n-e)/(i-e),_=1-m;for(let g=0;g!==o;++g)s[g]=r[l+g]*_+r[a+g]*m;return s}let d=o*2,p=t-1;for(let m=0;m!==o;++m){let _=r[l+m],g=r[a+m],x=p*d+m*2,y=h[x],S=h[x+1],v=t*d+m*2,b=f[v],T=f[v+1],A=(n-e)/(i-e),E,C,R,w,P;for(let L=0;L<8;L++){E=A*A,C=E*A,R=1-A,w=R*R,P=w*R;let O=P*e+3*w*A*y+3*R*E*b+C*i-n;if(Math.abs(O)<1e-10)break;let it=3*w*(y-e)+6*R*A*(b-y)+3*E*(i-b);if(Math.abs(it)<1e-10)break;A=A-O/it,A=Math.max(0,Math.min(1,A))}s[m]=P*_+3*w*A*S+3*R*E*T+C*g}return s}},pt=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=rn(e,this.TimeBufferType),this.values=rn(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:rn(t.times,Array),values:rn(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new yn(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new xn(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new _n(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new vn(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case De:e=this.InterpolantFactoryMethodDiscrete;break;case ln:e=this.InterpolantFactoryMethodLinear;break;case an:e=this.InterpolantFactoryMethodSmooth;break;case bi:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Q("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return De;case this.InterpolantFactoryMethodLinear:return ln;case this.InterpolantFactoryMethodSmooth:return an;case this.InterpolantFactoryMethodBezier:return bi}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,s=0,r=i-1;for(;s!==i&&n[s]<t;)++s;for(;r!==-1&&n[r]>e;)--r;if(++r,s!==0||r!==i){s>=r&&(r=Math.max(r,1),s=r-1);let o=this.getValueSize();this.times=n.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(G("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,s=n.length;s===0&&(G("KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let o=0;o!==s;o++){let a=n[o];if(typeof a=="number"&&isNaN(a)){G("KeyframeTrack: Time is not a valid number.",this,o,a),t=!1;break}if(r!==null&&r>a){G("KeyframeTrack: Out of order keys.",this,o,a,r),t=!1;break}r=a}if(i!==void 0&&Br(i))for(let o=0,a=i.length;o!==a;++o){let l=i[o];if(isNaN(l)){G("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===an,s=t.length-1,r=1;for(let o=1;o<s;++o){let a=!1,l=t[o],u=t[o+1];if(l!==u&&(o!==1||l!==t[0]))if(i)a=!0;else{let f=o*n,h=f-n,d=f+n;for(let p=0;p!==n;++p){let m=e[f+p];if(m!==e[h+p]||m!==e[d+p]){a=!0;break}}}if(a){if(o!==r){t[r]=t[o];let f=o*n,h=r*n;for(let d=0;d!==n;++d)e[h+d]=e[f+d]}++r}}if(s>0){t[r]=t[s];for(let o=s*n,a=r*n,l=0;l!==n;++l)e[a+l]=e[o+l];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};pt.prototype.ValueTypeName="";pt.prototype.TimeBufferType=Float32Array;pt.prototype.ValueBufferType=Float32Array;pt.prototype.DefaultInterpolation=ln;var zt=class extends pt{constructor(t,e,n){super(t,e,n)}};zt.prototype.ValueTypeName="bool";zt.prototype.ValueBufferType=Array;zt.prototype.DefaultInterpolation=De;zt.prototype.InterpolantFactoryMethodLinear=void 0;zt.prototype.InterpolantFactoryMethodSmooth=void 0;var Mn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Mn.prototype.ValueTypeName="color";var Sn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Sn.prototype.ValueTypeName="number";var bn=class extends Ot{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,a=(n-e)/(i-e),l=t*o;for(let u=l+o;l!==u;l+=4)Lt.slerpFlat(s,0,r,l-o,r,l,a);return s}},Fe=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new bn(this.times,this.values,this.getValueSize(),t)}};Fe.prototype.ValueTypeName="quaternion";Fe.prototype.InterpolantFactoryMethodSmooth=void 0;var Vt=class extends pt{constructor(t,e,n){super(t,e,n)}};Vt.prototype.ValueTypeName="string";Vt.prototype.ValueBufferType=Array;Vt.prototype.DefaultInterpolation=De;Vt.prototype.InterpolantFactoryMethodLinear=void 0;Vt.prototype.InterpolantFactoryMethodSmooth=void 0;var Tn=class extends pt{constructor(t,e,n,i){super(t,e,n,i)}};Tn.prototype.ValueTypeName="vector";var An=class{constructor(t,e,n){let i=this,s=!1,r=0,o=0,a,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(u){o++,s===!1&&i.onStart!==void 0&&i.onStart(u,r,o),s=!0},this.itemEnd=function(u){r++,i.onProgress!==void 0&&i.onProgress(u,r,o),r===o&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return a?a(u):u},this.setURLModifier=function(u){return a=u,this},this.addHandler=function(u,f){return l.push(u,f),this},this.removeHandler=function(u){let f=l.indexOf(u);return f!==-1&&l.splice(f,2),this},this.getHandler=function(u){for(let f=0,h=l.length;f<h;f+=2){let d=l[f],p=l[f+1];if(d.global&&(d.lastIndex=0),d.test(u))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Ys=new An,En=class{constructor(t){this.manager=t!==void 0?t:Ys,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,s){n.load(t,i,e,s)})}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}abort(){return this}};En.DEFAULT_MATERIAL_NAME="__DEFAULT";var Yi="\\\\[\\\\]\\\\.:\\\\/",eo=new RegExp("["+Yi+"]","g"),Zi="[^"+Yi+"]",no="[^"+Yi.replace("\\\\.","")+"]",io=/((?:WC+[\\/:])*)/.source.replace("WC",Zi),so=/(WCOD+)?/.source.replace("WCOD",no),ro=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Zi),oo=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Zi),ao=new RegExp("^"+io+so+ro+oo+"$"),co=["material","materials","bones","map"],Di=class{constructor(t,e,n){let i=n||k.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},k=class c{constructor(t,e,n){this.path=e,this.parsedPath=n||c.parseTrackName(e),this.node=c.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new c.Composite(t,e,n):new c(t,e,n)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(eo,"")}static parseTrackName(t){let e=ao.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);co.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(s){for(let r=0;r<s.length;r++){let o=s[r];if(o.name===e||o.uuid===e)return o;let a=n(o.children);if(a)return a}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,s=e.propertyIndex;if(t||(t=c.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Q("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){G("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){G("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){G("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===l){l=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){G("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){G("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){G("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){G("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let r=t[i];if(r===void 0){let l=e.nodeName;G("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){G("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){G("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}a=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(a=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=i;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};k.Composite=Di;k.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};k.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};k.prototype.GetterByBindingType=[k.prototype._getValue_direct,k.prototype._getValue_array,k.prototype._getValue_arrayElement,k.prototype._getValue_toArray];k.prototype.SetterByBindingTypeAndVersioning=[[k.prototype._setValue_direct,k.prototype._setValue_direct_setNeedsUpdate,k.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[k.prototype._setValue_array,k.prototype._setValue_array_setNeedsUpdate,k.prototype._setValue_array_setMatrixWorldNeedsUpdate],[k.prototype._setValue_arrayElement,k.prototype._setValue_arrayElement_setNeedsUpdate,k.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[k.prototype._setValue_fromArray,k.prototype._setValue_fromArray_setNeedsUpdate,k.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var vl=new Float32Array(1);var Ni=class c{static{c.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=i,this}};var Is=new M,on=new M,le=new M,ue=new M,fi=new M,lo=new M,uo=new M,at=class{constructor(t=new M,e=new M){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Is.subVectors(t,this.start),on.subVectors(this.end,this.start);let n=on.dot(on);if(n===0)return 0;let s=on.dot(Is)/n;return e&&(s=U(s,0,1)),s}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=lo,n=uo){let i=10000000000000001e-32,s,r,o=this.start,a=t.start,l=this.end,u=t.end;le.subVectors(l,o),ue.subVectors(u,a),fi.subVectors(o,a);let f=le.dot(le),h=ue.dot(ue),d=ue.dot(fi);if(f<=i&&h<=i)return e.copy(o),n.copy(a),e.sub(n),e.dot(e);if(f<=i)s=0,r=d/h,r=U(r,0,1);else{let p=le.dot(fi);if(h<=i)r=0,s=U(-p/f,0,1);else{let m=le.dot(ue),_=f*h-m*m;_!==0?s=U((m*d-p*h)/_,0,1):s=0,r=(m*s+d)/h,r<0?(r=0,s=U(-p/f,0,1)):r>1&&(r=1,s=U((m-p)/f,0,1))}}return e.copy(o).addScaledVector(le,s),n.copy(a).addScaledVector(ue,r),e.distanceToSquared(n)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"184"}}));typeof window<"u"&&(window.__THREE__?Q("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="184");var ho=\`#ifdef USE_ALPHAHASH
2
2
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
3
3
  #endif\`,fo=\`#ifdef USE_ALPHAHASH
4
4
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3661,6 +3661,6 @@ void main() {
3661
3661
  #include <colorspace_fragment>
3662
3662
  #include <fog_fragment>
3663
3663
  }\`,F={alphahash_fragment:ho,alphahash_pars_fragment:fo,alphamap_fragment:po,alphamap_pars_fragment:mo,alphatest_fragment:go,alphatest_pars_fragment:_o,aomap_fragment:xo,aomap_pars_fragment:yo,batching_pars_vertex:vo,batching_vertex:Mo,begin_vertex:So,beginnormal_vertex:bo,bsdfs:To,iridescence_fragment:Ao,bumpmap_pars_fragment:Eo,clipping_planes_fragment:wo,clipping_planes_pars_fragment:Co,clipping_planes_pars_vertex:Ro,clipping_planes_vertex:Po,color_fragment:Io,color_pars_fragment:Lo,color_pars_vertex:Do,color_vertex:No,common:Uo,cube_uv_reflection_fragment:Fo,defaultnormal_vertex:Bo,displacementmap_pars_vertex:Oo,displacementmap_vertex:zo,emissivemap_fragment:Vo,emissivemap_pars_fragment:ko,colorspace_fragment:Go,colorspace_pars_fragment:Ho,envmap_fragment:Wo,envmap_common_pars_fragment:Xo,envmap_pars_fragment:qo,envmap_pars_vertex:Yo,envmap_physical_pars_fragment:sa,envmap_vertex:Zo,fog_vertex:Jo,fog_pars_vertex:$o,fog_fragment:Ko,fog_pars_fragment:Qo,gradientmap_pars_fragment:jo,lightmap_pars_fragment:ta,lights_lambert_fragment:ea,lights_lambert_pars_fragment:na,lights_pars_begin:ia,lights_toon_fragment:ra,lights_toon_pars_fragment:oa,lights_phong_fragment:aa,lights_phong_pars_fragment:ca,lights_physical_fragment:la,lights_physical_pars_fragment:ua,lights_fragment_begin:ha,lights_fragment_maps:fa,lights_fragment_end:da,lightprobes_pars_fragment:pa,logdepthbuf_fragment:ma,logdepthbuf_pars_fragment:ga,logdepthbuf_pars_vertex:_a,logdepthbuf_vertex:xa,map_fragment:ya,map_pars_fragment:va,map_particle_fragment:Ma,map_particle_pars_fragment:Sa,metalnessmap_fragment:ba,metalnessmap_pars_fragment:Ta,morphinstance_vertex:Aa,morphcolor_vertex:Ea,morphnormal_vertex:wa,morphtarget_pars_vertex:Ca,morphtarget_vertex:Ra,normal_fragment_begin:Pa,normal_fragment_maps:Ia,normal_pars_fragment:La,normal_pars_vertex:Da,normal_vertex:Na,normalmap_pars_fragment:Ua,clearcoat_normal_fragment_begin:Fa,clearcoat_normal_fragment_maps:Ba,clearcoat_pars_fragment:Oa,iridescence_pars_fragment:za,opaque_fragment:Va,packing:ka,premultiplied_alpha_fragment:Ga,project_vertex:Ha,dithering_fragment:Wa,dithering_pars_fragment:Xa,roughnessmap_fragment:qa,roughnessmap_pars_fragment:Ya,shadowmap_pars_fragment:Za,shadowmap_pars_vertex:Ja,shadowmap_vertex:$a,shadowmask_pars_fragment:Ka,skinbase_vertex:Qa,skinning_pars_vertex:ja,skinning_vertex:tc,skinnormal_vertex:ec,specularmap_fragment:nc,specularmap_pars_fragment:ic,tonemapping_fragment:sc,tonemapping_pars_fragment:rc,transmission_fragment:oc,transmission_pars_fragment:ac,uv_pars_fragment:cc,uv_pars_vertex:lc,uv_vertex:uc,worldpos_vertex:hc,background_vert:fc,background_frag:dc,backgroundCube_vert:pc,backgroundCube_frag:mc,cube_vert:gc,cube_frag:_c,depth_vert:xc,depth_frag:yc,distance_vert:vc,distance_frag:Mc,equirect_vert:Sc,equirect_frag:bc,linedashed_vert:Tc,linedashed_frag:Ac,meshbasic_vert:Ec,meshbasic_frag:wc,meshlambert_vert:Cc,meshlambert_frag:Rc,meshmatcap_vert:Pc,meshmatcap_frag:Ic,meshnormal_vert:Lc,meshnormal_frag:Dc,meshphong_vert:Nc,meshphong_frag:Uc,meshphysical_vert:Fc,meshphysical_frag:Bc,meshtoon_vert:Oc,meshtoon_frag:zc,points_vert:Vc,points_frag:kc,shadow_vert:Gc,shadow_frag:Hc,sprite_vert:Wc,sprite_frag:Xc},I={common:{diffuse:{value:new j(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new N},alphaMap:{value:null},alphaMapTransform:{value:new N},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new N}},envmap:{envMap:{value:null},envMapRotation:{value:new N},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new N}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new N}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new N},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new N},normalScale:{value:new H(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new N},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new N}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new N}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new N}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new j(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new M},probesMax:{value:new M},probesResolution:{value:new M}},points:{diffuse:{value:new j(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new N},alphaTest:{value:0},uvTransform:{value:new N}},sprite:{diffuse:{value:new j(16777215)},opacity:{value:1},center:{value:new H(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new N},alphaMap:{value:null},alphaMapTransform:{value:new N},alphaTest:{value:0}}},Zs={basic:{uniforms:ct([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.fog]),vertexShader:F.meshbasic_vert,fragmentShader:F.meshbasic_frag},lambert:{uniforms:ct([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.fog,I.lights,{emissive:{value:new j(0)},envMapIntensity:{value:1}}]),vertexShader:F.meshlambert_vert,fragmentShader:F.meshlambert_frag},phong:{uniforms:ct([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.fog,I.lights,{emissive:{value:new j(0)},specular:{value:new j(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:F.meshphong_vert,fragmentShader:F.meshphong_frag},standard:{uniforms:ct([I.common,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.roughnessmap,I.metalnessmap,I.fog,I.lights,{emissive:{value:new j(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:F.meshphysical_vert,fragmentShader:F.meshphysical_frag},toon:{uniforms:ct([I.common,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.gradientmap,I.fog,I.lights,{emissive:{value:new j(0)}}]),vertexShader:F.meshtoon_vert,fragmentShader:F.meshtoon_frag},matcap:{uniforms:ct([I.common,I.bumpmap,I.normalmap,I.displacementmap,I.fog,{matcap:{value:null}}]),vertexShader:F.meshmatcap_vert,fragmentShader:F.meshmatcap_frag},points:{uniforms:ct([I.points,I.fog]),vertexShader:F.points_vert,fragmentShader:F.points_frag},dashed:{uniforms:ct([I.common,I.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:F.linedashed_vert,fragmentShader:F.linedashed_frag},depth:{uniforms:ct([I.common,I.displacementmap]),vertexShader:F.depth_vert,fragmentShader:F.depth_frag},normal:{uniforms:ct([I.common,I.bumpmap,I.normalmap,I.displacementmap,{opacity:{value:1}}]),vertexShader:F.meshnormal_vert,fragmentShader:F.meshnormal_frag},sprite:{uniforms:ct([I.sprite,I.fog]),vertexShader:F.sprite_vert,fragmentShader:F.sprite_frag},background:{uniforms:{uvTransform:{value:new N},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:F.background_vert,fragmentShader:F.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new N}},vertexShader:F.backgroundCube_vert,fragmentShader:F.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:F.cube_vert,fragmentShader:F.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:F.equirect_vert,fragmentShader:F.equirect_frag},distance:{uniforms:ct([I.common,I.displacementmap,{referencePosition:{value:new M},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:F.distance_vert,fragmentShader:F.distance_frag},shadow:{uniforms:ct([I.lights,I.fog,{color:{value:new j(0)},opacity:{value:1}}]),vertexShader:F.shadow_vert,fragmentShader:F.shadow_frag}};Zs.physical={uniforms:ct([Zs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new N},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new N},clearcoatNormalScale:{value:new H(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new N},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new N},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new N},sheen:{value:0},sheenColor:{value:new j(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new N},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new N},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new N},transmissionSamplerSize:{value:new H},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new N},attenuationDistance:{value:0},attenuationColor:{value:new j(0)},specularColor:{value:new j(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new N},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new N},anisotropyVector:{value:new H},anisotropyMap:{value:null},anisotropyMapTransform:{value:new N}}]),vertexShader:F.meshphysical_vert,fragmentShader:F.meshphysical_frag};var qc=new N;qc.set(-1,0,0,0,1,0,0,0,1);var Vm={[Bi]:"LINEAR_TONE_MAPPING",[Oi]:"REINHARD_TONE_MAPPING",[zi]:"CINEON_TONE_MAPPING",[Vi]:"ACES_FILMIC_TONE_MAPPING",[Gi]:"AGX_TONE_MAPPING",[Hi]:"NEUTRAL_TONE_MAPPING",[ki]:"CUSTOM_TONE_MAPPING"};var km=new Float32Array(16),Gm=new Float32Array(9),Hm=new Float32Array(4);var Wm={[Bi]:"Linear",[Oi]:"Reinhard",[zi]:"Cineon",[Vi]:"ACESFilmic",[Gi]:"AgX",[Hi]:"Neutral",[ki]:"Custom"};var Xm={[Ls]:"SHADOWMAP_TYPE_PCF",[Ds]:"SHADOWMAP_TYPE_VSM"};var qm={[Bs]:"ENVMAP_TYPE_CUBE",[Xi]:"ENVMAP_TYPE_CUBE",[Os]:"ENVMAP_TYPE_CUBE_UV"};var Ym={[Xi]:"ENVMAP_MODE_REFRACTION"};var Zm={[Ns]:"ENVMAP_BLENDING_MULTIPLY",[Us]:"ENVMAP_BLENDING_MIX",[Fs]:"ENVMAP_BLENDING_ADD"};var Yc=new N;Yc.set(-1,0,0,0,1,0,0,0,1);var Jm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);var $s=Math.pow(2,-24),Rn=Symbol("SKIP_GENERATION");function Zc(c){return c.index?c.index.count:c.attributes.position.count}function Et(c){return Zc(c)/3}function Jc(c,t=ArrayBuffer){return c>65535?new Uint32Array(new t(4*c)):new Uint16Array(new t(2*c))}function Ks(c,t){if(!c.index){let e=c.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Jc(e,n);c.setIndex(new ot(i,1));for(let s=0;s<e;s++)i[s]=s}}function Ji(c,t){let e=Et(c),n=t||c.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Math.max(0,i),o=Math.min(e,s)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function $i(c,t){if(!c.groups||!c.groups.length)return Ji(c,t);let e=[],n=new Set,i=t||c.drawRange,s=i.start/3,r=(i.start+i.count)/3;for(let a of c.groups){let l=a.start/3,u=(a.start+a.count)/3;n.add(Math.max(s,l)),n.add(Math.min(r,u))}let o=Array.from(n.values()).sort((a,l)=>a-l);for(let a=0;a<o.length-1;a++){let l=o[a],u=o[a+1];e.push({offset:Math.floor(l),count:Math.floor(u-l)})}return e}function Qs(c,t){let e=Et(c),n=$i(c,t).sort((r,o)=>r.offset-o.offset),i=n[n.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return n.forEach(({count:r})=>s+=r),e!==s}function Pn(c,t,e,n,i){let s=1/0,r=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0,f=1/0,h=1/0,d=1/0,p=-1/0,m=-1/0,_=-1/0;for(let g=t*6,x=(t+e)*6;g<x;g+=6){let y=c[g+0],S=c[g+1],v=y-S,b=y+S;v<s&&(s=v),b>a&&(a=b),y<f&&(f=y),y>p&&(p=y);let T=c[g+2],A=c[g+3],E=T-A,C=T+A;E<r&&(r=E),C>l&&(l=C),T<h&&(h=T),T>m&&(m=T);let R=c[g+4],w=c[g+5],P=R-w,L=R+w;P<o&&(o=P),L>u&&(u=L),R<d&&(d=R),R>_&&(_=R)}n[0]=s,n[1]=r,n[2]=o,n[3]=a,n[4]=l,n[5]=u,i[0]=f,i[1]=h,i[2]=d,i[3]=p,i[4]=m,i[5]=_}function js(c,t=null,e=null,n=null){let i=c.attributes.position,s=c.index?c.index.array:null,r=Et(c),o=i.normalized,a;t===null?(a=new Float32Array(r*6),e=0,n=r):(a=t,e=e||0,n=n||r);let l=i.array,u=i.offset||0,f=3;i.isInterleavedBufferAttribute&&(f=i.data.stride);let h=["getX","getY","getZ"];for(let d=e;d<e+n;d++){let p=d*3,m=d*6,_=p+0,g=p+1,x=p+2;s&&(_=s[_],g=s[g],x=s[x]),o||(_=_*f+u,g=g*f+u,x=x*f+u);for(let y=0;y<3;y++){let S,v,b;o?(S=i[h[y]](_),v=i[h[y]](g),b=i[h[y]](x)):(S=l[_+y],v=l[g+y],b=l[x+y]);let T=S;v<T&&(T=v),b<T&&(T=b);let A=S;v>A&&(A=v),b>A&&(A=b);let E=(A-T)/2,C=y*2;a[m+C+0]=T+E,a[m+C+1]=E+(Math.abs(T)+E)*$s}}return a}function z(c,t,e){return e.min.x=t[c],e.min.y=t[c+1],e.min.z=t[c+2],e.max.x=t[c+3],e.max.y=t[c+4],e.max.z=t[c+5],e}function Ki(c){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=c[n+3]-c[n];i>e&&(e=i,t=n)}return t}function Qi(c,t){t.set(c)}function ji(c,t,e){let n,i;for(let s=0;s<3;s++){let r=s+3;n=c[s],i=t[s],e[s]=n<i?n:i,n=c[r],i=t[r],e[r]=n>i?n:i}}function Be(c,t,e){for(let n=0;n<3;n++){let i=t[c+2*n],s=t[c+2*n+1],r=i-s,o=i+s;r<e[n]&&(e[n]=r),o>e[n+3]&&(e[n+3]=o)}}function me(c){let t=c[3]-c[0],e=c[4]-c[1],n=c[5]-c[2];return 2*(t*e+e*n+n*t)}var Dt=32,Kc=(c,t)=>c.candidate-t.candidate,kt=new Array(Dt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),In=new Float32Array(6);function nr(c,t,e,n,i,s){let r=-1,o=0;if(s===0)r=Ki(t),r!==-1&&(o=(t[r]+t[r+3])/2);else if(s===1)r=Ki(c),r!==-1&&(o=Qc(e,n,i,r));else if(s===2){let a=me(c),l=1.25*i,u=n*6,f=(n+i)*6;for(let h=0;h<3;h++){let d=t[h],_=(t[h+3]-d)/Dt;if(i<Dt/4){let g=[...kt];g.length=i;let x=0;for(let S=u;S<f;S+=6,x++){let v=g[x];v.candidate=e[S+2*h],v.count=0;let{bounds:b,leftCacheBounds:T,rightCacheBounds:A}=v;for(let E=0;E<3;E++)A[E]=1/0,A[E+3]=-1/0,T[E]=1/0,T[E+3]=-1/0,b[E]=1/0,b[E+3]=-1/0;Be(S,e,b)}g.sort(Kc);let y=i;for(let S=0;S<y;S++){let v=g[S];for(;S+1<y&&g[S+1].candidate===v.candidate;)g.splice(S+1,1),y--}for(let S=u;S<f;S+=6){let v=e[S+2*h];for(let b=0;b<y;b++){let T=g[b];v>=T.candidate?Be(S,e,T.rightCacheBounds):(Be(S,e,T.leftCacheBounds),T.count++)}}for(let S=0;S<y;S++){let v=g[S],b=v.count,T=i-v.count,A=v.leftCacheBounds,E=v.rightCacheBounds,C=0;b!==0&&(C=me(A)/a);let R=0;T!==0&&(R=me(E)/a);let w=1+1.25*(C*b+R*T);w<l&&(r=h,l=w,o=v.candidate)}}else{for(let y=0;y<Dt;y++){let S=kt[y];S.count=0,S.candidate=d+_+y*_;let v=S.bounds;for(let b=0;b<3;b++)v[b]=1/0,v[b+3]=-1/0}for(let y=u;y<f;y+=6){let b=~~((e[y+2*h]-d)/_);b>=Dt&&(b=Dt-1);let T=kt[b];T.count++,Be(y,e,T.bounds)}let g=kt[Dt-1];Qi(g.bounds,g.rightCacheBounds);for(let y=Dt-2;y>=0;y--){let S=kt[y],v=kt[y+1];ji(S.bounds,v.rightCacheBounds,S.rightCacheBounds)}let x=0;for(let y=0;y<Dt-1;y++){let S=kt[y],v=S.count,b=S.bounds,A=kt[y+1].rightCacheBounds;v!==0&&(x===0?Qi(b,In):ji(b,In,In)),x+=v;let E=0,C=0;x!==0&&(E=me(In)/a);let R=i-x;R!==0&&(C=me(A)/a);let w=1+1.25*(E*x+C*R);w<l&&(r=h,l=w,o=S.candidate)}}}}else console.warn(\`MeshBVH: Invalid build strategy value \${s} used.\`);return{axis:r,pos:o}}function Qc(c,t,e,n){let i=0;for(let s=t,r=t+e;s<r;s++)i+=c[s*6+n*2];return i/e}var ge=class{constructor(){this.boundingData=new Float32Array(6)}};function ir(c,t,e,n,i,s){let r=n,o=n+i-1,a=s.pos,l=s.axis*2;for(;;){for(;r<=o&&e[r*6+l]<a;)r++;for(;r<=o&&e[o*6+l]>=a;)o--;if(r<o){for(let u=0;u<3;u++){let f=t[r*3+u];t[r*3+u]=t[o*3+u],t[o*3+u]=f}for(let u=0;u<6;u++){let f=e[r*6+u];e[r*6+u]=e[o*6+u],e[o*6+u]=f}r++,o--}else return r}}function sr(c,t,e,n,i,s){let r=n,o=n+i-1,a=s.pos,l=s.axis*2;for(;;){for(;r<=o&&e[r*6+l]<a;)r++;for(;r<=o&&e[o*6+l]>=a;)o--;if(r<o){let u=c[r];c[r]=c[o],c[o]=u;for(let f=0;f<6;f++){let h=e[r*6+f];e[r*6+f]=e[o*6+f],e[o*6+f]=h}r++,o--}else return r}}function q(c,t){return t[c+15]===65535}function Z(c,t){return t[c+6]}function $(c,t){return t[c+14]}function tt(c){return c+8}function et(c,t){return t[c+6]}function Ln(c,t){return t[c+7]}var rr,Oe,Dn,or,jc=Math.pow(2,32);function Nn(c){return"count"in c?1:1+Nn(c.left)+Nn(c.right)}function ar(c,t,e){return rr=new Float32Array(e),Oe=new Uint32Array(e),Dn=new Uint16Array(e),or=new Uint8Array(e),ts(c,t)}function ts(c,t){let e=c/4,n=c/2,i="count"in t,s=t.boundingData;for(let r=0;r<6;r++)rr[e+r]=s[r];if(i)if(t.buffer){let r=t.buffer;or.set(new Uint8Array(r),c);for(let o=c,a=c+r.byteLength;o<a;o+=32){let l=o/2;q(l,Dn)||(Oe[o/4+6]+=e)}return c+r.byteLength}else{let r=t.offset,o=t.count;return Oe[e+6]=r,Dn[n+14]=o,Dn[n+15]=65535,c+32}else{let r=t.left,o=t.right,a=t.splitAxis,l;if(l=ts(c+32,r),l/4>jc)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Oe[e+6]=l/4,l=ts(l,o),Oe[e+7]=a,l}}function tl(c,t){let e=(c.index?c.index.count:c.attributes.position.count)/3,n=e>2**16,i=n?4:2,s=t?new SharedArrayBuffer(e*i):new ArrayBuffer(e*i),r=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,a=r.length;o<a;o++)r[o]=o;return r}function el(c,t,e,n,i){let{maxDepth:s,verbose:r,maxLeafTris:o,strategy:a,onProgress:l,indirect:u}=i,f=c._indirectBuffer,h=c.geometry,d=h.index?h.index.array:null,p=u?sr:ir,m=Et(h),_=new Float32Array(6),g=!1,x=new ge;return Pn(t,e,n,x.boundingData,_),S(x,e,n,_),x;function y(v){l&&l(v/m)}function S(v,b,T,A=null,E=0){if(!g&&E>=s&&(g=!0,r&&(console.warn(\`MeshBVH: Max depth of \${s} reached when generating BVH. Consider increasing maxDepth.\`),console.warn(h))),T<=o||E>=s)return y(b+T),v.offset=b,v.count=T,v;let C=nr(v.boundingData,A,t,b,T,a);if(C.axis===-1)return y(b+T),v.offset=b,v.count=T,v;let R=p(f,d,t,b,T,C);if(R===b||R===b+T)y(b+T),v.offset=b,v.count=T;else{v.splitAxis=C.axis;let w=new ge,P=b,L=R-b;v.left=w,Pn(t,P,L,w.boundingData,_),S(w,P,L,_,E+1);let D=new ge,O=R,it=T-L;v.right=D,Pn(t,O,it,D.boundingData,_),S(D,O,it,_,E+1)}return v}}function cr(c,t){let e=c.geometry;t.indirect&&(c._indirectBuffer=tl(e,t.useSharedArrayBuffer),Qs(e,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),c._indirectBuffer||Ks(e,t);let n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=js(e),s=t.indirect?Ji(e,t.range):$i(e,t.range);c._roots=s.map(r=>{let o=el(c,i,r.offset,r.count,t),a=Nn(o),l=new n(32*a);return ar(0,o,l),l})}var ht=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let s=0,r=t.length;s<r;s++){let a=t[s][e];n=a<n?a:n,i=a>i?a:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let s=0,r=e.length;s<r;s++){let o=e[s],a=t.dot(o);n=a<n?a:n,i=a>i?a:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};ht.prototype.setFromBox=(function(){let c=new M;return function(e,n){let i=n.min,s=n.max,r=1/0,o=-1/0;for(let a=0;a<=1;a++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){c.x=i.x*a+s.x*(1-a),c.y=i.y*l+s.y*(1-l),c.z=i.z*u+s.z*(1-u);let f=e.dot(c);r=Math.min(f,r),o=Math.max(f,o)}this.min=r,this.max=o}})();var Tg=(function(){let c=new ht;return function(e,n){let i=e.points,s=e.satAxes,r=e.satBounds,o=n.points,a=n.satAxes,l=n.satBounds;for(let u=0;u<3;u++){let f=r[u],h=s[u];if(c.setFromPoints(h,o),f.isSeparated(c))return!1}for(let u=0;u<3;u++){let f=l[u],h=a[u];if(c.setFromPoints(h,i),f.isSeparated(c))return!1}}})();var nl=(function(){let c=new M,t=new M,e=new M;return function(i,s,r){let o=i.start,a=c,l=s.start,u=t;e.subVectors(o,l),c.subVectors(i.end,i.start),t.subVectors(s.end,s.start);let f=e.dot(u),h=u.dot(a),d=u.dot(u),p=e.dot(a),_=a.dot(a)*d-h*h,g,x;_!==0?g=(f*h-p*d)/_:g=0,x=(f+g*h)/d,r.x=g,r.y=x}})(),Ve=(function(){let c=new H,t=new M,e=new M;return function(i,s,r,o){nl(i,s,c);let a=c.x,l=c.y;if(a>=0&&a<=1&&l>=0&&l<=1){i.at(a,r),s.at(l,o);return}else if(a>=0&&a<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,r);return}else if(l>=0&&l<=1){a<0?i.at(0,r):i.at(1,r),s.closestPointToPoint(r,!0,o);return}else{let u;a<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;let h=t,d=e;if(i.closestPointToPoint(f,!0,t),s.closestPointToPoint(u,!0,e),h.distanceToSquared(f)<=d.distanceToSquared(u)){r.copy(h),o.copy(f);return}else{r.copy(u),o.copy(d);return}}}})(),lr=(function(){let c=new M,t=new M,e=new Jt,n=new at;return function(s,r){let{radius:o,center:a}=s,{a:l,b:u,c:f}=r;if(n.start=l,n.end=u,n.closestPointToPoint(a,!0,c).distanceTo(a)<=o||(n.start=l,n.end=f,n.closestPointToPoint(a,!0,c).distanceTo(a)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(a,!0,c).distanceTo(a)<=o))return!0;let m=r.getPlane(e);if(Math.abs(m.distanceToPoint(a))<=o){let g=m.projectPoint(a,t);if(r.containsPoint(g))return!0}return!1}})();var il=1e-15;function es(c){return Math.abs(c)<il}var nt=class extends St{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M),this.satBounds=new Array(4).fill().map(()=>new ht),this.points=[this.a,this.b,this.c],this.sphere=new pe,this.plane=new Jt,this.needsUpdate=!0}intersectsSphere(t){return lr(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,s=this.satAxes,r=this.satBounds,o=s[0],a=r[0];this.getNormal(o),a.setFromPoints(o,i);let l=s[1],u=r[1];l.subVectors(t,e),u.setFromPoints(l,i);let f=s[2],h=r[2];f.subVectors(e,n),h.setFromPoints(f,i);let d=s[3],p=r[3];d.subVectors(n,t),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}};nt.prototype.closestPointToSegment=(function(){let c=new M,t=new M,e=new at;return function(i,s=null,r=null){let{start:o,end:a}=i,l=this.points,u,f=1/0;for(let h=0;h<3;h++){let d=(h+1)%3;e.start.copy(l[h]),e.end.copy(l[d]),Ve(e,i,c,t),u=c.distanceToSquared(t),u<f&&(f=u,s&&s.copy(c),r&&r.copy(t))}return this.closestPointToPoint(o,c),u=o.distanceToSquared(c),u<f&&(f=u,s&&s.copy(c),r&&r.copy(o)),this.closestPointToPoint(a,c),u=a.distanceToSquared(c),u<f&&(f=u,s&&s.copy(c),r&&r.copy(a)),Math.sqrt(f)}})();nt.prototype.intersectsTriangle=(function(){let c=new nt,t=new Array(3),e=new Array(3),n=new ht,i=new ht,s=new M,r=new M,o=new M,a=new M,l=new M,u=new at,f=new at,h=new at,d=new M;function p(m,_,g){let x=m.points,y=0,S=-1;for(let v=0;v<3;v++){let{start:b,end:T}=u;b.copy(x[v]),T.copy(x[(v+1)%3]),u.delta(r);let A=es(_.distanceToPoint(b));if(es(_.normal.dot(r))&&A){g.copy(u),y=2;break}let E=_.intersectLine(u,d);if(!E&&A&&d.copy(b),(E||A)&&!es(d.distanceTo(T))){if(y<=1)(y===1?g.start:g.end).copy(d),A&&(S=y);else if(y>=2){(S===1?g.start:g.end).copy(d),y=2;break}if(y++,y===2&&S===-1)break}}return y}return function(_,g=null,x=!1){this.needsUpdate&&this.update(),_.isExtendedTriangle?_.needsUpdate&&_.update():(c.copy(_),c.update(),_=c);let y=this.plane,S=_.plane;if(Math.abs(y.normal.dot(S.normal))>1-1e-10){let v=this.satBounds,b=this.satAxes;e[0]=_.a,e[1]=_.b,e[2]=_.c;for(let E=0;E<4;E++){let C=v[E],R=b[E];if(n.setFromPoints(R,e),C.isSeparated(n))return!1}let T=_.satBounds,A=_.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let E=0;E<4;E++){let C=T[E],R=A[E];if(n.setFromPoints(R,t),C.isSeparated(n))return!1}for(let E=0;E<4;E++){let C=b[E];for(let R=0;R<4;R++){let w=A[R];if(s.crossVectors(C,w),n.setFromPoints(s,t),i.setFromPoints(s,e),n.isSeparated(i))return!1}}return g&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let v=p(this,S,f);if(v===1&&_.containsPoint(f.end))return g&&(g.start.copy(f.end),g.end.copy(f.end)),!0;if(v!==2)return!1;let b=p(_,y,h);if(b===1&&this.containsPoint(h.end))return g&&(g.start.copy(h.end),g.end.copy(h.end)),!0;if(b!==2)return!1;if(f.delta(o),h.delta(a),o.dot(a)<0){let P=h.start;h.start=h.end,h.end=P}let T=f.start.dot(o),A=f.end.dot(o),E=h.start.dot(o),C=h.end.dot(o),R=A<E,w=T<C;return T!==C&&E!==A&&R===w?!1:(g&&(l.subVectors(f.start,h.start),l.dot(o)>0?g.start.copy(f.start):g.start.copy(h.start),l.subVectors(f.end,h.end),l.dot(o)<0?g.end.copy(f.end):g.end.copy(h.end)),!0)}}})();nt.prototype.distanceToPoint=(function(){let c=new M;return function(e){return this.closestPointToPoint(e,c),e.distanceTo(c)}})();nt.prototype.distanceToTriangle=(function(){let c=new M,t=new M,e=["a","b","c"],n=new at,i=new at;return function(r,o=null,a=null){let l=o||a?n:null;if(this.intersectsTriangle(r,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let u=1/0;for(let f=0;f<3;f++){let h,d=e[f],p=r[d];this.closestPointToPoint(p,c),h=p.distanceToSquared(c),h<u&&(u=h,o&&o.copy(c),a&&a.copy(p));let m=this[d];r.closestPointToPoint(m,c),h=m.distanceToSquared(c),h<u&&(u=h,o&&o.copy(m),a&&a.copy(c))}for(let f=0;f<3;f++){let h=e[f],d=e[(f+1)%3];n.set(this[h],this[d]);for(let p=0;p<3;p++){let m=e[p],_=e[(p+1)%3];i.set(r[m],r[_]),Ve(n,i,c,t);let g=c.distanceToSquared(t);g<u&&(u=g,o&&o.copy(c),a&&a.copy(t))}}return Math.sqrt(u)}})();var Y=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new M,this.max=new M,this.matrix=new W,this.invMatrix=new W,this.points=new Array(8).fill().map(()=>new M),this.satAxes=new Array(3).fill().map(()=>new M),this.satBounds=new Array(3).fill().map(()=>new ht),this.alignedSatBounds=new Array(3).fill().map(()=>new ht),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Y.prototype.update=(function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){let h=1*l|2*u|4*f,d=i[h];d.x=l?n.x:e.x,d.y=u?n.y:e.y,d.z=f?n.z:e.z,d.applyMatrix4(t)}let s=this.satBounds,r=this.satAxes,o=i[0];for(let l=0;l<3;l++){let u=r[l],f=s[l],h=1<<l,d=i[h];u.subVectors(o,d),f.setFromPoints(u,i)}let a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();Y.prototype.intersectsBox=(function(){let c=new ht;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,s=this.satBounds,r=this.satAxes,o=this.alignedSatBounds;if(c.min=n.x,c.max=i.x,o[0].isSeparated(c)||(c.min=n.y,c.max=i.y,o[1].isSeparated(c))||(c.min=n.z,c.max=i.z,o[2].isSeparated(c)))return!1;for(let a=0;a<3;a++){let l=r[a],u=s[a];if(c.setFromBox(l,e),u.isSeparated(c))return!1}return!0}})();Y.prototype.intersectsTriangle=(function(){let c=new nt,t=new Array(3),e=new ht,n=new ht,i=new M;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(c.copy(r),c.update(),r=c);let o=this.satBounds,a=this.satAxes;t[0]=r.a,t[1]=r.b,t[2]=r.c;for(let h=0;h<3;h++){let d=o[h],p=a[h];if(e.setFromPoints(p,t),d.isSeparated(e))return!1}let l=r.satBounds,u=r.satAxes,f=this.points;for(let h=0;h<3;h++){let d=l[h],p=u[h];if(e.setFromPoints(p,f),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=a[h];for(let p=0;p<4;p++){let m=u[p];if(i.crossVectors(d,m),e.setFromPoints(i,t),n.setFromPoints(i,f),e.isSeparated(n))return!1}}return!0}})();Y.prototype.closestPointToPoint=(function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}})();Y.prototype.distanceToPoint=(function(){let c=new M;return function(e){return this.closestPointToPoint(e,c),e.distanceTo(c)}})();Y.prototype.distanceToBox=(function(){let c=["x","y","z"],t=new Array(12).fill().map(()=>new at),e=new Array(12).fill().map(()=>new at),n=new M,i=new M;return function(r,o=0,a=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(a||l)&&(r.getCenter(i),this.closestPointToPoint(i,n),r.closestPointToPoint(n,i),a&&a.copy(n),l&&l.copy(i)),0;let u=o*o,f=r.min,h=r.max,d=this.points,p=1/0;for(let _=0;_<8;_++){let g=d[_];i.copy(g).clamp(f,h);let x=g.distanceToSquared(i);if(x<p&&(p=x,a&&a.copy(g),l&&l.copy(i),x<u))return Math.sqrt(x)}let m=0;for(let _=0;_<3;_++)for(let g=0;g<=1;g++)for(let x=0;x<=1;x++){let y=(_+1)%3,S=(_+2)%3,v=g<<y|x<<S,b=1<<_|g<<y|x<<S,T=d[v],A=d[b];t[m].set(T,A);let C=c[_],R=c[y],w=c[S],P=e[m],L=P.start,D=P.end;L[C]=f[C],L[R]=g?f[R]:h[R],L[w]=x?f[w]:h[R],D[C]=h[C],D[R]=g?f[R]:h[R],D[w]=x?f[w]:h[R],m++}for(let _=0;_<=1;_++)for(let g=0;g<=1;g++)for(let x=0;x<=1;x++){i.x=_?h.x:f.x,i.y=g?h.y:f.y,i.z=x?h.z:f.z,this.closestPointToPoint(i,n);let y=i.distanceToSquared(n);if(y<p&&(p=y,a&&a.copy(n),l&&l.copy(i),y<u))return Math.sqrt(y)}for(let _=0;_<12;_++){let g=t[_];for(let x=0;x<12;x++){let y=e[x];Ve(g,y,n,i);let S=n.distanceToSquared(i);if(S<p&&(p=S,a&&a.copy(n),l&&l.copy(i),S<u))return Math.sqrt(S)}}return Math.sqrt(p)}})();var Gt=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};var ns=class extends Gt{constructor(){super(()=>new nt)}},lt=new ns;var is=class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let t=[],e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}},B=new is;var Ht,xe,_e=[],Fn=new Gt(()=>new X);function ur(c,t,e,n,i,s){Ht=Fn.getPrimitive(),xe=Fn.getPrimitive(),_e.push(Ht,xe),B.setBuffer(c._roots[t]);let r=ss(0,c.geometry,e,n,i,s);B.clearBuffer(),Fn.releasePrimitive(Ht),Fn.releasePrimitive(xe),_e.pop(),_e.pop();let o=_e.length;return o>0&&(xe=_e[o-1],Ht=_e[o-2]),r}function ss(c,t,e,n,i=null,s=0,r=0){let{float32Array:o,uint16Array:a,uint32Array:l}=B,u=c*2;if(q(u,a)){let h=Z(c,l),d=$(u,a);return z(c,o,Ht),n(h,d,!1,r,s+c,Ht)}else{let C=function(w){let{uint16Array:P,uint32Array:L}=B,D=w*2;for(;!q(D,P);)w=tt(w),D=w*2;return Z(w,L)},R=function(w){let{uint16Array:P,uint32Array:L}=B,D=w*2;for(;!q(D,P);)w=et(w,L),D=w*2;return Z(w,L)+$(D,P)},h=tt(c),d=et(c,l),p=h,m=d,_,g,x,y;if(i&&(x=Ht,y=xe,z(p,o,x),z(m,o,y),_=i(x),g=i(y),g<_)){p=d,m=h;let w=_;_=g,g=w,x=y}x||(x=Ht,z(p,o,x));let S=q(p*2,a),v=e(x,S,_,r+1,s+p),b;if(v===2){let w=C(p),L=R(p)-w;b=n(w,L,!0,r+1,s+p,x)}else b=v&&ss(p,t,e,n,i,s,r+1);if(b)return!0;y=xe,z(m,o,y);let T=q(m*2,a),A=e(y,T,g,r+1,s+m),E;if(A===2){let w=C(m),L=R(m)-w;E=n(w,L,!0,r+1,s+m,y)}else E=A&&ss(m,t,e,n,i,s,r+1);return!!E}}var ke=new M,os=new M;function hr(c,t,e={},n=0,i=1/0){let s=n*n,r=i*i,o=1/0,a=null;if(c.shapecast({boundsTraverseOrder:u=>(ke.copy(t).clamp(u.min,u.max),ke.distanceToSquared(t)),intersectsBounds:(u,f,h)=>h<o&&h<r,intersectsTriangle:(u,f)=>{u.closestPointToPoint(t,ke);let h=t.distanceToSquared(ke);return h<o&&(os.copy(ke),o=h,a=f),h<s}}),o===1/0)return null;let l=Math.sqrt(o);return e.point?e.point.copy(os):e.point=os.clone(),e.distance=l,e.faceIndex=a,e}var rl=parseInt("184")>=169,$t=new M,Kt=new M,Qt=new M,Bn=new H,On=new H,zn=new H,fr=new M,dr=new M,pr=new M,Ge=new M;function ol(c,t,e,n,i,s,r,o){let a;if(s===Ui?a=c.intersectTriangle(n,e,t,!0,i):a=c.intersectTriangle(t,e,n,s!==Fi,i),a===null)return null;let l=c.origin.distanceTo(i);return l<r||l>o?null:{distance:l,point:i.clone()}}function al(c,t,e,n,i,s,r,o,a,l,u){$t.fromBufferAttribute(t,s),Kt.fromBufferAttribute(t,r),Qt.fromBufferAttribute(t,o);let f=ol(c,$t,Kt,Qt,Ge,a,l,u);if(f){let h=new M;St.getBarycoord(Ge,$t,Kt,Qt,h),n&&(Bn.fromBufferAttribute(n,s),On.fromBufferAttribute(n,r),zn.fromBufferAttribute(n,o),f.uv=St.getInterpolation(Ge,$t,Kt,Qt,Bn,On,zn,new H)),i&&(Bn.fromBufferAttribute(i,s),On.fromBufferAttribute(i,r),zn.fromBufferAttribute(i,o),f.uv1=St.getInterpolation(Ge,$t,Kt,Qt,Bn,On,zn,new H)),e&&(fr.fromBufferAttribute(e,s),dr.fromBufferAttribute(e,r),pr.fromBufferAttribute(e,o),f.normal=St.getInterpolation(Ge,$t,Kt,Qt,fr,dr,pr,new M),f.normal.dot(c.direction)>0&&f.normal.multiplyScalar(-1));let d={a:s,b:r,c:o,normal:new M,materialIndex:0};St.getNormal($t,Kt,Qt,d.normal),f.face=d,f.faceIndex=s,rl&&(f.barycoord=h)}return f}function ye(c,t,e,n,i,s,r){let o=n*3,a=o+0,l=o+1,u=o+2,f=c.index;c.index&&(a=f.getX(a),l=f.getX(l),u=f.getX(u));let{position:h,normal:d,uv:p,uv1:m}=c.attributes,_=al(e,h,d,p,m,a,l,u,t,s,r);return _?(_.faceIndex=n,i&&i.push(_),_):null}function V(c,t,e,n){let i=c.a,s=c.b,r=c.c,o=t,a=t+1,l=t+2;e&&(o=e.getX(o),a=e.getX(a),l=e.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(a),s.y=n.getY(a),s.z=n.getZ(a),r.x=n.getX(l),r.y=n.getY(l),r.z=n.getZ(l)}function mr(c,t,e,n,i,s,r,o){let{geometry:a,_indirectBuffer:l}=c;for(let u=n,f=n+i;u<f;u++)ye(a,t,e,u,s,r,o)}function gr(c,t,e,n,i,s,r){let{geometry:o,_indirectBuffer:a}=c,l=1/0,u=null;for(let f=n,h=n+i;f<h;f++){let d;d=ye(o,t,e,f,null,s,r),d&&d.distance<l&&(u=d,l=d.distance)}return u}function _r(c,t,e,n,i,s,r){let{geometry:o}=e,{index:a}=o,l=o.attributes.position;for(let u=c,f=t+c;u<f;u++){let h;if(h=u,V(r,h*3,a,l),r.needsUpdate=!0,n(r,h,i,s))return!0}return!1}function xr(c,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=c.geometry,n=e.index?e.index.array:null,i=e.attributes.position,s,r,o,a,l=0,u=c._roots;for(let h=0,d=u.length;h<d;h++)s=u[h],r=new Uint32Array(s),o=new Uint16Array(s),a=new Float32Array(s),f(0,l),l+=s.byteLength;function f(h,d,p=!1){let m=h*2;if(o[m+15]===65535){let g=r[h+6],x=o[m+14],y=1/0,S=1/0,v=1/0,b=-1/0,T=-1/0,A=-1/0;for(let E=3*g,C=3*(g+x);E<C;E++){let R=n[E],w=i.getX(R),P=i.getY(R),L=i.getZ(R);w<y&&(y=w),w>b&&(b=w),P<S&&(S=P),P>T&&(T=P),L<v&&(v=L),L>A&&(A=L)}return a[h+0]!==y||a[h+1]!==S||a[h+2]!==v||a[h+3]!==b||a[h+4]!==T||a[h+5]!==A?(a[h+0]=y,a[h+1]=S,a[h+2]=v,a[h+3]=b,a[h+4]=T,a[h+5]=A,!0):!1}else{let g=h+8,x=r[h+6],y=g+d,S=x+d,v=p,b=!1,T=!1;t?v||(b=t.has(y),T=t.has(S),v=!b&&!T):(b=!0,T=!0);let A=v||b,E=v||T,C=!1;A&&(C=f(g,d,v));let R=!1;E&&(R=f(x,d,v));let w=C||R;if(w)for(let P=0;P<3;P++){let L=g+P,D=x+P,O=a[L],it=a[L+3],Tt=a[D],At=a[D+3];a[h+P]=O<Tt?O:Tt,a[h+P+3]=it>At?it:At}return w}}}function xt(c,t,e,n,i){let s,r,o,a,l,u,f=1/e.direction.x,h=1/e.direction.y,d=1/e.direction.z,p=e.origin.x,m=e.origin.y,_=e.origin.z,g=t[c],x=t[c+3],y=t[c+1],S=t[c+3+1],v=t[c+2],b=t[c+3+2];return f>=0?(s=(g-p)*f,r=(x-p)*f):(s=(x-p)*f,r=(g-p)*f),h>=0?(o=(y-m)*h,a=(S-m)*h):(o=(S-m)*h,a=(y-m)*h),s>a||o>r||((o>s||isNaN(s))&&(s=o),(a<r||isNaN(r))&&(r=a),d>=0?(l=(v-_)*d,u=(b-_)*d):(l=(b-_)*d,u=(v-_)*d),s>u||l>r)?!1:((l>s||s!==s)&&(s=l),(u<r||r!==r)&&(r=u),s<=i&&r>=n)}function yr(c,t,e,n,i,s,r,o){let{geometry:a,_indirectBuffer:l}=c;for(let u=n,f=n+i;u<f;u++){let h=l?l[u]:u;ye(a,t,e,h,s,r,o)}}function vr(c,t,e,n,i,s,r){let{geometry:o,_indirectBuffer:a}=c,l=1/0,u=null;for(let f=n,h=n+i;f<h;f++){let d;d=ye(o,t,e,a?a[f]:f,null,s,r),d&&d.distance<l&&(u=d,l=d.distance)}return u}function Mr(c,t,e,n,i,s,r){let{geometry:o}=e,{index:a}=o,l=o.attributes.position;for(let u=c,f=t+c;u<f;u++){let h;if(h=e.resolveTriangleIndex(u),V(r,h*3,a,l),r.needsUpdate=!0,n(r,h,i,s))return!0}return!1}function Sr(c,t,e,n,i,s,r){B.setBuffer(c._roots[t]),as(0,c,e,n,i,s,r),B.clearBuffer()}function as(c,t,e,n,i,s,r){let{float32Array:o,uint16Array:a,uint32Array:l}=B,u=c*2;if(q(u,a)){let h=Z(c,l),d=$(u,a);mr(t,e,n,h,d,i,s,r)}else{let h=tt(c);xt(h,o,n,s,r)&&as(h,t,e,n,i,s,r);let d=et(c,l);xt(d,o,n,s,r)&&as(d,t,e,n,i,s,r)}}var cl=["x","y","z"];function br(c,t,e,n,i,s){B.setBuffer(c._roots[t]);let r=cs(0,c,e,n,i,s);return B.clearBuffer(),r}function cs(c,t,e,n,i,s){let{float32Array:r,uint16Array:o,uint32Array:a}=B,l=c*2;if(q(l,o)){let f=Z(c,a),h=$(l,o);return gr(t,e,n,f,h,i,s)}else{let f=Ln(c,a),h=cl[f],p=n.direction[h]>=0,m,_;p?(m=tt(c),_=et(c,a)):(m=et(c,a),_=tt(c));let x=xt(m,r,n,i,s)?cs(m,t,e,n,i,s):null;if(x){let v=x.point[h];if(p?v<=r[_+f]:v>=r[_+f+3])return x}let S=xt(_,r,n,i,s)?cs(_,t,e,n,i,s):null;return x&&S?x.distance<=S.distance?x:S:x||S||null}}var Vn=new X,ve=new nt,Me=new nt,He=new W,Tr=new Y,kn=new Y;function Ar(c,t,e,n){B.setBuffer(c._roots[t]);let i=ls(0,c,e,n);return B.clearBuffer(),i}function ls(c,t,e,n,i=null){let{float32Array:s,uint16Array:r,uint32Array:o}=B,a=c*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),Tr.set(e.boundingBox.min,e.boundingBox.max,n),i=Tr),q(a,r)){let u=t.geometry,f=u.index,h=u.attributes.position,d=e.index,p=e.attributes.position,m=Z(c,o),_=$(a,r);if(He.copy(n).invert(),e.boundsTree)return z(c,s,kn),kn.matrix.copy(He),kn.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:x=>kn.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let y=m*3,S=(_+m)*3;y<S;y+=3)if(V(Me,y,f,h),Me.needsUpdate=!0,x.intersectsTriangle(Me))return!0;return!1}});for(let g=m*3,x=(_+m)*3;g<x;g+=3){V(ve,g,f,h),ve.a.applyMatrix4(He),ve.b.applyMatrix4(He),ve.c.applyMatrix4(He),ve.needsUpdate=!0;for(let y=0,S=d.count;y<S;y+=3)if(V(Me,y,d,p),Me.needsUpdate=!0,ve.intersectsTriangle(Me))return!0}}else{let u=c+8,f=o[c+6];return z(u,s,Vn),!!(i.intersectsBox(Vn)&&ls(u,t,e,n,i)||(z(f,s,Vn),i.intersectsBox(Vn)&&ls(f,t,e,n,i)))}}var Gn=new W,us=new Y,We=new Y,ll=new M,ul=new M,hl=new M,fl=new M;function Er(c,t,e,n={},i={},s=0,r=1/0){t.boundingBox||t.computeBoundingBox(),us.set(t.boundingBox.min,t.boundingBox.max,e),us.needsUpdate=!0;let o=c.geometry,a=o.attributes.position,l=o.index,u=t.attributes.position,f=t.index,h=lt.getPrimitive(),d=lt.getPrimitive(),p=ll,m=ul,_=null,g=null;i&&(_=hl,g=fl);let x=1/0,y=null,S=null;return Gn.copy(e).invert(),We.matrix.copy(Gn),c.shapecast({boundsTraverseOrder:v=>us.distanceToBox(v),intersectsBounds:(v,b,T)=>T<x&&T<r?(b&&(We.min.copy(v.min),We.max.copy(v.max),We.needsUpdate=!0),!0):!1,intersectsRange:(v,b)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>We.distanceToBox(A),intersectsBounds:(A,E,C)=>C<x&&C<r,intersectsRange:(A,E)=>{for(let C=A,R=A+E;C<R;C++){V(d,3*C,f,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let w=v,P=v+b;w<P;w++){V(h,3*w,l,a),h.needsUpdate=!0;let L=h.distanceToTriangle(d,p,_);if(L<x&&(m.copy(p),g&&g.copy(_),x=L,y=w,S=C),L<s)return!0}}}});{let T=Et(t);for(let A=0,E=T;A<E;A++){V(d,3*A,f,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let C=v,R=v+b;C<R;C++){V(h,3*C,l,a),h.needsUpdate=!0;let w=h.distanceToTriangle(d,p,_);if(w<x&&(m.copy(p),g&&g.copy(_),x=w,y=C,S=A),w<s)return!0}}}}}),lt.releasePrimitive(h),lt.releasePrimitive(d),x===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=x,n.faceIndex=y,i&&(i.point?i.point.copy(g):i.point=g.clone(),i.point.applyMatrix4(Gn),m.applyMatrix4(Gn),i.distance=m.sub(i.point).length(),i.faceIndex=S),n)}function wr(c,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=c.geometry,n=e.index?e.index.array:null,i=e.attributes.position,s,r,o,a,l=0,u=c._roots;for(let h=0,d=u.length;h<d;h++)s=u[h],r=new Uint32Array(s),o=new Uint16Array(s),a=new Float32Array(s),f(0,l),l+=s.byteLength;function f(h,d,p=!1){let m=h*2;if(o[m+15]===65535){let g=r[h+6],x=o[m+14],y=1/0,S=1/0,v=1/0,b=-1/0,T=-1/0,A=-1/0;for(let E=g,C=g+x;E<C;E++){let R=3*c.resolveTriangleIndex(E);for(let w=0;w<3;w++){let P=R+w;P=n?n[P]:P;let L=i.getX(P),D=i.getY(P),O=i.getZ(P);L<y&&(y=L),L>b&&(b=L),D<S&&(S=D),D>T&&(T=D),O<v&&(v=O),O>A&&(A=O)}}return a[h+0]!==y||a[h+1]!==S||a[h+2]!==v||a[h+3]!==b||a[h+4]!==T||a[h+5]!==A?(a[h+0]=y,a[h+1]=S,a[h+2]=v,a[h+3]=b,a[h+4]=T,a[h+5]=A,!0):!1}else{let g=h+8,x=r[h+6],y=g+d,S=x+d,v=p,b=!1,T=!1;t?v||(b=t.has(y),T=t.has(S),v=!b&&!T):(b=!0,T=!0);let A=v||b,E=v||T,C=!1;A&&(C=f(g,d,v));let R=!1;E&&(R=f(x,d,v));let w=C||R;if(w)for(let P=0;P<3;P++){let L=g+P,D=x+P,O=a[L],it=a[L+3],Tt=a[D],At=a[D+3];a[h+P]=O<Tt?O:Tt,a[h+P+3]=it>At?it:At}return w}}}function Cr(c,t,e,n,i,s,r){B.setBuffer(c._roots[t]),hs(0,c,e,n,i,s,r),B.clearBuffer()}function hs(c,t,e,n,i,s,r){let{float32Array:o,uint16Array:a,uint32Array:l}=B,u=c*2;if(q(u,a)){let h=Z(c,l),d=$(u,a);yr(t,e,n,h,d,i,s,r)}else{let h=tt(c);xt(h,o,n,s,r)&&hs(h,t,e,n,i,s,r);let d=et(c,l);xt(d,o,n,s,r)&&hs(d,t,e,n,i,s,r)}}var dl=["x","y","z"];function Rr(c,t,e,n,i,s){B.setBuffer(c._roots[t]);let r=fs(0,c,e,n,i,s);return B.clearBuffer(),r}function fs(c,t,e,n,i,s){let{float32Array:r,uint16Array:o,uint32Array:a}=B,l=c*2;if(q(l,o)){let f=Z(c,a),h=$(l,o);return vr(t,e,n,f,h,i,s)}else{let f=Ln(c,a),h=dl[f],p=n.direction[h]>=0,m,_;p?(m=tt(c),_=et(c,a)):(m=et(c,a),_=tt(c));let x=xt(m,r,n,i,s)?fs(m,t,e,n,i,s):null;if(x){let v=x.point[h];if(p?v<=r[_+f]:v>=r[_+f+3])return x}let S=xt(_,r,n,i,s)?fs(_,t,e,n,i,s):null;return x&&S?x.distance<=S.distance?x:S:x||S||null}}var Hn=new X,Se=new nt,be=new nt,Xe=new W,Pr=new Y,Wn=new Y;function Ir(c,t,e,n){B.setBuffer(c._roots[t]);let i=ds(0,c,e,n);return B.clearBuffer(),i}function ds(c,t,e,n,i=null){let{float32Array:s,uint16Array:r,uint32Array:o}=B,a=c*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),Pr.set(e.boundingBox.min,e.boundingBox.max,n),i=Pr),q(a,r)){let u=t.geometry,f=u.index,h=u.attributes.position,d=e.index,p=e.attributes.position,m=Z(c,o),_=$(a,r);if(Xe.copy(n).invert(),e.boundsTree)return z(c,s,Wn),Wn.matrix.copy(Xe),Wn.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:x=>Wn.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(n),x.b.applyMatrix4(n),x.c.applyMatrix4(n),x.needsUpdate=!0;for(let y=m,S=_+m;y<S;y++)if(V(be,3*t.resolveTriangleIndex(y),f,h),be.needsUpdate=!0,x.intersectsTriangle(be))return!0;return!1}});for(let g=m,x=_+m;g<x;g++){let y=t.resolveTriangleIndex(g);V(Se,3*y,f,h),Se.a.applyMatrix4(Xe),Se.b.applyMatrix4(Xe),Se.c.applyMatrix4(Xe),Se.needsUpdate=!0;for(let S=0,v=d.count;S<v;S+=3)if(V(be,S,d,p),be.needsUpdate=!0,Se.intersectsTriangle(be))return!0}}else{let u=c+8,f=o[c+6];return z(u,s,Hn),!!(i.intersectsBox(Hn)&&ds(u,t,e,n,i)||(z(f,s,Hn),i.intersectsBox(Hn)&&ds(f,t,e,n,i)))}}var Xn=new W,ps=new Y,qe=new Y,pl=new M,ml=new M,gl=new M,_l=new M;function Lr(c,t,e,n={},i={},s=0,r=1/0){t.boundingBox||t.computeBoundingBox(),ps.set(t.boundingBox.min,t.boundingBox.max,e),ps.needsUpdate=!0;let o=c.geometry,a=o.attributes.position,l=o.index,u=t.attributes.position,f=t.index,h=lt.getPrimitive(),d=lt.getPrimitive(),p=pl,m=ml,_=null,g=null;i&&(_=gl,g=_l);let x=1/0,y=null,S=null;return Xn.copy(e).invert(),qe.matrix.copy(Xn),c.shapecast({boundsTraverseOrder:v=>ps.distanceToBox(v),intersectsBounds:(v,b,T)=>T<x&&T<r?(b&&(qe.min.copy(v.min),qe.max.copy(v.max),qe.needsUpdate=!0),!0):!1,intersectsRange:(v,b)=>{if(t.boundsTree){let T=t.boundsTree;return T.shapecast({boundsTraverseOrder:A=>qe.distanceToBox(A),intersectsBounds:(A,E,C)=>C<x&&C<r,intersectsRange:(A,E)=>{for(let C=A,R=A+E;C<R;C++){let w=T.resolveTriangleIndex(C);V(d,3*w,f,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=v,L=v+b;P<L;P++){let D=c.resolveTriangleIndex(P);V(h,3*D,l,a),h.needsUpdate=!0;let O=h.distanceToTriangle(d,p,_);if(O<x&&(m.copy(p),g&&g.copy(_),x=O,y=P,S=C),O<s)return!0}}}})}else{let T=Et(t);for(let A=0,E=T;A<E;A++){V(d,3*A,f,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let C=v,R=v+b;C<R;C++){let w=c.resolveTriangleIndex(C);V(h,3*w,l,a),h.needsUpdate=!0;let P=h.distanceToTriangle(d,p,_);if(P<x&&(m.copy(p),g&&g.copy(_),x=P,y=C,S=A),P<s)return!0}}}}}),lt.releasePrimitive(h),lt.releasePrimitive(d),x===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=x,n.faceIndex=y,i&&(i.point?i.point.copy(g):i.point=g.clone(),i.point.applyMatrix4(Xn),m.applyMatrix4(Xn),i.distance=m.sub(i.point).length(),i.faceIndex=S),n)}function Dr(){return typeof SharedArrayBuffer<"u"}var Ye=new B.constructor,qn=new B.constructor,Wt=new Gt(()=>new X),Te=new X,Ae=new X,ms=new X,gs=new X,_s=!1;function Nr(c,t,e,n){if(_s)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");_s=!0;let i=c._roots,s=t._roots,r,o=0,a=0,l=new W().copy(e).invert();for(let u=0,f=i.length;u<f;u++){Ye.setBuffer(i[u]),a=0;let h=Wt.getPrimitive();z(0,Ye.float32Array,h),h.applyMatrix4(l);for(let d=0,p=s.length;d<p&&(qn.setBuffer(s[d]),r=bt(0,0,e,l,n,o,a,0,0,h),qn.clearBuffer(),a+=s[d].length,!r);d++);if(Wt.releasePrimitive(h),Ye.clearBuffer(),o+=i[u].length,r)break}return _s=!1,r}function bt(c,t,e,n,i,s=0,r=0,o=0,a=0,l=null,u=!1){let f,h;u?(f=qn,h=Ye):(f=Ye,h=qn);let d=f.float32Array,p=f.uint32Array,m=f.uint16Array,_=h.float32Array,g=h.uint32Array,x=h.uint16Array,y=c*2,S=t*2,v=q(y,m),b=q(S,x),T=!1;if(b&&v)u?T=i(Z(t,g),$(t*2,x),Z(c,p),$(c*2,m),a,r+t,o,s+c):T=i(Z(c,p),$(c*2,m),Z(t,g),$(t*2,x),o,s+c,a,r+t);else if(b){let A=Wt.getPrimitive();z(t,_,A),A.applyMatrix4(e);let E=tt(c),C=et(c,p);z(E,d,Te),z(C,d,Ae);let R=A.intersectsBox(Te),w=A.intersectsBox(Ae);T=R&&bt(t,E,n,e,i,r,s,a,o+1,A,!u)||w&&bt(t,C,n,e,i,r,s,a,o+1,A,!u),Wt.releasePrimitive(A)}else{let A=tt(t),E=et(t,g);z(A,_,ms),z(E,_,gs);let C=l.intersectsBox(ms),R=l.intersectsBox(gs);if(C&&R)T=bt(c,A,e,n,i,s,r,o,a+1,l,u)||bt(c,E,e,n,i,s,r,o,a+1,l,u);else if(C)if(v)T=bt(c,A,e,n,i,s,r,o,a+1,l,u);else{let w=Wt.getPrimitive();w.copy(ms).applyMatrix4(e);let P=tt(c),L=et(c,p);z(P,d,Te),z(L,d,Ae);let D=w.intersectsBox(Te),O=w.intersectsBox(Ae);T=D&&bt(A,P,n,e,i,r,s,a,o+1,w,!u)||O&&bt(A,L,n,e,i,r,s,a,o+1,w,!u),Wt.releasePrimitive(w)}else if(R)if(v)T=bt(c,E,e,n,i,s,r,o,a+1,l,u);else{let w=Wt.getPrimitive();w.copy(gs).applyMatrix4(e);let P=tt(c),L=et(c,p);z(P,d,Te),z(L,d,Ae);let D=w.intersectsBox(Te),O=w.intersectsBox(Ae);T=D&&bt(E,P,n,e,i,r,s,a,o+1,w,!u)||O&&bt(E,L,n,e,i,r,s,a,o+1,w,!u),Wt.releasePrimitive(w)}}return T}var Yn=new Y,Ur=new X,xl={strategy:0,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null},Ze=class c{static serialize(t,e={}){e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,s=t._indirectBuffer,r=n.getIndex(),o;return e.cloneBuffers?o={roots:i.map(a=>a.slice()),index:r?r.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:r?r.array:null,indirectBuffer:s},o}static deserialize(t,e,n={}){n={setIndex:!0,indirect:!!t.indirectBuffer,...n};let{index:i,roots:s,indirectBuffer:r}=t,o=new c(e,{...n,[Rn]:!0});if(o._roots=s,o._indirectBuffer=r||null,n.setIndex){let a=e.getIndex();if(a===null){let l=new ot(t.index,1,!1);e.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({...xl,[Rn]:!1},e),e.useSharedArrayBuffer&&!Dr())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[Rn]||(cr(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new X))),this.resolveTriangleIndex=e.indirect?n=>this._indirectBuffer[n]:n=>n}refit(t=null){return(this.indirect?wr:xr)(this,t)}traverse(t,e=0){let n=this._roots[e],i=new Uint32Array(n),s=new Uint16Array(n);r(0);function r(o,a=0){let l=o*2,u=s[l+15]===65535;if(u){let f=i[o+6],h=s[l+14];t(a,u,new Float32Array(n,o*4,6),f,h)}else{let f=o+32/4,h=i[o+6],d=i[o+7];t(a,u,new Float32Array(n,o*4,6),d)||(r(f,a+1),r(h,a+1))}}}raycast(t,e=wn,n=0,i=1/0){let s=this._roots,r=this.geometry,o=[],a=e.isMaterial,l=Array.isArray(e),u=r.groups,f=a?e.side:e,h=this.indirect?Cr:Sr;for(let d=0,p=s.length;d<p;d++){let m=l?e[u[d].materialIndex].side:f,_=o.length;if(h(this,d,m,t,o,n,i),l){let g=u[d].materialIndex;for(let x=_,y=o.length;x<y;x++)o[x].face.materialIndex=g}}return o}raycastFirst(t,e=wn,n=0,i=1/0){let s=this._roots,r=this.geometry,o=e.isMaterial,a=Array.isArray(e),l=null,u=r.groups,f=o?e.side:e,h=this.indirect?Rr:br;for(let d=0,p=s.length;d<p;d++){let m=a?e[u[d].materialIndex].side:f,_=h(this,d,m,t,n,i);_!=null&&(l==null||_.distance<l.distance)&&(l=_,a&&(_.face.materialIndex=u[d].materialIndex))}return l}intersectsGeometry(t,e){let n=!1,i=this._roots,s=this.indirect?Ir:Ar;for(let r=0,o=i.length;r<o&&(n=s(this,r,t,e),!n);r++);return n}shapecast(t){let e=lt.getPrimitive(),n=this.indirect?Mr:_r,{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:o}=t;if(r&&o){let f=r;r=(h,d,p,m,_)=>f(h,d,p,m,_)?!0:n(h,d,this,o,p,m,e)}else r||(o?r=(f,h,d,p)=>n(f,h,this,o,d,p,e):r=(f,h,d)=>d);let a=!1,l=0,u=this._roots;for(let f=0,h=u.length;f<h;f++){let d=u[f];if(a=ur(this,f,s,r,i,l),a)break;l+=d.byteLength}return lt.releasePrimitive(e),a}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:s}=n,r=lt.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,l=this.indirect?p=>{let m=this.resolveTriangleIndex(p);V(r,m*3,o,a)}:p=>{V(r,p*3,o,a)},u=lt.getPrimitive(),f=t.geometry.index,h=t.geometry.attributes.position,d=t.indirect?p=>{let m=t.resolveTriangleIndex(p);V(u,m*3,f,h)}:p=>{V(u,p*3,f,h)};if(s){let p=(m,_,g,x,y,S,v,b)=>{for(let T=g,A=g+x;T<A;T++){d(T),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let E=m,C=m+_;E<C;E++)if(l(E),r.needsUpdate=!0,s(r,u,E,T,y,S,v,b))return!0}return!1};if(i){let m=i;i=function(_,g,x,y,S,v,b,T){return m(_,g,x,y,S,v,b,T)?!0:p(_,g,x,y,S,v,b,T)}}else i=p}return Nr(this,t,e,i)}intersectsBox(t,e){return Yn.set(t.min,t.max,e),Yn.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Yn.intersectsBox(n),intersectsTriangle:n=>Yn.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},s=0,r=1/0){return(this.indirect?Lr:Er)(this,t,e,n,i,s,r)}closestPointToPoint(t,e={},n=0,i=1/0){return hr(this,t,e,n,i)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{z(0,new Float32Array(n),Ur),t.union(Ur)}),t}};onmessage=({data:c})=>{let t=performance.now();function e(r){r=Math.min(r,1);let o=performance.now();o-t>=10&&r!==1&&(postMessage({error:null,serialized:null,position:null,progress:r}),t=o)}let{index:n,position:i,options:s}=c;try{let r=new Ue;if(r.setAttribute("position",new ot(i,3,!1)),n&&r.setIndex(new ot(n,1,!1)),s.includedProgressCallback&&(s.onProgress=e),s.groups){let u=s.groups;for(let f in u){let h=u[f];r.addGroup(h.start,h.count,h.materialIndex)}}let o=new Ze(r,s),a=Ze.serialize(o,{copyIndexBuffer:!1}),l=[i.buffer,...a.roots];a.index&&l.push(a.index.buffer),l=l.filter(u=>typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer)),o._indirectBuffer&&l.push(a.indirectBuffer.buffer),postMessage({error:null,serialized:a,position:i,progress:1},l)}catch(r){postMessage({error:r,serialized:null,position:null,progress:1})}};})();
3664
- `});var fi={};Kt(fi,{SimpleModelViewer:()=>Ot});module.exports=bn(fi);var l=require("react");var rt=require("three");var Mn="KHR_materials_variants",$t="riMaterialVariants";function ft(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Sn(t){if(!ft(t)||!ft(t.extensions))return[];let e=t.extensions[Mn];if(!ft(e)||!Array.isArray(e.variants))return[];let n=new Set;return e.variants.map((i,r)=>{let s=ft(i)&&typeof i.name=="string"&&i.name?i.name:`Variant ${r+1}`,o=s;for(let d=2;n.has(o);d+=1)o=`${s} (${d})`;return n.add(o),o})}function Jt(t){let e=t.parser,n=Sn(e?.json);if(!(!e||n.length===0))return t.scene.userData[$t]=n,{names:n,resolveMaterial:async(i,r)=>{let s={geometry:r.geometry,material:await e.getDependency("material",i),isPoints:r.isPoints,isLine:r.isLine};return e.assignFinalMaterial(s),s.material}}}function Qt(t){let e=t.userData?.[$t];return Array.isArray(e)&&e.every(n=>typeof n=="string")?e:[]}function pt(t){return[t.x,t.y,t.z]}function te(t){let e=new rt.Box3().setFromObject(t),n=0;return t.traverse(i=>{i.isMesh&&(n+=1)}),{bounds:{min:pt(e.min),max:pt(e.max),center:pt(e.getCenter(new rt.Vector3)),size:pt(e.getSize(new rt.Vector3))},objectCount:n,materialVariants:Qt(t)}}var yt=require("@react-three/drei"),N=require("@react-three/fiber"),je=require("@react-three/fiber");var ot=require("@react-three/fiber"),J=require("three"),B=require("three-stdlib"),be=require("three/examples/jsm/loaders/USDLoader.js");var K=require("fflate");var ee;function ne(t){ee=t}function at(t){ee?.(t)}var wn=[".glb",".gltf",".obj",".fbx",".usdz",".zip"],An=["model/gltf-binary","model/gltf+json","model/vnd.usdz+zip","application/vnd.usdz+zip","application/zip","application/x-zip-compressed"],st=1024*1024,ie=128*st,re=1024,ae=128*st,se=256*st,oe=200,Tn=st,D=new Map,ue=".glb,.gltf,.obj,.fbx,.usdz,.zip,model/gltf-binary,model/gltf+json,model/vnd.usdz+zip,application/vnd.usdz+zip,application/zip";function Et(t){let e=t.split(/[?#]/,1)[0].toLowerCase();return e.endsWith(".obj")?"obj":e.endsWith(".fbx")?"fbx":e.endsWith(".usdz")?"usdz":e.endsWith(".gltf")?"gltf":"glb"}function he(t){return D.get(t)??{format:Et(t)}}function En(t){let e=t.name.toLowerCase();return wn.some(n=>e.endsWith(n))||An.includes(t.type)}async function fe(t){if(!En(t))throw new Error("Unsupported model file. Please upload a .glb, .gltf, .obj, .fbx, .usdz, or .zip asset.");let e=t.name.toLowerCase();if(e.endsWith(".usdz")||t.type==="model/vnd.usdz+zip"||t.type==="application/vnd.usdz+zip")return le(t,"usdz");if(e.endsWith(".zip")||Cn(t.type))return Pn(t);if(e.endsWith(".gltf")||t.type==="model/gltf+json")return ce(t);let n=Et(t.name);return n==="gltf"?ce(t):le(t,n)}function le(t,e){let n=URL.createObjectURL(t);return D.set(n,{format:e,entryPath:t.name}),{url:n,name:t.name,format:e,cleanup:()=>{at(n),D.delete(n),URL.revokeObjectURL(n)}}}function Cn(t){return t==="application/zip"||t==="application/x-zip-compressed"}async function ce(t){let e=await t.text(),n=pe(e,t.name);for(let r of me(n))if(!Ct(r))throw new Error(`${t.name} references external assets. Upload a .zip containing the .gltf file and its dependencies.`);let i=URL.createObjectURL(t);return D.set(i,{format:"gltf",entryPath:t.name}),{url:i,name:t.name,format:"gltf",cleanup:()=>{at(i),D.delete(i),URL.revokeObjectURL(i)}}}async function Pn(t){if(t.size>ie)throw new Error(`Model zip is too large. The compressed archive must be ${Tt(ie)} or smaller.`);let e=await Nn(new Uint8Array(await t.arrayBuffer())),n=new Map;for(let[o,d]of Object.entries(e)){let c=Pt(o);!c||ge(c)||n.set(c,d)}let i=[...n.keys()].filter(o=>/\.(gltf|obj|fbx)$/i.test(o));if(i.length===0)throw new Error("Invalid model zip: no .gltf, .obj, or .fbx file found.");if(i.length>1)throw new Error("Invalid model zip: multiple model entry files found.");let r=i[0],s=Et(r);if(s==="gltf")return In(t,r,n);if(s==="obj"||s==="fbx")return Ln(t,r,s,n);throw new Error(`Unsupported model entry ${r}.`)}function Nn(t){return new Promise((e,n)=>{let i=0,r=0,s=null,o=c=>(s??(s=new Error(`Invalid model zip: ${c}`)),!1);(0,K.unzip)(t,{filter:c=>{if(s)return!1;if(i+=1,i>re)return o(`archive contains more than ${re.toLocaleString()} entries.`);if(c.originalSize>ae)return o(`${c.name} expands beyond the ${Tt(ae)} per-file limit.`);if(r+=c.originalSize,r>se)return o(`expanded contents exceed ${Tt(se)}.`);if(c.originalSize>=Tn&&(c.size===0||c.originalSize/c.size>oe))return o(`${c.name} exceeds the ${oe}:1 compression-ratio limit.`);let h=Pt(c.name);return!!h&&!ge(h)}},(c,h)=>{s?n(s):c?n(new Error(`Invalid model zip: ${c.message}`)):e(h)})})}function Tt(t){return`${t/st} MiB`}function Ln(t,e,n,i){let r=[],s={};for(let[d,c]of i){let h=URL.createObjectURL(new Blob([c],{type:ve(d)}));r.push(h),s[d]=h}let o=s[e];if(!o)throw r.forEach(d=>URL.revokeObjectURL(d)),new Error(`Invalid model zip: could not read ${e}.`);return D.set(o,{format:n,entryPath:e,resourceUrls:s}),{url:o,name:t.name,format:n,cleanup:()=>{at(o),D.delete(o),r.forEach(d=>URL.revokeObjectURL(d))}}}function In(t,e,n){let i=n.get(e);if(!i)throw new Error("Invalid GLTF zip: no .gltf found.");let r=pe((0,K.strFromU8)(i),e);Dn(r,e);let s=Rn(e),o=[];try{de(r.buffers,s,n,o),de(r.images,s,n,o);let d=new Blob([(0,K.strToU8)(JSON.stringify(r))],{type:"model/gltf+json"}),c=URL.createObjectURL(d);return o.push(c),D.set(c,{format:"gltf",entryPath:e}),{url:c,name:t.name,format:"gltf",cleanup:()=>{at(c),D.delete(c),o.forEach(h=>URL.revokeObjectURL(h))}}}catch(d){throw o.forEach(c=>URL.revokeObjectURL(c)),d}}function de(t,e,n,i){for(let r of t??[]){if(typeof r.uri!="string"||Ct(r.uri))continue;let s=Un(e,r.uri),o=n.get(s);if(!o)throw new Error(`Invalid GLTF zip: missing referenced asset ${r.uri}.`);let d=URL.createObjectURL(new Blob([o],{type:ve(s)}));i.push(d),r.uri=d}}function pe(t,e){try{return JSON.parse(t)}catch{throw new Error(`${e} is not a valid .gltf JSON file.`)}}function me(t){return[...t.buffers??[],...t.images??[]].map(e=>e.uri).filter(e=>typeof e=="string"&&e.length>0)}function Dn(t,e){for(let n of me(t)){if(Ct(n))continue;let i=/^[a-z][a-z0-9+.-]*:/i.test(n),r=n.startsWith("/")||n.startsWith("\\");if(i||r)throw new Error(`${e} references external assets. Include every dependency inside the uploaded .zip.`)}}function Ct(t){return t.startsWith("data:")}function Pt(t){let e=[];for(let n of t.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(i=>i&&i!==".")){if(n===".."){e.pop();continue}e.push(n)}return e.join("/")}function ge(t){let e=t.split("/");return t.endsWith("/")||e.includes("__MACOSX")||e.some(n=>n===".DS_Store"||n.startsWith("._"))}function Rn(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function Un(t,e){let n=e.split(/[?#]/)[0],i=zn(n);return Pt(t?`${t}/${i}`:i)}function zn(t){try{return decodeURI(t)}catch{return t}}function ve(t){let e=t.toLowerCase();return e.endsWith(".obj")||e.endsWith(".mtl")?"text/plain":e.endsWith(".fbx")?"application/octet-stream":e.endsWith(".usdz")?"model/vnd.usdz+zip":e.endsWith(".bin")?"application/octet-stream":e.endsWith(".png")?"image/png":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".webp")?"image/webp":e.endsWith(".avif")?"image/avif":e.endsWith(".ktx2")?"image/ktx2":"application/octet-stream"}var On=require("@react-three/drei"),Bn=require("@react-three/fiber"),kn=require("react"),_e=require("three"),$=require("three-stdlib");function Fn(t){return{name:"RI_unlit_emissive_texture",async afterRoot(e){let n=t.json.materials??[],i=new Map;if(n.forEach(s=>{let o=!!s?.extensions?.KHR_materials_unlit,d=!!s?.pbrMetallicRoughness?.baseColorTexture;o&&!d&&s?.emissiveTexture&&s.name&&i.set(s.name,s.emissiveTexture.index)}),i.size===0||!e.scene)return;let r=new Map;await Promise.all([...i].map(async([s,o])=>{let d=await t.getDependency("texture",o);d&&(d.colorSpace=_e.SRGBColorSpace,r.set(s,d))})),e.scene.traverse(s=>{let o=Array.isArray(s.material)?s.material:s.material?[s.material]:[];for(let d of o){let c=d.name?r.get(d.name):void 0;c&&!d.map&&(d.map=c,d.needsUpdate=!0)}})}}}var Vn="https://assets.react-immersive.liveroom.dev/three-r184/draco/",Hn="https://assets.react-immersive.liveroom.dev/three-r184/basis/";function xe(t,e={},n){let{dracoDecoderPath:i=Vn,ktx2TranscoderPath:r=Hn,meshopt:s=!0}=e;if(i){let o=new $.DRACOLoader;o.setDecoderPath(i),t.setDRACOLoader(o)}if(s&&t.setMeshoptDecoder($.MeshoptDecoder),r&&n){let o=new $.KTX2Loader().setTranscoderPath(r).detectSupport(n);t.setKTX2Loader(o)}t.register((o=>Fn(o)))}var mt=class extends J.Loader{constructor(){super(...arguments);this.options={source:{format:"glb"}}}configure(n){return this.options=n,this}load(n,i,r,s){this.loadAsset(n,r).then(i).catch(s)}async loadAsset(n,i){let r=Wn(this.options.source),{format:s}=this.options.source;if(s==="obj")return Gn(n,r,this.options.source,i);if(s==="fbx"){let c=Nt(this,new B.FBXLoader(r)),h=Xn(n,this.options.source);h&&c.setResourcePath(h);let _=await c.loadAsync(n,i);return Lt(_,"FBXMesh",!1),{scene:_,animations:_.animations??[]}}if(s==="usdz"){let h=await Nt(this,new be.USDLoader(r)).loadAsync(n,i);return Lt(h,"USDZMesh",!1),{scene:h,animations:h.animations??[]}}let o=Nt(this,new B.GLTFLoader(r));xe(o,this.options.decoderConfig,this.options.renderer);let d=await o.loadAsync(n,i);return{scene:d.scene,animations:d.animations??[],materialVariants:Jt(d)}}};ne(t=>{ot.useLoader.clear(mt,t)});function Me(t,e={},n,i){let r=(0,ot.useThree)(d=>d.gl),s=he(t),o=n?{...s,format:n}:s;return(0,ot.useLoader)(mt,t,d=>{d.configure({source:o,decoderConfig:e,renderer:r})},i)}async function Gn(t,e,n,i){let r=await ye(t,e,i),s=new B.OBJLoader(e),o=jn(r);if(o){let c=qn(o,t,n);if(c)try{let h=await ye(c.url,e),M=new B.MTLLoader(e).parse(h,c.basePath);M.preload(),s.setMaterials(M)}catch(h){console.warn(`[react-immersive] Could not load OBJ material ${o}; rendering geometry with fallback materials.`,h)}}let d=s.parse(r);return Lt(d,"OBJMesh",!0),{scene:d,animations:[]}}function Lt(t,e,n){let i=new Set,r=0;t.traverse(s=>{if(!("isMesh"in s&&s.isMesh===!0)){s.name&&i.add(s.name);return}let d=s.name||`${e}_${++r}`;if(!n&&s.name){i.add(s.name);return}let c=d,h=2;for(;i.has(c);)c=`${d}_${h++}`;s.name=c,i.add(c)})}function ye(t,e,n){let i=new J.FileLoader(e);return i.setResponseType("text"),i.loadAsync(t,n)}function Nt(t,e){return e.setCrossOrigin(t.crossOrigin),e.setWithCredentials(t.withCredentials),e.setRequestHeader(t.requestHeader),e}function Wn(t){let e=new J.LoadingManager,n=t.resourceUrls;return n&&e.setURLModifier(i=>{if(/^(?:blob:|data:)/i.test(i))return i;let r=vt(we(i).split(/[?#]/)[0]),s=n[r];if(s)return s;let o=gt(t.entryPath??""),d=vt(o?`${o}/${r}`:r);return n[d]??i}),e}function jn(t){return/^\s*mtllib\s+(.+?)\s*$/im.exec(t)?.[1]?.trim()||null}function qn(t,e,n){if(n.resourceUrls&&n.entryPath){let i=vt(`${gt(n.entryPath)}/${we(t)}`),r=n.resourceUrls[i];if(!r)return null;let s=gt(i);return{url:r,basePath:s?`${s}/`:""}}try{let i=new URL(t,e).href;return{url:i,basePath:Se(i)}}catch{return null}}function Xn(t,e){if(e.resourceUrls&&e.entryPath){let n=gt(e.entryPath);return n?`${n}/`:""}return Se(t)}function Se(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e+1)}function gt(t){let e=vt(t),n=e.lastIndexOf("/");return n===-1?"":e.slice(0,n)}function vt(t){let e=[];for(let n of t.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(i=>i&&i!=="."))n===".."?e.pop():e.push(n);return e.join("/")}function we(t){try{return decodeURI(t)}catch{return t}}var k=require("react/jsx-runtime");function Ae({visible:t,message:e,tone:n="default",progress:i}){if(!t)return null;let r=typeof i=="number"&&Number.isFinite(i),s=r?Math.min(Math.max(i,0),100):0,o=Math.round(s);return(0,k.jsxs)("div",{className:"bb-loadingOverlay",role:"status","aria-live":"polite",children:[r&&(0,k.jsxs)("div",{className:"bb-loadingProgressRow",children:[(0,k.jsx)("div",{className:"bb-loadingProgress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,k.jsx)("div",{className:"bb-loadingProgress__bar",style:{width:`${o}%`}})}),(0,k.jsxs)("span",{className:"bb-loadingProgress__label",children:[o,"%"]})]}),(0,k.jsx)("span",{className:`bb-loadingMessage bb-status--${n}`,children:e})]})}var T=require("three");var F=require("three");function Te(t){return!!(t&&typeof t=="object"&&"clone"in t&&"color"in t&&"metalness"in t&&"roughness"in t)}function Ee(t){if(Te(t))return t;if(!t||typeof t!="object")return null;let e=t,n=new T.MeshStandardMaterial;typeof e.name=="string"&&(n.name=e.name),n.metalness=0,n.roughness=1,e.type==="MeshBasicMaterial"||e.isMeshBasicMaterial===!0?(n.color.set(0),n.emissiveIntensity=1,e.map instanceof T.Texture?(n.emissiveMap=e.map,n.emissive.set(16777215)):e.color instanceof T.Color&&n.emissive.copy(e.color)):(e.color instanceof T.Color&&n.color.copy(e.color),e.map instanceof T.Texture&&(n.map=e.map),e.emissive instanceof T.Color&&n.emissive.copy(e.emissive),e.emissiveMap instanceof T.Texture&&(n.emissiveMap=e.emissiveMap));let r=["aoMap","aoMapIntensity","lightMap","lightMapIntensity","alphaMap","opacity","transparent","alphaTest","side","vertexColors","wireframe","depthTest","depthWrite","visible","toneMapped","fog"];for(let s of r)e[s]!==void 0&&(n[s]=e[s]);return n.needsUpdate=!0,n}function Ce(t){t.updateMatrixWorld(!0),t.traverse(e=>{let n=e;n.isSkinnedMesh&&(n.skeleton?.update(),n.computeBoundingBox?.(),n.computeBoundingSphere?.())})}var tt=require("three"),V=require("three-mesh-bvh"),Le=!1,Q=new WeakMap,lt=new WeakMap;function Zn(){Le||(tt.Mesh.prototype.raycast=V.acceleratedRaycast,Le=!0)}function Kn(t){let e=new Set;return t.traverse(n=>{let i=n.geometry;!i||!i.attributes?.position||e.add(i)}),[...e]}function Ie(t){let e=0;for(let n of t){let i=n.index?n.index.count:n.attributes.position.count;e+=i/3}return e}var _t=12e6;function De(t){return It(t)>_t}function It(t){let e=new Set;return t.traverse(n=>{let i=n.geometry;i?.attributes?.position&&e.add(i)}),Ie([...e])}function $n(t,e){return new Promise((n,i)=>{let r=h=>{let _=h.data;if(!_||!_.error&&!_.serialized)return;if(t.removeEventListener("message",r),t.removeEventListener("error",s),_.error){i(new Error(String(_.error)));return}let{serialized:M}=_,L=V.MeshBVH.deserialize(M,e,{setIndex:!1});M.index&&(e.index?e.index.array=M.index:e.setIndex(new tt.BufferAttribute(M.index,1,!1))),e.boundingBox=L.getBoundingBox(new tt.Box3),n(L)},s=h=>{t.removeEventListener("message",r),t.removeEventListener("error",s),i(new Error(h.message||"BVH worker error"))};t.addEventListener("message",r),t.addEventListener("error",s);let o=e.index?e.index.array.slice():null,d=e.attributes.position.array.slice(),c=[d,...o?[o]:[]].map(h=>h.buffer);t.postMessage({index:o,position:d,options:{groups:[...e.groups]}},c)})}async function Jn(){if(typeof window>"u"||typeof Worker>"u")return null;try{let{bvhWorkerCode:t}=await Promise.resolve().then(()=>(Ne(),Pe)),e=new Blob([t],{type:"text/javascript"}),n=URL.createObjectURL(e),i=new Worker(n);return{worker:i,dispose:()=>{i.terminate(),URL.revokeObjectURL(n)}}}catch{return null}}async function Qn(t,e){if(e)try{return await $n(e,t)}catch{}let n=V.computeBoundsTree.call(t);return t.boundsTree=void 0,await new Promise(i=>setTimeout(i,0)),n}async function ti(t,e,n){if(t.boundsTree)return;if(e.buildPromise)return e.buildPromise;let i=(async()=>{let r=await n();e.references>0&&!t.boundsTree&&(t.boundsTree=r,e.ownedTree=r)})();return e.buildPromise=i.finally(()=>{e.buildPromise=void 0,e.references===0&&Q.delete(t)}),e.buildPromise}async function Re(t,e){if(e?.aborted)return;let n=lt.get(t);if(!n){if(n=Kn(t),Ie(n)>_t){lt.set(t,[]);return}lt.set(t,n);for(let r of n){let s=Q.get(r)??{references:0};s.references+=1,Q.set(r,s)}}if(n.length===0)return;Zn();let i=await Jn();if(e?.aborted){i?.dispose();return}try{for(let r of n){if(e?.aborted)return;let s=Q.get(r);s&&await ti(r,s,()=>Qn(r,i?.worker))}}finally{i?.dispose()}}function Ue(t){let e=lt.get(t);if(e){lt.delete(t);for(let n of e){let i=Q.get(n);i&&(i.references=Math.max(0,i.references-1),!(i.references>0)&&(i.ownedTree&&n.boundsTree===i.ownedTree&&(V.disposeBoundsTree.call(n),n.boundsTree=void 0),i.ownedTree=void 0,i.buildPromise||Q.delete(n)))}}}var H=require("three"),qe=require("three-stdlib");var g=require("lucide-react");var j=require("react"),ze=require("@react-three/fiber");function Oe(){let t=(0,ze.useThree)(r=>r.gl.domElement),e=(0,j.useRef)(void 0),n=(0,j.useCallback)(r=>{e.current===void 0&&(e.current=t.style.cursor),t.style.cursor=r},[t]),i=(0,j.useCallback)(()=>{let r=e.current;r!==void 0&&(t.style.cursor=r,e.current=void 0)},[t]);return(0,j.useEffect)(()=>()=>{i()},[i]),{setCanvasCursor:n,restoreCanvasCursor:i}}var ke=require("react"),ei={"model-viewer":"@liveroom-tech/react-immersive/styles.css","simple-model-viewer":"@liveroom-tech/react-immersive/simple-model-viewer.css","binding-builder":"@liveroom-tech/react-immersive/binding-builder.css"},Dt=new Set,ni=1e3;function Be(t){return getComputedStyle(document.documentElement).getPropertyValue(`--ri-styles-${t}`).trim()!==""}function Fe(t,e){(0,ke.useEffect)(()=>{if(process.env.NODE_ENV==="production"||Dt.has(t)||Be(t))return;let n,i=()=>{n=setTimeout(()=>{Dt.has(t)||Be(t)||(Dt.add(t),console.warn(`[react-immersive] ${e}'s styles aren't loaded, so it renders unstyled. Import them once, in your app's root:
3664
+ `});var Fr={};Pe(Fr,{DEFAULT_MODEL_VIEWER_LABELS:()=>bt,SimpleModelViewer:()=>ce});module.exports=Ri(Fr);var at=require("react");var bt={verifyingLicense:"Verifying License",checkingYourLicenseKey:"Checking your license key...",invalidLicense:"Invalid License",licenseHasBeenRevokedOrHasExpired:"License has been revoked or has expired",failedToLoadPleaseContactTheSiteAdministrator:"Failed to load. Please contact the site administrator.",contextRestoringTitle:"Reloading viewer\u2026",contextLostTitle:"3D view interrupted",contextRestoringMessage:"Rebuilding the 3D view. Please wait\u2026",contextLostMessage:"The graphics connection was interrupted. The viewer will rebuild when it returns, or you can reload it now.",reloadViewer:"Reload viewer",texturePositioningHint:"Drag to move \xB7 Scroll to zoom \xB7 Click elsewhere to finish",texturePositioningStartHint:"Double-click to move or zoom",dismiss:"Dismiss",missingUVsAreShownInMagenta:"Missing UVs are shown in magenta.",viewThisModelInARWithAppleQuickLook:"View this model in AR with Apple Quick Look",viewInAR:"View in AR",openThisExperienceOnAPhoneForAR:"Open this experience on a phone for AR",openOnPhone:"Open on phone",viewThisModelInYourSpace:"View this model in your space",viewThisModelInVR:"View this model in VR",closePhoneHandoff:"Close phone handoff",arScanCode:"Scan the code and choose AR.",qrCodeToOpenThisModelOnAPhone:"QR code to open this model on a phone",disableUVChecker:"Disable UV checker",enableUVChecker:"Enable UV checker",explodedView:"Exploded view",explodeAmount:"Explode amount",removeSectionCut:"Remove section cut",sectionCut:"Section cut",sectionAxis:"Section axis",sectionPosition:"Section position",keepTheOtherSide:"Keep the other side",pauseCinematic:"Pause cinematic",playCinematic:"Play cinematic",stopCinematicAndResetCamera:"Stop cinematic and reset camera",cancel:"Cancel",annotationCategories:"Annotation categories",annotations:"Annotations",all:"All",uncategorized:"Uncategorized",decalDragHint:"Drag the decal on the object. Release to save; Escape to cancel.",showAll:"Show all",materialVariants:"Material variants",startGuidedTour:"Start guided tour",guidedTour:"Guided Tour",previousAnnotation:"Previous annotation",previous:"Prev",stopGuidedTour:"Stop guided tour",nextAnnotation:"Next annotation",next:"Next",exitFullscreen:"Exit fullscreen",enterFullscreen:"Enter fullscreen",resetCameraView:"Reset camera view",orbitControl:"Orbit Control",pointLock:"Point Lock",cameraController:"Camera controller",cameraControllerSettings:"Camera controller settings",downloadGLB:"Download GLB",downloadPNG:"Download PNG",downloadUVLayout:"Download UV Layout",videoFormat:"Video format",auto:"Auto",recordTurntableVideo:"Record turntable video",recordCinematicVideo:"Record cinematic video",videoUnsupported:"Video recording is not supported in this browser.",downloadOptions:"Download options",exporting:"Exporting\u2026",download:"Download",annotationTitlePlaceholder:"Title *",description:"Description",ok:"OK",arRelocate:"Relocate",tapToPlace:"Tap to place",closeAnnotation:"Close annotation",learnMore:"Learn more",stopMeasuring:"Stop measuring",startMeasuring:"Start measuring",toggleBoundingDimensions:"Toggle bounding dimensions",measurementTool:"Measurement tool",distance:"Distance",angle:"Angle",area:"Area",pointToPlane:"Point to plane",measurementSnapping:"Measurement snapping",noSnapping:"No snapping",snapAuto:"Snap: auto",snapVertex:"Snap: vertex",snapEdge:"Snap: edge",undoMeasurementPoint:"Undo measurement point",clearMeasurements:"Clear measurements",finishArea:"Finish area",openSceneObjectsPanel:"Open scene objects panel",sceneObjects:"SCENE OBJECTS",searchNodesLabels:"Search nodes, labels",closeSceneObjectsPanel:"Close scene objects panel",objectNavigator:"Objects in the 3D view",compareBefore:"Before",compareAfter:"After",compareDivider:"Comparison divider",viewIn3D:"View in 3D",objectNavigatorHint:"Arrow keys browse \xB7 Enter selects \xB7 Esc clears",selectionCleared:"Selection cleared",cameraKeyboardHelp:"3D view. Arrow keys orbit, Shift with Up or Down zooms, and W, A, S, D, Space and C move the camera.",isolate:"Isolate",hide:"Hide",show:"Show",closePanel:"Close panel",actions:"Actions",openPanel:"Open panel",close:"Close",position:"Position",decalNudgeHint:"Click to fine-tune \xB7 Hold to move",decalNudgeControls:"Move decal in small steps",text:"Text",yourText:"Your text",textToAdd:"Text to add",textColour:"Text colour",addText:"Add text",image:"Image",chooseImage:"Choose image",imageToAdd:"Image to add",added:"Added",colour:"Colour",size:"Size",turn:"Turn",rotation:"Rotation",dragTheDecalAcrossTheObjectsSurface:"Drag the decal across the object's surface",move:"Move",remove:"Remove",noneAddedYet:"None added yet",done:"Done",moveForward:"Move forward",moveLeft:"Move left",moveRight:"Move right",moveBackward:"Move backward",sceneSettings:"Scene Settings",background:"Background",backgroundColor:"Background Color",environment:"Environment",autoRotate:"Auto Rotate",lighting:"Lighting",exposure:"Exposure",ambientLightIntensity:"Ambient Light Intensity",ambientLightColor:"Ambient Light Color",directLightIntensity:"Direct Light Intensity",directLightColor:"Direct Light Color",searchObjects:"Search objects",uploadedModel:"Uploaded model",clear:"Clear",chooseModel:"Choose model",loadingModel:"Loading model...",releaseToLoadYourModel:"Release to load your model",arFindSurface:"Move your device over a flat surface",arReleaseToPlace:"Release to place",arGestureHint:"Pinch to resize \xB7 Twist to rotate",angleFirstArmHint:"Pick the first arm",angleVertexHint:"Pick the angle's vertex",angleSecondArmHint:"Pick the second arm",angleNewHint:"Pick a point to start a new angle",areaNewHint:"Pick a point to start a new area",areaCornersHint:"Pick polygon corners in order, then Finish area",pointToPlaneFaceHint:"Pick the reference face",pointToPlanePointHint:"Pick a point to measure its perpendicular distance",pointToPlaneNewHint:"Pick a face to start a new measurement",distanceHint:"Pick points on the model to measure distances",visibleEntries:"{count} visible entries",objectCount:"{count} objects",annotationMarker:"Annotation {id}: {title}",recordingVideo:"Recording video \xB7 {progress}%",isolatedObjects:"Isolated: {count} objects",largeModelWarning:"Very large model ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the objects panel to select parts.",preparingLargeModel:"Preparing large model ({millions}M triangles) \u2014 the first display can take a while on this device...",enterAR:"Enter AR",enterVR:"Enter VR",decalImage:"Image {index}",decalText:"Text {index}",decalAdded:"{count} added",up:"up",down:"down",left:"left",right:"right",moveDecal:"Move decal {direction}",moveDecalOnSurface:"Move {direction} on the visible surface",showAllObject:"Show all {name}",isolateObject:"Isolate {name}",isolatedObject:"Isolated: {name}",hideObject:"Hide {name}",showObject:"Show {name}",objectSelected:"{name} selected",objectNavigatorPosition:"{position} of {count}",compareDividerValue:"{before} {percent}%, {after} {rest}%",bindingMismatchOne:"1 object binding doesn't match this model",bindingMismatchMany:"{count} object bindings don't match this model",simpleLargeModelWarning:"Very large model detected ({millions}M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts.",dropModelHint:"Drag and drop {formats} here",loadErrorTitle:"This model couldn't be loaded",loadErrorNotFound:"Nothing was found at this address ({status}). Check that modelUrl points to the file.",loadErrorDenied:"The server refused access to the file ({status}). Check that the file is public, or that a signed URL hasn't expired.",loadErrorStatus:"The server responded with {status} when the file was requested.",loadErrorNetwork:"The download was blocked or failed. Check that the URL is correct and, if the file is on another domain, that its server allows cross-origin requests (CORS) from this site.",loadErrorHtml:"The server sent back a web page instead of a model. There's probably no file at this path: many servers answer a missing file with their index.html.",loadErrorInvalidFile:"The file couldn't be read as {format}. Check that it's a valid {format} file.",loadErrorInvalidExplicitFormat:"The file couldn't be read as {format}. Check that it's a valid {format} file and that modelFormat matches it.",loadErrorMissingFormat:"The file couldn't be read as {format}. The URL has no file extension, so set modelFormat to the file's format.",loadErrorPointCloud:"This PLY file is a point cloud: it has points but no faces, and the viewer shows meshes. Turn it into a mesh first, for example with MeshLab or Blender.",measurementReferenceFaceRequired:"Pick a triangle face to define the reference plane.",measurementTooManyPoints:"Finish or clear this measurement before adding more points.",measurementAngleDistinct:"Pick a point away from the angle's vertex.",areaMinimumPoints:"Pick at least three points to finish the area.",areaDistinctPoints:"Area points must be distinct.",areaStraightLine:"Area points must not lie on one straight line.",areaNotPlanar:"Area points must lie on one plane.",areaEdgesCross:"Area edges must not cross or touch each other.",areaZero:"The polygon has no measurable area.",decalSurfaceMissing:"Could not find a surface on this object for the decal.",decalDirectionMissing:"No visible surface in that direction. Try another arrow or rotate the view.",fullscreenExitFailed:"Could not exit fullscreen. Press Escape to exit.",fullscreenEnterFailed:"Could not enter fullscreen. Check your browser or iframe fullscreen permissions and try again.",uvCoordinatesMissing:"This model does not contain UV coordinates.",uvExportFailed:"Could not create the UV layout archive.",videoExportFailed:"Could not export the video.",videoNotReady:"Viewer not ready for video export.",videoExitXR:"Exit the XR session before recording a video.",videoAlreadyRecording:"A video export is already in progress.",videoPathRequired:"Enable a cinematic camera path before recording it.",videoDurationInvalid:"Video duration must be greater than 0 and at most 300 seconds.",videoFrameRateInvalid:"Video frame rate must be between 1 and 60.",videoBitrateInvalid:"Video bitrate must be a positive number.",videoContextLost:"Video export stopped because the WebGL context was lost.",videoTimedOut:"Video export timed out. Keep the viewer tab visible while recording.",videoEncodingFailed:"The browser could not encode the video.",videoEmpty:"The browser produced an empty video.",videoDidNotStart:"Video recording did not start.",videoWebMUnsupported:"Video recording as WEBM is not supported in this browser.",videoMP4Unsupported:"Video recording as MP4 is not supported in this browser.",videoGIFUnsupported:"Video recording as GIF is not supported in this browser.",videoGifWidthInvalid:"GIF width must be a whole number of pixels from 16 to 4096.",environmentApartment:"apartment",environmentCity:"city",environmentDawn:"dawn",environmentForest:"forest",environmentLobby:"lobby",environmentNight:"night",environmentPark:"park",environmentStudio:"studio",environmentSunset:"sunset",environmentWarehouse:"warehouse",color:"Color",material:"Material",texturePreview:"texture preview",noTextureApplied:"No texture applied",noTextureCoordinates:"This part has no texture coordinates, so an image can't be placed on it.",replaceImage:"Replace image",uploadImage:"Upload image",removeTexture:"Remove texture",texturePosition:"Texture position",offsetX:"Offset X",offsetY:"Offset Y",confirmTexturePosition:"Confirm this texture position and exit positioning mode",donePositioning:"Done positioning",textureOffsetHint:"Double-click the object in the preview to drag its texture directly (scroll to zoom), or edit its offset numerically.",actionToggleLight:"Toggle Light",actionChangeLightColor:"Change Light Color",actionSetBrightness:"Set Brightness",actionChangeColor:"Change Color",actionChangeMaterial:"Change Material",actionToggleVisibility:"Toggle Visibility"};function qt(t,e,n={}){return(t?.[e]??bt[e]).replace(/\{(\w+)\}/g,(r,a)=>Object.prototype.hasOwnProperty.call(n,a)?String(n[a]):r)}var Ii=new Map(Object.entries(bt).map(([t,e])=>[e,t]));function Ce(t,e){let n=Ii.get(e);return n?qt(t,n):e}var Re=require("react/jsx-runtime"),Le=(0,at.createContext)(void 0);function Ne({labels:t,children:e}){return(0,Re.jsx)(Le.Provider,{value:t,children:e})}function ot(){let t=(0,at.useContext)(Le);return(0,at.useMemo)(()=>Object.assign((e,n)=>qt(t,e,n),{message:e=>Ce(t,e)}),[t])}var Ie=require("react"),De="(prefers-reduced-motion: reduce)";function Di(t){if(typeof window>"u"||!window.matchMedia)return()=>{};let e=window.matchMedia(De);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}var Ui=()=>typeof window<"u"&&!!window.matchMedia?.(De).matches;function Ue(t="user"){let e=(0,Ie.useSyncExternalStore)(Di,Ui,()=>!1);return t==="always"?!0:t==="never"?!1:e}var d=require("react");var ht=require("three");var Oe="KHR_materials_variants",ze="riMaterialVariants",Be="riMaterialVariantGroups";function I(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Oi(t){if(!I(t)||!I(t.extensions))return[];let e=t.extensions[Oe];if(!I(e)||!Array.isArray(e.variants))return[];let n=new Set;return e.variants.map((i,r)=>{let a=I(i)&&typeof i.name=="string"&&i.name?i.name:`Variant ${r+1}`,s=a;for(let c=2;n.has(s);c+=1)s=`${a} (${c})`;return n.add(s),s})}var zi=/^\s*(.+?)\s*(?::|\s\/\s)\s*(.+?)\s*$/;function Bi(t){let e=Math.min(Math.max(t,0),1),n=e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055;return Math.round(n*255)}function ki(t){if(!I(t))return;let e=I(t.pbrMetallicRoughness)?t.pbrMetallicRoughness:{};if(e.baseColorTexture!==void 0)return;let n=Array.isArray(e.baseColorFactor)?e.baseColorFactor:[1,1,1,1];if(n.slice(0,3).every(i=>typeof i=="number"))return`#${n.slice(0,3).map(i=>Bi(i).toString(16).padStart(2,"0")).join("")}`}function Vi(t,e){if(e.length===0)return[];let n=I(t)?t:{},i=Array.isArray(n.meshes)?n.meshes:[],r=Array.isArray(n.accessors)?n.accessors:[],a=Array.isArray(n.materials)?n.materials:[],s=e.map(()=>new Set),c=e.map(()=>new Map);i.forEach((f,p)=>{(I(f)&&Array.isArray(f.primitives)?f.primitives:[]).forEach((y,x)=>{if(!I(y))return;let b=I(y.extensions)?y.extensions[Oe]:void 0;if(!I(b)||!Array.isArray(b.mappings))return;let N=I(y.attributes)?y.attributes.POSITION:void 0,w=typeof N=="number"?r[N]:void 0,L=I(w)&&typeof w.count=="number"?w.count:1;for(let R of b.mappings)if(!(!I(R)||!Number.isInteger(R.material)||!Array.isArray(R.variants)))for(let z of R.variants){if(!Number.isInteger(z)||!s[z])continue;s[z].add(`${p}/${x}`);let $=c[z],k=R.material;$.set(k,($.get(k)??0)+L)}})});let l=e.map((f,p)=>{let M=null;for(let[x,b]of c[p])(M===null||b>(c[p].get(M)??0))&&(M=x);let y=M===null?void 0:ki(a[M]);return{name:f,label:f,...y?{swatch:y}:{}}}),u=e.map(()=>-1),m=[],_=new Map;return e.forEach((f,p)=>{let M=zi.exec(f);if(!M)return;let[,y,x]=M;_.has(y)||(_.set(y,m.length),m.push({name:y,members:[]})),u[p]=_.get(y),m[u[p]].members.push(p),l[p].label=x}),e.map((f,p)=>p).filter(f=>u[f]<0).sort((f,p)=>+(s[f].size===0)-+(s[p].size===0)).forEach(f=>{let p=m.map((x,b)=>({group:x,groupIndex:b})).filter(({group:x})=>x.name===null&&x.members.some(b=>s[f].size===0||s[b].size===0?!1:[...s[f]].some(N=>s[b].has(N)))).map(({groupIndex:x})=>x);if(p.length===0&&s[f].size===0){let x=m.findIndex(b=>b.name===null);x>=0&&p.push(x)}if(p.length===0){u[f]=m.length,m.push({name:null,members:[f]});return}let[M,...y]=p;for(let x of y){for(let b of m[x].members)u[b]=M;m[M].members.push(...m[x].members),m[x].members=[]}u[f]=M,m[M].members.push(f)}),m.filter(f=>f.members.length>0).sort((f,p)=>Math.min(...f.members)-Math.min(...p.members)).map(f=>({name:f.name,variants:[...f.members].sort((p,M)=>p-M).map(p=>l[p])}))}function ke(t){let e=t.parser,n=Oi(e?.json);if(!(!e||n.length===0))return t.scene.userData[ze]=n,t.scene.userData[Be]=Vi(e.json,n),{names:n,resolveMaterial:async(i,r)=>{let a={geometry:r.geometry,material:await e.getDependency("material",i),isPoints:r.isPoints,isLine:r.isLine};return e.assignFinalMaterial(a),a.material}}}function Xt(t){let e=t.userData?.[ze];return Array.isArray(e)&&e.every(n=>typeof n=="string")?e:[]}function Ve(t){let e=t.userData?.[Be];if(Array.isArray(e))return e;let n=Xt(t);return n.length>0?[{name:null,variants:n.map(i=>({name:i,label:i}))}]:[]}function Mt(t){return[t.x,t.y,t.z]}function Fe(t){let e=new ht.Box3().setFromObject(t),n=0;return t.traverse(i=>{i.isMesh&&(n+=1)}),{bounds:{min:Mt(e.min),max:Mt(e.max),center:Mt(e.getCenter(new ht.Vector3)),size:Mt(e.getSize(new ht.Vector3))},objectCount:n,materialVariants:Xt(t),materialVariantGroups:Ve(t)}}var It=require("@react-three/drei"),F=require("@react-three/fiber"),ni=require("@react-three/fiber");var mt=require("@react-three/fiber"),Q=require("three"),q=require("three-stdlib"),gn=require("three/examples/jsm/loaders/USDLoader.js");var st=require("fflate");var He;function Ge(t){He=t}function pt(t){He?.(t)}var Fi=[".glb",".gltf",".obj",".fbx",".usdz",".stl",".ply",".zip"],Hi=["model/gltf-binary","model/gltf+json","model/vnd.usdz+zip","application/vnd.usdz+zip","application/zip","application/x-zip-compressed"],ft=1024*1024,We=128*ft,je=1024,qe=128*ft,Xe=256*ft,Ye=200,Gi=ft,W=new Map,Je=".glb,.gltf,.obj,.fbx,.usdz,.stl,.ply,.zip,model/gltf-binary,model/gltf+json,model/vnd.usdz+zip,application/vnd.usdz+zip,application/zip";function Zt(t){let e=t.split(/[?#]/,1)[0].toLowerCase();return e.endsWith(".obj")?"obj":e.endsWith(".fbx")?"fbx":e.endsWith(".usdz")?"usdz":e.endsWith(".stl")?"stl":e.endsWith(".ply")?"ply":e.endsWith(".gltf")?"gltf":"glb"}function Qe(t){return W.get(t)??{format:Zt(t)}}function Wi(t){let e=t.name.toLowerCase();return Fi.some(n=>e.endsWith(n))||Hi.includes(t.type)}async function tn(t){if(!Wi(t))throw new Error("Unsupported model file. Please upload a .glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, or .zip asset.");let e=t.name.toLowerCase();if(e.endsWith(".usdz")||t.type==="model/vnd.usdz+zip"||t.type==="application/vnd.usdz+zip")return Ze(t,"usdz");if(e.endsWith(".zip")||ji(t.type))return qi(t);if(e.endsWith(".gltf")||t.type==="model/gltf+json")return Ke(t);let n=Zt(t.name);return n==="gltf"?Ke(t):Ze(t,n)}function Ze(t,e){let n=URL.createObjectURL(t);return W.set(n,{format:e,entryPath:t.name}),{url:n,name:t.name,format:e,cleanup:()=>{pt(n),W.delete(n),URL.revokeObjectURL(n)}}}function ji(t){return t==="application/zip"||t==="application/x-zip-compressed"}async function Ke(t){let e=await t.text(),n=en(e,t.name);for(let r of nn(n))if(!Kt(r))throw new Error(`${t.name} references external assets. Upload a .zip containing the .gltf file and its dependencies.`);let i=URL.createObjectURL(t);return W.set(i,{format:"gltf",entryPath:t.name}),{url:i,name:t.name,format:"gltf",cleanup:()=>{pt(i),W.delete(i),URL.revokeObjectURL(i)}}}async function qi(t){if(t.size>We)throw new Error(`Model zip is too large. The compressed archive must be ${Yt(We)} or smaller.`);let e=await Xi(new Uint8Array(await t.arrayBuffer())),n=new Map;for(let[s,c]of Object.entries(e)){let l=$t(s);!l||rn(l)||n.set(l,c)}let i=[...n.keys()].filter(s=>/\.(gltf|obj|fbx|stl|ply)$/i.test(s));if(i.length===0)throw new Error("Invalid model zip: no .gltf, .obj, .fbx, .stl, or .ply file found.");if(i.length>1)throw new Error("Invalid model zip: multiple model entry files found.");let r=i[0],a=Zt(r);if(a==="gltf")return Zi(t,r,n);if(a==="obj"||a==="fbx"||a==="stl"||a==="ply")return Yi(t,r,a,n);throw new Error(`Unsupported model entry ${r}.`)}function Xi(t){return new Promise((e,n)=>{let i=0,r=0,a=null,s=l=>(a??(a=new Error(`Invalid model zip: ${l}`)),!1);(0,st.unzip)(t,{filter:l=>{if(a)return!1;if(i+=1,i>je)return s(`archive contains more than ${je.toLocaleString()} entries.`);if(l.originalSize>qe)return s(`${l.name} expands beyond the ${Yt(qe)} per-file limit.`);if(r+=l.originalSize,r>Xe)return s(`expanded contents exceed ${Yt(Xe)}.`);if(l.originalSize>=Gi&&(l.size===0||l.originalSize/l.size>Ye))return s(`${l.name} exceeds the ${Ye}:1 compression-ratio limit.`);let u=$t(l.name);return!!u&&!rn(u)}},(l,u)=>{a?n(a):l?n(new Error(`Invalid model zip: ${l.message}`)):e(u)})})}function Yt(t){return`${t/ft} MiB`}function Yi(t,e,n,i){let r=[],a={};for(let[c,l]of i){let u=URL.createObjectURL(new Blob([l],{type:an(c)}));r.push(u),a[c]=u}let s=a[e];if(!s)throw r.forEach(c=>URL.revokeObjectURL(c)),new Error(`Invalid model zip: could not read ${e}.`);return W.set(s,{format:n,entryPath:e,resourceUrls:a}),{url:s,name:t.name,format:n,cleanup:()=>{pt(s),W.delete(s),r.forEach(c=>URL.revokeObjectURL(c))}}}function Zi(t,e,n){let i=n.get(e);if(!i)throw new Error("Invalid GLTF zip: no .gltf found.");let r=en((0,st.strFromU8)(i),e);Ki(r,e);let a=$i(e),s=[];try{$e(r.buffers,a,n,s),$e(r.images,a,n,s);let c=new Blob([(0,st.strToU8)(JSON.stringify(r))],{type:"model/gltf+json"}),l=URL.createObjectURL(c);return s.push(l),W.set(l,{format:"gltf",entryPath:e}),{url:l,name:t.name,format:"gltf",cleanup:()=>{pt(l),W.delete(l),s.forEach(u=>URL.revokeObjectURL(u))}}}catch(c){throw s.forEach(l=>URL.revokeObjectURL(l)),c}}function $e(t,e,n,i){for(let r of t??[]){if(typeof r.uri!="string"||Kt(r.uri))continue;let a=Ji(e,r.uri),s=n.get(a);if(!s)throw new Error(`Invalid GLTF zip: missing referenced asset ${r.uri}.`);let c=URL.createObjectURL(new Blob([s],{type:an(a)}));i.push(c),r.uri=c}}function en(t,e){try{return JSON.parse(t)}catch{throw new Error(`${e} is not a valid .gltf JSON file.`)}}function nn(t){return[...t.buffers??[],...t.images??[]].map(e=>e.uri).filter(e=>typeof e=="string"&&e.length>0)}function Ki(t,e){for(let n of nn(t)){if(Kt(n))continue;let i=/^[a-z][a-z0-9+.-]*:/i.test(n),r=n.startsWith("/")||n.startsWith("\\");if(i||r)throw new Error(`${e} references external assets. Include every dependency inside the uploaded .zip.`)}}function Kt(t){return t.startsWith("data:")}function $t(t){let e=[];for(let n of t.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(i=>i&&i!==".")){if(n===".."){e.pop();continue}e.push(n)}return e.join("/")}function rn(t){let e=t.split("/");return t.endsWith("/")||e.includes("__MACOSX")||e.some(n=>n===".DS_Store"||n.startsWith("._"))}function $i(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}function Ji(t,e){let n=e.split(/[?#]/)[0],i=Qi(n);return $t(t?`${t}/${i}`:i)}function Qi(t){try{return decodeURI(t)}catch{return t}}function an(t){let e=t.toLowerCase();return e.endsWith(".obj")||e.endsWith(".mtl")?"text/plain":e.endsWith(".fbx")?"application/octet-stream":e.endsWith(".usdz")?"model/vnd.usdz+zip":e.endsWith(".bin")?"application/octet-stream":e.endsWith(".png")?"image/png":e.endsWith(".jpg")||e.endsWith(".jpeg")?"image/jpeg":e.endsWith(".webp")?"image/webp":e.endsWith(".avif")?"image/avif":e.endsWith(".ktx2")?"image/ktx2":"application/octet-stream"}var tr=require("@react-three/drei"),er=require("@react-three/fiber"),nr=require("react"),sn=require("three");var on=require("react");function St(t){return!!t?.isWebGPURenderer}var lt=require("three-stdlib");function ir(t){return{name:"RI_unlit_emissive_texture",async afterRoot(e){let n=t.json.materials??[],i=new Map;if(n.forEach(a=>{let s=!!a?.extensions?.KHR_materials_unlit,c=!!a?.pbrMetallicRoughness?.baseColorTexture;s&&!c&&a?.emissiveTexture&&a.name&&i.set(a.name,a.emissiveTexture.index)}),i.size===0||!e.scene)return;let r=new Map;await Promise.all([...i].map(async([a,s])=>{let c=await t.getDependency("texture",s);c&&(c.colorSpace=sn.SRGBColorSpace,r.set(a,c))})),e.scene.traverse(a=>{let s=Array.isArray(a.material)?a.material:a.material?[a.material]:[];for(let c of s){let l=c.name?r.get(c.name):void 0;l&&!c.map&&(c.map=l,c.needsUpdate=!0)}})}}}var rr="https://assets.react-immersive.liveroom.dev/three-r184/draco/",ar="https://assets.react-immersive.liveroom.dev/three-r184/basis/";function or(t,e){if(!St(e))return t.detectSupport(e);let n=e,i=r=>n.hasFeature(r);return t.workerConfig={astcSupported:i("texture-compression-astc"),etc1Supported:i("texture-compression-etc1"),etc2Supported:i("texture-compression-etc2"),dxtSupported:i("texture-compression-s3tc"),bptcSupported:i("texture-compression-bc"),pvrtcSupported:i("texture-compression-pvrtc")},t}function ln(t,e={},n){let{dracoDecoderPath:i=rr,ktx2TranscoderPath:r=ar,meshopt:a=!0}=e;if(i){let s=new lt.DRACOLoader;s.setDecoderPath(i),t.setDRACOLoader(s)}if(a&&t.setMeshoptDecoder(lt.MeshoptDecoder),r&&n){let s=or(new lt.KTX2Loader().setTranscoderPath(r),n);t.setKTX2Loader(s)}t.register((s=>ir(s)))}var O=require("three"),dn=require("three/examples/jsm/loaders/STLLoader.js"),un=require("three/examples/jsm/loaders/PLYLoader.js"),sr=12106948,lr="This PLY file is a point cloud: it has vertices but no faces.",Jt=class extends Error{constructor(){super(lr),this.name="PointCloudError"}};function hn(t,e){let n=t.split(/[?#]/,1)[0],i=n.slice(n.lastIndexOf("/")+1);try{i=decodeURIComponent(i)}catch{}return i.replace(/\.[^.]*$/,"").trim()||e}function Qt(t){return new O.MeshStandardMaterial({color:t?16777215:sr,vertexColors:t,metalness:0,roughness:.6})}function cn(t,e,n){let i=t.itemSize;return new O.Float32BufferAttribute(t.array.slice(e*i,(e+n)*i),i)}function pn(t,e){let n=new dn.STLLoader().parse(t),i=!!n.hasColors,r=new O.Group;if(n.groups.length>1){let c=n.userData.groupNames??[],l=n.getAttribute("position"),u=n.getAttribute("normal");return n.groups.forEach((m,_)=>{let P=new O.BufferGeometry;P.setAttribute("position",cn(l,m.start,m.count)),u&&P.setAttribute("normal",cn(u,m.start,m.count));let f=new O.Mesh(P,Qt(!1));f.name=c[_]?.trim()||`${e} ${_+1}`,r.add(f)}),n.dispose(),r}n.clearGroups();let a=Qt(i);i&&n.alpha!==void 0&&n.alpha<1&&(a.opacity=n.alpha,a.transparent=!0);let s=new O.Mesh(n,a);return s.name=e,r.add(s),r}function cr(t){let n=new TextDecoder().decode(new Uint8Array(t,0,Math.min(t.byteLength,65536))).split("end_header",1)[0],i=/^\s*element\s+face\s+(\d+)/m.exec(n);return!!(i&&Number(i[1])>0)}function fn(t,e){if(!cr(t))throw new Jt;let n=new un.PLYLoader().parse(t);n.getAttribute("normal")||n.computeVertexNormals();let i=new O.Mesh(n,Qt(!!n.getAttribute("color")));i.name=e;let r=new O.Group;return r.add(i),r}var At=class extends Q.Loader{constructor(){super(...arguments);this.options={source:{format:"glb"}}}configure(n){return this.options=n,this}load(n,i,r,a){this.loadAsset(n,r).then(i).catch(a)}async loadAsset(n,i){let r=hr(this.options.source),{format:a}=this.options.source;if(a==="obj")return dr(n,r,this.options.source,i);if(a==="fbx"){let l=te(this,new q.FBXLoader(r)),u=mr(n,this.options.source);u&&l.setResourcePath(u);let m=await l.loadAsync(n,i);return wt(m,"FBXMesh",!1),{scene:m,animations:m.animations??[]}}if(a==="stl"||a==="ply"){let l=await ur(n,r,i),u=hn(this.options.source.entryPath??n,a==="stl"?"STL model":"PLY model"),m=a==="stl"?pn(l,u):fn(l,u);return wt(m,a==="stl"?"STLMesh":"PLYMesh",!0),{scene:m,animations:[]}}if(a==="usdz"){let u=await te(this,new gn.USDLoader(r)).loadAsync(n,i);return wt(u,"USDZMesh",!1),{scene:u,animations:u.animations??[]}}let s=te(this,new q.GLTFLoader(r));ln(s,this.options.decoderConfig,this.options.renderer);let c=await s.loadAsync(n,i);return{scene:c.scene,animations:c.animations??[],materialVariants:ke(c)}}};Ge(t=>{mt.useLoader.clear(At,t)});function vn(t,e={},n,i){let r=(0,mt.useThree)(c=>c.gl),a=Qe(t),s=n?{...a,format:n}:a;return(0,mt.useLoader)(At,t,c=>{c.configure({source:s,decoderConfig:e,renderer:r})},i)}async function dr(t,e,n,i){let r=await mn(t,e,i),a=new q.OBJLoader(e),s=pr(r);if(s){let l=fr(s,t,n);if(l)try{let u=await mn(l.url,e),_=new q.MTLLoader(e).parse(u,l.basePath);_.preload(),a.setMaterials(_)}catch(u){console.warn(`[react-immersive] Could not load OBJ material ${s}; rendering geometry with fallback materials.`,u)}}let c=a.parse(r);return wt(c,"OBJMesh",!0),{scene:c,animations:[]}}function wt(t,e,n){let i=new Set,r=0;t.traverse(a=>{if(!("isMesh"in a&&a.isMesh===!0)){a.name&&i.add(a.name);return}let c=a.name||`${e}_${++r}`;if(!n&&a.name){i.add(a.name);return}let l=c,u=2;for(;i.has(l);)l=`${c}_${u++}`;a.name=l,i.add(l)})}function mn(t,e,n){let i=new Q.FileLoader(e);return i.setResponseType("text"),i.loadAsync(t,n)}function ur(t,e,n){let i=new Q.FileLoader(e);return i.setResponseType("arraybuffer"),i.loadAsync(t,n)}function te(t,e){return e.setCrossOrigin(t.crossOrigin),e.setWithCredentials(t.withCredentials),e.setRequestHeader(t.requestHeader),e}function hr(t){let e=new Q.LoadingManager,n=t.resourceUrls;return n&&e.setURLModifier(i=>{if(/^(?:blob:|data:)/i.test(i))return i;let r=Et(xn(i).split(/[?#]/)[0]),a=n[r];if(a)return a;let s=Tt(t.entryPath??""),c=Et(s?`${s}/${r}`:r);return n[c]??i}),e}function pr(t){return/^\s*mtllib\s+(.+?)\s*$/im.exec(t)?.[1]?.trim()||null}function fr(t,e,n){if(n.resourceUrls&&n.entryPath){let i=Et(`${Tt(n.entryPath)}/${xn(t)}`),r=n.resourceUrls[i];if(!r)return null;let a=Tt(i);return{url:r,basePath:a?`${a}/`:""}}try{let i=new URL(t,e).href;return{url:i,basePath:_n(i)}}catch{return null}}function mr(t,e){if(e.resourceUrls&&e.entryPath){let n=Tt(e.entryPath);return n?`${n}/`:""}return _n(t)}function _n(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e+1)}function Tt(t){let e=Et(t),n=e.lastIndexOf("/");return n===-1?"":e.slice(0,n)}function Et(t){let e=[];for(let n of t.replace(/\\/g,"/").replace(/^\/+/,"").split("/").filter(i=>i&&i!=="."))n===".."?e.pop():e.push(n);return e.join("/")}function xn(t){try{return decodeURI(t)}catch{return t}}var X=require("react/jsx-runtime");function yn({visible:t,message:e,tone:n="default",progress:i}){if(!t)return null;let r=typeof i=="number"&&Number.isFinite(i),a=r?Math.min(Math.max(i,0),100):0,s=Math.round(a);return(0,X.jsxs)("div",{className:"bb-loadingOverlay",role:"status","aria-live":"polite",children:[r&&(0,X.jsxs)("div",{className:"bb-loadingProgressRow",children:[(0,X.jsx)("div",{className:"bb-loadingProgress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s,children:(0,X.jsx)("div",{className:"bb-loadingProgress__bar",style:{width:`${s}%`}})}),(0,X.jsxs)("span",{className:"bb-loadingProgress__label",children:[s,"%"]})]}),(0,X.jsx)("span",{className:`bb-loadingMessage bb-status--${n}`,children:e})]})}var Ct=require("react");var gt=require("react"),gr="200px",bn=new Map;function Mn(t,e,n){let i=bn.get(e);if(!i){let s=new Map;i={observer:new IntersectionObserver(l=>{for(let u of l)s.get(u.target)?.(u.isIntersecting)},{rootMargin:e}),watchers:s},bn.set(e,i)}let{observer:r,watchers:a}=i;return a.set(t,n),r.observe(t),()=>{a.delete(t),r.unobserve(t)}}function Sn(t){let e=typeof IntersectionObserver<"u",[n,i]=(0,gt.useState)(!e),[r,a]=(0,gt.useState)(!e);return(0,gt.useEffect)(()=>{let s=t.current;if(!s||!e)return;let c=Mn(s,gr,i),l=Mn(s,"0px",a);return()=>{c(),l()}},[t,e]),{near:n,visible:r}}var Y=require("react");function wn(){return typeof navigator>"u"?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}function vr(){if(typeof window>"u"||typeof navigator>"u")return!1;let t=s=>typeof window.matchMedia=="function"&&window.matchMedia(s).matches,e=t("(pointer: coarse)")||t("(any-pointer: coarse)"),n=t("(hover: none)")||t("(any-hover: none)"),i=navigator.maxTouchPoints>0,r=typeof window.screen<"u"&&Math.min(window.screen.width,window.screen.height)<=1024,a=wn();return e||a||i&&n||i&&r}function An(){if(!vr())return!1;if(wn())return!0;let t=navigator.deviceMemory;return!(typeof t=="number"&&t>=8)}function _r(t,e){let n=new Set,i=r=>{for(let a of r){if(n.size>=e)return;n.add(a.id)}};return i(t.filter(r=>r.wanted).sort((r,a)=>Number(a.visible)-Number(r.visible)||Number(a.live)-Number(r.live)||r.since-a.since)),i(t.filter(r=>!r.wanted&&r.live).sort((r,a)=>a.since-r.since)),n}var xr=12,yr=6,Pt=new Map,br=1,ee=!1,Tn;function En(){ee||(ee=!0,queueMicrotask(()=>{ee=!1,Tn??(Tn=An()?yr:xr);let t=_r([...Pt.values()],Tn);for(let e of Pt.values()){let n=t.has(e.id);n!==e.live&&(e.live=n,e.onLiveChange(n))}}))}function Pn({managed:t,wanted:e,visible:n,onPark:i}){let[r,a]=(0,Y.useState)(!1),s=(0,Y.useRef)(i);s.current=i;let c=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!t)return;let l={id:br++,wanted:!1,visible:!1,live:!1,since:performance.now(),onLiveChange:u=>{u||s.current?.(),a(u)}};return Pt.set(l.id,l),c.current=l,()=>{Pt.delete(l.id),c.current=null,a(!1),En()}},[t]),(0,Y.useEffect)(()=>{let l=c.current;!l||l.wanted===e&&l.visible===n||(l.wanted!==e&&(l.since=performance.now()),l.wanted=e,l.visible=n,En())},[t,e,n]),t?r:e}function Cn({loading:t="lazy",reveal:e="auto",rootRef:n,onPark:i}){let{near:r,visible:a}=Sn(n),[s,c]=(0,Ct.useState)(e==="auto");return(0,Ct.useEffect)(()=>{e==="auto"&&c(!0)},[e]),{live:Pn({managed:t==="lazy",wanted:s&&(t==="eager"||r),visible:a,onPark:i}),visible:a,awaitingReveal:!s,reveal:()=>c(!0)}}var Ln=require("lucide-react");var tt=require("react/jsx-runtime");function ne({src:t,hidden:e=!1}){return t?(0,tt.jsx)("img",{className:`ri-poster${e?" ri-poster--hidden":""}`,src:t,alt:"","aria-hidden":"true",draggable:!1,decoding:"async"}):null}function Nn({className:t,background:e,poster:n,onReveal:i}){let r=ot();return(0,tt.jsxs)("div",{className:`${t} ri-viewerPlaceholder`,style:{background:e},children:[(0,tt.jsx)(ne,{src:n}),i?(0,tt.jsxs)("button",{type:"button",className:"ri-revealButton",onClick:i,children:[(0,tt.jsx)(Ln.Box,{size:16,"aria-hidden":"true"}),r("viewIn3D")]}):null]})}var Lt=require("@react-three/fiber"),ie=require("react");function Rn({captureRef:t}){let{gl:e,scene:n,camera:i,invalidate:r,get:a}=(0,Lt.useThree)();return(0,ie.useEffect)(()=>{if(!t)return;let s=()=>{let c=a();c.advance(c.frameloop==="never"?c.clock.elapsedTime:performance.now())};return t.current={gl:e,scene:n,camera:i,invalidate:r,drawNow:s},()=>{t.current=null}},[t,e,n,i,r,a]),null}function In(){let t=(0,Lt.useThree)(n=>n.frameloop),e=(0,Lt.useThree)(n=>n.invalidate);return(0,ie.useEffect)(()=>{t!=="never"&&e()},[t,e]),null}function Dn(t){t.dispose(),"forceContextLoss"in t&&!St(t)&&(t.forceContextLoss(),t.forceContextLoss=()=>{})}function Un(t){if(!t)return Promise.resolve(null);try{t.drawNow();let e=t.gl.domElement;return new Promise(n=>{e.toBlob(i=>n(i?URL.createObjectURL(i):null),"image/webp",.85)})}catch{return Promise.resolve(null)}}var B=require("three");var Z=require("three");function On(t){return!!(t&&typeof t=="object"&&"clone"in t&&"color"in t&&"metalness"in t&&"roughness"in t)}function zn(t){if(On(t))return t;if(!t||typeof t!="object")return null;let e=t,n=new B.MeshStandardMaterial;typeof e.name=="string"&&(n.name=e.name),n.metalness=0,n.roughness=1,e.type==="MeshBasicMaterial"||e.isMeshBasicMaterial===!0?(n.color.set(0),n.emissiveIntensity=1,e.map instanceof B.Texture?(n.emissiveMap=e.map,n.emissive.set(16777215)):e.color instanceof B.Color&&n.emissive.copy(e.color)):(e.color instanceof B.Color&&n.color.copy(e.color),e.map instanceof B.Texture&&(n.map=e.map),e.emissive instanceof B.Color&&n.emissive.copy(e.emissive),e.emissiveMap instanceof B.Texture&&(n.emissiveMap=e.emissiveMap));let r=["aoMap","aoMapIntensity","lightMap","lightMapIntensity","alphaMap","opacity","transparent","alphaTest","side","vertexColors","wireframe","depthTest","depthWrite","visible","toneMapped","fog"];for(let a of r)e[a]!==void 0&&(n[a]=e[a]);return n.needsUpdate=!0,n}function Bn(t){t.updateMatrixWorld(!0),t.traverse(e=>{let n=e;n.isSkinnedMesh&&(n.skeleton?.update(),n.computeBoundingBox?.(),n.computeBoundingSphere?.())})}var dt=require("three"),K=require("three-mesh-bvh"),Fn=!1,ct=new WeakMap,vt=new WeakMap;function Sr(){Fn||(dt.Mesh.prototype.raycast=K.acceleratedRaycast,Fn=!0)}function wr(t){let e=new Set;return t.traverse(n=>{let i=n.geometry;!i||!i.attributes?.position||e.add(i)}),[...e]}function Hn(t){let e=0;for(let n of t){let i=n.index?n.index.count:n.attributes.position.count;e+=i/3}return e}var Nt=12e6;function Gn(t){return re(t)>Nt}function re(t){let e=new Set;return t.traverse(n=>{let i=n.geometry;i?.attributes?.position&&e.add(i)}),Hn([...e])}function Ar(t,e){return new Promise((n,i)=>{let r=u=>{let m=u.data;if(!m||!m.error&&!m.serialized)return;if(t.removeEventListener("message",r),t.removeEventListener("error",a),m.error){i(new Error(String(m.error)));return}let{serialized:_}=m,P=K.MeshBVH.deserialize(_,e,{setIndex:!1});_.index&&(e.index?e.index.array=_.index:e.setIndex(new dt.BufferAttribute(_.index,1,!1))),e.boundingBox=P.getBoundingBox(new dt.Box3),n(P)},a=u=>{t.removeEventListener("message",r),t.removeEventListener("error",a),i(new Error(u.message||"BVH worker error"))};t.addEventListener("message",r),t.addEventListener("error",a);let s=e.index?e.index.array.slice():null,c=e.attributes.position.array.slice(),l=[c,...s?[s]:[]].map(u=>u.buffer);t.postMessage({index:s,position:c,options:{groups:[...e.groups]}},l)})}async function Tr(){if(typeof window>"u"||typeof Worker>"u")return null;try{let{bvhWorkerCode:t}=await Promise.resolve().then(()=>(Vn(),kn)),e=new Blob([t],{type:"text/javascript"}),n=URL.createObjectURL(e),i=new Worker(n);return{worker:i,dispose:()=>{i.terminate(),URL.revokeObjectURL(n)}}}catch{return null}}async function Er(t,e){if(e)try{return await Ar(e,t)}catch{}let n=K.computeBoundsTree.call(t);return t.boundsTree=void 0,await new Promise(i=>setTimeout(i,0)),n}async function Pr(t,e,n){if(t.boundsTree)return;if(e.buildPromise)return e.buildPromise;let i=(async()=>{let r=await n();e.references>0&&!t.boundsTree&&(t.boundsTree=r,e.ownedTree=r)})();return e.buildPromise=i.finally(()=>{e.buildPromise=void 0,e.references===0&&ct.delete(t)}),e.buildPromise}async function Wn(t,e){if(e?.aborted)return;let n=vt.get(t);if(!n){if(n=wr(t),Hn(n)>Nt){vt.set(t,[]);return}vt.set(t,n);for(let r of n){let a=ct.get(r)??{references:0};a.references+=1,ct.set(r,a)}}if(n.length===0)return;Sr();let i=await Tr();if(e?.aborted){i?.dispose();return}try{for(let r of n){if(e?.aborted)return;let a=ct.get(r);a&&await Pr(r,a,()=>Er(r,i?.worker))}}finally{i?.dispose()}}function jn(t){let e=vt.get(t);if(e){vt.delete(t);for(let n of e){let i=ct.get(n);i&&(i.references=Math.max(0,i.references-1),!(i.references>0)&&(i.ownedTree&&n.boundsTree===i.ownedTree&&(K.disposeBoundsTree.call(n),n.boundsTree=void 0),i.ownedTree=void 0,i.buildPromise||ct.delete(n)))}}}var H=require("three"),ii=require("three-stdlib");var S=require("lucide-react");var et=require("react"),qn=require("@react-three/fiber");function Xn(){let t=(0,qn.useThree)(r=>r.gl.domElement),e=(0,et.useRef)(void 0),n=(0,et.useCallback)(r=>{e.current===void 0&&(e.current=t.style.cursor),t.style.cursor=r},[t]),i=(0,et.useCallback)(()=>{let r=e.current;r!==void 0&&(t.style.cursor=r,e.current=void 0)},[t]);return(0,et.useEffect)(()=>()=>{i()},[i]),{setCanvasCursor:n,restoreCanvasCursor:i}}var Zn=require("react"),Cr={"model-viewer":"@liveroom-tech/react-immersive/styles.css","simple-model-viewer":"@liveroom-tech/react-immersive/simple-model-viewer.css","binding-builder":"@liveroom-tech/react-immersive/binding-builder.css"},ae=new Set,Lr=1e3;function Yn(t){return getComputedStyle(document.documentElement).getPropertyValue(`--ri-styles-${t}`).trim()!==""}function Kn(t,e){(0,Zn.useEffect)(()=>{if(process.env.NODE_ENV==="production"||ae.has(t)||Yn(t))return;let n,i=()=>{n=setTimeout(()=>{ae.has(t)||Yn(t)||(ae.add(t),console.warn(`[react-immersive] ${e}'s styles aren't loaded, so it renders unstyled. Import them once, in your app's root:
3665
3665
 
3666
- import "${ei[t]}";`))},ni)};return document.readyState==="complete"?(i(),()=>clearTimeout(n)):(window.addEventListener("load",i,{once:!0}),()=>{window.removeEventListener("load",i),clearTimeout(n)})},[t,e])}var a=require("react/jsx-runtime"),Ve={color:"#93c5fd",intensity:.05},ii=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];function ri(t){return!!(t&&"isMesh"in t&&t.isMesh)}function He(t,e){Array.isArray(t)?t.forEach(e):e(t)}function ai(t,e){if(!e)return;let n=e.camera;if(!(n instanceof H.PerspectiveCamera))return;let i=new H.Box3().setFromObject(t).getSize(new H.Vector3).length();!Number.isFinite(i)||i<=0||(n.near=i/100,n.far=i*100,n.updateProjectionMatrix(),e.maxDistance=i*10)}var zt=class extends l.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){this.props.onLoadError?.(n)}render(){return this.state.hasError?null:this.props.children}};function si({url:t,format:e,dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r,hiddenKeys:s,selectedKey:o,panelHoveredKey:d,nodeRefsOut:c,onMeshesReady:h,onModelLoaded:_,onLoadProgress:M,onMeshClick:L,highlightOnHover:m}){let{scene:R}=Me(t,{dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r},e,M),E=(0,N.useThree)(f=>f.invalidate),{setCanvasCursor:U,restoreCanvasCursor:C}=Oe(),[P,G]=(0,l.useState)(null),b=(0,l.useMemo)(()=>qe.SkeletonUtils.clone(R),[R]),w=(0,l.useMemo)(()=>{let f={};return b.traverse(p=>{if(!ri(p))return;let y=p.name||p.uuid;f[y]={key:y,label:p.name||p.type,ref:p}}),f},[b]),I=(0,l.useMemo)(()=>{let f={};for(let[p,{ref:y}]of Object.entries(w)){let W=(Array.isArray(y.material)?y.material:[y.material]).map(v=>{let S=(Ee(v)??new H.MeshStandardMaterial).clone();return S.userData.baseColor=S.color.clone(),S.userData.baseMap=S.map,S.userData.baseEmissive=S.emissive.clone(),S.userData.baseEmissiveMap=S.emissiveMap,S.userData.baseEmissiveIntensity=S.emissiveIntensity,S});f[p]=Array.isArray(y.material)?W:W[0]}return f},[w]);(0,l.useEffect)(()=>()=>{Object.values(I).forEach(f=>He(f,p=>p.dispose()))},[I]);let z=(0,l.useRef)(null);(0,l.useEffect)(()=>{z.current!==t&&(z.current=t,b.updateWorldMatrix(!0,!0),Ce(b),h(w),_(b))},[t,b,w,h,_]),(0,l.useEffect)(()=>{let f=new AbortController;return Re(b,f.signal),()=>{f.abort(),Ue(b)}},[b]);let ct=(0,l.useMemo)(()=>!De(b),[b]);(0,l.useEffect)(()=>{for(let[f,{ref:p}]of Object.entries(w))c.current[f]=p},[w,c]),(0,l.useEffect)(()=>{!m&&P!==null&&(G(null),C())},[m,P,C]),(0,l.useEffect)(()=>{for(let[f,{ref:p}]of Object.entries(w)){p.visible=!s.has(f);let y=I[f];if(!y)continue;p.material=y;let it=m&&P===f,W=m&&d===f;He(y,v=>{if(v.color.copy(v.userData.baseColor),v.map=v.userData.baseMap??null,v.emissive.copy(v.userData.baseEmissive),v.emissiveMap=v.userData.baseEmissiveMap??null,v.emissiveIntensity=v.userData.baseEmissiveIntensity,W||it){let q=!!v.userData.baseEmissiveMap;v.emissive.set(Ve.color),v.emissiveIntensity=q?v.userData.baseEmissiveIntensity:Ve.intensity}v.needsUpdate=!0})}E()},[w,I,P,o,d,m,s,E]);let et=f=>{let p=f;for(;p;){let y=p.name||p.uuid;if(w[y])return y;p=p.parent}return null},nt=ct?{onClick:f=>{let p=et(f.object);p&&(f.stopPropagation(),L(p))},...m?{onPointerOver:f=>{let p=et(f.object);p&&(f.stopPropagation(),U("pointer"),G(p))},onPointerOut:f=>{f.stopPropagation(),C(),G(null)}}:{}}:{};return(0,a.jsx)("primitive",{object:b,...nt})}function oi({scene:t,controlsRef:e,refitOnResize:n,onInitialFitComplete:i}){let r=(0,l.useRef)(!1),s=(0,N.useThree)(c=>c.invalidate),o=(0,N.useThree)(c=>c.size),d=(0,l.useRef)(null);return(0,l.useEffect)(()=>{r.current=!1,s()},[s,t]),(0,N.useFrame)(()=>{if(!r.current){if(!t||!e.current){s();return}r.current=!0,ai(t,e.current),e.current.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}).finally(i)}}),(0,l.useEffect)(()=>{if(!(!n||!r.current||!t||!e.current))return d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{e.current?.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}),s()},150),()=>{d.current&&clearTimeout(d.current)}},[o.width,o.height,n]),null}function li({exposure:t}){let e=(0,N.useThree)(i=>i.gl),n=(0,N.useThree)(i=>i.invalidate);return(0,l.useEffect)(()=>{e.toneMappingExposure=t,n()},[e,t,n]),null}function ci({enabled:t,controlsRef:e}){let n=(0,N.useThree)(i=>i.invalidate);return(0,N.useFrame)((i,r)=>{!t||!e.current||(e.current.rotate(r*.2,0,!1),n())}),null}function xt(t){return Array.from(t.types).includes("Files")}function Ge({label:t,checked:e,onChange:n}){return(0,a.jsxs)("div",{className:"env-row",children:[(0,a.jsx)("span",{className:"env-row__label",children:t}),(0,a.jsx)("div",{className:"env-row__value",children:(0,a.jsx)("button",{className:"env-checkbox-btn",onClick:()=>n(!e),children:(0,a.jsx)("span",{className:`env-checkbox${e?" env-checkbox--checked":""}`,children:e&&(0,a.jsx)(g.Check,{size:9,strokeWidth:2,color:"white"})})})})]})}function Rt({label:t,value:e,onChange:n}){return(0,a.jsxs)("div",{className:"env-row",children:[(0,a.jsx)("span",{className:"env-row__label",children:t}),(0,a.jsx)("div",{className:"env-row__value",children:(0,a.jsxs)("div",{className:"env-color-swatch",style:{background:e},children:[(0,a.jsx)("span",{className:"env-color-swatch__hex",children:e}),(0,a.jsx)("input",{type:"color",className:"env-color-swatch__input",value:e,onChange:i=>n(i.target.value)})]})})]})}function Ut({label:t,value:e,min:n,max:i,step:r,onChange:s}){return(0,a.jsxs)("div",{className:"env-row",children:[(0,a.jsx)("span",{className:"env-row__label",children:t}),(0,a.jsxs)("div",{className:"env-row__value env-row__value--slider",children:[(0,a.jsx)("input",{type:"range",className:"env-slider",min:n,max:i,step:r,value:e,onChange:o=>s(Number(o.target.value))}),(0,a.jsx)("span",{className:"env-slider__value",children:e.toFixed(2)})]})]})}function di({label:t,value:e,options:n,onChange:i}){return(0,a.jsxs)("div",{className:"env-row",children:[(0,a.jsx)("span",{className:"env-row__label",children:t}),(0,a.jsx)("div",{className:"env-row__value",children:(0,a.jsx)("select",{className:"env-select",value:e,onChange:r=>i(r.target.value),children:n.map(r=>(0,a.jsx)("option",{value:r,children:r},r))})})]})}function We({title:t,children:e}){let[n,i]=(0,l.useState)(!1);return(0,a.jsxs)("div",{className:"env-section",children:[(0,a.jsxs)("button",{className:"env-section__header",onClick:()=>i(r=>!r),children:[(0,a.jsx)(g.ChevronDown,{size:12,strokeWidth:2,className:`env-section__chevron${n?" env-section__chevron--collapsed":""}`}),(0,a.jsx)("span",{children:t})]}),!n&&(0,a.jsx)("div",{className:"env-section__body",children:e})]})}function ui({isOpen:t,onToggle:e,settings:n,onChange:i}){return(0,a.jsxs)("div",{className:`left-panel-wrapper ${t?"left-panel-wrapper--open":"left-panel-wrapper--closed"}`,children:[!t&&(0,a.jsx)("button",{className:"side-panel__open-btn side-panel__open-btn--left",onClick:()=>e(!0),children:(0,a.jsx)(g.Settings,{size:20,strokeWidth:1.8})}),(0,a.jsxs)("div",{className:`side-panel side-panel--left ${t?"side-panel--open-left":"side-panel--closed-left"}`,"aria-hidden":!t,children:[(0,a.jsx)("div",{className:"side-panel__header",children:(0,a.jsxs)("div",{className:"side-panel__header-top",children:[(0,a.jsx)("span",{className:"side-panel__eyebrow",children:"Scene Settings"}),(0,a.jsx)("button",{className:"side-panel__close-btn",onClick:()=>e(!1),title:"Close",children:(0,a.jsx)(g.X,{size:12,strokeWidth:1.6})})]})}),(0,a.jsxs)("div",{className:"env-controls",children:[(0,a.jsxs)(We,{title:"Background",children:[(0,a.jsx)(Ge,{label:"Background",checked:n.backgroundEnabled,onChange:r=>i("backgroundEnabled",r)}),(0,a.jsx)(Rt,{label:"Background Color",value:n.backgroundColor,onChange:r=>i("backgroundColor",r)}),(0,a.jsx)(di,{label:"Environment",value:n.envPreset,options:ii,onChange:r=>i("envPreset",r)}),(0,a.jsx)(Ge,{label:"Auto Rotate",checked:n.autoRotate,onChange:r=>i("autoRotate",r)})]}),(0,a.jsxs)(We,{title:"Lighting",children:[(0,a.jsx)(Ut,{label:"Exposure",value:n.exposure,min:0,max:2,step:.05,onChange:r=>i("exposure",r)}),(0,a.jsx)(Ut,{label:"Ambient Light Intensity",value:n.ambientIntensity,min:0,max:3,step:.05,onChange:r=>i("ambientIntensity",r)}),(0,a.jsx)(Rt,{label:"Ambient Light Color",value:n.ambientColor,onChange:r=>i("ambientColor",r)}),(0,a.jsx)(Ut,{label:"Direct Light Intensity",value:n.directionalIntensity,min:0,max:5,step:.05,onChange:r=>i("directionalIntensity",r)}),(0,a.jsx)(Rt,{label:"Direct Light Color",value:n.directionalColor,onChange:r=>i("directionalColor",r)})]})]})]})]})}function hi({meshKeys:t,hiddenKeys:e,selectedKey:n,isOpen:i,onToggle:r,onFocus:s,onHover:o,onToggleVisibility:d}){let[c,h]=(0,l.useState)(""),[_,M]=(0,l.useState)(null),L=Object.values(t).filter(m=>m.label.toLowerCase().includes(c.toLowerCase()));return(0,a.jsxs)("div",{className:`right-panel-wrapper ${i?"right-panel-wrapper--open":"right-panel-wrapper--closed"}`,children:[!i&&(0,a.jsx)("button",{className:"side-panel__open-btn",onClick:()=>r(!0),children:(0,a.jsx)(g.Boxes,{size:20,strokeWidth:1.8})}),(0,a.jsxs)("div",{className:`side-panel ${i?"side-panel--open":"side-panel--closed"}`,"aria-hidden":!i,children:[(0,a.jsxs)("div",{className:"side-panel__header",children:[(0,a.jsxs)("div",{className:"side-panel__header-top",children:[(0,a.jsx)("span",{className:"side-panel__eyebrow",children:"SCENE OBJECTS"}),(0,a.jsx)("button",{className:"side-panel__close-btn",onClick:()=>r(!1),title:"Close",children:(0,a.jsx)(g.X,{size:12,strokeWidth:1.6})})]}),(0,a.jsxs)("p",{className:"side-panel__title",children:[L.length," objects"]})]}),(0,a.jsx)("div",{className:"side-panel__search-wrap",children:(0,a.jsx)("input",{className:"side-panel__search",type:"text",placeholder:"Search objects",value:c,onChange:m=>h(m.target.value)})}),(0,a.jsx)("div",{className:"side-panel__list",children:L.map(({key:m,label:R})=>{let E=!e.has(m),U=n===m,C=_===m;return(0,a.jsxs)("div",{onClick:()=>s(m),onMouseEnter:()=>{M(m),o(m)},onMouseLeave:()=>{M(null),o(null)},className:["side-panel__row",C?"side-panel__row--hovered":"",U?"side-panel__row--selected":""].filter(Boolean).join(" "),children:[(0,a.jsx)("span",{className:`side-panel__label${C||U?" side-panel__label--hovered":""}`,children:R}),(0,a.jsx)("button",{className:"side-panel__vis-btn",title:E?"Hide":"Show",onClick:P=>{P.stopPropagation(),d(m)},children:(0,a.jsx)("span",{className:`side-panel__checkbox${E?" side-panel__checkbox--checked":""}`,children:E&&(0,a.jsx)(g.Check,{size:9,strokeWidth:5,color:"white"})})})]},m)})})]})]})}function Ot({modelUrl:t,modelFormat:e,dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r=!0,backgroundColor:s="#1a1a1a",showSceneObjectsPanel:o=!0,showSceneSettingsPanel:d=!0,enableModelUpload:c=!1,zoomOnSelected:h=!1,highlightOnHover:_=!1,showLoadingOverlay:M=!0,refitOnResize:L=!0,backgroundEnabled:m=!1,autoRotate:R=!1,envPreset:E="city",exposure:U=1,ambientIntensity:C=.6,ambientColor:P="#ffffff",directionalIntensity:G=1.2,directionalColor:b="#ffffff",onModelLoaded:w,onLoadError:I}){Fe("simple-model-viewer","SimpleModelViewer");let z=(0,l.useRef)(null),ct=(0,l.useRef)({}),et=(0,l.useRef)(null),nt=(0,l.useRef)(null),f=(0,l.useRef)(0),[p,y]=(0,l.useState)(null),[it,W]=(0,l.useState)(null),[v,q]=(0,l.useState)(!1),[S,Bt]=(0,l.useState)({}),[kt,bt]=(0,l.useState)(new Set),[Ft,Mt]=(0,l.useState)(null),[Xe,Vt]=(0,l.useState)(null),[Ht,Gt]=(0,l.useState)(null),[Ye,Wt]=(0,l.useState)(null),[Ze,dt]=(0,l.useState)(!1),[jt,qt]=(0,l.useState)(!1),[Ke,Xt]=(0,l.useState)(!1),[$e,ut]=(0,l.useState)(null),[Je,ht]=(0,l.useState)(!1),[Qe,tn]=(0,l.useState)(()=>typeof window>"u"?!0:window.innerWidth>900),[en,nn]=(0,l.useState)(()=>typeof window>"u"?!0:window.innerWidth>900),[A,St]=(0,l.useState)({backgroundEnabled:m,backgroundColor:s,autoRotate:R,envPreset:E,exposure:U,ambientIntensity:C,ambientColor:P,directionalIntensity:G,directionalColor:b}),O=c?Ht:t,X=(0,l.useCallback)(()=>{y(null),W(null),q(!1),Bt({}),bt(new Set),Mt(null),Vt(null),dt(!1),Xt(!1),ut(null)},[]),Y=(0,l.useCallback)(()=>{nt.current?.cleanup(),nt.current=null},[]),rn=(0,l.useCallback)(()=>{Y(),Gt(null),Wt(null),X(),St({backgroundEnabled:m,backgroundColor:s,autoRotate:R,envPreset:E,exposure:U,ambientIntensity:C,ambientColor:P,directionalIntensity:G,directionalColor:b})},[P,C,R,s,m,b,G,E,U,X,Y]),Yt=(0,l.useCallback)(async u=>{qt(!0);try{let x=await fe(u);Y(),nt.current=x,Gt(x.url),Wt(x.name),X()}catch(x){dt(!0),I?.(x)}finally{qt(!1)}},[I,X,Y]),wt=(0,l.useCallback)(u=>{let x=u?.[0];x&&Yt(x)},[Yt]);(0,l.useEffect)(()=>()=>{Y()},[Y]);let an=(0,l.useCallback)((u,x)=>{St(Z=>({...Z,[u]:x}))},[]);(0,l.useEffect)(()=>{St(u=>({...u,backgroundColor:s}))},[s]),(0,l.useEffect)(()=>{X()},[O,X]);let sn=(0,l.useCallback)(u=>{Bt(u),bt(new Set),Mt(null)},[]),on=(0,l.useCallback)(u=>{y(u),dt(!1);let x=It(u);W(x>_t?x:null),q(!1),ut(null),w?.(te(u))},[w]),ln=(0,l.useCallback)(u=>{dt(!0),ut(null),I?.(u)},[I]),cn=(0,l.useCallback)(u=>{u.lengthComputable&&u.total>0&&ut(u.loaded/u.total*100)},[]),Zt=(0,l.useCallback)(u=>{if(Mt(u),!h)return;let x=ct.current[u];!x||!z.current||z.current.fitToBox(x,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{})},[h]),dn=(0,l.useCallback)(u=>{bt(x=>{let Z=new Set(x);return Z.has(u)?Z.delete(u):Z.add(u),Z})},[]),un=(0,l.useCallback)(u=>{!c||!xt(u.dataTransfer)||(u.preventDefault(),u.stopPropagation(),f.current+=1,ht(!0))},[c]),hn=(0,l.useCallback)(u=>{!c||!xt(u.dataTransfer)||(u.preventDefault(),u.stopPropagation(),u.dataTransfer.dropEffect="copy",ht(!0))},[c]),fn=(0,l.useCallback)(u=>{!c||!xt(u.dataTransfer)||(u.preventDefault(),u.stopPropagation(),f.current=Math.max(0,f.current-1),f.current===0&&ht(!1))},[c]),pn=(0,l.useCallback)(u=>{!c||!xt(u.dataTransfer)||(u.preventDefault(),u.stopPropagation(),f.current=0,ht(!1),wt(u.dataTransfer.files))},[c,wt]),mn=M&&(jt||!!(O&&!Ze&&(!p||!Ke)));return(0,a.jsxs)("div",{className:"smv-root",style:{background:A.backgroundColor},onDragEnter:un,onDragOver:hn,onDragLeave:fn,onDrop:pn,children:[d&&O&&(0,a.jsx)(ui,{isOpen:en,onToggle:nn,settings:A,onChange:an}),(0,a.jsxs)("div",{className:"smv-canvasArea",children:[it!==null&&!v&&(0,a.jsxs)("div",{className:"smv-largeModelBanner",children:[(0,a.jsx)(g.AlertTriangle,{size:14,className:"smv-largeModelBanner__icon"}),(0,a.jsxs)("span",{children:["Very large model detected (",Math.round(it/1e6),"M triangles) \u2014 it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts."]}),(0,a.jsx)("button",{type:"button",className:"smv-largeModelBanner__dismiss",onClick:()=>q(!0),"aria-label":"Dismiss",children:(0,a.jsx)(g.X,{size:12})})]}),c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{ref:et,type:"file",accept:ue,className:"smv-upload-input",onChange:u=>{wt(u.target.files),u.currentTarget.value=""}}),O?(0,a.jsx)("div",{className:"smv-upload-toolbar",children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"smv-upload-toolbar__name",children:Ye??"Uploaded model"}),(0,a.jsxs)("button",{type:"button",className:"smv-upload-toolbar__button smv-upload-toolbar__button--ghost",onClick:rn,children:[(0,a.jsx)(g.Trash2,{size:14}),"Clear"]})]})}):null]}):null,O?(0,a.jsx)(je.Canvas,{dpr:[1,2],frameloop:"demand",resize:{debounce:0,scroll:!1},raycaster:{firstHitOnly:!0},style:{background:A.backgroundColor},camera:{position:[0,0,5],fov:45,near:.1,far:1e3},children:(0,a.jsxs)(l.Suspense,{fallback:null,children:[(0,a.jsx)("ambientLight",{intensity:A.ambientIntensity,color:A.ambientColor}),(0,a.jsx)("directionalLight",{position:[-4,5,7],intensity:A.directionalIntensity,color:A.directionalColor,castShadow:!0}),(0,a.jsx)("directionalLight",{position:[-5,5,5],intensity:.5}),(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(yt.Environment,{preset:A.envPreset,background:A.backgroundEnabled})}),(0,a.jsx)(li,{exposure:A.exposure}),(0,a.jsx)(ci,{enabled:A.autoRotate,controlsRef:z}),(0,a.jsx)(zt,{onLoadError:ln,children:(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(si,{url:O,format:Ht?void 0:e,dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r,hiddenKeys:kt,selectedKey:Ft,panelHoveredKey:Xe,nodeRefsOut:ct,onMeshesReady:sn,onModelLoaded:on,onLoadProgress:cn,onMeshClick:Zt,highlightOnHover:_})})},O),(0,a.jsx)(oi,{scene:p,controlsRef:z,refitOnResize:L,onInitialFitComplete:()=>Xt(!0)}),(0,a.jsx)(yt.CameraControls,{ref:z,makeDefault:!0,smoothTime:.3})]})}):(0,a.jsx)("div",{className:"smv-upload-empty-state",style:{background:A.backgroundColor},children:(0,a.jsxs)("div",{className:"smv-upload-empty-state__card",children:[(0,a.jsx)("div",{className:"smv-upload-empty-state__icon",children:(0,a.jsx)(g.Upload,{size:24})}),(0,a.jsxs)("p",{className:"smv-upload-empty-state__body",children:["Drag and drop ",(0,a.jsx)("code",{children:".glb"}),", ",(0,a.jsx)("code",{children:".gltf"}),","," ",(0,a.jsx)("code",{children:".obj"}),", ",(0,a.jsx)("code",{children:".fbx"}),", ",(0,a.jsx)("code",{children:".usdz"}),", or"," ",(0,a.jsx)("code",{children:".zip"})," here"]}),(0,a.jsxs)("button",{type:"button",className:"smv-upload-empty-state__button",onClick:()=>et.current?.click(),children:[(0,a.jsx)(g.Upload,{size:15}),"Choose model"]})]})}),(0,a.jsx)(Ae,{visible:mn,message:"Loading model...",progress:jt?void 0:$e??void 0}),c&&Je?(0,a.jsx)("div",{className:"smv-upload-drop-overlay",children:(0,a.jsxs)("div",{className:"smv-upload-drop-overlay__card",children:[(0,a.jsx)(g.Upload,{size:20}),(0,a.jsx)("span",{children:"Release to load your model"})]})}):null]}),o&&O&&(0,a.jsx)(hi,{meshKeys:S,hiddenKeys:kt,selectedKey:Ft,isOpen:Qe,onToggle:tn,onFocus:Zt,onHover:Vt,onToggleVisibility:dn})]})}0&&(module.exports={SimpleModelViewer});
3666
+ import "${Cr[t]}";`))},Lr)};return document.readyState==="complete"?(i(),()=>clearTimeout(n)):(window.addEventListener("load",i,{once:!0}),()=>{window.removeEventListener("load",i),clearTimeout(n)})},[t,e])}var o=require("react/jsx-runtime"),$n={color:"#93c5fd",intensity:.05},Jn=["apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];function Nr(t){return!!(t&&"isMesh"in t&&t.isMesh)}function Qn(t,e){Array.isArray(t)?t.forEach(e):e(t)}function Rr(t,e){if(!e)return;let n=e.camera;if(!(n instanceof H.PerspectiveCamera))return;let i=new H.Box3().setFromObject(t).getSize(new H.Vector3).length();!Number.isFinite(i)||i<=0||(n.near=i/100,n.far=i*100,n.updateProjectionMatrix(),e.maxDistance=i*10)}var le=class extends d.Component{constructor(){super(...arguments);this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){this.props.onLoadError?.(n)}render(){return this.state.hasError?null:this.props.children}};function Ir({url:t,format:e,dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r,hiddenKeys:a,selectedKey:s,panelHoveredKey:c,nodeRefsOut:l,onMeshesReady:u,onModelLoaded:m,onLoadProgress:_,onMeshClick:P,highlightOnHover:f}){let{scene:p}=vn(t,{dracoDecoderPath:n,ktx2TranscoderPath:i,meshopt:r},e,_),M=(0,F.useThree)(g=>g.invalidate),{setCanvasCursor:y,restoreCanvasCursor:x}=Xn(),[b,N]=(0,d.useState)(null),w=(0,d.useMemo)(()=>ii.SkeletonUtils.clone(p),[p]),L=(0,d.useMemo)(()=>{let g={};return w.traverse(v=>{if(!Nr(v))return;let E=v.name||v.uuid;g[E]={key:E,label:v.name||v.type,ref:v}}),g},[w]),R=(0,d.useMemo)(()=>{let g={};for(let[v,{ref:E}]of Object.entries(L)){let J=(Array.isArray(E.material)?E.material:[E.material]).map(A=>{let C=(zn(A)??new H.MeshStandardMaterial).clone();return C.userData.baseColor=C.color.clone(),C.userData.baseMap=C.map,C.userData.baseEmissive=C.emissive.clone(),C.userData.baseEmissiveMap=C.emissiveMap,C.userData.baseEmissiveIntensity=C.emissiveIntensity,C});g[v]=Array.isArray(E.material)?J:J[0]}return g},[L]);(0,d.useEffect)(()=>()=>{Object.values(R).forEach(g=>Qn(g,v=>v.dispose()))},[R]);let z=(0,d.useRef)(null);(0,d.useEffect)(()=>{z.current!==t&&(z.current=t,w.updateWorldMatrix(!0,!0),Bn(w),u(L),m(w))},[t,w,L,u,m]),(0,d.useEffect)(()=>{let g=new AbortController;return Wn(w,g.signal),()=>{g.abort(),jn(w)}},[w]);let $=(0,d.useMemo)(()=>!Gn(w),[w]);(0,d.useEffect)(()=>{for(let[g,{ref:v}]of Object.entries(L))l.current[g]=v},[L,l]),(0,d.useEffect)(()=>{!f&&b!==null&&(N(null),x())},[f,b,x]),(0,d.useEffect)(()=>{for(let[g,{ref:v}]of Object.entries(L)){v.visible=!a.has(g);let E=R[g];if(!E)continue;v.material=E;let G=f&&b===g,J=f&&c===g;Qn(E,A=>{if(A.color.copy(A.userData.baseColor),A.map=A.userData.baseMap??null,A.emissive.copy(A.userData.baseEmissive),A.emissiveMap=A.userData.baseEmissiveMap??null,A.emissiveIntensity=A.userData.baseEmissiveIntensity,J||G){let nt=!!A.userData.baseEmissiveMap;A.emissive.set($n.color),A.emissiveIntensity=nt?A.userData.baseEmissiveIntensity:$n.intensity}A.needsUpdate=!0})}M()},[L,R,b,s,c,f,a,M]);let k=g=>{let v=g;for(;v;){let E=v.name||v.uuid;if(L[E])return E;v=v.parent}return null},Dt=$?{onClick:g=>{let v=k(g.object);v&&(g.stopPropagation(),P(v))},...f?{onPointerOver:g=>{let v=k(g.object);v&&(g.stopPropagation(),y("pointer"),N(v))},onPointerOut:g=>{g.stopPropagation(),x(),N(null)}}:{}}:{};return(0,o.jsx)("primitive",{object:w,...Dt})}function Dr({scene:t,controlsRef:e,refitOnResize:n,onInitialFitComplete:i,resumeViewRef:r}){let a=(0,d.useRef)(!1),s=(0,F.useThree)(u=>u.invalidate),c=(0,F.useThree)(u=>u.size),l=(0,d.useRef)(null);return(0,d.useEffect)(()=>{a.current=!1,s()},[s,t]),(0,F.useFrame)(()=>{if(a.current)return;if(!t||!e.current){s();return}a.current=!0,Rr(t,e.current);let u=r.current;if(u){r.current=null,e.current.setLookAt(...u.position,...u.target,!1).catch(()=>{}).finally(i);return}e.current.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}).finally(i)}),(0,d.useEffect)(()=>{if(!(!n||!a.current||!t||!e.current))return l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{e.current?.fitToBox(t,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{}),s()},150),()=>{l.current&&clearTimeout(l.current)}},[c.width,c.height,n]),null}function Ur({exposure:t}){let e=(0,F.useThree)(i=>i.gl),n=(0,F.useThree)(i=>i.invalidate);return(0,d.useEffect)(()=>{e.toneMappingExposure=t,n()},[e,t,n]),null}function Or({enabled:t,controlsRef:e}){let n=(0,F.useThree)(i=>i.invalidate);return(0,F.useFrame)((i,r)=>{!t||!e.current||(e.current.rotate(r*.2,0,!1),n())}),null}function Rt(t){return Array.from(t.types).includes("Files")}function ti({label:t,checked:e,onChange:n}){return(0,o.jsxs)("div",{className:"env-row",children:[(0,o.jsx)("span",{className:"env-row__label",children:t}),(0,o.jsx)("div",{className:"env-row__value",children:(0,o.jsx)("button",{className:"env-checkbox-btn",onClick:()=>n(!e),children:(0,o.jsx)("span",{className:`env-checkbox${e?" env-checkbox--checked":""}`,children:e&&(0,o.jsx)(S.Check,{size:9,strokeWidth:2,color:"white"})})})})]})}function oe({label:t,value:e,onChange:n}){return(0,o.jsxs)("div",{className:"env-row",children:[(0,o.jsx)("span",{className:"env-row__label",children:t}),(0,o.jsx)("div",{className:"env-row__value",children:(0,o.jsxs)("div",{className:"env-color-swatch",style:{background:e},children:[(0,o.jsx)("span",{className:"env-color-swatch__hex",children:e}),(0,o.jsx)("input",{type:"color",className:"env-color-swatch__input",value:e,onChange:i=>n(i.target.value)})]})})]})}function se({label:t,value:e,min:n,max:i,step:r,onChange:a}){return(0,o.jsxs)("div",{className:"env-row",children:[(0,o.jsx)("span",{className:"env-row__label",children:t}),(0,o.jsxs)("div",{className:"env-row__value env-row__value--slider",children:[(0,o.jsx)("input",{type:"range",className:"env-slider",min:n,max:i,step:r,value:e,onChange:s=>a(Number(s.target.value))}),(0,o.jsx)("span",{className:"env-slider__value",children:e.toFixed(2)})]})]})}function zr({label:t,optionLabels:e,value:n,options:i,onChange:r}){return(0,o.jsxs)("div",{className:"env-row",children:[(0,o.jsx)("span",{className:"env-row__label",children:t}),(0,o.jsx)("div",{className:"env-row__value",children:(0,o.jsx)("select",{className:"env-select",value:n,onChange:a=>r(a.target.value),children:i.map(a=>(0,o.jsx)("option",{value:a,children:e?.[a]??a},a))})})]})}function ei({title:t,children:e}){let[n,i]=(0,d.useState)(!1);return(0,o.jsxs)("div",{className:"env-section",children:[(0,o.jsxs)("button",{className:"env-section__header",onClick:()=>i(r=>!r),children:[(0,o.jsx)(S.ChevronDown,{size:12,strokeWidth:2,className:`env-section__chevron${n?" env-section__chevron--collapsed":""}`}),(0,o.jsx)("span",{children:t})]}),!n&&(0,o.jsx)("div",{className:"env-section__body",children:e})]})}function Br({isOpen:t,onToggle:e,settings:n,onChange:i}){let r=ot();return(0,o.jsxs)("div",{className:`left-panel-wrapper ${t?"left-panel-wrapper--open":"left-panel-wrapper--closed"}`,children:[!t&&(0,o.jsx)("button",{className:"side-panel__open-btn side-panel__open-btn--left",onClick:()=>e(!0),children:(0,o.jsx)(S.Settings,{size:20,strokeWidth:1.8})}),(0,o.jsxs)("div",{className:`side-panel side-panel--left ${t?"side-panel--open-left":"side-panel--closed-left"}`,"aria-hidden":!t,children:[(0,o.jsx)("div",{className:"side-panel__header",children:(0,o.jsxs)("div",{className:"side-panel__header-top",children:[(0,o.jsx)("span",{className:"side-panel__eyebrow",children:r("sceneSettings")}),(0,o.jsx)("button",{className:"side-panel__close-btn",onClick:()=>e(!1),title:r("close"),children:(0,o.jsx)(S.X,{size:12,strokeWidth:1.6})})]})}),(0,o.jsxs)("div",{className:"env-controls",children:[(0,o.jsxs)(ei,{title:r("background"),children:[(0,o.jsx)(ti,{label:r("background"),checked:n.backgroundEnabled,onChange:a=>i("backgroundEnabled",a)}),(0,o.jsx)(oe,{label:r("backgroundColor"),value:n.backgroundColor,onChange:a=>i("backgroundColor",a)}),(0,o.jsx)(zr,{label:r("environment"),value:n.envPreset,options:Jn,optionLabels:Object.fromEntries(Jn.map(a=>[a,r(`environment${a[0].toUpperCase()}${a.slice(1)}`)])),onChange:a=>i("envPreset",a)}),(0,o.jsx)(ti,{label:r("autoRotate"),checked:n.autoRotate,onChange:a=>i("autoRotate",a)})]}),(0,o.jsxs)(ei,{title:r("lighting"),children:[(0,o.jsx)(se,{label:r("exposure"),value:n.exposure,min:0,max:2,step:.05,onChange:a=>i("exposure",a)}),(0,o.jsx)(se,{label:r("ambientLightIntensity"),value:n.ambientIntensity,min:0,max:3,step:.05,onChange:a=>i("ambientIntensity",a)}),(0,o.jsx)(oe,{label:r("ambientLightColor"),value:n.ambientColor,onChange:a=>i("ambientColor",a)}),(0,o.jsx)(se,{label:r("directLightIntensity"),value:n.directionalIntensity,min:0,max:5,step:.05,onChange:a=>i("directionalIntensity",a)}),(0,o.jsx)(oe,{label:r("directLightColor"),value:n.directionalColor,onChange:a=>i("directionalColor",a)})]})]})]})]})}function kr({meshKeys:t,hiddenKeys:e,selectedKey:n,isOpen:i,onToggle:r,onFocus:a,onHover:s,onToggleVisibility:c}){let l=ot(),[u,m]=(0,d.useState)(""),[_,P]=(0,d.useState)(null),f=Object.values(t).filter(p=>p.label.toLowerCase().includes(u.toLowerCase()));return(0,o.jsxs)("div",{className:`right-panel-wrapper ${i?"right-panel-wrapper--open":"right-panel-wrapper--closed"}`,children:[!i&&(0,o.jsx)("button",{className:"side-panel__open-btn",onClick:()=>r(!0),children:(0,o.jsx)(S.Boxes,{size:20,strokeWidth:1.8})}),(0,o.jsxs)("div",{className:`side-panel ${i?"side-panel--open":"side-panel--closed"}`,"aria-hidden":!i,children:[(0,o.jsxs)("div",{className:"side-panel__header",children:[(0,o.jsxs)("div",{className:"side-panel__header-top",children:[(0,o.jsx)("span",{className:"side-panel__eyebrow",children:l("sceneObjects")}),(0,o.jsx)("button",{className:"side-panel__close-btn",onClick:()=>r(!1),title:l("close"),children:(0,o.jsx)(S.X,{size:12,strokeWidth:1.6})})]}),(0,o.jsx)("p",{className:"side-panel__title",children:l("objectCount",{count:f.length})})]}),(0,o.jsx)("div",{className:"side-panel__search-wrap",children:(0,o.jsx)("input",{className:"side-panel__search",type:"text",placeholder:l("searchObjects"),value:u,onChange:p=>m(p.target.value)})}),(0,o.jsx)("div",{className:"side-panel__list",children:f.map(({key:p,label:M})=>{let y=!e.has(p),x=n===p,b=_===p;return(0,o.jsxs)("div",{onClick:()=>a(p),onMouseEnter:()=>{P(p),s(p)},onMouseLeave:()=>{P(null),s(null)},className:["side-panel__row",b?"side-panel__row--hovered":"",x?"side-panel__row--selected":""].filter(Boolean).join(" "),children:[(0,o.jsx)("button",{type:"button",className:`side-panel__label side-panel__labelButton${b||x?" side-panel__label--hovered":""}`,"aria-current":x?"true":void 0,onFocus:()=>{P(p),s(p)},onBlur:()=>{P(null),s(null)},children:M}),(0,o.jsx)("button",{type:"button",className:"side-panel__vis-btn",title:l(y?"hide":"show"),"aria-label":l(y?"hideObject":"showObject",{name:M}),onClick:N=>{N.stopPropagation(),c(p)},children:(0,o.jsx)("span",{className:`side-panel__checkbox${y?" side-panel__checkbox--checked":""}`,children:y&&(0,o.jsx)(S.Check,{size:9,strokeWidth:5,color:"white"})})})]},p)})})]})]})}function ce(t){return(0,o.jsx)(Ne,{labels:t.labels,children:(0,o.jsx)(Vr,{...t})})}function Vr({modelUrl:t,poster:e,loading:n,reveal:i,modelFormat:r,dracoDecoderPath:a,ktx2TranscoderPath:s,meshopt:c=!0,backgroundColor:l="#1a1a1a",showSceneObjectsPanel:u=!0,showSceneSettingsPanel:m=!0,enableModelUpload:_=!1,zoomOnSelected:P=!1,highlightOnHover:f=!1,showLoadingOverlay:p=!0,refitOnResize:M=!0,backgroundEnabled:y=!1,autoRotate:x=!1,envPreset:b="city",exposure:N=1,ambientIntensity:w=.6,ambientColor:L="#ffffff",directionalIntensity:R=1.2,directionalColor:z="#ffffff",onModelLoaded:$,onLoadError:k,reducedMotion:Dt="user"}){let g=ot(),v=Ue(Dt),E=x&&!v;Kn("simple-model-viewer","SimpleModelViewer");let G=(0,d.useRef)(null),J=(0,d.useRef)({}),A=(0,d.useRef)(null),nt=(0,d.useRef)(null),C=(0,d.useRef)(0),[Ut,Ot]=(0,d.useState)(null),[de,ue]=(0,d.useState)(null),[ri,zt]=(0,d.useState)(!1),[ai,he]=(0,d.useState)({}),[pe,fe]=(0,d.useState)(new Set),[me,ge]=(0,d.useState)(null),[oi,ve]=(0,d.useState)(null),[_e,xe]=(0,d.useState)(null),[si,ye]=(0,d.useState)(null),[li,_t]=(0,d.useState)(!1),[be,Me]=(0,d.useState)(!1),[Bt,kt]=(0,d.useState)(!1),[ci,xt]=(0,d.useState)(null),[di,yt]=(0,d.useState)(!1),[ui,hi]=(0,d.useState)(()=>typeof window>"u"?!0:window.innerWidth>900),[pi,fi]=(0,d.useState)(()=>typeof window>"u"?!0:window.innerWidth>900),[D,Vt]=(0,d.useState)({backgroundEnabled:y,backgroundColor:l,autoRotate:E,envPreset:b,exposure:N,ambientIntensity:w,ambientColor:L,directionalIntensity:R,directionalColor:z}),U=_?_e:t,Se=(0,d.useRef)(null),Ft=(0,d.useRef)(null),Ht=(0,d.useRef)(null),[ut,we]=(0,d.useState)(null);(0,d.useEffect)(()=>()=>{ut&&URL.revokeObjectURL(ut)},[ut]);let Ae=(0,d.useRef)(U);Ae.current=U;let Gt=(0,d.useRef)(null),j=Cn({loading:n,reveal:i,rootRef:Se,onPark:()=>{Gt.current=Ft.current?.gl??null;let h=G.current;if(h&&Bt){Ht.current={position:h.getPosition(new H.Vector3).toArray(),target:h.getTarget(new H.Vector3).toArray()};let T=U;Un(Ft.current).then(V=>{V&&(T===Ae.current?we(V):URL.revokeObjectURL(V))})}Ot(null),kt(!1)}});(0,d.useEffect)(()=>{if(j.live)return;let h=Gt.current;Gt.current=null,h&&Dn(h)},[j.live]);let it=(0,d.useCallback)(()=>{Ht.current=null,we(null),Ot(null),ue(null),zt(!1),he({}),fe(new Set),ge(null),ve(null),_t(!1),kt(!1),xt(null)},[]),rt=(0,d.useCallback)(()=>{nt.current?.cleanup(),nt.current=null},[]),mi=(0,d.useCallback)(()=>{rt(),xe(null),ye(null),it(),Vt({backgroundEnabled:y,backgroundColor:l,autoRotate:E,envPreset:b,exposure:N,ambientIntensity:w,ambientColor:L,directionalIntensity:R,directionalColor:z})},[L,w,E,l,y,z,R,b,N,it,rt]),Te=(0,d.useCallback)(async h=>{Me(!0);try{let T=await tn(h);rt(),nt.current=T,xe(T.url),ye(T.name),it()}catch(T){_t(!0),k?.(T)}finally{Me(!1)}},[k,it,rt]),Wt=(0,d.useCallback)(h=>{let T=h?.[0];T&&Te(T)},[Te]);(0,d.useEffect)(()=>()=>{rt()},[rt]);let gi=(0,d.useCallback)((h,T)=>{Vt(V=>({...V,[h]:T}))},[]);(0,d.useEffect)(()=>{Vt(h=>({...h,backgroundColor:l}))},[l]),(0,d.useEffect)(()=>{it()},[U,it]);let vi=(0,d.useCallback)(h=>{he(h)},[]),_i=(0,d.useCallback)(h=>{Ot(h),_t(!1);let T=re(h);ue(T>Nt?T:null),zt(!1),xt(null),$?.(Fe(h))},[$]),xi=(0,d.useCallback)(h=>{_t(!0),xt(null),k?.(h)},[k]),yi=(0,d.useCallback)(h=>{h.lengthComputable&&h.total>0&&xt(h.loaded/h.total*100)},[]),Ee=(0,d.useCallback)(h=>{if(ge(h),!P)return;let T=J.current[h];!T||!G.current||G.current.fitToBox(T,!0,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5}).catch(()=>{})},[P]),bi=(0,d.useCallback)(h=>{fe(T=>{let V=new Set(T);return V.has(h)?V.delete(h):V.add(h),V})},[]),Mi=(0,d.useCallback)(h=>{!_||!Rt(h.dataTransfer)||(h.preventDefault(),h.stopPropagation(),C.current+=1,yt(!0))},[_]),Si=(0,d.useCallback)(h=>{!_||!Rt(h.dataTransfer)||(h.preventDefault(),h.stopPropagation(),h.dataTransfer.dropEffect="copy",yt(!0))},[_]),wi=(0,d.useCallback)(h=>{!_||!Rt(h.dataTransfer)||(h.preventDefault(),h.stopPropagation(),C.current=Math.max(0,C.current-1),C.current===0&&yt(!1))},[_]),Ai=(0,d.useCallback)(h=>{!_||!Rt(h.dataTransfer)||(h.preventDefault(),h.stopPropagation(),C.current=0,yt(!1),Wt(h.dataTransfer.files))},[_,Wt]),Ti=p&&(be||!!(U&&j.live&&!li&&(!Ut||!Bt)));return(0,o.jsxs)("div",{className:"smv-root",ref:Se,"data-reduced-motion":v?"":void 0,style:{background:D.backgroundColor},onDragEnter:Mi,onDragOver:Si,onDragLeave:wi,onDrop:Ai,children:[m&&U&&(0,o.jsx)(Br,{isOpen:pi,onToggle:fi,settings:D,onChange:gi}),(0,o.jsxs)("div",{className:"smv-canvasArea",children:[de!==null&&!ri&&(0,o.jsxs)("div",{className:"smv-largeModelBanner",children:[(0,o.jsx)(S.AlertTriangle,{size:14,className:"smv-largeModelBanner__icon"}),(0,o.jsx)("span",{children:g("simpleLargeModelWarning",{millions:Math.round(de/1e6)})}),(0,o.jsx)("button",{type:"button",className:"smv-largeModelBanner__dismiss",onClick:()=>zt(!0),"aria-label":g("dismiss"),children:(0,o.jsx)(S.X,{size:12})})]}),_?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("input",{ref:A,type:"file",accept:Je,className:"smv-upload-input",onChange:h=>{Wt(h.target.files),h.currentTarget.value=""}}),U?(0,o.jsx)("div",{className:"smv-upload-toolbar",children:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"smv-upload-toolbar__name",children:si??g("uploadedModel")}),(0,o.jsxs)("button",{type:"button",className:"smv-upload-toolbar__button smv-upload-toolbar__button--ghost",onClick:mi,children:[(0,o.jsx)(S.Trash2,{size:14}),g("clear")]})]})}):null]}):null,U&&!j.live?(0,o.jsx)(Nn,{className:"ri-viewerPlaceholder--inset",background:D.backgroundColor,poster:ut??e,onReveal:j.awaitingReveal?j.reveal:void 0}):U?(0,o.jsxs)(ni.Canvas,{dpr:[1,2],frameloop:j.visible?"demand":"never",resize:{debounce:0,scroll:!1},raycaster:{firstHitOnly:!0},style:{background:D.backgroundColor},camera:{position:[0,0,5],fov:45,near:.1,far:1e3},children:[(0,o.jsx)(Rn,{captureRef:Ft}),(0,o.jsx)(In,{}),(0,o.jsxs)(d.Suspense,{fallback:null,children:[(0,o.jsx)("ambientLight",{intensity:D.ambientIntensity,color:D.ambientColor}),(0,o.jsx)("directionalLight",{position:[-4,5,7],intensity:D.directionalIntensity,color:D.directionalColor,castShadow:!0}),(0,o.jsx)("directionalLight",{position:[-5,5,5],intensity:.5}),(0,o.jsx)(d.Suspense,{fallback:null,children:(0,o.jsx)(It.Environment,{preset:D.envPreset,background:D.backgroundEnabled})}),(0,o.jsx)(Ur,{exposure:D.exposure}),(0,o.jsx)(Or,{enabled:D.autoRotate,controlsRef:G}),(0,o.jsx)(le,{onLoadError:xi,children:(0,o.jsx)(d.Suspense,{fallback:null,children:(0,o.jsx)(Ir,{url:U,format:_e?void 0:r,dracoDecoderPath:a,ktx2TranscoderPath:s,meshopt:c,hiddenKeys:pe,selectedKey:me,panelHoveredKey:oi,nodeRefsOut:J,onMeshesReady:vi,onModelLoaded:_i,onLoadProgress:yi,onMeshClick:Ee,highlightOnHover:f})})},U),(0,o.jsx)(Dr,{scene:Ut,controlsRef:G,refitOnResize:M,onInitialFitComplete:()=>kt(!0),resumeViewRef:Ht}),(0,o.jsx)(It.CameraControls,{ref:G,makeDefault:!0,smoothTime:v?0:.3})]})]}):(0,o.jsx)("div",{className:"smv-upload-empty-state",style:{background:D.backgroundColor},children:(0,o.jsxs)("div",{className:"smv-upload-empty-state__card",children:[(0,o.jsx)("div",{className:"smv-upload-empty-state__icon",children:(0,o.jsx)(S.Upload,{size:24})}),(0,o.jsx)("p",{className:"smv-upload-empty-state__body",children:g("dropModelHint",{formats:".glb, .gltf, .obj, .fbx, .usdz, .stl, .ply, .zip"})}),(0,o.jsxs)("button",{type:"button",className:"smv-upload-empty-state__button",onClick:()=>A.current?.click(),children:[(0,o.jsx)(S.Upload,{size:15}),g("chooseModel")]})]})}),U&&j.live?(0,o.jsx)(ne,{src:ut??e,hidden:!!(Ut&&Bt)}):null,(0,o.jsx)(yn,{visible:Ti,message:g("loadingModel"),progress:be?void 0:ci??void 0}),_&&di?(0,o.jsx)("div",{className:"smv-upload-drop-overlay",children:(0,o.jsxs)("div",{className:"smv-upload-drop-overlay__card",children:[(0,o.jsx)(S.Upload,{size:20}),(0,o.jsx)("span",{children:g("releaseToLoadYourModel")})]})}):null]}),u&&U&&(0,o.jsx)(kr,{meshKeys:ai,hiddenKeys:pe,selectedKey:me,isOpen:ui,onToggle:hi,onFocus:Ee,onHover:ve,onToggleVisibility:bi})]})}0&&(module.exports={DEFAULT_MODEL_VIEWER_LABELS,SimpleModelViewer});